CollectionBankDetail.vue 13.6 KB
Newer Older
lanbaoming's avatar
lanbaoming committed
1 2
<template>
  <div class="app-container">
lanbaoming's avatar
lanbaoming committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
    <el-descriptions :column="4">
      <el-descriptions-item :label="$t('收款单编号')">{{
        form.receiptNo
      }}</el-descriptions-item>
      <el-descriptions-item :label="$t('客户')">{{
        form.customerName
      }}</el-descriptions-item>
      <el-descriptions-item :label="$t('创建时间')">
        <template>
          <span>{{ parseTime(form.createTime, "{y}-{m}-{d}") }}</span>
        </template></el-descriptions-item
      >
      <el-descriptions-item :label="$t('业务员')">{{
        form.salesmanName
      }}</el-descriptions-item>
      <el-descriptions-item v-if="reason" :label="$t('申请理由')">{{
        reason
      }}</el-descriptions-item>
    </el-descriptions>
lanbaoming's avatar
lanbaoming committed
22 23
    <div class="btn">
      <el-table ref="multipleTable" :data="detailed" border row-key="id">
lanbaoming's avatar
lanbaoming committed
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
        <!-- <el-table-column :label="$t('序号')" type="index" align="center" width="50"></el-table-column> -->
        <el-table-column
          :label="$t('收款账户')"
          align="center"
          prop="accountName"
        />
        <el-table-column :label="$t('实收金额')" align="center" prop="amount" />
        <el-table-column :label="$t('实收币种')" align="center" prop="marks">
          <template slot-scope="scope">
            {{ getCurrencyLabel(scope.row.currencyId) }}
          </template>
        </el-table-column>
        <el-table-column :label="$t('汇率')" align="center" prop="rate" />
        <el-table-column align="center" prop="writeOffAmount">
          <template #header>
            {{ $t("兑核销基准金额") }}{{ getCurrencyLabel(showCurrencyId) }}
          </template>
        </el-table-column>
        <el-table-column
          :label="$t('实收日期')"
          align="center"
          prop="amountDate"
        >
        </el-table-column>
        <el-table-column :label="$t('水单号')" align="center" prop="billNo" />
        <el-table-column :label="$t('水单附件')" align="center" prop="attr">
          <template slot-scope="scope" v-if="scope.row.attr">
            <div v-for="(v, i) in scope.row.attr" :key="i">
              <el-link :href="v.url" type="primary" target="_blank">{{
                v.name
              }}</el-link>
            </div>
          </template>
        </el-table-column>
      </el-table>
lanbaoming's avatar
lanbaoming committed
59
    </div>
lanbaoming's avatar
lanbaoming committed
60 61 62 63 64 65 66 67 68

    <el-card class="card">
      <div class="btn">
        <!--链接到收款单详情页面 lanbm 2024-05-24 add-->
        <receiptDetail :receiptId="receiptId"></receiptDetail>
      </div>
    </el-card>

    <!--
lanbaoming's avatar
lanbaoming committed
69 70 71 72 73 74 75 76 77 78 79
    <div class="btn">
      <el-button
        size="mini"
        type="primary"
        @click="$router.push('/financial/receiptDetail?id=' + receiptId)"
        >{{ $t('查看收款单')}}</el-button>
        <el-button
          size="mini"
          type="primary"
          @click="openAddDialog=true"
          >{{ $t('查看银行实收明细')}}</el-button>
lanbaoming's avatar
lanbaoming committed
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
    </div>-->
    <el-dialog
      v-if="openAddDialog"
      :visible.sync="openAddDialog"
      :title="this.$t('银行实收明细详情')"
      width="50%"
      append-to-body
    >
      <div style="padding: 0 24px">
        <el-form ref="addForm" :model="addForm" label-width="250px">
          <el-form-item :label="$t('收款单号') + ':'">{{
            form.receiptNo
          }}</el-form-item>
          <el-form-item :label="$t('剩余应收金额') + ':'">
            <template>
              <div v-if="surplusData.length == 0">0</div>
              <div v-else>
                <div v-for="(amount, currency) in surplusData" :key="currency">
                  <span v-if="amount">
                    {{ amount }}{{ getCurrencyLabel(currency) }}</span
                  >
                </div>
