receiptDetail.vue 55.2 KB
Newer Older
1 2 3
<template>
  <div class="app-container">
    <el-card>
吴滔's avatar
吴滔 committed
4
      <div slot="header" class="card-title">{{ $t('收款单详情') }}</div>
5
      <el-descriptions :column="3" border>
吴滔's avatar
吴滔 committed
6 7
        <el-descriptions-item :label="$t('收款单编号')">{{ form.receiptNo }}</el-descriptions-item>
        <el-descriptions-item :label="$t('状态')">
8 9
          <dict-tag :type="DICT_TYPE.ECW_RECEIPT_STATE" :value="form.state"/>
        </el-descriptions-item>
吴滔's avatar
吴滔 committed
10 11 12
        <el-descriptions-item :label="$t('客户')">{{ form.customerName }}</el-descriptions-item>
        <el-descriptions-item :label="$t('部门')">{{ form.departmentName }}</el-descriptions-item>
        <el-descriptions-item :label="$t('业务员')">{{ form.salesmanName }}</el-descriptions-item>
我在何方's avatar
我在何方 committed
13
        <!-- <el-descriptions-item :label="$t('手续费(RMB)')">{{ form.feeRate }}</el-descriptions-item> -->
吴滔's avatar
吴滔 committed
14
        <el-descriptions-item :label="$t('备注')">{{ form.remark }}</el-descriptions-item>
15 16 17
      </el-descriptions>
    </el-card>
    <el-card class="card">
我在何方's avatar
我在何方 committed
18
      <div slot="header" class="card-title">{{ $t('应收明细') }}</div>
19
      <el-table :data="list" border>
吴滔's avatar
吴滔 committed
20 21 22
        <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">
23
          <template slot-scope="scope">
24
            <span v-if="scope.row.feeType!=5">{{ scope.row.titleZh?(scope.row.titleZh + "(" + scope.row.titleEn + ")"):'' }}</span>
25 26
          </template>
        </el-table-column>
吴滔's avatar
吴滔 committed
27
        <el-table-column :label="$t('箱数')" align="center" prop="num" />
我在何方's avatar
我在何方 committed
28 29
        <el-table-column :label="$t('体积/重量')" align="center" prop="weight">
          <template slot-scope="scope">
我在何方's avatar
我在何方 committed
30
             <span v-if="scope.row.feeType!=5"> {{ scope.row.volume + "/" + scope.row.weight }}</span>
我在何方's avatar
我在何方 committed
31 32
            </template>
          </el-table-column>
吴滔's avatar
吴滔 committed
33
        <el-table-column :label="$t('收入类型')" align="center" prop="feeType">
34 35 36 37 38 39 40
          <template slot-scope="scope">
            <dict-tag
              :type="DICT_TYPE.FEE_TYPE"
              :value="scope.row.feeType"
            ></dict-tag>
          </template>
        </el-table-column>
吴滔's avatar
吴滔 committed
41
        <el-table-column :label="$t('单价金额')" align="center" prop="unitPrice">
42 43
          <template slot-scope="scope">
            <span>{{ scope.row.unitPrice }}</span>
我在何方's avatar
我在何方 committed
44
            {{getCurrencyLabel(scope.row.currencyId)}}
45 46
          </template>
        </el-table-column>
吴滔's avatar
吴滔 committed
47
        <el-table-column :label="$t('总金额')" align="center" prop="totalAmount">
48 49
          <template slot-scope="scope">
            <span>{{ scope.row.totalAmount }}</span>
我在何方's avatar
我在何方 committed
50
            {{getCurrencyLabel(scope.row.currencyId)}}
51 52
          </template>
        </el-table-column>
吴滔's avatar
吴滔 committed
53
        <el-table-column :label="$t('优惠金额')" align="center">
吴滔's avatar
吴滔 committed
54 55 56 57
          <template slot-scope="scope">
            {{ scope.row.discountTotal ? `${scope.row.discountTotal}(${scope.row.discountRemark})` : 0 }}
          </template>
        </el-table-column>
58
      </el-table>
59 60
      <el-descriptions :column="2" border class="card">
        <!-- <el-descriptions-item v-for="(v, index) in form.platformAccountIdList" :label="`收款账户${index + 1}`" :key="index">
61
          <div style="display: flex">
Marcus's avatar
Marcus committed
62 63
            <el-button type="text" v-if="index === 0" @click="form.platformAccountIdList = [...form.platformAccountIdList, {}]">{{ $t('添加收款账户') }}</el-button>
            <el-button type="text" v-if="index > 0" @click="subtractItem(index)"><span style="color: red">{{ $t('删除') }}</span></el-button>
64 65
          </div>
        </el-descriptions-item>
66
         -->
吴滔's avatar
吴滔 committed
67 68
        <el-descriptions-item :label="$t('是否需要开票')">
          <span>{{ form.openInvoice == 1 ? $t('需要') : $t('不需要') }}</span>
69 70
          <!-- <el-select
            v-model="form.openInvoice"
Marcus's avatar
Marcus committed
71
            :placeholder="$t('请选择是否需要开票')"
72
          >
Marcus's avatar
Marcus committed
73 74
            <el-option :value="1" :label="$t('需要')"></el-option>
            <el-option :value="0" :label="$t('不需要')"></el-option>
75 76
          </el-select> -->
        </el-descriptions-item>
我在何方's avatar
我在何方 committed
77 78 79
        <el-descriptions-item>
              <template slot="label">
                {{$t('核销基准币种')}}
80 81
                <span :title="$t('应收可能出现多个币种的情况,多个币种没法计算整个收款单的核销比例,所以增加一个中间币种,如果应收只有一个币种就使用应收币种,如果有多个币种就以美元为核销基准币种')"><i class="el-icon-question"></i></span>
<!--                  <el-tooltip class="item" effect="light" :content="$t('应收可能出现多个币种的情况,多个币种没法计算整个收款单的核销比例,所以增加一个中间币种,如果应收只有一个币种就使用应收币种,如果有多个币种就以美元为核销基准币种')" placement="top">
我在何方's avatar
我在何方 committed
82
                    <el-button icon="el-icon-question"></el-button>
83
                  </el-tooltip> -->
我在何方's avatar
我在何方 committed
84 85
                </template>

我在何方's avatar
我在何方 committed
86
          {{getCurrencyLabel(showCurrencyId)}}
87 88 89 90
        </el-descriptions-item>
      </el-descriptions>
    </el-card>
    <el-card class="card">
吴滔's avatar
吴滔 committed
91
      <div slot="header" class="card-title">{{ $t('开票资料') }}</div>
92
      <el-descriptions :column="3" border>
吴滔's avatar
吴滔 committed
93
        <el-descriptions-item :label="$t('发票抬头')">
94 95 96
          {{ form.invoice }}
          <!-- <el-input v-model="form.invoice"></el-input> -->
        </el-descriptions-item>
吴滔's avatar
吴滔 committed
97
        <el-descriptions-item :label="$t('纳税人识别号')">
98 99 100
          {{ form.taxpayer }}
          <!-- <el-input v-model="form.taxpayer"></el-input> -->
        </el-descriptions-item>
吴滔's avatar
吴滔 committed
101
        <el-descriptions-item :label="$t('开户行')">
102 103 104
          {{ form.accountBank }}
          <!-- <el-input v-model="form.accountBank"></el-input> -->
        </el-descriptions-item>
吴滔's avatar
吴滔 committed
105
        <el-descriptions-item :label="$t('账号')">
106 107 108
          {{ form.accountName }}
          <!-- <el-input v-model="form.accountName"></el-input> -->
        </el-descriptions-item>
吴滔's avatar
吴滔 committed
109
        <el-descriptions-item :label="$t('项目')">
110 111 112
          {{ form.projectName }}
          <!-- <el-input v-model="form.projectName"></el-input> -->
        </el-descriptions-item>
我在何方's avatar
我在何方 committed
113
        <el-descriptions-item :label="$t('税率')+'%'">
114 115 116
          {{ form.taxRate }}
          <!-- <el-input v-model="form.taxRate"></el-input> -->
        </el-descriptions-item>
吴滔's avatar
吴滔 committed
117
        <el-descriptions-item :label="$t('开票地址/电话')">
118 119 120 121 122
        {{ form.addressPhone }}
          <!-- <el-input v-model="form.addressPhone"></el-input> -->
        </el-descriptions-item>
      </el-descriptions>
    </el-card>
我在何方's avatar
我在何方 committed
123

124
    <el-card class="card">
我在何方's avatar
我在何方 committed
125
      <div slot="header" class="card-title">{{ $t('收款信息') }}</div>
126
      <el-table :data="form.receiptAccountList" border>
吴滔's avatar
吴滔 committed
127
        <el-table-column :label="$t('应收币种')" align="center">
128
          <template slot-scope="scope">
我在何方's avatar
我在何方 committed
129
             {{getCurrencyLabel(scope.row.currencyId)}}
130 131
          </template>
        </el-table-column>
