Browse Source

SAI级别、SAI类别下拉框级联

wangggziwen 2 years ago
parent
commit
5dd89d326b

+ 67 - 4
ui/src/views/production/apply/all/index.vue

@@ -318,7 +318,7 @@
           </el-descriptions-item>
           <el-descriptions-item label="SAI级别" :span="1">
             <el-form-item prop="saiLevel">
-              <el-select v-model="form.saiLevel" placeholder="请选择SAI级别">
+              <el-select v-model="form.saiLevel" placeholder="请选择SAI级别" @change="handleSaiLevelChange">
                 <el-option key="1" label="1" value="1"></el-option>
                 <el-option key="2" label="2" value="2"></el-option>
                 <el-option key="3" label="3" value="3"></el-option>
@@ -328,12 +328,13 @@
           <el-descriptions-item label="SAI类别" :span="2">
             <el-form-item prop="category">
               <el-select
+                @change="handleSaiCategoryChange"
                 filterable
                 clearable
                 v-model="form.category"
                 placeholder="请选择SAI类别">
                 <el-option
-                  v-for="dict in saiCategoryOptions"
+                  v-for="dict in saiCategoryOptions2"
                   :key="dict.dictValue"
                   :label="dict.dictLabel"
                   :value="dict.dictValue"
@@ -601,7 +602,18 @@
         </el-table-column>
         <el-table-column label="SAI类别" align="center" prop="category" :show-overflow-tooltip="true">
           <template slot-scope="scope">
-            <el-input v-model="scope.row.category" placeholder="请输入" />
+            <el-select
+              filterable
+              clearable
+              v-model="scope.row.category"
+              placeholder="请选择SAI类别">
+              <el-option
+                v-for="dict in saiCategoryOptions2"
+                :key="dict.dictValue"
+                :label="dict.dictLabel"
+                :value="dict.dictValue"
+              ></el-option>
+            </el-select>
           </template>
         </el-table-column>
         <el-table-column label="采取或要采取的措施" align="center" prop="actions" :show-overflow-tooltip="true"/>
@@ -700,6 +712,7 @@ export default {
       estimateFinishDateRange: [],
       // SAI类别列表
       saiCategoryOptions: [],
+      saiCategoryOptions2: [],
       fileList: [],
       // 统计至SAI检查台账的数据
       saiList: [],
@@ -932,6 +945,52 @@ export default {
     this.getCategoryList();
   },
   methods: {
+    // 处理SAI级别下拉框选中事件
+    handleSaiLevelChange() {
+      this.saiCategoryOptions2 = [];
+      let saiLevel = this.form.saiLevel;
+      let saiCategoryOptionsTemp = [];
+      for (let i = 0; i < this.saiCategoryOptions.length; i++) {
+        if (saiLevel == 1 && this.saiCategoryOptions[i].dictLabel.indexOf("-1-") != -1) {
+          let saiCategoryOption = {
+            dictValue: this.saiCategoryOptions[i].dictValue,
+            dictLabel: this.saiCategoryOptions[i].dictLabel,
+          };
+          saiCategoryOptionsTemp.push(saiCategoryOption);
+        }
+        if (saiLevel == 2 && this.saiCategoryOptions[i].dictLabel.indexOf("-2-") != -1) {
+          let saiCategoryOption = {
+            dictValue: this.saiCategoryOptions[i].dictValue,
+            dictLabel: this.saiCategoryOptions[i].dictLabel,
+          };
+          saiCategoryOptionsTemp.push(saiCategoryOption);
+        }
+        if (saiLevel == 3 && this.saiCategoryOptions[i].dictLabel.indexOf("-3-") != -1) {
+          let saiCategoryOption = {
+            dictValue: this.saiCategoryOptions[i].dictValue,
+            dictLabel: this.saiCategoryOptions[i].dictLabel,
+          };
+          saiCategoryOptionsTemp.push(saiCategoryOption);
+        }
+      }
+      this.saiCategoryOptions2 = saiCategoryOptionsTemp;
+    },
+    // 处理SAI类别下拉框选中事件
+    handleSaiCategoryChange() {
+      for (let i = 0; i < this.saiCategoryOptions.length; i++) {
+        if (this.form.category == this.saiCategoryOptions[i].dictValue) {
+          if (this.saiCategoryOptions[i].dictLabel.indexOf("-1-") != -1) {
+            this.form.saiLevel = 1;
+          }
+          if (this.saiCategoryOptions[i].dictLabel.indexOf("-2-") != -1) {
+            this.form.saiLevel = 2;
+          }
+          if (this.saiCategoryOptions[i].dictLabel.indexOf("-3-") != -1) {
+            this.form.saiLevel = 3;
+          }
+        }
+      }
+    },
     // SAI类别字典翻译
     saiCategoryFormat(row, column) {
       return this.selectDictLabel(this.saiCategoryOptions, row.category);
@@ -946,6 +1005,10 @@ export default {
               dictLabel: data[i].saiCategoryName,
               dictValue: data[i].saiCategoryId
             });
+            this.saiCategoryOptions2.push({
+              dictLabel: data[i].saiCategoryName,
+              dictValue: data[i].saiCategoryId
+            });
           }
         }
       });
