|
|
@@ -35,16 +35,17 @@
|
|
|
</confirm-dialog>
|
|
|
<table-dialog
|
|
|
ref="subDeviceDialog"
|
|
|
+ size="lg fixed"
|
|
|
:title="groupName"
|
|
|
:schema="subDeviceSchema"
|
|
|
- size="lg fixed"
|
|
|
/>
|
|
|
- <table-dialog
|
|
|
+ <selection-table-dialog
|
|
|
ref="deviceDialog"
|
|
|
title="添加设备"
|
|
|
+ message="请选择设备"
|
|
|
:schema="deviceSchema"
|
|
|
append-to-body
|
|
|
- @choosen="onChoosenDevice"
|
|
|
+ @confirm="onChoosenDevices"
|
|
|
/>
|
|
|
</wrapper>
|
|
|
</template>
|
|
|
@@ -57,7 +58,7 @@ import {
|
|
|
deleteDeviceGroup,
|
|
|
getDevicesByGroup,
|
|
|
getDevices,
|
|
|
- addDeviceToGroup,
|
|
|
+ addDevicesToGroup,
|
|
|
deleteDeviceFromGroup
|
|
|
} from '@/api/device'
|
|
|
|
|
|
@@ -96,7 +97,6 @@ export default {
|
|
|
{ prop: 'name', label: '设备名称' },
|
|
|
{ prop: 'serialNumber', label: '序列号' },
|
|
|
{ prop: 'mac', label: 'MAC' },
|
|
|
- { prop: 'resolutionRatio', label: '分辨率' },
|
|
|
{ prop: 'address', label: '地址' },
|
|
|
{ type: 'invoke', width: 80, render: [
|
|
|
{ label: '移除', on: this.onDelDevice }
|
|
|
@@ -111,7 +111,6 @@ export default {
|
|
|
list: getDevices,
|
|
|
cols: [
|
|
|
{ prop: 'name', label: '设备名称' },
|
|
|
- { prop: 'resolutionRatio', label: '分辨率', width: 120 },
|
|
|
{ prop: 'address', label: '地址' }
|
|
|
]
|
|
|
},
|
|
|
@@ -168,47 +167,34 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
onViewDevices ({ id, name }) {
|
|
|
+ this.$groupId = id
|
|
|
this.$devices = null
|
|
|
this.groupName = name
|
|
|
- this.$refs.subDeviceDialog.show({ id })
|
|
|
+ this.$refs.subDeviceDialog.show()
|
|
|
},
|
|
|
- getDevicesByGroup ({ id }) {
|
|
|
+ getDevicesByGroup () {
|
|
|
if (this.$devices) {
|
|
|
return Promise.resolve({ data: this.$devices })
|
|
|
}
|
|
|
- return getDevicesByGroup(id).then(({ data }) => {
|
|
|
+ return getDevicesByGroup(this.$groupId).then(({ data }) => {
|
|
|
this.$devices = data
|
|
|
return { data }
|
|
|
})
|
|
|
},
|
|
|
onDelDevice (device) {
|
|
|
- const table = this.$refs.subDeviceDialog.getTable()
|
|
|
- deleteDeviceFromGroup(table.getCondition().id, device).then(() => {
|
|
|
+ deleteDeviceFromGroup(this.$groupId, device).then(() => {
|
|
|
this.$devices = null
|
|
|
- table.decrease(1)
|
|
|
+ this.$refs.subDeviceDialog.getTable().decrease(1)
|
|
|
})
|
|
|
},
|
|
|
onAddDevice () {
|
|
|
this.$refs.deviceDialog.show()
|
|
|
},
|
|
|
- canJoin (device) {
|
|
|
- const data = this.$refs.subDeviceDialog.getTable().getData()
|
|
|
- if (data.length === 0 || data.some(({ resolutionRatio }) => device.resolutionRatio === resolutionRatio)) {
|
|
|
- return Promise.resolve()
|
|
|
- }
|
|
|
- return this.$confirm(
|
|
|
- `设备 ${device.name} 与分组中的设备分辨率不一致,确定加入分组?`,
|
|
|
- { type: 'warning' }
|
|
|
- )
|
|
|
- },
|
|
|
- onChoosenDevice ({ value, done }) {
|
|
|
- const table = this.$refs.subDeviceDialog.getTable()
|
|
|
- this.canJoin(value).then(() => {
|
|
|
- addDeviceToGroup(table.getCondition().id, value.id).then(() => {
|
|
|
- done()
|
|
|
- this.$devices = null
|
|
|
- table.pageTo(1)
|
|
|
- })
|
|
|
+ onChoosenDevices ({ value, done }) {
|
|
|
+ addDevicesToGroup(this.$groupId, value.map(({ id }) => id)).then(() => {
|
|
|
+ done()
|
|
|
+ this.$devices = null
|
|
|
+ this.$refs.subDeviceDialog.getTable().pageTo(1)
|
|
|
})
|
|
|
}
|
|
|
}
|