Casper Dai преди 3 години
родител
ревизия
b159bc5ce8
променени са 4 файла, в които са добавени 220 реда и са изтрити 346 реда
  1. 36 16
      src/api/workflow.js
  2. 17 18
      src/views/review/workflow/detail/index.vue
  3. 25 49
      src/views/review/workflow/index.vue
  4. 142 263
      src/views/review/workflow/mine/index.vue

+ 36 - 16
src/api/workflow.js

@@ -1,27 +1,45 @@
-// 流程审批
 import request, { tenantRequest } from '@/utils/request'
 import {
-  addScope, addUser, submit, reject
+  addScope,
+  addUser,
+  submit,
+  del,
+  reject
 } from './base'
-//  审核管理分页列表
+
+export function getMyWorkflows (query) {
+  const { pageNum: pageIndex, pageSize, ...params } = query
+  return tenantRequest({
+    url: '/workflow/calendarRelease/page',
+    method: 'GET',
+    params: addUser({
+      pageIndex,
+      pageSize,
+      ...params
+    })
+  })
+}
+
 export function getPublishWorkflows (query) {
-  const { pageNum: pageIndex, pageSize, self, ...params } = query
+  const { pageNum: pageIndex, pageSize, ...params } = query
   return tenantRequest({
     url: '/workflow/calendarRelease/page',
     method: 'GET',
-    params: self
-      ? addUser({
-        pageIndex,
-        pageSize,
-        ...params
-      })
-      : addScope({
-        pageIndex,
-        pageSize,
-        ...params
-      })
+    params: addScope({
+      pageIndex,
+      pageSize,
+      ...params
+    })
   })
 }
