king
2022-12-09 cb9ade2afd2a367ad767bc605ab7086c695dd010
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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