feat: add last report memory for work report form
This commit is contained in:
@@ -144,4 +144,12 @@ export function suppProjectReport (data) {
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 查询当前用户最近一次报工记录(用于表单记忆回填)
|
||||
export function getLastReport () {
|
||||
return request({
|
||||
url: '/oa/projectReport/lastReport',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user