This commit is contained in:
AN
2025-05-28 11:25:26 +08:00
4 changed files with 13 additions and 7 deletions

View File

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

View File

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

View File

@ -143,7 +143,7 @@ async function addInRow(row: TableDataWithIndex<Api.Workflow.WorkflowCategory>)
handleAdd(); handleAdd();
} }
async function handleAddDataOperate() { async function handleAddOperate() {
editingData.value = null; editingData.value = null;
handleAdd(); handleAdd();
} }
@ -163,7 +163,7 @@ function handleExport() {
:show-add="hasAuth('workflow:category:add')" :show-add="hasAuth('workflow:category:add')"
:show-delete="false" :show-delete="false"
:show-export="false" :show-export="false"
@add="handleAddDataOperate" @add="handleAddOperate"
@export="handleExport" @export="handleExport"
@refresh="getData" @refresh="getData"
> >

View File

@ -43,7 +43,7 @@ const model: Model = reactive(createDefaultModel());
function createDefaultModel(): Model { function createDefaultModel(): Model {
return { return {
parentId: props.rowData?.categoryId, parentId: '',
categoryName: '', categoryName: '',
orderNum: 0 orderNum: 0
}; };
@ -60,7 +60,7 @@ const rules: Record<RuleKey, App.Global.FormRule> = {
function handleUpdateModelWhenEdit() { function handleUpdateModelWhenEdit() {
if (props.operateType === 'add') { if (props.operateType === 'add') {
Object.assign(model, createDefaultModel()); Object.assign(model, createDefaultModel());
return; model.parentId = props.rowData?.categoryId || 0;
} }
if (props.operateType === 'edit' && props.rowData) { if (props.operateType === 'edit' && props.rowData) {