From d5ce81026882ada34e5d49411be7c90ee96cc102 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 17 一月 2023 18:20:11 +0800
Subject: [PATCH] 2023-01-17

---
 src/tabviews/custom/components/module/voucher/index.jsx |  127 ++++++++++++++++++++++++++++++++++--------
 1 files changed, 102 insertions(+), 25 deletions(-)

diff --git a/src/tabviews/custom/components/module/voucher/index.jsx b/src/tabviews/custom/components/module/voucher/index.jsx
index bd053ab..1b18806 100644
--- a/src/tabviews/custom/components/module/voucher/index.jsx
+++ b/src/tabviews/custom/components/module/voucher/index.jsx
@@ -1,11 +1,12 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { is, fromJS } from 'immutable'
-import { Button, Select, Input, DatePicker } from 'antd'
-// import { EditOutlined, ToolOutlined, DeleteOutlined, FontColorsOutlined } from '@ant-design/icons'
+import { Button, Select, Input, DatePicker, notification } from 'antd'
+import moment from 'moment'
 
+import Api from '@/api'
 import asyncComponent from '@/utils/asyncComponent'
-// import MKEmitter from '@/utils/events.js'
+import MKEmitter from '@/utils/events.js'
 import './index.scss'
 
 const VoucherTable = asyncComponent(() => import('./voucherTable'))
