feat: 节点配置抽屉保持一致

pull/124/head
jason 2025-06-02 23:02:19 +08:00
parent 4a796b7e9b
commit 2a374b216b
7 changed files with 55 additions and 92 deletions

View File

@ -7,7 +7,7 @@ import { useVbenDrawer } from '@vben/common-ui';
import { IconifyIcon } from '@vben/icons';
import { cloneDeep } from '@vben/utils';
import { Button, Input } from 'ant-design-vue';
import { Input } from 'ant-design-vue';
import { ConditionType } from '../../consts';
import {
@ -91,13 +91,8 @@ const saveConfig = async () => {
return true;
};
// 使 useVbenDrawer Drawer
const [Drawer, drawerApi] = useVbenDrawer({
title: currentNode.value.name,
class: 'w-[588px]',
onCancel: () => {
drawerApi.close();
},
onConfirm: saveConfig,
});
@ -152,7 +147,7 @@ const blurEvent = () => {
defineExpose({ open }); // open
</script>
<template>
<Drawer>
<Drawer class="w-[580px]">
<template #title>
<div class="flex items-center">
<Input
@ -185,12 +180,5 @@ defineExpose({ open }); // 提供 open 方法,用于打开弹窗
<Condition ref="conditionRef" v-model:model-value="condition" />
</div>
</div>
<template #footer>
<div class="flex justify-end space-x-2">
<Button type="primary" @click="saveConfig"> </Button>
<Button @click="drawerApi.close"> </Button>
</div>
</template>
</Drawer>
</template>

View File

@ -12,7 +12,6 @@ import { useVbenDrawer } from '@vben/common-ui';
import { IconifyIcon } from '@vben/icons';
import {
Button,
Col,
Form,
FormItem,
@ -44,9 +43,7 @@ import {
useWatchNode,
} from '../../helpers';
defineOptions({
name: 'CopyTaskNodeConfig',
});
defineOptions({ name: 'CopyTaskNodeConfig' });
const props = defineProps({
flowNode: {
type: Object as () => SimpleFlowNode,
@ -67,10 +64,6 @@ const [Drawer, drawerApi] = useVbenDrawer({
header: true,
closable: true,
title: '',
placement: 'right',
onCancel() {
drawerApi.close();
},
onConfirm() {
saveConfig();
},
@ -512,10 +505,6 @@ defineExpose({ showCopyTaskNodeConfig }); // 暴露方法给父组件
</div>
</TabPane>
</Tabs>
<template #footer>
<Button type="primary" @click="saveConfig"> </Button>
<Button @click="drawerApi.close()"> </Button>
</template>
</Drawer>
</template>
<style lang="scss" scoped>

View File

@ -9,7 +9,6 @@ import { useVbenDrawer } from '@vben/common-ui';
import { IconifyIcon } from '@vben/icons';
import {
Button,
Col,
DatePicker,
Form,
@ -123,9 +122,6 @@ const saveConfig = async () => {
const [Drawer, drawerApi] = useVbenDrawer({
title: nodeName.value,
onCancel: () => {
drawerApi.close();
},
onConfirm: saveConfig,
});
@ -244,13 +240,6 @@ defineExpose({ openDrawer }); // 暴露方法给父组件
</FormItem>
</Form>
</div>
<template #footer>
<div class="flex justify-end space-x-2">
<Button type="primary" @click="saveConfig"> </Button>
<Button @click="drawerApi.close"> </Button>
</div>
</template>
</Drawer>
</template>
<style lang="scss" scoped></style>

View File

@ -25,9 +25,7 @@ import { ConditionType, NodeType } from '../../consts';
import { useNodeName, useWatchNode } from '../../helpers';
import Condition from './modules/condition.vue';
defineOptions({
name: 'RouterNodeConfig',
});
defineOptions({ name: 'RouterNodeConfig' });
const props = defineProps({
flowNode: {
type: Object as () => SimpleFlowNode,
@ -36,9 +34,9 @@ const props = defineProps({
});
const processNodeTree = inject<Ref<SimpleFlowNode>>('processNodeTree');
//
/** 当前节点 */
const currentNode = useWatchNode(props);
//
/** 节点名称 */
const { nodeName, showInput, clickIcon, blurEvent } = useNodeName(
NodeType.ROUTER_BRANCH_NODE,
);
@ -47,8 +45,8 @@ const nodeOptions = ref<any[]>([]);
const conditionRef = ref<any[]>([]);
const formRef = ref();
/** 保存配置 */
const saveConfig = async () => {
/** 校验节点配置 */
const validateConfig = async () => {
//
const routeIdValid = await formRef.value.validate().catch(() => false);
if (!routeIdValid) {
@ -64,26 +62,34 @@ const saveConfig = async () => {
}
}
if (!valid) return false;
//
const showText = getShowText();
if (!showText) return false;
return true;
};
/** 保存配置 */
const saveConfig = async () => {
//
if (!(await validateConfig())) {
return false;
}
//
currentNode.value.name = nodeName.value!;
currentNode.value.showText = showText;
currentNode.value.showText = getShowText();
currentNode.value.routerGroups = routerGroups.value;
drawerApi.close();
return true;
};
// 使 useVbenDrawer
const [Drawer, drawerApi] = useVbenDrawer({
title: nodeName.value,
class: 'w-[630px]',
onCancel: () => {
drawerApi.close();
},
onConfirm: saveConfig,
});
//
/** 打开路由节点配置抽屉,由父组件调用 */
const openDrawer = (node: SimpleFlowNode) => {
nodeOptions.value = [];
getRouterNode(processNodeTree?.value);
@ -95,6 +101,7 @@ const openDrawer = (node: SimpleFlowNode) => {
drawerApi.open();
};
/** 获取显示文本 */
const getShowText = () => {
if (
!routerGroups.value ||
@ -130,6 +137,7 @@ const getShowText = () => {
return `${routerGroups.value.length}条路由分支`;
};
/** 添加路由分支 */
const addRouterGroup = () => {
routerGroups.value.push({
nodeId: undefined,
@ -153,11 +161,12 @@ const addRouterGroup = () => {
});
};
/** 删除路由分支 */
const deleteRouterGroup = (index: number) => {
routerGroups.value.splice(index, 1);
};
//
/** 递归获取所有节点 */
const getRouterNode = (node: any) => {
// TODO
//
@ -188,7 +197,7 @@ const getRouterNode = (node: any) => {
defineExpose({ openDrawer }); //
</script>
<template>
<Drawer>
<Drawer class="w-[630px]">
<template #title>
<div class="flex items-center">
<Input
@ -279,12 +288,5 @@ defineExpose({ openDrawer }); // 暴露方法给父组件
</Button>
</Col>
</Row>
<template #footer>
<div class="flex justify-end space-x-2">
<Button type="primary" @click="saveConfig"> </Button>
<Button @click="drawerApi.close"> </Button>
</div>
</template>
</Drawer>
</template>

View File

@ -95,7 +95,7 @@ const [Drawer, drawerApi] = useVbenDrawer({
header: true,
closable: true,
onCancel() {
drawerApi.close();
drawerApi.setState({ isOpen: false });
},
onConfirm() {
saveConfig();
@ -111,7 +111,7 @@ const saveConfig = async () => {
currentNode.value.fieldsPermission = fieldsPermissionConfig.value;
//
currentNode.value.buttonsSetting = START_USER_BUTTON_SETTING;
drawerApi.close();
drawerApi.setState({ isOpen: false });
return true;
};

View File

@ -63,9 +63,6 @@ const [Drawer, drawerApi] = useVbenDrawer({
header: true,
closable: true,
title: '',
onCancel() {
drawerApi.close();
},
onConfirm() {
saveConfig();
},
@ -678,12 +675,6 @@ onMounted(() => {
</div>
</Form>
</div>
<template #footer>
<div class="flex justify-end">
<Button type="primary" @click="saveConfig"> </Button>
<Button class="ml-2" @click="drawerApi.close()"> </Button>
</div>
</template>
</Drawer>
</template>
<style lang="scss" scoped>

View File

@ -102,9 +102,6 @@ const [Drawer, drawerApi] = useVbenDrawer({
header: true,
closable: true,
title: '',
onCancel() {
drawerApi.close();
},
onConfirm() {
saveConfig();
},
@ -212,7 +209,7 @@ const changeCandidateStrategy = () => {
configForm.value.approveMethod = ApproveMethodType.SEQUENTIAL_APPROVE;
};
//
/** 审批方式改变 */
const approveMethodChanged = () => {
configForm.value.rejectHandlerType = RejectHandlerType.FINISH_PROCESS;
if (configForm.value.approveMethod === ApproveMethodType.APPROVE_BY_RATIO) {
@ -240,18 +237,8 @@ const nodeTypeName = computed(() => {
return currentNode.value.type === NodeType.TRANSACTOR_NODE ? '办理' : '审批';
});
/** 保存配置 */
const saveConfig = async () => {
//
currentNode.value.name = nodeName.value!;
//
currentNode.value.approveType = approveType.value;
//
if (approveType.value !== ApproveType.USER) {
currentNode.value.showText = getApproveTypeText(approveType.value);
drawerApi.close();
return true;
}
/** 校验节点配置 */
const validateConfig = async () => {
if (!formRef.value) return false;
if (!userTaskListenerRef.value) return false;
@ -274,6 +261,27 @@ const saveConfig = async () => {
const showText = getShowText();
if (!showText) return false;
return true;
};
/** 保存配置 */
const saveConfig = async () => {
//
if (approveType.value !== ApproveType.USER) {
currentNode.value.name = nodeName.value!;
currentNode.value.approveType = approveType.value;
currentNode.value.showText = getApproveTypeText(approveType.value);
drawerApi.close();
return true;
}
//
if (!(await validateConfig())) {
return false;
}
//
currentNode.value.name = nodeName.value!;
//
currentNode.value.approveType = approveType.value;
//
currentNode.value.candidateStrategy = configForm.value.candidateStrategy;
// candidateParam
currentNode.value.candidateParam = handleCandidateParam();
@ -336,7 +344,7 @@ const saveConfig = async () => {
//
currentNode.value.reasonRequire = configForm.value.reasonRequire;
currentNode.value.showText = showText;
currentNode.value.showText = getShowText();
drawerApi.close();
return true;
};
@ -1206,10 +1214,6 @@ onMounted(() => {
/>
</TabPane>
</Tabs>
<template #footer>
<Button type="primary" @click="saveConfig"> </Button>
<Button @click="drawerApi.close()"> </Button>
</template>
</Drawer>
</template>
<style lang="scss" scoped>