戴艳蓉 3 жил өмнө
parent
commit
ed1993e59f

+ 97 - 7
src/views/interest/account/addEdit.vue

@@ -522,13 +522,66 @@ export default {
               roleid,
               status,
               depart,
+              business,
+              platform,
             } = sitem;
             let depart_code = [];
             if (depart && depart.length > 0) {
               depart.forEach((a) => {
-                depart_code.push(a.id);
+                depart_code.push(a.depart_code);
               });
             }
+            let copyBusiness =
+              business && business.length > 0
+                ? JSON.parse(JSON.stringify(business))
+                : [];
+
+            let businessList =
+              business && business.length > 0
+                ? JSON.parse(JSON.stringify(business))
+                : [];
+            businessList.forEach((a, ai) => {
+              let sindex = this.coptions.findIndex((b) => b.id == a.businessid);
+              if (sindex === -1) {
+                copyBusiness.splice(ai, 1);
+              }
+            });
+            let is_all = false,
+              add = 0;
+            // if(copyBusiness.length===)
+
+            let resbusinesslist = [],
+              is_main = "";
+            if (copyBusiness && copyBusiness.length > 0) {
+              copyBusiness.forEach((a) => {
+                resbusinesslist.push(a.businessid);
+                if (a.is_main === "1") {
+                  is_main = a.businessid;
+                }
+              });
+            }
+
+            let copyplatform =
+              platform && platform.length > 0
+                ? JSON.parse(JSON.stringify(platform))
+                : [];
+            let platformList =
+              platform && platform.length > 0
+                ? JSON.parse(JSON.stringify(platform))
+                : [];
+            platformList.forEach((a, ai) => {
+              let sindex = this.platformoptions.findIndex((b) => b.id == a.id);
+              if (sindex === -1) {
+                copyplatform.splice(ai, 1);
+              }
+            });
+            let resplatformlist = [];
+            if (copyplatform && copyplatform.length > 0) {
+              copyplatform.forEach((a) => {
+                resplatformlist.push(a.id);
+              });
+            }
+
             this.ruleForm = {
               username: username || "", // 账号
               name: nickname || "", // 真实姓名
@@ -537,11 +590,14 @@ export default {
               role_id: roleid || "",
               status: status || "",
               itemid: depart_code,
-              is_main: "",
-              companyArr: [],
-              platform: [],
+              is_main: is_main || "",
+              companyArr: resbusinesslist || [],
+              platform: resplatformlist || [],
+              is_all: resbusinesslist.length === this.coptions.length,
             };
-            this.handleCheckAllChange();
+            this.isIndeterminate =
+              resbusinesslist.length > 0 &&
+              resbusinesslist.length < this.coptions.length;
           } else {
             this.ruleForm = {
               username: "", // 账号
@@ -565,8 +621,39 @@ export default {
       await this.$refs.ruleForm.validate(async (valid) => {
         if (valid) {
           this.loading = true;
-          const { username, name, mobile, email, role_id, status, itemid } =
-            JSON.parse(JSON.stringify(this.ruleForm));
+          const {
+            username,
+            name,
+            mobile,
+            email,
+            role_id,
+            status,
+            itemid,
+            is_main,
+            is_all,
+            companyArr,
+            platform,
+          } = JSON.parse(JSON.stringify(this.ruleForm));
+          let list = [],
+            isok = true;
+          companyArr.forEach((e) => {
+            let item = {
+              businessid: e,
+              is_main: is_main === e ? "1" : "0",
+            };
+            list.push(item);
+            let findex = this.coptions.findIndex(
+              (a) => a.id === e && a.status === "0"
+            );
+            if (findex !== -1) {
+              isok = false;
+            }
+          });
+          if (!isok) {
+            this.$message.warning("不能选择禁用的业务企业!");
+            this.loading = true;
+            return;
+          }
           const model = {
             id: this.id,
             username: username || "", // 账号
@@ -576,6 +663,9 @@ export default {
             role: role_id || "",
             status: status || "",
             itemid: itemid || [],
+            is_all: is_all ? "1" : "0",
+            platform: platform || [],
+            companyArr: list,
           };
           let res = {};
           if (this.id === "add") {