JZfollowUp.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. <template>
  2. <div class="bgcolor assignPage">
  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. <assignAwaitDetail :infoData="infoData" v-if="infoData" :source="'JZfollowUp'">
  13. <div class="info">
  14. 跟进状态:
  15. <span v-if="infoData.isClose == 1">跟进完成</span>
  16. <span v-if="infoData.isClose == 0">跟进中</span>
  17. <span v-if="infoData.isClose == -1">未跟进</span>
  18. <span v-if="infoData.isClose == 2">已过期</span>
  19. </div>
  20. <!-- 转交 -->
  21. <!-- -->
  22. <van-button
  23. v-if="
  24. infoData.isClose != 1 &&
  25. infoData.isClose != 2 &&
  26. postName &&
  27. postName == '区域家装销售负责人'
  28. "
  29. type="info"
  30. size="small"
  31. plain
  32. class="centerBtn"
  33. @click="showPicker = true">
  34. 转交下属
  35. </van-button>
  36. </assignAwaitDetail>
  37. <!-- 催办历史 -->
  38. <hasten
  39. v-if="infoData && infoData.customerClueInfoUrgeList"
  40. :hastenList="infoData.customerClueInfoUrgeList"></hasten>
  41. <!-- 历史跟进记录 -->
  42. <p style="margin: 0 16px 8px; color: #888" v-if="infoData && infoData.userCustomerClueList">
  43. 该客资历史跟进记录
  44. </p>
  45. <van-cell-group inset class="cardclewContentCell" v-if="infoData">
  46. <div style="border-radius: 6px; overflow: hidden">
  47. <van-cell
  48. is-link
  49. v-for="(item, index) in infoData.userCustomerClueList"
  50. :key="index"
  51. @click="viewFn(item.userCustomerClueId)">
  52. <template #title>
  53. <span class="custom-title">{{ item.nickName }}</span>
  54. </template>
  55. <div class="cardContent">
  56. <p class="textLeft" style="padding-bottom: 0px; margin: 0">{{ item.createTime }}</p>
  57. </div>
  58. </van-cell>
  59. </div>
  60. </van-cell-group>
  61. <!-- 跟进任务填写 -->
  62. <div class="assign" v-if="infoData && infoData.isClose != 1 && infoData.isClose != 2">
  63. <div class="followUp required">跟进结果</div>
  64. <div class="taskGather" v-if="taskGather && taskGather">
  65. <radioGroup :clueOptionList="taskGather"></radioGroup>
  66. </div>
  67. <div class="tc" style="padding: 0 16px">
  68. <van-button class="submitBtn" block type="info" color="#0057ba" @click="onSubmit">
  69. 提交
  70. </van-button>
  71. </div>
  72. </div>
  73. <!-- 转交下属 -->
  74. <van-popup v-model="showPicker" position="bottom">
  75. <van-picker
  76. title="转交下属"
  77. show-toolbar
  78. value-key="nickName"
  79. :columns="assignTypeData"
  80. @confirm="confirm"
  81. @cancel="showPicker = false" />
  82. </van-popup>
  83. <!-- 客资跟进历史 -->
  84. <van-dialog
  85. v-model="showView"
  86. title="客资历史"
  87. show-cancel-button
  88. cancel-button-text="关闭"
  89. :show-confirm-button="false"
  90. class="dialogz">
  91. <followUpHistory :historyId="historyId" :showView="showView"></followUpHistory>
  92. </van-dialog>
  93. </div>
  94. </template>
  95. <script>
  96. import { getCustomerClueInfoById } from '@/api/clew';
  97. import { getDictOption } from '@/api/index';
  98. import assignAwaitDetail from './assignAwaitDetail.vue';
  99. import {
  100. selectCustomerClueInfoById,
  101. selectSubUserList,
  102. allocationSubCustomer,
  103. insertFollowCustomerClueAnswer,
  104. } from '@/api/assignAwait';
  105. import { mapState } from 'vuex';
  106. import radioGroup from './radioGroup';
  107. import followUpHistory from './followUpHistory';
  108. import store from '@/store';
  109. import hasten from '@/views/clew/hasten';
  110. export default {
  111. name: 'assignPage',
  112. components: {
  113. assignAwaitDetail,
  114. radioGroup,
  115. followUpHistory,
  116. hasten,
  117. },
  118. computed: {
  119. ...mapState({
  120. userInfo: (state) => state.user.userInfo,
  121. }),
  122. },
  123. data() {
  124. return {
  125. id: '',
  126. infoData: null,
  127. collectionItemList: [],
  128. title: '',
  129. postName: '',
  130. showPicker: false,
  131. assignTypeData: [],
  132. taskGather: null, //跟进任务集合
  133. showView: false,
  134. historyId: '',
  135. requiredFlag: true, //问题必填检验
  136. requiredMessage: '', //必填提示信息
  137. };
  138. },
  139. watch: {},
  140. activated() {
  141. this.id = this.$route.query.id;
  142. this.postName = localStorage.getItem('postName');
  143. this.getCustomerClueInfoById();
  144. },
  145. methods: {
  146. getCustomerClueInfoById() {
  147. this.toastLoading(0, '加载中...', true);
  148. this.id = this.$route.query.id;
  149. this.collectionAnswerlisd = [];
  150. this.collectionItemList = [];
  151. getCustomerClueInfoById({ customerClueInfoId: this.id }).then((response) => {
  152. this.toastLoading().clear();
  153. if (response.code == 200) {
  154. this.infoData = response.data;
  155. this.title = response.data.name;
  156. if (response.data.customerClue != null) {
  157. this.collectionItemList = response.data.customerClue.customerClueItemList;
  158. } else {
  159. this.collectionItemList = [];
  160. }
  161. // 获取转交下属数据 未跟进状态下
  162. if (
  163. this.infoData.isClose != 1 &&
  164. this.infoData.isClose != 2 &&
  165. this.postName &&
  166. this.postName == '区域家装销售负责人'
  167. ) {
  168. this.getSelectSubUserList();
  169. }
  170. if (this.infoData.isClose != 1 && this.infoData.isClose != 1) {
  171. this.getSelectCustomerClueInfoById();
  172. }
  173. // 当前客资归属人不是当前登录人
  174. if (this.infoData.sendUserId != localStorage.getItem('userId')) {
  175. this.$dialog
  176. .confirm({
  177. title: '提示',
  178. message: '该客资已经被转移给其他人',
  179. showCancelButton: false,
  180. })
  181. .then(() => {
  182. window.location.replace(window.location.origin + this.locationOrigin + '/clew');
  183. });
  184. }
  185. } else {
  186. this.$toast(res.msg);
  187. }
  188. });
  189. },
  190. getSelectCustomerClueInfoById() {
  191. selectCustomerClueInfoById({ customerClueInfoId: this.id }).then((res) => {
  192. if (res.code == 200) {
  193. // res.data.customerClue.searchValue.customerClueItemList
  194. if (res.data.customerClue) {
  195. res.data.customerClue.customerClueItemList[0].customerClueInfoId = this.id;
  196. this.taskGather = res.data.customerClue.customerClueItemList;
  197. }
  198. } else {
  199. this.$toast(res.msg);
  200. }
  201. });
  202. },
  203. getSelectSubUserList() {
  204. selectSubUserList().then((res) => {
  205. if (res.code == 200) {
  206. this.assignTypeData = res.data ? res.data : [];
  207. } else {
  208. this.$toast(res.msg);
  209. }
  210. });
  211. },
  212. confirm(value) {
  213. this.$dialog
  214. .confirm({
  215. title: '提示',
  216. message: '一旦转交出去,则无法再查看,请确认!',
  217. })
  218. .then(() => {
  219. this.toastLoading(0, '加载中...', true);
  220. allocationSubCustomer({
  221. userId: value.userId, // string 用户ID
  222. customerClueInfoId: this.id, // string 客资主键ID
  223. }).then((res) => {
  224. this.toastLoading().clear();
  225. if (res.code == 200) {
  226. this.$toast(res.msg);
  227. window.location.replace(window.location.origin + this.locationOrigin + '/clew');
  228. } else {
  229. this.$toast(res.msg);
  230. }
  231. });
  232. });
  233. },
  234. // 查看历史跟进记录
  235. viewFn(val) {
  236. // this.viewTextShow = false;
  237. this.historyId = val;
  238. this.showView = true;
  239. },
  240. onSubmit() {
  241. // 没有选择跟进记录
  242. if (!this.taskGather[0].searchValue) {
  243. this.$toast('请选择跟进结果');
  244. return;
  245. }
  246. this.requiredFlag = true;
  247. let customerClueItemList = [];
  248. // 每一个层级都是一道题的题目,子级就是题,被选中和填写的题要带上题目一块上传(题的同级也要上传)
  249. // 第一级题目下的题默认都要上传
  250. let params = { customerClueItemList: [] };
  251. params.customerClueItemList.push(...this.deepClone(this.taskGather, 0));
  252. let optionList = this.taskGather[0].customerClueOptionList;
  253. this.filterOption(optionList, params);
  254. // 必填验证
  255. if (this.requiredFlag) {
  256. this.toastLoading(0, '加载中...', true);
  257. insertFollowCustomerClueAnswer(params).then((res) => {
  258. this.toastLoading().clear();
  259. if (res.code == 200) {
  260. if (this.$route.query.token != undefined) {
  261. window.location.replace(window.location.origin + this.locationOrigin + '/clew');
  262. } else {
  263. store.dispatch('setRefreshClewPage', true);
  264. // 返回上一页不会刷新页面
  265. this.$router.go(-1);
  266. }
  267. } else {
  268. this.$toast(res.msg);
  269. }
  270. });
  271. } else {
  272. this.$toast(this.requiredMessage);
  273. }
  274. },
  275. filterOption(optionList, params) {
  276. let copy = null;
  277. for (let i = 0; i < optionList.length; i++) {
  278. if (optionList[i].value == 'Y') {
  279. if (optionList[i].customerClueItemList) {
  280. // 必填校验
  281. this.isRequiredFlag(optionList[i].customerClueItemList);
  282. params.customerClueItemList.push(
  283. ...this.deepClone(optionList[i].customerClueItemList, 0),
  284. );
  285. if (
  286. optionList[i].customerClueItemList[0] &&
  287. optionList[i].customerClueItemList[0].customerClueOptionList.length
  288. ) {
  289. this.filterOption(
  290. optionList[i].customerClueItemList[0].customerClueOptionList,
  291. params,
  292. );
  293. }
  294. }
  295. }
  296. }
  297. },
  298. deepClone(obj, num) {
  299. // 检查是否为对象或数组
  300. if (obj === null || typeof obj !== 'object') {
  301. return obj; // 基本类型直接返回
  302. }
  303. // 创建一个数组或对象
  304. const copy = Array.isArray(obj) ? [] : {};
  305. // 遍历对象的每个属性
  306. for (const key in obj) {
  307. if (obj.hasOwnProperty(key) && num < 2) {
  308. // 递归调用深拷贝
  309. if (key == 'customerClueOptionList' || key == 'customerClueItemList') {
  310. num = num + 1;
  311. }
  312. copy[key] = this.deepClone(obj[key], num);
  313. }
  314. }
  315. return copy;
  316. },
  317. isRequiredFlag(optionList) {
  318. console.log(optionList);
  319. // 必填类型
  320. for (let i = 0; i < optionList.length; i++) {
  321. if (
  322. (optionList[i].answerType == 'wb' || optionList[i].answerType == 'sz') &&
  323. optionList[i].isMust == 0
  324. ) {
  325. if (!optionList[i].answerValue) {
  326. this.requiredFlag = false;
  327. this.requiredMessage = optionList[i].remark;
  328. return;
  329. }
  330. }
  331. }
  332. },
  333. // 校验错误返回信息
  334. onFailed(errorInfo) {
  335. console.log('failed', errorInfo);
  336. },
  337. onClickLeft() {
  338. this.$router.go(-1);
  339. },
  340. },
  341. };
  342. </script>
  343. <style scoped lang="scss">
  344. .assignPage {
  345. .assign {
  346. margin: 10px;
  347. background-color: #fff;
  348. padding-bottom: 20px;
  349. .followUp {
  350. padding: 16px;
  351. font-size: 14px;
  352. font-weight: 600;
  353. }
  354. }
  355. }
  356. </style>
  357. <style lang="scss">
  358. .assignPage {
  359. .van-field__label {
  360. width: 100px;
  361. &::before {
  362. content: '*';
  363. color: red;
  364. }
  365. }
  366. .centerBtn {
  367. float: right;
  368. background: #0057ba;
  369. border-color: #0057ba;
  370. color: #fff;
  371. margin-top: -33px;
  372. border-radius: 5px;
  373. }
  374. .dialogz {
  375. width: 100%;
  376. display: flex;
  377. flex-direction: column;
  378. overflow: hidden;
  379. height: 72vh;
  380. .van-dialog__content {
  381. flex: 1;
  382. overflow-y: auto;
  383. }
  384. }
  385. }
  386. </style>