Parcourir la source

排班修改历史记录调整

zhonghuizhen il y a 1 an
Parent
commit
2ba6c2884a

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

@@ -50,7 +50,7 @@ export default {
         return {
             userOption,
             stateType,
-            title: '调班记录',
+            title: '调班申请记录',
             pkKey: 'id', // 主键  如果主键不是pk需要传主键
             loading: true,
             height: document.clientHeight,
@@ -64,7 +64,7 @@ export default {
                 toolbars: [
                     { key: 'search', icon: 'ibps-icon-search', label: '查询', type: 'primary', hidden: false },
                     { key: 'create', icon: 'ibps-icon-plus', label: '申请', type: 'success', hidden: false },
-                    { key: 'remove', icon: 'ibps-icon-close', label: '删除', type: 'danger', hidden: false }
+                    { key: 'remove', icon: 'ibps-icon-close', label: '删除', type: 'danger', hidden: !this.isRoleFilter() }
                 ],
                 searchForm: {
                     labelWidth: 80,
@@ -124,7 +124,7 @@ export default {
                     isHighRole = true
                 }
             })
-            return this.$store.getters.isSuper || isHighRole
+            return (this.$store.getters.isSuper || isHighRole)
         },
         /**
          * 获取格式化参数

+ 1 - 1
src/views/business/​scheduleManage/adjustVerify.vue

@@ -132,7 +132,7 @@ export default {
                     isHighRole = true
                 }
             })
-            return this.$store.getters.isSuper || isHighRole
+            return (this.$store.getters.isSuper || isHighRole)
         },
         /**
          * 获取格式化参数

+ 24 - 19
src/views/business/​scheduleManage/components/record.vue

@@ -16,14 +16,14 @@
             <el-timeline-item
                 v-for="(item, index) in timelineDate"
                 :key="index"
-                :timestamp="item.createTime"
+                :timestamp="item.updateTime"
                 placement="top"
             >
                 <el-card class="card">
                     <div class="applicant">申请人:{{ item.creator }}</div>
                     <div class="reason">原因:{{ item.reason }}</div>
                     <div class="detail">详情:{{ item.overview }}</div>
-                    <div class="approve">通过时间:{{ item.executeDate }}</div>
+                    <div class="approve">通过时间:{{ item.updateTime }}</div>
                 </el-card>
             </el-timeline-item>
         </el-timeline>
@@ -65,7 +65,8 @@ export default {
             if (!this.scheduleId) {
                 return
             }
-            const sql = `select a.id_ as dataId, a.parent_id_ as parentId, a.record_id_ as recordId, a.before_adjust_ as beforeAdjust, a.before_date_ as beforeDate, a.after_adjust_ as afterAdjust, a.after_date_ as afterDate, a.party_ as party, b.create_by_ as createBy, date_format(b.create_time_,'%Y-%m-%d %H:%i') AS createTime, b.di_dian_ as location, b.reason_ as reason, b.executor_ as executor, b.execute_date_ as executeDate, b.overview_ as overview, b.schedule_id_ as scheduleId from t_adjustment_detail a left join t_adjustment b on a.parent_id_ = b.id_ and b.schedule_id_ = '${this.scheduleId}'`
+            // const sql = `select a.id_ as dataId, a.parent_id_ as parentId, a.record_id_ as recordId, a.before_adjust_ as beforeAdjust, a.before_date_ as beforeDate, a.after_adjust_ as afterAdjust, a.after_date_ as afterDate, a.party_ as party, b.create_by_ as createBy, date_format(b.create_time_,'%Y-%m-%d %H:%i') AS createTime, b.di_dian_ as location, b.reason_ as reason, b.executor_ as executor, b.execute_date_ as executeDate, b.overview_ as overview, b.schedule_id_ as scheduleId from t_adjustment_detail a left join t_adjustment b on a.parent_id_ = b.id_ and b.schedule_id_ = '${this.scheduleId}'`
+            const sql = 'select * from t_adjustment where status in ( "已通过") and schedule_id_ = ' + this.scheduleId
             this.$common.request('sql', sql).then(res => {
                 const { data = [] } = res.variables || {}
                 if (!data.length) {
@@ -76,30 +77,34 @@ export default {
             })
         },
         formatData (data) {
-            const groupedData = {}
+            const groupedData = []
             data.forEach(item => {
-                const parentId = item.parentId
-                if (!groupedData[parentId]) {
-                    groupedData[parentId] = {
-                        parentId,
-                        createTime: item.createTime,
-                        createBy: item.createBy,
-                        creator: this.transformData(this.userList, item.createBy, 'userId', 'userName'),
-                        reason: item.reason,
-                        overview: item.overview,
-                        executor: item.executor,
-                        executeDate: item.executeDate,
-                        items: []
-                    }
+                const tempObj = {
+                    updateTime: this.formatTime(item.update_time_),
+                    createBy: item.create_by_,
+                    creator: this.transformData(this.userList, item.create_by_, 'userId', 'userName'),
+                    reason: item.reason_,
+                    overview: item.overview_,
+                    items: []
                 }
-                groupedData[parentId].items.push(item)
+                groupedData.push(tempObj)
             })
-            return Object.values(groupedData)
+            return groupedData
         },
         handleClose () {
             console.log(123123)
             this.$emit('close', false)
         },
+        formatTime (timestamp) {
+            const dateObj = new Date(timestamp)
+            const year = dateObj.getFullYear()
+            const month = (dateObj.getMonth() + 1).toString().padStart(2, '0')
+            const day = dateObj.getDate().toString().padStart(2, '0')
+            const hours = dateObj.getHours().toString().padStart(2, '0')
+            const minutes = dateObj.getMinutes().toString().padStart(2, '0')
+            const seconds = dateObj.getSeconds().toString().padStart(2, '0')
+            return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
+        },
         transformData (dataset, data, from, to) {
             if (!data) {
                 return ''

+ 60 - 2
src/views/business/​scheduleManage/edit.vue

@@ -355,7 +355,7 @@
 
 <script>
 import { cycleOptions, scheduleType, scheduleColumn } from '../../constants/schedule'
-import { queryScheduleConfig, getStaffSchedule, saveStaffSchedule } from '@/api/business/schedule'
+import { queryScheduleConfig, getStaffSchedule, saveStaffSchedule, saveAdjustment } from '@/api/business/schedule'
 import request from '@/utils/request'
 import { SYSTEM_URL } from '@/api/baseUrl'
 import { previewFile } from '@/api/platform/file/attachment'
@@ -421,7 +421,7 @@ export default {
                 { key: 'next', icon: 'el-icon-d-arrow-right', label: '下一步', type: 'primary', steps: '1,2', show: true },
                 { key: 'changeView', icon: 'el-icon-set-up', label: '切换视图', type: 'primary', steps: '2', show: true },
                 // { key: 'history', icon: 'el-icon-time', label: '排班历史', type: 'info', steps: '2,3' },
-                { key: 'record', icon: 'el-icon-tickets', label: '修改记录', type: 'warning', steps: '2,3', show: (!this.readonly) },
+                { key: 'record', icon: 'el-icon-tickets', label: '修改记录', type: 'warning', steps: '2,3', show: true },
                 { key: 'export', icon: 'el-icon-download', label: '导出', type: 'primary', steps: '2,3', show: true },
                 { key: 'reset', icon: 'el-icon-refresh', label: '重置', type: 'warning', steps: '2', show: (!this.readonly) },
                 // { key: 'edit', icon: 'el-icon-edit', label: '编辑', type: 'primary', steps: '2,3' },
@@ -595,6 +595,7 @@ export default {
                 }))
                 console.log('formData', this.formData)
                 this.scheduleData = this.transformScheduleData(records, overview, temp)
+                this.responseData = { ...this.responseData, records, overview, temp }
                 console.log('scheduleData', this.scheduleData)
                 this.loading = false
                 this.userNameList = this.ordinateList.map(item => ({ // 存起user对应id和name
@@ -995,6 +996,8 @@ export default {
                     this.closeDialog()
                     this.$emit('callback')
                 }
+                // 增加一条调班申请记录,用于查看排班管理员修改历史。
+                this.submitAdjust(submitData)
             }).catch(() => {
                 this.loading = false
             })
@@ -1191,6 +1194,61 @@ export default {
             }
             this.resetShiftSetting()
         },
+        /** 获取排班变化描述 */
+        getOverViews (responseData, newData) {
+            const oldData = responseData.staffScheduleDetailPoList
+            const result = []
+            // 遍历newData
+            newData.forEach((newItem, i) => {
+                // 比较每个人班次的数量变化
+                if (newItem.statistics !== oldData[i].statistics) {
+                    const newStatistics = JSON.parse(newItem.statistics) || []
+                    const oldStatistics = JSON.parse(oldData[i].statistics) || []
+                    const changes = []
+                    // 比较每个人班次的数量变化
+                    for (const shift in newStatistics) {
+                        const newCount = newStatistics[shift] || 0
+                        const oldCount = oldStatistics[shift] || 0
+                        const shiftName = this.formData.scheduleShift.find(item => item.alias === shift)?.name
+                        if (newCount > oldCount) {
+                            changes.push(`${shiftName}增加了` + (newCount - oldCount) + '班次')
+                        } else if (newCount < oldCount) {
+                            changes.push(`${shiftName}减少了` + (oldCount - newCount) + '班次')
+                        }
+                    }
+                    // oldStatistics中有的项而newStatistics中没有的项
+                    for (const oldShift in oldStatistics) {
+                        if (!newStatistics.hasOwnProperty(oldShift)) {
+                            const shiftName = this.formData.scheduleShift.find(item => item.alias === oldShift)?.name
+                            const oldCount = oldStatistics[oldShift] || 0
+                            changes.push(`${shiftName}减少了` + oldCount + '班次')
+                        }
+                    }
+                    // 如果有班次变化,将其与userId记录到结果中
+                    if (changes.length > 0) {
+                        const userNameObj = this.userNameList.filter(item => item.userId === newItem.userId)
+                        const perOverView = userNameObj[0]?.userName + changes.join(',')
+                        result.push(perOverView)
+                    }
+                }
+            })
+            return '排班管理员调整如下:' + result.join('。')
+        },
+        // 提交调班申请数据
+        submitAdjust (submitData) {
+            const overView = this.getOverViews(this.responseData, submitData.staffScheduleDetailPoList)
+            const { first, second } = this.$store.getters.level || {}
+            const adjustData = {
+                scheduleId: submitData.id,
+                reason: '排班管理员调整排班',
+                diDian: second || first,
+                overview: overView,
+                status: '已通过',
+                updateTime: Date.now(),
+                adjustmentDetailPoList: []
+            }
+            saveAdjustment(adjustData)
+        },
         closeDialog () {
             this.$emit('close', false)
         }

+ 1 - 1
src/views/business/​scheduleManage/list.vue

@@ -27,7 +27,7 @@
             :page-params="params"
             :readonly="readonly"
             @refresh="loadData"
-            @close="() => showScheduleEdit = false"
+            @close="() => {showScheduleEdit = false;this.search()}"
         />
         <schedule-config-list
             v-if="showConfigList"