SpacerConfigDialog.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <table-dialog
  3. ref="dialog"
  4. title="垫片"
  5. :schema="schema"
  6. >
  7. <single-asset-dialog
  8. ref="assetDialog"
  9. :choosen="onChoosenAsset"
  10. @directory-changed="onAssetDirectoryChanged"
  11. @view="onViewAsset"
  12. />
  13. <preview-dialog ref="previewDialog" />
  14. </table-dialog>
  15. </template>
  16. <script>
  17. import { mapGetters } from 'vuex'
  18. import { AssetType } from '@/constant'
  19. import {
  20. getSpacers,
  21. addSpacers,
  22. deleteSpacer
  23. } from '@/api/platform'
  24. export default {
  25. name: 'SpacerTenantConfigDialog',
  26. data () {
  27. return {
  28. schema: {
  29. nonPagination: true,
  30. list: this.getSpacers,
  31. buttons: [
  32. { type: 'add', label: '新增图片', on: this.onAddImage },
  33. { type: 'add', label: '新增视频', on: this.onAddVideo }
  34. ],
  35. cols: [
  36. { prop: 'tagInfo', label: '类型', width: 80 },
  37. { prop: 'typeInfo', label: '资源', align: 'center', width: 72 },
  38. { prop: 'file', label: '', type: 'asset', on: this.onViewAsset },
  39. { prop: 'sizeInfo', label: '资源大小', 'align': 'right' },
  40. { prop: 'diff', label: '其他', 'align': 'right' },
  41. { type: 'invoke', render: [
  42. { label: '查看', on: this.onViewAsset },
  43. { label: '删除', on: this.onDel }
  44. ] }
  45. ]
  46. }
  47. }
  48. },
  49. computed: {
  50. ...mapGetters(['tenant'])
  51. },
  52. methods: {
  53. show () {
  54. this.$refs.dialog.show()
  55. },
  56. getSpacers () {
  57. return getSpacers({
  58. targetType: 2,
  59. targetKey: this.tenant
  60. })
  61. },
  62. onAddImage () {
  63. this.$refs.assetDialog.show(
  64. AssetType.IMAGE,
  65. this.directoryOption
  66. )
  67. },
  68. onAddVideo () {
  69. this.$refs.assetDialog.show(
  70. AssetType.VIDEO,
  71. this.directoryOption
  72. )
  73. },
  74. onAssetDirectoryChanged (directory) {
  75. this.directoryOption = directory
  76. },
  77. onViewAsset ({ file }) {
  78. this.$refs.previewDialog.show(file)
  79. },
  80. onChoosenAsset ({ tag, type, keyName, size, duration, md5 }) {
  81. return addSpacers({
  82. targetType: 2,
  83. targetKey: this.tenant,
  84. spacers: [
  85. { tag, type, keyName, size, duration, md5 }
  86. ]
  87. }).then(() => {
  88. this.$refs.dialog.getTable().pageTo(1)
  89. })
  90. },
  91. onDel (spacer) {
  92. deleteSpacer(spacer).then(() => {
  93. this.$refs.dialog.getTable().decrease(1)
  94. })
  95. }
  96. }
  97. }
  98. </script>