king
2023-02-09 69905117d0252701c4227c4c37a2403cd8999ecc
src/tabviews/custom/components/module/voucher/index.jsx
@@ -57,18 +57,40 @@
      BID = BData.$BID || ''
    }
    let book = null
    let vouDate = null
    if (config.wrap.supBook) {
      book = window.GLOB.CacheData.get(config.wrap.supBook) || null
      if (book) {
        let month = book.months
        vouDate = moment()
        if (month && month < moment().format('YYYY-MM')) {
          vouDate = moment(month, 'YYYY-MM').endOf('month')
        }
      }
    }
    window.GLOB.CacheVoucher.delete(config.uuid)
    let type = config.wrap.type || 'createVoucher'
    type = 'checkVoucher'
    // type = 'checkVoucher'
    // BID = '202302081418373862P8Q29OUD19CT1AVMU6'
    if (type === 'createVoucher' || type === 'createTemp') {
      BID = Utils.getguid()
    }
    this.setState({
      book: book,
      vouDate: vouDate,
      config: fromJS(config).toJS(),
      type: type,
      BID: BID || '',
      status: 'empty',
      book: window.GLOB.CacheData.get(config.wrap.supBook) || null
      status: 'empty'
    }, () => {
      this.loadData()
      this.getVoucher()
    })
  }
