临时外出申请增加上下午
This commit is contained in:
parent
bec1409474
commit
96a1a209c8
|
|
@ -16,11 +16,21 @@
|
||||||
<input type="text" v-model="formData.leaveStartDate" disabled />
|
<input type="text" v-model="formData.leaveStartDate" disabled />
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<view class="form-item">
|
||||||
|
<text class="label required">外出结束时间上下午</text>
|
||||||
|
<input type="text" :value="['请选择','上午', '下午'][formData.leaveStartInterval]" disabled />
|
||||||
|
</view>
|
||||||
|
|
||||||
<view class="form-item">
|
<view class="form-item">
|
||||||
<text class="label required">外出结束时间</text>
|
<text class="label required">外出结束时间</text>
|
||||||
<input type="text" v-model="formData.leaveEndDate" disabled />
|
<input type="text" v-model="formData.leaveEndDate" disabled />
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<view class="form-item">
|
||||||
|
<text class="label required">外出结束时间上下午</text>
|
||||||
|
<input type="text" :value="['请选择','上午', '下午'][formData.leaveEndInterval]" disabled />
|
||||||
|
</view>
|
||||||
|
|
||||||
<view class="form-item">
|
<view class="form-item">
|
||||||
<text class="label required">外出时长(天)</text>
|
<text class="label required">外出时长(天)</text>
|
||||||
<input type="number" v-model="formData.leaveDuration" disabled />
|
<input type="number" v-model="formData.leaveDuration" disabled />
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,21 @@
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<view class="form-item">
|
||||||
|
<text class="label required">外出开始时间上下午</text>
|
||||||
|
<!-- 上下午选择 -->
|
||||||
|
<picker
|
||||||
|
mode="selector"
|
||||||
|
:range="['请选择','上午', '下午']"
|
||||||
|
:value="formData.leaveStartInterval"
|
||||||
|
@change="onStartAmPmChange"
|
||||||
|
:disabled="isFormDisabled"
|
||||||
|
>
|
||||||
|
<view class="picker-value">{{ ['请选择','上午', '下午'][formData.leaveStartInterval ] }}</view>
|
||||||
|
</picker>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
|
||||||
<view class="form-item">
|
<view class="form-item">
|
||||||
<text class="label required">外出结束时间</text>
|
<text class="label required">外出结束时间</text>
|
||||||
<picker
|
<picker
|
||||||
|
|
@ -85,6 +100,20 @@
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<view class="form-item">
|
||||||
|
<text class="label required">外出结束时间上下午</text>
|
||||||
|
<!-- 上下午选择 -->
|
||||||
|
<picker
|
||||||
|
mode="selector"
|
||||||
|
:range="['请选择','上午', '下午']"
|
||||||
|
:value="formData.leaveEndInterval"
|
||||||
|
@change="onEndAmPmChange"
|
||||||
|
:disabled="isFormDisabled"
|
||||||
|
>
|
||||||
|
<view class="picker-value">{{ ['请选择','上午', '下午'][formData.leaveEndInterval] }}</view>
|
||||||
|
</picker>
|
||||||
|
</view>
|
||||||
|
|
||||||
<view class="form-item">
|
<view class="form-item">
|
||||||
<text class="label required">外出时长(天)</text>
|
<text class="label required">外出时长(天)</text>
|
||||||
<input type="number" v-model="formData.leaveDuration" disabled />
|
<input type="number" v-model="formData.leaveDuration" disabled />
|
||||||
|
|
@ -265,7 +294,9 @@
|
||||||
userName: '',
|
userName: '',
|
||||||
leaveType: null,
|
leaveType: null,
|
||||||
leaveStartDate: '',
|
leaveStartDate: '',
|
||||||
|
leaveStartInterval:'',
|
||||||
leaveEndDate: '',
|
leaveEndDate: '',
|
||||||
|
leaveEndInterval:'',
|
||||||
leaveDuration: '',
|
leaveDuration: '',
|
||||||
location: '',
|
location: '',
|
||||||
isAgree: '1',
|
isAgree: '1',
|
||||||
|
|
@ -292,6 +323,7 @@
|
||||||
hostUserNames: '', // 显示的选中名字
|
hostUserNames: '', // 显示的选中名字
|
||||||
isCheckboxGroupVisibles: false,
|
isCheckboxGroupVisibles: false,
|
||||||
isEdit: false, // 判断是否为编辑状态
|
isEdit: false, // 判断是否为编辑状态
|
||||||
|
daysNumber: "", //时间之间的差
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
|
@ -353,11 +385,29 @@
|
||||||
this.formData.leaveStartDate = startDate
|
this.formData.leaveStartDate = startDate
|
||||||
this.validateAndCalculateDuration(startDate, this.formData.leaveEndDate)
|
this.validateAndCalculateDuration(startDate, this.formData.leaveEndDate)
|
||||||
},
|
},
|
||||||
|
onStartAmPmChange(e) {
|
||||||
|
if(e.detail.value ==0){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log("开始",e.detail.value)
|
||||||
|
this.formData.leaveStartInterval = e.detail.value;
|
||||||
|
this.handleDateChanges()
|
||||||
|
},
|
||||||
|
|
||||||
onEndDateChange(e) {
|
onEndDateChange(e) {
|
||||||
const endDate = e.detail.value
|
const endDate = e.detail.value
|
||||||
this.formData.leaveEndDate = endDate
|
this.formData.leaveEndDate = endDate
|
||||||
this.validateAndCalculateDuration(this.formData.leaveStartDate, endDate)
|
this.validateAndCalculateDuration(this.formData.leaveStartDate, endDate)
|
||||||
},
|
},
|
||||||
|
onEndAmPmChange(e) {
|
||||||
|
if(e.detail.value ==0){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log("结束",e.detail.value)
|
||||||
|
this.formData.leaveEndInterval = e.detail.value;
|
||||||
|
this.handleDateChanges()
|
||||||
|
},
|
||||||
|
|
||||||
validateAndCalculateDuration(startDate, endDate) {
|
validateAndCalculateDuration(startDate, endDate) {
|
||||||
// 清除之前的错误信息
|
// 清除之前的错误信息
|
||||||
this.errors.leaveStartDate = ''
|
this.errors.leaveStartDate = ''
|
||||||
|
|
@ -390,13 +440,48 @@
|
||||||
getDays(dateData).then((response) => {
|
getDays(dateData).then((response) => {
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
console.log(response)
|
console.log(response)
|
||||||
this.formData.leaveDuration = response.data
|
// this.formData.leaveDuration = response.data
|
||||||
|
this.daysNumber = response.data
|
||||||
|
this.handleDateChanges()
|
||||||
} else {
|
} else {
|
||||||
this.formData.leaveDuration = ''
|
this.formData.leaveDuration = ''
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
handleDateChanges() {
|
||||||
|
if (this.formData.leaveStartDate && this.formData.leaveEndDate && this.formData.leaveStartInterval && this.formData.leaveEndInterval ) {
|
||||||
|
// 比较开始日期和结束日期
|
||||||
|
const startDate = new Date(this.formData.leaveStartDate);
|
||||||
|
const endDate = new Date(this.formData.leaveEndDate);
|
||||||
|
|
||||||
|
if (startDate > endDate ||
|
||||||
|
(startDate.getTime() === endDate.getTime() &&
|
||||||
|
this.formData.leaveStartInterval > this.formData.leaveEndInterval)) {
|
||||||
|
this.errors.leaveStartDate = '开始时间应该早于结束时间'
|
||||||
|
this.formData.leaveStartDate = ''
|
||||||
|
this.formData.leaveEndDate = ''
|
||||||
|
this.formData.leaveStartInterval = ''
|
||||||
|
this.formData.leaveEndInterval = ''
|
||||||
|
return
|
||||||
|
// 这里可以添加更多的用户提示或者处理逻辑
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (startDate.getTime() === endDate.getTime()) { // 同一天
|
||||||
|
if (this.formData.leaveStartInterval == 1 && this.formData.leaveEndInterval == 2) {
|
||||||
|
this.formData.leaveDuration = 1; // 上午到下午,算作1天
|
||||||
|
} else {
|
||||||
|
this.formData.leaveDuration = 0.5; // 其他情况,上/下午到同一天的上/下午,算作半天
|
||||||
|
}
|
||||||
|
} else { // 不同天
|
||||||
|
let totalDays = this.daysNumber;
|
||||||
|
if (this.formData.leaveStartInterval == 1) totalDays -= 0.5; // 开始当天只算半天
|
||||||
|
if (this.formData.leaveEndInterval == 1) totalDays -= 0.5; // 结束当天只算半天
|
||||||
|
this.formData.leaveDuration = totalDays;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
onApprovalChange(e) {
|
onApprovalChange(e) {
|
||||||
this.formData.isApproved = e.detail.value
|
this.formData.isApproved = e.detail.value
|
||||||
},
|
},
|
||||||
|
|
@ -541,6 +626,8 @@
|
||||||
leaveDuration,
|
leaveDuration,
|
||||||
leaveEndDate,
|
leaveEndDate,
|
||||||
leaveStartDate,
|
leaveStartDate,
|
||||||
|
leaveStartInterval,
|
||||||
|
leaveEndInterval,
|
||||||
leaveType,
|
leaveType,
|
||||||
location,
|
location,
|
||||||
remark,
|
remark,
|
||||||
|
|
@ -560,6 +647,8 @@
|
||||||
leaveDuration,
|
leaveDuration,
|
||||||
leaveEndDate,
|
leaveEndDate,
|
||||||
leaveStartDate,
|
leaveStartDate,
|
||||||
|
leaveStartInterval,
|
||||||
|
leaveEndInterval,
|
||||||
leaveType,
|
leaveType,
|
||||||
location,
|
location,
|
||||||
remark,
|
remark,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue