Browse Source

chore: compose task

master
wangxiang 2 years ago
parent
commit
5d431caad1
No known key found for this signature in database
GPG Key ID: 1BA7946AB6B232E4
  1. 17
      src/api/platform/workflow/extension/entity/workflowButton.ts
  2. 161
      src/views/workflow/task/TaskForm.vue

17
src/api/platform/workflow/extension/entity/workflowButton.ts

@ -0,0 +1,17 @@
import type { R } from '/#/axios';
import type { Page } from '/@/api/common/data/entity';
export type WorkflowButtonParams = Page & WorkflowButton;
export interface WorkflowButton {
id: string;
name: string;
code: string;
isHide: string;
next: string;
sort: number;
activityExtensionDataId: string;
[key:string]: any;
}
export type WorkflowButtonResult = R<WorkflowButton[]>;

161
src/views/workflow/task/TaskForm.vue

@ -1,6 +1,6 @@
<template> <template>
<LayoutContent style="min-height: 100vh"> <LayoutContent style="min-height: 100vh">
<h4 style="text-align:center">{{formTitle}}</h4> <h4 style="text-align:center">{{ state.formTitle }}</h4>
</LayoutContent> </LayoutContent>
</template> </template>
@ -11,15 +11,11 @@
* Copyright © 2023-2023 <a href="https://godolphinx.org">海豚生态开源社区</a> All rights reserved. * Copyright © 2023-2023 <a href="https://godolphinx.org">海豚生态开源社区</a> All rights reserved.
* author wangxiang4 * author wangxiang4
*/ */
import { ref, unref,reactive, toRaw } from 'vue'; import { reactive, onActivated } from 'vue';
import { LayoutContent } from 'ant-design-vue'; import { LayoutContent } from 'ant-design-vue';
import {TreeItem} from '/@/components/Tree'; import type { FormProperty } from '/@/api/platform/workflow/entity/formProperty';
import {useForm} from '/@/components/Form'; import type { Workflow } from '/@/api/platform/workflow/entity/workflow';
import {formSchema} from '/@/views/system/role/role.data'; import type { WorkflowButton } from '/@/api/platform/workflow/extension/entity/workflowButton';
import {DrawerProps, useDrawerInner} from '/@/components/Drawer';
import {listToTree} from '/@/utils/helper/treeHelper';
import {getRoleMenuIds, listMenu} from '/@/api/platform/system/controller/menu';
import {addRole, editRole, getRole} from '/@/api/platform/system/controller/role';
/** 类型规范统一声明定义区域 */ /** 类型规范统一声明定义区域 */
interface WindowState { interface WindowState {
@ -30,132 +26,81 @@
// (1:,2:) // (1:,2:)
formType: string; formType: string;
// //
formPath: ''; formPath: string;
// //
formReadOnly: false; formReadOnly: false,
// ID // ID
businessId: ''; businessId: string,
// //
taskFormData: [], taskFormData: FormProperty[],
// //
taskSelectedTab: 'formInfo', taskSelectedTab: string,
// ID // ID
taskId: '', taskId: string,
// key // key
taskDefKey: '', taskDefKey: string,
// ID // ID
processDefId: '', processDefId: string,
// ID // ID
processInsId: '', processInsId: string,
// Key // Key
processDefKey: '', processDefKey: string,
// //
status: '', status: string,
// //
historyFlowChangeList: [], historyFlowChangeList: Workflow[],
// //
buttons: [], buttons: WorkflowButton[],
// //
isCC: false, isCC: boolean,
// //
isAssign: false, isAssign: boolean,
//
printInfo: {
id: 'printForm',
popTitle: '',
extraCss: '',
extraHead: '<meta http-equiv="Content-Language" content="zh-cn"/>'
},
// //
auditForm: { auditForm: {
message: '', message: string,
mesCode: '', mesCode: string,
mesName: '', mesName: string,
// ID // ID
userIds: '', userIds: string,
// ID // ID
assignee: '' assignee: string,
} },
} }
/** 通用变量统一声明区域 */ /** 通用变量统一声明区域 */
const state = reactive<WindowState>({ const state = reactive<WindowState>({
// formTitle: '',
tag: '', formKey: '',
// formType: '',
menuTree: [], formPath: '',
// formReadOnly: false,
checkedKeys: {}, businessId: '',
}); taskFormData: [],
/** https://v3.cn.vuejs.org/api/options-data.html#emits */
const emit = defineEmits(['success', 'register']);
const [registerForm, { resetFields, setFieldsValue, validate, clearValidate }] = useForm({
labelWidth: 100,
schemas: formSchema,
showActionButtonGroup: false,
baseColProps: { span: 24 }
});
const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data: BoxPayload = { _tag: '' }) => {
//
await resetFields();
await clearValidate();
//
state.tag = data._tag;
state.menuTree = listToTree(await listMenu());
const roleId = data.record?.id;
const props: Partial<DrawerProps> = { confirmLoading: false };
// tag
switch (state.tag) {
case 'add':
props.title = '新增角色';
break;
case 'edit':
props.title = '编辑角色';
const result = await getRoleMenuIds(roleId);
const role = await getRole(roleId);
const checked = {
checkedKeys: result.extend?.filter(item => item.checkeType == '1')?.map(item=> item.menuId),
halfCheckedKeys: result.extend.filter(item => item.checkeType == '2')?.map(item=> item.menuId)
};
state.checkedKeys = checked;
await setFieldsValue(Object.assign({}, role, { menuIds: checked.checkedKeys }));
break;
}
// :
setDrawerProps(props);
});
/** 处理选中的半复选框合并至勾选数据中 */ taskSelectedTab: 'formInfo',
function handleHalfCheckedKeysMerge (checkedKeys: string[], e) { taskId: '',
state.checkedKeys = { checkedKeys, halfCheckedKeys: e.halfCheckedKeys }; taskDefKey: '',
}
processDefId: '',
processInsId: '',
processDefKey: '',
/** 处理弹出框提交 */ status: '',
async function handleSubmit() { historyFlowChangeList: [],
try { buttons: [],
// isCC: false,
const formData = await validate(); isAssign: false,
//
setDrawerProps({ confirmLoading: true }); auditForm: {
formData.menuIds = toRaw(state.checkedKeys); message: '',
// tag mesCode: '',
switch (state.tag) { mesName: '',
case 'add': userIds: '',
await addRole(formData); assignee: ''
break;
case 'edit':
await editRole(formData);
break;
}
//
closeDrawer();
emit('success');
} finally {
setDrawerProps({ confirmLoading: false });
} }
} });
</script> </script>

Loading…
Cancel
Save