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 @@ @@ -7,10 +7,17 @@
export enum GlStateEnum {
// 表单设计器
FORM_DESIGN_PROPS_KEY = 'MICRO_APP_FORM_DESIGN_PROPS_KEY',
FORM_DESIGN_EMIT_KEY = 'MICRO_APP_FORM_DESIGN_EMIT_KEY',
FORM_DESIGN_PROPS_KEY = 'MICRO_FORM_DESIGN_PROPS_KEY',
FORM_DESIGN_EMIT_KEY = 'MICRO_FORM_DESIGN_EMIT_KEY',
// 工作流设计器
WORKFLOW_DESIGN_PROPS_KEY = 'MICRO_APP_WORKFLOW_DESIGN_PROPS_KEY',
WORKFLOW_DESIGN_EMIT_KEY = 'MICRO_APP_WORKFLOW_DESIGN_EMIT_KEY',
WORKFLOW_DESIGN_PROPS_KEY = 'MICRO_WORKFLOW_DESIGN_PROPS_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 @@ @@ -6,6 +6,8 @@
*/
import { defineStore } from 'pinia';
import { store } from '/@/store';
import { merge } from 'lodash-es';
import { FORM_DESIGN_COMPONENTS, WORKFLOW_DESIGN_COMPONENTS } from '/@/enums/microAppEnum';
interface MicroAppState {
formDesignApp: Recordable;
@ -19,20 +21,24 @@ export const useMicroAppStore = defineStore({ @@ -19,20 +21,24 @@ export const useMicroAppStore = defineStore({
workflowDesignApp: {}
}),
getters: {
getFormDesignApp(): Recordable {
return this.formDesignApp;
getFormDesignApp(): Function {
return (component: FORM_DESIGN_COMPONENTS) => this.formDesignApp[component] || {};
},
getWorkflowDesignApp(): Recordable {
return this.workflowDesignApp;
getWorkflowDesignApp(): Function {
return (component: WORKFLOW_DESIGN_COMPONENTS) => this.workflowDesignApp[component] || {};
}
},
actions: {
setFormDesignApp(data: Recordable): void {
this.formDesignApp = { ...this.formDesignApp, ...data };
this.formDesignApp = merge(this.formDesignApp, data);
},
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 @@ @@ -25,6 +25,7 @@
import { apps } from '/@/qiankun/apps';
import { addFormDefinitionJson, editFormDefinitionJson, getFormDefinitionJson } from '/@/api/platform/workflow/extension/controller/formDefinitionJson';
import { FormDefinitionJson } from '/@/api/platform/workflow/extension/entity/formDefinitionJson';
import { FORM_DESIGN_COMPONENTS } from '/@/enums/microAppEnum';
interface TableState {
tag: string;
@ -90,7 +91,8 @@ @@ -90,7 +91,8 @@
/** 处理弹出框提交 */
async function handleSubmitForm(status: string) {
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.status = status;
state.form.isPrimary = '1';

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

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

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

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

Loading…
Cancel
Save