From a8e94242166881639cecf3809e45ca527233ebd7 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 23 三月 2021 16:42:20 +0800
Subject: [PATCH] 2021-03-23

---
 src/utils/utils-update.js |   55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 55 insertions(+), 0 deletions(-)

diff --git a/src/utils/utils-update.js b/src/utils/utils-update.js
index 733a0a5..2d851a6 100644
--- a/src/utils/utils-update.js
+++ b/src/utils/utils-update.js
@@ -1,4 +1,59 @@
 /**
+ * @description 鍗囩骇琛ㄥ崟淇℃伅
+ * @param {Object}   config      琛ㄥ崟閰嶇疆淇℃伅
+ * @return {Object}  config
+ */
+export function updateForm (config) {
+  if (!config.version && config.groups) {
+    config.version = '1.0'
+    if (config.groups && config.groups.length > 0) {
+      let fields = []
+      config.groups.forEach(group => {
+        if (group.sublist.length === 0) return
+
+        if (!group.default) {
+          fields.push({
+            type: 'split',
+            label: group.label,
+            uuid: group.uuid,
+            span: 24
+          })
+        }
+
+        fields.push(...group.sublist)
+      })
+      config.fields = fields
+    }
+    delete config.groups
+
+    let _col = config.setting.cols || '2'
+
+    config.fields = config.fields.map(item => {
+      item.labelwidth = 33.3
+      if (_col === '1' || item.entireLine === 'true' || ['textarea','hint','checkcard','brafteditor'].includes(item.type)) {
+        item.span = 24
+        if (_col === '2') {
+          item.labelwidth = 16.3
+        } else if (_col === '3') {
+          item.labelwidth = 10.5
+        } else if (_col === '4') {
+          item.labelwidth = 8.3
+        }
+      } else if (_col === '2') {
+        item.span = 12
+      } else if (_col === '3') {
+        item.span = 8
+      } else if (_col === '4') {
+        item.span = 6
+      }
+      return item
+    })
+  }
+
+  return config
+}
+
+/**
  * @description 鍗囩骇涓昏〃淇℃伅
  * @param {Object}   config      椤甸潰閰嶇疆淇℃伅
  * @return {Object}  config

--
Gitblit v1.8.0