From 1a176e4bdba485301385caac1a29102e598d25cc Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 13 五月 2025 11:32:02 +0800 Subject: [PATCH] 2025-05-13 --- src/menu/replaceField/index.jsx | 1014 ++++++++++++++++++++++++++++++++++------------------------ 1 files changed, 590 insertions(+), 424 deletions(-) diff --git a/src/menu/replaceField/index.jsx b/src/menu/replaceField/index.jsx index df1506a..fbca31e 100644 --- a/src/menu/replaceField/index.jsx +++ b/src/menu/replaceField/index.jsx @@ -5,15 +5,14 @@ import moment from 'moment' import Api from '@/api' -import options from '@/store/options.js' import Utils from '@/utils/utils.js' +import { setLangSingleTrans } from '@/utils/utils-custom.js' import SettingForm from './settingform' import { queryTableSql } from '@/utils/option.js' import './index.scss' class ReplaceField extends Component { static propTpyes = { - type: PropTypes.string, config: PropTypes.object, updateConfig: PropTypes.func } @@ -37,16 +36,17 @@ func: 'sPC_Get_SelectedList', LText: queryTableSql, obj_name: 'data', - arr_field: 'TbName,Remark' + arr_field: 'TbName,Remark', + exec_type: 'x' } - param.LText = Utils.formatOptions(param.LText) + param.LText = Utils.formatOptions(param.LText, 'x') param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt(param.LText, param.timestamp) + param.secretkey = Utils.encrypt('', param.timestamp) param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) // 浜戠鏁版嵁楠岃瘉 - if (options.cloudServiceApi) { // 涓斿瓨鍦ㄤ簯绔湴鍧� - param.rduri = options.cloudServiceApi + if (window.GLOB.cloudServiceApi) { // 涓斿瓨鍦ㄤ簯绔湴鍧� + param.rduri = window.GLOB.cloudServiceApi param.userid = sessionStorage.getItem('CloudUserID') || '' param.LoginUID = sessionStorage.getItem('CloudLoginUID') || '' } @@ -89,9 +89,9 @@ if (res.resource === 'custom') { if (res.reType === 'name') { - let map = {[res.label.toLowerCase()]: { - FieldDec: res.label, - FieldName: res.field, + let map = {[res.field.toLowerCase()]: { + FieldDec: res.field, + FieldName: res.label, datatype: '' }} @@ -105,10 +105,12 @@ this.execLabel(map) } + } else if (res.resource === 'langs') { + this.getDicts() } else { let param = {func: 'sPC_Get_FieldName', TBName: res.table} - if (options.cloudServiceApi) { // 涓斿瓨鍦ㄤ簯绔湴鍧� - param.rduri = options.cloudServiceApi + if (window.GLOB.cloudServiceApi) { // 涓斿瓨鍦ㄤ簯绔湴鍧� + param.rduri = window.GLOB.cloudServiceApi param.userid = sessionStorage.getItem('CloudUserID') || '' param.LoginUID = sessionStorage.getItem('CloudLoginUID') || '' } @@ -153,312 +155,501 @@ }) } + getDicts = () => { + let sql = `select mother_tongue as reg,translation as value,use_type as type,case when use_type='menu' then '鑿滃崟' when use_type='button' then '鎸夐挳' when use_type='title' then '鏍囬' when use_type='list' then '閫夐」' else '鏂囨湰' end as use_type_text from s_app_lang_translation where appkey=@appkey@ and deleted=0 and translation != '' and lang='${sessionStorage.getItem('lang') || ''}'` + + let param = { + func: 'sPC_Get_SelectedList', + LText: Utils.formatOptions(sql, 'x'), + obj_name: 'data', + arr_field: 'reg,value,type', + exec_type: 'x' + } + + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + param.secretkey = Utils.encrypt('', param.timestamp) + param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) + + this.$Api.getCloudConfig(param).then(result => { + if (!result.status) { + notification.warning({ + top: 92, + message: result.message, + duration: 5 + }) + this.setState({ + confirming: false + }) + return + } else if (!result.data || result.data.length === 0) { + notification.warning({ + top: 92, + message: '鏇挎崲鏁版嵁涓虹┖锛岃妫�鏌ュ綋鍓嶈瑷�涓嬫槸鍚﹀瓨鍦ㄨ瑷�鍖咃紒', + duration: 5 + }) + this.setState({ + confirming: false + }) + return + } + + let btnDict = {} + let titDict = {} + let lisDict = {} + let menuDict = {} + let regs = [] + + result.data.forEach(item => { + if (item.type === 'button') { + btnDict[item.reg] = item.value + } else if (item.type === 'title') { + titDict[item.reg] = item.value + } else if (item.type === 'list') { + lisDict[item.reg] = item.value + } else if (item.type === 'text') { + regs.push({reg: new RegExp(item.reg, 'g'), value: item.value, sort: item.reg.length}) + } else if (item.type === 'menu') { + menuDict[item.reg] = item.value + } + }) + + regs.sort((a, b) => b.sort - a.sort) + + let config = fromJS(this.props.config).toJS() + + setLangSingleTrans(config, btnDict, titDict, lisDict, menuDict, regs) + + this.setState({ + confirming: false, + visible: false + }) + + if (is(fromJS(this.props.config), fromJS(config))) { + notification.success({ + top: 92, + message: '鏈彂鐜伴渶瑕佹浛鎹㈢殑淇℃伅銆�', + duration: 3 + }) + return + } + + notification.success({ + top: 92, + message: '鏇挎崲宸插畬鎴愩��', + duration: 3 + }) + this.props.updateConfig(config) + }) + } + // 渚濇嵁鍘熷瓧娈垫浛鎹负鏂板瓧娈� exec = (map) => { - const { type } = this.props let config = fromJS(this.props.config).toJS() - if (type === 'custom') { - let _replace = (components) => { - return components.map(item => { - if (item.type === 'tabs') { - item.subtabs.forEach(tab => { - tab.components = _replace(tab.components) - }) - return item - } else if (item.type === 'group') { - item.components = _replace(item.components) - return item - } - - if (item.columns) { - item.columns = item.columns.map(col => { - let cell = map[col.field.toLowerCase()] - if (cell) { - col.field = cell.FieldName - if (cell.datatype) { - col.datatype = cell.datatype - } - } - return col - }) - } - if (item.search) { - item.search = item.search.map(col => { - if (col.field && map[col.field.toLowerCase()]) { - col.field = map[col.field.toLowerCase()].FieldName - } - return col - }) - } + let getVal = (val) => { + let _val = val.toLowerCase() + if (map[_val]) { + return map[_val].FieldName + } + return val + } - if (item.action) { - item.action.forEach(m => { - if (m.modal && m.modal.fields) { - m.modal.fields = m.modal.fields.map(col => { - if (col.field && map[col.field.toLowerCase()]) { - col.field = map[col.field.toLowerCase()].FieldName - } - return col - }) - } - if (m.verify && m.verify.columns) { - m.verify.columns = m.verify.columns.map(col => { - if (col.Column && map[col.Column.toLowerCase()]) { - col.Column = map[col.Column.toLowerCase()].FieldName - } - return col - }) - } - if (m.config && m.config.components) { - m.config.components = _replace(m.config.components) - } - }) - } - - if (item.subcards) { - item.subcards.forEach(card => { - if (card.elements) { // 鍗$墖 - card.elements = card.elements.map(m => { - if (m.datatype === 'dynamic' && map[m.field.toLowerCase()]) { - m.field = map[m.field.toLowerCase()].FieldName - } - if (m.modal && m.modal.fields) { - m.modal.fields = m.modal.fields.map(col => { - if (col.field && map[col.field.toLowerCase()]) { - col.field = map[col.field.toLowerCase()].FieldName - } - return col - }) - } - if (m.verify && m.verify.columns) { - m.verify.columns = m.verify.columns.map(col => { - if (col.Column && map[col.Column.toLowerCase()]) { - col.Column = map[col.Column.toLowerCase()].FieldName - } - return col - }) - } - if (m.config && m.config.components) { - m.config.components = _replace(m.config.components) - } - return m - }) - } - - if (card.backElements) { // 鍗$墖 - card.backElements = card.backElements.map(m => { - if (m.datatype === 'dynamic' && map[m.field.toLowerCase()]) { - m.field = map[m.field.toLowerCase()].FieldName - } - if (m.modal && m.modal.fields) { - m.modal.fields = m.modal.fields.map(col => { - if (col.field && map[col.field.toLowerCase()]) { - col.field = map[col.field.toLowerCase()].FieldName - } - return col - }) - } - if (m.verify && m.verify.columns) { - m.verify.columns = m.verify.columns.map(col => { - if (col.Column && map[col.Column.toLowerCase()]) { - col.Column = map[col.Column.toLowerCase()].FieldName - } - return col - }) - } - if (m.config && m.config.components) { - m.config.components = _replace(m.config.components) - } - return m - }) - } - - if (card.fields) { // 琛ㄥ崟 - card.fields = card.fields.map(m => { - if (m.field && map[m.field.toLowerCase()]) { - m.field = map[m.field.toLowerCase()].FieldName - } - return m - }) - } - }) - } - - if (item.elements) { - item.elements = item.elements.map(m => { - if (m.datatype === 'dynamic' && map[m.field.toLowerCase()]) { - m.field = map[m.field.toLowerCase()].FieldName - } - if (m.modal && m.modal.fields) { - m.modal.fields = m.modal.fields.map(col => { - if (col.field && map[col.field.toLowerCase()]) { - col.field = map[col.field.toLowerCase()].FieldName - } - return col - }) - } - if (m.verify && m.verify.columns) { - m.verify.columns = m.verify.columns.map(col => { - if (col.Column && map[col.Column.toLowerCase()]) { - col.Column = map[col.Column.toLowerCase()].FieldName - } - return col - }) - } - if (m.config && m.config.components) { - m.config.components = _replace(m.config.components) - } - return m - }) - } - - if (item.plot) { - if (item.plot.Xaxis && map[item.plot.Xaxis.toLowerCase()]) { - item.plot.Xaxis = map[item.plot.Xaxis.toLowerCase()].FieldName + let resetForm = (m) => { + if (m.field) { + m.field = getVal(m.field) + } + if (m.type === 'split' && m.splitctrl) { + m.splitctrl = getVal(m.splitctrl) + } + if (m.tabField) { + m.tabField = getVal(m.tabField) + } + if (m.linkField) { + m.linkField = getVal(m.linkField) + } + if (m.supField) { + m.supField = getVal(m.supField) + } + if (m.phoneField) { + m.phoneField = getVal(m.phoneField) + } + if (m.linkSubField) { + m.linkSubField = m.linkSubField.map(n => getVal(n)) + m.linkSubField = Array.from(new Set(m.linkSubField)) + } + } + let resetMark = (m) => { + m.marks = m.marks.map(n => { + if (n.field && Array.isArray(n.field)) { + if (n.field[1] === 'static') { + n.field[0] = getVal(n.field[0]) + } else { + if (n.field[0]) { + n.field[0] = getVal(n.field[0]) } - // 缁熻鍥� - if (item.plot.InfoValue && map[item.plot.InfoValue.toLowerCase()]) { - item.plot.InfoValue = map[item.plot.InfoValue.toLowerCase()].FieldName - } - if (item.plot.InfoType && map[item.plot.InfoType.toLowerCase()]) { - item.plot.InfoType = map[item.plot.InfoType.toLowerCase()].FieldName - } - // 鍗犳瘮鍥� - if (item.plot.valueField && map[item.plot.valueField.toLowerCase()]) { - item.plot.valueField = map[item.plot.valueField.toLowerCase()].FieldName - } - if (item.plot.labelField && map[item.plot.labelField.toLowerCase()]) { - item.plot.labelField = map[item.plot.labelField.toLowerCase()].FieldName - } - // 楗煎浘 - if (item.plot.type && map[item.plot.type.toLowerCase()]) { - item.plot.type = map[item.plot.type.toLowerCase()].FieldName - } - // 鏁g偣鍥� - if (item.plot.gender && map[item.plot.gender.toLowerCase()]) { - item.plot.gender = map[item.plot.gender.toLowerCase()].FieldName - } - if (item.Yaxis) { - if (Array.isArray(item.Yaxis)) { - item.Yaxis = item.Yaxis.map(m => { - if (map[m.toLowerCase()]) { - return map[m.toLowerCase()].FieldName - } - return m - }) - } else { - if (item.Yaxis && map[item.Yaxis.toLowerCase()]) { - item.Yaxis = map[item.Yaxis.toLowerCase()].FieldName - } - } + if (n.field[2]) { + n.field[2] = getVal(n.field[2]) } } + } - if (item.cols) { - let _update = (cols) => { - return cols.map(col => { - if (col.type === 'custom' && col.elements) { - col.elements = col.elements.map(m => { - if (m.eleType === 'button') { - if (m.modal && m.modal.fields) { - m.modal.fields = m.modal.fields.map(col => { - if (col.field && map[col.field.toLowerCase()]) { - col.field = map[col.field.toLowerCase()].FieldName - } - return col - }) - } - if (m.verify && m.verify.columns) { - m.verify.columns = m.verify.columns.map(col => { - if (col.Column && map[col.Column.toLowerCase()]) { - col.Column = map[col.Column.toLowerCase()].FieldName - } - return col - }) - } - if (m.config && m.config.components) { - m.config.components = _replace(m.config.components) - } - } else { - if (m.datatype === 'dynamic' && map[m.field.toLowerCase()]) { - m.field = map[m.field.toLowerCase()].FieldName - } - } + return n + }) + } + let resetElement = (m) => { + if (m.field) { + m.field = getVal(m.field) + } + if (m.posterField) { + m.posterField = getVal(m.posterField) + } + if (m.bgImage) { + m.bgImage = getVal(m.bgImage) + } + if (m.linkurl && /^[a-zA-Z0-9_]+$/.test(m.linkurl)) { + m.linkurl = getVal(m.linkurl) + } + if (m.modal && m.modal.fields) { + if (m.modal.setting) { + if (m.modal.setting.focus) { + m.modal.setting.focus = getVal(m.modal.setting.focus) + } + if (m.modal.setting.errFocus) { + m.modal.setting.errFocus = getVal(m.modal.setting.errFocus) + } + } + m.modal.fields = m.modal.fields.map(col => { + resetForm(col) + return col + }) + } + if (m.verify) { + if (m.verify.columns) { + m.verify.columns = m.verify.columns.map(col => { + if (col.Column) { + col.Column = getVal(col.Column) + } + return col + }) + } + if (m.verify.uniques) { + m.verify.uniques = m.verify.uniques.map(col => { + if (col.field) { + col.field = col.field.split(',').map(_field => { + if (_field === 'BID') return _field + return getVal(_field) + }).join(',') + } + return col + }) + } + if (m.verify.billcodes) { + m.verify.billcodes = m.verify.billcodes.map(col => { + if (col.field) { + col.field = getVal(col.field) + } + if (col.linkField && col.linkField !== 'BID') { + col.linkField = getVal(col.linkField) + } + return col + }) + } - return m - }) - } else if (col.type === 'colspan') { - col.subcols = _update(col.subcols) - } else if (col.field) { - if (map[col.field.toLowerCase()]) { - col.field = map[col.field.toLowerCase()].FieldName - } - } - - return col + if (m.verify.accountfield && m.verify.accountfield !== 'BID') { + m.verify.accountfield = getVal(m.verify.accountfield) + } + if (m.verify.voucher && m.verify.voucher.linkField && m.verify.voucher.linkField !== 'BID') { + m.verify.voucher.linkField = getVal(m.verify.voucher.linkField) + } + } + if (m.controlField) { + m.controlField = getVal(m.controlField) + } + + if (m.marks && m.marks.length) { + resetMark(m) + } + + if (m.config && m.config.components) { + m.config.components = _replace(m.config.components) + } + } + + let _replace = (components) => { + return components.map(item => { + if (item.type === 'tabs') { + item.subtabs.forEach(tab => { + tab.components = _replace(tab.components) + }) + return item + } else if (item.type === 'group') { + item.components = _replace(item.components) + return item + } + + if (item.columns) { + item.columns = item.columns.map(col => { + let cell = map[col.field.toLowerCase()] + if (cell) { + col.field = cell.FieldName + if (cell.datatype) { + col.datatype = cell.datatype + } + } + return col + }) + } + if (item.search) { + item.search = item.search.map(col => { + if (col.field) { + col.field = getVal(col.field) + } + return col + }) + } + + if (item.action) { + item.action.forEach(m => { + resetElement(m) + }) + } + + if (item.subcards) { + item.subcards.forEach(card => { + if (card.setting) { + if (card.setting.controlField) { + card.setting.controlField = getVal(card.setting.controlField) + } + if (card.setting.bgField) { + card.setting.bgField = getVal(card.setting.bgField) + } + if (card.setting.menuType) { + card.setting.menuType = getVal(card.setting.menuType) + } + } + + if (card.elements) { // 鍗$墖 + card.elements = card.elements.map(m => { + resetElement(m) + return m }) } - item.cols = _update(item.cols) - } + if (card.backElements) { // 鍗$墖 + card.backElements = card.backElements.map(m => { + resetElement(m) + return m + }) + } - if (item.subtype === 'basetable') { - item.cols = item.cols.map(col => { - if (col.field && map[col.field.toLowerCase()]) { - col.field = map[col.field.toLowerCase()].FieldName + if (card.fields) { // 琛ㄥ崟 + card.fields = card.fields.map(m => { + resetForm(m) + return m + }) + } + + if (card.subButton) { + resetElement(card.subButton) + + if (card.subButton.resetForms) { + card.subButton.resetForms = card.subButton.resetForms.map(n => getVal(n)) } + } + }) + } + + if (item.elements) { + item.elements = item.elements.map(m => { + resetElement(m) + return m + }) + } + + if (item.plot) { + if (item.plot.Xaxis) { + item.plot.Xaxis = getVal(item.plot.Xaxis) + } + // 缁熻鍥� + if (item.plot.InfoValue) { + item.plot.InfoValue = getVal(item.plot.InfoValue) + } + if (item.plot.InfoType) { + item.plot.InfoType = getVal(item.plot.InfoType) + } + // 鍗犳瘮鍥� + if (item.plot.valueField) { + item.plot.valueField = getVal(item.plot.valueField) + } + if (item.plot.labelField) { + item.plot.labelField = getVal(item.plot.labelField) + } + // 楗煎浘 + if (item.plot.type) { + item.plot.type = getVal(item.plot.type) + } + // 鏁g偣鍥� + if (item.plot.gender) { + item.plot.gender = getVal(item.plot.gender) + } + if (item.Yaxis) { + if (Array.isArray(item.Yaxis)) { + item.Yaxis = item.Yaxis.map(m => getVal(m)) + } else { + item.Yaxis = getVal(item.Yaxis) + } + } + } + + if (item.cols) { + let _update = (cols) => { + return cols.map(col => { + if (col.type === 'custom' && col.elements) { + col.elements = col.elements.map(m => { + resetElement(m) + return m + }) + } else if (col.type === 'colspan') { + col.subcols = _update(col.subcols) + } else if (col.field) { + col.field = getVal(col.field) + } + return col }) } - return item - }) - } + item.cols = _update(item.cols) - config.components = _replace(config.components) - // } else if (type === 'table') { - // config.columns = config.columns.map(col => { - // if (col.field && map[col.field.toLowerCase()]) { - // col.field = map[col.field.toLowerCase()].FieldName - // } - // return col - // }) - - // config.search = config.search.map(col => { - // if (col.field && map[col.field.toLowerCase()]) { - // col.field = map[col.field.toLowerCase()].FieldName - // } - // if (col.datefield && map[col.datefield.toLowerCase()]) { - // col.datefield = map[col.datefield.toLowerCase()].FieldName - // } - // return col - // }) - - // config.action = config.action.map(m => { - // if (m.verify && m.verify.columns) { - // m.verify.columns = m.verify.columns.map(col => { - // if (col.Column && map[col.Column.toLowerCase()]) { - // col.Column = map[col.Column.toLowerCase()].FieldName - // } - // return col - // }) - // } - // return m - // }) - } else if (type === 'form') { - config.fields = config.fields.map(col => { - if (col.field && map[col.field.toLowerCase()]) { - col.field = map[col.field.toLowerCase()].FieldName + if (item.lineMarks) { + item.lineMarks = item.lineMarks.map(n => { + if (n.field && Array.isArray(n.field)) { + if (n.field[1] === 'static') { + n.field[0] = getVal(n.field[0]) + } else { + if (n.field[0]) { + n.field[0] = getVal(n.field[0]) + } + if (n.field[2]) { + n.field[2] = getVal(n.field[2]) + } + } + } + + return n + }) + } } - return col + + if (item.subMenus) { + item.subMenus = item.subMenus.map(m => { + if (m.setting && m.setting.tip) { + m.setting.tip = getVal(m.setting.tip) + } + return m + }) + } + + if (item.wrap) { + if (item.wrap.field) { + item.wrap.field = getVal(item.wrap.field) + } + if (item.wrap.tipField) { + item.wrap.tipField = getVal(item.wrap.tipField) + } + if (item.wrap.controlField) { + item.wrap.controlField = getVal(item.wrap.controlField) + } + if (item.wrap.valueField) { + item.wrap.valueField = getVal(item.wrap.valueField) + } + if (item.wrap.labelField) { + item.wrap.labelField = getVal(item.wrap.labelField) + } + if (item.wrap.parentField) { + item.wrap.parentField = getVal(item.wrap.parentField) + } + if (item.wrap.broadcast) { + item.wrap.broadcast = getVal(item.wrap.broadcast) + } + if (item.wrap.jumpField) { + item.wrap.jumpField = getVal(item.wrap.jumpField) + } + if (item.wrap.link) { + item.wrap.link = getVal(item.wrap.link) + } + if (item.wrap.linkField) { + item.wrap.linkField = getVal(item.wrap.linkField) + } + if (item.wrap.focus) { + item.wrap.focus = getVal(item.wrap.focus) + } + if (item.wrap.refocus) { + item.wrap.refocus = getVal(item.wrap.refocus) + } + if (item.wrap.statusControl) { + item.wrap.statusControl = getVal(item.wrap.statusControl) + } + if (item.wrap.timeField) { + item.wrap.timeField = getVal(item.wrap.timeField) + } + if (item.wrap.endField) { + item.wrap.endField = getVal(item.wrap.endField) + } + if (item.wrap.remarkField) { + item.wrap.remarkField = getVal(item.wrap.remarkField) + } + if (item.wrap.colorField) { + item.wrap.colorField = getVal(item.wrap.colorField) + } + if (item.wrap.menuType) { + item.wrap.menuType = getVal(item.wrap.menuType) + } + + if (item.type === 'timeline') { + if (item.wrap.label) { + item.wrap.label = getVal(item.wrap.label) + } + if (item.wrap.node) { + item.wrap.node = getVal(item.wrap.node) + } + } + } + + return item }) } + + config.components = _replace(config.components) + + config.interfaces && config.interfaces.forEach(item => { + if (item.columns) { + item.columns = item.columns.map(col => { + let cell = map[col.field.toLowerCase()] + if (cell) { + col.field = cell.FieldName + if (cell.datatype) { + col.datatype = cell.datatype + } + } + return col + }) + } + }) this.setState({ confirming: false, visible: false }) + + if (is(fromJS(this.props.config), fromJS(config))) { + notification.success({ + top: 92, + message: '鏈煡璇㈠埌闇�瑕佹浛鎹㈢殑瀛楁銆�', + duration: 3 + }) + return + } notification.success({ top: 92, @@ -470,160 +661,135 @@ // 渚濇嵁瀛楁鏇挎崲鍚嶇О execLabel = (map) => { - const { type } = this.props let config = fromJS(this.props.config).toJS() - if (type === 'custom') { - let _replace = (components) => { - return components.map(item => { - if (item.type === 'tabs') { - item.subtabs.forEach(tab => { - tab.components = _replace(tab.components) - }) - return item - } else if (item.type === 'group') { - item.components = _replace(item.components) - return item - } - - if (item.columns) { - item.columns = item.columns.map(col => { - if (col.field && map[col.field.toLowerCase()]) { - col.label = map[col.field.toLowerCase()].FieldDec - } - return col - }) - } - if (item.search) { - item.search = item.search.map(col => { - if (col.field && map[col.field.toLowerCase()]) { - col.label = map[col.field.toLowerCase()].FieldDec - } - return col - }) - } + let _replace = (components) => { + return components.map(item => { + if (item.type === 'tabs') { + item.subtabs.forEach(tab => { + tab.components = _replace(tab.components) + }) + return item + } else if (item.type === 'group') { + item.components = _replace(item.components) + return item + } + + if (item.columns) { + item.columns = item.columns.map(col => { + if (col.field && map[col.field.toLowerCase()]) { + col.label = map[col.field.toLowerCase()].FieldDec + } + return col + }) + } + if (item.search) { + item.search = item.search.map(col => { + if (col.field && map[col.field.toLowerCase()]) { + col.label = map[col.field.toLowerCase()].FieldDec + } + return col + }) + } - if (item.action) { - item.action.forEach(m => { - if (m.modal && m.modal.fields) { - m.modal.fields = m.modal.fields.map(col => { - if (col.field && map[col.field.toLowerCase()]) { - col.label = map[col.field.toLowerCase()].FieldDec - } - return col - }) - } - if (m.verify && m.verify.columns) { - m.verify.columns = m.verify.columns.map(col => { - if (col.Column && map[col.Column.toLowerCase()]) { - col.Text = map[col.Column.toLowerCase()].FieldDec - } - return col - }) - } - if (m.config && m.config.components) { - m.config.components = _replace(m.config.components) - } - }) - } - - if (item.cols) { - let _update = (cols) => { - return cols.map(col => { - if (col.type === 'custom' && col.elements) { - col.elements = col.elements.map(m => { - if (m.eleType === 'button') { - if (m.modal && m.modal.fields) { - m.modal.fields = m.modal.fields.map(col => { - if (col.field && map[col.field.toLowerCase()]) { - col.label = map[col.field.toLowerCase()].FieldDec - } - return col - }) - } - if (m.verify && m.verify.columns) { - m.verify.columns = m.verify.columns.map(col => { - if (col.Column && map[col.Column.toLowerCase()]) { - col.Text = map[col.Column.toLowerCase()].FieldDec - } - return col - }) - } - if (m.config && m.config.components) { - m.config.components = _replace(m.config.components) - } - } - - return m - }) - } else if (col.type === 'colspan') { - col.subcols = _update(col.subcols) - } else if (col.field) { - if (map[col.field.toLowerCase()]) { - col.label = map[col.field.toLowerCase()].FieldDec - } + if (item.action) { + item.action.forEach(m => { + if (m.modal && m.modal.fields) { + m.modal.fields = m.modal.fields.map(col => { + if (col.field && map[col.field.toLowerCase()]) { + col.label = map[col.field.toLowerCase()].FieldDec } - return col }) } + if (m.verify && m.verify.columns) { + m.verify.columns = m.verify.columns.map(col => { + if (col.Column && map[col.Column.toLowerCase()]) { + col.Text = map[col.Column.toLowerCase()].FieldDec + } + return col + }) + } + if (m.config && m.config.components) { + m.config.components = _replace(m.config.components) + } + }) + } - item.cols = _update(item.cols) - } + if (item.cols) { + let _update = (cols) => { + return cols.map(col => { + if (col.type === 'custom' && col.elements) { + col.elements = col.elements.map(m => { + if (m.eleType === 'button') { + if (m.modal && m.modal.fields) { + m.modal.fields = m.modal.fields.map(col => { + if (col.field && map[col.field.toLowerCase()]) { + col.label = map[col.field.toLowerCase()].FieldDec + } + return col + }) + } + if (m.verify && m.verify.columns) { + m.verify.columns = m.verify.columns.map(col => { + if (col.Column && map[col.Column.toLowerCase()]) { + col.Text = map[col.Column.toLowerCase()].FieldDec + } + return col + }) + } + if (m.config && m.config.components) { + m.config.components = _replace(m.config.components) + } + } - if (item.subtype === 'basetable') { - item.cols = item.cols.map(col => { - if (col.field && map[col.field.toLowerCase()]) { - col.label = map[col.field.toLowerCase()].FieldDec + return m + }) + } else if (col.type === 'colspan') { + col.subcols = _update(col.subcols) + } else if (col.field) { + if (map[col.field.toLowerCase()]) { + col.label = map[col.field.toLowerCase()].FieldDec + } } + return col }) } - return item - }) - } - - config.components = _replace(config.components) - // } else if (type === 'table') { - // config.columns = config.columns.map(col => { - // if (col.field && map[col.field.toLowerCase()]) { - // col.label = map[col.field.toLowerCase()].FieldDec - // } - // return col - // }) - - // config.search = config.search.map(col => { - // if (col.field && map[col.field.toLowerCase()]) { - // col.label = map[col.field.toLowerCase()].FieldDec - // } - // return col - // }) - - // config.action = config.action.map(m => { - // if (m.verify && m.verify.columns) { - // m.verify.columns = m.verify.columns.map(col => { - // if (col.Column && map[col.Column.toLowerCase()]) { - // col.Text = map[col.Column.toLowerCase()].FieldDec - // } - // return col - // }) - // } - // return m - // }) - } else if (type === 'form') { - config.fields = config.fields.map(col => { - if (col.field && map[col.field.toLowerCase()]) { - col.label = map[col.field.toLowerCase()].FieldDec + item.cols = _update(item.cols) } - return col + + return item }) } + + config.components = _replace(config.components) + + config.interfaces && config.interfaces.forEach(item => { + if (item.columns) { + item.columns = item.columns.map(col => { + if (col.field && map[col.field.toLowerCase()]) { + col.label = map[col.field.toLowerCase()].FieldDec + } + return col + }) + } + }) this.setState({ confirming: false, visible: false }) + + if (is(fromJS(this.props.config), fromJS(config))) { + notification.success({ + top: 92, + message: '鏈煡璇㈠埌闇�瑕佹浛鎹㈢殑瀛楁銆�', + duration: 3 + }) + return + } notification.success({ top: 92, @@ -637,7 +803,7 @@ const { visible, loadingTable, tables, confirming } = this.state return ( - <div className="mk-replace-field" style={{display: 'inline-block'}}> + <> <Button className="mk-border-yellow" icon="swap" loading={loadingTable} onClick={this.trigger}>瀛楁鏇挎崲</Button> <Modal title="瀛楁鏇挎崲" @@ -652,7 +818,7 @@ > <SettingForm tables={tables} wrappedComponentRef={(inst) => this.settingRef = inst}/> </Modal> - </div> + </> ) } } -- Gitblit v1.8.0