+
+export function deleteWorkflow (workflowId) {
+  return del({
+    url: `/workflow/${workflowId}/delete`,
+    method: 'DELETE'
+  })
+}
+
 // 审核详情资源
 export function getPublishWorkflowDetail (workflowId) {
   return request({
@@ -29,7 +47,6 @@ export function getPublishWorkflowDetail (workflowId) {
     method: 'GET'
   })
 }
-// 审批通过
 
 // 审核驳回
 export function calendarPublishReject (workflowId, data, name) {
@@ -42,6 +59,7 @@ export function calendarPublishReject (workflowId, data, name) {
     name
   )
 }
+
 // 流程重提交
 export function calendarPublishRestart (workflowId, name) {
   return submit({
@@ -49,6 +67,7 @@ export function calendarPublishRestart (workflowId, name) {
     method: 'POST'
   }, name)
 }
+
 // 流程终止
 export function calendarPublishStop (workflowId) {
   return request({
@@ -56,6 +75,7 @@ export function calendarPublishStop (workflowId) {
     method: 'POST'
   })
 }
+
 // 单个流程-审核记录
 export function viewHistory ({ workflowId }) {
   return request({

+ 17 - 18
src/views/review/workflow/detail/index.vue

@@ -240,7 +240,7 @@ export default {
     },
     schema () {
       switch (this.backDataType) {
-        case front2back['assets']:
+        case front2back.assets:
           return {
             list: this.getList('assets'),
             cols: [
@@ -270,7 +270,7 @@ export default {
               }
             ]
           }
-        case front2back['program']:
+        case front2back.program:
           return {
             list: this.getList('program'),
             cols: [
@@ -310,8 +310,8 @@ export default {
               }
             ]
           }
-        case front2back['programRecur']:
-        case front2back['schedule']:
+        case front2back.programRecur:
+        case front2back.schedule:
           return {
             list: this.getList('schedule'),
             cols: [
@@ -351,7 +351,7 @@ export default {
               }
             ]
           }
-        case front2back['publish']:
+        case front2back.publish:
           return {
             list: this.getList('publish'),
             cols: [
@@ -374,7 +374,6 @@ export default {
               { prop: 'type', label: '类型', width: 100 },
               { prop: 'name', label: '名称', 'min-width': 100 },
               { prop: 'resolutionRatio', label: '分辨率' },
-              // { prop: 'createBy', label: '申请人' },
               {
                 type: 'invoke',
                 width: 160,
@@ -598,7 +597,7 @@ export default {
       return ''
     },
     onToggle (row) {
-      if (this.backDataType !== 'publish') {
+      if (this.backDataType !== front2back.publish) {
         return
       }
       this.$refs.table.getInst().toggleRowExpansion(row)
@@ -629,19 +628,19 @@ export default {
     onView (row) {
       const { id } = row
       switch (this.backDataType) {
-        case front2back['assets']:
+        case front2back.assets:
           this.$refs.reviewDialog.show(
             this.tableData.findIndex(i => i.id === id)
           )
           break
-        case front2back['program']:
+        case front2back.program:
           this.viewProgram(id)
           break
-        case front2back['schedule']:
-        case front2back['programRecur']:
+        case front2back.schedule:
+        case front2back.programRecur:
           this.viewSchedule(id)
           break
-        case front2back['publish']:
+        case front2back.publish:
           this.onPublishView(row)
           break
         default:
@@ -652,7 +651,7 @@ export default {
       this.$refs.previewDialog.show(asset)
     },
     closePreviewDialog () {
-      if (this.backDataType === front2back['assets']) {
+      if (this.backDataType === front2back.assets) {
         this.$refs.reviewDialog.close()
       }
     },
@@ -665,14 +664,14 @@ export default {
     },
     resolve (item) {
       switch (this.backDataType) {
-        case front2back['assets']:
+        case front2back.assets:
           return resolveAsset(item)
-        case front2back['program']:
+        case front2back.program:
           return resolveProgram(item)
-        case front2back['schedule']:
-        case front2back['programRecur']:
+        case front2back.schedule:
+        case front2back.programRecur:
           return resolveSchedule(item)
-        case front2back['publish']:
+        case front2back.publish:
           return resolvePublish(item)
         default:
           return new Promise().reject()

+ 25 - 49
src/views/review/workflow/index.vue

@@ -24,13 +24,6 @@ import { getEventDescription } from '@/utils/event'
 
 export default {
   name: 'WorkflowList',
-  beforeRouteEnter (to, from, next) {
-    next(vm => {
-      if (from.name === 'workflow-detail') {
-        vm.$refs.table.decrease(1)
-      }
-    })
-  },
   data () {
     return {
       schema: {
@@ -38,51 +31,39 @@ export default {
         list: getPublishWorkflows,
         transform: this.transform,
         cols: [
-          {
-            prop: 'expand',
-            type: 'expand',
-            render (data, h) {
-              return h(
-                'div',
-                {
-                  staticClass: 'o-info'
-                },
-                [
-                  h('div', null, data.desc),
-                  h('div', null, `设备:${data.device}`)
-                ]
-              )
-            }
-          },
+          { type: 'expand', render (data, h) {
+            return h('div', {
+              staticClass: 'o-info'
+            }, [
+              h('div', null, data.desc),
+              h('div', null, `设备:${data.device}`)
+            ])
+          } },
           { prop: 'type', label: '类型', width: 100 },
           { prop: 'name', label: '名称', 'min-width': 100 },
           { prop: 'resolutionRatio', label: '分辨率' },
           { prop: 'createBy', label: '申请人' },
-          { prop: 'createTime', label: '提交时间' },
-          {
-            label: '审核状态',
-            type: 'tag',
-            render ({ status }) {
-              return {
-                type: ['', 'warning', 'success', 'danger'][status],
-                label: ['草稿', '待审核', '通过', '驳回'][status]
-              }
-            }
-          },
-          {
-            type: 'invoke',
-            width: 80,
-            render: [{ label: '审核', on: this.review }]
-          }
+          { prop: 'updateTime', label: '提交时间' },
+          { type: 'invoke', render: [
+            { label: '审核', on: this.onReview }
+          ] }
         ]
       }
     }
   },
+  activated () {
+    this.$refs.table.pageTo(1)
+  },
   methods: {
     transform (item) {
-      const same = this.getSame(item.calendarRelease)
-      const diff = this.getDiff(item.calendarRelease)
-      return { ...same, ...diff, workflowId: item.id, status: item.status }
+      const { id, status, updateTime, calendarRelease } = item
+      return {
+        workflowId: id,
+        status,
+        updateTime,
+        ...this.getSame(calendarRelease),
+        ...this.getDiff(calendarRelease)
+      }
     },
     getSame ({
       id,
@@ -90,7 +71,6 @@ export default {
       resolutionRatio,
       createBy,
       createByUsername,
-      createTime,
       calendarReleaseDeviceList
     }) {
       return {
@@ -98,7 +78,6 @@ export default {
         name: programCalendarName,
         resolutionRatio,
         createBy: createByUsername || createBy,
-        createTime,
         device: calendarReleaseDeviceList
           ?.map(item => item.deviceName)
           .join(',')
@@ -124,10 +103,7 @@ export default {
       }
     },
     getDesc (target) {
-      if (
-        target.type === PublishType.EVENT
-        && target.detail.priority === EventPriority.INSERTED
-      ) {
+      if (target.type === PublishType.EVENT && target.detail.priority === EventPriority.INSERTED) {
         return getEventDescription(target.detail)
       }
       return ''
@@ -135,7 +111,7 @@ export default {
     onToggle (row) {
       this.$refs.table.getInst().toggleRowExpansion(row)
     },
-    review (item) {
+    onReview (item) {
       this.$router.push({
         name: 'workflow-detail',
         params: {

+ 142 - 263
src/views/review/workflow/mine/index.vue

@@ -19,7 +19,7 @@
         name="2"
       />
       <el-tab-pane
-        label="驳回"
+        label="驳回"
         name="3"
       />
     </el-tabs>
@@ -41,235 +41,79 @@
 
 <script>
 import {
-  getPublishWorkflows,
+  getMyWorkflows,
   calendarPublishRestart,
-  viewHistory
+  viewHistory,
+  deleteWorkflow
 } from '@/api/workflow'
-
 import {
-  PublishType, EventPriority, State, EventTarget
+  PublishType,
+  EventPriority,
+  State,
+  EventTarget
 } from '@/constant'
 import { getEventDescription } from '@/utils/event'
-// const data2label = {
-//   minio: '媒资',
-//   item: '节目',
-//   carousel: '轮播',
-//   program: '排期',
-//   calendar: '发布'
-// }
+
+const Type = {
+  minio: '媒资',
+  item: '节目',
+  carousel: '轮播',
+  program: '排期',
+  calendar: '发布'
+}
+
 export default {
-  name: 'MyWorkflow',
+  name: 'MyWorkflows',
   data () {
-    // eslint-disable-next-line consistent-this
-    const _this1 = this
     return {
-      active: '1',
-      schema: {
-        condition: { self: true, status: 1, name: '' },
-        list: getPublishWorkflows,
+      active: `${State.SUBMITTED}`,
+      workflowId: ''
+    }
+  },
+  computed: {
+    schema () {
+      const isRejected = this.active === `${State.REJECTED}`
+
+      return {
+        condition: { status: Number(this.active) },
+        list: getMyWorkflows,
         transform: this.transform,
         cols: [
-          {
-            prop: 'expand',
-            type: 'expand',
-            render (row, h) {
-              let base = [
-                h('div', null, row.desc),
-                h('div', null, `设备:${row.device}`)
-              ]
-              if (
-                row.status === State.REJECTED
-                && row.rejectEvent
-                && row.rejectEvent.length
-              ) {
-                base = base.concat(h('div', { style: { height: '10px' } }))
-                if (
-                  row.rejectEvent.length === 1
-                  && row.rejectEvent[0].type === 'calendar'
-                ) {
-                  base = base.concat(h('em', '发布驳回'))
-                } else {
-                  base = base.concat([
-                    h('em', { style: { verticalAlign: 'top' } }, '驳回对象:'),
-                    h(
-                      'ul',
-                      {
-                        staticClass: 'c-reject',
-                        style: { display: 'inline-block' }
-                      },
-                      row.rejectEvent
-                        .filter(i => i.type !== 'calendar')
-                        .map(item => h(
-                          'li',
-                          {
-                            staticClass: 'c-reject__item',
-                            class:
-                                item.type === 'minio'
-                                  ? ''
-                                  : 'c-table__btn u-pointer',
-                            // 'o-link c-table__btn u-pointer',
-                            on: {
-                              click ($event) {
-                                $event.stopPropagation()
-                                if (item.type === 'minio') {
-                                  return
-                                }
-                                _this1.onHandleReject(item, false)
-                              }
-                            }
-                          },
-                          `${item.name}`
-                        ))
-                    )
-                  ])
-                }
-              }
-              return h(
-                'div',
-                {
-                  staticClass: 'o-info'
-                },
-                base
-              )
-            }
-          },
+          { type: 'expand', render: this.renderRelative },
           { prop: 'type', label: '类型', width: 100 },
           { prop: 'name', label: '名称', 'min-width': 100 },
           { prop: 'resolutionRatio', label: '分辨率' },
-          { prop: 'createTime', label: '提交时间' },
-          {
-            label: '审核状态',
-            type: 'tag',
-            render ({ status }) {
-              return {
-                type: ['', 'warning', 'success', 'danger'][status],
-                label: ['草稿', '待审核', '通过', '驳回'][status]
-              }
-            }
-          },
-          null,
-          {
-            type: 'invoke',
-            width: 200,
-            render: [
-              { label: '查看', on: this.onView },
-              { label: '流程', on: this.onViewHistory },
-              {
-                label: '编辑',
-                render ({ status }) {
-                  return status === State.REJECTED
-                },
-                on: this.onEdit
-              },
-              {
-                label: '提交',
-                render ({ status }) {
-                  return status === State.REJECTED
-                },
-                on: this.restart
-              }
-            ]
-          }
+          { prop: 'createTime', label: '创建时间' },
+          isRejected ? { prop: 'reason', label: '驳回原因', 'min-width': 100 } : null,
+          { type: 'invoke', width: isRejected ? 200 : 120, render: [
+            isRejected ? { label: '编辑', on: this.onEdit } : { label: '查看', on: this.onView },
+            isRejected ? { label: '重提交', on: this.onResubmit } : null,
+            { label: '历史', on: this.onViewHistory },
+            isRejected ? { label: '删除', on: this.onDel } : null
+          ].filter(Boolean) }
         ]
-      },
-      temp: {
-        workflowId: ''
       }
-    }
-  },
-  computed: {
+    },
     historySchema () {
-      // eslint-disable-next-line consistent-this
-      const _this1 = this
       return {
-        props: {
-          rowClassName: this.isShowExpend
-        },
-        condition: { workflowId: this.temp.workflowId },
+        props: { rowClassName: this.isShowExpend },
+        listeners: { 'row-click': this.onToggleHistory },
+        condition: { workflowId: this.workflowId },
         list: viewHistory,
         transform: row => {
           return { ...row, rejectEvent: JSON.parse(row.rejectEvent) }
         },
         cols: [
-          {
-            prop: 'expand',
-            type: 'expand',
-            render: (row, h) => {
-              if (row.rejectEvent && row.rejectEvent.length) {
-                if (
-                  row.rejectEvent.length === 1
-                  && row.rejectEvent[0].type === 'calendar'
-                ) {
-                  return h(
-                    'div',
-                    {
-                      staticClass: 'o-info'
-                    },
-                    [h('em', '发布驳回')]
-                  )
-                }
-                let isView = true
-                if (row.index === 0 && row.status === State.REJECTED) {
-                  isView = false
-                }
-
-                return h(
-                  'div',
-                  {
-                    staticClass: 'o-info'
-                  },
-                  [
-                    h('em', { style: { verticalAlign: 'top' } }, '驳回对象:'),
-                    h(
-                      'ul',
-                      {
-                        staticClass: 'c-reject',
-                        style: { display: 'inline-block' }
-                      },
-                      row.rejectEvent
-                        .filter(i => i.type !== 'calendar')
-                        .map(item => h(
-                          'li',
-                          {
-                            staticClass: 'c-reject__item',
-                            class:
-                                item.type === 'minio'
-                                  ? ''
-                                  : 'c-table__btn u-pointer',
-                            // 'o-link c-table__btn u-pointer',
-                            on: {
-                              click ($event) {
-                                $event.stopPropagation()
-                                if (item.type === 'minio') {
-                                  return
-                                }
-                                _this1.onHandleReject(item, isView)
-                              }
-                            }
-                          },
-                          `${item.name}`
-                        ))
-                    )
-                  ]
-                )
-              }
-              return ''
-            }
-          },
-
-          { prop: 'handledBy', label: '审核人', width: 100 },
+          { type: 'expand', render: this.renderReason },
+          { prop: 'handledBy', label: '处理人', width: 100 },
           { prop: 'createTime', label: '时间' },
-          {
-            label: '状态',
-            type: 'tag',
-            render ({ status }) {
-              return {
-                type: ['', 'warning', 'success', 'danger'][status],
-                label: ['草稿', '开始审核', '通过', '驳回'][status]
-              }
+          { label: '状态', type: 'tag', render ({ status }) {
+            return {
+              type: ['', 'primary', 'success', 'danger'][status],
+              label: ['草稿', '提交', '通过', '驳回'][status]
             }
-          },
-          { prop: 'reason', label: '原因' }
+          } },
+          { prop: 'reason', label: '备注' }
         ]
       }
     }
@@ -281,39 +125,77 @@ export default {
       }
       return ''
     },
-    onViewAsset (asset) {
-      this.$refs.previewDialog.show(asset)
+    renderRelative (row, h) {
+      return h('div', { staticClass: 'o-info' }, [
+        h('div', null, row.desc),
+        h('div', { staticClass: 'c-sibling-item--v' }, `设备:${row.device}`),
+        ...this.renderRelativeItems(row, h, false)
+      ])
     },
-    onViewHistory ({ workflowId }) {
-      this.temp = {
-        workflowId
+    renderReason (row, h) {
+      return h('div', { staticClass: 'o-info' }, [
+        ...this.renderRelativeItems(row, h)
+      ])
+    },
+    renderRelativeItems (row, h, isView = true) {
+      const children = []
+      if (
+        row.status === State.REJECTED
+        && row.rejectEvent?.length
+      ) {
+        if (
+          row.rejectEvent.length === 1
+          && row.rejectEvent[0].type === 'calendar'
+        ) {
+          children.push(h('div', {
+            staticClass: 'c-sibling-item--v u-color--error'
+          }, '发布驳回'))
+        } else {
+          children.push(h('div', {
+            staticClass: 'c-sibling-item--v'
+          }, '驳回对象:'))
+          children.push(
+            h('div', {
+              staticClass: 'l-flex--col',
+              staticStyle: { 'align-items': 'flex-start' }
+            }, row.rejectEvent
+              .filter(i => i.type !== 'calendar')
+              .map(item => h('div', {
+                staticClass: isView || item.type === 'minio' ? 'u-color--black' : 'u-color--blue u-pointer',
+                staticStyle: { padding: '4px 0' },
+                on: isView || item.type === 'minio'
+                  ? null
+                  : {
+                    click: $event => {
+                      $event.stopPropagation()
+                      this.onViewOrEditItem(item)
+                    }
+                  }
+              }, `${Type[item.type]} ${item.name}`)))
+          )
+        }
       }
+      return children
+    },
+    onViewHistory ({ workflowId }) {
+      this.workflowId = workflowId
       this.$refs.tableDialog.show()
     },
     onTabClick ({ name: active }) {
       if (this.active !== active) {
         this.active = active
-        if (Number(active) === State.REJECTED) {
-          this.$set(this.schema.cols, 6, {
-            prop: 'reason',
-            label: '驳回原因'
-          })
-        } else {
-          this.$set(this.schema.cols, 6, null)
-        }
-        this.$refs.table.mergeCondition({ status: Number(active) })
       }
     },
-    transform (item) {
-      const same = this.getSame(item.calendarRelease)
-      const diff = this.getDiff(item.calendarRelease)
+    transform ({ id, status, reason, calendarRelease, rejectEvent }) {
+      const same = this.getSame(calendarRelease)
+      const diff = this.getDiff(calendarRelease)
       return {
         ...same,
         ...diff,
-        workflowId: item.id,
-        status: item.status,
-        reason: item.reason,
-        rejectEvent: JSON.parse(item.rejectEvent)
+        workflowId: id,
+        status,
+        reason,
+        rejectEvent: JSON.parse(rejectEvent)
       }
     },
     getSame ({
@@ -356,10 +238,7 @@ export default {
       }
     },
     getDesc (target) {
-      if (
-        target.type === PublishType.EVENT
-        && target.detail.priority === EventPriority.INSERTED
-      ) {
+      if (target.type === PublishType.EVENT && target.detail.priority === EventPriority.INSERTED) {
         return getEventDescription(target.detail)
       }
       return ''
@@ -367,14 +246,19 @@ export default {
     onToggle (row) {
       this.$refs.table.getInst().toggleRowExpansion(row)
     },
+    onToggleHistory (row) {
+      if (row.status === State.REJECTED) {
+        this.$refs.tableDialog.getTable().getInst().toggleRowExpansion(row)
+      }
+    },
     onView ({ target: { type, detail } }) {
       switch (type) {
         case PublishType.CALENDAR:
-          this.viewSchedule(detail)
+          this.$refs.scheduleDialog.show(detail)
           break
         case PublishType.EVENT:
           if (detail.target.type === EventTarget.RECUR) {
-            this.viewSchedule(detail.target.id)
+            this.$refs.scheduleDialog.show(detail.target.id)
           } else {
             this.$refs.programDialog.show(detail.target.id)
           }
@@ -386,61 +270,56 @@ export default {
     onEdit ({ target: { type, detail } }) {
       switch (type) {
         case PublishType.CALENDAR:
-          this.editSchedule(detail, 'schedule-design')
+          this.$router.push({
+            name: 'schedule-design',
+            params: { id: detail }
+          })
           break
         case PublishType.EVENT:
           if (detail.target.type === EventTarget.RECUR) {
-            this.editSchedule(detail.target.id, 'recur-design')
+            this.$router.push({
+              name: 'recur-design',
+              params: { id: detail.target.id }
+            })
           } else {
-            this.editProgram(detail.target.id)
+            this.$designProgram(detail.target.id)
           }
           break
         default:
           break
       }
     },
-    onHandleReject (row, isView = true) {
+    onViewOrEditItem (row) {
       switch (row.type) {
         case 'minio':
-          this.onViewAsset(row)
+          this.$refs.previewDialog.show(row)
           break
         case 'item':
-          isView
-            ? this.$refs.programDialog.show(row.id)
-            : this.editProgram(row.id)
+          this.$designProgram(row.id)
           break
         case 'carousel':
-          isView
-            ? this.viewSchedule(row.id)
-            : this.editSchedule(row.id, 'recur-design')
+          this.$router.push({
+            name: 'recur-design',
+            params: { id: row.id }
+          })
           break
-        // 排期
         case 'program':
-          isView
-            ? this.viewSchedule(row.id)
-            : this.editSchedule(row.id, 'schedule-design')
-          break
-        // 发布
-        case 'calendar':
+          this.$router.push({
+            name: 'schedule-design',
+            params: { id: row.id }
+          })
           break
         default:
           break
       }
     },
-    viewSchedule (id) {
-      this.$refs.scheduleDialog.show(id)
-    },
-    editSchedule (id, redirect) {
-      this.$router.push({
-        name: redirect,
-        params: { id: `${id}` }
+    onResubmit (item) {
+      calendarPublishRestart(item.workflowId, item.name).then(() => {
+        this.$refs.table.decrease(1)
       })
     },
-    editProgram (id) {
-      this.$designProgram(id)
-    },
-    restart (item) {
-      calendarPublishRestart(item.workflowId, item.name).then(() => {
+    onDel ({ workflowId }) {
+      deleteWorkflow(workflowId).then(() => {
         this.$refs.table.decrease(1)
       })
     }