人员管理模块优化
This commit is contained in:
parent
e49f216474
commit
ed7d25f1c0
|
|
@ -9,7 +9,7 @@ export const buildFormColumns = (
|
|||
) => [
|
||||
{
|
||||
type: 'input',
|
||||
prop: 'personName',
|
||||
prop: 'name',
|
||||
placeholder: '请输入姓名',
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@
|
|||
<el-switch
|
||||
active-value="1"
|
||||
inactive-value="0"
|
||||
v-model="row.longTermSecondment"
|
||||
@change="onHandleLongTermSecondmentChange(row)"
|
||||
:model-value="getLongTermSecondmentValue(row)"
|
||||
@change="onHandleLongTermSecondmentChange($event, row)"
|
||||
/>
|
||||
</template>
|
||||
</ComTable>
|
||||
|
|
@ -207,8 +207,32 @@ const onCloseDialogOuter = (visible) => {
|
|||
}
|
||||
}
|
||||
|
||||
// 获取 longTermSecondment 的值,统一转换为字符串格式
|
||||
const getLongTermSecondmentValue = (row) => {
|
||||
const value = row.longTermSecondment
|
||||
if (value === null || value === undefined) {
|
||||
return '0'
|
||||
}
|
||||
// 如果是数字,转换为字符串;如果已经是字符串,直接返回
|
||||
return String(value)
|
||||
}
|
||||
|
||||
// 是否长期借调
|
||||
const onHandleLongTermSecondmentChange = (row) => {
|
||||
console.log(row)
|
||||
const onHandleLongTermSecondmentChange = (value, row) => {
|
||||
// 更新 row 数据,保持与 switch 组件的值同步
|
||||
row.longTermSecondment = value
|
||||
|
||||
// 组装参数:将字符串转换为数字('1' -> 1, '0' -> 0)
|
||||
const params = {
|
||||
id: row.id,
|
||||
longTermSecondment: value === '1' ? 1 : 0,
|
||||
}
|
||||
|
||||
updatePersonAPI(params).then((res) => {
|
||||
if (res.code === 200) {
|
||||
proxy.$modal.msgSuccess('更新成功')
|
||||
comTableRef.value?.refresh()
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Reference in New Issue