index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <template>
  2. <wrapper
  3. fill
  4. margin
  5. padding
  6. background
  7. >
  8. <el-tabs
  9. :value="active"
  10. class="c-tabs has-bottom-padding"
  11. @tab-click="onTabClick"
  12. >
  13. <el-tab-pane
  14. label="待审核"
  15. name="1"
  16. />
  17. <el-tab-pane
  18. label="已审核"
  19. name="2"
  20. />
  21. <el-tab-pane
  22. label="被驳回"
  23. name="3"
  24. />
  25. </el-tabs>
  26. <schema-table
  27. ref="table"
  28. :schema="schema"
  29. @row-click="onToggle"
  30. />
  31. <schedule-dialog ref="scheduleDialog" />
  32. </wrapper>
  33. </template>
  34. <script>
  35. import {
  36. getPublishWorkflows,
  37. calendarPublishRestart
  38. } from '@/api/workflow'
  39. import {
  40. PublishType,
  41. EventPriority
  42. } from '@/constant'
  43. import { getEventDescription } from '@/utils/event'
  44. export default {
  45. name: 'MyWorkflow',
  46. data () {
  47. return {
  48. active: '1',
  49. schema: {
  50. condition: { self: true, status: 1, name: '' },
  51. list: getPublishWorkflows,
  52. transform: this.transform,
  53. cols: [
  54. {
  55. prop: 'expand',
  56. type: 'expand',
  57. render (data, h) {
  58. return h(
  59. 'div',
  60. {
  61. staticClass: 'o-info'
  62. },
  63. [
  64. h('div', null, data.desc),
  65. h('div', null, `设备:${data.device}`)
  66. ]
  67. )
  68. }
  69. },
  70. { prop: 'type', label: '类型', width: 100 },
  71. { prop: 'name', label: '名称', 'min-width': 100 },
  72. { prop: 'resolutionRatio', label: '分辨率' },
  73. { prop: 'createTime', label: '提交时间' },
  74. {
  75. label: '审核状态',
  76. type: 'tag',
  77. render ({ status }) {
  78. return {
  79. type: ['', 'warning', 'success', 'danger'][status],
  80. label: ['草稿', '待审核', '通过', '驳回'][status]
  81. }
  82. }
  83. },
  84. {
  85. type: 'invoke',
  86. width: 120,
  87. render: [
  88. { label: '查看', on: this.onView },
  89. { label: '提交', render ({ status }) {
  90. return status === 3
  91. }, on: this.restart }
  92. ]
  93. }
  94. ]
  95. }
  96. }
  97. },
  98. methods: {
  99. onTabClick ({ name: active }) {
  100. if (this.active !== active) {
  101. this.active = active
  102. this.$refs.table.mergeCondition({ status: Number(active) })
  103. }
  104. },
  105. transform (item) {
  106. const same = this.getSame(item.calendarRelease)
  107. const diff = this.getDiff(item.calendarRelease)
  108. return { ...same, ...diff, workflowId: item.id, status: item.status }
  109. },
  110. getSame ({
  111. id,
  112. programCalendarName,
  113. resolutionRatio,
  114. createBy,
  115. createByUsername,
  116. createTime,
  117. calendarReleaseDeviceList
  118. }) {
  119. return {
  120. id,
  121. name: programCalendarName,
  122. resolutionRatio,
  123. createBy: createByUsername || createBy,
  124. createTime,
  125. device: calendarReleaseDeviceList
  126. ?.map(item => item.deviceName)
  127. .join(',')
  128. }
  129. },
  130. getDiff (item) {
  131. const target = JSON.parse(item.target)
  132. let type = ''
  133. switch (target.type) {
  134. case PublishType.CALENDAR:
  135. type = '排期'
  136. break
  137. case PublishType.EVENT:
  138. type = ['', '默认播放', '单播', '插播'][target.detail.priority]
  139. break
  140. default:
  141. break
  142. }
  143. return {
  144. type,
  145. target,
  146. desc: this.getDesc(target)
  147. }
  148. },
  149. getDesc (target) {
  150. if (
  151. target.type === PublishType.EVENT
  152. && target.detail.priority === EventPriority.INSERTED
  153. ) {
  154. return getEventDescription(target.detail)
  155. }
  156. return ''
  157. },
  158. onToggle (row) {
  159. this.$refs.table.getInst().toggleRowExpansion(row)
  160. },
  161. onView ({ target: { type, detail } }) {
  162. switch (type) {
  163. case PublishType.CALENDAR:
  164. this.viewSchedule(detail)
  165. break
  166. case PublishType.EVENT:
  167. if (detail.target.type === EventTarget.RECUR) {
  168. this.viewSchedule(detail.target.id)
  169. } else {
  170. this.viewProgram(detail.target.id)
  171. }
  172. break
  173. default:
  174. break
  175. }
  176. },
  177. viewSchedule (id) {
  178. this.$refs.scheduleDialog.show(id)
  179. },
  180. viewProgram (id) {
  181. this.$viewProgram(id)
  182. },
  183. restart (item) {
  184. calendarPublishRestart(item.workflowId, item.name).then(() => {
  185. this.$refs.table.onPagination()
  186. })
  187. }
  188. }
  189. }
  190. </script>