bankDetail.vue 8.58 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
<template>
  <div class="app-container">
    <el-card>
      <div slot="header" class="card-title">{{ $t('银行实收明细详情') }}</div>
          <el-form ref="addForm" :data="addForm" label-width="250px">
            <el-form-item :label="$t('收款单号')">{{ form.receiptNo }}</el-form-item>
            <el-form-item :label="$t('剩余应收金额')">
              <template v-if="surplusData.length==0"> 0</template>
              <div v-if="surplusData.length>0">
                <div v-for="(amount, currency) in surplusData" :key="currency">
                   <span v-if="amount"> {{amount}}{{getCurrencyLabel(currency)}}</span>
                </div>
              </div>
            </el-form-item>
            <el-form-item :label="$t('收款账户')" prop="accountNo">
16
              <span>{{ addForm.accountNo}}{{'('+addForm.accountName+')' }}</span>
17 18 19 20 21 22 23 24 25
            </el-form-item>
            <el-form-item :label="$t('实收日期')" prop="amountDate">
              <span>{{ addForm.amountDate }}</span>
            </el-form-item>
            <div style="display: flex;">
              <el-form-item :label="$t('实收')" prop="amount">
                <span>{{ addForm.amount }}</span>
              </el-form-item>
              <el-form-item label-width="0px" prop="currencyId">
26
                <span>({{getCurrencyLabel(addForm.currencyId)}})</span>
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
              </el-form-item>
            </div>
            <el-form-item
              v-if="showCurrencyId != addForm.currencyId"
              prop="rate"
            >
              <template slot="label">
              <span :title="$t('实收币种与核销基准币种一样时,无需填写汇率,不一样需要填写汇率')">{{ $t('兑核销基准币种汇率') }}{{getCurrencyLabel(showCurrencyId)}}</span>
              </template>
              <span>{{ addForm.rate}}</span>
            </el-form-item>
            <el-form-item v-if="showCurrencyId != addForm.currencyId" >
              <template slot="label">
                {{ $t('兑核销基准币种金额') }}{{getCurrencyLabel(showCurrencyId)}}
              </template>
我在何方's avatar
我在何方 committed
42
              <span>{{ addForm.writeOffAmount?parseFloat(addForm.writeOffAmount).toFixed(2):'' }}</span>
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
            </el-form-item>
            <el-form-item :label="$t('水单附件')" prop="attr">
              <div>
                <div v-for="(v, i) in addForm.attr" :key="i"><el-link :href="v.url" type="primary" target="_blank">{{ v.name }}</el-link></div>
              </div>
            </el-form-item>
            <el-form-item :label="$t('水单号')" prop="billNo">
              <span>{{ addForm.billNo }}</span>
            </el-form-item>
          </el-form>
    </el-card>
    <div slot="header" class="bpm-title">{{ $t('审核流程') }}</div>
     <work-flow  xmlkey="merge_order" v-model="selectedUsers"></work-flow>

     <div slot="footer" style="margin: 20px 0">
       <el-button type="primary" @click="submitForm(0)">{{$t('提交审核')}}</el-button>
       <el-button type="primary"  @click="$store.dispatch('tagsView/delCurrentView')">{{ $t('关闭') }}</el-button>
     </div>
  </div>
</template>

