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

View File

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

View File

@ -9,7 +9,6 @@ import { useVbenDrawer } from '@vben/common-ui';
import { IconifyIcon } from '@vben/icons'; import { IconifyIcon } from '@vben/icons';
import { import {
Button,
Col, Col,
DatePicker, DatePicker,
Form, Form,
@ -123,9 +122,6 @@ const saveConfig = async () => {
const [Drawer, drawerApi] = useVbenDrawer({ const [Drawer, drawerApi] = useVbenDrawer({
title: nodeName.value, title: nodeName.value,
onCancel: () => {
drawerApi.close();
},
onConfirm: saveConfig, onConfirm: saveConfig,
}); });
@ -244,13 +240,6 @@ defineExpose({ openDrawer }); // 暴露方法给父组件
</FormItem> </FormItem>
</Form> </Form>
</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> </Drawer>
</template> </template>
<style lang="scss" scoped></style> <style lang="scss" scoped></style>

View File

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

View File

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

View File

@ -63,9 +63,6 @@ const [Drawer, drawerApi] = useVbenDrawer({
header: true, header: true,
closable: true, closable: true,
title: '', title: '',
onCancel() {
drawerApi.close();
},
onConfirm() { onConfirm() {
saveConfig(); saveConfig();
}, },
@ -678,12 +675,6 @@ onMounted(() => {
</div> </div>
</Form> </Form>
</div> </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> </Drawer>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

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