heyang 1 年之前
父節點
當前提交
3c99aa7c55
共有 1 個文件被更改,包括 45 次插入24 次删除
  1. 45 24
      src/views/safetyCheck/schoolInspection/inspectionPlan/addDialog.vue

+ 45 - 24
src/views/safetyCheck/schoolInspection/inspectionPlan/addDialog.vue

@@ -851,7 +851,9 @@ export default {
       deviceNumRight:0,
       deviceIdsRight:[],
       deviceDialogTableDataList:[],
+      deviceDialogList:[],//存储所有的设备
       dangerArr:[],
+      deviceIsEmpty:false,//如果是专项检查-判断是否选择检查范围和检查内容
       /*===================================文档预览===================================*/
       iframeSrc:"",
       /*===================================弹窗相关结束===================================*/
@@ -864,6 +866,8 @@ export default {
   mounted(){
     this.dangerList();
     this.initializationInterface();
+    this.deviceGetList();//查询所有设备
+
   },
   methods:{
     //初始化接口
@@ -992,6 +996,10 @@ export default {
               this.msgError('请添加至少一名巡查成员')
               return
             }
+            if(this.dialogForm.checkCategory == 2 && !this.deviceIsEmpty){
+              this.msgError('请选择检查内容')
+              return
+            }
             let obj = {
               title:this.dialogForm.title,
               checkType:this.dialogForm.checkType,
@@ -1097,8 +1105,9 @@ export default {
           list.push(self.deviceDialogTableDataList[i].id)
         }
         this.$set(this.dialogForm,'hazardIds',list.join(','));
-        this.$set(this.dialogForm,'hazardNum',self.deviceDialogTableDataList.length);
+        this.$set(this.dialogForm,'hazardNum',list.length);
         this.dialogClickType(1);
+        //实验室是否有当前设备
         let obj={
           "checkRange":this.dialogForm.checkRange,
           "collegeIds":this.dialogForm.checkRange==2?this.dialogForm.collegeIds+'':'',//学院ID转换字符串
@@ -1106,7 +1115,11 @@ export default {
           "hazardIds":this.dialogForm.hazardIds,
         }
         haveHazardInSub(obj).then(response => {
-
+          if(response.code==200){
+            this.deviceIsEmpty=true;
+          }else{
+            this.deviceIsEmpty=false;
+          }
         });
       }
     },
@@ -1131,6 +1144,19 @@ export default {
         this.$set(this,'addDialogBoxType',type);
       }else if(type == 6){//检查设备
         //设备
+        let list=[];
+        let list2=[];
+        if(this.dialogForm.hazardIds){
+          list=this.dialogForm.hazardIds.split(',')
+          for(let i=0;i<this.deviceDialogList.length;i++){
+            for(let b=0;b<list.length;b++){
+              if(list[b]==this.deviceDialogList[i].id){
+                list2.push(this.deviceDialogList[i])
+              }
+            }
+          }
+        }
+        this.$set(self,'deviceDialogTableDataList',list2);
         this.deviceResetQueryLeft();
         this.deviceResetQueryRight();
         this.$set(this,'addDialogBoxType',type);
@@ -1572,18 +1598,9 @@ export default {
       let self = this;
       let leftObj = JSON.parse(JSON.stringify(this.deviceQueryParamsLeft));
       leftObj.selectedHazardIds = [];
-
-      if(self.deviceDialogTableDataList[0]){
-        for(let i=0;i<self.deviceDialogTableDataList.length;i++){
-          leftObj.selectedHazardIds.push(self.deviceDialogTableDataList[i].id);
-        }
-      }else{
-        if(self.dialogForm.hazardIds){
-          leftObj.selectedHazardIds=self.dialogForm.hazardIds.split(',');
-        }
-
+      for(let i=0;i<self.deviceDialogTableDataList.length;i++){
+        leftObj.selectedHazardIds.push(self.deviceDialogTableDataList[i].id);
       }
-
       findDeviceList(leftObj).then(response => {
         this.deviceTotalLeft = response.total;
         this.deviceTableListLeft = response.rows;
@@ -1608,22 +1625,26 @@ export default {
       });
       this.deviceHandleQueryRight();
     },
+    //查询所有的设备
+    deviceGetList(){
+      let obj={
+        pageNum: 1,
+        pageSize: 200,
+        hazardTypeMode:"",
+        searchValue:"",
+        filtType:""
+      }
+      findDeviceList(obj).then(response => {
+        this.deviceDialogList=response.rows
+      });
+    },
     //查询接口
     deviceGetListRight(){
       let self = this;
       let rightObj = JSON.parse(JSON.stringify(this.deviceQueryParamsRight));
       rightObj.hazardIds = [];
-      if(self.deviceDialogTableDataList[0]){
-
-        for(let i=0;i<self.deviceDialogTableDataList.length;i++){
-          rightObj.hazardIds.push(self.deviceDialogTableDataList[i].id);
-        }
-      }else{
-        console.log(222)
-        if(self.dialogForm.hazardIds){
-          rightObj.hazardIds=self.dialogForm.hazardIds.split(',');
-        }
-
+      for(let i=0;i<self.deviceDialogTableDataList.length;i++){
+        rightObj.hazardIds.push(self.deviceDialogTableDataList[i].id);
       }
       findDeviceList(rightObj).then(response => {
         this.deviceTotalRight = response.total;