Преглед изворни кода

增加调班方式和对应的行校验

zhonghuizhen пре 1 година
родитељ
комит
3beb2d6273

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

@@ -22,6 +22,29 @@
             class="adjust-form"
             @submit.native.prevent
         >
+            <el-form-item label="调班方式">
+                <template slot="label">
+                    <span>调班方式</span>
+                    <el-tooltip content="调班方式为调班时目标人员、目标日期、目标班次必填。调班方式为排班变更时,目标人员、日期不可填写。" placement="top">
+                        <i class="el-icon-question"></i>
+                    </el-tooltip>
+                </template>
+
+                <el-select
+                    v-model="reScheduleValue"
+                    :disabled="readonly"
+                    filterable
+                    clearable
+                    :placeholder=" readonly ? '' : '请选择调班方式'"
+                >
+                    <el-option
+                        v-for="item in reScheduleOptions"
+                        :key="item.value"
+                        :label="item.label"
+                        :value="item.value"
+                    />
+                </el-select>
+            </el-form-item>
             <el-form-item label="选择排班" prop="scheduleId">
                 <el-select
                     v-model="formData.scheduleId"
@@ -150,7 +173,7 @@
                         <template slot-scope="scope">
                             <el-select
                                 v-model="scope.row.party"
-                                :disabled="readonly"
+                                :disabled="readonly || reScheduleValue==='paiban'"
                                 filterable
                                 :placeholder=" readonly ? '' : '请选择目标人员'"
                                 @change="handlePartyChange($event, scope.row, scope.$index, 'change')"
@@ -172,7 +195,7 @@
                         align="center"
                     >
                         <template slot="header">
-                            <span>调班日期</span>
+                            <span>目标日期</span>
                             <el-tooltip content="仅可选择当前排班范围内且目标人员有可选班次的日期" placement="top">
                                 <i class="el-icon-question"></i>
                             </el-tooltip>
@@ -180,7 +203,7 @@
                         <template slot-scope="scope">
                             <el-select
                                 v-model="scope.row.afterDate"
-                                :disabled="readonly"
+                                :disabled="readonly || reScheduleValue==='paiban'"
                                 :placeholder=" readonly ? '' : '请选择目标日期'"
                                 @change="handleDateChange($event, scope.$index, 'afterShiftList')"
                             >
@@ -214,6 +237,7 @@
                                 multiple
                                 filterable
                                 :placeholder=" readonly ? '' : '请选择目标班次'"
+                                @visible-change="(visible) => {getPaiBanBanci(visible,scope.$index)}"
                             >
                                 <el-option
                                     v-for="item in scope.row.afterShiftList"
