From 4453a9e63e8e176c70c432b03fd4ba3ebf00a04c Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 09 二月 2023 14:55:20 +0800
Subject: [PATCH] 2023-02-09

---
 src/tabviews/custom/components/module/voucher/voucherTable/index.jsx |  423 ++++++++++++++++++++++++++++++----------------------
 1 files changed, 241 insertions(+), 182 deletions(-)

diff --git a/src/tabviews/custom/components/module/voucher/voucherTable/index.jsx b/src/tabviews/custom/components/module/voucher/voucherTable/index.jsx
index 9a37f76..68aa28d 100644
--- a/src/tabviews/custom/components/module/voucher/voucherTable/index.jsx
+++ b/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,37 @@
         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 === '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 +191,43 @@
     let line = {...record}
     line[col.field] = value
 
-    if (col.field === 'debtor') {
-      line.creditor = ''
-      if (isNaN(line.debtor)) {
-        line.debtor = ''
+    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)) {
+      if (col.field === 'debit' && (line.debit || line.debit === 0)) {
         MKEmitter.emit('nextLine', col, record)
-      } else if (col.field === 'creditor') {
+      } else if (col.field === 'credit') {
         MKEmitter.emit('nextLine', 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 +238,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 +260,31 @@
     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 === '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
         }
       }
 
@@ -293,9 +327,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 +361,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 +373,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 +386,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 +404,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 +418,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 +428,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 +439,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 +462,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 +478,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 +490,7 @@
 
     this.setState({priceing: false})
     setTimeout(() => {
-      MKEmitter.emit('tdFocus', 'debtor' + record.uuid)
+      MKEmitter.emit('tdFocus', 'debit' + record.uuid)
     }, 50)
   }
 
@@ -459,10 +501,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 +532,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 +569,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 +597,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 +608,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 +621,7 @@
     this.setState({origining: false})
 
     setTimeout(() => {
-      MKEmitter.emit('tdFocus', 'debtor' + record.uuid)
+      MKEmitter.emit('tdFocus', 'debit' + record.uuid)
     }, 50)
   }
 
@@ -590,10 +632,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 +644,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,8 +687,8 @@
     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>
@@ -655,7 +697,9 @@
         extra = <PlusOutlined onClick={this.plusLine}/>
 
         if (editing) {
-          let options = ['鐜伴噾', '鍙戠エ']
+          let options = localStorage.getItem(window.GLOB.host + '_voucher_extract')
+          options = options ? JSON.parse(options) : []
+
           children = <AutoComplete
             dataSource={options.map((cell, i) => <AutoComplete.Option value={cell} key={i}>
               {cell}
@@ -672,7 +716,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 +727,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 +742,30 @@
           </>
         } 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 : ''
+                } else if (item.sup_acc_type === 'customer') {
+                  val += item.customercode ? '_' + item.customercode : ''
+                } else if (item.sup_acc_type === 'department') {
+                  val += item.co_pro_code ? '_' + item.co_pro_code : ''
+                } else if (item.sup_acc_type === 'project') {
+                  val += item.projectcode ? '_' + item.projectcode : ''
+                } else if (item.sup_acc_type === 'inventory') {
+                  val += item.productcode ? '_' + item.productcode : ''
+                } else if (item.sup_acc_type === 'employee') {
+                  val += item.workercode ? '_' + item.workercode : ''
+                } else if (item.sup_acc_type === 'cash_flow') {
+                  val += item.cash_flow_code ? '_' + item.cash_flow_code : ''
+                } else if (item.sup_acc_code) {
+                  val += '_' + item.sup_acc_code
+                }
+              })
+            }
           }
 
           let countNode = null
@@ -716,33 +776,33 @@
               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 {
               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 +835,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 +850,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 +865,7 @@
                 </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 {
@@ -820,7 +880,7 @@
                 </span>
                 <span onClick={this.editOrigin}>
                   <span>鍘熷竵锛�</span>
-                  <span>{record.origin || 0}</span>
+                  <span>{record.foreign_amount || 0}</span>
                 </span>
               </div>
             }
@@ -833,11 +893,11 @@
           </div>
         }
       }
-    } else if (col.field === 'debtor') {
+    } else if (col.field === 'debit') {
       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}/>
+        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.debtor
+        let val = record.debit
         let down = false
         let vals = []
         if (!isNaN(val) && val !== '') {
@@ -852,13 +912,13 @@
           <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') {
+    } else if (col.field === 'credit') {
       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 !== '') {
@@ -902,22 +962,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 +988,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 +1004,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},
         })
       }
     ]
@@ -1018,14 +1078,13 @@
     let _data = data.map((item, i) => {
       // item.uuid = Utils.getguid()
       item.index = i
-      item.$origin = true
       
       return item
     })
 
     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(), index: i + 1, subject_voucher_text: '', subject_code: '', subject_name: '', debit: '', credit: ''})
       }
     }
     return _data
@@ -1033,31 +1092,31 @@
 
   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
+    totalLine.debit = debit
+    totalLine.credit = credit
 
-    totalLine.remark = this.changeMoneyToChinese(debtor)
+    totalLine.subject_voucher_text = this.changeMoneyToChinese(debit)
     
     return totalLine
   }
@@ -1151,15 +1210,15 @@
     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 +1230,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) => {
@@ -1194,7 +1253,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 +1265,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 +1282,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))

--
Gitblit v1.8.0