index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  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="dictLabel"
  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.dictLabel || '';
  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. if (this.infoData.sendUserId != localStorage.getItem('userId')) {
  283. this.$dialog
  284. .confirm({
  285. title: '提示',
  286. message: '该客诉已经被转移给其他人',
  287. showCancelButton: false,
  288. })
  289. .then(() => {
  290. window.location.replace(window.location.origin + '/mobile/clew');
  291. });
  292. }
  293. } else {
  294. this.$toast(res.msg);
  295. }
  296. });
  297. },
  298. onSubmit() {
  299. // 没有选择跟进记录
  300. // if (!this.taskGather[0].searchValue) {
  301. // this.$toast('请选择跟进结果');
  302. // return;
  303. // }
  304. this.requiredFlag = true;
  305. let customerClueItemList = [];
  306. // 每一个层级都是一道题的题目,子级就是题,被选中和填写的题要带上题目一块上传(题的同级也要上传)
  307. // 第一级题目下的题默认都要上传
  308. let params = {
  309. customerClueItemList: [],
  310. customerClassify: this.customerClassify,
  311. customerSubClassify: this.customerSubClassify,
  312. };
  313. params.customerClueItemList.push(...this.deepClone(this.taskGather, 0));
  314. // let optionList = this.taskGather[0].customerClueOptionList;
  315. this.filterOption(this.taskGather, params);
  316. console.log(JSON.stringify(params));
  317. // 必填验证
  318. if (this.requiredFlag) {
  319. this.toastLoading(0, '加载中...', true);
  320. insertCustomerClueAnswerKs(params).then((res) => {
  321. this.toastLoading().clear();
  322. if (res.code == 200) {
  323. this.$toast(res.msg);
  324. window.location.replace(window.location.origin + '/mobile/clew');
  325. } else {
  326. this.$toast(res.msg);
  327. }
  328. });
  329. } else {
  330. this.$toast(this.requiredMessage);
  331. }
  332. },
  333. filterOption(optionList, params) {
  334. for (let val = 0; val < optionList.length; val++) {
  335. if (
  336. optionList[val].isMust == '0' &&
  337. optionList[val].searchValue == null &&
  338. optionList[val].answerType == 'dx'
  339. ) {
  340. // 题目必填校验
  341. this.requiredFlag = false;
  342. this.requiredMessage = '请选择' + optionList[val].customerClueName;
  343. return;
  344. } else if (optionList[val].isMust == '0' && optionList[val].searchValue) {
  345. let customerClueOptionList = optionList[val].customerClueOptionList;
  346. for (let i = 0; i < customerClueOptionList.length; i++) {
  347. if (customerClueOptionList[i].value == 'Y') {
  348. if (customerClueOptionList[i].customerClueItemList) {
  349. // 必填校验
  350. this.isRequiredFlag(customerClueOptionList[i].customerClueItemList);
  351. let customerClueItemList =
  352. params.customerClueItemList[val].customerClueOptionList[i].customerClueItemList;
  353. customerClueItemList.push(
  354. ...this.deepClone(customerClueOptionList[i].customerClueItemList, 0)
  355. );
  356. if (customerClueOptionList[i].customerClueItemList[0]) {
  357. this.filterOption(customerClueOptionList[i].customerClueItemList, params);
  358. }
  359. }
  360. }
  361. }
  362. }
  363. }
  364. },
  365. // 深拷贝指定拷贝层级
  366. deepClone(obj, num) {
  367. // 检查是否为对象或数组
  368. if (obj === null || typeof obj !== 'object') {
  369. return obj; // 基本类型直接返回
  370. }
  371. // 创建一个数组或对象
  372. const copy = Array.isArray(obj) ? [] : {};
  373. // 遍历对象的每个属性
  374. for (const key in obj) {
  375. if (obj.hasOwnProperty(key) && num < 2) {
  376. // 递归调用深拷贝
  377. if (key == 'customerClueOptionList' || key == 'customerClueItemList') {
  378. num = num + 1;
  379. }
  380. copy[key] = this.deepClone(obj[key], num);
  381. }
  382. }
  383. return copy;
  384. },
  385. isRequiredFlag(optionList) {
  386. // console.log(optionList);
  387. // 必填类型
  388. for (let i = 0; i < optionList.length; i++) {
  389. if (optionList[i].answerType == 'wb' && optionList[i].isMust == 0) {
  390. if (!optionList[i].answerValue) {
  391. this.requiredFlag = false;
  392. this.requiredMessage = optionList[i].remark;
  393. return;
  394. }
  395. }
  396. }
  397. },
  398. // 校验错误返回信息
  399. onFailed(errorInfo) {
  400. console.log('failed', errorInfo);
  401. },
  402. // 查看历史跟进记录
  403. viewFn(val) {
  404. // this.viewTextShow = false;
  405. this.historyId = val;
  406. this.showView = true;
  407. },
  408. onConfirm1(value) {
  409. this.customerClassifyValue = value.dictLabel;
  410. this.customerClassify = value.dictValue;
  411. this.showPicker1 = false;
  412. this.getCustomerSubClassify(this.customerClassify);
  413. },
  414. onConfirm2(value) {
  415. this.customerSubClassifyValue = value.dictLabel;
  416. this.customerSubClassify = value.dictValue;
  417. this.showPicker2 = false;
  418. },
  419. onstopVisit() {
  420. this.deptCode = '';
  421. this.regionList = [];
  422. this.deptList = [];
  423. this.companyName = '请选择公司';
  424. this.companyCode = '';
  425. this.regionName = '请选择大区';
  426. this.regionCode = '';
  427. this.deptName = '请选择销售部';
  428. this.show = true;
  429. },
  430. confirm(action, done) {
  431. if (action === 'confirm') {
  432. if (this.deptCode != '') {
  433. updateCustomerClueDept({
  434. customerClueInfoId: this.$route.query.id,
  435. deptId: this.deptCode,
  436. }).then((require) => {
  437. if (require.code == 200) {
  438. this.$toast.success('转发成功');
  439. this.show = false;
  440. if (this.$route.query.token != undefined) {
  441. window.location.replace(window.location.origin + '/mobile/clew');
  442. } else {
  443. this.$router.go(-1);
  444. }
  445. return done(true);
  446. } else {
  447. this.$toast(res.msg);
  448. }
  449. });
  450. } else {
  451. this.$toast('请选择要转发销售部');
  452. return done(false);
  453. }
  454. } else {
  455. return done(true);
  456. this.show = false;
  457. }
  458. },
  459. onregionConfirm(val) {
  460. this.RegionShow = false;
  461. this.companyName = val.deptName;
  462. this.companyCode = val.deptId;
  463. this.regionName = '请选择大区';
  464. this.regionCode = '';
  465. this.deptName = '请选择销售部';
  466. this.deptCode = '';
  467. this.getDeptInfo('dept', 1);
  468. },
  469. onSalesRegionConfirm(val) {
  470. this.SalesRegionShow = false;
  471. this.regionName = val.deptName;
  472. this.regionCode = val.deptId;
  473. if (val.deptId != '') {
  474. this.getDeptInfo('dept', 2);
  475. }
  476. this.deptName = '全部销售部';
  477. this.deptCode = '';
  478. },
  479. onSalesDepartmentConfirm(val) {
  480. this.SalesDepartmentShow = false;
  481. this.deptName = val.deptName;
  482. if (val.deptId != '') {
  483. this.deptCode = val.deptId;
  484. this.getDeptInfo('user');
  485. }
  486. this.userName = '全部业务员';
  487. this.userCode = '';
  488. },
  489. getDeptInfo(type, grade) {
  490. this.deptForm.type = type;
  491. if (grade == '1') {
  492. this.deptForm.parentId = this.companyCode;
  493. } else if (grade == '2') {
  494. this.deptForm.parentId = this.regionCode;
  495. } else {
  496. this.deptForm.type = '';
  497. this.deptForm.parentId = '';
  498. }
  499. getDeptInfo(this.deptForm).then((res) => {
  500. res.data.forEach((item) => {
  501. delete item.children;
  502. });
  503. if (grade == '1') {
  504. this.regionList = res.data;
  505. } else if (grade == '2') {
  506. this.deptList = res.data;
  507. } else {
  508. this.companyList = res.data;
  509. }
  510. });
  511. },
  512. regionClick() {
  513. this.RegionShow = true;
  514. },
  515. SalesRegionClick(val) {
  516. this.SalesRegionShow = true;
  517. },
  518. SalesDepartmentClick() {
  519. this.SalesDepartmentShow = true;
  520. },
  521. onClickLeft() {
  522. this.$router.go(-1);
  523. },
  524. },
  525. };
  526. </script>
  527. <style scoped lang="scss">
  528. .complaintDetail {
  529. .assign {
  530. margin: 10px;
  531. background-color: #fff;
  532. padding-bottom: 20px;
  533. .followUp {
  534. padding: 16px;
  535. font-size: 14px;
  536. font-weight: 600;
  537. }
  538. }
  539. .taskGather {
  540. padding-left: 20px;
  541. padding-bottom: 20px;
  542. .title {
  543. font-size: 15px;
  544. font-weight: 600;
  545. padding: 5px 0;
  546. }
  547. }
  548. }
  549. </style>
  550. <style lang="scss">
  551. .complaintDetail {
  552. .van-field__label {
  553. width: 100px;
  554. &::before {
  555. content: '*';
  556. color: red;
  557. }
  558. }
  559. .centerBtn {
  560. float: right;
  561. background: #0057ba;
  562. border-color: #0057ba;
  563. color: #fff;
  564. margin-top: -33px;
  565. border-radius: 5px;
  566. }
  567. .dialogz {
  568. width: 100%;
  569. display: flex;
  570. flex-direction: column;
  571. overflow: hidden;
  572. height: 72vh;
  573. .van-dialog__content {
  574. flex: 1;
  575. overflow-y: auto;
  576. }
  577. }
  578. .van-cell {
  579. font-size: 15px !important;
  580. .van-cell__title {
  581. color: #000 !important;
  582. }
  583. }
  584. .complaintType {
  585. .typeItem {
  586. .van-cell__title {
  587. padding: 3px;
  588. }
  589. .van-field__value {
  590. padding: 3px;
  591. padding-left: 5px;
  592. border: 1px solid #ccc;
  593. .van-field__control {
  594. color: #626262;
  595. }
  596. }
  597. }
  598. }
  599. }
  600. </style>