| | |
| | | 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)) { |
| | | useExec = true |
| | | 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)) { |
| | | useExec = true |
| | | maxScript = 1000 |
| | | } else if (item.sql.length > maxScript) { |
| | | maxScript = item.sql.length |
| | | } |
| | | }) |
| | | // 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' && sFields) { |
| | | if (new RegExp(`@(${sFields})@`, 'ig').test(res.setting.dataresource)) { |
| | | maxScript = 1000 |
| | | } |
| | | } |
| | | |
| | | res.scripts.forEach(item => { |
| | | if (item.status === 'false') return |
| | | |
| | | 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 |
| | | |
| | |
| | | }) |
| | | } |
| | | |
| | | cancel = () => { |
| | | this.verifyRef.closeDataSource(() => { |
| | | this.setState({ visible: false, loading: false }) |
| | | }) |
| | | } |
| | | |
| | | creatFunc = () => { |
| | | const { config } = this.props |
| | | const { mainSearch } = this.state |
| | |
| | | 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 |