creatCollection.vue 67.7 KB
Newer Older
1 2
<template>
  <div class="app-container">
3
    <el-form
吴滔's avatar
吴滔 committed
4 5 6 7
        ref="form"
        :model="form"
        label-width="120px"
        label-position="left"
我在何方's avatar
我在何方 committed
8
        :inline="true"
吴滔's avatar
吴滔 committed
9
      >
10
      <el-card>
吴滔's avatar
吴滔 committed
11 12
        <div v-if="id" slot="header" class="card-title">{{ $t('修改收款单') }}</div>
        <div v-else slot="header" class="card-title">{{ $t('新增收款单') }}</div>
我在何方's avatar
我在何方 committed
13
        <!-- <el-descriptions :column="3" border>-->
我在何方's avatar
我在何方 committed
14
          <!-- <el-descriptions-item > -->
吴滔's avatar
吴滔 committed
15
            <el-form-item
我在何方's avatar
我在何方 committed
16
              style="margin-bottom: 0;margin-top: 20px;"
吴滔's avatar
吴滔 committed
17
              prop="customerId"
我在何方's avatar
我在何方 committed
18
              :span="4"
吴滔's avatar
吴滔 committed
19
            >
我在何方's avatar
我在何方 committed
20
            <span style="margin-right:20px"><span style="color: #ff4949;">*</span>{{$t('客户')}}</span>
21
              <customer-selectorpay
我在何方's avatar
我在何方 committed
22
                ref="customer"
吴滔's avatar
吴滔 committed
23
                v-model="form.customerId"
24
                @change="customerChange"
吴滔's avatar
吴滔 committed
25 26
              />
            </el-form-item>
我在何方's avatar
我在何方 committed
27 28
  <!--        </el-descriptions-item>
          <el-descriptions-item > -->
吴滔's avatar
吴滔 committed
29
            <el-form-item
我在何方's avatar
我在何方 committed
30
              style="margin-bottom: 0;margin-top: 20px;"
吴滔's avatar
吴滔 committed
31
              prop="departmentId"
我在何方's avatar
我在何方 committed
32
              :span="4"
吴滔's avatar
吴滔 committed
33
            >
我在何方's avatar
我在何方 committed
34
            <span style="margin-right:20px"><span style="color: #ff4949;">*</span>{{$t('部门')}}:</span>
吴滔's avatar
吴滔 committed
35 36 37
              <el-select
                v-model="form.departmentId"
                style="width: 300px"
吴滔's avatar
吴滔 committed
38
                :placeholder="$t('请选择部门')"
吴滔's avatar
吴滔 committed
39 40 41 42 43 44 45 46 47 48
              >
                <el-option
                  v-for="item in deptData"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
            <el-form-item
我在何方's avatar
我在何方 committed
49
              style="margin-bottom: 0;margin-top: 20px;"
吴滔's avatar
吴滔 committed
50
              prop="salesmanId"
我在何方's avatar
我在何方 committed
51
              :span="4"
吴滔's avatar
吴滔 committed
52
            >
我在何方's avatar
我在何方 committed
53
            <span style="margin-right:20px"><span style="color: #ff4949;">*</span>{{$t('业务员')}}:</span>
我在何方's avatar
我在何方 committed
54
              <el-select v-model="form.salesmanId" filterable :placeholder="$t('请选择业务员')" @change="v => form.salesmanName = creatorData.find(t => t.id === v).nickname">
吴滔's avatar
吴滔 committed
55 56 57 58 59 60 61 62
                <el-option
                  v-for="item in creatorData"
                  :key="item.id"
                  :label="item.nickname"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
我在何方's avatar
我在何方 committed
63 64 65 66 67
          <!-- </el-descriptions-item> -->
          <!-- <el-descriptions-item > -->
<!--            <el-form-item
              :label="$t('手续费(RMB)')"
              style="margin-bottom: 0;margin-top: 20px;"
吴滔's avatar
吴滔 committed
68
              prop="feeRate"
吴滔's avatar
吴滔 committed
69
              :rules="{ required: true, trigger: ['blur', 'change'], message: $t('手续费不能为空') }"
吴滔's avatar
吴滔 committed
70 71 72
            >
              <el-input
                v-model="form.feeRate"
吴滔's avatar
吴滔 committed
73
                :placeholder="$t('请输入手续费')"
吴滔's avatar
吴滔 committed
74
              ></el-input>
我在何方's avatar
我在何方 committed
75 76 77
            </el-form-item> -->
<!--          </el-descriptions-item>
          <el-descriptions-item > -->
吴滔's avatar
吴滔 committed
78
            <el-form-item
我在何方's avatar
我在何方 committed
79
             :label="$t('备注')+':'"
我在何方's avatar
我在何方 committed
80
              style="margin-bottom: 0;margin-top: 20px;"
我在何方's avatar
我在何方 committed
81
              label-width="55px"
吴滔's avatar
吴滔 committed
82 83
              prop="remark"
            >
我在何方's avatar
我在何方 committed
84
              <el-input style="display:inline-block;" v-model="form.remark" :placeholder="$t('备注')"></el-input>
吴滔's avatar
吴滔 committed
85
            </el-form-item>
我在何方's avatar
我在何方 committed
86 87
          <!-- </el-descriptions-item> -->
        <!-- </el-descriptions> -->
88
      </el-card>
89
      <el-card class="card amountCard">
我在何方's avatar
我在何方 committed
90
        <div slot="header" class="card-title">{{ $t('应收明细') }}</div>
91 92 93 94 95 96 97
        <el-col :span="1.5">
          <el-button
            type="primary"
            plain
            icon="el-icon-plus"
            size="mini"
            @click="handleAdd"
我在何方's avatar
我在何方 committed
98
            v-hasPermi="['ecw:voucher:create:add']"
99
            style="padding: 10px; margin-bottom: 10px"
吴滔's avatar
吴滔 committed
100
            >{{ $t('添加未收客户款项') }}</el-button
101 102
          >
        </el-col>
我在何方's avatar
我在何方 committed
103
        <el-table v-loading="loadings" :data="list" border :key="isUpdate">
吴滔's avatar
吴滔 committed
104
          <el-table-column :label="$t('订单号')" align="center" prop="orderNo" />
我在何方's avatar
我在何方 committed
105
           <el-table-column :label="$t('提单号')" align="center" prop="tidanNo" />
吴滔's avatar
吴滔 committed
106 107
          <el-table-column :label="$t('唛头')" align="center" prop="marks" />
          <el-table-column :label="$t('品名')" align="center" prop="title">
108
            <template slot-scope="scope">
我在何方's avatar
我在何方 committed
109
             {{ scope.row.titleZh?(scope.row.titleZh + "(" + scope.row.titleEn + ")"): ''}}
110 111
            </template>
          </el-table-column>
吴滔's avatar
吴滔 committed
112
          <el-table-column :label="$t('箱数')" align="center" prop="num" />
113 114 115 116 117
            <el-table-column :label="$t('体积/重量')" align="center" prop="weight">
              <template slot-scope="scope">
                 {{ scope.row.volume}}/{{ scope.row.weight}}
                </template>
              </el-table-column>
吴滔's avatar
吴滔 committed
118
          <el-table-column :label="$t('收入类型')" align="center" prop="feeType">
119 120 121 122 123 124 125
            <template slot-scope="scope">
              <dict-tag
                :type="DICT_TYPE.FEE_TYPE"
                :value="scope.row.feeType"
              ></dict-tag>
            </template>
          </el-table-column>
吴滔's avatar
吴滔 committed
126
          <el-table-column :label="$t('单价金额')" align="center" prop="unitPrice">
127
            <template slot-scope="scope">
我在何方's avatar
我在何方 committed
128 129
              <span>{{ scope.row.unitPrice }}{{getCurrencyLabel(scope.row.currencyId)}}</span>
              <!-- <dict-tag :type="DICT_TYPE.BOX_SHIPPING_PRICE_UNIT" :value="scope.row.currencyId" /> -->
130 131
            </template>
          </el-table-column>
132
          <el-table-column :label="$t('税率%')" align="center" prop="totalAmount">
133
            <template slot-scope="scope">
我在何方's avatar
我在何方 committed
134
                <el-input type="text" v-model="scope.row.taxPoint" @input="changeTaxRate(scope.row,scope.$index)"></el-input>
135 136 137
            </template>
          </el-table-column>
          <el-table-column :label="$t('不含税金额')" align="center" prop="totalAmount">
138
            <template slot-scope="scope">
我在何方's avatar
我在何方 committed
139
              <span>{{ scope.row.totalAmount }}{{getCurrencyLabel(scope.row.currencyId)}}</span>
140 141
            </template>
          </el-table-column>
142
          <el-table-column :label="$t('含税金额')" align="center" prop="taxAmount">
143
            <template slot-scope="scope">
144
              <span>{{ scope.row.taxAmount }}{{getCurrencyLabel(scope.row.currencyId)}}</span>
我在何方's avatar
我在何方 committed
145

我在何方's avatar
我在何方 committed
146
              <!-- <dict-tag :type="DICT_TYPE.BOX_SHIPPING_PRICE_UNIT" :value="scope.row.currencyId" /> -->
147
            </template>
148
             </el-table-column>
吴滔's avatar
吴滔 committed
149
          <el-table-column :label="$t('优惠金额')" align="center">
吴滔's avatar
吴滔 committed
150
            <template slot-scope="scope">
我在何方's avatar
我在何方 committed
151
             <span> {{ scope.row.discountTotal ? `${scope.row.discountTotal}`:0}}</span>
我在何方's avatar
我在何方 committed
152 153
              {{getCurrencyLabel(scope.row.currencyId)}}
			  <!-- <dict-tag :type="DICT_TYPE.BOX_SHIPPING_PRICE_UNIT" :value="scope.row.currencyId" /> -->
吴滔's avatar
吴滔 committed
154
              <span v-if="scope.row.discountTotal">{{scope.row.discountRemark?('('+scope.row.discountRemark+')'): '' }}</span>
吴滔's avatar
吴滔 committed
155 156
            </template>
          </el-table-column>
吴滔's avatar
吴滔 committed
157
          <el-table-column :label="$t('操作')" align="center">
吴滔's avatar
吴滔 committed
158
            <template slot-scope="scope">
我在何方's avatar
我在何方 committed
159 160
              <el-button v-if="scope.row.type !== 'total'" type="text" v-hasPermi="['ecw:voucher:create:editdiscount']" @click="addDiscount(scope.row, scope.$index)">{{ scope.row.discountTotal ? $t('修改优惠') : $t('新增优惠') }}</el-button>
              <el-button v-if="scope.row.type !== 'total'" type="text" v-hasPermi="['ecw:voucher:create:deldiscount']" @click="deleteListRow(scope.$index)">{{ $t('删除') }}</el-button>
吴滔's avatar
吴滔 committed
161 162
            </template>
          </el-table-column>
163
        </el-table>
我在何方's avatar
我在何方 committed
164 165
<!--        <el-descriptions :column="2" border class="card">
          <el-descriptions-item > -->
吴滔's avatar
吴滔 committed
166
            <el-form-item
我在何方's avatar
我在何方 committed
167
              style="margin-bottom: 0;margin-top: 20px;"
168
              prop="openInvoice"
吴滔's avatar
吴滔 committed
169
            >
我在何方's avatar
我在何方 committed
170
            <span style="margin-right:20px"><span style="color: #ff4949;">*</span>{{$t('是否需要开票')}}:</span>
吴滔's avatar
吴滔 committed
171
              <el-select
172
                v-model="form.openInvoice"
吴滔's avatar
吴滔 committed
173
                :placeholder="$t('请选择是否需要开票')"
吴滔's avatar
吴滔 committed
174
              >
