index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <wrapper
  3. fill
  4. margin
  5. padding
  6. background
  7. >
  8. <schema-table
  9. ref="table"
  10. :schema="schema"
  11. @row-click="onToggle"
  12. />
  13. <schedule-dialog ref="scheduleDialog" />
  14. </wrapper>
  15. </template>
  16. <script>
  17. import { getPublishHistory } from '@/api/platform'
  18. import {
  19. State,
  20. EventPriority,
  21. EventTarget,
  22. PublishType
  23. } from '@/constant'
  24. import { getEventDescription } from '@/utils/event'
  25. export default {
  26. name: 'ScheduleDeployHistory',
  27. data () {
  28. return {
  29. schema: {
  30. condition: { status: State.RESOLVED },
  31. list: getPublishHistory,
  32. transform: this.transform,
  33. cols: [
  34. { 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: 'createBy', label: '申请人' },
  45. { prop: 'createTime', label: '发布时间' },
  46. { type: 'invoke', render: [
  47. { label: '查看', on: this.onView }
  48. ] }
  49. ]
  50. }
  51. }
  52. },
  53. methods: {
  54. transform (item) {
  55. const same = this.getSame(item)
  56. const diff = this.getDiff(item)
  57. return { ...same, ...diff }
  58. },
  59. getSame ({ programCalendarName, resolutionRatio, createBy, createByUsername, createTime, calendarReleaseDeviceList }) {
  60. return {
  61. name: programCalendarName,
  62. resolutionRatio,
  63. createBy: createByUsername || createBy,
  64. createTime,
  65. device: calendarReleaseDeviceList?.map(item => item.deviceName).join(',')
  66. }
  67. },
  68. getDiff (item) {
  69. const target = JSON.parse(item.target)
  70. let type = ''
  71. switch (target.type) {
  72. case PublishType.CALENDAR:
  73. type = '排期'
  74. break
  75. case PublishType.EVENT:
  76. type = ['', '默认播放', '单播', '插播'][target.detail.priority]
  77. break
  78. default:
  79. break
  80. }
  81. return {
  82. type,
  83. target,
  84. desc: this.getDesc(target)
  85. }
  86. },
  87. getDesc (target) {
  88. if (target.type === PublishType.EVENT && target.detail.priority === EventPriority.INSERTED) {
  89. return getEventDescription(target.detail)
  90. }
  91. return ''
  92. },
  93. onToggle (row) {
  94. this.$refs.table.getInst().toggleRowExpansion(row)
  95. },
  96. onView ({ target: { type, detail } }) {
  97. switch (type) {
  98. case PublishType.CALENDAR:
  99. this.viewSchedule(detail)
  100. break
  101. case PublishType.EVENT:
  102. if (detail.target.type === EventTarget.RECUR) {
  103. this.viewSchedule(detail.target.id)
  104. } else {
  105. this.$viewProgram(detail.target.id)
  106. }
  107. break
  108. default:
  109. break
  110. }
  111. },
  112. viewSchedule (id) {
  113. this.$refs.scheduleDialog.show(id)
  114. }
  115. }
  116. }
  117. </script>