完成申请延期接口

This commit is contained in:
WindowBird 2025-11-13 16:33:00 +08:00
parent 9246d19806
commit 92ee88a961
2 changed files with 63 additions and 32 deletions

View File

@ -81,3 +81,20 @@ export const submitTask = ({ id, submitAttaches, submitRemark }) => {
});
};
/**
* 申请任务延期发起审核
* @param {Object} payload 请求数据
* @param {string|number} payload.bstId 任务ID
* @param {string} payload.bstType 审核类型
* @param {string} payload.createRemark 申请说明
* @param {string} payload.data 业务数据JSON字符串
* @returns {Promise} 返回接口响应
*/
export const applyTaskDelay = (payload) => {
return uni.$uv.http.post('/bst/verify', payload, {
custom: {
auth: true
}
});
};

View File

@ -111,8 +111,9 @@
</template>
<script setup>
import { ref, computed, onMounted } from 'vue';
import { ref, computed } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import { applyTaskDelay } from '@/api';
//
const formData = ref({
@ -281,6 +282,15 @@ const selectedTime = computed(() => {
return formData.value.selectedTime;
});
// YYYY-MM-DD HH:mm:ss
const buildExpireDateTime = () => {
if (!formData.value.selectedDate) return '';
const rawTime = formData.value.selectedTime || '00:00';
const hasSeconds = /^\d{2}:\d{2}:\d{2}$/.test(rawTime);
const timeSegment = hasSeconds ? rawTime : `${rawTime}:00`;
return `${formData.value.selectedDate} ${timeSegment}`;
};
//
const openTimePicker = () => {
const timeParts = formData.value.selectedTime.split(':');
@ -331,7 +341,7 @@ const handleCancel = () => {
};
//
const handleSubmit = () => {
const handleSubmit = async () => {
if (!canSubmit.value) {
uni.showToast({
title: '请填写申请说明',
@ -340,54 +350,58 @@ const handleSubmit = () => {
return;
}
if (!taskId.value) {
uni.showToast({
title: '缺少任务ID',
icon: 'none'
});
return;
}
const expireDateTime = buildExpireDateTime();
const payload = {
bstId: taskId.value,
bstType: 'UPDATE_TASK',
createRemark: formData.value.description.trim(),
data: JSON.stringify({
expireTime: expireDateTime
})
};
uni.showLoading({
title: '提交中...'
});
//
const submitData = {
taskId: taskId.value,
description: formData.value.description.trim(),
delayDate: formData.value.selectedDate,
delayTime: formData.value.selectedTime
};
// TODO:
// 使API
// uni.request({
// url: '/api/task/delay/apply',
// method: 'POST',
// data: submitData,
// success: (res) => {
// //
// },
// fail: (err) => {
// //
// }
// });
//
setTimeout(() => {
uni.hideLoading();
try {
await applyTaskDelay(payload);
// 使
uni.setStorageSync('delayApplication', {
taskId: taskId.value,
description: submitData.description,
delayDate: submitData.delayDate,
delayTime: submitData.delayTime
description: payload.createRemark,
delayDate: formData.value.selectedDate,
delayTime: formData.value.selectedTime,
expireTime: expireDateTime
});
uni.hideLoading();
uni.showToast({
title: '申请提交成功',
icon: 'success'
});
//
setTimeout(() => {
uni.navigateBack();
}, 1500);
}, 1000);
} catch (error) {
uni.hideLoading();
console.error('申请延期失败:', error);
const message = error?.data?.message || error?.errMsg || '申请失败,请稍后再试';
uni.showToast({
title: message,
icon: 'none'
});
}
};
</script>