Эх сурвалжийг харах

fix: dataset cannot be paginated

Casper Dai 2 жил өмнө
parent
commit
5852c1707c

+ 57 - 8
src/views/ad/automation/dataset/components/DatasetConfigDialog.vue

@@ -1,7 +1,7 @@
 <template>
   <c-dialog
     ref="dialog"
-    size="medium"
+    size="medium fixed"
     :title="title"
   >
     <template #default>
@@ -21,7 +21,6 @@
         ref="table"
         :schema="assetSchema"
       />
-      <preview-dialog ref="previewDialog" />
       <radio-table-dialog
         ref="datasetDialog"
         title="填充素材包"
@@ -30,6 +29,13 @@
         append-to-body
         @confirm="onBindDataset"
       />
+      <table-dialog
+        ref="contentDialog"
+        :title="contentDialogTitle"
+        :schema="contentSchema"
+        append-to-body
+      />
+      <preview-dialog ref="previewDialog" />
     </template>
   </c-dialog>
 </template>
@@ -47,7 +53,8 @@ import {
   getDatasetByDevice,
   bindDatasetToDevice,
   getDatasets,
-  unbindDatasetByDevice
+  unbindDatasetByDevice,
+  getDataset
 } from '../api'
 
 export default {
@@ -57,18 +64,19 @@ export default {
       isUnbound: false,
       title: '绑定填充素材包',
       assetSchema: {
+        singlePage: true,
+        list: this.getAssetsByDataset,
+        transform: this.transformDatasetAsset,
         buttons: [
           { label: '重新绑定', on: this.onBind },
           { label: '解绑', on: this.onUnbind }
         ],
-        list: this.getAssetsByDataset,
-        transform: this.transformDatasetAsset,
         cols: [
           { prop: 'tagInfo', label: '类型', align: 'center', width: 80 },
           { prop: 'typeName', label: '文件', align: 'center', width: 80 },
           { prop: 'file', label: '', type: 'asset', on: this.onViewAsset },
           { prop: 'name', label: '' },
-          { prop: 'duration', label: '上播时长', 'align': 'center' },
+          { prop: 'duration', label: '上播时长', width: 100, 'align': 'center' },
           { type: 'invoke', render: [
             { label: '查看', on: this.onViewAsset }
           ] }
@@ -77,9 +85,33 @@ export default {
       schema: {
         list: this.getDatasets,
         cols: [
-          { prop: 'name', label: '名称', 'align': 'center' }
+          { prop: 'name', label: '名称', 'align': 'center' },
+          { type: 'invoke', render: [
+            { label: '查看', on: this.onViewDataset }
+          ] }
         ]
-      }
+      },
+      contentSchema: {
+        singlePage: true,
+        list: this.getAssets,
+        transform: this.transformDatasetAsset,
+        cols: [
+          { prop: 'tagInfo', label: '类型', align: 'center', width: 80 },
+          { prop: 'typeName', label: '文件', align: 'center', width: 80 },
+          { prop: 'file', label: '', type: 'asset', on: this.onViewAsset },
+          { prop: 'name', label: '' },
+          { prop: 'duration', label: '上播时长', 'align': 'center', width: 100 },
+          { type: 'invoke', render: [
+            { label: '查看', on: this.onViewAsset }
+          ] }
+        ]
+      },
+      datasetName: ''
+    }
+  },
+  computed: {
+    contentDialogTitle () {
+      return `${this.datasetName}的上播内容`
     }
   },
   methods: {
@@ -157,6 +189,23 @@ export default {
       unbindDatasetByDevice({ id: this.$deviceId }).then(() => {
         this.setDataset(null)
       })
+    },
+    onViewDataset ({ id, name }) {
+      this.datasetName = name
+      this.$datasetId = id
+      this.$datasetAssets = null
+      this.$refs.contentDialog.show()
+    },
+    getAssets () {
+      if (this.$datasetAssets) {
+        return Promise.resolve({ data: this.$datasetAssets })
+      }
+      return getDataset(this.$datasetId).then(({ data: { mediaList } }) => {
+        this.$datasetAssets = mediaList
+        return {
+          data: mediaList
+        }
+      })
     }
   }
 }

+ 7 - 18
src/views/ad/automation/dataset/index.vue

@@ -26,8 +26,7 @@
     </confirm-dialog>
     <table-dialog
       ref="assetDialog"
-      size="lg"
-      :title="assetDialogName"
+      title="上播内容"
       :schema="assetSchema"
     />
     <selection-table-dialog
@@ -39,7 +38,7 @@
     />
     <table-dialog
       ref="deviceDialog"
-      :title="deviceDialog"
+      title="关联的设备"
       :schema="deviceSchema"
       @row-click="onToggleSelection"
       @selection-change="onSelectionChange"
@@ -169,18 +168,9 @@ export default {
           { prop: 'address', label: '地址' }
         ]
       },
-      datasetName: '',
       dataset: {}
     }
   },
-  computed: {
-    assetDialogName () {
-      return `${this.datasetName}的上播内容`
-    },
-    deviceDialog () {
-      return `${this.datasetName}关联的设备`
-    }
-  },
   methods: {
     onAdd () {
       this.dataset = { name: '' }
@@ -195,9 +185,10 @@ export default {
         })
         return
       }
-      addDataset({ name }).then(() => {
+      addDataset({ name }).then(({ data }) => {
         done()
-        this.$refs.table.pageTo()
+        this.onEdit({ id: data })
+        this.$refs.table.pageTo(1)
       })
     },
     onEditName (dataset, { newVal, oldVal }) {
@@ -219,8 +210,7 @@ export default {
         dataset.name = oldVal
       })
     },
-    onEdit ({ id, name }) {
-      this.datasetName = name
+    onEdit ({ id }) {
       this.$datasetId = id
       this.$refs.assetDialog.show()
     },
@@ -275,8 +265,7 @@ export default {
         this.$refs.assetDialog.getTable().pageTo()
       })
     },
-    onViewDevices ({ id, name }) {
-      this.datasetName = name
+    onViewDevices ({ id }) {
       this.$datasetId = id
       this.$selectionItems = null
       this.$refs.deviceDialog.show({ datasetId: id })

+ 0 - 1
src/views/screen/review/single/index.vue

@@ -137,7 +137,6 @@ export default {
         })
         return
       }
-      console.log(this.active, this.reject)
       this.reject(this.$item, reason).then(() => {
         done()
         this.$refs.component.refresh()