From ba6844240cda904db061ee0b3689aeaf0f50ff5e Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 13 五月 2025 11:19:05 +0800
Subject: [PATCH] Merge branch 'develop'

---
 src/tabviews/custom/components/module/voucher/voucherTable/index.jsx | 1304 +++++++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 952 insertions(+), 352 deletions(-)

diff --git a/src/tabviews/custom/components/module/voucher/voucherTable/index.jsx b/src/tabviews/custom/components/module/voucher/voucherTable/index.jsx
index b79fdd7..0c5af4a 100644
--- a/src/tabviews/custom/components/module/voucher/voucherTable/index.jsx
+++ b/src/tabviews/custom/components/module/voucher/voucherTable/index.jsx
@@ -1,13 +1,11 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { is, fromJS } from 'immutable'
-import { Table, Modal, Input, InputNumber, notification, message, AutoComplete, Select } from 'antd'
+import { Table, Form, Input, InputNumber, notification, AutoComplete, Select, Popover, Button } from 'antd'
+import { PlusOutlined, CloseOutlined } from '@ant-design/icons'
 
-import Api from '@/api'
 import Utils from '@/utils/utils.js'
 import MKEmitter from '@/utils/events.js'
-import zhCN from '@/locales/zh-CN/main.js'
-import enUS from '@/locales/en-US/main.js'
 import './index.scss'
 
 class BodyRow extends React.Component {
@@ -24,14 +22,146 @@
   }
 }
 