吴滔's avatar
吴滔 committed
175 176
                <el-option :value="1" :label="$t('是')"></el-option>
                <el-option :value="0" :label="$t('否')"></el-option>
吴滔's avatar
吴滔 committed
177 178
              </el-select>
            </el-form-item>
我在何方's avatar
我在何方 committed
179 180 181 182
            <el-form-item
              :label="$t('核销基准币种')+':'"
              style="margin-bottom: 0;margin-top: 20px;"
            >
我在何方's avatar
我在何方 committed
183 184
			{{getCurrencyLabel(showCurrencyId)}}
             <!-- <dict-tag :type="DICT_TYPE.BOX_SHIPPING_PRICE_UNIT" :value="showCurrencyId" /> -->
我在何方's avatar
我在何方 committed
185 186
            </el-form-item>
<!--          </el-descriptions-item>
吴滔's avatar
吴滔 committed
187
          <el-descriptions-item :label="$t('核销基准币种')">
我在何方's avatar
我在何方 committed
188

189
          </el-descriptions-item>
我在何方's avatar
我在何方 committed
190
        </el-descriptions> -->
191
      </el-card>
192

193
      <el-card v-if="showInvoice" class="card">
吴滔's avatar
吴滔 committed
194
        <div slot="header" class="card-title">{{ $t('开票资料') }}</div>
195
        <el-descriptions :column="3" border>
吴滔's avatar
吴滔 committed
196
          <el-descriptions-item :label="$t('发票抬头')">
吴滔's avatar
吴滔 committed
197 198 199 200
            <el-form-item
              label=""
              label-width="0"
              style="margin-bottom: 0"
201
              prop="invoice"
吴滔's avatar
吴滔 committed
202
              :rules="{ required: true, trigger: ['blur', 'change'], message: $t('请输入发票抬头') }"
吴滔's avatar
吴滔 committed
203
            >
204 205 206
              <el-input v-model="form.invoice"></el-input>
            </el-form-item>
          </el-descriptions-item>
吴滔's avatar
吴滔 committed
207
          <el-descriptions-item :label="$t('纳税人识别号')">
208 209 210 211 212
            <el-form-item
              label=""
              label-width="0"
              style="margin-bottom: 0"
              prop="taxpayer"
吴滔's avatar
吴滔 committed
213
              :rules="{ required: true, trigger: ['blur', 'change'], message: $t('请输入纳税人识别号') }"
214 215 216 217
            >
              <el-input v-model="form.taxpayer"></el-input>
            </el-form-item>
          </el-descriptions-item>
吴滔's avatar
吴滔 committed
218
          <el-descriptions-item :label="$t('开户行')">
219 220 221 222 223
            <el-form-item
              label=""
              label-width="0"
              style="margin-bottom: 0"
              prop="accountBank"
吴滔's avatar
吴滔 committed
224
              :rules="{ required: true, trigger: ['blur', 'change'], message: $t('请输入开户行') }"
225 226 227 228
            >
              <el-input v-model="form.accountBank"></el-input>
            </el-form-item>
          </el-descriptions-item>
吴滔's avatar
吴滔 committed
229
          <el-descriptions-item :label="$t('账号')">
230 231 232 233 234
            <el-form-item
              label=""
              label-width="0"
              style="margin-bottom: 0"
              prop="accountName"
吴滔's avatar
吴滔 committed
235
              :rules="{ required: true, trigger: ['blur', 'change'], message: $t('请输入账号') }"
236 237 238 239
            >
              <el-input v-model="form.accountName"></el-input>
            </el-form-item>
          </el-descriptions-item>
吴滔's avatar
吴滔 committed
240
          <el-descriptions-item :label="$t('项目')">
241 242 243 244 245
            <el-form-item
              label=""
              label-width="0"
              style="margin-bottom: 0"
              prop="projectName"
吴滔's avatar
吴滔 committed
246
              :rules="{ required: true, trigger: ['blur', 'change'], message: $t('请输入项目') }"
247 248 249 250
            >
              <el-input v-model="form.projectName"></el-input>
            </el-form-item>
          </el-descriptions-item>
吴滔's avatar
吴滔 committed
251
          <el-descriptions-item :label="$t('税率%')">
252 253 254 255 256
            <el-form-item
              label=""
              label-width="0"
              style="margin-bottom: 0"
              prop="taxRate"
吴滔's avatar
吴滔 committed
257
              :rules="{ required: true, trigger: ['blur', 'change'], message: $t('请输入税率') }"
258 259 260 261
            >
              <el-input v-model="form.taxRate"></el-input>
            </el-form-item>
          </el-descriptions-item>
吴滔's avatar
吴滔 committed
262
          <el-descriptions-item :label="$t('开票地址/电话')">
263 264 265 266 267
            <el-form-item
              label=""
              label-width="0"
              style="margin-bottom: 0"
              prop="addressPhone"
吴滔's avatar
吴滔 committed
268
              :rules="{ required: true, trigger: ['blur', 'change'], message: $t('请输入开票地址/电话') }"
269 270
            >
              <el-input v-model="form.addressPhone"></el-input>
吴滔's avatar
吴滔 committed
271 272 273
            </el-form-item>
          </el-descriptions-item>
        </el-descriptions>
274
      </el-card>
275
      <el-card class="card">
我在何方's avatar
我在何方 committed
276
        <div slot="header" class="card-title">{{ $t('收款信息') }}</div>
277
        <el-table :data="form.receiptAccountList" border :key="form.receiptAccountList.length">
吴滔's avatar
吴滔 committed
278
          <el-table-column :label="$t('应收币种')" align="center">
279
            <template slot-scope="scope">
我在何方's avatar
我在何方 committed
280
              {{getCurrencyLabel(scope.row.currencyId)}}
281 282
            </template>
          </el-table-column>
吴滔's avatar
吴滔 committed
283
          <el-table-column :label="$t('应收金额')" align="center" prop="receivableAmount">
吴滔's avatar
吴滔 committed
284
            <template slot-scope="scope" v-if="scope.row.type !== 'total'">
285
              {{ `${NP.minus(scope.row.receivableAmount, scope.row.discountTotal || 0)}${scope.row.discountTotal > 0 ? `(${scope.row.receivableAmount} - ${scope.row.discountTotal})` : ''}` }}
吴滔's avatar
吴滔 committed
286 287
            </template>
          </el-table-column>
我在何方's avatar
我在何方 committed
288
          <el-table-column align="center">
289
            <template #header>
我在何方's avatar
我在何方 committed
290
              {{ $t('核销基准币种')+''+getCurrencyLabel(showCurrencyId)+''+ $t('汇率') }}
291 292 293 294 295 296 297 298 299 300 301
            </template>
            <template slot-scope="scope">
              <template v-if="scope.row.type !== 'total'">
                <span v-if="showCurrencyId === scope.row.currencyId">{{ scope.row.writeOffRate }}</span>
                <el-form-item
                  v-else
                  label=""
                  label-width="0"
                  style="margin-bottom: 0"
                  :prop="`receiptAccountList.${scope.$index}.writeOffRate`"
                >
吴滔's avatar
吴滔 committed
302
                  <el-input v-model="scope.row.writeOffRate" @input="() => writeOffRateChange(scope.row, scope.$index)"></el-input>
303 304 305
                </el-form-item>
              </template>
              <template v-else>
houjn@hikoon.cn's avatar
houjn@hikoon.cn committed
306
                {{ $t('应核销总金额')+''+getCurrencyLabel(showCurrencyId)+''}}
307 308 309 310 311
              </template>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="writeOffAmount">
            <template #header>
我在何方's avatar
我在何方 committed
312
              {{ $t('核销基准金额')+''+getCurrencyLabel(showCurrencyId)+''}}
313 314
            </template>
          </el-table-column>
我在何方's avatar
我在何方 committed
315
          <el-table-column :label="$t('期望收款账户')" align="center">
316 317 318 319 320 321 322 323
            <template slot-scope="scope">
              <el-form-item
                v-if="scope.row.type !== 'total'"
                label=""
                label-width="0"
                style="margin-bottom: 0"
                :prop="`receiptAccountList.${scope.$index}.platformAccountId`"
              >
我在何方's avatar
我在何方 committed
324
<!--                <el-select
325
                  v-model="scope.row.platformAccountId"
吴滔's avatar
吴滔 committed
326
                  :placeholder="$t('请选择收款账户')"
327
                  @change="(platformAccountId)=>changePlatformAccountId(platformAccountId,scope.$index)"
328 329 330 331 332 333 334
                >
                  <el-option
                    v-for="item in bankData"
                    :key="item.id"
                    :label="item.baAccountName + '(' + item.baAccountNum + ')'"
                    :value="item.id"
                  />
我在何方's avatar
我在何方 committed
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349
                </el-select> -->
                <el-select
                    filterable
                    clear
                    v-model="scope.row.platformAccountId"
                    :placeholder="$t('请选择收款账户')"
                    @change="(platformAccountId)=>changePlatformAccountId(platformAccountId,scope.$index)"
                    v-el-select-loadmore="loadmore"
                    :loading="codeLoading">
                    <el-option
                      v-for="(item, i) in bankData"
                      :key="'opt-code' + i"
                      :label="item.baAccountName + '(' + item.baAccountNum + ')'"
                      :value="item.id"
                      ></el-option>
350 351 352 353
                </el-select>
              </el-form-item>
            </template>
          </el-table-column>
我在何方's avatar
我在何方 committed
354
          <el-table-column :label="$t('期望收款币种')" align="center">
355 356 357 358 359 360 361 362
            <template slot-scope="scope">
              <el-form-item
                v-if="scope.row.type !== 'total'"
                label=""
                label-width="0"
                style="margin-bottom: 0"
                :prop="`receiptAccountList.${scope.$index}.collectionCurrencyId`"
              >
我在何方's avatar
我在何方 committed
363 364 365 366 367 368 369 370
              <el-select
                v-model="scope.row.collectionCurrencyId"
                :placeholder="$t('请选择')"
                @change="val => currencyIdChange(val, scope.row, scope.$index)"
              >
                <el-option
                  v-for="item in currencyList"
                  :key="item.id"
我在何方's avatar
我在何方 committed
371
                  :label="$i18n.locale=='zh_CN'?item.titleZh:item.titleEn"
我在何方's avatar
我在何方 committed
372 373 374
                  :value="item.id"
                />
              </el-select>
375 376 377
              </el-form-item>
            </template>
          </el-table-column>
我在何方's avatar
我在何方 committed
378
          <el-table-column :label="$t('期望收款汇率')" align="center">
379 380 381 382 383 384 385 386 387 388
            <template slot-scope="scope">
              <el-form-item
                v-if="scope.row.type !== 'total'"
                label=""
                label-width="0"
                style="margin-bottom: 0"
                :prop="`receiptAccountList.${scope.$index}.collectionRate`"
              >
                <el-input v-model="scope.row.collectionRate" @input="() => rateChange(scope.row, scope.$index)"></el-input>
              </el-form-item>
我在何方's avatar
我在何方 committed
389
              <span v-else>{{ $t('期望收费金额') }}</span>
390 391
            </template>
          </el-table-column>
我在何方's avatar
我在何方 committed
392
          <el-table-column :label="$t('期望收款金额')" align="center" prop="collectionAmount">
393
            <template slot-scope="scope">
我在何方's avatar
我在何方 committed
394
              <span v-if="scope.row.type !== 'total'">{{ scope.row.collectionAmount }}</span>
395
              <div v-else>
我在何方's avatar
我在何方 committed
396
                <div v-for="itemAmount in scope.row.collectionAmount">{{$i18n.locale=='zh_CN'?(itemAmount?itemAmount.currencyNameZh:''):(itemAmount?itemAmount.currencyNameEn:'')}}: {{ itemAmount&&itemAmount.amount?itemAmount.amount:0}}</div>