lanbaoming's avatar
lanbaoming committed
102
              </div>
lanbaoming's avatar
lanbaoming committed
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
            </template>
          </el-form-item>
          <el-form-item :label="$t('收款账户') + ':'" prop="accountNo">
            <span>{{ addForm.accountNo }}</span>
          </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">
              <el-select
                v-model="addForm.currencyId"
                :placeholder="$t('请选择')"
                :disabled="true"
                @change="(val) => currencyIdChange(val)"
lanbaoming's avatar
lanbaoming committed
121
              >
lanbaoming's avatar
lanbaoming committed
122 123 124 125 126 127 128 129 130 131 132
                <el-option
                  v-for="item in currencyList"
                  :key="item.id"
                  :label="$i18n.locale == 'zh_CN' ? item.titleZh : item.titleEn"
                  :value="item.id"
                />
              </el-select>
              <!-- <dict-selector v-if="!isView" :type="DICT_TYPE.BOX_SHIPPING_PRICE_UNIT" v-model="addForm.currencyId" @change="val => currencyIdChange(val)"/> -->
              <!-- <span v-else>{{ addForm.currencyId }}</span> -->
              <!-- <dict-tag v-else :type="DICT_TYPE.BOX_SHIPPING_PRICE_UNIT" :value="addForm.currencyId" /> -->
            </el-form-item>
lanbaoming's avatar
lanbaoming committed
133
          </div>
lanbaoming's avatar
lanbaoming committed
134 135 136 137 138 139 140 141 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
          <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>
            <span>{{
              addForm.writeOffAmount
                ? parseFloat(addForm.writeOffAmount).toFixed(6)
                : ""
            }}</span>
          </el-form-item>
          <el-form-item :label="$t('水单附件') + ':'" prop="attr">
            <div v-if="addForm.attr.length > 0">
              <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>
            <div v-else>{{ $t("") }}</div>
          </el-form-item>
          <el-form-item :label="$t('水单号') + ':'" prop="billNo">
            <span>{{ addForm.billNo }}</span>
          </el-form-item>
        </el-form>
      </div>
    </el-dialog>
lanbaoming's avatar
lanbaoming committed
177 178 179 180
  </div>
</template>

<script>
lanbaoming's avatar
lanbaoming committed
181
import { getCustomer } from "@/api/ecw/customer";
lanbaoming's avatar
lanbaoming committed
182 183 184 185 186
import {
  getReceiptInfoByIds,
  getReceivableItem,
  getInvoicingItem,
  getReceiptAccountList,
lanbaoming's avatar
lanbaoming committed
187
  getReceiptApprove,
lanbaoming's avatar
lanbaoming committed
188 189
} from "@/api/ecw/financial";
import { getCurrencyPage } from "@/api/ecw/currency";
lanbaoming's avatar
lanbaoming committed
190 191
import NP from "number-precision";
import receiptDetail from "@/views/ecw/financial/receiptDetail2";
lanbaoming's avatar
lanbaoming committed
192 193

