From c1a720f950f96f9315dd152289ea57b673d47d84 Mon Sep 17 00:00:00 2001
From: wwl <xchao828@163.com>
Date: 星期二, 31 十二月 2024 18:53:11 +0800
Subject: [PATCH] 1

---
 src/views/system/comp/index.vue |  715 ++++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 587 insertions(+), 128 deletions(-)

diff --git a/src/views/system/comp/index.vue b/src/views/system/comp/index.vue
index ab041e2..f162fef 100644
--- a/src/views/system/comp/index.vue
+++ b/src/views/system/comp/index.vue
@@ -291,6 +291,7 @@
         :visible.sync="opens"
         width="1350px"
         append-to-body
+        :close-on-click-modal="false"
       >
         <el-row :gutter="20">
           <el-col :span="7" :xs="24">
@@ -378,6 +379,7 @@
                   placeholder="璇烽�夋嫨鎬у埆"
                   style="width: 120px"
                   clearable
+                  :disabled="isSexDisabled"
                 >
                   <el-option
                     v-for="dict in dict.type.sys_user_sex"
@@ -387,14 +389,14 @@
                   />
                 </el-select>
               </el-form-item>
-              <el-form-item label="濂楅鍚嶇О" prop="pacName">
+              <!-- <el-form-item label="濂楅鍚嶇О" prop="pacName">
                 <el-input
                   v-model="forms.pacName"
                   placeholder="璇疯緭鍏ュ椁愬悕绉�"
                   @focus="changeName"
                   style="width: 130px"
                 />
-              </el-form-item>
+              </el-form-item> -->
               <el-form-item label="鍘熶环" prop="price">
                 <el-input
                   v-model="forms.price"
@@ -407,17 +409,16 @@
                   v-model="forms.limits"
                   placeholder="璇疯緭鍏ユ姌鎵�"
                   style="width: 130px"
-                  :disabled="isfalse"
                   @change="numberChange"
                 />
+                <!-- :disabled="isfalse" -->
               </el-form-item>
 
-              <el-form-item label="搴旀敹" prop="ysPrice">
+              <el-form-item label="浼樻儬浠�" prop="ysPrice">
                 <el-input
                   v-model="forms.ysPrice"
                   placeholder="璇疯緭鍏ュ簲鏀�"
                   style="width: 120px"
-                  disabled
                 />
               </el-form-item>
               <el-form-item label="缁撶畻鏂瑰紡" prop="payType">
@@ -453,7 +454,6 @@
                   icon="el-icon-plus"
                   size="mini"
                   @click="handleGroup"
-                  v-hasPermi="['system:comp:add']"
                   >淇濆瓨</el-button
                 >
               </el-col>
@@ -463,8 +463,17 @@
                   icon="el-icon-edit"
                   size="mini"
                   :disabled="singlegg"
+                  @click="xiangmuWh"
+                  >椤圭洰缁存姢</el-button
+                >
+              </el-col>
+              <el-col :span="1.5">
+                <el-button
+                  type="primary"
+                  icon="el-icon-edit"
+                  size="mini"
+                  :disabled="singlegg"
                   @click="GroupUpdate"
-                  v-hasPermi="['system:comp:edit']"
                   >閲嶇疆</el-button
                 >
                 <el-button
@@ -473,7 +482,6 @@
                   size="mini"
                   :disabled="singlegg"
                   @click="deleteGroup"
-                  v-hasPermi="['system:comp:edit']"
                   >鍒犻櫎</el-button
                 >
               </el-col>
@@ -531,6 +539,7 @@
         :visible.sync="openss"
         width="1400px"
         append-to-body
+        :close-on-click-modal="false"
       >
         <el-row :gutter="24">
           <el-col :span="8" :xs="24">
@@ -606,16 +615,24 @@
                   style="width: 140px"
                 />
               </el-form-item>
+              <el-form-item>
+                <el-button
+                  icon="el-icon-refresh"
+                  size="mini"
+                  @click="resetQuerys"
+                  >閲嶇疆</el-button
+                >
+              </el-form-item>
             </el-form>
-            <div style="color: red; font-size: 8px">
+            <!-- <div style="color: red; font-size: 8px">
               娉ㄩ噴锛氶紶鏍囧乏閿弻鍑婚�変腑琛屽彲鍒犻櫎
