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

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

diff --git a/src/tabviews/custom/components/module/voucher/voucherTable/index.jsx b/src/tabviews/custom/components/module/voucher/voucherTable/index.jsx
index c07a89e..0c5af4a 100644
--- a/src/tabviews/custom/components/module/voucher/voucherTable/index.jsx
+++ b/src/tabviews/custom/components/module/voucher/voucherTable/index.jsx
@@ -51,8 +51,8 @@
     this.setState({
       subAccounts: fromJS(this.state.subAccounts).toJS().map(cell => {
         if (key === cell.field) {
-          cell.value = option.props.value
-          cell.name = option.props.name
+          cell.value = option ? option.props.value : ''
+          cell.name = option ? option.props.name : ''
         }
         return cell
       })
@@ -110,6 +110,10 @@
       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') {
@@ -191,6 +195,16 @@
     let line = {...record}
     line[col.field] = value
 
+    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)) {
@@ -223,9 +237,9 @@
 
     setTimeout(() => {
       if (col.field === 'debit' && (line.debit || line.debit === 0)) {
-        MKEmitter.emit('nextLine', col, record)
+        MKEmitter.emit('nextVoucher', col, record)
       } else if (col.field === 'credit') {
-        MKEmitter.emit('nextLine', col, record)
+        MKEmitter.emit('nextVoucher', col, record)
       } else {
         let cl = {subject_voucher_text: 'subject_code', subject_code: 'debit', debit: 'credit'}
         MKEmitter.emit('tdFocus', cl[col.uuid] + record.uuid)
@@ -259,6 +273,11 @@
 
     if (value !== record[col.field]) {
       let line = {...record, [col.field]: value}
+
+      if (col.field === 'subject_voucher_text') {
+        MKEmitter.emit('changeRecord', col.tableId, line)
+        return
+      }
 
       if (col.field === 'debit') {
         line.credit = ''
@@ -308,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 = () => {
@@ -693,11 +712,15 @@
       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}
@@ -746,21 +769,25 @@
             if (record.sup_accounting && record.supAccounts) {
               record.supAccounts.forEach(item => {
                 if (item.sup_acc_type === 'supplier') {
-                  val += item.suppliercode ? '_' + item.suppliercode : ''
+                  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 : ''
+                  val += item.customercode ? '_' + item.customercode + ' ' + item.customername : ''
                 } else if (item.sup_acc_type === 'department') {
-                  val += item.co_pro_code ? '_' + item.co_pro_code : ''
+                  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 : ''
+                  val += item.projectcode ? '_' + item.projectcode + ' ' + item.projectname : ''
                 } else if (item.sup_acc_type === 'inventory') {
-                  val += item.productcode ? '_' + item.productcode : ''
+                  val += item.productcode ? '_' + item.productcode + ' ' + item.productname : ''
                 } else if (item.sup_acc_type === 'employee') {
-                  val += item.workercode ? '_' + item.workercode : ''
+                  val += item.workercode ? '_' + item.workercode + ' ' + item.workername : ''
                 } else if (item.sup_acc_type === 'cash_flow') {
-                  val += item.cash_flow_code ? '_' + item.cash_flow_code : ''
+                  val += item.cash_flow_code ? '_' + item.cash_flow_code + ' ' + item.cash_flow_name : ''
                 } else if (item.sup_acc_code) {
-                  val += '_' + item.sup_acc_code
+                  val += '_' + item.sup_acc_code + ' ' + item.sup_acc_name
                 }
               })
             }
@@ -790,6 +817,17 @@
                 <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 {
@@ -866,6 +904,21 @@
                   <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}>
@@ -884,11 +937,19 @@
             }
           }
 
-          children = <div className="content-wrap" onClick={this.focus}>
-            {val}
-            {countNode}
-            {currencyNode}
-          </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 === 'debit') {
@@ -905,13 +966,23 @@
           }
           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>
+        }
       }
     } else if (col.field === 'credit') {
-      extra = <CloseOutlined onClick={this.delRecord}/>
+      if (record.type !== 'total' && !record.$disabled) {
+        extra = <CloseOutlined onClick={this.delVoucher}/>
+      }
 
       if (editing) {
         children = <InputNumber id={col.uuid + record.uuid} precision={2} defaultValue={record.credit} onChange={(val) => this.onChange(val)} onPressEnter={this.enterPress} onBlur={this.onBlur}/>
@@ -926,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>
+        }
       }
     }
 
@@ -941,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 () {
@@ -1024,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)
   }
 
@@ -1038,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)
   }
 
@@ -1080,9 +1159,11 @@
       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, subject_voucher_text: '', subject_code: '', subject_name: '', debit: '', credit: ''})
+        _data.push({uuid: Utils.getguid(), $disabled: disabled, index: i + 1, subject_voucher_text: '', subject_code: '', subject_name: '', debit: '', credit: ''})
       }
     }
     return _data
@@ -1111,10 +1192,23 @@
       }
     })
 
+    let _total = debit
+    if (debit === 0) {
+      debit = ''
+    }
+
+    if (_total === '' && credit !== '') {
+      _total = 0
+    }
+
+    if (credit === 0) {
+      credit = ''
+    }
+
     totalLine.debit = debit
     totalLine.credit = credit
 
-    totalLine.subject_voucher_text = this.changeMoneyToChinese(debit)
+    totalLine.subject_voucher_text = this.changeMoneyToChinese(_total)
     
     return totalLine
   }
@@ -1202,7 +1296,7 @@
     return ChineseStr
   }
 
-  nextLine = (col, record) => {
+  nextVoucher = (col, record) => {
     const { edData, tableId } = this.state
 
     if (col.tableId !== tableId) return
@@ -1240,7 +1334,7 @@
     this.props.onChange(_data)
   }
 
-  delRecord = (id, record) => {
+  delVoucher = (id, record) => {
     const { tableId, edData } = this.state
 
     if (id !== tableId) return

--
Gitblit v1.8.0