index.vue 20 KB

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