HomeTarget.vue 14 KB

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