|
|
@@ -8,42 +8,51 @@
|
|
|
<schema-table
|
|
|
ref="table"
|
|
|
:schema="schema"
|
|
|
+ />
|
|
|
+ <confirm-dialog
|
|
|
+ ref="editDialog"
|
|
|
+ title="新增素材包"
|
|
|
+ @confirm="onSave"
|
|
|
>
|
|
|
- <confirm-dialog
|
|
|
- ref="editDialog"
|
|
|
- title="新增素材包"
|
|
|
- @confirm="onSave"
|
|
|
- >
|
|
|
- <div class="c-grid-form u-align-self--center">
|
|
|
- <span class="c-grid-form__label u-required">名称</span>
|
|
|
- <el-input
|
|
|
- v-model.trim="dataset.name"
|
|
|
- placeholder="最多30个字符"
|
|
|
- maxlength="30"
|
|
|
- clearable
|
|
|
- />
|
|
|
- </div>
|
|
|
- </confirm-dialog>
|
|
|
- <table-dialog
|
|
|
- ref="assetDialog"
|
|
|
- size="lg"
|
|
|
- :title="assetDialogName"
|
|
|
- :schema="assetSchema"
|
|
|
- />
|
|
|
- <selection-table-dialog
|
|
|
- ref="assetTableDialog"
|
|
|
- title="上播内容选择"
|
|
|
- message="请选择上播内容"
|
|
|
- :schema="assetTableSchema"
|
|
|
- @confirm="onChoosenAsset"
|
|
|
- />
|
|
|
- <table-dialog
|
|
|
- ref="deviceDialog"
|
|
|
- :title="deviceDialog"
|
|
|
- :schema="deviceSchema"
|
|
|
- />
|
|
|
- <preview-dialog ref="previewDialog" />
|
|
|
- </schema-table>
|
|
|
+ <div class="c-grid-form u-align-self--center">
|
|
|
+ <span class="c-grid-form__label u-required">名称</span>
|
|
|
+ <el-input
|
|
|
+ v-model.trim="dataset.name"
|
|
|
+ placeholder="最多30个字符"
|
|
|
+ maxlength="30"
|
|
|
+ clearable
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </confirm-dialog>
|
|
|
+ <table-dialog
|
|
|
+ ref="assetDialog"
|
|
|
+ size="lg"
|
|
|
+ :title="assetDialogName"
|
|
|
+ :schema="assetSchema"
|
|
|
+ />
|
|
|
+ <selection-table-dialog
|
|
|
+ ref="assetTableDialog"
|
|
|
+ title="上播内容选择"
|
|
|
+ message="请选择上播内容"
|
|
|
+ :schema="assetTableSchema"
|
|
|
+ @confirm="onChoosenAsset"
|
|
|
+ />
|
|
|
+ <table-dialog
|
|
|
+ ref="deviceDialog"
|
|
|
+ :title="deviceDialog"
|
|
|
+ :schema="deviceSchema"
|
|
|
+ @row-click="onToggleSelection"
|
|
|
+ @selection-change="onSelectionChange"
|
|
|
+ />
|
|
|
+ <radio-table-dialog
|
|
|
+ ref="devicesDialog"
|
|
|
+ title="绑定设备"
|
|
|
+ message="请选择设备"
|
|
|
+ :schema="devicesSchema"
|
|
|
+ append-to-body
|
|
|
+ @confirm="onChoosenDevice"
|
|
|
+ />
|
|
|
+ <preview-dialog ref="previewDialog" />
|
|
|
</wrapper>
|
|
|
</template>
|
|
|
|
|
|
@@ -58,6 +67,7 @@ import {
|
|
|
getAssetThumb,
|
|
|
getAssetDuration
|
|
|
} from '@/utils'
|
|
|
+import { getDevices } from '@/api/device'
|
|
|
import {
|
|
|
getDatasets,
|
|
|
addDataset,
|
|
|
@@ -68,6 +78,8 @@ import {
|
|
|
unbindAssetsFromDataset,
|
|
|
updateDatasetAssetDuration,
|
|
|
getDevicesByDataset,
|
|
|
+ bindDatasetToDevice,
|
|
|
+ unbindDatasetByDevices,
|
|
|
unbindDatasetByDevice
|
|
|
} from './api'
|
|
|
import { assetPublicTableMixin } from '@/mixins/asset-table'
|
|
|
@@ -97,7 +109,7 @@ export default {
|
|
|
// }, align: 'center' },
|
|
|
{ type: 'invoke', render: [
|
|
|
{ label: '上播内容', on: this.onEdit },
|
|
|
- { label: '查看关联设备', on: this.onViewDevices },
|
|
|
+ { label: '关联设备', on: this.onViewDevices },
|
|
|
{ label: '删除', on: this.onDel }
|
|
|
], width: 240 }
|
|
|
]
|
|
|
@@ -134,7 +146,12 @@ export default {
|
|
|
},
|
|
|
deviceSchema: {
|
|
|
list: getDevicesByDataset,
|
|
|
+ buttons: [
|
|
|
+ { type: 'add', label: '绑定设备', on: this.onBindDevice },
|
|
|
+ { icon: 'el-icon-scissors', label: '解绑', on: this.onUnbindDevices }
|
|
|
+ ],
|
|
|
cols: [
|
|
|
+ { type: 'selection' },
|
|
|
{ prop: 'name', label: '名称' },
|
|
|
{ prop: 'address', label: '地址', 'min-width': 120 },
|
|
|
{ type: 'invoke', render: [
|
|
|
@@ -142,6 +159,16 @@ export default {
|
|
|
] }
|
|
|
]
|
|
|
},
|
|
|
+ devicesSchema: {
|
|
|
+ list: getDevices,
|
|
|
+ filters: [
|
|
|
+ { key: 'name', type: 'search', placeholder: '设备名称' }
|
|
|
+ ],
|
|
|
+ cols: [
|
|
|
+ { prop: 'name', label: '设备名称' },
|
|
|
+ { prop: 'address', label: '地址' }
|
|
|
+ ]
|
|
|
+ },
|
|
|
datasetName: '',
|
|
|
dataset: {}
|
|
|
}
|
|
|
@@ -250,6 +277,8 @@ export default {
|
|
|
},
|
|
|
onViewDevices ({ id, name }) {
|
|
|
this.datasetName = name
|
|
|
+ this.$datasetId = id
|
|
|
+ this.$selectionItems = null
|
|
|
this.$refs.deviceDialog.show({ datasetId: id })
|
|
|
},
|
|
|
onDel (dataset) {
|
|
|
@@ -261,6 +290,37 @@ export default {
|
|
|
unbindDatasetByDevice(device).then(() => {
|
|
|
this.$refs.deviceDialog.getTable().decrease(1)
|
|
|
})
|
|
|
+ },
|
|
|
+ onUnbindDevices () {
|
|
|
+ if (this.$selectionItems?.length) {
|
|
|
+ unbindDatasetByDevices(this.$selectionItems.map(({ id }) => id)).then(() => {
|
|
|
+ this.$refs.deviceDialog.getTable().decrease(this.$selectionItems.length)
|
|
|
+ this.$selectionItems = null
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.$message({
|
|
|
+ type: 'warning',
|
|
|
+ message: '请先选择需要解绑的设备'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onToggleSelection (row) {
|
|
|
+ this.$refs.table.getInst().toggleRowSelection(row)
|
|
|
+ },
|
|
|
+ onSelectionChange (val) {
|
|
|
+ this.$selectionItems = val
|
|
|
+ },
|
|
|
+ onBindDevice () {
|
|
|
+ this.$refs.devicesDialog.show()
|
|
|
+ },
|
|
|
+ onChoosenDevice ({ value, done }) {
|
|
|
+ bindDatasetToDevice({
|
|
|
+ deviceId: value.id,
|
|
|
+ datasetId: this.$datasetId
|
|
|
+ }).then(() => {
|
|
|
+ done()
|
|
|
+ this.$refs.deviceDialog.getTable().pageTo(1)
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
}
|