JZfollowUp.vue 12 KB

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