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