-            </div>
+            </div> -->
+            <!--       @row-dblclick="dbclick" -->
             <el-table
               border
               v-loading="loading"
               :data="OnenewpacName"
               :row-class-name="tableRowClassName"
-              @row-dblclick="dbclick"
               height="478"
             >
               <el-table-column
@@ -625,6 +642,17 @@
               >
                 <template slot-scope="scope">
                   {{ scope.row.proName + "/" + scope.row.proPrice }}
+                </template>
+              </el-table-column>
+              <el-table-column label="鎿嶄綔" align="center" width="68">
+                <template slot-scope="scope">
+                  <el-button
+                    size="mini"
+                    type="text"
+                    icon="el-icon-delete"
+                    @click="handledbelete(scope.row)"
+                    >鍒犻櫎</el-button
+                  >
                 </template>
               </el-table-column>
             </el-table>
@@ -689,6 +717,195 @@
         </el-row>
         <div slot="footer" class="dialog-footer1">
           <el-button type="primary" @click="submitrighr">纭� 瀹�</el-button>
+          <el-button @click="cancell">鍙� 娑�</el-button>
+        </div>
+      </el-dialog>
+    </div>
+
+    <div>
+      <el-dialog
+        :title="title"
+        :visible.sync="openOne"
+        width="1400px"
+        append-to-body
+        :close-on-click-modal="false"
+      >
+        <el-row :gutter="24">
+          <el-col :span="8" :xs="24">
+            <el-form
+              :model="queryParams"
+              ref="queryForm"
+              size="small"
+              :inline="true"
+              label-width="68px"
+            >
+              <el-form-item label="濂楅鍚嶇О" prop="pacName">
+                <el-input
+                  ref="inputName"
+                  v-model="queryParams.pacName"
+                  placeholder="璇疯緭鍏ュ椁愬悕绉�"
+                  clearable
+                  @keyup.enter.native="handleSearch"
+                  style="width: 140px"
+                />
+              </el-form-item>
+              <el-form-item>
+                <el-button
+                  type="primary"
+                  icon="el-icon-search"
+                  size="mini"
+                  @click="handleSearch"
+                  >鎼滅储</el-button
+                >
+                <!-- <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">閲嶇疆</el-button> -->
+              </el-form-item>
+            </el-form>
+            <el-table
+              ref="tbone"
+              border
+              v-loading="loading"
+              :data="newpacName"
+              @selection-change="handleChangeOne"
+              height="478"
+            >
+              <el-table-column type="selection" width="40px" align="center" />
+              <el-table-column
+                label="搴忓彿"
+                align="center"
+                prop="newID"
+                width="50px"
+              />
+              <el-table-column
+                label="濂楅鍚嶇О/浠锋牸/鍏�"
+                align="center"
+                prop="pacName"
+              >
+                <template slot-scope="scope">
+                  {{ scope.row.pacName + "/" + scope.row.price }}
+                </template>
+              </el-table-column>
+            </el-table>
+          </el-col>
+          <el-col :span="6" :xs="24">
+            <el-form
+              :model="queryParams"
+              ref="queryForm"
+              size="small"
+              :inline="true"
+              label-width="46px"
+              style="height: 35px"
+            >
+              <el-form-item label="鍚堣" prop="price">
+                <el-input
+                  ref="inputName"
+                  v-model="queryParams.price"
+                  placeholder="鍚堣"
+                  clearable
+                  style="width: 140px"
+                />
+              </el-form-item>
+              <el-form-item>
+                <el-button
+                  icon="el-icon-refresh"
+                  size="mini"
+                  @click="resetQuerys"
+                  >閲嶇疆</el-button
+                >
+              </el-form-item>
+            </el-form>
+            <!-- <div style="color: red; font-size: 8px">
+              娉ㄩ噴锛氶紶鏍囧乏閿弻鍑婚�変腑琛屽彲鍒犻櫎
+            </div> -->
+            <!--       @row-dblclick="dbclick" -->
+            <el-table
+              border
+              v-loading="loading"
+              :data="OnenewpacName"
+              :row-class-name="tableRowClassName"
+              height="478"
+            >
+              <el-table-column
+                label="椤圭洰鍚嶇О/浠锋牸/鍏�"
+                align="center"
+                prop="proName"
+              >
+                <template slot-scope="scope">
+                  {{ scope.row.proName + "/" + scope.row.proPrice }}
+                </template>
+              </el-table-column>
+              <el-table-column label="鎿嶄綔" align="center" width="68">
+                <template slot-scope="scope">
+                  <el-button
+                    size="mini"
+                    type="text"
+                    icon="el-icon-delete"
+                    @click="handledbelete(scope.row)"
+                    >鍒犻櫎</el-button
+                  >
+                </template>
+              </el-table-column>
+            </el-table>
+          </el-col>
+          <el-col :span="2" :xs="24">
+            <div style="margin: 240% 6%">
+              <el-button
+                type="primary"
+                size="medium "
+                icon="el-icon-back"
+                @click="resetright"
+                >纭� 璁�</el-button
+              >
+            </div>
+          </el-col>
+          <el-col :span="8" :xs="24">
+            <el-form
+              :model="queryParams"
+              ref="queryForm"
+              size="small"
+              :inline="true"
+              v-show="showSearch"
+              label-width="68px"
+            >
+              <el-form-item label="椤圭洰鍚嶇О" prop="proName">
+                <el-input
+                  ref="inputName"
+                  v-model="queryParams.proName"
+                  placeholder="璇疯緭鍏ラ」鐩悕绉�"
+                  clearable
+                  @keyup.enter.native="handleSearchFor"
+                  style="width: 140px"
+                />
+              </el-form-item>
+              <el-form-item>
+                <el-button
+                  type="primary"
+                  icon="el-icon-search"
+                  size="mini"
+                  @click="handleSearchFor"
+                  >鎼滅储</el-button
+                >
+              </el-form-item>
+            </el-form>
+            <el-table
+              border
+              v-loading="loading"
+              ref="tre"
+              :data="Treedata"
+              @selection-change="handleChangesingle"
+              height="478"
+            >
+              <el-table-column type="selection" width="40px" align="center" />
+              <el-table-column label="椤圭洰鍚嶇О" align="center" prop="proName" />
+              <el-table-column
+                label="椤圭洰浠锋牸/鍏�"
+                align="center"
+                prop="proPrice"
+              />
+            </el-table>
+          </el-col>
+        </el-row>
+        <div slot="footer" class="dialog-footer1">
+          <el-button type="primary" @click="submitrighr">纭骞朵繚瀛�</el-button>
           <el-button @click="cancell">鍙� 娑�</el-button>
         </div>
       </el-dialog>
