index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  1. <template>
  2. <view class="follow_wrap">
  3. <u-navbar placeholder :autoBack="true" :title="title" @rightClick="handleNavSaveClick">
  4. <!-- <view class="u-nav-slot left_btn" slot="left">
  5. <text class="close_btn" @click="handleClose">重置</text>
  6. </view> -->
  7. <view class="u-nav-slot" slot="right">
  8. 保存
  9. </view>
  10. </u-navbar>
  11. <view class="follow_form_wrap">
  12. <u--form labelPosition="left" labelWidth="100" :model="form" :rules="rules" ref="form" class="form_wrap"
  13. :errorType="'toast'">
  14. <u-form-item label="粘贴识别" borderBottom>
  15. <u--textarea v-model="recognitionContent" placeholder='电话:15099998888
  16. 姓名:卡地亚萧邦
  17. 来源:广点通
  18. 运营:小小
  19. 归属:南京麒麟分公司
  20. 快速录入页面增加运营字段识别' confirmType="done" height="120" :maxlength="-1" @blur='handleRecognition'>
  21. </u--textarea>
  22. </u-form-item>
  23. <u-form-item label="姓名" prop="name" borderBottom class="form_required">
  24. <u--input v-model="form.name" disabledColor="#ffffff" border="none" placeholder="请输入姓名"></u--input>
  25. </u-form-item>
  26. <u-form-item label="电话" prop="telephone" borderBottom class="form_required">
  27. <u--input v-model="form.telephone" disabledColor="#ffffff" border="none" placeholder="请输入电话"></u--input>
  28. </u-form-item>
  29. <u-form-item label="运营人" prop="clueOperationName" borderBottom @click="handleShowclueOperation" class="form_required">
  30. <u--input v-model="form.clueOperationName" disabled style='pointer-events: none !important'
  31. disabledColor="#ffffff" placeholder="点击选择" border="none">
  32. </u--input>
  33. <u-icon slot="right" name="arrow-right"></u-icon>
  34. </u-form-item>
  35. <u-form-item label='来源' prop='appNameLabel' class="form_required" @click="handleShowclueAppName" borderBottom>
  36. <u--input v-model="form.appNameLabel" disabled style='pointer-events: none !important'
  37. disabledColor="#ffffff" placeholder="点击选择" border="none">
  38. </u--input>
  39. <u-icon slot="right" name="arrow-right"></u-icon>
  40. </u-form-item>
  41. <u-form-item label='归属机构' prop='deptName' class="form_required" @click="handleShowclueDept" borderBottom>
  42. <u--input v-model="form.deptName" disabled style='pointer-events: none !important'
  43. disabledColor="#ffffff" placeholder="点击选择" border="none">
  44. </u--input>
  45. <u-icon slot="right" name="arrow-right"></u-icon>
  46. </u-form-item>
  47. <u-form-item label="归属人" prop="clueOwnerName" borderBottom @click="handleShowclueOwner" borderBottom>
  48. <u--input v-model="form.clueOwnerName" disabled style='pointer-events: none !important'
  49. disabledColor="#ffffff" placeholder="点击选择" border="none">
  50. </u--input>
  51. <u-icon slot="right" name="arrow-right"></u-icon>
  52. </u-form-item>
  53. <u-form-item label="性别" prop="genderTypeCode" borderBottom>
  54. <ld-select :list="genderTypeCodeDict" label-key="dictLabel" value-key="dictValue" placeholder="请选择性别"
  55. v-model="form.genderTypeCode" :border="false"></ld-select>
  56. <u-icon slot="right" name="arrow-right"></u-icon>
  57. </u-form-item>
  58. <u-form-item label="业务类别" prop="clueBizType" borderBottom>
  59. <ld-select :list="clueBizTypeDict" label-key="dictLabel" value-key="dictValue" placeholder="请选择业务类别"
  60. v-model="form.clueBizType" :border="false"></ld-select>
  61. <u-icon slot="right" name="arrow-right"></u-icon>
  62. </u-form-item>
  63. <u-form-item label="物品类别" prop="clueObjType" borderBottom>
  64. <ld-select :list="clueObjTypeDict" label-key="dictLabel" value-key="dictValue" placeholder="请选择物品类别"
  65. v-model="form.clueObjType" :border="false"></ld-select>
  66. <u-icon slot="right" name="arrow-right"></u-icon>
  67. </u-form-item>
  68. <u-form-item label="线索类别" prop="clueAdType" borderBottom>
  69. <ld-select :list="clueAdTypeDict" label-key="dictLabel" value-key="dictValue" placeholder="请选择线索类别"
  70. v-model="form.clueAdType" :border="false"></ld-select>
  71. <u-icon slot="right" name="arrow-right"></u-icon>
  72. </u-form-item>
  73. <u-form-item label="年龄" prop="age" borderBottom>
  74. <u--input v-model.number="form.age" disabledColor="#ffffff" border="none" placeholder="请输入年龄"></u--input>
  75. </u-form-item>
  76. <u-form-item label="微信" prop="weixin" borderBottom>
  77. <u--input v-model="form.weixin" disabledColor="#ffffff" border="none" placeholder="请输入微信"></u--input>
  78. </u-form-item>
  79. <u-form-item label="详情地址" prop="address" borderBottom>
  80. <u--textarea v-model="form.address" placeholder="请输入详情地址" count confirmType="done">
  81. </u--textarea>
  82. </u-form-item>
  83. <u-form-item label="备注" prop="remark" borderBottom>
  84. <u--textarea v-model="form.remark" placeholder="请输入备注" count confirmType="done">
  85. </u--textarea>
  86. </u-form-item>
  87. <u-form-item label="QQ号" prop="qq" borderBottom>
  88. <u--input v-model="form.qq" disabledColor="#ffffff" border="none" placeholder="请输入QQ号"></u--input>
  89. </u-form-item>
  90. <u-form-item label="邮箱" prop="email" borderBottom>
  91. <u--input v-model="form.email" disabledColor="#ffffff" border="none" placeholder="请输入邮箱"></u--input>
  92. </u-form-item>
  93. <u-form-item label="手动填写地域" prop="email" borderBottom>
  94. <pick-regions :defaultRegion="defaultRegion" @getRegion="handleGetRegion">
  95. <view class="province">
  96. <template v-if="form.manualProvince">
  97. <u--input :value="form.manualProvince + '/' + form.manualCity + '/' + form.manualArea" placeholder="点击选择" readonly suffixIcon="arrow-right" suffixIconStyle="color : #c0c4cc"></u--input>
  98. </template>
  99. <template v-else>
  100. <u--input placeholder="点击选择" readonly suffixIcon="arrow-right" suffixIconStyle="color : #c0c4cc"></u--input>
  101. </template>
  102. </view>
  103. </pick-regions>
  104. </u-form-item>
  105. <u-form-item label="广告计划ID" prop="adId" borderBottom>
  106. <u--input v-model="form.adId" disabledColor="#ffffff" border="none" placeholder="请输入广告计划ID"></u--input>
  107. </u-form-item>
  108. <u-form-item label="广告计划名称" prop="adName" borderBottom>
  109. <u--input v-model="form.adName" disabledColor="#ffffff" border="none" placeholder="请输入广告计划名称"></u--input>
  110. </u-form-item>
  111. <u-form-item label="广告主ID" prop="advId" borderBottom>
  112. <u--input v-model="form.advId" disabledColor="#ffffff" border="none" placeholder="请输入广告主ID"></u--input>
  113. </u-form-item>
  114. <u-form-item label="广告主名称" prop="advName" borderBottom>
  115. <u--input v-model="form.advName" disabledColor="#ffffff" border="none" placeholder="请输入广告主名称"></u--input>
  116. </u-form-item>
  117. </u--form>
  118. </view>
  119. <ba-tree-picker :selectParent="false" v-if="clueOwnerListData.length > 0" ref="clueOwner" :multiple='false'
  120. @select-change="clueOwnerSeletchang" border title="归属人" :localdata="clueOwnerListData" valueKey="id" textKey="label"
  121. childrenKey="children" :selectedValues="form.clueOwnerId" :personNames="form.clueOwnerName" />
  122. <ba-tree-picker :selectParent="false" v-if="clueOperationListData.length > 0" ref="clueOperation" :multiple='false'
  123. @select-change="clueOperationSeletchang" border title="运营人" :localdata="clueOperationListData" valueKey="id" textKey="label"
  124. childrenKey="children" :selectedValues="form.clueOperationId" :personNames="form.clueOperationName" />
  125. <ba-tree-picker :selectParent="true" v-if="dictCascadeData.length > 0" ref="appName" :multiple='false'
  126. @select-change="appNameSeletchang" border title="来源" :localdata="dictCascadeData" valueKey="id" textKey="name"
  127. childrenKey="children" :selectedValues="form.appName" :personNames="form.appNameLabel" />
  128. <ba-tree-picker :selectParent="true" v-if="deptList.length > 0" ref="dept" :multiple='false'
  129. @select-change="deptSeletchang" border title="归属机构" :localdata="deptList" valueKey="deptId" textKey="deptName"
  130. childrenKey="children" :selectedValues="form.deptId" :personNames="form.deptName" />
  131. </view>
  132. </template>
  133. <script>
  134. const columnProps = [
  135. {
  136. prop : "name",
  137. label : "姓名",
  138. },
  139. {
  140. prop : "telephone",
  141. label : "电话",
  142. },
  143. {
  144. prop : "clueOperationName",
  145. label : "运营",
  146. },
  147. {
  148. prop : "appName",
  149. label : "来源",
  150. },
  151. {
  152. prop : "deptName",
  153. label : "归属",
  154. },
  155. {
  156. prop : "clueBizType",
  157. label : "业务类别",
  158. },
  159. {
  160. prop : "clueObjType",
  161. label : "物品类别",
  162. },
  163. {
  164. prop : "clueAdType",
  165. label : "线索类别",
  166. }
  167. ];
  168. import ldSelect from '@/components/ld-select/ld-select.vue'
  169. import {
  170. filterCustomerManager,
  171. handleTree,
  172. isChinese
  173. } from '@/utils/util';
  174. export default {
  175. data() {
  176. return {
  177. recognitionContent: "",
  178. defaultRegion: ['广东省', '广州市', '番禺区'],
  179. clueOwnerListData: [],
  180. clueOperationListData : [],
  181. deptList: [],
  182. dictCascadeData: [],
  183. genderTypeCodeDict: [],
  184. clueBizTypeDict: [],
  185. clueObjTypeDict: [],
  186. clueAdTypeDict: [],
  187. originalDictCascadeData : [],
  188. originaDeptList : [],
  189. title: "新建线索",
  190. rules: {
  191. name: {
  192. type: 'string',
  193. required: true,
  194. message: '请输入姓名',
  195. trigger: ['blur', 'change']
  196. },
  197. telephone: {
  198. type: 'string',
  199. required: true,
  200. message: '请输入电话',
  201. trigger: ['blur', 'change']
  202. },
  203. clueOperationName: {
  204. type: 'string',
  205. required: true,
  206. message: '请选择运营人',
  207. trigger: ['blur', 'change']
  208. },
  209. appName: {
  210. type: 'string',
  211. required: true,
  212. message: '请选择来源',
  213. trigger: ['blur', 'change']
  214. },
  215. deptName: {
  216. type: 'string',
  217. required: true,
  218. message: '请选择归属机构',
  219. trigger: ['blur', 'change']
  220. },
  221. },
  222. form: {
  223. manualAddressCode: '',
  224. manualProvince: '',
  225. manualCity: '',
  226. manualArea: '',
  227. name: '',
  228. telephone: '',
  229. genderTypeCode: '',
  230. age: '',
  231. weixin: '',
  232. address: '',
  233. remark: '',
  234. qq: '',
  235. email: '',
  236. adId: '',
  237. appName: undefined,
  238. appNameLabel: undefined,
  239. province: undefined,
  240. city: undefined,
  241. area: undefined,
  242. clueOperationId: undefined,
  243. clueOperationName: undefined,
  244. clueOwnerId: undefined,
  245. clueOwnerName: undefined,
  246. deptName: undefined,
  247. deptId: undefined,
  248. advName : undefined,
  249. advId : undefined,
  250. adName : undefined,
  251. clueBizType: '回收',
  252. clueObjType: '腕表',
  253. clueAdType: '常规',
  254. }
  255. }
  256. },
  257. methods: {
  258. async handleRecognition() {
  259. if(!this.recognitionContent){
  260. return;
  261. }
  262. try{
  263. // 电话:15099998888
  264. // 姓名:卡地亚萧邦
  265. // 来源:广点通
  266. // 运营:yxx
  267. // 归属:集团总部
  268. const splitStr = ":";
  269. // 避免用错符号,直接转换一下
  270. const lines = this.recognitionContent.replace(/:/g, splitStr).split('\n');
  271. lines.forEach(line => {
  272. const [key, value] = line.split(splitStr);
  273. const column = columnProps.find(v => key.trim() === v.label);
  274. if (column) {
  275. const {
  276. prop
  277. } = column;
  278. this.form[prop] = value?.trim();
  279. }
  280. });
  281. // 来源 归属机构 运营人 需要找id
  282. const {
  283. appName,
  284. deptName,
  285. clueOperationName
  286. } = this.form;
  287. if (appName) {
  288. let dictList = this.originalDictCascadeData;
  289. let appNameDict = dictList.find(v => v.name === appName);
  290. if (appNameDict) {
  291. this.form.appName = appNameDict.id;
  292. this.form.appNameLabel = appNameDict.name;
  293. } else {
  294. uni.$u.toast(appName + "当前来源未配置,请重新选择");
  295. }
  296. }
  297. if (deptName) {
  298. let deptList = this.originaDeptList;
  299. let dept = deptList.find(v => v.deptName === deptName);
  300. if (dept) {
  301. this.form.deptId = dept.deptId;
  302. } else {
  303. uni.$u.toast(deptName + "找不到对应的机构");
  304. }
  305. }
  306. if(clueOperationName){
  307. // 没有现成的数据 请求接口
  308. const { data } = await uni.$u.api.getIdByName({ clueOperationName : clueOperationName});
  309. const { clueOperationId } = data;
  310. this.form.clueOperationId = clueOperationId;
  311. }
  312. }catch(e){
  313. uni.$u.toast("文本识别异常");
  314. }
  315. },
  316. // 获取选择的地区
  317. handleGetRegion(region) {
  318. const {
  319. 0: provinceData,
  320. 1: cityData,
  321. 2: areaData
  322. } = region;
  323. this.form.manualProvince = provinceData.name;
  324. this.form.manualCity = cityData.name;
  325. this.form.manualArea = areaData.name;
  326. this.form.manualAddressCode = provinceData.name + cityData.name + areaData.name;
  327. },
  328. handleShowclueDept() {
  329. this.$refs.dept._show();
  330. },
  331. handleShowclueAppName() {
  332. this.$refs.appName._show();
  333. },
  334. handleShowclueOperation() {
  335. this.$refs.clueOperation._show();
  336. },
  337. handleShowclueOwner() {
  338. this.$refs.clueOwner._show();
  339. },
  340. appNameSeletchang(ids, names) {
  341. this.form.appName = ids[0];
  342. this.form.appNameLabel = names[0];
  343. },
  344. clueOperationSeletchang(ids, names) {
  345. this.form.clueOperationId = ids[0];
  346. this.form.clueOperationName = names[0];
  347. },
  348. clueOwnerSeletchang(ids, names) {
  349. this.form.clueOwnerId = ids[0];
  350. this.form.clueOwnerName = names[0];
  351. },
  352. deptSeletchang(ids, names) {
  353. this.form.deptId = ids[0];
  354. this.form.deptName = names[0];
  355. },
  356. // 返回
  357. handleClose() {
  358. this.$refs.form.resetFields();
  359. this.form.manualProvince = undefined;
  360. this.form.manualCity = undefined;
  361. this.form.manualArea = undefined;
  362. this.form.manualAddressCode = undefined;
  363. this.recognitionContent = undefined;
  364. },
  365. // 保存
  366. handleNavSaveClick() {
  367. this.$refs.form.validate().then(async () => {
  368. await uni.$u.api.addClueMainInfo(this.form);
  369. uni.$u.toast("保存成功");
  370. this.handleClose();
  371. })
  372. },
  373. async handleOption() {
  374. // 获取人员
  375. uni.$u.api.getDeptOwner({ excludeDeptIds : [100,369,378,356] }).then(res => {
  376. this.clueOwnerListData = filterCustomerManager(res.data);
  377. });
  378. // 获取人员
  379. uni.$u.api.getDeptCustomerByOrg({ deptId : 369 }).then(res => {
  380. this.clueOperationListData = filterCustomerManager(res.data);
  381. });
  382. uni.$u.api.getDictCascadeData().then(({
  383. data
  384. }) => {
  385. this.originalDictCascadeData = data;
  386. this.dictCascadeData = handleTree(data, 'id');
  387. });
  388. uni.$u.api.selectAllDeptList({
  389. isDept: 2
  390. }).then(({
  391. data
  392. }) => {
  393. this.originaDeptList = data;
  394. this.deptList = handleTree(data, 'deptId');
  395. });
  396. this.$getDicts('sys_user_sex').then(res => {
  397. this.genderTypeCodeDict = res;
  398. });
  399. this.$getDicts('crm_clue_biz').then(res => {
  400. this.clueBizTypeDict = res;
  401. });
  402. this.$getDicts('crm_clue_obj').then(res => {
  403. this.clueObjTypeDict = res;
  404. });
  405. this.$getDicts('crm_clue_type').then(res => {
  406. this.clueAdTypeDict = res;
  407. });
  408. },
  409. },
  410. onLoad(option) {
  411. this.handleOption();
  412. }
  413. }
  414. </script>
  415. <style lang="scss">
  416. @import "@/static/follow/index.scss";
  417. </style>