Browse Source

日历

intex_online20250117
张立 3 weeks ago
parent
commit
e03b35e640
  1. 150
      src/views/wms/basicDataManage/supplierManage/receivedCalendar/index.vue

150
src/views/wms/basicDataManage/supplierManage/receivedCalendar/index.vue

@ -33,21 +33,17 @@
<div :class="data.isSelected ? 'is-selected' : 'day'" >
{{ Number(data.day.split('-').slice(2).join('-')) }}
</div>
<div v-for="(item,index) in dayData" :key='index'>
<div v-if="data.day == item.day">
<div class="sun" v-if="item.isShowSun">
<el-image style="width: 1.1vw; height: 1.1vw" src="/src/assets/svgs/sun.svg" />
<div class="text">白班</div>
<Icon class="mr-5px" icon="ep:delete" color="#409eff" size="14px" @click="deleteShift(data,item,1)"/>
</div>
<div class="sun" v-if="item.isShowMoon">
<el-image style="width: 1.1vw; height: 1.1vw" src="/src/assets/svgs/moon.svg" />
<div class="text">夜班</div>
<Icon class="mr-5px" icon="ep:delete" color="#409eff" size="14px" @click="deleteShift(data,item,2)"/>
</div>
</div>
<div class="sun" v-if="isSpecialDate(data.day) && !isSpecialDate(data.day).isHideSun">
<el-image style="width: 1.1vw; height: 1.1vw" src="/src/assets/svgs/sun.svg" />
<div class="text">白班</div>
<Icon class="mr-5px" icon="ep:delete" color="#409eff" size="14px" @click="deleteShift(data.day,1)" />
</div>
<!-- 做监听 -->
<div class="sun" v-if="isSpecialDate(data.day) && !isSpecialDate(data.day).isHideMoon">
<el-image style="width: 1.1vw; height: 1.1vw" src="/src/assets/svgs/moon.svg" />
<div class="text">夜班</div>
<Icon class="mr-5px" icon="ep:delete" color="#409eff" size="14px" @click="deleteShift(data.day,2)" />
</div>
<!-- -->
</div>
<div v-if="data.type == 'prev-month'"></div>
<div v-if="data.type == 'next-month'"></div>
@ -98,74 +94,52 @@ const tableColumns = ref(ReceivedCalendar.allSchemas.tableColumns)
const dayData = ref([{
day:'2025-01-01',
isShowSun:true,
isShowMoon:true,
isHideSun:false,
isHideMoon:true,
},{
day:'2025-01-02',
isShowSun:true,
isShowMoon:true,
isHideSun:true,
isHideMoon:true,
},{
day:'2025-01-03',
isShowSun:true,
isShowMoon:true,
},{
day:'2025-01-04',
isShowSun:true,
isShowMoon:true,
},{
day:'2025-01-05',
isShowSun:true,
isShowMoon:true,
},{
day:'2025-01-06',
isShowSun:true,
isShowMoon:true,
},{
day:'2025-01-07',
isShowSun:true,
isShowMoon:true,
},{
day:'2025-01-08',
isShowSun:true,
isShowMoon:true,
},{
day:'2025-01-09',
isShowSun:true,
isShowMoon:true,
},{
day:'2025-01-10',
isShowSun:true,
isShowMoon:true,
},{
day:'2025-01-11',
isShowSun:true,
isShowMoon:true,
},{
day:'2025-01-12',
isShowSun:true,
isShowMoon:true,
},{
day:'2025-01-13',
isShowSun:true,
isShowMoon:true,
},{
day:'2025-01-14',
isShowSun:true,
isShowMoon:true,
},{
day:'2025-01-15',
isShowSun:true,
isShowMoon:true,
},{
day:'2025-01-16',
isShowSun:true,
isShowMoon:true,
isHideSun:true,
},{
day:'2025-01-17',
isShowSun:true,
isShowMoon:true,
isHideSun:true,
}])
const getDatesInCurrentMonth=() =>{
const today = new Date();
const year1 = today.getFullYear();
const month1 = today.getMonth(); // 0011112
const date1 = 1; // 1
const firstDayOfMonth = new Date(year1, month1, date1);
const lastDayOfMonth = new Date(year1, month1 + 1, 0); // 0
const daysInMonth = lastDayOfMonth.getDate();
const dates = [];
for (let i = 1; i <= daysInMonth; i++) {
const year =new Date(year1, month1, i).getFullYear();
const month = new Date(year1, month1, i).getMonth() + 1 >= 10 ? new Date(year1, month1, i).getMonth() + 1 : '0' + (new Date(year1, month1, i).getMonth() + 1);
const date = new Date(year1, month1, i).getDate()>= 10 ? new Date(year1, month1, i).getDate() : '0' + (new Date(year1, month1, i).getDate());
const day = `${year}-${month}-${date}`
const isHaveDay = dayData.value.find(item => (item.day == day))
dates.push({
day:`${year}-${month}-${date}`,
isHideSun:isHaveDay&&isHaveDay.isHideSun ? isHaveDay.isHideSun : false,
isHideMoon:isHaveDay&&isHaveDay.isHideMoon ? isHaveDay.isHideMoon : false,
});
}
return dates;
}
// 使
const datesInCurrentMonth = ref(getDatesInCurrentMonth());
const isSpecialDate=(date)=> {
return datesInCurrentMonth.value.find(item=>item.day == date);
}
//
const searchTableSuccess = (formField, searchField, val, formRef) => {
nextTick(() => {
@ -258,18 +232,16 @@ const handleDateChange=async(value)=> {
// form
const formsSuccess = async (formType, data) => {
console.log(data)
// const date = formatDate(data.calendarDate, 'YYYY-MM-DD')
const dateArray = await handleDateChange(data.calendarDate)
console.log(dateArray)
dayData.value.forEach(item => {
datesInCurrentMonth.value.forEach(item => {
dateArray.forEach(cur => {
if (item.day == cur) {
item.isShowMoon = false
item.isShowSun = false
item.isHideMoon = true
item.isHideSun = true
}
})
})
return
var isHave =ReceivedCalendar.allSchemas.formSchema.some(function (item) {
return item.field === 'activeTime' || item.field === 'expireTime';
@ -352,12 +324,22 @@ const searchFormClick = (searchData) => {
getList() //
}
//
const deleteShift=(data,item,type) =>{
console.log(data)
const deleteShift=(day,type) =>{
console.log(dayData.value)
if (type == 1) {
item.isShowSun = false
datesInCurrentMonth.value.forEach((item => {
if (item.day == day) {
console.log(day)
item.isHideSun = true
}
}))
} else if (type == 2) {
item.isShowMoon = false
datesInCurrentMonth.value.forEach((item => {
if (item.day == day) {
console.log(day)
item.isHideMoon = true
}
}))
}
console.log(item)
}

Loading…
Cancel
Save