fix: 修复部门新增上级部门回显bug

This commit is contained in:
AN 2025-05-28 11:18:01 +08:00
parent f88f462b5d
commit be7585d856
2 changed files with 9 additions and 3 deletions

View File

@ -158,6 +158,11 @@ async function addInRow(row: TableDataWithIndex<Api.System.Dept>) {
editingData.value = jsonClone(row);
handleAdd();
}
async function handleAddOperate() {
editingData.value = null;
handleAdd();
}
</script>
<template>
@ -170,7 +175,7 @@ async function addInRow(row: TableDataWithIndex<Api.System.Dept>) {
:loading="loading"
:show-add="hasAuth('system:dept:add')"
:show-delete="false"
@add="handleAdd"
@add="handleAddOperate"
@refresh="getData"
>
<template #prefix>

View File

@ -55,7 +55,7 @@ const model: Model = reactive(createDefaultModel());
function createDefaultModel(): Model {
return {
parentId: props.rowData?.deptId,
parentId: '',
deptName: '',
deptCategory: '',
orderNum: null,
@ -80,6 +80,7 @@ const rules: Record<RuleKey, App.Global.FormRule> = {
function handleUpdateModelWhenEdit() {
if (props.operateType === 'add') {
Object.assign(model, createDefaultModel());
model.parentId = props.rowData?.deptId || 0;
}
if (props.operateType === 'edit' && props.rowData) {
@ -185,7 +186,7 @@ watch(visible, () => {
<NDrawer v-model:show="visible" :title="title" display-directive="show" :width="800" class="max-w-90%">
<NDrawerContent :title="title" :native-scrollbar="false" closable>
<NForm ref="formRef" :model="model" :rules="rules">
<NFormItem :label="$t('page.system.dept.parentId')" path="parentId">
<NFormItem v-if="model.parentId != 0" :label="$t('page.system.dept.parentId')" path="parentId">
<NTreeSelect
v-model:value="model.parentId"
:loading="deptLoading"