@@ -1500,7 +1563,7 @@ export default {
             sai.source = "装置";
             sai.deptId = 103;
             sai.saiLevel = apply.saiLevel;
-            sai.category = apply.category;
+            sai.category = Number(apply.category);
             sai.applicant = apply.applicant;
             sai.applicantName = apply.applicantName;
             this.saiList.push(sai);

+ 67 - 4
ui/src/views/production/apply/mine/index.vue

@@ -318,7 +318,7 @@
           </el-descriptions-item>
           <el-descriptions-item label="SAI级别" :span="1">
             <el-form-item prop="saiLevel">
-              <el-select v-model="form.saiLevel" placeholder="请选择SAI级别">
+              <el-select v-model="form.saiLevel" placeholder="请选择SAI级别" @change="handleSaiLevelChange">
                 <el-option key="1" label="1" value="1"></el-option>
                 <el-option key="2" label="2" value="2"></el-option>
                 <el-option key="3" label="3" value="3"></el-option>
@@ -328,12 +328,13 @@
           <el-descriptions-item label="SAI类别" :span="2">
             <el-form-item prop="category">
               <el-select
+                @change="handleSaiCategoryChange"
                 filterable
                 clearable
                 v-model="form.category"
                 placeholder="请选择SAI类别">
                 <el-option
-                  v-for="dict in saiCategoryOptions"
+                  v-for="dict in saiCategoryOptions2"
                   :key="dict.dictValue"
                   :label="dict.dictLabel"
                   :value="dict.dictValue"
@@ -601,7 +602,18 @@
         </el-table-column>
         <el-table-column label="SAI类别" align="center" prop="category" :show-overflow-tooltip="true">
           <template slot-scope="scope">
-            <el-input v-model="scope.row.category" placeholder="请输入" />
+            <el-select
+              filterable
+              clearable
+              v-model="scope.row.category"
+              placeholder="请选择SAI类别">
+              <el-option
+                v-for="dict in saiCategoryOptions2"
+                :key="dict.dictValue"
+                :label="dict.dictLabel"
+                :value="dict.dictValue"
+              ></el-option>
+            </el-select>
           </template>
         </el-table-column>
         <el-table-column label="采取或要采取的措施" align="center" prop="actions" :show-overflow-tooltip="true"/>
@@ -700,6 +712,7 @@
         estimateFinishDateRange: [],
         // SAI类别列表
         saiCategoryOptions: [],
+        saiCategoryOptions2: [],
         fileList: [],
         // 统计至SAI检查台账的数据
         saiList: [],
@@ -932,6 +945,52 @@
       this.getCategoryList();
     },
     methods: {
+      // 处理SAI级别下拉框选中事件
+      handleSaiLevelChange() {
+        this.saiCategoryOptions2 = [];
+        let saiLevel = this.form.saiLevel;
+        let saiCategoryOptionsTemp = [];
+        for (let i = 0; i < this.saiCategoryOptions.length; i++) {
+          if (saiLevel == 1 && this.saiCategoryOptions[i].dictLabel.indexOf("-1-") != -1) {
+            let saiCategoryOption = {
+              dictValue: this.saiCategoryOptions[i].dictValue,
+              dictLabel: this.saiCategoryOptions[i].dictLabel,
+            };
+            saiCategoryOptionsTemp.push(saiCategoryOption);
+          }
+          if (saiLevel == 2 && this.saiCategoryOptions[i].dictLabel.indexOf("-2-") != -1) {
+            let saiCategoryOption = {
+              dictValue: this.saiCategoryOptions[i].dictValue,
+              dictLabel: this.saiCategoryOptions[i].dictLabel,
+            };
+            saiCategoryOptionsTemp.push(saiCategoryOption);
+          }
+          if (saiLevel == 3 && this.saiCategoryOptions[i].dictLabel.indexOf("-3-") != -1) {
+            let saiCategoryOption = {
+              dictValue: this.saiCategoryOptions[i].dictValue,
+              dictLabel: this.saiCategoryOptions[i].dictLabel,
+            };
+            saiCategoryOptionsTemp.push(saiCategoryOption);
+          }
+        }
+        this.saiCategoryOptions2 = saiCategoryOptionsTemp;
+      },
+      // 处理SAI类别下拉框选中事件
+      handleSaiCategoryChange() {
+        for (let i = 0; i < this.saiCategoryOptions.length; i++) {
+          if (this.form.category == this.saiCategoryOptions[i].dictValue) {
+            if (this.saiCategoryOptions[i].dictLabel.indexOf("-1-") != -1) {
+              this.form.saiLevel = 1;
+            }
+            if (this.saiCategoryOptions[i].dictLabel.indexOf("-2-") != -1) {
+              this.form.saiLevel = 2;
+            }
+            if (this.saiCategoryOptions[i].dictLabel.indexOf("-3-") != -1) {
+              this.form.saiLevel = 3;
+            }
+          }
+        }
+      },
       // SAI类别字典翻译
       saiCategoryFormat(row, column) {
         return this.selectDictLabel(this.saiCategoryOptions, row.category);
@@ -946,6 +1005,10 @@
                 dictLabel: data[i].saiCategoryName,
                 dictValue: data[i].saiCategoryId
               });
