creatCollection.vue 64.1 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>
吴滔's avatar
吴滔 committed
21
              <customer-selector
我在何方'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="selfNo" />
吴滔'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`"
              >
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"
                  />
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:''}}</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 521 522 523 524 525
              <customer-selector
                v-model="queryParams.consignorId"
                @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="selfNo">
吴滔's avatar
吴滔 committed
536
            <el-input
吴滔's avatar
吴滔 committed
537
              v-model="queryParams.selfNo"
吴滔's avatar
吴滔 committed
538
              :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="selfNo" />
吴滔'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 695 696 697 698
import { DICT_TYPE } from "@/utils/dict";
import { getToken } from "@/utils/auth";
import CustomerSelector from "@/components/CustomerSelector";
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
699
import { createReceipt,getFirstReceivableListByOrderId, getReceivableList, getReceivableItemDetail, getReceiptInfoByIds, getReceiptAccountList, getInvoicingItem, updateReceipt, updateReceivableDiscountById, getReceivableDiscountLogById } from "@/api/ecw/financial";
700 701
import {getCustomer} from '@/api/ecw/customer'
import NP from 'number-precision'
702
import {getOrder} from '@/api/ecw/order'
703
import { getCurrencyPage } from "@/api/ecw/currency";
我在何方's avatar
我在何方 committed
704
import { getExchangeRatePage } from "@/api/ecw/exchangeRate";
705
import ret from "bluebird/js/release/util";
吴滔's avatar
吴滔 committed
706 707
import dayjs from "dayjs";
import { getUserProfile } from "@/api/system/user";
我在何方's avatar
我在何方 committed
708
import {getWarehouseList} from '@/api/ecw/warehouse'
709
import WorkFlow from '@/components/WorkFlow/'
710

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

770
      },
我在何方's avatar
我在何方 committed
771 772 773
      pages:1,
      rateList:[],
      orderNo:null
吴滔's avatar
吴滔 committed
774 775
    };
  },
我在何方's avatar
我在何方 committed
776 777 778 779 780 781
  activated(){
    if (this.$route.query.id) {
      this.flag = true
      this.id = this.$route.query.id;
      this.getReceivableData()
    }
我在何方's avatar
我在何方 committed
782
    if (this.$route.query.receiptId && this.$route.query.receiptId != 0) {
我在何方's avatar
我在何方 committed
783

我在何方's avatar
我在何方 committed
784
      this.receiptId = this.$route.query.receiptId;
我在何方's avatar
我在何方 committed
785
      this.orderNo = this.$route.query.orderNo||'';
我在何方's avatar
我在何方 committed
786
      this.getReceivableInfo()
我在何方's avatar
我在何方 committed
787 788
    }else{
      this.removeData()
我在何方's avatar
我在何方 committed
789
    }
我在何方's avatar
我在何方 committed
790 791 792 793 794
    getUserProfile().then(res => {
      this.discountForm.author = res.data.username
      this.form.departmentId = res.data.deptId
      this.form.salesmanId = res.data.id
    })
我在何方's avatar
我在何方 committed
795
  },
796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811
  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()
            }
          })
        }
      }
    },
