import React, {Component} from 'react'
|
import { Input, notification } from 'antd'
|
import moment from 'moment'
|
|
import Utils from '@/utils/utils.js'
|
import Api from '@/api'
|
import CodeMirror from '@/templates/zshare/codemirror'
|
import './index.scss'
|
|
const { Search } = Input
|
|
class ProcControl extends Component {
|
state = {
|
procName: '',
|
content: null,
|
loading: false
|
}
|
|
componentDidMount () {
|
|
}
|
|
search = (value) => {
|
let proc = value.replace(/^(\s*)|(\s*)$/ig, '')
|
|
if (!proc) {
|
this.setState({content: '', procName: ''})
|
return
|
}
|
|
let _param = {
|
func: 's_get_userproc',
|
LText: proc
|
}
|
|
_param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
|
_param.secretkey = Utils.encrypt(_param.LText, _param.timestamp)
|
|
this.setState({loading: true})
|
|
Api.genericInterface(_param).then(res => {
|
if (!res.status) {
|
notification.warning({
|
top: 92,
|
message: res.message,
|
duration: 5
|
})
|
this.setState({content: '', procName: '', loading: false})
|
return
|
}
|
|
this.setState({content: res.Ltext.replace(/mchr13k/ig, '\n'), procName: proc, loading: false})
|
})
|
}
|
|
render () {
|
const { loading, content } = this.state
|
|
return (
|
<div className="mk-proc-wrap">
|
<div className="control-wrap">
|
<div className="search-wrap">
|
<Search placeholder="请输入存储过程名称" disabled={loading} enterButton="确定" onSearch={this.search}/>
|
</div>
|
<div className="action-wrap">
|
|
</div>
|
</div>
|
<div className="edit-wrap">
|
<CodeMirror value={content} onChange={(val) => this.setState({content: val})}/>
|
</div>
|
</div>
|
)
|
}
|
}
|
|
export default ProcControl
|