export default {
lanbaoming's avatar
lanbaoming committed
194 195 196 197 198
  props: {
    id: [String, Number],
  },
  components: {
    receiptDetail,
lanbaoming's avatar
lanbaoming committed
199 200 201 202
  },
  data() {
    return {
      form: {},
lanbaoming's avatar
lanbaoming committed
203 204
      currencyList: [],
      list: [],
lanbaoming's avatar
lanbaoming committed
205
      detailed: [],
lanbaoming's avatar
lanbaoming committed
206 207 208 209
      detatilData: [],
      showCurrencyId: 0,
      surplusData: [],
      openAddDialog: false,
lanbaoming's avatar
lanbaoming committed
210
      collectionAmount: [],
lanbaoming's avatar
lanbaoming committed
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
      addForm: {},
      receiptId: 0,
      receiptItemId: 0,
      reason: "",
      receiptAccountList: [],
    };
  },
  watch: {
    id() {
      this.getCurrencyData();
    },
    currencyList() {
      this.getData();
    },
    form() {
      this.getList();
      this.getListData();
    },
lanbaoming's avatar
lanbaoming committed
229
  },
lanbaoming's avatar
lanbaoming committed
230 231 232 233 234 235 236 237 238 239
  computed: {
    businessKeyToComponent() {
      var page = {
        component: () => import("@/views/ecw/financial/receiptDetail"),
        id: this.receiptId,
        name: "receiptDetail",
        path: "receiptDetail",
      };
      return page;
    },
lanbaoming's avatar
lanbaoming committed
240 241
  },
  created() {
lanbaoming's avatar
lanbaoming committed
242 243 244
    if (this.id) {
      this.getCurrencyData();
    }
lanbaoming's avatar
lanbaoming committed
245 246
  },
  methods: {
lanbaoming's avatar
lanbaoming committed
247 248 249 250 251 252 253 254 255
    getData() {
      getReceiptApprove(this.id).then((res) => {
        if (res.data.receiptId) {
          this.receiptId = res.data.receiptId;
          this.receiptItemId = res.data.receiptItemId;
          this.reason = res.data.reason;
          this.getReceiptInfo();
        }
      });
lanbaoming's avatar
lanbaoming committed
256 257
    },
    // 获取汇率
lanbaoming's avatar
lanbaoming committed
258 259 260 261
    getCurrencyData() {
      getCurrencyPage(this.params).then((res) => {
        this.currencyList = res.data.list;
      });
lanbaoming's avatar
lanbaoming committed
262
    },
lanbaoming's avatar
lanbaoming committed
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280
    getList() {
      getReceivableItem({ id: this.receiptId }).then((res) => {
        this.detatilData = res.data.map((v) => ({
          ...v,
          amountDate: this.parseTime(v.amountDate, "{y}-{m}-{d}"),
          accountNo: +v.accountNo,
          rate: parseFloat(v.rate).toFixed(6),
          attr: v.attr
            ? v.attr
                .split(",")
                .map((t) => ({ name: t.slice(t.lastIndexOf("/") + 1), url: t }))
            : [],
        }));
        this.addForm = this.detatilData.find((v) => v.id == this.receiptItemId);
        this.detailed = [];
        this.detailed.push(this.addForm);
        this.getCollectionData();
      });
lanbaoming's avatar
lanbaoming committed
281
    },
lanbaoming's avatar
lanbaoming committed
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300
    getReceiptInfo() {
      getReceiptInfoByIds({ id: this.receiptId }).then((res) => {
        this.form = res.data;
        getCustomer(this.form.customerId).then((res) => {
          this.form.customerName = res?.data?.name;
        });
      });
    },
    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 "";
    },
    getListData() {
      getInvoicingItem({ id: this.receiptId }).then((res) => {
        this.list = [...res.data];
lanbaoming's avatar
lanbaoming committed
301
        let fieldList = [];
lanbaoming's avatar
lanbaoming committed
302 303 304 305
        let groupList = [];
        this.list.map((element) => {
          if (fieldList.indexOf(element["currencyId"]) === -1) {
            fieldList.push(element["currencyId"]);
lanbaoming's avatar
lanbaoming committed
306
          }
lanbaoming's avatar
lanbaoming committed
307 308 309 310 311
        });
        for (let i = 0; i < fieldList.length; i++) {
          let arr = this.list.filter((element) => {
            return element["currencyId"] === fieldList[i];
          });
lanbaoming's avatar
lanbaoming committed
312
          groupList.push({
lanbaoming's avatar
lanbaoming committed
313 314 315
            currencyId: arr[0].currencyId,
            list: arr,
          });
lanbaoming's avatar
lanbaoming committed
316
        }
lanbaoming's avatar
lanbaoming committed
317 318 319 320
        this.showCurrencyId = 1;
        if (groupList.length === 1)
          this.showCurrencyId = groupList[0].currencyId;
      });
lanbaoming's avatar
lanbaoming committed
321
    },
lanbaoming's avatar
lanbaoming committed
322 323 324
    getCollectionData() {
      getReceiptAccountList({ id: this.receiptId }).then((res) => {
        var n;
lanbaoming's avatar
lanbaoming committed
325
        // 收款总计
lanbaoming's avatar
lanbaoming committed
326 327 328 329 330 331 332 333 334 335 336 337 338
        var amountList = [];
        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
            );
            n = res.data.find((v) => v.currencyId == item.id);
            n && (n.discountTotal = discountNaira);
lanbaoming's avatar
lanbaoming committed
339
          }
lanbaoming's avatar
lanbaoming committed
340 341 342
          var dollarList = res.data.filter(
            (v) => v.collectionCurrencyId == item.id
          );
lanbaoming's avatar
lanbaoming committed
343

lanbaoming's avatar
lanbaoming committed
344 345 346 347 348 349 350 351 352 353 354 355 356 357
          if (dollarList.length > 0) {
            var dollar = dollarList
              .reduce(
                (total, currentValue) =>
                  NP.plus(total, currentValue.collectionAmount),
                0
              )
              .toFixed(2);
            amountList.push({
              currencyId: item.id,
              currencyNameEn: item.titleEn,
              currencyNameZh: item.titleZh,
              amount: dollar,
            });
lanbaoming's avatar
lanbaoming committed
358
          }
lanbaoming's avatar
lanbaoming committed
359 360 361 362 363
        });
        this.$set(this, "collectionAmount", amountList);
        this.handleAddReceiptItem();
      });
    },
