|
|
@@ -17,17 +17,54 @@
|
|
|
row-key="id"
|
|
|
:schema="schema"
|
|
|
/>
|
|
|
+ <table-dialog
|
|
|
+ ref="tableDialog"
|
|
|
+ :title="title"
|
|
|
+ :schema="schedulingSchema"
|
|
|
+ />
|
|
|
+ <table-dialog
|
|
|
+ ref="adDialog"
|
|
|
+ title="广告内容"
|
|
|
+ :schema="adSchema"
|
|
|
+ />
|
|
|
</wrapper>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { getDeviceSchedulings } from '../api'
|
|
|
+import { AssetType } from '@/constant'
|
|
|
+import {
|
|
|
+ parseTime,
|
|
|
+ parseByte,
|
|
|
+ parseDuration
|
|
|
+} from '@/utils'
|
|
|
+import {
|
|
|
+ createScheduling,
|
|
|
+ getDeviceSchedulings,
|
|
|
+ getDeviceScheduling,
|
|
|
+ getOrderDetail
|
|
|
+} from '../api'
|
|
|
|
|
|
export default {
|
|
|
name: 'AdScheduling',
|
|
|
data () {
|
|
|
return {
|
|
|
- deviceId: ''
|
|
|
+ deviceId: '',
|
|
|
+ schedulingId: '',
|
|
|
+ title: '',
|
|
|
+ adSchema: {
|
|
|
+ list: this.getSources,
|
|
|
+ cols: [
|
|
|
+ { prop: 'file', label: '缩略图', type: 'asset', on: this.onViewAsset },
|
|
|
+ { prop: 'fileType', label: '文件类型', align: 'center' },
|
|
|
+ { prop: 'adDuration', label: '播放时长', align: 'right' },
|
|
|
+ { prop: 'size', label: '文件大小', align: 'right' },
|
|
|
+ { prop: 'ratio', label: '分辨率', align: 'right' },
|
|
|
+ { prop: 'remark', label: '其他', align: 'right' },
|
|
|
+ { type: 'invoke', width: 80, render: [
|
|
|
+ { label: '查看', render ({ file }) { return !!file }, on: this.onViewSource }
|
|
|
+ ] }
|
|
|
+ ]
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
@@ -38,7 +75,29 @@ export default {
|
|
|
],
|
|
|
condition: { deviceId: this.deviceId },
|
|
|
list: getDeviceSchedulings,
|
|
|
- cols: [{ prop: 'name', label: '名称', align: 'center' }]
|
|
|
+ transform: this.transform,
|
|
|
+ cols: [
|
|
|
+ { type: 'refresh' },
|
|
|
+ { prop: 'startDate', label: '日期' },
|
|
|
+ { prop: 'createTime', label: '生成时间' },
|
|
|
+ { prop: 'statusTag', type: 'tag', align: 'center' },
|
|
|
+ { type: 'invoke', render: [
|
|
|
+ { label: '详情', on: this.onView }
|
|
|
+ ] }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ },
|
|
|
+ schedulingSchema () {
|
|
|
+ return {
|
|
|
+ condition: { id: this.schedulingId },
|
|
|
+ list: getDeviceScheduling,
|
|
|
+ transform: this.transformScheduling,
|
|
|
+ cols: [
|
|
|
+ { prop: 'time', label: '时间', 'align': 'center' },
|
|
|
+ { type: 'invoke', render: [
|
|
|
+ { label: '内容', on: this.onViewOrder }
|
|
|
+ ] }
|
|
|
+ ]
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
@@ -46,8 +105,77 @@ export default {
|
|
|
onChange (deviceId) {
|
|
|
this.deviceId = deviceId
|
|
|
},
|
|
|
- onScheduling (val) {
|
|
|
- console.log(val)
|
|
|
+ onScheduling () {
|
|
|
+ const startDate = parseTime(new Date(), '{y}-{m}-{d}')
|
|
|
+ createScheduling([this.deviceId], {
|
|
|
+ startDate,
|
|
|
+ endDate: startDate
|
|
|
+ }).then(() => {
|
|
|
+ this.$refs.table.pageTo()
|
|
|
+ })
|
|
|
+ },
|
|
|
+ transform (scheduling) {
|
|
|
+ const { status } = scheduling
|
|
|
+ scheduling.statusTag = {
|
|
|
+ label: ['生成中', '待发布', '已发布'][status],
|
|
|
+ type: ['primary', 'warning', 'success'][status]
|
|
|
+ }
|
|
|
+ return scheduling
|
|
|
+ },
|
|
|
+ onView ({ id, startDate }) {
|
|
|
+ this.title = startDate
|
|
|
+ this.schedulingId = id
|
|
|
+ this.$refs.tableDialog.show()
|
|
|
+ },
|
|
|
+ transformScheduling ({ id, orderId, startTime, endTime }) {
|
|
|
+ return {
|
|
|
+ id,
|
|
|
+ orderId,
|
|
|
+ time: `${startTime}-${endTime}`
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onViewOrder ({ orderId }) {
|
|
|
+ getOrderDetail(orderId).then(({ data }) => {
|
|
|
+ this.$order = data
|
|
|
+ this.$refs.adDialog.show()
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getSources () {
|
|
|
+ const sources = this.$order.assets
|
|
|
+ return Promise.resolve({
|
|
|
+ data: sources.map(this.transformSource),
|
|
|
+ totalCount: sources.length
|
|
|
+ })
|
|
|
+ },
|
|
|
+ transformSource ({ keyName, type, adDuration, duration, size, width, height, thumb }) {
|
|
|
+ const isImage = type === AssetType.IMAGE
|
|
|
+ return type
|
|
|
+ ? {
|
|
|
+ file: {
|
|
|
+ type,
|
|
|
+ url: keyName,
|
|
|
+ thumbnail: isImage ? keyName : thumb || null,
|
|
|
+ origin: !isImage
|
|
|
+ },
|
|
|
+ fileType: isImage ? '图片' : '视频',
|
|
|
+ adDuration: parseDuration(adDuration || duration),
|
|
|
+ ratio: width && height ? `${width}x${height}` : '-',
|
|
|
+ size: parseByte(size),
|
|
|
+ remark: duration ? parseDuration(duration) : '-'
|
|
|
+ }
|
|
|
+ : {
|
|
|
+ fileType: '-',
|
|
|
+ adDuration: parseDuration(adDuration || duration),
|
|
|
+ ratio: '-',
|
|
|
+ size: '-',
|
|
|
+ remark: '素材已删除'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onViewSource ({ file }) {
|
|
|
+ this.onViewAsset(file)
|
|
|
+ },
|
|
|
+ onViewAsset (asset) {
|
|
|
+ this.$refs.previewDialog.show(asset)
|
|
|
}
|
|
|
}
|
|
|
}
|