Просмотр исходного кода

关联企业非必填,默认获取一个联系人的企业

xiaohaizhao 1 год назад
Родитель
Сommit
e43897117a
1 измененных файлов с 27 добавлено и 2 удалено
  1. 27 2
      packageA/project/modules/contacts/add/index.js

+ 27 - 2
packageA/project/modules/contacts/add/index.js

@@ -81,7 +81,7 @@ Page({
                 query: "&radio=true",
                 placeholder: "选择关联企业",
                 valueName: "sys_enterpriseid",
-                required: true,
+                required: false,
                 checking: "base",
             }, {
                 label: "部门",
@@ -189,7 +189,6 @@ Page({
         if (options.data) {
             let item = JSON.parse(options.data),
                 arr = item.phonenumber.split("-");
-            console.log("item", item)
             if (item.sys_enterpriseid == 0) this.data.form = this.data.form.filter(v => v.valueName != 'sys_enterpriseid');
             item.sys_enterpriseid = item.enterprisename ? [item.enterprisename, [item.sys_enterpriseid]] : '';
             item.isTelephone = arr.length == 2 ? "1" : "0";
@@ -233,6 +232,32 @@ Page({
                 })
             });
             this.selectComponent("#Form").confirm();
+
+
+            if (item.sa_project_contactsid) return;
+            _Http.basic({
+                "id": "20231215134204",
+                "content": {
+                    "sys_phonebookid": item.sys_phonebookid,
+                    "nocache": true,
+                    "pageSize": 1,
+                    "where": {
+                        "condition": ""
+                    },
+                    "sa_projectid": options.sa_projectid,
+                    "total": 1
+                },
+            }).then(res => {
+                if (res.code == 1 && res.total) {
+                    let value = [res.data[0].enterprisename, [res.data[0].sys_enterpriseid]]
+                    let index = this.data.form.findIndex(v => v.label == '关联企业')
+                    if (index != -1) this.setData({
+                        [`form[${index}].value`]: value
+                    })
+                }
+                console.log("获取一条关联企业", res)
+            })
+
         }
     },
     /* 打断 */