Parcourir la source

feat: batch deletion of assets and scheduling

adjust some styles
Casper Dai il y a 2 ans
Parent
commit
afe1eb7dea

+ 8 - 0
src/api/asset.js

@@ -89,6 +89,14 @@ export function deleteAsset ({ keyName, originalName }) {
   }, originalName)
 }
 
+export function deleteAssets (keyNames) {
+  return del({
+    url: '/minio-data/batchDelete',
+    method: 'POST',
+    data: keyNames
+  }, '所选资源')
+}
+
 export function getAssetUrl (keyName) {
   return `${process.env.VUE_APP_MINIO}/${keyName}`
 }

+ 8 - 0
src/api/calendar.js

@@ -69,6 +69,14 @@ export function deleteSchedule ({ id, name }) {
   }, name)
 }
 
+export function deleteSchedules (ids) {
+  return del({
+    url: '/content/calendar/batchDelete',
+    method: 'POST',
+    data: ids
+  }, '所选内容')
+}
+
 export function saveScheduleEvents (schedule, events) {
   const { id } = schedule
   return messageSend({

+ 4 - 1
src/components/dialog/MaterialDialog/index.vue

@@ -4,6 +4,7 @@
     :custom-class="customClass"
     title="上播内容"
     :close-on-click-modal="false"
+    :show-close="false"
     append-to-body
     @open="onOpen"
     @closed="onClosed"
@@ -61,6 +62,7 @@ export default {
           { prop: 'tagType', label: '文件', width: 100, align: 'center' },
           { prop: 'fileType', label: '', width: 80 },
           { prop: 'file', label: '', type: 'asset', on: this.onViewAsset },
+          { prop: 'name', label: '' },
           { prop: 'adDuration', label: '上播时长', align: 'center' },
           { type: 'invoke', render: [
             { label: '查看', allow: ({ file }) => !!file, on: this.onViewAsset }
@@ -154,7 +156,7 @@ export default {
     getContentAssets () {
       return Promise.resolve({ data: this.assets })
     },
-    transformAsset ({ tag, type, keyName, duration }) {
+    transformAsset ({ tag, type, keyName, name, duration }) {
       return {
         tagType: AssetTagInfo[tag],
         fileType: AssetTypeInfo[type],
@@ -162,6 +164,7 @@ export default {
           type,
           url: keyName
         },
+        name: name || '',
         adDuration: parseDuration(duration)
       }
     },

+ 3 - 13
src/components/service/EventTargetPicker/index.vue

@@ -107,10 +107,6 @@ export default {
     ratio: {
       type: String,
       default: ''
-    },
-    hasName: {
-      type: [Boolean, String],
-      default: false
     }
   },
   data () {
@@ -304,15 +300,9 @@ export default {
           }
           : {
             type,
-            sources: assets.map(
-              this.hasName
-                ? ({ tag, type, name, keyName, duration, size, md5 }) => {
-                  return { tag, type, name, keyName, duration, size, md5 }
-                }
-                : ({ tag, type, keyName, duration, size, md5 }) => {
-                  return { tag, type, keyName, duration, size, md5 }
-                }
-            )
+            sources: assets.map(({ tag, type, name, keyName, duration, size, md5 }) => {
+              return { tag, type, name, keyName, duration, size, md5 }
+            })
           }
     },
     getSnapshot () {

+ 0 - 1
src/components/service/Schedule/ScheduleCalendar/index.vue

@@ -71,7 +71,6 @@
           class="l-flex__auto"
           :event="event"
           :ratio="ratio"
-          has-name
         />
       </template>
     </confirm-dialog>

+ 2 - 1
src/components/table/Table/Column.vue

@@ -236,7 +236,8 @@ export default {
         return h('el-table-column', {
           props: {
             type,
-            width: 50
+            width: 50,
+            ...columnProps
           }
         })
       case 'tag':

+ 4 - 0
src/components/table/mixins/table.js

@@ -3,6 +3,10 @@ const ButtonConfig = {
   add: {
     icon: 'el-icon-circle-plus-outline',
     label: '新增'
+  },
+  del: {
+    icon: 'el-icon-delete',
+    label: '删除'
   }
 }
 

+ 2 - 0
src/views/ad/automation/task/AssetTask.vue

@@ -276,6 +276,7 @@ export default {
           { prop: 'tagType', label: '文件', width: 100, align: 'center' },
           { prop: 'fileType', label: '', width: 80 },
           { prop: 'file', label: '', type: 'asset', on: this.onViewAsset },
+          { prop: 'name', label: '' },
           { prop: 'adDuration', label: '上播时长', align: 'center' },
           { type: 'invoke', render: [
             { label: '查看', allow: ({ file }) => !!file, on: this.onViewAsset }
@@ -461,6 +462,7 @@ export default {
             url: keyName,
             thumb: getAssetThumb(minioData)
           },
+          name: minioData.originalName,
           adDuration: parseDuration(duration)
         }
       }

+ 2 - 0
src/views/ad/automation/task/ScreenTask.vue

@@ -224,6 +224,7 @@ export default {
           { prop: 'tagType', label: '文件', width: 100, align: 'center' },
           { prop: 'fileType', label: '', width: 80 },
           { prop: 'file', label: '', type: 'asset', on: this.onViewAsset },
+          { prop: 'name', label: '' },
           { prop: 'adDuration', label: '上播时长', align: 'center' },
           { type: 'invoke', render: [
             { label: '查看', allow: ({ file }) => !!file, on: this.onViewAsset }
@@ -417,6 +418,7 @@ export default {
             url: keyName,
             thumb: getAssetThumb(minioData)
           },
+          name: minioData.originalName,
           adDuration: parseDuration(duration)
         }
       }

+ 16 - 2
src/views/realm/user/Account.vue

@@ -73,7 +73,8 @@ import { mapGetters } from 'vuex'
 import {
   getUsersByDepartment,
   addUser,
-  updateUserName
+  updateUserName,
+  toggleUser
 } from '@/api/user'
 import Settings from './Settings'
 
@@ -118,7 +119,7 @@ export default {
             : {
               type: enabled ? 'success' : 'danger',
               label: enabled ? '启用' : '禁用'
-            } },
+            }, on: this.onToggle },
           { type: 'invoke', use: ({ userId }) => userId !== this.userId, render: [
             { label: '设置', on: this.onSettings }
           ] }
@@ -233,6 +234,19 @@ export default {
       updateUserName(user.userId, newVal).catch(() => {
         user.name = oldVal
       })
+    },
+    onToggle (user) {
+      const enabled = [1, 0][user.enabled]
+      this.$confirm(
+        `${enabled ? '启用' : '停用'}账号${user.userName}?`,
+        '操作确认',
+        { type: 'warning' }
+      ).then(() => toggleUser(
+        user.userId,
+        enabled
+      )).then(() => {
+        user.enabled = enabled
+      })
     }
   }
 }

+ 8 - 4
src/views/realm/user/Settings.vue

@@ -258,16 +258,20 @@ export default {
     },
     onToggleEnable () {
       const enabled = [1, 0][this.user.enabled]
-      toggleUser(
+      this.$confirm(
+        `${enabled ? '启用' : '停用'}账号${this.userName}?`,
+        '操作确认',
+        { type: 'warning' }
+      ).then(() => toggleUser(
         this.userId,
         enabled
-      ).then(() => {
+      )).then(() => {
         this.user.enabled = enabled
       })
     },
     onResetPassword () {
       this.$confirm(
-        `将${this.userName}的密码重置为默认密码?`,
+        `将账号${this.userName}的密码重置为默认密码?`,
         '操作确认',
         { type: 'warning' }
       ).then(() => {
@@ -276,7 +280,7 @@ export default {
     },
     onResetOTP () {
       this.$confirm(
-        `将${this.userName}当前绑定的OTP重置?`,
+        `将账号${this.userName}的OTP重置?`,
         '操作确认',
         { type: 'warning' }
       ).then(() => {

+ 27 - 2
src/views/screen/material/media/MediaDesigner.vue

@@ -21,6 +21,8 @@
       ref="table"
       :key="active"
       :schema="schema"
+      @row-click="onToggleSelection"
+      @selection-change="onSelectionChange"
     />
     <streaming-media-dialog
       ref="addDialog"
@@ -45,7 +47,8 @@ import {
 import {
   getAssetsWithDel,
   updateAsset,
-  deleteAsset
+  deleteAsset,
+  deleteAssets
 } from '@/api/asset'
 import StreamingMediaDialog from './components/StreamingMediaDialog.vue'
 
@@ -71,7 +74,8 @@ export default {
 
       return {
         buttons: [
-          { type: 'add', label: `新增${AssetTypeInfo[AssetType.STREAMING_MEDIA]}`, on: this.addStreamingMedia }
+          { type: 'add', label: `新增${AssetTypeInfo[AssetType.STREAMING_MEDIA]}`, on: this.addStreamingMedia },
+          { type: 'del', on: this.onBatchDel }
         ],
         condition: { status: active, ...this.$condition },
         list: getAssetsWithDel,
@@ -95,6 +99,7 @@ export default {
           { key: 'originalName', type: 'search', placeholder: '资源名称' }
         ],
         cols: [
+          { type: 'selection', selectable: row => row.del },
           { prop: 'tagInfo', type: 'refresh', width: 80 },
           { prop: 'typeName', label: '资源', align: 'center', width: 80 },
           { prop: 'file', label: '', type: 'asset', on: this.onView },
@@ -133,6 +138,7 @@ export default {
         const { tag, type, originalName } = this.$refs.table.getCondition()
         this.$condition = { tag, type, originalName }
         this.active = active
+        this.$selectionItems = null
       }
     },
     transform (asset) {
@@ -187,6 +193,25 @@ export default {
       if (Number(this.active) === State.AVAILABLE_ASSET) {
         this.$refs.table.resetCondition(streamingMedia)
       }
+    },
+    onBatchDel () {
+      if (this.$selectionItems?.length) {
+        deleteAssets(this.$selectionItems.map(({ keyName }) => keyName)).then(() => {
+          this.$refs.table.decrease(this.$selectionItems.length)
+          this.$selectionItems = null
+        })
+      } else {
+        this.$message({
+          type: 'warning',
+          message: '请先选择需要删除的资源'
+        })
+      }
+    },
+    onToggleSelection (row) {
+      this.$refs.table.getInst().toggleRowSelection(row)
+    },
+    onSelectionChange (val) {
+      this.$selectionItems = val
     }
   }
 }

+ 26 - 2
src/views/screen/material/media/MediaManager.vue

@@ -8,6 +8,8 @@
     <schema-table
       ref="table"
       :schema="schema"
+      @row-click="onToggleSelection"
+      @selection-change="onSelectionChange"
     />
     <streaming-media-dialog
       ref="addDialog"
@@ -28,7 +30,8 @@ import {
 import { addTenantOrOrg } from '@/api/base'
 import {
   getAssetsByQuery,
-  deleteAsset
+  deleteAsset,
+  deleteAssets
 } from '@/api/asset'
 import {
   parseByte,
@@ -47,7 +50,8 @@ export default {
         list: this.getAssetsByQuery,
         transform: this.transform,
         buttons: [
-          { type: 'add', label: `新增${AssetTypeInfo[AssetType.STREAMING_MEDIA]}`, on: this.addStreamingMedia }
+          { type: 'add', label: `新增${AssetTypeInfo[AssetType.STREAMING_MEDIA]}`, on: this.addStreamingMedia },
+          { type: 'del', on: this.onBatchDel }
         ],
         filters: [
           { key: 'status', type: 'select', placeholder: '审核状态', options: [
@@ -73,6 +77,7 @@ export default {
           { key: 'originalName', type: 'search', placeholder: '资源名称' }
         ],
         cols: [
+          { type: 'selection', selectable: row => row.status !== State.DRAFT },
           { prop: 'tagInfo', type: 'refresh', width: 80 },
           { prop: 'typeName', label: '资源', align: 'center', width: 80 },
           { prop: 'file', label: '', type: 'asset', on: this.onView },
@@ -153,6 +158,25 @@ export default {
         status: State.AVAILABLE_ASSET,
         ...streamingMedia
       })
+    },
+    onBatchDel () {
+      if (this.$selectionItems?.length) {
+        deleteAssets(this.$selectionItems.map(({ keyName }) => keyName)).then(() => {
+          this.$refs.table.decrease(this.$selectionItems.length)
+          this.$selectionItems = null
+        })
+      } else {
+        this.$message({
+          type: 'warning',
+          message: '请先选择需要删除的资源'
+        })
+      }
+    },
+    onToggleSelection (row) {
+      this.$refs.table.getInst().toggleRowSelection(row)
+    },
+    onSelectionChange (val) {
+      this.$selectionItems = val
     }
   }
 }

+ 10 - 1
src/views/screen/material/schedule/ScheduleDesigner.vue

@@ -38,6 +38,8 @@
       ref="table"
       :key="active"
       :schema="schema"
+      @row-click="onToggleSelection"
+      @selection-change="onSelectionChange"
     />
     <confirm-dialog
       ref="addDialog"
@@ -118,13 +120,19 @@ export default {
       const active = Number(this.active)
 
       return {
-        condition: { type: this.type, status: active, ...this.$condition },
         list: getSchedulesWidthDel,
+        condition: { type: this.type, status: active, ...this.$condition },
+        buttons: active === State.SUBMITTED
+          ? null
+          : [
+            { type: 'del', on: this.onBatchDel }
+          ],
         filters: [
           { key: 'resolutionRatio', type: 'select', placeholder: '分辨率', remote: getRatios },
           { key: 'name', type: 'search', placeholder: '名称' }
         ],
         cols: [
+          active === State.SUBMITTED ? null : { type: 'selection', selectable: row => row.del },
           { prop: 'name', label: '名称', 'min-width': 120 },
           active === State.REJECTED ? null : { prop: 'resolutionRatio', label: '分辨率' },
           active === State.REJECTED ? null : { prop: 'createTime', label: '创建时间' },
@@ -148,6 +156,7 @@ export default {
         const { resolutionRatio, name } = this.$refs.table.getCondition()
         this.$condition = { resolutionRatio, name }
         this.active = active
+        this.$selectionItems = null
       }
     },
     onAdd () {

+ 4 - 1
src/views/screen/material/schedule/ScheduleManager.vue

@@ -26,8 +26,11 @@ export default {
   data () {
     return {
       schema: {
-        condition: { type: this.type },
         list: this.getSchedulesByQuery,
+        condition: { type: this.type },
+        buttons: [
+          { type: 'del', on: this.onBatchDel }
+        ],
         filters: [
           { key: 'status', type: 'select', placeholder: '审核状态', options: [
             { value: State.RESOLVED, label: '已审核' },

+ 23 - 1
src/views/screen/material/schedule/mixin.js

@@ -1,5 +1,8 @@
 import { ScheduleType } from '@/constant'
-import { deleteSchedule } from '@/api/calendar'
+import {
+  deleteSchedule,
+  deleteSchedules
+} from '@/api/calendar'
 
 export default {
   props: {
@@ -16,6 +19,25 @@ export default {
       deleteSchedule(item).then(() => {
         this.$refs.table.decrease(1)
       })
+    },
+    onBatchDel () {
+      if (this.$selectionItems?.length) {
+        deleteSchedules(this.$selectionItems.map(({ id }) => id)).then(() => {
+          this.$refs.table.decrease(this.$selectionItems.length)
+          this.$selectionItems = null
+        })
+      } else {
+        this.$message({
+          type: 'warning',
+          message: '请先选择需要删除的内容'
+        })
+      }
+    },
+    onToggleSelection (row) {
+      this.$refs.table.getInst().toggleRowSelection(row)
+    },
+    onSelectionChange (val) {
+      this.$selectionItems = val
     }
   }
 }