瀏覽代碼

refactor: adjust some constants

Casper Dai 3 年之前
父節點
當前提交
a588b82ccb

+ 3 - 1
src/api/base.js

@@ -26,11 +26,13 @@ const Status = {
   [State.REVIEW]: [0, 1],
   [State.REVIEW_SUBMITTED]: [1],
   [State.AVAILABLE]: [0, 1, 2],
-  [State.AVAILABLE_ASSET]: [-1, 0, 1]
+  [State.AVAILABLE_ASSET]: [-1, 0, 1],
+  [State.AVAILABLE_TENANT]: [0, 1, 2]
 }
 export function addStatusScope ({ status, ...data }) {
   switch (status) {
     case State.RESOLVED:
+    case State.AVAILABLE_TENANT:
       data.tenant = store.getters.tenant
       break
     case State.REVIEW:

+ 5 - 1
src/components/form/EditInput/index.vue

@@ -19,7 +19,7 @@
       :value="value"
       class="o-editor input u-ellipsis"
       :class="align"
-      maxlength="50"
+      :maxlength="maxlength"
       @focus="onFocus"
       @blur="onBlur"
       @input="onInput"
@@ -43,6 +43,10 @@ export default {
     align: {
       type: String,
       default: ''
+    },
+    maxlength: {
+      type: [String, Number],
+      default: 50
     }
   },
   data () {

+ 4 - 3
src/constant.js

@@ -58,7 +58,8 @@ export const State = {
   REVIEW: 100,
   REVIEW_SUBMITTED: 101,
   AVAILABLE: 110,
-  AVAILABLE_ASSET: 111
+  AVAILABLE_ASSET: 111,
+  AVAILABLE_TENANT: 112
 }
 
 export const ScheduleType = {
@@ -75,7 +76,7 @@ export const EventPriority = {
   DEFAULT: 1,
   NORMAL: 2,
   INSERTED: 3,
-  AD: 4,
+  PROGRAMME: 4,
   EMERGENT: 99
 }
 
@@ -95,7 +96,7 @@ export const EventFreq = {
 export const EventTarget = {
   PROGRAM: 1,
   RECUR: 2,
-  AD: 3
+  ASSETS: 3
 }
 
 export const ThirdPartyDevice = {

+ 1 - 1
src/layout/components/Navbar/UploadDashboard/index.vue

@@ -26,7 +26,7 @@
             />
           </div>
           <div class="l-flex--row c-sibling-item far">
-            <span class="c-sibling-item">分类</span>
+            <span class="c-sibling-item">标签</span>
             <schema-select
               v-model="subTag"
               class="c-sibling-item o-select"

+ 1 - 2
src/router/index.js

@@ -323,7 +323,6 @@ export const asyncRoutes = [
             name: 'device-management-settings',
             path: 'settings/:id',
             component: () => import('@/views/realm/device/settings/index'),
-            access: Access.MANAGE_TENANTS,
             meta: { title: '配置', cache: 'DeviceManagement' }
           }
         ]
@@ -338,7 +337,7 @@ export const asyncRoutes = [
         name: 'asset-tag',
         path: 'asset/tag',
         component: () => import('@/views/realm/tag/index'),
-        meta: { title: '素材分类' }
+        meta: { title: '素材标签' }
       },
       {
         name: 'ai-stock',

+ 1 - 0
src/scss/bem/_object.scss

@@ -187,6 +187,7 @@
 
 .o-refresh-header.cell {
   display: inline-flex !important;
+  justify-content: center;
 }
 
 .o-refresh {

+ 2 - 16
src/utils/event.js

@@ -1,7 +1,4 @@
-import {
-  EventFreq,
-  EventTarget
-} from '@/constant'
+import { EventFreq } from '@/constant'
 
 export const ONE_DAY = 86400000
 
@@ -264,11 +261,8 @@ export function correctEndTime (endTime) {
 }
 
 export function getEventDateDescription (event) {
-  const { freq, start, until, target } = event
+  const { freq, start, until } = event
   if (freq === EventFreq.WEEKLY) {
-    if (target.type === EventTarget.AD) {
-      return `自${toDateStr(start)}开始 持续${Math.ceil((toDate(until) - toDate(start)) / ONE_DAY)}天`
-    }
     return until ? `${toDateStr(start)} - ${toDateStr(until, -1)}` : `自${toDateStr(start)}开始`
   }
   return until ? `${start} - ${until}` : `自${start}开始`
@@ -276,14 +270,6 @@ export function getEventDateDescription (event) {
 
 export function getEventExtraDescription (event) {
   const { freq, byDay, start, until, startTime, endTime, target } = event
-  if (target.type === EventTarget.AD) {
-    switch (freq) {
-      case EventFreq.WEEKLY:
-        return `每日播放${(toDate(`1970/01/01 ${endTime}`) - toDate(`1970/01/01 ${startTime}`)) / target.duration / 1000}次`
-      default:
-        return `播放${(toDate(until) - toDate(start)) / target.duration / 1000}次`
-    }
-  }
   switch (freq) {
     case EventFreq.WEEKLY:
       return `每周${byDay.split(',').sort().map(val => ['日', '一', '二', '三', '四', '五', '六'][val])

+ 7 - 2
src/views/ad/api.js

@@ -11,8 +11,13 @@ import {
 
 export const TaskType = {
   ORDER: 1,
-  IMAGE: 2,
-  VIDEO: 3
+  ASSET: 2
+}
+
+export const TimeType = {
+  SCREEN: 1,
+  RANGE: 2,
+  POINT: 3
 }
 
 export function getOrders (query, options) {

+ 4 - 11
src/views/ad/components/TaskTargetDialog/index.vue

@@ -2,8 +2,8 @@
   <el-dialog
     ref="tableDialog"
     :visible.sync="choosing"
-    title="素材选择"
-    custom-class="c-dialog medium"
+    title="上播内容选择"
+    custom-class="c-dialog"
     :close-on-click-modal="false"
     v-bind="$attrs"
   >
@@ -29,8 +29,7 @@ import {
   State,
   AssetType,
   AssetTypeInfo,
-  AssetTag,
-  AssetTagInfo
+  AssetTag
 } from '@/constant'
 import {
   getAssets,
@@ -43,16 +42,10 @@ export default {
     return {
       choosing: false,
       schema: {
-        condition: { status: State.AVAILABLE, tag: AssetTag.AD, type: AssetType.IMAGE, originalName: '' },
+        condition: { status: State.AVAILABLE_TENANT, tag: AssetTag.AD, type: AssetType.IMAGE, originalName: '' },
         list: getAssets,
         transform: this.transformAsset,
         filters: [
-          { key: 'tag', type: 'select', options: [
-            { value: AssetTag.AD, label: AssetTagInfo[AssetTag.AD] },
-            { value: AssetTag.PUBLICITY, label: AssetTagInfo[AssetTag.PUBLICITY] },
-            { value: AssetTag.LOCAL_PUBLICITY, label: AssetTagInfo[AssetTag.LOCAL_PUBLICITY] },
-            { value: AssetTag.SHIM, label: AssetTagInfo[AssetTag.SHIM] }
-          ] },
           { key: 'type', type: 'select', options: [
             { value: AssetType.IMAGE, label: AssetTypeInfo[AssetType.IMAGE] },
             { value: AssetType.VIDEO, label: AssetTypeInfo[AssetType.VIDEO] }

+ 28 - 39
src/views/ad/task/index.vue

@@ -28,7 +28,7 @@
       @confirm="onAddTask"
     >
       <div class="c-grid-form mini u-align-self--center">
-        <div class="c-grid-form__label required">素材</div>
+        <div class="c-grid-form__label required">上播内容</div>
         <div
           class="c-grid-form__info c-grid-form__option c-task u-pointer"
           :data-info="assetInfo"
@@ -86,21 +86,14 @@
             v-model="taskDuration"
             :min="1"
             :max="86400"
-            step-strictly
-          />
-        </div>
-        <div class="c-grid-form__label">保底次数</div>
-        <div class="l-flex--row c-grid-form__option">
-          <el-input-number
-            v-model="taskCount"
-            :min="1"
+            :disabled="disableTaskDuration"
             step-strictly
           />
         </div>
         <div class="c-grid-form__label">上播次数</div>
         <div class="l-flex--row c-grid-form__option">
           <el-input-number
-            v-model="taskAuditCount"
+            v-model="taskCount"
             :min="1"
             step-strictly
           />
@@ -165,6 +158,7 @@ import {
 } from '@/utils'
 import {
   TaskType,
+  TimeType,
   getTasks,
   addTask,
   deleteTask,
@@ -199,14 +193,13 @@ export default {
       taskDate: '',
       taskDuration: 5,
       taskCount: 100,
-      taskAuditCount: 100,
       taskAsset: null,
       taskTime: {},
       taskTimeTypeSelectSchema: {
         options: [
-          { value: 1, label: '开机期间' },
-          { value: 2, label: '时段' },
-          { value: 3, label: '时间点' }
+          { value: TimeType.SCREEN, label: '开机期间' },
+          { value: TimeType.RANGE, label: '时段' },
+          { value: TimeType.POINT, label: '时间点' }
         ]
       }
     }
@@ -219,8 +212,7 @@ export default {
         list: getTasks,
         transform: this.transform,
         cols: [
-          { type: 'refresh' },
-          { prop: 'type', label: '类型', width: 60, align: 'center' },
+          { prop: 'type', type: 'refresh', width: 60, align: 'center' },
           { label: '上刊日期', 'min-width': 220, render: (data, h) => data.from > TaskType.ORDER
             ? h('el-date-picker', {
               staticClass: 'o-date-picker',
@@ -245,7 +237,7 @@ export default {
               }
             }, data.range)
             : data.range, 'min-width': 110, align: 'center' },
-          { label: '上播时长(s)', render: (data, h) => data.from === TaskType.IMAGE
+          { label: '上播时长(s)', render: (data, h) => data.from === TaskType.ASSET
             ? h('edit-input', {
               staticClass: 'border',
               props: {
@@ -257,7 +249,7 @@ export default {
               }
             })
             : data.duration, 'min-width': 100, align: 'center' },
-          { label: '保底次数', render: (data, h) => data.from > TaskType.ORDER
+          { label: '上播次数', render: (data, h) => data.from > TaskType.ORDER
             ? h('edit-input', {
               staticClass: 'border',
               props: {
@@ -269,18 +261,16 @@ export default {
               }
             })
             : data.count, align: 'center' },
-          { label: '上播次数', render: (data, h) => data.from > TaskType.ORDER
-            ? h('edit-input', {
-              staticClass: 'border',
-              props: {
-                value: `${data.auditCount}`,
-                align: 'center'
-              },
-              on: {
-                edit: val => this.onSimpleEdit(data, 'auditCount', val)
-              }
-            })
-            : data.auditCount, align: 'center' },
+          { label: '审核次数', render: (data, h) => h('edit-input', {
+            staticClass: 'border',
+            props: {
+              value: `${data.auditCount}`,
+              align: 'center'
+            },
+            on: {
+              edit: val => this.onSimpleEdit(data, 'auditCount', val)
+            }
+          }), align: 'center' },
           { prop: 'tag', type: 'tag', width: 100, on: this.onAudit },
           { type: 'invoke', render: [
             { label: '内容', on: this.onView },
@@ -299,7 +289,7 @@ export default {
       return this.taskAsset ? this.taskAsset.name : '点击选择'
     },
     disableTaskDuration () {
-      return this.taskAsset ? this.taskAsset.type === AssetType.IMAGE : true
+      return this.taskAsset ? this.taskAsset.type === AssetType.VIDEO : false
     }
   },
   methods: {
@@ -311,7 +301,7 @@ export default {
         id,
         from,
         fromId,
-        type: ['', '订单', '图片', '视频'][from],
+        type: ['', '订单', '素材'][from],
         startDate,
         endDate: this.offsetDate(startDate, day),
         startTime,
@@ -399,13 +389,12 @@ export default {
       const time = parseTime(new Date(), '{h}:{i}:{s}')
       this.taskDate = [date, date]
       this.taskTime = {
-        type: 1,
+        type: TimeType.SCREEN,
         val: [hour, hour],
         point: time
       }
       this.taskDuration = 5
       this.taskCount = 100
-      this.taskAuditCount = 100
       this.taskAsset = null
       this.$refs.taskDialog.show()
     },
@@ -431,7 +420,7 @@ export default {
       const { id } = this.device
       const [startDate, endDate] = this.taskDate
       addTask({
-        from: this.taskAsset.type + 1,
+        from: TaskType.ASSET,
         fromId: this.taskAsset.keyName,
         deviceIdList: [id],
         startTime: '1',
@@ -440,7 +429,7 @@ export default {
         day: (new Date(endDate) - new Date(startDate)) / 86400000 + 1,
         duration: this.taskDuration,
         count: this.taskCount,
-        auditCount: this.taskAuditCount,
+        auditCount: this.taskCount,
         enable: false
       }).then(() => {
         done()
@@ -541,15 +530,15 @@ export default {
       let targetStartTime = ''
       let targetEndTime = ''
       switch (type) {
-        case 1:
+        case TimeType.SCREEN:
           targetStartTime = '1'
           targetEndTime = '1'
           break
-        case 2:
+        case TimeType.RANGE:
           targetStartTime = val[0]
           targetEndTime = val[1]
           break
-        case 3:
+        case TimeType.POINT:
           targetStartTime = point
           break
         default:

+ 8 - 1
src/views/realm/device/Group.vue

@@ -65,7 +65,8 @@ export default {
                 : { type: 'warning', label: '未激活' }
           }, on: this.onTagClick },
           { type: 'invoke', render: [
-            { label: '详情', render ({ empty }) { return !empty }, on: this.onViewDevice }
+            { label: '详情', render ({ empty }) { return !empty }, on: this.onViewDevice },
+            { label: '配置', render ({ isMaster }) { return isMaster }, on: this.onSettingDevice }
           ] }
         ]
       }
@@ -152,6 +153,12 @@ export default {
           this.reloadSubDevices(data.parent)
         }
       })
+    },
+    onSettingDevice ({ id }) {
+      this.$router.push({
+        name: 'device-management-settings',
+        params: { id }
+      })
     }
   }
 }

+ 1 - 1
src/views/realm/device/settings/components/AdConfigDialog.vue

@@ -5,7 +5,7 @@
     @confirm="onSave"
   >
     <div class="c-grid-form medium u-align-self--center">
-      <span class="c-grid-form__label">开启</span>
+      <span class="c-grid-form__label">自助投放</span>
       <div class="l-flex--row c-grid-form__option">
         <el-switch
           v-model="attributes.enable"

+ 1 - 1
src/views/realm/device/settings/components/DeviceNormalConfig.vue

@@ -4,7 +4,7 @@
       class="o-button"
       @click="onAttributeConfig"
     >
-      属性
+      下发属性配置
     </button>
     <button
       class="o-button"

+ 17 - 9
src/views/realm/device/settings/index.vue

@@ -49,6 +49,7 @@
 </template>
 
 <script>
+import { mapGetters } from 'vuex'
 import { getDevice } from '@/api/device'
 import DeviceNormalConfig from './components/DeviceNormalConfig'
 import SendingCard from './components/external/SendingCard'
@@ -71,18 +72,25 @@ export default {
     return {
       loading: true,
       device: null,
-      active: 'DeviceNormalConfig',
-      tabs: [
-        { key: 'DeviceNormalConfig', label: '基础配置' },
-        { key: 'SendingCard', label: '发送控制设备' },
-        { key: 'ReceivingCard', label: '接收卡' },
-        { key: 'Camera', label: '摄像头' },
-        __GATEWAY__ ? { key: 'Gateway', label: '网关' } : null,
-        { key: 'DeviceShadow', label: '影子配置' }
-      ].filter(Boolean)
+      active: 'DeviceNormalConfig'
     }
   },
   computed: {
+    ...mapGetters(['isSuperAdmin']),
+    tabs () {
+      return this.isSuperAdmin
+        ? [
+          { key: 'DeviceNormalConfig', label: '基础配置' },
+          { key: 'SendingCard', label: '发送控制设备' },
+          { key: 'ReceivingCard', label: '接收卡' },
+          { key: 'Camera', label: '摄像头' },
+          __GATEWAY__ ? { key: 'Gateway', label: '网关' } : null,
+          { key: 'DeviceShadow', label: '影子配置' }
+        ].filter(Boolean)
+        : [
+          { key: 'DeviceNormalConfig', label: '基础配置' }
+        ]
+    },
     deviceId () {
       return this.$route.params.id
     },

+ 36 - 33
src/views/realm/tag/components/AssetSubTagTable.vue

@@ -5,7 +5,7 @@
   >
     <confirm-dialog
       ref="editDialog"
-      :title="dialogTitle"
+      title="新增素材标签"
       @confirm="onSave"
     >
       <div class="c-grid-form u-align-self--center">
@@ -39,7 +39,6 @@ export default {
   },
   data () {
     return {
-      isAdd: false,
       dialogTitle: '',
       schema: {
         list: this.getAssetSubTagsByTenant,
@@ -47,9 +46,14 @@ export default {
           { type: 'add', on: this.onAdd }
         ],
         cols: [
-          { prop: 'name', label: '名称' },
+          { prop: 'name', label: '名称', render: (data, h) => h('edit-input', {
+            props: {
+              value: `${data.name}`,
+              maxlength: 20
+            },
+            on: { edit: val => this.onEdit(data, val) }
+          }) },
           { type: 'invoke', render: [
-            { label: '编辑', on: this.onEdit },
             { label: '删除', on: this.onDel }
           ] }
         ]
@@ -70,44 +74,43 @@ export default {
       })
     },
     onAdd () {
-      this.isAdd = true
-      this.dialogTitle = '新增素材分类'
       this.tag = { name: '' }
       this.$refs.editDialog.show()
     },
-    onEdit (tag) {
-      this.isAdd = false
-      this.dialogTitle = '编辑素材分类'
-      const { id, name } = tag
-      this.$tag = tag
-      this.tag = { id, name }
-      this.$refs.editDialog.show()
-    },
     onSave (done) {
-      if (this.isAdd) {
-        const { name } = this.tag
-        if (!name) {
-          this.$message({
-            type: 'warning',
-            message: '请填写素材分类名称'
-          })
-          return
-        }
-        addAssetSubTag({
-          name: this.tag.name,
-          tenant: this.tenant
-        }).then(() => {
-          done()
-          this.$refs.table.pageTo()
+      const { name } = this.tag
+      if (!name) {
+        this.$message({
+          type: 'warning',
+          message: '请填写素材标签名称'
         })
         return
       }
-      if (this.$tag.name !== this.tag.name) {
-        updateAssetSubTag(this.tag).then(() => {
-          done()
-          this.$tag.name = this.tag.name
+      addAssetSubTag({
+        name,
+        tenant: this.tenant
+      }).then(() => {
+        done()
+        this.$refs.table.pageTo()
+      })
+    },
+    onEdit (tag, { newVal, oldVal }) {
+      if (newVal === oldVal) {
+        return
+      }
+      if (!newVal) {
+        this.$message({
+          type: 'warning',
+          message: '请填写素材标签名称'
         })
+        return
       }
+      updateAssetSubTag({
+        id: tag.id,
+        name: newVal
+      }).then(() => {
+        tag.name = newVal
+      })
     },
     onDel (tag) {
       deleteAssetSubTag(tag).then(() => {

+ 7 - 7
src/views/screen/material/media/mixin.js

@@ -32,6 +32,12 @@ export default {
         list: getAssetsWithDel,
         transform: this.transform,
         filters: [
+          { key: 'tag', type: 'select', placeholder: '类型', options: [
+            { value: AssetTag.AD, label: AssetTagInfo[AssetTag.AD] },
+            { value: AssetTag.PUBLICITY, label: AssetTagInfo[AssetTag.PUBLICITY] },
+            { value: AssetTag.LOCAL_PUBLICITY, label: AssetTagInfo[AssetTag.LOCAL_PUBLICITY] },
+            { value: AssetTag.SHIM, label: AssetTagInfo[AssetTag.SHIM] }
+          ] },
           { key: 'type', type: 'select', placeholder: '文件类型', options: [
             { value: AssetType.IMAGE, label: AssetTypeInfo[AssetType.IMAGE] },
             { value: AssetType.VIDEO, label: AssetTypeInfo[AssetType.VIDEO] },
@@ -39,12 +45,6 @@ export default {
             { value: AssetType.PPT, label: AssetTypeInfo[AssetType.PPT] },
             { value: AssetType.PDF, label: AssetTypeInfo[AssetType.PDF] },
             { value: AssetType.DOC, label: AssetTypeInfo[AssetType.DOC] }
-          ] },
-          { key: 'tag', type: 'select', placeholder: '类型', options: [
-            { value: AssetTag.AD, label: AssetTagInfo[AssetTag.AD] },
-            { value: AssetTag.PUBLICITY, label: AssetTagInfo[AssetTag.PUBLICITY] },
-            { value: AssetTag.LOCAL_PUBLICITY, label: AssetTagInfo[AssetTag.LOCAL_PUBLICITY] },
-            { value: AssetTag.SHIM, label: AssetTagInfo[AssetTag.SHIM] }
           ] }
         ].concat(this.active === `${State.RESOLVED}`
           ? [
@@ -53,7 +53,7 @@ export default {
           : [
           ]),
         cols: [
-          { prop: 'tagInfo', label: '类型', align: 'center', width: 80 },
+          { prop: 'tagInfo', type: 'refresh', align: 'center', width: 80 },
           { prop: 'typeName', label: '文件', align: 'center', width: 80 },
           { prop: 'file', label: '', type: 'asset', on: this.onViewAsset },
           { prop: 'name', 'min-width': isRejected ? 80 : 100, render: this.active === `${State.AVAILABLE_ASSET}`

+ 1 - 2
src/views/screen/material/program/ast/Designer.vue

@@ -450,8 +450,7 @@ export default {
           { key: 'tag', type: 'select', options: [
             { value: AssetTag.AD, label: AssetTagInfo[AssetTag.AD] },
             { value: AssetTag.PUBLICITY, label: AssetTagInfo[AssetTag.PUBLICITY] },
-            { value: AssetTag.LOCAL_PUBLICITY, label: AssetTagInfo[AssetTag.LOCAL_PUBLICITY] },
-            { value: AssetTag.SHIM, label: AssetTagInfo[AssetTag.SHIM] }
+            { value: AssetTag.LOCAL_PUBLICITY, label: AssetTagInfo[AssetTag.LOCAL_PUBLICITY] }
           ] },
           this.assetType.length > 1
             ? {