From 27eb6c35533be910488869c393e2c89e3c0a5b20 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 07 九月 2020 23:33:23 +0800 Subject: [PATCH] 2020-09-07 --- src/templates/sharecomponent/settingcomponent/settingform/index.jsx | 791 ++++++++++++++++--------------------------------------- 1 files changed, 237 insertions(+), 554 deletions(-) diff --git a/src/templates/sharecomponent/settingcomponent/settingform/index.jsx b/src/templates/sharecomponent/settingcomponent/settingform/index.jsx index 8bac6b7..661b2c0 100644 --- a/src/templates/sharecomponent/settingcomponent/settingform/index.jsx +++ b/src/templates/sharecomponent/settingcomponent/settingform/index.jsx @@ -1,42 +1,41 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { fromJS } from 'immutable' -import { Form, Row, Col, Input, Radio, Select, Tooltip, Icon, notification, InputNumber, Modal, Table, Popconfirm, Typography, Button } from 'antd' +import { Form, Icon, notification, Modal, Spin, Tabs, Table, Popconfirm, Typography } from 'antd' import moment from 'moment' import Api from '@/api' import Utils from '@/utils/utils.js' import SettingUtils from './utils.jsx' import CustomScript from './customscript' -import CodeMirror from '@/templates/zshare/codemirror' +import DataSource from './datasource' import './index.scss' -const { TextArea } = Input -const { confirm } = Modal +const { TabPane } = Tabs const { Paragraph } = Typography class SettingForm extends Component { static propTpyes = { - type: PropTypes.string, // 鑿滃崟绫诲瀷 - dict: PropTypes.object, // 瀛楀吀椤� - menu: PropTypes.object, // 鑿滃崟淇℃伅 - config: PropTypes.object, // 椤甸潰閰嶇疆淇℃伅 - formlist: PropTypes.array, // 琛ㄥ崟淇℃伅 - inputSubmit: PropTypes.any // 鍥炶溅鎻愪氦浜嬩欢 + type: PropTypes.string, // 鑿滃崟绫诲瀷 + dict: PropTypes.object, // 瀛楀吀椤� + menu: PropTypes.object, // 鑿滃崟淇℃伅 + config: PropTypes.object, // 椤甸潰閰嶇疆淇℃伅 + permFuncField: PropTypes.array, // 鑷畾涔夊嚱鏁板彲鐢ㄥ瓧娈� + search: PropTypes.array, // 鎼滅储鏉′欢 + inputSubmit: PropTypes.any // 鍥炶溅鎻愪氦浜嬩欢 } state = { formlist: [], btnloading: false, + activeKey: 'setting', search: '', arr_field: '', regoptions: [], setting: null, view: 'normal', - systemScripts: [{ - name: '榛樿sql', - value: '' - }], + defaultSql: '', + systemScripts: [], scriptsColumns: [ { title: 'SQL', @@ -88,37 +87,52 @@ } UNSAFE_componentWillMount() { - const { config } = this.props + const { config, search } = this.props - let _formlist = fromJS(this.props.formlist).toJS() - let interType = 'inner' + let _setting = fromJS(config.setting).toJS() + let _scripts = _setting.scripts || [] - _formlist.forEach(item => { - if (item.key === 'interType') { - interType = item.initVal - } - }) + _setting.default = _setting.default || 'true' // 榛樿sql + _setting.sysInterface = _setting.sysInterface || 'false' // 鏄惁涓虹郴缁熸帴鍙� + _setting.interface = _setting.sysInterface === 'true' ? (window.GLOB.mainSystemApi || '') : (_setting.interface || '') - let _setting = fromJS(this.props.config.setting).toJS() - _setting.scripts = _setting.scripts || [] - _setting.default = _setting.default || 'true' - - delete _setting.subtabs - - // 鎼滅储鏉′欢 - let allSearch = Utils.initMainSearch(config.search) - allSearch = Utils.getAllSearchOptions(allSearch) + if (_setting.interType === 'inner' && !_setting.innerFunc) { // 淇敼宸叉湁鏁版嵁 + _setting.interType = 'system' + } // 鏄剧ず鍒楀瓧娈碉紝鐢ㄤ簬鏌ヨ + let columns = [] let arr_field = [] config.columns.forEach(col => { if (col.field) { + columns.push({ + value: col.field, + text: col.label + }) arr_field.push(col.field) } + if (col.nameField) { // 閾炬帴鐨勫悕绉板瓧娈� + arr_field.push(col.nameField) + } }) - arr_field = arr_field.join(',') - let _search = this.formatSearch(config.search) + if (_setting.primaryKey && !arr_field.includes(_setting.primaryKey)) { + _setting.primaryKey = '' + } + if (!_setting.primaryKey && arr_field.length > 0) { + arr_field.forEach(field => { + if (field.toLowerCase() === 'id') { + _setting.primaryKey = field + } + }) + } + + // 鎼滅储鏉′欢锛屾鍒欐浛鎹� + let allSearch = Utils.initMainSearch(search) + allSearch = Utils.getAllSearchOptions(allSearch) + + // 鎼滅储鐨剋here鏉′欢 + let _search = this.formatSearch(search) _search = Utils.joinMainSearchkey(_search) _search = _search.replace(/@\$@/ig, '') @@ -127,17 +141,10 @@ this.setState({ setting: _setting, search: _search, - arr_field: arr_field, + arr_field: arr_field.join(','), regoptions: allSearch, - formlist: _formlist.map(item => { - if (interType === 'inner' && ['sysInterface', 'interface', 'outerFunc'].includes(item.key)) { - item.hidden = true - } else if (interType === 'outer' && ['innerFunc', 'dataresource', 'queryType', 'default'].includes(item.key)) { - item.hidden = true - } - - return item - }) + columns: columns, + scripts: _scripts }) } @@ -168,12 +175,11 @@ name: item.funcname, value: Utils.UnformatOptions(item.longparam) } - return _item }) this.setState({ - systemScripts: [...this.state.systemScripts, ..._scripts] + systemScripts: _scripts }) } else { notification.warning({ @@ -185,134 +191,75 @@ }) } - handleConfirm = (otype) => { - const { menu, type } = this.props - const { view, setting } = this.state + handleConfirm = (trigger) => { + const { activeKey, setting, scripts } = this.state + + if (trigger) { + this.setState({loading: true}) + } + // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� - - if (view !== 'custom') { + if (activeKey === 'setting') { return new Promise((resolve, reject) => { - this.props.form.validateFieldsAndScroll((err, values) => { - if (!err) { - if (type === 'main') { - values.actionfixed = values.actionfixed === 'true' - values.columnfixed = values.columnfixed === 'true' - } - - values = {...setting, ...values} - - // 鏁版嵁婧愬墠绔獙璇� - if (values.interType === 'inner' && !values.innerFunc && values.default !== 'false' && !values.dataresource) { - notification.warning({ - top: 92, - message: '璇峰~鍐欏唴閮ㄥ嚱鏁版垨鏁版嵁婧愶紒', - duration: 5 - }) - reject() - return - } else if (values.interType === 'inner' && !values.innerFunc && values.default !== 'false' && values.dataresource) { - let _quot = values.dataresource.match(/'{1}/g) - let _lparen = values.dataresource.match(/\({1}/g) - let _rparen = values.dataresource.match(/\){1}/g) - - _quot = _quot ? _quot.length : 0 - _lparen = _lparen ? _lparen.length : 0 - _rparen = _rparen ? _rparen.length : 0 - - if (_quot % 2 !== 0) { - notification.warning({ - top: 92, - message: '鏁版嵁婧愪腑\'蹇呴』鎴愬鍑虹幇', - duration: 5 - }) - reject() - return - } else if (_lparen !== _rparen) { - notification.warning({ - top: 92, - message: '鏁版嵁婧愪腑()蹇呴』鎴愬鍑虹幇', - duration: 5 - }) - reject() - return - } else if (/--/ig.test(values.dataresource)) { - notification.warning({ - top: 92, - message: '鏁版嵁婧愪腑锛屼笉鍙嚭鐜板瓧绗� -- 锛屾敞閲婅鐢� /*鍐呭*/', - duration: 5 - }) - reject() - return - } - - let error = Utils.verifySql(values.dataresource) - - if (error) { - notification.warning({ - top: 92, - message: '鏁版嵁婧愪腑涓嶅彲浣跨敤' + error, - duration: 5 - }) - reject() - return - } - } - - // 鏁版嵁婧愪繚瀛� - if ( - values.interType === 'inner' && !values.innerFunc && - values.default !== 'false' && - /[^\s]+\s+[^\s]+/ig.test(values.dataresource) && - this.props.config.setting.dataresource !== values.dataresource - ) { - let param = { - func: 's_DataSrc_Save', - LText: values.dataresource, - MenuID: menu.MenuID - } - - param.LText = Utils.formatOptions(param.LText) - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - - Api.getLocalConfig(param) - } - - if (otype === 'change') { - this.setState({ - setting: values, - }, () => { - resolve() - }) - } else { - values.customScript = this.getCustomScript(values) - - this.sqlverify(values, resolve, reject) - } - } else { - reject(err) + this.settingForm.handleConfirm().then(res => { + if (res.interType === 'system' && res.default === 'false' && scripts.length === 0) { + notification.warning({ + top: 92, + message: '涓嶆墽琛岄粯璁ql鏃讹紝璇锋坊鍔犺嚜瀹氫箟鑴氭湰锛�', + duration: 5 + }) + reject() + return } + + this.setState({ + setting: res + }, () => { + this.sqlverify(() => { + this.setState({loading: false}) + resolve({...res, scripts}) + }, () => { + this.setState({loading: false}) + reject() + }, true) + }) + }, () => { + this.setState({loading: false}) }) }) } else { - let _setting = fromJS(this.state.setting).toJS() - _setting.customScript = this.getCustomScript(_setting) - - let _this = this - return new Promise((resolve, reject) => { - if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql')) { - confirm({ - content: `瀛樺湪鏈繚瀛橀」锛岀‘瀹氭彁浜ゅ悧锛焋, - onOk() { - _this.sqlverify(_setting, resolve, reject) - }, - onCancel() { - reject() - } + let _loading = false + if (this.scriptsForm && this.scriptsForm.state.editItem) { + _loading = true + } else if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql')) { + _loading = true + } + + if (_loading) { + notification.warning({ + top: 92, + message: '瀛樺湪鏈繚瀛樿剼鏈紝璇风偣鍑荤‘瀹氫繚瀛橈紝鎴栫偣鍑诲彇娑堟斁寮冧慨鏀癸紒', + duration: 5 }) + this.setState({loading: false}) + reject() + } else if (setting.interType === 'system' && setting.default === 'false' && scripts.length === 0) { + notification.warning({ + top: 92, + message: '涓嶆墽琛岄粯璁ql鏃讹紝璇锋坊鍔犺嚜瀹氫箟鑴氭湰锛�', + duration: 5 + }) + this.setState({loading: false}) + reject() } else { - this.sqlverify(_setting, resolve, reject) + this.sqlverify(() => { + this.setState({loading: false}) + resolve({...setting, scripts}) + }, () => { + this.setState({loading: false}) + reject() + }, true) } }) } @@ -338,23 +285,16 @@ return _customScript } - sqlverify = (_setting, _resolve, _reject, isChange = false) => { - const { arr_field, regoptions, search } = this.state + sqlverify = (_resolve, _reject, force) => { + const { setting, scripts, arr_field, regoptions, search } = this.state - if (!isChange && _setting.interType === 'inner' && !_setting.innerFunc && _setting.default === 'false' && !_setting.customScript) { - notification.warning({ - top: 92, - message: '涓嶆墽琛岄粯璁ql鏃讹紝璇锋坊鍔犺嚜瀹氫箟鑴氭湰锛�', - duration: 5 - }) - _reject() - return + if (setting.interType !== 'system') { // 涓嶄娇鐢ㄧ郴缁熸帴鍙f椂锛屼笉闇�瑕乻ql楠岃瘉 + _resolve() } - - if (_setting.interType === 'inner' && !_setting.innerFunc && _setting.default !== 'false') { + if (force || (setting.interType === 'system' && setting.default !== 'false')) { let param = { func: 's_debug_sql', - LText: SettingUtils.getDebugSql(_setting, arr_field, regoptions, search) + LText: SettingUtils.getDebugSql(setting, scripts, arr_field, regoptions, search) } param.LText = Utils.formatOptions(param.LText) param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' @@ -362,7 +302,7 @@ Api.getLocalConfig(param).then(result => { if (result.status) { - _resolve(_setting) + _resolve() } else { _reject() Modal.error({ @@ -371,53 +311,7 @@ } }) } else { - _resolve(_setting) - } - } - - selectChange = (key, val) => { - if (key === 'primaryKey' && val) { - this.props.form.setFieldsValue({ - order: `${val} desc` - }) - } - } - - onRadioChange = (e, key) => { - let value = e.target.value - let _formlist = fromJS(this.state.formlist).toJS() - - if (key === 'interType') { - this.setState({ - formlist: _formlist.map(item => { - item.hidden = false - - if (value === 'inner' && ['sysInterface', 'interface', 'outerFunc'].includes(item.key)) { - item.initVal = this.props.form.getFieldValue(item.key) - item.hidden = true - } else if (value === 'outer' && ['innerFunc', 'dataresource', 'queryType', 'default'].includes(item.key)) { - item.initVal = this.props.form.getFieldValue(item.key) - item.hidden = true - } - - return item - }) - }) - } else if (key === 'sysInterface') { - if (value === 'true') { - this.props.form.setFieldsValue({ - interface: window.GLOB.mainSystemApi || '' - }) - } - this.setState({ - formlist: _formlist.map(item => { - if (item.key === 'interface') { - item.readonly = value === 'true' - } - - return item - }) - }) + _resolve() } } @@ -473,285 +367,12 @@ return newsearches } - changeView = () => { - const { view, arr_field, regoptions, search } = this.state - let _this = this - - if (view === 'normal') { - this.handleConfirm('change').then(() => { - const { setting } = this.state - - if (setting.interType !== 'inner' || (setting.interType === 'inner' && setting.innerFunc)) { - notification.warning({ - top: 92, - message: '浣跨敤澶栭儴鎺ュ彛鎴栧唴閮ㄦ帴鍙g殑鑷畾涔夊嚱鏁帮紝涓嶅彲娣诲姞鑷畾涔夎缃紒', - duration: 5 - }) - return - } - - let _search = search - - let _dataresource = setting.dataresource - - if (/\s/.test(_dataresource)) { - _dataresource = '(' + _dataresource + ') tb' - } - - if (setting.queryType === 'statistics') { // 缁熻鏁版嵁婧愶紝鍐呭鏇挎崲 - // 姝e垯鏇挎崲 - let _regoptions = regoptions.map(item => { - return { - reg: new RegExp('@' + item.key + '@', 'ig'), - value: `'${item.value}'` - } - }) - _regoptions.forEach(item => { - _dataresource = _dataresource.replace(item.reg, item.value) - }) - - _search = '' - } - - let LText = `select ${setting.laypage !== 'false' ? 'top @pageSize@' : ''} ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by @orderBy@) as rows from ${_dataresource} ${_search}) tmptable ${setting.laypage !== 'false' ? 'where rows > (@pageSize@ * (@pageIndex@ - 1))' : ''} order by tmptable.rows` - let _scripts = fromJS(this.state.systemScripts).toJS() - _scripts[0].value = LText - - - if (setting.default === 'false') { - this.setState({ - view: 'custom', - btnloading: false, - systemScripts: _scripts - }) - this.scrolltop() - } else { - this.setState({ - btnloading: true - }) - new Promise((resolve, reject) => { - this.sqlverify(setting, resolve, reject, true) - }).then(() => { - this.setState({ - view: 'custom', - btnloading: false, - systemScripts: _scripts - }) - this.scrolltop() - }, () => { - this.setState({ - btnloading: false - }) - }) - } - }) - } else { - let _loading = false - - if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql')) { - _loading = true - } - - if (_loading) { - confirm({ - content: `瀛樺湪鏈繚瀛橀」锛岀‘瀹氬垏鎹㈠悧锛焋, - onOk() { - _this.setState({ - view: 'normal' - }) - - _this.scrolltop() - }, - onCancel() {} - }) - } else { - _this.setState({ - view: 'normal' - }) - - _this.scrolltop() - } - } - } - handleSubmit = (e) => { e.preventDefault() if (this.props.inputSubmit) { this.props.inputSubmit() } - } - - getFields(formlist) { - const { getFieldDecorator } = this.props.form - const fields = [] - - formlist.forEach((item, index) => { - if (item.hidden || item.forbid) return - - if (item.type === 'text') { // 鏂囨湰鎼滅储 - let rules = item.rules || [] - - fields.push( - <Col span={12} key={index}> - <Form.Item label={item.tooltip ? - <Tooltip placement="topLeft" title={item.tooltip}> - <Icon type="question-circle" /> - {item.label} - </Tooltip> : item.label - }> - {getFieldDecorator(item.key, { - initialValue: item.initVal || '', - rules: [ - { - required: !!item.required, - message: this.props.dict['form.required.input'] + item.label + '!' - }, - ...rules - ] - })(<Input placeholder={item.placeholder || ''} autoComplete="off" disabled={item.readonly} onPressEnter={this.handleSubmit} />)} - </Form.Item> - </Col> - ) - } else if (item.type === 'number') { - fields.push( - <Col span={12} key={index}> - <Form.Item label={item.tooltip ? - <Tooltip placement="topLeft" title={item.tooltip}> - <Icon type="question-circle" /> - {item.label} - </Tooltip> : item.label - }> - {getFieldDecorator(item.key, { - initialValue: item.initVal || 6, - rules: [ - { - required: item.required, - message: this.props.dict['form.required.input'] + item.label + '!' - } - ] - })(<InputNumber min={item.min} max={item.max} precision={0} />)} - </Form.Item> - </Col> - ) - } else if (item.type === 'select') { // 涓嬫媺鎼滅储 - fields.push( - <Col span={12} key={index}> - <Form.Item label={item.label}> - {getFieldDecorator(item.key, { - initialValue: item.initVal || '', - rules: [ - { - required: !!item.required, - message: this.props.dict['form.required.select'] + item.label + '!' - } - ] - })( - <Select - showSearch - filterOption={(input, option) => { - return option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0 || - option.props.value.toLowerCase().indexOf(input.toLowerCase()) >= 0 - }} - onChange={(value) => {this.selectChange(item.key, value)}} - getPopupContainer={() => document.getElementById('model-table-setting-form')} - > - {item.options.map((option, i) => - <Select.Option id={i} key={i} value={option.value}> - {option.text} - </Select.Option> - )} - </Select> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'radio') { - fields.push( - <Col span={12} key={index}> - <Form.Item label={item.tooltip ? - <Tooltip placement="topLeft" title={item.tooltip}> - <Icon type="question-circle" /> - {item.label} - </Tooltip> : item.label - }> - {getFieldDecorator(item.key, { - initialValue: item.initVal, - rules: [ - { - required: !!item.required, - message: this.props.dict['form.required.select'] + item.label + '!' - } - ] - })( - <Radio.Group onChange={(e) => {this.onRadioChange(e, item.key)}}> - { - item.options.map((option, i) => { - return ( - <Radio key={i} value={option.value}>{option.text}</Radio> - ) - }) - } - </Radio.Group>, - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'datasource') { - fields.push( - <Col span={24} key={index} style={{paddingLeft: '7px'}}> - <Form.Item className="text-area" labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} } help={item.help} label={ - <Tooltip placement="topLeft" title={item.tooltip}> - <Icon type="question-circle" /> - {item.label} - </Tooltip> - }> - {getFieldDecorator(item.key, { - initialValue: item.initVal - })(<CodeMirror />)} - </Form.Item> - </Col> - ) - } else if (item.type === 'textarea') { - fields.push( - <Col span={20} offset={4} key={index}> - <Form.Item className="text-area"> - {getFieldDecorator(item.key, { - initialValue: item.initVal, - rules: [ - { - required: !!item.required, - message: this.props.dict['form.required.input'] + item.label + '!' - } - ] - })(<TextArea rows={4} />)} - </Form.Item> - </Col> - ) - } else if (item.type === 'multiselect') { // 澶氶�� - fields.push( - <Col span={12} key={index}> - <Form.Item label={item.label}> - {getFieldDecorator(item.key, { - initialValue: item.initVal || [] - })( - <Select - showSearch - mode="multiple" - filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} - > - {item.options.map((option, i) => - <Select.Option id={i} key={i} value={option.value}>{option.text}</Select.Option> - )} - </Select> - )} - </Form.Item> - </Col> - ) - } - }) - - return fields } handleEdit = (record) => { @@ -778,7 +399,7 @@ } handleUpDown = (record, direction) => { - let scripts = fromJS(this.state.setting.scripts).toJS() + let scripts = fromJS(this.state.scripts).toJS() let index = 0 scripts = scripts.filter((item, i) => { @@ -798,13 +419,11 @@ scripts.splice(index + 1, 0, record) } - this.setState({ - setting: {...this.state.setting, scripts: scripts} - }) + this.setState({scripts}) } handleStatus = (record) => { - let scripts = fromJS(this.state.setting.scripts).toJS() + let scripts = fromJS(this.state.scripts).toJS() record.status = record.status === 'false' ? 'true' : 'false' scripts = scripts.map(item => { @@ -815,20 +434,18 @@ } }) - this.setState({ - setting: {...this.state.setting, scripts: scripts} - }) + this.setState({scripts}) } handleDelete = (record) => { - let scripts = fromJS(this.state.setting.scripts).toJS() + let scripts = fromJS(this.state.scripts).toJS() scripts = scripts.filter(item => item.uuid !== record.uuid) - this.setState({ setting: {...this.state.setting, scripts: scripts} }) + this.setState({ scripts }) } scriptsChange = (values) => { - let scripts = fromJS(this.state.setting.scripts).toJS() + let scripts = fromJS(this.state.scripts).toJS() if (values.uuid) { scripts = scripts.map(item => { @@ -843,57 +460,123 @@ scripts.push(values) } - this.setState({ - setting: {...this.state.setting, scripts: scripts} - }) + this.setState({scripts}) + } + + changeTab = (val) => { + const { activeKey, search, arr_field } = this.state + + if (activeKey === 'setting') { + this.setState({loading: true}) + + let _defaultSql = '' + this.settingForm.handleConfirm().then(res => { + if (res.interType !== 'system') { + notification.warning({ + top: 92, + message: '浣跨敤绯荤粺鎺ュ彛鏃讹紝鎵嶅彲浠ヨ缃嚜瀹氫箟鑴氭湰锛�', + duration: 5 + }) + this.setState({loading: false}) + return + } + + this.setState({ + setting: res + }, () => { + if (res.dataresource) { + let _dataresource = res.dataresource + + if (/\s/.test(_dataresource)) { + _dataresource = '(' + _dataresource + ') tb' + } + + _defaultSql = `select top @pageSize@ ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by @orderBy@) as rows from ${_dataresource} ${search}) tmptable where rows > (@pageSize@ * (@pageIndex@ - 1)) order by tmptable.rows` + } + + this.sqlverify(() => { // 楠岃瘉鎴愬姛 + this.setState({ + activeKey: val, + defaultSql: _defaultSql, + loading: false + }) + }, () => { // 楠岃瘉澶辫触 + this.setState({ + loading: false + }) + }) + }) + }, () => { + this.setState({loading: false}) + }) + } else if (activeKey === 'scripts') { + let _loading = false + if (this.scriptsForm && this.scriptsForm.state.editItem) { + _loading = true + } else if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql')) { + _loading = true + } + + if (_loading) { + notification.warning({ + top: 92, + message: '瀛樺湪鏈繚瀛樿剼鏈紝璇风偣鍑荤‘瀹氫繚瀛橈紝鎴栫偣鍑诲彇娑堟斁寮冧慨鏀癸紒', + duration: 5 + }) + return + } + + this.setState({ + activeKey: val + }) + } } render() { - const { config, type } = this.props - const { formlist, view, setting, scriptsColumns, systemScripts, arr_field, regoptions, search, btnloading } = this.state - const formItemLayout = { - labelCol: { - xs: { span: 24 }, - sm: { span: 8 } - }, - wrapperCol: { - xs: { span: 24 }, - sm: { span: 16 } - } - } + const { type, menu, dict, permFuncField } = this.props + const { loading, activeKey, setting, scriptsColumns, systemScripts, arr_field, defaultSql, regoptions, search, columns, scripts } = this.state return ( <div className="model-table-setting-form-box" id="model-table-setting-form-box"> - {view ==='custom' ? <div> - <Icon className="setting-custom-back" onClick={this.changeView} type="arrow-left" /> - <CustomScript - type={type} - setting={setting} - swhere={search} - arr_field={arr_field} - regoptions={regoptions} - dict={this.props.dict} - searches={config.search} - systemScripts={systemScripts} - scriptsChange={this.scriptsChange} - wrappedComponentRef={(inst) => this.scriptsForm = inst} - /> - <Table - bordered - rowKey="uuid" - className="custom-table" - dataSource={setting.scripts} - columns={scriptsColumns} - pagination={false} - /> - </div> : null } - <Form {...formItemLayout} className="model-table-setting-form" id="model-table-setting-form"> - {view !=='custom' ? <Row gutter={24}>{this.getFields(formlist)}</Row> : null} - <Row gutter={24}> - {view !=='custom' ? <Button onClick={this.changeView} className="to-custom-script" loading={btnloading}>鑷畾涔夎缃�<Icon style={{marginLeft: 5}} type="right" /></Button> : null} - {view ==='custom' ? <span onClick={this.changeView} style={{float: 'left', color: '#1890ff', marginLeft: 12, marginTop: 15, cursor: 'pointer'}}><Icon style={{marginRight: 5}} type="left" />鍩虹璁剧疆</span> : null} - </Row> - </Form> + {loading && <Spin size="large" />} + <Tabs activeKey={activeKey} className="verify-card-box" onChange={this.changeTab}> + <TabPane tab="鏁版嵁婧�" key="setting"> + <DataSource + type={type} + menu={menu} + dict={dict} + columns={columns} + setting={setting} + scripts={scripts} + permFuncField={permFuncField} + wrappedComponentRef={(inst) => this.settingForm = inst} + /> + </TabPane> + <TabPane tab="鑷畾涔夎剼鏈�" key="scripts"> + <CustomScript + type={type} + dict={dict} + swhere={search} + setting={setting} + scripts={scripts} + arr_field={arr_field} + defaultSql={defaultSql} + regoptions={regoptions} + searches={this.props.search} + systemScripts={systemScripts} + scriptsChange={this.scriptsChange} + wrappedComponentRef={(inst) => this.scriptsForm = inst} + /> + <Table + bordered + rowKey="uuid" + className="custom-table" + dataSource={scripts} + columns={scriptsColumns} + pagination={false} + /> + </TabPane> + </Tabs> </div> ) } -- Gitblit v1.8.0