Browse Source

chore: 微应用扩展多组件

master
wangxiang 2 years ago
parent
commit
ad08c3da57
  1. 15
      src/enums/microAppEnum.ts
  2. 20
      src/store/modules/microApp.ts
  3. 4
      src/views/workflow/extension/form/helper/WorkflowFormDesign.vue
  4. 64
      src/views/workflow/extension/formJson/FormJsonModal.vue
  5. 177
      src/views/workflow/extension/formJson/formJson.data.ts
  6. 24
      src/views/workflow/extension/formJson/index.vue

15
src/enums/microAppEnum.ts

@ -7,10 +7,17 @@
export enum GlStateEnum { export enum GlStateEnum {
// 表单设计器 // 表单设计器
FORM_DESIGN_PROPS_KEY = 'MICRO_APP_FORM_DESIGN_PROPS_KEY', FORM_DESIGN_PROPS_KEY = 'MICRO_FORM_DESIGN_PROPS_KEY',
FORM_DESIGN_EMIT_KEY = 'MICRO_APP_FORM_DESIGN_EMIT_KEY', FORM_DESIGN_EMIT_KEY = 'MICRO_FORM_DESIGN_EMIT_KEY',
// 工作流设计器 // 工作流设计器
WORKFLOW_DESIGN_PROPS_KEY = 'MICRO_APP_WORKFLOW_DESIGN_PROPS_KEY', WORKFLOW_DESIGN_PROPS_KEY = 'MICRO_WORKFLOW_DESIGN_PROPS_KEY',
WORKFLOW_DESIGN_EMIT_KEY = 'MICRO_APP_WORKFLOW_DESIGN_EMIT_KEY', WORKFLOW_DESIGN_EMIT_KEY = 'MICRO_WORKFLOW_DESIGN_EMIT_KEY',
} }
export enum FORM_DESIGN_COMPONENTS {
DESIGN = 'MicroDesign',
PREVIEW = 'MicroPreview'
}
export enum WORKFLOW_DESIGN_COMPONENTS {
}

20
src/store/modules/microApp.ts

@ -6,6 +6,8 @@
*/ */
import { defineStore } from 'pinia'; import { defineStore } from 'pinia';
import { store } from '/@/store'; import { store } from '/@/store';
import { merge } from 'lodash-es';
import { FORM_DESIGN_COMPONENTS, WORKFLOW_DESIGN_COMPONENTS } from '/@/enums/microAppEnum';
interface MicroAppState { interface MicroAppState {
formDesignApp: Recordable; formDesignApp: Recordable;
@ -19,20 +21,24 @@ export const useMicroAppStore = defineStore({
workflowDesignApp: {} workflowDesignApp: {}
}), }),
getters: { getters: {
getFormDesignApp(): Recordable { getFormDesignApp(): Function {
return this.formDesignApp; return (component: FORM_DESIGN_COMPONENTS) => this.formDesignApp[component] || {};
}, },
getWorkflowDesignApp(): Recordable { getWorkflowDesignApp(): Function {
return this.workflowDesignApp; return (component: WORKFLOW_DESIGN_COMPONENTS) => this.workflowDesignApp[component] || {};
} }
}, },
actions: { actions: {
setFormDesignApp(data: Recordable): void { setFormDesignApp(data: Recordable): void {
this.formDesignApp = { ...this.formDesignApp, ...data }; this.formDesignApp = merge(this.formDesignApp, data);
}, },
setWorkflowDesignApp(data: Recordable): void { setWorkflowDesignApp(data: Recordable): void {
this.workflowDesignApp = { ...this.workflowDesignApp, ...data }; this.workflowDesignApp = merge(this.workflowDesignApp, data);
} },
resetState(): void {
this.formDesignApp = {};
this.workflowDesignApp = {};
},
} }
}); });

4
src/views/workflow/extension/form/helper/WorkflowFormDesign.vue