Marcus's avatar
Marcus committed
132
        <!-- <el-table-column :label="$t('应收金额')" align="center" prop="receivableAmount" /> -->
吴滔's avatar
吴滔 committed
133
        <el-table-column :label="$t('应收金额')" align="center" prop="receivableAmount">
吴滔's avatar
吴滔 committed
134
          <template slot-scope="scope" v-if="scope.row.type !== 'total'">
135 136
           <span v-if="scope.row.discountTotal&&scope.row.discountTotal>0">{{ `${scope.row.receivableAmount - scope.row.discountTotal }(${scope.row.receivableAmount} - ${scope.row.discountTotal})` }}</span>
           <span v-else>{{ `${scope.row.receivableAmount}` }}</span>
吴滔's avatar
吴滔 committed
137 138
          </template>
        </el-table-column>
139 140
        <el-table-column align="center" width="220">
          <template #header>
我在何方's avatar
我在何方 committed
141
            {{ $t('核销基准币种') }}{{getCurrencyLabel(showCurrencyId)}}{{ $t('汇率') }}
142 143 144 145 146 147
          </template>
          <template slot-scope="scope">
            <template v-if="scope.row.type !== 'total'">
              <span>{{ scope.row.writeOffRate }}</span>
            </template>
            <template v-else>
houjn@hikoon.cn's avatar
houjn@hikoon.cn committed
148
              {{ $t('应核销总金额') }}{{getCurrencyLabel(showCurrencyId)}}
149 150 151 152 153
            </template>
          </template>
        </el-table-column>
        <el-table-column align="center" prop="writeOffAmount">
          <template #header>
我在何方's avatar
我在何方 committed
154
            {{ $t('核销基准金额') }}{{getCurrencyLabel(showCurrencyId)}}
155 156
          </template>
        </el-table-column>
我在何方's avatar
我在何方 committed
157
        <el-table-column :label="$t('期望收款账户')" align="center">
158 159 160 161
          <template slot-scope="scope" v-if="scope.row.type !== 'total'">
            {{ `${bankData.find(v => v.id == scope.row.platformAccountId).baAccountName}(${bankData.find(v => v.id == scope.row.platformAccountId).baAccountNum})` }}
          </template>
        </el-table-column>
houjn@hikoon.cn's avatar
houjn@hikoon.cn committed
162

我在何方's avatar
我在何方 committed
163
        <el-table-column :label="$t('期望收款币种')" align="center">
164
          <template slot-scope="scope">
我在何方's avatar
我在何方 committed
165 166
            <!-- <dict-tag :type="DICT_TYPE.BOX_SHIPPING_PRICE_UNIT" :value="scope.row.collectionCurrencyId" /> -->
            {{getCurrencyLabel(scope.row.collectionCurrencyId)}}
167 168
          </template>
        </el-table-column>
我在何方's avatar
我在何方 committed
169
        <el-table-column :label="$t('期望收款汇率')" align="center">
170 171 172 173 174 175 176 177 178 179 180
          <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> -->
            <span v-if="scope.row.type !== 'total'">{{ scope.row.collectionRate }}</span>
houjn@hikoon.cn's avatar
houjn@hikoon.cn committed
181 182
            <span v-else>{{ $t('期望收费金额') }}
              <span :title="$t('导出账单给客户时显示的收款金额与币种')"><i class="el-icon-question"></i></span>
183
            </span>
houjn@hikoon.cn's avatar
houjn@hikoon.cn committed
184

185 186
          </template>
        </el-table-column>
我在何方's avatar
我在何方 committed
187
        <el-table-column :label="$t('期望收款金额')" align="center" prop="collectionAmount">
188 189 190
          <template slot-scope="scope">
            <span v-if="scope.row.type !== 'total'">{{ scope.row.collectionAmount }}</span>
            <div v-else>
我在何方's avatar
我在何方 committed
191
              <div v-for="itemAmount in scope.row.collectionAmount">{{$i18n.locale=='zh_CN'?itemAmount.currencyNameZh:itemAmount.currencyNameEn}}: {{ itemAmount.amount}}</div>
我在何方's avatar
我在何方 committed
192
<!--              <div v-if="scope.row.collectionAmount[0]">{{ $t('美元') }}: {{ scope.row.collectionAmount[0] }}</div>
吴滔's avatar
吴滔 committed
193
              <div v-if="scope.row.collectionAmount[1]">{{ $t('人民币') }}: {{ scope.row.collectionAmount[1] }}</div>
我在何方's avatar
我在何方 committed
194
              <div v-if="scope.row.collectionAmount[2]">{{ $t('奈拉') }}: {{ scope.row.collectionAmount[2] }}</div> -->
195 196 197 198 199 200
            </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
201
        <el-descriptions-item :label="$t('账单汇率有效期')">
202 203 204 205 206 207 208 209 210 211
          {{ parseTime(form.rateValidateDate) }}
          <!-- <el-form-item
            label=""
            label-width="0"
            style="margin-bottom: 0"
            prop="rateValidateDate"
          >
            <el-date-picker
              v-model="form.rateValidateDate"
              type="datetime"
Marcus's avatar
Marcus committed
212
              :placeholder="$t('选择日期时间')">
213 214 215 216 217
            </el-date-picker>
          </el-form-item> -->
        </el-descriptions-item>
      </el-descriptions>
    </el-card>
我在何方's avatar
我在何方 committed
218 219 220
    <el-card class="card">
      <div slot="header" class="card-title">{{ $t('银行收款明细') }}</div>
      <div>
221
        <!-- <el-button type="primary" v-if="form.state!=7&&form.state!=0" plain size="mini" @click="batchVerification" v-hasPermi="['ecw:payment:detail:batchWriteOff']" style="padding: 10px; margin-bottom: 10px">{{ $t('批量核销') }}</el-button> -->
我在何方's avatar
我在何方 committed
222
        <el-button type="primary"  v-if="form.state!=7&&form.state!=0" plain size="mini" @click="handleAddReceiptItem" v-hasPermi="['ecw:payment:detail:addBank']" style="padding: 10px; margin-bottom: 10px">{{ $t('添加收款明细') }}</el-button>
我在何方's avatar
我在何方 committed
223 224 225 226 227 228 229 230
      </div>
      <el-table ref="multipleTable" :data="detailed" border row-key="id" @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="50" :reserve-selection="true"> </el-table-column>
        <el-table-column :label="$t('序号')" type="index" align="center" width="50"></el-table-column>
        <el-table-column :label="$t('收款账户')" align="center" prop="accountName" />
        <el-table-column :label="$t('实收金额')" align="center" prop="amount" />
        <el-table-column :label="$t('实收币种')" align="center" prop="marks">
          <template slot-scope="scope">
我在何方's avatar
我在何方 committed
231
            {{getCurrencyLabel(scope.row.currencyId)}}
我在何方's avatar
我在何方 committed
232 233 234
          </template>
        </el-table-column>
        <el-table-column :label="$t('汇率')" align="center" prop="rate" />
235 236 237 238 239 240
<!--        <el-table-column :label="$t('核销货币金额')" align="center" prop="writeOffAmount" />-->
        <el-table-column align="center" prop="writeOffAmount" >
          <template #header>
            {{ $t('兑核销基准金额') }}{{getCurrencyLabel(showCurrencyId)}}
          </template>
        </el-table-column>
我在何方's avatar
我在何方 committed
241 242 243 244 245 246 247 248 249 250 251 252 253
        <el-table-column :label="$t('实收日期')" align="center" prop="amountDate">
          <!-- <template slot-scope="scope">
            <span>{{ parseTime(scope.row.amountDate, '{y}-{m}-{d}') }}</span>
          </template> -->
        </el-table-column>
        <el-table-column :label="$t('水单号')" align="center" prop="billNo" />
        <el-table-column :label="$t('水单附件')" align="center" prop="attr">
          <template slot-scope="scope" v-if="scope.row.attr">
            <div v-for="(v, i) in scope.row.attr" :key="i"><el-link :href="v.url" type="primary" target="_blank">{{ v.name }}</el-link></div>
          </template>
        </el-table-column>
        <el-table-column :label="$t('状态')" align="center" prop="status">
          <template slot-scope="scope">
我在何方's avatar
我在何方 committed
254 255 256 257
            <dict-tag
              :type="DICT_TYPE.RECEIPT_ITEM_STATE"
              :value="scope.row.status"
            />
我在何方's avatar
我在何方 committed
258 259 260 261
          </template>
        </el-table-column>
        <el-table-column :label="$t('操作')" align="center" width="200">
          <template slot-scope="scope">
262
            <el-button v-if="scope.row.status == 0" v-hasPermi="['ecw:payment:detail:delete']" type="text" @click="deleteClick(scope.row)">{{ $t('删除') }}</el-button>
我在何方's avatar
我在何方 committed
263
            <el-button v-if="scope.row.status == 0" type="text" @click="detailClick(scope.row)" v-hasPermi="['ecw:payment:detail:detail']">{{ $t('详情') }}</el-button>
