fix(hrm): 人员交接详情抽屉数据不回显
el-drawer 早期渲染插槽时 t_id 仍为 null,mounted() 走到 else 分支把 localMode 设成 add,后续 prop 变化 getTid 不再触发。 改用 watch t_id (immediate:true),prop 何时到位都能拉数据。 同时给 system.post.list 单独加 try/catch 并对 state_ 做空安全 访问,避免内层异常吃掉主数据赋值。 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
64060a6e2f
commit
cacb548517
|
|
@ -188,15 +188,22 @@ export default {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
deep: true,
|
deep: true,
|
||||||
|
},
|
||||||
|
t_id: {
|
||||||
|
handler(val) {
|
||||||
|
this.localMode = this.mode;
|
||||||
|
if (val) {
|
||||||
|
this.getTid();
|
||||||
|
} else {
|
||||||
|
this.formData = { person: [] };
|
||||||
|
this.localMode = "add";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
immediate: true,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.getGroup();
|
this.getGroup();
|
||||||
if (this.t_id) {
|
|
||||||
this.getTid();
|
|
||||||
} else {
|
|
||||||
this.localMode = "add";
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async getTid() {
|
async getTid() {
|
||||||
|
|
@ -204,6 +211,7 @@ export default {
|
||||||
let res = await this.$API.hrm.empjoin.item.req(this.t_id);
|
let res = await this.$API.hrm.empjoin.item.req(this.t_id);
|
||||||
// 获取岗位列表,填充 post_name
|
// 获取岗位列表,填充 post_name
|
||||||
if (res.person && res.person.length > 0) {
|
if (res.person && res.person.length > 0) {
|
||||||
|
try {
|
||||||
const postRes = await this.$API.system.post.list.req({ page: 0 });
|
const postRes = await this.$API.system.post.list.req({ page: 0 });
|
||||||
const postList = Array.isArray(postRes) ? postRes : (postRes.results || postRes.data || []);
|
const postList = Array.isArray(postRes) ? postRes : (postRes.results || postRes.data || []);
|
||||||
const postMap = {};
|
const postMap = {};
|
||||||
|
|
@ -213,9 +221,12 @@ export default {
|
||||||
p.post_name = postMap[p.post] || '';
|
p.post_name = postMap[p.post] || '';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} catch (postErr) {
|
||||||
|
console.error('获取岗位列表失败:', postErr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.formData = res;
|
this.formData = res;
|
||||||
if (res.ticket_ && res.ticket_.state_.type == 1 && res.create_by == this.$TOOL.data.get("USER_INFO").id) {
|
if (res.ticket_ && res.ticket_.state_ && res.ticket_.state_.type == 1 && res.create_by == this.$TOOL.data.get("USER_INFO").id) {
|
||||||
this.localMode = "edit";
|
this.localMode = "edit";
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue