From 253fbcbdd06f6354e857a8e1e47ddf116459df42 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 10 二月 2023 17:43:58 +0800
Subject: [PATCH] 2023-02-10

---
 src/tabviews/custom/components/module/voucher/index.jsx |   85 +++++++++++++++++++-----------------------
 1 files changed, 38 insertions(+), 47 deletions(-)

diff --git a/src/tabviews/custom/components/module/voucher/index.jsx b/src/tabviews/custom/components/module/voucher/index.jsx
index b1842ef..80c4e62 100644
--- a/src/tabviews/custom/components/module/voucher/index.jsx
+++ b/src/tabviews/custom/components/module/voucher/index.jsx
@@ -11,8 +11,9 @@
 import './index.scss'
 
 const { confirm } = Modal
-const { TextArea } = Input
 const VoucherTable = asyncComponent(() => import('./voucherTable'))
+const ResetRemark = asyncComponent(() => import('./resetRemark'))
+const ResetAttach = asyncComponent(() => import('./resetAttach'))
 
 class VoucherModule extends Component {
   static propTpyes = {
@@ -34,8 +35,8 @@
     book: null,
     username: sessionStorage.getItem('User_Name'),
     remark: '',
-    remarkVisible: false,
     attachments: 0,
+    attachlist: [],
     title: '',
     orgcode: '',
     orgname: '',
@@ -603,23 +604,7 @@
   }
 
   triggerprint = () => {
-    this.setState({remarkVisible: true})
-  }
 
-  remarkSubmit = () => {
-    const { config } = this.state
-    let node = document.getElementById(config.uuid + 'remark')
-    let val = node.value
-
-    if (val && val.length > 512) {
-      notification.warning({
-        top: 92,
-        message: '褰撳墠鍐呭瓒呴暱锛屽娉ㄦ渶澶�512涓瓧绗︺��',
-        duration: 5
-      })
-      return
-    }
-    this.setState({remark: val, remarkVisible: false})
   }
 
   dataChange = (data) => {
@@ -651,7 +636,7 @@
   }
 
   updateVoucherChar = (val) => {
-    const {book} = this.state
+    const { book, config } = this.state
 
     if (!book) return
 
@@ -674,17 +659,38 @@
         return
       }
 
-      // let typeOptions = res.char || []
-      // let charInt = typeOptions[0] ? typeOptions[0].voucher_char_int + 1 : 1
+      let typeOptions = res.char || []
 
-      // this.setState({
-      //   typeOptions: typeOptions,
-      //   charType: typeOptions[0] ? typeOptions[0].voucher_class : '',
-      //   charName: typeOptions[0] ? typeOptions[0].voucher_char : '',
-      //   charInt: charInt,
-      //   orgcode: res.orgcode,
-      //   orgname: res.orgname,
-      // })
+      if (typeOptions.length > 0) {
+        let charType = this.state.charType
+        let charName = this.state.charName
+        let charInt = this.state.charInt
+  
+        if (charType && typeOptions.filter(n => n.voucher_class === charType) > 0) {
+          typeOptions.forEach(n => {
+            if (n.voucher_class === charType) {
+              charName = n.voucher_char
+              charInt = n.voucher_char_int + 1
+            }
+          })
+        } else {
+          charType = typeOptions[0].voucher_class
+          charName = typeOptions[0].voucher_char
+          charInt = typeOptions[0].voucher_char_int + 1
+        }
+
+        this.setState({
+          typeOptions: typeOptions,
+          charType: charType,
+          charName: charName,
+          charInt: charInt
+        })
+      }
+
+      let msg = window.GLOB.CacheVoucher.get(config.uuid) || {}
+      msg.currency = res.currency || []
+
+      window.GLOB.CacheVoucher.set(config.uuid, msg)
     })
   }
 
@@ -696,12 +702,8 @@
 
   }
 
-  triggerAttach = () => {
-
-  }
-
   render() {
-    const { type, status, loading, config, typeOptions, charType, charInt, data, vouDate, username, remark, remarkVisible, attachments, title } = this.state
+    const { type, status, loading, config, typeOptions, charType, charInt, data, vouDate, username, remark, attachments, title, attachlist } = this.state
 
     return (
       <div className="menu-voucher-wrap" style={config.style}>
@@ -734,24 +736,13 @@
             </div>
             <div className="voucher-affix">
               闄勫崟鎹� <InputNumber precision={0} value={attachments || 0} autoComplete="off" onChange={this.changeAttach}/> 寮�
-              <Button type="link" className="" onClick={this.triggerAttach}>闄勪欢</Button>
-              <Button type="link" className="" onClick={this.triggerprint}>澶囨敞</Button>
+              <ResetAttach attachlist={attachlist} onChange={(vals) => this.setState({attachlist: vals})}/>
+              <ResetRemark remark={remark} ID={config.uuid + 'remark'} onChange={(val) => this.setState({remark: val})}/>
             </div>
           </div> : null}
           <VoucherTable config={config} loading={loading} data={data} onChange={this.dataChange}/>
         </div>
         <div className="user">鍒跺崟浜猴細{username}</div>
-        <Modal
-          title="澶囨敞"
-          visible={remarkVisible}
-          width={700}
-          maskClosable={false}
-          onOk={this.remarkSubmit}
-          onCancel={() => { this.setState({ remarkVisible: false })}}
-          destroyOnClose
-        >
-          <TextArea id={config.uuid + 'remark'} defaultValue={remark} rows={6}/>
-        </Modal>
       </div>
     )
   }

--
Gitblit v1.8.0