feat(@vben/web-antd): 关联部门功能

- 修改工作流数据,将'update'操作改为'edit'操作
- 实现关联部门功能,添加linkWorkflow API
- 调整工作流列表展示顺序
This commit is contained in:
Kven 2025-06-19 16:39:47 +08:00
parent 3781e6cd47
commit 6910bd28cc
5 changed files with 27 additions and 12 deletions

View File

@ -26,6 +26,10 @@ export namespace WorkflowApi {
keyword?: string; keyword?: string;
workflowRunId?: string; workflowRunId?: string;
} }
export interface WorkflowLinkParams {
workflowId: string;
deptIds: string[];
}
} }
// 工作流 // 工作流
@ -49,3 +53,7 @@ export function getWorkflowList(params: WorkflowApi.WorkflowLogParams) {
params, params,
}); });
} }
export function linkWorkflow(data: WorkflowApi.WorkflowLinkParams) {
return requestClient.post(`/v1/server/link`, data);
}

View File

@ -22,10 +22,12 @@ const itemMessage = ref<ResultItem[]>([]);
const getLogs = async (appid: string, limit: number) => { const getLogs = async (appid: string, limit: number) => {
loading.value = true; loading.value = true;
hitsory.value = await getWorkflowList({ const res = await getWorkflowList({
appid, appid,
limit, limit,
}); });
// hitsory
hitsory.value = res.reverse();
loading.value = false; loading.value = false;
}; };

View File

@ -68,9 +68,9 @@ export function useColumns(
}, },
options: [ options: [
{ {
code: 'update', code: 'edit',
text: '关联部门', text: '关联部门',
permission: 'workflow:update', // permission: 'workflow:update',
}, },
], ],
}, },

View File

@ -8,12 +8,12 @@ import { ref } from 'vue';
import { useVbenModal, VbenTree } from '@vben/common-ui'; import { useVbenModal, VbenTree } from '@vben/common-ui';
import { useVbenForm } from '#/adapter/form'; import { useVbenForm } from '#/adapter/form';
import { getAllDeptTree } from '#/api'; import { getAllDeptTree, linkWorkflow } from '#/api';
import { useFormSchema } from '../data'; import { useFormSchema } from '../data';
const emits = defineEmits(['success']); const emits = defineEmits(['success']);
const formData = ref<string[]>([]); const workflowId = ref();
const deptData = ref<DataNode[]>([]); const deptData = ref<DataNode[]>([]);
function convertToTreeNode(item: any): DataNode { function convertToTreeNode(item: any): DataNode {
@ -30,18 +30,22 @@ async function getDeptList() {
deptData.value = res.map((item) => convertToTreeNode(item)); deptData.value = res.map((item) => convertToTreeNode(item));
} }
const [Form] = useVbenForm({ const [Form, formApi] = useVbenForm({
schema: useFormSchema(), schema: useFormSchema(),
showDefaultActions: false, showDefaultActions: false,
}); });
const [Modal, modalApi] = useVbenModal({ const [Modal, modalApi] = useVbenModal({
async onConfirm() { async onConfirm() {
// const values = await formApi.getValues(); // const values = await formApi;
if (!formData.value) return; if (!formApi.form.values.deptIds) return;
const deptIds = formApi.form.values.deptIds;
modalApi.lock(); modalApi.lock();
try { try {
await linkWorkflow({
workflowId: workflowId.value,
deptIds,
});
emits('success'); emits('success');
modalApi.close(); modalApi.close();
} finally { } finally {
@ -50,6 +54,7 @@ const [Modal, modalApi] = useVbenModal({
}, },
async onOpenChange(isOpen) { async onOpenChange(isOpen) {
if (isOpen) { if (isOpen) {
workflowId.value = modalApi.getData().id;
await getDeptList(); await getDeptList();
} }
}, },
@ -69,7 +74,7 @@ function getNodeClass(node: Recordable<any>) {
</script> </script>
<template> <template>
<Modal title="修改工作流"> <Modal title="关联部门">
<Form class="mx-4"> <Form class="mx-4">
<template #deptIds="slotProps"> <template #deptIds="slotProps">
<VbenTree <VbenTree

View File

@ -11,8 +11,8 @@ export default defineConfig(async () => {
rewrite: (path) => path.replace(/^\/api/, ''), rewrite: (path) => path.replace(/^\/api/, ''),
// mock代理目标地址 // mock代理目标地址
// target: 'http://172.16.35.190:9090/api', // target: 'http://172.16.35.190:9090/api',
// target: 'http://43.139.10.64:8082/api', target: 'http://43.139.10.64:8082/api',
target: 'http://localhost:8081/api', // target: 'http://localhost:8081/api',
// target: 'http://192.168.3.238:8081/api', // target: 'http://192.168.3.238:8081/api',
ws: true, ws: true,
}, },