dedsudiyu 1 年之前
父節點
當前提交
2fa652aa1d

+ 8 - 0
src/api/iotDevice/index.js

@@ -122,6 +122,14 @@ export function iotDeviceExtraDeviceList(data) {
     data: data
   })
 }
+//批量添加-设备
+export function iotDeviceAddBatch(data) {
+  return request({
+    url: '/iot/device/addBatch',
+    method: 'post',
+    data: data
+  })
+}
 /************物联分类************/
 //物联分类列表
 export function iotTypeList(data) {

+ 21 - 12
src/views/iotDevice/intelligenceIot/iotHardware/addPage.vue

@@ -338,23 +338,32 @@
           // reservedField:type==1 ? (this.$refs.forElFormItem.formData?JSON.stringify(this.$refs.forElFormItem.formData):''):'',
         };
         //获取校区-楼栋-楼层数据
-        for(let i=0;i<self.treeOptions.length;i++){
-          if(self.treeOptions[i].id == self.newData.address[0]){
-            for(let o=0;o<self.treeOptions[i].buildFloorVoList.length;o++){
-              if(self.treeOptions[i].buildFloorVoList[o].id == self.newData.address[1]){
-                for(let x=0;x<self.treeOptions[i].buildFloorVoList[o].buildFloorVoList.length;x++){
-                  if(self.treeOptions[i].buildFloorVoList[o].buildFloorVoList[x].id == self.newData.address[2]){
-                    obj.schoolId = self.treeOptions[i].id;
-                    obj.schoolName = self.treeOptions[i].name;
-                    obj.buildId = self.treeOptions[i].buildFloorVoList[o].id;
-                    obj.buildName = self.treeOptions[i].buildFloorVoList[o].name;
-                    obj.floorId = self.treeOptions[i].buildFloorVoList[o].buildFloorVoList[x].id;
-                    obj.floorName = self.treeOptions[i].buildFloorVoList[o].buildFloorVoList[x].name;
+        if(self.newData.address[0]){
+          for(let i=0;i<self.treeOptions.length;i++){
+            if(self.treeOptions[i].id == self.newData.address[0]){
+              for(let o=0;o<self.treeOptions[i].buildFloorVoList.length;o++){
+                if(self.treeOptions[i].buildFloorVoList[o].id == self.newData.address[1]){
+                  for(let x=0;x<self.treeOptions[i].buildFloorVoList[o].buildFloorVoList.length;x++){
+                    if(self.treeOptions[i].buildFloorVoList[o].buildFloorVoList[x].id == self.newData.address[2]){
+                      obj.schoolId = self.treeOptions[i].id;
+                      obj.schoolName = self.treeOptions[i].name;
+                      obj.buildId = self.treeOptions[i].buildFloorVoList[o].id;
+                      obj.buildName = self.treeOptions[i].buildFloorVoList[o].name;
+                      obj.floorId = self.treeOptions[i].buildFloorVoList[o].buildFloorVoList[x].id;
+                      obj.floorName = self.treeOptions[i].buildFloorVoList[o].buildFloorVoList[x].name;
+                    }
                   }
                 }
               }
             }
           }
+        }else{
+          obj.schoolId = '';
+          obj.schoolName = '';
+          obj.buildId = '';
+          obj.buildName = '';
+          obj.floorId = '';
+          obj.floorName = '';
         }
         //获取实验室数据
         if(this.newData.subId){

+ 144 - 9
src/views/iotDevice/intelligenceIot/iotHardware/batchAddPage.vue

@@ -211,7 +211,7 @@
 
 <script>
   import { systemBuildingGetTreeList,laboratorySubRelInfoGetListByFloor } from "@/api/commonality/permission";
-  import { iotTypeGetAllTypes,iotTypeGetParamByTypeId,iotAttributeGetByTypeId,iotDeviceExtraDeviceList } from "@/api/iotDevice/index";
+  import { iotTypeGetAllTypes,iotTypeGetParamByTypeId,iotAttributeGetByTypeId,iotDeviceExtraDeviceList,iotDeviceAddBatch } from "@/api/iotDevice/index";
   export default {
     name: 'batchAddPage',
     props:{
@@ -225,14 +225,12 @@
         options:[],
         //楼栋楼层
         treeOptions:[],
-        //实验室数据
-        subOptions:[],
         //查询条件
         queryParams:{
           page:1,
           pageSize:20,
           typeKey:null,
-          state:false,
+          state:true,
         },
         //表格扩展选择器---需要在@selection-change绑定的方法内监控selection数组长度
         selectedData:{
@@ -252,7 +250,7 @@
         //属性信息
         attributeInfo:[],
         //配置信息
-        modelList:{},
+        modelList:[],
         rules:{},
         basicsRules:{
           deviceName: [
@@ -352,6 +350,9 @@
         }).then(function() {
         }).then(() => {
           self.formData.userList.splice(index,1);
+          if(!self.formData.userList[0]){
+            self.$set(self,'pageTitleName','');
+          }
         }).catch(() => {});
       },
       // 返回按钮
@@ -360,9 +361,109 @@
       },
       /** 提交按钮 */
       submitForm() {
+        let self = this;
         this.$refs["form"].validate(valid => {
           if (valid) {
-
+            let list = JSON.parse(JSON.stringify(this.formData.userList));
+            let newList = [];
+            for(let i=0;i<list.length;i++){
+              let obj = JSON.parse(JSON.stringify({
+                deviceNo : list[i].deviceNo,
+                deviceName : list[i].deviceName,
+                code : list[i].code,
+                attributeId : list[i].attributeId,
+                remark : list[i].remark,
+                typeKey : list[i].typeKey,
+                typeName : list[i].typeName,
+                typeId : list[i].typeId,
+              }));
+              //匹配校区-楼栋-楼层数据
+              if(list[i].address[0]){
+                for(let y=0;y<self.treeOptions.length;y++){
+                  if(self.treeOptions[y].id == list[i].address[0]){
+                    for(let o=0;o<self.treeOptions[y].buildFloorVoList.length;o++){
+                      if(self.treeOptions[y].buildFloorVoList[o].id == list[i].address[1]){
+                        for(let x=0;x<self.treeOptions[y].buildFloorVoList[o].buildFloorVoList.length;x++){
+                          if(self.treeOptions[y].buildFloorVoList[o].buildFloorVoList[x].id == list[i].address[2]){
+                            obj.schoolId = self.treeOptions[y].id;
+                            obj.schoolName = self.treeOptions[y].name;
+                            obj.buildId = self.treeOptions[y].buildFloorVoList[o].id;
+                            obj.buildName = self.treeOptions[y].buildFloorVoList[o].name;
+                            obj.floorId = self.treeOptions[y].buildFloorVoList[o].buildFloorVoList[x].id;
+                            obj.floorName = self.treeOptions[y].buildFloorVoList[o].buildFloorVoList[x].name;
+                          }
+                        }
+                      }
+                    }
+                  }
+                }
+              }else{
+                obj.schoolId = '';
+                obj.schoolName = '';
+                obj.buildId = '';
+                obj.buildName = '';
+                obj.floorId = '';
+                obj.floorName = '';
+              }
+              //匹配实验室数据
+              if(list[i].subId){
+                for(let o=0;o<list[i].subOptions.length;o++){
+                  if(list[i].subOptions[o].subId == list[i].subId){
+                    obj.subjectId = list[i].subOptions[o].subId
+                    obj.subjectName = list[i].subOptions[o].subName
+                    obj.room = list[i].subOptions[o].roomNum
+                  }
+                }
+              }else{
+                obj.subjectId = ''
+                obj.subjectName = ''
+                obj.room = ''
+              }
+              //匹配分类参数
+              let reservedField = {};
+              for(let o=0;o<self.modelList.length;o++){
+                reservedField[self.modelList[o].field] = list[i][self.modelList[o].field]
+              }
+              // delete list[i].showType;
+              // delete list[i].subOptions;
+              // delete list[i].address;
+              // delete list[i].subId;
+              // delete list[i].deviceNo;
+              // delete list[i].deviceName;
+              // delete list[i].code;
+              // delete list[i].attributeId;
+              // delete list[i].remark;
+              // delete list[i].typeKey;
+              // delete list[i].typeName;
+              // delete list[i].typeId;
+              obj.reservedField = JSON.stringify(reservedField)
+              newList.push(obj);
+            }
+            this.$confirm('是否确认提交?', "警告", {
+              confirmButtonText: "确定",
+              cancelButtonText: "取消",
+              type: "warning"
+            }).then(function() {
+            }).then(() => {
+              iotDeviceAddBatch(newList).then(response => {
+                self.msgSuccess(response.message)
+                self.$set(self,'formData',{
+                  userList:[],
+                });
+                self.$set(self,'queryParams',{
+                  page:1,
+                  pageSize:20,
+                  typeKey:null,
+                  state:true,
+                });
+                self.$set(self,'dataList',[]);
+                self.$set(self,'selectedData',{
+                  dialogTypeId:null,
+                  selection:{},
+                  userList:[],
+                });
+              })
+            }).catch(() => {});
           }
         })
       },
@@ -372,7 +473,7 @@
           page:1,
           pageSize:20,
           typeKey:null,
-          state:false,
+          state:true,
         });
         this.$set(this,'dataList',[]);
         this.$set(this,'selectedData',{
@@ -399,7 +500,36 @@
             self.$set(self,'pageTitleName',self.options[i].typeName);
           }
         }
-        this.$set(this.formData,'userList',JSON.parse(JSON.stringify(this.selectedData.userList)));
+        //条件过滤 剔除没有设备编号的设备
+        let list = [];
+        let listNum = 0;
+        for(let i=0;i<self.selectedData.userList.length;i++){
+          if(self.selectedData.userList[i].deviceNo){
+            let obj = {
+              deviceNo : self.selectedData.userList[i].deviceNo,
+              deviceName : self.selectedData.userList[i].deviceName?self.selectedData.userList[i].deviceName:'',
+              code : self.selectedData.userList[i].code?self.selectedData.userList[i].code:'',
+              attributeId : self.selectedData.userList[i].attributeId?self.selectedData.userList[i].attributeId:'',
+              address : self.selectedData.userList[i].address?self.selectedData.userList[i].address:'',
+              subId : self.selectedData.userList[i].subId?self.selectedData.userList[i].subId:'',
+              remark : self.selectedData.userList[i].remark?self.selectedData.userList[i].remark:'',
+              typeKey : '',
+              typeName : '',
+              typeId : '',
+            };
+            for(let o=0;o<self.modelList.length;o++){
+              obj[self.modelList[o].field] = self.selectedData.userList[i][self.modelList[o].field]
+            }
+            list.push(obj)
+          }else{
+            listNum++
+          }
+        }
+        if(!list[0]){
+          this.msgError('未检测到设备编号,请勾选带有设备编号的设备!')
+          return
+        }
+        this.$set(this.formData,'userList',JSON.parse(JSON.stringify(list)));
         //数据处理
         for(let i=0;i<self.formData.userList.length;i++){
           //写入设备类型相关数据
@@ -420,10 +550,15 @@
             self.$set(self.formData.userList[i],'attributeId','');
           }
           //写入设备状态
-          self.$set(self.formData.userList[i],'state',true);
+          // self.$set(self.formData.userList[i],'state',true);
+          //写入实验室列表选择字段
+          self.$set(self.formData.userList[i],'subOptions',[]);
           //写入页面展示状态
           self.$set(self.formData.userList[i],'showType',false);
         }
+        if(listNum != 0){
+          this.msgError('有'+listNum+'个设备,因没有设备编号,未加入编辑列表.')
+        }
         self.$set(self,'showType',false);
         self.$set(self,'dialogType',false);
       },

+ 52 - 44
src/views/iotDevice/monitoringWarning/messageTemplate/addPage.vue

@@ -139,28 +139,32 @@
               <el-option label="文本播报" :value="2"></el-option>
             </el-select>
           </el-form-item>
-          <el-form-item label="被叫人:" prop="receiver">
-            <el-select
-              style="width:500px;"
-              :disabled="showType"
-              v-model="newData.receiver"
-              collapse-tags
-              multiple
-              filterable
-              remote
-              clearable
-              reserve-keyword
-              @change="userSelectClick"
-              @clear="userClearClick"
-              placeholder="请选择"
-              :remote-method="userSelect">
-              <el-option
-                v-for="item in userOptions"
-                :key="item.userId"
-                :label="item.userName"
-                :value="item.userId">
-              </el-option>
-            </el-select>
+          <!--<el-form-item label="被叫人:" prop="receiver">-->
+            <!--<el-select-->
+              <!--style="width:500px;"-->
+              <!--:disabled="showType"-->
+              <!--v-model="newData.receiver"-->
+              <!--collapse-tags-->
+              <!--multiple-->
+              <!--filterable-->
+              <!--remote-->
+              <!--clearable-->
+              <!--reserve-keyword-->
+              <!--@change="userSelectClick"-->
+              <!--@clear="userClearClick"-->
+              <!--placeholder="请选择"-->
+              <!--:remote-method="userSelect">-->
+              <!--<el-option-->
+                <!--v-for="item in userOptions"-->
+                <!--:key="item.userId"-->
+                <!--:label="item.userName"-->
+                <!--:value="item.userId">-->
+              <!--</el-option>-->
+            <!--</el-select>-->
+          <!--</el-form-item>-->
+          <el-form-item label="手机号码:" prop="receiver">
+            <el-input :disabled="showType" v-model="newData.receiver"
+                      placeholder="请输入手机号码" maxLength="11" style="width:500px;"></el-input>
           </el-form-item>
           <el-form-item label="播放次数:" prop="retry">
             <el-input-number :disabled="showType" v-model="newData.retry"
@@ -172,29 +176,33 @@
             <el-input :disabled="showType" v-model="newData.agentId"
                       placeholder="请输入第三方ID" maxLength="200" style="width:500px;"></el-input>
           </el-form-item>
-          <el-form-item label="接收人:" prop="receiver">
-            <el-select
-              style="width:500px;"
-              :disabled="showType"
-              v-model="newData.receiver"
-              collapse-tags
-              multiple
-              filterable
-              remote
-              clearable
-              reserve-keyword
-              @change="userSelectClick"
-              @clear="userClearClick"
-              placeholder="请选择"
-              :remote-method="userSelect">
-              <el-option
-                v-for="item in userOptions"
-                :key="item.userId"
-                :label="item.userName"
-                :value="item.userId">
-              </el-option>
-            </el-select>
+          <el-form-item label="手机号码:" prop="receiver">
+            <el-input :disabled="showType" v-model="newData.receiver"
+                      placeholder="请输入手机号码" maxLength="11" style="width:500px;"></el-input>
           </el-form-item>
+          <!--<el-form-item label="接收人:" prop="receiver">-->
+            <!--<el-select-->
+              <!--style="width:500px;"-->
+              <!--:disabled="showType"-->
+              <!--v-model="newData.receiver"-->
+              <!--collapse-tags-->
+              <!--multiple-->
+              <!--filterable-->
+              <!--remote-->
+              <!--clearable-->
+              <!--reserve-keyword-->
+              <!--@change="userSelectClick"-->
+              <!--@clear="userClearClick"-->
+              <!--placeholder="请选择"-->
+              <!--:remote-method="userSelect">-->
+              <!--<el-option-->
+                <!--v-for="item in userOptions"-->
+                <!--:key="item.userId"-->
+                <!--:label="item.userName"-->
+                <!--:value="item.userId">-->
+              <!--</el-option>-->
+            <!--</el-select>-->
+          <!--</el-form-item>-->
           <!--<el-form-item label="短信签名:" prop="signature" v-if="newData.category == 1">-->
             <!--<el-input :disabled="showType" v-model="newData.signature"-->
                       <!--placeholder="请输入短信签名" maxLength="50" style="width:500px;"></el-input>-->