asset-table.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import {
  2. State,
  3. AssetTag,
  4. AssetTagInfo,
  5. AssetType,
  6. AssetTypeInfo
  7. } from '@/constant'
  8. import { getAssetsByQuery } from '@/api/asset'
  9. export const assetTableMixin = {
  10. data () {
  11. return {
  12. assetTableSchema: {
  13. list: this.getAssetsByQuery,
  14. condition: { status: State.AVAILABLE, tag: AssetTag.AD, type: AssetType.IMAGE },
  15. filters: [
  16. { key: 'tag', type: 'select', options: [
  17. { value: AssetTag.AD, label: AssetTagInfo[AssetTag.AD] },
  18. { value: AssetTag.PUBLICITY, label: AssetTagInfo[AssetTag.PUBLICITY] },
  19. { value: AssetTag.LOCAL_PUBLICITY, label: AssetTagInfo[AssetTag.LOCAL_PUBLICITY] },
  20. { value: AssetTag.SHIM, label: AssetTagInfo[AssetTag.SHIM] }
  21. ] },
  22. { key: 'type', type: 'select', options: [
  23. { value: AssetType.IMAGE, label: AssetTypeInfo[AssetType.IMAGE] },
  24. { value: AssetType.VIDEO, label: AssetTypeInfo[AssetType.VIDEO] },
  25. { value: AssetType.STREAMING_MEDIA, label: AssetTypeInfo[AssetType.STREAMING_MEDIA] }
  26. ] },
  27. { key: 'originalName', type: 'search', placeholder: '资源名称' }
  28. ],
  29. cols: [
  30. { prop: 'file', label: '资源', type: 'asset', on: this.onViewAsset },
  31. { prop: 'originalName', label: '' },
  32. { prop: 'diff', label: '其他', width: 80, align: 'center' }
  33. ]
  34. }
  35. }
  36. },
  37. methods: {
  38. onViewAsset ({ file }) {
  39. this.$refs.previewDialog.show(file)
  40. },
  41. onAssetDirectoryChanged (directory) {
  42. this.$directoryOption = directory
  43. this.$refs.transfer?.getTable.pageTo(1)
  44. },
  45. getAssetsByQuery (params) {
  46. if (!this.$directoryOption) {
  47. return Promise.resolve({ data: [] })
  48. }
  49. const { root, id, group: { path } } = this.$directoryOption
  50. return getAssetsByQuery({
  51. ...params,
  52. ...(root
  53. ? { org: path }
  54. : { treeId: id, queryRelation: '1' })
  55. })
  56. }
  57. }
  58. }