From f59a500d24291d7f54b71dcca939a2a23dedca7c Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 18 六月 2020 17:52:03 +0800 Subject: [PATCH] 2020-06-18 --- src/templates/comtableconfig/index.jsx | 121 +++++++++++++++++++++++----------------- 1 files changed, 70 insertions(+), 51 deletions(-) diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx index 34481c6..8f6904e 100644 --- a/src/templates/comtableconfig/index.jsx +++ b/src/templates/comtableconfig/index.jsx @@ -103,40 +103,75 @@ }) } - // 閰嶇疆榛樿鍊硷紝鍏煎 - _config.Template = 'CommonTable' - _config.easyCode = _config.easyCode || '' + if (!_config.version || _config.version < '1.0') { + // 閰嶇疆榛樿鍊硷紝鍏煎 + _config.version = '1.0' + _config.Template = 'CommonTable' + _config.easyCode = _config.easyCode || '' + + 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 = 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' + } - 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() - } + if (!_cell.height) { + _cell.height = 1 + } - delete _config[groupId] + return _cell + }) - _tabgroups.push(_group) - }) - - _config.tabgroups = _tabgroups - } - - // 鍏煎鍥捐〃 - if (!_config.charts) { - _config.expand = false - _config.charts = [{ - uuid: Utils.getuuid(), - label: '', - title: '', - chartType: 'table', - icon: 'table', - Hide: 'false', - blacklist: [] - }] + if (card.widthType === 'ratio' && card.avatar && card.avatar.widthType !== 'ratio') { + card.avatar.widthType = 'ratio' + card.avatar.width = 32 + } + } + }) + } } let _oriActions = [] @@ -249,13 +284,6 @@ }) } }) - } - - /** - * @description 涓夌骇鑿滃崟鍒囨崲妯℃澘(寮冪敤) - */ - changeTemplate = () => { - this.props.handleView({tabview: 'template'}) } getFuncNames = (data, funcNames, tableNames) => { @@ -1283,9 +1311,7 @@ {/* 鎼滅储鏉′欢娣诲姞 */} <Panel header={this.state.dict['header.menu.search']} key="1"> <div className="search-element"> - {Source.searchItems.map((item, index) => { - return (<SourceElement key={index} content={item}/>) - })} + {Source.searchItems.map((item, index) => (<SourceElement key={index} content={item}/>))} </div> <FieldsComponent config={config} @@ -1297,9 +1323,7 @@ {/* 鎸夐挳娣诲姞 */} <Panel header={this.state.dict['header.menu.action']} key="2"> <div className="search-element"> - {Source.actionItems.map((item, index) => { - return (<SourceElement key={index} content={item}/>) - })} + {Source.actionItems.map((item, index) => (<SourceElement key={index} content={item}/>))} </div> <div className="config-btn"> {confActions.length > 0 ? @@ -1327,9 +1351,7 @@ {/* 娣诲姞鏄剧ず鍒� */} <Panel header={this.state.dict['header.menu.column']} key="3"> <div className="search-element"> - {Source.columnItems.map((item, index) => { - return (<SourceElement key={index} content={item}/>) - })} + {Source.columnItems.map((item, index) => (<SourceElement key={index} content={item}/>))} </div> <FieldsComponent config={config} @@ -1341,9 +1363,7 @@ {/* 娣诲姞鏍囩 */} <Panel header={this.state.dict['header.menu.tab']} key="4"> <div className="search-element"> - {Source.tabItems.map((item, index) => { - return (<SourceElement key={index} content={item}/>) - })} + {Source.tabItems.map((item, index) => (<SourceElement key={index} content={item}/>))} </div> {configTabs.length > 0 ? <p className="config-btn-title"> @@ -1378,7 +1398,6 @@ <div> <EditComponent dict={this.state.dict} type="maintable" config={this.state.config} MenuID={this.props.menu.MenuID} thawButtons={this.state.thawButtons} refresh={this.editConfig}/> <Switch className="big" checkedChildren="鍚�" unCheckedChildren="鍋�" checked={this.state.config.enabled} onChange={this.onEnabledChange} /> - {/* <Button type="primary" onClick={this.changeTemplate}>{this.state.dict['header.menu.template.change']}</Button> */} <Button type="primary" onClick={this.submitConfig} loading={this.state.menuloading}>{this.state.dict['header.save']}</Button> <Button onClick={this.cancelConfig}>{this.state.dict['header.return']}</Button> </div> -- Gitblit v1.8.0