hintDetail.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686
  1. <template>
  2. <div class="hintDetail">
  3. <div class="header">
  4. <van-nav-bar class="navBar" title="门店拜访" left-arrow @click-left="onClickLeft" />
  5. </div>
  6. <div class="tabBox">
  7. <van-tabs class="myTab" v-model="activeTabName" color="#0057ba" @change="tabChange">
  8. <van-tab
  9. v-for="(item, index) in tabsItem"
  10. :title="item.title"
  11. :name="item.name"
  12. :key="index"></van-tab>
  13. </van-tabs>
  14. <van-tabs
  15. class="myTab"
  16. v-model="activaPantoneName"
  17. color="#0057ba"
  18. @change="tabChangePantone"
  19. v-if="activeTabName == 'pantone'">
  20. <van-tab
  21. v-for="(val, key, index) in tabsItemPantone"
  22. :key="index"
  23. :title="key"
  24. :name="key"></van-tab>
  25. </van-tabs>
  26. <van-tabs
  27. class="myTab"
  28. v-model="activaPantoneName"
  29. color="#0057ba"
  30. @change="tabChangePantone"
  31. v-if="activeTabName == 'colorWarning'">
  32. <van-tab
  33. v-for="(val, key, index) in tabsItemPantone"
  34. :key="index"
  35. :title="key=='keKong'?'可控店':'金牌店'"
  36. :name="key"></van-tab>
  37. </van-tabs>
  38. </div>
  39. <div class="content">
  40. <el-table
  41. v-if="fromType"
  42. :data="tableList"
  43. :load="load"
  44. :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
  45. border
  46. class="elTreeTable"
  47. lazy
  48. :row-key="rowKey"
  49. :key="toggleIndex">
  50. <el-table-column
  51. class="firstName"
  52. :label="firstLabel"
  53. :prop="firstProp"
  54. align="center"
  55. width="120">
  56. <template slot-scope="scope">
  57. <span>{{ scope.row[firstProp] }}</span>
  58. <!-- <span v-if="scope.row.reportType != 1">{{ scope.row.deptName }}</span> -->
  59. </template>
  60. </el-table-column>
  61. <el-table-column
  62. :label="item.label"
  63. width="46"
  64. align="center"
  65. v-for="(item, index) in tableColumn"
  66. :key="index"
  67. v-if="tableColumn.length">
  68. <el-table-column
  69. :label="val.label"
  70. :prop="val.prop"
  71. width="46"
  72. align="center"
  73. v-if="item.childredColumn"
  74. v-for="(val, ind) in item.childredColumn"
  75. :key="ind">
  76. <template slot-scope="scope">
  77. <span>{{ Micrometer(scope.row[val.prop]) }}</span>
  78. </template>
  79. </el-table-column>
  80. </el-table-column>
  81. </el-table>
  82. <div class="mask" v-if="maskShow"><van-loading type="spinner" color="#1989fa" /></div>
  83. </div>
  84. </div>
  85. </template>
  86. <script>
  87. import {
  88. selectNoVisitsInfo,
  89. selectPendingCasesInfo,
  90. getReportMaterialType,
  91. getReportMaterial,
  92. selectColorMixerStoreInfo,
  93. getColorWarning
  94. } from '@/api/index';
  95. import { mapState } from 'vuex';
  96. export default {
  97. name: 'hintDetail',
  98. computed: {
  99. ...mapState({
  100. userInfo: (state) => state.user.userInfo,
  101. }),
  102. },
  103. data() {
  104. return {
  105. empLevel: '',
  106. deptId: null,
  107. fromType: null,
  108. activeTabName: 'noVisit',
  109. activaPantoneName: '',
  110. tabsItem: [
  111. {
  112. title: '未拜访',
  113. name: 'noVisit',
  114. },
  115. {
  116. title: '建店',
  117. name: 'createStore',
  118. },
  119. // {
  120. // title: '色卡',
  121. // name: 'pantone',
  122. // },
  123. ],
  124. activePantoneTabName: '', //色卡/调色预警tabName
  125. tabsItemPantone: {}, //色卡/调色预警tabItem
  126. toggleIndex: 0,
  127. firstLabel: '',
  128. firstProp: '',
  129. tableColumn: [],
  130. tableList: [],
  131. // 未拜访
  132. noVisit: [
  133. {
  134. label: '可控店',
  135. childredColumn: [
  136. {
  137. label: '(当月)',
  138. prop: 'keKongNotVisited',
  139. },
  140. ],
  141. },
  142. {
  143. label: '金牌店',
  144. childredColumn: [
  145. {
  146. label: '(当月)',
  147. prop: 'jinPaiNotVisited',
  148. },
  149. ],
  150. },
  151. {
  152. label: '同城分销-涂料店',
  153. childredColumn: [
  154. {
  155. label: '(近2月)',
  156. prop: 'TuLiaoNotVisited',
  157. },
  158. ],
  159. },
  160. {
  161. label: '同城分销-其他店',
  162. childredColumn: [
  163. {
  164. label: '(近3月)',
  165. prop: 'QiTaNotVisited',
  166. },
  167. ],
  168. },
  169. ],
  170. // 建店
  171. createStore: [
  172. {
  173. label: '可控店',
  174. childredColumn: [
  175. {
  176. label: '(45天未结案)',
  177. prop: 'keKongAbnormalNum',
  178. },
  179. ],
  180. },
  181. {
  182. label: '金牌店',
  183. childredColumn: [
  184. {
  185. label: '(7天未完工)',
  186. prop: 'jinPaiUnfinishedNum',
  187. },
  188. {
  189. label: '(30天未结案)',
  190. prop: 'jinPaiAbnormalNum',
  191. },
  192. ],
  193. },
  194. {
  195. label: '同城分销-涂料店',
  196. childredColumn: [
  197. {
  198. label: '(7天未结案)',
  199. prop: 'TuLiaoAbnormalNum',
  200. },
  201. ],
  202. },
  203. {
  204. label: '同城分销-其他店',
  205. childredColumn: [
  206. {
  207. label: '(7天未结案)',
  208. prop: 'QiTaAbnormalNum',
  209. },
  210. ],
  211. },
  212. ],
  213. // 色卡
  214. pantone: [
  215. {
  216. label: '直发销售部',
  217. childredColumn: [
  218. {
  219. label: '(本)',
  220. prop: 'zfxsbNum',
  221. },
  222. ],
  223. },
  224. {
  225. label: '已领用',
  226. childredColumn: [
  227. {
  228. label: '(本)',
  229. prop: 'ywyylyNum',
  230. },
  231. ],
  232. },
  233. {
  234. label: '门店发放',
  235. childredColumn: [
  236. {
  237. label: '(本)',
  238. prop: 'ywyyffNum',
  239. },
  240. ],
  241. },
  242. {
  243. label: '门店未签收',
  244. childredColumn: [
  245. {
  246. label: '(本)',
  247. prop: 'mdwqsNum',
  248. },
  249. ],
  250. },
  251. {
  252. label: '未签收门店',
  253. childredColumn: [
  254. {
  255. label: '(家)',
  256. prop: 'wqsmdNum',
  257. },
  258. ],
  259. },
  260. ],
  261. // 调色预警
  262. colorWarning: [
  263. {
  264. label: '滚动7天未调色机',
  265. childredColumn: [
  266. {
  267. label: '(家)',
  268. prop: 'colorSeven',
  269. },
  270. ],
  271. },
  272. {
  273. label: '当月未调色',
  274. childredColumn: [
  275. {
  276. label: '(家)',
  277. prop: 'colorMonth',
  278. },
  279. ],
  280. },
  281. {
  282. label: '从未调色',
  283. childredColumn: [
  284. {
  285. label: '(家)',
  286. prop: 'colorStop',
  287. },
  288. ],
  289. },
  290. {
  291. label: '布机但近两年DIS为0',
  292. childredColumn: [
  293. {
  294. label: '(家)',
  295. prop: 'colorDis',
  296. },
  297. ],
  298. },
  299. {
  300. label: '合计',
  301. childredColumn: [
  302. {
  303. label: '(家)',
  304. prop: 'colorMixerSum',
  305. },
  306. ],
  307. },
  308. ],
  309. materialCode: null, //色卡物料来源
  310. maskShow: true,
  311. controller: null, //取消请求
  312. };
  313. },
  314. watch: {
  315. // 监听tab切换的状态
  316. fromType: {
  317. handler(newVal) {
  318. this.tableColumn = this[newVal]; //表格头
  319. this.activeTabName = newVal; // 当前激活tab
  320. },
  321. immediate: true,
  322. },
  323. // 初始化监听fromType,不同类型显示不同的tabItem
  324. '$route.query.fromType': {
  325. handler(newVal) {
  326. if (newVal) this.setTabsItem();
  327. },
  328. immediate: true,
  329. },
  330. },
  331. activated() {
  332. this.empLevel = this.userInfo.empLevel;
  333. this.firstLabel = this.empLevel == '1' ? '组织名称/大区主管' : '组织名称/销售部主管';
  334. this.fromType = this.$route.query.fromType; // fromType: 'noVisit':未拜访; 'createStore':建店; 'pantone':色卡
  335. this.deptId = this.userInfo.deptId; // 当前用户部门id
  336. this.activaPantoneName = this.$route.query.pantoneName; //当前色卡
  337. this.materialCode = this.$route.query.materialCode; // 色卡code
  338. this.controller = new AbortController(); //取消请求
  339. this.initData();
  340. },
  341. methods: {
  342. rowKey(row) {
  343. return row['onlyId'] || row['warehouseCode'];
  344. // if (this.fromType == 'noVisit' || this.fromType == 'createStore') {
  345. // return row['onlyId'];
  346. // } else if (this.fromType == 'pantone') {
  347. // return row['warehouseCode'];
  348. // }
  349. },
  350. setTabsItem() {
  351. this.tabsItem = [
  352. {
  353. title: '未拜访',
  354. name: 'noVisit',
  355. },
  356. {
  357. title: '建店',
  358. name: 'createStore',
  359. },
  360. {
  361. title: '调色预警',
  362. name: 'colorWarning',
  363. },
  364. ];
  365. // 业务员不显示色卡
  366. if (this.userInfo.empLevel != '3') {
  367. this.tabsItem.push({
  368. title: '色卡',
  369. name: 'pantone',
  370. });
  371. }
  372. },
  373. /**
  374. * 初始化数据和搜索操作接口的入口
  375. * @param {*function} resolve //子级数据数据回调
  376. * @param {*object} tree //展开时当前节点数据
  377. * */
  378. initData(resolve, tree) {
  379. // 请求子级数据时不需要loading
  380. if (!resolve && !tree) {
  381. this.toggleIndex = this.toggleIndex++;
  382. }
  383. this.maskShow = true;
  384. if (this.fromType == 'noVisit') {
  385. // 未拜访
  386. this.deptId = tree ? tree.onlyId : null;
  387. this.firstProp = 'onlyName';
  388. this.selectNoVisitsInfoFun(resolve);
  389. } else if (this.fromType == 'createStore') {
  390. // 建店
  391. this.deptId = tree ? tree.onlyId : null;
  392. this.firstProp = 'onlyName';
  393. this.selectPendingCasesInfoFun(resolve);
  394. } else if (this.fromType == 'pantone') {
  395. // 色卡
  396. this.firstProp = 'warehouseName';
  397. let deptId = tree ? tree.deptId : null;
  398. this.getPantoneData(resolve, deptId);
  399. }else if (this.fromType == 'colorWarning') {
  400. // 调色预警
  401. let deptId = tree ? tree.onlyId : null;
  402. this.firstProp = 'onlyName';
  403. this.getColorWarningData(resolve, deptId);
  404. }
  405. },
  406. tabChange(val) {
  407. this.tableList = []; // 清楚tab数
  408. this.tabsItemPantone = {}; // 清楚色卡tab数据
  409. this.fromType = val;
  410. if (this.controller) {
  411. this.controller.abort();
  412. }
  413. this.controller = new AbortController(); //取消请求
  414. this.initData();
  415. },
  416. tabChangePantone(val) {
  417. this.tableList = [];
  418. this.materialCode = this.tabsItemPantone[val].materialCode;
  419. this.initData();
  420. },
  421. onClickLeft() {
  422. this.$router.go(-1);
  423. },
  424. linKReportHistory(row, type) {},
  425. // 加载子节点数据的函数
  426. load(tree, treeNode, resolve) {
  427. this.initData(resolve, tree);
  428. },
  429. // 未拜访
  430. selectNoVisitsInfoFun(resolve) {
  431. selectNoVisitsInfo({ deptId: this.deptId }, this.controller.signal).then((res) => {
  432. this.maskShow = false;
  433. if (res.code == 200) {
  434. res.data.forEach((val) => {
  435. if (val.empLevel < 3) val.hasChildren = true;
  436. });
  437. // 是否是子级
  438. if (resolve) {
  439. resolve && resolve(res.data);
  440. } else {
  441. this.tableList = res.data;
  442. }
  443. } else {
  444. this.Toast({
  445. message: res.msg,
  446. duration: 5000,
  447. });
  448. }
  449. });
  450. },
  451. // 建店
  452. selectPendingCasesInfoFun(resolve) {
  453. selectPendingCasesInfo({ deptId: this.deptId }, this.controller.signal).then((res) => {
  454. this.maskShow = false;
  455. if (res.code == 200) {
  456. res.data.forEach((val) => {
  457. // 是否还有子级
  458. if (val.empLevel < 3) val.hasChildren = true;
  459. });
  460. // 是否是子级
  461. if (resolve) {
  462. resolve && resolve(res.data);
  463. } else {
  464. this.tableList = res.data;
  465. }
  466. } else {
  467. this.Toast({
  468. message: res.msg,
  469. duration: 5000,
  470. });
  471. }
  472. });
  473. },
  474. // 色卡tab
  475. getPantoneData(resolve, deptId) {
  476. if (JSON.stringify(this.tabsItemPantone) != '{}') {
  477. this.getReportMaterialTypeFun(resolve, deptId);
  478. } else {
  479. getReportMaterial().then((res) => {
  480. this.tabsItemPantone = res.data;
  481. delete this.tabsItemPantone.tip;
  482. // 初次获取tab数据延迟等待this.activaPantoneName当前激活tab赋值成功,获取其物料code
  483. this.$nextTick(() => {
  484. this.materialCode = this.materialCode
  485. ? this.materialCode
  486. : this.tabsItemPantone[this.activaPantoneName].materialCode;
  487. this.getReportMaterialTypeFun(null, null);
  488. });
  489. });
  490. }
  491. },
  492. // 色卡详情
  493. getReportMaterialTypeFun(resolve, deptId) {
  494. // deptId 第一次传 null 获取当前等级下的数据(不需要当前层级)
  495. getReportMaterialType(
  496. { materialCode: this.materialCode, deptId: deptId },
  497. this.controller.signal
  498. ).then((res) => {
  499. this.maskShow = false;
  500. if (res.code == 200) {
  501. res.data.colorCardList.forEach((val) => {
  502. if (val.isChildren && val.isChildren == 'true') val.hasChildren = true;
  503. });
  504. // 是否是子级
  505. if (resolve) {
  506. resolve && resolve(res.data.colorCardList);
  507. } else {
  508. this.tableList = res.data.colorCardList;
  509. }
  510. } else {
  511. this.Toast({
  512. message: res.msg,
  513. duration: 5000,
  514. });
  515. }
  516. });
  517. },
  518. // 调色机tab
  519. getColorWarningData(resolve, deptId) {
  520. if (JSON.stringify(this.tabsItemPantone) != '{}') {
  521. this.getColorWarningFun(resolve, deptId);
  522. } else {
  523. getColorWarning().then((res) => {
  524. this.tabsItemPantone = res.data;
  525. delete this.tabsItemPantone.reminderContent;
  526. this.$nextTick(() => {
  527. this.getColorWarningFun(null, null);
  528. });
  529. });
  530. }
  531. },
  532. // 调色机详情
  533. getColorWarningFun(resolve, deptId) {
  534. // deptId 第一次传 null 获取当前等级下的数据(不需要当前层级)
  535. selectColorMixerStoreInfo({ deptId: deptId,storeType:this.activaPantoneName }, this.controller.signal).then((res) => {
  536. this.maskShow = false;
  537. if (res.code == 200) {
  538. res.data.forEach((val) => {
  539. // 是否还有子级
  540. if (val.empLevel < 3) val.hasChildren = true;
  541. });
  542. // 是否是子级
  543. if (resolve) {
  544. resolve && resolve(res.data);
  545. } else {
  546. this.tableList = res.data;
  547. }
  548. } else {
  549. this.Toast({
  550. message: res.msg,
  551. duration: 5000,
  552. });
  553. }
  554. });
  555. },
  556. },
  557. };
  558. </script>
  559. <style lang="scss" scoped>
  560. .hintDetail {
  561. .tabBox {
  562. position: sticky;
  563. top: 0px;
  564. z-index: 10;
  565. }
  566. }
  567. </style>
  568. <style lang="scss">
  569. #app {
  570. width: 100%;
  571. height: 100%;
  572. .bgcolor {
  573. width: 100%;
  574. height: 100%;
  575. .hintDetail {
  576. width: 100%;
  577. height: 100%;
  578. display: flex;
  579. flex-direction: column;
  580. .content {
  581. flex: 1;
  582. overflow: hidden;
  583. padding-bottom: 20px;
  584. background: #fff;
  585. position: relative;
  586. .el-table {
  587. overflow: hidden;
  588. height: 100%;
  589. display: flex;
  590. flex-direction: column;
  591. .el-table__body-wrapper {
  592. overflow: auto;
  593. flex: 1;
  594. }
  595. }
  596. .mask {
  597. position: absolute;
  598. width: 100%;
  599. height: 100%;
  600. top: 0;
  601. background: rgba(255, 255, 255, 0.8);
  602. display: flex;
  603. justify-content: center;
  604. align-items: center;
  605. }
  606. }
  607. }
  608. }
  609. }
  610. .hintDetail {
  611. .el-table__head .el-table__body {
  612. overflow: hidden;
  613. width: 99.9% !important;
  614. }
  615. .elTreeTable table {
  616. width: 99.9% !important;
  617. }
  618. .el-table__body {
  619. width: 99.9% !important;
  620. }
  621. .el-table__empty-block {
  622. width: 99.9% !important;
  623. }
  624. .elTreeTable .el-table__cell:first-child .cell {
  625. padding-left: 2px !important;
  626. }
  627. .elTreeTable .el-table__cell {
  628. padding: 0px;
  629. }
  630. .elTreeTable .el-table__body td.el-table__cell {
  631. padding: 2px;
  632. }
  633. .elTreeTable table col {
  634. text-align: center;
  635. }
  636. .elTreeTable th.el-table__cell > .cell {
  637. padding: 1px !important;
  638. }
  639. .elTreeTable {
  640. font-size: 12px !important;
  641. }
  642. .elTreeTable th.el-table__cell {
  643. padding: 1px !important;
  644. }
  645. .elTreeTable th.el-table__cell > .cell {
  646. text-align: center;
  647. }
  648. .elTreeTable .el-table__header tr:first-child th.el-table__cell:first-child .cell {
  649. /* width: 98px; */
  650. }
  651. .elTreeTable .linkSpan {
  652. text-decoration: underline;
  653. color: #0057ba;
  654. display: block;
  655. text-align: right;
  656. padding: 6px 10px;
  657. }
  658. .elTreeTable td.el-table__cell div {
  659. padding: 0px;
  660. }
  661. .elTreeTable .cell .spanNum {
  662. display: block;
  663. text-align: right;
  664. padding: 6px 10px;
  665. }
  666. .elTreeTable .el-table__expand-icon {
  667. float: right;
  668. .el-icon-arrow-right {
  669. vertical-align: -2px;
  670. }
  671. }
  672. }
  673. </style>