Explorar el Código

高权限角色过滤、加入已取消状态、状态变更发送消息

zhonghuizhen hace 1 año
padre
commit
aa8a6540b6

+ 35 - 1
src/api/business/schedule.js

@@ -1,6 +1,6 @@
 import request from '@/utils/request'
 import { BUSINESS_BASE_URL } from '@/api/baseUrl'
-
+import { save } from '@/api/platform/message/innerMessage'
 /**
  * 获取排班配置
  * @param {*} params
@@ -216,3 +216,37 @@ export function saveAdjustmentDetail (params) {
         params
     })
 }
+
+/**
+ * 发送申请单状态改变提醒
+ * @param {data, receiverId} 申请单数据、消息接收人
+ */
+export function sendMessage (data, receiverId) {
+    let content = ''
+    switch (data.status) {
+        case '待审核':
+            content = '调班申请单[' + data.overview + ']' + ' 待您审核'
+            break
+        case '待审批':
+            content = '调班申请单[' + data.overview + ']' + ' 待您审批'
+            break
+        case '已拒绝':
+            content = '调班申请单[' + data.overview + ']' + ' 已被拒绝'
+            break
+        case '已通过':
+            content = '调班申请单[' + data.overview + ']' + ' 已通过'
+            break
+        default:
+            // 如果data.status的值不在上述列举的情况中,可以在这里添加默认处理逻辑
+            content = '调班申请单[' + data.overview + ']'
+            break
+    }
+    const params = {
+        subject: '调班申请单变更提醒',
+        content: content,
+        receiverId: receiverId,
+        canreplay: '0'
+    }
+    return save(params)
+}
+

+ 16 - 3
src/views/business/​scheduleManage/adjust.vue

@@ -33,7 +33,7 @@
 </template>
 
 <script>
-import { queryAdjustment, removeAdjustment } from '@/api/business/schedule'
+import { queryAdjustment, removeAdjustment, saveAdjustment } from '@/api/business/schedule'
 import { stateType } from '@/views/constants/schedule'
 import ActionUtils from '@/utils/action'
 import FixHeight from '@/mixins/height'
@@ -88,7 +88,8 @@ export default {
                     effect: 'default',
                     // effect: 'display',
                     actions: [
-                        { key: 'edit', label: '编辑', type: 'primary', icon: 'ibps-icon-edit', hidden: function (row) { return row.status !== '已暂存' } },
+                        { key: 'edit', label: '编辑', type: 'primary', icon: 'ibps-icon-edit', hidden: function (row) { return row.status !== '已暂存' && row.status !== '已取消' } },
+                        { key: 'cancel', label: '取消', type: 'danger', icon: 'ibps-icon-cancel', hidden: function (row) { return row.status !== '待审核' } },
                         { key: 'detail', label: '详情', type: 'primary', icon: 'ibps-icon-list-alt' }
                     ]
                 }
