fix: [BPM 工作流] 流程表单字段解析调整为使用库解析
parent
07d15f5c88
commit
4f65156a95
|
|
@ -4,6 +4,7 @@
|
||||||
// TODO @芋艿:后续这些 form-create 的优化;另外需要使用 form-create-helper 会好点
|
// TODO @芋艿:后续这些 form-create 的优化;另外需要使用 form-create-helper 会好点
|
||||||
import { isRef } from 'vue';
|
import { isRef } from 'vue';
|
||||||
|
|
||||||
|
import formCreate from '@form-create/ant-design-vue';
|
||||||
// 编码表单 Conf
|
// 编码表单 Conf
|
||||||
export const encodeConf = (designerRef: any) => {
|
export const encodeConf = (designerRef: any) => {
|
||||||
return JSON.stringify(designerRef.value.getOption());
|
return JSON.stringify(designerRef.value.getOption());
|
||||||
|
|
@ -23,7 +24,7 @@ export const encodeFields = (designerRef: any) => {
|
||||||
export const decodeFields = (fields: string[]) => {
|
export const decodeFields = (fields: string[]) => {
|
||||||
const rule: object[] = [];
|
const rule: object[] = [];
|
||||||
fields.forEach((item) => {
|
fields.forEach((item) => {
|
||||||
rule.push(JSON.parse(item));
|
rule.push(formCreate.parseJson(item));
|
||||||
});
|
});
|
||||||
return rule;
|
return rule;
|
||||||
};
|
};
|
||||||
|
|
@ -34,7 +35,7 @@ export const setConfAndFields = (
|
||||||
conf: string,
|
conf: string,
|
||||||
fields: string | string[],
|
fields: string | string[],
|
||||||
) => {
|
) => {
|
||||||
designerRef.value.setOption(JSON.parse(conf));
|
designerRef.value.setOption(formCreate.parseJson(conf));
|
||||||
// 处理 fields 参数类型,确保传入 decodeFields 的是 string[] 类型
|
// 处理 fields 参数类型,确保传入 decodeFields 的是 string[] 类型
|
||||||
const fieldsArray = Array.isArray(fields) ? fields : [fields];
|
const fieldsArray = Array.isArray(fields) ? fields : [fields];
|
||||||
designerRef.value.setRule(decodeFields(fieldsArray));
|
designerRef.value.setRule(decodeFields(fieldsArray));
|
||||||
|
|
@ -50,7 +51,7 @@ export const setConfAndFields2 = (
|
||||||
if (isRef(detailPreview)) {
|
if (isRef(detailPreview)) {
|
||||||
detailPreview = detailPreview.value;
|
detailPreview = detailPreview.value;
|
||||||
}
|
}
|
||||||
detailPreview.option = JSON.parse(conf);
|
detailPreview.option = formCreate.parseJson(conf);
|
||||||
detailPreview.rule = decodeFields(fields);
|
detailPreview.rule = decodeFields(fields);
|
||||||
if (value) {
|
if (value) {
|
||||||
detailPreview.value = value;
|
detailPreview.value = value;
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import { computed, nextTick, ref, watch } from 'vue';
|
||||||
import { useTabs } from '@vben/hooks';
|
import { useTabs } from '@vben/hooks';
|
||||||
import { IconifyIcon } from '@vben/icons';
|
import { IconifyIcon } from '@vben/icons';
|
||||||
|
|
||||||
|
import formCreate from '@form-create/ant-design-vue';
|
||||||
import { Button, Card, Col, message, Row, Space, Tabs } from 'ant-design-vue';
|
import { Button, Card, Col, message, Row, Space, Tabs } from 'ant-design-vue';
|
||||||
|
|
||||||
import { getProcessDefinition } from '#/api/bpm/definition';
|
import { getProcessDefinition } from '#/api/bpm/definition';
|
||||||
|
|
@ -126,11 +127,11 @@ async function initProcessInfo(row: any, formVariables?: any) {
|
||||||
// 注意:需要从 formVariables 中,移除不在 row.formFields 的值。
|
// 注意:需要从 formVariables 中,移除不在 row.formFields 的值。
|
||||||
// 原因是:后端返回的 formVariables 里面,会有一些非表单的信息。例如说,某个流程节点的审批人。
|
// 原因是:后端返回的 formVariables 里面,会有一些非表单的信息。例如说,某个流程节点的审批人。
|
||||||
// 这样,就可能导致一个流程被审批不通过后,重新发起时,会直接后端报错!!!
|
// 这样,就可能导致一个流程被审批不通过后,重新发起时,会直接后端报错!!!
|
||||||
const allowedFields = new Set(
|
const formApi = formCreate.create(decodeFields(row.formFields));
|
||||||
decodeFields(row.formFields).map((fieldObj: any) => fieldObj.field),
|
const allowedFields = formApi.fields();
|
||||||
);
|
console.error('allowedFields===>', allowedFields);
|
||||||
for (const key in formVariables) {
|
for (const key in formVariables) {
|
||||||
if (!allowedFields.has(key)) {
|
if (!allowedFields.includes(key)) {
|
||||||
delete formVariables[key];
|
delete formVariables[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue