import { State, AssetTag, AssetTagInfo, AssetType, AssetTypeInfo } from '@/constant' import { getAssetsByQuery } from '@/api/asset' export const assetTableMixin = { data () { return { assetTableSchema: { list: this.getAssetsByQuery, condition: { status: State.AVAILABLE, tag: AssetTag.AD, type: AssetType.IMAGE }, filters: [ { key: 'tag', type: 'select', options: [ { value: AssetTag.AD, label: AssetTagInfo[AssetTag.AD] }, { value: AssetTag.PUBLICITY, label: AssetTagInfo[AssetTag.PUBLICITY] }, { value: AssetTag.LOCAL_PUBLICITY, label: AssetTagInfo[AssetTag.LOCAL_PUBLICITY] }, { value: AssetTag.SHIM, label: AssetTagInfo[AssetTag.SHIM] } ] }, { key: 'type', type: 'select', options: [ { value: AssetType.IMAGE, label: AssetTypeInfo[AssetType.IMAGE] }, { value: AssetType.VIDEO, label: AssetTypeInfo[AssetType.VIDEO] }, { value: AssetType.STREAMING_MEDIA, label: AssetTypeInfo[AssetType.STREAMING_MEDIA] } ] }, { key: 'originalName', type: 'search', placeholder: '资源名称' } ], cols: [ { prop: 'file', label: '资源', type: 'asset', on: this.onViewAsset }, { prop: 'originalName', label: '' }, { prop: 'diff', label: '其他', width: 80, align: 'center' } ] } } }, methods: { onViewAsset ({ file }) { this.$refs.previewDialog.show(file) }, onAssetDirectoryChanged (directory) { this.$directoryOption = directory this.$refs.transfer?.getTable.pageTo(1) }, getAssetsByQuery (params) { if (!this.$directoryOption) { return Promise.resolve({ data: [] }) } const { root, id, group: { path } } = this.$directoryOption return getAssetsByQuery({ ...params, ...(root ? { org: path } : { treeId: id, queryRelation: '1' }) }) } } }