812
  async created() {
我在何方's avatar
我在何方 committed
813
    await getUserProfile().then(res => {
吴滔's avatar
吴滔 committed
814
      this.discountForm.author = res.data.username
我在何方's avatar
我在何方 committed
815 816
      this.form.departmentId = res.data.deptId
      this.form.salesmanId = res.data.id
吴滔's avatar
吴滔 committed
817
    })
818 819
    // 获取汇率
    await getCurrencyPage(this.params).then(res => this.currencyList = res.data.list)
我在何方's avatar
我在何方 committed
820
    await getExchangeRatePage(this.params).then(res => this.rateList = res.data.list)
我在何方's avatar
我在何方 committed
821
    getWarehouseList().then(res => this.warehouseList = res.data)
吴滔's avatar
吴滔 committed
822
    let that = this;
823 824 825
    if (that.$route.query.orderId) {
      await getFirstReceivableListByOrderId({id:that.$route.query.orderId}).then(response => {
        this.list = [...response.data]
826
        this.list.map(v=>{
我在何方's avatar
我在何方 committed
827
          if(!v.taxPoint){
828 829 830
            v.taxAmount = v.totalAmount
          }
        })
831
        this.calculation()
832 833 834 835 836 837
        getOrder(that.$route.query.orderId).then(response => {
          // console.log(response.data)
          if(response.data.customerId) this.$set(this.form,'customerId',response.data.customerId)
        })
    })
    }
吴滔's avatar
吴滔 committed
838
    if (that.$route.query.id) {
吴滔's avatar
吴滔 committed
839
      this.flag = true
吴滔's avatar
吴滔 committed
840
      this.id = this.$route.query.id;
我在何方's avatar
我在何方 committed
841
      this.getReceivableData()
842 843 844
    }
    if (that.$route.query.receiptId && that.$route.query.receiptId !== '0') {
      this.receiptId = this.$route.query.receiptId;
我在何方's avatar
我在何方 committed
845
      this.orderNo = this.$route.query.orderNo||'';
我在何方's avatar
我在何方 committed
846
      this.getReceivableInfo()
吴滔's avatar
吴滔 committed
847
    }
848 849

    // this.getList();
吴滔's avatar
吴滔 committed
850 851 852 853 854 855
    // if(that.$route.query.consignorId){
    //   this.queryParams.consignorId = this.$route.query.consignorId
    // }
    // if(that.$route.query.writeOffName){
    //   this.form.writeOffName = this.$route.query.writeOffName
    // }
856
    listSimpleUsers().then((res) => (that.creatorData = res.data));
吴滔's avatar
吴滔 committed
857 858
    getChannelList().then((res) => (that.channelList = res.data));
    getTradeCityList().then((res) => (that.tradeCityList = res.data));
859
    this.getCodeList()
吴滔's avatar
吴滔 committed
860
    listSimpleDepts().then((res) => {
我在何方's avatar
我在何方 committed
861 862 863 864 865 866 867 868
      that.deptData =  res.data
      // res.data.forEach((item) => {
      //   if (item.parentId == 0) {
      //     that.deptArr.push(item);
      //   } else {
      //     that.deptData.push(item);
      //   }
      // });
吴滔's avatar
吴滔 committed
869

我在何方's avatar
我在何方 committed
870 871 872 873 874 875
      // 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
876 877 878 879
    });
  },
  computed: {
    expoerCityList() {
我在何方's avatar
我在何方 committed
880 881
      // return this.tradeCityList.filter((item) => item.type == 2);
      return this.warehouseList.filter(item => item.tradeType == 2 || item.tradeType == 3)
吴滔's avatar
吴滔 committed
882 883
    },
    importCityList() {
我在何方's avatar
我在何方 committed
884 885
      // return this.tradeCityList.filter((item) => item.type == 1);
      return this.warehouseList.filter(item => item.tradeType == 1 || item.tradeType == 3)
吴滔's avatar
吴滔 committed
886
    },
887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909
    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
910 911
  },
  methods: {
912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930
// 懒加载
    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)
931
            this.pages = (res.data.total/this.codePage.pageSize)+1
932 933 934
            })
        }, 200)
    },
