follow.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. import {
  2. filterCustomerManager,
  3. handleTree,
  4. isChinese
  5. } from '@/utils/util'
  6. const columnProps = [
  7. {
  8. prop : "name",
  9. label : "姓名",
  10. },
  11. {
  12. prop : "telephone",
  13. label : "电话",
  14. },
  15. {
  16. prop : "clueOperationName",
  17. label : "运营",
  18. },
  19. {
  20. prop : "appName",
  21. label : "来源",
  22. },
  23. {
  24. prop : "deptName",
  25. label : "归属",
  26. }
  27. ]
  28. export default {
  29. data() {
  30. return {
  31. recognitionContent: "",
  32. defaultRegion: ['广东省', '广州市', '番禺区'],
  33. listData: [],
  34. deptList: [],
  35. dictCascadeData: [],
  36. genderTypeCodeDict: [],
  37. originalDictCascadeData : [],
  38. originaDeptList : [],
  39. title: "新建线索",
  40. rules: {
  41. name: {
  42. type: 'string',
  43. required: true,
  44. message: '请输入姓名',
  45. trigger: ['blur', 'change']
  46. },
  47. telephone: {
  48. type: 'string',
  49. required: true,
  50. message: '请输入电话',
  51. trigger: ['blur', 'change']
  52. },
  53. clueOperationName: {
  54. type: 'string',
  55. required: true,
  56. message: '请选择运营人',
  57. trigger: ['blur', 'change']
  58. },
  59. appName: {
  60. type: 'string',
  61. required: true,
  62. message: '请选择来源',
  63. trigger: ['blur', 'change']
  64. },
  65. deptName: {
  66. type: 'string',
  67. required: true,
  68. message: '请选择归属机构',
  69. trigger: ['blur', 'change']
  70. },
  71. },
  72. form: {
  73. manualAddressCode: '',
  74. manualProvince: '',
  75. manualCity: '',
  76. manualArea: '',
  77. name: '',
  78. telephone: '',
  79. genderTypeCode: '',
  80. age: '',
  81. weixin: '',
  82. address: '',
  83. remark: '',
  84. qq: '',
  85. email: '',
  86. adId: '',
  87. appName: undefined,
  88. appNameLabel: undefined,
  89. province: undefined,
  90. city: undefined,
  91. area: undefined,
  92. clueOperationId: undefined,
  93. clueOperationName: undefined,
  94. clueOwnerId: undefined,
  95. clueOwnerName: undefined,
  96. deptName: undefined,
  97. deptId: undefined,
  98. }
  99. }
  100. },
  101. methods: {
  102. async handleRecognition() {
  103. // 电话:15099998888
  104. // 姓名:卡地亚萧邦
  105. // 来源:广点通
  106. // 运营:yxx
  107. // 归属:集团总部
  108. const splitStr = ":";
  109. // 避免用错符号,直接转换一下
  110. const lines = this.recognitionContent.replace(/:/g, splitStr).split('\n');
  111. lines.forEach(line => {
  112. const [key, value] = line.split(splitStr);
  113. const column = columnProps.find(v => key.trim() === v.label);
  114. if (column) {
  115. const {
  116. prop
  117. } = column;
  118. this.form[prop] = value?.trim();
  119. }
  120. });
  121. // 来源 归属机构 运营人 需要找id
  122. const {
  123. appName,
  124. deptName,
  125. clueOperationName
  126. } = this.form;
  127. if (appName) {
  128. let dictList = this.originalDictCascadeData;
  129. let appNameDict = dictList.find(v => v.name === appName);
  130. if (appNameDict) {
  131. this.form.appName = appNameDict.id;
  132. this.form.appNameLabel = appNameDict.name;
  133. } else {
  134. uni.$u.toast(appName + "当前来源未配置,请重新选择");
  135. }
  136. }
  137. if (deptName) {
  138. let deptList = this.originaDeptList;
  139. let dept = deptList.find(v => v.deptName === deptName);
  140. if (dept) {
  141. this.form.deptId = dept.deptId;
  142. } else {
  143. uni.$u.toast(deptName + "找不到对应的机构");
  144. }
  145. }
  146. if(clueOperationName){
  147. // 没有现成的数据 请求接口
  148. const { data } = await uni.$u.api.getIdByName({ clueOperationName : clueOperationName});
  149. const { clueOperationId } = data;
  150. this.form.clueOperationId = clueOperationId;
  151. }
  152. },
  153. // 获取选择的地区
  154. handleGetRegion(region) {
  155. const {
  156. 0: provinceData,
  157. 1: cityData,
  158. 2: areaData
  159. } = region;
  160. this.form.manualProvince = provinceData.name;
  161. this.form.manualCity = cityData.name;
  162. this.form.manualArea = areaData.name;
  163. this.form.manualAddressCode = provinceData.name + cityData.name + areaData.name;
  164. },
  165. handleShowclueDept() {
  166. this.$refs.dept._show();
  167. },
  168. handleShowclueAppName() {
  169. this.$refs.appName._show();
  170. },
  171. handleShowclueOperation() {
  172. this.$refs.clueOperation._show();
  173. },
  174. handleShowclueOwner() {
  175. this.$refs.clueOwner._show();
  176. },
  177. appNameSeletchang(ids, names) {
  178. this.form.appName = ids[0];
  179. this.form.appNameLabel = names[0];
  180. },
  181. clueOperationSeletchang(ids, names) {
  182. this.form.clueOperationId = ids[0];
  183. this.form.clueOperationName = names[0];
  184. },
  185. clueOwnerSeletchang(ids, names) {
  186. this.form.clueOwnerId = ids[0];
  187. this.form.clueOwnerName = names[0];
  188. },
  189. deptSeletchang(ids, names) {
  190. this.form.deptId = ids[0];
  191. this.form.deptName = names[0];
  192. },
  193. // 返回
  194. handleClose() {
  195. this.$refs.form.resetFields();
  196. this.form.manualProvince = undefined;
  197. this.form.manualCity = undefined;
  198. this.form.manualArea = undefined;
  199. this.form.manualAddressCode = undefined;
  200. },
  201. // 保存
  202. handleNavSaveClick() {
  203. this.$refs.form.validate().then(async () => {
  204. await uni.$u.api.addClueMainInfo(this.form);
  205. uni.$u.toast("保存成功");
  206. this.handleClose();
  207. })
  208. },
  209. async handleOption() {
  210. // 获取人员
  211. uni.$u.api.getDeptCustomerByOrg().then(res => {
  212. this.listData = filterCustomerManager(res.data);
  213. });
  214. uni.$u.api.getDictCascadeData().then(({
  215. data
  216. }) => {
  217. this.originalDictCascadeData = data;
  218. this.dictCascadeData = handleTree(data, 'id');
  219. });
  220. uni.$u.api.selectAllDeptList({
  221. isDept: 2
  222. }).then(({
  223. data
  224. }) => {
  225. this.originaDeptList = data;
  226. this.deptList = handleTree(data, 'deptId');
  227. });
  228. this.$getDicts('sys_user_sex').then(res => {
  229. this.genderTypeCodeDict = res;
  230. });
  231. },
  232. },
  233. onLoad(option) {
  234. this.handleOption();
  235. }
  236. }