index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  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="age" borderBottom>
  59. <u--input v-model.number="form.age" disabledColor="#ffffff" border="none" placeholder="请输入年龄"></u--input>
  60. </u-form-item>
  61. <u-form-item label="微信" prop="weixin" borderBottom>
  62. <u--input v-model="form.weixin" disabledColor="#ffffff" border="none" placeholder="请输入微信"></u--input>
  63. </u-form-item>
  64. <u-form-item label="详情地址" prop="address" borderBottom>
  65. <u--textarea v-model="form.address" placeholder="请输入详情地址" count confirmType="done">
  66. </u--textarea>
  67. </u-form-item>
  68. <u-form-item label="备注" prop="remark" borderBottom>
  69. <u--textarea v-model="form.remark" placeholder="请输入备注" count confirmType="done">
  70. </u--textarea>
  71. </u-form-item>
  72. <u-form-item label="QQ号" prop="qq" borderBottom>
  73. <u--input v-model="form.qq" disabledColor="#ffffff" border="none" placeholder="请输入QQ号"></u--input>
  74. </u-form-item>
  75. <u-form-item label="邮箱" prop="email" borderBottom>
  76. <u--input v-model="form.email" disabledColor="#ffffff" border="none" placeholder="请输入邮箱"></u--input>
  77. </u-form-item>
  78. <u-form-item label="手动填写地域" prop="email" borderBottom>
  79. <pick-regions :defaultRegion="defaultRegion" @getRegion="handleGetRegion">
  80. <view class="province">
  81. <template v-if="form.manualProvince">
  82. <u--input :value="form.manualProvince + '/' + form.manualCity + '/' + form.manualArea" placeholder="点击选择" readonly suffixIcon="arrow-right" suffixIconStyle="color : #c0c4cc"></u--input>
  83. </template>
  84. <template v-else>
  85. <u--input placeholder="点击选择" readonly suffixIcon="arrow-right" suffixIconStyle="color : #c0c4cc"></u--input>
  86. </template>
  87. </view>
  88. </pick-regions>
  89. </u-form-item>
  90. <u-form-item label="广告计划ID" prop="adId" borderBottom>
  91. <u--input v-model="form.adId" disabledColor="#ffffff" border="none" placeholder="请输入广告计划ID"></u--input>
  92. </u-form-item>
  93. </u--form>
  94. </view>
  95. <ba-tree-picker :selectParent="false" v-if="clueOwnerListData.length > 0" ref="clueOwner" :multiple='false'
  96. @select-change="clueOwnerSeletchang" border title="归属人" :localdata="clueOwnerListData" valueKey="id" textKey="label"
  97. childrenKey="children" :selectedValues="form.clueOwnerId" :personNames="form.clueOwnerName" />
  98. <ba-tree-picker :selectParent="false" v-if="clueOperationListData.length > 0" ref="clueOperation" :multiple='false'
  99. @select-change="clueOperationSeletchang" border title="运营人" :localdata="clueOperationListData" valueKey="id" textKey="label"
  100. childrenKey="children" :selectedValues="form.clueOperationId" :personNames="form.clueOperationName" />
  101. <ba-tree-picker :selectParent="true" v-if="dictCascadeData.length > 0" ref="appName" :multiple='false'
  102. @select-change="appNameSeletchang" border title="来源" :localdata="dictCascadeData" valueKey="id" textKey="name"
  103. childrenKey="children" :selectedValues="form.appName" :personNames="form.appNameLabel" />
  104. <ba-tree-picker :selectParent="true" v-if="deptList.length > 0" ref="dept" :multiple='false'
  105. @select-change="deptSeletchang" border title="归属机构" :localdata="deptList" valueKey="deptId" textKey="deptName"
  106. childrenKey="children" :selectedValues="form.deptId" :personNames="form.deptName" />
  107. </view>
  108. </template>
  109. <script>
  110. const columnProps = [
  111. {
  112. prop : "name",
  113. label : "姓名",
  114. },
  115. {
  116. prop : "telephone",
  117. label : "电话",
  118. },
  119. {
  120. prop : "clueOperationName",
  121. label : "运营",
  122. },
  123. {
  124. prop : "appName",
  125. label : "来源",
  126. },
  127. {
  128. prop : "deptName",
  129. label : "归属",
  130. }
  131. ];
  132. import ldSelect from '@/components/ld-select/ld-select.vue'
  133. import {
  134. filterCustomerManager,
  135. handleTree,
  136. isChinese
  137. } from '@/utils/util';
  138. export default {
  139. data() {
  140. return {
  141. recognitionContent: "",
  142. defaultRegion: ['广东省', '广州市', '番禺区'],
  143. clueOwnerListData: [],
  144. clueOperationListData : [],
  145. deptList: [],
  146. dictCascadeData: [],
  147. genderTypeCodeDict: [],
  148. originalDictCascadeData : [],
  149. originaDeptList : [],
  150. title: "新建线索",
  151. rules: {
  152. name: {
  153. type: 'string',
  154. required: true,
  155. message: '请输入姓名',
  156. trigger: ['blur', 'change']
  157. },
  158. telephone: {
  159. type: 'string',
  160. required: true,
  161. message: '请输入电话',
  162. trigger: ['blur', 'change']
  163. },
  164. clueOperationName: {
  165. type: 'string',
  166. required: true,
  167. message: '请选择运营人',
  168. trigger: ['blur', 'change']
  169. },
  170. appName: {
  171. type: 'string',
  172. required: true,
  173. message: '请选择来源',
  174. trigger: ['blur', 'change']
  175. },
  176. deptName: {
  177. type: 'string',
  178. required: true,
  179. message: '请选择归属机构',
  180. trigger: ['blur', 'change']
  181. },
  182. },
  183. form: {
  184. manualAddressCode: '',
  185. manualProvince: '',
  186. manualCity: '',
  187. manualArea: '',
  188. name: '',
  189. telephone: '',
  190. genderTypeCode: '',
  191. age: '',
  192. weixin: '',
  193. address: '',
  194. remark: '',
  195. qq: '',
  196. email: '',
  197. adId: '',
  198. appName: undefined,
  199. appNameLabel: undefined,
  200. province: undefined,
  201. city: undefined,
  202. area: undefined,
  203. clueOperationId: undefined,
  204. clueOperationName: undefined,
  205. clueOwnerId: undefined,
  206. clueOwnerName: undefined,
  207. deptName: undefined,
  208. deptId: undefined,
  209. }
  210. }
  211. },
  212. methods: {
  213. async handleRecognition() {
  214. if(!this.recognitionContent){
  215. return;
  216. }
  217. try{
  218. // 电话:15099998888
  219. // 姓名:卡地亚萧邦
  220. // 来源:广点通
  221. // 运营:yxx
  222. // 归属:集团总部
  223. const splitStr = ":";
  224. // 避免用错符号,直接转换一下
  225. const lines = this.recognitionContent.replace(/:/g, splitStr).split('\n');
  226. lines.forEach(line => {
  227. const [key, value] = line.split(splitStr);
  228. const column = columnProps.find(v => key.trim() === v.label);
  229. if (column) {
  230. const {
  231. prop
  232. } = column;
  233. this.form[prop] = value?.trim();
  234. }
  235. });
  236. // 来源 归属机构 运营人 需要找id
  237. const {
  238. appName,
  239. deptName,
  240. clueOperationName
  241. } = this.form;
  242. if (appName) {
  243. let dictList = this.originalDictCascadeData;
  244. let appNameDict = dictList.find(v => v.name === appName);
  245. if (appNameDict) {
  246. this.form.appName = appNameDict.id;
  247. this.form.appNameLabel = appNameDict.name;
  248. } else {
  249. uni.$u.toast(appName + "当前来源未配置,请重新选择");
  250. }
  251. }
  252. if (deptName) {
  253. let deptList = this.originaDeptList;
  254. let dept = deptList.find(v => v.deptName === deptName);
  255. if (dept) {
  256. this.form.deptId = dept.deptId;
  257. } else {
  258. uni.$u.toast(deptName + "找不到对应的机构");
  259. }
  260. }
  261. if(clueOperationName){
  262. // 没有现成的数据 请求接口
  263. const { data } = await uni.$u.api.getIdByName({ clueOperationName : clueOperationName});
  264. const { clueOperationId } = data;
  265. this.form.clueOperationId = clueOperationId;
  266. }
  267. }catch(e){
  268. uni.$u.toast("文本识别异常");
  269. }
  270. },
  271. // 获取选择的地区
  272. handleGetRegion(region) {
  273. const {
  274. 0: provinceData,
  275. 1: cityData,
  276. 2: areaData
  277. } = region;
  278. this.form.manualProvince = provinceData.name;
  279. this.form.manualCity = cityData.name;
  280. this.form.manualArea = areaData.name;
  281. this.form.manualAddressCode = provinceData.name + cityData.name + areaData.name;
  282. },
  283. handleShowclueDept() {
  284. this.$refs.dept._show();
  285. },
  286. handleShowclueAppName() {
  287. this.$refs.appName._show();
  288. },
  289. handleShowclueOperation() {
  290. this.$refs.clueOperation._show();
  291. },
  292. handleShowclueOwner() {
  293. this.$refs.clueOwner._show();
  294. },
  295. appNameSeletchang(ids, names) {
  296. this.form.appName = ids[0];
  297. this.form.appNameLabel = names[0];
  298. },
  299. clueOperationSeletchang(ids, names) {
  300. this.form.clueOperationId = ids[0];
  301. this.form.clueOperationName = names[0];
  302. },
  303. clueOwnerSeletchang(ids, names) {
  304. this.form.clueOwnerId = ids[0];
  305. this.form.clueOwnerName = names[0];
  306. },
  307. deptSeletchang(ids, names) {
  308. this.form.deptId = ids[0];
  309. this.form.deptName = names[0];
  310. },
  311. // 返回
  312. handleClose() {
  313. this.$refs.form.resetFields();
  314. this.form.manualProvince = undefined;
  315. this.form.manualCity = undefined;
  316. this.form.manualArea = undefined;
  317. this.form.manualAddressCode = undefined;
  318. this.recognitionContent = undefined;
  319. },
  320. // 保存
  321. handleNavSaveClick() {
  322. this.$refs.form.validate().then(async () => {
  323. await uni.$u.api.addClueMainInfo(this.form);
  324. uni.$u.toast("保存成功");
  325. this.handleClose();
  326. })
  327. },
  328. async handleOption() {
  329. // 获取人员
  330. uni.$u.api.getDeptOwner({ excludeDeptIds : [100,369,378,356] }).then(res => {
  331. this.clueOwnerListData = filterCustomerManager(res.data);
  332. });
  333. // 获取人员
  334. uni.$u.api.getDeptCustomerByOrg({ deptId : 369 }).then(res => {
  335. this.clueOperationListData = filterCustomerManager(res.data);
  336. });
  337. uni.$u.api.getDictCascadeData().then(({
  338. data
  339. }) => {
  340. this.originalDictCascadeData = data;
  341. this.dictCascadeData = handleTree(data, 'id');
  342. });
  343. uni.$u.api.selectAllDeptList({
  344. isDept: 2
  345. }).then(({
  346. data
  347. }) => {
  348. this.originaDeptList = data;
  349. this.deptList = handleTree(data, 'deptId');
  350. });
  351. this.$getDicts('sys_user_sex').then(res => {
  352. this.genderTypeCodeDict = res;
  353. });
  354. },
  355. },
  356. onLoad(option) {
  357. this.handleOption();
  358. }
  359. }
  360. </script>
  361. <style lang="scss">
  362. @import "@/static/follow/index.scss";
  363. </style>