|
|
@@ -0,0 +1,322 @@
|
|
|
+const _Http = getApp().globalData.http;
|
|
|
+Page({
|
|
|
+ data: {
|
|
|
+ sat_orderclue_contactsid: null, //是否为快捷选择创建的账号
|
|
|
+ fromShowAll: false,
|
|
|
+ form: [{
|
|
|
+ label: "姓名",
|
|
|
+ error: false,
|
|
|
+ errMsg: "",
|
|
|
+ type: "text",
|
|
|
+ value: "",
|
|
|
+ placeholder: "联系人名称",
|
|
|
+ valueName: "name",
|
|
|
+ required: true,
|
|
|
+ checking: "base"
|
|
|
+ }, {
|
|
|
+ label: "联系方式",
|
|
|
+ error: false,
|
|
|
+ errMsg: "",
|
|
|
+ hint: "",
|
|
|
+ type: "radio",
|
|
|
+ value: "0",
|
|
|
+ radioList: [{
|
|
|
+ id: '0',
|
|
|
+ name: '手机号'
|
|
|
+ }, {
|
|
|
+ id: '1',
|
|
|
+ name: '座机电话'
|
|
|
+ }],
|
|
|
+ valueName: "isTelephone", //绑定的字段名称
|
|
|
+ required: true, //必填
|
|
|
+ interrupt: true,
|
|
|
+ checking: `true`,
|
|
|
+ phonenumber: "",
|
|
|
+ telephone: ["", ""]
|
|
|
+ }, {
|
|
|
+ label: "手机号",
|
|
|
+ error: false,
|
|
|
+ errMsg: "",
|
|
|
+ type: "number",
|
|
|
+ value: "",
|
|
|
+ placeholder: "联系人手机号码",
|
|
|
+ valueName: "phonenumber",
|
|
|
+ required: true,
|
|
|
+ checking: "phone"
|
|
|
+ }, {
|
|
|
+ label: "微信",
|
|
|
+ error: false,
|
|
|
+ errMsg: "",
|
|
|
+ type: "text",
|
|
|
+ value: "",
|
|
|
+ placeholder: "联系人微信",
|
|
|
+ valueName: "wechatnum",
|
|
|
+ required: false
|
|
|
+ }, {
|
|
|
+ label: "邮箱",
|
|
|
+ error: false,
|
|
|
+ errMsg: "",
|
|
|
+ type: "textarea",
|
|
|
+ value: "",
|
|
|
+ placeholder: "请填写",
|
|
|
+ valueName: "email",
|
|
|
+ required: false,
|
|
|
+ checking: "mail"
|
|
|
+ }, {
|
|
|
+ label: "传真",
|
|
|
+ error: false,
|
|
|
+ errMsg: "",
|
|
|
+ type: "textarea",
|
|
|
+ value: "",
|
|
|
+ placeholder: "请填写",
|
|
|
+ valueName: "fax",
|
|
|
+ required: false,
|
|
|
+ }, {
|
|
|
+ label: "部门",
|
|
|
+ error: false,
|
|
|
+ errMsg: "",
|
|
|
+ type: "text",
|
|
|
+ value: "",
|
|
|
+ placeholder: "联系人所属部门",
|
|
|
+ valueName: "depname",
|
|
|
+ required: true,
|
|
|
+ checking: "base"
|
|
|
+ }, {
|
|
|
+ label: "职位",
|
|
|
+ error: false,
|
|
|
+ errMsg: "",
|
|
|
+ type: "text",
|
|
|
+ value: "",
|
|
|
+ placeholder: "联系人职位",
|
|
|
+ valueName: "position",
|
|
|
+ required: true,
|
|
|
+ checking: "base"
|
|
|
+ }, {
|
|
|
+ label: "性别",
|
|
|
+ error: false,
|
|
|
+ errMsg: "",
|
|
|
+ type: "sex",
|
|
|
+ value: "男",
|
|
|
+ placeholder: "联系人性别",
|
|
|
+ valueName: "sex",
|
|
|
+ required: false,
|
|
|
+ checking: "base"
|
|
|
+ }, {
|
|
|
+ label: "生日",
|
|
|
+ error: false,
|
|
|
+ errMsg: "",
|
|
|
+ type: "date",
|
|
|
+ value: "",
|
|
|
+ placeholder: "联系人生日",
|
|
|
+ valueName: "birthday",
|
|
|
+ required: false
|
|
|
+ }, {
|
|
|
+ label: "家庭地址",
|
|
|
+ error: false,
|
|
|
+ errMsg: "",
|
|
|
+ type: "textarea",
|
|
|
+ value: "",
|
|
|
+ placeholder: "家庭地址",
|
|
|
+ valueName: "homeaddress",
|
|
|
+ required: false,
|
|
|
+ checking: "base"
|
|
|
+ }, {
|
|
|
+ label: "偏好",
|
|
|
+ error: false,
|
|
|
+ errMsg: "",
|
|
|
+ type: "textarea",
|
|
|
+ value: "",
|
|
|
+ placeholder: "请填写",
|
|
|
+ valueName: "preference",
|
|
|
+ required: false
|
|
|
+ }, {
|
|
|
+ label: "爱好",
|
|
|
+ error: false,
|
|
|
+ errMsg: "",
|
|
|
+ type: "textarea",
|
|
|
+ value: "",
|
|
|
+ placeholder: "请填写",
|
|
|
+ valueName: "hobby",
|
|
|
+ required: false
|
|
|
+ }, {
|
|
|
+ label: "备注",
|
|
|
+ error: false,
|
|
|
+ errMsg: "",
|
|
|
+ type: "textarea",
|
|
|
+ value: "",
|
|
|
+ placeholder: "请填写",
|
|
|
+ valueName: "remarks",
|
|
|
+ required: false,
|
|
|
+ checking: "base"
|
|
|
+ }],
|
|
|
+ disabled: true,
|
|
|
+ "content": {
|
|
|
+ "sat_orderclueid": 0, //绑定数据
|
|
|
+ "isleader": 0, //默认0
|
|
|
+ "isdefault": 0, //是否默认地址
|
|
|
+ sys_phonebookid: 0,
|
|
|
+ "isprimary": 0 //是否为主地址
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onLoad(options) {
|
|
|
+ getApp().globalData.Language.getLanguagePackage(this, '联系人');
|
|
|
+ if (options.sat_orderclueid) this.data.content.sat_orderclueid = options.sat_orderclueid;
|
|
|
+ if (options.enterprisename) this.data.content.enterprisename = options.enterprisename;
|
|
|
+ if (options.data) {
|
|
|
+ let item = JSON.parse(options.data),
|
|
|
+ arr = item.phonenumber.split("-");
|
|
|
+ this.data.content.sat_orderclue_contactsid = item.sat_orderclue_contactsid;
|
|
|
+ item.isTelephone = arr.length == 2 ? "1" : "0";
|
|
|
+ if (options.enterprisename) {
|
|
|
+ item.sat_orderclueid = [options.enterprisename, [options.sat_orderclueid]]
|
|
|
+ } else if (item.enterprisename) {
|
|
|
+ item.sat_orderclueid = [item.enterprisename, [item.sat_orderclueid]]
|
|
|
+ }
|
|
|
+ this.data.content.enterprisename = item.enterprisename;
|
|
|
+ this.data.sat_orderclue_contactsid = item.sat_orderclue_contactsid || 0;
|
|
|
+ this.data.content.sys_phonebookid = item.sys_phonebookid || 0;
|
|
|
+ this.setData({
|
|
|
+ form: this.data.form.map(v => {
|
|
|
+ if (v.valueName == 'phonenumber') {
|
|
|
+ v = arr.length == 2 ? {
|
|
|
+ label: "电话",
|
|
|
+ error: false,
|
|
|
+ errMsg: "",
|
|
|
+ type: "telephone",
|
|
|
+ value: arr,
|
|
|
+ placeholder: "联系人手机号码",
|
|
|
+ valueName: "telephone",
|
|
|
+ required: true,
|
|
|
+ checking: "telephone"
|
|
|
+ } : {
|
|
|
+ label: "手机号",
|
|
|
+ error: false,
|
|
|
+ errMsg: "",
|
|
|
+ type: "number",
|
|
|
+ value: arr[0],
|
|
|
+ placeholder: "联系人手机号码",
|
|
|
+ valueName: "phonenumber",
|
|
|
+ required: true,
|
|
|
+ checking: "phone"
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ v.value = item[v.valueName] || v.value || '';
|
|
|
+ }
|
|
|
+ return v
|
|
|
+ })
|
|
|
+ });
|
|
|
+ this.selectComponent("#Form").confirm();
|
|
|
+ } else {
|
|
|
+
|
|
|
+ this.setData({
|
|
|
+ form: this.data.form
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /* 打断 */
|
|
|
+ interrupt({
|
|
|
+ detail
|
|
|
+ }) {
|
|
|
+ let {
|
|
|
+ data,
|
|
|
+ form
|
|
|
+ } = detail;
|
|
|
+ if (data.label == '联系方式') {
|
|
|
+ if (data.value == 0) {
|
|
|
+ data.telephone = form[2].value;
|
|
|
+ form[2] = {
|
|
|
+ label: "手机号",
|
|
|
+ error: false,
|
|
|
+ errMsg: "",
|
|
|
+ type: "number",
|
|
|
+ value: data.phonenumber,
|
|
|
+ placeholder: "联系人手机号码",
|
|
|
+ valueName: "phonenumber",
|
|
|
+ required: true,
|
|
|
+ checking: "phone"
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ data.phonenumber = form[2].value;
|
|
|
+ form[2] = {
|
|
|
+ label: "电话",
|
|
|
+ error: false,
|
|
|
+ errMsg: "",
|
|
|
+ type: "telephone",
|
|
|
+ value: data.telephone,
|
|
|
+ placeholder: "联系人手机号码",
|
|
|
+ valueName: "telephone",
|
|
|
+ required: true,
|
|
|
+ checking: "telephone"
|
|
|
+ }
|
|
|
+ };
|
|
|
+ this.setData({
|
|
|
+ form
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /* 提交数据 */
|
|
|
+ submit() {
|
|
|
+ let data = this.selectComponent("#Form").submit();
|
|
|
+ if (!data || this.data.disabled) return;
|
|
|
+ const content = {
|
|
|
+ ...this.data.content,
|
|
|
+ ...data,
|
|
|
+ };
|
|
|
+ if (content.telephone) {
|
|
|
+ content.phonenumber = content.telephone.join("-");
|
|
|
+ delete(content.telephone)
|
|
|
+ }
|
|
|
+ content.sat_orderclueid = this.data.content.sat_orderclueid;
|
|
|
+ this.handleSubmit(content);
|
|
|
+ },
|
|
|
+ handleSubmit(content) {
|
|
|
+ _Http.basic({
|
|
|
+ "id": "2025042110003902",
|
|
|
+ content
|
|
|
+ }).then(res => {
|
|
|
+ console.log("编辑联系人", res)
|
|
|
+ wx.showToast({
|
|
|
+ title: res.code != '1' ? res.msg : getApp().globalData.Language.getMapText('保存成功'),
|
|
|
+ icon: "none",
|
|
|
+ mask: true
|
|
|
+ });
|
|
|
+ if (res.code == '1') setTimeout(() => {
|
|
|
+ wx.navigateBack()
|
|
|
+ getCurrentPages().forEach(v => {
|
|
|
+ if (v.__route__ == 'packageA/saleClue/modules/contacts/detail/index' || v.__route__ == 'packageA/contacts/detail' || v.__route__ == "packageA/publicCustomer/detail") {
|
|
|
+ v.getDetail();
|
|
|
+ } else if (v.selectComponent("#Contacts")) {
|
|
|
+ let page = v.selectComponent("#Contacts");
|
|
|
+ let index = page.data.list.findIndex(value => value.sat_orderclue_contactsid == res.data.sat_orderclue_contactsid);
|
|
|
+ if (index != -1) page.setData({
|
|
|
+ [`list[${index}]`]: res.data
|
|
|
+ })
|
|
|
+
|
|
|
+ } else if (v.__route__ == 'packageA/project/modules/contacts/search/index') {
|
|
|
+ let index = v.data.list.findIndex(value => value.sat_orderclue_contactsid == res.data.sat_orderclue_contactsid);
|
|
|
+ if (index != -1) v.setData({
|
|
|
+ [`list[${index}]`]: res.data
|
|
|
+ })
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }, 500)
|
|
|
+
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /* 表单是否填写完成 */
|
|
|
+ onConfirm({
|
|
|
+ detail
|
|
|
+ }) {
|
|
|
+ this.setData({
|
|
|
+ disabled: detail
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 是否显示全部 */
|
|
|
+ changefromShowAll({
|
|
|
+ detail
|
|
|
+ }) {
|
|
|
+ this.setData({
|
|
|
+ fromShowAll: detail
|
|
|
+ })
|
|
|
+ },
|
|
|
+})
|