feat: add last report memory for work report form

This commit is contained in:
2026-07-04 19:07:41 +08:00
parent 5544056833
commit 8cfd69d9bb
7 changed files with 74 additions and 0 deletions

View File

@@ -144,4 +144,12 @@ export function suppProjectReport (data) {
method: 'post',
data: data
})
}
// 查询当前用户最近一次报工记录(用于表单记忆回填)
export function getLastReport () {
return request({
url: '/oa/projectReport/lastReport',
method: 'get'
})
}

View File

@@ -167,6 +167,7 @@
import {
addProjectReport,
delProjectReport,
getLastReport,
getProjectReport,
getTodayProjectReport,
listProjectReport,
@@ -448,6 +449,10 @@ export default {
this.suppVisible = false;
this.title = "添加项目报工";
this.checkTodayReport().finally(() => {
// 如果今天还没报过工,尝试加载上次报工记录回填
if (!this.hasTodayReport) {
this.loadLastReport();
}
this.open = true;
this.$nextTick(() => {
if (!this.form.reportId) {
@@ -456,6 +461,22 @@ export default {
});
});
},
/** 加载上次报工记录,回填表单关键字段(项目、工作地点、是否出差等) */
loadLastReport () {
getLastReport().then(response => {
if (response.data && response.data.projectId) {
this.form = {
...this.form,
projectId: response.data.projectId,
workPlace: response.data.workPlace || this.form.workPlace,
isTrip: response.data.isTrip,
workType: response.data.workType,
};
}
}).catch(() => {
// 加载失败不影响正常使用
});
},
/** 修改按钮操作 */
handleUpdate (row) {
this.suppVisible = false;