paymentExamine.vue 10.1 KB
Newer Older
吴滔's avatar
吴滔 committed
1 2 3
<template>
  <div class="app-container examine-wrap">
    <el-card>
吴滔's avatar
吴滔 committed
4
      <div slot="header" class="card-title">{{ $t('审核请款单') }}</div>
吴滔's avatar
吴滔 committed
5
        <el-descriptions :column="3" class="card" border>
吴滔's avatar
吴滔 committed
6
          <el-descriptions-item :label="$t('供应商')">
吴滔's avatar
吴滔 committed
7 8
            {{ detail.supplierName }}
          </el-descriptions-item>
吴滔's avatar
吴滔 committed
9
          <el-descriptions-item :label="$t('部门')">
吴滔's avatar
吴滔 committed
10 11
            {{ findDepartmentName(detail.departmentId) }}
          </el-descriptions-item>
吴滔's avatar
吴滔 committed
12
          <el-descriptions-item :label="$t('业务员')">
吴滔's avatar
吴滔 committed
13 14
            {{ detail.salesmanName }}
          </el-descriptions-item>
吴滔's avatar
吴滔 committed
15
          <el-descriptions-item :label="$t('申请日期')">
吴滔's avatar
吴滔 committed
16 17
            {{ detail.applicationAt }}
          </el-descriptions-item>
吴滔's avatar
吴滔 committed
18
          <el-descriptions-item :label="$t('供应商银行账号')" style="width: 50%">
我在何方's avatar
我在何方 committed
19
            {{ detail.supplierBankAccountName+'('+detail.supplierBankAccount+')' }} 
吴滔's avatar
吴滔 committed
20 21 22
          </el-descriptions-item>
        </el-descriptions>
        <el-descriptions :column="3" class="card" border>
吴滔's avatar
吴滔 committed
23
          <el-descriptions-item :label="$t('最后付款日期')">
吴滔's avatar
吴滔 committed
24 25
            {{ detail.latestPayAt }}
          </el-descriptions-item>
吴滔's avatar
吴滔 committed
26
          <el-descriptions-item :label="$t('结算方式')">
吴滔's avatar
吴滔 committed
27 28 29 30 31 32
            <!-- {{ detail.settlementType }} -->
            <dict-tag :type="DICT_TYPE.CUSTOMER_BALANCE" :value="detail.settlementType"></dict-tag>
          </el-descriptions-item>
        </el-descriptions>
    </el-card>
    <el-card class="card">
吴滔's avatar
吴滔 committed
33
      <div slot="header" class="card-title">{{ $t('费用信息') }}</div>
吴滔's avatar
吴滔 committed
34
      <el-table v-loading="loadings" :data="list" border :show-summary="!!list.length" :summary-method="getSummaries">
吴滔's avatar
吴滔 committed
35 36
        <el-table-column :label="$t('自编号')" align="center" prop="payableNo" />
        <el-table-column :label="$t('费用类型')" align="center" prop="feeType">
吴滔's avatar
吴滔 committed
37 38 39 40 41 42 43
          <template slot-scope="scope">
            <dict-tag
              :type="DICT_TYPE.FEE_TYPE"
              :value="scope.row.feeType"
            ></dict-tag>
          </template>
        </el-table-column>
吴滔's avatar
吴滔 committed
44
        <el-table-column :label="$t('发票号码')" align="center" prop="invoiceNumber">
吴滔's avatar
吴滔 committed
45 46 47 48
          <!-- <template slot-scope="scope">
            <el-input v-model="scope.row.invoiceNumber"></el-input>
          </template> -->
        </el-table-column>
吴滔's avatar
吴滔 committed
49 50
        <el-table-column :label="$t('应付金额')" align="center" prop="totalAmount" />
        <el-table-column :label="$t('币种')" align="center" prop="currencyId">
吴滔's avatar
吴滔 committed
51
          <template slot-scope="scope">
我在何方's avatar
我在何方 committed
52 53
			  {{getCurrencyLabel(scope.row.currencyId)}}
            <!-- <dict-tag :type="DICT_TYPE.BOX_SHIPPING_PRICE_UNIT" :value="scope.row.currencyId" /> -->
吴滔's avatar
吴滔 committed
54 55
          </template>
        </el-table-column>
吴滔's avatar
吴滔 committed
56
        <el-table-column :label="$t('汇率')" align="center" prop="exchangeRate">
吴滔's avatar
吴滔 committed
57 58 59 60
          <!-- <template slot-scope="scope">
            <el-input v-model="scope.row.exchangeRate"></el-input>
          </template> -->
        </el-table-column>
我在何方's avatar
我在何方 committed
61
        <el-table-column :label="$t('税率')+'%'" align="center" prop="taxRate" >
吴滔's avatar
吴滔 committed
62 63 64 65
          <!-- <template slot-scope="scope">
            <el-input v-model="scope.row.taxRate"></el-input>
          </template> -->
        </el-table-column>