+              this.saiCategoryOptions2.push({
+                dictLabel: data[i].saiCategoryName,
+                dictValue: data[i].saiCategoryId
+              });
             }
           }
         });
@@ -1516,7 +1579,7 @@
               sai.source = "装置";
               sai.deptId = 103;
               sai.saiLevel = apply.saiLevel;
-              sai.category = apply.category;
+              sai.category = Number(apply.category);
               sai.applicant = apply.applicant;
               sai.applicantName = apply.applicantName;
               this.saiList.push(sai);

+ 67 - 4
ui/src/views/production/apply/pending/index.vue

@@ -318,7 +318,7 @@
           </el-descriptions-item>
           <el-descriptions-item label="SAI级别" :span="1">
             <el-form-item prop="saiLevel">
-              <el-select v-model="form.saiLevel" placeholder="请选择SAI级别">
+              <el-select v-model="form.saiLevel" placeholder="请选择SAI级别" @change="handleSaiLevelChange">
                 <el-option key="1" label="1" value="1"></el-option>
                 <el-option key="2" label="2" value="2"></el-option>
                 <el-option key="3" label="3" value="3"></el-option>
@@ -328,12 +328,13 @@
           <el-descriptions-item label="SAI类别" :span="2">
             <el-form-item prop="category">
               <el-select
+                @change="handleSaiCategoryChange"
                 filterable
                 clearable
                 v-model="form.category"
                 placeholder="请选择SAI类别">
                 <el-option
-                  v-for="dict in saiCategoryOptions"
+                  v-for="dict in saiCategoryOptions2"
                   :key="dict.dictValue"
                   :label="dict.dictLabel"
                   :value="dict.dictValue"
@@ -601,7 +602,18 @@
         </el-table-column>
         <el-table-column label="SAI类别" align="center" prop="category" :show-overflow-tooltip="true">
           <template slot-scope="scope">
