king
2022-02-24 f2aa6b6a973e9b2f541bba7fc23e71d7791311f8
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { Button, Select, Input, DatePicker } from 'antd'
// import { EditOutlined, ToolOutlined, DeleteOutlined, FontColorsOutlined } from '@ant-design/icons'
 
import asyncComponent from '@/utils/asyncComponent'
// import MKEmitter from '@/utils/events.js'
import './index.scss'
 
const VoucherTable = asyncComponent(() => import('./voucherTable'))
 
class VoucherModule extends Component {
  static propTpyes = {
    BID: PropTypes.any,              // 父级Id
    config: PropTypes.object,        // 组件配置信息
  }
 
  state = {
    BID: '',
    type: '',
    config: null,
    loading: false,
    data: null,
    searchkey: null,
    disableAdd: true,
    disableSave: true,
    typeOptions: []
  }
 
  UNSAFE_componentWillMount () {
    const { config, BID } = this.props
 
    this.setState({
      config: fromJS(config).toJS(),
      BID: BID || '',
      type: config.wrap.type
    }, () => {
      this.loadData()
    })
  }
 
  componentDidMount () {
 
  }
 
  shouldComponentUpdate (nextProps, nextState) {
    return !is(fromJS(this.state), fromJS(nextState))
  }
 
  /**
   * @description 组件销毁,清除state更新,清除快捷键设置
   */
  componentWillUnmount () {
    this.setState = () => {
      return
    }
  }
 
  loadData = () => {
 
  }
 
  triggeradd = () => {
    
  }
 
  triggersave = () => {
 
  }
 
  triggerprint = () => {
 
  }
 
  render() {
    const { config, disableSave, disableAdd, typeOptions, data, type } = this.state
 
    return (
      <div className="menu-voucher-wrap" style={config.style}>
        <div className="voucher-header">
          <Button className="system-background header-btn" disabled={disableAdd} onClick={this.triggeradd}>新增</Button>
          <Button className="system-background header-btn" disabled={disableSave} onClick={this.triggersave}>保存</Button>
          <Button className="system-background header-btn" disabled={disableSave} onClick={this.triggerprint}>打印</Button>
          <Button className="system-background header-btn" disabled={disableSave} onClick={this.triggerprint}>导入</Button>
          <Button className="system-background header-btn" disabled={disableSave} onClick={this.triggerprint}>导出</Button>
        </div>
        {type === 'edit' ? <div className="voucher-body">
          <div className="pre-wrap">
            <div className="voucher-code">
              <Select>
                {typeOptions.map(option =>
                  <Select.Option value={option.value}>{option.label}</Select.Option>
                )}
              </Select>
              <Input autoComplete="off" /> 号
            </div>
            <div className="voucher-date">
              日期:<DatePicker onChange={this.onChange}/>
            </div>
            <div className="voucher-affix">
              附单据 <Input autoComplete="off" /> 张
              <Button type="link" className="" onClick={this.triggerprint}>附件</Button>
              <Button type="link" className="" onClick={this.triggerprint}>备注</Button>
            </div>
          </div>
          <VoucherTable config={config} data={data}/>
        </div> : null}
        {type === 'check' ? <div className="voucher-body">
          <div className="pre-wrap">
            <div className="voucher-code">
              记 1 号
            </div>
            <div className="voucher-date">
              日期:2022-02-24
            </div>
            <div className="voucher-affix">
              附单据 2 张
              <Button type="link" className="" onClick={this.triggerprint}>附件</Button>
              <Button type="link" className="" onClick={this.triggerprint}>备注</Button>
            </div>
          </div>
          <VoucherTable config={config} data={data}/>
        </div> : null}
      </div>
    )
  }
}
 
export default VoucherModule