我在何方's avatar
我在何方 committed
264 265
            <el-button v-if="scope.row.status == 0" type="text" @click="$router.push(`bankDetail?id=`+id+`&bankId=`+scope.row.id)" v-hasPermi="['ecw:payment:detail:writeOff']">{{ $t('核销') }}</el-button>
            <el-button v-if="scope.row.status == 1" type="text" @click="showCancel(scope.$index)" v-hasPermi="['ecw:payment:detail:cancelWriteOff']">{{ $t('反核销') }}</el-button>
266
            <el-button v-if="scope.row.status == 0" type="text" @click="editClick(scope.row)" v-hasPermi="['ecw:payment:detail:bankEdit']">{{ $t('编辑') }}</el-button>
我在何方's avatar
我在何方 committed
267
            <el-button v-if="scope.row.status == 2" type="text" @click="cancelClick(scope.$index,1)" v-hasPermi="['ecw:payment:detail:cancelDetailApproval']">{{ $t('取消审核') }}</el-button>
我在何方's avatar
我在何方 committed
268
             <el-button v-if="scope.row.status == 3" type="text" @click="cancelClick(scope.$index,2)" v-hasPermi="['ecw:payment:detail:cancelWriteOffNo']">{{ $t('取消反核销审核') }}</el-button>
我在何方's avatar
我在何方 committed
269
            <el-button v-if="scope.row.status == 3 || scope.row.status == 2" type="text"  @click="$router.push(`/bpm/process-instance/detail?id=`+scope.row.bmpId)" v-hasPermi="['ecw:payment:detail:approval']">{{ $t('审核详情') }}</el-button>
我在何方's avatar
我在何方 committed
270 271 272 273
          </template>
        </el-table-column>
      </el-table>
    </el-card>
274 275
    <el-card class="card hexiaoCard">
      <el-descriptions :column="3" border>
houjn@hikoon.cn's avatar
houjn@hikoon.cn committed
276 277
        <el-descriptions-item >

278
          <!-- <el-tag>{{ verificationData.usCount.toFixed(6) }}{{$t('美元')}}</el-tag>
我在何方's avatar
我在何方 committed
279
          <el-tag>{{ verificationData.rmbCount.toFixed(6) }}{{$t('人民币')}}</el-tag>
280
          <el-tag>{{ verificationData.nairaCount.toFixed(6) }}{{$t('奈拉')}}</el-tag> -->
houjn@hikoon.cn's avatar
houjn@hikoon.cn committed
281 282 283 284
          <template slot="label">
            {{ $t('实收已核销总金额') }}          <span :title="$t('所有银行收款明细中状态为已核销的实收金额,币种根据实收币种分类统计')"><i class="el-icon-question"></i></span>

          </template>
dragondean@qq.com's avatar
dragondean@qq.com committed
285 286 287 288
          <template v-if="!Object.keys(writeOffTotal).length">
            0
          </template>
          <div v-else>
289
            <div v-for="(amount, currency) in writeOffTotal" :key="currency">
我在何方's avatar
我在何方 committed
290
              {{amount}}{{getCurrencyLabel(currency)}}
291 292
            </div>
          </div>
houjn@hikoon.cn's avatar
houjn@hikoon.cn committed
293

294 295 296
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
houjn@hikoon.cn's avatar
houjn@hikoon.cn committed
297 298 299
            {{ $t('核销基准币种已核销总金额') }}{{getCurrencyLabel(showCurrencyId)}}
            <span :title="$t('为了方便统计收款单核销比例,将所有银行收款明细中状态为已核销的实收金额,转换为核销基准币种的金额累加')"><i class="el-icon-question"></i></span>

300
          </template>
301
          {{ writeOffAmount}}
houjn@hikoon.cn's avatar
houjn@hikoon.cn committed
302

303 304 305
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
houjn@hikoon.cn's avatar
houjn@hikoon.cn committed
306 307 308
            {{ $t('总核销比例') }}{{getCurrencyLabel(showCurrencyId)}}
            <span :title="$t('总核销比例=核销基准币种已核销总金额/核销基准币种应收总金额')"><i class="el-icon-question"></i></span>

309
          </template>
310
          {{ WriteOffProportion }}%
311 312 313 314
        </el-descriptions-item>
      </el-descriptions>
    </el-card>
    <div slot="footer" style="margin: 20px 0">
315 316
      <el-button v-if="form.state!=7&&form.state!=9&&form.state!=10&&form.state!=11&&form.state != 4&&form.state != 5 && form.state != 6" type="primary" @click="toEdit" v-hasPermi="['ecw:payment:detail:edit']">{{ $t('编辑') }}</el-button>
      <el-button v-if="form.state!=7&&form.state!=9&&form.state!=10&&form.state!=11&&form.state != 4&&form.state != 5 && form.state != 6"  type="primary" @click="verificationAll" v-hasPermi="['ecw:payment:detail:allWriteOff']">{{ $t('全部核销') }}</el-button>
我在何方's avatar
我在何方 committed
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344
      <el-button
        type="primary"
        v-if="form.state == 11"
        v-hasPermi="['ecw:voucher:cancelWriteOff']"
        @click="$router.push(`/bpm/process-instance/detail?id=`+form.bmpId)"
        >{{ $t('反核销审核详情') }}</el-button
      >
      <el-button
        type="primary"
        v-if="form.state == 10"
        v-hasPermi="['ecw:voucher:cancelWriteOff']"
        @click="$router.push(`/bpm/process-instance/detail?id=`+form.bmpId)"
        >{{ $t('全部核销审核详情') }}</el-button
      >
      <el-button
        v-if="form.state == 11"
        type="primary"
        v-hasPermi="['ecw:vocher:cancelWriteOfflNo']"
        @click="detailClickCancel(1)"
        >{{ $t('取消反核销审核') }}</el-button
      >
      <el-button
        v-if="form.state == 10"
        type="primary"
        v-hasPermi="['ecw:vocher:cancelWriteOffAll']"
        @click="detailClickCancel(2)"
        >{{ $t('取消全部核销审核') }}</el-button
      >
345 346 347 348 349 350 351
      <el-button
        v-if="form.state == 4 || form.state == 5 || form.state == 6"
        type="primary"
        v-hasPermi="['ecw:voucher:cancelWriteOff']"
        @click="writeOffShow()"
        >{{ $t('提交收款单反核销') }}</el-button
      >
我在何方's avatar
我在何方 committed
352
      <el-button  plain type="primary" @click="$store.dispatch('tagsView/delCurrentView')">{{$t('返回')}}</el-button>
我在何方's avatar
我在何方 committed
353

我在何方's avatar
我在何方 committed
354 355 356 357 358 359 360 361 362 363 364 365 366 367
    </div>
    <el-dialog
     :title="detailTitle"
      :visible.sync="detailShow"
      width="30%">
       <div class="cancel_content">
         <span>{{$t('申请理由')}}</span>
         <el-input type="textarea" :rows ="6" v-model="detailReason" :placeholder="$t('请输入取消理由')"></el-input>
       </div>
      <span slot="footer" class="dialog-footers">
        <el-button type="primary" @click="detailWriteOffClick()">{{$t('提交')}}</el-button>
        <el-button @click="detailShow = false">{{$t('取消')}}</el-button>
      </span>
    </el-dialog>
368 369 370 371 372 373 374 375 376 377 378 379 380
    <el-dialog
     :title="$t('收款单反核销')"
      :visible.sync="wiffShow"
      width="30%">
       <div class="cancel_content">
         <span>{{$t('申请理由')}}</span>
         <el-input type="textarea" :rows ="6" v-model="wiffRemark" :placeholder="$t('请输入理由')"></el-input>
       </div>
      <span slot="footer" class="dialog-footers">
        <el-button  type="primary" @click="writeOffClick()">{{$t('提交反核销')}}</el-button>
        <el-button @click="wiffShow = false">{{$t('取消')}}</el-button>
      </span>
    </el-dialog>
我在何方's avatar
我在何方 committed
381
    <el-dialog v-if="openAddDialog" :visible.sync="openAddDialog" :title="dialogTitle" width="50%" append-to-body>
382
      <div style="padding: 0 24px">
我在何方's avatar
我在何方 committed
383
        <el-form ref="addForm" :model="addForm" label-width="250px">
吴滔's avatar
吴滔 committed
384 385
          <el-form-item :label="$t('收款单号')">{{ form.receiptNo }}</el-form-item>
          <el-form-item :label="$t('剩余应收金额')">
386 387 388 389 390
            <template v-if="surplusData.length==0">
              0
            </template>
            <div v-else>
              <div v-for="(amount, currency) in surplusData" :key="currency">
我在何方's avatar
我在何方 committed
391
                 <span v-if="amount"> {{amount}}{{getCurrencyLabel(currency)}}</span>
392
              </div>
393
            </div>
394

395
          </el-form-item>
