本文主要是介绍element 日期插件开始结束区域限制 场景新员工转正,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
规则 提前转正1-2个月内
正常转正3个月
延迟转正4-6个月
限制3种状态根据入职日期判断转正生效时间 15号以前算一个月 超过15号不算满一个月 每个月1号生效
<el-radio-group v-model="form.turnPositiveType" @change="typeChange" >
<el-radio label="1" >${@m.lang('bs.Betheformal')}</el-radio>
<el-radio label="2" >${@m.lang('bs.Betheformalemployee')}</el-radio>
<el-radio label="3" >${@m.lang('bs.Delaytheprobation')}</el-radio>
</el-radio-group>
<el-form-item label="转正生效日期">
<el-date-picker
:picker-options="pickerOptions"
v-model="form.effectiveTime"
type="month"
:editable="false"
format="yyyy-MM"
value-format="yyyy-MM-dd"
placeholder="转正生效日期">
</el-date-picker>
</el-form-item>
1.提前转正
2.正常转正
3.延迟转正
js实现
pickerOptions: {
disabledDate(time) {
var now= new Date(vm.form.dateOfEntry);
var minYear = now.getFullYear();
var maxYear = now.getFullYear();
var day = now.getDate();
var flag=true;//禁用
if (vm.form.turnPositiveType==1) { //如果提前转正
var minMonth = now.getMonth()+2;
var maxMonth = now.getMonth()+3;
if(day>15){
var minMonth = minMonth+1;
var maxMonth = maxMonth+1;
}
if(minMonth>12){
minYear=minYear+1;
minMonth=minMonth-12;
}
if(maxMonth>12){
maxYear=maxYear+1;
maxMonth=maxMonth-12;
}
if(new Date(minYear+'-'+minMonth).getTime()<new Date(time).getTime()&&new Date(maxYear+'-'+maxMonth).getTime()>=new Date(time).getTime()){
flag=false;
}
}else if(vm.form.turnPositiveType==2) {//如果正常转正
var minMonth = now.getMonth()+4;
if(day>15){
var minMonth = minMonth+1;
}
if(minMonth>12){
minYear=minYear+1;
minMonth=minMonth-12;
}
if(minMonth==new Date(time).getMonth()+1&&minYear==new Date(time).getFullYear()){
flag=false;
}
}else if(vm.form.turnPositiveType==3) {//如果延迟转正 最多6个月
var minMonth = now.getMonth()+5;
var maxMonth = now.getMonth()+7;
if(day>15){
var minMonth = minMonth+1;
var maxMonth = maxMonth+1;
}
if(minMonth>12){
minYear=minYear+1;
minMonth=minMonth-12;
}
if(maxMonth>12){
maxYear=maxYear+1;
maxMonth=maxMonth-12;
}
if(new Date(minYear+'-'+minMonth).getTime()<new Date(time).getTime()&&new Date(maxYear+'-'+maxMonth).getTime()>=new Date(time).getTime()){
flag=false;
}
}
return flag;
}
}
这篇关于element 日期插件开始结束区域限制 场景新员工转正的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!