| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251 |
- import {
- filterCustomerManager,
- handleTree,
- isChinese
- } from '@/utils/util'
- const columnProps = [
- {
- prop : "name",
- label : "姓名",
- },
- {
- prop : "telephone",
- label : "电话",
- },
- {
- prop : "clueOperationName",
- label : "运营",
- },
- {
- prop : "appName",
- label : "来源",
- },
- {
- prop : "deptName",
- label : "归属",
- }
- ]
- export default {
- data() {
- return {
- recognitionContent: "",
- defaultRegion: ['广东省', '广州市', '番禺区'],
- listData: [],
- deptList: [],
- dictCascadeData: [],
- genderTypeCodeDict: [],
- originalDictCascadeData : [],
- originaDeptList : [],
- title: "新建线索",
- rules: {
- name: {
- type: 'string',
- required: true,
- message: '请输入姓名',
- trigger: ['blur', 'change']
- },
- telephone: {
- type: 'string',
- required: true,
- message: '请输入电话',
- trigger: ['blur', 'change']
- },
- clueOperationName: {
- type: 'string',
- required: true,
- message: '请选择运营人',
- trigger: ['blur', 'change']
- },
- appName: {
- type: 'string',
- required: true,
- message: '请选择来源',
- trigger: ['blur', 'change']
- },
- deptName: {
- type: 'string',
- required: true,
- message: '请选择归属机构',
- trigger: ['blur', 'change']
- },
- },
- form: {
- manualAddressCode: '',
- manualProvince: '',
- manualCity: '',
- manualArea: '',
- name: '',
- telephone: '',
- genderTypeCode: '',
- age: '',
- weixin: '',
- address: '',
- remark: '',
- qq: '',
- email: '',
- adId: '',
- appName: undefined,
- appNameLabel: undefined,
- province: undefined,
- city: undefined,
- area: undefined,
- clueOperationId: undefined,
- clueOperationName: undefined,
- clueOwnerId: undefined,
- clueOwnerName: undefined,
- deptName: undefined,
- deptId: undefined,
- }
- }
- },
- methods: {
- async handleRecognition() {
- // 电话:15099998888
- // 姓名:卡地亚萧邦
- // 来源:广点通
- // 运营:yxx
- // 归属:集团总部
- const splitStr = ":";
- // 避免用错符号,直接转换一下
- const lines = this.recognitionContent.replace(/:/g, splitStr).split('\n');
- lines.forEach(line => {
- const [key, value] = line.split(splitStr);
- const column = columnProps.find(v => key.trim() === v.label);
- if (column) {
- const {
- prop
- } = column;
- this.form[prop] = value?.trim();
- }
- });
- // 来源 归属机构 运营人 需要找id
- const {
- appName,
- deptName,
- clueOperationName
- } = this.form;
- if (appName) {
- let dictList = this.originalDictCascadeData;
- let appNameDict = dictList.find(v => v.name === appName);
- if (appNameDict) {
- this.form.appName = appNameDict.id;
- this.form.appNameLabel = appNameDict.name;
- } else {
- uni.$u.toast(appName + "当前来源未配置,请重新选择");
- }
- }
-
- if (deptName) {
- let deptList = this.originaDeptList;
- let dept = deptList.find(v => v.deptName === deptName);
- if (dept) {
- this.form.deptId = dept.deptId;
- } else {
- uni.$u.toast(deptName + "找不到对应的机构");
- }
- }
-
- if(clueOperationName){
- // 没有现成的数据 请求接口
- const { data } = await uni.$u.api.getIdByName({ clueOperationName : clueOperationName});
- const { clueOperationId } = data;
- this.form.clueOperationId = clueOperationId;
- }
- },
- // 获取选择的地区
- handleGetRegion(region) {
- const {
- 0: provinceData,
- 1: cityData,
- 2: areaData
- } = region;
- this.form.manualProvince = provinceData.name;
- this.form.manualCity = cityData.name;
- this.form.manualArea = areaData.name;
- this.form.manualAddressCode = provinceData.name + cityData.name + areaData.name;
- },
- handleShowclueDept() {
- this.$refs.dept._show();
- },
- handleShowclueAppName() {
- this.$refs.appName._show();
- },
- handleShowclueOperation() {
- this.$refs.clueOperation._show();
- },
- handleShowclueOwner() {
- this.$refs.clueOwner._show();
- },
- appNameSeletchang(ids, names) {
- this.form.appName = ids[0];
- this.form.appNameLabel = names[0];
- },
- clueOperationSeletchang(ids, names) {
- this.form.clueOperationId = ids[0];
- this.form.clueOperationName = names[0];
- },
- clueOwnerSeletchang(ids, names) {
- this.form.clueOwnerId = ids[0];
- this.form.clueOwnerName = names[0];
- },
- deptSeletchang(ids, names) {
- this.form.deptId = ids[0];
- this.form.deptName = names[0];
- },
- // 返回
- handleClose() {
- this.$refs.form.resetFields();
- this.form.manualProvince = undefined;
- this.form.manualCity = undefined;
- this.form.manualArea = undefined;
- this.form.manualAddressCode = undefined;
- },
- // 保存
- handleNavSaveClick() {
- this.$refs.form.validate().then(async () => {
- await uni.$u.api.addClueMainInfo(this.form);
- uni.$u.toast("保存成功");
- this.handleClose();
- })
- },
- async handleOption() {
- // 获取人员
- uni.$u.api.getDeptCustomerByOrg().then(res => {
- this.listData = filterCustomerManager(res.data);
- });
- uni.$u.api.getDictCascadeData().then(({
- data
- }) => {
- this.originalDictCascadeData = data;
- this.dictCascadeData = handleTree(data, 'id');
- });
- uni.$u.api.selectAllDeptList({
- isDept: 2
- }).then(({
- data
- }) => {
- this.originaDeptList = data;
- this.deptList = handleTree(data, 'deptId');
- });
- this.$getDicts('sys_user_sex').then(res => {
- this.genderTypeCodeDict = res;
- });
- },
- },
- onLoad(option) {
- this.handleOption();
- }
- }
|