detail.vue 36.3 KB
Newer Older
lanbaoming's avatar
lanbaoming committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 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 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829
<template>
  <div class="app-container">
        <el-card>
            <div slot="header" class="card-title">{{$t('报价单详情')}}</div>
          <!-- 列表 -->
          <div class="offer-header">
              <span style="font-size: 15px;">{{$t('报价单号')}}{{list.number}}</span>
              <div class="btns">
                <el-button v-hasPermi="['ecw:offer:update']" size="mini" type="primary" v-if="[4,5,6].indexOf(list.status) == -1"  @click="$router.push('edit?id=' + offerId)">{{$t('编辑')}}</el-button>
                <el-button v-hasPermi="['ecw:offer:loglist']" type="primary" v-if="[1,3,7].indexOf(list.status) > -1"  size="mini" @click="handleAdd">{{$t('跟进')}}</el-button>
                <el-button v-hasPermi="['ecw:offer:result']" type="primary"  v-if="[3,7].indexOf(list.status) > -1" size="mini" @click="toResult">{{$t('结果')}}</el-button>
                <el-button v-hasPermi="['ecw:offer:discount','ecw:offer:commission']" size="mini" v-if="[1,3,7].indexOf(list.status) > -1" type="primary" @click.native="$router.push('/offer/special?offerId=' + offerId)" >{{$t('特价')}}</el-button>
                <el-button v-hasPermi="['ecw:offer:delete']" type="danger" size="mini" @click="handleDelete">{{$t('删除')}}</el-button>
              </div>
          </div>
          <div>
            <div class="title-font">
              <label>{{$t('报价单所属')}}{{list.relation?list.relation==1?$t('发货人'):$t('收货人'):$t('发货人')}}</label>
            </div>
                <el-descriptions :column="3" border class="card" v-if="list.consignorId">
                    <el-descriptions-item :label="$t('发货人')+':'">
                        {{consignorData.contactsName||$t('')}}
                    </el-descriptions-item>
                    <el-descriptions-item :label="$t('手机号')+':'">
                      {{consignorData && consignorData.phoneNew ? (checkCode(consignorData.areaCode) + consignorData.phoneNew)||$t(''):$t('')}}
                    </el-descriptions-item>
                    <el-descriptions-item :label="$t('联系地址')+':'">
                      {{consignorData.address||$t('')}}
                    </el-descriptions-item>
                    <el-descriptions-item :label="$t('客户来源')+':'">
                          {{consignorData.source||$t('')}}
                    </el-descriptions-item>
                    <el-descriptions-item :label="$t('发货人公司名称')+':'">
                      {{consignorData.company||$t('')}}
                    </el-descriptions-item>
                    <el-descriptions-item :label="$t('社交软件')+':'">
                       <dict-tag :type="DICT_TYPE.SOCIAL" :value="consignorData.social" />
                       {{consignorData.socialNumber?('('+consignorData.socialNumber+')'):''}}
                    </el-descriptions-item>
                </el-descriptions>

               <el-descriptions :column="3" border class="card" v-if="list.consigneeId">
                   <el-descriptions-item :label="$t('收货人')+':'">
                    {{consigneeData.contactsName||$t('')}}
                    </el-descriptions-item>
                    <el-descriptions-item :label="$t('手机号')+':'">
                      {{consigneeData && consigneeData.phoneNew ?(checkCode(consigneeData.areaCode)+consigneeData.phoneNew)||$t(''):$t('')}}
                    </el-descriptions-item>
                    <el-descriptions-item :label="$t('联系地址')+':'">
                      {{consigneeData.address||$t('')}}
                    </el-descriptions-item>
                    <el-descriptions-item :label="$t('客户来源')+':'">
                          {{consigneeData.source||$t('')}}
                    </el-descriptions-item>
                    <el-descriptions-item :label="$t('发货人公司名称')+':'">
                      {{consigneeData.company||$t('')}}
                    </el-descriptions-item>
                    <el-descriptions-item :label="$t('社交软件')+':'">
                       <dict-tag :type="DICT_TYPE.SOCIAL" :value="consigneeData.social" />
                       {{consigneeData.socialNumber?('('+consigneeData.socialNumber+')'):''}}
                    </el-descriptions-item>
               </el-descriptions>
                <el-descriptions :column="4" class="card">
                    <el-descriptions-item :label="$t('运输方式')">
                         <dict-tag :type="DICT_TYPE.ECW_TRANSPORT_TYPE" :value="list.transportId" />
                    </el-descriptions-item>
                    <el-descriptions-item :label="$t('出货渠道')" v-if="[3,4].indexOf(list.transportId) > -1">
                      {{channelName}}
                    </el-descriptions-item>
                 </el-descriptions>
                 <el-descriptions :column="4" class="card">
                     <el-descriptions-item :label="$t('始发城市')">
                        {{getCity(list.departureId)}}
                     </el-descriptions-item>
                     <el-descriptions-item :label="$t('目的城市')">
                        {{getCity(list.objectiveId)}}
                     </el-descriptions-item>
                  </el-descriptions>
                <el-descriptions :column="4" class="card">
                    <el-descriptions-item :label="$t('线路')">
                      {{getRouterNameById(list.lineId)}}
                    </el-descriptions-item>
                 </el-descriptions>
                 <el-descriptions :column="4" class="card">
                     <el-descriptions-item :label="$t('报价单状态')">
                       <dict-tag :type="DICT_TYPE.ECW_OFFER_STATUS" :value="list.status" />
                     </el-descriptions-item>
                  </el-descriptions>
                  <el-descriptions :column="4" class="card" v-if="list.status==5">
                      <el-descriptions-item :label="$t('输单原因')">
                        {{list.reason}}
                      </el-descriptions-item>
                   </el-descriptions>

          </div>
        </el-card>

        <el-card class="card">
          <div slot="header" class="card-title">{{$t('商品信息')}}</div>
          <div style="overflow: auto;">
          <el-table v-loading="loading" border :data="list.offerProdRespVOList">
                <el-table-column :label="$t('序号')" width="60px" fixed>
                  <template slot-scope="scope">
                      {{scope.$index + 1}}
                  </template>
                </el-table-column>
