feat: 【BPM 工作流】完善流程表单模块
parent
3ac5f784e7
commit
18c4e92418
|
@ -0,0 +1,48 @@
|
||||||
|
import type { PageParam, PageResult } from '@vben/request';
|
||||||
|
|
||||||
|
import { requestClient } from '#/api/request';
|
||||||
|
|
||||||
|
export namespace BpmFormApi {
|
||||||
|
export interface FormVO {
|
||||||
|
id?: number | undefined;
|
||||||
|
name: string;
|
||||||
|
conf: string;
|
||||||
|
fields: string[];
|
||||||
|
status: number;
|
||||||
|
remark: string;
|
||||||
|
createTime: string;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获取表单分页列表 */
|
||||||
|
export async function getFormPage(params: PageParam) {
|
||||||
|
return requestClient.get<PageResult<BpmFormApi.FormVO>>('/bpm/form/page', {
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获取表单详情 */
|
||||||
|
export async function getFormDetail(id: number) {
|
||||||
|
return requestClient.get<BpmFormApi.FormVO>(`/bpm/form/get?id=${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 创建表单 */
|
||||||
|
export async function createForm(data: BpmFormApi.FormVO) {
|
||||||
|
return requestClient.post('/bpm/form/create', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 更新表单 */
|
||||||
|
export async function updateForm(data: BpmFormApi.FormVO) {
|
||||||
|
return requestClient.put('/bpm/form/update', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除表单 */
|
||||||
|
export async function deleteForm(id: number) {
|
||||||
|
return requestClient.delete(`/bpm/form/delete?id=${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获取表单简单列表 */
|
||||||
|
export async function getFormSimpleList() {
|
||||||
|
return requestClient.get<BpmFormApi.FormVO[]>('/bpm/form/simple-list');
|
||||||
|
}
|
|
@ -47,6 +47,24 @@ const routes: RouteRecordRaw[] = [
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** 编辑流程表单 */
|
||||||
|
{
|
||||||
|
path: '/bpm/manager/form/edit',
|
||||||
|
name: 'BpmFormEditor',
|
||||||
|
component: () => import('#/views/bpm/form/editor.vue'),
|
||||||
|
meta: {
|
||||||
|
title: '编辑流程表单',
|
||||||
|
activePath: '/bpm/manager/form',
|
||||||
|
},
|
||||||
|
props: (route) => {
|
||||||
|
return {
|
||||||
|
id: route.query.id,
|
||||||
|
type: route.query.type,
|
||||||
|
copyId: route.query.copyId,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
|
@ -0,0 +1,146 @@
|
||||||
|
import type { VbenFormSchema } from '#/adapter/form';
|
||||||
|
import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { BpmFormApi } from '#/api/bpm/form';
|
||||||
|
|
||||||
|
import { useAccess } from '@vben/access';
|
||||||
|
import { $t } from '@vben/locales';
|
||||||
|
|
||||||
|
import { z } from '#/adapter/form';
|
||||||
|
import { CommonStatusEnum, DICT_TYPE, getDictOptions } from '#/utils';
|
||||||
|
|
||||||
|
const { hasAccessByCodes } = useAccess();
|
||||||
|
|
||||||
|
/** 新增/修改的表单 */
|
||||||
|
export function useFormSchema(): VbenFormSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
fieldName: 'id',
|
||||||
|
component: 'Input',
|
||||||
|
dependencies: {
|
||||||
|
triggerFields: [''],
|
||||||
|
show: () => false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'name',
|
||||||
|
label: '表单名称',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入表单名称',
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'status',
|
||||||
|
label: '状态',
|
||||||
|
component: 'RadioGroup',
|
||||||
|
componentProps: {
|
||||||
|
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
|
||||||
|
buttonStyle: 'solid',
|
||||||
|
optionType: 'button',
|
||||||
|
},
|
||||||
|
rules: z.number().default(CommonStatusEnum.ENABLE),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'remark',
|
||||||
|
label: '备注',
|
||||||
|
component: 'Textarea',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入备注',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 列表的搜索表单 */
|
||||||
|
export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
fieldName: 'name',
|
||||||
|
label: '表单名称',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入表单名称',
|
||||||
|
allowClear: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 列表的字段 */
|
||||||
|
export function useGridColumns<T = BpmFormApi.FormVO>(
|
||||||
|
onActionClick: OnActionClickFn<T>,
|
||||||
|
): VxeTableGridOptions['columns'] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
field: 'id',
|
||||||
|
title: '编号',
|
||||||
|
minWidth: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'name',
|
||||||
|
title: '表单名称',
|
||||||
|
minWidth: 200,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'status',
|
||||||
|
title: '状态',
|
||||||
|
minWidth: 200,
|
||||||
|
cellRender: {
|
||||||
|
name: 'CellDict',
|
||||||
|
props: { type: DICT_TYPE.COMMON_STATUS },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
field: 'remark',
|
||||||
|
title: '备注',
|
||||||
|
minWidth: 200,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
field: 'createTime',
|
||||||
|
title: '创建时间',
|
||||||
|
minWidth: 180,
|
||||||
|
formatter: 'formatDateTime',
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
field: 'operation',
|
||||||
|
title: '操作',
|
||||||
|
minWidth: 150,
|
||||||
|
align: 'center',
|
||||||
|
fixed: 'right',
|
||||||
|
cellRender: {
|
||||||
|
attrs: {
|
||||||
|
nameField: 'name',
|
||||||
|
nameTitle: '流程名称',
|
||||||
|
onClick: onActionClick,
|
||||||
|
},
|
||||||
|
name: 'CellOperation',
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
code: 'copy',
|
||||||
|
text: $t('ui.actionTitle.copy'),
|
||||||
|
show: hasAccessByCodes(['bpm:form:update']),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: 'edit',
|
||||||
|
text: $t('ui.actionTitle.edit'),
|
||||||
|
show: hasAccessByCodes(['bpm:form:update']),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: 'detail',
|
||||||
|
text: $t('ui.actionTitle.detail'),
|
||||||
|
show: hasAccessByCodes(['bpm:form:query']),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: 'delete',
|
||||||
|
text: $t('ui.actionTitle.delete'),
|
||||||
|
show: hasAccessByCodes(['bpm:form:delete']),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
|
@ -0,0 +1,156 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed, onMounted, ref } from 'vue';
|
||||||
|
|
||||||
|
import { Page, useVbenModal } from '@vben/common-ui';
|
||||||
|
import { IconifyIcon } from '@vben/icons';
|
||||||
|
|
||||||
|
import FcDesigner from '@form-create/antd-designer';
|
||||||
|
import { Button, message } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { getFormDetail } from '#/api/bpm/form';
|
||||||
|
import { useFormCreateDesigner } from '#/components/form-create';
|
||||||
|
import { router } from '#/router';
|
||||||
|
import { setConfAndFields } from '#/utils';
|
||||||
|
|
||||||
|
import Form from './modules/form.vue';
|
||||||
|
|
||||||
|
defineOptions({ name: 'BpmFormEditor' });
|
||||||
|
|
||||||
|
const props = defineProps<Props>();
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
copyId?: number;
|
||||||
|
id?: number;
|
||||||
|
type: 'copy' | 'create' | 'edit';
|
||||||
|
}
|
||||||
|
|
||||||
|
// 流程表单详情
|
||||||
|
const flowFormConfig = ref();
|
||||||
|
|
||||||
|
const [FormModal, formModalApi] = useVbenModal({
|
||||||
|
connectedComponent: Form,
|
||||||
|
destroyOnClose: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const designerRef = ref<InstanceType<typeof FcDesigner>>();
|
||||||
|
|
||||||
|
// 表单设计器配置
|
||||||
|
const designerConfig = ref({
|
||||||
|
switchType: [], // 是否可以切换组件类型,或者可以相互切换的字段
|
||||||
|
autoActive: true, // 是否自动选中拖入的组件
|
||||||
|
useTemplate: false, // 是否生成vue2语法的模板组件
|
||||||
|
formOptions: {
|
||||||
|
form: {
|
||||||
|
labelWidth: '100px', // 设置默认的 label 宽度为 100px
|
||||||
|
},
|
||||||
|
}, // 定义表单配置默认值
|
||||||
|
fieldReadonly: false, // 配置field是否可以编辑
|
||||||
|
hiddenDragMenu: false, // 隐藏拖拽操作按钮
|
||||||
|
hiddenDragBtn: false, // 隐藏拖拽按钮
|
||||||
|
hiddenMenu: [], // 隐藏部分菜单
|
||||||
|
hiddenItem: [], // 隐藏部分组件
|
||||||
|
hiddenItemConfig: {}, // 隐藏组件的部分配置项
|
||||||
|
disabledItemConfig: {}, // 禁用组件的部分配置项
|
||||||
|
showSaveBtn: false, // 是否显示保存按钮
|
||||||
|
showConfig: true, // 是否显示右侧的配置界面
|
||||||
|
showBaseForm: true, // 是否显示组件的基础配置表单
|
||||||
|
showControl: true, // 是否显示组件联动
|
||||||
|
showPropsForm: true, // 是否显示组件的属性配置表单
|
||||||
|
showEventForm: true, // 是否显示组件的事件配置表单
|
||||||
|
showValidateForm: true, // 是否显示组件的验证配置表单
|
||||||
|
showFormConfig: true, // 是否显示表单配置
|
||||||
|
showInputData: true, // 是否显示录入按钮
|
||||||
|
showDevice: true, // 是否显示多端适配选项
|
||||||
|
appendConfigData: [], // 定义渲染规则所需的formData
|
||||||
|
});
|
||||||
|
|
||||||
|
useFormCreateDesigner(designerRef); // 表单设计器增强
|
||||||
|
|
||||||
|
// 计算属性:获取当前需要加载的表单ID
|
||||||
|
const currentFormId = computed(() => {
|
||||||
|
switch (props.type) {
|
||||||
|
case 'copy': {
|
||||||
|
return props.copyId;
|
||||||
|
}
|
||||||
|
case 'create':
|
||||||
|
case 'edit': {
|
||||||
|
return props.id;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 加载表单配置
|
||||||
|
async function loadFormConfig(id: number) {
|
||||||
|
try {
|
||||||
|
const formDetail = await getFormDetail(id);
|
||||||
|
flowFormConfig.value = formDetail;
|
||||||
|
if (designerRef.value) {
|
||||||
|
setConfAndFields(designerRef, formDetail.conf, formDetail.fields);
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
message.error('加载表单配置失败');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化设计器
|
||||||
|
async function initializeDesigner() {
|
||||||
|
const id = currentFormId.value;
|
||||||
|
|
||||||
|
if (props.type === 'copy' && !id) {
|
||||||
|
message.error('复制ID不能为空');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (id) {
|
||||||
|
await loadFormConfig(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleSave() {
|
||||||
|
formModalApi
|
||||||
|
.setData({
|
||||||
|
designer: designerRef.value,
|
||||||
|
formConfig: flowFormConfig.value,
|
||||||
|
action: props.type,
|
||||||
|
})
|
||||||
|
.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
function onBack() {
|
||||||
|
router.push({
|
||||||
|
path: '/bpm/manager/form',
|
||||||
|
query: {
|
||||||
|
refresh: '1',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
initializeDesigner();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Page auto-content-height>
|
||||||
|
<FormModal @success="onBack" />
|
||||||
|
|
||||||
|
<FcDesigner class="my-designer" ref="designerRef" :config="designerConfig">
|
||||||
|
<template #handle>
|
||||||
|
<Button size="small" type="primary" @click="handleSave">
|
||||||
|
<IconifyIcon icon="mdi:content-save" />
|
||||||
|
保存
|
||||||
|
</Button>
|
||||||
|
</template>
|
||||||
|
</FcDesigner>
|
||||||
|
</Page>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.my-designer {
|
||||||
|
height: 100%;
|
||||||
|
min-height: 500px;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -1,34 +1,215 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { Page } from '@vben/common-ui';
|
import type {
|
||||||
|
OnActionClickParams,
|
||||||
|
VxeTableGridOptions,
|
||||||
|
} from '#/adapter/vxe-table';
|
||||||
|
import type { BpmFormApi } from '#/api/bpm/form';
|
||||||
|
|
||||||
import { Button } from 'ant-design-vue';
|
import { ref, watch } from 'vue';
|
||||||
|
import { useRoute } from 'vue-router';
|
||||||
|
|
||||||
|
import { Page, useVbenModal } from '@vben/common-ui';
|
||||||
|
import { Plus } from '@vben/icons';
|
||||||
|
import { $t } from '@vben/locales';
|
||||||
|
|
||||||
|
import { Button, message } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
|
import { deleteForm, getFormDetail, getFormPage } from '#/api/bpm/form';
|
||||||
import { DocAlert } from '#/components/doc-alert';
|
import { DocAlert } from '#/components/doc-alert';
|
||||||
|
import { router } from '#/router';
|
||||||
|
import { setConfAndFields2 } from '#/utils';
|
||||||
|
|
||||||
|
import { useGridColumns, useGridFormSchema } from './data';
|
||||||
|
|
||||||
|
defineOptions({ name: 'BpmForm' });
|
||||||
|
|
||||||
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
|
formOptions: {
|
||||||
|
schema: useGridFormSchema(),
|
||||||
|
},
|
||||||
|
gridOptions: {
|
||||||
|
columns: useGridColumns(onActionClick),
|
||||||
|
height: 'auto',
|
||||||
|
keepSource: true,
|
||||||
|
proxyConfig: {
|
||||||
|
ajax: {
|
||||||
|
query: async ({ page }, formValues) => {
|
||||||
|
return await getFormPage({
|
||||||
|
pageNo: page.currentPage,
|
||||||
|
pageSize: page.pageSize,
|
||||||
|
...formValues,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rowConfig: {
|
||||||
|
keyField: 'id',
|
||||||
|
},
|
||||||
|
toolbarConfig: {
|
||||||
|
refresh: { code: 'query' },
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
cellConfig: {
|
||||||
|
height: 64,
|
||||||
|
},
|
||||||
|
} as VxeTableGridOptions<BpmFormApi.FormVO>,
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 表格操作按钮的回调函数 */
|
||||||
|
function onActionClick({ code, row }: OnActionClickParams<BpmFormApi.FormVO>) {
|
||||||
|
switch (code) {
|
||||||
|
case 'copy': {
|
||||||
|
onCopy(row);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'delete': {
|
||||||
|
onDelete(row);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'detail': {
|
||||||
|
onDetail(row);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'edit': {
|
||||||
|
onEdit(row);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/** 复制 */
|
||||||
|
function onCopy(row: BpmFormApi.FormVO) {
|
||||||
|
router.push({
|
||||||
|
name: 'BpmFormEditor',
|
||||||
|
query: {
|
||||||
|
copyId: row.id,
|
||||||
|
type: 'copy',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除 */
|
||||||
|
async function onDelete(row: BpmFormApi.FormVO) {
|
||||||
|
const hideLoading = message.loading({
|
||||||
|
content: $t('ui.actionMessage.deleting', [row.id]),
|
||||||
|
duration: 0,
|
||||||
|
key: 'action_process_msg',
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await deleteForm(row.id as number);
|
||||||
|
message.success($t('ui.actionMessage.deleteSuccess', [row.name]));
|
||||||
|
onRefresh();
|
||||||
|
} finally {
|
||||||
|
hideLoading();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 详情 */
|
||||||
|
const formConfig = ref<any>({});
|
||||||
|
async function onDetail(row: BpmFormApi.FormVO) {
|
||||||
|
formConfig.value = await getFormDetail(row.id as number);
|
||||||
|
|
||||||
|
setConfAndFields2(
|
||||||
|
formConfig.value,
|
||||||
|
formConfig.value.conf,
|
||||||
|
formConfig.value.fields,
|
||||||
|
);
|
||||||
|
detailModalApi.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 编辑 */
|
||||||
|
function onEdit(row: BpmFormApi.FormVO) {
|
||||||
|
console.warn(row);
|
||||||
|
router.push({
|
||||||
|
name: 'BpmFormEditor',
|
||||||
|
query: {
|
||||||
|
id: row.id,
|
||||||
|
type: 'edit',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 刷新表格 */
|
||||||
|
function onRefresh() {
|
||||||
|
gridApi.query();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增 */
|
||||||
|
function onCreate() {
|
||||||
|
router.push({
|
||||||
|
name: 'BpmFormEditor',
|
||||||
|
query: {
|
||||||
|
type: 'create',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 详情弹窗 */
|
||||||
|
const [DetailModal, detailModalApi] = useVbenModal({
|
||||||
|
destroyOnClose: true,
|
||||||
|
footer: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 检测路由参数 */
|
||||||
|
const route = useRoute();
|
||||||
|
watch(
|
||||||
|
() => route.query.refresh,
|
||||||
|
(val) => {
|
||||||
|
if (val === '1') {
|
||||||
|
onRefresh();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ immediate: true },
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Page>
|
<Page auto-content-height>
|
||||||
<DocAlert
|
<DocAlert
|
||||||
title="审批接入(流程表单)"
|
title="审批接入(流程表单)"
|
||||||
url="https://doc.iocoder.cn/bpm/use-bpm-form/"
|
url="https://doc.iocoder.cn/bpm/use-bpm-form/"
|
||||||
/>
|
/>
|
||||||
<Button
|
<FormModal @success="onRefresh" />
|
||||||
danger
|
<Grid table-title="流程表单">
|
||||||
type="link"
|
<template #toolbar-tools>
|
||||||
target="_blank"
|
<Button type="primary" @click="onCreate">
|
||||||
href="https://github.com/yudaocode/yudao-ui-admin-vue3"
|
<Plus class="size-5" />
|
||||||
|
{{ $t('ui.actionTitle.create', ['流程表单']) }}
|
||||||
|
</Button>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<!-- 摘要 -->
|
||||||
|
<template #slot-summary="{ row }">
|
||||||
|
<div
|
||||||
|
class="flex flex-col py-2"
|
||||||
|
v-if="
|
||||||
|
row.processInstance.summary &&
|
||||||
|
row.processInstance.summary.length > 0
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
v-for="(item, index) in row.processInstance.summary"
|
||||||
|
:key="index"
|
||||||
|
>
|
||||||
|
<span class="text-gray-500">
|
||||||
|
{{ item.key }} : {{ item.value }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-else>-</div>
|
||||||
|
</template>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<DetailModal
|
||||||
|
title="流程表单详情"
|
||||||
|
class="w-[800px]"
|
||||||
|
:body-style="{
|
||||||
|
maxHeight: '100px',
|
||||||
|
}"
|
||||||
>
|
>
|
||||||
该功能支持 Vue3 + element-plus 版本!
|
<div class="mx-4">
|
||||||
</Button>
|
<form-create :option="formConfig.option" :rule="formConfig.rule" />
|
||||||
<br />
|
</div>
|
||||||
<Button
|
</DetailModal>
|
||||||
type="link"
|
|
||||||
target="_blank"
|
|
||||||
href="https://github.com/yudaocode/yudao-ui-admin-vue3/blob/master/src/views/bpm/form/index"
|
|
||||||
>
|
|
||||||
可参考
|
|
||||||
https://github.com/yudaocode/yudao-ui-admin-vue3/blob/master/src/views/bpm/form/index
|
|
||||||
代码,pull request 贡献给我们!
|
|
||||||
</Button>
|
|
||||||
</Page>
|
</Page>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -0,0 +1,107 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { FcDesigner } from '@form-create/antd-designer';
|
||||||
|
|
||||||
|
import type { BpmFormApi } from '#/api/bpm/form';
|
||||||
|
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import { message } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { useVbenForm } from '#/adapter/form';
|
||||||
|
import { createForm, updateForm } from '#/api/bpm/form';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
import { encodeConf, encodeFields } from '#/utils';
|
||||||
|
|
||||||
|
import { useFormSchema } from '../data';
|
||||||
|
|
||||||
|
const emit = defineEmits(['success']);
|
||||||
|
|
||||||
|
const designerComponent = ref<InstanceType<typeof FcDesigner>>();
|
||||||
|
const formData = ref<BpmFormApi.FormVO>();
|
||||||
|
const editorAction = ref<string>();
|
||||||
|
|
||||||
|
const getTitle = computed(() => {
|
||||||
|
if (!formData.value?.id) {
|
||||||
|
return $t('ui.actionTitle.create', ['流程表单']);
|
||||||
|
}
|
||||||
|
return editorAction.value === 'copy'
|
||||||
|
? $t('ui.actionTitle.copy', ['流程表单'])
|
||||||
|
: $t('ui.actionTitle.edit', ['流程表单']);
|
||||||
|
});
|
||||||
|
|
||||||
|
const [Form, formApi] = useVbenForm({
|
||||||
|
layout: 'horizontal',
|
||||||
|
schema: useFormSchema(),
|
||||||
|
showDefaultActions: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
const [Modal, modalApi] = useVbenModal({
|
||||||
|
async onConfirm() {
|
||||||
|
const { valid } = await formApi.validate();
|
||||||
|
if (!valid) return;
|
||||||
|
|
||||||
|
modalApi.lock();
|
||||||
|
try {
|
||||||
|
const data = (await formApi.getValues()) as BpmFormApi.FormVO;
|
||||||
|
|
||||||
|
data.conf = encodeConf(designerComponent);
|
||||||
|
data.fields = encodeFields(designerComponent);
|
||||||
|
|
||||||
|
const saveForm = async () => {
|
||||||
|
if (!formData.value?.id) {
|
||||||
|
return createForm(data);
|
||||||
|
}
|
||||||
|
return editorAction.value === 'copy'
|
||||||
|
? createForm(data)
|
||||||
|
: updateForm(data);
|
||||||
|
};
|
||||||
|
|
||||||
|
await saveForm();
|
||||||
|
await modalApi.close();
|
||||||
|
emit('success');
|
||||||
|
message.success($t('ui.actionMessage.operationSuccess'));
|
||||||
|
} finally {
|
||||||
|
modalApi.unlock();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
async onOpenChange(isOpen: boolean) {
|
||||||
|
if (!isOpen) {
|
||||||
|
formData.value = undefined;
|
||||||
|
designerComponent.value = undefined;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = modalApi.getData<any>();
|
||||||
|
if (!data) return;
|
||||||
|
|
||||||
|
designerComponent.value = data.designer;
|
||||||
|
formData.value = data.formConfig;
|
||||||
|
editorAction.value = data.action;
|
||||||
|
|
||||||
|
if (editorAction.value === 'copy' && formData.value) {
|
||||||
|
formData.value = {
|
||||||
|
...formData.value,
|
||||||
|
name: `${formData.value.name}_copy`,
|
||||||
|
id: undefined,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (formData.value) {
|
||||||
|
await formApi.setValues(formData.value);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
modalApi.unlock();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Modal :title="getTitle" class="w-[600px]">
|
||||||
|
<Form class="mx-4" />
|
||||||
|
</Modal>
|
||||||
|
</template>
|
|
@ -11,6 +11,7 @@
|
||||||
"mobile": "Please input a valid {0}"
|
"mobile": "Please input a valid {0}"
|
||||||
},
|
},
|
||||||
"actionTitle": {
|
"actionTitle": {
|
||||||
|
"copy": "Copy {0}",
|
||||||
"cancel": "Cancel {0}",
|
"cancel": "Cancel {0}",
|
||||||
"edit": "Modify {0}",
|
"edit": "Modify {0}",
|
||||||
"create": "Create {0}",
|
"create": "Create {0}",
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
"mobile": "请输入正确的{0}"
|
"mobile": "请输入正确的{0}"
|
||||||
},
|
},
|
||||||
"actionTitle": {
|
"actionTitle": {
|
||||||
|
"copy": "复制{0}",
|
||||||
"cancel": "取消{0}",
|
"cancel": "取消{0}",
|
||||||
"edit": "修改{0}",
|
"edit": "修改{0}",
|
||||||
"create": "新增{0}",
|
"create": "新增{0}",
|
||||||
|
|
Loading…
Reference in New Issue