Sfoglia il codice sorgente

fix(contract): unable to add content

Casper Dai 3 anni fa
parent
commit
a0caa8537e
1 ha cambiato i file con 20 aggiunte e 10 eliminazioni
  1. 20 10
      src/views/ad/contract/index.vue

+ 20 - 10
src/views/ad/contract/index.vue

@@ -173,8 +173,9 @@
     </confirm-dialog>
     <table-dialog
       ref="assetTableDialog"
+      title="上播内容选择"
       :schema="assetTableSchema"
-      @row-dblclick="onChoosenAsset"
+      @choosen="onChoosenAsset"
     />
     <preview-dialog ref="previewDialog" />
   </wrapper>
@@ -324,7 +325,9 @@ export default {
           time: parseTaskTime({ startTime: data.startTime, endTime: data.endTime })
         }
         this.files = files
-        this.assets = assets.map(({ id, keyName, duration, minioData }) => {
+        this.$assetMap = {}
+        this.assets = assets.map(({ id, keyName, orderNo, duration, minioData }) => {
+          this.$assetMap[id] = `${orderNo}_${duration}`
           return {
             key: id,
             id,
@@ -336,10 +339,6 @@ export default {
             disabled: minioData.type === AssetType.VIDEO
           }
         })
-        this.$assets = {}
-        this.assets.forEach(({ id, duration, orderNo }) => {
-          this.$assets[id] = { duration, orderNo }
-        })
         this.$refs.editDialog.show()
       })
     },
@@ -357,6 +356,9 @@ export default {
         data.attrs = attrs
       }
       let totalDuration = 0
+      const delIdMap = {
+        ...this.$assetMap
+      }
       const assets = this.assets.map(({ id, keyName, duration }, index) => {
         totalDuration += duration
         const data = {
@@ -365,21 +367,29 @@ export default {
           orderNo: index
         }
         if (id) {
-          delete this.$assets[id]
           data.id = id
         }
         return data
+      }).filter(({ id, orderNo, duration }) => {
+        if (id) {
+          delete delIdMap[id]
+          console.log(`${orderNo}_${duration}`, this.$assetMap[id])
+          if (`${orderNo}_${duration}` === this.$assetMap[id]) {
+            return false
+          }
+        }
+        return true
       })
       if (assets.length > 0) {
         data.assets = assets
       }
-      const delIds = Object.keys(this.$assets)
+      const delIds = Object.keys(delIdMap)
       if (delIds.length > 0) {
         data.deleteIds = delIds
       }
-      if (totalDuration && totalDuration !== duration) {
+      if (this.assets.length > 1 && totalDuration % duration !== 0) {
         this.$confirm(
-          '上播时长与上播内容总时长不一致',
+          '上播时长与上播内容总时长不一致,上播内容无法完整播放',
           '继续保存',
           { type: 'warning' }
         ).then(() => {