Commit 825aa82a authored by xinzhedeai's avatar xinzhedeai

add:员工字典获取name处理

parent ec13edd4
...@@ -150,10 +150,10 @@ ...@@ -150,10 +150,10 @@
clearable clearable
> >
<el-option <el-option
v-for="item in cardIdOptions" v-for="item in deptOptions"
:key="item.cardId" :key="item.value"
:label="item.cardId" :label="item.label"
:value="item.cardId" :value="item.value"
></el-option> ></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
...@@ -305,6 +305,16 @@ export default { ...@@ -305,6 +305,16 @@ export default {
name: "Info", name: "Info",
data() { data() {
return { return {
deptOptions: [
{
label: "部门1",
value: "1",
},
{
label: "部门2",
value: "2",
},
],
// 绑定卡对话框 // 绑定卡对话框
bindOpen: false, bindOpen: false,
// 绑定卡表单 // 绑定卡表单
...@@ -616,14 +626,32 @@ export default { ...@@ -616,14 +626,32 @@ export default {
this.$refs["form"].validate((valid) => { this.$refs["form"].validate((valid) => {
if (valid) { if (valid) {
this.form.personType = "staff"; this.form.personType = "staff";
if (this.form.personId != null) {
updateInfo(this.form).then((response) => { // 创建一个表单数据的副本,避免直接修改原表单
const formData = { ...this.form };
// 根据 deptId 查找对应的部门名称
if (
formData.deptId &&
this.deptOptions &&
this.deptOptions.length > 0
) {
const deptItem = this.deptOptions.find(
(item) => item.value === formData.deptId
);
if (deptItem) {
formData.deptName = deptItem.label; // 添加部门名称参数
}
}
if (formData.personId != null) {
updateInfo(formData).then((response) => {
this.$modal.msgSuccess("修改成功"); this.$modal.msgSuccess("修改成功");
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
} else { } else {
addInfo(this.form).then((response) => { addInfo(formData).then((response) => {
this.$modal.msgSuccess("新增成功"); this.$modal.msgSuccess("新增成功");
this.open = false; this.open = false;
this.getList(); this.getList();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment