Procházet zdrojové kódy

feat: support resource statistics in fill dataset

Casper Dai před 2 roky
rodič
revize
b647d4ced0
1 změnil soubory, kde provedl 76 přidání a 10 odebrání
  1. 76 10
      src/views/ad/automation/dataset/index.vue

+ 76 - 10
src/views/ad/automation/dataset/index.vue

@@ -29,8 +29,50 @@
             @change="onAssetDirectoryChanged"
           />
         </template>
+        <div
+          class="l-flex__none l-flex--row right c-sibling-item--v"
+        >
+          <div class="l-flex__fill c-sibling-item">
+            <div
+              class="o-button"
+              @click="onDelAssets"
+            >
+              移除
+            </div>
+          </div>
+          <div class="l-flex__none l-flex--row right c-sibling-item--v near u-font-size--sm u-color-black u-bold">
+            <div class="c-sibling-item">
+              {{ resourceSize }}
+            </div>
+            <div class="c-sibling-item">
+              {{ statistics }}
+            </div>
+          </div>
+          <!-- <div class="l-flex__none l-flex--row c-sibling-item near">
+            <div class="c-sibling-item u-color--info u-font-size--sm">
+              图片统一上播时长(s)
+            </div>
+            <el-input-number
+              v-model="duration"
+              class="c-sibling-item u-width--xs"
+              size="small"
+              title="上播时长(s)"
+              controls-position="right"
+              :min="1"
+              :max="86400"
+              step-strictly
+            />
+            <div
+              class="c-sibling-item near o-button"
+              @click="onSetImageDuration"
+            >
+              设置
+            </div>
+          </div> -->
+        </div>
         <schema-table
           ref="assetContentTable"
+          class="c-sibling-item--v"
           :schema="assetSchema"
           @row-click="onAssetRowClick"
           @selection-change="onAssetSelectionChange"
@@ -60,13 +102,13 @@
 import {
   AssetType,
   Dataset
-} from '@/constant'
+} from '@/constant.js'
 import {
   parseDuration,
   getAssetDuration,
   transformDatasetAssetToAsset
 } from '@/utils'
-import { getDevices } from '@/api/device'
+import { getDevices } from '@/api/device.js'
 import {
   getDatasets,
   addDataset,
@@ -81,14 +123,17 @@ import {
   unbindDatasetByDevices,
   unbindDatasetByDevice,
   copyDataset
-} from '@/api/asset'
-import { assetTableMixin } from '../mixins/asset-table'
+} from '@/api/asset.js'
+import { assetTableMixin } from '../mixins/asset-table.js'
 
 export default {
   name: 'DatasetFill',
   mixins: [assetTableMixin],
   data () {
     return {
+      assetMap: null,
+      assets: [],
+      duration: 10,
       schema: {
         list: getDatasets,
         condition: { type: Dataset.FILL },
@@ -125,9 +170,6 @@ export default {
         },
         list: this.getAssetsByDataset,
         transform: transformDatasetAssetToAsset,
-        buttons: [
-          { type: 'del', label: '移除', on: this.onDelAssets }
-        ],
         cols: [
           { type: 'selection' },
           { prop: 'tagInfo', label: '分类', width: 72, align: 'center' },
@@ -173,11 +215,34 @@ export default {
           { prop: 'name', label: '设备名称' },
           { prop: 'address', label: '地址' }
         ]
-      },
-      assetMap: null
+      }
+    }
+  },
+  computed: {
+    statistics () {
+      const length = this.assets.length
+      return `共${length}条,总时长 ${parseDuration(this.assets.reduce((total, asset) => total + asset.adDuration, 0), false)}`
+    },
+    resourceSize () {
+      const totalSizeMB = this.assets.reduce((total, item) => total + parseInt(item.minioData.size), 0) / (1024 * 1024)
+      if (totalSizeMB >= 1024) {
+        const totalSizeGB = totalSizeMB / 1024
+        return `资源包大小: ${totalSizeGB.toFixed(2)} GB`
+      }
+      return `资源包大小: ${totalSizeMB.toFixed(2)} MB`
     }
   },
   methods: {
+    onSetImageDuration () {
+      const duration = this.duration
+      this.assets.forEach(asset => {
+        const { type, disabled } = asset
+        if (!disabled && type === AssetType.IMAGE) {
+          asset.duration = duration
+          // todo
+        }
+      })
+    },
     onRefreshTable () {
       this.$refs.transfer?.getTable.pageTo(1)
     },
@@ -261,8 +326,9 @@ export default {
           map[keyName] = true
         })
         this.assetMap = map
+        this.assets = mediaList
         return {
-          data: mediaList
+          data: this.assets
         }
       })
     },