| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- <template>
- <wrapper
- fill
- margin
- padding
- background
- >
- <schema-table
- ref="table"
- :schema="schema"
- @row-click="onToggle"
- />
- <program-dialog ref="programDialog" />
- <schedule-dialog ref="scheduleDialog" />
- </wrapper>
- </template>
- <script>
- import {
- getPublishHistory,
- cancelPublish
- } from '@/api/platform'
- import {
- State,
- EventPriority,
- EventTarget,
- PublishType
- } from '@/constant'
- import { getEventDescription } from '@/utils/event'
- export default {
- name: 'ScheduleDeployHistory',
- data () {
- return {
- schema: {
- list: getPublishHistory,
- transform: this.transform,
- cols: [
- { type: 'expand', render (data, h) {
- return h('div', {
- staticClass: 'o-info'
- }, [
- h('div', null, data.desc),
- h('div', null, `设备:${data.device}`)
- ])
- } },
- { prop: 'type', label: '类型', width: 100 },
- { prop: 'name', label: '名称', 'min-width': 100 },
- { prop: 'createBy', label: '发布人' },
- { prop: 'createTime', label: '发布时间' },
- { label: '状态', type: 'tag', render ({ status }) {
- if (status === State.CANCEL) {
- return {
- type: 'danger',
- label: '已下架'
- }
- }
- return {
- type: 'success',
- label: '正常'
- }
- } },
- { type: 'invoke', render: [
- { label: '下架', render: ({ status }) => status === State.RESOLVED, on: this.onCancel },
- { label: '查看', on: this.onView }
- ] }
- ]
- }
- }
- },
- methods: {
- transform (item) {
- const same = this.getSame(item)
- const diff = this.getDiff(item)
- return { ...same, ...diff }
- },
- getSame ({ id, status, programCalendarName, resolutionRatio, createBy, createByUsername, createTime, calendarReleaseDeviceList }) {
- return {
- id,
- status,
- name: programCalendarName,
- resolutionRatio,
- createBy: createByUsername || createBy,
- createTime,
- device: calendarReleaseDeviceList?.map(item => item.deviceName).join(',')
- }
- },
- getDiff (item) {
- const target = JSON.parse(item.target)
- let type = ''
- switch (target.type) {
- case PublishType.CALENDAR:
- type = '排期'
- break
- case PublishType.EVENT:
- type = ['', '默认播放', '单播', '插播'][target.detail.priority]
- break
- default:
- break
- }
- return {
- type,
- target,
- desc: this.getDesc(target)
- }
- },
- getDesc (target) {
- if (target.type === PublishType.EVENT && target.detail.priority === EventPriority.INSERTED) {
- return getEventDescription(target.detail)
- }
- return ''
- },
- onToggle (row) {
- this.$refs.table.getInst().toggleRowExpansion(row)
- },
- onView ({ target: { type, detail } }) {
- switch (type) {
- case PublishType.CALENDAR:
- this.viewSchedule(detail)
- break
- case PublishType.EVENT:
- if (detail.target.type === EventTarget.RECUR) {
- this.viewSchedule(detail.target.id)
- } else {
- this.$refs.programDialog.show(detail.target.id)
- }
- break
- default:
- break
- }
- },
- viewSchedule (id) {
- this.$refs.scheduleDialog.show(id)
- },
- onCancel (publishItem) {
- cancelPublish(publishItem.id, publishItem.name).then(() => {
- publishItem.status = State.CANCEL
- })
- }
- }
- }
- </script>
|