index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <table-dialog
  3. ref="tableDialog"
  4. title="选择播放内容"
  5. size="medium"
  6. :schema="schema"
  7. append-to-body
  8. v-bind="$attrs"
  9. @choosen="onChoosen"
  10. >
  11. <program-dialog ref="programDialog" />
  12. <schedule-dialog ref="scheduleDialog" />
  13. </table-dialog>
  14. </template>
  15. <script>
  16. import { getPrograms } from '@/api/program'
  17. import { getSchedules } from '@/api/calendar'
  18. import {
  19. State,
  20. ScheduleType,
  21. EventTarget
  22. } from '@/constant'
  23. export default {
  24. name: 'EventTargetDialog',
  25. props: {
  26. ratio: {
  27. type: String,
  28. default: ''
  29. }
  30. },
  31. data () {
  32. return {
  33. schema: {
  34. list: this.getListInvoke,
  35. condition: { type: EventTarget.PROGRAM, name: '' },
  36. filters: [
  37. { key: 'type', type: 'select', options: [
  38. { value: EventTarget.PROGRAM, label: '单节目' },
  39. { value: EventTarget.RECUR, label: '轮播' }
  40. ] },
  41. { key: 'name', type: 'search', placeholder: '节目名称' }
  42. ],
  43. cols: [
  44. { label: '缩略图', type: 'asset', render ({ id, img }) {
  45. return img
  46. ? { id, thumbnail: img }
  47. : null
  48. }, on: this.onView },
  49. { prop: 'name', label: '节目名称' },
  50. { type: 'invoke', render: [
  51. { label: '查看', on: this.onView }
  52. ] }
  53. ]
  54. }
  55. }
  56. },
  57. methods: {
  58. show () {
  59. this.$refs.tableDialog.show()
  60. },
  61. getListInvoke ({ type, pageSize, pageNum, name }) {
  62. switch (type) {
  63. case EventTarget.RECUR:
  64. return getSchedules({
  65. pageSize, pageNum, name,
  66. type: ScheduleType.RECUR,
  67. resolutionRatio: this.ratio,
  68. status: State.AVAILABLE
  69. })
  70. default:
  71. return getPrograms({
  72. pageSize, pageNum, name,
  73. resolutionRatio: this.ratio,
  74. status: State.AVAILABLE
  75. })
  76. }
  77. },
  78. onView ({ id }) {
  79. switch (this.$refs.tableDialog.getTable().getCondition().type) {
  80. case EventTarget.PROGRAM:
  81. this.$refs.programDialog.show(id)
  82. break
  83. case EventTarget.RECUR:
  84. this.$refs.scheduleDialog.show(id)
  85. break
  86. default:
  87. break
  88. }
  89. },
  90. onChoosen ({ value, done }) {
  91. this.$emit('choosen', {
  92. value: this.getValue(this.$refs.tableDialog.getTable().getCondition().type, value),
  93. done
  94. })
  95. },
  96. getValue (type, item) {
  97. switch (type) {
  98. case EventTarget.PROGRAM:
  99. return {
  100. type,
  101. id: item.id,
  102. name: item.name,
  103. programUrl: `${item.buckets}/${item.itemConfigName}`,
  104. duration: Number(item.duration)
  105. }
  106. case EventTarget.RECUR:
  107. return {
  108. type,
  109. id: item.id,
  110. name: item.name
  111. }
  112. default:
  113. return null
  114. }
  115. }
  116. }
  117. }
  118. </script>