@@ -280,6 +304,8 @@ export default {
             afterDateList: [], // 目标日期下拉数据
             blockList: [], // 被锁定数据
             scheduleOptions: [],
+            reScheduleOptions: [{ key: 'diaoban', value: 'diaoban', label: '调班' }, { key: 'paiban', value: 'paiban', label: '排班变更' }],
+            reScheduleValue: '',
             selectionIndex: [],
             toolbars: [
                 { key: 'save', icon: 'ibps-icon-save', label: '提交', type: 'success', visible: !this.readonly },
@@ -446,6 +472,30 @@ export default {
             //     }
             // }
         },
+        rowValidate (row, index) {
+            if (!row.beforeDate) {
+                this.$message.warning(`第${index}行` + '调班日期未选择!')
+                return true
+            }
+            if (row.beforeAdjust.length < 1) {
+                this.$message.warning(`第${index}行` + '调班班次未选择!')
+                return true
+            }
+            if (this.reScheduleValue === 'diaoban') { // 排班变更目标日期目标人员不用填
+                if (!row.afterDate) {
+                    this.$message.warning(`第${index}行` + '目标人员未选择!')
+                    return true
+                }
+                if (!row.party) {
+                    this.$message.warning(`第${index}行` + '目标日期未选择!')
+                    return true
+                }
+            }
+            if (row.afterAdjust.length < 1) {
+                this.$message.warning(`第${index}行` + '目标班次未选择!')
+                return true
+            }
+        },
         initDateOptions (startDateStr, obj) { // 初始化日期下拉数据
             const result = []
             const startDate = new Date(startDateStr)
@@ -640,6 +690,13 @@ export default {
                 this.handleDateChange(row.afterDate, index, 'afterShiftList')
             }
         },
+        getPaiBanBanci (visible, index) { // 排班变更方式,班次全部可选,目标人员和日期不可选
+            if (this.reScheduleValue === 'paiban' && visible === true) {
+                this.formData.adjustList[index]['afterShiftList'] = this.scheduleInfo.scheduleShift
+            } else {
+                return
+            }
+        },
         handleFormAction ({ key }) {
             switch (key) {
                 case 'save':
@@ -699,6 +756,15 @@ export default {
                 let statusVal = '已暂存'
                 if (key === 'tempSave') { // 暂存
                 } else { // 提交
+                    // 对最后一行进行行校验
+                    if (this.formData.adjustList.length < 1) { // 校验不通过则返回true
+                        this.$message.warning('调班表未填写数据!')
+                        return
+                    }
+                    if (this.rowValidate(this.formData.adjustList[this.formData.adjustList.length - 1], this.formData.adjustList.length)) {
+                        return
+                    }
+
                     statusVal = adjustList.some(i => this.$utils.isNotEmpty(i.party)) ? '待审核' : '待审批'
                 }
                 // return
@@ -746,6 +812,10 @@ export default {
             if (this.formData.adjustList.length > 0) {
                 this.addFilterList(this.formData.adjustList)
             }
+            // 对上一行进行行校验
+            if (this.formData.adjustList.length > 0 && this.rowValidate(this.formData.adjustList[this.formData.adjustList.length - 1], this.formData.adjustList.length)) { // 校验不通过则返回true
+                return
+            }
             this.formData.adjustList.push({
                 recordId: '',
                 beforeDate: '',

+ 6 - 6
src/views/business/​scheduleManage/edit.vue

@@ -365,6 +365,7 @@ import ActionUtils from '@/utils/action'
 import Json from '@/business/platform/serv/components/json.vue'
 import color from '@/store/modules/ibps/modules/color'
 import height from '@/mixins/height'
+import { reset } from '@/api/platform/auth/client'
 
 export default {
     name: 'schedule',
@@ -390,7 +391,6 @@ export default {
     },
     data () {
         const { userList = [], deptList = [] } = this.$store.getters || {}
-        const readonly = false
         return {
             userList,
             deptList,
@@ -412,7 +412,7 @@ export default {
             },
             rules: {},
             scheduleColumn,
-            title: readonly ? '创建排班' : '编辑排班',
+            title: this.readonly ? '创建排班' : '编辑排班',
             configList: [],
             configOptions: [],
             maxHeight: '250px',
@@ -421,12 +421,12 @@ 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: readonly },
+                { key: 'record', icon: 'el-icon-tickets', label: '修改记录', type: 'warning', steps: '2,3', show: (!this.readonly) },
                 { 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: readonly },
+                { 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' },
-                { key: 'save', icon: 'ibps-icon-save', label: '保存', type: 'primary', show: readonly },
-                { key: 'submit', icon: 'ibps-icon-send', label: '提交', type: 'success', steps: '3', show: readonly },
+                { key: 'save', icon: 'ibps-icon-save', label: '保存', type: 'primary', show: (!this.readonly) },
+                { key: 'submit', icon: 'ibps-icon-send', label: '提交', type: 'success', steps: '3', show: (!this.readonly) },
                 { key: 'cancel', icon: 'el-icon-close', label: '关闭', type: 'danger', show: true }
             ],
             viewType: 'users',

+ 12 - 10
src/views/business/​scheduleManage/preview.vue

@@ -4,7 +4,7 @@
             <div class="page-header">
                 <div class="toolbar">
                     <el-button
-                        v-for="btn in toolbars"
+                        v-if="btn.show && (!btn.steps || btn.steps.includes(activeStep)) "
                         :key="btn.key"
                         :type="btn.type"
                         size="mini"
@@ -87,15 +87,17 @@ export default {
             readonly,
             title: '排班',
             toolbars: [
-                { key: 'changeView', icon: 'el-icon-set-up', label: '切换视图', type: 'primary' },
-                { key: 'history', icon: 'el-icon-time', label: '排班历史', type: 'info' },
-                { key: 'record', icon: 'el-icon-tickets', label: '修改记录', type: 'warning' },
-                { key: 'export', icon: 'el-icon-download', label: '导出', type: 'primary', hidden: readonly },
-                { key: 'reset', icon: 'el-icon-refresh', label: '重置', type: 'warning', hidden: readonly },
-                { key: 'edit', icon: 'el-icon-edit', label: '编辑', type: 'primary', hidden: readonly },
-                { key: 'save', icon: 'ibps-icon-save', label: '保存', type: 'primary', hidden: readonly },
-                { key: 'submit', icon: 'ibps-icon-send', label: '提交', type: 'success', hidden: readonly },
-                { key: 'cancel', icon: 'el-icon-close', label: '关闭', type: 'danger' }
+                { key: 'prev', icon: 'el-icon-d-arrow-left', label: '上一步', type: 'primary', steps: '2,3', show: true },
+                { 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: !readonly },
+                { 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: !readonly },
+                // { key: 'edit', icon: 'el-icon-edit', label: '编辑', type: 'primary', steps: '2,3' },
+                { key: 'save', icon: 'ibps-icon-save', label: '保存', type: 'primary', show: !readonly },
+                { key: 'submit', icon: 'ibps-icon-send', label: '提交', type: 'success', steps: '3', show: !readonly },
+                { key: 'cancel', icon: 'el-icon-close', label: '关闭', type: 'danger', show: true }
             ],
             dateRange: ['2024-07-29', '2024-09-01'],
             viewType: 'users',