吴滔's avatar
吴滔 committed
396
          <el-form-item :label="$t('收款账户')" prop="accountNo" :rules="{ required: true, trigger: ['blur', 'change'], message: $t('收款账户不能为空') }">
我在何方's avatar
我在何方 committed
397
            <el-select v-if="!isView" v-model="addForm.accountId" :placeholder="$t('请选择收款账户')" style="width: 220px" @change="accountChange">
398 399
              <el-option v-for="item in bankData" :key="item.id" :label="item.baAccountName + '(' + item.baAccountNum + ')'" :value="item.id" />
            </el-select>
我在何方's avatar
我在何方 committed
400
            <span v-else>{{ addForm.accountNo+'('+addForm.accountName+')' }}</span>
401 402
          </el-form-item>
          <el-form-item
吴滔's avatar
吴滔 committed
403
            :label="$t('实收日期')"
404
            prop="amountDate"
吴滔's avatar
吴滔 committed
405
            :rules="{ required: true, trigger: ['blur', 'change'], message: $t('实收日期不能为空') }"
406 407
          >
            <el-date-picker
408
              v-if="!isView"
409 410 411 412 413
              clearable
              v-model="addForm.amountDate"
              value-format="yyyy-MM-dd"
              format="yyyy-MM-dd"
              type="date"
吴滔's avatar
吴滔 committed
414
              :placeholder="$t('选择实收日期')"
415
            />
416
            <span v-else>{{ addForm.amountDate }}</span>
417 418 419
          </el-form-item>
          <div style="display: flex;">
            <el-form-item
吴滔's avatar
吴滔 committed
420
              :label="$t('实收')"
421
              prop="amount"
吴滔's avatar
吴滔 committed
422
              :rules="{ required: true, trigger: ['blur', 'change'], message: $t('实收不能为空') }"
423
            >
424 425
              <el-input v-if="!isView" v-model="addForm.amount" style="width: 220px; margin-right: 12px" @input="setWriteOffAmount"></el-input>
              <span v-else>{{ addForm.amount }}</span>
426 427 428 429
            </el-form-item>
            <el-form-item
              label-width="0px"
              prop="currencyId"
吴滔's avatar
吴滔 committed
430
              :rules="{ required: true, trigger: ['blur', 'change'], message: $t('币种不能为空') }"
431
            >
我在何方's avatar
我在何方 committed
432 433 434 435 436 437 438 439 440
            <el-select
              v-model="addForm.currencyId"
              :placeholder="$t('请选择')"
              :disabled="isView"
              @change="val => currencyIdChange(val)"
            >
              <el-option
                v-for="item in currencyList"
                :key="item.id"
我在何方's avatar
我在何方 committed
441
                :label="$i18n.locale=='zh_CN'?item.titleZh:item.titleEn"
我在何方's avatar
我在何方 committed
442 443 444 445
                :value="item.id"
              />
            </el-select>
              <!-- <dict-selector v-if="!isView" :type="DICT_TYPE.BOX_SHIPPING_PRICE_UNIT" v-model="addForm.currencyId" @change="val => currencyIdChange(val)"/> -->
446
              <!-- <span v-else>{{ addForm.currencyId }}</span> -->
我在何方's avatar
我在何方 committed
447
              <!-- <dict-tag v-else :type="DICT_TYPE.BOX_SHIPPING_PRICE_UNIT" :value="addForm.currencyId" /> -->
448 449 450 451 452
            </el-form-item>
          </div>
          <el-form-item
            v-if="showCurrencyId != addForm.currencyId"
            prop="rate"
453
            :rules="{ required: true, trigger: ['blur', 'change'], message: $t('兑核销基准币种汇率不能为空') }"
454 455
          >
            <template slot="label">
456
<!--              <el-tooltip class="item" effect="light" :content="$t('实收币种与核销基准币种一样时,无需填写汇率,不一样需要填写汇率')" placement="top-start">
我在何方's avatar
我在何方 committed
457
               <el-button> {{ $t('兑核销基准币种汇率') }}{{getCurrencyLabel(showCurrencyId)}}</el-button>
458 459
              </el-tooltip> -->
            <span :title="$t('实收币种与核销基准币种一样时,无需填写汇率,不一样需要填写汇率')">{{ $t('兑核销基准币种汇率') }}{{getCurrencyLabel(showCurrencyId)}}</span>
460
            </template>
461
            <el-input  v-if="!isView" v-model="addForm.rate" style="width: 220px"></el-input>
462
            <span v-else>{{ addForm.rate}}</span>
463 464 465 466 467
          </el-form-item>
          <el-form-item
            v-if="showCurrencyId != addForm.currencyId"
          >
            <template slot="label">
468
              {{ $t('兑核销基准币种金额') }}{{getCurrencyLabel(showCurrencyId)}}
469
            </template>
470
            <span>{{ addForm.writeOffAmount?parseFloat(addForm.writeOffAmount).toFixed(6):'' }}</span>
471 472
          </el-form-item>
          <el-form-item
吴滔's avatar
吴滔 committed
473
            :label="$t('水单附件')"
474 475 476
            prop="attr"
          >
            <el-upload
477
              v-if="!isView"
478 479 480 481 482 483 484 485 486 487
              class="upload-demo"
              :action="uploadFileUrl"
              :headers="headers"
              :on-success="handleUploadSuccess"
              :before-upload="handleBeforeUpload"
              :on-error="handleUploadError"
              :before-remove="beforeRemove"
              :file-list="addForm.attr"
              multiple
            >
吴滔's avatar
吴滔 committed
488
              <el-button size="small" type="primary">{{ $t('上传附件') }}</el-button>
489
            </el-upload>
490 491 492
            <div v-else>
              <div v-for="(v, i) in addForm.attr" :key="i"><el-link :href="v.url" type="primary" target="_blank">{{ v.name }}</el-link></div>
            </div>
493 494
          </el-form-item>
          <el-form-item
吴滔's avatar
吴滔 committed
495
            :label="$t('水单号')"
496
            prop="billNo"
吴滔's avatar
吴滔 committed
497
            :rules="{ required: true, trigger: ['blur', 'change'], message: $t('水单号不能为空') }"
498
          >
499 500
            <el-input v-if="!isView" v-model="addForm.billNo" style="width: 220px"></el-input>
            <span v-else>{{ addForm.billNo }}</span>
501 502
          </el-form-item>
        </el-form>
503
        <div slot="footer" v-if="!isView">
504
          <el-button type="primary" @click="saveFrom">{{ saveBtnText }}</el-button>
吴滔's avatar
吴滔 committed
505
          <el-button @click="hiddenDialog">{{ $t('取消') }}</el-button>
506 507 508
        </div>
      </div>
    </el-dialog>
509
        <el-dialog
我在何方's avatar
我在何方 committed
510
         :title="$t('收款单银行实收明细反核销-未提交')"
511 512 513 514
          :visible.sync="dialogVisible"
          width="30%">
           <div class="cancel_content">
             <span>{{$t('申请理由')}}</span>
我在何方's avatar
我在何方 committed
515
             <el-input type="textarea" :rows ="6" v-model="reason" :placeholder="$t('请输入理由')"></el-input>
516 517
           </div>
          <span slot="footer" class="dialog-footer">
我在何方's avatar
我在何方 committed
518
            <el-button type="primary" @click="verificationCancelClick()">{{$t('提交反核销')}}</el-button>
519 520 521
            <el-button @click="dialogVisible = false">{{$t('取消')}}</el-button>
          </span>
        </el-dialog>
我在何方's avatar
我在何方 committed
522 523 524 525 526 527 528 529 530
        <el-dialog
         :title="$t('取消审核')"
          :visible.sync="cancelShow"
          width="30%">
           <div class="cancel_content">
             <span>{{$t('申请理由')}}</span>
             <el-input type="textarea" :rows ="6" v-model="cancelReason" :placeholder="$t('请输入取消审核理由')"></el-input>
           </div>
          <span slot="footer" class="dialog-footer">
我在何方's avatar
我在何方 committed
531
            <el-button type="primary" @click="cancelWriteOffClick()">{{$t('提交')}}</el-button>
我在何方's avatar
我在何方 committed
532 533 534
            <el-button @click="cancelShow = false">{{$t('取消')}}</el-button>
          </span>
        </el-dialog>
535 536 537 538
  </div>
</template>

<script>
我在何方's avatar
我在何方 committed
539
import helpIcon from  "@/assets/images/help.png"
540 541
import { getBankAccountPage } from "@/api/ecw/bankAccount";
import { getToken } from "@/utils/auth";
我在何方's avatar
我在何方 committed
542
import { listSimpleDepts } from "@/api/system/dept";
543
import { getCustomer } from '@/api/ecw/customer'
544

