日期选择器修改

This commit is contained in:
jjLv 2024-10-12 18:21:27 +08:00
parent c06cd4a2ea
commit 3febfd29ec
2 changed files with 76 additions and 6 deletions

View File

@ -78,8 +78,8 @@
<!-- 相关记录 -->
<el-dialog :title="title" :visible.sync="showRecord" width="1200px" height="1000px" append-to-body @close="cancelRecord">
<el-form :model="queryRecord" ref="queryFormRecord" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="姓名:" prop="name">
<el-form :model="queryRecord" ref="queryFormRecord" size="small" :inline="true" v-show="showSearch" label-width="90px">
<!-- <el-form-item label="姓名:" prop="name">
<el-input
v-model="queryRecord.name"
placeholder="请输入姓名"
@ -87,6 +87,18 @@
@keyup.enter.native="handleQueryRecord"
maxlength="20"
/>
</el-form-item> -->
<el-form-item label="选择时间段">
<el-date-picker
v-model="dateRange"
style="width: 240px"
value-format="yyyy-MM-dd"
type="daterange"
range-separator="-"
start-placeholder="请假开始日期"
end-placeholder="请假结束日期"
:picker-options="pickerOptions"
></el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQueryRecord">查询</el-button>
@ -235,6 +247,9 @@
{ required: true, message: "补充内容不能为空", trigger: "blur" }
],
},
pickerOptions: {
disabledDate: this.disabledDate,
},
};
},
computed: {
@ -281,6 +296,18 @@
// },
methods: {
disabledDate(time) {
const str=this.queryRecord.attCurrentMonth+'-01';
//
var currentDate = new Date(str);
//
var firstDayOfMonth = new Date(currentDate.getFullYear(), currentDate.getMonth(), 1);
//
var lastDayOfMonth = new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 0);
return time < firstDayOfMonth || time > lastDayOfMonth;
},
handleChange(newValue) {
//
if (!newValue) {
@ -385,13 +412,13 @@
getListRecord() {
this.loadingTwo = true;
if(this.title=='轮休未审批记录'){
getDetailExceptionRest(this.queryRecord).then(response => {
getDetailExceptionRest(this.addDateRange(this.queryRecord, this.dateRange)).then(response => {
this.tableDataRecord = response.rows;
this.totalTwo = response.total;
this.loadingTwo = false;
});
}else if(this.title=='外出办事未审批记录'){
getDetailExceptionOut(this.queryRecord).then(response => {
getDetailExceptionOut(this.addDateRange(this.queryRecord, this.dateRange)).then(response => {
this.tableDataRecord = response.rows;
this.totalTwo = response.total;
this.loadingTwo = false;

View File

@ -45,6 +45,7 @@
</el-table-column>
<el-table-column label="姓名" align="center" prop="name" sortable/>
<el-table-column label="所属部门" align="center" prop="orgName" sortable/>
<el-table-column label="考勤月份" align="center" prop="attCurrentMonth" sortable/>
<el-table-column label="应出勤天数" align="center" prop="requiredDays" sortable/>
<el-table-column label="正常打卡天数" align="center" prop="normalNum" sortable>
<template slot-scope="scope">
@ -131,6 +132,8 @@
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
:picker-options="pickerOptions"
></el-date-picker>
</el-form-item>
<el-form-item>
@ -246,6 +249,8 @@
//
open: false,
dateRange: [],
startDate:undefined,
endDate:undefined,
queryParams: {
pageNum: 1,
@ -261,22 +266,59 @@
pageSize: 10,
userId: undefined,
attStatis: undefined,
attCurrent: undefined,
},
//
pickerOptions: {
disabledDate: this.disabledDate,
}
};
},
computed: {
},
created() {
this.getMonth()
this.getDeptList(),
this.getList();
},
mounted(){
},
methods: {
disabledDate(time) {
const str=this.queryRecord.attCurrent+'-01';
//
var currentDate = new Date(str);
//
var firstDayOfMonth = new Date(currentDate.getFullYear(), currentDate.getMonth(), 1);
//
var lastDayOfMonth = new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 0);
return time < firstDayOfMonth || time > lastDayOfMonth;
},
// defaultTime(){
// // ['2023-04-01', '2023-04-10']
// console.log(11111111111111)
// const str=this.queryRecord.attCurrent+'-01';
// var currentDate = new Date(str);
// //
// var firstDayOfMonth = new Date(currentDate.getFullYear(), currentDate.getMonth(), 1);
// //
// var lastDayOfMonth = new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 0);
// const strTemp=[firstDayOfMonth,lastDayOfMonth]
// return strTemp;
// },
getMonth(){
//
var nowDate = new Date();
var date = {
year: nowDate.getFullYear(),
month: nowDate.getMonth() ,
day: nowDate.getDate()
};
const dayDate = date.year + "-" + (date.month >= 10 ? date.month : "0" + date.month);
// var date = new Date();
this.$set(this.queryParams, "attCurrentMonth", dayDate.toString());
},
formatDate(dateString){
const date = new Date(dateString); //
const year = date.getFullYear(); //
@ -346,6 +388,7 @@
this.id = row.id;
this.title = titleBoss;
this.queryRecord.userId = row.userId;
this.queryRecord.attCurrent = row.attCurrentMonth;
if(titleBoss=='打卡记录'){
this.queryRecord.attStatis=1;
}else if(titleBoss=='迟到记录'){