Bläddra i källkod

refactor: adjust some apis

Casper Dai 3 år sedan
förälder
incheckning
f3126e2aa3

+ 3 - 3
src/api/asset.js

@@ -16,7 +16,7 @@ import {
   addStatus,
   addStatusScope,
   addTenant,
-  addOrg,
+  addTenantAndOrg,
   addTenantOrOrg
 } from './base'
 
@@ -306,7 +306,7 @@ export function addContract (data) {
   return add({
     url: '/contract',
     method: 'POST',
-    data: addOrg(data)
+    data: addTenantAndOrg(data)
   })
 }
 
@@ -371,7 +371,7 @@ export function addAsset (data) {
   return add({
     url: '/minio-data',
     method: 'POST',
-    data: addOrg(data)
+    data: addTenantAndOrg(data)
   }, tenantRequest)
 }
 

+ 47 - 27
src/api/base.js

@@ -14,30 +14,44 @@ export function addTenant (data = {}) {
   if (data.tenant && store.getters.isSuperAdmin) {
     return data
   }
-  data.tenant = store.getters.tenant
-  return data
+  return {
+    ...data,
+    tenant: store.getters.tenant
+  }
 }
 
-export function addTenantOrOrg (data = {}) {
-  if (store.getters.isTopGroupAdmin) {
-    data.tenant = store.getters.tenant
-  } else {
-    data.org = store.getters.org
+export function addOrg (data = {}) {
+  return {
+    ...data,
+    org: store.getters.org
   }
-  return data
 }
 
-export function addOrg (data = {}, needTenant = true) {
-  if (needTenant) {
-    data.tenant = store.getters.tenant
+export function addTenantAndOrg (data = {}) {
+  return {
+    ...data,
+    tenant: store.getters.tenant,
+    org: store.getters.org
   }
-  data.org = store.getters.org
-  return data
+}
+
+export function addTenantOrOrg (data = {}) {
+  return store.getters.isTopGroupAdmin
+    ? {
+      ...data,
+      tenant: store.getters.tenant
+    }
+    : {
+      ...data,
+      org: store.getters.org
+    }
 }
 
 export function addUser (data = {}) {
-  data.user = store.getters.userId
-  return data
+  return {
+    ...data,
+    user: store.getters.userId
+  }
 }
 
 export function addScope (data) {
@@ -62,25 +76,31 @@ export function addStatus ({ status, ...data }) {
   return data
 }
 
-export function addStatusScope (data) {
-  switch (data.status) {
+export function addStatusScope ({ status, ...data }) {
+  switch (status) {
     case State.RESOLVED:
     case State.AVAILABLE_TENANT:
-      addTenant(data)
-      break
+      return {
+        ...addTenant(data),
+        status
+      }
     case State.REVIEW:
     case State.REVIEW_SUBMITTED:
-      addTenantOrOrg(data)
-      break
+      return {
+        ...addTenantOrOrg(data),
+        status
+      }
     case State.AVAILABLE:
-      addTenant(data)
-      addUser(data)
-      break
+      return {
+        ...addTenant(addUser(data)),
+        status
+      }
     default:
-      addUser(data)
-      break
+      return {
+        ...addUser(data),
+        status
+      }
   }
-  return data
 }
 
 export function canDel ({ status, org, createBy }) {

+ 3 - 3
src/api/calendar.js

@@ -10,7 +10,7 @@ import {
   messageSend,
   addStatus,
   addStatusScope,
-  addOrg,
+  addTenantAndOrg,
   canDel
 } from './base'
 import { ScheduleType } from '@/constant'
@@ -58,7 +58,7 @@ export function addSchedule (data) {
   return add({
     url: '/content/calendar',
     method: 'POST',
-    data: addOrg(data)
+    data: addTenantAndOrg(data)
   }, tenantRequest)
 }
 
@@ -161,6 +161,6 @@ export function copySchedule ({ id }, name) {
   return messageSend({
     url: '/content/calendar/copy',
     method: 'POST',
-    data: addOrg({ id, name })
+    data: addTenantAndOrg({ id, name })
   }, '复制')
 }

+ 2 - 3
src/api/device.js

@@ -9,8 +9,7 @@ import {
   confirmAndSend,
   addTenant,
   addTenantOrOrg,
-  addUser,
-  addOrg
+  addUser
 } from './base'
 import {
   AssetType,
@@ -280,7 +279,7 @@ export function addDeviceGroup (data) {
   return add({
     url: '/deviceGroup',
     method: 'POST',
-    data: addOrg(data, false)
+    data
   })
 }
 

+ 2 - 2
src/api/platform.js

@@ -7,12 +7,12 @@ import {
   del,
   reject,
   addScope,
-  addOrg
+  addTenantAndOrg
 } from './base'
 
 // 发布
 export function publish (type, ids, publishTarget, data) {
-  const requestData = addOrg({
+  const requestData = addTenantAndOrg({
     type,
     target: JSON.stringify(publishTarget),
     ...data

+ 12 - 8
src/api/program.js

@@ -9,7 +9,7 @@ import {
   messageSend,
   addStatus,
   addStatusScope,
-  addOrg,
+  addTenantAndOrg,
   canDel
 } from './base'
 
@@ -22,11 +22,6 @@ export function getProgramsByQuery (query) {
       currentPage, pageCount,
       ...params
     })
-  }).then(({ data, totalCount }) => {
-    data.forEach(program => {
-      program.del = canDel(program)
-    })
-    return { data, totalCount }
   })
 }
 
@@ -34,11 +29,20 @@ export function getPrograms (query) {
   return getProgramsByQuery(addStatusScope(query))
 }
 
+export function getProgramsWithDel (query) {
+  return getPrograms(query).then(({ data, totalCount }) => {
+    data.forEach(asset => {
+      asset.del = canDel(asset)
+    })
+    return { data, totalCount }
+  })
+}
+
 export function addProgram (data) {
   return add({
     url: '/item/add',
     method: 'POST',
-    data: addOrg(data)
+    data: addTenantAndOrg(data)
   }, tenantRequest)
 }
 
@@ -121,6 +125,6 @@ export function copyProgram ({ id }, name) {
   return messageSend({
     url: '/item/copy',
     method: 'POST',
-    data: addOrg({ id, name })
+    data: addTenantAndOrg({ id, name })
   }, '复制')
 }

+ 1 - 1
src/api/user.js

@@ -39,7 +39,7 @@ export function userinfo (silence) {
   return send(config, keycloakRequest)
 }
 
-export function addUser (data) {
+export function addUserAccount (data) {
   return add({
     url: `/users`,
     method: 'POST',

+ 19 - 0
src/mixins/role.js

@@ -0,0 +1,19 @@
+import { mapGetters } from 'vuex'
+
+export default {
+  computed: {
+    ...mapGetters(['isGroupAdmin', 'isOperator'])
+  },
+  render (h) {
+    return h(
+      this.isOperator
+        ? 'Designer'
+        : this.isGroupAdmin
+          ? 'Manager'
+          : 'Viewer',
+      {
+        props: this.$attrs
+      }
+    )
+  }
+}

+ 2 - 2
src/utils/upload.js

@@ -6,7 +6,7 @@ import {
   Message,
   Notification
 } from 'element-ui'
-import { addOrg } from '@/api/base'
+import { addTenantAndOrg } from '@/api/base'
 import request, { tenantRequest } from '@/utils/request'
 import { AssetType } from '@/constant'
 const CancelToken = axios.CancelToken
@@ -662,7 +662,7 @@ function startMerge (obj) {
   tenantRequest({
     url: '/minio-data/chunk/reduce',
     method: 'POST',
-    data: addOrg({
+    data: addTenantAndOrg({
       identifier: hash,
       filename: transformName(name),
       totalSize,

+ 1 - 1
src/views/dashboard/v0/DeviceInfo.vue

@@ -86,7 +86,7 @@ export default {
         ],
         [
           {
-            label: '产品',
+            label: '配置',
             key: 'productName'
           },
           {

+ 1 - 1
src/views/dashboard/v0/api.js

@@ -3,7 +3,7 @@ import { addTenant } from '@/api/base'
 
 export function getTimelines (deviceIdList, options) {
   return request({
-    url: `/content/deviceCalender`,
+    url: '/content/deviceCalender',
     method: 'POST',
     ...options,
     data: { deviceIdList },

+ 1 - 1
src/views/dashboard/v1/api.js

@@ -6,7 +6,7 @@ import {
 
 export function getTimelines (deviceIdList, options) {
   return request({
-    url: `/content/deviceCalender`,
+    url: '/content/deviceCalender',
     method: 'POST',
     ...options,
     data: { deviceIdList },

+ 1 - 1
src/views/device/detail/components/DeviceInfo.vue

@@ -10,7 +10,7 @@
         <div class="l-flex__fill c-info__value">{{ device.name }}</div>
       </div>
       <div class="l-flex--row l-flex__fill c-info__item">
-        <div class="l-flex__none c-info__title">产品</div>
+        <div class="l-flex__none c-info__title">配置</div>
         <div class="l-flex__fill c-info__value">{{ device.productName }}</div>
       </div>
     </div>

+ 10 - 8
src/views/device/detail/components/external/Sensors/Sensor.vue

@@ -2,14 +2,14 @@
   <div class="l-flex--col o-device-grid-item o-sensor has-border radius">
     <div class="l-flex--row l-flex__none">
       <i
-        class="l-flex__none o-device-grid-item__icon o-icon has-bg"
+        class="l-flex__none o-device-grid-item__icon o-icon medium has-bg"
         :class="type"
       />
       <span class="l-flex__fill u-color--info u-ellipsis">{{ title }}</span>
       <i
         v-if="enough"
         class="l-flex__none u-font-size--md u-color--blue el-icon-s-operation u-pointer"
-        @click="show = true"
+        @click="onShowAll"
       />
     </div>
     <div class="l-flex__fill l-flex--row center u-font-size--md u-color--black u-bold">
@@ -69,14 +69,13 @@ export default {
   data () {
     return {
       list: [],
-      show: false,
       schema: {
         singlePage: true,
         list: this.getSensors,
         cols: [
-          { prop: 'time', label: '采集时间' },
-          { prop: 'name', label: '名称' },
-          { prop: 'value', label: this.title }
+          { prop: 'name', label: '传感器名称' },
+          { prop: 'value', label: this.title },
+          { prop: 'time', label: '采集时间' }
         ]
       }
     }
@@ -117,10 +116,13 @@ export default {
   methods: {
     onUpdate (list) {
       this.list = list
-      this.$refs.tableDialog?.getTable().pageTo()
+      this.$refs.tableDialog?.getTable()?.pageTo()
     },
     getSensors () {
-      return Promise.resolve({ data: this.list })
+      return Promise.resolve({ data: this.list.concat(this.list).concat(this.list) })
+    },
+    onShowAll () {
+      this.$refs.tableDialog.show()
     }
   }
 }

+ 3 - 3
src/views/platform/tenant/device/components/Device.vue

@@ -18,10 +18,10 @@
           maxlength="50"
           clearable
         />
-        <span class="c-grid-form__label u-required">产品</span>
+        <span class="c-grid-form__label u-required">配置</span>
         <schema-select
           v-model="currObj.productId"
-          placeholder="请选择产品"
+          placeholder="请选择配置"
           :schema="productSelectSchema"
           :disabled="isSub"
         />
@@ -255,7 +255,7 @@ export default {
       if (!item.productId) {
         this.$message({
           type: 'warning',
-          message: '请选择产品'
+          message: '请选择配置'
         })
         return false
       }

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

@@ -86,7 +86,7 @@
 <script>
 import { mapGetters } from 'vuex'
 import {
-  addUser,
+  addUserAccount,
   getUsersByGroup
 } from '@/api/user'
 import Settings from './Settings'
@@ -215,7 +215,7 @@ export default {
         })
         return
       }
-      addUser({
+      addUserAccount({
         username,
         groups: this.getGroups(group),
         enabled: true

+ 21 - 30
src/views/screen/material/media/MediaDesigner.vue

@@ -21,7 +21,6 @@
       ref="table"
       :key="active"
       :schema="schema"
-      :proxy.sync="currOptions"
     />
     <streaming-media-dialog
       ref="addDialog"
@@ -40,7 +39,6 @@ import {
   AssetTagInfo
 } from '@/constant'
 import {
-  createListOptions,
   parseByte,
   getAIState
 } from '@/utils'
@@ -63,20 +61,19 @@ export default {
         { value: `${State.AVAILABLE_ASSET}`, label: '待审核' },
         { value: `${State.RESOLVED}`, label: '已审核' },
         { value: `${State.REJECTED}`, label: '已驳回' }
-      ],
-      [State.AVAILABLE_ASSET]: createListOptions({ status: State.AVAILABLE_ASSET }),
-      [State.RESOLVED]: createListOptions({ status: State.RESOLVED }),
-      [State.REJECTED]: createListOptions({ status: State.REJECTED })
+      ]
     }
   },
   computed: {
     schema () {
-      const isRejected = this.active === `${State.REJECTED}`
+      const active = Number(this.active)
+      const isRejected = active === State.REJECTED
 
       return {
         buttons: [
           { type: 'add', label: `新增${AssetTypeInfo[AssetType.STREAMING_MEDIA]}`, on: this.addStreamingMedia }
         ],
+        condition: { status: active, ...this.$condition },
         list: getAssetsWithDel,
         transform: this.transform,
         filters: [
@@ -101,22 +98,20 @@ export default {
           { prop: 'tagInfo', type: 'refresh', width: 80 },
           { prop: 'typeName', label: '资源', align: 'center', width: 80 },
           { prop: 'file', label: '', type: 'asset', on: this.onView },
-          { prop: 'name', 'min-width': 100, render: this.active === `${State.AVAILABLE_ASSET}`
-            ? (data, h) => data.del
-              ? h('edit-input', {
-                model: {
-                  value: data.name,
-                  callback (val) {
-                    data.name = typeof val === 'string' ? val.trim() : val
-                  }
-                },
-                on: {
-                  edit: () => this.onEdit(data)
+          { prop: 'name', 'min-width': 100, render: active === State.AVAILABLE_ASSET
+            ? (data, h) => h('edit-input', {
+              model: {
+                value: data.name,
+                callback (val) {
+                  data.name = typeof val === 'string' ? val.trim() : val
                 }
-              })
-              : data.name
+              },
+              on: {
+                edit: () => this.onEdit(data)
+              }
+            })
             : null },
-          this.active === `${State.RESOLVED}` ? null : { prop: 'ai', label: 'AI审核', type: 'tag' },
+          active === State.RESOLVED ? null : { prop: 'ai', label: 'AI审核', type: 'tag' },
           isRejected ? { prop: 'remark', label: '驳回原因', 'align': 'right', 'min-width': 120 } : null,
           isRejected ? null : { prop: 'size', label: '资源大小', 'align': 'right' },
           isRejected ? null : { prop: 'diff', label: '其他', 'align': 'right' },
@@ -127,19 +122,15 @@ export default {
           ] }
         ]
       }
-    },
-    currOptions: {
-      get () {
-        return this[this.active]
-      },
-      set (val) {
-        this[this.active] = val
-      }
     }
   },
   methods: {
     onTabClick ({ name: active }) {
-      this.active = active
+      if (this.active !== active) {
+        const { tag, type, originalName } = this.$refs.table.getCondition()
+        this.$condition = { tag, type, originalName }
+        this.active = active
+      }
     },
     transform (asset) {
       asset.tagInfo = AssetTagInfo[asset.tag]

+ 3 - 5
src/views/screen/material/media/MediaManager.vue

@@ -51,8 +51,8 @@ export default {
         ],
         filters: [
           { key: 'status', type: 'select', placeholder: '审核状态', options: [
-            { value: State.AVAILABLE_ASSET, label: '待审核' },
             { value: State.RESOLVED, label: '已审核' },
+            { value: State.AVAILABLE_ASSET, label: '待审核' },
             { value: State.REJECTED, label: '已驳回' }
           ] },
           { key: 'tag', type: 'select', placeholder: '类型', options: [
@@ -85,7 +85,7 @@ export default {
           { prop: 'createTime', label: '上传时间', 'align': 'right' },
           { type: 'invoke', render: [
             { label: '查看', allow: ({ status }) => status !== State.DRAFT, on: this.onView },
-            { label: '删除', allow: ({ status }) => status !== State.SUBMITTED, on: this.onDel }
+            { label: '删除', allow: ({ status }) => status !== State.DRAFT, on: this.onDel }
           ] }
         ]
       }
@@ -93,9 +93,7 @@ export default {
   },
   methods: {
     getAssetsByQuery (params) {
-      return getAssetsByQuery(addTenantOrOrg({
-        ...params
-      }))
+      return getAssetsByQuery(addTenantOrOrg(params))
     },
     transform (asset) {
       asset.tagInfo = AssetTagInfo[asset.tag]

+ 2 - 13
src/views/screen/material/media/index.vue

@@ -1,5 +1,5 @@
 <script>
-import { mapGetters } from 'vuex'
+import roleMixin from '@/mixins/role'
 import Manager from './MediaManager'
 import Designer from './MediaDesigner'
 import Viewer from './MediaViewer'
@@ -11,17 +11,6 @@ export default {
     Designer,
     Viewer
   },
-  computed: {
-    ...mapGetters(['isGroupAdmin', 'isOperator'])
-  },
-  render (h) {
-    return h(
-      this.isOperator
-        ? 'Designer'
-        : this.isGroupAdmin
-          ? 'Manager'
-          : 'Viewer'
-    )
-  }
+  mixins: [roleMixin]
 }
 </script>

+ 6 - 2
src/views/screen/material/program/Program.vue

@@ -43,6 +43,10 @@ export default {
     program: {
       type: Object,
       required: true
+    },
+    editable: {
+      type: [Boolean, String],
+      default: false
     }
   },
   data () {
@@ -52,7 +56,7 @@ export default {
   },
   computed: {
     disabled () {
-      return this.program.status !== State.READY
+      return !this.editable || this.program.status !== State.READY
     },
     style () {
       const img = this.program.img
@@ -73,7 +77,7 @@ export default {
   methods: {
     onClick () {
       const { id, status } = this.program
-      if (status !== State.SUBMITTED && status !== State.RESOLVED) {
+      if (this.editable && status !== State.SUBMITTED && status !== State.RESOLVED) {
         this.$designProgram(id)
       } else {
         this.$emit('view', this.program)

+ 28 - 11
src/views/screen/material/program/ProgramDesigner.vue

@@ -30,7 +30,7 @@
         name="1"
       />
       <el-tab-pane
-        label="驳回"
+        label="驳回"
         name="3"
       />
     </el-tabs>
@@ -42,10 +42,11 @@
         <program
           :key="item.id"
           :program="item"
+          :editable="editable"
           @view="onView"
         >
           <div
-            v-if="item.status === 1 || item.status === 2"
+            v-if="!editable"
             @click="onCopy(item)"
           >
             复制
@@ -100,12 +101,13 @@
 </template>
 
 <script>
-import { getRatiosWithUser } from '@/api/device'
+import { State } from '@/constant'
+import { getRatios } from '@/api/device'
 import {
+  getProgramsWithDel,
   addProgram,
   copyProgram
 } from '@/api/program'
-import { State } from '@/constant'
 import mixin from './mixin'
 
 export default {
@@ -113,8 +115,16 @@ export default {
   mixins: [mixin],
   data () {
     return {
-      active: `${this.status}`,
-      resolutionRatioSelectSchema: { remote: getRatiosWithUser },
+      active: `${State.READY}`,
+      schema: {
+        condition: { status: State.READY },
+        list: getProgramsWithDel,
+        filters: [
+          { key: 'resolutionRatio', type: 'select', placeholder: '全部分辨率', simple: true, remote: getRatios },
+          { key: 'name', type: 'search', placeholder: '节目名称' }
+        ]
+      },
+      resolutionRatioSelectSchema: { remote: getRatios },
       program: {},
       copyProgram: {
         id: null,
@@ -122,6 +132,12 @@ export default {
       }
     }
   },
+  computed: {
+    editable () {
+      const active = Number(this.active)
+      return active !== State.SUBMITTED && active !== State.RESOLVED
+    }
+  },
   created () {
     window.addEventListener('message', this.onMessage)
   },
@@ -148,14 +164,15 @@ export default {
       this.$refs.addDialog.show()
     },
     onConfirmAdd (done) {
-      if (!this.program.name) {
+      const { name, resolutionRatio } = this.program
+      if (!name) {
         this.$message({
           type: 'warning',
           message: '名称不能为空'
         })
         return
       }
-      if (!this.program.resolutionRatio) {
+      if (!resolutionRatio) {
         this.$message({
           type: 'warning',
           message: '请选择分辨率'
@@ -165,14 +182,14 @@ export default {
       addProgram(this.program).then(({ data: id }) => {
         done()
         this.active = `${State.READY}`
-        this.$refs.table.resetCondition({ status: State.READY, name: this.program.name })
+        this.$refs.table.resetCondition({ status: State.READY, resolutionRatio, name })
         setTimeout(() => {
           this.$designProgram(id)
         }, 500)
       })
     },
-    onCopy ({ id, name }) {
-      this.copyProgram = { id, name }
+    onCopy ({ id, resolutionRatio, name }) {
+      this.copyProgram = { id, resolutionRatio, name }
       this.$refs.copyDialog.show()
     },
     onConfirmCopy (done) {

+ 60 - 0
src/views/screen/material/program/ProgramManager.vue

@@ -0,0 +1,60 @@
+<template>
+  <wrapper
+    fill
+    margin
+    padding
+    background
+  >
+    <grid-table
+      ref="table"
+      :schema="schema"
+    >
+      <grid-table-item v-slot="item">
+        <program
+          :key="item.id"
+          :program="item"
+          @view="onView"
+        >
+          <div @click="onDel(item)">
+            删除
+          </div>
+        </program>
+      </grid-table-item>
+    </grid-table>
+    <material-dialog ref="materialDialog" />
+  </wrapper>
+</template>
+
+<script>
+import { State } from '@/constant'
+import { addTenantOrOrg } from '@/api/base'
+import { getRatios } from '@/api/device'
+import { getProgramsByQuery } from '@/api/program'
+import mixin from './mixin'
+
+export default {
+  name: 'ProgramManager',
+  mixins: [mixin],
+  data () {
+    return {
+      schema: {
+        list: this.getProgramsByQuery,
+        filters: [
+          { key: 'status', type: 'select', placeholder: '审核状态', options: [
+            { value: State.RESOLVED, label: '已审核' },
+            { value: State.SUBMITTED, label: '待审核' },
+            { value: State.REJECTED, label: '已驳回' }
+          ] },
+          { key: 'resolutionRatio', type: 'select', placeholder: '全部分辨率', simple: true, remote: getRatios },
+          { key: 'name', type: 'search', placeholder: '节目名称' }
+        ]
+      }
+    }
+  },
+  methods: {
+    getProgramsByQuery (params) {
+      return getProgramsByQuery(addTenantOrOrg(params))
+    }
+  }
+}
+</script>

+ 17 - 9
src/views/screen/material/program/ProgramViewer.vue

@@ -14,14 +14,7 @@
           :key="item.id"
           :program="item"
           @view="onView"
-        >
-          <div
-            v-if="item.del"
-            @click="onDel(item)"
-          >
-            删除
-          </div>
-        </program>
+        />
       </grid-table-item>
     </grid-table>
     <material-dialog ref="materialDialog" />
@@ -29,10 +22,25 @@
 </template>
 
 <script>
+import { State } from '@/constant'
+import { getRatios } from '@/api/device'
+import { getPrograms } from '@/api/program'
 import mixin from './mixin'
 
 export default {
   name: 'ProgramViewer',
-  mixins: [mixin]
+  mixins: [mixin],
+  data () {
+    return {
+      schema: {
+        condition: { status: State.RESOLVED },
+        list: getPrograms,
+        filters: [
+          { key: 'resolutionRatio', type: 'select', placeholder: '全部分辨率', simple: true, remote: getRatios },
+          { key: 'name', type: 'search', placeholder: '节目名称' }
+        ]
+      }
+    }
+  }
 }
 </script>

+ 4 - 2
src/views/screen/material/program/index.vue

@@ -1,14 +1,16 @@
 <script>
-import dvMixin from '@/mixins/dv'
+import roleMixin from '@/mixins/role'
 import Designer from './ProgramDesigner'
+import Manager from './ProgramManager'
 import Viewer from './ProgramViewer'
 
 export default {
   name: 'ProgramList',
   components: {
+    Manager,
     Designer,
     Viewer
   },
-  mixins: [dvMixin]
+  mixins: [roleMixin]
 }
 </script>

+ 1 - 24
src/views/screen/material/program/mixin.js

@@ -1,33 +1,10 @@
-import { getRatios } from '@/api/device'
-import {
-  getPrograms,
-  deleteProgram
-} from '@/api/program'
-import { State } from '@/constant'
+import { deleteProgram } from '@/api/program'
 import Program from './Program'
 
 export default {
   components: {
     Program
   },
-  props: {
-    status: {
-      type: Number,
-      default: State.READY
-    }
-  },
-  data () {
-    return {
-      schema: {
-        condition: { status: this.status, resolutionRatio: void 0, name: '' },
-        list: getPrograms,
-        filters: [
-          { key: 'resolutionRatio', type: 'select', placeholder: '全部分辨率', simple: true, remote: getRatios },
-          { key: 'name', type: 'search', placeholder: '节目名称' }
-        ]
-      }
-    }
-  },
   methods: {
     onDel (item) {
       deleteProgram(item).then(() => {

+ 40 - 15
src/views/screen/material/schedule/ScheduleDesigner.vue

@@ -30,12 +30,13 @@
         name="1"
       />
       <el-tab-pane
-        label="驳回"
+        label="驳回"
         name="3"
       />
     </el-tabs>
     <schema-table
       ref="table"
+      :key="active"
       :schema="schema"
     />
     <confirm-dialog
@@ -79,12 +80,13 @@
 </template>
 
 <script>
-import { getRatiosWithUser } from '@/api/device'
+import { State } from '@/constant'
+import { getRatios } from '@/api/device'
 import {
+  getSchedulesWidthDel,
   addSchedule,
   copySchedule
 } from '@/api/calendar'
-import { State } from '@/constant'
 import mixin from './mixin'
 
 export default {
@@ -98,13 +100,8 @@ export default {
   },
   data () {
     return {
-      invokes: [
-        { label: '编辑', render ({ status }) { return status !== State.SUBMITTED && status !== State.RESOLVED }, on: this.onDesign },
-        { label: '查看', render ({ status }) { return status === State.SUBMITTED || status === State.RESOLVED }, on: this.onView },
-        { label: '复制', render ({ status }) { return status === State.SUBMITTED || status === State.RESOLVED }, on: this.onCopy },
-        { label: '删除', allow: ({ del }) => del, on: this.onDel }
-      ],
-      resolutionRatioSelectSchema: { remote: getRatiosWithUser },
+      active: `${State.READY}`,
+      resolutionRatioSelectSchema: { remote: getRatios },
       schedule: {},
       copySchedule: {
         id: null,
@@ -115,6 +112,30 @@ export default {
   computed: {
     dialogTitle () {
       return `新增${[null, '日程', '轮播', '排期'][this.type]}`
+    },
+    schema () {
+      const active = Number(this.active)
+
+      return {
+        condition: { type: this.type, status: active, ...this.$condition },
+        list: getSchedulesWidthDel,
+        filters: [
+          { key: 'resolutionRatio', type: 'select', placeholder: '全部分辨率', simple: true, remote: getRatios },
+          { key: 'name', type: 'search', placeholder: '名称' }
+        ],
+        cols: [
+          { prop: 'name', label: '名称', 'min-width': 120 },
+          active === State.REJECTED ? null : { prop: 'resolutionRatio', label: '分辨率' },
+          active === State.REJECTED ? null : { prop: 'createTime', label: '创建时间' },
+          active === State.REJECTED ? { prop: 'remark', label: '驳回原因', 'min-width': 160 } : null,
+          { type: 'invoke', width: 160, render: [
+            active !== State.SUBMITTED && active !== State.RESOLVED ? { label: '编辑', on: this.onDesign } : null,
+            active === State.SUBMITTED || active === State.RESOLVED ? { label: '查看', on: this.onView } : null,
+            active === State.SUBMITTED || active === State.RESOLVED ? { label: '复制', on: this.onCopy } : null,
+            active === State.SUBMITTED ? null : { label: '删除', allow: ({ del }) => del, on: this.onDel }
+          ].filter(Boolean) }
+        ]
+      }
     }
   },
   activated () {
@@ -130,31 +151,35 @@ export default {
     },
     onAdd () {
       this.schedule = {
-        type: this.type,
         name: '',
         resolutionRatio: ''
       }
       this.$refs.addDialog.show()
     },
     onConfirmAdd (done) {
-      if (!this.schedule.name) {
+      const { name, resolutionRatio } = this.schedule
+      if (!name) {
         this.$message({
           type: 'warning',
           message: '名称不能为空'
         })
         return
       }
-      if (!this.schedule.resolutionRatio) {
+      if (!resolutionRatio) {
         this.$message({
           type: 'warning',
           message: '请选择分辨率'
         })
         return
       }
-      addSchedule(this.schedule).then(({ data: id }) => {
+      addSchedule({
+        type: this.type,
+        name,
+        resolutionRatio
+      }).then(({ data: id }) => {
         done()
         this.active = `${State.READY}`
-        this.$refs.table.resetCondition({ status: State.READY, name: this.schedule.name })
+        this.$refs.table.resetCondition({ status: State.READY, resolutionRatio, name })
         this.onDesign({ id })
       })
     },

+ 58 - 0
src/views/screen/material/schedule/ScheduleManager.vue

@@ -0,0 +1,58 @@
+<template>
+  <wrapper
+    fill
+    margin
+    padding
+    background
+  >
+    <schema-table
+      ref="table"
+      :schema="schema"
+    />
+    <material-dialog ref="materialDialog" />
+  </wrapper>
+</template>
+
+<script>
+import { State } from '@/constant'
+import { addTenantOrOrg } from '@/api/base'
+import { getRatios } from '@/api/device'
+import { getSchedulesByQuery } from '@/api/calendar'
+import mixin from './mixin'
+
+export default {
+  name: 'ScheduleManager',
+  mixins: [mixin],
+  data () {
+    return {
+      schema: {
+        condition: { type: this.type },
+        list: this.getSchedulesByQuery,
+        filters: [
+          { key: 'status', type: 'select', placeholder: '审核状态', options: [
+            { value: State.RESOLVED, label: '已审核' },
+            { value: State.SUBMITTED, label: '待审核' },
+            { value: State.REJECTED, label: '已驳回' }
+          ] },
+          { key: 'resolutionRatio', type: 'select', placeholder: '全部分辨率', simple: true, remote: getRatios },
+          { key: 'name', type: 'search', placeholder: '名称' }
+        ],
+        cols: [
+          { prop: 'name', label: '名称', 'min-width': 120 },
+          { prop: 'resolutionRatio', label: '分辨率' },
+          { prop: 'createTime', label: '创建时间', 'min-width': 90 },
+          { type: 'invoke', render: [
+            { label: '查看', on: this.onView },
+            { label: '删除', on: this.onDel }
+          ] }
+        ]
+      }
+    }
+  },
+  methods: {
+    getSchedulesByQuery (params) {
+      return getSchedulesByQuery(addTenantOrOrg(params))
+    }
+  }
+}
+</script>

+ 19 - 4
src/views/screen/material/schedule/ScheduleViewer.vue

@@ -14,6 +14,9 @@
 </template>
 
 <script>
+import { State } from '@/constant'
+import { getRatios } from '@/api/device'
+import { getSchedules } from '@/api/calendar'
 import mixin from './mixin'
 
 export default {
@@ -21,10 +24,22 @@ export default {
   mixins: [mixin],
   data () {
     return {
-      invokes: [
-        { label: '查看', on: this.onView },
-        { label: '删除', allow: ({ del }) => del, on: this.onDel }
-      ]
+      schema: {
+        condition: { type: this.type, status: State.RESOLVED },
+        list: getSchedules,
+        filters: [
+          { key: 'resolutionRatio', type: 'select', placeholder: '全部分辨率', simple: true, remote: getRatios },
+          { key: 'name', type: 'search', placeholder: '名称' }
+        ],
+        cols: [
+          { prop: 'name', label: '名称', 'min-width': 120 },
+          { prop: 'resolutionRatio', label: '分辨率' },
+          { prop: 'createTime', label: '创建时间', 'min-width': 90 },
+          { type: 'invoke', render: [
+            { label: '查看', on: this.onView }
+          ] }
+        ]
+      }
     }
   }
 }

+ 4 - 2
src/views/screen/material/schedule/index.vue

@@ -1,14 +1,16 @@
 <script>
-import dvMixin from '@/mixins/dv'
+import roleMixin from '@/mixins/role'
 import Designer from './ScheduleDesigner'
+import Manager from './ScheduleManager'
 import Viewer from './ScheduleViewer'
 
 export default {
   name: 'ScheduleList',
   components: {
+    Manager,
     Designer,
     Viewer
   },
-  mixins: [dvMixin]
+  mixins: [roleMixin]
 }
 </script>

+ 3 - 42
src/views/screen/material/schedule/mixin.js

@@ -1,53 +1,14 @@
-import { getRatios } from '@/api/device'
-import {
-  getSchedulesWidthDel,
-  deleteSchedule
-} from '@/api/calendar'
-import { State } from '@/constant'
+import { ScheduleType } from '@/constant'
+import { deleteSchedule } from '@/api/calendar'
 
 export default {
   props: {
     type: {
       type: Number,
-      default: 0
-    },
-    status: {
-      type: Number,
-      default: State.READY
-    }
-  },
-  data () {
-    return {
-      active: `${this.status}`
-    }
-  },
-  computed: {
-    schema () {
-      return {
-        condition: {
-          type: this.type,
-          status: Number(this.active),
-          ...this.getCondition()
-        },
-        list: getSchedulesWidthDel,
-        filters: [
-          { key: 'resolutionRatio', type: 'select', placeholder: '全部分辨率', simple: true, remote: getRatios },
-          { key: 'name', type: 'search', placeholder: '名称' }
-        ],
-        cols: [
-          { prop: 'name', label: '名称', 'min-width': 120 },
-          { prop: 'resolutionRatio', label: '分辨率' },
-          { prop: 'createTime', label: '创建时间', 'min-width': 90 },
-          this.active === `${State.REJECTED}` ? { prop: 'remark', label: '驳回原因' } : null,
-          { type: 'invoke', width: 160, render: this.invokes }
-        ]
-      }
+      default: ScheduleType.RECUR
     }
   },
   methods: {
-    getCondition () {
-      return this.$condition || { resolutionRatio: void 0, name: '' }
-    },
     onView ({ id }) {
       this.$refs.materialDialog.showSchedule(id)
     },