@@ -128,7 +129,6 @@ export default {
          * 获取格式化参数
          */
         getSearchFormData () {
-            debugger
             const paramjson = this.$refs['crud'] ? this.$refs['crud'].getSearcFormData() : {}
             if (this.isRoleFilter()) { // 超级管理员和高权限角色不做申请人过滤
             } else {
@@ -179,6 +179,9 @@ export default {
                 case 'edit':
                     this.handleEdit(command, data)
                     break
+                case 'cancel':
+                    this.handleCancel(data)
+                    break
                 case 'detail':
                     this.handleEdit(command, data)
                     break
@@ -202,6 +205,16 @@ export default {
             this.readonly = key === 'detail'
             this.showAdjustEdit = true
         },
+        /**
+         * 处理取消
+         */
+        async handleCancel (data) {
+            data.status = '已取消'
+            saveAdjustment(data).then(() => {
+                ActionUtils.successMessage()
+                this.search()
+            }).catch((e) => { console.error(e) })
+        },
         /**
          * 处理删除
          */

+ 108 - 13
src/views/business/​scheduleManage/adjustVerify.vue

@@ -31,11 +31,11 @@
 </template>
 
 <script>
-import { queryAdjustment, removeAdjustment, saveAdjustment, getAdjustmentDetail, saveAdjustmentDetail } from '@/api/business/schedule'
+import { queryAdjustment, removeAdjustment, saveAdjustment, sendMessage, getAdjustmentDetail, saveAdjustmentDetail } from '@/api/business/schedule'
 import { stateType } from '@/views/constants/schedule'
 import ActionUtils from '@/utils/action'
 import FixHeight from '@/mixins/height'
-import { status } from '@/api/platform/job/scheduler';
+import { status } from '@/api/platform/job/scheduler'
 
 export default {
     components: {
@@ -75,7 +75,7 @@ export default {
                     itemWidth: 180,
                     forms: [
                         { prop: 'Q^reason_^SL', label: '调班原因' },
-                        { prop: 'Q^status^S', label: '状态', fieldType: 'select', options: stateType.filter(item => item.value !== '已暂存') },
+                        { prop: 'Q^status^S', label: '状态', fieldType: 'select', options: stateType.filter(item => item.value !== '已暂存' && item.value !== '已取消') },
                         { prop: ['Q^create_time_^DL', 'Q^create_time_^DG'], label: '申请时间', fieldType: 'daterange', itemWidth: 200 }
                     ]
                 },
@@ -138,8 +138,43 @@ export default {
          * 获取格式化参数
          */
         getSearchFormData () {
-            let paramjson = this.$refs['crud'] ? this.$refs['crud'].getSearcFormData() : {}
-            paramjson['Q^status^NE'] = '已暂存'
+            const parameters = [{
+                relation: 'AND',
+                parameters: [
+                    {
+                        'key': 'Q^status^NE',
+                        'value': '已取消',
+                        'param': 'status'
+                    },
+                    {
+                        'key': 'Q^status^NE',
+                        'value': '已暂存',
+                        'param': 'status1'
+                    }
+                ]
+            }]
+            // 加入搜索栏参数
+            const searchParam = this.$refs['crud'] ? this.$refs['crud'].getSearcFormData() : {}
+            if (Object.keys(searchParam).length) { // 查询条件不为空,则加入parameters
+                const statusArr = Object.keys(searchParam).filter(key => key.includes('status'))
+                const notstatusArr = Object.keys(searchParam).filter(key => key.includes('status') === false)
+                if (statusArr.length > 0) { // 加入状态查询
+                    parameters[0].parameters.push({
+                        'key': statusArr[0],
+                        'value': searchParam[statusArr[0]],
+                        'param': 'status2'
+                    })
+                }
+                if (notstatusArr.length > 0) { // 加入其他查询
+                    notstatusArr.forEach((el) => {
+                        parameters[0].parameters.push({
+                            'key': el,
+                            'value': searchParam[el]
+                        })
+                    })
+                }
+            }
+
             if (this.isRoleFilter()) { // 超级管理员和高权限角色不做审批人过滤
             } else {
                 /* 审批人过滤
@@ -149,12 +184,11 @@ export default {
                 }
                 */
             }
-            return ActionUtils.formatParams(
-                // this.$refs['crud'] ? this.$refs['crud'].getSearcFormData() : {},
-                paramjson,
-                this.pagination,
-                this.sorts
-            )
+            const param = {
+                parameters: parameters,
+                ...ActionUtils.formatParams(null, this.pagination, this.sorts)
+            }
+            return param
         },
         /**
          * 处理分页事件
@@ -228,14 +262,72 @@ export default {
             this.readonly = key === 'detail'
             this.showAdjustEdit = true
         },
+        /**
+         * 状态变更发送系统消息
+         */
+        sendMsg (data) {
+            switch (data.status) {
+                case '待审批':
+                    sendMessage(data, data.executor || '')
+                    break
+                case '已拒绝':
+                { // 已拒绝时视情况发送给审核人申请人(审核时拒绝消息对象需排除自己)
+                    const parties = data.adjustmentDetailPoList.map(obj => obj.party)
+                    if (parties.length > 0) { // 发给审核人
+                        const { userId = '' } = this.$store.getters
+                        const filteredParties = parties.filter(party => party !== userId)
+                        filteredParties.forEach((el) => {
+                            sendMessage(data, el)
+                        })
+                    }
+                    sendMessage(data, data.createBy) // 发给申请人
+                    break
+                }
+                case '已通过':
+                { // 已通过时发送给申请人审核人
+                    const parties = data.adjustmentDetailPoList.map(obj => obj.party)
+                    if (parties.length > 0) { // 发给审核人
+                        parties.forEach((el) => {
+                            sendMessage(data, el)
+                        })
+                    }
+                    sendMessage(data, data.createBy) // 发给申请人
+                    break
+                }
+                default:
+                    // 如果data.status的值不在上述列举的情况中,可以在这里添加默认处理逻辑
+                    break
+            }
+        },
+        /**
+         * 判断是否由审核进入审批状态
+         */
+        isNextStep (data) {
+            if (data.status === '待审核') {
+                if (data.adjustmentDetailPoList.length > 0) { // 审核人数是否>0
+                    data.adjustmentDetailPoList.forEach((el) => {
+                        if (el.party) { // 判断多个审核人状态
+                            return '审核中'
+                        } else {
+                            return '待审批'
+                        }
+                    })
+                } else {
+                    return '待审批'
+                }
+            }
+            // '待审批' 状态则直接通过
+            return '已通过'
+        },
         /**
          * 处理单条同意/不同意
          */
         async handleAgree (key, data) {
             // console.log(data)
-            data.status = (key === 'agree' ? (data.status === '待审核' ? '待审批' : '已通过') : '已拒绝')
+            data.status = (key === 'agree' ? this.isNextStep(data) : '已拒绝')
             saveAdjustment(data).then(() => {
                 ActionUtils.successMessage()
+                this.sendMsg(data) // 发送系统通知
                 this.search()
             }).catch((e) => { console.error(e) })
         },
@@ -256,7 +348,7 @@ export default {
                         id_: el.id
                     },
                     param: {
-                        status: key === 'massAgree' ? (el.status === '待审核' ? '待审批' : '已通过') : '已拒绝'
+                        status: key === 'massAgree' ? this.isNextStep(el) : '已拒绝'
                     }
                 })
             })
@@ -266,6 +358,9 @@ export default {
             }
             this.$common.request('update', updateParams).then(() => {
                 ActionUtils.successMessage()
+                data.forEach((el) => { // 给每个申请单发通知
+                    this.sendMsg(el)
+                })
                 this.search()
             }).catch((e) => { console.error(e) })
         },

+ 11 - 1
src/views/business/​scheduleManage/components/adjust-edit.vue

@@ -199,7 +199,7 @@
 
 <script>
 // import {  } from '@/views/constants/schedule'
-import { getAdjustment, saveAdjustment, queryStaffSchedule, getStaffSchedule } from '@/api/business/schedule'
+import { getAdjustment, saveAdjustment, queryStaffSchedule, getStaffSchedule, sendMessage } from '@/api/business/schedule'
 
 export default {
     props: {
@@ -498,6 +498,16 @@ export default {
                 }
                 console.log('this.params.id', this.params.id)
                 this.submitForm(submitData)
+                // sendMessage(submitData, '1169304256906264576')
+                // 提交后通知审核人、审批人
+                if (statusVal === '待审核') {
+                    const partyArray = adjustList.map(obj => obj.party)
+                    partyArray.forEach(el => {
+                        sendMessage(submitData, el)
+                    })
+                } else if (statusVal === '待审批') {
+                    sendMessage(submitData, submitData.executor || '')
+                }
             })
         },
         // 提交数据

+ 5 - 0
src/views/constants/schedule.js

@@ -173,6 +173,11 @@ export const stateType = [
         value: '待审核',
         type: 'primary'
     },
+    {
+        label: '审核中',
+        value: '审核中',
+        type: 'info'
+    },
     {
         label: '待审批',
         value: '待审批',