+class Accounting extends React.Component {
+  state = {
+    subAccounts: []
+  }
+
+  UNSAFE_componentWillMount() {
+    const { data, tableId } = this.props
+    let subAccounts = fromJS(data.supAccounts).toJS()
+    let msg = window.GLOB.CacheVoucher.get(tableId) || {}
+
+    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})
+  }
+
+  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() {
+    const { subAccounts } = this.state
+
+    const fields = []
+
+    subAccounts.forEach((item) => {
+      fields.push(
+        <Form.Item label={item.label} key={item.field}>
+          <Select
+            showSearch
+            allowClear
+            defaultValue={item.initval}
+            dropdownMatchSelectWidth={false}
+            filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
+            onChange={(val, option) => this.selectChange(option, item.field)}
+          >
+            {item.options.map((option, i) =>
+              <Select.Option key={i} name={option.label} value={option.value}>{option.label}</Select.Option>
+            )}
+          </Select>
+        </Form.Item>
+      )
+    })
+    
+    return fields
+  }
+
+  confirm = () => {
+    const { data } = this.props
+    const { subAccounts } = this.state
+
+    let empty = ''
+    subAccounts.forEach(item => {
+      if (!empty && !item.value) {
+        empty = item.label
+      }
+    })
+
+    if (empty) {
+      notification.warning({
+        top: 92,
+        message: '璇烽�夋嫨' + empty,
+        duration: 5
+      })
+    } else {
+      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)
+    }
+  }
+
+  render() {
+    return <div>
+      {this.getFields()}
+      <div className="footer">
+        <Button onClick={this.props.cancel}>鍙栨秷</Button>
+        <Button onClick={this.confirm}>纭畾</Button>
+      </div>
+    </div>
+  }
+}
+
 class BodyCell extends React.Component {
   state = {
     editing: false,
-  }
-
-  shouldComponentUpdate (nextProps, nextState) {
-    return !is(fromJS(this.props.record), fromJS(nextProps.record)) ||
-      nextState.editing !== this.state.editing
+    visible: false,
+    counting: false,
+    priceing: false,
+    curring: false,
+    ratioing: false,
+    origining: false,
   }
 
   componentDidMount () {
@@ -62,23 +192,56 @@
 
     this.setState({editing: false})
 
-    if (value !== record[col.field]) {
-      let line = {...record, [col.field]: value}
+    let line = {...record}
+    line[col.field] = value
 
-      if (col.field === 'debtor') {
-        line.creditor = ''
-      } else {
-        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.debit = ''
+      if (isNaN(line.credit)) {
+        line.credit = ''
+      }
+    }
+
+    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.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 === '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)
@@ -89,12 +252,10 @@
 
     if (record.type === 'total') return
 
-    if (col.field === 'subjectscode') {
+    if (col.field === 'subject_code') {
       this.setState({editing: true}, () => {
-        try {
-          let node = document.getElementById(col.uuid + record.uuid)
-          node.click()
-        } catch(e) {}
+        let node = document.getElementById(col.uuid + record.uuid)
+        node && node.click()
       })
     } else {
       this.setState({editing: true, value: record[col.field]}, () => {
@@ -110,15 +271,40 @@
 
     this.setState({editing: false})
 
-    if (col.field === 'subjectscode') return
-
     if (value !== record[col.field]) {
       let line = {...record, [col.field]: value}
 
-      if (col.field === 'debtor') {
-        line.creditor = ''
+      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 = ''
+        line.debit = ''
+        if (isNaN(line.credit)) {
+          line.credit = ''
+        }
+      }
+
+      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.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)
@@ -135,36 +321,406 @@
     })
   }
 
+  plusLine = () => {
+    const { col, record } = this.props
+
+    MKEmitter.emit('plusLine', col.tableId, record)
+  }
+
+  delVoucher = () => {
+    const { col, record } = this.props
+
+    MKEmitter.emit('delVoucher', col.tableId, record)
+  }
+
+  onSelectBlur = () => {
+    const { visible } = this.state
+
+    if (visible) return
+
+    this.setState({editing: false})
+  }
+
   onSelectChange = (val, option) => {
     const { col, record } = this.props
 
-    this.setState({editing: false})
-
     let line = {...record, ...option.props.extra}
+
+    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: ''
+        }
+      })
+    }
+
+    if (line.foreign_currency_type === 'Y' && line.foreign_currency) {
+      let msg = window.GLOB.CacheVoucher.get(col.tableId)
+      let cur = msg ? msg.currency.filter(n => n.exratename === line.foreign_currency)[0] : null
+      if (cur) {
+        line = {...line, ...cur}
+      }
+
+      this.currencyChange(line)
+    }
 
     MKEmitter.emit('changeRecord', col.tableId, line)
 
+    if (line.sup_accounting) {
+      setTimeout(() => {
+        this.setState({visible: true})
+      }, 100)
+    } else if (line.count_type === 'Y') {
+      this.setState({counting: true, value: line.fcc_count || 0}, () => {
+        let node = document.getElementById(col.uuid + record.uuid + 'count')
+        node && node.select()
+      })
+    } else if (line.foreign_currency_type === 'Y') {
+      this.setState({curring: true}, () => {
+        let node = document.getElementById(col.uuid + record.uuid + 'currency')
+        node && node.click()
+      })
+    } else {
+      this.setState({editing: false, visible: false, counting: false, priceing: false})
+      setTimeout(() => {
+        MKEmitter.emit('tdFocus', 'debit' + record.uuid)
+      }, 50)
+    }
+  }
+
+  confirm = (res) => {
+    const { col } = this.props
+
+    MKEmitter.emit('changeRecord', col.tableId, fromJS(res).toJS())
+
+    this.setState({editing: false, visible: false})
+
+    if (res.count_type === 'Y') {
+      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', 'debit' + res.uuid)
+      }, 50)
+    }
+  }
+
+  cancel = () => {
+    const { col } = this.props
+    let record = fromJS(this.props.record).toJS()
+    record.balance_direction = ''
+    record.count_type = ''
+    record.foreign_currency_type = ''
+    record.mnemonic_code = ''
+    record.subject_code = ''
+    record.subject_name = ''
+    record.sup_accounting = ''
+    record.supAccounts = []
+
+    MKEmitter.emit('changeRecord', col.tableId, record)
+
+    this.setState({editing: false, visible: false})
+  }
+
+  editCount = (e) => {
+    const { col, record } = this.props
+    e.stopPropagation()
+
+    this.setState({counting: true, value: record.fcc_count || 0}, () => {
+      let node = document.getElementById(col.uuid + record.uuid + 'count')
+      node && node.select()
+    })
+  }
+
+  editPrice = (e) => {
+    const { col, record } = this.props
+    e.stopPropagation()
+
+    this.setState({priceing: true, value: record.net_unitprice || 0}, () => {
+      let node = document.getElementById(col.uuid + record.uuid + 'price')
+      node && node.select()
+    })
+  }
+
+  countPress = () => {
+    const { col, record } = this.props
+    const { value } = this.state
+
+    let line = {...record}
+    line.fcc_count = value || 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.net_unitprice || 0}, () => {
+      let node = document.getElementById(col.uuid + record.uuid + 'price')
+      node && node.select()
+    })
+  }
+
+  countBlur = () => {
+    const { col, record } = this.props
+    const { value } = this.state
+
+    this.setState({counting: false})
+
+    let line = {...record}
+    line.fcc_count = value || 0
+
+    if (isNaN(line.fcc_count)) {
+      line.fcc_count = 0
+    }
+
+    this.countChange(line)
+    
+    MKEmitter.emit('changeRecord', col.tableId, line)
+  }
+
+  pricePress = () => {
+    const { col, record } = this.props
+    const { value } = this.state
+
+    let line = {...record}
+    line.net_unitprice = value || 0
+
+    if (isNaN(line.net_unitprice)) {
+      line.net_unitprice = 0
+    }
+
+    this.countChange(line)
+
+    MKEmitter.emit('changeRecord', col.tableId, line)
+
+    this.setState({priceing: false})
     setTimeout(() => {
-      MKEmitter.emit('tdFocus', 'debtor' + record.uuid)
+      MKEmitter.emit('tdFocus', 'debit' + record.uuid)
     }, 50)
   }
 