545
import {
546 547 548 549 550 551 552 553 554
  getReceiptInfoByIds,
  getInvoicingItem,
  receiptItemCreate,
  getReceivableItem,
  deleteReceiptItem,
  receiptItemVerification,
  receiptItemVerificationCancel,
  updateReceiptItem,
  receiptItemBatchVerification,
555
  receiptItemAllVerification,
我在何方's avatar
我在何方 committed
556 557 558
  getReceiptAccountList,
  financeReceiptWriteOff,
  financeReceiptItemWriteOffNo,
我在何方's avatar
我在何方 committed
559
  cancelFinanceReceiptItemWriteOff,
我在何方's avatar
我在何方 committed
560 561
  cancelFinanceReceiptItemWriteOffNo,
  cancelFinanceReceiptWriteOffNo,
562 563
  cancelFinanceReceiptWriteOff,
  financeReceiptWriteOffNo
564 565 566 567
} from "@/api/ecw/financial";
import { getCurrencyPage } from "@/api/ecw/currency";
import NP from 'number-precision'

我在何方's avatar
我在何方 committed
568

569
export default {
570

571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588
  data() {
    return {
      uploadFileUrl: process.env.VUE_APP_BASE_API + "/app-api/file/upload", // 上传的图片服务器地址
      headers: {
        Authorization: "Bearer " + getToken(),
      },
      id: 0,
      form: {},
      list: [],
      detailedList: [],
      openAddDialog: false,
      bankData: [],
      params: {
        page: 1,
        rows: 20,
      },
      addForm: {},
      detailed: [],
我在何方's avatar
我在何方 committed
589 590
      deptData: [],
      deptArr: [],
吴滔's avatar
吴滔 committed
591 592
      dialogTitle: this.$t('添加银行实收明细'),
      saveBtnText: this.$t('添加'),
593
      isView: false,
594 595 596 597 598 599 600 601
      multipleSelection: [],
      currencyList: [],
      verificationData: {
        usCount: 0,
        rmbCount: 0,
        nairaCount: 0,
        writtenOff: 0,
        WriteOffProportion: 0
吴滔's avatar
吴滔 committed
602 603 604 605 606
      },
      remainingAmount: {
        usAmount: 0,
        rmbAmount: 0,
        nairaAmount: 0
607
      },
608 609
      surplusData:[],
      dialogVisible:false,
我在何方's avatar
我在何方 committed
610 611 612 613
      reason:'',
      cancelShow:false,
      cancelTitle:'',
      cancelReason:'',
我在何方's avatar
我在何方 committed
614 615 616 617
      cancelType:1,
      detailReason:'',
      detailTitle:'',
      detailShow:false,
618 619 620
      detailIndex:1,
      wiffShow:false,
      wiffRemark:''
621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642
    }
  },
  computed: {
    showCurrencyId() {
      let fieldList = [];
      let groupList=[];
      this.list.map((element)=>{
        if(fieldList.indexOf(element['currencyId'])===-1){
          fieldList.push(element['currencyId'])
        }
      })
      for(let i=0;i<fieldList.length;i++){
        let arr = this.list.filter((element)=>{
          return element['currencyId']===fieldList[i];
        })
        groupList.push({
          currencyId:arr[0].currencyId,
          list:arr
        })
      }
      if (groupList.length === 1) return groupList[0].currencyId
      else return 1
643 644 645 646 647
    },
    // 已核销总金额
    writeOffTotal(){
      let total = {}
      this.detailed.forEach(item => {
dragondean@qq.com's avatar
dragondean@qq.com committed
648 649 650 651 652
        if(item.status){
          if(!total[item.currencyId]){
            total[item.currencyId] = item.amount
          }else total[item.currencyId] = NP.plus(total[item.currencyId], item.amount)
        }
653 654
      })
      return total
655 656 657 658 659
    },
    // 已核销总金额
    writeOffAmount(){
      let total = 0
      this.detailed.forEach(item => {
660 661 662
        if(item.status){
          total = NP.plus(total, item.writeOffAmount)
        }
663
      })
664
      return total.toFixed(2)
665
    },
666 667 668 669 670
    //显示反审核反核销弹窗
    writeOffShow(){
      this.wiffRemark = ''
      this.wiffShow = true
    },
671
    WriteOffProportion(){
我在何方's avatar
我在何方 committed
672
        let total = 0
dragondean@qq.com's avatar
dragondean@qq.com committed
673
        if(!this.form.receiptAccountList) return 0
我在何方's avatar
我在何方 committed
674 675
        let amountTotal = this.form.receiptAccountList.find(item=>item.type=='total').writeOffAmount

我在何方's avatar
我在何方 committed
676
        this.detailed.forEach(item => {
我在何方's avatar
我在何方 committed
677 678 679 680
          if(item.status){
            total = NP.plus(total, item.writeOffAmount)
          }
           // total = NP.plus(total, item.writeOffAmount)
我在何方's avatar
我在何方 committed
681
        })
我在何方's avatar
我在何方 committed
682
        console.log(total);
我在何方's avatar
我在何方 committed
683
      let portion = NP.divide(total,amountTotal)
684
      return (portion*100).toFixed(2)
685 686
    }
  },
吴滔's avatar
吴滔 committed
687
  watch: {
688 689 690 691 692 693
    // 'addForm.currencyId'(newVal) {
    //   this.currencyIdChange(newVal)
    // },
    'addForm.rate'() {
      this.setWriteOffAmount()
    },
吴滔's avatar
吴滔 committed
694
  },
695 696 697
  async created() {
    // 获取汇率
    await getCurrencyPage(this.params).then(res => this.currencyList = res.data.list)
我在何方's avatar
我在何方 committed
698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714
     await listSimpleDepts().then((res) => {
      res.data.forEach((item) => {
        if (item.parentId == 0) {
          this.deptArr.push(item);
        } else {
          this.deptData.push(item);
        }
      });

      this.deptData.forEach((value) => {
        var dept = this.deptArr.filter((itt) => itt.id == value.parentId);
        if (dept.length > 0) {
          value.name = dept[0].name + " | " + value.name;
        }
      });
      // console.log(this.deptData)
    });
715
    await getBankAccountPage(this.params).then((res) => (this.bankData = res.data.list));
716 717 718 719 720 721 722
    if (this.$route.query.id) {
      this.id = this.$route.query.id;
      await getReceiptInfoByIds({ id: this.id }).then(res => {
        this.form = res.data
        getCustomer(this.form.customerId).then(res => {
          this.form.customerName = res?.data?.name
        })
我在何方's avatar
我在何方 committed
723 724 725 726 727
        var dept = this.deptData.filter((itt) => itt.id == res.data.departmentId);
        // console.log(dept)
        if(dept.length>0){
          this.form.departmentName = dept[0].name
        }
728 729 730 731
      })
      await getInvoicingItem({ id: this.id }).then(res => {
        this.list = [...res.data]
      })
732 733 734 735 736 737
      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),
我在何方's avatar
我在何方 committed
738
            collectionAmount: []
739 740
          }]
        }
我在何方's avatar
我在何方 committed
741
       this.$set(this.form, 'receiptAccountList', [...res.data])
742
        // 收款总计
我在何方's avatar
我在何方 committed
743 744
        // const dollarList = res.data.filter(v => v.collectionCurrencyId == 1)
        // const dollar = dollarList.reduce((total, currentValue) => NP.plus(total, currentValue.collectionAmount || 0), 0)
745

我在何方's avatar
我在何方 committed
746 747
        // const rmbList = res.data.filter(v => v.collectionCurrencyId == 3)
        // const rmb = rmbList.reduce((total, currentValue) => NP.plus(total, currentValue.collectionAmount || 0), 0)
748

我在何方's avatar
我在何方 committed
749 750
        // const nairaList = res.data.filter(v => v.collectionCurrencyId == 2)
        // const naira = nairaList.reduce((total, currentValue) => NP.plus(total, currentValue.collectionAmount || 0), 0)
751

我在何方's avatar
我在何方 committed
752
        // res.data[res.data.length -1].collectionAmount = [dollar, rmb, naira]
753 754
        // this.$set(this.form, 'receiptAccountList', [...this.form.receiptAccountList])

我在何方's avatar
我在何方 committed
755 756 757 758 759 760 761 762 763
        // const dollarListByList = this.list.filter(v => v.currencyId === 1)
        // const discountDollar = dollarListByList.reduce((total, currentValue) => NP.plus(total, currentValue.discountTotal || 0), 0)
        // const d = res.data.find(v => v.currencyId == 1)
        // d && (d.discountTotal = discountDollar)

        // const rmbListByList = this.list.filter(v => v.currencyId === 3)
        // const discountRmb = rmbListByList.reduce((total, currentValue) => NP.plus(total, currentValue.discountTotal || 0), 0)
        // const r = res.data.find(v => v.currencyId == 3)
        // r && (r.discountTotal = discountRmb)
吴滔's avatar
吴滔 committed
764 765 766



dragondean@qq.com's avatar
dragondean@qq.com committed
767
        var n
