|
|
|
|
@ -160,480 +160,468 @@ export default { |
|
|
|
|
headers: {}, |
|
|
|
|
labId: '' |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
watch: { |
|
|
|
|
detailForm(newVal, oldVal) { |
|
|
|
|
if (JSON.stringify(newVal) != '{}') { |
|
|
|
|
this.deviceList = [] |
|
|
|
|
this.detailForm = newVal |
|
|
|
|
this.addForm = { |
|
|
|
|
...this.detailForm, |
|
|
|
|
unitId: newVal.deptId, |
|
|
|
|
unitName: newVal.deptName, |
|
|
|
|
content: newVal.planContent, |
|
|
|
|
} |
|
|
|
|
this.floorArr = [] |
|
|
|
|
this.roomArr = [] |
|
|
|
|
if (newVal.details && newVal.details.length != 0) { |
|
|
|
|
this.tableData = this.getDeepCode(newVal.details, []) |
|
|
|
|
this.tableData.map(item => { |
|
|
|
|
item.period = item.period |
|
|
|
|
}) |
|
|
|
|
this.changeUnit(newVal.deptId) |
|
|
|
|
}, |
|
|
|
|
watch: { |
|
|
|
|
detailForm(newVal, oldVal) { |
|
|
|
|
if (JSON.stringify(newVal) != '{}') { |
|
|
|
|
console.log('JSON.stringify(newVal)---------------------->',JSON.stringify(newVal)) |
|
|
|
|
this.deviceList = [] |
|
|
|
|
this.detailForm = newVal |
|
|
|
|
this.addForm = { |
|
|
|
|
...this.detailForm, |
|
|
|
|
unitId: newVal.deptId, |
|
|
|
|
unitName: newVal.deptName, |
|
|
|
|
content: newVal.planContent, |
|
|
|
|
} |
|
|
|
|
this.floorArr = [] |
|
|
|
|
this.roomArr = [] |
|
|
|
|
if (newVal.details && newVal.details.length != 0) { |
|
|
|
|
this.tableData = this.getDeepCode(newVal.details, []) |
|
|
|
|
this.tableData.map(item => { |
|
|
|
|
item.period = item.period |
|
|
|
|
}) |
|
|
|
|
this.changeUnit(newVal.deptId) |
|
|
|
|
} |
|
|
|
|
this.imgList = [] |
|
|
|
|
this.filesList = [] |
|
|
|
|
this.drawList = [] |
|
|
|
|
this.drawfiles = [] |
|
|
|
|
this.filesList = this.detailForm.attaches |
|
|
|
|
this.imgList = this.detailForm.attaches |
|
|
|
|
this.detailForm.draws && this.detailForm.draws.length != 0 && this.detailForm.draws.map(item => { |
|
|
|
|
this.drawList.push({ |
|
|
|
|
name: item.name, |
|
|
|
|
url: item.link |
|
|
|
|
}) |
|
|
|
|
this.drawfiles.push({ |
|
|
|
|
name: item.name, |
|
|
|
|
url: item.link |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
this.deviceList = [] |
|
|
|
|
this.imgList = [] |
|
|
|
|
this.filesList = [] |
|
|
|
|
this.drawList = [] |
|
|
|
|
this.drawfiles = [] |
|
|
|
|
// this.getDeviceData() |
|
|
|
|
getChildList(1, 100, '1858710780677984257').then(res => { |
|
|
|
|
this.periodArr = res.data.data |
|
|
|
|
}) |
|
|
|
|
this.headers = { |
|
|
|
|
"Authorization": `Basic ${Base64.encode(`${website.clientId}:${website.clientSecret}`)}`, |
|
|
|
|
'Blade-Auth': 'bearer ' + getToken(), |
|
|
|
|
'Blade-Requested-With': 'BladeHttpRequest' |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
this.imgList = [] |
|
|
|
|
this.filesList = [] |
|
|
|
|
this.drawList = [] |
|
|
|
|
this.drawfiles = [] |
|
|
|
|
this.filesList = this.detailForm.attaches |
|
|
|
|
this.imgList = this.detailForm.attaches |
|
|
|
|
this.detailForm.draws.map(item => { |
|
|
|
|
this.drawList.push({ |
|
|
|
|
name: item.name, |
|
|
|
|
url: item.link |
|
|
|
|
}) |
|
|
|
|
this.drawfiles.push({ |
|
|
|
|
name: item.name, |
|
|
|
|
url: item.link |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
}, |
|
|
|
|
created() { |
|
|
|
|
this.deviceList = [] |
|
|
|
|
this.imgList = [] |
|
|
|
|
this.filesList = [] |
|
|
|
|
this.drawList = [] |
|
|
|
|
this.drawfiles = [] |
|
|
|
|
// this.getDeviceData() |
|
|
|
|
getChildList(1, 100, '1858710780677984257').then(res => { |
|
|
|
|
this.periodArr = res.data.data |
|
|
|
|
this.periodArr = res.data.data |
|
|
|
|
}) |
|
|
|
|
this.headers = { |
|
|
|
|
"Authorization": `Basic ${Base64.encode(`${website.clientId}:${website.clientSecret}`)}`, |
|
|
|
|
'Blade-Auth': 'bearer ' + getToken(), |
|
|
|
|
'Blade-Requested-With': 'BladeHttpRequest' |
|
|
|
|
"Authorization": `Basic ${Base64.encode(`${website.clientId}:${website.clientSecret}`)}`, |
|
|
|
|
'Blade-Auth': 'bearer ' + getToken(), |
|
|
|
|
'Blade-Requested-With': 'BladeHttpRequest' |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
created() { |
|
|
|
|
this.deviceList = [] |
|
|
|
|
// this.getDeviceData() |
|
|
|
|
getChildList(1, 100, '1858710780677984257').then(res => { |
|
|
|
|
this.periodArr = res.data.data |
|
|
|
|
}) |
|
|
|
|
this.headers = { |
|
|
|
|
"Authorization": `Basic ${Base64.encode(`${website.clientId}:${website.clientSecret}`)}`, |
|
|
|
|
'Blade-Auth': 'bearer ' + getToken(), |
|
|
|
|
'Blade-Requested-With': 'BladeHttpRequest' |
|
|
|
|
} |
|
|
|
|
this.imgList = [] |
|
|
|
|
this.filesList = [] |
|
|
|
|
this.drawList = [] |
|
|
|
|
this.drawfiles = [] |
|
|
|
|
if (JSON.stringify(this.detailForm) != '{}') { |
|
|
|
|
this.addForm = { |
|
|
|
|
...this.detailForm, |
|
|
|
|
unitId: this.detailForm.deptId, |
|
|
|
|
unitName: this.detailForm.deptName, |
|
|
|
|
content: this.detailForm.planContent, |
|
|
|
|
} |
|
|
|
|
this.floorArr = [] |
|
|
|
|
this.roomArr = [] |
|
|
|
|
this.tableData = this.getDeepCode(this.detailForm.details, []) |
|
|
|
|
this.changeUnit(this.detailForm.deptId) |
|
|
|
|
|
|
|
|
|
this.detailForm.attaches.map(item => { |
|
|
|
|
this.imgList.push({ |
|
|
|
|
name: item.name, |
|
|
|
|
url: item.link |
|
|
|
|
}) |
|
|
|
|
this.filesList.push({ |
|
|
|
|
name: item.name, |
|
|
|
|
url: item.link |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
this.detailForm.draws.map(item => { |
|
|
|
|
this.drawList.push({ |
|
|
|
|
name: item.name, |
|
|
|
|
url: item.link |
|
|
|
|
}) |
|
|
|
|
this.drawfiles.push({ |
|
|
|
|
name: item.name, |
|
|
|
|
url: item.link |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
this.drawList = [] |
|
|
|
|
this.drawfiles = [] |
|
|
|
|
this.imgList = [] |
|
|
|
|
this.filesList = [] |
|
|
|
|
this.addForm = {} |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
getDeepCode(data, arr) { |
|
|
|
|
console.log('data', data) |
|
|
|
|
if (data && data.length > 0) { |
|
|
|
|
data.map(item => { |
|
|
|
|
if (item.details.length != 0) { |
|
|
|
|
this.getDeepCode(item.details, arr) |
|
|
|
|
} else { |
|
|
|
|
arr.push(item) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
return arr |
|
|
|
|
} |
|
|
|
|
this.imgList = [] |
|
|
|
|
this.filesList = [] |
|
|
|
|
this.drawList = [] |
|
|
|
|
this.drawfiles = [] |
|
|
|
|
if (JSON.stringify(this.detailForm) != '{}') { |
|
|
|
|
this.addForm = { |
|
|
|
|
...this.detailForm, |
|
|
|
|
unitId: this.detailForm.deptId, |
|
|
|
|
unitName: this.detailForm.deptName, |
|
|
|
|
content: this.detailForm.planContent, |
|
|
|
|
} |
|
|
|
|
this.floorArr = [] |
|
|
|
|
this.roomArr = [] |
|
|
|
|
this.tableData = this.getDeepCode(this.detailForm.details, []) |
|
|
|
|
this.detailForm.deptId && this.changeUnit(this.detailForm.deptId) |
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
handleSuccess(response, file, fileList) { |
|
|
|
|
if (response.code == 200) { |
|
|
|
|
this.filesList.push({ |
|
|
|
|
url: response.data.link, //附件url |
|
|
|
|
name: response.data.originalName, //附件名称 |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
handleRemove(res, file) { |
|
|
|
|
this.filesList = this.filesList.filter(item => item.link == res.url && item.name == res.name) |
|
|
|
|
}, |
|
|
|
|
handledrawSuccess(response, file, fileList) { |
|
|
|
|
if (response.code == 200) { |
|
|
|
|
this.drawfiles.push({ |
|
|
|
|
url: response.data.link, //附件url |
|
|
|
|
name: response.data.originalName, //附件名称 |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
handledrawRemove(res, file) { |
|
|
|
|
this.drawfiles = this.drawfiles.filter(item => item.link == res.url && item.name == res.name) |
|
|
|
|
}, |
|
|
|
|
getDeviceData() { |
|
|
|
|
getDeviceList({ current: this.deviceCurrent, size: this.deviceSize }).then(res => { |
|
|
|
|
this.deviceList = res.data.data.records |
|
|
|
|
this.deviceList.forEach(item => { |
|
|
|
|
item.disabled = false |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
async justify() { |
|
|
|
|
//校验成功则方法自动返回true,校验方法报错则说明校验失败,返回false |
|
|
|
|
try { |
|
|
|
|
return await this.$refs['form'].validate() |
|
|
|
|
} catch (error) { |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
getSpanArr(data) { |
|
|
|
|
for (var i = 0; i < data.length; i++) { |
|
|
|
|
if (i === 0) { |
|
|
|
|
this.spanArr.push(1); |
|
|
|
|
this.pos = 0 |
|
|
|
|
} else { |
|
|
|
|
// 判断当前元素与上一个元素是否相同 |
|
|
|
|
if (data[i].deviceId === data[i - 1].deviceId) { |
|
|
|
|
this.spanArr[this.pos] += 1; |
|
|
|
|
this.spanArr.push(0); |
|
|
|
|
} else { |
|
|
|
|
this.spanArr.push(1); |
|
|
|
|
this.pos = i; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
objectSpanMethod({ row, column, rowIndex, columnIndex }) { |
|
|
|
|
if (columnIndex === 1 && row.deviceId != '') { |
|
|
|
|
if (this.spanArr.length != 0) { |
|
|
|
|
const _row = this.spanArr[rowIndex]; |
|
|
|
|
const _col = _row > 0 ? 1 : 0; |
|
|
|
|
return { |
|
|
|
|
rowspan: _row, |
|
|
|
|
colspan: _col |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
// 切换开始时间 |
|
|
|
|
changeStartTime(val, index) { |
|
|
|
|
this.addForm.tableData[index].nextStartTime = val |
|
|
|
|
}, |
|
|
|
|
// 切换设备 |
|
|
|
|
changeDevice(val, index) { |
|
|
|
|
console.log('val------------->', val, index) |
|
|
|
|
getDetail({ id: val }).then(res => { |
|
|
|
|
if (this.title == '新建') { |
|
|
|
|
console.log('tmp------------------->', this.tableData.find(item => item.deviceId == val)) |
|
|
|
|
let arr = [] |
|
|
|
|
res.data.data.maintenances.map(item => { |
|
|
|
|
arr.push({ |
|
|
|
|
floorId: this.activeFloor, // 楼层id |
|
|
|
|
floorName: this.floorArr.find(item => item.id == this.activeFloor).deptName, // 楼层名称 |
|
|
|
|
deviceId: item.deviceId, |
|
|
|
|
deviceName: res.data.data.name, |
|
|
|
|
deptId: this.activeRoom, // 房间id |
|
|
|
|
deptName: this.roomArr.find(item => item.id == this.activeRoom).deptName, // 房间名称 |
|
|
|
|
checkContent: item.checkContent, |
|
|
|
|
majorName: '', |
|
|
|
|
nextStartTime: item.startTime, |
|
|
|
|
startTime: item.startTime, |
|
|
|
|
craft: item.craft, |
|
|
|
|
period: item.period, |
|
|
|
|
this.detailForm.attaches && this.detailForm.attaches.length != 0 && this.detailForm.attaches.map(item => { |
|
|
|
|
this.imgList.push({ |
|
|
|
|
name: item.name, |
|
|
|
|
url: item.link |
|
|
|
|
}) |
|
|
|
|
this.filesList.push({ |
|
|
|
|
name: item.name, |
|
|
|
|
url: item.link |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
this.tableData = [...this.tableData, ...arr] |
|
|
|
|
this.addForm.tableData = this.tableData.filter(item => item.floorId == this.activeFloor && item.deptId == this.activeRoom) |
|
|
|
|
this.spanArr = [] |
|
|
|
|
this.pos = 0 |
|
|
|
|
this.getSpanArr(this.addForm.tableData) |
|
|
|
|
let arr1 = this.deviceList.filter(item1 => |
|
|
|
|
this.addForm.tableData.some(item2 => |
|
|
|
|
item1.id == item2.deviceId |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
this.deviceList.map(item1 => { |
|
|
|
|
item1.disabled = false |
|
|
|
|
arr1.map(item2 => { |
|
|
|
|
if (item2.id == item1.id) { |
|
|
|
|
item1.disabled = true |
|
|
|
|
} |
|
|
|
|
this.detailForm.draws && this.detailForm.draws.length != 0 && this.detailForm.draws.map(item => { |
|
|
|
|
this.drawList.push({ |
|
|
|
|
name: item.name, |
|
|
|
|
url: item.link |
|
|
|
|
}) |
|
|
|
|
this.drawfiles.push({ |
|
|
|
|
name: item.name, |
|
|
|
|
url: item.link |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
let arr = [] |
|
|
|
|
res.data.data.maintenances.map(item => { |
|
|
|
|
arr.push({ |
|
|
|
|
floorId: this.activeFloor, // 楼层id |
|
|
|
|
floorName: this.floorArr.find(item => item.id == this.activeFloor).deptName, // 楼层名称 |
|
|
|
|
deviceId: item.deviceId, |
|
|
|
|
deviceName: res.data.data.name, |
|
|
|
|
deptId: this.activeRoom, // 房间id |
|
|
|
|
deptName: this.roomArr.find(item => item.id == this.activeRoom).deptName, // 房间名称 |
|
|
|
|
checkContent: item.checkContent, |
|
|
|
|
majorName: '', |
|
|
|
|
nextStartTime: item.startTime, |
|
|
|
|
startTime: item.startTime, |
|
|
|
|
craft: item.craft, |
|
|
|
|
period: item.period, |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
if (index == this.addForm.tableData.length - 1) { |
|
|
|
|
this.addForm.tableData.splice(index, 1, ...arr) |
|
|
|
|
// this.tableData.splice(index,1,...arr) |
|
|
|
|
this.spanArr = [] |
|
|
|
|
this.pos = 0 |
|
|
|
|
this.getSpanArr(this.addForm.tableData) |
|
|
|
|
} else { |
|
|
|
|
this.addForm.tableData.splice(index, this.spanArr[index], ...arr) |
|
|
|
|
// this.tableData.splice(index,this.spanArr[index],...arr) |
|
|
|
|
this.spanArr = [] |
|
|
|
|
this.pos = 0 |
|
|
|
|
this.getSpanArr(this.addForm.tableData) |
|
|
|
|
} |
|
|
|
|
this.addForm.tableData = func.process(this.addForm.tableData) |
|
|
|
|
this.$forceUpdate() |
|
|
|
|
this.spanArr = [] |
|
|
|
|
this.pos = 0 |
|
|
|
|
this.getSpanArr(this.addForm.tableData) |
|
|
|
|
this.tableData = [...this.tableData, ...this.addForm.tableData] |
|
|
|
|
this.tableData = func.process(this.tableData) |
|
|
|
|
let arr1 = this.deviceList.filter(item1 => |
|
|
|
|
this.addForm.tableData.some(item2 => |
|
|
|
|
item1.id == item2.deviceId |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
console.log('arr1==============>', arr1) |
|
|
|
|
this.deviceList.map(item1 => { |
|
|
|
|
item1.disabled = false |
|
|
|
|
arr1.map(item2 => { |
|
|
|
|
if (item2.id == item1.id) { |
|
|
|
|
item1.disabled = true |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
console.log('this.deviceList', this.deviceList) |
|
|
|
|
this.drawList = [] |
|
|
|
|
this.drawfiles = [] |
|
|
|
|
this.imgList = [] |
|
|
|
|
this.filesList = [] |
|
|
|
|
this.addForm = {} |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
// 切换实验室 |
|
|
|
|
changeUnit(val) { |
|
|
|
|
console.log('val===========>', val) |
|
|
|
|
console.log('unitData===============>', this.unitData) |
|
|
|
|
this.labId = val |
|
|
|
|
if (this.title == '新建') { |
|
|
|
|
this.addForm.unitName = this.unitData.length > 0 ? this.unitData.find(item => item.id == val).title : '' |
|
|
|
|
this.deviceList.map(item => { |
|
|
|
|
item.disabled = false |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
getDeepData({ parentId: val }).then(res => { |
|
|
|
|
console.log('res ------------------->', res) |
|
|
|
|
this.floorArr = res.data.data |
|
|
|
|
this.activeFloor = res.data.data.length > 0 ? res.data.data[0].id : '' |
|
|
|
|
getDeepData({ parentId: this.activeFloor }).then(res => { |
|
|
|
|
this.roomArr = res.data.data |
|
|
|
|
this.activeRoom = res.data.data.length > 0 ? res.data.data[0].id : '' |
|
|
|
|
this.clickRoom(res.data.data[0]) |
|
|
|
|
if (JSON.stringify(this.detailForm) != '{}') { |
|
|
|
|
console.log(this.activeFloor, this.activeRoom) |
|
|
|
|
this.addForm.tableData = this.tableData.filter(item => item.floorId == this.activeFloor && item.deptId == this.activeRoom) |
|
|
|
|
console.log('addForm==========>', this.addForm.tableData) |
|
|
|
|
let arr1 = this.deviceList.filter(item1 => |
|
|
|
|
this.addForm.tableData.some(item2 => |
|
|
|
|
item1.id == item2.deviceId |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
console.log('arr1==============>', arr1) |
|
|
|
|
this.deviceList.map(item1 => { |
|
|
|
|
item1.disabled = false |
|
|
|
|
arr1.map(item2 => { |
|
|
|
|
if (item2.id == item1.id) { |
|
|
|
|
item1.disabled = true |
|
|
|
|
methods: { |
|
|
|
|
getDeepCode(data, arr) { |
|
|
|
|
data && data.length != 0 && data.map(item => { |
|
|
|
|
if (item.details.length != 0) { |
|
|
|
|
this.getDeepCode(item.details, arr) |
|
|
|
|
} else { |
|
|
|
|
arr.push(item) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
console.log('deviceList', this.deviceList) |
|
|
|
|
this.spanArr = [] |
|
|
|
|
this.pos = 0 |
|
|
|
|
this.getSpanArr(this.addForm.tableData) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
openForm() { |
|
|
|
|
this.addForm.tableData = [ |
|
|
|
|
{ floorId: this.activeFloor, roomId: this.activeRoom, majorName: '', checkContent: '', craft: '' }, |
|
|
|
|
] |
|
|
|
|
this.tableData = this.tableData.concat(this.addForm.tableData) |
|
|
|
|
this.activeFloor = '001' |
|
|
|
|
this.activeRoom = '001' |
|
|
|
|
}, |
|
|
|
|
clearForm() { |
|
|
|
|
this.$refs['form'].resetFields() |
|
|
|
|
this.tableData = [] |
|
|
|
|
this.addForm = { |
|
|
|
|
tableData: [] |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
addColumn() { |
|
|
|
|
if (this.title == '查看') { |
|
|
|
|
return |
|
|
|
|
} else { |
|
|
|
|
this.addForm.tableData.push({ floorId: this.activeFloor, roomId: this.activeRoom, majorName: '', checkContent: '', craft: '', deviceId: '' }) |
|
|
|
|
this.tableData = this.tableData.filter(item => (item.floorId != this.activeFloor || item.roomId != this.activeRoom)) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
deleteColumn(row, index) { |
|
|
|
|
if (this.title == '查看') { |
|
|
|
|
return |
|
|
|
|
} else { |
|
|
|
|
this.tableData.splice(index, 1); |
|
|
|
|
this.spanArr = [] |
|
|
|
|
this.pos = 0 |
|
|
|
|
this.addForm.tableData.splice(index, 1); |
|
|
|
|
this.getSpanArr(this.addForm.tableData) |
|
|
|
|
console.log('tableData', this.tableData) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
dealFloor(val) { |
|
|
|
|
getDeepData({ parentId: val }).then(res => { |
|
|
|
|
this.roomArr = res.data.data |
|
|
|
|
this.activeRoom = this.roomArr[0].id |
|
|
|
|
this.clickRoom(this.roomArr[0]) |
|
|
|
|
this.addForm.tableData = this.tableData.filter(item => item.floorId == this.activeFloor && item.deptId == this.activeRoom) |
|
|
|
|
if (this.addForm.tableData.length == 0) { |
|
|
|
|
this.addForm.tableData = [{ floorId: this.activeFloor, roomId: this.activeRoom, majorName: '', checkContent: '', craft: '' }] |
|
|
|
|
} |
|
|
|
|
const uniqueArr = this.addForm.tableData.filter((item, index, self) => { |
|
|
|
|
return index === self.findIndex(obj => obj.craft === item.craft && obj.deviceId === item.deviceId); |
|
|
|
|
}); |
|
|
|
|
this.addForm.tableData = uniqueArr |
|
|
|
|
let arr1 = this.deviceList.filter(item1 => |
|
|
|
|
this.addForm.tableData.some(item2 => |
|
|
|
|
item1.id == item2.deviceId |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
this.deviceList.map(item1 => { |
|
|
|
|
item1.disabled = false |
|
|
|
|
arr1.map(item2 => { |
|
|
|
|
if (item2.id == item1.id) { |
|
|
|
|
item1.disabled = true |
|
|
|
|
return arr |
|
|
|
|
}, |
|
|
|
|
handleSuccess(response, file, fileList) { |
|
|
|
|
if (response.code == 200) { |
|
|
|
|
this.filesList.push({ |
|
|
|
|
url: response.data.link, //附件url |
|
|
|
|
name: response.data.originalName, //附件名称 |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
this.spanArr = [] |
|
|
|
|
this.pos = 0 |
|
|
|
|
this.getSpanArr(this.addForm.tableData) |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
clickFloor(val) { |
|
|
|
|
this.activeFloor = val.id |
|
|
|
|
this.dealFloor(val.id) |
|
|
|
|
}, |
|
|
|
|
clickRoom(val) { |
|
|
|
|
console.log('val1------------->', val) |
|
|
|
|
console.log('title------------->', this.title) |
|
|
|
|
if (val) { |
|
|
|
|
this.activeRoom = val.id |
|
|
|
|
|
|
|
|
|
if (this.title == '新建') { |
|
|
|
|
getDeviceLists({ limsId: this.labId, floorId: this.activeFloor, roomId: this.activeRoom }).then(res => { |
|
|
|
|
this.deviceList = res.data.data |
|
|
|
|
console.log('res==============>', res) |
|
|
|
|
console.log('table-------------->', this.tableData) |
|
|
|
|
res.data.data.map((item, index) => { |
|
|
|
|
if (!this.tableData.find(item => item.deptId == this.activeRoom)) { |
|
|
|
|
this.changeDevice(item.id, index) |
|
|
|
|
} else { |
|
|
|
|
this.addForm.tableData = this.tableData.filter(item => item.floorId == this.activeFloor && item.deptId == this.activeRoom) |
|
|
|
|
}, |
|
|
|
|
handleRemove(res, file) { |
|
|
|
|
this.filesList = this.filesList.filter(item => item.link == res.url && item.name == res.name) |
|
|
|
|
}, |
|
|
|
|
handledrawSuccess(response, file, fileList) { |
|
|
|
|
if (response.code == 200) { |
|
|
|
|
this.drawfiles.push({ |
|
|
|
|
url: response.data.link, //附件url |
|
|
|
|
name: response.data.originalName, //附件名称 |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
handledrawRemove(res, file) { |
|
|
|
|
this.drawfiles = this.drawfiles.filter(item => item.link == res.url && item.name == res.name) |
|
|
|
|
}, |
|
|
|
|
getDeviceData() { |
|
|
|
|
getDeviceList({ current: this.deviceCurrent, size: this.deviceSize }).then(res => { |
|
|
|
|
this.deviceList = res.data.data.records |
|
|
|
|
this.deviceList.forEach(item => { |
|
|
|
|
item.disabled = false |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
async justify() { |
|
|
|
|
//校验成功则方法自动返回true,校验方法报错则说明校验失败,返回false |
|
|
|
|
try { |
|
|
|
|
return await this.$refs['form'].validate() |
|
|
|
|
} catch (error) { |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
getSpanArr(data) { |
|
|
|
|
for (var i = 0; i < data.length; i++) { |
|
|
|
|
if (i === 0) { |
|
|
|
|
this.spanArr.push(1); |
|
|
|
|
this.pos = 0 |
|
|
|
|
} else { |
|
|
|
|
// 判断当前元素与上一个元素是否相同 |
|
|
|
|
if (data[i].deviceId === data[i - 1].deviceId) { |
|
|
|
|
this.spanArr[this.pos] += 1; |
|
|
|
|
this.spanArr.push(0); |
|
|
|
|
} else { |
|
|
|
|
this.spanArr.push(1); |
|
|
|
|
this.pos = i; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
objectSpanMethod({ row, column, rowIndex, columnIndex }) { |
|
|
|
|
if (columnIndex === 1 && row.deviceId != '') { |
|
|
|
|
if (this.spanArr.length != 0) { |
|
|
|
|
const _row = this.spanArr[rowIndex]; |
|
|
|
|
const _col = _row > 0 ? 1 : 0; |
|
|
|
|
return { |
|
|
|
|
rowspan: _row, |
|
|
|
|
colspan: _col |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
// 切换开始时间 |
|
|
|
|
changeStartTime(val, index) { |
|
|
|
|
this.addForm.tableData[index].nextStartTime = val |
|
|
|
|
}, |
|
|
|
|
// 切换设备 |
|
|
|
|
changeDevice(val, index) { |
|
|
|
|
console.log('val------------->', val, index) |
|
|
|
|
getDetail({ id: val }).then(res => { |
|
|
|
|
if (this.title == '新建') { |
|
|
|
|
console.log('tmp------------------->', this.tableData.find(item => item.deviceId == val)) |
|
|
|
|
let arr = [] |
|
|
|
|
res.data.data.maintenances.map(item => { |
|
|
|
|
arr.push({ |
|
|
|
|
floorId: this.activeFloor, // 楼层id |
|
|
|
|
floorName: this.floorArr.find(item => item.id == this.activeFloor).deptName, // 楼层名称 |
|
|
|
|
deviceId: item.deviceId, |
|
|
|
|
deviceName: res.data.data.name, |
|
|
|
|
deptId: this.activeRoom, // 房间id |
|
|
|
|
deptName: this.roomArr.find(item => item.id == this.activeRoom).deptName, // 房间名称 |
|
|
|
|
checkContent: item.checkContent, |
|
|
|
|
majorName: '', |
|
|
|
|
nextStartTime: item.startTime, |
|
|
|
|
startTime: item.startTime, |
|
|
|
|
craft: item.craft, |
|
|
|
|
period: item.period, |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
this.tableData = [...this.tableData, ...arr] |
|
|
|
|
this.addForm.tableData = this.tableData.filter(item => item.floorId == this.activeFloor && item.deptId == this.activeRoom) |
|
|
|
|
this.spanArr = [] |
|
|
|
|
this.pos = 0 |
|
|
|
|
this.getSpanArr(this.addForm.tableData) |
|
|
|
|
let arr1 = this.deviceList.filter(item1 => |
|
|
|
|
this.addForm.tableData.some(item2 => |
|
|
|
|
item1.id == item2.deviceId |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
this.deviceList.map(item1 => { |
|
|
|
|
item1.disabled = false |
|
|
|
|
arr1.map(item2 => { |
|
|
|
|
if (item2.id == item1.id) { |
|
|
|
|
item1.disabled = true |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
let arr = [] |
|
|
|
|
res.data.data.maintenances.map(item => { |
|
|
|
|
arr.push({ |
|
|
|
|
floorId: this.activeFloor, // 楼层id |
|
|
|
|
floorName: this.floorArr.find(item => item.id == this.activeFloor).deptName, // 楼层名称 |
|
|
|
|
deviceId: item.deviceId, |
|
|
|
|
deviceName: res.data.data.name, |
|
|
|
|
deptId: this.activeRoom, // 房间id |
|
|
|
|
deptName: this.roomArr.find(item => item.id == this.activeRoom).deptName, // 房间名称 |
|
|
|
|
checkContent: item.checkContent, |
|
|
|
|
majorName: '', |
|
|
|
|
nextStartTime: item.startTime, |
|
|
|
|
startTime: item.startTime, |
|
|
|
|
craft: item.craft, |
|
|
|
|
period: item.period, |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
if (index == this.addForm.tableData.length - 1) { |
|
|
|
|
this.addForm.tableData.splice(index, 1, ...arr) |
|
|
|
|
// this.tableData.splice(index,1,...arr) |
|
|
|
|
this.spanArr = [] |
|
|
|
|
this.pos = 0 |
|
|
|
|
this.getSpanArr(this.addForm.tableData) |
|
|
|
|
} else { |
|
|
|
|
this.addForm.tableData.splice(index, this.spanArr[index], ...arr) |
|
|
|
|
// this.tableData.splice(index,this.spanArr[index],...arr) |
|
|
|
|
this.spanArr = [] |
|
|
|
|
this.pos = 0 |
|
|
|
|
this.getSpanArr(this.addForm.tableData) |
|
|
|
|
} |
|
|
|
|
this.addForm.tableData = func.process(this.addForm.tableData) |
|
|
|
|
this.$forceUpdate() |
|
|
|
|
this.spanArr = [] |
|
|
|
|
this.pos = 0 |
|
|
|
|
this.getSpanArr(this.addForm.tableData) |
|
|
|
|
this.tableData = [...this.tableData, ...this.addForm.tableData] |
|
|
|
|
this.tableData = func.process(this.tableData) |
|
|
|
|
let arr1 = this.deviceList.filter(item1 => |
|
|
|
|
this.addForm.tableData.some(item2 => |
|
|
|
|
item1.id == item2.deviceId |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
console.log('arr1==============>', arr1) |
|
|
|
|
this.deviceList.map(item1 => { |
|
|
|
|
item1.disabled = false |
|
|
|
|
arr1.map(item2 => { |
|
|
|
|
if (item2.id == item1.id) { |
|
|
|
|
item1.disabled = true |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
console.log('this.deviceList', this.deviceList) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
// 切换实验室 |
|
|
|
|
changeUnit(val) { |
|
|
|
|
this.labId = val |
|
|
|
|
if (this.title == '新建') { |
|
|
|
|
this.addForm.unitName = this.unitData.find(item => item.id == val) ? this.unitData.find(item => item.id == val).title : '' |
|
|
|
|
this.deviceList.map(item => { |
|
|
|
|
item.disabled = false |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
getDeepData({ parentId: val }).then(res => { |
|
|
|
|
this.floorArr = res.data.data |
|
|
|
|
this.activeFloor = res.data.data.length > 0 ? res.data.data[0].id : '' |
|
|
|
|
getDeepData({ parentId: this.activeFloor }).then(res => { |
|
|
|
|
this.roomArr = res.data.data |
|
|
|
|
this.activeRoom = res.data.data.length > 0 ? res.data.data[0].id : '' |
|
|
|
|
this.clickRoom(res.data.data[0]) |
|
|
|
|
if (JSON.stringify(this.detailForm) != '{}') { |
|
|
|
|
console.log(this.activeFloor, this.activeRoom) |
|
|
|
|
this.addForm.tableData = this.tableData.filter(item => item.floorId == this.activeFloor && item.deptId == this.activeRoom) |
|
|
|
|
let arr1 = this.deviceList.filter(item1 => |
|
|
|
|
this.addForm.tableData.some(item2 => |
|
|
|
|
item1.id == item2.deviceId |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
this.deviceList.map(item1 => { |
|
|
|
|
item1.disabled = false |
|
|
|
|
arr1.map(item2 => { |
|
|
|
|
if (item2.id == item1.id) { |
|
|
|
|
item1.disabled = true |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
console.log('deviceList', this.deviceList) |
|
|
|
|
this.spanArr = [] |
|
|
|
|
this.pos = 0 |
|
|
|
|
this.getSpanArr(this.addForm.tableData) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
openForm() { |
|
|
|
|
this.addForm.tableData = [ |
|
|
|
|
{ floorId: this.activeFloor, roomId: this.activeRoom, majorName: '', checkContent: '', craft: '' }, |
|
|
|
|
] |
|
|
|
|
this.tableData = this.tableData.concat(this.addForm.tableData) |
|
|
|
|
this.activeFloor = '001' |
|
|
|
|
this.activeRoom = '001' |
|
|
|
|
}, |
|
|
|
|
clearForm() { |
|
|
|
|
this.$refs['form'].resetFields() |
|
|
|
|
this.tableData = [] |
|
|
|
|
this.addForm = { |
|
|
|
|
tableData: [] |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
addColumn() { |
|
|
|
|
if (this.title == '查看') { |
|
|
|
|
return |
|
|
|
|
} else { |
|
|
|
|
this.addForm.tableData.push({ floorId: this.activeFloor, roomId: this.activeRoom, majorName: '', checkContent: '', craft: '', deviceId: '' }) |
|
|
|
|
this.tableData = this.tableData.filter(item => (item.floorId != this.activeFloor || item.roomId != this.activeRoom)) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
deleteColumn(row, index) { |
|
|
|
|
if (this.title == '查看') { |
|
|
|
|
return |
|
|
|
|
} else { |
|
|
|
|
this.tableData.splice(index, 1); |
|
|
|
|
this.spanArr = [] |
|
|
|
|
this.pos = 0 |
|
|
|
|
this.addForm.tableData.splice(index, 1); |
|
|
|
|
this.getSpanArr(this.addForm.tableData) |
|
|
|
|
console.log('tableData',this.tableData) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
dealFloor(val) { |
|
|
|
|
getDeepData({ parentId: val }).then(res => { |
|
|
|
|
this.roomArr = res.data.data |
|
|
|
|
this.activeRoom = this.roomArr[0].id |
|
|
|
|
this.clickRoom(this.roomArr[0]) |
|
|
|
|
this.addForm.tableData = this.tableData.filter(item => item.floorId == this.activeFloor && item.deptId == this.activeRoom) |
|
|
|
|
if (this.addForm.tableData.length == 0) { |
|
|
|
|
this.addForm.tableData = [{ floorId: this.activeFloor, roomId: this.activeRoom, majorName: '', checkContent: '', craft: '' }] |
|
|
|
|
} |
|
|
|
|
const uniqueArr = this.addForm.tableData.filter((item, index, self) => { |
|
|
|
|
return index === self.findIndex(obj => obj.craft === item.craft && obj.deviceId === item.deviceId); |
|
|
|
|
}); |
|
|
|
|
this.addForm.tableData = uniqueArr |
|
|
|
|
let arr1 = this.deviceList.filter(item1 => |
|
|
|
|
this.addForm.tableData.some(item2 => |
|
|
|
|
item1.id == item2.deviceId |
|
|
|
|
) |
|
|
|
|
this.addForm.tableData.some(item2 => |
|
|
|
|
item1.id == item2.deviceId |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
this.deviceList.map(item1 => { |
|
|
|
|
item1.disabled = false |
|
|
|
|
arr1.map(item2 => { |
|
|
|
|
if (item2.id == item1.id) { |
|
|
|
|
item1.disabled = true |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
item1.disabled = false |
|
|
|
|
arr1.map(item2 => { |
|
|
|
|
if (item2.id == item1.id) { |
|
|
|
|
item1.disabled = true |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
this.isLoad = true |
|
|
|
|
getDeviceLists({ limsId: this.labId, floorId: this.activeFloor, roomId: this.activeRoom }).then(res => { |
|
|
|
|
this.deviceList = res.data.data |
|
|
|
|
this.addForm.tableData = this.tableData.filter(item => item.floorId == this.activeFloor && item.deptId == this.activeRoom) |
|
|
|
|
setTimeout(() => { |
|
|
|
|
this.isLoad = false |
|
|
|
|
}, 200) |
|
|
|
|
this.deviceList.map(item1 => { |
|
|
|
|
item1.disabled = false |
|
|
|
|
if (this.addForm.tableData.filter(item2 => item2.deviceId == item1.id).length == item1.maintenances.length) { |
|
|
|
|
item1.disabled = true |
|
|
|
|
} |
|
|
|
|
// arr1.map(item2 => { |
|
|
|
|
// if (item2.id == item1.id) { |
|
|
|
|
// item1.disabled = true |
|
|
|
|
// } |
|
|
|
|
// }) |
|
|
|
|
this.spanArr = [] |
|
|
|
|
this.pos = 0 |
|
|
|
|
this.getSpanArr(this.addForm.tableData) |
|
|
|
|
}) |
|
|
|
|
console.log('this.addForm.tableData', this.addForm.tableData) |
|
|
|
|
this.$forceUpdate(); |
|
|
|
|
this.spanArr = [] |
|
|
|
|
this.pos = 0 |
|
|
|
|
this.getSpanArr(this.addForm.tableData) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
clickFloor(val) { |
|
|
|
|
this.activeFloor = val.id |
|
|
|
|
this.dealFloor(val.id) |
|
|
|
|
}, |
|
|
|
|
clickRoom(val) { |
|
|
|
|
this.activeRoom = val.id |
|
|
|
|
console.log('val1------------->', val) |
|
|
|
|
console.log('title------------->', this.title) |
|
|
|
|
if (this.title == '新建') { |
|
|
|
|
getDeviceLists({ limsId: this.labId, floorId: this.activeFloor, roomId: this.activeRoom }).then(res => { |
|
|
|
|
this.deviceList = res.data.data |
|
|
|
|
console.log('res==============>', res) |
|
|
|
|
console.log('table-------------->', this.tableData) |
|
|
|
|
res.data.data.map((item, index) => { |
|
|
|
|
if (!this.tableData.find(item => item.deptId == this.activeRoom)) { |
|
|
|
|
this.changeDevice(item.id, index) |
|
|
|
|
} else { |
|
|
|
|
this.addForm.tableData = this.tableData.filter(item => item.floorId == this.activeFloor && item.deptId == this.activeRoom) |
|
|
|
|
this.spanArr = [] |
|
|
|
|
this.pos = 0 |
|
|
|
|
this.getSpanArr(this.addForm.tableData) |
|
|
|
|
let arr1 = this.deviceList.filter(item1 => |
|
|
|
|
this.addForm.tableData.some(item2 => |
|
|
|
|
item1.id == item2.deviceId |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
this.deviceList.map(item1 => { |
|
|
|
|
item1.disabled = false |
|
|
|
|
arr1.map(item2 => { |
|
|
|
|
if (item2.id == item1.id) { |
|
|
|
|
item1.disabled = true |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
this.isLoad = true |
|
|
|
|
getDeviceLists({ limsId: this.labId, floorId: this.activeFloor, roomId: this.activeRoom }).then(res => { |
|
|
|
|
this.deviceList = res.data.data |
|
|
|
|
this.addForm.tableData = this.tableData.filter(item => item.floorId == this.activeFloor && item.deptId == this.activeRoom) |
|
|
|
|
setTimeout(() => { |
|
|
|
|
this.isLoad = false |
|
|
|
|
}, 200) |
|
|
|
|
this.deviceList.map(item1 => { |
|
|
|
|
item1.disabled = false |
|
|
|
|
if(this.addForm.tableData.filter(item2 => item2.deviceId == item1.id).length == item1.maintenances.length){ |
|
|
|
|
item1.disabled = true |
|
|
|
|
} |
|
|
|
|
// arr1.map(item2 => { |
|
|
|
|
// if (item2.id == item1.id) { |
|
|
|
|
// item1.disabled = true |
|
|
|
|
// } |
|
|
|
|
// }) |
|
|
|
|
}) |
|
|
|
|
console.log('this.addForm.tableData',this.addForm.tableData) |
|
|
|
|
this.$forceUpdate(); |
|
|
|
|
this.spanArr = [] |
|
|
|
|
this.pos = 0 |
|
|
|
|
this.getSpanArr(this.addForm.tableData) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
</script> |
|
|
|
|
|