|
|
@ -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: '', |
|
|
|
async function handleSubmit() { |
|
|
|
processInsId: '', |
|
|
|
try { |
|
|
|
processDefKey: '', |
|
|
|
// 提取验证数据 |
|
|
|
|
|
|
|
const formData = await validate(); |
|
|
|
status: '', |
|
|
|
// 处理提交之前逻辑 |
|
|
|
historyFlowChangeList: [], |
|
|
|
setDrawerProps({ confirmLoading: true }); |
|
|
|
buttons: [], |
|
|
|
formData.menuIds = toRaw(state.checkedKeys); |
|
|
|
isCC: false, |
|
|
|
// 采用tag标签区分操作 |
|
|
|
isAssign: false, |
|
|
|
switch (state.tag) { |
|
|
|
|
|
|
|
case 'add': |
|
|
|
auditForm: { |
|
|
|
await addRole(formData); |
|
|
|
message: '', |
|
|
|
break; |
|
|
|
mesCode: '', |
|
|
|
case 'edit': |
|
|
|
mesName: '', |
|
|
|
await editRole(formData); |
|
|
|
userIds: '', |
|
|
|
break; |
|
|
|
assignee: '' |
|
|
|
} |
|
|
|
|
|
|
|
// 处理提交完成之后逻辑 |
|
|
|
|
|
|
|
closeDrawer(); |
|
|
|
|
|
|
|
emit('success'); |
|
|
|
|
|
|
|
} finally { |
|
|
|
|
|
|
|
setDrawerProps({ confirmLoading: false }); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
</script> |
|
|
|
</script> |
|
|
|