From c33ac9ddcdbed91bd2267bed2a96199441806a04 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 22 九月 2022 17:00:15 +0800
Subject: [PATCH] 2022-09-22
---
src/utils/utils-update.js | 390 +++++++++++++++++++++++++++++++++++++------------------
1 files changed, 260 insertions(+), 130 deletions(-)
diff --git a/src/utils/utils-update.js b/src/utils/utils-update.js
index eb738e5..29b1fa1 100644
--- a/src/utils/utils-update.js
+++ b/src/utils/utils-update.js
@@ -1,147 +1,277 @@
-import { fromJS } from 'immutable'
-import Utils from './utils.js'
+/**
+ * @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
-export default class UpdateUtils {
- /**
- * @description 鍗囩骇涓昏〃淇℃伅
- * @param {Object} config 椤甸潰閰嶇疆淇℃伅
- * @return {Object} config
- */
- static updateCommonTable (config) {
- if (!config.version || config.version < '1.0') {
- config.version = '1.0'
- // 鍏煎鏍囩
- if (!config.tabgroups) {
- config.tabgroups = [{ uuid: 'tabs', sublist: [] }]
- } else if (typeof(config.tabgroups[0]) === 'string') {
- let _tabgroups = []
- config.tabgroups.forEach(groupId => {
- let _group = {
- uuid: groupId,
- sublist: fromJS(config[groupId]).toJS()
- }
-
- delete config[groupId]
-
- _tabgroups.push(_group)
- })
-
- config.tabgroups = _tabgroups
- }
-
- // 鍏煎鍥捐〃
- if (!config.charts) {
- config.expand = true
- config.charts = [{ uuid: Utils.getuuid(), label: '', title: '', chartType: 'table', icon: 'table', Hide: 'false', blacklist: [] }]
- } else {
- config.charts.forEach(card => {
- if (card.chartType === 'card') {
- card.details = card.details.map(_cell => {
- _cell.fontSize = _cell.fontSize || 14
- if (!_cell.width) {
- _cell.width = 100
- } else if (_cell.width === 'helf') {
- _cell.width = 50
- } else if (_cell.width === 'third') {
- _cell.width = 33
- }
- if (!_cell.fontWeight && _cell.bold === 'true') {
- _cell.fontWeight = 'normal'
- }
- _cell.height = _cell.height || 1
-
- return _cell
- })
- }
- })
- }
- }
-
- if (config.version < '1.1') {
- if (config.setting.interType === 'inner' && !config.setting.innerFunc) {
- config.setting.interType = 'system'
- }
- // 鍏煎鎺ュ彛绫诲瀷
- config.action = config.action.map(item => {
- if (item.intertype === 'inner' && !item.innerFunc) {
- item.intertype = 'system'
+ if (!group.default) {
+ fields.push({
+ type: 'split',
+ label: group.label,
+ uuid: group.uuid,
+ span: 24
+ })
}
- return item
+
+ fields.push(...group.sublist)
})
+ config.fields = fields
}
+ delete config.groups
- config.version = '1.1'
- config.Template = 'CommonTable'
+ let _col = config.setting.cols || '2'
- return config
+ 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
+ })
}
- /**
- * @description 鍗囩骇瀛愯〃淇℃伅
- * @param {Object} config 椤甸潰閰嶇疆淇℃伅
- * @return {Object} config
- */
- static updateSubTable (config) {
- if (!config.version || config.version < '1.0') {
- config.version = '1.0'
- // 鍏煎鍥捐〃
- if (!config.charts) {
- config.expand = false
- config.charts = [{
- uuid: Utils.getuuid(),
- label: '',
- title: '',
- chartType: 'table',
- icon: 'table',
- Hide: 'false',
- blacklist: []
- }]
- } else {
- config.charts.forEach(card => {
- if (card.chartType === 'card') {
- card.details = card.details.map(_cell => {
- if (!_cell.fontSize) {
- _cell.fontSize = 14
- }
- if (!_cell.width) {
- _cell.width = 100
- } else if (_cell.width === 'helf') {
- _cell.width = 50
- } else if (_cell.width === 'third') {
- _cell.width = 33
- }
-
- if (_cell.bold === 'true') {
- _cell.fontWeight = 'normal'
- }
+ return config
+}
- if (!_cell.height) {
- _cell.height = 1
- }
+/**
+ * @description 鍗囩骇涓昏〃淇℃伅
+ * @param {Object} config 椤甸潰閰嶇疆淇℃伅
+ * @return {Object} config
+ */
+export function updateCommonTable (config) {
+ if (!config.version || config.version < '1.0') {
+ config.version = '1.0'
+ // 鍏煎鏍囩
+ if (!config.tabgroups) {
+ config.tabgroups = [{ uuid: 'tabs', sublist: [] }]
+ } else if (typeof(config.tabgroups[0]) === 'string') {
+ let _tabgroups = []
+ config.tabgroups.forEach(groupId => {
+ let _group = {
+ uuid: groupId,
+ sublist: config[groupId]
+ }
- return _cell
- })
- }
- })
- }
+ delete config[groupId]
+
+ _tabgroups.push(_group)
+ })
+
+ config.tabgroups = _tabgroups
}
- if (config.version < '1.1') {
- if (config.setting.interType === 'inner' && !config.setting.innerFunc) {
- config.setting.interType = 'system'
- }
- // 鍏煎鎺ュ彛绫诲瀷
- config.action = config.action.map(item => {
- if (item.intertype === 'inner' && !item.innerFunc) {
- item.intertype = 'system'
+ // 鍏煎鍥捐〃
+ if (!config.charts) {
+ config.expand = true
+ config.charts = [{ uuid: '$$normaltable', label: '', title: '', chartType: 'table', icon: 'table', Hide: 'false', blacklist: [] }]
+ } else {
+ config.charts.forEach(card => {
+ if (card.chartType === 'card') {
+ card.details = card.details.map(_cell => {
+ _cell.fontSize = _cell.fontSize || 14
+ if (!_cell.width) {
+ _cell.width = 100
+ } else if (_cell.width === 'helf') {
+ _cell.width = 50
+ } else if (_cell.width === 'third') {
+ _cell.width = 33
+ }
+ if (!_cell.fontWeight && _cell.bold === 'true') {
+ _cell.fontWeight = 'normal'
+ }
+ _cell.height = _cell.height || 1
+
+ return _cell
+ })
}
- return item
})
}
-
- config.version = '1.1'
- config.Template = 'SubTable'
-
- return config
}
+
+ if (config.version < '1.1') {
+ config.version = '1.1'
+ if (config.setting.interType === 'inner' && !config.setting.innerFunc) {
+ config.setting.interType = 'system'
+ }
+ // 鍏煎鎺ュ彛绫诲瀷
+ config.action = config.action.map(item => {
+ if (item.intertype === 'inner' && !item.innerFunc) {
+ item.intertype = 'system'
+ }
+ return item
+ })
+ }
+
+ if (config.version < '1.2') {
+ config.version = '1.2'
+ // 鍏煎鍔熻兘鎸夐挳
+ config.action = config.action.map(item => {
+ if (item.execMode) {
+ item.OpenType = 'funcbutton'
+ } else if (item.OpenType === 'blank') {
+ item.OpenType = 'tab'
+ }
+ return item
+ })
+ }
+
+ if (config.version < '2.0') {
+ config.version = '2.0'
+ // 鍘婚櫎浼犵粺table涓殑鏍囩锛岃皟鏁存暟鎹粨鏋�
+ if (config.charts && config.charts.length === 1) {
+ config.charts = null
+ }
+ }
+
+ config.Template = 'CommonTable'
+
+ return config
+}
+
+/**
+ * @description 鍗囩骇瀛愯〃淇℃伅
+ * @param {Object} config 椤甸潰閰嶇疆淇℃伅
+ * @return {Object} config
+ */
+export function updateSubTable (config) {
+ if (!config.version || config.version < '1.0') {
+ config.version = '1.0'
+ // 鍏煎鍥捐〃
+ if (!config.charts) {
+ config.expand = false
+ config.charts = [{
+ uuid: '$$normalsubtable',
+ label: '',
+ title: '',
+ chartType: 'table',
+ icon: 'table',
+ Hide: 'false',
+ blacklist: []
+ }]
+ } else {
+ config.charts.forEach(card => {
+ if (card.chartType === 'card') {
+ card.details = card.details.map(_cell => {
+ if (!_cell.fontSize) {
+ _cell.fontSize = 14
+ }
+ if (!_cell.width) {
+ _cell.width = 100
+ } else if (_cell.width === 'helf') {
+ _cell.width = 50
+ } else if (_cell.width === 'third') {
+ _cell.width = 33
+ }
+
+ if (_cell.bold === 'true') {
+ _cell.fontWeight = 'normal'
+ }
+
+ if (!_cell.height) {
+ _cell.height = 1
+ }
+
+ return _cell
+ })
+ }
+ })
+ }
+ }
+
+ if (config.version < '1.1') {
+ config.version = '1.1'
+ if (config.setting.interType === 'inner' && !config.setting.innerFunc) {
+ config.setting.interType = 'system'
+ }
+ // 鍏煎鎺ュ彛绫诲瀷
+ config.action = config.action.map(item => {
+ if (item.intertype === 'inner' && !item.innerFunc) {
+ item.intertype = 'system'
+ }
+ return item
+ })
+ }
+
+ if (config.version < '1.2') {
+ config.version = '1.2'
+ // 鍏煎鍔熻兘鎸夐挳
+ config.action = config.action.map(item => {
+ if (item.execMode) {
+ item.OpenType = 'funcbutton'
+ } else if (item.OpenType === 'blank') {
+ item.OpenType = 'tab'
+ }
+ return item
+ })
+ }
+
+ if (config.version < '2.0') {
+ config.version = '2.0'
+ // 鍘婚櫎浼犵粺table涓殑鏍囩锛岃皟鏁存暟鎹粨鏋�
+ if (config.charts && config.charts.length === 1) {
+ config.charts = null
+ }
+ }
+
+ config.Template = 'SubTable'
+
+ return config
+}
+
+/**
+ * @description 鍗囩骇寮圭獥瀛愯〃淇℃伅
+ * @param {Object} config 椤甸潰閰嶇疆淇℃伅
+ * @return {Object} config
+ */
+export function updateSubTabTable (config) {
+ if (!config.version || config.version < '1.1') {
+ config.version = '1.1'
+ if (config.setting.interType === 'inner' && !config.setting.innerFunc) {
+ config.setting.interType = 'system'
+ }
+ // 鍏煎鎺ュ彛绫诲瀷
+ config.action = config.action.map(item => {
+ if (item.intertype === 'inner' && !item.innerFunc) {
+ item.intertype = 'system'
+ }
+ return item
+ })
+ }
+
+ if (config.version < '1.2') {
+ config.version = '1.2'
+ // 鍏煎鍔熻兘鎸夐挳
+ config.action = config.action.map(item => {
+ if (item.execMode) {
+ item.OpenType = 'funcbutton'
+ } else if (item.OpenType === 'blank') {
+ item.OpenType = 'tab'
+ }
+ return item
+ })
+ }
+
+ config.Template = 'SubTable'
+
+ return config
}
\ No newline at end of file
--
Gitblit v1.8.0