@@ -93,7 +115,7 @@
  }
  resetParentParam = (MenuID, id, data) => {
    const { config } = this.state
    const { config, type } = this.state
    if (config.wrap.supBook === MenuID) {
      let month = data.months
@@ -110,7 +132,7 @@
      return
    }
    if (!config.wrap.supModule || config.wrap.supModule !== MenuID) return
    if (!config.wrap.supModule || config.wrap.supModule !== MenuID || type === 'createVoucher' || type === 'createTemp') return
    if (id !== this.state.BID || id !== '') {
      this.setState({ BID: id }, () => {
        this.getVoucher()
@@ -127,6 +149,8 @@
      func: 's_get_fcc_account_data',
      // account_code: book.account_code || '',
      fcc_date: book.months ? book.months + '-01' : moment().format('YYYY-MM-DD'),
      account_year_code: book.account_year_code || '',
      months: book.months ? book.months : moment().format('YYYY-MM'),
      BID: book.id
    }
@@ -225,17 +249,14 @@
  }
  getVoucher = () => {
    // const { book, BID, type } = this.state
    const { book, type } = this.state
    const { book, BID, type } = this.state
    // if (!book || !BID || type === 'createVoucher' || type === 'createTemp') return
    if (!book || type === 'createVoucher' || type === 'createTemp') return
    if (!book || !BID || type === 'createVoucher' || type === 'createTemp') return
    let param = {
      func: 's_get_fcc_voucher',
      BID: book.id,
      // ID: BID
      ID: '20230207175535042UOMRLECLIVPKOBU7L2N'
      ID: BID
    }
    Api.genericInterface(param).then(res => {
@@ -265,20 +286,14 @@
          line.exratecode = line.foreign_exratecode || ''
          line.exratename = line.foreign_exratename || ''
          line.local_currency = line.local_exratecode || ''
          if (line.unitratio && line.foreign_amount) {
            line.foreign_currency_type = 'Y'
          }
          if (line.net_unitprice && line.fcc_count) {
            line.count_type = 'Y'
          }
          line.foreign_currency_type = line.foreign_type || ''
          if (line.sup) {
            line.supAccounts = line.sup.map(cell => {
              cell.uuid = cell.sup_id
              return cell
            })
            delete line.sup
          }
          return line
@@ -416,7 +431,7 @@
  }
  voucherSave = (list, t) => {
    const { data, config, charInt, charType, vouDate, book, remark, charName, attachments, title, orgcode, orgname } = this.state
    const { type, data, config, charInt, charType, vouDate, book, remark, charName, attachments, title, orgcode, orgname } = this.state
    if (!book) {
      notification.warning({
@@ -441,6 +456,7 @@
      orgname: orgname || '',
      voucher_class: charType,
      years: book.years,
      months: moment(vouDate).format('YYYY-MM'),
      business_type: config.wrap.businessType || '',
      voucher_sign: config.wrap.voucherSign || '',
      voucher_char: charName,
@@ -467,6 +483,8 @@
    let sup_data = []
    let voucherMap = new Map()
    let supMap = new Map()
    let extract = localStorage.getItem(window.GLOB.host + '_voucher_extract')
    extract = extract ? JSON.parse(extract) : []
    data.forEach(item => {
      voucherMap.set(item.uuid, item)
@@ -494,6 +512,10 @@
      let count = item.count_type === 'Y'
      let curr = item.foreign_currency_type === 'Y'
      let direct = item.debit ? 'debit' : 'credit'
      if (type === 'createVoucher' && item.subject_voucher_text && item.subject_voucher_text.length < 20) {
        extract.unshift(item.subject_voucher_text)
      }
      if (voucherMap.has(item.uuid)) {
        voucherMap.delete(item.uuid)
@@ -507,15 +529,23 @@
          sup_data.push(`'${n.uuid}','${item.subject_voucher_code || ''}','${item.voucher_lp || ''}','${n.voucher_sup_lp || ''}','${item.subject_code}','${item.subject_name}','${n.sup_voucher_text || ''}','${direct}',${item.debit || item.credit},'${n.customercode || ''}','${n.customername || ''}','${n.suppliercode || ''}','${n.suppliername || ''}','${n.co_pro_code || ''}','${n.co_pro_name || ''}','${n.workercode || ''}','${n.workername || ''}','${n.project_code || ''}','${n.project_name || ''}','${n.productcode || ''}','${n.productname || ''}','${n.cash_flow_code || ''}','${n.cash_flow_name || ''}','${n.sup_acc_code || ''}','${n.sup_acc_name || ''}','${n.sup_acc_type || ''}','${item.uuid}',0`)
        })
      }
      return `'${item.uuid}','${item.subject_voucher_code || ''}','${item.voucher_lp || ''}','${item.subject_code}','${item.subject_name}','${item.subject_voucher_text || ''}',${count ? item.fcc_count || 0 : 0},${count ? item.net_unitprice || 0 : 0},'${item.unit}',${item.debit || item.credit},'${direct}','${curr ? item.exratecode : '01010001'}','${curr ? item.exratename : 'CNY'}',${curr ? item.unitratio || 0 : 0},'${item.sup_accounting}',${item.debit ? 1 : -1},${curr ? item.foreign_amount || 0 : 0},0,'${item.local_currency || ''}'`
      return `'${item.uuid}','${item.subject_voucher_code || ''}','${item.voucher_lp || ''}','${item.subject_code}','${item.subject_name}','${item.subject_voucher_text || ''}',${count ? item.fcc_count || 0 : 0},${count ? item.net_unitprice || 0 : 0},'${item.unit}',${item.debit || item.credit},'${direct}','${curr ? item.exratecode : '01010001'}','${curr ? item.exratename : 'CNY'}',${curr ? item.unitratio || 0 : 0},'${item.sup_accounting}',${item.debit ? 1 : -1},${curr ? item.foreign_amount || 0 : 0},0,'${item.local_currency || ''}','${count ? 'Y' : ''}','${curr ? 'Y' : ''}'`
    })
    if (type === 'createVoucher') {
      extract = Array.from(new Set(extract))
      if (extract.length > 20) {
        extract.length = 20
      }
      localStorage.setItem(window.GLOB.host + '_voucher_extract', JSON.stringify(extract))
    }
    voucherMap.forEach(item => {
      let count = item.count_type === 'Y'
      let curr = item.foreign_currency_type === 'Y'
      let direct = item.debit ? 'debit' : 'credit'
      subject_data.push(`'${item.uuid}','${item.subject_voucher_code || ''}','${item.voucher_lp || ''}','${item.subject_code}','${item.subject_name}','${item.subject_voucher_text || ''}',${count ? item.fcc_count || 0 : 0},${count ? item.net_unitprice || 0 : 0},'${item.unit}',${item.debit || item.credit},'${direct}','${curr ? item.exratecode : '01010001'}','${curr ? item.exratename : 'CNY'}',${curr ? item.unitratio || 0 : 0},'${item.sup_accounting}',${item.debit ? 1 : -1},${curr ? item.foreign_amount || 0 : 0},1,'${item.local_currency || ''}'`)
      subject_data.push(`'${item.uuid}','${item.subject_voucher_code || ''}','${item.voucher_lp || ''}','${item.subject_code}','${item.subject_name}','${item.subject_voucher_text || ''}',${count ? item.fcc_count || 0 : 0},${count ? item.net_unitprice || 0 : 0},'${item.unit}',${item.debit || item.credit},'${direct}','${curr ? item.exratecode : '01010001'}','${curr ? item.exratename : 'CNY'}',${curr ? item.unitratio || 0 : 0},'${item.sup_accounting}',${item.debit ? 1 : -1},${curr ? item.foreign_amount || 0 : 0},1,'${item.local_currency || ''}','${count ? 'Y' : ''}','${curr ? 'Y' : ''}'`)
    })
    supMap.forEach(n => {
@@ -535,17 +565,25 @@
        return
      }
      notification.success({
        top: 92,
        message: '保存成功!' + (res.voucher_char_int !== charInt ? charInt + '号凭证号已经存在,已为您更新为' + res.voucher_char_int + '号凭证。'  : ''),
        duration: 5
      })
      if (t === 'add') {
        this.setState({
          status: 'empty',
          remark: '',
          tbdata: [],
          charInt: charInt + 1
          charInt: res.voucher_char_int + 1,
          BID: Utils.getguid()
        })
        MKEmitter.emit('cleartable', config.uuid)
      } else {
        this.setState({
          status: 'saved',
          charInt: res.voucher_char_int || charInt,
          data: fromJS(list).toJS()
        })
      }
@@ -599,6 +637,10 @@
  }
  triggerAttach = () => {
  }
  render() {
    const { type, status, loading, config, typeOptions, charType, charInt, data, vouDate, username, remark, remarkVisible, attachments, title } = this.state
@@ -633,7 +675,7 @@
            </div>
            <div className="voucher-affix">
              附单据 <InputNumber precision={0} value={attachments || 0} autoComplete="off" onChange={this.changeAttach}/> 张
              <Button type="link" className="" onClick={this.triggerprint}>附件</Button>
              <Button type="link" className="" onClick={this.triggerAttach}>附件</Button>
              <Button type="link" className="" onClick={this.triggerprint}>备注</Button>
            </div>
          </div> : null}