我在何方's avatar
我在何方 committed
935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982
    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)
      })
       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',
            writeOffAmount: res.data.reduce((total, currentValue) => NP.plus(total, currentValue.writeOffAmount || 0), 0),
            collectionAmount: []
          }]
        }
        this.$set(this.form, 'receiptAccountList', [...res.data])
        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)

          this.form.receiptAccountList.forEach((item, index) => {
            this.rateChange(item, index)

          });
          this.calculation()
        })
      })
    },
    getReceivableInfo(){
我在何方's avatar
我在何方 committed
983 984
      getReceivableItemDetail({ id: this.receiptId,orderNo:this.orderNo }).then(res => {
        this.list = res.data
我在何方's avatar
我在何方 committed
985 986 987 988 989 990 991 992 993 994 995 996 997
        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
998 999
	  getCurrencyLabel(id){
	    var label = this.currencyList.filter(item=>item.id == id)
我在何方's avatar
我在何方 committed
1000
	    if(label.length>0) return this.$i18n.locale=='zh_CN'?label[0].titleZh:label[0].titleEn
我在何方's avatar
我在何方 committed
1001 1002
	    return ''
	  },
我在何方's avatar
我在何方 committed
1003 1004 1005 1006 1007
    checkDiscount(e){
      if(e>this.selectListRow.totalAmount){
        this.discountForm.discountTotal = this.selectListRow.totalAmount
      }
    },
1008 1009 1010 1011
    currencyIdChange(val, row, index) {
      row.collectionCurrencyId = val
      if (val == row.currencyId) row.collectionRate = 1
      else {
我在何方's avatar
我在何方 committed
1012 1013 1014 1015 1016 1017
        // 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
1018 1019
         // 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)
1020
      }
我在何方's avatar
我在何方 committed
1021

1022 1023
      this.rateChange(row, index)
    },
我在何方's avatar
我在何方 committed
1024 1025 1026 1027 1028 1029
    //获取汇率
    getRate(sourceCurrencyId,targetCurrencyId){
      var rate = this.rateList.find(v=>(v.sourceCurrencyId === sourceCurrencyId&&v.targetCurrencyId===targetCurrencyId))
      if(rate) return rate.currencyRate
      return 1
    },
吴滔's avatar
吴滔 committed
1030
    writeOffRateChange(row, index) {
我在何方's avatar
我在何方 committed
1031
      row.writeOffAmount = Math.round(NP.times(row.writeOffRate || 0, NP.minus(row.receivableAmount, row.discountTotal)))
吴滔's avatar
吴滔 committed
1032 1033 1034 1035

      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
    },
1036
    rateChange(row, index) {
我在何方's avatar
我在何方 committed
1037
      console.log(row)
我在何方's avatar
我在何方 committed
1038
      row.receivableAmount && (row.collectionAmount = Math.round(NP.times(row.collectionRate || 0, NP.minus(row.receivableAmount, row.discountTotal||0))))
1039 1040 1041 1042
      this.form.receiptAccountList[index] = {...row}

      setTimeout(() => {
        // 收款总计
我在何方's avatar
我在何方 committed
1043 1044 1045 1046
        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
1047
            var dollar = Math.round(dollarList.reduce((total, currentValue) => NP.plus(total, currentValue.collectionAmount), 0))
我在何方's avatar
我在何方 committed
1048
            amountList.push({currencyId:item.id,currencyNameEn:item.titleEn,currencyNameZh:item.titleZh,amount:dollar})
我在何方's avatar
我在何方 committed
1049 1050 1051 1052
          }
        })
        // const dollarList = this.form.receiptAccountList.filter(v => v.collectionCurrencyId == 1)
        // const dollar = dollarList.reduce((total, currentValue) => NP.plus(total, currentValue.collectionAmount), 0)
1053

我在何方's avatar
我在何方 committed
1054 1055
        // const rmbList = this.form.receiptAccountList.filter(v => v.collectionCurrencyId == 3)
        // const rmb = rmbList.reduce((total, currentValue) => NP.plus(total, currentValue.collectionAmount), 0)
1056

我在何方's avatar
我在何方 committed
1057 1058 1059 1060 1061
        // const nairaList = this.form.receiptAccountList.filter(v => v.collectionCurrencyId == 2)
        // const naira = nairaList.reduce((total, currentValue) => NP.plus(total, currentValue.collectionAmount), 0)
        // const faList = this.form.receiptAccountList.filter(v => v.collectionCurrencyId == 6)
        // const fa = faList.reduce((total, currentValue) => NP.plus(total, currentValue.collectionAmount), 0)
        this.form.receiptAccountList[this.form.receiptAccountList.length -1].collectionAmount = amountList
1062 1063 1064
        this.$set(this.form, 'receiptAccountList', [...this.form.receiptAccountList])
      }, 100)
    },
