From c92f19bea0eab25cfc6b9ee6c338e62dde4b44da Mon Sep 17 00:00:00 2001
From: hdy <1105738590@qq.com>
Date: 星期二, 19 三月 2024 14:08:52 +0800
Subject: [PATCH] 设备保养计划修改

---
 jcdm-ui/src/views/main/em/inspectionPlan/machinery.vue  |   51 ++++++----------
 jcdm-ui/src/views/main/em/inspectionPlan/index.vue      |   24 ++++++-
 jcdm-ui/src/components/inspectionPlanItems/index.vue    |    2 
 jcdm-ui/src/views/main/em/inspectionPlan/subject.vue    |   70 ++++++++++-------------
 jcdm-ui/src/components/inspectionPlanArchives/index.vue |    9 --
 5 files changed, 72 insertions(+), 84 deletions(-)

diff --git a/jcdm-ui/src/components/inspectionPlanArchives/index.vue b/jcdm-ui/src/components/inspectionPlanArchives/index.vue
index 49a0dad..f787cbb 100644
--- a/jcdm-ui/src/components/inspectionPlanArchives/index.vue
+++ b/jcdm-ui/src/components/inspectionPlanArchives/index.vue
@@ -91,19 +91,12 @@
       machineryList: [],
       // 寮瑰嚭灞傛爣棰�
       title: "",
-      // 璁惧绫诲瀷鏍戦�夐」
-      machineryTypeOptions: [],
-      //杞﹂棿閫夐」
-      workshopOptions:[],
       // 鏄惁鏄剧ず寮瑰嚭灞�
       open: false,
       //鑷姩鐢熸垚鐗╂枡缂栫爜鏍囪瘑
       autoGenFlag: false,
       // 琛ㄥ崟鍙傛暟
       form: {},
-      defaultProps: {
-        children: "children",
-      },
       // 鏌ヨ鍙傛暟
       queryParams: {
         pageNum: 1,
@@ -145,7 +138,7 @@
     },
     // 澶氶�夋閫変腑鏁版嵁
     handleSelectionChange(selection) {
-      this.ids = selection.map(item => item.machineryId);
+      this.ids = selection.map(item => item.subjectId);
       this.selectedRows = selection;
       this.single = selection.length != 1;
       this.multiple = !selection.length;
diff --git a/jcdm-ui/src/components/inspectionPlanItems/index.vue b/jcdm-ui/src/components/inspectionPlanItems/index.vue
index df52ff4..b93c435 100644
--- a/jcdm-ui/src/components/inspectionPlanItems/index.vue
+++ b/jcdm-ui/src/components/inspectionPlanItems/index.vue
@@ -1,5 +1,5 @@
 <template>
-  <el-dialog title="璁惧閫夋嫨"
+  <el-dialog title="椤圭洰閫夋嫨"
              v-if="showFlag"
              :visible.sync="showFlag"
              :modal= false
diff --git a/jcdm-ui/src/views/main/em/inspectionPlan/index.vue b/jcdm-ui/src/views/main/em/inspectionPlan/index.vue
index b4b7d6c..e601391 100644
--- a/jcdm-ui/src/views/main/em/inspectionPlan/index.vue
+++ b/jcdm-ui/src/views/main/em/inspectionPlan/index.vue
@@ -217,20 +217,20 @@
           <Checkmachinery ref="machinerylist"  @inSelected="onMachineryAdd"></Checkmachinery>
         </el-tab-pane>
         <el-tab-pane label="鐐规椤圭洰">
-          <Checksubject ref="subjectlist"></Checksubject>
+          <Checksubject ref="subjectlist"      @subSelected="subMachineryAdd"></Checksubject>
             </el-tab-pane>
           </el-tabs>
       <el-divider></el-divider>
         <el-button type="primary" @click="submitForm">纭� 瀹�</el-button>
         <el-button @click="cancel">鍙� 娑�</el-button>
-      <el-button @click="checkMachineryAdd">娴嬭瘯</el-button>
     </el-dialog>
   </div>
 </template>
 
 <script>
 import { listInspectionPlan, getInspectionPlan, delInspectionPlan, addInspectionPlan, updateInspectionPlan } from "@/api/main/em/inspectionPlan/inspectionPlan";
-import { listInspectionPlanArchives, delInspectionPlanArchives, addInspectionPlanArchives} from "@/api/main/em/inspectionPlanArchives/inspectionPlanArchives";
+import { listInspectionPlanArchives, delInspectionPlanArchives, addInspectionPlanArchives,getInspectionPlanArchives} from "@/api/main/em/inspectionPlanArchives/inspectionPlanArchives";
+import {listInspectionPlanItems,delInspectionPlanItems,addInspectionPlanItems,getInspectionPlanItems} from "@/api/main/em/inspectionPlanItems/inspectionPlanItems";
 import Checkmachinery from "./machinery.vue"
 import Checksubject from "./subject.vue"
 
@@ -257,6 +257,7 @@
       // 鐐规淇濆吇璁″垝琛ㄦ牸鏁版嵁
       inspectionPlanList: [],
       machineryList: [],
+      subjectList: [],
       // 寮瑰嚭灞傛爣棰�
       title: "",
       // 鏄惁鏄剧ず寮瑰嚭灞�
@@ -391,6 +392,11 @@
         this.machineryList = checkmachineryList
       }
     },
