|
|
@@ -0,0 +1,178 @@
|
|
|
+<template>
|
|
|
+ <el-dialog
|
|
|
+ :visible.sync="dialogVisible"
|
|
|
+ :custom-class="customClass"
|
|
|
+ title="上播内容"
|
|
|
+ :close-on-click-modal="false"
|
|
|
+ :show-close="false"
|
|
|
+ append-to-body
|
|
|
+ @open="onOpen"
|
|
|
+ @closed="onClosed"
|
|
|
+ >
|
|
|
+ <template v-if="contentRender">
|
|
|
+ <program
|
|
|
+ v-if="program"
|
|
|
+ :program="program"
|
|
|
+ />
|
|
|
+ <schedule
|
|
|
+ v-if="scheduleId"
|
|
|
+ class="l-flex__auto has-padding--h has-bottom-padding"
|
|
|
+ :schedule="scheduleId"
|
|
|
+ />
|
|
|
+ <schema-table
|
|
|
+ v-if="assets"
|
|
|
+ :schema="contentSchema"
|
|
|
+ >
|
|
|
+ <preview-dialog ref="previewDialog" />
|
|
|
+ </schema-table>
|
|
|
+ <i
|
|
|
+ class="l-flex__none c-dialog--preview__close el-icon-close has-active u-bold"
|
|
|
+ @click="hide"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import {
|
|
|
+ PublishTargetType,
|
|
|
+ EventTarget,
|
|
|
+ AssetTagInfo,
|
|
|
+ AssetTypeInfo
|
|
|
+} from '@/constant'
|
|
|
+import { parseDuration } from '@/utils'
|
|
|
+import { getTemplateProgram } from '@/api/program'
|
|
|
+import Program from '@/views/screen/material/program/ast/Viewer'
|
|
|
+import dialogMixin from '@/mixins/dialog'
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'MaterialTemplateDialog',
|
|
|
+ components: {
|
|
|
+ Program
|
|
|
+ },
|
|
|
+ mixins: [dialogMixin],
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ program: null,
|
|
|
+ scheduleId: null,
|
|
|
+ assets: null,
|
|
|
+ contentSchema: {
|
|
|
+ singlePage: true,
|
|
|
+ list: this.getContentAssets,
|
|
|
+ cols: [
|
|
|
+ { prop: 'tagInfo', label: '分类', width: 80, align: 'center' },
|
|
|
+ { prop: 'typeInfo', label: '资源', width: 72, align: 'center' },
|
|
|
+ { prop: 'file', label: '', type: 'asset', on: this.onViewAsset },
|
|
|
+ { prop: 'name', label: '' },
|
|
|
+ { prop: 'adDuration', label: '上播时长', width: 80, align: 'center' },
|
|
|
+ { type: 'invoke', render: [
|
|
|
+ { label: '查看', allow: ({ file }) => !!file, on: this.onViewAsset }
|
|
|
+ ] }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ customClass () {
|
|
|
+ if (this.assets) {
|
|
|
+ return 'c-dialog medium'
|
|
|
+ }
|
|
|
+ return `c-dialog--preview ${this.program ? 'program' : ''}`
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ onClosed () {
|
|
|
+ this.contentRender = false
|
|
|
+ this.program = null
|
|
|
+ this.scheduleId = null
|
|
|
+ this.assets = null
|
|
|
+ this.$emit('closed')
|
|
|
+ },
|
|
|
+ showProgram (id) {
|
|
|
+ const loading = this.$showLoading()
|
|
|
+ getTemplateProgram(id).then(({ data }) => {
|
|
|
+ try {
|
|
|
+ const { id, status, name, resolutionRatio, itemJsonStr } = data
|
|
|
+ const [width, height] = resolutionRatio.split('x')
|
|
|
+ if (!width || !height) {
|
|
|
+ this.showMessage('error', '布局分辨率异常,请联系管理员')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ this.program = {
|
|
|
+ id, status, name, resolutionRatio,
|
|
|
+ detail: {
|
|
|
+ width: Number(width),
|
|
|
+ height: Number(height),
|
|
|
+ ...JSON.parse(itemJsonStr)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.dialogVisible = true
|
|
|
+ } catch (e) {
|
|
|
+ this.showMessage('error', '布局解析失败')
|
|
|
+ }
|
|
|
+ }).finally(() => {
|
|
|
+ this.$closeLoading(loading)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ showSchedule (id) {
|
|
|
+ this.scheduleId = id
|
|
|
+ this.dialogVisible = true
|
|
|
+ },
|
|
|
+ showPublishTarget ({ type, detail }) {
|
|
|
+ switch (type) {
|
|
|
+ case PublishTargetType.CALENDAR:
|
|
|
+ this.showSchedule(detail)
|
|
|
+ break
|
|
|
+ case PublishTargetType.EVENT:
|
|
|
+ this.showEventTarget(detail.target)
|
|
|
+ break
|
|
|
+ default:
|
|
|
+ break
|
|
|
+ }
|
|
|
+ },
|
|
|
+ showEventTarget ({ type, id, sources }) {
|
|
|
+ switch (type) {
|
|
|
+ case EventTarget.PROGRAM:
|
|
|
+ this.showProgram(id)
|
|
|
+ break
|
|
|
+ case EventTarget.RECUR:
|
|
|
+ this.showSchedule(id)
|
|
|
+ break
|
|
|
+ case EventTarget.ASSETS:
|
|
|
+ this.showAssets(sources)
|
|
|
+ break
|
|
|
+ default:
|
|
|
+ break
|
|
|
+ }
|
|
|
+ },
|
|
|
+ showAssets (assets) {
|
|
|
+ assets = assets.map(this.transformAsset)
|
|
|
+ if (assets.length === 1) {
|
|
|
+ assets[0].adDuration = '独占'
|
|
|
+ }
|
|
|
+ this.assets = assets
|
|
|
+ this.dialogVisible = true
|
|
|
+ },
|
|
|
+ getContentAssets () {
|
|
|
+ console.log('1234325436457568679780895634523---')
|
|
|
+ return Promise.resolve({ data: this.assets })
|
|
|
+ },
|
|
|
+ transformAsset ({ tag, type, keyName, name, duration }) {
|
|
|
+ return {
|
|
|
+ tagInfo: AssetTagInfo[tag],
|
|
|
+ typeInfo: AssetTypeInfo[type],
|
|
|
+ file: {
|
|
|
+ type,
|
|
|
+ url: keyName
|
|
|
+ },
|
|
|
+ name: name || '',
|
|
|
+ adDuration: parseDuration(duration)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onViewAsset ({ file }) {
|
|
|
+ this.$refs.previewDialog.show(file)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|