1065 1066
    //明细改变税率
    changeTaxRate(row,index){
1067
      var pointArr = []
我在何方's avatar
我在何方 committed
1068
      var regs=/^[0-9]+\d*(\.\d*)?$|^0?\.\d*[0-9]\d*$/;
1069
      if(row.taxPoint&&!regs.test(row.taxPoint)){
1070
        row.taxPoint = ''
1071
        this.$modal.msgError(this.$t('输入税率格式不对'));
1072 1073 1074 1075 1076 1077
      }else{
         pointArr = row.taxPoint.split('.')
         if(pointArr.length>1&&pointArr[1]){
           row.taxPoint =Math.round(row.taxPoint*100)/100
         }

1078
      }
我在何方's avatar
我在何方 committed
1079 1080 1081 1082 1083 1084 1085
      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
      }

1086
      this.list[index] = {...row}
我在何方's avatar
我在何方 committed
1087 1088
      let dataArrTemp = JSON.stringify(this.list);
      this.list= JSON.parse(dataArrTemp);
1089 1090 1091 1092 1093 1094
      if(pointArr.length>1&&!pointArr[1]){
        return
      }else{
        this.calculation()
      }

1095
    },
1096
    calculation() {
1097 1098
      const copyList = this.form.receiptAccountList
      this.form.receiptAccountList = []
我在何方's avatar
我在何方 committed
1099 1100 1101 1102
      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
1103
            dollar = dollarList.reduce((total, currentValue) => NP.plus(total, currentValue.taxAmount || 0), 0)
我在何方's avatar
我在何方 committed
1104 1105
            discountDollar = dollarList.reduce((total, currentValue) => NP.plus(total, currentValue.discountTotal || 0), 0)
            var t = copyList.find(v => v.currencyId == item.id)
1106
            console.log(discountDollar)
我在何方's avatar
我在何方 committed
1107 1108 1109 1110
            this.form.receiptAccountList.push(
              {
                discountTotal: discountDollar,
                currencyId: item.id,
我在何方's avatar
我在何方 committed
1111
                receivableAmount: Math.round(dollar),
我在何方's avatar
我在何方 committed
1112
                writeOffRate: item.id==this.showCurrencyId?1: this.getRate(item.id,this.showCurrencyId),
我在何方's avatar
我在何方 committed
1113
                platformAccountId: t?.platformAccountId || '',
1114 1115
                collectionCurrencyId:  item.id,
                collectionRate: 1
我在何方's avatar
我在何方 committed
1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180
              }
            )
            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)
      // }
1181 1182 1183 1184 1185
      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
1186
          writeOffAmount: Math.round(totalt),
我在何方's avatar
我在何方 committed
1187
          collectionAmount: [this.form.receiptAccountList.discountNaira, 0, 0]
1188 1189 1190 1191 1192 1193 1194 1195 1196 1197
        }]

        this.form.receivableTotalAmount = totalt
      }
      // 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 },
        // ]

1198
      if (this.showCurrencyId === 1) { // 美元
1199 1200 1201 1202 1203 1204 1205
        // 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)
1206
      } else if (this.showCurrencyId === 2) { // 人民币
1207 1208 1209 1210 1211 1212 1213
        // 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)
1214
      } else if (this.showCurrencyId === 3) { // 奈拉
1215 1216 1217 1218 1219 1220 1221
        // 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)
1222
      }
1223 1224

      this.$set(this.form, 'receiptAccountList', [...this.form.receiptAccountList])
