+    
       
         复制分组
       
@@ -980,14 +980,6 @@ export default {
 
   //监听事件
   watch: {
-    //
-    // "customerOrgGroup.id"(newVal, oldVal) {
-    //   console.log("customerOrgGroup.id ",newVal,oldVal);
-    //   if (newVal != oldVal) {
-    //     this.getCustomerOrgGroupAsbitems(newVal);
-    //   }
-    // },
-
     // 体检分组ID未切换换时 也可以强制刷新数据
     "dataTransOpts.refresh.customer_org_group_detail.M":{
       immediate:true,
diff --git a/src/store/index.js b/src/store/index.js
index ca8ec96..fd42184 100644
--- a/src/store/index.js
+++ b/src/store/index.js
@@ -340,6 +340,7 @@ export default new Vuex.Store({
 
         // 弹窗控制
         dialogWin: {
+            CustomerOrgGroupEdit:false, // 单位分组 新增/编辑  
             PatientList: false,  // 体检人员档案列表
             PatientRegisterEdit: false, // 体检人员登记 新增/编辑            
             PatientRegisterForChoose: false,  // 体检人员登记列表
diff --git a/src/views/customerOrg/CustomerOrgGroupEdit.vue b/src/views/customerOrg/CustomerOrgGroupEdit.vue
new file mode 100644
index 0000000..fd1c6cf
--- /dev/null
+++ b/src/views/customerOrg/CustomerOrgGroupEdit.vue
@@ -0,0 +1,376 @@
+
+  
+    
+      
+        
+          
+            
+          
+        
+        
+          
+            
+          
+        
+        
+          
+            
+              
+              
+            
+          
+        
+        
+          
+            
+              
+              
+            
+          
+        
+        
+          
+            
+          
+        
+        
+          
+            
+          
+        
+        
+          
+            
+          
+        
+        
+          
+            
+          
+        
+        
+          
+            
+          
+        
+      
+    
+    
+  
 
+
+
+
diff --git a/src/views/customerOrg/customerOrgGroup.vue b/src/views/customerOrg/customerOrgGroup.vue
index 9e83510..b0f5b96 100644
--- a/src/views/customerOrg/customerOrgGroup.vue
+++ b/src/views/customerOrg/customerOrgGroup.vue
@@ -72,9 +72,9 @@
           
 
         
+        
           
-            新增
+            新增
           
           
             编辑
@@ -96,75 +96,14 @@
 
       
       
-        
+        
       
      
 
     
-    
-      
-        
-          
-            
-              
-            
-          
-          
-            
-              
-            
-          
-          
-            
-              
-                
-                
-              
-            
-          
-          
-            
-              
-                
-                
-              
-            
-          
-          
-            
-              
-            
-          
-          
-            
-              
-            
-          
-          
-            
-              
-            
-          
-          
-            
-              
-            
-          
-          
-            
-              
-            
-          
-        
-      
-      
+    
+      
     
     
    
@@ -184,10 +123,11 @@ import {
 } from "../../utlis/proFunc";
 
 import CustomerOrgGroupAsbitem from "../../components/customerOrg/customerOrgGroupAsbitem.vue";
+import CustomerOrgGroupEdit from "./CustomerOrgGroupEdit.vue";
 
 export default {
   components: {
-    CustomerOrgGroupAsbitem,
+    CustomerOrgGroupAsbitem,CustomerOrgGroupEdit
   },
   data() {
     return {
@@ -201,6 +141,9 @@ export default {
       customerOrgRegisterList: [], //体检次数列表
       customerOrgRegister: {}, //体检次数
 
+      curCustomerOrgGroup: {}, // 当前选中分组
+      CustomerOrgGroupEditParams:{}, //分组 新增时 用到参数 
+
       isDrag: false,
       form: {
         //体检单位分组
@@ -225,11 +168,10 @@ export default {
         displayName: [{ required: true, message: "请填写分组名称", trigger: "blur" }],
       },
 
-      dialogVisible: false,
     };
   },
   computed: {
-    ...mapState(["personnelUnit", "window", "dict", "dataTransOpts"]),
+    ...mapState(["personnelUnit", "window", "dict", "dialogWin", "dataTransOpts"]),
   },
   created() {
     //获取用户当前页面的权限
@@ -237,6 +179,9 @@ export default {
     if (userPriv)
       this.pagePriv.privs = deepCopy(getPagePriv(this.pagePriv.routeUrlorPageName));
 
+    // 清除当前选中的分组ID
+    this.dataTransOpts.tableS.customer_org_group.id = ''
+
     this.rowDrop();
     this.formInit = deepCopy(this.form);
   },
@@ -459,52 +404,51 @@ export default {
 
     //点击分组
     rowClick(row) {
-      objCopy(row, this.form);
-      this.formOri = Object.assign({}, row);
-      this.form.isComplete = this.customerOrgRegister.isComplete;
+      this.dataTransOpts.tableS.customer_org_group.id = row.id
+      this.curCustomerOrgGroup = deepCopy(row);
+      this.curCustomerOrgGroup.isComplete = this.customerOrgRegister.isComplete;
       setTimeout(() => {
         this.dataTransOpts.refresh.customer_org_group_detail.M++;
       }, 20);
     },
 
-    //新增弹框
-    btnAdd() {
+    // 新增(编辑调用时,传入id值) 弹框
+    btnAdd(id) {
       if (!this.customerOrgRegister.id) {
         this.$message.warning("请选择体检次数");
         return;
       }
+
       if (this.customerOrgRegister.isComplete.toUpperCase() == "Y") {
-        this.$message.warning("该单位体检次数已完成,不允许新增分组");
+        this.$message.warning(`该单位的该次体检次数已完成,不能再${id ? '编辑' : '新增'}分组!`);
         return;
       }
+      if (!id) this.dataTransOpts.tableS.customer_org_group.id = ''
+      setTimeout(() => {
+        this.dataTransOpts.refresh.customer_org_group.S++
+        if (!id) this.dataTransOpts.refresh.customer_org_group_detail.M++; //新增则清掉已选组合项目
+      }, 20);
 
-      if (this.customerOrgRegister.isComplete.toUpperCase() == "Y") {
-        this.$message.warning("该单位的该次体检次数已完成,不能再添加分组!");
-        return;
+      this.CustomerOrgGroupEditParams = {
+        customerOrgRegisterId: this.customerOrgRegister.id,
+        customerOrgId: this.customerOrgId
       }
 
-      this.form = deepCopy(this.formInit);
-      this.form.customerOrgRegisterId = this.customerOrgRegister.id;
-      this.form.customerOrgId = this.customerOrgId;
-      this.dialogVisible = true;
+      this.dialogWin.CustomerOrgGroupEdit = true;
     },
 
     //编辑弹框
     btnEdit() {
-      if (!this.form.id) {
-        this.$message.warning("请选择需要操作的数据");
-        return;
-      }
-      if (this.customerOrgRegister.isComplete.toUpperCase() == "Y") {
-        this.$message.warning("该单位体检次数已完成,不允许编辑分组");
+      if (!this.dataTransOpts.tableS.customer_org_group.id) {
+        this.$message.warning("请先选择体检分组");
         return;
       }
-      this.dialogVisible = true;
+      this.btnAdd(this.dataTransOpts.tableS.customer_org_group.id)
     },
 
     //删除
     btnDel() {
-      if (!this.form.id) {
+      if (!this.dataTransOpts.tableS.customer_org_group.id) {
         this.$message.warning("请选择需要操作的数据");
         return;
       }
@@ -519,120 +463,28 @@ export default {
         type: "warning",
       })
         .then(() => {
-          return deletapi(`/api/app/customer-org-group/${this.form.id}`);
+          return deletapi(`/api/app/customer-org-group/${this.dataTransOpts.tableS.customer_org_group.id}`);
         })
         .then((res) => {
           if (res.code != -1) {
             console.log("删除成功");
-            let lfind = arrayExistObj(this.customerOrgGroups, "id", this.form.id);
+            let lfind = arrayExistObj(this.customerOrgGroups, "id", this.dataTransOpts.tableS.customer_org_group.id);
             if (lfind > -1) this.customerOrgGroups.splice(lfind, 1);
-            objCopy(this.formInit, this.form);
-            this.isDrag = false;
+            this.dataTransOpts.tableS.customer_org_group.id = ''
+            setTimeout(() => {
+              this.dataTransOpts.refresh.customer_org_group_detail.M++
+            }, 20);
           }
         })
         .catch((err) => {
           if (err == "cancel") {
-            this.$message.info("已取消删除");
+            console.log("已取消删除");
+            // this.$message.info("已取消删除");
           }
         });
     },
 
-    onSubmit(formName) {
-      this.$refs[formName].validate((valid, fields) => {
-        if (!valid) {
-          this.$message.warning(fields[Object.keys(fields)[0]][0].message);
-          return false;
-        }
-
-        if (!this.form.customerOrgRegisterId) {
-          this.$message.warning("请选择单位体检次数!");
-          return false;
-        }
-
-        let body = deepCopy(this.form);
-        delete body.id;
-        delete body.customerOrgId;
-        delete body.isComplete;
-
-        if (this.form.id) {
-          let customerOrgGroupId = this.form.id;
-          let customerOrgGroupAsbitems = []; //分组包含的套餐
-
-          //编辑
-          putapi(`/api/app/customer-org-group/${this.form.id}`, body)
-            .then((res) => {
-              // console.log(res)
-              if (res.code != -1) {
-                console.log("保存分组成功!");
-                let lfind = arrayExistObj(this.customerOrgGroups, "id", this.form.id);
-                if (lfind > -1) objCopy(this.form, this.customerOrgGroups[lfind]);
-                console.log(
-                  "this.formOri.price != this.form.price",
-                  this.formOri.price,
-                  this.form.price
-                );
-                if (this.formOri.price != this.form.price) {
-                  return getapi(
-                    `/api/app/customerorggroupdetail/getcustomerorggroupdetailinasbitem?CustomerOrgGroupId=${customerOrgGroupId}`
-                  );
-                } else {
-                  this.dialogVisible = false;
-                }
-              }
-            })
-            .then((res) => {
-              if (res && res.code != -1) {
-                customerOrgGroupAsbitems = res.data;
-                if (customerOrgGroupAsbitems.length < 1) {
-                  console.log("该分组暂没有组合项目!");
-                  this.dialogVisible = false;
-                } else {
-                  let detailsBody = {
-                    customerOrgGroupId,
-                    details: this.madeNewGroupAsbitems(
-                      customerOrgGroupAsbitems,
-                      this.form.price
-                    ),
-                  };
-                  return postapi(
-                    "/api/app/customerorggroupdetail/createcustomerorggroupdetailmany",
-                    detailsBody
-                  );
-                }
-              }
-            })
-            .then((res) => {
-              if (res && res.code != -1) {
-                console.log("操作成功!并自动按总价同比折算组合项目价格!");
-                this.dialogVisible = false;
-                // 刷新明细
-                let id = this.form.id;
-                this.form.id = "";
-                setTimeout(() => {
-                  this.form.id = id;
-                }, 100);
-              }
-            });
-        } else {
-          //新增
-          postapi(
-            "/api/customerorggroup/createcustomerorggroupincustomerorgregister",
-            body
-          ).then((res) => {
-            if (res.code != -1) {
-              console.log("操作成功!");
-              this.form.id = res.data.id;
-              this.customerOrgGroups.push(deepCopy(res.data));
-              this.$refs["customerOrgGroups"].setCurrentRow(
-                this.customerOrgGroups[this.customerOrgGroups.length - 1]
-              );
-              this.dialogVisible = false;
-            }
-          });
-        }
-      });
-    },
-
+    //计算总价
     computePrice() {
       if (!this.form.id) {
         this.$message.warning("尚未保存信息,不可执行此操作!");
@@ -730,6 +582,40 @@ export default {
 
       return newGroupAsbitems;
     },
+
+    // 关闭 分组 新增/编辑
+    close_dialogWinCustomerOrgGroupEdit() {
+      let id = this.dataTransOpts.tableS.customer_org_group.id
+      if (id) {
+        // 点编辑 或 新增有提交
+        getapi(`/api/app/customer-org-group/${id}`)
+          .then(res => {
+            if (res.code != -1) {
+              let lfind = -1
+              lfind = arrayExistObj(this.customerOrgGroups, 'id', id)
+              if (lfind > -1) {
+                objCopy(res.data, this.customerOrgGroups[lfind])
+              }else{
+                lfind = this.customerOrgGroups.length
+                this.customerOrgGroups.push(res.data)
+              }
+
+              // 选中当前操作的列
+              this.$refs["customerOrgGroups"].setCurrentRow(); //清除选择
+              this.$refs["customerOrgGroups"].setCurrentRow(this.customerOrgGroups[lfind]);
+
+              // 更新 customer_org_group_detail 参数
+              this.curCustomerOrgGroup = deepCopy(res.data);
+              this.curCustomerOrgGroup.isComplete = this.customerOrgRegister.isComplete;       
+            }
+          })
+      }else{
+        // 点 新增 但未提交
+        this.dataTransOpts.tableS.customer_org_group.id = this.curCustomerOrgGroup.id || ''
+      }
+      
+      this.dataTransOpts.refresh.customer_org_group_detail.M++;
+    },
   },
 };