index.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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. <infoDetail :infoData="infoData" v-if="infoData"> </infoDetail>
  13. <!-- 客诉记录 -->
  14. <!-- 跟进任务填写 -->
  15. <div class="assign" v-if="infoData && infoData.isClose != 1">
  16. <div class="followUp required">跟进结果</div>
  17. <div class="taskGather" v-if="taskGather && taskGather">
  18. <radioGroup :clueOptionList="taskGather"></radioGroup>
  19. </div>
  20. <div class="tc" style="padding: 0 16px">
  21. <van-button class="submitBtn" block type="info" color="#0057ba" @click="onSubmit">
  22. 提交
  23. </van-button>
  24. </div>
  25. </div>
  26. </div>
  27. </template>
  28. <script>
  29. import { getComplaintCustomerClueInfoById } from '@/api/complaintDetail';
  30. import infoDetail from './infoDetail.vue';
  31. // import { selectCustomerClueInfoById, insertFollowCustomerClueAnswer } from '@/api/assignAwait';
  32. import { mapState } from 'vuex';
  33. import radioGroup from './radioGroup';
  34. export default {
  35. name: 'assignPage',
  36. components: {
  37. assignAwaitDetail,
  38. radioGroup,
  39. followUpHistory,
  40. },
  41. computed: {
  42. ...mapState({
  43. userInfo: (state) => state.user.userInfo,
  44. }),
  45. },
  46. data() {
  47. return {
  48. id: '',
  49. infoData: null,
  50. title: '',
  51. postName: '',
  52. taskGather: null, //跟进任务集合
  53. requiredFlag: true, //问题必填检验
  54. requiredMessage: '', //必填提示信息
  55. };
  56. },
  57. watch: {},
  58. activated() {
  59. this.id = this.$route.query.id;
  60. this.postName = localStorage.getItem('postName');
  61. this.getComplaintCustomerClueInfoByIdFun();
  62. },
  63. methods: {
  64. getComplaintCustomerClueInfoByIdFun() {
  65. this.toastLoading(0, '加载中...', true);
  66. this.id = this.$route.query.id;
  67. getComplaintCustomerClueInfoById({ customerClueInfoId: this.id }).then((response) => {
  68. this.toastLoading().clear();
  69. if (response.code == 200) {
  70. this.infoData = response.data;
  71. this.title = response.data.name;
  72. // if (this.infoData.isClose != 1) {
  73. // this.getSelectCustomerClueInfoById();
  74. // }
  75. } else {
  76. this.$toast(res.msg);
  77. }
  78. });
  79. },
  80. getSelectCustomerClueInfoById() {
  81. selectCustomerClueInfoById({ customerClueInfoId: this.id }).then((res) => {
  82. if (res.code == 200) {
  83. // res.data.customerClue.searchValue.customerClueItemList
  84. if (res.data.customerClue) {
  85. res.data.customerClue.customerClueItemList[0].customerClueInfoId = this.id;
  86. this.taskGather = res.data.customerClue.customerClueItemList;
  87. }
  88. } else {
  89. this.$toast(res.msg);
  90. }
  91. });
  92. },
  93. onSubmit() {
  94. // 没有选择跟进记录
  95. if (!this.taskGather[0].searchValue) {
  96. this.$toast('请选择跟进结果');
  97. return;
  98. }
  99. this.requiredFlag = true;
  100. let customerClueItemList = [];
  101. // 每一个层级都是一道题的题目,子级就是题,被选中和填写的题要带上题目一块上传(题的同级也要上传)
  102. // 第一级题目下的题默认都要上传
  103. let params = { customerClueItemList: [] };
  104. params.customerClueItemList.push(...this.deepClone(this.taskGather, 0));
  105. let optionList = this.taskGather[0].customerClueOptionList;
  106. this.filterOption(optionList, params);
  107. // 必填验证
  108. if (this.requiredFlag) {
  109. this.toastLoading(0, '加载中...', true);
  110. insertFollowCustomerClueAnswer(params).then((res) => {
  111. this.toastLoading().clear();
  112. if (res.code == 200) {
  113. this.$toast(res.msg);
  114. window.location.replace(window.location.origin + '/mobile/clew');
  115. } else {
  116. this.$toast(res.msg);
  117. }
  118. });
  119. } else {
  120. this.$toast(this.requiredMessage);
  121. }
  122. },
  123. filterOption(optionList, params) {
  124. let copy = null;
  125. for (let i = 0; i < optionList.length; i++) {
  126. if (optionList[i].value == 'Y') {
  127. if (optionList[i].customerClueItemList) {
  128. // 必填校验
  129. this.isRequiredFlag(optionList[i].customerClueItemList);
  130. params.customerClueItemList.push(
  131. ...this.deepClone(optionList[i].customerClueItemList, 0)
  132. );
  133. if (
  134. optionList[i].customerClueItemList[0] &&
  135. optionList[i].customerClueItemList[0].customerClueOptionList.length
  136. ) {
  137. this.filterOption(
  138. optionList[i].customerClueItemList[0].customerClueOptionList,
  139. params
  140. );
  141. }
  142. }
  143. }
  144. }
  145. },
  146. deepClone(obj, num) {
  147. // 检查是否为对象或数组
  148. if (obj === null || typeof obj !== 'object') {
  149. return obj; // 基本类型直接返回
  150. }
  151. // 创建一个数组或对象
  152. const copy = Array.isArray(obj) ? [] : {};
  153. // 遍历对象的每个属性
  154. for (const key in obj) {
  155. if (obj.hasOwnProperty(key) && num < 2) {
  156. // 递归调用深拷贝
  157. if (key == 'customerClueOptionList' || key == 'customerClueItemList') {
  158. num = num + 1;
  159. }
  160. copy[key] = this.deepClone(obj[key], num);
  161. }
  162. }
  163. return copy;
  164. },
  165. isRequiredFlag(optionList) {
  166. console.log(optionList);
  167. // 必填类型
  168. for (let i = 0; i < optionList.length; i++) {
  169. if (optionList[i].answerType == 'wb' && optionList[i].isMust == 0) {
  170. if (!optionList[i].answerValue) {
  171. this.requiredFlag = false;
  172. this.requiredMessage = optionList[i].remark;
  173. return;
  174. }
  175. }
  176. }
  177. },
  178. // 校验错误返回信息
  179. onFailed(errorInfo) {
  180. console.log('failed', errorInfo);
  181. },
  182. onClickLeft() {
  183. this.$router.go(-1);
  184. },
  185. },
  186. };
  187. </script>
  188. <style scoped lang="scss">
  189. .assignPage {
  190. .assign {
  191. margin: 10px;
  192. background-color: #fff;
  193. padding-bottom: 20px;
  194. .followUp {
  195. padding: 16px;
  196. font-size: 14px;
  197. font-weight: 600;
  198. }
  199. }
  200. }
  201. </style>
  202. <style lang="scss">
  203. .assignPage {
  204. .van-field__label {
  205. width: 100px;
  206. &::before {
  207. content: '*';
  208. color: red;
  209. }
  210. }
  211. .centerBtn {
  212. float: right;
  213. background: #0057ba;
  214. border-color: #0057ba;
  215. color: #fff;
  216. margin-top: -33px;
  217. border-radius: 5px;
  218. }
  219. .dialogz {
  220. width: 100%;
  221. display: flex;
  222. flex-direction: column;
  223. overflow: hidden;
  224. height: 72vh;
  225. .van-dialog__content {
  226. flex: 1;
  227. overflow-y: auto;
  228. }
  229. }
  230. }
  231. </style>