| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { fromJS } from 'immutable' |
| | | import { Form, Tabs, Table, Popconfirm, Icon, notification, Modal, Spin } from 'antd' |
| | | import { Form, Tabs, Table, Popconfirm, notification, Modal, Spin } from 'antd' |
| | | import { EditOutlined, DeleteOutlined } from '@ant-design/icons' |
| | | import moment from 'moment' |
| | | |
| | | import Api from '@/api' |
| | |
| | | |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import ColForm from './columnform' |
| | | import CustomScript from '@/templates/zshare/customscript' |
| | | import SettingForm from './settingform' |
| | | import SettingUtils from './utils' |
| | | import './index.scss' |
| | | |
| | | const { TabPane } = Tabs |
| | | |
| | | const CustomScript = asyncComponent(() => import('@/templates/zshare/customscript')) |
| | | const FieldsComponent = asyncComponent(() => import('@/templates/sharecomponent/fieldscomponent')) |
| | | |
| | | class VerifyCard extends Component { |
| | | static propTpyes = { |
| | | dict: PropTypes.object, // 字典项 |
| | | tableFields: PropTypes.any, // 数据源信息 |
| | | permFuncField: PropTypes.any, // 数据源信息 |
| | | config: PropTypes.object, // 数据源信息 |
| | | menuId: PropTypes.string, // 菜单Id |
| | | searches: PropTypes.array, // 搜索条件 |
| | |
| | | dataIndex: 'operation', |
| | | render: (text, record) => |
| | | (<div> |
| | | <span className="operation-btn" title={this.props.dict['model.edit']} onClick={() => this.handleEdit(record)} style={{color: '#1890ff'}}><Icon type="edit" /></span> |
| | | <span className="operation-btn" title={this.props.dict['model.edit']} onClick={() => this.handleEdit(record)} style={{color: '#1890ff'}}><EditOutlined /></span> |
| | | <Popconfirm |
| | | overlayClassName="popover-confirm" |
| | | title={this.props.dict['model.query.delete']} |
| | | onConfirm={() => this.deleteColumn(record) |
| | | }> |
| | | <span className="operation-btn" style={{color: '#ff4d4f'}}><Icon type="delete" /></span> |
| | | <span className="operation-btn" style={{color: '#ff4d4f'}}><DeleteOutlined /></span> |
| | | </Popconfirm> |
| | | </div>) |
| | | } |
| | |
| | | UNSAFE_componentWillMount() { |
| | | const { config } = this.props |
| | | |
| | | let _setting = fromJS(config.setting).toJS() |
| | | let _scripts = fromJS(config.scripts).toJS() |
| | | |
| | | if (window.GLOB.funcs && window.GLOB.funcs.length > 0) { |
| | | window.GLOB.funcs.forEach(m => { |
| | | let reg = new RegExp(`\\/\\*\\$ex@${m.func_code}-begin\\*\\/[\\s\\S]+\\/\\*@ex\\$-end\\*\\/`, 'ig') |
| | | _scripts.forEach(item => { |
| | | item.sql = item.sql.replace(reg, `$ex@${m.func_code}@ex$`) |
| | | }) |
| | | if (_setting.dataresource) { |
| | | _setting.dataresource = _setting.dataresource.replace(reg, `$ex@${m.func_code}@ex$`) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | this.setState({ |
| | | setting: fromJS(config.setting).toJS(), |
| | | setting: _setting, |
| | | columns: fromJS(config.columns).toJS(), |
| | | scripts: fromJS(config.scripts).toJS() |
| | | scripts: _scripts |
| | | }) |
| | | } |
| | | |
| | |
| | | let _loading = false |
| | | if (this.scriptsForm && this.scriptsForm.state.editItem) { |
| | | _loading = true |
| | | } else if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql')) { |
| | | } else if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql') && !/^\s+$/.test(this.scriptsForm.props.form.getFieldValue('sql'))) { |
| | | _loading = true |
| | | } |
| | | |
| | |
| | | let _loading = false |
| | | if (this.scriptsForm && this.scriptsForm.state.editItem) { |
| | | _loading = true |
| | | } else if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql')) { |
| | | } else if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql') && !/^\s+$/.test(this.scriptsForm.props.form.getFieldValue('sql'))) { |
| | | _loading = true |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | sqlverify = (resolve, reject, type, testScripts) => { |
| | | const { searches } = this.props |
| | | const { searches, config } = this.props |
| | | const { columns, setting, scripts } = this.state |
| | | |
| | | if (setting.interType !== 'system') { // 不使用系统接口时,不需要sql验证 |
| | |
| | | } else if (setting.execute !== 'false' || _scripts.length > 0) { |
| | | let param = { |
| | | func: 's_debug_sql', |
| | | LText: SettingUtils.getDebugSql(setting, _scripts, columns, searches) |
| | | exec_type: 'y', |
| | | LText: SettingUtils.getDebugSql(setting, _scripts, columns, Utils.getRegOptions(searches), config.calendar, config.urlFields) |
| | | } |
| | | param.LText = Utils.formatOptions(param.LText) |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | param.secretkey = Utils.encrypt(param.LText, param.timestamp) |
| | | param.secretkey = Utils.encrypt('', param.timestamp) |
| | | |
| | | Api.getLocalConfig(param).then(result => { |
| | | if (result.status) { |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { config } = this.props |
| | | const { columns, setting, scripts, colColumns, activeKey, loading } = this.state |
| | | |
| | | return ( |
| | |
| | | <SettingForm |
| | | menuId={this.props.menuId} |
| | | dict={this.props.dict} |
| | | permFuncField={this.props.permFuncField} |
| | | columns={columns} |
| | | setting={setting} |
| | | scripts={scripts} |
| | |
| | | wrappedComponentRef={(inst) => this.contrastForm = inst} |
| | | /> |
| | | <FieldsComponent |
| | | config={{...this.props.config, columns}} |
| | | config={{...config, columns}} |
| | | type="fields" |
| | | tableFields={this.props.tableFields} |
| | | updatefield={this.updatefields} |
| | | /> |
| | | <Table |
| | |
| | | dict={this.props.dict} |
| | | setting={setting} |
| | | scripts={scripts} |
| | | urlFields={config.urlFields} |
| | | defaultSql={this.state.defaultsql} |
| | | searches={this.props.searches} |
| | | scriptsChange={this.scriptsChange} |