From 03a22ec6f9ad7303d10b4c65bb5bc6fa5cbd448a Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期六, 22 十月 2022 23:21:42 +0800 Subject: [PATCH] 2022-10-22 --- src/menu/datasource/verifycard/index.jsx | 182 ++++++++++++++++++++++++++++++++++++++------ 1 files changed, 155 insertions(+), 27 deletions(-) diff --git a/src/menu/datasource/verifycard/index.jsx b/src/menu/datasource/verifycard/index.jsx index e97052a..ec62f40 100644 --- a/src/menu/datasource/verifycard/index.jsx +++ b/src/menu/datasource/verifycard/index.jsx @@ -2,7 +2,7 @@ import PropTypes from 'prop-types' import { fromJS } from 'immutable' import { Form, Tabs, Popconfirm, notification, Modal, Typography, Spin, message, Button } from 'antd' -import { StopOutlined, CheckCircleOutlined, EditOutlined, SwapOutlined, DeleteOutlined, CopyOutlined, BorderOutlined } from '@ant-design/icons' +import { StopOutlined, CheckCircleOutlined, EditOutlined, SwapOutlined, DeleteOutlined, CopyOutlined, BorderOutlined, SnippetsOutlined } from '@ant-design/icons' import moment from 'moment' import Api from '@/api' @@ -12,6 +12,7 @@ import ColForm from './columnform' import CustomScriptsForm from './customscript' import SettingForm from './settingform' +import PasteForm from '@/templates/zshare/pasteform' import SettingUtils from './utils' import MinView from '@/assets/img/minview.png' import './index.scss' @@ -25,7 +26,6 @@ class VerifyCard extends Component { static propTpyes = { - dict: PropTypes.object, // 瀛楀吀椤� config: PropTypes.object, // 缁勪欢閰嶇疆淇℃伅 } @@ -39,6 +39,8 @@ defaultSearch: '', systemScripts: [], visible: false, + pvisible: false, + reload: false, script: null, scriptValue: '', colColumns: [ @@ -146,11 +148,11 @@ dataIndex: 'operation', render: (text, record) => (<div style={{textAlign: 'center'}}> - <span className="operation-btn" title={this.props.dict['model.edit']} onClick={() => this.handleEdit(record)} style={{color: '#1890ff'}}><EditOutlined /></span> - <span className="operation-btn" title={this.props.dict['model.status.change']} onClick={() => this.handleStatus(record)} style={{color: '#8E44AD'}}><SwapOutlined /></span> + <span className="operation-btn" title="缂栬緫" onClick={() => this.handleEdit(record)} style={{color: '#1890ff'}}><EditOutlined /></span> + <span className="operation-btn" title="鐘舵�佸垏鎹�" onClick={() => this.handleStatus(record)} style={{color: '#8E44AD'}}><SwapOutlined /></span> <Popconfirm overlayClassName="popover-confirm" - title={this.props.dict['model.query.delete']} + title="纭畾鍒犻櫎鍚�?" onConfirm={() => this.deleteScript(record) }> <span className="operation-btn" style={{color: '#ff4d4f'}}><DeleteOutlined /></span> @@ -202,6 +204,13 @@ } getsysScript = () => { + if (sessionStorage.getItem('mk_sys_scripts')) { + this.setState({ + systemScripts: JSON.parse(sessionStorage.getItem('mk_sys_scripts')) + }) + return + } + let _scriptSql = `Select distinct func+Remark as funcname,longparam, s.Sort from聽 s_custom_script s inner join (select OpenID from sapp where ID=@Appkey@) p on s.openid = case when s.appkey='' then s.openid else p.OpenID end order by s.Sort` _scriptSql = Utils.formatOptions(_scriptSql) @@ -220,16 +229,14 @@ Api.getSystemConfig(_sParam).then(res => { if (res.status) { - let _scripts = [] - - res.data.forEach(item => { - let _item = { + let _scripts = res.data.map(item => { + return { name: item.funcname, value: window.decodeURIComponent(window.atob(item.longparam)) } - - _scripts.push(_item) }) + + sessionStorage.setItem('mk_sys_scripts', JSON.stringify(_scripts)) this.setState({ systemScripts: _scripts @@ -277,7 +284,8 @@ handleEdit = (record) => { this.scriptsForm.edit(record) - let node = document.getElementById('model-data-source-wrap').parentNode + // let node = document.getElementById('mk-scripts-tabpane').parentNode + let node = document.getElementById('mk-scripts-tabpane') if (node && node.scrollTop) { let inter = Math.ceil(node.scrollTop / 10) @@ -688,6 +696,105 @@ }) } + copyDatasource = () => { + const { config } = this.props + const { columns, scripts } = this.state + + if (columns.length === 0) { + notification.warning({ + top: 92, + message: '璇锋坊鍔犲瓧娈甸泦!', + duration: 5 + }) + return + } + + this.settingForm.handleConfirm().then(res => { + delete res.supModule + res.name = config.name + + let source = { + key: 'interface', + type: 'line', + data: {setting: res, columns, scripts, pageable: false, format: 'array', name: res.name, status: 'false', type: 'interface', uuid: '' } + } + + try { + source = window.btoa(window.encodeURIComponent(JSON.stringify(source))) + } catch (e) { + console.warn('Stringify Failure') + source = '' + } + + if (source) { + let oInput = document.createElement('input') + oInput.value = source + document.body.appendChild(oInput) + oInput.select() + document.execCommand('Copy') + document.body.removeChild(oInput) + message.success('澶嶅埗鎴愬姛銆�') + } + }) + } + + pasteSubmit = () => { + const { config } = this.props + const { setting } = this.state + + this.pasteFormRef.handleConfirm().then(res => { + if (res.key !== 'interface') { + notification.warning({ + top: 92, + message: '閰嶇疆绫诲瀷閿欒!', + duration: 5 + }) + return + } else if (res.type !== 'line') { + notification.warning({ + top: 92, + message: '璇风矘璐村崟椤规暟鎹簮!', + duration: 5 + }) + return + } + + if (setting.supModule) { + res.data.setting.supModule = setting.supModule + } + + if (config.subtype !== 'basetable') { + this.setState({ + scripts: res.data.scripts.map(col => { + col.uuid = Utils.getuuid() + return col + }), + columns: res.data.columns.map(col => { + col.uuid = Utils.getuuid() + return col + }), + setting: res.data.setting, + reload: true, + pvisible: false + }, () => { + this.setState({reload: false}) + }) + } else { + this.setState({ + scripts: res.data.scripts.map(col => { + col.uuid = Utils.getuuid() + return col + }), + setting: res.data.setting, + reload: true, + pvisible: false + }, () => { + this.setState({reload: false}) + }) + } + }) + } + copyColumns = () => { const { columns } = this.state let m = [] @@ -720,39 +827,50 @@ render() { const { config } = this.props - const { columns, setting, scripts, colColumns, scriptsColumns, activeKey, loading, searches, defaultsql, visible, script, scriptValue } = this.state + const { columns, setting, scripts, colColumns, scriptsColumns, activeKey, loading, searches, defaultsql, visible, pvisible, reload, script, scriptValue } = this.state return ( - <div id="model-data-source-wrap"> + <div className="model-data-source-wrap"> + {config.name ? <div className="mk-com-name">{config.name} - 鏁版嵁婧�</div> : null} {loading && <Spin size="large" />} <Tabs activeKey={activeKey} className="data-source-card-box" onChange={this.changeTab}> - <TabPane tab="鏁版嵁婧�" key="setting"> - <SettingForm - dict={this.props.dict} + <TabPane tab={ + <span> + 鏁版嵁婧� + {config.type !== 'interface' ? <CopyOutlined title="澶嶅埗鏁版嵁婧�" className="mk-copy-datasource" onClick={this.copyDatasource}/> : null} + {config.type !== 'interface' ? <SnippetsOutlined title="瀵煎叆鏁版嵁婧�" className="mk-paste-datasource" onClick={() => this.setState({pvisible: true})}/> : null} + </span> + } key="setting"> + {!reload ? <SettingForm config={config} columns={columns} setting={setting} scripts={scripts} wrappedComponentRef={(inst) => this.settingForm = inst} - /> + /> : null} </TabPane> - <TabPane tab="瀛楁闆�" key="columns"> - <ColForm dict={this.props.dict} columnChange={this.columnChange}/> + {config.subtype !== 'basetable' ? <TabPane tab={ + <span> + 瀛楁闆� + {columns.length ? <span className="count-tip">{columns.length}</span> : null} + <CopyOutlined title="浠ラ�楀彿鎷兼帴褰㈠紡澶嶅埗瀛楁" className="mk-copy-fields" onClick={this.copyColumns}/> + </span> + } key="columns"> + <ColForm columnChange={this.columnChange}/> <FieldsComponent config={{...config, columns}} type="fields" updatefield={this.updatefields} /> - <CopyOutlined title="浠ラ�楀彿鎷兼帴褰㈠紡澶嶅埗瀛楁" onClick={this.copyColumns} style={{position: 'absolute', cursor: 'pointer', zIndex: 1, top: '-35px', right: '0px', color: '#1890ff'}} /> <EditTable actions={['edit', 'move', 'copy', 'del', 'clear']} type="datasourcefield" wrappedComponentRef={(inst) => this.datasource = inst} data={columns} columns={colColumns} onChange={(columns) => this.setState({columns})}/> - </TabPane> + </TabPane> : null} <TabPane tab={ <span> 鑷畾涔夎剼鏈� {scripts.length ? <span className="count-tip">{scripts.length}</span> : null} </span> - } key="scripts"> - <BorderOutlined className="full-scripts" onClick={() => { + } key="scripts" id="mk-scripts-tabpane"> + {scripts.length ? <BorderOutlined className="full-scripts" onClick={() => { if (this.scriptsForm && (this.scriptsForm.state.editItem || (this.scriptsForm.props.form.getFieldValue('sql') && !/^\s+$/.test(this.scriptsForm.props.form.getFieldValue('sql'))))) { notification.warning({ top: 92, @@ -762,13 +880,12 @@ return } this.setState({visible: true, script: null, scriptValue: ''}) - }}/> + }}/> : null} <CustomScriptsForm setting={setting} searches={searches} defaultsql={defaultsql} initsql={this.state.initsql} - dict={this.props.dict} customScripts={scripts} systemScripts={this.state.systemScripts} scriptsChange={this.scriptsChange} @@ -815,7 +932,7 @@ <span className="operation-btn" onClick={() => this.handleStatus(item)} style={{color: '#8E44AD'}}><SwapOutlined /></span> <Popconfirm overlayClassName="popover-confirm" - title={this.props.dict['model.query.delete']} + title="纭畾鍒犻櫎鍚�?" onConfirm={() => this.deleteScript(item) }> <span className="operation-btn" style={{color: '#ff4d4f'}}><DeleteOutlined /></span> @@ -835,6 +952,17 @@ </div> <CodeMirror value={scriptValue} onChange={(val) => {this.setState({scriptValue: val})}}></CodeMirror> </Modal> + <Modal + title="绮樿创" + visible={pvisible} + width={600} + maskClosable={false} + onOk={this.pasteSubmit} + onCancel={() => {this.setState({pvisible: false})}} + destroyOnClose + > + <PasteForm wrappedComponentRef={(inst) => this.pasteFormRef = inst} inputSubmit={this.pasteSubmit}/> + </Modal> </div> ) } -- Gitblit v1.8.0