<!--                <el-table-column :label="商品类型" align="center" prop="goodsType" /> -->
                <el-table-column :label="$t('中文品名')" align="center" prop="prodTitleZh" />
                <el-table-column :label="$t('英文品名')" align="center" prop="prodTitleEn" />
                <el-table-column :label="$t('品牌')" width="100px">
                  <template slot-scope="scope">
                      <dict-tag :value="scope.row.brand" :type="DICT_TYPE.ECW_IS_BRAND" defaultable />
                  </template>
                </el-table-column>
                <el-table-column :label="$t('件数')" width="90px" prop="num" />
                <el-table-column :label="$t('包装单位')">
                  <template slot-scope="scope">
                      <dict-tag :value="scope.row.unit" :type="DICT_TYPE.ECW_PACKAGING_TYPE" defaultable />
                  </template>
                </el-table-column>
                <!-- <el-table-column :label="$t('箱规') + '(m)'" width="120px" prop="boxGauge" /> -->
                <el-table-column :label="$t('体积') + '(m³)'" width="100px" prop="volume" />
                <el-table-column :label="$t('数量')" width="100px" prop="quantity" />
                <el-table-column :label="$t('重量') + '(kg)'" width="100px" prop="weight" />
                <el-table-column :label="$t('货值') + '(RMB)'" width="100px" prop="worth" />
                <el-table-column :label="$t('商品特性')" width="200px" prop="prodAttrName" />
                 <el-table-column :label="$t('是否预付')">
                   <template slot-scope="scope">
                      {{scope.row.isPayAdvance==1?$t('预付'):$t('到付')}}
                   </template>
                 </el-table-column>

                <el-table-column :label="$t('成交价')" width="200px">
                  <template slot-scope="{row}">
                    <template v-if="row.charging ==1">
                      <template v-if="!row.oneSeaFreight">{{ $t('未报价') }}</template>
                      <template>{{$t('全包价')}} {{row.oneSeaFreight}} {{currentcyMap[row.seaFreightCurrency]}} / {{unitMap[row.seaFreightVolume]}}</template>
                    </template>
                    <template v-else-if="!row.oneSeaFreight && !row.oneClearanceFreight">{{ $t('未报价') }}</template>
                    <template v-else>
                      <div>
                          {{$t('运费')}}{{row.oneSeaFreight}} {{currentcyMap[row.seaFreightCurrency]}} / {{unitMap[row.seaFreightVolume]}}
                      </div>
                      <div v-if="row.oneClearanceFreight">
                          {{$t('清关费')}}{{row.oneClearanceFreight}} {{currentcyMap[row.clearanceFreightCurrency]}} / {{unitMap[row.clearanceFreightVolume]}}
                      </div>
                      <div v-else>{{$t('清关费未报价')}}</div>
                    </template>
                  </template>
                </el-table-column>
              </el-table>
              </div>
        </el-card>
        <el-card class="card">
          <div slot="header" class="card-title">{{$t('费用小计')}}</div>
            <el-descriptions border class="card" :column="5">
              <el-descriptions-item :label="$t('总件数')+':'">
                  {{list.estCostVO?list.estCostVO.totalNum||'0':0}}
              </el-descriptions-item>
              <el-descriptions-item :label="$t('总体积')+':'">
                {{list.estCostVO?(list.estCostVO.totalVolume+'m³')||'0':0}}
              </el-descriptions-item>
              <el-descriptions-item :label="$t('总重量')+':'">
                {{list.estCostVO?(list.estCostVO.totalWeight+'kg')||'0':0}}
              </el-descriptions-item>
              <el-descriptions-item :label="$t('总数量')+':'">
                {{list.estCostVO?list.estCostVO.totalQuantity||'0':0}}
              </el-descriptions-item>
              <el-descriptions-item :label="$t('总货值(RMB)')+':'">
                  {{list.estCostVO?list.estCostVO.totalWorth||'0':0}}
              </el-descriptions-item>
