HomeTarget.vue 13 KB

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