@@ -17,14 +18,17 @@
 
   state = {
     BID: '',
-    type: '',
     config: null,
     loading: false,
-    data: null,
-    searchkey: null,
-    disableAdd: true,
-    disableSave: true,
-    typeOptions: []
+    data: [],
+    disableAdd: false,
+    disableSave: false,
+    typeOptions: [],
+    subjects: [],
+    charType: '',
+    charInt: '',
+    vouDate: null,
+    book: null
   }
 
   UNSAFE_componentWillMount () {
@@ -33,8 +37,8 @@
     let BID = ''
     let BData = ''
 
-    if (config.setting.supModule) {
-      BData = window.GLOB.CacheData.get(config.setting.supModule)
+    if (config.wrap.supModule) {
+      BData = window.GLOB.CacheData.get(config.wrap.supModule)
     } else {
       BData = window.GLOB.CacheData.get(config.$pageId)
     }
@@ -45,14 +49,14 @@
     this.setState({
       config: fromJS(config).toJS(),
       BID: BID || '',
-      type: config.wrap.type
+      book: window.GLOB.CacheData.get(config.wrap.supBook) || null
     }, () => {
       this.loadData()
     })
   }
 
   componentDidMount () {
-
+    MKEmitter.addListener('resetSelectLine', this.resetParentParam)
   }
 
   shouldComponentUpdate (nextProps, nextState) {
@@ -66,10 +70,83 @@
     this.setState = () => {
       return
     }
+
+    MKEmitter.removeListener('resetSelectLine', this.resetParentParam)
+  }
+
+  resetParentParam = (MenuID, id, data) => {
+    const { config } = this.state
+
+    if (config.wrap.supBook === MenuID) {
+      let month = data.months
+      let vouDate = moment()
+
+      if (month && month < moment().format('YYYY-MM')) {
+        vouDate = moment(month, 'YYYY-MM').endOf('month')
+      }
+
+      this.setState({ book: data, vouDate }, () => {
+        this.loadData()
+      })
+      return
+    }
+
+    if (!config.wrap.supModule || config.wrap.supModule !== MenuID) return
+    if (id !== this.state.BID || id !== '') {
+      this.setState({ BID: id, BData: data }, () => {
+        this.loadData()
+      })
+    }
   }
 
   loadData = () => {
+    const { book } = this.state
 
+    if (!book) return
+
+    let param = {
+      func: 's_get_fcc_account_data',
+      account_code: book.account_code || '',
+      fcc_date: book.months ? book.months + '-01' : moment().format('YYYY-MM-DD')
+    }
+
+    Api.genericInterface(param).then(res => {
+      if (!res.status) {
+        notification.warning({
+          top: 92,
+          message: res.message,
+          duration: 5
+        })
+        return
+      }
+
+      let typeOptions = res.char || []
+
+      this.setState({
+        typeOptions: typeOptions,
+        charType: typeOptions[0] ? typeOptions[0].voucher_class : '',
+        charInt: typeOptions[0] ? typeOptions[0].voucher_char_int : '',
+        subjects: res.subjects || [],
+      })
+
+      setTimeout(() => {
+        this.getVoucher()
+      }, 200)
+    })
+  }
+
+
+  getVoucher = () => {
+    let data = [
+      {remark: '鎻愮幇', subjectscode: '1001', subjectsname: '搴撳瓨鐜伴噾', debtor: 124, creditor: ''},
+      {remark: '璐叆鍥哄畾璧勪骇', subjectscode: '1001', subjectsname: '搴撳瓨鐜伴噾', debtor: '', creditor: 124},
+      {remark: '杞粨閿�鍞垚鏈�', subjectscode: '1001', subjectsname: '搴撳瓨鐜伴噾', debtor: -524, creditor: ''},
+      {remark: '鎻愮幇', subjectscode: '1001', subjectsname: '搴撳瓨鐜伴噾', debtor: 34, creditor: ''},
+    ]
+
+    this.setState({
+      data: data
+    })
   }
 
   triggeradd = () => {
@@ -85,29 +162,29 @@
   }
 
   render() {
-    const { config, disableSave, disableAdd, typeOptions, data, type } = this.state
+    const { config, disableSave, disableAdd, typeOptions, charType, charInt, data, vouDate, subjects } = this.state
 
     return (
       <div className="menu-voucher-wrap" style={config.style}>
         <div className="voucher-header">
-          <Button className="system-background header-btn" disabled={disableAdd} onClick={this.triggeradd}>鏂板</Button>
-          <Button className="system-background header-btn" disabled={disableSave} onClick={this.triggersave}>淇濆瓨</Button>
-          <Button className="system-background header-btn" disabled={disableSave} onClick={this.triggerprint}>鎵撳嵃</Button>
+          <Button className="add-background header-btn" disabled={disableAdd} onClick={this.triggeradd}>鏂板</Button>
+          <Button className="add-background header-btn" disabled={disableSave} onClick={this.triggersave}>淇濆瓨</Button>
+          <Button className="print-background header-btn" disabled={disableSave} onClick={this.triggerprint}>鎵撳嵃</Button>
           <Button className="system-background header-btn" disabled={disableSave} onClick={this.triggerprint}>瀵煎叆</Button>
-          <Button className="system-background header-btn" disabled={disableSave} onClick={this.triggerprint}>瀵煎嚭</Button>
+          <Button className="out-background header-btn" disabled={disableSave} onClick={this.triggerprint}>瀵煎嚭</Button>
         </div>
-        {type === 'edit' ? <div className="voucher-body">
+        {config.wrap.type === 'edit' ? <div className="voucher-body">
           <div className="pre-wrap">
             <div className="voucher-code">
-              <Select>
+              <Select value={charType} dropdownClassName="mk-vcode-dropdown" onChange={(val, option) => this.setState({charType: val, charInt: option.props.charint})}>
                 {typeOptions.map(option =>
-                  <Select.Option value={option.value}>{option.label}</Select.Option>
+                  <Select.Option key={option.voucher_char_int} value={option.voucher_class} charint={option.voucher_char_int}>{option.voucher_char}</Select.Option>
                 )}
               </Select>
-              <Input autoComplete="off" /> 鍙�
+              <Input value={charInt} autoComplete="off" onChange={(e) => this.setState({charInt: e.target.value})}/> 鍙�
             </div>
             <div className="voucher-date">
-              鏃ユ湡锛�<DatePicker onChange={this.onChange}/>
+              鏃ユ湡锛�<DatePicker value={vouDate} onChange={(val) => this.setState({vouDate: val})}/>
             </div>
             <div className="voucher-affix">
               闄勫崟鎹� <Input autoComplete="off" /> 寮�
@@ -115,9 +192,9 @@
               <Button type="link" className="" onClick={this.triggerprint}>澶囨敞</Button>
             </div>
           </div>
-          <VoucherTable config={config} data={data}/>
+          <VoucherTable config={config} subjects={subjects} data={data}/>
         </div> : null}
-        {type === 'check' ? <div className="voucher-body">
+        {config.wrap.type === 'check' ? <div className="voucher-body">
           <div className="pre-wrap">
             <div className="voucher-code">
               璁� 1 鍙�

--
Gitblit v1.8.0