<!--              <el-descriptions-item :label="报价费:">
                {{list.estCostVO?list.estCostVO.insuranceFee||'0':0}}
              </el-descriptions-item> -->
          </el-descriptions>
<!--          <el-descriptions border class="card">
            <el-descriptions-item :label="佣金类型" :span="2" class="card">
                <dict-selector :type="DICT_TYPE.COMMISSION_TYPE" form-type="radio" fomtter="number"  :value="list.commissionType" defaultable />
            </el-descriptions-item>
          </el-descriptions> -->
        </el-card>
        <el-card class="mt-10">
            <div class="card-title" slot="header">{{$t('预计费用')}}</div>

            <el-descriptions :column="5" border>
                <el-descriptions-item :label="$t('保价费')">
                    {{list.estCostVO?list.estCostVO.insuranceFee: 0}} {{ selectedRouter ? currentcyMap[selectedRouter.currencyUnit || 1] : '' }}
                </el-descriptions-item>
                <el-descriptions-item :label="$t('总运费')">
                    <template v-if="freightFeeList.length>0" v-for="item in freightFeeList">
                        <div :key="item.currencyId">{{item.amount || 0}}{{currentcyMap[item.currencyId]}}</div>
                    </template>
                </el-descriptions-item>
                <template v-if="freightFeeList.length==0">
                    0
                </template>
                <!--代收货款,只有非控货订单、并且线路开通了代收货款后,才显示是否代收货款选项-->
                <el-descriptions-item :label="$t('总清关费')">
                    <template v-if="clearanceFeeList.length>0" v-for="item in clearanceFeeList">
                        <div :key="item.currencyId">{{item.amount || 0}}{{currentcyMap[item.currencyId]}}</div>
                    </template>
                    <template v-if="clearanceFeeList.length==0">
                        0
                    </template>
                </el-descriptions-item>
                <el-descriptions-item :label="$t('其他费用')">
                   <template v-if="otherFeeList.length>0" v-for="item in otherFeeList">
                       <div :key="item.currencyId">{{item.amount || 0}}{{currentcyMap[item.currencyId]}}</div>
                   </template>
                   <template v-if="otherFeeList.length==0">
                       0
                   </template>
                </el-descriptions-item>
                <el-descriptions-item :label="$t('原价')" :span="2">
                    <template v-if="originalFeeList.length>0" v-for="item in originalFeeList">
                        <div :key="item.currencyId">{{item.amount || 0}}{{currentcyMap[item.currencyId]}}</div>
                    </template>
                    <template v-if="originalFeeList.length==0">
                        0
                    </template>
                </el-descriptions-item>
            </el-descriptions>


            <div class="card-title" style="padding:20px 0;">{{$t('优惠信息')}}</div>
            <el-table :data="couponList" :show-header="false">
                <el-table-column label="">
                    <template slot-scope="scope">
                        {{scope.$index+1}}.
                        {{getProductName(scope.row.prodId)}}
                    </template>
                </el-table-column>
                <el-table-column label="">
                    <template slot-scope="{row}">
                      <dict-tag :type="DICT_TYPE.ECW_COUPON_TYPE" :value="row.type" />
                    </template>
                </el-table-column>
                <el-table-column label="">
                    <template slot-scope="{row}">
                        {{$l(row, 'title')}}
                    </template>
                </el-table-column>
                <el-table-column label="">
                    <template slot-scope="{row}">
                        -{{row.reduceAmount}}
                        {{currentcyMap[row.reduceCurrencyId]}}
                    </template>
                </el-table-column>
                <el-table-column label="">
                    <template slot-scope="{row}">
                        {{$t('有效期至')}}{{row.endTime ? row.endTime : $t('永久有效')}}
                    </template>
                </el-table-column>
            </el-table>

            <el-descriptions :column="1" class="mt-20">
                <el-descriptions-item :label="$t('优惠费用')"  v-if="couponTotalAmountList && couponTotalAmountList.length>0">
                    <div v-for="(item, discountIndex) in couponTotalAmountList" :key="discountIndex">
                        {{item.totalAmount}} {{currentcyMap[item.currencyId]}}
                    </div>
                </el-descriptions-item>
                <el-descriptions-item :label="$t('预计费用')">
                    <template >
                      <div style="display:flex;flex-direction:column">
                        <div v-for="item in estimatedCosts" :key="item.currencyId">
                          <span>{{item.amount || 0}}{{currentcyMap[item.currencyId]}}</span>
                          </div>
                          </div>
                    </template>
                </el-descriptions-item>
            </el-descriptions>
        </el-card>
        <el-card class="card">
          <div slot="header" class="card-title">{{$t('通用信息')}}</div>
            <el-descriptions :column="4">
              <el-descriptions-item :label="$t('唛头')">
                  {{list.marks||'/'}}
              </el-descriptions-item>
              <el-descriptions-item :label="$t('报关方式')">
                  <dict-tag :type="DICT_TYPE.ECW_CUSTOMS_TYPE" :value="list.customsType"></dict-tag>
              </el-descriptions-item>
              </el-descriptions>
            <el-descriptions :column="4">
             <el-descriptions-item :label="$t('预计结束时间')">
                  {{list.stopTime||'/'}}
              </el-descriptions-item>
              <el-descriptions-item :label="$t('控货')">
                   {{list.control?$t('是'):$t('否')}}
               </el-descriptions-item>
               <el-descriptions-item :label="$t('竞争对手')">
                  {{list.competitor||'/'}}
                </el-descriptions-item>
                <el-descriptions-item :label="$t('重要程度')">
                    <el-rate v-model="list.importance" disabled></el-rate>
                 </el-descriptions-item>
          </el-descriptions>
          <el-descriptions :column="4">
             <el-descriptions-item :label="$t('价格有效期')">
                 {{list.startTime+$t('至')}}{{list.endTime}}
              </el-descriptions-item>
              <el-descriptions-item :label="$t('交货方式')">
                <dict-tag :type="DICT_TYPE.ECW_TRADE_TYPE" :value="list.tradeType"></dict-tag>
                   <span style="margin-left: 10px;">{{list.tradeAdress}}</span>
               </el-descriptions-item>
          </el-descriptions>
          <el-descriptions >
              <el-descriptions-item :label="$t('备注')">
                   {{list.remarks||'/'}}
               </el-descriptions-item>
          </el-descriptions>
        </el-card>
        <el-card class="card" v-if='list.transportVO'>
          <div slot="header" class="card-title">
            <dict-tag :type="DICT_TYPE.ECW_TRANSPORT_TYPE" :value="list.transportId"></dict-tag>
          </div>
          <div class="line">
            <el-descriptions>
                <el-descriptions-item :label="[3,4].indexOf(list.transportId)>-1?$t('空运路线'):$t('海运路线')">
                    {{getRouterNameById(list.lineId)||'/'}}
                </el-descriptions-item>
            </el-descriptions>
            <el-descriptions v-if="[3,4].indexOf(list.transportId) > -1">
               <el-descriptions-item :label="$t('出货渠道')">
                   {{channelName||'/'}}
                </el-descriptions-item>
            </el-descriptions>
          </div>
          <el-descriptions class="card" v-if="[2,3,4].indexOf(list.transportId) > -1">
              <el-descriptions-item :label="$t('是否双清')">
                  <dict-tag :type="DICT_TYPE.ECW_DOUBLE_CLEAR" :value="list.transportVO.doubleClear"></dict-tag>
              </el-descriptions-item>
          </el-descriptions>
          <el-descriptions v-if="[3,4].indexOf(list.transportId) > -1">
              <el-descriptions-item :label="$t('航空公司')">
                 {{airlineCompany ? $l(airlineCompany, 'company') : '/'}}
              </el-descriptions-item>
          </el-descriptions>
          <el-descriptions v-if="list.transportId==2">
              <el-descriptions-item :label="$t('船公司')">
                {{shippingCompany ? $l(shippingCompany, 'company') : '/'}}
              </el-descriptions-item>
          </el-descriptions>
          <el-descriptions v-if="[2,3,4].indexOf(list.transportId) > -1">
              <el-descriptions-item :label="$t('清关证书')">
                 <dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="list.transportVO.customsClearCert"></dict-tag>
              </el-descriptions-item>
          </el-descriptions>
          <el-descriptions v-if="[2,3,4].indexOf(list.transportId) > -1">
              <el-descriptions-item :label="$t('清关证书备注')">
                 {{list.transportVO.remarks||'/'}}
              </el-descriptions-item>
          </el-descriptions>
          <el-descriptions class="card" v-if="[3,4].indexOf(list.transportId) > -1">
              <el-descriptions-item :label="$t('是否拆包')">
                 <dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="list.transportVO.isUnpack"></dict-tag>
              </el-descriptions-item>
          </el-descriptions>
          <el-descriptions v-if="[3,4].indexOf(list.transportId) > -1">
              <el-descriptions-item :label="$t('单票立刻转运')">
                <dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="list.transportVO.isSingleTicketTransport"></dict-tag>

                   <span style="margin-left:10px;color: #0000FF;">{{$t('注:若只有一件,货到仓库立即发,选“是”,多件需仓库集运待发,选“否”')}}</span>
              </el-descriptions-item>

          </el-descriptions>
          <el-descriptions>
              <el-descriptions-item :label="$t('特殊要求')">
                 <dict-selector  form-type="checkbox"  :type="DICT_TYPE.ORDER_SPECIAL_NEEDS" multiple  v-model="list.transportVO.packageType" :disabled="true" />
              </el-descriptions-item>
          </el-descriptions>
          <el-descriptions>
              <el-descriptions-item :label="$t('特殊要求备注')">
                {{list.transportVO.packageRemarks||'/'}}
              </el-descriptions-item>
          </el-descriptions>
        </el-card>

  </div>
