From 46f59e30133c25f1f01074b1c92445f9e85b8c98 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 31 十二月 2019 15:58:37 +0800 Subject: [PATCH] 2019-12-31 --- src/templates/comtableconfig/index.jsx | 123 ++++++++++++++++++++++++++++++++++------- 1 files changed, 102 insertions(+), 21 deletions(-) diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx index bfe8078..cde6d93 100644 --- a/src/templates/comtableconfig/index.jsx +++ b/src/templates/comtableconfig/index.jsx @@ -108,13 +108,13 @@ }) } - // _config.tabs = _config.tabs || [] - // _config.tabgroups = _config.tabgroups || ['tabs'] - // _config.setting.subtabs = _config.setting.subtabs || [] + _config.tabs = _config.tabs || [] + _config.tabgroups = _config.tabgroups || ['tabs'] + _config.setting.subtabs = _config.setting.subtabs || [] this.setState({ - originActions: _oriActions, config: _config, + originActions: _oriActions, originMenu: JSON.parse(JSON.stringify(menu)), selectedTables: _config.tables || [], menuformlist: [ @@ -358,7 +358,16 @@ key: 'field', label: this.state.dict['header.form.field'], initVal: card.field, + tooltip: '瀛楁鍚嶅彲浠ヤ娇鐢ㄩ�楀彿鍒嗛殧锛岃繘琛屽瀛楁缁煎悎鎼滅储锛屾敞锛氱患鍚堟悳绱粎鍦ㄦ枃鏈被鍨嬫椂鏈夋晥', + tooltipClass: 'middle', required: true, + rules: [{ + pattern: /^[\u4E00-\u9FA50-9a-zA-Z,_]*$/ig, + message: '瀛楁鍚嶅彧鍏佽鍖呭惈鏁板瓧銆佸瓧姣嶃�佹眽瀛椾互鍙奯' + }, { + max: 50, + message: '瀛楁鍚嶆渶澶�50涓瓧绗︼紒' + }], readonly: false }, { @@ -373,6 +382,9 @@ }, { value: 'select', text: this.state.dict['header.form.select'] + }, { + value: 'multiselect', + text: this.state.dict['header.form.multiselect'] }, { value: 'link', text: this.state.dict['header.form.link'] @@ -832,6 +844,13 @@ label: this.state.dict['header.form.field'], initVal: card.field, required: true, + rules: [{ + pattern: /^[\u4E00-\u9FA50-9a-zA-Z_]*$/ig, + message: '瀛楁鍚嶅彧鍏佽鍖呭惈鏁板瓧銆佸瓧姣嶃�佹眽瀛椾互鍙奯' + }, { + max: 50, + message: '瀛楁鍚嶆渶澶�50涓瓧绗︼紒' + }], readonly: false }, { @@ -1159,9 +1178,15 @@ if (res.type === 'search') { if ((res.values.type === 'select' || res.values.type === 'link') && res.values.resourceType === '1') { - let sql = 'select ' + res.values.valueField + ',' + res.values.valueText + ' from ' + res.values.dataSource + let _datasource = res.values.dataSource + + if (/\s/.test(_datasource)) { + _datasource = '(' + _datasource + ') tb' + } + + let sql = 'select ' + res.values.valueField + ',' + res.values.valueText + ' from ' + _datasource if (res.values.type === 'link') { - sql = 'select ' + res.values.valueField + ',' + res.values.valueText + ',' + res.values.linkField + ' from ' + res.values.dataSource + sql = 'select ' + res.values.valueField + ',' + res.values.valueText + ',' + res.values.linkField + ' from ' + _datasource } if (res.values.orderBy) { sql = sql + ' order by ' + res.values.orderBy + ' ' + res.values.orderType @@ -1823,13 +1848,24 @@ cancelText: this.state.dict['header.cancel'], onOk() { let _config = JSON.parse(JSON.stringify(_this.state.config)) - _config[element.type] = _config[element.type].filter(item => { - if (item.uuid === element.card.uuid) { - return false - } else { - return true - } - }) + + if (element.type === 'tabs') { + _config[element.card.groupId] = _config[element.card.groupId].filter(item => { + if (item.uuid === element.card.uuid) { + return false + } else { + return true + } + }) + } else { + _config[element.type] = _config[element.type].filter(item => { + if (item.uuid === element.card.uuid) { + return false + } else { + return true + } + }) + } let refreshtype = element.type + 'loading' @@ -1849,6 +1885,10 @@ }, onCancel() {} }) + } + + profileAction = (element) => { + console.log(element) } changeTemplate = () => { @@ -1882,6 +1922,17 @@ let _LongParam = '' let _config = {...config, tables: this.state.selectedTables} let _pageParam = {...menu.PageParam, OpenType: res.opentype} + + // 鏈缃暟鎹簮鎴栨爣绛句笉鍚堟硶鏃讹紝鍚敤鐘舵�佷负false + if (_config.setting.interType === 'inner' && !_config.setting.innerFunc && !_config.setting.dataresource) { + _config.enabled = false + } else if (_config.tabgroups.length > 1) { + _config.tabgroups.forEach(group => { + if (_config[group].length === 0) { + _config.enabled = false + } + }) + } // 淇濆瓨鏃跺垹闄ら厤缃被鍨嬶紝system 銆乽ser delete _config.type @@ -2617,12 +2668,35 @@ } } - onEnabledChange = () => { + onEnabledChange = (val, e) => { const { config } = this.state - this.setState({ - config: {...config, enabled: !config.enabled} - }) + let tabinvalid = true + if (config.tabgroups.length > 1) { + config.tabgroups.forEach(group => { + if (config[group].length === 0) { + tabinvalid = false + } + }) + } + + if (config.setting.interType === 'inner' && !config.setting.innerFunc && !config.setting.dataresource) { + notification.warning({ + top: 92, + message: '鑿滃崟灏氭湭璁剧疆鏁版嵁婧愶紝涓嶅彲鍚敤锛�', + duration: 10 + }) + } else if (!tabinvalid) { + notification.warning({ + top: 92, + message: '鑿滃崟鏍囩椤佃缃敊璇紙澶氳鏍囩鍐咃紝琛屾爣绛句笉鍙负绌猴級锛屼笉鍙惎鐢紒', + duration: 10 + }) + } else { + this.setState({ + config: {...config, enabled: !config.enabled} + }) + } } onColumnNameChange = () => { @@ -2690,6 +2764,11 @@ const configAction = this.state.config.action.filter(_action => !_action.origin && (_action.OpenType === 'pop' || _action.OpenType === 'popview' || _action.OpenType === 'blank' || _action.OpenType === 'tab') ) + + let configTabs = [] + this.state.config.tabgroups.forEach(group => { + configTabs.push(...this.state.config[group]) + }) return ( <div className="common-table-board"> @@ -2773,7 +2852,7 @@ <Button icon={item.icon} style={{marginBottom: '10px'}} - className={'mk-btn mk-' + item.class} + className={'config-button mk-btn mk-' + item.class} onClick={() => this.setSubConfig(item, 'button')} >{item.label}</Button> </div> @@ -2796,7 +2875,7 @@ return (<SourceElement key={index} content={item}/>) })} </div> - {this.state.config.tabs.length > 0 ? + {configTabs.length > 0 ? <p className="config-btn-title"> <Tooltip placement="topLeft" title="鐐瑰嚮鎸夐挳锛屽彲瀹屾垚鎴栨煡鐪嬫爣绛鹃厤缃俊鎭��"> <Icon type="question-circle" /> @@ -2804,10 +2883,11 @@ {this.state.dict['header.menu.tab.configurable']} </p> : null } - {this.state.config.tabs.map((item, index) => { + {configTabs.map((item, index) => { return ( <div key={index}> <Button + className="config-button" icon={item.icon} style={{marginBottom: '10px'}} onClick={() => this.setSubConfig(item, 'tab')} @@ -2821,7 +2901,7 @@ <div className="setting"> <Card title={this.state.dict['header.menu.page.configurable']} bordered={false} extra={ <div> - <Switch className="big" checkedChildren="鍚�" unCheckedChildren="鍋�" defaultChecked={this.state.config.enabled} onChange={this.onEnabledChange} /> + <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> @@ -2855,6 +2935,7 @@ handleMenu={this.handleAction} copyElement={(val) => this.handleAction(val, 'copy')} deleteMenu={this.deleteElement} + profileMenu={this.profileAction} placeholder={this.state.dict['header.form.action.placeholder']} /> : null } -- Gitblit v1.8.0