+  priceBlur = () => {
+    const { col, record } = this.props
+    const { value } = this.state
+
+    this.setState({priceing: false})
+
+    let line = {...record}
+    line.net_unitprice = value || 0
+
+    if (isNaN(line.net_unitprice)) {
+      line.net_unitprice = 0
+    }
+
+    this.countChange(line)
+    
+    MKEmitter.emit('changeRecord', col.tableId, line)
+  }
+
+  editCurrency = (e) => {
+    const { col, record } = this.props
+    e.stopPropagation()
+
+    this.setState({curring: true}, () => {
+      let node = document.getElementById(col.uuid + record.uuid + 'currency')
+      node && node.click()
+    })
+  }
+
+  onCurrSelectChange = (val, option) => {
+    const { col, record } = this.props
+
+    let line = {...record, ...option.props.extra}
+
+    this.currencyChange(line)
+
+    MKEmitter.emit('changeRecord', col.tableId, line)
+
+    if (line.exratename === 'CNY') {
+      this.setState({curring: false, origining: true, value: line.foreign_amount || 0}, () => {
+        let node = document.getElementById(col.uuid + record.uuid + 'origin')
+        node && node.select()
+      })
+    } else {
+      this.setState({curring: false, ratioing: true, value: line.unitratio || 1}, () => {
+        let node = document.getElementById(col.uuid + record.uuid + 'ratio')
+        node && node.select()
+      })
+    }
+  }
+
+  editRatio = (e) => {
+    const { col, record } = this.props
+    e.stopPropagation()
+
+    this.setState({ratioing: true, value: record.unitratio || 1}, () => {
+      let node = document.getElementById(col.uuid + record.uuid + 'ratio')
+      node && node.select()
+    })
+  }
+
+  ratioPress = () => {
+    const { col, record } = this.props
+    const { value } = this.state
+
+    let line = {...record}
+    line.unitratio = value || 1
+
+    if (isNaN(line.unitratio)) {
+      line.unitratio = 1
+    }
+
+    this.currencyChange(line)
+
+    MKEmitter.emit('changeRecord', col.tableId, line)
+
+    this.setState({ratioing: false, origining: true, value: line.foreign_amount || 0}, () => {
+      let node = document.getElementById(col.uuid + record.uuid + 'origin')
+        node && node.select()
+    })
+  }
+
+  ratioBlur = () => {
+    const { col, record } = this.props
+    const { value } = this.state
+
+    this.setState({ratioing: false})
+
+    let line = {...record}
+    line.unitratio = value || 1
+
+    if (isNaN(line.unitratio)) {
+      line.unitratio = 1
+    }
+
+    this.currencyChange(line)
+    
+    MKEmitter.emit('changeRecord', col.tableId, line)
+  }
+
+  editOrigin = (e) => {
+    const { col, record } = this.props
+    e.stopPropagation()
+
+    this.setState({origining: true, value: record.foreign_amount || 1}, () => {
+      let node = document.getElementById(col.uuid + record.uuid + 'origin')
+      node && node.select()
+    })
+  }
+
+  originPress = () => {
+    const { col, record } = this.props
+    const { value } = this.state
+
+    let line = {...record}
+    line.foreign_amount = value || 0
+
+    if (isNaN(line.foreign_amount)) {
+      line.foreign_amount = 0
+    }
+
+    this.currencyChange(line)
+
+    MKEmitter.emit('changeRecord', col.tableId, line)
+
+    this.setState({origining: false})
+
+    setTimeout(() => {
+      MKEmitter.emit('tdFocus', 'debit' + record.uuid)
+    }, 50)
+  }
+
+  originBlur = () => {
+    const { col, record } = this.props
+    const { value } = this.state
+
+    this.setState({origining: false})
+
+    let line = {...record}
+    line.foreign_amount = value || 0
+
+    if (isNaN(line.foreign_amount)) {
+      line.foreign_amount = 0
+    }
+
+    this.currencyChange(line)
+    
+    MKEmitter.emit('changeRecord', col.tableId, line)
+  }
+
+  countChange = (line) => {
+    if (line.fcc_count && line.net_unitprice) {
+      if (line.credit) {
+        line.credit = Math.round(line.fcc_count * line.net_unitprice * 100) / 100
+      } else {
+        line.debit = Math.round(line.fcc_count * line.net_unitprice * 100) / 100
+      }
+
+      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.foreign_amount) {
+      if (line.credit) {
+        line.credit = Math.round(line.unitratio * line.foreign_amount * 100) / 100
+      } else {
+        line.debit = Math.round(line.unitratio * line.foreign_amount * 100) / 100
+      }
+
+      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
+        }
+      }
+    }
+  }
+
   render() {
-    let { col, record, subjects, className } = this.props
-    const { editing } = this.state
+    let { col, record, className } = this.props
+    const { editing, visible, counting, priceing, curring, ratioing, origining } = this.state
 
     let children = null
     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}