-            <el-input v-model="scope.row.category" placeholder="请输入" />
+            <el-select
+              filterable
+              clearable
+              v-model="scope.row.category"
+              placeholder="请选择SAI类别">
+              <el-option
+                v-for="dict in saiCategoryOptions2"
+                :key="dict.dictValue"
+                :label="dict.dictLabel"
+                :value="dict.dictValue"
+              ></el-option>
+            </el-select>
           </template>
         </el-table-column>
         <el-table-column label="采取或要采取的措施" align="center" prop="actions" :show-overflow-tooltip="true"/>
@@ -700,6 +712,7 @@
         estimateFinishDateRange: [],
         // SAI类别列表
         saiCategoryOptions: [],
+        saiCategoryOptions2: [],
         fileList: [],
         // 统计至SAI检查台账的数据
         saiList: [],
@@ -932,6 +945,52 @@
       this.getCategoryList();
     },
     methods: {
+      // 处理SAI级别下拉框选中事件
+      handleSaiLevelChange() {
+        this.saiCategoryOptions2 = [];
+        let saiLevel = this.form.saiLevel;
+        let saiCategoryOptionsTemp = [];
+        for (let i = 0; i < this.saiCategoryOptions.length; i++) {
+          if (saiLevel == 1 && this.saiCategoryOptions[i].dictLabel.indexOf("-1-") != -1) {
+            let saiCategoryOption = {
+              dictValue: this.saiCategoryOptions[i].dictValue,
+              dictLabel: this.saiCategoryOptions[i].dictLabel,
+            };
+            saiCategoryOptionsTemp.push(saiCategoryOption);
+          }
+          if (saiLevel == 2 && this.saiCategoryOptions[i].dictLabel.indexOf("-2-") != -1) {
+            let saiCategoryOption = {
+              dictValue: this.saiCategoryOptions[i].dictValue,
+              dictLabel: this.saiCategoryOptions[i].dictLabel,
+            };
+            saiCategoryOptionsTemp.push(saiCategoryOption);
+          }
+          if (saiLevel == 3 && this.saiCategoryOptions[i].dictLabel.indexOf("-3-") != -1) {
+            let saiCategoryOption = {
+              dictValue: this.saiCategoryOptions[i].dictValue,
+              dictLabel: this.saiCategoryOptions[i].dictLabel,
+            };
+            saiCategoryOptionsTemp.push(saiCategoryOption);
+          }
+        }
+        this.saiCategoryOptions2 = saiCategoryOptionsTemp;
+      },
+      // 处理SAI类别下拉框选中事件
+      handleSaiCategoryChange() {
+        for (let i = 0; i < this.saiCategoryOptions.length; i++) {
+          if (this.form.category == this.saiCategoryOptions[i].dictValue) {
+            if (this.saiCategoryOptions[i].dictLabel.indexOf("-1-") != -1) {
+              this.form.saiLevel = 1;
+            }
+            if (this.saiCategoryOptions[i].dictLabel.indexOf("-2-") != -1) {
+              this.form.saiLevel = 2;
+            }
+            if (this.saiCategoryOptions[i].dictLabel.indexOf("-3-") != -1) {
+              this.form.saiLevel = 3;
+            }
+          }
+        }
+      },
       // SAI类别字典翻译
       saiCategoryFormat(row, column) {
         return this.selectDictLabel(this.saiCategoryOptions, row.category);
@@ -946,6 +1005,10 @@
                 dictLabel: data[i].saiCategoryName,
                 dictValue: data[i].saiCategoryId
               });
+              this.saiCategoryOptions2.push({
+                dictLabel: data[i].saiCategoryName,
+                dictValue: data[i].saiCategoryId
+              });
             }
           }
         });
@@ -1513,7 +1576,7 @@
               sai.source = "装置";
               sai.deptId = 103;
               sai.saiLevel = apply.saiLevel;
-              sai.category = apply.category;
+              sai.category = Number(apply.category);
               sai.applicant = apply.applicant;
               sai.applicantName = apply.applicantName;
               this.saiList.push(sai);

+ 53 - 2
ui/src/views/production/check/index.vue

