diff --git a/yudao-admin-ui/src/utils/formGenerator.js b/yudao-admin-ui/src/utils/formGenerator.js new file mode 100644 index 000000000..248e0b23e --- /dev/null +++ b/yudao-admin-ui/src/utils/formGenerator.js @@ -0,0 +1,13 @@ +/** + * 将服务端返回的 fields 字符串数组,解析成 JSON 数组 + * + * @param fields JSON 字符串数组 + * @returns {*[]} JSON 数组 + */ +export function decodeFields(fields) { + const drawingList = [] + fields.forEach(item => { + drawingList.push(JSON.parse(item)) + }) + return drawingList +} diff --git a/yudao-admin-ui/src/views/bpm/form/formEditor.vue b/yudao-admin-ui/src/views/bpm/form/formEditor.vue index d59d0069d..b04ef694e 100644 --- a/yudao-admin-ui/src/views/bpm/form/formEditor.vue +++ b/yudao-admin-ui/src/views/bpm/form/formEditor.vue @@ -169,6 +169,7 @@ import { import loadBeautifier from '@/utils/loadBeautifier' import {SysCommonStatusEnum} from "@/utils/constants"; import {createForm, getForm, updateForm} from "@/api/bpm/form"; +import {decodeFields} from "@/utils/formGenerator"; let beautifier const emptyActiveData = { style: {}, autosize: {} } @@ -316,7 +317,7 @@ export default { remark: data.remark } this.formConf = JSON.parse(data.conf) - this.drawingList = this.decodeFields(data.fields) + this.drawingList = decodeFields(data.fields) // 设置激活的表单项 this.activeData = this.drawingList[0] this.activeId = this.activeData.__config__.formId @@ -428,7 +429,6 @@ export default { } const form = { conf: JSON.stringify(this.formConf), // 表单配置 - // fields: JSON.stringify(this.drawingList), // 表单项的数组 fields: this.encodeFields(), // 表单项的数组 ...this.form // 表单名等 } @@ -459,13 +459,6 @@ export default { }) return fields }, - decodeFields(fields) { - const drawingList = [] - fields.forEach(item => { - drawingList.push(JSON.parse(item)) - }) - return drawingList - }, generate(data) { const func = this[`exec${titleCase(this.operationType)}`] this.generateConf = data diff --git a/yudao-admin-ui/src/views/bpm/form/index.vue b/yudao-admin-ui/src/views/bpm/form/index.vue index ba4a8ecce..15943b7ce 100644 --- a/yudao-admin-ui/src/views/bpm/form/index.vue +++ b/yudao-admin-ui/src/views/bpm/form/index.vue @@ -63,6 +63,7 @@