@@ -181,123 +737,324 @@
           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 {
         if (editing) {
-          children = <Select
-            showSearch
-            defaultValue={record.subjectscode || ''}
-            dropdownClassName="edit-table-dropdown"
-            id={col.uuid + record.uuid}
-            onBlur={this.onBlur}
-            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>))}
-          </Select>
+          let msg = window.GLOB.CacheVoucher.get(col.tableId)
+          let subjects = msg ? msg.subjects : []
+
+          children = <>
+            <Select
+              showSearch
+              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.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>
+            </Popover>
+          </>
         } else {
           let val = ''
-          if (record.subjectscode) {
-            val = (record.subjectscode || '') + ' ' + (record.subjectsname || '')
+          if (record.subject_code) {
+            val = (record.subject_code || '') + ' ' + (record.subject_name || '')
+
+            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
+                }
+              })
+            }
           }
-          children = <div className="content-wrap" onClick={this.focus}>{val}</div>
+
+          let countNode = null
+          let currencyNode = null
+
+          if (record.count_type === 'Y') {
+            if (counting) {
+              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.fcc_count || 0} onChange={(val) => this.onChange(val)} onPressEnter={this.countPress} onBlur={this.countBlur}/></span>
+                </span>
+                <span onClick={this.editPrice}>
+                  <span>鍗曚环锛�</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.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.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.fcc_count || 0}</span>
+                </span>
+                <span onClick={this.editPrice}>
+                  <span>鍗曚环锛�</span>
+                  <span>{record.net_unitprice || 0}</span>
+                </span>
+              </div>
+            }
+          }
+
+          if (record.foreign_currency_type === 'Y') {
+            if (curring) {
+              let msg = window.GLOB.CacheVoucher.get(col.tableId)
+              let currency = msg ? msg.currency : []
+
+              currencyNode = <div className="count-wrap">
+                <span style={{marginRight: '5px'}} onClick={(e) => e.stopPropagation()}>
+                  <span>璐у竵锛�</span>
+                  <span>
+                    <Select
+                      className="currency-select"
+                      defaultValue={record.exratename || ''}
+                      dropdownClassName="edit-table-dropdown"
+                      id={col.uuid + record.uuid + 'currency'}
+                      onBlur={() => this.setState({curring: false})}
+                      onSelect={this.onCurrSelectChange}
+                    >
+                      {currency.map((item, i) => (<Select.Option key={i} extra={item} value={item.exratename}>{item.exratename}</Select.Option>))}
+                    </Select>
+                  </span>
+                </span>
+                <span style={{marginRight: '5px'}} onClick={this.editRatio}>
+                  <span>姹囩巼锛�</span>
+                  <span>{record.unitratio || 1}</span>
+                </span>
+                <span onClick={this.editOrigin}>
+                  <span>鍘熷竵锛�</span>
+                  <span>{record.foreign_amount || 0}</span>
+                </span>
+              </div>
+            } else if (ratioing) {
+              currencyNode = <div className="count-wrap">
+                <span style={{marginRight: '5px'}} onClick={this.editCurrency}>
+                  <span>璐у竵锛�</span>
+                  <span>{record.exratename || ''}</span>
+                </span>
+                <span style={{marginRight: '5px'}} onClick={(e) => e.stopPropagation()}>
+                  <span>姹囩巼锛�</span>
+                  <span><InputNumber precision={5} className="inner-input" id={col.uuid + record.uuid + 'ratio'} defaultValue={record.unitratio || 1} onChange={(val) => this.onChange(val)} onPressEnter={this.ratioPress} onBlur={this.ratioBlur}/></span>
+                </span>
+                <span onClick={this.editOrigin}>
+                  <span>鍘熷竵锛�</span>
+                  <span>{record.foreign_amount || 0}</span>
+                </span>
+              </div>
+            } else if (origining) {
+              currencyNode = <div className="count-wrap">
+                <span style={{marginRight: '5px'}} onClick={this.editCurrency}>
+                  <span>璐у竵锛�</span>
+                  <span>{record.exratename || ''}</span>
+                </span>
+                <span style={{marginRight: '5px'}} onClick={this.editRatio}>
+                  <span>姹囩巼锛�</span>
+                  <span>{record.unitratio || 1}</span>
+                </span>
+                <span onClick={(e) => e.stopPropagation()}>
+                  <span>鍘熷竵锛�</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 {
+              currencyNode = <div className="count-wrap">
+                <span style={{marginRight: '5px'}} onClick={this.editCurrency}>
+                  <span>璐у竵锛�</span>
+                  <span>{record.exratename || ''}</span>
+                </span>
+                <span style={{marginRight: '5px'}} onClick={this.editRatio}>
+                  <span>姹囩巼锛�</span>
+                  <span>{record.unitratio || 1}</span>
+                </span>
+                <span onClick={this.editOrigin}>
+                  <span>鍘熷竵锛�</span>
+                  <span>{record.foreign_amount || 0}</span>
+                </span>
+              </div>
+            }
+          }
+
+          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 === 'debtor') {
-      let val = record.debtor
-      let down = false
-      let vals = []
-      if (typeof(val) === 'number') {
-        if (val < 0) {
-          down = true
-          val = Math.abs(val)
+    } 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()
         }
-        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 === 'credit') {
+      if (record.type !== 'total' && !record.$disabled) {
+        extra = <CloseOutlined onClick={this.delVoucher}/>
       }
 
       if (editing) {
-        children = <InputNumber id={col.uuid + record.uuid} defaultValue={val} 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 {
-        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 === 'creditor') {
-      let val = record.creditor
-      let down = false
-      let vals = []
-      if (typeof(val) === 'number') {
-        if (val < 0) {
-          down = true
-          val = Math.abs(val)
+        let val = record.credit
+        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()
         }
-        vals = (val * 100).toFixed(0).split('').reverse()
-      }
 
-      if (editing) {
-        children = <InputNumber id={col.uuid + record.uuid} defaultValue={val} onChange={(val) => this.onChange(val)} onPressEnter={this.enterPress} onBlur={this.onBlur}/>
-      } 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>
+        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>
+        }
       }
     }
 
     if (!colSpan) return null
 
