Explorar o código

feat: schedule timeline (preview)

Casper Dai %!s(int64=3) %!d(string=hai) anos
pai
achega
bf07b44a49
Modificáronse 5 ficheiros con 24 adicións e 16 borrados
  1. 1 0
      .eslintrc.js
  2. 2 1
      src/router/index.js
  3. 2 2
      src/store/modules/permission.js
  4. 17 13
      src/views/schedule/timeline/index.vue
  5. 2 0
      vue.config.js

+ 1 - 0
.eslintrc.js

@@ -13,6 +13,7 @@ module.exports = {
   globals: {
     __VERSION__: true,
     __DEV__: true,
+    __PREVIEW__: true,
     __PLACEHOLDER__: true,
     __DELETABLE_FOR_ADMIN__: true,
     __SENSOR__: true,

+ 2 - 1
src/router/index.js

@@ -142,7 +142,7 @@ export const asyncRoutes = [
     ]
   },
   {
-    dev: true,
+    dev: !__PREVIEW__,
     path: '/dm',
     component: Layout,
     meta: { title: '大屏设备', icon: 'el-icon-monitor', placeholder: true },
@@ -154,6 +154,7 @@ export const asyncRoutes = [
         meta: { title: '排期预览' }
       },
       {
+        dev: true,
         name: 'remote',
         path: 'remote',
         component: () => import('@/views/remote/index'),

+ 2 - 2
src/store/modules/permission.js

@@ -13,7 +13,7 @@ export function filterAsyncRoutes (routes, roles, force) {
 
   routes.forEach(route => {
     const tmp = { ...route }
-    if ((!tmp.dev || __DEV__) && (force || hasPermission(roles, tmp))) {
+    if (!tmp.dev && (force || hasPermission(roles, tmp))) {
       if (tmp.children) {
         tmp.children = filterAsyncRoutes(tmp.children, roles, force)
       }
@@ -29,7 +29,7 @@ const state = {
 }
 
 const mutations = {
-  SET_ROUTES: (state, routes) => {
+  SET_ROUTES (state, routes) {
     state.routes = constantRoutes.concat(routes)
   }
 }

+ 17 - 13
src/views/schedule/timeline/index.vue

@@ -140,7 +140,7 @@
               v-else
               class="has-padding--h"
             >
-              当前时段暂无节目
+              {{ item.activate === 2 ? '当前时段暂无节目' : '设备未初始化' }}
             </div>
           </div>
         </div>
@@ -328,9 +328,9 @@ export default {
       this.getDevices()
     },
     transform (device) {
-      const { id, name } = device
+      const { id, name, activate } = device
       return {
-        id, name,
+        id, name, activate,
         options: {
           loading: true,
           error: false,
@@ -359,16 +359,20 @@ export default {
     getTimeline (device) {
       const options = device.options
       options.error = false
-      options.loading = true
-      getTimeline(device.id).finally(() => {
+      if (device.activate === 2) {
+        options.loading = true
+        getTimeline(device.id).finally(() => {
+          options.loading = false
+        }).then(({ data }) => {
+          options.programs = (JSON.parse(data.eventDetail) || []).map(this.createProgram)
+          this._calcPrograms(options)
+        }, () => {
+          options.error = true
+          options.list = []
+        })
+      } else {
         options.loading = false
-      }).then(({ data }) => {
-        options.programs = (JSON.parse(data.eventDetail) || []).map(this.createProgram)
-        this._calcPrograms(options)
-      }, () => {
-        options.error = true
-        options.list = []
-      })
+      }
     },
     createProgram ({ programCalendarId, type, startTimestamp, endTimestamp }) {
       const startDateTime = new Date(Number(startTimestamp))
@@ -429,7 +433,7 @@ export default {
     },
     chooseProgram (device, program) {
       this.device = device
-      this.program = program.origin
+      this.program = program ? program.origin : null
     },
     onTimeChange (val) {
       this.initTimes(val)

+ 2 - 0
vue.config.js

@@ -10,6 +10,8 @@ const features = {
   __VERSION__: JSON.stringify(`v${require('./package.json').version}.${getTimestamp()}`),
   // 未开发完的路由
   __DEV__: !isProd,
+  // 预览
+  __PREVIEW__: process.env.ENV !== 'production',
   // 未开发的功能组件
   __PLACEHOLDER__: !isProd || false,
   // 可删除已提交审核的数据