浏览代码

refactor: adjust publish review workflow

fenghao 3 年之前
父节点
当前提交
4845e96da6

+ 4 - 4
src/api/workflow.js

@@ -1,7 +1,7 @@
 // 流程审批
 import request, { tenantRequest } from '@/utils/request'
 import {
-  addScope, addUser, resolve, reject
+  addScope, addUser, submit, reject
 } from './base'
 //  审核管理分页列表
 export function getPublishWorkflows (query) {
@@ -43,11 +43,11 @@ export function calendarPublishReject (workflowId, data, name) {
   )
 }
 // 流程重提交
-export function calendarPublishRestart (workflowId) {
-  return resolve({
+export function calendarPublishRestart (workflowId, name) {
+  return submit({
     url: `/workflow/${workflowId}/restart `,
     method: 'POST'
-  }, '提交')
+  }, name)
 }
 // 流程终止
 export function calendarPublishStop (workflowId) {

+ 47 - 10
src/views/review/components/MyWorkflow.vue

@@ -1,9 +1,32 @@
 <template>
-  <schema-table
-    ref="table"
-    :schema="schema"
-    @row-click="onToggle"
-  />
+  <div>
+    <el-tabs
+      :value="active"
+      class="c-tabs has-bottom-padding"
+      @tab-click="onTabClick"
+    >
+
+      <el-tab-pane
+        label="待审核"
+        name="1"
+      />
+      <el-tab-pane
+        label="已审核"
+        name="2"
+      />
+      <el-tab-pane
+        label="被驳回"
+        name="3"
+      />
+    </el-tabs>
+    <schema-table
+      ref="table"
+      :schema="schema"
+      @row-click="onToggle"
+    />
+    <schedule-dialog ref="scheduleDialog" />
+  </div>
+
 </template>
 
 <script>
@@ -18,8 +41,12 @@ export default {
   name: 'MyWorkflow',
   data () {
     return {
+      active: '1',
       schema: {
-        condition: { self: true },
+        condition: { self: true, status: 1, name: '' },
+        // filters: [
+        //   { key: 'name', type: 'search', placeholder: '名称' }
+        // ],
         list: getPublishWorkflows,
         transform: this.transform,
         cols: [
@@ -58,8 +85,10 @@ export default {
             type: 'invoke',
             width: 160,
             render: [
-              { label: '审核', on: this.review },
-              { label: '提交', on: this.restart }
+              { label: '查看', on: this.onView },
+              { label: '提交', render ({ status }) {
+                return status === 3
+              }, on: this.restart }
             ]
           }
         ]
@@ -67,10 +96,16 @@ export default {
     }
   },
   methods: {
+    onTabClick ({ name: active }) {
+      if (this.active !== active) {
+        this.active = active
+        this.$refs.table.mergeCondition({ status: Number(active) })
+      }
+    },
     transform (item) {
       const same = this.getSame(item.calendarRelease)
       const diff = this.getDiff(item.calendarRelease)
-      return { ...same, ...diff, workflowId: item.id }
+      return { ...same, ...diff, workflowId: item.id, status: item.status }
     },
     getSame ({
       id,
@@ -160,7 +195,9 @@ export default {
       })
     },
     restart (item) {
-      calendarPublishRestart(item.workflowId).then(() => {})
+      calendarPublishRestart(item.workflowId, item.name).then(() => {
+        this.$refs.table.onPagination()
+      })
     }
   }
 }

+ 3 - 2
src/views/review/components/ReviewWorkflow.vue

@@ -64,7 +64,7 @@ export default {
     transform (item) {
       const same = this.getSame(item.calendarRelease)
       const diff = this.getDiff(item.calendarRelease)
-      return { ...same, ...diff, workflowId: item.id }
+      return { ...same, ...diff, workflowId: item.id, status: item.status }
     },
     getSame ({
       id,
@@ -149,7 +149,8 @@ export default {
       this.$router.push({
         name: 'review-detail',
         params: {
-          id: item.workflowId
+          id: item.workflowId,
+          name: item.name
         }
       })
     }

+ 124 - 33
src/views/review/detail/index.vue

@@ -12,6 +12,7 @@
       @click="getPublishWorkflowDetail"
     />
     <div v-if="dataMap.length">
+      <div class="l-flex--row has-padding o-title">{{ title }}</div>
       <div class="l-flex--row has-padding">
         <el-steps
           :active="active"
@@ -44,19 +45,17 @@
       </div>
 
       <div class="l-flex--row fl-end has-padding">
-        <el-button
+        <!-- <el-button
           v-if="active === totalStep - 2"
           class="o-button"
           @click="onPublish"
-        >流程通过</el-button>
+          >确认发布</el-button
+        > -->
         <el-button
-          v-if="
-            (active < totalStep && rejectInfo.length) ||
-              active === totalStep - 2
-          "
+          v-if="showTempReject && tempRejectInfo.length"
           class="o-button"
           @click="reject"
-        >流程驳回</el-button>
+        >{{ tempRejectMap[backDataType]["text"] }}</el-button>
       </div>
       <schema-table
         v-if="active < totalStep"
@@ -67,6 +66,7 @@
       >
         <preview-dialog ref="previewDialog" />
         <review-dialog
+          v-if="dataMap[active] === 'minios'"
           ref="reviewDialog"
           :list="tableData"
           @resolve="onResolve"
@@ -140,6 +140,7 @@ import {
   EventTarget,
   PublishType
 } from '@/constant'
+// 前端命名 和后端数据命名
 const front2back = {
   assets: 'minios',
   program: 'items',
@@ -147,13 +148,30 @@ const front2back = {
   schedule: 'programCalendar',
   publish: 'calendarReleaseScheduling'
 }
+// 数据 是否单个还是list
+const singleMap = {
+  minios: false,
+  items: false,
+  carousels: false,
+  programCalendar: true,
+  calendarReleaseScheduling: true
+}
+// 数据 转 驳回type
 const data2type = {
   minios: 'minio',
   items: 'item',
-  carousels: 'carouse',
+  carousels: 'carousel',
   programCalendar: 'program',
   calendarReleaseScheduling: 'calendar'
 }
+// label
+const data2label = {
+  minios: '媒资',
+  items: '节目',
+  carousels: '轮播',
+  programCalendar: '排期',
+  calendarReleaseScheduling: '发布'
+}
 function showOpt (status) {
   return ![2, 3].includes(status)
 }
@@ -187,21 +205,37 @@ export default {
         type: '',
         reason: ''
       },
-      rejectInfo: []
+      tempRejectInfo: [],
+      tempRejectMap: {}
     }
   },
   computed: {
+    backDataType () {
+      return this.dataMap[this.active]
+    },
     tableData () {
-      return this.sourceMap[this.dataMap[this.active]] || []
+      return this.sourceMap[this.backDataType] || []
     },
     id () {
       return this.$route.params.id
     },
+    title () {
+      return this.$route.params.name
+    },
     totalStep () {
       return this.dataMap.length + 1
     },
+    showTempReject () {
+      if (
+        this.tempRejectMap[this.backDataType]
+        && this.tempRejectMap[this.backDataType].length > 1
+      ) {
+        return true
+      }
+      return false
+    },
     schema () {
-      switch (this.dataMap[this.active]) {
+      switch (this.backDataType) {
         case front2back['assets']:
           return {
             singlePage: true,
@@ -355,8 +389,24 @@ export default {
               { prop: 'createTime', label: '提交时间' },
               {
                 type: 'invoke',
-                width: 80,
-                render: [{ label: '查看', on: this.onView }]
+                width: 160,
+                render: [
+                  { label: '查看', on: this.onView },
+                  {
+                    label: '通过',
+                    render ({ status }) {
+                      return showOpt(status)
+                    },
+                    on: this.onPublish
+                  },
+                  {
+                    label: '驳回',
+                    render ({ status }) {
+                      return showOpt(status)
+                    },
+                    on: this.onReject
+                  }
+                ]
               }
             ]
           }
@@ -369,6 +419,18 @@ export default {
     this.getPublishWorkflowDetail()
   },
   methods: {
+    // 判断是否需要缓存驳回
+    calTempReject (item) {
+      if (!singleMap[item]) {
+        this.tempRejectMap[item] = {
+          text: `${data2label[item]}驳回`,
+          show:
+            !this.tempRejectMap.length
+            && this.sourceMap[item].filter(i => ![2, 3].includes(i.status))
+              .length
+        }
+      }
+    },
     async getPublishWorkflowDetail () {
       let res = await getPublishWorkflowDetail(this.id).catch(err => {
         console.log(err)
@@ -396,6 +458,15 @@ export default {
         if (this.sourceMap[item][0]) {
           this.sourceMap[item] = this.sourceMap[item].map(row => this.transform(row, item))
           temp.push(item)
+          // 处理缓存驳回初始状态
+          if (!singleMap[item]) {
+            this.tempRejectMap[item] = {
+              text: `${data2label[item]}驳回`,
+              length: this.sourceMap[item].filter(
+                i => ![2, 3].includes(i.status)
+              ).length
+            }
+          }
         }
       }
       this.dataMap = temp
@@ -418,7 +489,7 @@ export default {
       this.getPublishWorkflowDetail()
     },
     refreshStatus (item, status, review) {
-      const list = this.sourceMap[this.dataMap[this.active]]
+      const list = this.sourceMap[this.backDataType]
       const index = list.findIndex(i => i.id === item.id)
       list[index].status = status
       this.$refs.table.onPagination()
@@ -439,8 +510,8 @@ export default {
       if (this.active === this.totalStep - 1) {
         this.active = this.totalStep
       }
-      this.rejectInfo = []
-      this.$refs.table && this.$refs.table.onPagination()
+      this.tempRejectInfo = []
+      this.tableKey++
     },
     next () {
       if (this.active++ > 5) {
@@ -534,7 +605,7 @@ export default {
       return ''
     },
     onToggle (row) {
-      if (this.dataMap[this.active] !== 'publish') {
+      if (this.backDataType !== 'publish') {
         return
       }
       this.$refs.table.getInst().toggleRowExpansion(row)
@@ -570,7 +641,7 @@ export default {
     // 查看
     onView (row) {
       const { id } = row
-      switch (this.dataMap[this.active]) {
+      switch (this.backDataType) {
         case front2back['assets']:
           this.$refs.reviewDialog.show(
             this.tableData.findIndex(i => i.id === id)
@@ -586,6 +657,7 @@ export default {
           )
           break
         case front2back['schedule']:
+        case front2back['programRecur']:
           this.$refs.scheduleDialog.show(id)
           break
         case front2back['publish']:
@@ -599,8 +671,7 @@ export default {
       this.$refs.previewDialog.show(asset)
     },
     closePreviewDialog () {
-      debugger
-      if (this.dataMap[this.active] === front2back['assets']) {
+      if (this.backDataType === front2back['assets']) {
         this.$refs.reviewDialog.close()
       }
     },
@@ -611,12 +682,13 @@ export default {
       })
     },
     resolve (item) {
-      switch (this.dataMap[this.active]) {
+      switch (this.backDataType) {
         case front2back['assets']:
           return resolveAsset(item)
         case front2back['program']:
           return resolveProgram(item)
         case front2back['schedule']:
+        case front2back['programRecur']:
           return resolveSchedule(item)
         case front2back['publish']:
           return resolvePublish(item)
@@ -650,27 +722,41 @@ export default {
         })
         return
       }
-      // 缓存驳回数据
-      this.rejectInfo.push({
+      const rejectInfo = {
         id: this.$item.id,
         name: this.$item.name || this.$item.originalName,
         remark: reason
-      })
-      this.refreshStatus(this.$item, 3, {
-        type: this.review.type,
-        reason: this.review.reason
-      })
-      done()
+      }
+      if (this.showTempReject) {
+        this.$confirm(`驳回 ${rejectInfo.name} ?`, {
+          type: 'warning'
+        }).then(() => {
+          // 缓存驳回数据
+          done()
+          this.tempRejectInfo.push(rejectInfo)
+          this.refreshStatus(this.$item, 3, {
+            type: this.review.type,
+            reason: this.review.reason
+          })
+        })
+      } else {
+        // 取最新
+        done()
+        this.reject([rejectInfo], rejectInfo.name)
+      }
     },
     // 流程驳回
-    reject () {
+    reject (
+      rejectInfo = this.tempRejectInfo,
+      name = data2label[this.backDataType]
+    ) {
       return calendarPublishReject(
         this.id,
         {
-          type: data2type[this.dataMap[this.active]],
-          rejectInfo: this.rejectInfo
+          type: data2type[this.backDataType],
+          rejectInfo
         },
-        '审核流程'
+        name
       )
         .then(() => {
           this.$router.push({ name: 'review-list' })
@@ -717,6 +803,11 @@ export default {
     padding-left: 15px;
   }
 }
+.o-title {
+  font-size: 18px;
+  font-weight: bold;
+  color: #333333;
+}
 .fl-end {
   justify-content: flex-end;
 }