-    return (<td colSpan={colSpan} className={className}>{children}</td>)
+    return (<td colSpan={colSpan} className={className}>{children}{extra}</td>)
   }
 }
 
 class VoucherTable extends Component {
   static propTpyes = {
-    config: PropTypes.object,        // 鑿滃崟Id
-    subjects: PropTypes.array,       // 浼氳绉戠洰
-    BID: PropTypes.any,              // 涓昏〃ID
-    data: PropTypes.any,             // 琛ㄦ牸鏁版嵁
-    total: PropTypes.any,            // 鎬绘暟
-    loading: PropTypes.bool,         // 琛ㄦ牸鍔犺浇涓�
-    refreshdata: PropTypes.func,     // 琛ㄦ牸涓帓搴忓垪銆侀〉鐮佺殑鍙樺寲鏃跺埛鏂�
+    config: PropTypes.object,
+    data: PropTypes.any,
+    loading: PropTypes.bool,
+    onChange: PropTypes.func
   }
 
   state = {
-    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
     data: [],
     edData: [],
-    edColumns: [],
-    tableId: '',          // 琛ㄦ牸ID
-    pageSize: 10,         // 姣忛〉鏁版嵁鏉℃暟
-    columns: null,        // 鏄剧ず鍒�
-    loading: false,
+    tableId: '',
+    columns: null,
   }
 
   UNSAFE_componentWillMount () {
-    const { config, subjects, data } = this.props
+    const { config, data } = this.props
 
     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,
-          subjects,
-          col: {uuid: 'subjectscode', field: 'subjectscode', tableId: config.uuid},
+          col: {uuid: 'subject_code', field: 'subject_code', tableId: config.uuid},
         })
       },
       {
@@ -308,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},
         })
       },
       {
@@ -324,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},
         })
       }
     ]
