ReviewPublish.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <template>
  2. <schema-table
  3. ref="table"
  4. :schema="schema"
  5. @row-click="onToggle"
  6. >
  7. <program-dialog ref="programDialog" />
  8. <schedule-dialog ref="scheduleDialog" />
  9. </schema-table>
  10. </template>
  11. <script>
  12. import {
  13. getPublishes,
  14. resolvePublish
  15. } from '@/api/platform'
  16. import {
  17. State,
  18. EventPriority,
  19. EventTarget,
  20. PublishType
  21. } from '@/constant'
  22. import { getEventDescription } from '@/utils/event'
  23. import mixin from './mixin'
  24. export default {
  25. name: 'ReviewPublish',
  26. mixins: [mixin],
  27. data () {
  28. return {
  29. schema: {
  30. condition: { status: State.SUBMITTED },
  31. list: getPublishes,
  32. transform: this.transform,
  33. cols: [
  34. { prop: 'expand', type: 'expand', render (data, h) {
  35. return h('div', {
  36. staticClass: 'o-info'
  37. }, [
  38. h('div', null, data.desc),
  39. h('div', null, `设备:${data.device}`)
  40. ])
  41. } },
  42. { prop: 'type', label: '类型', width: 100 },
  43. { prop: 'name', label: '名称', 'min-width': 100 },
  44. { prop: 'resolutionRatio', label: '分辨率' },
  45. { prop: 'createBy', label: '申请人' },
  46. { prop: 'createTime', label: '提交时间' },
  47. { type: 'invoke', width: 160, render: [
  48. { label: '查看', on: this.onView },
  49. { label: '通过', on: this.onResolve },
  50. { label: '驳回', on: this.onReject }
  51. ] }
  52. ]
  53. }
  54. }
  55. },
  56. methods: {
  57. resolve: resolvePublish,
  58. transform (item) {
  59. const same = this.getSame(item)
  60. const diff = this.getDiff(item)
  61. return { ...same, ...diff }
  62. },
  63. getSame ({ id, programCalendarName, resolutionRatio, createBy, createByUsername, createTime, calendarReleaseDeviceList }) {
  64. return {
  65. id,
  66. name: programCalendarName,
  67. resolutionRatio,
  68. createBy: createByUsername || createBy,
  69. createTime,
  70. device: calendarReleaseDeviceList?.map(item => item.deviceName).join(',')
  71. }
  72. },
  73. getDiff (item) {
  74. const target = JSON.parse(item.target)
  75. let type = ''
  76. switch (target.type) {
  77. case PublishType.CALENDAR:
  78. type = '排期'
  79. break
  80. case PublishType.EVENT:
  81. type = ['', '默认播放', '单播', '插播'][target.detail.priority]
  82. break
  83. default:
  84. break
  85. }
  86. return {
  87. type,
  88. target,
  89. desc: this.getDesc(target)
  90. }
  91. },
  92. getDesc (target) {
  93. if (target.type === PublishType.EVENT && target.detail.priority === EventPriority.INSERTED) {
  94. return getEventDescription(target.detail)
  95. }
  96. return ''
  97. },
  98. onToggle (row) {
  99. this.$refs.table.getInst().toggleRowExpansion(row)
  100. },
  101. onView ({ target: { type, detail } }) {
  102. switch (type) {
  103. case PublishType.CALENDAR:
  104. this.viewSchedule(detail)
  105. break
  106. case PublishType.EVENT:
  107. if (detail.target.type === EventTarget.RECUR) {
  108. this.viewSchedule(detail.target.id)
  109. } else {
  110. this.$refs.programDialog.show(detail.target.id)
  111. }
  112. break
  113. default:
  114. break
  115. }
  116. },
  117. viewSchedule (id) {
  118. this.$refs.scheduleDialog.show(id)
  119. }
  120. }
  121. }
  122. </script>