index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  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>
  109. </view>
  110. <ba-tree-picker :selectParent="false" v-if="clueOwnerListData.length > 0" ref="clueOwner" :multiple='false'
  111. @select-change="clueOwnerSeletchang" border title="归属人" :localdata="clueOwnerListData" valueKey="id" textKey="label"
  112. childrenKey="children" :selectedValues="form.clueOwnerId" :personNames="form.clueOwnerName" />
  113. <ba-tree-picker :selectParent="false" v-if="clueOperationListData.length > 0" ref="clueOperation" :multiple='false'
  114. @select-change="clueOperationSeletchang" border title="运营人" :localdata="clueOperationListData" valueKey="id" textKey="label"
  115. childrenKey="children" :selectedValues="form.clueOperationId" :personNames="form.clueOperationName" />
  116. <ba-tree-picker :selectParent="true" v-if="dictCascadeData.length > 0" ref="appName" :multiple='false'
  117. @select-change="appNameSeletchang" border title="来源" :localdata="dictCascadeData" valueKey="id" textKey="name"
  118. childrenKey="children" :selectedValues="form.appName" :personNames="form.appNameLabel" />
  119. <ba-tree-picker :selectParent="true" v-if="deptList.length > 0" ref="dept" :multiple='false'
  120. @select-change="deptSeletchang" border title="归属机构" :localdata="deptList" valueKey="deptId" textKey="deptName"
  121. childrenKey="children" :selectedValues="form.deptId" :personNames="form.deptName" />
  122. </view>
  123. </template>
  124. <script>
  125. const columnProps = [
  126. {
  127. prop : "name",
  128. label : "姓名",
  129. },
  130. {
  131. prop : "telephone",
  132. label : "电话",
  133. },
  134. {
  135. prop : "clueOperationName",
  136. label : "运营",
  137. },
  138. {
  139. prop : "appName",
  140. label : "来源",
  141. },
  142. {
  143. prop : "deptName",
  144. label : "归属",
  145. },
  146. {
  147. prop : "clueBizType",
  148. label : "业务类别",
  149. },
  150. {
  151. prop : "clueObjType",
  152. label : "物品类别",
  153. },
  154. {
  155. prop : "clueAdType",
  156. label : "线索类别",
  157. }
  158. ];
  159. import ldSelect from '@/components/ld-select/ld-select.vue'
  160. import {
  161. filterCustomerManager,
  162. handleTree,
  163. isChinese
  164. } from '@/utils/util';
  165. export default {
  166. data() {
  167. return {
  168. recognitionContent: "",
  169. defaultRegion: ['广东省', '广州市', '番禺区'],
  170. clueOwnerListData: [],
  171. clueOperationListData : [],
  172. deptList: [],
  173. dictCascadeData: [],
  174. genderTypeCodeDict: [],
  175. clueBizTypeDict: [],
  176. clueObjTypeDict: [],
  177. clueAdTypeDict: [],
  178. originalDictCascadeData : [],
  179. originaDeptList : [],
  180. title: "新建线索",
  181. rules: {
  182. name: {
  183. type: 'string',
  184. required: true,
  185. message: '请输入姓名',
  186. trigger: ['blur', 'change']
  187. },
  188. telephone: {
  189. type: 'string',
  190. required: true,
  191. message: '请输入电话',
  192. trigger: ['blur', 'change']
  193. },
  194. clueOperationName: {
  195. type: 'string',
  196. required: true,
  197. message: '请选择运营人',
  198. trigger: ['blur', 'change']
  199. },
  200. appName: {
  201. type: 'string',
  202. required: true,
  203. message: '请选择来源',
  204. trigger: ['blur', 'change']
  205. },
  206. deptName: {
  207. type: 'string',
  208. required: true,
  209. message: '请选择归属机构',
  210. trigger: ['blur', 'change']
  211. },
  212. },
  213. form: {
  214. manualAddressCode: '',
  215. manualProvince: '',
  216. manualCity: '',
  217. manualArea: '',
  218. name: '',
  219. telephone: '',
  220. genderTypeCode: '',
  221. age: '',
  222. weixin: '',
  223. address: '',
  224. remark: '',
  225. qq: '',
  226. email: '',
  227. adId: '',
  228. appName: undefined,
  229. appNameLabel: undefined,
  230. province: undefined,
  231. city: undefined,
  232. area: undefined,
  233. clueOperationId: undefined,
  234. clueOperationName: undefined,
  235. clueOwnerId: undefined,
  236. clueOwnerName: undefined,
  237. deptName: undefined,
  238. deptId: undefined,
  239. clueBizType: '回收',
  240. clueObjType: '腕表',
  241. clueAdType: '常规',
  242. }
  243. }
  244. },
  245. methods: {
  246. async handleRecognition() {
  247. if(!this.recognitionContent){
  248. return;
  249. }
  250. try{
  251. // 电话:15099998888
  252. // 姓名:卡地亚萧邦
  253. // 来源:广点通
  254. // 运营:yxx
  255. // 归属:集团总部
  256. const splitStr = ":";
  257. // 避免用错符号,直接转换一下
  258. const lines = this.recognitionContent.replace(/:/g, splitStr).split('\n');
  259. lines.forEach(line => {
  260. const [key, value] = line.split(splitStr);
  261. const column = columnProps.find(v => key.trim() === v.label);
  262. if (column) {
  263. const {
  264. prop
  265. } = column;
  266. this.form[prop] = value?.trim();
  267. }
  268. });
  269. // 来源 归属机构 运营人 需要找id
  270. const {
  271. appName,
  272. deptName,
  273. clueOperationName
  274. } = this.form;
  275. if (appName) {
  276. let dictList = this.originalDictCascadeData;
  277. let appNameDict = dictList.find(v => v.name === appName);
  278. if (appNameDict) {
  279. this.form.appName = appNameDict.id;
  280. this.form.appNameLabel = appNameDict.name;
  281. } else {
  282. uni.$u.toast(appName + "当前来源未配置,请重新选择");
  283. }
  284. }
  285. if (deptName) {
  286. let deptList = this.originaDeptList;
  287. let dept = deptList.find(v => v.deptName === deptName);
  288. if (dept) {
  289. this.form.deptId = dept.deptId;
  290. } else {
  291. uni.$u.toast(deptName + "找不到对应的机构");
  292. }
  293. }
  294. if(clueOperationName){
  295. // 没有现成的数据 请求接口
  296. const { data } = await uni.$u.api.getIdByName({ clueOperationName : clueOperationName});
  297. const { clueOperationId } = data;
  298. this.form.clueOperationId = clueOperationId;
  299. }
  300. }catch(e){
  301. uni.$u.toast("文本识别异常");
  302. }
  303. },
  304. // 获取选择的地区
  305. handleGetRegion(region) {
  306. const {
  307. 0: provinceData,
  308. 1: cityData,
  309. 2: areaData
  310. } = region;
  311. this.form.manualProvince = provinceData.name;
  312. this.form.manualCity = cityData.name;
  313. this.form.manualArea = areaData.name;
  314. this.form.manualAddressCode = provinceData.name + cityData.name + areaData.name;
  315. },
  316. handleShowclueDept() {
  317. this.$refs.dept._show();
  318. },
  319. handleShowclueAppName() {
  320. this.$refs.appName._show();
  321. },
  322. handleShowclueOperation() {
  323. this.$refs.clueOperation._show();
  324. },
  325. handleShowclueOwner() {
  326. this.$refs.clueOwner._show();
  327. },
  328. appNameSeletchang(ids, names) {
  329. this.form.appName = ids[0];
  330. this.form.appNameLabel = names[0];
  331. },
  332. clueOperationSeletchang(ids, names) {
  333. this.form.clueOperationId = ids[0];
  334. this.form.clueOperationName = names[0];
  335. },
  336. clueOwnerSeletchang(ids, names) {
  337. this.form.clueOwnerId = ids[0];
  338. this.form.clueOwnerName = names[0];
  339. },
  340. deptSeletchang(ids, names) {
  341. this.form.deptId = ids[0];
  342. this.form.deptName = names[0];
  343. },
  344. // 返回
  345. handleClose() {
  346. this.$refs.form.resetFields();
  347. this.form.manualProvince = undefined;
  348. this.form.manualCity = undefined;
  349. this.form.manualArea = undefined;
  350. this.form.manualAddressCode = undefined;
  351. this.recognitionContent = undefined;
  352. },
  353. // 保存
  354. handleNavSaveClick() {
  355. this.$refs.form.validate().then(async () => {
  356. await uni.$u.api.addClueMainInfo(this.form);
  357. uni.$u.toast("保存成功");
  358. this.handleClose();
  359. })
  360. },
  361. async handleOption() {
  362. // 获取人员
  363. uni.$u.api.getDeptOwner({ excludeDeptIds : [100,369,378,356] }).then(res => {
  364. this.clueOwnerListData = filterCustomerManager(res.data);
  365. });
  366. // 获取人员
  367. uni.$u.api.getDeptCustomerByOrg({ deptId : 369 }).then(res => {
  368. this.clueOperationListData = filterCustomerManager(res.data);
  369. });
  370. uni.$u.api.getDictCascadeData().then(({
  371. data
  372. }) => {
  373. this.originalDictCascadeData = data;
  374. this.dictCascadeData = handleTree(data, 'id');
  375. });
  376. uni.$u.api.selectAllDeptList({
  377. isDept: 2
  378. }).then(({
  379. data
  380. }) => {
  381. this.originaDeptList = data;
  382. this.deptList = handleTree(data, 'deptId');
  383. });
  384. this.$getDicts('sys_user_sex').then(res => {
  385. this.genderTypeCodeDict = res;
  386. });
  387. this.$getDicts('crm_clue_biz').then(res => {
  388. this.clueBizTypeDict = res;
  389. });
  390. this.$getDicts('crm_clue_obj').then(res => {
  391. this.clueObjTypeDict = res;
  392. });
  393. this.$getDicts('crm_clue_type').then(res => {
  394. this.clueAdTypeDict = res;
  395. });
  396. },
  397. },
  398. onLoad(option) {
  399. this.handleOption();
  400. }
  401. }
  402. </script>
  403. <style lang="scss">
  404. @import "@/static/follow/index.scss";
  405. </style>