@@ -346,8 +1103,10 @@
   }
 
   componentDidMount () {
-    MKEmitter.addListener('nextLine', this.nextLine)
-    MKEmitter.addListener('delRecord', this.delRecord)
+    MKEmitter.addListener('plusLine', this.plusLine)
+    MKEmitter.addListener('delVoucher', this.delVoucher)
+    MKEmitter.addListener('cleartable', this.cleartable)
+    MKEmitter.addListener('nextVoucher', this.nextVoucher)
     MKEmitter.addListener('changeRecord', this.changeRecord)
   }
 
@@ -358,41 +1117,25 @@
     this.setState = () => {
       return
     }
-    MKEmitter.removeListener('nextLine', this.nextLine)
-    MKEmitter.removeListener('delRecord', this.delRecord)
+    MKEmitter.removeListener('plusLine', this.plusLine)
+    MKEmitter.removeListener('delVoucher', this.delVoucher)
+    MKEmitter.removeListener('cleartable', this.cleartable)
+    MKEmitter.removeListener('nextVoucher', this.nextVoucher)
     MKEmitter.removeListener('changeRecord', this.changeRecord)
   }
 
   UNSAFE_componentWillReceiveProps(nextProps) {
     if (!is(fromJS(this.props.data), fromJS(nextProps.data))) {
       this.resetData(fromJS(nextProps.data).toJS())
-    } else if (!is(fromJS(this.props.subjects), fromJS(nextProps.subjects))) {
-      this.resetSubjects(nextProps.subjects)
     }
   }
 
