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);
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"

View File

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

View File

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