const _Http = getApp().globalData.http; Page({ data: { showAll: false, form: [{ label: "企业名称", error: false, errMsg: "", type: "textarea", value: "", placeholder: "企业全称", valueName: "enterprisename", checking: "base", required: true }, { label: "企业简称", error: false, errMsg: "", type: "textarea", value: "", placeholder: "企业简称", valueName: "abbreviation", checking: "base", required: false }, { label: "统一社会信用代码", error: false, errMsg: "", type: "textarea", value: "", placeholder: "企业税号/注册号/营业执照号码", valueName: "taxno", checking: "base", required: false }, { label: "法定代表人", error: false, errMsg: "", type: "text", value: "", placeholder: "企业法人", valueName: "contact", checking: "base", required: false }, { label: "法人电话号码", error: false, errMsg: "", type: "number", value: "", placeholder: "法人联系手机号", valueName: "phonenumber", checking: "phone", required: false }, { label: "所属行业", error: false, errMsg: "", type: "option", //自定义选择 配合预定接口 optionNmae: "industry", //选择类型 optionType: "radio", //复选 radio 单选 value: "", placeholder: "企业所属行业", valueName: "industry", checking: "base", required: false }, { label: "地区", error: false, errMsg: "", type: "region", value: [], placeholder: "所属地区 省/市/区", valueName: "region", required: false }, { label: "注册地址", error: false, errMsg: "", type: "textarea", value: "", placeholder: "企业注册地址", valueName: "address", checking: "base", required: false }, { label: "客户类型", error: false, errMsg: "", type: "option", optionNmae: "customertypemx", optionType: "radio", //复选 radio 单选 value: "", placeholder: "客户类型", valueName: "type", checking: "base", required: false }, { label: "客户级别", error: false, errMsg: "", type: "option", optionNmae: "customergrade", optionType: "radio", //复选 radio 单选 value: "", placeholder: "客户数字级别", valueName: "grade", checking: "base", required: false }], content: { "sa_customersid": 0, //新增是传0 "parentid": 0, //上级客户ID,默认或没有上级的时候传0 "sys_enterpriseid": 0, //合作企业档案ID,新增是传0,更新 "sa_customerpoolid": 0, //客户池(公海池)ID,默认或没有的时候传0 "source": "", //客户来源 }, disabled: true }, setOption(item) { let i = this.data.form.findIndex(v => v.valueName == item.valueName); this.setData({ [`form[${i}]`]: item }) }, onLoad(options) { if (options.data) { let data = JSON.parse(options.data); this.setData({ disabled: false, content: { sa_customersid: data.sa_customersid, parentid: data.parentid, sys_enterpriseid: data.sys_enterpriseid, sa_customerpoolid: data.sa_customerpoolid, source: data.source, }, form: this.data.form.map(v => { if (v.valueName != 'region') { v.value = data[v.valueName]; } else { v.value = data.province ? [data.province, data.city, data.county] : [] } return v }) }) } }, /* 表单必填项是否完成 */ onConfirm({ detail }) { this.setData({ disabled: detail }) }, // 是否显示全部 onChange({ detail }) { this.setData({ showAll: detail }) }, submit() { let data = this.selectComponent("#Form").submit(); if (data.region.length != 0) { data.province = data.region[0] data.city = data.region[1] data.county = data.region[2] }; delete(data.region); _Http.basic({ "id": 20221012163902, "content": { ...this.data.content, ...data, } }).then(res => { console.log("新建客户", res) if (res.msg != '成功') return wx.showToast({ title: res.data, icon: "none" }) wx.showToast({ title: '保存成功', icon: "none" }) setTimeout(() => { wx.navigateBack() getCurrentPages().forEach(v => { switch (v.__route__) { case 'packageA/setclient/index': v.getList(true); break; case 'packageA/setclient/search': v.getList(true); break; case 'packageA/setclient/detail': v.getDetail(); break; } }) let pages = getCurrentPages(); if (pages[pages.length - 2].__route__ == 'packageA/setclient/index') wx.navigateTo({ url: '/packageA/setclient/detail?id=' + res.data.sa_customersid, }) }, 300) }) }, })