<script>
我在何方's avatar
我在何方 committed
65
  import { getReceivableItem ,getInvoicingItem,getReceiptAccountList,getReceiptInfoByIds,financeReceiptItemWriteOff} from "@/api/ecw/financial";
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
  import { getCurrencyPage } from "@/api/ecw/currency";
  import WorkFlow from '@/components/WorkFlow/'
  import NP from 'number-precision'

  export default {
    components: {
      WorkFlow
    },
    data() {
      return {
        addForm:{},
        id:0,
        detailed:[],
         currencyList: [],
        surplusData:[],
        receiptAccountList:[],
        selectedUsers:[],
        list:[],
        params: {
          page: 1,
          rows: 20,
        },
        bankId:0,
        form:{}
      }
    },
    async created() {
        if (this.$route.query.id) {
          this.id = this.$route.query.id;
        }
        if (this.$route.query.bankId) {
          this.bankId = this.$route.query.bankId;
        }
        await getInvoicingItem({ id: this.id }).then(res => {
          this.list = [...res.data]
        })
        await getReceiptAccountList({ id: this.id }).then(res => {
            this.receiptAccountList = [...res.data]
          })
        await getCurrencyPage(this.params).then(res => this.currencyList = res.data.list)
        await this.getList()
        await getReceiptInfoByIds({ id: this.id }).then(res => {
          this.form = res.data
          })
    },
    methods:{
      getList() {
        getReceivableItem({ id: this.id }).then(res => {
          this.detailed = res.data.map(v => ({
            ...v,
            amountDate: this.parseTime(v.amountDate, '{y}-{m}-{d}'),
我在何方's avatar
我在何方 committed
117
            rate:parseFloat(v.rate).toFixed(2),
118 119
            attr: v.attr ? v.attr.split(',').map(t => ({ name: t.slice(t.lastIndexOf('/') + 1), url: t })) : []
          }))
120
          console.log(this.detailed)
121
          this.addForm = this.detailed.find((itt) => itt.id == this.bankId);
122
          console.log(this.addForm)
123 124 125 126 127 128 129 130
          this.handleAddReceiptItem()
        })
      },
      getCurrencyLabel(id){
        var label = this.currencyList.filter(item=>item.id == id)
        if(label.length>0) return this.$i18n.locale=='zh_CN'?label[0].titleZh:label[0].titleEn
        return ''
      },
我在何方's avatar
我在何方 committed
131 132 133 134 135 136 137 138 139 140 141
      submitForm(){
        this.$modal
          .confirm(this.$t('您确认要提交审核吗'+'?'))
          .then(() => {
            financeReceiptItemWriteOff({receiptId:this.id,receiptNo:this.form.receiptNo,receiptItemId:this.bankId}).then(res=>{
              this.$message.success(this.$t("提交成功"));
              this.$store.dispatch('tagsView/delCurrentView')
            });
          })
          .catch(() => {});
      },
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
      handleAddReceiptItem() {
        this.surplusData = []

        // 已收
        let recepted = []
        this.detailed.forEach(item => {

            if(!recepted[item.currencyId]){
              recepted[item.currencyId] = item.amount
            }else recepted[item.currencyId] = NP.plus(recepted[item.currencyId], item.amount)
        })
        console.log('rece',recepted)

        // 应收
        let collom = []
        // 从期望收费金额中提取应收币种和金额

       this.currencyList.forEach((item,index)=>{
          var nairaListByList = this.list.filter(v => v.currencyId === item.id)
          if(nairaListByList.length>0){
            var discountNaira = nairaListByList.reduce((total, currentValue) => NP.plus(total, currentValue.discountTotal || 0), 0)
          }
          var dollarList = this.receiptAccountList.filter(v => v.collectionCurrencyId == item.id)
          if(dollarList.length>0){
            var dollar = dollarList.reduce((total, currentValue) => NP.plus(total, currentValue.collectionAmount), 0).toFixed(2)
            if(dollar){
              collom[item.id] = dollar
            }else{
              collom.push(0)
            }
          }
        })
        console.log('collom',collom)
          recepted.forEach((amount,currency)=>{
            if(amount){
              if(collom[currency]){
                if((collom[currency]-amount)!=0) this.surplusData[currency] = +parseFloat((collom[currency]-amount).toPrecision(12))
              }else{
                this.surplusData[currency] = -amount
              }
            }

          })
          collom.forEach((amount,currency)=>{
            if(amount){
              if(!this.surplusData[currency]){
                if(recepted[currency]){
                 if((amount-recepted[currency])!=0)  this.surplusData[currency] = +parseFloat((amount-recepted[currency]).toPrecision(12))
                }else{
                this.surplusData[currency] = amount
              }

              }
            }
          })
      },
    },
    computed: {
      showCurrencyId() {
        let fieldList = [];
        let groupList=[];
        this.list.map((element)=>{
          if(fieldList.indexOf(element['currencyId'])===-1){
            fieldList.push(element['currencyId'])
          }
        })
        for(let i=0;i<fieldList.length;i++){
          let arr = this.list.filter((element)=>{
            return element['currencyId']===fieldList[i];
          })
          groupList.push({
            currencyId:arr[0].currencyId,
            list:arr
          })
        }
        if (groupList.length === 1) return groupList[0].currencyId
        else return 1
      },
    }
  }
</script>

<style>
  .card {
    margin-top: 20px;
  }
  .dialog-footer {
    text-align: left;
  }
  .card-title {
    font-size: 18px;
    font-weight: bold;
  }
  .bpm-title{
    font-size: 20px;
    font-weight: bold;
    color:#666;
    margin:20px 0;
  }
</style>