1225
    },
1226 1227 1228 1229
    calculationCount(usCount, type) {
      const index = this.form.receiptAccountList.findIndex(v => v.currencyId == type)
      const t = this.form.receiptAccountList[index]
      if (t) {
我在何方's avatar
我在何方 committed
1230
        t.writeOffAmount = Math.round(NP.times(t.writeOffRate || 0, usCount))
1231
        this.rateChange(t, index)
1232 1233 1234
      }
    },
    RMBtoUS() {
我在何方's avatar
我在何方 committed
1235
      return NP.divide(100, this.currencyList.find(v => v.titleEn === 'USD').huilv).toFixed(6)
1236 1237
    },
    NANtoUS() {
我在何方's avatar
我在何方 committed
1238
      return NP.times(this.RMBtoUS(), this.NANtoRMB()).toFixed(6)
1239 1240
    },
    UStoRMB() {
我在何方's avatar
我在何方 committed
1241
      return NP.divide(this.currencyList.find(v => v.titleEn === 'USD').huilv, 100).toFixed(6)
1242 1243
    },
    UStoNAN() {
我在何方's avatar
我在何方 committed
1244
      return NP.times(this.RMBtoNAN(), this.UStoRMB()).toFixed(6)
1245 1246
    },
    RMBtoNAN() {
我在何方's avatar
我在何方 committed
1247
      return NP.divide(100, this.currencyList.find(v => v.titleEn === 'NGN').huilv).toFixed(6)
1248 1249
    },
    NANtoRMB() {
我在何方's avatar
我在何方 committed
1250
      return NP.divide(this.currencyList.find(v => v.titleEn === 'NGN').huilv, 100).toFixed(6)
1251 1252
    },
    customerChange(value) {
我在何方's avatar
我在何方 committed
1253
      if (this.flag||!value) {
吴滔's avatar
吴滔 committed
1254 1255 1256
        this.flag = false
        return
      }
1257 1258 1259 1260
      this.form.customerName = value.name
      this.form.customerId && getCustomer(this.form.customerId).then(res => {
        this.form = {
          ...this.form,
吴滔's avatar
吴滔 committed
1261 1262 1263 1264 1265 1266 1267
          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 || ''}`,
1268 1269
        }
      })
吴滔's avatar
吴滔 committed
1270 1271 1272 1273 1274 1275 1276 1277 1278
    },
    cancelDiscount() {
      this.discountVisible = false
      this.discountForm = {}
      this.selectListRow = {}
    },
    addDiscount(row, index) {
      this.discountVisible = true
      this.selectListRow = { ...row }
我在何方's avatar
我在何方 committed
1279
      console.log(this.selectListRow)
吴滔's avatar
吴滔 committed
1280 1281 1282 1283 1284 1285 1286 1287
      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
1288 1289 1290
          this.opnotice = true
        }else{
          this.opnotice = false
1291 1292 1293
          this.$set(this.discountForm, 'discountTotal', '')
          this.$set(this.discountForm, 'discountRemark', '')
          this.$set(this.discountForm, 'author', '')
吴滔's avatar
吴滔 committed
1294 1295 1296 1297 1298 1299
        }
      })
    },
    saveDiscount() {
      console.log(this.discountForm)
      // this.selectListRow.id
我在何方's avatar
我在何方 committed
1300
      if (this.discountForm.discountTotal === 0||!this.discountForm.discountTotal) {
吴滔's avatar
吴滔 committed
1301
        this.$modal.msgError(this.$t('优惠金额不能为空'));
我在何方's avatar
我在何方 committed
1302 1303 1304
        return
      }
      if (this.discountForm.discountRemark === 0||!this.discountForm.discountRemark) {
吴滔's avatar
吴滔 committed
1305
        this.$modal.msgError(this.$t('优惠原因不能为空'));
我在何方's avatar
我在何方 committed
1306 1307
        return
      }
吴滔's avatar
吴滔 committed
1308 1309 1310 1311 1312 1313
      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
1314 1315
        taxPoint:this.selectListRow.taxPoint,
        taxAmount:this.selectListRow.taxAmount,
吴滔's avatar
吴滔 committed
1316
      }
1317
       updateReceivableDiscountById(params).then(res => {
吴滔's avatar
吴滔 committed
1318
        if (this.selectListRow.discountTotal) {
吴滔's avatar
吴滔 committed
1319
          this.$modal.msgSuccess(this.$t('修改成功'));
吴滔's avatar
吴滔 committed
1320
        } else {
吴滔's avatar
吴滔 committed
1321
          this.$modal.msgSuccess(this.$t('新增成功'));
吴滔's avatar
吴滔 committed
1322
        }
我在何方's avatar
我在何方 committed
1323 1324 1325 1326 1327 1328 1329
        // if(this.id>0){
        //    getInvoicingItem({ id: this.id }).then(res => {
        //     this.list = [...res.data]
        //     this.cancelDiscount()
        //     this.calculation()
        //   })
        // }else{
1330 1331
          var discount = this.list[this.selectListIndex]
          discount['discountTotal'] = this.discountForm.discountTotal
1332
          discount['discountRemark'] = this.discountForm.discountRemark
我在何方's avatar
我在何方 committed
1333
          setTimeout(()=>{
1334 1335
            // getReceivableInfoByIds({ id: this.selectListRow.id }).then(res => {
              this.$set(this.list, this.selectListIndex, {...discount})
我在何方's avatar
我在何方 committed
1336 1337
              this.cancelDiscount()
              this.calculation()
1338
            // })
我在何方's avatar
我在何方 committed
1339 1340 1341 1342 1343 1344
          },1000)


        // }


吴滔's avatar
吴滔 committed
1345
      })
吴滔's avatar
吴滔 committed
1346 1347 1348 1349 1350 1351 1352 1353 1354
    },
    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
1355
        this.dialogTableKey ++
吴滔's avatar
吴滔 committed
1356 1357
        this.total = response.data.total;
        this.loading1 = false;
1358 1359 1360 1361 1362 1363
        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
1364 1365 1366 1367
      });
    },
    /** 新增按钮操作 */
    handleAdd() {
我在何方's avatar
我在何方 committed
1368
      this.queryParams.consignorId=this.form.customerId
我在何方's avatar
我在何方 committed
1369
      this.multipleSelection = this.list
吴滔's avatar
吴滔 committed
1370 1371 1372 1373
      this.open = true;
    },
    hiddenDialog() {
      this.open = false;
我在何方's avatar
我在何方 committed
1374
      this.queryParams.consignorId=''
吴滔's avatar
吴滔 committed
1375
    },
1376 1377 1378
    changePlatformAccountId(platformAccountId,index){
      this.form.receiptAccountList[index].platformAccountId = platformAccountId
    },
1379
    submitForm(addType) {
我在何方's avatar
我在何方 committed
1380 1381
      const params = {...this.form}
      params.addType = addType
1382
      // params.receiptAccountList = params.receiptAccountList.map(v => Object.assign(v, {  }))
我在何方's avatar
我在何方 committed
1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397
      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
      }
1398 1399
      if(params.openInvoice!=0&&params.openInvoice!=1){
        console.log(params.openInvoice)
我在何方's avatar
我在何方 committed
1400 1401 1402 1403
        this.saveBtnLoading = false
        this.$modal.msgError(this.$t('请选择是否需要开票'));
        return
      }
1404 1405
      if (this.list && this.list.length > 0) {
        params.receivableVOList = this.list
1406
      }else{
我在何方's avatar
我在何方 committed
1407
        this.saveBtnLoading = false
吴滔's avatar
吴滔 committed
1408
        this.$modal.msgError(this.$t('请添加未收客户款项'));
1409 1410
        return
      }
我在何方's avatar
我在何方 committed
1411

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

我在何方's avatar
我在何方 committed
1414
      var saveStatus = true
我在何方's avatar
我在何方 committed
1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427
      params.receiptAccountList.forEach(v => {
        if(v.type!='total'){
          if(!v.platformAccountId){
            saveStatus = false
          }
          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
1428
        }
我在何方's avatar
我在何方 committed
1429
      })
我在何方's avatar
我在何方 committed
1430 1431 1432 1433
      if(!saveStatus){
        this.$modal.msgError(this.$t('请添加收款账户'));
        return
      }
我在何方's avatar
我在何方 committed
1434 1435 1436
      delete params.receivableDetail


1437
      if (addType === 1) {
吴滔's avatar
吴滔 committed
1438
            this.saveBtnLoading = true
我在何方's avatar
我在何方 committed
1439
            params.receiptAccountList.splice(params.receiptAccountList.length - 1,1)
我在何方's avatar
我在何方 committed
1440
            if (this.id && this.id != 0) {
我在何方's avatar
我在何方 committed
1441
              params.updateType = 0
1442
              updateReceipt(params).then(res => {
我在何方's avatar
我在何方 committed
1443
                this.$modal.msgSuccess(this.$t('提交成功'));
我在何方's avatar
我在何方 committed
1444
                this.$store.dispatch('tagsView/delCurrentView')
吴滔's avatar
吴滔 committed
1445 1446
              }).finally(() => {
                this.saveBtnLoading = false
1447 1448
              })
            } else {
1449
              params.currencyId = this.showCurrencyId
1450
              createReceipt(params).then(res => {
吴滔's avatar
吴滔 committed
1451
                this.$modal.msgSuccess(this.$t('保存成功'));
我在何方's avatar
我在何方 committed
1452
                this.$store.dispatch('tagsView/delCurrentView')
吴滔's avatar
吴滔 committed
1453 1454
              }).finally(() => {
                this.saveBtnLoading = false
1455 1456 1457 1458
              })
            }
        return
      }
1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477
        this.saveBtnLoading = true
        params.receiptAccountList.splice(params.receiptAccountList.length - 1,1)
        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
          })
1478
        }
吴滔's avatar
吴滔 committed
1479 1480 1481 1482
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
我在何方's avatar
我在何方 committed
1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496
    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
1497
    saveSelectList() {
我在何方's avatar
我在何方 committed
1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509
      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
1510
      this.open = false;
1511
      this.calculation()
吴滔's avatar
吴滔 committed
1512
    },
吴滔's avatar
吴滔 committed
1513 1514 1515 1516
    deleteListRow(index) {
      const list = [...this.list]
      delete list[index]
      this.list = list.filter(v => v)
我在何方's avatar
我在何方 committed
1517
      this.calculation()
吴滔's avatar
吴滔 committed
1518
    },
吴滔's avatar
吴滔 committed
1519 1520 1521
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.page = 1;
吴滔's avatar
吴滔 committed
1522
      this.getList()
1523
    },
我在何方's avatar
我在何方 committed
1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536
    //清空数据
    removeData(){
      console.log(this.form)
      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
1537 1538
  },
};
1539 1540
</script>

1541
<style scoped lang="scss">
吴滔's avatar
吴滔 committed
1542 1543 1544 1545
.card {
  margin-top: 20px;
}
.dialog-footer {
吴滔's avatar
吴滔 committed
1546 1547
  // padding: 40px;
  text-align: left;
吴滔's avatar
吴滔 committed
1548 1549 1550 1551 1552
}
.card-title {
  font-size: 18px;
  font-weight: bold;
}
1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563
::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%;
  }
}
1564 1565 1566 1567 1568 1569
  .bpm-title{
    font-size: 20px;
    font-weight: bold;
    color:#666;
    margin:20px 0;
  }
1570
</style>