fix:排版日历切换后第一时间没有刷新,需要切换月份后才刷新问题解决。

This commit is contained in:
zhangxuanming 2024-12-26 14:12:59 +08:00
parent c7357a12d4
commit 1050affe7c

View File

@ -2,12 +2,12 @@
<div class="app-container"> <div class="app-container">
<el-container> <el-container>
<el-aside width="150px"> <el-aside width="150px">
<el-radio-group v-model="selectedType" class="x-fillitem el-group-list" @change="onSelected"> <el-radio-group v-model="selectedType" class="x-fillitem el-group-list" @change="onSelected">
<el-radio-button <el-radio-button
v-for="dict in dict.type.mes_calendar_type" v-for="dict in dict.type.mes_calendar_type"
:key="dict.value" :key="dict.value"
:label="dict.value" :label="dict.value"
>{{dict.label}}</el-radio-button> >{{dict.label}}</el-radio-button>
</el-radio-group> </el-radio-group>
</el-aside> </el-aside>
<el-main> <el-main>
@ -16,7 +16,7 @@
<div> <div>
<el-row> <el-row>
<el-col :span="6"> <el-col :span="6">
<div class="solar"> <div class="solar">
{{ data.day.split('-')[2] }} {{ data.day.split('-')[2] }}
</div> </div>
</el-col> </el-col>
@ -35,10 +35,10 @@
<el-button v-if="teamShift.orderNum ==2 && calendarDay.shiftType=='SHIFT_THREE'" type="warning" icon="el-icon-sunny">{{ teamShift.teamName }}</el-button> <el-button v-if="teamShift.orderNum ==2 && calendarDay.shiftType=='SHIFT_THREE'" type="warning" icon="el-icon-sunny">{{ teamShift.teamName }}</el-button>
<el-button v-if="teamShift.orderNum ==2 && calendarDay.shiftType=='SHIFT_TWO'" type="info" icon="el-icon-moon">{{ teamShift.teamName }}</el-button> <el-button v-if="teamShift.orderNum ==2 && calendarDay.shiftType=='SHIFT_TWO'" type="info" icon="el-icon-moon">{{ teamShift.teamName }}</el-button>
<el-button v-if="teamShift.orderNum ==3 && calendarDay.shiftType=='SHIFT_THREE'" type="info" icon="el-icon-moon">{{ teamShift.teamName }}</el-button> <el-button v-if="teamShift.orderNum ==3 && calendarDay.shiftType=='SHIFT_THREE'" type="info" icon="el-icon-moon">{{ teamShift.teamName }}</el-button>
</div> </div>
</el-col> </el-col>
</el-row> </el-row>
</div> </div>
</template> </template>
</el-calendar> </el-calendar>
</el-main> </el-main>
@ -51,8 +51,8 @@ import { listCalholiday } from "@/api/mes/cal/calholiday";
import { listCalendars } from "@/api/mes/cal/calendar"; import { listCalendars } from "@/api/mes/cal/calendar";
import calendar from '@/utils/calendar'; import calendar from '@/utils/calendar';
export default { export default {
name: 'CalendarTypeView', name: 'CalendarTypeView',
dicts:['mes_calendar_type'], dicts:['mes_calendar_type'],
data(){ data(){
return { return {
// //
@ -72,15 +72,15 @@ export default {
holidayType: null, holidayType: null,
startTime: null, startTime: null,
endTime: null, endTime: null,
}, },
} }
}, },
watch:{ watch:{
date:{ date:{
handler(newVal,oldVal){ handler(newVal,oldVal){
console.log(newVal.getFullYear()+'-'+(newVal.getMonth()+1)+'-'+newVal.getDate()); console.log(newVal.getFullYear()+'-'+(newVal.getMonth()+1)+'-'+newVal.getDate());
this.teamShiftQueryParams.date = newVal.getFullYear()+'-'+(newVal.getMonth()+1)+'-'+newVal.getDate(); this.teamShiftQueryParams.date = newVal.getFullYear()+'-'+(newVal.getMonth()+1)+'-'+newVal.getDate();
this.loading = true; this.loading = true;
listCalendars(this.teamShiftQueryParams).then(response =>{ listCalendars(this.teamShiftQueryParams).then(response =>{
this.calendarDayList = response.data; this.calendarDayList = response.data;
this.loading = false; this.loading = false;
@ -94,10 +94,10 @@ export default {
methods:{ methods:{
/** 查询节假日设置列表 */ /** 查询节假日设置列表 */
getList() { getList() {
this.loading = true; this.loading = true;
this.holidayList =[]; this.holidayList =[];
this.workdayList =[]; this.workdayList =[];
let that = this; let that = this;
listCalholiday(this.queryParams).then(response => { listCalholiday(this.queryParams).then(response => {
if(response.data !=null){ if(response.data !=null){
response.data.forEach(theDay => { response.data.forEach(theDay => {
@ -106,16 +106,16 @@ export default {
}else{ }else{
that.workdayList.push(theDay.theDay); that.workdayList.push(theDay.theDay);
} }
}); });
this.loading = false; this.loading = false;
} }
}); });
}, },
// //
onSelected(calType){ onSelected(calType){
this.loading = true; this.loading = true;
this.teamShiftQueryParams.calendarType = calType; this.teamShiftQueryParams.calendarType = calType;
this.teamShiftQueryParams.date = this.date; this.teamShiftQueryParams.date = this.date.getFullYear() + '-' + (this.date.getMonth() + 1) + '-' + this.date.getDate();
listCalendars(this.teamShiftQueryParams).then(response =>{ listCalendars(this.teamShiftQueryParams).then(response =>{
this.calendarDayList = response.data; this.calendarDayList = response.data;
this.loading = false; this.loading = false;
@ -124,20 +124,20 @@ export default {
isFestival(slotDate, slotData) { isFestival(slotDate, slotData) {
let solarDayArr = slotData.day.split('-'); let solarDayArr = slotData.day.split('-');
let lunarDay = calendar.solar2lunar(solarDayArr[0], solarDayArr[1], solarDayArr[2]) let lunarDay = calendar.solar2lunar(solarDayArr[0], solarDayArr[1], solarDayArr[2])
// \\ // \\
let festAndTerm = []; let festAndTerm = [];
festAndTerm.push(lunarDay.festival == null ? '' : ' ' + lunarDay.festival) festAndTerm.push(lunarDay.festival == null ? '' : ' ' + lunarDay.festival)
festAndTerm.push(lunarDay.lunarFestival == null ? '' : '' + lunarDay.lunarFestival) festAndTerm.push(lunarDay.lunarFestival == null ? '' : '' + lunarDay.lunarFestival)
festAndTerm.push(lunarDay.Term == null ? '' : '' + lunarDay.Term) festAndTerm.push(lunarDay.Term == null ? '' : '' + lunarDay.Term)
festAndTerm = festAndTerm.join('') festAndTerm = festAndTerm.join('')
return festAndTerm != '' return festAndTerm != ''
}, },
solarDate2lunar(solarDate) { solarDate2lunar(solarDate) {
var solar = solarDate.split('-') var solar = solarDate.split('-')
var lunar = calendar.solar2lunar(solar[0], solar[1], solar[2]) var lunar = calendar.solar2lunar(solar[0], solar[1], solar[2])
let lunarMD = lunar.IMonthCn + lunar.IDayCn; let lunarMD = lunar.IMonthCn + lunar.IDayCn;
// \\ // \\
let festAndTerm = []; let festAndTerm = [];
@ -145,9 +145,9 @@ export default {
festAndTerm.push(lunar.lunarFestival == null ? '' : '' + lunar.lunarFestival) festAndTerm.push(lunar.lunarFestival == null ? '' : '' + lunar.lunarFestival)
festAndTerm.push(lunar.Term == null ? '' : '' + lunar.Term) festAndTerm.push(lunar.Term == null ? '' : '' + lunar.Term)
festAndTerm = festAndTerm.join('') festAndTerm = festAndTerm.join('')
return festAndTerm == '' ? lunarMD : festAndTerm return festAndTerm == '' ? lunarMD : festAndTerm
} }
} }
} }
@ -204,4 +204,4 @@ export default {
.el-calendar-table .holiday { .el-calendar-table .holiday {
background-color: #88E325; background-color: #88E325;
} }
</style> </style>