From 1654c2e3838428eeef6bc04b5e46811cafdaf608 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 10 十月 2022 15:25:58 +0800 Subject: [PATCH] 2022-10-10 --- src/menu/datasource/verifycard/index.jsx | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 110 insertions(+), 5 deletions(-) diff --git a/src/menu/datasource/verifycard/index.jsx b/src/menu/datasource/verifycard/index.jsx index 64a38ce..8cbd450 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' @@ -39,6 +40,8 @@ defaultSearch: '', systemScripts: [], visible: false, + pvisible: false, + reload: false, script: null, scriptValue: '', colColumns: [ @@ -694,6 +697,90 @@ }) } + 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 { 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 + } + + 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}) + }) + }) + } + copyColumns = () => { const { columns } = this.state let m = [] @@ -726,26 +813,33 @@ 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 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 + <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 dict={this.props.dict} config={config} columns={columns} setting={setting} scripts={scripts} wrappedComponentRef={(inst) => this.settingForm = inst} - /> + /> : null} </TabPane> <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"> @@ -846,6 +940,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