Explorar el Código

Merge remote-tracking branch 'origin/workflow_history' into staging

fenghao hace 3 años
padre
commit
14e496f3a4

+ 12 - 0
src/api/workflow.js

@@ -56,3 +56,15 @@ export function calendarPublishStop (workflowId) {
     method: 'POST'
   })
 }
+// 单个流程-审核记录
+export function viewHistory ({ workflowId }) {
+  return request({
+    url: `/workflow/${workflowId}/history `,
+    method: 'GET'
+  }).then(({ success, data }) => {
+    if (success) {
+      data = data.map((i, index) => { return { ...i, index } })
+    }
+    return { data }
+  })
+}

+ 1 - 1
src/views/review/workflow/detail/index.vue

@@ -660,7 +660,7 @@ export default {
     onResolve (item, done) {
       this.resolve(item).then(() => {
         this.refreshStatus(item, State.RESOLVED)
-        done()
+        done && done()
       })
     },
     resolve (item) {

+ 231 - 10
src/views/review/workflow/mine/index.vue

@@ -30,22 +30,38 @@
     />
     <program-dialog ref="programDialog" />
     <schedule-dialog ref="scheduleDialog" />
+    <preview-dialog ref="previewDialog" />
+    <table-dialog
+      ref="tableDialog"
+      title="流程详细"
+      :schema="historySchema"
+    />
   </wrapper>
 </template>
 
 <script>
 import {
   getPublishWorkflows,
-  calendarPublishRestart
+  calendarPublishRestart,
+  viewHistory
 } from '@/api/workflow'
+
 import {
   PublishType, EventPriority, State, EventTarget
 } from '@/constant'
 import { getEventDescription } from '@/utils/event'
-
+// const data2label = {
+//   minio: '媒资',
+//   item: '节目',
+//   carousel: '轮播',
+//   program: '排期',
+//   calendar: '发布'
+// }
 export default {
   name: 'MyWorkflow',
   data () {
+    // eslint-disable-next-line consistent-this
+    const _this1 = this
     return {
       active: '1',
       schema: {
@@ -56,16 +72,64 @@ export default {
           {
             prop: 'expand',
             type: 'expand',
-            render (data, h) {
+            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'
                 },
-                [
-                  h('div', null, data.desc),
-                  h('div', null, `设备:${data.device}`)
-                ]
+                base
               )
             }
           },
@@ -86,9 +150,10 @@ export default {
           null,
           {
             type: 'invoke',
-            width: 160,
+            width: 200,
             render: [
               { label: '查看', on: this.onView },
+              { label: '流程', on: this.onViewHistory },
               {
                 label: '编辑',
                 render ({ status }) {
@@ -106,16 +171,132 @@ export default {
             ]
           }
         ]
+      },
+      temp: {
+        workflowId: ''
+      }
+    }
+  },
+  computed: {
+    historySchema () {
+      // eslint-disable-next-line consistent-this
+      const _this1 = this
+      return {
+        props: {
+          rowClassName: this.isShowExpend
+        },
+        condition: { workflowId: this.temp.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 },
+          { prop: 'createTime', label: '时间' },
+          {
+            label: '状态',
+            type: 'tag',
+            render ({ status }) {
+              return {
+                type: ['', 'warning', 'success', 'danger'][status],
+                label: ['草稿', '开始审核', '通过', '驳回'][status]
+              }
+            }
+          },
+          { prop: 'reason', label: '原因' }
+        ]
       }
     }
   },
   methods: {
+    isShowExpend ({ row }) {
+      if (row.status !== State.REJECTED) {
+        return 'hide-expend'
+      }
+      return ''
+    },
+    onViewAsset (asset) {
+      this.$refs.previewDialog.show(asset)
+    },
+    onViewHistory ({ workflowId }) {
+      this.temp = {
+        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: '驳回原因'
+            prop: 'reason',
+            label: '驳回原因'
           })
         } else {
           this.$set(this.schema.cols, 6, null)
@@ -126,7 +307,14 @@ export default {
     transform (item) {
       const same = this.getSame(item.calendarRelease)
       const diff = this.getDiff(item.calendarRelease)
-      return { ...same, ...diff, workflowId: item.id, status: item.status, reason: item.reason }
+      return {
+        ...same,
+        ...diff,
+        workflowId: item.id,
+        status: item.status,
+        reason: item.reason,
+        rejectEvent: JSON.parse(item.rejectEvent)
+      }
     },
     getSame ({
       id,
@@ -211,6 +399,34 @@ export default {
           break
       }
     },
+    onHandleReject (row, isView = true) {
+      switch (row.type) {
+        case 'minio':
+          this.onViewAsset(row)
+          break
+        case 'item':
+          isView
+            ? this.$refs.programDialog.show(row.id)
+            : this.editProgram(row.id)
+          break
+        case 'carousel':
+          isView
+            ? this.viewSchedule(row.id)
+            : this.editSchedule(row.id, 'recur-design')
+          break
+        // 排期
+        case 'program':
+          isView
+            ? this.viewSchedule(row.id)
+            : this.editSchedule(row.id, 'schedule-design')
+          break
+        // 发布
+        case 'calendar':
+          break
+        default:
+          break
+      }
+    },
     viewSchedule (id) {
       this.$refs.scheduleDialog.show(id)
     },
@@ -231,3 +447,8 @@ export default {
   }
 }
 </script>
+<style lang="scss" scoped>
+::v-deep .hide-expend .el-table__expand-icon {
+  display: none;
+}
+</style>