我在何方's avatar
我在何方 committed
66
        <el-table-column :label="$t('价税合计')+'(RMB)'" align="center" prop="total" />
吴滔's avatar
吴滔 committed
67 68 69
      </el-table>

      <el-descriptions :column="1" class="card" border>
吴滔's avatar
吴滔 committed
70
        <el-descriptions-item :label="$t('账单号')">
吴滔's avatar
吴滔 committed
71 72
          {{ detail.accountNumber }}
        </el-descriptions-item>
吴滔's avatar
吴滔 committed
73 74
        <el-descriptions-item :label="$t('发票')">
          {{ detail.invoiceStatus == 0 ? $t('未开票') : $t('已开票') }}
吴滔's avatar
吴滔 committed
75
        </el-descriptions-item>
吴滔's avatar
吴滔 committed
76
        <el-descriptions-item :label="$t('审核备注')">
吴滔's avatar
吴滔 committed
77 78 79 80 81 82
          <el-input type="textarea" :rows="2" v-model="notes">
          </el-input>
        </el-descriptions-item>
      </el-descriptions>
    </el-card>
    <div slot="footer" style="margin: 20px 0">
吴滔's avatar
吴滔 committed
83 84
      <el-button type="primary" @click="examine('y')">{{ $t('审核通过') }}</el-button>
      <el-button type="danger" @click="examine('n')">{{ $t('审核驳回') }}</el-button>
吴滔's avatar
吴滔 committed
85 86 87 88 89 90 91
    </div>
  </div>
</template>