我在何方's avatar
我在何方 committed
397
<!--                <div v-if="scope.row.collectionAmount[1]">{{ $t('人民币') }}: {{ scope.row.collectionAmount[1].toFixed(6) }}</div>
吴滔's avatar
吴滔 committed
398
                <div v-if="scope.row.collectionAmount[2]">{{ $t('奈拉') }}: {{ scope.row.collectionAmount[2].toFixed(6) }}</div>
我在何方's avatar
我在何方 committed
399
                <div v-if="scope.row.collectionAmount[3]">{{ $t('西非法郎') }}: {{ scope.row.collectionAmount[3].toFixed(6) }}</div> -->
400 401 402 403 404 405
              </div>
              <!-- <dict-tag :type="DICT_TYPE.BOX_SHIPPING_PRICE_UNIT" :value="scope.row.currencyId" /> -->
            </template>
          </el-table-column>
        </el-table>
        <el-descriptions :column="2" border class="card">
吴滔's avatar
吴滔 committed
406
          <el-descriptions-item :label="$t('账单汇率有效期')">
407 408 409 410 411 412 413 414 415
            <el-form-item
              label=""
              label-width="0"
              style="margin-bottom: 0"
              prop="rateValidateDate"
            >
              <el-date-picker
                v-model="form.rateValidateDate"
                type="datetime"
吴滔's avatar
吴滔 committed
416
                value-format="yyyy-MM-dd HH:mm:ss"
吴滔's avatar
吴滔 committed
417
                :placeholder="$t('选择日期时间')">
418 419 420 421 422
              </el-date-picker>
            </el-form-item>
          </el-descriptions-item>
        </el-descriptions>
      </el-card>
423
    </el-form>
424
<!--    <div slot="footer" style="margin: 20px 0">
425
      <el-button v-if="id==0||form.state==0" type="primary" :loading="saveBtnLoading" @click="submitForm(1)">{{ $t('保存草稿') }}</el-button>
吴滔's avatar
吴滔 committed
426
      <el-button v-else type="primary" :loading="saveBtnLoading" @click="$store.dispatch('tagsView/delCurrentView')">{{ $t('返回') }}</el-button>
427
      <el-button type="primary" :loading="saveBtnLoading" @click="submitForm(0)">{{ id&&form.state!=0 ? $t('修改') : $t('新增收款单') }}</el-button>
428 429
    </div> -->
    <div slot="header" class="bpm-title">{{ $t('审核流程') }}</div>
我在何方's avatar
我在何方 committed
430
    <work-flow  xmlkey="merge_order" v-model="form.copyUserList"></work-flow>
431 432

    <div slot="footer" style="margin: 20px 0">
我在何方's avatar
我在何方 committed
433 434 435
      <el-button type="primary" @click="submitForm(0)" v-hasPermi="['ecw:voucher:create:sumbit']">{{$t('提交申请')}}</el-button>
      <el-button v-if="id==0||form.state==0" type="primary" :loading="saveBtnLoading" v-hasPermi="['ecw:voucher:create:save']" @click="submitForm(1)">{{ $t('保存草稿') }}</el-button>
      <el-button v-if="orderData.inWarehouseState==207" type="primary" v-hasPermi="['ecw:voucher:create:see']" @click="$router.push(`/bpm/process-instance/detail?id=`+orderApprovalBackVO.applyingFormId)">{{$t('审核中')}}</el-button>
我在何方's avatar
我在何方 committed
436
      <!-- <el-button v-if="orderData.inWarehouseState==207" plain type="primary" @click="dialogVisible = true">{{$t('取消审核')}}</el-button> -->
437 438
      <el-button plain type="primary" @click="$store.dispatch('tagsView/delCurrentView')">{{$t('返回')}}</el-button>
      <!-- <el-button type="primary" :loading="saveBtnLoading" @click="submitForm(0)">{{ id&&form.state!=0 ? $t('修改') : $t('新增收款单') }}</el-button> -->
439
    </div>
吴滔's avatar
吴滔 committed
440 441
    <el-dialog
      :visible.sync="open"
吴滔's avatar
吴滔 committed
442
      :title="$t('添加未收客户款项')"
吴滔's avatar
吴滔 committed
443 444
      width="80%"
      append-to-body
445
      @open="getList"
吴滔's avatar
吴滔 committed
446 447
    >
      <div>
Marcus's avatar
Marcus committed
448
        <!-- <div slot="header" class="card-title">{{ $t('添加未收客户款项') }}</div> -->
吴滔's avatar
吴滔 committed
449 450
        <!-- 搜索工作栏 -->
        <el-form
451
          v-if="open"
吴滔's avatar
吴滔 committed
452 453 454 455 456 457 458
          :model="queryParams"
          ref="queryForm"
          size="small"
          :inline="true"
          label-width="80px"
        >
          <el-row>
我在何方's avatar
我在何方 committed
459
            <el-form-item :label="$t('始发仓')">
吴滔's avatar
吴滔 committed
460 461
              <el-select
                v-model="queryParams.departureId"
吴滔's avatar
吴滔 committed
462
                :placeholder="$t('请选择始发地')"
吴滔's avatar
吴滔 committed
463 464 465 466 467 468 469 470 471
              >
                <el-option
                  v-for="item in expoerCityList"
                  :label="item.titleZh"
                  :value="item.id"
                  :key="item.id"
                ></el-option>
              </el-select>
            </el-form-item>
我在何方's avatar
我在何方 committed
472
            <el-form-item :label="$t('目的仓')">
吴滔's avatar
吴滔 committed
473 474
              <el-select
                v-model="queryParams.objectiveId"
吴滔's avatar
吴滔 committed
475
                :placeholder="$t('请选择始发地')"
吴滔's avatar
吴滔 committed
476 477 478 479 480 481 482 483 484
              >
                <el-option
                  v-for="item in importCityList"
                  :label="item.titleZh"
                  :value="item.id"
                  :key="item.id"
                ></el-option>
              </el-select>
            </el-form-item>
吴滔's avatar
吴滔 committed
485
            <el-form-item :label="$t('运输方式')">
吴滔's avatar
吴滔 committed
486 487 488 489 490 491
              <dict-selector
                :type="DICT_TYPE.ECW_TRANSPORT_TYPE"
                v-model="queryParams.transportId"
                formatter="number"
              />
            </el-form-item>
吴滔's avatar
吴滔 committed
492
            <el-form-item :label="$t('出货渠道')">
吴滔's avatar
吴滔 committed
493 494
              <el-select
                v-model="queryParams.channelId"
吴滔's avatar
吴滔 committed
495
                :placeholder="$t('请选择出货渠道')"
吴滔's avatar
吴滔 committed
496 497 498 499 500 501 502 503 504 505 506
              >
                <el-option
                  v-for="item in channelList"
                  :label="item.nameZh"
                  :value="item.channelId"
                  :key="item.channelId"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-row>
          <el-row>
吴滔's avatar
吴滔 committed
507
            <el-form-item :label="$t('报关方式')">
吴滔's avatar
吴滔 committed
508 509 510 511 512
              <dict-selector
                :type="DICT_TYPE.ECW_CUSTOMS_TYPE"
                v-model="queryParams.customsType"
              />
            </el-form-item>
吴滔's avatar
吴滔 committed
513
            <el-form-item :label="$t('控货')">
吴滔's avatar
吴滔 committed
514 515 516 517 518
              <dict-selector
                :type="DICT_TYPE.INFRA_BOOLEAN_STRING"
                v-model="queryParams.control"
              />
            </el-form-item>
吴滔's avatar
吴滔 committed
519
            <el-form-item :label="$t('客户名称')">
吴滔's avatar
吴滔 committed
520
              <customer-selector
我在何方's avatar
我在何方 committed
521
                v-model="queryParams.customerId"
吴滔's avatar
吴滔 committed
522 523 524 525
                @change="consignor = $event"
              />
            </el-form-item>
          </el-row>
吴滔's avatar
吴滔 committed
526
          <el-form-item :label="$t('订单编号')" prop="orderNo">
吴滔's avatar
吴滔 committed
527 528
            <el-input
              v-model="queryParams.orderNo"
吴滔's avatar
吴滔 committed
529
              :placeholder="$t('请输入订单编号')"
吴滔's avatar
吴滔 committed
530 531 532 533
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
534

我在何方's avatar
我在何方 committed
535
          <el-form-item :label="$t('提单号')" prop="tidanNo">
吴滔's avatar
吴滔 committed
536
            <el-input
我在何方's avatar
我在何方 committed
537 538
              v-model="queryParams.tidanNo"
              :placeholder="$t('请输入提单号')"
吴滔's avatar
吴滔 committed
539 540 541 542
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
543

吴滔's avatar
吴滔 committed
544 545
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" @click="handleQuery"
吴滔's avatar
吴滔 committed
546
              >{{$t('查询')}}</el-button
吴滔's avatar
吴滔 committed
547 548 549 550
            >
          </el-form-item>
        </el-form>
        <el-table
551
          ref="multipleTable"
吴滔's avatar
吴滔 committed
552 553 554 555
          v-loading="loading1"
          :data="orderData"
          border
          @selection-change="handleSelectionChange"
556 557
          row-key="id"
          height="calc(100vh - 480px)"
吴滔's avatar
吴滔 committed
558
        >
吴滔's avatar
吴滔 committed
559
          <el-table-column type="selection" width="55" :reserve-selection="true"> </el-table-column>
吴滔's avatar
吴滔 committed
560
          <el-table-column :label="$t('订单号')" align="center" prop="orderNo" />
我在何方's avatar
我在何方 committed
561
          <el-table-column :label="$t('提单号')" align="center" prop="tidanNo" />
吴滔's avatar
吴滔 committed
562 563
          <el-table-column :label="$t('唛头')" align="center" prop="marks" />
          <el-table-column :label="$t('品名')" align="center" prop="title">
吴滔's avatar
吴滔 committed
564
            <template slot-scope="scope">
我在何方's avatar
我在何方 committed
565
              {{ scope.row.titleZh?(scope.row.titleZh + "(" + scope.row.titleEn + ")"): ''}}
吴滔's avatar
吴滔 committed
566 567
            </template>
          </el-table-column>
吴滔's avatar
吴滔 committed
568
          <el-table-column :label="$t('箱数')" align="center" prop="num" />
569 570 571 572 573
          <el-table-column :label="$t('体积/重量')" align="center" prop="weight">
            <template slot-scope="scope">
               {{ scope.row.volume}}/{{ scope.row.weight}}
              </template>
            </el-table-column>
吴滔's avatar
吴滔 committed
574 575 576
          <el-table-column :label="$t('发货人')" align="center" prop="consignorName" />
          <el-table-column :label="$t('收货人')" align="center" prop="consigneeName" />
          <el-table-column :label="$t('订单状态')" align="center" prop="status">
吴滔's avatar
吴滔 committed
577 578 579 580 581 582 583
            <template slot-scope="scope">
              <dict-tag
                :type="DICT_TYPE.ORDER_STATUS"
                :value="scope.row.status"
              />
            </template>
          </el-table-column>
吴滔's avatar
吴滔 committed
584
          <el-table-column :label="$t('收入类型')" align="center" prop="feeType">
吴滔's avatar
吴滔 committed
585 586 587 588 589 590 591
            <template slot-scope="scope">
              <dict-tag
                :type="DICT_TYPE.FEE_TYPE"
                :value="scope.row.feeType"
              ></dict-tag>
            </template>
          </el-table-column>
Marcus's avatar
Marcus committed
592
          <!-- <el-table-column :label="$t('单价美元')" align="center" prop="unitPrice" /> -->
