|
|
@@ -5,8 +5,8 @@
|
|
|
<span class="c-sibling-item u-font-size--sm">上播内容</span>
|
|
|
<i
|
|
|
v-if="isAssets"
|
|
|
- class="c-sibling-item el-icon-circle-plus-outline u-color--blue u-pointer"
|
|
|
- @click="onAddAsset"
|
|
|
+ class="c-sibling-item el-icon-edit u-color--blue u-pointer"
|
|
|
+ @click="onEditAssets"
|
|
|
/>
|
|
|
</div>
|
|
|
<div
|
|
|
@@ -25,6 +25,13 @@
|
|
|
:value="option.value"
|
|
|
/>
|
|
|
</el-select>
|
|
|
+ <div
|
|
|
+ v-if="isAssets"
|
|
|
+ class="c-sibling-item o-button"
|
|
|
+ @click="onImportDataset"
|
|
|
+ >
|
|
|
+ 导入
|
|
|
+ </div>
|
|
|
<div
|
|
|
class="l-flex--row c-sibling-item far has-active u-ellipsis"
|
|
|
@click="onViewCurrentTarget"
|
|
|
@@ -33,22 +40,29 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <draggable
|
|
|
- v-if="isAssets"
|
|
|
- v-model="currentTarget.assets"
|
|
|
- class="l-flex__fill c-sibling-item--v u-overflow-y--auto"
|
|
|
- handle=".mover"
|
|
|
- animation="300"
|
|
|
- >
|
|
|
- <draggable-item
|
|
|
- v-for="(asset, index) in currentTarget.assets"
|
|
|
- :key="asset.key"
|
|
|
- :item="asset"
|
|
|
- :hide-duration="hideDuration"
|
|
|
- @view="onViewAsset"
|
|
|
- @del="onDelAsset(index)"
|
|
|
+ <template v-if="isAssets">
|
|
|
+ <draggable
|
|
|
+ v-if="currentTarget.assets.length"
|
|
|
+ v-model="currentTarget.assets"
|
|
|
+ class="l-flex__fill c-sibling-item--v u-overflow-y--auto"
|
|
|
+ handle=".mover"
|
|
|
+ animation="300"
|
|
|
+ >
|
|
|
+ <draggable-item
|
|
|
+ v-for="(asset, index) in currentTarget.assets"
|
|
|
+ :key="asset.key"
|
|
|
+ :item="asset"
|
|
|
+ :hide-duration="hideDuration"
|
|
|
+ @view="onViewAsset"
|
|
|
+ @del="onDelAsset(index)"
|
|
|
+ />
|
|
|
+ </draggable>
|
|
|
+ <el-empty
|
|
|
+ v-else
|
|
|
+ class="l-flex__fill l-flex--row center"
|
|
|
+ description="请添加素材"
|
|
|
/>
|
|
|
- </draggable>
|
|
|
+ </template>
|
|
|
<schema-table
|
|
|
v-else
|
|
|
:key="currentTarget.type"
|
|
|
@@ -59,13 +73,53 @@
|
|
|
highlight-current-row
|
|
|
@row-click="onClickRow"
|
|
|
/>
|
|
|
- <selection-table-dialog
|
|
|
+ <confirm-dialog
|
|
|
ref="assetTableDialog"
|
|
|
- title="上播内容选择"
|
|
|
- message="请选择上播内容"
|
|
|
- :schema="assetTableSchema"
|
|
|
+ title="上播内容"
|
|
|
+ size="xl fixed"
|
|
|
+ append-to-body
|
|
|
+ @confirm="onSaveAssets"
|
|
|
+ >
|
|
|
+ <c-transfer
|
|
|
+ class="l-flex__auto"
|
|
|
+ :source-schema="assetTableSchema"
|
|
|
+ :add="onAddAssets"
|
|
|
+ >
|
|
|
+ <el-empty
|
|
|
+ v-if="!selectionAssets.length"
|
|
|
+ class="l-flex__auto l-flex--row center"
|
|
|
+ description="请添加素材"
|
|
|
+ />
|
|
|
+ <draggable
|
|
|
+ v-else
|
|
|
+ v-model="selectionAssets"
|
|
|
+ class="l-flex__auto l-flex--col u-font-size--sm u-overflow-y--auto"
|
|
|
+ handle=".mover"
|
|
|
+ animation="300"
|
|
|
+ >
|
|
|
+ <draggable-item
|
|
|
+ v-for="(asset, index) in selectionAssets"
|
|
|
+ :key="asset.key"
|
|
|
+ :item="asset"
|
|
|
+ @view="onViewAsset"
|
|
|
+ @del="onDelSelectionAsset(index)"
|
|
|
+ />
|
|
|
+ </draggable>
|
|
|
+ </c-transfer>
|
|
|
+ </confirm-dialog>
|
|
|
+ <radio-table-dialog
|
|
|
+ ref="datasetDialog"
|
|
|
+ title="素材包"
|
|
|
+ message="请选择素材包"
|
|
|
+ :schema="datasetSchema"
|
|
|
+ append-to-body
|
|
|
+ @confirm="onChoosenDataset"
|
|
|
+ />
|
|
|
+ <table-dialog
|
|
|
+ ref="contentDialog"
|
|
|
+ title="素材包"
|
|
|
+ :schema="contentSchema"
|
|
|
append-to-body
|
|
|
- @confirm="onChoosenAsset"
|
|
|
/>
|
|
|
<preview-dialog ref="previewDialog" />
|
|
|
<material-dialog ref="materialDialog" />
|
|
|
@@ -80,10 +134,19 @@ import {
|
|
|
EventTargetInfo,
|
|
|
AssetTagInfo,
|
|
|
AssetType,
|
|
|
- AssetTypeInfo
|
|
|
+ AssetTypeInfo,
|
|
|
+ Dataset
|
|
|
} from '@/constant'
|
|
|
-import { getAssetDuration } from '@/utils'
|
|
|
+import {
|
|
|
+ parseDuration,
|
|
|
+ getAssetThumb,
|
|
|
+ getAssetDuration
|
|
|
+} from '@/utils'
|
|
|
import { getRatios } from '@/api/device'
|
|
|
+import {
|
|
|
+ getDatasets,
|
|
|
+ getCommonDataset
|
|
|
+} from '@/api/asset'
|
|
|
import { getSchedules } from '@/api/calendar'
|
|
|
import { getPrograms } from '@/api/program'
|
|
|
import { assetTableMixin } from '@/mixins/asset-table'
|
|
|
@@ -116,7 +179,32 @@ export default {
|
|
|
{ value: EventTarget.RECUR, label: EventTargetInfo[EventTarget.RECUR] },
|
|
|
{ value: EventTarget.ASSETS, label: EventTargetInfo[EventTarget.ASSETS] }
|
|
|
],
|
|
|
- currentTarget: null
|
|
|
+ currentTarget: null,
|
|
|
+ selectionAssets: [],
|
|
|
+ datasetSchema: {
|
|
|
+ list: getDatasets,
|
|
|
+ condition: { type: Dataset.COMMON },
|
|
|
+ cols: [
|
|
|
+ { prop: 'name', label: '名称', 'align': 'center' },
|
|
|
+ { type: 'invoke', render: [
|
|
|
+ { label: '查看', on: this.onViewDataset }
|
|
|
+ ] }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ contentSchema: {
|
|
|
+ singlePage: true,
|
|
|
+ list: this.getAssets,
|
|
|
+ cols: [
|
|
|
+ { prop: 'tagInfo', label: '类型', align: 'center', width: 80 },
|
|
|
+ { prop: 'typeName', label: '文件', align: 'center', width: 80 },
|
|
|
+ { prop: 'file', label: '', type: 'asset', on: this.onViewAsset },
|
|
|
+ { prop: 'name', label: '' },
|
|
|
+ { prop: 'duration', label: '上播时长', 'align': 'center', width: 100 },
|
|
|
+ { type: 'invoke', render: [
|
|
|
+ { label: '查看', on: this.onViewAsset }
|
|
|
+ ] }
|
|
|
+ ]
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
@@ -251,13 +339,21 @@ export default {
|
|
|
onClickRow (row) {
|
|
|
this.currentTarget.detail = row
|
|
|
},
|
|
|
- onAddAsset () {
|
|
|
+ onEditAssets () {
|
|
|
+ this.selectionAssets = this.currentTarget.assets.map(asset => {
|
|
|
+ return {
|
|
|
+ ...asset
|
|
|
+ }
|
|
|
+ })
|
|
|
this.$refs.assetTableDialog.show()
|
|
|
},
|
|
|
- onChoosenAsset ({ value, done }) {
|
|
|
+ onDelSelectionAsset (index) {
|
|
|
+ this.selectionAssets.splice(index, 1)
|
|
|
+ },
|
|
|
+ onAddAssets (value) {
|
|
|
value.forEach(item => {
|
|
|
const { tag, type, keyName, originalName, size, md5, file } = item
|
|
|
- this.currentTarget.assets.push({
|
|
|
+ this.selectionAssets.push({
|
|
|
key: `${Date.now()}_${Math.random().toString(16).slice(2)}`,
|
|
|
tag,
|
|
|
type,
|
|
|
@@ -271,8 +367,75 @@ export default {
|
|
|
file
|
|
|
})
|
|
|
})
|
|
|
+ return Promise.resolve()
|
|
|
+ },
|
|
|
+ onSaveAssets (done) {
|
|
|
+ this.currentTarget.assets = this.selectionAssets.map(asset => {
|
|
|
+ return {
|
|
|
+ ...asset
|
|
|
+ }
|
|
|
+ })
|
|
|
done()
|
|
|
},
|
|
|
+ onImportDataset () {
|
|
|
+ this.$datasetAssets = null
|
|
|
+ this.$refs.datasetDialog.show()
|
|
|
+ },
|
|
|
+ onViewDataset ({ id }) {
|
|
|
+ this.$datasetId = id
|
|
|
+ this.$datasetAssets = null
|
|
|
+ this.$refs.contentDialog.show()
|
|
|
+ },
|
|
|
+ getAssets () {
|
|
|
+ if (this.$datasetAssets) {
|
|
|
+ return Promise.resolve({ data: this.$datasetAssets })
|
|
|
+ }
|
|
|
+ return getCommonDataset(this.$datasetId).then(({ data: { mediaList } }) => {
|
|
|
+ this.$datasetAssets = mediaList.map(this.transformDatasetAsset)
|
|
|
+ return {
|
|
|
+ data: this.$datasetAssets
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ transformDatasetAsset (asset) {
|
|
|
+ asset.tagInfo = AssetTagInfo[asset.tag]
|
|
|
+ asset.typeName = AssetTypeInfo[asset.type]
|
|
|
+ asset.file = {
|
|
|
+ type: asset.type,
|
|
|
+ url: asset.keyName,
|
|
|
+ thumb: asset.minioData ? getAssetThumb(asset.minioData) : null
|
|
|
+ }
|
|
|
+ asset.name = asset.minioData?.originalName || '素材已删除'
|
|
|
+ asset.duration = parseDuration(asset.adDuration)
|
|
|
+ return asset
|
|
|
+ },
|
|
|
+ onChoosenDataset ({ value, done }) {
|
|
|
+ if (this.$datasetId !== value.id) {
|
|
|
+ this.$datasetId = value.id
|
|
|
+ this.$datasetAssets = null
|
|
|
+ }
|
|
|
+ this.getAssets().then(({ data }) => {
|
|
|
+ data.forEach(item => {
|
|
|
+ const { tag, type, keyName, adDuration, name, file, minioData } = item
|
|
|
+ if (minioData) {
|
|
|
+ this.currentTarget.assets.push({
|
|
|
+ key: `${Date.now()}_${Math.random().toString(16).slice(2)}`,
|
|
|
+ tag,
|
|
|
+ type,
|
|
|
+ keyName,
|
|
|
+ size: minioData.size,
|
|
|
+ md5: minioData.md5,
|
|
|
+ info: `${AssetTagInfo[tag]} ${AssetTypeInfo[type]}`,
|
|
|
+ name,
|
|
|
+ duration: adDuration,
|
|
|
+ disabled: type === AssetType.VIDEO,
|
|
|
+ file
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ done()
|
|
|
+ })
|
|
|
+ },
|
|
|
onDelAsset (index) {
|
|
|
this.currentTarget.assets.splice(index, 1)
|
|
|
},
|