|
@@ -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);
|
|
|
},
|