king
2023-02-10 253fbcbdd06f6354e857a8e1e47ddf116459df42
src/tabviews/custom/components/module/voucher/index.jsx
@@ -11,8 +11,9 @@
import './index.scss'
const { confirm } = Modal
const { TextArea } = Input
const VoucherTable = asyncComponent(() => import('./voucherTable'))
const ResetRemark = asyncComponent(() => import('./resetRemark'))
const ResetAttach = asyncComponent(() => import('./resetAttach'))
class VoucherModule extends Component {
  static propTpyes = {
@@ -34,8 +35,8 @@
    book: null,
    username: sessionStorage.getItem('User_Name'),
    remark: '',
    remarkVisible: false,
    attachments: 0,
    attachlist: [],
    title: '',
    orgcode: '',
    orgname: '',
@@ -603,23 +604,7 @@
  }
  triggerprint = () => {
    this.setState({remarkVisible: true})
  }
  remarkSubmit = () => {
    const { config } = this.state
    let node = document.getElementById(config.uuid + 'remark')
    let val = node.value
    if (val && val.length > 512) {
      notification.warning({
        top: 92,
        message: '当前内容超长,备注最多512个字符。',
        duration: 5
      })
      return
    }
    this.setState({remark: val, remarkVisible: false})
  }
  dataChange = (data) => {
@@ -651,7 +636,7 @@
  }
  updateVoucherChar = (val) => {
    const {book} = this.state
    const { book, config } = this.state
    if (!book) return
@@ -674,17 +659,38 @@
        return
      }
      // let typeOptions = res.char || []
      // let charInt = typeOptions[0] ? typeOptions[0].voucher_char_int + 1 : 1
      let typeOptions = res.char || []
      // this.setState({
      //   typeOptions: typeOptions,
      //   charType: typeOptions[0] ? typeOptions[0].voucher_class : '',
      //   charName: typeOptions[0] ? typeOptions[0].voucher_char : '',
      //   charInt: charInt,
      //   orgcode: res.orgcode,
      //   orgname: res.orgname,
      // })
      if (typeOptions.length > 0) {
        let charType = this.state.charType
        let charName = this.state.charName
        let charInt = this.state.charInt
        if (charType && typeOptions.filter(n => n.voucher_class === charType) > 0) {
          typeOptions.forEach(n => {
            if (n.voucher_class === charType) {
              charName = n.voucher_char
              charInt = n.voucher_char_int + 1
            }
          })
        } else {
          charType = typeOptions[0].voucher_class
          charName = typeOptions[0].voucher_char
          charInt = typeOptions[0].voucher_char_int + 1
        }
        this.setState({
          typeOptions: typeOptions,
          charType: charType,
          charName: charName,
          charInt: charInt
        })
      }
      let msg = window.GLOB.CacheVoucher.get(config.uuid) || {}
      msg.currency = res.currency || []
      window.GLOB.CacheVoucher.set(config.uuid, msg)
    })
  }
@@ -696,12 +702,8 @@
  }
  triggerAttach = () => {
  }
  render() {
    const { type, status, loading, config, typeOptions, charType, charInt, data, vouDate, username, remark, remarkVisible, attachments, title } = this.state
    const { type, status, loading, config, typeOptions, charType, charInt, data, vouDate, username, remark, attachments, title, attachlist } = this.state
    return (
      <div className="menu-voucher-wrap" style={config.style}>
@@ -734,24 +736,13 @@
            </div>
            <div className="voucher-affix">
              附单据 <InputNumber precision={0} value={attachments || 0} autoComplete="off" onChange={this.changeAttach}/> 张
              <Button type="link" className="" onClick={this.triggerAttach}>附件</Button>
              <Button type="link" className="" onClick={this.triggerprint}>备注</Button>
              <ResetAttach attachlist={attachlist} onChange={(vals) => this.setState({attachlist: vals})}/>
              <ResetRemark remark={remark} ID={config.uuid + 'remark'} onChange={(val) => this.setState({remark: val})}/>
            </div>
          </div> : null}
          <VoucherTable config={config} loading={loading} data={data} onChange={this.dataChange}/>
        </div>
        <div className="user">制单人:{username}</div>
        <Modal
          title="备注"
          visible={remarkVisible}
          width={700}
          maskClosable={false}
          onOk={this.remarkSubmit}
          onCancel={() => { this.setState({ remarkVisible: false })}}
          destroyOnClose
        >
          <TextArea id={config.uuid + 'remark'} defaultValue={remark} rows={6}/>
        </Modal>
      </div>
    )
  }