浏览代码

过期事务处理优化

cfort 3 年之前
父节点
当前提交
86d718ace7
共有 2 个文件被更改,包括 27 次插入 和 12 次删除
  1. 3 3
      src/store/modules/ibps/modules/user.js
  2. 24 9
      src/views/system/dashboard/components/workbench.vue

+ 3 - 3
src/store/modules/ibps/modules/user.js

@@ -57,7 +57,6 @@ export default {
                 await dispatch('getAccount')
                 // 获取切换用户账号
                 await dispatch('getSwitchAccount')
-                
 
                 // 获取注册用户账号
                 dispatch('getRegister').then((r) => {
@@ -184,8 +183,9 @@ export default {
          * 获取所有系统部门信息
          */
         getDeptList ({ state, dispatch }, { first, second }) {
-            const params = second ? ` and (path_ like '%${second}%' or id_ = '${first}')` : first ? ` and path_ like '%${first}%'` : ''
-            const sql = `select id_ as positionId, name_ as positionName, path_ as path, depth_ as depth, sn_ as sn from ibps_party_entity where party_type_ = 'position'${params} order by depth_ asc, sn_ asc`
+            const params = second ? ` and (pe.path_ like '%${second}%' or pe.id_ = '${first}')` : first ? ` and pe.path_ like '%${first}%'` : ''
+            // const sql = `select id_ as positionId, name_ as positionName, path_ as path, depth_ as depth, sn_ as sn from ibps_party_entity where party_type_ = 'position'${params} order by depth_ asc, sn_ asc`
+            const sql = `select pe.id_ as positionId, pe.name_ as positionName, pe.path_ as path, pe.depth_ as depth, pe.sn_ as sn, r.name_ as manager, r.id_ as managerId from ibps_party_entity as pe left join (select em.id_, em.positions_, em.name_ from ibps_party_employee as em left join ibps_party_user_role as ur on em.id_ = ur.user_id_ left join ibps_party_role as pr on pr.id_ = ur.role_id_ where role_alias_ in ('zhsfzr', 'syszr', 'zhglzzc')) as r on find_in_set(pe.id_, r.positions_) > 0 where pe.party_type_ = 'position'${params} order by pe.depth_ asc, pe.sn_ asc`
             common.request('sql', sql).then(res => {
                 const { data = [] } = res.variables || {}
                 dispatch('ibps/param/setDeptList', data, {

+ 24 - 9
src/views/system/dashboard/components/workbench.vue

@@ -368,7 +368,7 @@ export default {
         },
         getName ({ createBy, updateBy }) {
             const id = updateBy || createBy
-            const { name = '' } = this.$store.getters
+            const { name = '' } = this.$store.getters || {}
             if (this.activeTab === 'finish') {
                 const t = this.userList.find(i => i.userId === id)
                 return t ? t.userName : ''
@@ -397,6 +397,13 @@ export default {
             result.deptName = deptNames.join(',')
             return result[arg]
         },
+        getDept (v, arg = 'positionName') {
+            if (!v) {
+                return ''
+            }
+            const t = this.deptList.find(i => i.positionId === v)
+            return t ? t[arg] : ''
+        },
         tableRowClassName ({ row, rowIndex }) {
             if (rowIndex % 2 === 1) return 'warning-row'
             return 'success-row'
@@ -583,6 +590,7 @@ export default {
                 // 截取流程名
                 item.workName = item.subject.includes('#') ? item.subject.split('#')[0] : item.subject.split('(')[0]
                 item.workType = this.plan.includes(item.procDefKey) ? 'plan' : 'normal'
+                item.deptId = this.getAttr(item.subject, 'dept')
                 const limit = this.getAttr(item.subject, 'loseDate') || this.getAttr(item.subject, 'timeLimit')
                 const isExpire = this.judgeExpire(item.createTime, currentTime, item.workType, limit)
                 if (isExpire) {
@@ -602,7 +610,14 @@ export default {
                 this.dealUnexpile(result.all, noticeList)
             }
         },
-        // 判断是否过期、获取办理状态
+        /**
+         * 判断是否过期、获取办理状态
+         * @param {string} time 比较时间
+         * @param {number} current 当前时间戳
+         * @param {string} type 事务类型
+         * @param {string} limit 限时,值分为两种类型,传值为字符串格式的时间时,判定逻辑为当前时间小于该时间,传值为字符串类型数字时,判定逻辑为创建limit天后,大于当前时间
+         * @param {string} isState 调用类型
+         */
         judgeExpire (time, current, type, limit, isState) {
             const D = new Date(time)
             const a = new Date(time).getTime()
@@ -629,7 +644,7 @@ export default {
             }
             // 返回是否过期
             if (isDate) {
-                return b > new Date(l).getTime()
+                return b + (86400000 * 7) > new Date(l).getTime()
             }
             if (type === 'plan') {
                 return b + (86400000 * 7) > c
@@ -645,7 +660,7 @@ export default {
             const addList = []
             const sendList = []
             const msgContent = {
-                plan: '距离过期还剩七天,请及时处理!',
+                plan: '距离超时还剩七天,请及时处理!',
                 normal: '至今三天未处理,已超时,请及时处理!'
             }
             const msgTitle = {
@@ -653,6 +668,7 @@ export default {
                 normal: '事务超时提醒'
             }
             const nowTime = new Date(new Date().getTime() + 28800000).toJSON().slice(0, 16).replace('T', ' ')
+            // console.log(data)
             data.forEach(item => {
                 const isExist = !!noticeList.find(i => i.taskId === item.taskId)
                 // 筛选出不存在于主管提醒表的过期数据
@@ -675,11 +691,10 @@ export default {
                         chu_li_ren_ming_: item.ownerName,
                         chu_li_ren_id_: this.getInfoByName(item.ownerName, 'id'),
                         chu_li_ren_dian_h: this.getInfoByName(item.ownerName, 'phone'),
-                        bu_men_: this.orgInfo.orgName,
-                        bu_men_id_: this.orgInfo.groupID,
-                        // 主管ID与当前用户id相等时将主管ID设置为主任【】的ID,主管电话设为空
-                        zhu_guan_id_: this.orgInfo.id === userId ? '990927120278487040' : this.orgInfo.id,
-                        zhu_guan_dian_hua: this.orgInfo.id === userId ? '' : this.orgInfo.mobile,
+                        bu_men_: this.getDept(item.deptId),
+                        bu_men_id_: item.deptId,
+                        zhu_guan_id_: this.getDept(item.deptId, 'managerId'),
+                        zhu_guan_dian_hua: this.getInfoByName(this.getDept(item.deptId, 'manager'), 'phone'),
                         bian_zhi_shi_jian: item.createTime,
                         ti_xing_ci_shu_: 1,
                         duan_xin_ci_shu_: 0,