生育休假手机端

This commit is contained in:
=
2025-11-08 17:43:19 +08:00
parent 572539f834
commit 648f0d116f
6 changed files with 362 additions and 216 deletions
@@ -209,13 +209,33 @@ layout("/layouts/platform.html"){
}
},
computed: {
// 是否为男性
isMale() {
return this.formData.sex === '男性' || this.formData.sex === '男';
},
// 是否为女性
isFemale() {
return this.formData.sex === '女性' || this.formData.sex === '女';
},
},
watch: {
// 监听性别变化,设置默认值
isMale(newVal) {
if (newVal) {
// 男性默认设置
this.$set(this.formData, 'loverSex', '女');
}
},
isFemale(newVal) {
if (newVal) {
// 女性默认设置
this.$set(this.formData, 'loverSex', '男');
}
}
},
methods: {
// 保存
onSave() {
console.log(this.formData);
@@ -17,7 +17,7 @@ layout("/layouts/platform_h5.html"){
readonly></van-field>
<van-field label="性别" v-model="formData.sex" placeholder="从信息中心获取" readonly></van-field>
<van-field label="民族" v-model="formData.nation" placeholder="从信息中心获取" readonly></van-field>
<van-field label="出生年月" v-model="formData.birthday" placeholder="从信息中心获取"
<van-field label="出生年月" v-model="$moment(formData.birthday).format('YYYY-MM-DD')" placeholder="从信息中心获取"
readonly></van-field>
<van-field label="工作单位" v-model="formData.unitName" placeholder="从信息中心获取"
readonly></van-field>
@@ -54,7 +54,7 @@ layout("/layouts/platform_h5.html"){
</van-popup>
<van-field label="出生年月"
v-model="formData.loverBirthday"
:value="formData.loverBirthday ? $moment(formData.loverBirthday).format('YYYY-MM-DD') : ''"
placeholder="请选择出生年月"
readonly
@click="showLoverBirthdayPicker = true"
@@ -74,7 +74,7 @@ layout("/layouts/platform_h5.html"){
<van-field label="工作单位" v-model="formData.loverUnitName" placeholder="请输入工作单位"
required></van-field>
<van-field label="子女出生日期"
v-model="formData.childrenBirthday"
:value="formData.childrenBirthday ? $moment(formData.childrenBirthday).format('YYYY-MM-DD') : ''"
placeholder="请选择子女出生日期"
readonly
@click="showChildrenBirthdayPicker = true"
@@ -91,6 +91,32 @@ layout("/layouts/platform_h5.html"){
show-toolbar
></van-datetime-picker>
</van-popup>
<van-field label="是否难产" required>
<template #input>
<van-radio-group v-model="formData.isDystocia" direction="horizontal">
<van-radio :name="true"></van-radio>
<van-radio :name="false"></van-radio>
</van-radio-group>
</template>
</van-field>
<van-field label="是否三胎" required>
<template #input>
<van-radio-group v-model="formData.isThreeChildren" direction="horizontal">
<van-radio :name="true"></van-radio>
<van-radio :name="false"></van-radio>
</van-radio-group>
</template>
</van-field>
<van-field label="是否多胞胎" required>
<template #input>
<van-radio-group v-model="formData.isMultipleBirths" direction="horizontal">
<van-radio :name="true"></van-radio>
<van-radio :name="false"></van-radio>
</van-radio-group>
</template>
</van-field>
</van-cell-group>
<!-- <van-cell-group title="假期类型" class="form-section">
@@ -221,46 +247,9 @@ layout("/layouts/platform_h5.html"){
showDifficultLeavePicker: false,
minDate: new Date(1950, 0, 1), // 设置最小日期为1950年1月1日
maxDate: new Date(2040, 12, 31), // 设置最大日期为2040年12月31日
// 表单验证规则
formRules: {
loverName: [{required: true, message: '请输入爱人姓名'}],
loverSex: [{required: true, message: '请选择爱人性别'}],
loverNationName: [{required: true, message: '请选择爱人民族'}],
loverBirthday: [{required: true, message: '请选择爱人出生年月'}],
loverUnitName: [{required: true, message: '请输入爱人工作单位'}],
withLeave: [{required: true, message: '请输入陪产假天数'}],
parentalLeave: [{required: true, message: '请输入育儿假天数'}],
maternityLeave: [{required: true, message: '请输入产假天数'}],
extendLeave: [{required: true, message: '请输入延长假天数'}],
startTime: [{required: true, message: '请选择休假开始时间'}],
endTime: [{required: true, message: '请选择休假结束时间'}],
childrenBirthday: [{required: true, message: '请选择子女出生日期'}]
}
}
},
computed: {
totalLeaveDays() {
const fields = [
'withLeave', // 陪产假
'parentalLeave', // 育儿假
'maternityLeave', // 产假
'extendLeave', // 延长假
'birthsLeave', // 多胞胎
'difficultLeave', // 难产假
'winterLeave', // 寒假
'summerLeave' // 暑假
];
let total = 0;
fields.forEach(field => {
const value = parseFloat(this.formData[field]) || 0;
total += value;
});
// 同时更新 formData.leaveDays,以便保存到后端
this.$set(this.formData, 'leaveDays', total);
return total;
},
// 是否为男性
isMale() {
return this.formData.sex === '男性' || this.formData.sex === '男';
@@ -271,15 +260,6 @@ layout("/layouts/platform_h5.html"){
}
},
watch: {
totalLeaveDays(newVal) {
this.$set(this.formData, 'leaveDays', newVal);
// 当合计天数或开始时间变化时,自动计算结束时间
this.calculateEndTime();
},
'formData.startTime'() {
// 当开始时间变化时,自动计算结束时间
this.calculateEndTime();
},
// 监听性别变化,设置默认值
isMale(newVal) {
if (newVal) {
@@ -324,29 +304,7 @@ layout("/layouts/platform_h5.html"){
return date;
}
},
// 计算休假时间止
calculateEndTime() {
// 如果是男性,则不自动计算结束时间
if (this.isMale) {
return;
}
if (this.formData.startTime && this.formData.leaveDays) {
const startDate = new Date(this.formData.startTime);
if (!isNaN(startDate.getTime())) {
// 创建新的日期对象,避免修改原始日期
const endDate = new Date(startDate);
// 添加天数(leaveDays - 1,因为包含开始日期)
endDate.setDate(endDate.getDate() + this.formData.leaveDays - 1);
// 格式化为 yyyy-MM-dd
const year = endDate.getFullYear();
const month = String(endDate.getMonth() + 1).padStart(2, '0');
const day = String(endDate.getDate()).padStart(2, '0');
this.$set(this.formData, 'endTime', year + '-' + month + '-' + day);
}
}
},
async onSave() {
// 保存时不需要验证,直接提交数据
this.$axios.post("/platform/maternityLeave/apply/save", {data: JSON.stringify(this.formData)})
.then((res) => {
this.$toast.clear();
@@ -391,42 +349,20 @@ layout("/layouts/platform_h5.html"){
errors.push('请输入爱人工作单位');
}
// 根据性别验证假期字段
if (isMale) {
if (!this.formData.withLeave && this.formData.withLeave !== 0) {
errors.push('请输入陪产假天数');
}
if (!this.formData.parentalLeave && this.formData.parentalLeave !== 0) {
errors.push('请输入育儿假天数');
}
}
if (isFemale) {
if (!this.formData.maternityLeave && this.formData.maternityLeave !== 0) {
errors.push('请输入产假天数');
}
if (!this.formData.extendLeave && this.formData.extendLeave !== 0) {
errors.push('请输入延长假天数');
}
}
if (!this.formData.startTime) {
errors.push('请选择休假开始时间');
}
if (!this.formData.endTime) {
errors.push('请选择休假结束时间');
}
if (!this.formData.childrenBirthday) {
errors.push('请选择子女出生日期');
}
// 添加时间顺序验证
if (this.formData.startTime && this.formData.endTime) {
const startDate = new Date(this.formData.startTime);
const endDate = new Date(this.formData.endTime);
if (endDate < startDate) {
errors.push('休假结束时间不能早于开始时间');
}
if (this.formData.isDystocia === undefined || this.formData.isDystocia === null) {
errors.push('请选择是否难产');
}
if (this.formData.isThreeChildren === undefined || this.formData.isThreeChildren === null) {
errors.push('请选择是否三胎');
}
if (this.formData.isMultipleBirths === undefined || this.formData.isMultipleBirths === null) {
errors.push('请选择是否多胞胎');
}
return errors;
@@ -488,33 +424,17 @@ layout("/layouts/platform_h5.html"){
this.$set(this.formData, "loverBirthday", this.formatDate(value));
this.showLoverBirthdayPicker = false;
},
// 休假开始时间确认事件 - 格式化为 yyyy-MM-dd
onStartTimeConfirm(value) {
this.$set(this.formData, "startTime", this.formatDate(value));
this.showStartTimePicker = false;
},
// 休假结束时间确认事件 - 格式化为 yyyy-MM-dd
onEndTimeConfirm(value) {
this.$set(this.formData, "endTime", this.formatDate(value));
this.showEndTimePicker = false;
},
// 子女出生日期确认事件 - 格式化为 yyyy-MM-dd
onChildrenBirthdayConfirm(value) {
this.$set(this.formData, "childrenBirthday", this.formatDate(value));
this.showChildrenBirthdayPicker = false;
},
onBirthsLeaveConfirm(value) {
this.$set(this.formData, "birthsLeave", value.value);
this.showBirthsLeavePicker = false;
onLoverSexConfirm(o) {
this.$set(this.formData, "loverSex", o.text);
this.showLoverSexPicker = false;
},
onDifficultLeaveConfirm(value) {
this.$set(this.formData, "difficultLeave", value.value);
this.showDifficultLeavePicker = false;
},
onLoverNationConfirm(o) {
this.$set(this.formData, "loverNationName", o.text); // 显示名称
@@ -535,84 +455,42 @@ layout("/layouts/platform_h5.html"){
return {value: item.code, text: item.name}
})
},
async findOne(id) {
const resp = await $.get('/platform/maternityLeave/apply/findOne', {id})
if (resp.code === 0) {
return resp.data
}
},
init() {
this.bizId = GetQueryString("bizId")
if (this.bizId) {
this.$axios.post("/platform/maternityLeave/apply/findOne", {id: this.bizId}).then((res) => {
if (res.code === 0) {
// 先保存原始数据
const originalData = {...res.data};
this.formData = res.data;
this.findOne(this.bizId).then(async data => {
this.formData = data
// 处理支付方式显示
if (this.loverNationColumns.length > 0) {
const matched = this.loverNationColumns.find(item =>
item.value === originalData.loverNation
)
if (matched) {
this.$set(this.formData, "loverNationName", matched.text)
this.$set(this.formData, "loverNation", matched.value)
}
}
// 格式化所有日期字段,确保不包含时分秒
const dateFields = ['birthday', 'loverBirthday', 'startTime', 'endTime', 'childrenBirthday'];
dateFields.forEach(field => {
if (this.formData[field]) {
this.$set(this.formData, field, this.formatDate(this.formData[field]));
}
});
// 根据性别设置默认值
if (this.isMale) {
// 男性默认设置
if (!this.formData.withLeave) this.$set(this.formData, 'withLeave', 15);
if (!this.formData.parentalLeave) this.$set(this.formData, 'parentalLeave', 10);
// 男性默认产假和延长假为0
if (!this.formData.maternityLeave) this.$set(this.formData, 'maternityLeave', 0);
if (!this.formData.extendLeave) this.$set(this.formData, 'extendLeave', 0);
} else if (this.isFemale) {
// 女性默认设置
if (!this.formData.maternityLeave) this.$set(this.formData, 'maternityLeave', 98);
if (!this.formData.extendLeave) this.$set(this.formData, 'extendLeave', 60);
// 女性默认陪产假和育儿假为0
if (!this.formData.withLeave) this.$set(this.formData, 'withLeave', 0);
if (!this.formData.parentalLeave) this.$set(this.formData, 'parentalLeave', 0);
// 处理民族字段回显
if (this.loverNationColumns.length > 0 && this.formData.loverNation) {
const matched = this.loverNationColumns.find(item =>
item.value === this.formData.loverNation
);
if (matched) {
this.$set(this.formData, "loverNationName", matched.text);
}
}
})
} else {
const user = this.$store.state.user
this.$set(this.formData, "userId", user.id)
this.$set(this.formData, "userName", user.username)
this.$set(this.formData, "loginName", user.loginname)
this.$set(this.formData, "unitId", user.unitId)
this.$set(this.formData, "unitName", user.unit.name)
this.$set(this.formData, "unionId", user.union.id)
this.$set(this.formData, "unionName", user.union.name)
this.$set(this.formData, "sex", user.sex)
this.$set(this.formData, "nation", user.nation)
this.$set(this.formData, "birthday", this.formatDate(user.birthday)) // 格式化日期
this.$set(this.formData, "mobile", user.mobile)
// 根据性别设置默认值
if (this.isMale) {
// 男性默认设置
this.$set(this.formData, 'loverSex', '女');
this.$set(this.formData, 'withLeave', 15);
this.$set(this.formData, 'parentalLeave', 10);
// 男性默认产假和延长假为0
this.$set(this.formData, 'maternityLeave', 0);
this.$set(this.formData, 'extendLeave', 0);
} else if (this.isFemale) {
// 女性默认设置
this.$set(this.formData, 'loverSex', '男');
this.$set(this.formData, 'maternityLeave', 98);
this.$set(this.formData, 'extendLeave', 60);
// 女性默认陪产假和育儿假为0
this.$set(this.formData, 'withLeave', 0);
this.$set(this.formData, 'parentalLeave', 0);
const {id, username, loginname, union, unit, sex, nation, birthday, mobile} = this.$store.state.user
this.formData = {
userId: id,
userName: username,
loginName: loginname,
unitId: unit.id,
unitName: unit.name,
unionId: union.id,
unionName: union.name,
sex: sex,
nation: nation,
birthday: birthday,
mobile: mobile
}
}
}
@@ -15,24 +15,11 @@ const MATERNITY_LEAVE_INFO = {
<van-cell title="民族">{{ viewData.loverNation }}</van-cell>
<van-cell title="出生年月">{{$moment(viewData.loverBirthday).format('YYYY-MM-DD')}}</van-cell>
<van-cell title="单位">{{ viewData.loverUnitName }}</van-cell>
</van-cell-group>
<van-cell-group title="假期类型">
<van-cell title="陪产假" v-if="viewData.sex === '男性' || viewData.sex === '男'">{{ viewData.withLeave }}</van-cell>
<van-cell title="育儿假" v-if="viewData.sex === '男性' || viewData.sex === '男'">{{ viewData.parentalLeave }}</van-cell>
<van-cell title="产假" v-if="viewData.sex === '女性' || viewData.sex === '女'">{{ viewData.maternityLeave }}</van-cell>
<van-cell title="延长假" v-if="viewData.sex === '女性' || viewData.sex === '女'">{{ viewData.extendLeave }}</van-cell>
<van-cell title="多胞胎" v-if="viewData.sex === '女性' || viewData.sex === '女'">{{ viewData.birthsLeave }}</van-cell>
<van-cell title="难产假" v-if="viewData.sex === '女性' || viewData.sex === '女'">{{ viewData.difficultLeave }}</van-cell>
<van-cell title="寒假">{{ viewData.winterLeave }}</van-cell>
<van-cell title="暑假">{{ viewData.summerLeave }}</van-cell>
<van-cell title="合计">{{ viewData.leaveDays }}</van-cell>
<van-cell title="休假时间起">{{$moment(viewData.startTime).format('YYYY-MM-DD')}}</van-cell>
<van-cell title="休假时间止">{{$moment(viewData.endTime).format('YYYY-MM-DD')}}</van-cell>
<van-cell title="子女出生日">{{$moment(viewData.childrenBirthday).format('YYYY-MM-DD')}}</van-cell>
<van-cell title="是否难产">{{ viewData.isDystocia ?'是':'否'}}</van-cell>
<van-cell title="是否三胎">{{ viewData.isThreeChildren ?'是':'否'}}</van-cell>
<van-cell title="是否多胞胎">{{ viewData.isMultipleBirths ?'是':'否'}}</van-cell>
</van-cell-group>
<template v-for="(task,index) in doneTasks">
<div class="process-title">
{{ task.displayName }}
@@ -67,6 +54,21 @@ const MATERNITY_LEAVE_INFO = {
}}
</template>
</van-cell>
<template v-if="viewData.leaveDays&&task.taskName==='d3b59e32-2f30-499b-b015-c485b330ddcb'&&task.taskState===20">
<van-cell-group title="假期信息">
<van-cell title="陪产假" v-if="viewData.withLeave">{{ viewData.withLeave }}天</van-cell>
<van-cell title="育儿假" v-if="viewData.parentalLeave">{{ viewData.parentalLeave }}天</van-cell>
<van-cell title="产假" v-if="viewData.maternityLeave">{{ viewData.maternityLeave }}天</van-cell>
<van-cell title="延长假" v-if="viewData.extendLeave">{{ viewData.extendLeave }}天</van-cell>
<van-cell title="多胞胎假" v-if="viewData.birthsLeave">{{ viewData.birthsLeave }}天</van-cell>
<van-cell title="难产假" v-if="viewData.difficultLeave">{{ viewData.difficultLeave }}天</van-cell>
<van-cell title="寒假" v-if="viewData.winterLeave">{{ viewData.winterLeave }}天</van-cell>
<van-cell title="暑假" v-if="viewData.summerLeave">{{ viewData.summerLeave }}天</van-cell>
<van-cell title="合计">{{ viewData.leaveDays }}天</van-cell>
<van-cell title="休假时间起">{{$moment(viewData.startTime).format('YYYY-MM-DD')}}</van-cell>
<van-cell title="休假时间止">{{$moment(viewData.endTime).format('YYYY-MM-DD')}}</van-cell>
</van-cell-group>
</template>
<van-cell title="签字" v-if="!task.ext.isFirstTaskNode">
<van-image :src="task.ext.tf_userSign"
v-if="task.ext.tf_userSign"
@@ -3,7 +3,7 @@ layout("/layouts/platform_h5.html"){
#-->
<div id="app" v-cloak>
<van-nav-bar @click-left="historyBack" left-arrow left-text="返回" title="校工会审核" placeholder
<van-nav-bar @click-left="historyBack" left-arrow left-text="返回" title="计生办审批" placeholder
fixed></van-nav-bar>
<van-sticky offset-top="46px">
<van-search
@@ -57,6 +57,92 @@ layout("/layouts/platform_h5.html"){
</div>
<div class="form-container">
<van-form ref="formRef">
<van-cell-group title="假期信息">
<van-field label="陪产假" v-model="formData.withLeave" type="number" v-if="isMale"></van-field>
<van-field label="育儿假" v-model="formData.parentalLeave" type="number" v-if="isMale"></van-field>
<van-field label="产假" v-model="formData.maternityLeave" type="number" v-if="isFemale" readonly></van-field>
<van-field label="延长假" v-model="formData.extendLeave" type="number" v-if="isFemale" readonly></van-field>
<van-field
v-if="formData.isMultipleBirths"
label="多胞胎"
v-model="formData.birthsLeave"
readonly
placeholder="请选择天数"
@click="showBirthsLeavePicker = true"
clickable
></van-field>
<van-popup position="bottom" round v-model:show="showBirthsLeavePicker">
<van-picker
:columns="[{value: 15, text: '15天'}]"
@cancel="showBirthsLeavePicker = false"
@confirm="onBirthsLeaveConfirm"
show-toolbar
></van-picker>
</van-popup>
<van-field
v-if="formData.isDystocia"
label="难产假"
v-model="formData.difficultLeave"
readonly
placeholder="请选择天数"
@click="showDifficultLeavePicker = true"
clickable
></van-field>
<van-popup position="bottom" round v-model:show="showDifficultLeavePicker">
<van-picker
:columns="[{value: 15, text: '15天'}]"
@cancel="showDifficultLeavePicker = false"
@confirm="onDifficultLeaveConfirm"
show-toolbar
></van-picker>
</van-popup>
<van-field label="寒假" v-model="formData.winterLeave" type="number"></van-field>
<van-field label="暑假" v-model="formData.summerLeave" type="number"></van-field>
<van-field label="休假时间起"
v-model="formData.startTime"
placeholder="请选择休假开始时间"
readonly
@click="showStartTimePicker = true"
clickable
required
></van-field>
<van-popup position="bottom" round v-model:show="showStartTimePicker">
<van-datetime-picker
type="date"
:min-date="minDate"
:max-date="maxDate"
@confirm="onStartTimeConfirm"
@cancel="showStartTimePicker = false"
show-toolbar
></van-datetime-picker>
</van-popup>
<van-field label="休假时间止"
v-model="formData.endTime"
placeholder="请选择休假结束时间"
readonly
@click="showEndTimePicker = true"
clickable
required
></van-field>
<van-popup position="bottom" round v-model:show="showEndTimePicker">
<van-datetime-picker
type="date"
:min-date="minDate"
:max-date="maxDate"
@confirm="onEndTimeConfirm"
@cancel="showEndTimePicker = false"
show-toolbar
></van-datetime-picker>
</van-popup>
<van-field label="合计天数" :value="totalLeaveDays" readonly></van-field>
</van-cell-group>
<van-cell-group title="审批意见">
<van-field label=""
:rules="[{ required: true,message:'请填审批意见' }]"
@@ -110,9 +196,62 @@ layout("/layouts/platform_h5.html"){
},
formData: {},
showApprovalForm: false,
infoShow: false
infoShow: false,
// 添加以下变量用于日期选择器
showStartTimePicker: false,
showEndTimePicker: false,
showBirthsLeavePicker: false,
showDifficultLeavePicker: false,
minDate: new Date(2000, 0, 1),
maxDate: new Date(2030, 12, 31),
formRules: {
tf_opinion: [{ required: true, message: '请填写审批意见' }],
startTime: [{ required: true, message: '请选择休假开始时间' }],
endTime: [{ required: true, message: '请选择休假结束时间' }]
}
}
},
computed: {
// 计算合计天数
totalLeaveDays() {
const fields = [
'withLeave', 'parentalLeave', 'maternityLeave',
'extendLeave', 'birthsLeave', 'difficultLeave',
'winterLeave', 'summerLeave'
];
let total = 0;
fields.forEach(field => {
const value = this.formData[field];
if (value && !isNaN(value)) {
total += parseFloat(value);
}
});
// 更新 formData.leaveDays
this.$set(this.formData, 'leaveDays', total);
return total;
},
// 是否为男性
isMale() {
return this.formData.sex === '男性' || this.formData.sex === '男';
},
// 是否为女性
isFemale() {
return this.formData.sex === '女性' || this.formData.sex === '女';
},
},
watch: {
totalLeaveDays(newVal) {
this.$set(this.formData, 'leaveDays', newVal);
// 当合计天数变化时,自动计算结束时间
this.calculateEndTime();
},
'formData.startTime'() {
// 当开始时间变化时,自动计算结束时间
this.calculateEndTime();
},
},
methods: {
onRevoke(row) {
this.$dialog.confirm({
@@ -130,9 +269,52 @@ layout("/layouts/platform_h5.html"){
// on cancel
});
},
async validateApprovalForm() {
try {
// 验证审批意见
if (!this.formData.tf_opinion || this.formData.tf_opinion.trim() === '') {
this.$toast.fail('请填写审批意见');
return false;
}
// 验证电子签名
if (!this.formData.tf_userSign) {
this.$toast.fail('请进行电子签名');
return false;
}
// 验证休假开始时间
if (!this.formData.startTime) {
this.$toast.fail('请选择休假开始时间');
return false;
}
// 验证休假结束时间
if (!this.formData.endTime) {
this.$toast.fail('请选择休假结束时间');
return false;
}
// 验证时间顺序
if (this.formData.startTime && this.formData.endTime) {
const startDate = new Date(this.formData.startTime);
const endDate = new Date(this.formData.endTime);
if (endDate < startDate) {
this.$toast.fail('休假结束时间不能早于开始时间');
return false;
}
}
return true;
} catch (error) {
console.error('表单验证出错:', error);
this.$toast.fail('表单验证失败,请检查输入');
return false;
}
},
async handleTaskAction(val) {
if (val === 1) {
const isValid = await this.$refs.formRef.validate()
const isValid = await this.validateApprovalForm();
if (!isValid) return;
}
this.$dialog.confirm({
@@ -166,7 +348,17 @@ layout("/layouts/platform_h5.html"){
processTaskId: row.taskId,
id: row.id,
sex: row.sex,
taskName: row.curTaskName
taskName: row.curTaskName,
isMultipleBirths: row.isMultipleBirths || false,
isDystocia: row.isDystocia || false
}
// 根据性别初始化默认假期天数
if (["男", "男性"].includes(row.sex)) {
this.$set(this.formData, 'withLeave', 15);
this.$set(this.formData, 'parentalLeave', 10);
} else {
this.$set(this.formData, 'maternityLeave', 98);
this.$set(this.formData, 'extendLeave', 60);
}
this.$refs.maternityLeaveInfoRef.onOpen(row)
},
@@ -179,6 +371,60 @@ layout("/layouts/platform_h5.html"){
})
},
// 日期选择确认方法
onStartTimeConfirm(value) {
this.$set(this.formData, "startTime", this.formatDate(value));
this.showStartTimePicker = false;
// 当开始时间变化时,自动计算结束时间
this.calculateEndTime();
},
onEndTimeConfirm(value) {
this.$set(this.formData, "endTime", this.formatDate(value));
this.showEndTimePicker = false;
},
onBirthsLeaveConfirm(value) {
this.$set(this.formData, "birthsLeave", value.value);
this.showBirthsLeavePicker = false;
},
onDifficultLeaveConfirm(value) {
this.$set(this.formData, "difficultLeave", value.value);
this.showDifficultLeavePicker = false;
},
// 格式化日期为 yyyy-MM-dd 格式
formatDate(date) {
if (!date) return '';
const d = new Date(date);
if (isNaN(d.getTime())) {
return date;
}
const year = d.getFullYear();
const month = String(d.getMonth() + 1).padStart(2, '0');
const day = String(d.getDate()).padStart(2, '0');
return year + '-' + month + '-' + day;
},
// 计算休假时间止
calculateEndTime() {
// 如果开始时间和天数都存在,则自动计算结束时间
if (this.formData.startTime && this.formData.leaveDays) {
const startDate = new Date(this.formData.startTime);
if (!isNaN(startDate.getTime())) {
// 创建新的日期对象,避免修改原始日期
const endDate = new Date(startDate);
// 添加天数(leaveDays - 1,因为包含开始日期)
endDate.setDate(endDate.getDate() + this.formData.leaveDays - 1);
// 格式化为 yyyy-MM-dd
const year = endDate.getFullYear();
const month = String(endDate.getMonth() + 1).padStart(2, '0');
const day = String(endDate.getDate()).padStart(2, '0');
this.$set(this.formData, 'endTime', year + '-' + month + '-' + day);
}
}
},
},
created() {
@@ -3,7 +3,7 @@ layout("/layouts/platform_h5.html"){
#-->
<div id="app" v-cloak>
<van-nav-bar @click-left="historyBack" left-arrow left-text="返回" title="校工会审核" placeholder fixed></van-nav-bar>
<van-nav-bar @click-left="historyBack" left-arrow left-text="返回" title="计生办终审" placeholder fixed></van-nav-bar>
<van-sticky offset-top="46px">
<van-search
:reverse-color="false"
@@ -3,7 +3,7 @@ layout("/layouts/platform_h5.html"){
#-->
<div id="app" v-cloak>
<van-nav-bar @click-left="historyBack" left-arrow left-text="返回" title="分工会审核" placeholder fixed></van-nav-bar>
<van-nav-bar @click-left="historyBack" left-arrow left-text="返回" title="单位领导审核" placeholder fixed></van-nav-bar>
<van-sticky offset-top="46px">
<van-search
:reverse-color="false"