吴滔's avatar
吴滔 committed
593
          <el-table-column :label="$t('单价')" align="center" prop="unitPrice">
594
            <template slot-scope="scope">
我在何方's avatar
我在何方 committed
595 596
              <span>{{ scope.row.unitPrice }}{{getCurrencyLabel(scope.row.currencyId)}}</span>
              <!-- <dict-tag :type="DICT_TYPE.BOX_SHIPPING_PRICE_UNIT" :value="scope.row.currencyId" /> -->
597 598
            </template>
          </el-table-column>
吴滔's avatar
吴滔 committed
599
          <el-table-column :label="$t('总金额')" align="center" prop="totalAmount">
600
            <template slot-scope="scope">
我在何方's avatar
我在何方 committed
601 602
              <span>{{ scope.row.totalAmount }}{{getCurrencyLabel(scope.row.currencyId)}}</span>
              <!-- <dict-tag :type="DICT_TYPE.BOX_SHIPPING_PRICE_UNIT" :value="scope.row.currencyId" /> -->
603 604
            </template>
          </el-table-column>
吴滔's avatar
吴滔 committed
605 606 607 608 609 610 611 612 613 614
        </el-table>
        <pagination
          v-show="total > 0"
          :total="total"
          :page.sync="queryParams.page"
          :limit.sync="queryParams.rows"
          @pagination="getList"
        />
        <!-- </el-card> -->
        <div slot="footer" class="dialog-footer">
吴滔's avatar
吴滔 committed
615 616
          <el-button type="primary" @click="saveSelectList">{{ $t('确认添加') }}</el-button>
          <el-button @click="hiddenDialog">{{ $t('取消') }}</el-button>
吴滔's avatar
吴滔 committed
617 618 619
        </div>
      </div>
    </el-dialog>
吴滔's avatar
吴滔 committed
620
    <el-dialog v-if="discountVisible" :visible.sync="discountVisible" :title="$t('优惠信息确认')" width="60%" append-to-body>
吴滔's avatar
吴滔 committed
621
      <el-form label-width="120px">
吴滔's avatar
吴滔 committed
622
        <el-form-item v-if="form.receiptNo" :label="$t('收款单号')">
吴滔's avatar
吴滔 committed
623 624 625
          {{ form.receiptNo }}
        </el-form-item>
        <el-table :data="[selectListRow]" border style="margin-bottom: 22px">
吴滔's avatar
吴滔 committed
626 627 628
          <el-table-column :label="$t('订单号')" align="center" prop="orderNo" />
          <el-table-column :label="$t('唛头')" align="center" prop="marks" />
          <el-table-column :label="$t('品名')" align="center" prop="title">
吴滔's avatar
吴滔 committed
629
            <template slot-scope="scope">
我在何方's avatar
我在何方 committed
630
              {{ scope.row.titleZh?(scope.row.titleZh + "(" + scope.row.titleEn + ")"): ''}}
吴滔's avatar
吴滔 committed
631 632
            </template>
          </el-table-column>
吴滔's avatar
吴滔 committed
633
          <el-table-column :label="$t('箱数')" align="center" prop="num" />
634 635 636 637 638
          <el-table-column :label="$t('体积/重量')" align="center" prop="weight">
            <template slot-scope="scope">
               {{ scope.row.volume}}/{{ scope.row.weight}}
              </template>
            </el-table-column>
吴滔's avatar
吴滔 committed
639
          <el-table-column :label="$t('收入类型')" align="center" prop="feeType">
吴滔's avatar
吴滔 committed
640 641 642 643 644 645 646
            <template slot-scope="scope">
              <dict-tag
                :type="DICT_TYPE.FEE_TYPE"
                :value="scope.row.feeType"
              ></dict-tag>
            </template>
          </el-table-column>
吴滔's avatar
吴滔 committed
647
          <el-table-column :label="$t('单价金额')" align="center" prop="unitPrice">
吴滔's avatar
吴滔 committed
648
            <template slot-scope="scope">
我在何方's avatar
我在何方 committed
649 650
              <span>{{ scope.row.unitPrice }}{{getCurrencyLabel(scope.row.currencyId)}}</span>
              <!-- <dict-tag :type="DICT_TYPE.BOX_SHIPPING_PRICE_UNIT" :value="scope.row.currencyId" /> -->
吴滔's avatar
吴滔 committed
651 652
            </template>
          </el-table-column>
吴滔's avatar
吴滔 committed
653
          <el-table-column :label="$t('总金额')" align="center" prop="totalAmount">
吴滔's avatar
吴滔 committed
654
            <template slot-scope="scope">
我在何方's avatar
我在何方 committed
655
              <span>{{ scope.row.taxAmount }}{{getCurrencyLabel(scope.row.currencyId)}}</span>
我在何方's avatar
我在何方 committed
656
              <!-- <dict-tag :type="DICT_TYPE.BOX_SHIPPING_PRICE_UNIT" :value="scope.row.currencyId" /> -->
吴滔's avatar
吴滔 committed
657 658 659
            </template>
          </el-table-column>
        </el-table>
吴滔's avatar
吴滔 committed
660
        <el-form-item :label="$t('总金额')">
我在何方's avatar
我在何方 committed
661
          {{ selectListRow.taxAmount }}{{getCurrencyLabel(selectListRow.currencyId)}}
吴滔's avatar
吴滔 committed
662
        </el-form-item>
吴滔's avatar
吴滔 committed
663
        <el-form-item :label="$t('优惠金额')">
我在何方's avatar
我在何方 committed
664
          <el-input v-model="discountForm.discountTotal" type="number" min="0" :max="selectListRow.totalAmount" @input="checkDiscount" style="width: 300px" ></el-input>
我在何方's avatar
我在何方 committed
665 666
          &nbsp;&nbsp;{{getCurrencyLabel(selectListRow.currencyId)}}

吴滔's avatar
吴滔 committed
667
        </el-form-item>
吴滔's avatar
吴滔 committed
668
        <el-form-item :label="$t('优惠原因')">
吴滔's avatar
吴滔 committed
669 670
          <el-input v-model="discountForm.discountRemark" type="textarea" style="width: 300px"></el-input>
        </el-form-item>
吴滔's avatar
吴滔 committed
671
        <el-form-item :label="$t('优惠后')">
我在何方's avatar
我在何方 committed
672
          {{ (selectListRow.taxAmount - (discountForm.discountTotal || 0)).toFixed(2)}}
我在何方's avatar
我在何方 committed
673
		  {{getCurrencyLabel(selectListRow.currencyId)}}
吴滔's avatar
吴滔 committed
674
        </el-form-item>
吴滔's avatar
吴滔 committed
675
        <el-form-item v-if="opnotice" :label="$t('操作人')">
吴滔's avatar
吴滔 committed
676 677
          {{ discountForm.author }}
        </el-form-item>
吴滔's avatar
吴滔 committed
678
        <el-form-item v-if="opnotice" :label="$t('操作时间')">
吴滔's avatar
吴滔 committed
679 680 681 682
          {{ discountForm.time }}
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
吴滔's avatar
吴滔 committed
683 684
        <el-button type="primary" @click="saveDiscount">{{$t('提交')  }}</el-button>
        <el-button @click="cancelDiscount">{{ $t('取消') }}</el-button>
吴滔's avatar
吴滔 committed
685 686
      </div>
    </el-dialog>
687 688 689 690
  </div>
</template>

<script>
691
import { listSimpleUsers } from "@/api/system/user";
吴滔's avatar
吴滔 committed
692 693 694
import { DICT_TYPE } from "@/utils/dict";
import { getToken } from "@/utils/auth";
import CustomerSelector from "@/components/CustomerSelector";
695
import CustomerSelectorpay from "@/components/CustomerSelectorpay";
吴滔's avatar
吴滔 committed
696 697 698 699
import { getBankAccountPage } from "@/api/ecw/bankAccount";
import { listSimpleDepts } from "@/api/system/dept";
import { getChannelList } from "@/api/ecw/channel";
import { getTradeCityList } from "@/api/ecw/region";
我在何方's avatar
我在何方 committed
700
import { createReceipt,getReceivableByOrderId, getReceivableList, getReceivableItemDetail, getReceiptInfoByIds, getReceiptAccountList, getInvoicingItem, updateReceipt, updateReceivableDiscountById, getReceivableDiscountLogById } from "@/api/ecw/financial";
701 702
import {getCustomer} from '@/api/ecw/customer'
import NP from 'number-precision'
我在何方's avatar
我在何方 committed
703
import {getOrder,getDestCountryByOrderId} from '@/api/ecw/order'
704
import { getCurrencyPage } from "@/api/ecw/currency";
我在何方's avatar
我在何方 committed
705
import { getExchangeRatePage } from "@/api/ecw/exchangeRate";
706
import ret from "bluebird/js/release/util";
吴滔's avatar
吴滔 committed
707 708
import dayjs from "dayjs";
import { getUserProfile } from "@/api/system/user";
我在何方's avatar
我在何方 committed
709
import {getWarehouseList} from '@/api/ecw/warehouse'
710
import WorkFlow from '@/components/WorkFlow/'
711

