| | |
| | | changeScripts = (interfaces) => { |
| | | const { config } = this.props |
| | | |
| | | interfaces = interfaces.map(item => { |
| | | item.$tables = this.getTables(item) |
| | | return item |
| | | }) |
| | | |
| | | this.setState({ interfaces }) |
| | | this.props.updateConfig({...config, interfaces}) |
| | | } |
| | | |
| | | getTables = (record) => { |
| | | let tables = [] |
| | | let cuts = [] |
| | | let cutreg = /(from|update|insert\s+into)\s+(@db@)?[a-z_]+/ig |
| | | let trimreg = /(from|update|insert\s+into)\s+(@db@)?/ig |
| | | |
| | | if (record.setting.interType === 'system') { |
| | | if (record.setting.execute !== 'false') { |
| | | let tbs = record.setting.dataresource.match(cutreg) |
| | | tbs && cuts.push(...tbs) |
| | | } |
| | | record.scripts && record.scripts.forEach(script => { |
| | | if (script.status === 'false') return |
| | | let tbs = script.sql.match(cutreg) |
| | | tbs && cuts.push(...tbs) |
| | | }) |
| | | } else { |
| | | let tb = record.setting.tableName.replace(/@db@|\s+/ig, '') |
| | | if (/[a-z_]+/ig.test(tb)) { |
| | | tables.push(tb) |
| | | } |
| | | } |
| | | |
| | | cuts = cuts.map(item => item.replace(trimreg, '')) |
| | | tables.push(...cuts) |
| | | tables = tables.filter(Boolean) |
| | | tables = Array.from(new Set(tables)) |
| | | |
| | | return tables |
| | | } |
| | | |
| | | update = (record) => { |
| | |
| | | record.status = 'false' |
| | | } |
| | | record.name = record.setting.name |
| | | record.$tables = this.getTables(record) |
| | | |
| | | let interfaces = this.state.interfaces.map(item => { |
| | | if (item.uuid !== record.uuid) { |