@@ -900,6 +1117,7 @@
   getProjectList,
   getPackageList,
   delegrouping,
+  getDetails,
 } from "@/api/system/comp";
 import { deptTreeSelect, projectGetList } from "@/api/system/tijian";
 import { getInfo } from "@/api/login";
@@ -913,7 +1131,6 @@
   ],
   data() {
     let checkPhoneNum = (rule, value, callback) => {
-      console.log(value);
       let patter = new RegExp(/^1\s*[3456789]\s*(\d\s*){9}$/);
       if (value == "" && value == undefined && !value) {
         return callback("");
@@ -931,6 +1148,8 @@
       id: "",
       // 閫変腑鏁扮粍
       ids: [],
+      // 鎺у埗鎬у埆閫夋嫨妗嗘槸鍚︾鐢�
+      isSexDisabled: false,
       dwIds: [],
       groupIds: [],
       deptList: [],
@@ -940,6 +1159,7 @@
       pacList: [],
       dataList: [],
       groupList: [],
+      dataLists: [],
       // 闈炲崟涓鐢�
       single: true,
       singleg: true,
@@ -960,6 +1180,7 @@
       open: false,
       opens: false,
       openss: false,
+      openOne: false,
       // 鏌ヨ鍙傛暟
       queryParams: {
         pageNum: 1,
@@ -994,9 +1215,9 @@
         gtAge: [{ required: true, validator: checkPhoneNum, trigger: "blur" }],
         limits: [{ required: true, validator: checkPhoneNum, trigger: "blur" }],
         ltAge: [{ required: true, validator: checkPhoneNum, trigger: "blur" }],
-        pacName: [
+        /*  pacName: [
           { required: true, validator: checkPhoneNum, trigger: "blur" },
-        ],
+        ], */
         payType: [
           { required: true, validator: checkPhoneNum, trigger: "blur" },
         ],
@@ -1011,31 +1232,31 @@
         contactPhone: [
           { required: true, validator: checkPhoneNum, trigger: "blur" },
         ],
-        taxNumber: [
-          { required: true, validator: checkPhoneNum, trigger: "blur" },
-        ],
-        legalPerson: [
-          { required: true, validator: checkPhoneNum, trigger: "blur" },
-        ],
-        registerAddress: [
-          { required: true, validator: checkPhoneNum, trigger: "blur" },
-        ],
-        bankAccount: [
-          { required: true, validator: checkPhoneNum, trigger: "blur" },
-        ],
-        countNum: [
-          { required: true, validator: checkPhoneNum, trigger: "blur" },
-        ],
-        principal: [
-          { required: true, validator: checkPhoneNum, trigger: "blur" },
-        ],
-        faxNumber: [
-          { required: true, validator: checkPhoneNum, trigger: "blur" },
-        ],
-        mailingAddress: [
-          { required: true, validator: checkPhoneNum, trigger: "blur" },
-        ],
-        email: [{ required: true, validator: checkPhoneNum, trigger: "blur" }],
+        // taxNumber: [
+        //   { required: true, validator: checkPhoneNum, trigger: "blur" },
+        // ],
+        // legalPerson: [
+        //   { required: true, validator: checkPhoneNum, trigger: "blur" },
+        // ],
+        // registerAddress: [
+        //   { required: true, validator: checkPhoneNum, trigger: "blur" },
+        // ],
+        // bankAccount: [
+        //   { required: true, validator: checkPhoneNum, trigger: "blur" },
+        // ],
+        // countNum: [
+        //   { required: true, validator: checkPhoneNum, trigger: "blur" },
+        // ],
+        // principal: [
+        //   { required: true, validator: checkPhoneNum, trigger: "blur" },
+        // ],
+        // faxNumber: [
+        //   { required: true, validator: checkPhoneNum, trigger: "blur" },
+        // ],
+        // mailingAddress: [
+        //   { required: true, validator: checkPhoneNum, trigger: "blur" },
+        // ],
+        // email: [{ required: true, validator: checkPhoneNum, trigger: "blur" }],
       },
     };
   },
@@ -1071,6 +1292,7 @@
     // 鍙栨秷濂楅
     cancell() {
       this.openss = false;
+      this.openOne = false;
       this.reset();
     },
     // 琛ㄥ崟閲嶇疆
@@ -1126,6 +1348,11 @@
       this.resetForm("queryForm");
       this.handleQuery();
     },
+    resetQuerys() {
+      (this.OnenewpacName = []),
+        (this.queryParams.price = 0),
+        this.$refs.tbone.toggleRowSelection(this.pacList[0], false);
+    },
     // 澶氶�夋閫変腑鏁版嵁
     handleSelectionChange(selection) {
       selection.forEach((item) => {
@@ -1144,9 +1371,24 @@
       }
       this.dwIds = selection.map((item) => item.id);
       this.singleg = !selection.length;
-      if (this.selectionList[0].id) {
+      if (this.selectionList.length && this.selectionList[0].id) {
         this.beCurrent();
+      } else {
+        this.GroupUpdate();
       }
+
+      /* if (this.selectionList.length) {
+        // 濡傛灉绗竴涓〃鏍兼湁閫変腑椤癸紝閫変腑绗簩涓〃鏍煎搴旂殑鏁版嵁
+        const selectedDeptId = this.selectionList[0].id; // 鍋囪姣忎釜椤规湁涓�涓敮涓�鐨� id
+        const correspondingGroups = this.groupingList.filter(
+          (group) => group.deptId === selectedDeptId
+        );
+        this.groupList = correspondingGroups;
+      } else {
+        // 濡傛灉娌℃湁閫変腑浠讳綍椤癸紝娓呯┖绗簩涓〃鏍肩殑閫変腑椤�
+        this.groupList = [];
+        this.$refs.tbs.clearSelection();
+      } */
     },
     /** 鏂板鎸夐挳鎿嶄綔 */
     handleAdd() {
@@ -1167,6 +1409,9 @@
     // 缁存姢閮ㄩ棬
     mainDepartment() {
       this.opens = true;
+
+      this.groupingList = [];
+
       if (this.form.drugManufacturerId) {
         this.beCurrentDept();
       }
@@ -1179,15 +1424,19 @@
       });
     },
     // 鎶樻墸
-    numberChange(currentValue, oldValue) {
+    numberChange(currentValue) {
       this.forms.limits = currentValue;
-      if (this.forms.limits > this.getInfodis) {
+      /* if (this.forms.limits > this.getInfodis) {
         this.forms.limits = this.getInfodis;
         this.forms.ysPrice = (
           this.forms.price *
           (this.forms.limits / 10)
         ).toFixed(2);
-      }
+      } */
+      this.forms.ysPrice = (
+        this.forms.price *
+        (this.forms.limits / 10)
+      ).toFixed(2);
     },
 
     changegroupingName() {
@@ -1212,36 +1461,36 @@
               index +
               1;
           });
-          if (this.groupList.length >= 1) {
-            if (this.groupList[0].id) {
-              getfzgrouping(this.groupList[0].id).then((response) => {
-                this.OnenewpacName = response.data.groupingProList;
-                this.queryParams.price = 0;
-                this.OnenewpacName.forEach((item) => {
-                  this.queryParams.price += item.proPrice;
-                });
-              });
-            }
-          }
+          // if (this.groupList.length >= 1) {
+          //   if (this.groupList[0].id) {
+          //     getfzgrouping(this.groupList[0].id).then((response) => {
+          //       this.OnenewpacName = response.data.groupingProList;
+          //       this.queryParams.price = 0;
+          //       this.OnenewpacName.forEach((item) => {
+          //         this.queryParams.price += item.proPrice;
+          //       });
+          //     });
+          //   }
+          // }
 
-          if (this.newpacName.length != 0) {
-            this.$nextTick(() => {
-              if (this.forms.pacName) {
-                this.newpacName.forEach((item, index) => {
-                  if (this.forms.pacName == item.pacName) {
-                    this.$refs.tbone.toggleRowSelection(
-                      this.newpacName[index],
-                      true
-                    );
-                  }
-                });
-              } else {
-                this.$refs.tbone.toggleRowSelection(this.newpacName[0], true);
-              }
-            });
-          } else {
-            this.$refs.tbone.clearSelection();
-          }
+          // if (this.newpacName.length != 0) {
+          //   this.$nextTick(() => {
+          //     if (this.forms.pacName) {
+          //       this.newpacName.forEach((item, index) => {
+          //         if (this.forms.pacName == item.pacName) {
+          //           this.$refs.tbone.toggleRowSelection(
+          //             this.newpacName[index],
+          //             true
+          //           );
+          //         }
+          //       });
+          //     } else {
+          //       this.$refs.tbone.toggleRowSelection(this.newpacName[0], true);
+          //     }
+          //   });
+          // } else {
+          //   this.$refs.tbone.clearSelection();
+          // }
         });
       } else {
         deptTreeSelect().then((response) => {
@@ -1253,35 +1502,35 @@
               index +
               1;
           });
-          if (this.groupList.length >= 1) {
-            if (this.groupList[0].id) {
-              getfzgrouping(this.groupList[0].id).then((response) => {
-                this.OnenewpacName = response.data.groupingProList;
-                this.queryParams.price = 0;
-                this.OnenewpacName.forEach((item) => {
-                  this.queryParams.price += item.proPrice;
-                });
-              });
-            }
-          }
-          if (this.newpacName.length != 0) {
-            this.$nextTick(() => {
-              if (this.forms.pacName) {
-                this.newpacName.forEach((item, index) => {
-                  if (this.forms.pacName == item.pacName) {
-                    this.$refs.tbone.toggleRowSelection(
-                      this.newpacName[index],
-                      true
-                    );
-                  }
-                });
-              } else {
-                this.$refs.tbone.toggleRowSelection(this.newpacName[0], true);
-              }
-            });
-          } else {
-            this.$refs.tbone.clearSelection();
-          }
+          // if (this.groupList.length >= 1) {
+          //   if (this.groupList[0].id) {
+          //     getfzgrouping(this.groupList[0].id).then((response) => {
+          //       this.OnenewpacName = response.data.groupingProList;
+          //       this.queryParams.price = 0;
+          //       this.OnenewpacName.forEach((item) => {
+          //         this.queryParams.price += item.proPrice;
+          //       });
+          //     });
+          //   }
+          // }
+          // if (this.newpacName.length != 0) {
+          //   this.$nextTick(() => {
+          //     if (this.forms.pacName) {
+          //       this.newpacName.forEach((item, index) => {
+          //         if (this.forms.pacName == item.pacName) {
+          //           this.$refs.tbone.toggleRowSelection(
+          //             this.newpacName[index],
+          //             true
+          //           );
+          //         }
+          //       });
+          //     } else {
+          //       this.$refs.tbone.toggleRowSelection(this.newpacName[0], true);
+          //     }
+          //   });
+          // } else {
+          //   this.$refs.tbone.clearSelection();
+          // }
         });
       }
       getProjectList().then((response) => {
@@ -1339,6 +1588,7 @@
     // 鍗曢」閫夊畾鎸夐挳
     resetright() {
       this.queryParams.price = 0;
+      // this.dataLists=JSON.parse(JSON.stringify(this.dataList));
       this.dataList.forEach((item) => {
         this.$refs.tre.toggleRowSelection(item, false);
         this.OnenewpacName.push(item);
@@ -1356,7 +1606,18 @@
         this.queryParams.price += item.proPrice;
       });
     },
-    submitrighr() {
+    handledbelete(row) {
+      this.queryParams.price = 0;
+      this.OnenewpacName.forEach((item, index) => {
+        if (item.proId == row.proId) {
+          this.OnenewpacName.splice(index, 1);
+        }
+      });
+      return this.OnenewpacName.forEach((item) => {
+        this.queryParams.price += item.proPrice;
+      });
+    },
+    /*  submitrighr() {
       if (this.pacList.length >= 1) {
         this.openss = false;
         this.forms.pacName = this.pacList[0].pacName;
@@ -1368,31 +1629,82 @@
       } else {
         this.$modal.msgError("璇烽�夋嫨濂楅");
       }
+    }, */
+    submitrighr() {
+      this.openOne = false;
+      // this.forms.pacName = this.pacList[0].pacName;
+      this.forms.price = this.queryParams.price;
+      this.forms.ysPrice = (
+        this.forms.price *
+        (this.forms.limits / 10)
+      ).toFixed(2);
+      // console.log(this.groupingList, 555);
+
+      let mapList = [];
+      this.OnenewpacName.forEach((item) => {
+        mapList.push({
+          proName: item.proName,
+          proId: item.proId,
+          proPrice: item.proPrice,
+        });
+      });
+
+      // 濡傛灉 selectionList 涓虹┖锛屼娇鐢� mapList 缁х画淇濆瓨
+      if (this.OnenewpacName.length === 0) {
+        this.$modal.msgError("璇峰厛閫変腑椤圭洰");
+        return; // 鎻愮ず鐢ㄦ埛閫変腑椤圭洰
+      }
+
+      let data = {
+        groupingName: this.forms.groupingName,
+        gtAge: this.forms.gtAge,
+        limits: this.forms.limits,
+        ltAge: this.forms.ltAge,
+        pacName: this.forms.pacName,
+        payType: this.forms.payType,
+        sex: this.forms.sex,
+        dwDeptId: this.selectionList.length > 0 ? this.selectionList[0].id : "", // 濡傛灉娌℃湁閫変腑閮ㄩ棬锛岃缃负绌�
+        dwId: this.selectionList.length > 0 ? this.selectionList[0].dwId : "",
+        mapList: mapList,
+        price: this.forms.price,
+        ysPrice: this.forms.ysPrice,
+        id: this.groupList[0].id,
+      };
+
+      // 鍙戦�佽姹備繚瀛樻暟鎹�
+      dwgrouping(data).then((res) => {
+        if (res.code == 200) {
+          this.beCurrent();
+          this.forms.groupingName = "";
+          this.forms.sex = "";
+          this.forms.pacName = "";
+          this.forms.price = "";
+          this.forms.ysPrice = "";
+          this.forms.payType = "";
+        }
+      });
+
+      // this.handleGroup();
     },
     // 濂楅鍗曢」鑾峰彇
     handleChangeOne(selection) {
-      this.pacList = selection;
-      this.OnenewpacName = [];
-      this.queryParams.price = 0;
-      this.pacList.forEach((item) => {
-        item.tjProjectList.forEach(item2 => {
-          this.OnenewpacName.push(item2)
-        })
-        this.OnenewpacName.forEach((item) => {
-          this.queryParams.price += item.proPrice;
-        });
-      });
-      if(this.dataList.length >= 1){
-        console.log(11111)
-          this.dataList.forEach(item1 => {
-            this.OnenewpacName.push(item1)
-          })
-          
-        }
       if (selection.length > 1) {
         let del_row = selection.shift();
         this.$refs.tbone.toggleRowSelection(del_row, false); //璁剧疆杩欎竴琛屽彇娑堥�変腑
       }
+      this.pacList = selection;
+
+      this.dataLists = [];
+      this.queryParams.price = 0;
+      this.pacList.forEach((item) => {
+        this.OnenewpacName = item.tjProjectList;
+      });
+      // this.dataLists.forEach((item2) => {
+      //   this.OnenewpacName.push(item2);
+      // });
+      this.OnenewpacName.forEach((item) => {
+        this.queryParams.price += item.proPrice;
+      });
     },
     beCurrentDept() {
       Deptlist(this.form.drugManufacturerId).then((response) => {
@@ -1432,7 +1744,27 @@
 
     handleChange(selection) {
       this.groupList = selection;
-      this.groupList.forEach((item) => {
+
+      if (selection.length > 0) {
+        this.groupList.forEach((item) => {
+          this.forms.groupingName = item.groupingName;
+          this.forms.gtAge = item.gtAge;
+          this.forms.limits = item.limits;
+          this.forms.ltAge = item.ltAge;
+          this.forms.pacName = item.pacName;
+          this.forms.payType = item.payType;
+          this.forms.sex = item.sex;
+          this.forms.price = item.price;
+          this.forms.ysPrice = item.ysPrice;
+        });
+        this.isSexDisabled = true; // 绂佺敤鎬у埆閫夋嫨
+      } else {
+        // 濡傛灉娌℃湁閫変腑琛岋紝娓呯┖琛ㄥ崟骞跺彇娑堢鐢�
+        this.GroupUpdate();
+        this.isSexDisabled = false; // 鎭㈠鎬у埆閫夋嫨妗嗕负鍙敤
+      }
+
+      /* this.groupList.forEach((item) => {
         this.forms.groupingName = item.groupingName;
         this.forms.gtAge = item.gtAge;
         this.forms.limits = item.limits;
@@ -1447,11 +1779,64 @@
         let del_row = selection.shift();
         this.$refs.tbs.toggleRowSelection(del_row, false); //璁剧疆杩欎竴琛屽彇娑堥�変腑
       }
+      if(selection.length > 0) {
+        this.isSexDisabled = true;
+      }
+      else {
+        this.isSexDisabled = false;
+      } */
       this.groupIds = selection.map((item) => item.id);
       this.singlegg = !selection.length;
     },
+    xiangmuWh() {
+      this.openOne = true;
+      this.title = "鍒嗙粍椤圭洰缁存姢";
+      this.OnenewpacName = [];
+      this.queryParams.price = 0;
+      this.loading = true;
+      let id = this.groupList[0].id;
+      // console.log(this.groupList[0].id, 9966);
+
+      getDetails(id).then((res) => {
+        this.OnenewpacName = res.data.groupingProList;
+        this.OnenewpacName.forEach((item, index) => {
+          this.queryParams.price += item.proPrice;
+        });
+        // return this.OnenewpacName.forEach((item) => {
+        //   this.queryParams.price += item.proPrice;
+        // });
+      });
+      if (this.forms.sex) {
+        deptTreeSelect(this.forms.sex).then((response) => {
+          // 濂楅鍚嶇О
+          this.newpacName = response.rows;
+
+          this.loading = false;
+          response.rows.forEach((item, index) => {
+            item.newID =
+              (this.queryParams.pageNum - 1) * this.queryParams.pageSize +
+              index +
+              1;
+          });
+        });
+      } else {
+        deptTreeSelect().then((response) => {
+          this.newpacName = response.rows;
+          this.loading = false;
+          response.rows.forEach((item, index) => {
+            item.newID =
+              (this.queryParams.pageNum - 1) * this.queryParams.pageSize +
+              index +
+              1;
+          });
+        });
+      }
+      getProjectList().then((response) => {
+        this.Treedata = response.data;
+      });
+    },
     //淇濆瓨鍒嗙粍
-    handleGroup() {
+    /* handleGroup() {
       if (this.selectionList.length <= 0) {
         this.$modal.msgError("璇峰厛閫変腑閮ㄩ棬鎴栨坊鍔犳柊鐨勯儴闂�");
       } else {
@@ -1503,6 +1888,7 @@
         dwgrouping(data).then((res) => {
           if (res.code == 200) {
             this.beCurrent();
+            this.groupingList = res.data.updatedGroupingList; 
             this.forms.groupingName = "";
             this.forms.sex = "";
             this.forms.pacName = "";
@@ -1512,10 +1898,74 @@
           }
         });
       }
+    }, */
+    handleGroup() {
+      // 濡傛灉娌℃湁閫変腑浠讳綍閮ㄩ棬锛堝嵆娌℃湁 selectionList锛夛紝鍙互鐩存帴浠� OnenewpacName 鑾峰彇鏁版嵁
+      let mapList = [];
+      this.OnenewpacName.forEach((item) => {
+        mapList.push({
+          proName: item.proName,
+          proId: item.proId,
+          proPrice: item.proPrice,
+        });
+      });
+
+      // 濡傛灉 selectionList 涓虹┖锛屼娇鐢� mapList 缁х画淇濆瓨
+      /* if (this.OnenewpacName.length === 0) {
+        this.$modal.msgError("璇峰厛閫変腑椤圭洰");
+        return; // 鎻愮ず鐢ㄦ埛閫変腑椤圭洰
+      } */
+
+      this.forms.ysPrice = (
+        this.forms.price *
+        (this.forms.limits / 10)
+      ).toFixed(2);
+
+      let data = {
+        groupingName: this.forms.groupingName,
+        gtAge: this.forms.gtAge,
+        limits: this.forms.limits,
+        ltAge: this.forms.ltAge,
+        pacName: this.forms.pacName,
+        payType: this.forms.payType,
+        sex: this.forms.sex,
+        dwDeptId: this.selectionList.length > 0 ? this.selectionList[0].id : "", // 濡傛灉娌℃湁閫変腑閮ㄩ棬锛岃缃负绌�
+        dwId: this.selectionList.length > 0 ? this.selectionList[0].dwId : "",
+        mapList: mapList,
+        price: this.forms.price,
+        ysPrice: this.forms.ysPrice,
+        id: this.groupList[0].id,
+      };
+
+      // 鍙戦�佽姹備繚瀛樻暟鎹�
+      dwgrouping(data).then((res) => {
+        if (res.code == 200) {
+          this.beCurrent();
+          this.forms.groupingName = "";
+          this.forms.sex = "";
+          this.forms.pacName = "";
+          this.forms.price = "";
+          this.forms.ysPrice = "";
+          this.forms.payType = "";
+        }
+      });
     },
     // 淇敼鍒嗙粍
     GroupUpdate() {
-      this.forms = {};
+      // this.forms = {};
+      this.forms = {
+        groupingName: "",
+        gtAge: "",
+        limits: "",
+        ltAge: "",
+        pacName: "",
+        payType: "",
+        sex: "",
+        price: "",
+        ysPrice: "",
+      };
+
+      // this.$refs.forms.resetFields();
     },
     beCurrent() {
       let data = {
@@ -1523,6 +1973,7 @@
         dwId: this.selectionList[0].dwId,
       };
       getDwAndDwDept(data).then((response) => {
+        // 閮ㄩ棬鍚嶇О
         this.groupingList = response.data;
         response.data.forEach((item, index) => {
           item.newID =
@@ -1588,11 +2039,19 @@
               this.getList();
             });
           } else {
-            addComp(this.form).then((response) => {
-              this.$modal.msgSuccess("鏂板鎴愬姛");
-              this.open = false;
-              this.getList();
-            });
+            if (
+              this.form.cnName &&
+              this.form.contactPerson &&
+              this.form.contactPhone
+            ) {
+              addComp(this.form).then((response) => {
+                this.$modal.msgSuccess("鏂板鎴愬姛");
+                this.open = false;
+                this.getList();
+              });
+            } else {
+              this.$modal.msgError("璇峰~鍐欏繀浼犻」");
+            }
           }
         }
       });

--
Gitblit v1.8.0