</template>

<script>
  import {DICT_TYPE,getDictDatas} from  '@/utils/dict'
  import {getOffer,deleteOffer} from '@/api/ecw/offer'
  import {getProductAttrList} from '@/api/ecw/productAttr'
  import {getCustomerList,getCustomer} from '@/api/ecw/customer'
   import {getChannelList,getChannel} from '@/api/ecw/channel'
   import {getTradeCityList} from '@/api/ecw/region'
   import {getUnitList} from '@/api/ecw/unit'
   import { getOrder } from '@/api/ecw/order'
   import {getCurrencyList} from '@/api/ecw/currency'
   import {getCustomerContactsSelect} from '@/api/ecw/customerContacts'
   import {openedRouterList as getOpenedRouterList} from '@/api/ecw/warehouse'
   import {calculationPrice} from '@/api/ecw/product'
   import {getSupplier, getSupplierPage} from '@/api/ecw/supplier'
   import Decimal from 'decimal.js'
   window.Decimal=  Decimal

  export default {
    name: "detail",
    data() {
      return {
        // 遮罩层
        loading: false,
        list: [],
        types:'package,bag',
        importance:1,
        productAttrList:[],
        offerId:0,
        //发货/收货人信息
        consigneeData:{},
        routerList:[],
        fee:{},
        channelName:'/',
        tradeCityList:[],
        productNames: {},
        currencyList:[],
        unitList:[],
        orderData:[],
        consignorData:{},
        customerSource: getDictDatas(DICT_TYPE.CUSTOMER_SOURCE),
        couponAvailableGroupDtoList: [], // 可用优惠
        couponTotalAmountList: [], // 优惠总额
        // 航空公司
        airlineCompany: null,
        // 船公司
        shippingCompany: null,
      };
    },
    computed:{
      // 根据id获取商品名称(显示优惠列表的时候用)
      getProductName(){
        return prodId => {
          if(!this.list) return this.$t('未知')
          let row = this.list.offerProdRespVOList.find(item => item.prodId == prodId)
          if(!row) return this.$t('未知')
          return this.$l(row, 'prodTitle')
        }
      },
      selectedRouter(){
          // otherService 1 送货上门,2非控货订单代收货款
          if(!this.list.lineId) return null
          return this.routerList.find(item => item.id == this.list.lineId)
      },
      currentcyMap(){
          let map = {}
          this.currencyList.forEach(item => {
              map[item.id] = this.$i18n.locale=='zh_CN'?item.titleZh:item.titleEn
          })
          return map
      },
      unitMap(){
          let map = {}
          this.unitList.forEach(item => {
              map[item.id] = this.$i18n.locale=='zh_CN'?item.titleZh:item.titleEn
          })
          return map
      },
      // 总有优惠金额
    // 总有优惠金额
   // 总有优惠金额
    couponList(){
        let arr = []
        this.couponAvailableGroupDtoList.forEach(item => {
            if(item.couponAvailableDtoList && item.couponAvailableDtoList.length){
                // 只取第一个
                let it = item.couponAvailableDtoList[0]
                arr.push({
                        prodId: item.prodId,
                        type: it.type,
                        titleZh: it.titleZh,
                        titleEn: it.titleEn,
                        endTime: it.endTime,
                        reduceAmount: it.reduceAmount,
                        reduceCurrencyId: it.reduceCurrencyId
                    })
            }
        })
        return arr
    },
      // 计算返回的费用清单
      feeDtoList(){
          if(this.list&&this.list.estCostVO){
            return this.list.estCostVO.feeDtoList || []
          }else{
            return []
          }
      },
      // 清关费
      clearanceFeeList(){
          return this.feeDtoList.filter(item => item.feeType == 2)
      },
      // 运费
      freightFeeList(){
          return this.feeDtoList.filter(item => item.feeType == 1)
      },
      // 其他费用
      otherFeeList(){
          return this.feeDtoList.filter(item => item.feeType == 3)
      },
      // 原价(清关费 + 运费)
      originalFeeList(){
          let arr = []
          this.clearanceFeeList.forEach(item => {
              let it = {
                  src: this.$t('清关费'),
                  currencyId: item.currencyId,
                  amount: Decimal(item.amount)
              }
              let freight = this.freightFeeList.find(fee => fee.currencyId == item.currencyId)
              if(freight){
                  it.amount = it.amount.plus(freight.amount)
              }
              arr.push(it)
          })
          // 判断是否有运费单位不在清关费里的
          this.freightFeeList.forEach(item => {
              if(!arr.find(arrItem => arrItem.currencyId == item.currencyId)){
                  arr.push({
                      src: this.$t('未计算的运费'),
                      currencyId: item.currencyId,
                      amount: Decimal(item.amount)
                  })
              }
          })
          return arr
      },
      // 预计费用(原价 - 优惠金额)
      estimatedCosts(){
          let arr = []
          this.originalFeeList.forEach(item => {
              let it = {
                  currencyId: item.currencyId,
                  amount: Decimal(item.amount)
              }
              let coupon = this.couponList.find(coupon => coupon.reduceCurrencyId == item.currencyId)
              if(coupon){
                  it.amount = it.amount.minus(coupon.reduceAmount)
              }
              arr.push(it)
          })
          // 累加保价费
          const insuranceFeeIndex = arr.findIndex(item => item.currencyId == this.insuranceFeeCurrency)
          const insuranceFee = this.list&&this.list.estCostVO&&this.list.estCostVO.insuranceFee
          if(insuranceFeeIndex > -1){
              arr[insuranceFeeIndex].amount = arr[insuranceFeeIndex].amount.plus(insuranceFee || 0)
          }else{
              arr.push({
                  currencyId: this.insuranceFeeCurrency,
                  amount: Decimal(insuranceFee || 0)
              })
          }

          // 累加其他费用
          const otherFeeIndex = arr.findIndex(item => item.currencyId == this.list.otherFeeCurrencyId)
          if(otherFeeIndex > -1){
              arr[otherFeeIndex].amount = arr[otherFeeIndex].amount.plus(this.list.otherFee || 0)
          }else{
              if(this.list.otherFee>0){
                arr.push({
                    currencyId: this.list.otherFeeCurrencyId,
                    amount: Decimal(this.list.otherFee || 0)
                })
              }
          }
          return arr
      },
      // 保价费单位(路线里设置,默认美元)
      insuranceFeeCurrency() {
          return this.selectedRouter?.currencyUnit || 1;
      },
    },
    created() {
      getCurrencyList().then(res => this.currencyList = res.data)
      getUnitList().then(res => this.unitList = res.data)
      getTradeCityList().then(res => this.tradeCityList = res.data)
      getProductAttrList().then(res => this.productAttrList = res.data)
      if(this.$route.query.offerId){
        this.offerId = this.$route.query.offerId
        this.getList();
      }
    },
    methods: {
      sourceLabel(data){
        let label=''
        var source = this.customerSource.find(item=>item.value==data)
        if(source) label = this.$i18n.locale=='zh_CN'?source.label:source.labelEn
        return label
      },
      checkCode(data){
        if(!data){
          return ''
        }
        if(data.indexOf('+')==-1){
        	return '+'+data
        }
        return data
      },
      getOrderData(id) {
        let that = this
        that.loading = true;
        // 执行查询
        getOrder(id).then(response => {
          that.orderData = response.data;
        });
      },
      getProductListWithDefaultValue(){
          let arr = []
          this.list.offerProdRespVOList.forEach(item => {
              let tmp = {
                "brand":item.brand,
                "unit":item.unit,
                "prodId":item.prodId,
                "num":item.num,
                "quantity":item.quantity,
                "volume":item.volume,
                "weight":item.weight,
                "worth":item.worth,
                "brandType":item.brandType||0,
                "prodAttrIds":item.prodAttrIds
              }
              arr.push(tmp)
          })
          return arr
      },
      // 计算商品运费
      calculationPrice(){
          calculationPrice({
              lineId: this.list.lineId,
              transportId: this.list.transportId,
              channelId: this.list.channelId,
              prodConditionParamList: this.getProductListWithDefaultValue(),
              consigneeCustomerContactsId: this.list.consigneeCustomerContactsId,
              consignorCustomerContactsId: this.list.consignorCustomerContactsId,
              customsType: this.list.customsType,
              isCargoControl: this.list.control,
              orderType: this.list.orderType,
          }).then(res => {
              this.$set(this, 'fee', res.data.costDto)
              if(res.data.availableDto){
                this.$set(this, 'couponTotalAmountList', res.data.availableDto.couponTotalAmountList)
                this.$set(this, 'couponAvailableGroupDtoList', res.data.availableDto.couponAvailableGroupDtoList)
              }
          }).finally(() => {
              this.calculating = false
          })
      },
      /** 查询列表 */
      getList() {
        let that = this
        that.loading = true;
        // 执行查询
        getOffer(that.offerId).then(response => {
          that.list = response.data;
          if(that.list.channelId){
            that.getChannelData()
          }
          that.calculationPrice()
          // if(that.list.orderId){
          //   that.getOrderData(that.list.orderId)
          // }
          getCustomerContactsSelect({ids: [that.list.consignorId, that.list.consigneeId].join(',')}).then((res) => {
               let consignor = res.data.list.find(item => item.customerContactsId == that.list.consignorId)
               if(consignor) that.consignorData=consignor
               let consignee = res.data.list.find(item => item.customerContactsId == that.list.consigneeId)
               if(consignee) that.consigneeData=consignee
               that.getCnsigneeData()
          })
          that.list.offerProdRespVOList.forEach((item)=>{
            var arr = item.prodAttrIds.split(',')
            var prodAttrName = []
            arr.forEach((itemValue)=>{
                 var prodAttrCenter = this.productAttrList.filter(items=>items.id==itemValue)
                 if(prodAttrCenter.length>0){
                   prodAttrName.push(this.$i18n.locale=='zh_CN'?prodAttrCenter[0].attrName:prodAttrCenter[0].attrNameEn)
                 }
            })
            if(prodAttrName.length>1){
              item.prodAttrName = prodAttrName.join(',')
            }else if(prodAttrName.length==1){
              item.prodAttrName = prodAttrName[0]
            }else{
              item.prodAttrName = ''
            }
          })

          that.loading = false;

          that.getOpenedRouterList()

          if(this.list.transportVO.airlineCompany){
            getSupplier(this.list.transportVO.airlineCompany).then(res=>{
              if(res.data){
                this.airlineCompany = res.data.companyZh
              }
            })
          }
          if(this.list.transportVO.shippingCompany){
            getSupplier(this.list.transportVO.shippingCompany).then(res=>{
              if(res.data){
                this.shippingCompany = res.data.companyZh
              }
            })
          }
        });
      },
      getCity(id){
        var city = ''
        this.tradeCityList.forEach((item)=>{
          if(item.id == id){
            city = this.$i18n.locale=='zh_CN'?item.titleZh:item.titleEn
          }
        })
        return city
      },
      getChannelData(){
        getChannel(this.list.channelId).then(res=>{
          this.channelName = res.data.nameZh
        })
      },
      // 获取路线
      getOpenedRouterList(){
          let params = {}
          if(this.list.departureId){
              params.startCityId = this.list.departureId
          }
          if(this.list.objectiveId){
              params.destCityId = this.list.objectiveId
          }
          getOpenedRouterList(params).then(res => this.routerList = res.data)
      },
      // 根据线路id显示线路名称
      getRouterNameById(routerId){
            let router = this.routerList.find(item => item.id == routerId)
            if(router){
                return this.$i18n.locale=='zh_CN'?router.startTitleZh:router.startTitleEn + ' >>>' + this.$i18n.locale=='zh_CN'?router.destTitleZh:router.destTitleEn
            }
            return '-'
      },
      // 获取发货/收货人
      getCnsigneeData(){
        let that = this
         if(that.consigneeData&&that.consigneeData.customerId){
            getCustomer(that.consigneeData.customerId).then(result=>{
                result.data.source = this.sourceLabel(result.data.source)
                that.$set(that.consigneeData,'source',result.data.source)
                that.$set(that.consigneeData,'address',result.data.address)

            })
        }
        if(that.consignorData&&that.consignorData.customerId){
            getCustomer(that.consignorData.customerId).then(ress=>{
              ress.data.source = this.sourceLabel(ress.data.source)
                that.$set(that.consignorData,'source',ress.data.source)
                that.$set(that.consignorData,'address',ress.data.address)
            })
          }
      },
      /** 跟进按钮操作 */
      handleAdd() {
        this.$router.push({
          path: "/offer/logList",
          query:{
            offerId:this.offerId,
            relationId:this.list.consignorId
          }
        });
      },
      toResult(){
        this.$router.push({
          path: "/offer/result",
          query:{
            offerId:this.offerId,
            number:this.list.number
          }
        });
      },
      /** 删除按钮操作 */
      handleDelete() {
        const offerId = this.offerId;
        this.$confirm(this.$t('是否确认删除报价单管理编号为')+'"' + offerId + '"'+this.$t('的数据项')+'?').then(function() {
            return deleteOffer(offerId);
          }).then(() => {
            this.$router.push({
              path: "/offer/result"
            });
            this.$message.success(this.$t("删除成功"));
          }).catch(() => {});
      },
    }
  }
</script>

<style scoped>
  .card-title{
      font-size: 18px;
      font-weight: bold;
       margin-top: 10px;
  }
  .offer-header{
    padding-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .line{
    display: flex;
    align-items: center;
  }
  .line el-descriptions{
    flex: 1;
  }
  .btn{
    width: 60%;
    display: flex;
    align-items: center;
    justify-content: space-around;
  }
  .title-font{
    font-size: 16px;
    font-weight: 600;
    margin-top: 20px;
  }
  .title-font label{
    margin-right: 20px;
  }
  .card{
    margin-top: 20px;
  }
</style>