JZfollowUp.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  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">
  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.customerClueStatus == 0 && 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. export default {
  99. name: 'assignPage',
  100. components: {
  101. assignAwaitDetail,
  102. radioGroup,
  103. followUpHistory,
  104. },
  105. computed: {
  106. ...mapState({
  107. userInfo: (state) => state.user.userInfo,
  108. }),
  109. },
  110. data() {
  111. return {
  112. id: '',
  113. infoData: null,
  114. collectionItemList: [],
  115. title: '',
  116. postName: '',
  117. showPicker: false,
  118. assignTypeData: [],
  119. taskGather: null, //跟进任务集合
  120. showView: false,
  121. historyId: '',
  122. requiredFlag: true, //问题必填检验
  123. requiredMessage: '', //必填提示信息
  124. };
  125. },
  126. watch: {},
  127. activated() {
  128. this.id = this.$route.query.id;
  129. this.postName = localStorage.getItem('postName');
  130. this.getCustomerClueInfoById();
  131. },
  132. methods: {
  133. getCustomerClueInfoById() {
  134. this.toastLoading(0, '加载中...', true);
  135. this.id = this.$route.query.id;
  136. this.collectionAnswerlisd = [];
  137. this.collectionItemList = [];
  138. getCustomerClueInfoById({ customerClueInfoId: this.id }).then((response) => {
  139. this.toastLoading().clear();
  140. if (response.code == 200) {
  141. this.infoData = response.data;
  142. this.title = response.data.name;
  143. if (response.data.customerClue != null) {
  144. this.collectionItemList = response.data.customerClue.customerClueItemList;
  145. } else {
  146. this.collectionItemList = [];
  147. }
  148. // 获取转交下属数据
  149. if (
  150. this.infoData.customerClueStatus == 0 &&
  151. this.postName &&
  152. this.postName == '区域家装销售负责人'
  153. ) {
  154. this.getSelectSubUserList();
  155. }
  156. if (this.infoData.isClose != 1) {
  157. this.getSelectCustomerClueInfoById();
  158. }
  159. } else {
  160. this.$toast(res.msg);
  161. }
  162. });
  163. },
  164. getSelectCustomerClueInfoById() {
  165. selectCustomerClueInfoById({ customerClueInfoId: this.id }).then((res) => {
  166. if (res.code == 200) {
  167. // res.data.customerClue.searchValue.customerClueItemList
  168. if (res.data.customerClue) {
  169. res.data.customerClue.customerClueItemList[0].customerClueInfoId = this.id;
  170. this.taskGather = res.data.customerClue.customerClueItemList;
  171. }
  172. } else {
  173. this.$toast(res.msg);
  174. }
  175. });
  176. },
  177. getSelectSubUserList() {
  178. selectSubUserList().then((res) => {
  179. if (res.code == 200) {
  180. this.assignTypeData = res.data ? res.data : [];
  181. } else {
  182. this.$toast(res.msg);
  183. }
  184. });
  185. },
  186. confirm(value) {
  187. this.$dialog
  188. .confirm({
  189. title: '提示',
  190. message: '一旦转交出去,则无法再查看,请确认!',
  191. })
  192. .then(() => {
  193. this.toastLoading(0, '加载中...', true);
  194. allocationSubCustomer({
  195. userId: value.userId, // string 用户ID
  196. customerClueInfoId: this.id, // string 客资主键ID
  197. }).then((res) => {
  198. this.toastLoading().clear();
  199. if (res.code == 200) {
  200. this.$toast(res.msg);
  201. this.onClickLeft();
  202. } else {
  203. this.$toast(res.msg);
  204. }
  205. });
  206. });
  207. },
  208. // 查看历史跟进记录
  209. viewFn(val) {
  210. // this.viewTextShow = false;
  211. this.historyId = val;
  212. this.showView = true;
  213. },
  214. onSubmit() {
  215. // 没有选择跟进记录
  216. if (!this.taskGather[0].searchValue) {
  217. this.$toast('请选择跟进结果');
  218. return;
  219. }
  220. this.requiredFlag = true;
  221. let customerClueItemList = [];
  222. // 每一个层级都是一道题的题目,子级就是题,被选中和填写的题要带上题目一块上传(题的同级也要上传)
  223. // 第一级题目下的题默认都要上传
  224. let params = { customerClueItemList: [] };
  225. params.customerClueItemList.push(...this.deepClone(this.taskGather, 0));
  226. let optionList = this.taskGather[0].customerClueOptionList;
  227. this.filterOption(optionList, params);
  228. // 必填验证
  229. if (this.requiredFlag) {
  230. this.toastLoading(0, '加载中...', true);
  231. insertFollowCustomerClueAnswer(params).then((res) => {
  232. this.toastLoading().clear();
  233. if (res.code == 200) {
  234. this.$toast(res.msg);
  235. this.onClickLeft();
  236. } else {
  237. this.$toast(res.msg);
  238. }
  239. });
  240. } else {
  241. this.$toast(this.requiredMessage);
  242. }
  243. },
  244. filterOption(optionList, params) {
  245. let copy = null;
  246. for (let i = 0; i < optionList.length; i++) {
  247. if (optionList[i].value == 'Y') {
  248. if (optionList[i].customerClueItemList) {
  249. // 必填校验
  250. this.isRequiredFlag(optionList[i].customerClueItemList[0]);
  251. params.customerClueItemList.push(
  252. ...this.deepClone(optionList[i].customerClueItemList, 0)
  253. );
  254. if (
  255. optionList[i].customerClueItemList[0] &&
  256. optionList[i].customerClueItemList[0].customerClueOptionList.length
  257. ) {
  258. this.filterOption(
  259. optionList[i].customerClueItemList[0].customerClueOptionList,
  260. params
  261. );
  262. }
  263. }
  264. }
  265. }
  266. },
  267. deepClone(obj, num) {
  268. // 检查是否为对象或数组
  269. if (obj === null || typeof obj !== 'object') {
  270. return obj; // 基本类型直接返回
  271. }
  272. // 创建一个数组或对象
  273. const copy = Array.isArray(obj) ? [] : {};
  274. // 遍历对象的每个属性
  275. for (const key in obj) {
  276. if (obj.hasOwnProperty(key) && num < 2) {
  277. // 递归调用深拷贝
  278. if (key == 'customerClueOptionList' || key == 'customerClueItemList') {
  279. num = num + 1;
  280. }
  281. copy[key] = this.deepClone(obj[key], num);
  282. }
  283. }
  284. return copy;
  285. },
  286. isRequiredFlag(optionList) {
  287. // 必填类型
  288. if (optionList.answerType == 'wb' && optionList.isMust == 0) {
  289. if (!optionList.answerValue) {
  290. this.requiredFlag = false;
  291. this.requiredMessage = optionList.remark;
  292. }
  293. }
  294. },
  295. // 校验错误返回信息
  296. onFailed(errorInfo) {
  297. console.log('failed', errorInfo);
  298. },
  299. onClickLeft() {
  300. this.$router.go(-1);
  301. },
  302. },
  303. };
  304. </script>
  305. <style scoped lang="scss">
  306. .assignPage {
  307. .assign {
  308. margin: 16px;
  309. background-color: #fff;
  310. padding-bottom: 20px;
  311. .followUp {
  312. padding: 16px;
  313. font-size: 14px;
  314. font-weight: 600;
  315. }
  316. }
  317. }
  318. </style>
  319. <style lang="scss">
  320. .assignPage {
  321. .van-field__label {
  322. width: 100px;
  323. &::before {
  324. content: '*';
  325. color: red;
  326. }
  327. }
  328. .centerBtn {
  329. float: right;
  330. background: #0057ba;
  331. border-color: #0057ba;
  332. color: #fff;
  333. margin-top: -33px;
  334. border-radius: 5px;
  335. }
  336. .dialogz {
  337. width: 100%;
  338. display: flex;
  339. flex-direction: column;
  340. overflow: hidden;
  341. height: 72vh;
  342. .van-dialog__content {
  343. flex: 1;
  344. overflow-y: auto;
  345. }
  346. }
  347. }
  348. </style>