index.vue 2.7 KB

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