JZfollowUp.vue 11 KB

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