index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. <template>
  2. <div class="bgcolor complaintDetail">
  3. <div class="navBarTOP">
  4. <van-nav-bar class="navBar" left-arrow :title="title" @click-left="onClickLeft" />
  5. </div>
  6. <div class="lineGrey"></div>
  7. <div class="lineGrey"></div>
  8. <div class="lineGrey"></div>
  9. <div class="lineGrey"></div>
  10. <div class="lineGrey"></div>
  11. <!-- 客诉详情 -->
  12. <infoDetail v-if="infoData" :infoData="infoData" :customerClassify="customerClassifyOption">
  13. <van-button
  14. type="info"
  15. v-if="infoData.customerClueStatus == 0"
  16. style="
  17. float: right;
  18. background: #0057ba;
  19. border-color: #0057ba;
  20. color: #fff;
  21. margin-top: -36px;
  22. border-radius: 5px;
  23. "
  24. size="small"
  25. plain
  26. class="centerBtn"
  27. @click="onstopVisit"
  28. >转交其他组织</van-button
  29. >
  30. </infoDetail>
  31. <!-- 客诉记录 -->
  32. <complaintLog
  33. v-if="infoData && infoData.customerClueInfoComplaintList.length"
  34. :customerClueInfoComplaintList="infoData.customerClueInfoComplaintList"></complaintLog>
  35. <!-- 跟进记录 userCustomerClueList -->
  36. <!-- 历史跟进记录 -->
  37. <p style="margin: 0 16px 8px; color: #888" v-if="infoData && infoData.userCustomerClueList">
  38. 该客诉历史跟进记录
  39. </p>
  40. <van-cell-group inset class="cardclewContentCell" v-if="infoData">
  41. <div style="border-radius: 6px; overflow: hidden">
  42. <van-cell
  43. is-link
  44. v-for="(item, index) in infoData.userCustomerClueList"
  45. :key="index"
  46. @click="viewFn(item.userCustomerClueId)">
  47. <template #title>
  48. <span class="custom-title">{{ item.nickName }}</span>
  49. </template>
  50. <div class="cardContent">
  51. <p class="textLeft" style="padding-bottom: 0px; margin: 0">{{ item.createTime }}</p>
  52. </div>
  53. </van-cell>
  54. </div>
  55. </van-cell-group>
  56. <p v-if="infoData && infoData.isClose == 1" style="padding: 10px 0"></p>
  57. <!-- 跟进任务填写 -->
  58. <div class="assign" v-if="infoData && infoData.isClose != 1">
  59. <!-- <div class="assign"> -->
  60. <!-- 来电分类 -->
  61. <div class="complaintType">
  62. <div class="typeItem">
  63. <van-field
  64. readonly
  65. clickable
  66. name="picker"
  67. :value="customerClassifyValue"
  68. label="来电分类一 :"
  69. placeholder="点击选择来电分类一"
  70. @click="showPicker1 = true" />
  71. </div>
  72. <div class="typeItem">
  73. <van-field
  74. readonly
  75. clickable
  76. name="picker"
  77. :value="customerSubClassifyValue"
  78. label="来电分类二 :"
  79. placeholder="点击选择来电分类二"
  80. @click="showPicker2 = true" />
  81. </div>
  82. </div>
  83. <!-- <div class="followUp required">跟进结果</div> -->
  84. <div class="taskGather" v-if="taskGather">
  85. <radioGroup :clueOptionList="taskGather"></radioGroup>
  86. </div>
  87. <div class="tc" style="padding: 0 16px">
  88. <van-button class="submitBtn" block type="info" color="#0057ba" @click="onSubmit">
  89. 提交
  90. </van-button>
  91. </div>
  92. </div>
  93. <van-dialog v-model="show" title="转发客资" show-cancel-button :before-close="confirm">
  94. <p>
  95. <van-notice-bar wrapable :scrollable="false" text="一旦转交出去,则无法再查看,请确认!" />
  96. </p>
  97. <van-row class="serchInput">
  98. <van-col span="24">
  99. <van-cell
  100. class="monthNow selectcell"
  101. :title="companyName"
  102. is-link
  103. arrow-direction="down"
  104. @click="regionClick" />
  105. </van-col>
  106. <van-col span="24">
  107. <van-cell
  108. class="monthNow selectcell"
  109. :title="regionName"
  110. is-link
  111. @click="SalesRegionClick"
  112. arrow-direction="down" />
  113. </van-col>
  114. <van-col span="24">
  115. <van-cell
  116. class="monthNow selectcell"
  117. :title="deptName"
  118. is-link
  119. @click="SalesDepartmentClick"
  120. arrow-direction="down" />
  121. </van-col>
  122. </van-row>
  123. </van-dialog>
  124. <!-- 客诉跟进历史 -->
  125. <van-dialog
  126. v-model="showView"
  127. title="客诉历史"
  128. show-cancel-button
  129. cancel-button-text="关闭"
  130. :show-confirm-button="false"
  131. class="dialogz">
  132. <followUpHistory :historyId="historyId" :showView="showView"></followUpHistory>
  133. </van-dialog>
  134. <van-popup v-model="showPicker1" position="bottom">
  135. <van-picker
  136. show-toolbar
  137. value-key="remark"
  138. :columns="customerClassifyOption"
  139. @confirm="onConfirm1"
  140. @cancel="showPicker1 = false" />
  141. </van-popup>
  142. <van-popup v-model="showPicker2" position="bottom">
  143. <van-picker
  144. show-toolbar
  145. value-key="dictLabel"
  146. :columns="customerSubClassifyOption"
  147. @confirm="onConfirm2"
  148. @cancel="showPicker2 = false" />
  149. </van-popup>
  150. <van-popup v-model="RegionShow" capture position="bottom">
  151. <van-picker
  152. :columns="companyList"
  153. show-toolbar
  154. value-key="deptName"
  155. @cancel="RegionShow = false"
  156. @confirm="onregionConfirm" />
  157. </van-popup>
  158. <van-popup v-model="SalesRegionShow" capture position="bottom">
  159. <van-picker
  160. :columns="regionList"
  161. show-toolbar
  162. value-key="deptName"
  163. @cancel="SalesRegionShow = false"
  164. @confirm="onSalesRegionConfirm" />
  165. </van-popup>
  166. <van-popup v-model="SalesDepartmentShow" capture position="bottom">
  167. <van-picker
  168. :columns="deptList"
  169. show-toolbar
  170. value-key="deptName"
  171. @cancel="SalesDepartmentShow = false"
  172. @confirm="onSalesDepartmentConfirm" />
  173. </van-popup>
  174. </div>
  175. </template>
  176. <script>
  177. import {
  178. getComplaintCustomerClueInfoById,
  179. insertCustomerClueAnswerKs,
  180. customerClassify,
  181. customerSubClassify,
  182. } from '@/api/complaintDetail';
  183. import infoDetail from './infoDetail.vue';
  184. import complaintLog from './complaintLog.vue';
  185. import { mapState } from 'vuex';
  186. import radioGroup from './radioGroup';
  187. import followUpHistory from './followUpHistory';
  188. import { getDictOption } from '@/api/index';
  189. import { updateCustomerClueDept, getDeptInfo } from '@/api/clew';
  190. export default {
  191. name: 'complaintDetail',
  192. components: {
  193. infoDetail,
  194. complaintLog,
  195. radioGroup,
  196. followUpHistory,
  197. },
  198. computed: {
  199. ...mapState({
  200. userInfo: (state) => state.user.userInfo,
  201. }),
  202. },
  203. data() {
  204. return {
  205. id: '',
  206. infoData: null,
  207. title: '',
  208. postName: '',
  209. taskGather: null, //跟进任务集合
  210. requiredFlag: true, //问题必填检验
  211. requiredMessage: '', //必填提示信息
  212. showView: false,
  213. historyId: '',
  214. customerClassifyValue: '',
  215. customerClassify: '',
  216. customerSubClassifyValue: '',
  217. customerSubClassify: '',
  218. showPicker1: false,
  219. showPicker2: false,
  220. customerClassifyOption: [],
  221. customerSubClassifyOption: [],
  222. deptCode: '',
  223. regionList: [],
  224. deptList: [],
  225. companyName: '',
  226. companyCode: '',
  227. regionName: '',
  228. regionCode: '',
  229. deptName: '',
  230. show: false,
  231. RegionShow: false,
  232. SalesRegionShow: false,
  233. SalesDepartmentShow: false,
  234. companyList: [],
  235. deptForm: { type: '', parentId: '' },
  236. };
  237. },
  238. watch: {},
  239. activated() {
  240. this.id = this.$route.query.id;
  241. this.postName = localStorage.getItem('postName');
  242. this.getDeptInfo();
  243. this.getComplaintCustomerClueInfoByIdFun();
  244. },
  245. methods: {
  246. async getCustomerClassify() {
  247. let option = await customerClassify();
  248. this.customerClassifyOption = option.data || [];
  249. // 来电分类一
  250. let item = this.customerClassifyOption.find(
  251. (val) => val.dictValue == this.infoData.customerClassify
  252. );
  253. this.customerClassifyValue = item.remark || '';
  254. this.customerClassify = item.dictValue;
  255. this.getCustomerSubClassify(this.customerClassify);
  256. },
  257. async getCustomerSubClassify(parentId) {
  258. let option = await customerSubClassify({ parentId: parentId });
  259. this.customerSubClassifyOption = option.data || [];
  260. // 来电分类二
  261. let item = this.customerSubClassifyOption.find(
  262. (val) => val.dictValue == this.infoData.customerSubClassify
  263. );
  264. item = item || this.customerSubClassifyOption[0];
  265. this.customerSubClassifyValue = item.dictLabel || '';
  266. this.customerSubClassify = item.dictValue;
  267. },
  268. getComplaintCustomerClueInfoByIdFun() {
  269. this.toastLoading(0, '加载中...', true);
  270. this.id = this.$route.query.id;
  271. getComplaintCustomerClueInfoById({ customerClueInfoId: this.id }).then((response) => {
  272. this.toastLoading().clear();
  273. if (response.code == 200) {
  274. this.infoData = response.data;
  275. this.title = response.data.name;
  276. if (this.infoData.isClose != 1) {
  277. // response.data.customerClue.customerClueItemList[0].customerClueInfoId = this.id;
  278. this.taskGather = response.data.customerClue.customerClueItemList;
  279. }
  280. this.getCustomerClassify();
  281. // 当前客资归属人不是当前登录人
  282. let deptIds = JSON.parse(localStorage.getItem('deptIds'));
  283. if (deptIds.indexOf(this.infoData.deptId) == -1) {
  284. this.$dialog
  285. .confirm({
  286. title: '提示',
  287. message: '该客诉已经被转移给其他人',
  288. showCancelButton: false,
  289. })
  290. .then(() => {
  291. window.location.replace(window.location.origin + '/mobile/clew');
  292. });
  293. }
  294. } else {
  295. this.$toast(res.msg);
  296. }
  297. });
  298. },
  299. onSubmit() {
  300. // 没有选择跟进记录
  301. // if (!this.taskGather[0].searchValue) {
  302. // this.$toast('请选择跟进结果');
  303. // return;
  304. // }
  305. this.requiredFlag = true;
  306. let customerClueItemList = [];
  307. // 每一个层级都是一道题的题目,子级就是题,被选中和填写的题要带上题目一块上传(题的同级也要上传)
  308. // 第一级题目下的题默认都要上传
  309. let params = {
  310. customerClueItemList: [],
  311. customerClassify: this.customerClassify,
  312. customerSubClassify: this.customerSubClassify,
  313. };
  314. params.customerClueItemList.push(...this.deepClone(this.taskGather, 0));
  315. // let optionList = this.taskGather[0].customerClueOptionList;
  316. this.filterOption(this.taskGather, params);
  317. console.log(JSON.stringify(params));
  318. // 必填验证
  319. if (this.requiredFlag) {
  320. this.toastLoading(0, '加载中...', true);
  321. insertCustomerClueAnswerKs(params).then((res) => {
  322. this.toastLoading().clear();
  323. if (res.code == 200) {
  324. this.$toast(res.msg);
  325. window.location.replace(window.location.origin + '/mobile/clew');
  326. } else {
  327. this.$toast(res.msg);
  328. }
  329. });
  330. } else {
  331. this.$toast(this.requiredMessage);
  332. }
  333. },
  334. filterOption(optionList, params) {
  335. for (let val = 0; val < optionList.length; val++) {
  336. if (
  337. optionList[val].isMust == '0' &&
  338. optionList[val].searchValue == null &&
  339. optionList[val].answerType == 'dx'
  340. ) {
  341. // 题目必填校验
  342. this.requiredFlag = false;
  343. this.requiredMessage = '请选择' + optionList[val].customerClueName;
  344. return;
  345. } else if (optionList[val].isMust == '0' && optionList[val].searchValue) {
  346. // 子级题校验
  347. let customerClueOptionList = optionList[val].customerClueOptionList;
  348. for (let i = 0; i < customerClueOptionList.length; i++) {
  349. // 选中的题目Y:选中,N:未选中
  350. if (customerClueOptionList[i].value == 'Y') {
  351. if (customerClueOptionList[i].customerClueItemList) {
  352. // 必填校验
  353. this.isRequiredFlag(customerClueOptionList[i].customerClueItemList);
  354. // 赋值选中题
  355. let customerClueItemList =
  356. params.customerClueItemList[val].customerClueOptionList[i].customerClueItemList;
  357. customerClueItemList.push(
  358. ...this.deepClone(customerClueOptionList[i].customerClueItemList, 0)
  359. );
  360. if (customerClueOptionList[i].customerClueItemList[0]) {
  361. this.filterOption(customerClueOptionList[i].customerClueItemList, params);
  362. }
  363. }
  364. }
  365. }
  366. }
  367. }
  368. },
  369. // 深拷贝指定拷贝层级
  370. deepClone(obj, num) {
  371. // 检查是否为对象或数组
  372. if (obj === null || typeof obj !== 'object') {
  373. return obj; // 基本类型直接返回
  374. }
  375. // 创建一个数组或对象
  376. const copy = Array.isArray(obj) ? [] : {};
  377. // 遍历对象的每个属性
  378. for (const key in obj) {
  379. if (obj.hasOwnProperty(key) && num < 2) {
  380. // 递归调用深拷贝
  381. if (key == 'customerClueOptionList' || key == 'customerClueItemList') {
  382. num = num + 1;
  383. }
  384. copy[key] = this.deepClone(obj[key], num);
  385. }
  386. }
  387. return copy;
  388. },
  389. isRequiredFlag(optionList) {
  390. // console.log(optionList);
  391. for (let i = 0; i < optionList.length; i++) {
  392. // 是否必填
  393. if (optionList[i].isMust == 0) {
  394. // 输入框
  395. if (optionList[i].answerType == 'wb' || optionList[i].answerType == 'sz') {
  396. if (!optionList[i].answerValue) {
  397. // 必填类型
  398. this.requiredFlag = false;
  399. this.requiredMessage = optionList[i].remark;
  400. return;
  401. } else {
  402. // 条件校验
  403. if (optionList[i].minTextLength) {
  404. // 输入内容长度校验
  405. if (optionList[i].answerValue.length < optionList[i].minTextLength) {
  406. this.requiredFlag = false;
  407. this.requiredMessage = optionList[i].remark;
  408. return;
  409. }
  410. }
  411. }
  412. } else if (optionList[i].answerType == 'zp') {
  413. // 照片
  414. if (!optionList[i].fileInfoList || !optionList[i].fileInfoList.length) {
  415. this.requiredFlag = false;
  416. this.requiredMessage = optionList[i].remark;
  417. return;
  418. }
  419. }
  420. }
  421. }
  422. },
  423. // 校验错误返回信息
  424. onFailed(errorInfo) {
  425. console.log('failed', errorInfo);
  426. },
  427. // 查看历史跟进记录
  428. viewFn(val) {
  429. // this.viewTextShow = false;
  430. this.historyId = val;
  431. this.showView = true;
  432. },
  433. onConfirm1(value) {
  434. this.customerClassifyValue = value.remark;
  435. this.customerClassify = value.dictValue;
  436. this.showPicker1 = false;
  437. this.getCustomerSubClassify(this.customerClassify);
  438. },
  439. onConfirm2(value) {
  440. this.customerSubClassifyValue = value.dictLabel;
  441. this.customerSubClassify = value.dictValue;
  442. this.showPicker2 = false;
  443. },
  444. onstopVisit() {
  445. this.deptCode = '';
  446. this.regionList = [];
  447. this.deptList = [];
  448. this.companyName = '请选择公司';
  449. this.companyCode = '';
  450. this.regionName = '请选择大区';
  451. this.regionCode = '';
  452. this.deptName = '请选择销售部';
  453. this.show = true;
  454. },
  455. confirm(action, done) {
  456. if (action === 'confirm') {
  457. if (this.deptCode != '') {
  458. updateCustomerClueDept({
  459. customerClueInfoId: this.$route.query.id,
  460. deptId: this.deptCode,
  461. }).then((require) => {
  462. if (require.code == 200) {
  463. this.$toast.success('转发成功');
  464. this.show = false;
  465. if (this.$route.query.token != undefined) {
  466. window.location.replace(window.location.origin + '/mobile/clew');
  467. } else {
  468. this.$router.go(-1);
  469. }
  470. return done(true);
  471. } else {
  472. this.$toast(res.msg);
  473. }
  474. });
  475. } else {
  476. this.$toast('请选择要转发销售部');
  477. return done(false);
  478. }
  479. } else {
  480. return done(true);
  481. this.show = false;
  482. }
  483. },
  484. onregionConfirm(val) {
  485. this.RegionShow = false;
  486. this.companyName = val.deptName;
  487. this.companyCode = val.deptId;
  488. this.regionName = '请选择大区';
  489. this.regionCode = '';
  490. this.deptName = '请选择销售部';
  491. this.deptCode = '';
  492. this.getDeptInfo('dept', 1);
  493. },
  494. onSalesRegionConfirm(val) {
  495. this.SalesRegionShow = false;
  496. this.regionName = val.deptName;
  497. this.regionCode = val.deptId;
  498. if (val.deptId != '') {
  499. this.getDeptInfo('dept', 2);
  500. }
  501. this.deptName = '全部销售部';
  502. this.deptCode = '';
  503. },
  504. onSalesDepartmentConfirm(val) {
  505. this.SalesDepartmentShow = false;
  506. this.deptName = val.deptName;
  507. if (val.deptId != '') {
  508. this.deptCode = val.deptId;
  509. this.getDeptInfo('user');
  510. }
  511. this.userName = '全部业务员';
  512. this.userCode = '';
  513. },
  514. getDeptInfo(type, grade) {
  515. this.deptForm.type = type;
  516. if (grade == '1') {
  517. this.deptForm.parentId = this.companyCode;
  518. } else if (grade == '2') {
  519. this.deptForm.parentId = this.regionCode;
  520. } else {
  521. this.deptForm.type = '';
  522. this.deptForm.parentId = '';
  523. }
  524. getDeptInfo(this.deptForm).then((res) => {
  525. res.data.forEach((item) => {
  526. delete item.children;
  527. });
  528. if (grade == '1') {
  529. this.regionList = res.data;
  530. } else if (grade == '2') {
  531. this.deptList = res.data;
  532. } else {
  533. this.companyList = res.data;
  534. }
  535. });
  536. },
  537. regionClick() {
  538. this.RegionShow = true;
  539. },
  540. SalesRegionClick(val) {
  541. this.SalesRegionShow = true;
  542. },
  543. SalesDepartmentClick() {
  544. this.SalesDepartmentShow = true;
  545. },
  546. onClickLeft() {
  547. this.$router.go(-1);
  548. },
  549. },
  550. };
  551. </script>
  552. <style scoped lang="scss">
  553. .complaintDetail {
  554. .assign {
  555. margin: 10px;
  556. background-color: #fff;
  557. padding-bottom: 20px;
  558. .followUp {
  559. padding: 16px;
  560. font-size: 14px;
  561. font-weight: 600;
  562. }
  563. }
  564. .taskGather {
  565. padding-left: 20px;
  566. padding-bottom: 20px;
  567. .title {
  568. font-size: 15px;
  569. font-weight: 600;
  570. padding: 5px 0;
  571. }
  572. }
  573. }
  574. </style>
  575. <style lang="scss">
  576. .complaintDetail {
  577. .van-field__label {
  578. width: 100px;
  579. &::before {
  580. content: '*';
  581. color: red;
  582. }
  583. }
  584. .centerBtn {
  585. float: right;
  586. background: #0057ba;
  587. border-color: #0057ba;
  588. color: #fff;
  589. margin-top: -33px;
  590. border-radius: 5px;
  591. }
  592. .dialogz {
  593. width: 100%;
  594. display: flex;
  595. flex-direction: column;
  596. overflow: hidden;
  597. height: 72vh;
  598. .van-dialog__content {
  599. flex: 1;
  600. overflow-y: auto;
  601. }
  602. }
  603. .van-cell {
  604. font-size: 15px !important;
  605. .van-cell__title {
  606. color: #000 !important;
  607. }
  608. }
  609. .complaintType {
  610. .typeItem {
  611. .van-cell__title {
  612. padding: 3px;
  613. }
  614. .van-field__value {
  615. padding: 3px;
  616. padding-left: 5px;
  617. border: 1px solid #ccc;
  618. .van-field__control {
  619. color: #626262;
  620. }
  621. }
  622. }
  623. }
  624. }
  625. </style>