Browse Source

2024-05-22 节假日设置的bug修复;工作日历的bug修复

master_hella_20240701
zhousq 6 months ago
parent
commit
fec9ff3a25
  1. 20
      src/views/mes/holiday/holiday.data.ts
  2. 48
      src/views/mes/workcalendar/index.vue

20
src/views/mes/holiday/holiday.data.ts

@ -1,8 +1,17 @@
import type { CrudSchema } from '@/hooks/web/useCrudSchemas' import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { dateFormatter } from '@/utils/formatTime' import { dateFormatter, dateFormatter2 } from '@/utils/formatTime'
// 表单校验 // 表单校验
export const HolidayRules = reactive({ export const HolidayRules = reactive({
holidayName: [
{ required: true, message: '请输入节日名称', trigger: 'blur' }
],
holidayType: [
{ required: true, message: '请输入节日类型', trigger: 'blur' }
],
holidayDate: [
{ required: true, message: '请输入节日日期', trigger: 'blur' }
],
}) })
export const Holiday = useCrudSchemas(reactive<CrudSchema[]>([ export const Holiday = useCrudSchemas(reactive<CrudSchema[]>([
@ -10,7 +19,9 @@ export const Holiday = useCrudSchemas(reactive<CrudSchema[]>([
label: '主键', label: '主键',
field: 'id', field: 'id',
sort: 'custom', sort: 'custom',
isForm: false, isSearch: false,
isTable:false,
isForm:false
}, },
@ -56,13 +67,13 @@ export const Holiday = useCrudSchemas(reactive<CrudSchema[]>([
label: '节日日期', label: '节日日期',
field: 'holidayDate', field: 'holidayDate',
sort: 'custom', sort: 'custom',
formatter: dateFormatter, formatter: dateFormatter2,
isSearch: true, isSearch: true,
search: { search: {
component: 'DatePicker', component: 'DatePicker',
componentProps: { componentProps: {
type: 'date', type: 'date',
valueFormat: 'YYYY-MM-DD', valueFormat: 'YYYY-MM-DD 00:00:00',
} }
}, },
form: { form: {
@ -72,6 +83,7 @@ export const Holiday = useCrudSchemas(reactive<CrudSchema[]>([
valueFormat: 'x' valueFormat: 'x'
} }
}, },
}, },
{ {
label: '状态', label: '状态',

48
src/views/mes/workcalendar/index.vue

@ -59,7 +59,7 @@
</el-aside> </el-aside>
<el-main> <el-main>
<div class="calender-class"> <div class="calender-class">
<el-calendar ref="calendarMain"> <el-calendar ref="calendarMain" :key="calendarCount">
<template #header="{ date }"> <template #header="{ date }">
<span>排班日历</span> <span>排班日历</span>
<span>{{ date }}</span> <span>{{ date }}</span>
@ -151,7 +151,7 @@
<el-drawer :title="batchTitle" v-model="batchAddDrawer" size="40%"> <el-drawer :title="batchTitle" v-model="batchAddDrawer" size="40%">
<div class="demo-drawer_content"> <div class="demo-drawer_content">
<el-form v-model="batchAddForm"> <el-form v-model="batchAddForm">
<el-form-item label="排班日期:" label-width="120px"> <el-form-item label="排班日期:" >
<el-date-picker <el-date-picker
v-model="batchAddForm.batchDate" v-model="batchAddForm.batchDate"
value-format="YYYY-MM-DD" value-format="YYYY-MM-DD"
@ -162,7 +162,7 @@
> >
</el-date-picker> </el-date-picker>
</el-form-item> </el-form-item>
<el-form-item label="规则类型:" label-width="120px"> <el-form-item label="规则类型:" >
<!-- <el-button type="primary" @click="addDomain" link> <Icon icon="ep:plus" /> </el-button> --> <!-- <el-button type="primary" @click="addDomain" link> <Icon icon="ep:plus" /> </el-button> -->
<el-radio-group v-model="ruleType" @change="handleRuleType"> <el-radio-group v-model="ruleType" @change="handleRuleType">
<el-radio label="一班倒">一班倒</el-radio> <el-radio label="一班倒">一班倒</el-radio>
@ -170,7 +170,7 @@
<el-radio label="三班倒">三班倒</el-radio> <el-radio label="三班倒">三班倒</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="排除非法定休息日:" label-width="120px"> <el-form-item label="排除非法定休息日:">
<el-switch v-model="batchAddForm.excludeRestDay" /> <el-switch v-model="batchAddForm.excludeRestDay" />
</el-form-item> </el-form-item>
@ -329,7 +329,7 @@ interface Team {
name: string name: string
class: string class: string
} }
const calendarCount=ref(0)
const currentRow = ref() // const currentRow = ref() //
const handleTableCurrentChange = (val: Team) => { const handleTableCurrentChange = (val: Team) => {
currentRow.value = val currentRow.value = val
@ -414,6 +414,12 @@ watch(
} }
} }
) )
// watch(
// () => viewDate.value,
// (newVal) => {
// console.log('🚀 ~ file: workcalendar:420 ~ watch ~ viewDate:', newVal)
// }
// )
onMounted( onMounted(
async function () { async function () {
let res=await workCalendarApi.getHolidays(dayjs(currentDate.value).year()) let res=await workCalendarApi.getHolidays(dayjs(currentDate.value).year())
@ -573,9 +579,15 @@ const addWork = () => {
saveList.push(info) saveList.push(info)
}) })
//console.log('🚀 ~ file: App.vue:571 ~ addWork ~ saveList:', saveList)
savePlan(saveList) savePlan(saveList,currentRow.value.code, hanleDay.value.day.slice(0, 8) + '01', dayjs(hanleDay.value.day).endOf('month').format('YYYY-MM-DD'))
getViewData(currentRow.value.code, hanleDay.value.day, hanleDay.value.day)
//nextTick(() => {
//getViewData(currentRow.value.code, hanleDay.value.day.slice(0, 8) + '01', dayjs(hanleDay.value.day).endOf('month').format('YYYY-MM-DD'))
///})
//getViewData(currentRow.value.code, hanleDay.value.day, hanleDay.value.day)
//console.log('🚀 ~ file: App.vue:571 ~ addWork ~ saveList:', dayjs(hanleDay.value.day).endOf('month').format('YYYY-MM-DD'))
drawer.value = false drawer.value = false
} }
@ -650,8 +662,8 @@ const batchAddWork = () => {
} }
}) })
savePlan(saveList) savePlan(saveList,currentRow.value.code, dateList[0], dateList[1])
getViewData(currentRow.value.code, dateList[0], dateList[1]) //getViewData(currentRow.value.code, dateList[0], dateList[1])
batchAddDrawer.value = false batchAddDrawer.value = false
batchAddForm.value = { batchAddForm.value = {
batchDate: [], batchDate: [],
@ -665,8 +677,11 @@ const handleAddClose = () => {
drawer.value = false drawer.value = false
} }
const savePlan = async (workList) => { const savePlan = async (workList, code,startTime,endTime) => {
await workCalendarApi.createBatch(workList) await workCalendarApi.createBatch(workList)
nextTick(() => {
getViewData( code,startTime,endTime)
})
//await workCalendarApi.createObj(workList); //await workCalendarApi.createObj(workList);
} }
const getViewData = async (teamCode: any, startDate: any, endDate: any) => { const getViewData = async (teamCode: any, startDate: any, endDate: any) => {
@ -676,8 +691,12 @@ const getViewData = async (teamCode: any, startDate: any, endDate: any) => {
endTime: endDate endTime: endDate
} }
let res = await workCalendarApi.getWorkPlan(params) let res = await workCalendarApi.getWorkPlan(params)
//if(res) //onsole.log('🚀 ~ file: App.vue:689 ~ getViewData ~ getViewData:',res)
viewDate.value = res viewDate.value = res
calendarCount.value++
// })
//if(res)
//workInfoList.value =viewDate.value //workInfoList.value =viewDate.value
//console.log('🚀 ~ file: App.vue:672 ~ getViewData ~ getViewData:', viewDate.value) //console.log('🚀 ~ file: App.vue:672 ~ getViewData ~ getViewData:', viewDate.value)
} }
@ -726,7 +745,7 @@ const getTeamList = async () => {
// //
const handleDelete=(row:any)=>{ const handleDelete=(row:any)=>{
message.delConfirm('确认要删除['+row.name+']班组当月排班数据吗?', 'Warning').then(() => { message.delConfirm('确认要删除['+row.name+']班组当月排班数据吗?', '警告').then(() => {
//console.log('🚀 ~ file: App.vue:720 ~ handleDelete ~ :', dayjs(currentDate.value).endOf('month').format('YYYY-MM-DD')) //console.log('🚀 ~ file: App.vue:720 ~ handleDelete ~ :', dayjs(currentDate.value).endOf('month').format('YYYY-MM-DD'))
deleteWorkPlan(row.code,currentDate.value.slice(0, 8) + '01', dayjs(currentDate.value).endOf('month').format('YYYY-MM-DD')) deleteWorkPlan(row.code,currentDate.value.slice(0, 8) + '01', dayjs(currentDate.value).endOf('month').format('YYYY-MM-DD'))
@ -742,10 +761,11 @@ const deleteWorkPlan=async (code:any,startTime:any,endTime:any)=>{
startTime:startTime, startTime:startTime,
endTime: endTime endTime: endTime
} }
console.log('🚀 ~ file: App.vue:720 ~ deleteWorkPlan ~ :', data) //console.log('🚀 ~ file: App.vue:720 ~ deleteWorkPlan ~ :', data)
workCalendarApi.deleteWorkPlan(data) workCalendarApi.deleteWorkPlan(data)
getViewData(code, startTime,endTime) getViewData(code, startTime,endTime)
} }
</script> </script>
<style> <style>

Loading…
Cancel
Save