我在何方's avatar
我在何方 committed
768 769 770 771 772 773
        // 收款总计
        var amountList =[]
        this.currencyList.forEach((item,index)=>{
          var nairaListByList = this.list.filter(v => v.currencyId === item.id)
          if(nairaListByList.length>0){
            var discountNaira = nairaListByList.reduce((total, currentValue) => NP.plus(total, currentValue.discountTotal || 0), 0)
dragondean@qq.com's avatar
dragondean@qq.com committed
774
            n = res.data.find(v => v.currencyId == item.id)
我在何方's avatar
我在何方 committed
775 776 777 778
            n && (n.discountTotal = discountNaira)
          }
          var dollarList = this.form.receiptAccountList.filter(v => v.collectionCurrencyId == item.id)
          if(dollarList.length>0){
779
            var dollar = dollarList.reduce((total, currentValue) => NP.plus(total, currentValue.collectionAmount), 0).toFixed(2)
我在何方's avatar
我在何方 committed
780 781 782
           // if(n && n.discountTotal&&n.discountTotal>0){
           //   amountList.push({currencyName:item.titleZh, currencyId: item.id, amount:(dollar-n.discountTotal).toFixed(2)})
           // }else{
我在何方's avatar
我在何方 committed
783
             amountList.push({currencyId:item.id,currencyNameEn:item.titleEn,currencyNameZh:item.titleZh,amount:dollar})
我在何方's avatar
我在何方 committed
784
           // }
我在何方's avatar
我在何方 committed
785

我在何方's avatar
我在何方 committed
786 787 788 789
          }
        })
        this.form.receiptAccountList[this.form.receiptAccountList.length -1].collectionAmount = amountList
        this.$set(this.form, 'receiptAccountList', [...this.form.receiptAccountList])
我在何方's avatar
我在何方 committed
790

我在何方's avatar
我在何方 committed
791

792
        this.$nextTick(() => {
我在何方's avatar
我在何方 committed
793 794 795
          this.form.receiptAccountList.forEach((item, index) => {
            this.rateChange(item, index)
          });
796 797
        })
      })
798
    }
799

