From 8a6ce370f1aa1c061b76fa3e9d2d4d1df53ca4c5 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 21 五月 2024 16:38:09 +0800 Subject: [PATCH] Merge branch 'master' into positec --- src/menu/datasource/verifycard/index.jsx | 124 +++++++++++++++++++++++++++++++--------- 1 files changed, 95 insertions(+), 29 deletions(-) diff --git a/src/menu/datasource/verifycard/index.jsx b/src/menu/datasource/verifycard/index.jsx index e103038..8fb10d0 100644 --- a/src/menu/datasource/verifycard/index.jsx +++ b/src/menu/datasource/verifycard/index.jsx @@ -48,6 +48,7 @@ systemScripts: [], median: {}, visible: false, + editLineId: '', pvisible: false, reload: false, script: null, @@ -215,9 +216,11 @@ let columns = config.columns ? fromJS(config.columns).toJS() : [] let subColumns = config.subColumns ? fromJS(config.subColumns).toJS() : [] - columns.reverse() + if (!config.fixedCol) { + columns.reverse() + } subColumns.reverse() - + columns.forEach(col => { if (!col.datatype) return if (/^nvarchar/.test(col.datatype)) { @@ -545,7 +548,7 @@ submitDataSource = () => { const { config, mainSearch } = this.props - const { activeKey, setting, columns, subColumns, scripts, cols } = this.state + const { activeKey, setting, columns, subColumns, scripts, cols, median } = this.state if (config.subtype === 'dualdatacard') { let arr = columns.map(col => col.field.toLowerCase()) @@ -579,6 +582,25 @@ message: '瀛楁闆嗕腑涓嶅彲浣跨敤' + _arr.join('銆�') + '锛佹敞锛氭瀛楁涓烘彁浜ゆ椂鐨勭郴缁熷瓧娈点��', duration: 5 }) + return Promise.reject() + } + } + + if (median.interType === 'system') { + let _loading = false + if (this.scriptsForm && this.scriptsForm.state.editItem) { + _loading = true + } else if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql') && !/^\s+$/.test(this.scriptsForm.props.form.getFieldValue('sql'))) { + _loading = true + } + + if (_loading) { + notification.warning({ + top: 92, + message: '瀛樺湪鏈繚瀛樿剼鏈紝璇风偣鍑荤‘瀹氫繚瀛橈紝鎴栫偣鍑诲彇娑堟斁寮冧慨鏀癸紒', + duration: 5 + }) + this.setState({activeKey: 'scripts'}) return Promise.reject() } } @@ -624,23 +646,6 @@ } this.sqlverify(() => { resolve({setting, columns, subColumns, scripts, cols }) }, reject, 'submit') } else if (activeKey === 'scripts') { - let _loading = false - if (this.scriptsForm && this.scriptsForm.state.editItem) { - _loading = true - } else if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql') && !/^\s+$/.test(this.scriptsForm.props.form.getFieldValue('sql'))) { - _loading = true - } - - if (_loading) { - notification.warning({ - top: 92, - message: '瀛樺湪鏈繚瀛樿剼鏈紝璇风偣鍑荤‘瀹氫繚瀛橈紝鎴栫偣鍑诲彇娑堟斁寮冧慨鏀癸紒', - duration: 5 - }) - reject() - return - } - this.sqlverify(() => { resolve({setting, columns, subColumns, scripts, cols }) }, reject, 'submit') } }) @@ -675,7 +680,8 @@ if (config.subtype === 'dualdatacard') { _columns = [...columns, ...subColumns] } - let r = SettingUtils.getDebugSql(setting, _scripts, _columns, searches, config.type) + + let r = SettingUtils.getDebugSql(setting, _scripts, _columns, searches, config.subtype, config.hasExtend) let _debugId = md5(r.sql) @@ -807,7 +813,9 @@ return } + let editLineId = '' if (script) { + editLineId = script.uuid _scripts = _scripts.map(item => { if (script.uuid === item.uuid) { item.sql = scriptValue @@ -822,10 +830,11 @@ status: 'true' } + editLineId = _script.uuid _scripts.push(_script) } - this.setState({loading: true}) + this.setState({loading: true, editLineId}) this.sqlverify(() => {this.setState({scripts: _scripts, script: null, scriptValue: '', loading: false})}, () => {this.setState({loading: false})}, 'script', _scripts) } @@ -952,7 +961,9 @@ } copyColumns = () => { - const { columns } = this.state + const { config } = this.props + const { columns, setting } = this.state + let m = [] let n = [] let s = [] @@ -975,9 +986,57 @@ console.info('select ' + s.join(', ')) } + let extend = '' + if (config.hasExtend) { + extend = [] + let mapCol = (cols) => { + cols.forEach(col => { + if (col.type === 'extend') { + let datatype = 'Nvarchar(50)' + columns.forEach(c => { + if (c.field === col.field) { + datatype = c.datatype + } + }) + for (let i = 1; i < col.quota; i++) { + extend.push(`${col.field}${i} ${datatype}`) + } + } else if (col.type === 'colspan' && col.subcols) { + mapCol(col.subcols) + } + }) + } + mapCol(config.cols) + extend = ` + /* 鎵╁睍鍒楀瓧娈� */ + /* ${extend.join(',')} */ + ` + } + let oInput = document.createElement('input') - oInput.value = `/*${m.join(',')}*/ - ${n.join(',')}` + oInput.value = `create table #${setting.tableName || 'tb'} + (${m.join(',')},sort_id INT IDENTITY(1,1)) + insert into #${setting.tableName || 'tb'} + (${n.join(',')}) + select ${n.join(',')} + from ${setting.dataresource ? `(${setting.dataresource.replace(/\n/g, ' ')}) tb` : setting.tableName || 'tb'} + order by @orderBy@ + + declare @mk_total int + set @mk_total = 0 + + select @mk_total = count(1) from #${setting.tableName || 'tb'} + declare @pageIndex_top int + set @pageIndex_top=(@pageIndex@-1)*@pageSize@ + + if @mk_total > @pageIndex@*@pageSize@ + delete #${setting.tableName || 'tb'} where sort_id > @pageIndex@*@pageSize@ + + if @pageIndex_top > 0 + delete #${setting.tableName || 'tb'} where sort_id <= @pageIndex_top + + drop table #${setting.tableName || 'tb'}${extend}` + document.body.appendChild(oInput) oInput.select() document.execCommand('Copy') @@ -1104,7 +1163,7 @@ render() { const { config } = this.props - const { columns, subColumns, median, setting, scripts, colColumns, scriptsColumns, activeKey, loading, searches, defaultsql, visible, pvisible, reload, script, scriptValue, searchKey } = this.state + const { columns, subColumns, median, setting, scripts, colColumns, scriptsColumns, activeKey, loading, searches, defaultsql, visible, pvisible, reload, script, scriptValue, searchKey, editLineId } = this.state return ( <div className="model-data-source-wrap"> @@ -1128,7 +1187,7 @@ wrappedComponentRef={(inst) => this.settingForm = inst} /> : null} </TabPane> - {config.subtype !== 'basetable' ? <TabPane tab={ + {!['basetable', 'invoice', 'invTable'].includes(config.subtype) ? <TabPane tab={ <span> 瀛楁闆� {columns.length ? <span className="count-tip">{columns.length}</span> : null} @@ -1184,10 +1243,11 @@ }) return } - this.setState({visible: true, script: null, scriptValue: ''}) + this.setState({visible: true, script: null, scriptValue: '', editLineId: ''}) }}/> : null} <CustomScriptsForm type={config.type} + hasExtend={config.hasExtend} setting={setting} searches={searches} defaultsql={defaultsql} @@ -1234,8 +1294,14 @@ </div> ) } else { + let sign = '' + if (script && script.uuid === item.uuid) { + sign = 'active' + } else if (editLineId === item.uuid) { + sign = 'edited' + } return ( - <div className={'script-item ' + (script && script.uuid === item.uuid ? 'active' : '') } key={item.uuid}> + <div className={'script-item ' + sign} key={item.uuid}> <div style={{cursor: 'pointer'}} onClick={() => { this.setState({script: item, scriptValue: item.sql}) }}> -- Gitblit v1.8.0