@@ -144,7 +144,7 @@
           <el-input v-model="form.dificiency" placeholder="请输入识别出的安全问题" />
         </el-form-item>
         <el-form-item label="SAI级别" prop="saiLevel">
-          <el-select v-model="form.saiLevel" placeholder="请选择SAI级别">
+          <el-select v-model="form.saiLevel" placeholder="请选择SAI级别" @change="handleSaiLevelChange">
             <el-option key="1" label="1" value="1"></el-option>
             <el-option key="2" label="2" value="2"></el-option>
             <el-option key="3" label="3" value="3"></el-option>
@@ -152,12 +152,13 @@
         </el-form-item>
         <el-form-item :label="$t('SAI类别')" prop="category">
           <el-select
+            @change="handleSaiCategoryChange"
             filterable
             clearable
             v-model="form.category"
             placeholder="请选择SAI类别">
             <el-option
-              v-for="dict in saiCategoryOptions"
+              v-for="dict in saiCategoryOptions2"
               :key="dict.dictValue"
               :label="dict.dictLabel"
               :value="dict.dictValue"
@@ -253,6 +254,7 @@ export default {
     return {
       // SAI类别列表
       saiCategoryOptions: [],
+      saiCategoryOptions2: [],
       // 登记人列表
       applicantOptions: [],
       score: null,
@@ -368,6 +370,53 @@ export default {
     this.getCategoryList();
   },
   methods: {
+
+    // 处理SAI级别下拉框选中事件
+    handleSaiLevelChange() {
+      this.saiCategoryOptions2 = [];
+      let saiLevel = this.form.saiLevel;
+      let saiCategoryOptionsTemp = [];
+      for (let i = 0; i < this.saiCategoryOptions.length; i++) {
+        if (saiLevel == 1 && this.saiCategoryOptions[i].dictLabel.indexOf("-1-") != -1) {
+          let saiCategoryOption = {
+            dictValue: this.saiCategoryOptions[i].dictValue,
+            dictLabel: this.saiCategoryOptions[i].dictLabel,
+          };
+          saiCategoryOptionsTemp.push(saiCategoryOption);
+        }
+        if (saiLevel == 2 && this.saiCategoryOptions[i].dictLabel.indexOf("-2-") != -1) {
+          let saiCategoryOption = {
+            dictValue: this.saiCategoryOptions[i].dictValue,
+            dictLabel: this.saiCategoryOptions[i].dictLabel,
+          };
+          saiCategoryOptionsTemp.push(saiCategoryOption);
+        }
+        if (saiLevel == 3 && this.saiCategoryOptions[i].dictLabel.indexOf("-3-") != -1) {
+          let saiCategoryOption = {
+            dictValue: this.saiCategoryOptions[i].dictValue,
+            dictLabel: this.saiCategoryOptions[i].dictLabel,
+          };
+          saiCategoryOptionsTemp.push(saiCategoryOption);
+        }
+      }
+      this.saiCategoryOptions2 = saiCategoryOptionsTemp;
+    },
+    // 处理SAI类别下拉框选中事件
+    handleSaiCategoryChange() {
+      for (let i = 0; i < this.saiCategoryOptions.length; i++) {
+        if (this.form.category == this.saiCategoryOptions[i].dictValue) {
+          if (this.saiCategoryOptions[i].dictLabel.indexOf("-1-") != -1) {
+            this.form.saiLevel = 1;
+          }
+          if (this.saiCategoryOptions[i].dictLabel.indexOf("-2-") != -1) {
+            this.form.saiLevel = 2;
+          }
+          if (this.saiCategoryOptions[i].dictLabel.indexOf("-3-") != -1) {
+            this.form.saiLevel = 3;
+          }
+        }
+      }
+    },
     // SAI类别字典翻译
     saiCategoryFormat(row, column) {
       return this.selectDictLabel(this.saiCategoryOptions, row.category);
@@ -507,7 +556,9 @@ export default {
       this.reset();
       const saiId = row.saiId || this.ids
       getSai(saiId).then(response => {
+        this.saiCategoryOptions2 = this.saiCategoryOptions;
         this.form = response.data;
+        this.form.category = Number(this.form.category);
         this.open = true;
         this.title = "修改SAI信息";
       });