From d1c95c4d8aeeb94d13bc65290ef7816d1e3e6fce Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 2 Jan 2022 12:56:34 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E6=B8=85=E7=90=86=E6=97=A7=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E7=9A=84=20form=20generator=202.=20=E6=8E=A5=E5=85=A5?= =?UTF-8?q?=E8=A1=A8=E5=8D=95=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yudao-admin-ui/src/utils/formGenerator.js | 13 ++ .../src/views/bpm/form/formEditor.vue | 11 +- yudao-admin-ui/src/views/bpm/form/index.vue | 189 +----------------- yudao-admin-ui/src/views/bpm/model/index.vue | 45 ++++- 4 files changed, 65 insertions(+), 193 deletions(-) create mode 100644 yudao-admin-ui/src/utils/formGenerator.js 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 @@