HomeTarget.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  1. <template>
  2. <div class="ABtarage HomeTarget">
  3. <p class="updataTime">更新时间:{{ updataTime }}</p>
  4. <!-- labelStyle 垃圾,不能全匹配,需要特殊处理 -->
  5. <template>
  6. <div class="container linep">
  7. <van-collapse v-model="activeNames">
  8. <div v-for="(homePageItem, index) in homePageIndicatorList" :key="index">
  9. <van-collapse-item
  10. v-if="homePageItem.labelStyle == 1"
  11. :name="(index + 1).toString()"
  12. :title="homePageItem.name">
  13. <van-row>
  14. <!-- 动态渲染标题栏 -->
  15. <div
  16. v-for="(periodItem, periodIndex) in homePageItem.children"
  17. :key="'title-' + periodIndex">
  18. <van-col span="12" v-if="periodItem.name">
  19. <span :class="periodIndex % 2 === 0 ? 'leftTitle' : 'rightTitle'">{{
  20. periodItem.name
  21. }}</span>
  22. </van-col>
  23. </div>
  24. <!-- 动态渲染指标项 -->
  25. <div v-if="homePageItem.children.length >= 2">
  26. <!-- 遍历第一个周期的所有指标 -->
  27. <div
  28. v-for="(metric, metricIndex) in homePageItem.children[0].children"
  29. :key="'metric-' + metricIndex">
  30. <!-- 左侧指标 -->
  31. <van-col span="12">
  32. <p>
  33. {{ metric.name }}:
  34. <span class="colorblack">
  35. {{ metric.indicatorDisplayValue }}
  36. </span>
  37. </p>
  38. </van-col>
  39. <!-- 对应右侧指标 -->
  40. <van-col span="12">
  41. <p>
  42. {{ homePageItem.children[1]?.children[metricIndex]?.name || '-' }}:
  43. <span class="colorblack">
  44. {{
  45. homePageItem.children[1]?.children[metricIndex]?.indicatorDisplayValue
  46. }}
  47. </span>
  48. </p>
  49. </van-col>
  50. </div>
  51. </div>
  52. </van-row>
  53. </van-collapse-item>
  54. <van-collapse-item
  55. v-if="homePageItem.labelStyle == 2"
  56. :name="(index + 1).toString()"
  57. :title="homePageItem.name">
  58. <!-- 外层循环:遍历主要类别 -->
  59. <van-row
  60. v-for="(category, index) in homePageItem.children"
  61. :key="index"
  62. :style="{ marginTop: index > 0 ? '10px' : '0' }">
  63. <van-col span="24" v-if="category.name">
  64. <span :class="index % 2 === 0 ? 'leftTitle' : 'rightTitle'">{{
  65. category.name
  66. }}</span>
  67. </van-col>
  68. <!-- 内层循环:遍历各个统计项 -->
  69. <div v-for="(item, idx) in category.children" :key="idx">
  70. <van-col :span="idx == 0 ? 24 : 12">
  71. <p>
  72. {{ item.name }}:<span
  73. :style="labelStyle(item.clickable)"
  74. @click="onClick(item.clickable)"
  75. class="colorbalck"
  76. >{{ item.indicatorDisplayValue }}</span
  77. >
  78. </p>
  79. </van-col>
  80. </div>
  81. </van-row>
  82. </van-collapse-item>
  83. <van-collapse-item
  84. v-if="homePageItem.labelStyle == 3"
  85. :name="(index + 1).toString()"
  86. :title="homePageItem.name">
  87. <!-- 外层循环:遍历主要类别 -->
  88. <van-row
  89. v-for="(category, index) in homePageItem.children"
  90. :key="index"
  91. :style="{ marginTop: index == 0 ? '-10px' : '0' }">
  92. <!-- 内层循环:遍历各个统计项 -->
  93. <div v-for="(item, idx) in category.children" :key="idx">
  94. <van-col :span="idx == 0 ? 24 : 12">
  95. <p>
  96. {{ item.name }}:<span
  97. :style="labelStyle(item.clickable)"
  98. @click="onClick(item.clickable)"
  99. class="colorbalck"
  100. >{{ item.indicatorDisplayValue }}</span
  101. >
  102. </p>
  103. </van-col>
  104. </div>
  105. </van-row>
  106. </van-collapse-item>
  107. <van-collapse-item
  108. v-if="homePageItem.labelStyle == 4"
  109. :name="(index + 1).toString()"
  110. :title="homePageItem.name">
  111. <!-- 外层循环:遍历主要类别 -->
  112. <template v-for="(category, index) in homePageItem.children">
  113. <van-row
  114. :style="{
  115. width: category.name ? '49%' : '100%',
  116. float: category.name ? 'left' : 'none',
  117. }">
  118. <van-col
  119. span="20"
  120. :class="index % 2 === 0 ? 'leftTitle' : 'rightTitle'"
  121. v-if="category.name">
  122. <span>{{ category.name }}</span>
  123. </van-col>
  124. <!-- 内层循环:遍历各个统计项 -->
  125. <div v-for="(item, idx) in category.children" :key="idx">
  126. <van-col :span="24">
  127. <p>
  128. {{ item.name }}:<span
  129. :style="labelStyle(item.clickable)"
  130. @click="onClick(item.clickable)"
  131. class="colorbalck"
  132. >{{ item.indicatorDisplayValue }}</span
  133. >
  134. </p>
  135. </van-col>
  136. </div>
  137. </van-row>
  138. </template>
  139. </van-collapse-item>
  140. <van-collapse-item
  141. v-if="homePageItem.labelStyle == 5"
  142. :name="(index + 1).toString()"
  143. :title="homePageItem.name">
  144. <!-- 外层循环:遍历主要类别 -->
  145. <van-row
  146. v-for="(category, index) in homePageItem.children"
  147. :key="index"
  148. :style="{ marginTop: index == 0 ? '-10px' : '0' }">
  149. <!-- 内层循环:遍历各个统计项 -->
  150. <div v-for="(item, idx) in category.children" :key="idx">
  151. <van-col :span="24">
  152. <p>
  153. {{ item.name }}:<span
  154. :style="labelStyle(item.clickable)"
  155. @click="onClick(item.clickable)"
  156. class="colorbalck"
  157. >{{ item.indicatorDisplayValue }}</span
  158. >
  159. </p>
  160. </van-col>
  161. </div>
  162. </van-row>
  163. </van-collapse-item>
  164. </div>
  165. </van-collapse>
  166. </div>
  167. </template>
  168. </div>
  169. </template>
  170. <script>
  171. import store from '@/store';
  172. import { userTodayPlanNum, getReportInfo } from '@/api/index';
  173. import { mapState } from 'vuex';
  174. export default {
  175. name: 'home',
  176. computed: {
  177. ...mapState({
  178. reportInfo: (state) => state.user.reportInfo,
  179. }),
  180. },
  181. props: {
  182. tabVal: {
  183. type: [String, Number],
  184. default: '-1',
  185. },
  186. },
  187. data() {
  188. return {
  189. shows: true,
  190. show: true,
  191. num: 0,
  192. todayGoal: {},
  193. progressWidth: 0,
  194. updataTime: '',
  195. activeNames: [
  196. '1',
  197. '2',
  198. '3',
  199. '4',
  200. '5',
  201. '6',
  202. '7',
  203. '8',
  204. '10',
  205. '11',
  206. '12',
  207. '16',
  208. '17',
  209. '20',
  210. '21',
  211. '22',
  212. '23',
  213. '24',
  214. '25',
  215. '26',
  216. '27',
  217. '28',
  218. '29',
  219. '30',
  220. '31',
  221. '32',
  222. '33',
  223. '34',
  224. '35',
  225. '36',
  226. '37',
  227. '38',
  228. '39',
  229. '40',
  230. '41',
  231. '42',
  232. '43',
  233. ],
  234. activeNameType: [],
  235. powerGradeShow: false,
  236. showButton: false,
  237. isCommit: null,
  238. powerGrade: '2',
  239. deptLevel: '',
  240. // positionId:等级(1-销售员 2-销售部主管 3-大区主管 4-区域公司总经理 5-DIY公司)
  241. reportTargetAll: {},
  242. homePageIndicatorList: [],
  243. approvalPendingNum: 0,
  244. isDiy: false,
  245. approvalButton: false,
  246. times: 5,
  247. timer: null,
  248. type: '-1',
  249. monthNoVisit: {},
  250. flag: true,
  251. reportInfoData: {},
  252. applyNumber: '',
  253. proccessPendingNum: 0,
  254. JZQuota: false,
  255. GZdata: false,
  256. };
  257. },
  258. watch: {
  259. // tabVal: {
  260. // handler(val) {
  261. // if (val == 2) {
  262. // // keep-alive 模式watch执行了两次
  263. // this.initData();
  264. // }
  265. // },
  266. // immediate: true,
  267. // },
  268. reportInfo: {
  269. handler(val) {
  270. if (val) {
  271. this.initData();
  272. }
  273. },
  274. immediate: true,
  275. },
  276. },
  277. methods: {
  278. labelStyle(val) {
  279. return {
  280. 'text-decoration': val == 1 ? 'underline' : 'none',
  281. color: val == 1 ? '#0057ba' : '#666666',
  282. };
  283. },
  284. // 跳转详情
  285. onClick(val) {
  286. if (val == 1) {
  287. store.dispatch('setActivaTypeStore', 'FuWuShang');
  288. this.$router.push({ path: '/noVisit' });
  289. }
  290. },
  291. initData() {
  292. console.log(this.tabVal);
  293. this.getReportInfo();
  294. this.userTodayPlanNum();
  295. },
  296. getReportInfo() {
  297. if (this.reportInfo && this.reportInfo.homePageIndicatorList != null) {
  298. this.homePageIndicatorList = this.reportInfo.homePageIndicatorList;
  299. this.updataTime = this.reportInfo.homePageIndicatorUpdateTime;
  300. }
  301. return;
  302. let loading1 = this.$toast.loading({
  303. duration: 0,
  304. message: '加载中...',
  305. forbidClick: true,
  306. });
  307. getReportInfo({ isContent: false }).then((res) => {
  308. if (res.code == 200) {
  309. loading1.clear();
  310. localStorage.setItem('powerGrade', res.data.positionId);
  311. localStorage.setItem('userDeptLevel', res.data.userDeptLevel);
  312. localStorage.setItem('isDiy', res.data.diy);
  313. localStorage.setItem('uType', res.data.userType);
  314. localStorage.setItem('jzType', res.data.jzType);
  315. localStorage.setItem('customerVisits', res.data.customerManagerVisits);
  316. localStorage.setItem('postType', res.data.postType);
  317. if (res.data.homePageIndicatorList != null) {
  318. this.homePageIndicatorList = res.data.homePageIndicatorList;
  319. this.updataTime = res.data.homePageIndicatorUpdateTime;
  320. }
  321. this.type = res.data.userType;
  322. } else {
  323. this.$toast(res.msg);
  324. }
  325. });
  326. },
  327. userTodayPlanNum() {
  328. localStorage.setItem('outvstoreName', '');
  329. localStorage.setItem('outvchainName', '');
  330. localStorage.removeItem('outvstoreLabelTypes');
  331. localStorage.removeItem('outvjpdStoreLevelTypes');
  332. localStorage.removeItem('outvstoreCategoryList');
  333. localStorage.setItem('outvchainCode', '');
  334. localStorage.setItem('outvstoreName', '');
  335. localStorage.setItem('deviveStoreName', '');
  336. localStorage.setItem('outvsortType', '');
  337. localStorage.setItem('outsortParam', '');
  338. localStorage.setItem('lat', '');
  339. localStorage.setItem('lon', '');
  340. userTodayPlanNum().then((res) => {
  341. if (res.code == 200) {
  342. this.todayGoal = res.data;
  343. this.progressWidth = (this.todayGoal.finishNum / this.todayGoal.planNum) * 100 + '%';
  344. localStorage.setItem('nickName', res.data.user.nickName);
  345. localStorage.setItem('postName', res.data.user.postName);
  346. localStorage.setItem('zipPhoto', res.data.zipPhoto);
  347. localStorage.setItem('storeType', res.data.user.type);
  348. localStorage.setItem('deptLevel', res.data.user.depts[0].deptLevel);
  349. localStorage.setItem('userId', res.data.user.userId);
  350. localStorage.setItem('deptIds', JSON.stringify(res.data.user.deptIds));
  351. this.monthNoVisit = res.data.monthNoVisit;
  352. } else {
  353. this.$toast(res.msg);
  354. }
  355. });
  356. },
  357. },
  358. };
  359. </script>
  360. <style scoped>
  361. .homeTitle {
  362. padding: 6px 16px;
  363. }
  364. .homeTitle .van-icon__image {
  365. width: 1.4em;
  366. height: auto;
  367. }
  368. .container {
  369. margin: 10px;
  370. }
  371. .container .van-collapse-item {
  372. margin-bottom: 10px;
  373. border-radius: 6px;
  374. overflow: hidden;
  375. }
  376. .progressContentlist {
  377. font-size: 14px;
  378. border-bottom: 1px dashed #f1f1f1;
  379. padding: 10px 0;
  380. }
  381. .linep p {
  382. margin: 10px 0 0 0;
  383. font-size: 14px;
  384. color: #666;
  385. }
  386. .leftTitle {
  387. background-color: #74a4d9;
  388. color: #fff;
  389. display: inline-block;
  390. padding: 0 4px;
  391. border-radius: 2px;
  392. }
  393. .rightTitle {
  394. background-color: #e7b4bb;
  395. color: #fff;
  396. display: inline-block;
  397. padding: 0 4px;
  398. border-radius: 2px;
  399. white-space: nowrap;
  400. }
  401. </style>
  402. <style lang="scss">
  403. .myTab .van-tabs__nav--card {
  404. margin: 0 !important;
  405. border-left: 0;
  406. border-right: 0;
  407. }
  408. .myTab .van-tabs__wrap,
  409. .van-tabs__nav--card {
  410. height: 39px;
  411. }
  412. .myTab .van-tab {
  413. line-height: 40px;
  414. }
  415. .linep .van-collapse-item__content {
  416. color: #666;
  417. }
  418. .linep .van-collapse-item__content {
  419. color: #666;
  420. }
  421. .linep .van-cell__title {
  422. color: #1e5398;
  423. font-weight: 500;
  424. font-size: 16px;
  425. }
  426. .homeCellIcon {
  427. line-height: 34px;
  428. }
  429. .homeTitle .van-cell__title {
  430. color: #444;
  431. font-size: 16px;
  432. font-weight: bold;
  433. padding-left: 4px;
  434. line-height: 36px;
  435. height: 36px;
  436. }
  437. .updataTime {
  438. color: #999;
  439. font-size: 12px;
  440. text-align: center;
  441. }
  442. .homeTitle .van-tag--danger {
  443. /* border-radius: 20px; */
  444. }
  445. .van-dialog__confirm,
  446. .van-dialog__confirm:active {
  447. color: #0057ba;
  448. }
  449. .tipTitleBox p {
  450. margin: 0;
  451. line-height: 28px;
  452. color: #555;
  453. }
  454. .tipTitleBox .p {
  455. color: #555;
  456. font-size: 16px;
  457. border-bottom: 1px solid #f5f5f5;
  458. margin: 0;
  459. margin-bottom: 10px;
  460. text-align: center;
  461. padding: 14px 0px;
  462. }
  463. .HomeTarget .van-collapse-item__content {
  464. padding: 0px 15px 15px 15px;
  465. overflow: hidden;
  466. }
  467. .storeTypeHome .storeTypeHomeList .van-cell__title {
  468. color: #4a4a4a;
  469. font-size: 14px;
  470. }
  471. .storeTypeHome .monthNoVisit {
  472. padding: 10px;
  473. margin: 10px;
  474. border-radius: 5px;
  475. background-color: #ebf4ff;
  476. }
  477. .storeTypeHome .leftContent {
  478. padding-right: 68px;
  479. position: relative;
  480. }
  481. .storeTypeHome .monthNoVisitStatstext {
  482. font-size: 12px;
  483. background-color: #0057ba;
  484. position: absolute;
  485. right: 0;
  486. top: 6px;
  487. padding: 2px 6px 2px 12px;
  488. border-bottom-left-radius: 60px;
  489. border-top-left-radius: 60px;
  490. color: #fff;
  491. }
  492. .ABtarage {
  493. .table-headermd {
  494. font-size: 12px;
  495. text-align: center;
  496. position: initial;
  497. width: 98% !important;
  498. margin: 0 auto;
  499. border-right: 0;
  500. }
  501. .table-headermdhome {
  502. font-size: 14px;
  503. }
  504. .table-headermdhome th.el-table__cell > .cell {
  505. white-space: pre;
  506. }
  507. .table-headermd .el-table__header,
  508. .table-headermd .el-table__body {
  509. width: 100% !important;
  510. }
  511. .table-headermdhome.van-cell {
  512. padding: 0 6px;
  513. height: 100%;
  514. }
  515. .table-headermd th.el-table__cell > .cell {
  516. padding: 0 4px;
  517. text-align: center;
  518. }
  519. .table-headermdhometh.el-table__cell:first-child > .cell {
  520. text-align: left;
  521. }
  522. .table-headermd th.el-table__cell {
  523. background-color: #1989fa;
  524. color: #fff;
  525. }
  526. .table-headermdhome th.el-table__cell {
  527. background-color: #fff;
  528. color: #444;
  529. }
  530. .table-headermd .el-table__cell {
  531. padding: 4px 0;
  532. }
  533. .table-headermdhome.el-table .cell {
  534. padding: 0 4px;
  535. text-align: center;
  536. }
  537. .table-headermdhome .tipTitle {
  538. overflow: hidden;
  539. text-overflow: ellipsis;
  540. display: -webkit-box;
  541. -webkit-box-orient: vertical;
  542. -webkit-line-clamp: 2;
  543. text-align: center;
  544. }
  545. .table-headermd::before {
  546. height: 0;
  547. }
  548. .table-headermd .cell,
  549. .el-table--border .el-table__cell:first-child .cell {
  550. padding: 0 4px;
  551. }
  552. }
  553. .colBack {
  554. width: 100%;
  555. height: 100%;
  556. display: block;
  557. /* overflow: unset; */
  558. position: relative;
  559. z-index: 2;
  560. float: left;
  561. z-index: 2;
  562. .back {
  563. position: absolute;
  564. background: rgb(226, 240, 217);
  565. height: 100%;
  566. display: block;
  567. overflow: hidden;
  568. /* z-index: 1; */
  569. border-radius: 12px;
  570. bottom: -4px;
  571. }
  572. .backLeft {
  573. width: 45%;
  574. left: -12px;
  575. }
  576. .backRight {
  577. width: 50%;
  578. left: calc(50% - 12px);
  579. }
  580. .van-col {
  581. position: relative;
  582. z-index: 3;
  583. }
  584. }
  585. </style>