king
2025-05-13 ba6844240cda904db061ee0b3689aeaf0f50ff5e
src/tabviews/custom/components/module/voucher/voucherTable/index.jsx
@@ -24,36 +24,39 @@
class Accounting extends React.Component {
  state = {
    subAccounts: [],
    record: null
    subAccounts: []
  }
  UNSAFE_componentWillMount() {
    const { data, tableId } = this.props
    let subAccounts = data.sup_accounting.split(',')
    let subAccounts = fromJS(data.supAccounts).toJS()
    let msg = window.GLOB.CacheVoucher.get(tableId) || {}
    let names = msg.names || {}
    subAccounts = subAccounts.map(n => {
      let item = {
        field: n,
        label: names[n] || n,
        initval: data[n] || '',
        options: []
      }
      if (msg[n]) {
        item.options = msg[n]
    subAccounts = subAccounts.map(item => {
      if (msg[item.field]) {
        item.options = msg[item.field]
      } else if (msg.others) {
        item.options = msg.others.filter(cell => cell.parentId === item.field)
      } else {
        item.options = []
      }
      return item
    })
    this.setState({subAccounts: subAccounts, record: fromJS(data).toJS()})
    this.setState({subAccounts: subAccounts})
  }
  selectChange = (val, item) => {
    this.setState({record: {...this.state.record, [item.field]: val || ''}})
  selectChange = (option, key) => {
    this.setState({
      subAccounts: fromJS(this.state.subAccounts).toJS().map(cell => {
        if (key === cell.field) {
          cell.value = option ? option.props.value : ''
          cell.name = option ? option.props.name : ''
        }
        return cell
      })
    })
  }
  getFields() {
@@ -70,10 +73,10 @@
            defaultValue={item.initval}
            dropdownMatchSelectWidth={false}
            filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
            onChange={(val) => this.selectChange(val, item)}
            onChange={(val, option) => this.selectChange(option, item.field)}
          >
            {item.options.map((option, i) =>
              <Select.Option key={i} value={option.value}>{option.label}</Select.Option>
              <Select.Option key={i} name={option.label} value={option.value}>{option.label}</Select.Option>
            )}
          </Select>
        </Form.Item>
@@ -84,11 +87,12 @@
  }
  confirm = () => {
    const { subAccounts, record } = this.state
    const { data } = this.props
    const { subAccounts } = this.state
    let empty = ''
    subAccounts.forEach(item => {
      if (!empty && !record[item.field]) {
      if (!empty && !item.value) {
        empty = item.label
      }
    })
@@ -100,7 +104,41 @@
        duration: 5
      })
    } else {
      this.props.confirm(record)
      let line = fromJS(data).toJS()
      let account = {}
      subAccounts.forEach(item => {
        if (item.field === 'supplier') {
          account[item.field] = {suppliercode: item.value, suppliername: item.name}
        } else if (item.field === 'logistics') {
          account[item.field] = {logistics_code: item.value, logistics_name: item.name}
        } else if (item.field === 'lessor') {
          account[item.field] = {lessor_code: item.value, lessor_name: item.name}
        } else if (item.field === 'customer') {
          account[item.field] = {customercode: item.value, customername: item.name}
        } else if (item.field === 'department') {
          account[item.field] = {co_pro_code: item.value, co_pro_name: item.name}
        } else if (item.field === 'project') {
          account[item.field] = {projectcode: item.value, projectname: item.name}
        } else if (item.field === 'inventory') {
          account[item.field] = {productcode: item.value, productname: item.name}
        } else if (item.field === 'employee') {
          account[item.field] = {workercode: item.value, workername: item.name}
        } else if (item.field === 'cash_flow') {
          account[item.field] = {cash_flow_code: item.value, cash_flow_name: item.name}
        } else {
          account[item.field] = {sup_acc_code: item.value, sup_acc_name: item.name}
        }
      })
      line.supAccounts = line.supAccounts.map(item => {
        if (account[item.field]) {
          item = {...item, ...account[item.field]}
        }
        return item
      })
      this.props.confirm(line)
    }
  }
@@ -157,43 +195,53 @@
    let line = {...record}
    line[col.field] = value
    if (col.field === 'debtor') {
      line.creditor = ''
      if (isNaN(line.debtor)) {
        line.debtor = ''
    if (col.field === 'subject_voucher_text') {
      MKEmitter.emit('changeRecord', col.tableId, line)
      setTimeout(() => {
        let cl = {subject_voucher_text: 'subject_code', subject_code: 'debit', debit: 'credit'}
        MKEmitter.emit('tdFocus', cl[col.uuid] + record.uuid)
      }, 50)
      return
    }
    if (col.field === 'debit') {
      line.credit = ''
      if (isNaN(line.debit)) {
        line.debit = ''
      }
    } else {
      line.debtor = ''
      if (isNaN(line.creditor)) {
        line.creditor = ''
      line.debit = ''
      if (isNaN(line.credit)) {
        line.credit = ''
      }
    }
    if (line.count_type === 'Y' && line.count) {
      if (line.debtor) {
        line.price = Math.round(line.debtor / line.count * 10000) / 10000
      } else if (line.creditor) {
        line.price = Math.round(line.creditor / line.count * 10000) / 10000
    if (line.count_type === 'Y' && line.fcc_count) {
      if (line.debit) {
        line.net_unitprice = Math.round(line.debit / line.fcc_count * 10000) / 10000
      } else if (line.credit) {
        line.net_unitprice = Math.round(line.credit / line.fcc_count * 10000) / 10000
      }
    }
    if (line.foreign_currency_type === 'Y' && line.origin) {
      if (line.debtor) {
        line.unitratio = Math.round(line.debtor / line.origin * 100000) / 100000
      } else if (line.creditor) {
        line.unitratio = Math.round(line.creditor / line.origin * 100000) / 100000
    if (line.foreign_currency_type === 'Y' && line.foreign_amount) {
      if (line.debit) {
        line.unitratio = Math.round(line.debit / line.foreign_amount * 100000) / 100000
      } else if (line.credit) {
        line.unitratio = Math.round(line.credit / line.foreign_amount * 100000) / 100000
      }
    }
    MKEmitter.emit('changeRecord', col.tableId, line)
    setTimeout(() => {
      if (col.field === 'debtor' && (line.debtor || line.debtor === 0)) {
        MKEmitter.emit('nextLine', col, record)
      } else if (col.field === 'creditor') {
        MKEmitter.emit('nextLine', col, record)
      if (col.field === 'debit' && (line.debit || line.debit === 0)) {
        MKEmitter.emit('nextVoucher', col, record)
      } else if (col.field === 'credit') {
        MKEmitter.emit('nextVoucher', col, record)
      } else {
        let cl = {remark: 'subjectscode', subjectscode: 'debtor', debtor: 'creditor'}
        let cl = {subject_voucher_text: 'subject_code', subject_code: 'debit', debit: 'credit'}
        MKEmitter.emit('tdFocus', cl[col.uuid] + record.uuid)
      }
    }, 50)
@@ -204,7 +252,7 @@
    if (record.type === 'total') return
    if (col.field === 'subjectscode') {
    if (col.field === 'subject_code') {
      this.setState({editing: true}, () => {
        let node = document.getElementById(col.uuid + record.uuid)
        node && node.click()
@@ -226,31 +274,36 @@
    if (value !== record[col.field]) {
      let line = {...record, [col.field]: value}
      if (col.field === 'debtor') {
        line.creditor = ''
        if (isNaN(line.debtor)) {
          line.debtor = ''
      if (col.field === 'subject_voucher_text') {
        MKEmitter.emit('changeRecord', col.tableId, line)
        return
      }
      if (col.field === 'debit') {
        line.credit = ''
        if (isNaN(line.debit)) {
          line.debit = ''
        }
      } else {
        line.debtor = ''
        if (isNaN(line.creditor)) {
          line.creditor = ''
        line.debit = ''
        if (isNaN(line.credit)) {
          line.credit = ''
        }
      }
      if (line.count_type === 'Y' && line.count) {
        if (line.debtor) {
          line.price = Math.round(line.debtor / line.count * 10000) / 10000
        } else if (line.creditor) {
          line.price = Math.round(line.creditor / line.count * 10000) / 10000
      if (line.count_type === 'Y' && line.fcc_count) {
        if (line.debit) {
          line.net_unitprice = Math.round(line.debit / line.fcc_count * 10000) / 10000
        } else if (line.credit) {
          line.net_unitprice = Math.round(line.credit / line.fcc_count * 10000) / 10000
        }
      }
      if (line.foreign_currency_type === 'Y' && line.origin) {
        if (line.debtor) {
          line.unitratio = Math.round(line.debtor / line.origin * 100000) / 100000
        } else if (line.creditor) {
          line.unitratio = Math.round(line.creditor / line.origin * 100000) / 100000
      if (line.foreign_currency_type === 'Y' && line.foreign_amount) {
        if (line.debit) {
          line.unitratio = Math.round(line.debit / line.foreign_amount * 100000) / 100000
        } else if (line.credit) {
          line.unitratio = Math.round(line.credit / line.foreign_amount * 100000) / 100000
        }
      }
@@ -274,10 +327,10 @@
    MKEmitter.emit('plusLine', col.tableId, record)
  }
  delRecord = () => {
  delVoucher = () => {
    const { col, record } = this.props
    MKEmitter.emit('delRecord', col.tableId, record)
    MKEmitter.emit('delVoucher', col.tableId, record)
  }
  onSelectBlur = () => {
@@ -293,9 +346,20 @@
    let line = {...record, ...option.props.extra}
    if (record.sup_accounting && !line.sup_accounting) {
      record.sup_accounting.split(',').forEach(item => {
        line[item] = ''
    line.supAccounts = []
    if (line.sup_accounting) {
      let msg = window.GLOB.CacheVoucher.get(col.tableId) || {}
      let names = msg.names || {}
      line.supAccounts = line.sup_accounting.split(',').map(item => {
        return {
          uuid: Utils.getguid(),
          sup_acc_type: item,
          field: item,
          label: names[item] || item,
          initval: ''
        }
      })
    }
@@ -316,7 +380,7 @@
        this.setState({visible: true})
      }, 100)
    } else if (line.count_type === 'Y') {
      this.setState({counting: true, value: line.count || 0}, () => {
      this.setState({counting: true, value: line.fcc_count || 0}, () => {
        let node = document.getElementById(col.uuid + record.uuid + 'count')
        node && node.select()
      })
@@ -328,7 +392,7 @@
    } else {
      this.setState({editing: false, visible: false, counting: false, priceing: false})
      setTimeout(() => {
        MKEmitter.emit('tdFocus', 'debtor' + record.uuid)
        MKEmitter.emit('tdFocus', 'debit' + record.uuid)
      }, 50)
    }
  }
@@ -341,13 +405,13 @@
    this.setState({editing: false, visible: false})
    if (res.count_type === 'Y') {
      this.setState({counting: true, value: res.count || 0}, () => {
      this.setState({counting: true, value: res.fcc_count || 0}, () => {
        let node = document.getElementById(col.uuid + res.uuid + 'count')
        node && node.select()
      })
    } else {
      setTimeout(() => {
        MKEmitter.emit('tdFocus', 'debtor' + res.uuid)
        MKEmitter.emit('tdFocus', 'debit' + res.uuid)
      }, 50)
    }
  }
@@ -359,13 +423,10 @@
    record.count_type = ''
    record.foreign_currency_type = ''
    record.mnemonic_code = ''
    record.subjectscode = ''
    record.subjectsname = ''
    record.sup_accounting.split(',').forEach(item => {
      record[item] = ''
    })
    record.subject_code = ''
    record.subject_name = ''
    record.sup_accounting = ''
    record.supAccounts = []
    MKEmitter.emit('changeRecord', col.tableId, record)
@@ -376,7 +437,7 @@
    const { col, record } = this.props
    e.stopPropagation()
    this.setState({counting: true, value: record.count || 0}, () => {
    this.setState({counting: true, value: record.fcc_count || 0}, () => {
      let node = document.getElementById(col.uuid + record.uuid + 'count')
      node && node.select()
    })
@@ -386,7 +447,7 @@
    const { col, record } = this.props
    e.stopPropagation()
    this.setState({priceing: true, value: record.price || 0}, () => {
    this.setState({priceing: true, value: record.net_unitprice || 0}, () => {
      let node = document.getElementById(col.uuid + record.uuid + 'price')
      node && node.select()
    })
@@ -397,17 +458,17 @@
    const { value } = this.state
    let line = {...record}
    line.count = value || 0
    line.fcc_count = value || 0
    if (isNaN(line.count)) {
      line.count = 0
    if (isNaN(line.fcc_count)) {
      line.fcc_count = 0
    }
    this.countChange(line)
    MKEmitter.emit('changeRecord', col.tableId, line)
    this.setState({counting: false, priceing: true, value: line.price || 0}, () => {
    this.setState({counting: false, priceing: true, value: line.net_unitprice || 0}, () => {
      let node = document.getElementById(col.uuid + record.uuid + 'price')
      node && node.select()
    })
@@ -420,10 +481,10 @@
    this.setState({counting: false})
    let line = {...record}
    line.count = value || 0
    line.fcc_count = value || 0
    if (isNaN(line.count)) {
      line.count = 0
    if (isNaN(line.fcc_count)) {
      line.fcc_count = 0
    }
    this.countChange(line)
@@ -436,10 +497,10 @@
    const { value } = this.state
    let line = {...record}
    line.price = value || 0
    line.net_unitprice = value || 0
    if (isNaN(line.price)) {
      line.price = 0
    if (isNaN(line.net_unitprice)) {
      line.net_unitprice = 0
    }
    this.countChange(line)
@@ -448,7 +509,7 @@
    this.setState({priceing: false})
    setTimeout(() => {
      MKEmitter.emit('tdFocus', 'debtor' + record.uuid)
      MKEmitter.emit('tdFocus', 'debit' + record.uuid)
    }, 50)
  }
@@ -459,10 +520,10 @@
    this.setState({priceing: false})
    let line = {...record}
    line.price = value || 0
    line.net_unitprice = value || 0
    if (isNaN(line.price)) {
      line.price = 0
    if (isNaN(line.net_unitprice)) {
      line.net_unitprice = 0
    }
    this.countChange(line)
@@ -490,7 +551,7 @@
    MKEmitter.emit('changeRecord', col.tableId, line)
    if (line.exratename === 'CNY') {
      this.setState({curring: false, origining: true, value: line.origin || 0}, () => {
      this.setState({curring: false, origining: true, value: line.foreign_amount || 0}, () => {
        let node = document.getElementById(col.uuid + record.uuid + 'origin')
        node && node.select()
      })
@@ -527,7 +588,7 @@
    MKEmitter.emit('changeRecord', col.tableId, line)
    this.setState({ratioing: false, origining: true, value: line.origin || 0}, () => {
    this.setState({ratioing: false, origining: true, value: line.foreign_amount || 0}, () => {
      let node = document.getElementById(col.uuid + record.uuid + 'origin')
        node && node.select()
    })
@@ -555,7 +616,7 @@
    const { col, record } = this.props
    e.stopPropagation()
    this.setState({origining: true, value: record.origin || 1}, () => {
    this.setState({origining: true, value: record.foreign_amount || 1}, () => {
      let node = document.getElementById(col.uuid + record.uuid + 'origin')
      node && node.select()
    })
@@ -566,10 +627,10 @@
    const { value } = this.state
    let line = {...record}
    line.origin = value || 0
    line.foreign_amount = value || 0
    if (isNaN(line.origin)) {
      line.origin = 0
    if (isNaN(line.foreign_amount)) {
      line.foreign_amount = 0
    }
    this.currencyChange(line)
@@ -579,7 +640,7 @@
    this.setState({origining: false})
    setTimeout(() => {
      MKEmitter.emit('tdFocus', 'debtor' + record.uuid)
      MKEmitter.emit('tdFocus', 'debit' + record.uuid)
    }, 50)
  }
@@ -590,10 +651,10 @@
    this.setState({origining: false})
    let line = {...record}
    line.origin = value || 0
    line.foreign_amount = value || 0
    if (isNaN(line.origin)) {
      line.origin = 0
    if (isNaN(line.foreign_amount)) {
      line.foreign_amount = 0
    }
    this.currencyChange(line)
@@ -602,36 +663,36 @@
  }
  countChange = (line) => {
    if (line.count && line.price) {
      if (line.creditor) {
        line.creditor = Math.round(line.count * line.price * 100) / 100
    if (line.fcc_count && line.net_unitprice) {
      if (line.credit) {
        line.credit = Math.round(line.fcc_count * line.net_unitprice * 100) / 100
      } else {
        line.debtor = Math.round(line.count * line.price * 100) / 100
        line.debit = Math.round(line.fcc_count * line.net_unitprice * 100) / 100
      }
      if (line.foreign_currency_type === 'Y' && line.origin) {
        if (line.debtor) {
          line.unitratio = Math.round(line.debtor / line.origin * 100000) / 100000
        } else if (line.creditor) {
          line.unitratio = Math.round(line.creditor / line.origin * 100000) / 100000
      if (line.foreign_currency_type === 'Y' && line.foreign_amount) {
        if (line.debit) {
          line.unitratio = Math.round(line.debit / line.foreign_amount * 100000) / 100000
        } else if (line.credit) {
          line.unitratio = Math.round(line.credit / line.foreign_amount * 100000) / 100000
        }
      }
    }
  }
  currencyChange = (line) => {
    if (line.unitratio && line.origin) {
      if (line.creditor) {
        line.creditor = Math.round(line.unitratio * line.origin * 100) / 100
    if (line.unitratio && line.foreign_amount) {
      if (line.credit) {
        line.credit = Math.round(line.unitratio * line.foreign_amount * 100) / 100
      } else {
        line.debtor = Math.round(line.unitratio * line.origin * 100) / 100
        line.debit = Math.round(line.unitratio * line.foreign_amount * 100) / 100
      }
      if (line.count_type === 'Y' && line.count) {
        if (line.debtor) {
          line.price = Math.round(line.debtor / line.count * 10000) / 10000
        } else if (line.creditor) {
          line.price = Math.round(line.creditor / line.count * 10000) / 10000
      if (line.count_type === 'Y' && line.fcc_count) {
        if (line.debit) {
          line.net_unitprice = Math.round(line.debit / line.fcc_count * 10000) / 10000
        } else if (line.credit) {
          line.net_unitprice = Math.round(line.credit / line.fcc_count * 10000) / 10000
        }
      }
    }
@@ -645,17 +706,21 @@
    let colSpan = 1
    let extra = null
    if (col.field === 'remark') {
      let val = record.remark || ''
    if (col.field === 'subject_voucher_text') {
      let val = record.subject_voucher_text || ''
      if (record.type === 'total') {
        children = <div className="content-wrap" style={{lineHeight: '60px'}}>合计: {val}</div>
        colSpan = 2
      } else {
      } else if (record.$disabled) {
        children = <div className="content-wrap">{val}</div>
      } else  {
        extra = <PlusOutlined onClick={this.plusLine}/>
        if (editing) {
          let options = ['现金', '发票']
          let options = localStorage.getItem(window.GLOB.sysSign + '_voucher_extract')
          options = options ? JSON.parse(options) : []
          children = <AutoComplete
            dataSource={options.map((cell, i) => <AutoComplete.Option value={cell} key={i}>
              {cell}
@@ -672,7 +737,7 @@
          children = <div className="content-wrap" onClick={this.focus}>{val}</div>
        }
      }
    } else if (col.field === 'subjectscode') {
    } else if (col.field === 'subject_code') {
      if (record.type === 'total') {
        colSpan = 0
      } else {
@@ -683,14 +748,14 @@
          children = <>
            <Select
              showSearch
              defaultValue={record.subjectscode || ''}
              defaultValue={record.subject_code || ''}
              dropdownClassName="edit-table-dropdown"
              id={col.uuid + record.uuid}
              onBlur={this.onSelectBlur}
              filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
              onSelect={this.onSelectChange}
            >
              {subjects.map((item, i) => (<Select.Option key={i} extra={item} value={item.subjectscode}>{item.subjectscode + ' ' + item.subjectsname}</Select.Option>))}
              {subjects.map((item, i) => (<Select.Option key={i} extra={item} value={item.subject_code}>{item.subject_code + ' ' + item.subject_name}</Select.Option>))}
            </Select>
            <Popover overlayClassName="subject-pop-wrap" placement="bottom" title="" visible={visible} content={<Accounting confirm={this.confirm} cancel={this.cancel} tableId={col.tableId} data={record}/>}>
              <span className="pop-anchor"></span>
@@ -698,14 +763,34 @@
          </>
        } else {
          let val = ''
          if (record.subjectscode) {
            val = (record.subjectscode || '') + ' ' + (record.subjectsname || '')
          if (record.subject_code) {
            val = (record.subject_code || '') + ' ' + (record.subject_name || '')
            record.sup_accounting && record.sup_accounting.split(',').forEach(item => {
              if (record[item]) {
                val += '_' + record[item]
              }
            })
            if (record.sup_accounting && record.supAccounts) {
              record.supAccounts.forEach(item => {
                if (item.sup_acc_type === 'supplier') {
                  val += item.suppliercode ? '_' + item.suppliercode + ' ' + item.suppliername : ''
                } else if (item.sup_acc_type === 'logistics') {
                  val += item.logistics_code ? '_' + item.logistics_code + ' ' + item.logistics_name : ''
                } else if (item.sup_acc_type === 'lessor') {
                  val += item.lessor_code ? '_' + item.lessor_code + ' ' + item.lessor_name : ''
                } else if (item.sup_acc_type === 'customer') {
                  val += item.customercode ? '_' + item.customercode + ' ' + item.customername : ''
                } else if (item.sup_acc_type === 'department') {
                  val += item.co_pro_code ? '_' + item.co_pro_code + ' ' + item.co_pro_name : ''
                } else if (item.sup_acc_type === 'project') {
                  val += item.projectcode ? '_' + item.projectcode + ' ' + item.projectname : ''
                } else if (item.sup_acc_type === 'inventory') {
                  val += item.productcode ? '_' + item.productcode + ' ' + item.productname : ''
                } else if (item.sup_acc_type === 'employee') {
                  val += item.workercode ? '_' + item.workercode + ' ' + item.workername : ''
                } else if (item.sup_acc_type === 'cash_flow') {
                  val += item.cash_flow_code ? '_' + item.cash_flow_code + ' ' + item.cash_flow_name : ''
                } else if (item.sup_acc_code) {
                  val += '_' + item.sup_acc_code + ' ' + item.sup_acc_name
                }
              })
            }
          }
          let countNode = null
@@ -716,33 +801,44 @@
              countNode = <div className="count-wrap">
                <span style={{marginRight: '5px'}} onClick={(e) => e.stopPropagation()}>
                  <span>数量:</span>
                  <span><InputNumber precision={4} className="inner-input" id={col.uuid + record.uuid + 'count'} defaultValue={record.count || 0} onChange={(val) => this.onChange(val)} onPressEnter={this.countPress} onBlur={this.countBlur}/></span>
                  <span><InputNumber precision={4} className="inner-input" id={col.uuid + record.uuid + 'count'} defaultValue={record.fcc_count || 0} onChange={(val) => this.onChange(val)} onPressEnter={this.countPress} onBlur={this.countBlur}/></span>
                </span>
                <span onClick={this.editPrice}>
                  <span>单价:</span>
                  <span>{record.price || 0}</span>
                  <span>{record.net_unitprice || 0}</span>
                </span>
              </div>
            } else if (priceing) {
              countNode = <div className="count-wrap">
                <span style={{marginRight: '5px'}} onClick={this.editCount}>
                  <span>数量:</span>
                  <span>{record.count || 0}</span>
                  <span>{record.fcc_count || 0}</span>
                </span>
                <span onClick={(e) => e.stopPropagation()}>
                  <span>单价:</span>
                  <span><InputNumber precision={4} className="inner-input" id={col.uuid + record.uuid + 'price'} defaultValue={record.price || 0} onChange={(val) => this.onChange(val)} onPressEnter={this.pricePress} onBlur={this.priceBlur}/></span>
                  <span><InputNumber precision={4} className="inner-input" id={col.uuid + record.uuid + 'price'} defaultValue={record.net_unitprice || 0} onChange={(val) => this.onChange(val)} onPressEnter={this.pricePress} onBlur={this.priceBlur}/></span>
                </span>
              </div>
            } else if (record.$disabled) {
              countNode = <div className="count-wrap">
                <span style={{marginRight: '5px'}}>
                  <span>数量:</span>
                  <span>{record.fcc_count || 0}</span>
                </span>
                <span>
                  <span>单价:</span>
                  <span>{record.net_unitprice || 0}</span>
                </span>
              </div>
            } else {
              countNode = <div className="count-wrap">
                <span style={{marginRight: '5px'}} onClick={this.editCount}>
                  <span>数量:</span>
                  <span>{record.count || 0}</span>
                  <span>{record.fcc_count || 0}</span>
                </span>
                <span onClick={this.editPrice}>
                  <span>单价:</span>
                  <span>{record.price || 0}</span>
                  <span>{record.net_unitprice || 0}</span>
                </span>
              </div>
            }
@@ -775,7 +871,7 @@
                </span>
                <span onClick={this.editOrigin}>
                  <span>原币:</span>
                  <span>{record.origin || 0}</span>
                  <span>{record.foreign_amount || 0}</span>
                </span>
              </div>
            } else if (ratioing) {
@@ -790,7 +886,7 @@
                </span>
                <span onClick={this.editOrigin}>
                  <span>原币:</span>
                  <span>{record.origin || 0}</span>
                  <span>{record.foreign_amount || 0}</span>
                </span>
              </div>
            } else if (origining) {
@@ -805,7 +901,22 @@
                </span>
                <span onClick={(e) => e.stopPropagation()}>
                  <span>原币:</span>
                  <span><InputNumber precision={2} className="inner-input" id={col.uuid + record.uuid + 'origin'} defaultValue={record.origin || 0} onChange={(val) => this.onChange(val)} onPressEnter={this.originPress} onBlur={this.originBlur}/></span>
                  <span><InputNumber precision={2} className="inner-input" id={col.uuid + record.uuid + 'origin'} defaultValue={record.foreign_amount || 0} onChange={(val) => this.onChange(val)} onPressEnter={this.originPress} onBlur={this.originBlur}/></span>
                </span>
              </div>
            } else if (record.$disabled) {
              currencyNode = <div className="count-wrap">
                <span style={{marginRight: '5px'}}>
                  <span>货币:</span>
                  <span>{record.exratename || ''}</span>
                </span>
                <span style={{marginRight: '5px'}}>
                  <span>汇率:</span>
                  <span>{record.unitratio || 1}</span>
                </span>
                <span>
                  <span>原币:</span>
                  <span>{record.foreign_amount || 0}</span>
                </span>
              </div>
            } else {
@@ -820,45 +931,63 @@
                </span>
                <span onClick={this.editOrigin}>
                  <span>原币:</span>
                  <span>{record.origin || 0}</span>
                  <span>{record.foreign_amount || 0}</span>
                </span>
              </div>
            }
          }
          children = <div className="content-wrap" onClick={this.focus}>
            {val}
            {countNode}
            {currencyNode}
          if (record.$disabled) {
            children = <div className="content-wrap">
              {val}
              {countNode}
              {currencyNode}
            </div>
          } else {
            children = <div className="content-wrap" onClick={this.focus}>
              {val}
              {countNode}
              {currencyNode}
            </div>
          }
        }
      }
    } else if (col.field === 'debit') {
      if (editing) {
        children = <InputNumber id={col.uuid + record.uuid} precision={2} defaultValue={record.debit} onChange={(val) => this.onChange(val)} onPressEnter={this.enterPress} onBlur={this.onBlur}/>
      } else {
        let val = record.debit
        let down = false
        let vals = []
        if (!isNaN(val) && val !== '') {
          if (val < 0) {
            down = true
            val = Math.abs(val)
          }
          vals = (val * 100).toFixed(0).split('').reverse()
        }
        if (record.$disabled) {
          children = <div className={'money-uint' + (down ? ' down' : '')}>
            <span>{vals[10] || ''}</span> <span>{vals[9] || ''}</span> <span>{vals[8] || ''}</span> <span>{vals[7] || ''}</span> <span>{vals[6] || ''}</span> <span>{vals[5] || ''}</span>
            <span>{vals[4] || ''}</span> <span>{vals[3] || ''}</span> <span>{vals[2] || ''}</span> <span>{vals[1] || ''}</span> <span className="last">{vals[0] || ''}</span>
          </div>
        } else {
          children = <div className={'money-uint' + (down ? ' down' : '')} onClick={this.focus}>
            <span>{vals[10] || ''}</span> <span>{vals[9] || ''}</span> <span>{vals[8] || ''}</span> <span>{vals[7] || ''}</span> <span>{vals[6] || ''}</span> <span>{vals[5] || ''}</span>
            <span>{vals[4] || ''}</span> <span>{vals[3] || ''}</span> <span>{vals[2] || ''}</span> <span>{vals[1] || ''}</span> <span className="last">{vals[0] || ''}</span>
          </div>
        }
      }
    } else if (col.field === 'debtor') {
      if (editing) {
        children = <InputNumber id={col.uuid + record.uuid} precision={2} defaultValue={record.debtor} onChange={(val) => this.onChange(val)} onPressEnter={this.enterPress} onBlur={this.onBlur}/>
      } else {
        let val = record.debtor
        let down = false
        let vals = []
        if (!isNaN(val) && val !== '') {
          if (val < 0) {
            down = true
            val = Math.abs(val)
          }
          vals = (val * 100).toFixed(0).split('').reverse()
        }
        children = <div className={'money-uint' + (down ? ' down' : '')} onClick={this.focus}>
          <span>{vals[10] || ''}</span> <span>{vals[9] || ''}</span> <span>{vals[8] || ''}</span> <span>{vals[7] || ''}</span> <span>{vals[6] || ''}</span> <span>{vals[5] || ''}</span>
          <span>{vals[4] || ''}</span> <span>{vals[3] || ''}</span> <span>{vals[2] || ''}</span> <span>{vals[1] || ''}</span> <span className="last">{vals[0] || ''}</span>
        </div>
    } else if (col.field === 'credit') {
      if (record.type !== 'total' && !record.$disabled) {
        extra = <CloseOutlined onClick={this.delVoucher}/>
      }
    } else if (col.field === 'creditor') {
      extra = <CloseOutlined onClick={this.delRecord}/>
      if (editing) {
        children = <InputNumber id={col.uuid + record.uuid} precision={2} defaultValue={record.creditor} onChange={(val) => this.onChange(val)} onPressEnter={this.enterPress} onBlur={this.onBlur}/>
        children = <InputNumber id={col.uuid + record.uuid} precision={2} defaultValue={record.credit} onChange={(val) => this.onChange(val)} onPressEnter={this.enterPress} onBlur={this.onBlur}/>
      } else {
        let val = record.creditor
        let val = record.credit
        let down = false
        let vals = []
        if (!isNaN(val) && val !== '') {
@@ -868,10 +997,18 @@
          }
          vals = (val * 100).toFixed(0).split('').reverse()
        }
        children = <div className={'money-uint' + (down ? ' down' : '')} onClick={this.focus}>
        <span>{vals[10] || ''}</span> <span>{vals[9] || ''}</span> <span>{vals[8] || ''}</span> <span>{vals[7] || ''}</span> <span>{vals[6] || ''}</span> <span>{vals[5] || ''}</span>
        <span>{vals[4] || ''}</span> <span>{vals[3] || ''}</span> <span>{vals[2] || ''}</span> <span>{vals[1] || ''}</span> <span className="last">{vals[0] || ''}</span>
      </div>
        if (record.$disabled) {
          children = <div className={'money-uint' + (down ? ' down' : '')}>
            <span>{vals[10] || ''}</span> <span>{vals[9] || ''}</span> <span>{vals[8] || ''}</span> <span>{vals[7] || ''}</span> <span>{vals[6] || ''}</span> <span>{vals[5] || ''}</span>
            <span>{vals[4] || ''}</span> <span>{vals[3] || ''}</span> <span>{vals[2] || ''}</span> <span>{vals[1] || ''}</span> <span className="last">{vals[0] || ''}</span>
          </div>
        } else {
          children = <div className={'money-uint' + (down ? ' down' : '')} onClick={this.focus}>
            <span>{vals[10] || ''}</span> <span>{vals[9] || ''}</span> <span>{vals[8] || ''}</span> <span>{vals[7] || ''}</span> <span>{vals[6] || ''}</span> <span>{vals[5] || ''}</span>
            <span>{vals[4] || ''}</span> <span>{vals[3] || ''}</span> <span>{vals[2] || ''}</span> <span>{vals[1] || ''}</span> <span className="last">{vals[0] || ''}</span>
          </div>
        }
      }
    }
@@ -883,17 +1020,17 @@
class VoucherTable extends Component {
  static propTpyes = {
    config: PropTypes.object,        // 菜单Id
    data: PropTypes.any,             // 表格数据
    loading: PropTypes.bool,         // 表格加载中
    onChange: PropTypes.func,        // 表格变动
    config: PropTypes.object,
    data: PropTypes.any,
    loading: PropTypes.bool,
    onChange: PropTypes.func
  }
  state = {
    data: [],
    edData: [],
    tableId: '',          // 表格ID
    columns: null,        // 显示列
    tableId: '',
    columns: null,
  }
  UNSAFE_componentWillMount () {
@@ -902,22 +1039,22 @@
    let columns = [
      {
        title: '摘要',
        dataIndex: 'remark',
        key: 'remark',
        dataIndex: 'subject_voucher_text',
        key: 'subject_voucher_text',
        width: '22%',
        onCell: record => ({
          record,
          col: {uuid: 'remark', field: 'remark', tableId: config.uuid},
          col: {uuid: 'subject_voucher_text', field: 'subject_voucher_text', tableId: config.uuid},
        })
      },
      {
        title: '会计科目',
        dataIndex: 'subjectscode',
        key: 'subjectscode',
        dataIndex: 'subject_code',
        key: 'subject_code',
        width: '34%',
        onCell: record => ({
          record,
          col: {uuid: 'subjectscode', field: 'subjectscode', tableId: config.uuid},
          col: {uuid: 'subject_code', field: 'subject_code', tableId: config.uuid},
        })
      },
      {
@@ -928,12 +1065,12 @@
            <span>百</span> <span>十</span> <span>元</span> <span>角</span> <span className="last">分</span>
          </div>
        </>),
        dataIndex: 'debtor',
        key: 'debtor',
        dataIndex: 'debit',
        key: 'debit',
        width: '22%',
        onCell: record => ({
          record,
          col: {uuid: 'debtor', field: 'debtor', tableId: config.uuid},
          col: {uuid: 'debit', field: 'debit', tableId: config.uuid},
        })
      },
      {
@@ -944,12 +1081,12 @@
            <span>百</span> <span>十</span> <span>元</span> <span>角</span> <span className="last">分</span>
          </div>
        </>),
        dataIndex: 'creditor',
        key: 'creditor',
        dataIndex: 'credit',
        key: 'credit',
        width: '22%',
        onCell: record => ({
          record,
          col: {uuid: 'creditor', field: 'creditor', tableId: config.uuid},
          col: {uuid: 'credit', field: 'credit', tableId: config.uuid},
        })
      }
    ]
@@ -966,10 +1103,10 @@
  }
  componentDidMount () {
    MKEmitter.addListener('nextLine', this.nextLine)
    MKEmitter.addListener('plusLine', this.plusLine)
    MKEmitter.addListener('delRecord', this.delRecord)
    MKEmitter.addListener('delVoucher', this.delVoucher)
    MKEmitter.addListener('cleartable', this.cleartable)
    MKEmitter.addListener('nextVoucher', this.nextVoucher)
    MKEmitter.addListener('changeRecord', this.changeRecord)
  }
@@ -980,10 +1117,10 @@
    this.setState = () => {
      return
    }
    MKEmitter.removeListener('nextLine', this.nextLine)
    MKEmitter.removeListener('plusLine', this.plusLine)
    MKEmitter.removeListener('delRecord', this.delRecord)
    MKEmitter.removeListener('delVoucher', this.delVoucher)
    MKEmitter.removeListener('cleartable', this.cleartable)
    MKEmitter.removeListener('nextVoucher', this.nextVoucher)
    MKEmitter.removeListener('changeRecord', this.changeRecord)
  }
@@ -1018,14 +1155,15 @@
    let _data = data.map((item, i) => {
      // item.uuid = Utils.getguid()
      item.index = i
      item.$origin = true
      
      return item
    })
    let disabled = _data[0] && _data[0].$disabled ? true : false
    if (_data.length < 4) {
      for (let i = _data.length - 1; i < 4; i++) {
        _data.push({uuid: Utils.getguid(), index: i + 1, remark: '', subjectscode: '', subjectsname: '', debtor: '', creditor: ''})
        _data.push({uuid: Utils.getguid(), $disabled: disabled, index: i + 1, subject_voucher_text: '', subject_code: '', subject_name: '', debit: '', credit: ''})
      }
    }
    return _data
@@ -1033,31 +1171,44 @@
  getTotalLine = (data) => {
    let totalLine = {uuid: Utils.getguid(), type: 'total'}
    let debtor = ''
    let creditor = ''
    let debit = ''
    let credit = ''
    data.forEach(item => {
      if (!isNaN(item.debtor) && item.debtor !== '') {
        if (debtor === '') {
          debtor = 0
      if (!isNaN(item.debit) && item.debit !== '') {
        if (debit === '') {
          debit = 0
        }
        debtor += item.debtor
      } else if (!isNaN(item.creditor) && item.creditor !== '') {
        if (debtor === '') {
          debtor = 0
        debit += item.debit
      } else if (!isNaN(item.credit) && item.credit !== '') {
        if (debit === '') {
          debit = 0
        }
        if (creditor === '') {
          creditor = 0
        if (credit === '') {
          credit = 0
        }
        creditor += item.creditor
        credit += item.credit
      }
    })
    totalLine.debtor = debtor
    totalLine.creditor = creditor
    let _total = debit
    if (debit === 0) {
      debit = ''
    }
    totalLine.remark = this.changeMoneyToChinese(debtor)
    if (_total === '' && credit !== '') {
      _total = 0
    }
    if (credit === 0) {
      credit = ''
    }
    totalLine.debit = debit
    totalLine.credit = credit
    totalLine.subject_voucher_text = this.changeMoneyToChinese(_total)
    
    return totalLine
  }
@@ -1145,21 +1296,21 @@
    return ChineseStr
  }
  nextLine = (col, record) => {
  nextVoucher = (col, record) => {
    const { edData, tableId } = this.state
    if (col.tableId !== tableId) return
    if (record.index < edData.length - 2) {
      MKEmitter.emit('tdFocus', 'remark' + edData[record.index + 1].uuid)
      MKEmitter.emit('tdFocus', 'subject_voucher_text' + edData[record.index + 1].uuid)
    } else {
      let _data = fromJS(edData).toJS()
      let line = {uuid: Utils.getguid(), index: _data.length - 1, remark: record.remark || '', subjectscode: '', subjectsname: '', debtor: '', creditor: ''}
      let line = {uuid: Utils.getguid(), index: _data.length - 1, subject_voucher_text: record.subject_voucher_text || '', subject_code: '', subject_name: '', debit: '', credit: ''}
      _data.splice(_data.length - 1, 0, line)
      this.setState({edData: _data}, () => {
        MKEmitter.emit('tdFocus', 'remark' + line.uuid)
        MKEmitter.emit('tdFocus', 'subject_voucher_text' + line.uuid)
      })
      this.props.onChange(_data)
    }
@@ -1171,7 +1322,7 @@
    if (tid !== tableId) return
    let _data = fromJS(edData).toJS()
    let line = {uuid: Utils.getguid(), index: 0, remark: '', subjectscode: '', subjectsname: '', debtor: '', creditor: ''}
    let line = {uuid: Utils.getguid(), index: 0, subject_voucher_text: '', subject_code: '', subject_name: '', debit: '', credit: ''}
    _data.splice(record.index, 0, line)
    _data = _data.map((item, index) => {
@@ -1183,7 +1334,7 @@
    this.props.onChange(_data)
  }
  delRecord = (id, record) => {
  delVoucher = (id, record) => {
    const { tableId, edData } = this.state
    if (id !== tableId) return
@@ -1194,7 +1345,7 @@
    if (_data.length < 4) {
      for (let i = _data.length; i < 4; i++) {
        _data.push({uuid: Utils.getguid(), index: 0, remark: '', subjectscode: '', subjectsname: '', debtor: '', creditor: ''})
        _data.push({uuid: Utils.getguid(), index: 0, subject_voucher_text: '', subject_code: '', subject_name: '', debit: '', credit: ''})
      }
    }
@@ -1206,7 +1357,7 @@
    _data.push(this.getTotalLine(_data))
    this.setState({edData: _data})
    this.props.onChange(_data, record.$origin ? record : null)
    this.props.onChange(_data)
  }
  changeRecord = (tableId, record) => {
@@ -1223,7 +1374,7 @@
    _data.pop()
    if (record.index === _data.length - 1) {
      _data.push({uuid: Utils.getguid(), index: record.index + 1, remark: '', subjectscode: '', subjectsname: '', debtor: '', creditor: ''})
      _data.push({uuid: Utils.getguid(), index: record.index + 1, subject_voucher_text: '', subject_code: '', subject_name: '', debit: '', credit: ''})
    }
    _data.push(this.getTotalLine(_data))