index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. </wrapper>
  14. </template>
  15. <script>
  16. import { getPublishWorkflows } from '@/api/workflow'
  17. import {
  18. PublishType,
  19. EventPriority,
  20. State,
  21. EventTarget
  22. } from '@/constant'
  23. import { getEventDescription } from '@/utils/event'
  24. export default {
  25. name: 'WorkflowList',
  26. data () {
  27. return {
  28. schema: {
  29. condition: { status: State.SUBMITTED },
  30. list: getPublishWorkflows,
  31. transform: this.transform,
  32. cols: [
  33. {
  34. prop: 'expand',
  35. type: 'expand',
  36. render (data, h) {
  37. return h(
  38. 'div',
  39. {
  40. staticClass: 'o-info'
  41. },
  42. [
  43. h('div', null, data.desc),
  44. h('div', null, `设备:${data.device}`)
  45. ]
  46. )
  47. }
  48. },
  49. { prop: 'type', label: '类型', width: 100 },
  50. { prop: 'name', label: '名称', 'min-width': 100 },
  51. { prop: 'resolutionRatio', label: '分辨率' },
  52. { prop: 'createBy', label: '申请人' },
  53. { prop: 'createTime', label: '提交时间' },
  54. {
  55. label: '审核状态',
  56. type: 'tag',
  57. render ({ status }) {
  58. return {
  59. type: ['', 'warning', 'success', 'danger'][status],
  60. label: ['草稿', '待审核', '通过', '驳回'][status]
  61. }
  62. }
  63. },
  64. {
  65. type: 'invoke',
  66. width: 80,
  67. render: [{ label: '审核', on: this.review }]
  68. }
  69. ]
  70. }
  71. }
  72. },
  73. methods: {
  74. transform (item) {
  75. const same = this.getSame(item.calendarRelease)
  76. const diff = this.getDiff(item.calendarRelease)
  77. return { ...same, ...diff, workflowId: item.id, status: item.status }
  78. },
  79. getSame ({
  80. id,
  81. programCalendarName,
  82. resolutionRatio,
  83. createBy,
  84. createByUsername,
  85. createTime,
  86. calendarReleaseDeviceList
  87. }) {
  88. return {
  89. id,
  90. name: programCalendarName,
  91. resolutionRatio,
  92. createBy: createByUsername || createBy,
  93. createTime,
  94. device: calendarReleaseDeviceList
  95. ?.map(item => item.deviceName)
  96. .join(',')
  97. }
  98. },
  99. getDiff (item) {
  100. const target = JSON.parse(item.target)
  101. let type = ''
  102. switch (target.type) {
  103. case PublishType.CALENDAR:
  104. type = '排期'
  105. break
  106. case PublishType.EVENT:
  107. type = ['', '默认播放', '单播', '插播'][target.detail.priority]
  108. break
  109. default:
  110. break
  111. }
  112. return {
  113. type,
  114. target,
  115. desc: this.getDesc(target)
  116. }
  117. },
  118. getDesc (target) {
  119. if (
  120. target.type === PublishType.EVENT
  121. && target.detail.priority === EventPriority.INSERTED
  122. ) {
  123. return getEventDescription(target.detail)
  124. }
  125. return ''
  126. },
  127. onToggle (row) {
  128. this.$refs.table.getInst().toggleRowExpansion(row)
  129. },
  130. onView ({ target: { type, detail } }) {
  131. switch (type) {
  132. case PublishType.CALENDAR:
  133. this.viewSchedule(detail)
  134. break
  135. case PublishType.EVENT:
  136. if (detail.target.type === EventTarget.RECUR) {
  137. this.viewSchedule(detail.target.id)
  138. } else {
  139. this.viewProgram(detail.target.id)
  140. }
  141. break
  142. default:
  143. break
  144. }
  145. },
  146. viewSchedule (id) {
  147. this.$refs.scheduleDialog.show(id)
  148. },
  149. viewProgram (id) {
  150. this.$viewProgram(id)
  151. },
  152. review (item) {
  153. this.$router.push({
  154. name: 'workflow-detail',
  155. params: {
  156. id: item.workflowId,
  157. name: item.name
  158. }
  159. })
  160. }
  161. }
  162. }
  163. </script>