-  resetSubjects = (subjects) => {
-    const { config } = this.props
-    let columns = fromJS(this.state.columns).toJS()
+  cleartable = (tbid) => {
+    const { tableId } = this.state
 
-    this.setState({
-      columns: columns.map(col => {
-        if (col.key === 'subjectscode') {
-          return {
-            title: '浼氳绉戠洰',
-            dataIndex: 'subjectscode',
-            key: 'subjectscode',
-            width: '34%',
-            onCell: record => ({
-              record,
-              subjects,
-              col: {uuid: 'subjectscode', field: 'subjectscode', tableId: config.uuid},
-            })
-          }
-        }
-        return col
-      })
-    })
+    if (tbid !== tableId) return
+
+    this.resetData([])
   }
 
   resetData = (data) => {
@@ -400,53 +1143,72 @@
     data.push(this.getTotalLine(data))
 
     this.setState({
-      edData: data
+      edData: []
+    }, () => {
+      this.setState({
+        edData: data
+      })
     })
   }
 
   initData = (data) => {
     let _data = data.map((item, i) => {
-      item.uuid = Utils.getuuid()
+      // item.uuid = Utils.getguid()
       item.index = i
       
       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.getuuid(), 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
   }
 
   getTotalLine = (data) => {
-    let totalLine = {uuid: Utils.getuuid(), type: 'total'}
-    let debtor = ''
-    let creditor = ''
+    let totalLine = {uuid: Utils.getguid(), type: 'total'}
+    let debit = ''
+    let credit = ''
 
     data.forEach(item => {
-      if (typeof(item.debtor) === 'number') {
-        if (debtor === '') {
-          debtor = 0
+      if (!isNaN(item.debit) && item.debit !== '') {
+        if (debit === '') {
+          debit = 0
         }
 
-        debtor += item.debtor
-      } else if (typeof(item.creditor) === 'number') {
-        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
   }
@@ -534,56 +1296,68 @@
     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.getuuid(), 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)
     }
   }
 
-  plusLine = (initEditLine) => {
-    const { edData } = this.state
+  plusLine = (tid, record) => {
+    const { edData, tableId } = this.state
 
-    let item = {...edData[edData.length - 1]}
+    if (tid !== tableId) return
 
-    item.key = item.key + 1
-    item.$$uuid = '$new'
+    let _data = fromJS(edData).toJS()
+    let line = {uuid: Utils.getguid(), index: 0, subject_voucher_text: '', subject_code: '', subject_name: '', debit: '', credit: ''}
 
-    this.setState({edData: [...edData, item]}, () => {
-      MKEmitter.emit('tdFocus', initEditLine.uuid + item.uuid)
+    _data.splice(record.index, 0, line)
+    _data = _data.map((item, index) => {
+      item.index = index
+      return item
     })
+
+    this.setState({edData: _data})
+    this.props.onChange(_data)
   }
 
-  delRecord = (id, record) => {
+  delVoucher = (id, record) => {
     const { tableId, edData } = this.state
 
     if (id !== tableId) return
 
-    let _data = edData.filter(item => item.uuid !== record.uuid)
+    let _data = fromJS(edData).toJS().filter(item => item.uuid !== record.uuid)
 
     _data.pop()
 
     if (_data.length < 4) {
-      for (let i = _data.length - 1; i < 4; i++) {
-        _data.push({uuid: Utils.getuuid(), index: i + 1, remark: '', subjectscode: '', subjectsname: '', debtor: '', creditor: ''})
+      for (let i = _data.length; i < 4; i++) {
+        _data.push({uuid: Utils.getguid(), index: 0, subject_voucher_text: '', subject_code: '', subject_name: '', debit: '', credit: ''})
       }
     }
+
+    _data = _data.map((item, index) => {
+      item.index = index
+      return item
+    })
 
     _data.push(this.getTotalLine(_data))
 
     this.setState({edData: _data})
+    this.props.onChange(_data)
   }
 
   changeRecord = (tableId, record) => {
@@ -600,187 +1374,13 @@
     _data.pop()
 
     if (record.index === _data.length - 1) {
-      _data.push({uuid: Utils.getuuid(), 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))
 
     this.setState({edData: _data})
-  }
-
-  addLine = () => {
-    const { BID } = this.props
-    const { edData } = this.state
-
-    let item = {}
-    if (edData.length > 0) {
-      item = {...edData[edData.length - 1]}
-      item.key = item.key + 1
-      item.$$uuid = '$new'
-    } else {
-      item.key = 0
-      item.$$uuid = '$new'
-      item.$$BID = BID || ''
-    }
-
-    this.setState({edData: [...edData, item]})
-  }
-
-  checkData = () => {
-    const { edData } = this.state
-
-    if (edData.length === 0) {
-      notification.warning({
-        top: 92,
-        message: '鎻愪氦鏁版嵁涓嶅彲涓虹┖锛�',
-        duration: 5
-      })
-      return
-    }
-    let err = ''
-    let data = fromJS(edData).toJS().map(item => {
-      // let line = []
-      // fields.forEach(col => {
-      //   if (col.editable !== 'true' || item.$deleted) {
-      //     if (col.type === 'number') {
-      //       item[col.field] = +item[col.field]
-      //       if (isNaN(item[col.field])) {
-      //         item[col.field] = 0
-      //       }
-      //     } else {
-      //       item[col.field] = item[col.field] !== undefined ? (item[col.field] + '') : ''
-      //     }
-      //     return
-      //   }
-      //   if (col.type === 'text') {
-      //     let val = item[col.field] !== undefined ? (item[col.field] + '') : ''
-      //     if (col.required === 'true' && !val) {
-      //       line.push(`${col.label}涓嶅彲涓虹┖`)
-      //     }
-      //     item[col.field] = val
-      //   } else if (col.type === 'number') {
-      //     let val = item[col.field]
-      //     if (!val && val !== 0) {
-      //       line.push(`${col.label}涓嶅彲涓虹┖`)
-      //       return
-      //     }
-      //     val = +val
-      //     if (isNaN(val)) {
-      //       line.push(`${col.label}鏁版嵁鏍煎紡閿欒`)
-      //       return
-      //     }
-
-      //     val = +val.toFixed(col.decimal || 0)
-          
-      //     if (typeof(col.max) === 'number' && val > col.max) {
-      //       line.push(`${col.label}涓嶅彲澶т簬${col.max}`)
-      //     } else if (typeof(col.min) === 'number' && val < col.min) {
-      //       line.push(`${col.label}涓嶅彲灏忎簬${col.min}`)
-      //     }
-
-      //     item[col.field] = val
-      //   }
-      // })
-
-      return item
-    })
-
-    if (err) {
-      notification.warning({
-        top: 92,
-        message: err,
-        duration: 5
-      })
-    } else {
-      this.submit(data)
-    }
-  }
-
-  submit = (data) => {
-    const { BID } = this.props
-
-    let param = {
-      // excel_in: result.lines,
-      BID: BID || ''
-    }
-
-    this.setState({
-      loading: true
-    })
-
-    param.func = 'submit.innerFunc'
-
-    Api.genericInterface(param).then((res) => {
-      if (res.status) {
-        this.execSuccess(res)
-      } else {
-        this.execError(res)
-      }
-    }, () => {
-      this.execError({})
-    })
-  }
-
-  execSuccess = (res) => {
-    const { submit } = this.props
-
-    if (res && res.ErrCode === 'S') { // 鎵ц鎴愬姛
-      notification.success({
-        top: 92,
-        message: res.ErrMesg || this.state.dict['main.action.confirm.success'],
-        duration: submit.stime ? submit.stime : 2
-      })
-    } else if (res && res.ErrCode === 'Y') { // 鎵ц鎴愬姛
-      Modal.success({
-        title: res.ErrMesg || this.state.dict['main.action.confirm.success']
-      })
-    } else if (res && res.ErrCode === '-1') { // 瀹屾垚鍚庝笉鎻愮ず
-
-    }
-
-    this.setState({
-      loading: false
-    })
-
-    if (submit.closetab === 'true') {
-      MKEmitter.emit('popclose')
-    }
-    if (submit.execSuccess !== 'never') {
-      MKEmitter.emit('refreshByButtonResult', submit.$menuId, submit.execSuccess, submit)
-    }
-  }
-
-  execError = (res) => {
-    const { submit } = this.props
-
-    if (res.ErrCode === 'E') {
-      Modal.error({
-        title: res.message || res.ErrMesg,
-      })
-    } else if (res.ErrCode === 'N') {
-      notification.error({
-        top: 92,
-        message: res.message || res.ErrMesg,
-        duration: submit.ntime ? submit.ntime : 10
-      })
-    } else if (res.ErrCode === 'F') {
-      notification.error({
-        className: 'notification-custom-error',
-        top: 92,
-        message: res.message || res.ErrMesg,
-        duration: submit.ftime ? submit.ftime : 10
-      })
-    } else if (res.ErrCode === 'NM') {
-      message.error(res.message || res.ErrMesg)
-    }
-    
-    this.setState({
-      loading: false
-    })
-
-    if (submit.execError !== 'never') {
-      MKEmitter.emit('refreshByButtonResult', submit.$menuId, submit.execError, submit)
-    }
+    this.props.onChange(_data)
   }
 
   render() {
@@ -801,7 +1401,7 @@
           columns={columns}
           dataSource={edData}
           bordered={true}
-          // loading={this.props.loading}
+          loading={this.props.loading}
           onRow={(record, index) => {
             return {
               data: record

--
Gitblit v1.8.0