吴滔's avatar
吴滔 committed
712
export default {
713
  name: "EcwFinancialCreatcollection",
吴滔's avatar
吴滔 committed
714
  components: {
715
    CustomerSelector,WorkFlow,CustomerSelectorpay
吴滔's avatar
吴滔 committed
716 717 718
  },
  data() {
    return {
吴滔's avatar
吴滔 committed
719
      NP,
吴滔's avatar
吴滔 committed
720 721 722
      loadings: false,
      loading1: false,
      uploadFileUrl: process.env.VUE_APP_BASE_API + "/app-api/file/upload", // 上传的图片服务器地址
723
      form: {
我在何方's avatar
我在何方 committed
724 725 726 727
        receiptAccountList: [],
        departmentId:'',
        salesmanId:'',
        salesmanName:''
728
      },
吴滔's avatar
吴滔 committed
729 730
      creatorData: [],
      list: [],
731
      // fileList: [],
吴滔's avatar
吴滔 committed
732
      orderData: [],
我在何方's avatar
我在何方 committed
733
      opnotice:false,
吴滔's avatar
吴滔 committed
734
      dialogTableKey: 0,
735
      total: 0,
吴滔's avatar
吴滔 committed
736 737
      headers: {
        Authorization: "Bearer " + getToken(),
738
      },
吴滔's avatar
吴滔 committed
739 740 741 742 743
      loading: "",
      open: false,
      bankData: [],
      params: {
        page: 1,
我在何方's avatar
我在何方 committed
744
        rows: 100,
745
      },
吴滔's avatar
吴滔 committed
746 747 748 749 750 751 752
      deptData: [],
      deptArr: [],
      oadings: false,
      channelList: [],
      queryParams: {
        page: 1,
        rows: 20,
753
      },
吴滔's avatar
吴滔 committed
754 755
      multipleSelection: [],
      tradeCityList: [],
756 757
      id: 0,
      receiptId: 0,
758
      currencyList: [],
吴滔's avatar
吴滔 committed
759 760
      saveBtnLoading: false,
      discountVisible: false,
我在何方's avatar
我在何方 committed
761 762 763
      discountForm: {
        author:''
      },
吴滔's avatar
吴滔 committed
764
      selectListRow: {},
吴滔's avatar
吴滔 committed
765
      selectListIndex: 0,
我在何方's avatar
我在何方 committed
766
      flag: false,
767 768
      warehouseList:[],
      selectedUsers:[],
我在何方's avatar
我在何方 committed
769
      dialogVisible:false,
我在何方's avatar
我在何方 committed
770 771 772 773 774
      isUpdate:false,
      codeLoading: false,
      codePage: {
         pageNo: 1,
         pageSize: 100
我在何方's avatar
我在何方 committed
775

我在何方's avatar
我在何方 committed
776
      },
我在何方's avatar
我在何方 committed
777
      pages:1,
我在何方's avatar
我在何方 committed
778 779
      rateList:[],
      userInfo:null
吴滔's avatar
吴滔 committed
780 781
    };
  },
我在何方's avatar
我在何方 committed
782 783 784 785 786 787 788
  async activated(){
    let that = this;
    await getUserProfile().then(res => that.userInfo = res.data)
    if (that.$route.query.id) {
      that.flag = true
      that.id = that.$route.query.id;
      that.getReceivableData()
我在何方's avatar
我在何方 committed
789
    }else{
我在何方's avatar
我在何方 committed
790 791 792 793 794
      that.removeData()
      that.$set(that.form,'departmentId',that.userInfo.deptId)
      that.$set(that.discountForm,'author',that.userInfo.nickname)
      that.$set(that.form,'salesmanId',that.userInfo.id)
       that.$set(that.form,'salesmanName',that.userInfo.nickname)
我在何方's avatar
我在何方 committed
795
    }
我在何方's avatar
我在何方 committed
796
    if (that.$route.query.receiptId && that.$route.query.receiptId != 0) {
我在何方's avatar
我在何方 committed
797

我在何方's avatar
我在何方 committed
798 799
      that.receiptId = that.$route.query.receiptId;
      that.getReceivableInfo()
我在何方's avatar
我在何方 committed
800
    }else{
我在何方's avatar
我在何方 committed
801
      // that.removeData()
我在何方's avatar
我在何方 committed
802
    }
我在何方's avatar
我在何方 committed
803 804 805 806
    if (that.$route.query.orderId) {
       getReceivableByOrderId({orderId:that.$route.query.orderId}).then(response => {
        that.list = [...response.data]
        that.list.map(v=>{
我在何方's avatar
我在何方 committed
807 808 809 810
          if(!v.taxPoint){
            v.taxAmount = v.totalAmount
          }
        })
我在何方's avatar
我在何方 committed
811 812
        that.calculation()
        getOrder(that.$route.query.orderId).then(response => {
我在何方's avatar
我在何方 committed
813
          // console.log(response.data)
814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834
          if(response.data.customerId){
            that.$set(that.form,'customerId',response.data.customerId)
          }else{
            if(response.data.drawee==1){
              that.$set(that.form,'customerId',response.data.consignorVO.customerId)
            }else if(response.data.drawee==2){
              that.$set(that.form,'customerId',response.data.consigneeVO.customerId)
            }else{
              if(response.data.customDraweeVOList){
                response.data.customDraweeVOList.map(v=>{
                  if(v.name == 'freight'){
                    if(v.value==1){
                       that.$set(that.form,'customerId',response.data.consignorVO.customerId)
                    }else{
                      that.$set(that.form,'customerId',response.data.consigneeVO.customerId)
                    }
                  }
                })
              }
            }
          }
我在何方's avatar
我在何方 committed
835
        })
我在何方's avatar
我在何方 committed
836
        getDestCountryByOrderId({orderId:that.$route.query.orderId}).then(response => {
我在何方's avatar
我在何方 committed
837
          // console.log(response.data)
我在何方's avatar
我在何方 committed
838
          if(response.data) that.$set(that.queryParams,'destCountry',response.data)
我在何方's avatar
我在何方 committed
839 840 841
        })
    })
    }
我在何方's avatar
我在何方 committed
842

843
  },
我在何方's avatar
我在何方 committed
844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859
  directives: {
      'el-select-loadmore': {
        bind (el, binding) {
          const SELECTWRAP_DOM = el.querySelector(
            '.el-select-dropdown .el-select-dropdown__wrap'
          )
          SELECTWRAP_DOM.addEventListener('scroll', function () {
            const condition =
              this.scrollHeight - this.scrollTop <= this.clientHeight
            if (condition) {
              binding.value()
            }
          })
        }
      }
    },
860
  async created() {
我在何方's avatar
我在何方 committed
861
    await getUserProfile().then(res => this.userInfo = res.data)
862 863
    // 获取汇率
    await getCurrencyPage(this.params).then(res => this.currencyList = res.data.list)
我在何方's avatar
我在何方 committed
864
    await getExchangeRatePage(this.params).then(res => this.rateList = res.data.list)
我在何方's avatar
我在何方 committed
865
    getWarehouseList().then(res => this.warehouseList = res.data)
吴滔's avatar
吴滔 committed
866
    let that = this;
867
    if (that.$route.query.orderId) {
我在何方's avatar
我在何方 committed
868
      await getReceivableByOrderId({orderId:that.$route.query.orderId}).then(response => {
869
        this.list = [...response.data]
870
        this.list.map(v=>{
我在何方's avatar
我在何方 committed
871
          if(!v.taxPoint){
872 873 874
            v.taxAmount = v.totalAmount
          }
        })
875
        this.calculation()
876
        getOrder(that.$route.query.orderId).then(response => {
877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897
          if(response.data.customerId){
            that.$set(that.form,'customerId',response.data.customerId)
          }else{
            if(response.data.drawee==1){
              that.$set(that.form,'customerId',response.data.consignorVO.customerId)
            }else if(response.data.drawee==2){
              that.$set(that.form,'customerId',response.data.consigneeVO.customerId)
            }else{
              if(response.data.customDraweeVOList){
                response.data.customDraweeVOList.map(v=>{
                  if(v.name == 'freight'){
                    if(v.value==1){
                       that.$set(that.form,'customerId',response.data.consignorVO.customerId)
                    }else{
                      that.$set(that.form,'customerId',response.data.consigneeVO.customerId)
                    }
                  }
                })
              }
            }
          }
898
        })
我在何方's avatar
我在何方 committed
899 900 901 902
      })
      getDestCountryByOrderId({orderId:this.$route.query.orderId}).then(response => {
        if(response.data) this.$set(this.queryParams,'destCountry',response.data)
      })
903
    }
吴滔's avatar
吴滔 committed
904
    if (that.$route.query.id) {
吴滔's avatar
吴滔 committed
905
      this.flag = true
吴滔's avatar
吴滔 committed
906
      this.id = this.$route.query.id;
我在何方's avatar
我在何方 committed
907
      this.getReceivableData()
我在何方's avatar
我在何方 committed
908
    }else{
我在何方's avatar
我在何方 committed
909
      this.discountForm.author = this.userInfo.nickname
我在何方's avatar
我在何方 committed
910 911
      this.form.departmentId = this.userInfo.deptId
      this.form.salesmanId = this.userInfo.id
我在何方's avatar
我在何方 committed
912
      this.$set(this.form,'salesmanName',this.userInfo.nickname)
913 914 915
    }
    if (that.$route.query.receiptId && that.$route.query.receiptId !== '0') {
      this.receiptId = this.$route.query.receiptId;
我在何方's avatar
我在何方 committed
916
      this.getReceivableInfo()
吴滔's avatar
吴滔 committed
917
    }
918 919

    // this.getList();
吴滔's avatar
吴滔 committed
920 921 922 923 924 925
    // if(that.$route.query.consignorId){
    //   this.queryParams.consignorId = this.$route.query.consignorId
    // }
    // if(that.$route.query.writeOffName){
    //   this.form.writeOffName = this.$route.query.writeOffName
    // }
926
    listSimpleUsers().then((res) => (that.creatorData = res.data));
吴滔's avatar
吴滔 committed
927 928
    getChannelList().then((res) => (that.channelList = res.data));
    getTradeCityList().then((res) => (that.tradeCityList = res.data));
我在何方's avatar
我在何方 committed
929
    this.getCodeList()
吴滔's avatar
吴滔 committed
930
    listSimpleDepts().then((res) => {
我在何方's avatar
我在何方 committed
931 932 933 934 935 936 937 938
      that.deptData =  res.data
      // res.data.forEach((item) => {
      //   if (item.parentId == 0) {
      //     that.deptArr.push(item);
      //   } else {
      //     that.deptData.push(item);
      //   }
      // });
吴滔's avatar
吴滔 committed
939

我在何方's avatar
我在何方 committed
940 941 942 943 944 945
      // that.deptData.forEach((value) => {
      //   var dept = res.data.filter((itt) => itt.id == value.parentId);
      //   if (dept.length > 0) {
      //     value.name = dept[0].name + " | " + value.name;
      //   }
      // });
吴滔's avatar
吴滔 committed
946 947 948 949
    });
  },
  computed: {
    expoerCityList() {
我在何方's avatar
我在何方 committed
950 951
      // return this.tradeCityList.filter((item) => item.type == 2);
      return this.warehouseList.filter(item => item.tradeType == 2 || item.tradeType == 3)
吴滔's avatar
吴滔 committed
952 953
    },
    importCityList() {
我在何方's avatar
我在何方 committed
954 955
      // return this.tradeCityList.filter((item) => item.type == 1);
      return this.warehouseList.filter(item => item.tradeType == 1 || item.tradeType == 3)
吴滔's avatar
吴滔 committed
956
    },
957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979
    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
    },
    showInvoice() {
      return this.form.openInvoice == 1
    }
吴滔's avatar
吴滔 committed
980 981
  },
  methods: {
我在何方's avatar
我在何方 committed
982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000
    // 懒加载
    loadmore () {
      this.codePage.pageNo++
      // 大于页码不请求了
      console.log(111)
      if (this.codePage.pageNo > this.pages) {
        return
      }
      this.getCodeList()
    },
   getCodeList (flag) {
        if (flag) {
          this.bankData = []
          this.codeLoading = true
        }
        setTimeout(() => {
          getBankAccountPage(this.codePage).then(res => {
            this.codeLoading = false
            this.bankData = this.bankData.concat(res.data.list)
1001
            this.pages = (res.data.total/this.codePage.pageSize)+1
我在何方's avatar
我在何方 committed
1002 1003
            })
        }, 200)
1004
    },
我在何方's avatar
我在何方 committed
1005 1006 1007 1008
    getReceivableData(){
      getReceiptInfoByIds({ id: this.id }).then(res => {
        if(res.data.rateValidateDate) res.data.rateValidateDate = dayjs(res.data.rateValidateDate).format('YYYY-MM-DD HH:mm:ss')
        this.form = Object.assign({}, this.form, res.data)
我在何方's avatar
我在何方 committed
1009
        this.discountForm.author = this.userInfo.nickname
我在何方's avatar
我在何方 committed
1010 1011
        if(!this.form.departmentId) this.form.departmentId = this.userInfo.deptId
        if(!this.form.salesmanId) this.form.salesmanId = this.userInfo.id
我在何方's avatar
我在何方 committed
1012
        if(!this.form.salesmanName) this.$set(this.form,'salesmanName',this.userInfo.nickname)
我在何方's avatar
我在何方 committed
1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026
      })
       getInvoicingItem({ id: this.id }).then(res => {
        this.list = [...res.data]
        this.list.map(v=>{
          if(!v.taxPoint){
            v.taxAmount = v.totalAmount
          }
        })
      })
      getReceiptAccountList({ id: this.id }).then(res => {
        if (res.data.length > 0) {
          // totalAmount
          res.data = [...res.data, {
            type: 'total',
我在何方's avatar
我在何方 committed
1027
            writeOffAmount: res.data.reduce((total, currentValue) => NP.plus(total, currentValue.writeOffAmount || 0), 0).toFixed(2),
我在何方's avatar
我在何方 committed
1028 1029 1030
            collectionAmount: []
          }]
        }
我在何方's avatar
我在何方 committed
1031 1032
        this.$set(this.form, 'receiptAccountList', res.data)

我在何方's avatar
我在何方 committed
1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048
        this.$nextTick(() => {
          // const dollarList = this.list.filter(v => v.currencyId === 1)
          // const discountDollar = dollarList.reduce((total, currentValue) => NP.plus(total, currentValue.discountTotal || 0), 0)
          // const d = this.form.receiptAccountList.find(v => v.currencyId == 1)
          // d && (d.discountTotal = discountDollar)

          // const rmbList = this.list.filter(v => v.currencyId === 2)
          // const discountRmb = rmbList.reduce((total, currentValue) => NP.plus(total, currentValue.discountTotal || 0), 0)
          // const r = this.form.receiptAccountList.find(v => v.currencyId == 2)
          // r && (r.discountTotal = discountRmb)

          // const nairaList = this.list.filter(v => v.currencyId === 3)
          // const discountNaira = nairaList.reduce((total, currentValue) => NP.plus(total, currentValue.discountTotal || 0), 0)
          // const n = this.form.receiptAccountList.find(v => v.currencyId == 3)
          // n && (n.discountTotal = discountNaira)

我在何方's avatar
我在何方 committed
1049 1050
          // this.form.receiptAccountList.forEach((item, index) => {
          //   this.rateChange(item, index)
我在何方's avatar
我在何方 committed
1051

我在何方's avatar
我在何方 committed
1052
          // });
我在何方's avatar
我在何方 committed
1053
          console.log(111)
我在何方's avatar
我在何方 committed
1054 1055 1056 1057
          if(this.form.receiptAccountList.length>0){
            this.editReceiptAccountList()
          }
          // this.calculation()
我在何方's avatar
我在何方 committed
1058 1059 1060 1061
        })
      })
    },
    getReceivableInfo(){
我在何方's avatar
我在何方 committed
1062
      getReceivableItemDetail({ id: this.receiptId}).then(res => {
我在何方's avatar
我在何方 committed
1063
        this.list = res.data
我在何方's avatar
我在何方 committed
1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075
        this.list.map(v=>{
          if(!v.taxPoint){
            v.taxAmount = v.totalAmount
          }
        })
        this.calculation()

          getOrder(res.data.orderId).then(response => {
            // console.log(response.data)
            if(response.data.customerId) this.$set(this.form,'customerId',response.data.customerId)
          })
      })
我在何方's avatar
我在何方 committed
1076
    },
我在何方's avatar
我在何方 committed
1077 1078
	  getCurrencyLabel(id){
	    var label = this.currencyList.filter(item=>item.id == id)
我在何方's avatar
我在何方 committed
1079
	    if(label.length>0) return this.$i18n.locale=='zh_CN'?label[0].titleZh:label[0].titleEn
我在何方's avatar
我在何方 committed
1080 1081
	    return ''
	  },
我在何方's avatar
我在何方 committed
1082 1083 1084 1085 1086
    checkDiscount(e){
      if(e>this.selectListRow.totalAmount){
        this.discountForm.discountTotal = this.selectListRow.totalAmount
      }
    },
1087 1088 1089 1090
    currencyIdChange(val, row, index) {
      row.collectionCurrencyId = val
      if (val == row.currencyId) row.collectionRate = 1
      else {
我在何方's avatar
我在何方 committed
1091 1092 1093 1094 1095 1096
        // if (row.currencyId == 1 && val == 3) row.collectionRate = this.UStoRMB()
        // if (row.currencyId == 1 && val == 2) row.collectionRate = this.UStoNAN()
        // if (row.currencyId == 3 && val == 1) row.collectionRate = this.RMBtoUS()
        // if (row.currencyId == 3 && val == 2) row.collectionRate = this.RMBtoNAN()
        // if (row.currencyId == 2 && val == 1) row.collectionRate = this.NANtoUS()
        // if (row.currencyId == 2 && val == 3) row.collectionRate = this.NANtoRMB()
我在何方's avatar
我在何方 committed
1097 1098
         // row.collectionRate = NP.times(this.currencyList.find(v => v.id === row.currencyId).huilv/100, this.currencyList.find(v => v.id === val).exchangeToFc/100).toFixed(6)
        row.collectionRate = this.getRate(row.currencyId,val)
1099
      }
我在何方's avatar
我在何方 committed
1100

1101 1102
      this.rateChange(row, index)
    },
我在何方's avatar
我在何方 committed
1103 1104 1105 1106
    //获取汇率
    getRate(sourceCurrencyId,targetCurrencyId){
      var rate = this.rateList.find(v=>(v.sourceCurrencyId === sourceCurrencyId&&v.targetCurrencyId===targetCurrencyId))
      if(rate) return rate.currencyRate
我在何方's avatar
我在何方 committed
1107
      return ''
我在何方's avatar
我在何方 committed
1108
    },
吴滔's avatar
吴滔 committed
1109
    writeOffRateChange(row, index) {
我在何方's avatar
我在何方 committed
1110
      if(row.writeOffRate==0&&parseInt(row.writeOffRate)===0){
我在何方's avatar
我在何方 committed
1111 1112 1113
        this.$modal.msgError(this.$t('汇率不能为0,请输入正确的汇率'));
      }
      if(row.writeOffRate){
我在何方's avatar
我在何方 committed
1114

我在何方's avatar
我在何方 committed
1115
        row.writeOffAmount = NP.times(row.writeOffRate || 0, NP.minus(row.receivableAmount, row.discountTotal||0)).toFixed(2)
我在何方's avatar
我在何方 committed
1116 1117 1118
      }else{
        row.writeOffAmount = ''
      }
吴滔's avatar
吴滔 committed
1119 1120 1121 1122

      const writeOffAmountTotal = this.form.receiptAccountList.filter(v => v.type !== 'total').reduce((total, currentValue) => NP.plus(total, currentValue.writeOffAmount || 0), 0)
      this.form.receiptAccountList[this.form.receiptAccountList.length -1].writeOffAmount = writeOffAmountTotal
    },
1123
    rateChange(row, index) {
我在何方's avatar
我在何方 committed
1124
      if(row.collectionRate==0&&parseInt(row.collectionRate)===0){
我在何方's avatar
我在何方 committed
1125 1126
        this.$modal.msgError(this.$t('汇率不能为0,请输入正确的汇率'));
      }
我在何方's avatar
我在何方 committed
1127
      if(row.collectionRate){
我在何方's avatar
我在何方 committed
1128
        row.receivableAmount && (row.collectionAmount = NP.times(row.collectionRate || 0, NP.minus(row.receivableAmount, row.discountTotal||0)).toFixed(2))
我在何方's avatar
我在何方 committed
1129
      }else{
我在何方's avatar
我在何方 committed
1130
        row.collectionAmount = ''
我在何方's avatar
我在何方 committed
1131
      }
1132 1133 1134 1135
      this.form.receiptAccountList[index] = {...row}

      setTimeout(() => {
        // 收款总计
我在何方's avatar
我在何方 committed
1136
        this.editReceiptAccountList()
1137 1138
      }, 100)
    },
我在何方's avatar
我在何方 committed
1139 1140 1141 1142 1143
    editReceiptAccountList(){
      var amountList =[]
      this.currencyList.forEach((item,index)=>{
        var dollarList = this.form.receiptAccountList.filter(v => v.collectionCurrencyId == item.id)
        if(dollarList.length>0){
我在何方's avatar
我在何方 committed
1144
          var dollar = dollarList.reduce((total, currentValue) => NP.plus(total, currentValue.collectionAmount), 0)
我在何方's avatar
我在何方 committed
1145
          amountList.push({currencyId:item.id,currencyNameEn:item.titleEn,currencyNameZh:item.titleZh,amount:dollar.toFixed(2)})
我在何方's avatar
我在何方 committed
1146 1147 1148 1149 1150
        }
      })
      this.form.receiptAccountList[this.form.receiptAccountList.length -1].collectionAmount = amountList
      this.$set(this.form, 'receiptAccountList', [...this.form.receiptAccountList])
    },
1151 1152
    //明细改变税率
    changeTaxRate(row,index){
1153
      var pointArr = []
我在何方's avatar
我在何方 committed
1154
      var regs=/^[0-9]+\d*(\.\d*)?$|^0?\.\d*[0-9]\d*$/;
1155
      if(row.taxPoint&&!regs.test(row.taxPoint)){
1156
        row.taxPoint = ''
1157
        this.$modal.msgError(this.$t('输入税率格式不对'));
1158 1159 1160 1161 1162 1163
      }else{
         pointArr = row.taxPoint.split('.')
         if(pointArr.length>1&&pointArr[1]){
           row.taxPoint =Math.round(row.taxPoint*100)/100
         }

1164
      }
我在何方's avatar
我在何方 committed
1165 1166 1167 1168 1169 1170 1171
      if(row.taxPoint){
        var amout = NP.times(NP.divide(row.taxPoint,100), row.totalAmount)
        row.taxAmount = NP.plus(row.totalAmount,amout)
      }else{
        row.taxAmount = row.totalAmount
      }

1172
      this.list[index] = {...row}
我在何方's avatar
我在何方 committed
1173 1174
      let dataArrTemp = JSON.stringify(this.list);
      this.list= JSON.parse(dataArrTemp);
1175 1176 1177 1178 1179 1180
      if(pointArr.length>1&&!pointArr[1]){
        return
      }else{
        this.calculation()
      }

1181
    },
1182
    calculation() {
1183 1184
      const copyList = this.form.receiptAccountList
      this.form.receiptAccountList = []
我在何方's avatar
我在何方 committed
1185 1186 1187 1188
      this.currencyList.forEach((item,index)=>{
        var dollarList = this.list.filter(v => v.currencyId === item.id)
        if(dollarList.length>0){
          let dollar,discountDollar
我在何方's avatar
我在何方 committed
1189
            dollar = dollarList.reduce((total, currentValue) => NP.plus(total, currentValue.taxAmount || 0), 0)
我在何方's avatar
我在何方 committed
1190 1191
            discountDollar = dollarList.reduce((total, currentValue) => NP.plus(total, currentValue.discountTotal || 0), 0)
            var t = copyList.find(v => v.currencyId == item.id)
1192
            console.log(discountDollar)
我在何方's avatar
我在何方 committed
1193 1194 1195 1196
            this.form.receiptAccountList.push(
              {
                discountTotal: discountDollar,
                currencyId: item.id,
我在何方's avatar
我在何方 committed
1197
                receivableAmount: Math.round(dollar),
我在何方's avatar
我在何方 committed
1198
                writeOffRate: item.id==this.showCurrencyId?1: this.getRate(item.id,this.showCurrencyId),
我在何方's avatar
我在何方 committed
1199
                platformAccountId: t?.platformAccountId || '',
1200 1201
                collectionCurrencyId:  item.id,
                collectionRate: 1
我在何方's avatar
我在何方 committed
1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266
              }
            )
            this.calculationCount(NP.minus(dollar, discountDollar), item.id)
        }
      })

      // let dollar,discountDollar
      // if (dollarList.length > 0) {
      //   dollar = dollarList.reduce((total, currentValue) => NP.plus(total, currentValue.totalAmount || 0), 0)
      //   discountDollar = dollarList.reduce((total, currentValue) => NP.plus(total, currentValue.discountTotal || 0), 0)
      //   const t = copyList.find(v => v.currencyId == 1)
      //   this.form.receiptAccountList = [
      //     {
      //       discountTotal: discountDollar,
      //       currencyId: 1,
      //       receivableAmount: dollar,
      //       writeOffRate: t?.writeOffRate || (this.showCurrencyId === 1 ? 1 : this.showCurrencyId === 2 ? this.UStoRMB() : this.UStoNAN()),
      //       platformAccountId: t?.platformAccountId || '',
      //       collectionCurrencyId: t?.collectionCurrencyId || 1,
      //       collectionRate: t?.collectionRate || 1
      //     }
      //   ]
      //   this.calculationCount(NP.minus(dollar, discountDollar), 1)
      // }
      // const rmbList = this.list.filter(v => v.currencyId === 2)
      // let rmb,discountRmb
      // if (rmbList.length > 0) {
      //   rmb = rmbList.reduce((total, currentValue) => NP.plus(total, currentValue.totalAmount || 0), 0)
      //   discountRmb = rmbList.reduce((total, currentValue) => NP.plus(total, currentValue.discountTotal || 0), 0)
      //   const t = copyList.find(v => v.currencyId == 2)
      //   this.form.receiptAccountList = [
      //     ...this.form.receiptAccountList,
      //     {
      //       discountTotal: discountRmb,
      //       currencyId: 2,
      //       receivableAmount: rmb,
      //       writeOffRate: t?.writeOffRate || (this.showCurrencyId === 1 ? this.RMBtoUS() : this.showCurrencyId === 2 ? 1 : this.RMBtoNAN()),
      //       platformAccountId: t?.platformAccountId || '',
      //       collectionCurrencyId: t?.collectionCurrencyId || '',
      //       collectionRate: t?.collectionRate || ''
      //     }
      //   ]
      //   this.calculationCount(NP.minus(rmb, discountRmb), 2)
      // }
      // const nairaList = this.list.filter(v => v.currencyId === 3)
      // let naira,discountNaira
      // if (nairaList.length > 0) {
      //   naira = nairaList.reduce((total, currentValue) => NP.plus(total, currentValue.totalAmount || 0), 0)
      //   discountNaira = nairaList.reduce((total, currentValue) => NP.plus(total, currentValue.discountTotal || 0), 0)
      //   const t = copyList.find(v => v.currencyId == 3)
      //   this.form.receiptAccountList = [
      //     ...this.form.receiptAccountList,
      //     {
      //       discountTotal: discountNaira,
      //       currencyId: 3,
      //       receivableAmount: naira,
      //       writeOffRate: t?.writeOffRate || (this.showCurrencyId === 1 ? this.NANtoUS() : this.showCurrencyId === 2 ? this.NANtoRMB() : 1),
      //       platformAccountId: t?.platformAccountId || '',
      //       collectionCurrencyId: t?.collectionCurrencyId || '',
      //       collectionRate: t?.collectionRate || '',
      //       collectionAmount:discountNaira
      //     }
      //   ]
      //   this.calculationCount(NP.minus(naira, discountNaira), 3)
      // }
1267 1268 1269 1270 1271
      if (this.form.receiptAccountList.length > 0) {
        // totalAmount
        const totalt = this.form.receiptAccountList.reduce((total, currentValue) => NP.plus(total, currentValue.writeOffAmount || 0), 0)
        this.form.receiptAccountList = [...this.form.receiptAccountList, {
          type: 'total',
我在何方's avatar
我在何方 committed
1272 1273
          writeOffAmount:totalt.toFixed(2),
          collectionAmount: []
1274 1275
        }]

我在何方's avatar
我在何方 committed
1276
        this.form.receivableTotalAmount = totalt.toFixed(2)
1277 1278 1279 1280 1281 1282 1283
      }
      // receiptAccountList: [
          // { currencyId: 1, receivableAmount: 0, writeOffRate: 1, writeOffAmount: 999, platformAccountId: '', currencyId: '', rate: 1, collectionAmount: 0 },
          // { currencyId: 2, receivableAmount: 0, writeOffRate: 1, writeOffAmount: 999, platformAccountId: '', currencyId: '', rate: 1, collectionAmount: 0 },
          // { currencyId: 3, receivableAmount: 0, writeOffRate: 1, writeOffAmount: 999, platformAccountId: '', currencyId: '', rate: 1, collectionAmount: 0 },
        // ]

1284
      if (this.showCurrencyId === 1) { // 美元
1285 1286 1287 1288 1289 1290 1291
        // const usCount = NP.plus(dollar, NP.times(this.RMBtoUS(), rmb),  NP.times(this.NANtoUS(), naira))
        // this.form.receivableDetailList[0].rate = 1
        // this.form.receivableDetailList[0].amount = usCount
        // this.form.receivableDetailList[1].rate || (this.form.receivableDetailList[1].rate = this.UStoRMB())
        // this.form.receivableDetailList[2].rate || (this.form.receivableDetailList[2].rate = this.UStoNAN())
        // this.form.receivableTotalAmount = usCount
        // this.calculationCount(usCount)
1292
      } else if (this.showCurrencyId === 2) { // 人民币
1293 1294 1295 1296 1297 1298 1299
        // const rmbCount = NP.plus(rmb, NP.times(this.UStoRMB(), dollar),  NP.times(this.NANtoRMB(), naira))
        // this.form.receivableDetailList[1].rate = 1
        // this.form.receivableDetailList[1].amount = usCount
        // this.form.receivableDetailList[0].rate || (this.form.receivableDetailList[0].rate = this.RMBtoUS())
        // this.form.receivableDetailList[2].rate || (this.form.receivableDetailList[2].rate = this.RMBtoNAN())
        // this.form.receivableTotalAmount = rmbCount
        // this.calculationCount(rmbCount)
1300
      } else if (this.showCurrencyId === 3) { // 奈拉
1301 1302 1303 1304 1305 1306 1307
        // const nairaCount = NP.plus(naira, NP.times(this.UStoNAN(), dollar),  NP.times(this.RMBtoNAN(), rmb))
        // this.form.receivableDetailList[2].rate = 1
        // this.form.receivableDetailList[2].amount = nairaCount
        // this.form.receivableDetailList[0].rate || (this.form.receivableDetailList[0].rate = this.NANtoUS())
        // this.form.receivableDetailList[1].rate || (this.form.receivableDetailList[1].rate = this.NANtoRMB())
        // this.form.receivableTotalAmount = nairaCount
        // this.calculationCount(nairaCount)
1308
      }
1309 1310

      this.$set(this.form, 'receiptAccountList', [...this.form.receiptAccountList])
1311
    },
1312 1313 1314 1315
    calculationCount(usCount, type) {
      const index = this.form.receiptAccountList.findIndex(v => v.currencyId == type)
      const t = this.form.receiptAccountList[index]
      if (t) {
1316
        t.writeOffAmount = NP.times(t.writeOffRate || 0, usCount).toFixed(2)
1317
        this.rateChange(t, index)
1318 1319 1320
      }
    },
    RMBtoUS() {
我在何方's avatar
我在何方 committed
1321
      return NP.divide(100, this.currencyList.find(v => v.titleEn === 'USD').huilv).toFixed(6)
1322 1323
    },
    NANtoUS() {
我在何方's avatar
我在何方 committed
1324
      return NP.times(this.RMBtoUS(), this.NANtoRMB()).toFixed(6)
1325 1326
    },
    UStoRMB() {
我在何方's avatar
我在何方 committed
1327
      return NP.divide(this.currencyList.find(v => v.titleEn === 'USD').huilv, 100).toFixed(6)
1328 1329
    },
    UStoNAN() {
我在何方's avatar
我在何方 committed
1330
      return NP.times(this.RMBtoNAN(), this.UStoRMB()).toFixed(6)
1331 1332
    },
    RMBtoNAN() {
我在何方's avatar
我在何方 committed
1333
      return NP.divide(100, this.currencyList.find(v => v.titleEn === 'NGN').huilv).toFixed(6)
1334 1335
    },
    NANtoRMB() {
我在何方's avatar
我在何方 committed
1336
      return NP.divide(this.currencyList.find(v => v.titleEn === 'NGN').huilv, 100).toFixed(6)
1337 1338
    },
    customerChange(value) {
我在何方's avatar
我在何方 committed
1339
      if (this.flag||!value) {
吴滔's avatar
吴滔 committed
1340 1341 1342
        this.flag = false
        return
      }
1343
      this.form.customerName = value.payerName?value.payerName:value.name
1344 1345 1346
      this.form.customerId && getCustomer(this.form.customerId).then(res => {
        this.form = {
          ...this.form,
吴滔's avatar
吴滔 committed
1347 1348 1349 1350 1351 1352 1353
          invoice: res.data.invoiceTitle,
          taxpayer: res.data.licenseNumber,
          accountBank: res.data.bank,
          accountName: res.data.bankNumber,
          projectName: res.data.project,
          taxRate: res.data.taxRate,
          addressPhone: `${res.data.billingAddress || ''}/${res.data.billingTell || ''}`,
1354 1355
        }
      })
吴滔's avatar
吴滔 committed
1356 1357 1358 1359 1360 1361 1362 1363 1364
    },
    cancelDiscount() {
      this.discountVisible = false
      this.discountForm = {}
      this.selectListRow = {}
    },
    addDiscount(row, index) {
      this.discountVisible = true
      this.selectListRow = { ...row }
我在何方's avatar
我在何方 committed
1365
      console.log(this.selectListRow)
吴滔's avatar
吴滔 committed
1366 1367 1368 1369 1370 1371 1372 1373
      this.selectListIndex = index
      this.$set(this.discountForm, 'time', dayjs().format('YYYY-MM-DD HH:mm:ss'))
      getReceivableDiscountLogById({ id: row.id }).then(res => {
        if (res.data?.creatorName) {
          this.$set(this.discountForm, 'time', dayjs(res.data.createTime).format('YYYY-MM-DD HH:mm:ss'))
          this.$set(this.discountForm, 'discountTotal', res.data.discountTotal)
          this.$set(this.discountForm, 'discountRemark', res.data.discountRemark)
          this.$set(this.discountForm, 'author', res.data.creatorName)
我在何方's avatar
我在何方 committed
1374 1375 1376
          this.opnotice = true
        }else{
          this.opnotice = false
1377 1378 1379
          this.$set(this.discountForm, 'discountTotal', '')
          this.$set(this.discountForm, 'discountRemark', '')
          this.$set(this.discountForm, 'author', '')
吴滔's avatar
吴滔 committed
1380 1381 1382 1383 1384 1385
        }
      })
    },
    saveDiscount() {
      console.log(this.discountForm)
      // this.selectListRow.id
我在何方's avatar
我在何方 committed
1386
      if (this.discountForm.discountTotal === 0||!this.discountForm.discountTotal) {
吴滔's avatar
吴滔 committed
1387
        this.$modal.msgError(this.$t('优惠金额不能为空'));
我在何方's avatar
我在何方 committed
1388 1389 1390
        return
      }
      if (this.discountForm.discountRemark === 0||!this.discountForm.discountRemark) {
吴滔's avatar
吴滔 committed
1391
        this.$modal.msgError(this.$t('优惠原因不能为空'));
我在何方's avatar
我在何方 committed
1392 1393
        return
      }
吴滔's avatar
吴滔 committed
1394 1395 1396 1397 1398 1399
      const params = {
        id: this.selectListRow.id,
        discountTotal: this.discountForm.discountTotal,
        discountRemark: this.discountForm.discountRemark,
        orderNo: this.selectListRow.orderNo,
        orderId: this.selectListRow.orderId,
我在何方's avatar
我在何方 committed
1400 1401
        taxPoint:this.selectListRow.taxPoint,
        taxAmount:this.selectListRow.taxAmount,
吴滔's avatar
吴滔 committed
1402
      }
1403
       updateReceivableDiscountById(params).then(res => {
吴滔's avatar
吴滔 committed
1404
        if (this.selectListRow.discountTotal) {
吴滔's avatar
吴滔 committed
1405
          this.$modal.msgSuccess(this.$t('修改成功'));
吴滔's avatar
吴滔 committed
1406
        } else {
吴滔's avatar
吴滔 committed
1407
          this.$modal.msgSuccess(this.$t('新增成功'));
吴滔's avatar
吴滔 committed
1408
        }
我在何方's avatar
我在何方 committed
1409 1410 1411 1412 1413 1414 1415
        // if(this.id>0){
        //    getInvoicingItem({ id: this.id }).then(res => {
        //     this.list = [...res.data]
        //     this.cancelDiscount()
        //     this.calculation()
        //   })
        // }else{
1416 1417
          var discount = this.list[this.selectListIndex]
          discount['discountTotal'] = this.discountForm.discountTotal
1418
          discount['discountRemark'] = this.discountForm.discountRemark
我在何方's avatar
我在何方 committed
1419
          setTimeout(()=>{
1420 1421
            // getReceivableInfoByIds({ id: this.selectListRow.id }).then(res => {
              this.$set(this.list, this.selectListIndex, {...discount})
我在何方's avatar
我在何方 committed
1422 1423
              this.cancelDiscount()
              this.calculation()
1424
            // })
我在何方's avatar
我在何方 committed
1425 1426 1427 1428 1429 1430
          },1000)


        // }


吴滔's avatar
吴滔 committed
1431
      })
吴滔's avatar
吴滔 committed
1432 1433 1434 1435 1436 1437 1438 1439 1440
    },
    getList() {
      this.loading1 = true;
      // 处理查询参数
      let params = { ...this.queryParams };
      this.addBeginAndEndTime(params, this.dateType, "createTime");
      // 执行查询
      getReceivableList(params).then((response) => {
        this.orderData = response.data.list;
吴滔's avatar
吴滔 committed
1441
        this.dialogTableKey ++
吴滔's avatar
吴滔 committed
1442 1443
        this.total = response.data.total;
        this.loading1 = false;
1444 1445 1446 1447 1448 1449
        this.$nextTick(() => {
          this.list.forEach(itm => {
            const t = this.orderData.find(v => v.id == itm.id)
            t && this.$refs.multipleTable.toggleRowSelection(t, true)
          })
        })
吴滔's avatar
吴滔 committed
1450 1451 1452 1453
      });
    },
    /** 新增按钮操作 */
    handleAdd() {
我在何方's avatar
我在何方 committed
1454
      this.queryParams.customerId=this.form.customerId
我在何方's avatar
我在何方 committed
1455
      this.multipleSelection = this.list
吴滔's avatar
吴滔 committed
1456 1457 1458 1459
      this.open = true;
    },
    hiddenDialog() {
      this.open = false;
我在何方's avatar
我在何方 committed
1460
      this.queryParams.customerId=''
吴滔's avatar
吴滔 committed
1461
    },
1462 1463 1464
    changePlatformAccountId(platformAccountId,index){
      this.form.receiptAccountList[index].platformAccountId = platformAccountId
    },
1465
    submitForm(addType) {
我在何方's avatar
我在何方 committed
1466 1467
      // const params = {...this.form}
      const params = JSON.parse(JSON.stringify(this.form))
我在何方's avatar
我在何方 committed
1468
      params.addType = addType
1469
      // params.receiptAccountList = params.receiptAccountList.map(v => Object.assign(v, {  }))
我在何方's avatar
我在何方 committed
1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484
      if(!params.customerId){
        this.saveBtnLoading = false
        this.$modal.msgError(this.$t('客户不能为空'));
        return
      }
      if(!params.departmentId){
        this.saveBtnLoading = false
        this.$modal.msgError(this.$t('部门不能为空'));
        return
      }
      if(!params.salesmanId){
        this.saveBtnLoading = false
        this.$modal.msgError(this.$t('业务员不能为空'));
        return
      }
1485 1486
      if(params.openInvoice!=0&&params.openInvoice!=1){
        console.log(params.openInvoice)
我在何方's avatar
我在何方 committed
1487 1488 1489 1490
        this.saveBtnLoading = false
        this.$modal.msgError(this.$t('请选择是否需要开票'));
        return
      }
1491 1492
      if (this.list && this.list.length > 0) {
        params.receivableVOList = this.list
1493
      }else{
我在何方's avatar
我在何方 committed
1494
        this.saveBtnLoading = false
吴滔's avatar
吴滔 committed
1495
        this.$modal.msgError(this.$t('请添加未收客户款项'));
1496 1497
        return
      }
我在何方's avatar
我在何方 committed
1498

我在何方's avatar
我在何方 committed
1499
      // params.receiptAccountList.length = params.receiptAccountList.length - 1
我在何方's avatar
我在何方 committed
1500

我在何方's avatar
我在何方 committed
1501
      var saveStatus = true
我在何方's avatar
我在何方 committed
1502 1503
      var writeStatus = true
      var reatStatus = true
我在何方's avatar
我在何方 committed
1504
      params.receiptAccountList.forEach(v => {
我在何方's avatar
我在何方 committed
1505

我在何方's avatar
我在何方 committed
1506 1507 1508 1509
        if(v.type!='total'){
          if(!v.platformAccountId){
            saveStatus = false
          }
我在何方's avatar
我在何方 committed
1510 1511 1512 1513 1514 1515
          if(!v.writeOffRate){
           writeStatus = false
          }
          if(!v.collectionRate){
           reatStatus = false
          }
我在何方's avatar
我在何方 committed
1516 1517 1518 1519 1520 1521 1522 1523
          var bankname = this.bankData.filter(item=>item.id == v.platformAccountId)
          if(bankname.length>0){
            v.platformAccountName = bankname[0].baAccountName
            v.platformAccountNo = bankname[0].baAccountNum
            v.platformAccountBlankName = bankname[0].baBankName
          }
          delete v.discountTotal
          v.writeOffRate = Number(v.writeOffRate)
我在何方's avatar
我在何方 committed
1524
        }
我在何方's avatar
我在何方 committed
1525
      })
我在何方's avatar
我在何方 committed
1526 1527 1528 1529 1530
      if(!writeStatus){
        this.$modal.msgError(this.$t('核销基准币种汇率不能为0,请输入正确的汇率'));
        return
      }

我在何方's avatar
我在何方 committed
1531 1532 1533 1534
      if(!saveStatus){
        this.$modal.msgError(this.$t('请添加收款账户'));
        return
      }
我在何方's avatar
我在何方 committed
1535 1536 1537 1538
      if(!reatStatus){
        this.$modal.msgError(this.$t('期望收款汇率不能为0,请输入正确的汇率'));
        return
      }
我在何方's avatar
我在何方 committed
1539 1540 1541
      delete params.receivableDetail


1542
      if (addType === 1) {
吴滔's avatar
吴滔 committed
1543
            this.saveBtnLoading = true
我在何方's avatar
我在何方 committed
1544
            params.receiptAccountList.splice(params.receiptAccountList.length - 1,1)
我在何方's avatar
我在何方 committed
1545
            if (this.id && this.id != 0) {
我在何方's avatar
我在何方 committed
1546
              params.updateType = 0
1547
              updateReceipt(params).then(res => {
我在何方's avatar
我在何方 committed
1548
                this.$modal.msgSuccess(this.$t('提交成功'));
我在何方's avatar
我在何方 committed
1549
                this.$store.dispatch('tagsView/delCurrentView')
吴滔's avatar
吴滔 committed
1550 1551
              }).finally(() => {
                this.saveBtnLoading = false
1552 1553
              })
            } else {
1554
              params.currencyId = this.showCurrencyId
1555
              createReceipt(params).then(res => {
吴滔's avatar
吴滔 committed
1556
                this.$modal.msgSuccess(this.$t('保存成功'));
我在何方's avatar
我在何方 committed
1557
                this.$store.dispatch('tagsView/delCurrentView')
吴滔's avatar
吴滔 committed
1558 1559
              }).finally(() => {
                this.saveBtnLoading = false
1560 1561 1562 1563
              })
            }
        return
      }
1564 1565
        this.saveBtnLoading = true
        params.receiptAccountList.splice(params.receiptAccountList.length - 1,1)
我在何方's avatar
我在何方 committed
1566

1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583
        if (this.id && this.id != 0) {
          // if(params.state==0) params.state = 1
           params.updateType = 1
          updateReceipt(params).then(res => {
            this.$modal.msgSuccess(this.$t('修改成功'));
            this.$store.dispatch('tagsView/delCurrentView')
          }).finally(() => {
            this.saveBtnLoading = false
          })
        } else {
          params.currencyId = this.showCurrencyId
          createReceipt(params).then(res => {
            this.$modal.msgSuccess(this.$t('新增成功'));
             this.$store.dispatch('tagsView/delCurrentView')
          }).finally(() => {
            this.saveBtnLoading = false
          })
1584
        }
吴滔's avatar
吴滔 committed
1585 1586 1587 1588
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
我在何方's avatar
我在何方 committed
1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602
    removedup(arr, batch) {
      if (!Array.isArray(arr)) {
        return arr;
      }
      if (arr.length == 0) {
        return [];
      }
      let obj = {};
      let uniqueArr = arr.reduce(function (total, item) {
        obj[item[batch]] ? '' : (obj[item[batch]] = true && total.push(item));
        return total;
      }, []);
      return uniqueArr;
    },
吴滔's avatar
吴滔 committed
1603
    saveSelectList() {
我在何方's avatar
我在何方 committed
1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615
      this.multipleSelection.map(v=>{
        if(!v.taxPoint){
          v.taxAmount = v.totalAmount
        }
      })
      if(this.list.length>0){
        this.list = this.list.concat(this.multipleSelection)
        this.list = this.removedup(this.list,'id')
      }else{
        this.list = this.multipleSelection
      }

吴滔's avatar
吴滔 committed
1616
      this.open = false;
1617
      this.calculation()
吴滔's avatar
吴滔 committed
1618
    },
吴滔's avatar
吴滔 committed
1619 1620 1621 1622
    deleteListRow(index) {
      const list = [...this.list]
      delete list[index]
      this.list = list.filter(v => v)
我在何方's avatar
我在何方 committed
1623
      this.calculation()
吴滔's avatar
吴滔 committed
1624
    },
吴滔's avatar
吴滔 committed
1625 1626 1627
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.page = 1;
吴滔's avatar
吴滔 committed
1628
      this.getList()
1629
    },
我在何方's avatar
我在何方 committed
1630 1631
    //清空数据
    removeData(){
我在何方's avatar
我在何方 committed
1632 1633 1634 1635 1636
      this.id = 0
       this.flag = false
      this.discountForm = {
        author:''
      }
我在何方's avatar
我在何方 committed
1637 1638 1639 1640 1641 1642 1643 1644 1645 1646
      this.$refs.customer.reset()
      this.list = []
      for(var i in this.form){
        if(i=='receiptAccountList'){
          this.$set(this.form,i,[])
        }else{
          this.$set(this.form,i,'')
        }
      }
    }
吴滔's avatar
吴滔 committed
1647 1648
  },
};
1649 1650
</script>

1651
<style scoped lang="scss">
吴滔's avatar
吴滔 committed
1652 1653 1654 1655
.card {
  margin-top: 20px;
}
.dialog-footer {
吴滔's avatar
吴滔 committed
1656 1657
  // padding: 40px;
  text-align: left;
吴滔's avatar
吴滔 committed
1658 1659 1660 1661 1662
}
.card-title {
  font-size: 18px;
  font-weight: bold;
}
1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673
::v-deep .el-descriptions-item__label {
  width: 200px;
}
.amountCard {
  ::v-deep .el-descriptions-item__label {
    width: 20%;
  }
  ::v-deep .el-descriptions-item__content {
    width: 30%;
  }
}
1674 1675 1676 1677 1678 1679
  .bpm-title{
    font-size: 20px;
    font-weight: bold;
    color:#666;
    margin:20px 0;
  }
1680
</style>