<script>
import { getBankAccountPage } from "@/api/ecw/bankAccount";
import { listSimpleDepts } from "@/api/system/dept";
我在何方's avatar
我在何方 committed
92
import { getCurrencyPage } from "@/api/ecw/currency";
吴滔's avatar
吴滔 committed
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
import { getPaymentInfoByIds, getPaymentItem, paymentVerify } from "@/api/ecw/financial"
export default {
  name: "CreatPayment",
  components: {
    // CustomerSelector
  },
  data() {
    return {
      id: 0,
      loadings: false,
      detail: {},
      list: [],
      bankData: [],
      params: {
        page: 1,
        rows: 20,
      },
我在何方's avatar
我在何方 committed
110
	  currencyList:[],
吴滔's avatar
吴滔 committed
111 112 113 114 115 116
      deptData: [],
      deptArr: [],
      notes: ''
    };
  },
  created() {
我在何方's avatar
我在何方 committed
117
	  getCurrencyPage(this.params).then(res => this.currencyList = res.data.list)
吴滔's avatar
吴滔 committed
118
    let that = this;
我在何方's avatar
我在何方 committed
119

吴滔's avatar
吴滔 committed
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
    if (that.$route.query.id && that.$route.query.id !== '0') {
      this.id = this.$route.query.id;
      getPaymentInfoByIds({ id: this.id }).then(res => {
        this.detail = {
          ...res.data,
          latestPayAt: this.parseTime(res.data.latestPayAt, '{y}-{m}-{d}'),
          applicationAt: this.parseTime(res.data.applicationAt, '{y}-{m}-{d}'),
          supplierBankAccount: Number(res.data.supplierBankAccount),
          invoiceStatus: String(res.data.invoiceStatus),
        }
      })
      getPaymentItem({ id: this.id }).then(res => {
        this.list = [...res.data]
      })
    }
    getBankAccountPage(that.params).then((res) => (that.bankData = res.data.list));
    listSimpleDepts().then((res) => {
      res.data.forEach((item) => {
        if (item.parentId == 0) {
          that.deptArr.push(item);
        } else {
          that.deptData.push(item);
        }
      });

      that.deptData.forEach((value) => {
        var dept = that.deptArr.filter((itt) => itt.id == value.parentId);
        if (dept.length > 0) {
          value.name = dept[0].name + " | " + value.name;
        }
      });
    });
  },
  methods: {
我在何方's avatar
我在何方 committed
154 155
	  getCurrencyLabel(id){
	    var label = this.currencyList.filter(item=>item.id == id)
我在何方's avatar
我在何方 committed
156
	    if(label.length>0) return this.$i18n.locale=='zh_CN'?label[0].titleZh:label[0].titleEn
我在何方's avatar
我在何方 committed
157 158
	    return ''
	  },
吴滔's avatar
吴滔 committed
159 160 161 162
    getSummaries(param) {
      const { columns, data } = param;
      const sums = new Array(columns.length).map(v => '');
      const index = sums.length - 1
吴滔's avatar
吴滔 committed
163
      sums[index - 1] = this.$t('价税合计大写')
吴滔's avatar
吴滔 committed
164 165 166 167 168 169 170 171 172 173 174 175 176
      const t = data.map(v => v.total).reduce((prev, curr) => {
        return prev + curr;
      }, 0)
      sums[index] = this.convertCurrency(t)
      return sums;
    },
    examine(status) {
      const params = {
        notes: this.notes,
        paymentId: this.detail.id,
        verifyStatus: status
      }
      paymentVerify(params).then(res => {
吴滔's avatar
吴滔 committed
177
        this.$modal.msgSuccess(this.$t('操作成功'));
吴滔's avatar
吴滔 committed
178 179 180 181 182
        this.$router.back();
      })
    },
    convertCurrency(money) {
      //汉字的数字
Marcus's avatar
Marcus committed
183
      var cnNums = new Array('', this.$t(''), this.$t(''), this.$t(''), this.$t(''), this.$t(''), this.$t(''), this.$t(''), this.$t(''), '');
吴滔's avatar
吴滔 committed
184
      //基本单位
Marcus's avatar
Marcus committed
185
      var cnIntRadice = new Array('', this.$t(''), this.$t(''), '');
吴滔's avatar
吴滔 committed
186
      //对应整数部分扩展单位
Marcus's avatar
Marcus committed
187
      var cnIntUnits = new Array('', this.$t(''), this.$t('亿'), '');
吴滔's avatar
吴滔 committed
188
      //对应小数部分单位
Marcus's avatar
Marcus committed
189
      var cnDecUnits = new Array('', this.$t(''), this.$t(''), '');
吴滔's avatar
吴滔 committed
190
      //整数金额时后面跟的字符
Marcus's avatar
Marcus committed
191
      var cnInteger = this.$t('');
吴滔's avatar
吴滔 committed
192
      //整型完以后的单位
Marcus's avatar
Marcus committed
193
      var cnIntLast = this.$t('');
吴滔's avatar
吴滔 committed
194 195 196 197 198 199 200 201 202 203
      //最大处理的数字
      var maxNum = 999999999999999.9999;
      //金额整数部分
      var integerNum;
      //金额小数部分
      var decimalNum;
      //输出的中文金额字符串
      var chineseStr = '';
      //分离金额后用的数组,预定义
      var parts;
我在何方's avatar
我在何方 committed
204
      // 传入的参数为空情况
吴滔's avatar
吴滔 committed
205 206 207 208 209 210 211
      if(money === '') {
        return '';
      }
      money = parseFloat(money)
      if(money >= maxNum){
        return ''
      }
我在何方's avatar
我在何方 committed
212
      // 传入的参数为0情况
吴滔's avatar
吴滔 committed
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 242 243 244 245 246
      if (money === 0) {
        chineseStr = cnNums[0] + cnIntLast + cnInteger;
        return chineseStr
      }
      // 转为字符串
      money = money.toString();
      // indexOf 检测某字符在字符串中首次出现的位置 返回索引值(从0 开始) -1 代表无
      if (money.indexOf('.') == -1) {
        integerNum = money;
        decimalNum = ''
      }else{
        parts = money.split('.');
        integerNum = parts[0];
        decimalNum = parts[1].substr(0,4);
      }
      //转换整数部分
      if(parseInt(integerNum,10) > 0){
        let zeroCount  = 0;
        let IntLen = integerNum.length
        for(let i = 0; i < IntLen; i++){
          let n = integerNum.substr(i,1);
          let p = IntLen - i - 1;
          let q = p / 4;
          let m = p % 4;
          if( n == '0'){
            zeroCount ++ ;
          }else{
            if(zeroCount > 0){
                chineseStr += cnNums[0]
            }
            zeroCount = 0;
            chineseStr += cnNums[parseInt(n)] + cnIntRadice[m];
          }
          if(m == 0 && zeroCount < 4){
我在何方's avatar
我在何方 committed
247
            chineseStr += cnIntUnits[q];
吴滔's avatar
吴滔 committed
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297
          }
        }
        // 最后+ 元
        chineseStr += cnIntLast;
      }
      // 转换小数部分
      if(decimalNum != ''){
        let decLen = decimalNum.length;
        for(let i = 0; i <decLen; i++){
          let n = decimalNum.substr(i,1);
          if(n != '0'){
            chineseStr += cnNums[Number(n)] + cnDecUnits[i]
          }
        }
      }
      if(chineseStr == ''){
        chineseStr += cnNums[0] + cnIntLast + cnInteger;
      }else if(decimalNum == ''){
        chineseStr += cnInteger;
      }
      return chineseStr
    },
    findDepartmentName(val) {
      return this.deptData.find(v => v.id == val) ? this.deptData.find(v => v.id == val).name : ''
    },
    findBank(val) {
      const t = this.bankData.find(v => v.id == val)
      return t ? t.baAccountName + '(' + t.baAccountNum + ')' : ''
    }
  },
};
</script>

<style lang="scss" scoped>
.examine-wrap {
  ::v-deep .is-bordered-label {
    width: 200px;
  }
}
.card {
  margin-top: 20px;
}
.dialog-footer {
  padding: 40px;
}
.card-title {
  font-size: 18px;
  font-weight: bold;
}
</style>