+    subMachineryAdd(checksubjectList){
+      if(checksubjectList !=null && checksubjectList.length >0){
+        this.subjectList = checksubjectList
+      }
+    },
     /** 鎼滅储鎸夐挳鎿嶄綔 */
     handleQuery() {
       this.queryParams.pageNum = 1;
@@ -423,14 +429,20 @@
         this.titleName = "淇敼鐐规淇濆吇璁″垝";
       });
     },
-    /** 璁惧娓呭崟鏂板 */
-    checkMachineryAdd(){
+    /** 瀛愯〃娓呭崟鏂板 */
+    checkAdd(){
       for (let i = 0; i < this.machineryList.length; i++) {
         this.machineryList[i].planCode = this.form.planCode
         addInspectionPlanArchives(this.machineryList[i]).then(response =>{
         });
       }
+      for (let i = 0; i < this.subjectList.length; i++) {
+        this.subjectList[i].planCode = this.form.planCode
+        addInspectionPlanItems(this.subjectList[i]).then(response =>{
+        });
+      }
     },
+
     /** 鎻愪氦鎸夐挳 */
     submitForm() {
       this.$refs["form"].validate(valid => {
@@ -441,12 +453,14 @@
               this.open = false;
               this.getList();
             });
+            this.checkAdd()
           } else {
             addInspectionPlan(this.form).then(response => {
               this.$modal.msgSuccess("鏂板鎴愬姛");
               this.open = false;
               this.getList();
             });
+            this.checkAdd()
           }
         }
       });
diff --git a/jcdm-ui/src/views/main/em/inspectionPlan/machinery.vue b/jcdm-ui/src/views/main/em/inspectionPlan/machinery.vue
index b3634e6..ca066eb 100644
--- a/jcdm-ui/src/views/main/em/inspectionPlan/machinery.vue
+++ b/jcdm-ui/src/views/main/em/inspectionPlan/machinery.vue
@@ -11,20 +11,9 @@
           v-hasPermi="['mes:dv:checkplan:add']"
         >鏂板</el-button>
       </el-col>
-      <el-col :span="1.5">
-        <el-button
-          type="danger"
-          plain
-          icon="el-icon-delete"
-          size="mini"
-          :disabled="multiple"
-          @click="handleDelete"
-          v-hasPermi="['mes:dv:checkplan:remove']"
-        >鍒犻櫎</el-button>
-      </el-col>
     </el-row>
     <MachinerySelect ref="machinerySelect" @onSelected="onMachineryAdd" ></MachinerySelect>
