From ee50d5424a093209d1c5c549f4578107893b22f8 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 05 十一月 2020 18:40:54 +0800 Subject: [PATCH] 2020-11-05 --- src/menu/datasource/verifycard/index.jsx | 138 +++++++++++++++++++++++++++++++++++++++------ 1 files changed, 118 insertions(+), 20 deletions(-) diff --git a/src/menu/datasource/verifycard/index.jsx b/src/menu/datasource/verifycard/index.jsx index e1b3e56..8332eac 100644 --- a/src/menu/datasource/verifycard/index.jsx +++ b/src/menu/datasource/verifycard/index.jsx @@ -122,19 +122,77 @@ } UNSAFE_componentWillMount() { - const { config, mainSearch } = this.props + const { config, mainSearch, menu } = this.props let search = config.search || [] - search = [...search, ...mainSearch] + + if (config.setting.useMSearch === 'true') { // 浣跨敤涓绘悳绱㈡潯浠� + search = [...search, ...mainSearch] + } + + let Marks = [] + let getcomponentmarks = (box, conf) => { + if (!conf.parentId && box.Template === 'CustomPage') { + box.components.forEach(item => { + if (item.uuid !== conf.uuid && item.setting && item.setting.varMark) { + Marks.push(item.setting.varMark) + } + }) + } else if (conf.parentId === box.parentId && conf.tabId === box.uuid) { + box.components.forEach(item => { + if (item.uuid !== conf.uuid && item.setting && item.setting.varMark) { + Marks.push(item.setting.varMark) + } + }) + } else { + box.components.forEach(item => { + if (item.type !== 'tabs') return + + item.subtabs.forEach(tab => { + getcomponentmarks(tab, conf) + }) + }) + } + } + + getcomponentmarks(menu, config) + + let _setting = fromJS(config.setting).toJS() + + if (!_setting.varMark) { + _setting.varMark = this.getMark(Marks) + } this.setState({ columns: fromJS(config.columns).toJS(), - setting: fromJS(config.setting).toJS(), + setting: _setting, scripts: fromJS(config.scripts).toJS(), - searches: search + searches: search, + varMarks: Marks }) this.getsysScript() + } + + getMark = (varMarks) => { + let m = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] + let i = 0 + let n = 25 + + let name = '' + while (!name) { + name = `${m[n]}${m[i]}_` + if (varMarks.includes(name) && n > 0) { + i++ + if (i >= 26) { + n-- + i = 0 + } + name = '' + } + } + + return name } getsysScript = () => { @@ -309,12 +367,32 @@ } changeTab = (val) => { - const { activeKey } = this.state + const { config, mainSearch } = this.props + const { activeKey, varMarks } = this.state this.setState({loading: true}) if (activeKey === 'setting') { this.settingForm.handleConfirm().then(res => { + let search = config.search || [] + + if (res.useMSearch === 'true') { // 浣跨敤涓绘悳绱㈡潯浠� + search = [...search, ...mainSearch] + } + + if (res.varMark && varMarks.includes(res.varMark)) { + notification.warning({ + top: 92, + message: '鍙橀噺鏍囪瘑涓嶅彲閲嶅锛�', + duration: 5 + }) + this.setState({ + loading: false + }) + return + } + this.setState({ + searches: search, setting: res }, () => { this.sqlverify(() => { // 楠岃瘉鎴愬姛 @@ -324,6 +402,7 @@ }) }, () => { // 楠岃瘉澶辫触 this.setState({ + activeKey: val, loading: false }) }, true) @@ -340,7 +419,7 @@ 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') && this.scriptsForm.props.form.getFieldValue('sql') !== ' ') { _loading = true } @@ -360,27 +439,34 @@ activeKey: val, loading: false }) - - // this.sqlverify(() => { // 楠岃瘉鎴愬姛 - // this.setState({ - // activeKey: val, - // loading: false - // }) - // }, () => { // 楠岃瘉澶辫触 - // this.setState({ - // loading: false - // }) - // }, true) } } submitDataSource = () => { - const { activeKey, setting, columns, scripts } = this.state + const { config, mainSearch } = this.props + const { activeKey, setting, columns, scripts, varMarks } = this.state return new Promise((resolve, reject) => { if (activeKey === 'setting') { this.settingForm.handleConfirm().then(res => { + let search = config.search || [] + + if (res.useMSearch === 'true') { // 浣跨敤涓绘悳绱㈡潯浠� + search = [...search, ...mainSearch] + } + + if (res.varMark && varMarks.includes(res.varMark)) { + notification.warning({ + top: 92, + message: '鍙橀噺鏍囪瘑涓嶅彲閲嶅锛�', + duration: 5 + }) + reject() + return + } + this.setState({ + searches: search, setting: res }, () => { this.sqlverify(() => { resolve({setting: res, columns, scripts }) }, reject, false) @@ -394,7 +480,7 @@ 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') && this.scriptsForm.props.form.getFieldValue('sql') !== ' ') { _loading = true } @@ -432,9 +518,21 @@ } if ((setting.interType === 'system' && setting.execute !== 'false') || _scripts.length > 0) { + let result = SettingUtils.getDebugSql(setting, _scripts, columns, searches) + + if (result.error) { + notification.warning({ + top: 92, + message: result.error, + duration: 5 + }) + reject() + return + } + let param = { func: 's_debug_sql', - LText: SettingUtils.getDebugSql(setting, _scripts, columns, searches) + LText: result.sql } param.LText = Utils.formatOptions(param.LText) param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') -- Gitblit v1.8.0