mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
feat: 对接工作流分类模块
This commit is contained in:
@ -212,6 +212,8 @@ const local: App.I18n.Schema = {
|
|||||||
demo: 'Demo',
|
demo: 'Demo',
|
||||||
demo_demo: 'Demo Table',
|
demo_demo: 'Demo Table',
|
||||||
demo_tree: 'Demo Tree',
|
demo_tree: 'Demo Tree',
|
||||||
|
workflow: 'Workflow',
|
||||||
|
workflow_category: 'Workflow Category',
|
||||||
exception: 'Exception',
|
exception: 'Exception',
|
||||||
exception_403: '403',
|
exception_403: '403',
|
||||||
exception_404: '404',
|
exception_404: '404',
|
||||||
|
@ -212,6 +212,8 @@ const local: App.I18n.Schema = {
|
|||||||
demo: '测试',
|
demo: '测试',
|
||||||
demo_demo: '测试单表',
|
demo_demo: '测试单表',
|
||||||
demo_tree: '测试树表',
|
demo_tree: '测试树表',
|
||||||
|
workflow: '流程管理',
|
||||||
|
workflow_category: '流程分类',
|
||||||
exception: '异常页',
|
exception: '异常页',
|
||||||
exception_403: '403',
|
exception_403: '403',
|
||||||
exception_404: '404',
|
exception_404: '404',
|
||||||
|
@ -43,4 +43,5 @@ export const views: Record<LastLevelRouteKey, RouteComponent | (() => Promise<Ro
|
|||||||
system_tenant: () => import("@/views/system/tenant/index.vue"),
|
system_tenant: () => import("@/views/system/tenant/index.vue"),
|
||||||
system_user: () => import("@/views/system/user/index.vue"),
|
system_user: () => import("@/views/system/user/index.vue"),
|
||||||
tool_gen: () => import("@/views/tool/gen/index.vue"),
|
tool_gen: () => import("@/views/tool/gen/index.vue"),
|
||||||
|
workflow_category: () => import("@/views/workflow/category/index.vue"),
|
||||||
};
|
};
|
||||||
|
@ -331,5 +331,25 @@ export const generatedRoutes: GeneratedRoute[] = [
|
|||||||
icon: 'material-symbols:account-circle-full',
|
icon: 'material-symbols:account-circle-full',
|
||||||
hideInMenu: true
|
hideInMenu: true
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'workflow',
|
||||||
|
path: '/workflow',
|
||||||
|
component: 'layout.base',
|
||||||
|
meta: {
|
||||||
|
title: 'workflow',
|
||||||
|
i18nKey: 'route.workflow'
|
||||||
|
},
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
name: 'workflow_category',
|
||||||
|
path: '/workflow/category',
|
||||||
|
component: 'view.workflow_category',
|
||||||
|
meta: {
|
||||||
|
title: 'workflow_category',
|
||||||
|
i18nKey: 'route.workflow_category'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -198,7 +198,9 @@ const routeMap: RouteMap = {
|
|||||||
"system_user": "/system/user",
|
"system_user": "/system/user",
|
||||||
"tool": "/tool",
|
"tool": "/tool",
|
||||||
"tool_gen": "/tool/gen",
|
"tool_gen": "/tool/gen",
|
||||||
"user-center": "/user-center"
|
"user-center": "/user-center",
|
||||||
|
"workflow": "/workflow",
|
||||||
|
"workflow_category": "/workflow/category"
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
45
src/service/api/workflow/category.ts
Normal file
45
src/service/api/workflow/category.ts
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
import { request } from '@/service/request';
|
||||||
|
|
||||||
|
/** 获取测试树列表 */
|
||||||
|
export function fetchGetCategoryList(params?: Api.Workflow.WorkflowCategorySearchParams) {
|
||||||
|
return request<Api.Workflow.WorkflowCategoryList>({
|
||||||
|
url: '/workflow/category/list',
|
||||||
|
method: 'get',
|
||||||
|
params
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增测试树 */
|
||||||
|
export function fetchCreateCategory(data: Api.Workflow.WorkflowCategoryOperateParams) {
|
||||||
|
return request<boolean>({
|
||||||
|
url: '/workflow/category',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 修改测试树 */
|
||||||
|
export function fetchUpdateCategory(data: Api.Workflow.WorkflowCategoryOperateParams) {
|
||||||
|
return request<boolean>({
|
||||||
|
url: '/workflow/category',
|
||||||
|
method: 'put',
|
||||||
|
data
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除分类 */
|
||||||
|
export function fetchDeleteCategory(id: CommonType.IdType) {
|
||||||
|
return request<boolean>({
|
||||||
|
url: `/workflow/category/${id}`,
|
||||||
|
method: 'delete'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出工作流分类 */
|
||||||
|
export function fetchExportCategory(params?: Api.Workflow.WorkflowCategorySearchParams) {
|
||||||
|
return request<boolean>({
|
||||||
|
url: '/workflow/category/export',
|
||||||
|
method: 'post',
|
||||||
|
params
|
||||||
|
});
|
||||||
|
}
|
1
src/service/api/workflow/index.ts
Normal file
1
src/service/api/workflow/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export * from './category';
|
44
src/typings/api/workflow.api.d.ts
vendored
Normal file
44
src/typings/api/workflow.api.d.ts
vendored
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/**
|
||||||
|
* Namespace Api
|
||||||
|
*
|
||||||
|
* All backend api type
|
||||||
|
*/
|
||||||
|
declare namespace Api {
|
||||||
|
/**
|
||||||
|
* namespace Workflow
|
||||||
|
*
|
||||||
|
* backend api module: "Workflow"
|
||||||
|
*/
|
||||||
|
namespace Workflow {
|
||||||
|
/** 工作流分类 */
|
||||||
|
type WorkflowCategory = Common.CommonRecord<{
|
||||||
|
/** 主键 */
|
||||||
|
categoryId: CommonType.IdType;
|
||||||
|
/** 租户编号 */
|
||||||
|
tenantId: CommonType.IdType;
|
||||||
|
/** 分类名称 */
|
||||||
|
categoryName: string;
|
||||||
|
/** 父级ID */
|
||||||
|
parentId: CommonType.IdType;
|
||||||
|
/** 祖级列表 */
|
||||||
|
ancestors: string;
|
||||||
|
/** 排序号 */
|
||||||
|
orderNum: number;
|
||||||
|
/** 删除标志 */
|
||||||
|
delFlag: number;
|
||||||
|
}>;
|
||||||
|
|
||||||
|
/** 工作流分类搜索参数 */
|
||||||
|
type WorkflowCategorySearchParams = CommonType.RecordNullable<
|
||||||
|
Pick<WorkflowCategory, 'categoryName'> & Api.Common.CommonSearchParams
|
||||||
|
>;
|
||||||
|
|
||||||
|
/** 工作流分类操作参数 */
|
||||||
|
type WorkflowCategoryOperateParams = CommonType.RecordNullable<
|
||||||
|
Pick<WorkflowCategory, 'categoryId' | 'categoryName' | 'parentId' | 'orderNum'>
|
||||||
|
>;
|
||||||
|
|
||||||
|
/** 工作流分类列表 */
|
||||||
|
type WorkflowCategoryList = WorkflowCategory[];
|
||||||
|
}
|
||||||
|
}
|
4
src/typings/elegant-router.d.ts
vendored
4
src/typings/elegant-router.d.ts
vendored
@ -53,6 +53,8 @@ declare module "@elegant-router/types" {
|
|||||||
"tool": "/tool";
|
"tool": "/tool";
|
||||||
"tool_gen": "/tool/gen";
|
"tool_gen": "/tool/gen";
|
||||||
"user-center": "/user-center";
|
"user-center": "/user-center";
|
||||||
|
"workflow": "/workflow";
|
||||||
|
"workflow_category": "/workflow/category";
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -100,6 +102,7 @@ declare module "@elegant-router/types" {
|
|||||||
| "system"
|
| "system"
|
||||||
| "tool"
|
| "tool"
|
||||||
| "user-center"
|
| "user-center"
|
||||||
|
| "workflow"
|
||||||
>;
|
>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -145,6 +148,7 @@ declare module "@elegant-router/types" {
|
|||||||
| "system_tenant"
|
| "system_tenant"
|
||||||
| "system_user"
|
| "system_user"
|
||||||
| "tool_gen"
|
| "tool_gen"
|
||||||
|
| "workflow_category"
|
||||||
>;
|
>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -194,10 +194,10 @@ async function addInRow(row: TableDataWithIndex<Api.System.Dept>) {
|
|||||||
:columns="columns"
|
:columns="columns"
|
||||||
:data="data"
|
:data="data"
|
||||||
size="small"
|
size="small"
|
||||||
|
:indent="32"
|
||||||
:flex-height="!appStore.isMobile"
|
:flex-height="!appStore.isMobile"
|
||||||
:scroll-x="962"
|
:scroll-x="962"
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
:indent="28"
|
|
||||||
:row-key="row => row.deptId"
|
:row-key="row => row.deptId"
|
||||||
class="sm:h-full"
|
class="sm:h-full"
|
||||||
/>
|
/>
|
||||||
|
207
src/views/workflow/category/index.vue
Normal file
207
src/views/workflow/category/index.vue
Normal file
@ -0,0 +1,207 @@
|
|||||||
|
<script setup lang="tsx">
|
||||||
|
import { NDivider } from 'naive-ui';
|
||||||
|
import { jsonClone } from '@sa/utils';
|
||||||
|
import { type TableDataWithIndex } from '@sa/hooks';
|
||||||
|
import { fetchDeleteCategory, fetchGetCategoryList } from '@/service/api/workflow';
|
||||||
|
import { useAppStore } from '@/store/modules/app';
|
||||||
|
import { useAuth } from '@/hooks/business/auth';
|
||||||
|
import { useTreeTable, useTreeTableOperate } from '@/hooks/common/tree-table';
|
||||||
|
import { useDownload } from '@/hooks/business/download';
|
||||||
|
import { $t } from '@/locales';
|
||||||
|
import ButtonIcon from '@/components/custom/button-icon.vue';
|
||||||
|
import WorkflowCategoryOperateDrawer from './modules/category-operate-drawer.vue';
|
||||||
|
import WorkflowCategorySearch from './modules/category-search.vue';
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
name: 'WorkflowCategoryList'
|
||||||
|
});
|
||||||
|
|
||||||
|
const appStore = useAppStore();
|
||||||
|
const { download } = useDownload();
|
||||||
|
const { hasAuth } = useAuth();
|
||||||
|
|
||||||
|
const {
|
||||||
|
columns,
|
||||||
|
columnChecks,
|
||||||
|
data,
|
||||||
|
getData,
|
||||||
|
loading,
|
||||||
|
searchParams,
|
||||||
|
resetSearchParams,
|
||||||
|
expandedRowKeys,
|
||||||
|
isCollapse,
|
||||||
|
expandAll,
|
||||||
|
collapseAll
|
||||||
|
} = useTreeTable({
|
||||||
|
apiFn: fetchGetCategoryList,
|
||||||
|
apiParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
// if you want to use the searchParams in Form, you need to define the following properties, and the value is null
|
||||||
|
// the value can not be undefined, otherwise the property in Form will not be reactive
|
||||||
|
categoryName: null
|
||||||
|
},
|
||||||
|
idField: 'categoryId',
|
||||||
|
columns: () => [
|
||||||
|
{
|
||||||
|
key: 'categoryName',
|
||||||
|
title: '分类名称',
|
||||||
|
align: 'center',
|
||||||
|
minWidth: 120
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'orderNum',
|
||||||
|
title: '显示顺序',
|
||||||
|
align: 'center',
|
||||||
|
minWidth: 120
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'createTime',
|
||||||
|
title: '创建时间',
|
||||||
|
align: 'center',
|
||||||
|
minWidth: 120
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'operate',
|
||||||
|
title: $t('common.operate'),
|
||||||
|
align: 'center',
|
||||||
|
width: 130,
|
||||||
|
render: row => {
|
||||||
|
const addBtn = () => {
|
||||||
|
return (
|
||||||
|
<ButtonIcon
|
||||||
|
text
|
||||||
|
type="primary"
|
||||||
|
icon="material-symbols:add-2-rounded"
|
||||||
|
tooltipContent={$t('common.add')}
|
||||||
|
onClick={() => addInRow(row)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const editBtn = () => {
|
||||||
|
return (
|
||||||
|
<ButtonIcon
|
||||||
|
text
|
||||||
|
type="primary"
|
||||||
|
icon="material-symbols:drive-file-rename-outline-outline"
|
||||||
|
tooltipContent={$t('common.edit')}
|
||||||
|
onClick={() => edit(row)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const deleteBtn = () => {
|
||||||
|
return (
|
||||||
|
<ButtonIcon
|
||||||
|
text
|
||||||
|
type="error"
|
||||||
|
icon="material-symbols:delete-outline"
|
||||||
|
tooltipContent={$t('common.delete')}
|
||||||
|
popconfirmContent={$t('common.confirmDelete')}
|
||||||
|
onPositiveClick={() => handleDelete(row.categoryId!)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const buttons = [];
|
||||||
|
if (hasAuth('workflow:category:add')) buttons.push(addBtn());
|
||||||
|
if (hasAuth('workflow:category:edit')) buttons.push(editBtn());
|
||||||
|
if (hasAuth('workflow:category:remove')) buttons.push(deleteBtn());
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div class="flex-center gap-8px">
|
||||||
|
{buttons.map((btn, index) => (
|
||||||
|
<>
|
||||||
|
{index !== 0 && <NDivider vertical />}
|
||||||
|
{btn}
|
||||||
|
</>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
const { drawerVisible, operateType, editingData, handleAdd, handleEdit, checkedRowKeys, onDeleted } =
|
||||||
|
useTreeTableOperate(data, getData);
|
||||||
|
|
||||||
|
async function handleDelete(id: CommonType.IdType) {
|
||||||
|
// request
|
||||||
|
const { error } = await fetchDeleteCategory(id);
|
||||||
|
if (error) return;
|
||||||
|
onDeleted();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function edit(row: TableDataWithIndex<Api.Workflow.WorkflowCategory>) {
|
||||||
|
handleEdit(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
function addInRow(row: TableDataWithIndex<Api.Workflow.WorkflowCategory>) {
|
||||||
|
editingData.value = jsonClone(row);
|
||||||
|
handleAdd();
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleExport() {
|
||||||
|
download('/workflow/category/export', searchParams, `流程分类_#[[${new Date().getTime()}]]#.xlsx`);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="min-h-500px flex-col-stretch gap-16px overflow-hidden lt-sm:overflow-auto">
|
||||||
|
<WorkflowCategorySearch v-model:model="searchParams" @reset="resetSearchParams" @search="getData" />
|
||||||
|
<NCard title="流程分类列表" :bordered="false" size="small" class="sm:flex-1-hidden card-wrapper">
|
||||||
|
<template #header-extra>
|
||||||
|
<TableHeaderOperation
|
||||||
|
v-model:columns="columnChecks"
|
||||||
|
:loading="loading"
|
||||||
|
:show-add="hasAuth('workflow:category:add')"
|
||||||
|
:show-delete="false"
|
||||||
|
:show-export="false"
|
||||||
|
@add="handleAdd"
|
||||||
|
@export="handleExport"
|
||||||
|
@refresh="getData"
|
||||||
|
>
|
||||||
|
<template #prefix>
|
||||||
|
<NButton v-if="!isCollapse" :disabled="!data.length" size="small" @click="expandAll">
|
||||||
|
<template #icon>
|
||||||
|
<icon-quill:expand />
|
||||||
|
</template>
|
||||||
|
全部展开
|
||||||
|
</NButton>
|
||||||
|
<NButton v-if="isCollapse" :disabled="!data.length" size="small" @click="collapseAll">
|
||||||
|
<template #icon>
|
||||||
|
<icon-quill:collapse />
|
||||||
|
</template>
|
||||||
|
全部收起
|
||||||
|
</NButton>
|
||||||
|
</template>
|
||||||
|
</TableHeaderOperation>
|
||||||
|
</template>
|
||||||
|
<NDataTable
|
||||||
|
v-model:checked-row-keys="checkedRowKeys"
|
||||||
|
v-model:expanded-row-keys="expandedRowKeys"
|
||||||
|
:columns="columns"
|
||||||
|
:data="data"
|
||||||
|
size="small"
|
||||||
|
:indent="32"
|
||||||
|
:flex-height="!appStore.isMobile"
|
||||||
|
:scroll-x="962"
|
||||||
|
:loading="loading"
|
||||||
|
remote
|
||||||
|
:row-key="row => row.categoryId"
|
||||||
|
class="sm:h-full"
|
||||||
|
/>
|
||||||
|
<WorkflowCategoryOperateDrawer
|
||||||
|
v-model:visible="drawerVisible"
|
||||||
|
:operate-type="operateType"
|
||||||
|
:row-data="editingData"
|
||||||
|
:category-tree-list="data"
|
||||||
|
@submitted="getData"
|
||||||
|
/>
|
||||||
|
</NCard>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped></style>
|
139
src/views/workflow/category/modules/category-operate-drawer.vue
Normal file
139
src/views/workflow/category/modules/category-operate-drawer.vue
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { computed, reactive, watch } from 'vue';
|
||||||
|
import { fetchCreateCategory, fetchUpdateCategory } from '@/service/api/workflow';
|
||||||
|
import { useFormRules, useNaiveForm } from '@/hooks/common/form';
|
||||||
|
import { $t } from '@/locales';
|
||||||
|
defineOptions({
|
||||||
|
name: 'WorkflowCategoryOperateDrawer'
|
||||||
|
});
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
/** the type of operation */
|
||||||
|
operateType: NaiveUI.TableOperateType;
|
||||||
|
/** the edit row data */
|
||||||
|
rowData?: Api.Workflow.WorkflowCategory | null;
|
||||||
|
/** the category data */
|
||||||
|
categoryTreeList?: Api.Workflow.WorkflowCategory[] | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = defineProps<Props>();
|
||||||
|
|
||||||
|
interface Emits {
|
||||||
|
(e: 'submitted'): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const emit = defineEmits<Emits>();
|
||||||
|
|
||||||
|
const visible = defineModel<boolean>('visible', {
|
||||||
|
default: false
|
||||||
|
});
|
||||||
|
|
||||||
|
const { formRef, validate, restoreValidation } = useNaiveForm();
|
||||||
|
const { createRequiredRule } = useFormRules();
|
||||||
|
|
||||||
|
const title = computed(() => {
|
||||||
|
const titles: Record<NaiveUI.TableOperateType, string> = {
|
||||||
|
add: '新增测试树',
|
||||||
|
edit: '编辑测试树'
|
||||||
|
};
|
||||||
|
return titles[props.operateType];
|
||||||
|
});
|
||||||
|
|
||||||
|
type Model = Api.Workflow.WorkflowCategoryOperateParams;
|
||||||
|
|
||||||
|
const model: Model = reactive(createDefaultModel());
|
||||||
|
|
||||||
|
function createDefaultModel(): Model {
|
||||||
|
return {
|
||||||
|
parentId: null,
|
||||||
|
categoryName: '',
|
||||||
|
orderNum: 0
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
type RuleKey = Extract<keyof Model, 'categoryId' | 'parentId' | 'categoryName'>;
|
||||||
|
|
||||||
|
const rules: Record<RuleKey, App.Global.FormRule> = {
|
||||||
|
categoryId: createRequiredRule('主键不能为空'),
|
||||||
|
parentId: createRequiredRule('上级分类不能为空'),
|
||||||
|
categoryName: createRequiredRule('分类名称不能为空')
|
||||||
|
};
|
||||||
|
|
||||||
|
function handleUpdateModelWhenEdit() {
|
||||||
|
if (props.operateType === 'add') {
|
||||||
|
Object.assign(model, createDefaultModel());
|
||||||
|
model.parentId = props.rowData?.categoryId || 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (props.operateType === 'edit' && props.rowData) {
|
||||||
|
Object.assign(model, props.rowData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeDrawer() {
|
||||||
|
visible.value = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleSubmit() {
|
||||||
|
await validate();
|
||||||
|
|
||||||
|
// request
|
||||||
|
if (props.operateType === 'add') {
|
||||||
|
const { parentId, categoryName, orderNum } = model;
|
||||||
|
const { error } = await fetchCreateCategory({ parentId, categoryName, orderNum });
|
||||||
|
if (error) return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (props.operateType === 'edit') {
|
||||||
|
const { categoryId, parentId, categoryName, orderNum } = model;
|
||||||
|
const { error } = await fetchUpdateCategory({ categoryId, parentId, categoryName, orderNum });
|
||||||
|
if (error) return;
|
||||||
|
}
|
||||||
|
|
||||||
|
window.$message?.success($t('common.updateSuccess'));
|
||||||
|
closeDrawer();
|
||||||
|
emit('submitted');
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(visible, () => {
|
||||||
|
if (visible.value) {
|
||||||
|
handleUpdateModelWhenEdit();
|
||||||
|
restoreValidation();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<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="上级分类" path="parentId">
|
||||||
|
<NTreeSelect
|
||||||
|
v-model:value="model.parentId"
|
||||||
|
filterable
|
||||||
|
class="h-full"
|
||||||
|
key-field="categoryId"
|
||||||
|
label-field="categoryName"
|
||||||
|
:options="categoryTreeList!"
|
||||||
|
:default-expanded-keys="[0]"
|
||||||
|
/>
|
||||||
|
</NFormItem>
|
||||||
|
<NFormItem label="分类名称" path="categoryName">
|
||||||
|
<NInput v-model:value="model.categoryName" placeholder="请输入分类名称" />
|
||||||
|
</NFormItem>
|
||||||
|
<NFormItem label="排序" path="orderNum">
|
||||||
|
<NInputNumber v-model:value="model.orderNum" placeholder="请输入排序" />
|
||||||
|
</NFormItem>
|
||||||
|
</NForm>
|
||||||
|
<template #footer>
|
||||||
|
<NSpace :size="16">
|
||||||
|
<NButton @click="closeDrawer">{{ $t('common.cancel') }}</NButton>
|
||||||
|
<NButton type="primary" @click="handleSubmit">{{ $t('common.confirm') }}</NButton>
|
||||||
|
</NSpace>
|
||||||
|
</template>
|
||||||
|
</NDrawerContent>
|
||||||
|
</NDrawer>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped></style>
|
63
src/views/workflow/category/modules/category-search.vue
Normal file
63
src/views/workflow/category/modules/category-search.vue
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { useNaiveForm } from '@/hooks/common/form';
|
||||||
|
import { $t } from '@/locales';
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
name: 'WorkflowCategorySearch'
|
||||||
|
});
|
||||||
|
|
||||||
|
interface Emits {
|
||||||
|
(e: 'reset'): void;
|
||||||
|
(e: 'search'): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const emit = defineEmits<Emits>();
|
||||||
|
|
||||||
|
const { formRef, validate, restoreValidation } = useNaiveForm();
|
||||||
|
|
||||||
|
const model = defineModel<Api.Workflow.WorkflowCategorySearchParams>('model', { required: true });
|
||||||
|
|
||||||
|
async function reset() {
|
||||||
|
await restoreValidation();
|
||||||
|
emit('reset');
|
||||||
|
}
|
||||||
|
|
||||||
|
async function search() {
|
||||||
|
await validate();
|
||||||
|
emit('search');
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<NCard :bordered="false" size="small" class="card-wrapper">
|
||||||
|
<NCollapse>
|
||||||
|
<NCollapseItem :title="$t('common.search')" name="user-search">
|
||||||
|
<NForm ref="formRef" :model="model" label-placement="left" :label-width="80">
|
||||||
|
<NGrid responsive="screen" item-responsive>
|
||||||
|
<NFormItemGi span="24 s:12 m:6" label="分类名称" path="categoryName" class="pr-24px">
|
||||||
|
<NInput v-model:value="model.categoryName" placeholder="请输入分类名称" />
|
||||||
|
</NFormItemGi>
|
||||||
|
<NFormItemGi :show-feedback="false" span="24" class="pr-24px">
|
||||||
|
<NSpace class="w-full" justify="end">
|
||||||
|
<NButton @click="reset">
|
||||||
|
<template #icon>
|
||||||
|
<icon-ic-round-refresh class="text-icon" />
|
||||||
|
</template>
|
||||||
|
{{ $t('common.reset') }}
|
||||||
|
</NButton>
|
||||||
|
<NButton type="primary" ghost @click="search">
|
||||||
|
<template #icon>
|
||||||
|
<icon-ic-round-search class="text-icon" />
|
||||||
|
</template>
|
||||||
|
{{ $t('common.search') }}
|
||||||
|
</NButton>
|
||||||
|
</NSpace>
|
||||||
|
</NFormItemGi>
|
||||||
|
</NGrid>
|
||||||
|
</NForm>
|
||||||
|
</NCollapseItem>
|
||||||
|
</NCollapse>
|
||||||
|
</NCard>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped></style>
|
Reference in New Issue
Block a user