-    <el-table v-loading="loading" :data="checkmachineryList" @selection-change="handleSelectionChange">
+    <el-table v-loading="loading" :data="checkmachineryList" >
       <el-table-column label="璁惧缂栫爜" align="center" prop="equipmentCode" />
       <el-table-column label="璁惧鍚嶇О" align="center" prop="equipmentName" />
       <el-table-column label="鍝佺墝" align="center" prop="equipmentBrand" />
@@ -36,7 +25,7 @@
             size="mini"
             type="danger"
             icon="el-icon-delete"
-            @click="handleDelete(scope.row)"
+            @click="deleteSelectedColumns(scope.row)"
           >鍒犻櫎</el-button>
         </template>
       </el-table-column>
@@ -79,7 +68,7 @@
       total: 0,
       // 鐐规璁惧琛ㄦ牸鏁版嵁
       checkmachineryList: [],
-      // 寮瑰嚭灞傛爣棰�
+        // 寮瑰嚭灞傛爣棰�
       title: "",
       // 鏄惁鏄剧ず寮瑰嚭灞�
       open: false,
@@ -102,7 +91,21 @@
     this.getList();
   },
   methods: {
-    /** 鏌ヨ鐐规璁惧鍒楄〃 */
+
+    deleteSelectedColumns(row) {
+      const index = this.checkmachineryList.findIndex(item => item.id === row.id);
+      if (index !== -1) {
+        this.checkmachineryList.splice(index, 1);
+      } else {
+        this.$message({
+          message: '鏈壘鍒板叿鏈夎ID鐨勯」鐩�',
+          type: 'warning'
+        });
+      }
+      this.$emit('inSelected',this.checkmachineryList);
+
+    },
+  /** 鏌ヨ鐐规璁惧鍒楄〃 */
     getList() {
       this.loading = true;
       listInspectionPlanArchives(this.queryParams).then(response => {
@@ -112,12 +115,7 @@
       });
     },
 
-    // 澶氶�夋閫変腑鏁版嵁
-    handleSelectionChange(selection) {
-      this.ids = selection.map(item => item.recordId)
-      this.single = selection.length!==1
-      this.multiple = !selection.length
-    },
+
     /** 鏂板鎸夐挳鎿嶄綔 */
     handleAdd() {
       this.$refs.machinerySelect.showFlag = true;
@@ -140,16 +138,7 @@
       this.$emit('inSelected',this.checkmachineryList);
       console.log(this.checkmachineryList)
     },
-    /** 鍒犻櫎鎸夐挳鎿嶄綔 */
-    handleDelete(row) {
-      const recordIds = row.recordId || this.ids;
-      this.$modal.confirm('鏄惁纭鍒犻櫎鐐规璁惧缂栧彿涓�"' + recordIds + '"鐨勬暟鎹」锛�').then(function() {
-        return delInspectionPlanArchives(recordIds);
-      }).then(() => {
-        this.getList();
-        this.$modal.msgSuccess("鍒犻櫎鎴愬姛");
-      }).catch(() => {});
-    }
+
   }
 };
 </script>
diff --git a/jcdm-ui/src/views/main/em/inspectionPlan/subject.vue b/jcdm-ui/src/views/main/em/inspectionPlan/subject.vue
index ed0aebc..6b44127 100644
--- a/jcdm-ui/src/views/main/em/inspectionPlan/subject.vue
+++ b/jcdm-ui/src/views/main/em/inspectionPlan/subject.vue
@@ -11,21 +11,9 @@
           v-hasPermi="['mes:dv:checkplan:add']"
         >鏂板</el-button>
       </el-col>