800 801 802
    this.getList()
  },
  methods: {
我在何方's avatar
我在何方 committed
803 804
    rateChange(row, index) {
      console.log(row)
805
      row.receivableAmount && (row.collectionAmount = NP.times(row.collectionRate || 0, NP.minus(row.receivableAmount, row.discountTotal||0)).toFixed(2))
我在何方's avatar
我在何方 committed
806 807
      this.form.receiptAccountList[index] = {...row}
    },
808
    setWriteOffAmount() {
我在何方's avatar
我在何方 committed
809 810 811 812 813 814 815 816 817 818 819 820
      var pointArr = []
      var regs=/^[0-9]+\d*(\.\d*)?$|^0?\.\d*[0-9]\d*$/;
      if(this.addForm.amount&&!regs.test(this.addForm.amount)){
        this.addForm.amount = ''
        this.$modal.msgError(this.$t('输入金额不对'));
      }else{
         pointArr = this.addForm.amount.split('.')
         if(pointArr.length>1&&pointArr[1]){
           this.addForm.amount =Math.round(this.addForm.amount*100)/100
         }

      }
821 822
      this.$set(this.addForm, 'writeOffAmount', NP.times(this.addForm.rate || 0, this.addForm.amount || 0))
    },
我在何方's avatar
我在何方 committed
823 824
    getCurrencyLabel(id){
      var label = this.currencyList.filter(item=>item.id == id)
我在何方's avatar
我在何方 committed
825
      if(label.length>0) return this.$i18n.locale=='zh_CN'?label[0].titleZh:label[0].titleEn
我在何方's avatar
我在何方 committed
826 827
      return ''
    },
828
    calculation() {
829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857
      // this.currencyList.forEach((item,index)=>{
      //   var verificationList = this.detailed.filter(v => v.status === 1)
      //   var dollarList = verificationList.filter(v => v.currencyId === item.id)
      //   if(dollarList.length>0){
      //     let dollar,discountDollar
      //       dollar = dollarList.reduce((total, currentValue) => NP.plus(total, currentValue.amount || 0), 0) : 0
      //       discountDollar = dollarList.reduce((total, currentValue) => NP.plus(total, currentValue.discountTotal || 0), 0)
      //       var t = copyList.find(v => v.currencyId == item.id)
      //       this.form.receiptAccountList.push(
      //         {
      //           discountTotal: discountDollar,
      //           currencyId: item.id,
      //           receivableAmount: dollar,
      //           writeOffRate: t?.writeOffRate || NP.divide(this.currencyList.find(v => v.id === item.id).huilv, this.currencyList.find(v => v.id === this.showCurrencyId).huilv).toFixed(6),
      //           platformAccountId: t?.platformAccountId || '',
      //           collectionCurrencyId: t?.collectionCurrencyId || item.id,
      //           collectionRate: t?.collectionRate || 1
      //         }
      //       )
      //       this.calculationCount(NP.minus(dollar, discountDollar), item.id)
      //   }
      // })
      // const verificationList = this.detailed.filter(v => v.status === 1)
      // const dollarList = verificationList.filter(v => v.currencyId === 1)
      // const dollar = dollarList.length > 0 ? dollarList.reduce((total, currentValue) => NP.plus(total, currentValue.amount || 0), 0) : 0
      // const rmbList = verificationList.filter(v => v.currencyId === 3)
      // const rmb = rmbList.length > 0 ? rmbList.reduce((total, currentValue) => NP.plus(total, currentValue.amount || 0), 0) : 0
      // const nairaList = verificationList.filter(v => v.currencyId === 2)
      // const naira = nairaList.length > 0 ? nairaList.reduce((total, currentValue) => NP.plus(total, currentValue.amount || 0), 0) : 0
858

859 860 861
      // const usCount = NP.plus(dollar, NP.times(this.RMBtoUS(), rmb),  NP.times(this.NANtoUS(), naira))
      // const rmbCount = NP.plus(rmb, NP.times(this.UStoRMB(), dollar),  NP.times(this.NANtoRMB(), naira))
      // const nairaCount = NP.plus(naira, NP.times(this.UStoNAN(), dollar),  NP.times(this.RMBtoNAN(), rmb))
862

863 864 865
      // this.verificationData.usCount = usCount
      // this.verificationData.rmbCount = rmbCount
      // this.verificationData.nairaCount = nairaCount
866 867 868
      // this.verificationData.usCount = dollar
      // this.verificationData.rmbCount = rmb
      // this.verificationData.nairaCount = naira
869

870 871 872 873
      // if (verificationList.indexOf(1)>-1) { // 美元
      //   this.verificationData.writtenOff = dollar
      //   this.verificationData.WriteOffProportion = NP.times(NP.divide(dollar, this.form.receivableTotalAmount), 100)
      //   const remaining = NP.minus(this.form.receivableTotalAmount, dollar)
874 875 876 877 878
        // this.remainingAmount = {
        //   usAmount: remaining,
        //   rmbAmount: NP.times(this.UStoRMB(), remaining),
        //   nairaAmount: NP.times(this.UStoNAN(), remaining)
        // }
879 880 881 882 883
      //   this.remainingAmount.usAmount = remaining
      // } else if (this.showCurrencyId === 2) { // 人民币
      //   this.verificationData.writtenOff = rmb
      //   this.verificationData.WriteOffProportion = NP.times(NP.divide(rmb, this.form.receivableTotalAmount), 100)
      //   const remaining = NP.minus(this.form.receivableTotalAmount, rmb)
884 885 886 887 888
        // this.remainingAmount = {
        //   usAmount: NP.times(this.RMBtoUS(), remaining),
        //   rmbAmount: remaining,
        //   nairaAmount: NP.times(this.RMBtoNAN(), remaining)
        // }
889 890 891 892 893
      //   this.remainingAmount.rmbAmount = remaining
      // } else if (this.showCurrencyId === 3) { // 奈拉
      //   this.verificationData.writtenOff = naira
      //   this.verificationData.WriteOffProportion = NP.times(NP.divide(naira, this.form.receivableTotalAmount), 100)
      //   const remaining = NP.minus(this.form.receivableTotalAmount, naira)
894 895 896 897 898
        // this.remainingAmount = {
        //   usAmount: NP.times(this.NANtoUS(), remaining),
        //   rmbAmount: NP.times(this.NANtoRMB(), remaining),
        //   nairaAmount: remaining
        // }
899 900
        // this.remainingAmount.nairaAmount = remaining
      // }
901
    },
902 903 904
    accountChange(val){
      var data = this.bankData.find(item=>item.id==val)
      this.$set(this.addForm,'accountName',data.baAccountName)
我在何方's avatar
我在何方 committed
905 906
      this.$set(this.addForm,'accountNo',data.baAccountNum)
      this.$set(this.addForm,'accountBankName',data.baBankName)
907
    },
908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925
    RMBtoUS() {
      return NP.divide(100, this.currencyList.find(v => v.titleEn === 'USD').huilv)
    },
    NANtoUS() {
      return NP.times(this.RMBtoUS(), this.NANtoRMB())
    },
    UStoRMB() {
      return NP.divide(this.currencyList.find(v => v.titleEn === 'USD').huilv, 100)
    },
    UStoNAN() {
      return NP.times(this.RMBtoNAN(), this.UStoRMB())
    },
    RMBtoNAN() {
      return NP.divide(100, this.currencyList.find(v => v.titleEn === 'NGN').huilv)
    },
    NANtoRMB() {
      return NP.divide(this.currencyList.find(v => v.titleEn === 'NGN').huilv, 100)
    },
我在何方's avatar
我在何方 committed
926 927 928 929 930 931
    //显示反核销弹窗
    showCancel(index){
      this.selectIndex = index
      this.reason = ''
      this.dialogVisible = true
    },
我在何方's avatar
我在何方 committed
932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949
    writeOffClick(){
      if(!this.wiffRemark){
         this.$modal.msgError(this.$t('请输入申请理由'));
        return
      }
        this.$modal
          .confirm(this.$t('您确认要反核销吗')+'?')
          .then(()=>{
            financeReceiptWriteOffNo({receiptId:this.id,receiptNo:this.form.receiptNo,remark:this.wiffRemark}).then(res=>{
              this.getReceiptInfoData();
              this.$message.success(this.$t("提交成功"));
              this.wiffShow = false
              // this.$store.dispatch('tagsView/delCurrentView')
            });
          })
          .catch(() => {this.wiffShow = false});
    
    },
我在何方's avatar
我在何方 committed
950 951 952 953 954 955 956 957 958 959 960
    //显示取消审核弹窗
    detailClickCancel(type){
      this.detailIndex = type
      this.detailReason = ''
      if(this.detailIndex==1){
        this.detailTitle = this.$t('取消反核销审核')
      }else{
        this.detailTitle = this.$t('取消全部核销审核')
      }
      this.detailShow = true
    },
我在何方's avatar
我在何方 committed
961
    //取消审核弹窗
我在何方's avatar
我在何方 committed
962
    cancelClick(index,type){
我在何方's avatar
我在何方 committed
963
       this.selectIndex = index
我在何方's avatar
我在何方 committed
964
       this.cancelType = type
我在何方's avatar
我在何方 committed
965 966 967 968
        this.cancelReason = ''
        this.cancelShow = true
    },
    //取消审核
我在何方's avatar
我在何方 committed
969 970 971 972 973 974 975 976
    detailWriteOffClick(){
      if(!this.detailReason){
         this.$modal.msgError(this.$t('请输入申请理由'));
        return
      }
      if(this.detailIndex ==1){
          cancelFinanceReceiptWriteOffNo({receiptId:this.id,remark:this.detailReason}).then(res=>{
            this.detailShow = false
977
            this.getReceiptInfoData();
我在何方's avatar
我在何方 committed
978 979 980 981 982 983
            this.$message.success(this.$t("提交成功"));

          });
      }else{
          cancelFinanceReceiptWriteOff({receiptId:this.id,remark:this.detailReason}).then(res=>{
            this.detailShow = false
984
            this.getReceiptInfoData();
我在何方's avatar
我在何方 committed
985 986 987 988 989 990
            this.$message.success(this.$t("提交成功"));

          });
      }

    },
991 992 993 994 995 996 997 998 999 1000 1001 1002 1003
    getReceiptInfoData(){
      getReceiptInfoByIds({ id: this.id }).then(res => {
        this.form = res.data
        getCustomer(this.form.customerId).then(res => {
          this.form.customerName = res?.data?.name
        })
        var dept = this.deptData.filter((itt) => itt.id == res.data.departmentId);
        // console.log(dept)
        if(dept.length>0){
          this.form.departmentName = dept[0].name
        }
      })
    },
我在何方's avatar
我在何方 committed
1004
    //取消审核
我在何方's avatar
我在何方 committed
1005 1006 1007 1008 1009 1010
    cancelWriteOffClick(){
      if(!this.cancelReason){
         this.$modal.msgError(this.$t('请输入申请理由'));
        return
      }
      var receiptItemId = this.detailed[this.selectIndex].id
我在何方's avatar
我在何方 committed
1011
      if(this.cancelType==1){
我在何方's avatar
我在何方 committed
1012 1013
        cancelFinanceReceiptItemWriteOff({receiptItemId:receiptItemId,remark:this.cancelReason}).then(res=>{
          this.cancelShow = false
我在何方's avatar
我在何方 committed
1014
          this.getList()
我在何方's avatar
我在何方 committed
1015 1016
          this.$message.success(this.$t("提交成功"));

我在何方's avatar
我在何方 committed
1017
        });
我在何方's avatar
我在何方 committed
1018 1019 1020 1021
      }else{
        cancelFinanceReceiptItemWriteOffNo({receiptItemId:receiptItemId,remark:this.cancelReason}).then(res=>{
          this.cancelShow = false
          this.getList()
我在何方's avatar
我在何方 committed
1022 1023
          this.$message.success(this.$t("提交成功"));

我在何方's avatar
我在何方 committed
1024 1025 1026
        });
      }

我在何方's avatar
我在何方 committed
1027
    },
吴滔's avatar
吴滔 committed
1028 1029
    currencyIdChange(val) {
      val = Number(val)
1030
      let rate
吴滔's avatar
吴滔 committed
1031
      if(val === this.showCurrencyId) {
1032
        rate = 1
吴滔's avatar
吴滔 committed
1033
      } else {
我在何方's avatar
我在何方 committed
1034 1035 1036 1037 1038 1039
        // if (this.showCurrencyId === 1 && val === 3) rate = this.RMBtoUS()
        // else if (this.showCurrencyId === 1 && val === 2) rate = this.NANtoUS()
        // else if (this.showCurrencyId === 3 && val === 1) rate = this.UStoRMB()
        // else if (this.showCurrencyId === 3 && val === 2) rate = this.NANtoRMB()
        // else if (this.showCurrencyId === 2 && val === 1) rate = this.UStoNAN()
        // else if (this.showCurrencyId === 2 && val === 3) rate = this.RMBtoNAN()
1040
        rate = NP.times(this.currencyList.find(v => v.id === val).huilv/100, this.currencyList.find(v => v.id === this.showCurrencyId).exchangeToFc/100).toFixed(6)
吴滔's avatar
吴滔 committed
1041
      }
1042
      this.$set(this.addForm, 'rate', rate)
吴滔's avatar
吴滔 committed
1043
    },
1044 1045 1046 1047 1048 1049
    getList() {
      getReceivableItem({ id: this.id }).then(res => {
        this.detailed = res.data.map(v => ({
          ...v,
          amountDate: this.parseTime(v.amountDate, '{y}-{m}-{d}'),
          accountNo: +v.accountNo,
1050
          rate:parseFloat(v.rate).toFixed(6),
1051 1052
          attr: v.attr ? v.attr.split(',').map(t => ({ name: t.slice(t.lastIndexOf('/') + 1), url: t })) : []
        }))
1053
        // this.calculation()
1054 1055 1056 1057 1058 1059 1060 1061 1062
      })
    },
    saveFrom() {
      this.$refs.addForm.validate ((valid)=>{
        if (valid) {
          if (this.addForm.id) {
            const params = {...this.addForm}
            params.attr && (params.attr = params.attr.map(v => v.url).join(','))
            updateReceiptItem(params).then(res => {
吴滔's avatar
吴滔 committed
1063
              this.$modal.msgSuccess(this.$t('修改成功'));
1064 1065 1066 1067 1068 1069 1070 1071 1072
              this.openAddDialog = false
              this.getList()
            })
            return
          }
          const params = {...this.addForm}
          params.attr && (params.attr = params.attr.map(v => v.url).join(','))
          params.receiptId = this.id
          receiptItemCreate(params).then(res => {
吴滔's avatar
吴滔 committed
1073
            this.$modal.msgSuccess(this.$t('新增成功'));
1074 1075 1076 1077 1078
            this.openAddDialog = false
            this.getList()
          })
        }
      })
1079

1080 1081 1082 1083
    },
    toEdit() {
      return this.$router.push("creatCollection?id=" + this.id);
    },
1084 1085
    detailClick(row) {
      this.openAddDialog = true
吴滔's avatar
吴滔 committed
1086
      this.dialogTitle = this.$t('银行实收明细详情')
1087 1088 1089
      this.isView = true
      setTimeout(() => {
        this.addForm = { ...row }
1090
        this.setWriteOffAmount()
1091 1092
      }, 0)
    },
1093 1094
    editClick(row) {
      this.openAddDialog = true
吴滔's avatar
吴滔 committed
1095 1096
      this.dialogTitle = this.$t('编辑银行实收明细')
      this.saveBtnText = this.$t('提交')
1097
      this.isView = false
1098 1099
      setTimeout(() => {
        this.addForm = { ...row }
1100
        this.setWriteOffAmount()
1101 1102 1103 1104
      }, 0)
    },
    deleteClick(row) {
      const id = row.id;
我在何方's avatar
我在何方 committed
1105
      this.$modal.confirm(this.$t('是否确认删除该收款单')+'?').then(function() {
1106 1107 1108
        return deleteReceiptItem(id);
      }).then(() => {
        this.getList();
吴滔's avatar
吴滔 committed
1109
        this.$modal.msgSuccess(this.$t('删除成功'));
1110 1111 1112 1113 1114
      }).catch(() => {});
    },
    verificationClick(row) {
      const id = row.id;
      this.$modal
我在何方's avatar
我在何方 committed
1115
        .confirm(this.$t('您确认要核销吗')+'?')
1116 1117 1118 1119 1120
        .then(function () {
          return receiptItemVerification(id);
        })
        .then(() => {
          this.getList();
吴滔's avatar
吴滔 committed
1121
          this.$modal.msgSuccess(this.$t('核销成功'));
1122 1123 1124
        })
        .catch(() => {});
    },
我在何方's avatar
我在何方 committed
1125 1126 1127 1128 1129 1130 1131
    //银行明细反核销
    verificationCancelClick() {
      if(!this.reason){
         this.$modal.msgError(this.$t('请输入申请理由'));
        return
      }
      const id = this.detailed[this.selectIndex].id
1132
      this.$modal
我在何方's avatar
我在何方 committed
1133
        .confirm(this.$t('您确认要反核销吗')+'?')
我在何方's avatar
我在何方 committed
1134 1135
        .then(()=>{
          financeReceiptItemWriteOffNo({receiptId:this.id,receiptNo:this.form.receiptNo,receiptItemId:id,remark:this.reason}).then(res=>{
我在何方's avatar
我在何方 committed
1136
              this.getList();
我在何方's avatar
我在何方 committed
1137 1138 1139
              this.$message.success(this.$t("提交成功"));
              this.dialogVisible = false
            });
1140
        })
我在何方's avatar
我在何方 committed
1141
        .catch(() => {this.dialogVisible = false});
1142 1143 1144 1145 1146 1147
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    batchVerification() {
      if (this.multipleSelection.length === 0) {
我在何方's avatar
我在何方 committed
1148
        this.$modal.msgError(this.$t('请选择需要核销的收款明细'));
1149 1150 1151 1152
        return
      }
      const params = { ids: this.multipleSelection.map(v => v.id).join(',') }
      this.$modal
我在何方's avatar
我在何方 committed
1153
        .confirm(this.$t('您确认要核销吗'+'?'))
1154 1155 1156 1157 1158 1159 1160 1161
        .then(function () {
          return receiptItemBatchVerification(params);
        })
        .then(() => {
          this.multipleSelection.forEach(row => {
            this.$refs.multipleTable.toggleRowSelection(row);
          });
          this.getList();
吴滔's avatar
吴滔 committed
1162
          this.$modal.msgSuccess(this.$t('核销成功'));
1163 1164 1165 1166
        })
        .catch(() => {});
    },
    verificationAll() {
我在何方's avatar
我在何方 committed
1167
      if(!this.detailed||this.detailed.length==0){
我在何方's avatar
我在何方 committed
1168
        this.$modal.msgError(this.$t('当前收款单未添加银行收款明细,无法全部核销,请添加银行收款单明细,并核销所有实收明细后再进行全部核销'));
我在何方's avatar
我在何方 committed
1169 1170
        return
      }
1171
      this.$modal
我在何方's avatar
我在何方 committed
1172
        .confirm(this.$t('您确认要全部核销吗'+'?'))
1173
        .then(() => {
我在何方's avatar
我在何方 committed
1174
          return financeReceiptWriteOff({receiptId:this.id,receiptNo:this.form.receiptNo});
1175 1176
        })
        .then(() => {
吴滔's avatar
吴滔 committed
1177
          this.$modal.msgSuccess(this.$t('核销成功'));
我在何方's avatar
我在何方 committed
1178
          this.$store.dispatch('tagsView/delCurrentView');
1179 1180 1181 1182 1183 1184 1185
        })
        .catch(() => {});
    },
    hiddenDialog() {
      this.openAddDialog = false
    },
    handleAddReceiptItem() {
1186
      this.surplusData = []
dragondean@qq.com's avatar
dragondean@qq.com committed
1187 1188

      // 已收
1189 1190 1191 1192 1193 1194 1195 1196
      let recepted = []
      this.detailed.forEach(item => {

          if(!recepted[item.currencyId]){
            recepted[item.currencyId] = item.amount
          }else recepted[item.currencyId] = NP.plus(recepted[item.currencyId], item.amount)
      })
      console.log('rece',recepted)
dragondean@qq.com's avatar
dragondean@qq.com committed
1197 1198

      // 应收
1199
      let collom = []
dragondean@qq.com's avatar
dragondean@qq.com committed
1200
      /* this.form.receiptAccountList.forEach(item => {
1201 1202 1203 1204 1205
          if(item.type!='total'){
            if(!collom[item.currencyId]){
              collom[item.currencyId] = item.receivableAmount-item.discountTotal
            }else collom[item.currencyId] = NP.plus(collom[item.currencyId], item.receivableAmount)
          }
dragondean@qq.com's avatar
dragondean@qq.com committed
1206 1207 1208 1209
      }) */
      // 从期望收费金额中提取应收币种和金额
      this.form.receiptAccountList.find(item => item.type == 'total').collectionAmount.forEach(item => {
        collom[item.currencyId] = item.amount
1210
      })
我在何方's avatar
我在何方 committed
1211
      console.log(this.form.receiptAccountList)
1212
          console.log('collom',collom)
我在何方's avatar
我在何方 committed
1213
      // if(recepted.length>collom.length){
1214 1215 1216 1217 1218 1219 1220 1221 1222 1223
        recepted.forEach((amount,currency)=>{
          if(amount){
            if(collom[currency]){
              if((collom[currency]-amount)!=0) this.surplusData[currency] = +parseFloat((collom[currency]-amount).toPrecision(12))
            }else{
              this.surplusData[currency] = -amount
            }
          }

        })
我在何方's avatar
我在何方 committed
1224
      // }else{
1225 1226
        collom.forEach((amount,currency)=>{
          if(amount){
我在何方's avatar
我在何方 committed
1227 1228 1229 1230
            if(!this.surplusData[currency]){
              if(recepted[currency]){
               if((amount-recepted[currency])!=0)  this.surplusData[currency] = +parseFloat((amount-recepted[currency]).toPrecision(12))
              }else{
1231 1232
              this.surplusData[currency] = amount
            }
我在何方's avatar
我在何方 committed
1233 1234

            }
1235 1236
          }
        })
我在何方's avatar
我在何方 committed
1237
      // }
1238
      console.log(this.surplusData)
1239 1240
      this.addForm = {}
      this.openAddDialog = true
1241
      this.isView = false
吴滔's avatar
吴滔 committed
1242 1243
      this.dialogTitle = this.$t('添加银行实收明细')
      this.saveBtnText = this.$t('添加')
1244 1245 1246 1247 1248 1249 1250 1251 1252
    },
    handleUploadSuccess(res, file, fileList) {
      var arr = [];
      setTimeout(() => {
        fileList.forEach((item) => {
          arr.push({ name: item.name, url: item.response ? item.response.data : item.url });
        });
        this.addForm.attr = arr;
      }, 300)
1253
      this.loading.close();
1254 1255 1256 1257
    },
    handleBeforeUpload() {
      this.loading = this.$loading({
        lock: true,
吴滔's avatar
吴滔 committed
1258
        text: this.$t('上传中'),
1259 1260 1261 1262 1263 1264
        background: "rgba(0, 0, 0, 0.7)",
      });
    },
    handleUploadError() {
      this.$message({
        type: "error",
吴滔's avatar
吴滔 committed
1265
        message: this.$t('上传失败'),
1266 1267 1268 1269
      });
      this.loading.close();
    },
    beforeRemove(file, fileList) {
我在何方's avatar
我在何方 committed
1270
      return this.$confirm(this.$t('确定移除')+'?').then(res => {
1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298
        setTimeout(() => {
          this.addForm.attr = fileList.map(v => ({ name: v.name, url: v.response ? v.response.data : v.url }))
        }, 300)
      });
    }
  }
}
</script>

<style scoped lang="scss">
.app-container {
  ::v-deep .el-descriptions-item__label {
    width: 200px;
  }
  ::v-deep .el-tag + .el-tag {
    margin-left: 8px;
  }
}
.card {
  margin-top: 20px;
}
.dialog-footer {
  padding: 40px;
}
.card-title {
  font-size: 18px;
  font-weight: bold;
}
1299 1300 1301 1302 1303 1304 1305 1306
.hexiaoCard {
  ::v-deep .el-descriptions-item__label {
    width: 11%;
  }
  ::v-deep .el-descriptions-item__content {
    width: 22%;
  }
}
1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317
  .cancel_content{
    display: flex;
    // align-items: center;
    flex-direction: column;
    // padding-top: 20px;
  }
  .cancel_content span{
    font-size: 16px;
    font-weight:600;
    margin-bottom:10px
  }
1318
</style>