lanbaoming's avatar
lanbaoming committed
364 365
    handleAddReceiptItem() {
      // 已收
lanbaoming's avatar
lanbaoming committed
366 367 368 369 370 371 372 373 374 375
      let recepted = [];
      this.detatilData.forEach((item) => {
        if (!recepted[item.currencyId]) {
          recepted[item.currencyId] = item.amount;
        } else
          recepted[item.currencyId] = NP.plus(
            recepted[item.currencyId],
            item.amount
          );
      });
lanbaoming's avatar
lanbaoming committed
376
      // 应收
lanbaoming's avatar
lanbaoming committed
377
      let collom = [];
lanbaoming's avatar
lanbaoming committed
378
      // 从期望收费金额中提取应收币种和金额
lanbaoming's avatar
lanbaoming committed
379 380 381 382 383 384 385 386 387 388 389 390 391
      this.collectionAmount.forEach((item) => {
        collom[item.currencyId] = item.amount;
      });
      console.log(recepted);
      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;
lanbaoming's avatar
lanbaoming committed
392
          }
lanbaoming's avatar
lanbaoming committed
393 394 395 396 397 398 399 400 401 402 403 404 405
        }
      });
      console.log(collom);
      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;
lanbaoming's avatar
lanbaoming committed
406 407
            }
          }
lanbaoming's avatar
lanbaoming committed
408 409 410
        }
      });
      console.log(this.surplusData);
lanbaoming's avatar
lanbaoming committed
411
    },
lanbaoming's avatar
lanbaoming committed
412 413
  },
};
lanbaoming's avatar
lanbaoming committed
414 415 416
</script>

<style scoped lang="scss">
lanbaoming's avatar
lanbaoming committed
417 418 419 420 421 422 423
.btn {
  margin-top: 20px;
}
.app-container {
  ::v-deep .el-descriptions-item__label {
    font-size: 16px;
    font-weight: 600;
lanbaoming's avatar
lanbaoming committed
424
  }
lanbaoming's avatar
lanbaoming committed
425 426 427
  ::v-deep .el-descriptions-item__content {
    font-size: 16px;
    font-weight: 600;
lanbaoming's avatar
lanbaoming committed
428
  }
lanbaoming's avatar
lanbaoming committed
429
}
lanbaoming's avatar
lanbaoming committed
430
</style>