-      <el-col :span="1.5">
-        <el-button
-          type="danger"
-          plain
-          icon="el-icon-delete"
-          size="mini"
-          :disabled="multiple"
-          @click="handleDelete"
-          v-hasPermi="['mes:dv:checkplan:remove']"
-        >鍒犻櫎</el-button>
-      </el-col>
     </el-row>
     <DvsubjectSelect ref="subjectSelect"  @onSelected="onSubjectSelected"></DvsubjectSelect>
-    <el-table v-loading="loading" :data="checksubjectList" @selection-change="handleSelectionChange">
-      <el-table-column type="selection" width="55" align="center" />
+    <el-table v-loading="loading" :data="checksubjectList" >
       <el-table-column label="椤圭洰缂栫爜" align="center" prop="itemsCode" />
       <el-table-column label="椤圭洰鍚嶇О" align="center" prop="itemsName" />
       <el-table-column label="椤圭洰绫诲瀷" align="center" prop="itemsType">
@@ -35,6 +23,16 @@
       </el-table-column>
       <el-table-column label="椤圭洰鍐呭" align="center" width="300px" prop="itemsContent" />
       <el-table-column label="鏍囧噯" align="center" width="300px" prop="standard" />
+      <el-table-column label="鎿嶄綔" align="center" >
+        <template slot-scope="scope">
+          <el-button
+            size="mini"
+            type="danger"
+            icon="el-icon-delete"
+            @click="deleteSelectedColumns(scope.row)"
+          >鍒犻櫎</el-button>
+        </template>
+      </el-table-column>
     </el-table>
 
     <pagination
@@ -98,45 +96,39 @@
     this.getList();
   },
   methods: {
+    deleteSelectedColumns(row) {
+      const index = this.checksubjectList.findIndex(item => item.id === row.id);
+      if (index !== -1) {
+        this.checksubjectList.splice(index, 1);
+      } else {
+        this.$message({
+          message: '鏈壘鍒板叿鏈夎ID鐨勯」鐩�',
+          type: 'warning'
+        });
+      }
+      this.$emit('subSelected',this.checksubjectList);
+
+    },
     /** 鏌ヨ鐐规椤圭洰鍒楄〃 */
     getList() {
       this.loading = true;
       listInspectionPlanItems(this.queryParams).then(response => {
-        this.checksubjectList = response.rows;
+        // this.checksubjectList = response.rows;
         this.total = response.total;
         this.loading = false;
         // console.log(response.rows)
       });
     },
-    // 澶氶�夋閫変腑鏁版嵁
-    handleSelectionChange(selection) {
-      this.ids = selection.map(item => item.recordId)
-      this.single = selection.length!==1
-      this.multiple = !selection.length
-    },
     /** 鏂板鎸夐挳鎿嶄綔 */
     handleAdd() {
         this.$refs.subjectSelect.showFlag = true;
     },
-    onSubjectSelected(rows){
-        if(rows != null && rows.length >0){
-            rows.forEach(row => {
-                row.planId= this.planId;
-              addInspectionPlanItems(row).then(response => {
-                    this.getList();
-                });
-            });
-        }
-    },
-    /** 鍒犻櫎鎸夐挳鎿嶄綔 */
-    handleDelete(row) {
-      const recordIds = row.recordId || this.ids;
-      this.$modal.confirm('鏄惁纭鍒犻櫎鐐规椤圭洰缂栧彿涓�"' + recordIds + '"鐨勬暟鎹」锛�').then(function() {
-        return delInspectionPlanItems(recordIds);
-      }).then(() => {
-        this.getList();
-        this.$modal.msgSuccess("鍒犻櫎鎴愬姛");
-      }).catch(() => {});
+    onSubjectSelected(selectedRows){
+      if(selectedRows !=null && selectedRows.length >0){
+        this.checksubjectList = selectedRows
+      }
+      this.$emit('subSelected',this.checksubjectList);
+      console.log(this.checksubjectList)
     },
 
   }

--
Gitblit v1.9.3