Bladeren bron

feat(media): ai status

Casper Dai 3 jaren geleden
bovenliggende
commit
8088798c0f
4 gewijzigde bestanden met toevoegingen van 100 en 33 verwijderingen
  1. 11 4
      src/api/asset.js
  2. 28 11
      src/components/table/Table/Column.vue
  3. 53 8
      src/views/platform/media/mixin.js
  4. 8 10
      src/views/schedule/deploy/index.vue

+ 11 - 4
src/api/asset.js

@@ -23,10 +23,17 @@ export function getAssets (query) {
     data.forEach(asset => {
       if (asset.type === AssetType.IMAGE) {
         asset.thumbnail = asset.keyName
+      } else if (asset.type === AssetType.VIDEO && asset.screenshot !== 'analyzing') {
+        asset.thumbnail = asset.screenshot
       }
-      if (asset.type === AssetType.VIDEO) {
-        asset.thumbnail = asset.screenshot === 'analyzing' ? void 0 : asset.screenshot
-      }
+    })
+    return { data, totalCount }
+  })
+}
+
+export function getAssetsWithDel (query) {
+  return getAssets(query).then(({ data, totalCount }) => {
+    data.forEach(asset => {
       asset.del = canDel(asset)
     })
     return { data, totalCount }
@@ -37,7 +44,7 @@ export function updateAsset (data) {
   return update({
     url: '/minio-data/update',
     method: 'POST',
-    data: data
+    data
   })
 }
 

+ 28 - 11
src/components/table/Table/Column.vue

@@ -146,6 +146,21 @@ export default {
       if (!tag) {
         return '-'
       }
+      const { msg } = tag
+      if (msg) {
+        return this.$createElement('el-tooltip', {
+          props: {
+            content: msg,
+            placement: 'left',
+            enterable: false
+          }
+        }, [
+          this.createTag(tag, data)
+        ])
+      }
+      return this.createTag(tag, data)
+    },
+    createTag (tag, data) {
       const { label, ...tagProps } = tag
       const { on } = this.schema
       return this.$createElement('el-tag', {
@@ -163,18 +178,20 @@ export default {
     renderInvokes (data) {
       const { render, use } = this.schema
       const h = this.$createElement
-      const invokes = Array.isArray(render) ? render : render(data.row)
-      return (!use || use(data.row)) && invokes.filter(({ render }) => !render || render(data.row)).map(({ label, on }) => {
-        return h('div', {
-          staticClass: 'c-table__btn u-pointer',
-          on: on && {
-            click ($event) {
-              $event.stopPropagation()
-              on(data.row, data.$index)
+      if (!use || use(data.row)) {
+        return (Array.isArray(render) ? render : render(data.row))
+          .filter(({ render }) => !render || render(data.row))
+          .map(({ label, on }) => h('div', {
+            staticClass: 'c-table__btn u-pointer',
+            on: on && {
+              click ($event) {
+                $event.stopPropagation()
+                on(data.row, data.$index)
+              }
             }
-          }
-        }, label)
-      })
+          }, label))
+      }
+      return null
     }
   },
   render (h) {

+ 53 - 8
src/views/platform/media/mixin.js

@@ -1,5 +1,5 @@
 import {
-  getAssets,
+  getAssetsWithDel,
   updateAsset,
   deleteAsset,
   submitAsset
@@ -50,15 +50,17 @@ export default {
       const canEdit = this.active === `${State.READY}`
 
       return {
-        list: getAssets,
+        list: getAssetsWithDel,
         transform: this.transform,
-        filters: this.active === `${State.RESOLVED}` ? [
-          { key: 'originalName', type: 'search', placeholder: '媒资名称' }
-        ] : [],
+        filters: this.active === `${State.RESOLVED}`
+          ? [
+            { key: 'originalName', type: 'search', placeholder: '媒资名称' }
+          ]
+          : [],
         cols: [
           { prop: 'file', type: 'asset', on: this.onViewAsset },
-          { prop: 'name', 'min-width': 100, render: canEdit ? (data, h) => {
-            return h('edit-input', {
+          { prop: 'name', 'min-width': 100, render: canEdit
+            ? (data, h) => h('edit-input', {
               model: {
                 value: data.name,
                 callback (val) {
@@ -69,10 +71,11 @@ export default {
                 edit: () => this.onEdit(data)
               }
             })
-          } : null },
+            : null },
           this.isImage ? null : { prop: 'duration', label: '时长' },
           { prop: 'size', label: '文件大小' },
           { prop: 'createTime', label: '上传时间' },
+          { prop: 'ai', label: 'AI审核', type: 'tag', width: 100 },
           { type: 'invoke', align: 'center', width: 140, render: [
             { label: '查看', on: this.onView },
             canEdit ? { label: '提交', on: this.onSubmit } : null,
@@ -112,8 +115,50 @@ export default {
       }
       asset.duration = parseDuration(asset.duration)
       asset.size = parseByte(asset.size)
+      asset.ai = this.getAIState(asset)
       return asset
     },
+    getAIState ({ aiAuditState: status, aiAuditMsg: msg }) {
+      switch (status) {
+        case 1:
+          return {
+            type: 'danger',
+            label: '不合规'
+          }
+        case 2:
+          return {
+            type: 'warning',
+            label: '疑似',
+            msg
+          }
+        case 3:
+          return {
+            type: 'info',
+            label: '审核失败',
+            msg
+          }
+        case 8:
+          return {
+            type: 'info',
+            label: '无法审核',
+            msg
+          }
+        case 4:
+        case 5:
+        case 6:
+          return {
+            type: 'primmary',
+            label: '审核中'
+          }
+        case 7:
+          return {
+            type: 'success',
+            label: '通过'
+          }
+        default:
+          return null
+      }
+    },
     to (type) {
       if (this.type !== AssetType[type]) {
         this.type = null

+ 8 - 10
src/views/schedule/deploy/index.vue

@@ -370,16 +370,14 @@ export default {
         `对设备 ${devices.map(device => device.name)}`,
         `发布 ${this.typeMsg} ${this.eventTarget.name}`,
         { type: 'warning' }
-      ).then(() => {
-        return publish(
-          devices.map((device) => device.id),
-          this.getPublishTarget(),
-          {
-            programCalendarName: this.eventTarget.name,
-            resolutionRatio: this.resolutionRatio
-          }
-        )
-      }).then(() => {
+      ).then(() => publish(
+        devices.map(device => device.id),
+        this.getPublishTarget(),
+        {
+          programCalendarName: this.eventTarget.name,
+          resolutionRatio: this.resolutionRatio
+        }
+      )).then(() => {
         this.active = 0
         this.$refs.tree.reset()
         this.eventOptions = null