@ -25,6 +25,7 @@
import { apps } from '/@/qiankun/apps'; import { apps } from '/@/qiankun/apps';
import { addFormDefinitionJson, editFormDefinitionJson, getFormDefinitionJson } from '/@/api/platform/workflow/extension/controller/formDefinitionJson'; import { addFormDefinitionJson, editFormDefinitionJson, getFormDefinitionJson } from '/@/api/platform/workflow/extension/controller/formDefinitionJson';
import { FormDefinitionJson } from '/@/api/platform/workflow/extension/entity/formDefinitionJson'; import { FormDefinitionJson } from '/@/api/platform/workflow/extension/entity/formDefinitionJson';
import { FORM_DESIGN_COMPONENTS } from '/@/enums/microAppEnum';
interface TableState { interface TableState {
tag: string; tag: string;
@ -90,7 +91,8 @@
/** 处理弹出框提交 */ /** 处理弹出框提交 */
async function handleSubmitForm(status: string) { async function handleSubmitForm(status: string) {
try { try {
const formRef = microAppStore.getFormDesignApp.getFormDesignRef(); const formDesignApp: Recordable = microAppStore.getFormDesignApp(FORM_DESIGN_COMPONENTS.DESIGN),
formRef: Recordable = formDesignApp.getFormDesignRef();
state.form.json = formRef.getWidgetFormJson(); state.form.json = formRef.getWidgetFormJson();
state.form.status = status; state.form.status = status;
state.form.isPrimary = '1'; state.form.isPrimary = '1';

64
src/views/workflow/extension/formJson/FormJsonModal.vue

@ -0,0 +1,64 @@
<template>
<BasicModal
v-bind="$attrs"
width="720px"
minHeight="100px"
@register="registerModal"
@ok="handleSubmit"
>
todo
</BasicModal>
</template>
<script lang="ts" setup>
import { ref, unref } from 'vue';
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal';
/** 通用变量统一声明区域 */
const tag = ref<Nullable<string>>('');
/** https://v3.cn.vuejs.org/api/options-data.html#emits */
const emit = defineEmits(['success', 'register']);
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data: BoxPayload = { _tag: '' }) => {
//
//
tag.value = data._tag;
const id = data.record?.id;
const props: Partial<ModalProps> = { confirmLoading: false };
// tag
switch (unref(tag)) {
case 'add':
props.title = '新增流程表单';
break;
case 'edit':
props.title = '编辑流程表单';
// await setFieldsValue(await getFormDefinition(id));
break;
}
// :
setModalProps(props);
});
/** 处理弹出框提交 */
async function handleSubmit() {
try {
//
//
setModalProps({ confirmLoading: true });
// tag
switch (unref(tag)) {
case 'add':
break;
case 'edit':
break;
}
//
closeModal();
emit('success');
} finally {
setModalProps({ confirmLoading: false });
}
}
</script>

177
src/views/workflow/extension/formJson/formJson.data.ts

@ -1,164 +1,79 @@
/**
* @program: kicc-ui
* @description:
* @author: entfrm开发团队-
* @create: 2022/4/21
*/
import { BasicColumn } from '/@/components/Table'; import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table'; import { FormSchema } from '/@/components/Table';
import { h } from 'vue';
import { Tag } from 'ant-design-vue';
/** 表格列配置 */
export const columns: BasicColumn[] = [ export const columns: BasicColumn[] = [
{ {
title: '客户端Id', title: '流程定义ID',
dataIndex: 'clientId', dataIndex: 'formDefinitionId',
width: 100 width: 120
},
{
title: '客户端密钥',
dataIndex: 'clientSecret',
width: 100
}, },
{ {
title: '授权类型', title: '流程表单结构体',
dataIndex: 'authorizedGrantTypes', dataIndex: 'json',
width: 130 width: 220,
ellipsis: true
}, },
{ {
title: '授权范围', title: '版本号',
dataIndex: 'scope', dataIndex: 'version',
width: 90 width: 80
}, },
{ {
title: '令牌过期秒数', title: '状态',
dataIndex: 'accessTokenValidity', dataIndex: 'status',
width: 130 width: 90,
}, customRender: ({ record }) => {
{ return record.formDefinitionJson?.status == '1' ?
title: '令牌过期秒数', h(Tag, { color: 'success' }, () => '已发布'):
dataIndex: 'refreshTokenValidity', h(Tag, { color: 'red' }, () => '未发布');
width: 130 }
}, },
{ {
title: '创建时间', title: '是否主版本',
dataIndex: 'createTime', dataIndex: 'isPrimary',
width: 100 width: 90,
customRender: ({ record }) => {
return record.formDefinitionJson?.status == '1' ?
h(Tag, { color: 'success' }, () => '主版本'):
h(Tag, { color: 'red' }, () => '非主版本');
}
} }
]; ];
/** 搜索表单配置 */
export const searchFormSchema: FormSchema[] = [ export const searchFormSchema: FormSchema[] = [
{ {
field: 'clientId', field: 'version',
label: '客户端编码', label: '版本号',
component: 'Input', component: 'Input',
componentProps: { componentProps: {
placeholder: '请输入客户端编码', placeholder: '请输入版本号',
}, },
colProps: { span: 8 }, colProps: { span: 8 },
}, },
{ {
field: 'dateRange', field: 'status',
label: '创建时间', label: '状态',
component: 'RangePicker', component: 'Select',
componentProps: { componentProps: {
style: { width:'100%' }, options: [
valueFormat: 'YYYY-MM-DD', { label: '未发布', value: '0' },
placeholder: ['开始日期','结束日期'] { label: '已发布', value: '1' }
]
}, },
colProps: { span: 8 } colProps: { span: 8 }
}
];
/** 表单配置 */
export const formSchema: FormSchema[] = [
{
field: 'id',
label: 'ID',
component: 'Input',
show: false
}, },
{ {
field: 'clientId', field: 'isPrimary',
label: '客户端Id', label: '是否主版本',
component: 'Input', component: 'Select',
required: true,
colProps: {
span: 12
}
},
{
field: 'clientSecret',
label: '客户端密钥',
component: 'Input',
required: true,
colProps: {
span: 12
}
},
{
field: 'authorizedGrantTypes',
label: '授权类型',
component: 'InputTextArea',
required:true,
componentProps: { componentProps: {
rows: 3 options: [
{ label: '非主版本', value: '0' },
{ label: '主版本', value: '1' }
]
}, },
colProps: { colProps: { span: 8 }
span: 24
}
},
{
field: 'scope',
label: '授权范围',
component: 'Input',
required:true,
colProps: {
span: 12
}
},
{
field: 'accessTokenValidity',
label: '过期秒数',
component: 'InputNumber',
componentProps: {
style: { width:'100%' },
min: 0
},
colProps: {
span: 12
}
},
{
field: 'refreshTokenValidity',
label: '刷新秒数',
component: 'InputNumber',
componentProps: {
style: { width:'100%' },
min: 0
},
colProps: {
span: 12
}
},
{
field: 'webServerRedirectUri',
label: '回调地址',
component: 'Input',
colProps: {
span: 12
}
},
{
field: 'additionalInformation',
label: '附加说明',
component: 'InputTextArea',
componentProps: {
rows: 6
},
colProps: {
span: 24
}
} }
]; ];

24
src/views/workflow/extension/formJson/index.vue

@ -5,34 +5,30 @@
@selection-change="handleSelectionChange" @selection-change="handleSelectionChange"
> >
<template #toolbar> <template #toolbar>
<a-button
v-auth="['client_add']"
type="primary"
@click="handleAdd()"
>新增客户端</a-button>
<a-button
v-auth="['client_edit']"
type="primary"
:disabled="state.single"
@click="handleEdit()"
>修改客户端</a-button>
<a-button <a-button
v-auth="['client_del']" v-auth="['client_del']"
type="primary" type="primary"
:disabled="state.multiple" :disabled="state.multiple"
@click="handleDel()" @click="handleDel()"
>删除客户端</a-button> >删除表单</a-button>
</template> </template>
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'"> <template v-if="column.key === 'action'">
<TableAction <TableAction
:actions="[ :actions="[
{ {
label: '编辑', label: '预览',
icon: 'fa6-regular:pen-to-square', icon: 'fa6-regular:pen-to-square',
auth: ['client_edit'], auth: ['client_edit'],
onClick: handleEdit.bind(null, record) onClick: handleEdit.bind(null, record)
}, },
{
label: '设置为主版本',
icon: 'ant-design:delete-outlined',
color: 'error',
auth: ['client_del'],
onClick: handleDel.bind(null, record)
},
{ {
label: '删除', label: '删除',
icon: 'ant-design:delete-outlined', icon: 'ant-design:delete-outlined',
@ -77,7 +73,7 @@
const { createConfirm, createMessage } = useMessage(); const { createConfirm, createMessage } = useMessage();
const [registerModal, { openModal }] = useModal(); const [registerModal, { openModal }] = useModal();
const [registerTable, { reload, clearSelectedRowKeys, getSelectRowKeys }] = useTable({ const [registerTable, { reload, clearSelectedRowKeys, getSelectRowKeys }] = useTable({
title: '客户端列表', title: '列表',
api: listClient, api: listClient,
rowKey: 'clientId', rowKey: 'clientId',
columns, columns,

Loading…
Cancel
Save