834 fix:bpm 流程表单编辑打开直接保存js丢失问题修复
parent
1d65908402
commit
500705df07
|
|
@ -4,24 +4,30 @@
|
||||||
import { isRef } from 'vue'
|
import { isRef } from 'vue'
|
||||||
import formCreate from '@form-create/element-ui'
|
import formCreate from '@form-create/element-ui'
|
||||||
|
|
||||||
// 编码表单 Conf
|
/** 编码表单 Conf */
|
||||||
export const encodeConf = (designerRef: object) => {
|
export const encodeConf = (designerRef: object) => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
// 关联案例:https://gitee.com/yudaocode/yudao-ui-admin-vue3/pulls/834/
|
||||||
return formCreate.toJson(designerRef.value.getOption())
|
return formCreate.toJson(designerRef.value.getOption())
|
||||||
}
|
}
|
||||||
|
|
||||||
// 编码表单 Fields
|
/** 解码表单 Conf */
|
||||||
|
export const decodeConf = (conf: string) => {
|
||||||
|
return formCreate.parseJson(conf)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 编码表单 Fields */
|
||||||
export const encodeFields = (designerRef: object) => {
|
export const encodeFields = (designerRef: object) => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const rule = JSON.parse(designerRef.value.getJson())
|
const rule = designerRef.value.getRule()
|
||||||
const fields: string[] = []
|
const fields: string[] = []
|
||||||
rule.forEach((item) => {
|
rule.forEach((item: any) => {
|
||||||
fields.push(JSON.stringify(item))
|
fields.push(formCreate.toJson(item))
|
||||||
})
|
})
|
||||||
return fields
|
return fields
|
||||||
}
|
}
|
||||||
|
|
||||||
// 解码表单 Fields
|
/** 解码表单 Fields */
|
||||||
export const decodeFields = (fields: string[]) => {
|
export const decodeFields = (fields: string[]) => {
|
||||||
const rule: object[] = []
|
const rule: object[] = []
|
||||||
fields.forEach((item) => {
|
fields.forEach((item) => {
|
||||||
|
|
@ -30,15 +36,15 @@ export const decodeFields = (fields: string[]) => {
|
||||||
return rule
|
return rule
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置表单的 Conf 和 Fields,适用 FcDesigner 场景
|
/** 设置表单的 Conf 和 Fields,适用 FcDesigner 场景 */
|
||||||
export const setConfAndFields = (designerRef: object, conf: string, fields: string) => {
|
export const setConfAndFields = (designerRef: object, conf: string, fields: string[]) => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
designerRef.value.setOption(formCreate.parseJson(conf))
|
designerRef.value.setOption(decodeConf(conf))
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
designerRef.value.setRule(decodeFields(fields))
|
designerRef.value.setRule(decodeFields(fields))
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置表单的 Conf 和 Fields,适用 form-create 场景
|
/** 设置表单的 Conf 和 Fields,适用 form-create 场景 */
|
||||||
export const setConfAndFields2 = (
|
export const setConfAndFields2 = (
|
||||||
detailPreview: object,
|
detailPreview: object,
|
||||||
conf: string,
|
conf: string,
|
||||||
|
|
@ -51,7 +57,7 @@ export const setConfAndFields2 = (
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
detailPreview.option = formCreate.parseJson(conf)
|
detailPreview.option = decodeConf(conf)
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
detailPreview.rule = decodeFields(fields)
|
detailPreview.rule = decodeFields(fields)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue