| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Modal, Button } from 'antd' |
| | | import { Modal, Button, notification } from 'antd' |
| | | import { SettingOutlined } from '@ant-design/icons' |
| | | |
| | | import VerifyCard from './verifycard' |
| | |
| | | } |
| | | |
| | | let maxScript = 0 |
| | | let useExec = false |
| | | |
| | | if (window.GLOB.funcs && window.GLOB.funcs.length > 0) { |
| | | window.GLOB.funcs.forEach(m => { |
| | | let reg = new RegExp('\\$ex@' + m.func_code + '@ex\\$', 'ig') |
| | | if (res.setting.dataresource) { |
| | | res.setting.dataresource = res.setting.dataresource.replace(reg, `/*$ex@${m.func_code}-begin*/\n${m.key_sql}\n/*@ex$-end*/`) |
| | | let sFields = [] |
| | | res.searches && res.searches.forEach(item => { |
| | | if (!item.key) return |
| | | |
| | | if (item.type === 'date') { |
| | | if (sFields.includes(item.key)) { |
| | | sFields.push(item.key + '1') |
| | | } else { |
| | | sFields.push(item.key) |
| | | } |
| | | res.scripts.forEach(item => { |
| | | item.sql = item.sql.replace(reg, `/*$ex@${m.func_code}-begin*/\n${m.key_sql}\n/*@ex$-end*/`) |
| | | |
| | | if (item.status === 'false') return |
| | | |
| | | if (/exec\s/ig.test(item.sql)) { |
| | | maxScript = 1000 |
| | | } else if (item.sql.length > maxScript) { |
| | | maxScript = item.sql.length |
| | | } |
| | | } else if (item.type === 'dateweek' || item.type === 'range' || (item.type === 'datemonth' && item.match !== '=')) { |
| | | sFields.push(item.key) |
| | | sFields.push(item.key + '1') |
| | | } else if (item.type === 'daterange') { |
| | | if (/,/.test(item.key)) { |
| | | sFields.push(item.key.split(',')[0]) |
| | | sFields.push(item.key.split(',')[1]) |
| | | } else { |
| | | sFields.push(item.key) |
| | | sFields.push(item.key + '1') |
| | | } |
| | | } else if (item.type === 'text' || item.type === 'select') { |
| | | item.key.split(',').forEach(field => { |
| | | sFields.push(field) |
| | | }) |
| | | }) |
| | | } else { |
| | | res.scripts.forEach(item => { |
| | | if (item.status === 'false') return |
| | | } else { |
| | | sFields.push(item.key) |
| | | } |
| | | }) |
| | | delete res.searches |
| | | sFields = sFields.join('|') |
| | | |
| | | if (/exec\s/ig.test(item.sql)) { |
| | | // if (window.GLOB.funcs && window.GLOB.funcs.length > 0) { |
| | | // window.GLOB.funcs.forEach(m => { |
| | | // let reg = new RegExp('\\$ex@' + m.func_code + '@ex\\$', 'ig') |
| | | // if (res.setting.dataresource) { |
| | | // res.setting.dataresource = res.setting.dataresource.replace(reg, `/*$ex@${m.func_code}-begin*/\n${m.key_sql}\n/*@ex$-end*/`) |
| | | // } |
| | | // res.scripts.forEach(item => { |
| | | // item.sql = item.sql.replace(reg, `/*$ex@${m.func_code}-begin*/\n${m.key_sql}\n/*@ex$-end*/`) |
| | | |
| | | // if (item.status === 'false') return |
| | | |
| | | // if (/exec\s/ig.test(item.sql)) { |
| | | // useExec = true |
| | | // maxScript = 1000 |
| | | // } else if (item.sql.length > maxScript) { |
| | | // maxScript = item.sql.length |
| | | // } |
| | | // }) |
| | | // }) |
| | | // } else { |
| | | // res.scripts.forEach(item => { |
| | | // if (item.status === 'false') return |
| | | |
| | | // if (/exec\s/ig.test(item.sql)) { |
| | | // useExec = true |
| | | // maxScript = 1000 |
| | | // } else if (item.sql.length > maxScript) { |
| | | // maxScript = item.sql.length |
| | | // } |
| | | // }) |
| | | // } |
| | | |
| | | if (res.setting.interType === 'system' && res.setting.dataresource && res.setting.execute !== 'false') { |
| | | res.setting.dataresource = res.setting.dataresource.replace(/\t+|\v+/g, ' ') |
| | | if (sFields) { |
| | | if (new RegExp(`@(${sFields})@`, 'ig').test(res.setting.dataresource)) { |
| | | maxScript = 1000 |
| | | } else if (item.sql.length > maxScript) { |
| | | maxScript = item.sql.length |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | |
| | | res.scripts.forEach(item => { |
| | | if (item.status === 'false') return |
| | | |
| | | item.sql = item.sql.replace(/\t+|\v+/g, ' ') |
| | | |
| | | if (/exec\s/ig.test(item.sql)) { |
| | | useExec = true |
| | | maxScript = 1000 |
| | | } else if (sFields && new RegExp(`@(${sFields})@`, 'ig').test(item.sql)) { |
| | | maxScript = 1000 |
| | | } else if (item.sql.length > maxScript) { |
| | | maxScript = item.sql.length |
| | | } |
| | | }) |
| | | |
| | | res.setting.maxScript = maxScript |
| | | |
| | | if (useExec && res.setting.sync === 'true') { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '当前数据源使用了同步查询且自定义脚本中存在函数exec,如遇接口报错需关闭同步查询后重新测试。', |
| | | duration: 5 |
| | | }) |
| | | } |
| | | |
| | | if (config.subtype !== 'dualdatacard') { |
| | | delete res.subColumns |
| | |
| | | if (res.setting && res.setting.tableName && config.setting && !config.setting.tableName) { |
| | | setTimeout(() => { |
| | | MKEmitter.emit('publicTableChange', res.setting.tableName, 'init') |
| | | }, 100) |
| | | } |
| | | |
| | | if ((config.type === 'card' && config.subtype === 'datacard') || (config.type === 'table' && config.subtype === 'normaltable')) { |
| | | setTimeout(() => { |
| | | MKEmitter.emit('mkUpdateInter', {uuid: config.uuid, columns: res.columns}, {delay: 0}) |
| | | }, 150) |
| | | } |
| | | }, () => { |
| | | this.setState({loading: false}) |
| | | }) |
| | | } |
| | | |
| | | cancel = () => { |
| | | this.verifyRef.closeDataSource(() => { |
| | | this.setState({ visible: false, loading: false }) |
| | | }) |
| | | } |
| | | |
| | |
| | | onCancel={() => {this.setState({ visible: false, loading: false }) }} |
| | | footer={[ |
| | | config.subtype !== 'dualdatacard' && record.interType === 'inner' ? <CreateFunc key="create" getMsg={this.creatFunc}/> : null, |
| | | <Button key="cancel" onClick={() => { this.setState({ visible: false, loading: false }) }}>取消</Button>, |
| | | <Button key="cancel" onClick={this.cancel}>取消</Button>, |
| | | <Button key="confirm" type="primary" loading={loading} onClick={this.verifySubmit}>确定</Button> |
| | | ]} |
| | | destroyOnClose |