supplementOrder.vue 20.4 KB
Newer Older
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
<template>
  <el-dialog :visible.sync="show" class="supplementOrder" append-to-body fullscreen :title="$t('补单')">
    <el-card>
      <!-- 内容区 -->
      <el-row class="content-area">

        <!-- 左侧 -->
        <el-col :span="6" class="left-area">
          <!--<el-row>
            <el-button type="primary" @click="addPart">{{$t('新增')}}</el-button>
            <el-button type="danger" @click="deletePart">{{$t('删除')}}</el-button>
          </el-row>-->
          <el-scrollbar style="height:calc(100% - 40px)">
            <el-row v-for="item in partList" :key="item.id" class="title-info" :class="item.id === partData.id ? 'selected' : ''">
              <div @click="partClick(item)">
                <!--<p>{{item.title}}</p>-->
                <p>{{$t('出货渠道')}}:{{channelName}}</p>
              </div>
              <el-collapse-transition>
                <div v-if="item.fold === false ? true : false">
                  <div v-for="(secGoog, index) in item.sectionOrderList" :key="index" class="part-secGoog">
                    <p>{{secGoog.orderNo}}</p>
                    <p>{{secGoog.prodTitleZh}}</p>
                    <div>
                      <i class="el-icon-delete" @click="deleteOrder(secGoog)"></i>
                    </div>
                  </div>
                </div>
              </el-collapse-transition>
              <div class="part-secGoog">
                <template>
                  {{getTotlContent(item.secStatistics)}}
                </template>
              </div>
            </el-row>
          </el-scrollbar>
        </el-col>

        <!-- 右侧 -->
        <el-col :span="18" class="right-area">

          <el-row class="right-title">
            <div>{{$t('货物筛选')}}</div>
            <div>{{$t('出货渠道')}}:{{channelName}}</div>
            <div>{{$t('可出特性')}}:{{attrName}}</div>
            <div></div>
          </el-row>

          <!-- 搜索工作栏 -->
          <el-row>
            <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
              <el-form-item :label="$t('始发地')">
                <p>{{importCityName(queryParams.startWarehouseId)}}</p>
              </el-form-item>
              <el-form-item :label="$t('国家')" prop="destination">
                <el-select v-model="queryParams.destCountryId" :placeholder="$t('请选择国家')" @change="clearDestWarehouseIdList">
                  <el-option v-for="item in countryList" :key="item.id" :label="$l(item, 'title')" :value="item.id" />
                </el-select>
              </el-form-item>
              <el-form-item :label="$t('目的地')" prop="destination">
                <el-select v-model="queryParams.destWarehouseIdList" :placeholder="$t('请选择目的地')" multiple>
                  <el-option v-for="item in importWarehouseList" :label="item.titleZh" :value="item.id" :key="item.id"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item :label="$t('订单号')" prop="orderNo">
                <el-input v-model="queryParams.orderNo" :placeholder="$t('请输入订单号')" clearable />
              </el-form-item>
							<el-form-item :label="$t('出货渠道')" prop="orderNo">
								<el-select v-model="queryParams.channelId" clearable :placeholder="$t('请选择出货渠道')">
zhoutong's avatar
zhoutong committed
70
                  <el-option v-for="item in channelList" :label="$l(item, 'name')" :value="item.channelId" :key="item.channelId"></el-option>
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
                </el-select>
							</el-form-item>
              <el-form-item>
                <el-button type="primary" icon="el-icon-search" @click="queryAllData">{{$t('搜索')}}</el-button>
              </el-form-item>
            </el-form>
          </el-row>

          <!-- 表格 -->
          <el-scrollbar style="height:calc(100% - 164px)">
            <el-row v-for="(item, index) in toBePreList" :key="index" class="toBePre-table">
              <el-row class="table-title">
                <div>{{item.orderNo}}</div>
                <div>{{$t('发往')}}:{{item.destWarehouseName}}</div>
                <div :class="item.customsType !== 1 ? 'custom_type_red' : ''">
                  <dict-tag :type="DICT_TYPE.ECW_CUSTOMS_TYPE" :value="item.customsType" />
                </div>
                <div>{{$t('入仓时间')}}:{{formatDate(item.rucangTime)}}</div>
                <div>
90
                  <el-button v-if="item.airShipment==4" type="text" @click="handleGoods('all', item)">[{{$t('全部分拣')}}]</el-button>
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
                  <el-button type="text" @click="foldTable(index, item)">[{{item.fold ? $t('展开') : $t('收起')}}]</el-button>
                </div>
              </el-row>
              <el-collapse-transition>
                <div v-show="!item.fold">
                  <el-table v-loading="loading" :data="item.boxOrderItemList" border>
                    <el-table-column :label="$t('序号')" type="index" align="center" width="50" />
                    <el-table-column :label="$t('品名')" align="center" prop="" min-width="500">
                      <template slot-scope="{row}">
                        {{$l(row,'prodTitle')}}
                      </template>
                    </el-table-column>
                    <el-table-column :label="$t('品牌')" align="center" prop="brandType" width="120">
                      <template slot-scope="scope">
                        <template v-if="scope.row.brandName">{{scope.row.brandName}}</template>
                        <dict-tag v-else :type="DICT_TYPE.ECW_IS_BRAND" :value="scope.row.feeType" />
                      </template>
                    </el-table-column>
                    <el-table-column :label="$t('箱数')" align="center" prop="num" width="120" />
                    <el-table-column :label="$t('体积')" align="center" prop="volume" width="120">
                      <template slot-scope="scope">
                        <p v-if="scope.row.volume">{{getTotlContent(scope.row,['volume'])}}</p>
                      </template>
                    </el-table-column>
                    <el-table-column :label="$t('重量')" align="center" prop="weight" width="120">
                      <template slot-scope="scope">
                        <p v-if="scope.row.weight">{{getTotlContent(scope.row,['weight'])}}</p>
                      </template>
                    </el-table-column>
zhoutong's avatar
zhoutong committed
120
                    <!-- <el-table-column :label="$t('分拣柜')"
121 122 123 124 125
                                     align="center"
                                     prop=""
                                     width="120">{{ $t('无返回') }}</el-table-column> -->
                    <el-table-column :label="$t('操作')" align="center" class-name="small-padding fixed-width" width="100">
                      <template slot-scope="scope">
126
                        <el-button v-if="item.airShipment==4" type="text" size="small" @click="handleGoods('singele',scope.row)">{{$t('分拣')}}</el-button>
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
                      </template>
                    </el-table-column>
                  </el-table>
                </div>
              </el-collapse-transition>
            </el-row>
          </el-scrollbar>

          <!-- 分页 -->
          <el-pagination background layout="prev, pager, next" :page-size="pageParam.pageSize" :total="total" @current-change="pageChange" v-show="total > 0"></el-pagination>
        </el-col>

      </el-row>
    </el-card>
    <el-row>
      <el-col :span="6" class="totle-info">
        <div>
          <p>{{$t('总计')}}:</p>
          <p>{{sumStatistics(partList)}}</p>
        </div>
        <!--<div>
          <p>{{$t('容量')}}:</p>
          <p>{{calcCapacity}}</p>
        </div>-->
      </el-col>
    </el-row>
    <el-row class="button-area">
      <el-button type="primary" @click="handlerFinish">{{$t('完成')}}</el-button>
    </el-row>
  </el-dialog>
</template>

<script>
import {
  loadSecGoodsList,
  createSection,
  deleteSection,
  remove,
} from "@/api/ecw/boxSea";
import { preloadPage, createGoods } from '@/api/ecw/boxAir'
import { getWarehouseList } from "@/api/ecw/warehouse"
import {
  formatDate,
  getTotlContent,
  serviceMsg,
  getCapacity,
  sumStatistics,
} from "../../utils";
import { getListTree } from "@/api/ecw/region";
import {getChannelList} from "@/api/ecw/channel";
/**
 * 补单
 */
export default {
  name: "supplementOrder",
  inheritAttrs: false,
  data() {
    return {
      //国家列表
      countryList:[],
      //仓库列表
      warehouseList: [],
      // 二维码/条码编号
      cabinetNo: "",
      // 表格数据
      listData: [],
      // 选中部分
      partData: {},
      // 部分列表
      partList: [],
      // 部分统计
      loadStatistics: {},
      // 查询参数
      queryParams: {
        startWarehouseId: this.$attrs.shipmentObj.startWarehouseId,
      },
      pageParam: { pageNo: 1, pageSize: 10 },
zhoutong's avatar
zhoutong committed
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
      toBePreList: [],
      total: 0,
      loading: false,
      unloadStatistics: {},
      show: true,
      // 渠道列表
      channelList: []
    };
  },
  watch:{
    show(show){
      if(!show){
        this.$emit('close')
      }
    }
  },
  created() {
    this.getCountry()
    getChannelList().then(res => this.channelList = res.data)
  },
  methods: {
    //获取国家
    async getCountry() {
      let countryList = await getListTree({treeType: 1})
      this.countryList = countryList.data
      let warehouseList = await getWarehouseList()
      this.warehouseList = warehouseList.data
      let warehouse = this.warehouseList.find(item=>item.id == this.$attrs.shipmentObj.destWarehouseId)
      console.log(warehouse,'warehouse')
      if(warehouse){
        this.$set(this.queryParams,'destCountryId', warehouse.guojia)
      }
      this.queryAllData();
    },
zhoutong's avatar
zhoutong committed
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
    getSecGoods() {
      loadSecGoodsList({ shipmentId: this.$attrs.shipmentObj.id }).then(
        (res) => {
          this.partList = res.data.map((item, index) => {
            item.fold = true;
            if (
              Object.keys(this.partData).length &&
              this.partData.id === item.id
            ) {
              item.fold = false;
            }
            return {
              ...item,
              title: this.$t("第{index}部分", { index: index + 1 }),
            };
          });

          if (this.partList.length && !Object.keys(this.partData).length) {
            this.partList[0].fold = false;
            this.partData = this.partList[0];
          }
        }
      );
    },
zhoutong's avatar
zhoutong committed
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
    getPreLoad() {
      this.loading = true;
      // 处理查询参数
      let params = {
        ...this.queryParams,
        shipmentId: this.$attrs.shipmentObj.id,
      };
      preloadPage({ ...params, ...this.pageParam }).then((res) => {
        const { data } = res;
        this.toBePreList = data.dataList?.list ?? [];
        this.total = data.dataList?.total ?? 0;
        this.unloadStatistics = data.unloadStatistics ?? {};
        this.loading = false;
      });
    },
    /* 删除订单 */
    deleteOrder(data) {
      let params = {
        secId: this.partData.id,
        shipmentId: this.$attrs.shipmentObj.id,
        orderId: data.orderId,
      };
      remove(params).then((res) => {
        serviceMsg(res, this).then(() => {
          this.getSecGoods();
290
          this.getPreLoad();
291 292 293 294 295 296 297 298 299 300 301 302 303
        });
      }).catch((res) => {
        if (res.code === 666) {
              this.$confirm(res.msg+this.$t('是否需要一起移出?'), this.$t("提示"), {
                dangerouslyUseHTMLString: true,
                distinguishCancelAndClose: true,
                confirmButtonText: '确定移出',
                cancelButtonText: '仅移出当前订单'
              })
                .then((_) => {
                  remove({ ...params, deleteType: 2 }).then((res) => {
                    serviceMsg(res, this).then(() => {
                      this.getSecGoods();
304
                      this.getPreLoad();
305 306 307 308 309 310 311 312
                    });
                  });
                })
                .catch(action => {
                  if(action =='cancel'){
                    remove({ ...params, deleteType: 1 }).then((res) => {
                      serviceMsg(res, this).then(() => {
                        this.getSecGoods();
313
                        this.getPreLoad();
314 315 316 317 318 319 320
                      });
                    });
                  }
                });
            }
      });
    },
zhoutong's avatar
zhoutong committed
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
    handleGoods(type, item) {
      let params = {
        secId: this.partData.id,
        shipmentId: this.$attrs.shipmentObj.id,
        orderId: item.orderId,
        isCover: 1
      };
      if (type === "all") {
        params.orderItemIdList = item.boxOrderItemList.map(
          (data) => data.orderItemId
        );
      } else {
        params.orderItemIdList = [item.orderItemId];
      }
      createGoods(params)
          .then((res) => {
            const { data } = res;
            if (data.relationMsg) {
              const msg = data.relationMsg.replaceAll(",", "");
              this.$confirm(msg, this.$t("提示"), {
                dangerouslyUseHTMLString: true,
                type: "warning",
              })
                .then((_) => {
                  loadRelationOrder(data).then((res) => {
                    serviceMsg(res, this).then(() => {
                      this.queryAllData();
                    });
                  });
                })
                .catch((_) => {
                  this.queryAllData();
                });
            } else {
              serviceMsg(res, this).then(() => {
                this.queryAllData();
              });
            }
          })
          .catch((res) => {
            if (res.code === 555) {
              const msg = res.msg && res.msg.replaceAll(",", "");
              this.$confirm(msg, this.$t("提示"), {
                dangerouslyUseHTMLString: true,
                type: "warning",
              })
                .then((_) => {
                  createGoods({ ...params, relationStatus: 1 }).then((res) => {
                    serviceMsg(res, this).then(() => {
                      this.queryAllData();
                    });
                  });
                })
                .catch((_) => {
                  this.queryAllData();
                });
            }

            if (res.code === 566) {
zhoutong's avatar
zhoutong committed
381
              this.$confirm(res.msg+this.$t('是否需要一起分拣?'), this.$t("提示"), {
382 383
                dangerouslyUseHTMLString: true,
                distinguishCancelAndClose: true,
zhoutong's avatar
zhoutong committed
384
                confirmButtonText: '分拣关联单',
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
                cancelButtonText: '仅当前订单'
              })
                .then((_) => {
                  createGoods({ ...params, relationStatus: 2, singleLoad: false }).then((res) => {
                    serviceMsg(res, this).then(() => {
                      this.queryAllData();
                    });
                  });
                })
                .catch((action) => {
                  if(action =='cancel'){
                    createGoods({ ...params, relationStatus: 2, singleLoad: true }).then((res) => {
                      serviceMsg(res, this).then(() => {
                        this.queryAllData();
                      });
                    });
                  }
                });
            }
          });
    },
    /* 增加部分 */
    addPart() {
      createSection({
        shipmentId: this.$attrs.shipmentObj.id,
        isCover: 1,
      }).then((res) => {
        serviceMsg(res, this).then(() => {
          this.getSecGoods();
        });
      });
    },
    /* 删除部分 */
    deletePart() {
      this.$confirm(
zhoutong's avatar
zhoutong committed
420
        this.$t("确认删除该部分及其已分拣订单?"),
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
        this.$t("提示"),
        {
          type: "warning",
        }
      )
        .then((_) => {
          let params = {
            id: this.partData.id,
            deleteType: 2
          };
          deleteSection(params).then((res) => {
            serviceMsg(res, this).then(() => {
              this.partData = {};
              this.getSecGoods();
            });
          });
        })
        .catch((_) => {});
    },
    /* 部分点击 */
    partClick(item) {
      item.fold = !item.fold;
      this.partData = item;
      let copyList = [...this.partList];
      copyList = copyList.map((cItem) => {
        cItem.fold = true;
        if (item.id === cItem.id) {
          cItem.fold = false;
          return cItem;
        }
      });
      this.$set(this.partList, copyList);
    },
    /* 获取城市 */
    importCityName(id) {
      var arr = this.$attrs.warehouseList.filter((item) => item.id == id);
      return arr.length > 0 ? this.$l(arr[0], "title") : this.$t("");
    },
zhoutong's avatar
zhoutong committed
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
    pageChange(page) {
      this.pageParam.pageNo = page;
      this.getPreLoad();
    },
    /* 折叠 */
    foldTable(index, item) {
      item.fold = !item.fold;
      this.$set(this.toBePreList, index, item);
    },
    /* 查询所有数据 */
    queryAllData() {
      this.getSecGoods();
      this.pageParam.pageNo = 1;
      this.getPreLoad();
    },
    /* 完成 */
    handlerFinish() {
      this.$confirm(this.$t("确定执行操作?"), this.$t("提示"), {
        type: "warning",
      })
        .then((_) => {
          this.$emit("supplementFinish");
        })
        .catch((_) => {});
    },
    formatDate,
    getTotlContent,
    sumStatistics,
    //切换国家时清除目的仓
    clearDestWarehouseIdList() {
      this.queryParams.destWarehouseIdList = []
    }
  },
  computed: {
    /** 目的地 */
    importWarehouseList() {
      return this.$attrs.warehouseList.filter(
        (item) => (item.tradeType == "1" || item.type == "3") && item.guojia == this.queryParams.destCountryId
      );
    },
    /* 容量 */
    calcCapacity() {
      const { cabinetRespVO } = this.$attrs.shipmentObj;
      return getCapacity(cabinetRespVO);
    },
    // 渠道
    channelName(){
      return this.$l(this.$attrs.shipmentObj?.channelRespVO, 'name')
    },
    // 可出特性
    attrName(){
      return this.$attrs.shipmentObj?.channelRespVO?.attrNameList.join(",")
    }
  },
};
</script>

<style lang="scss">
.supplementOrder {
  display: flex;
  flex-direction: column;
  p {
    margin: 0;
  }
  .el-card__body {
    height: 100%;
  }
  .content-area {
    display: flex;
    height: 100%;
    .left-area {
      border-right: 3px solid #e6ebf5;
      .el-scrollbar__view {
        padding-right: 10px;
      }
      .title-info {
        margin-top: 10px;
        height: auto;

        &.selected {
          > div:first-child {
            background-color: #4f9cdd;
            color: #fff;
          }
        }

        > div:first-child {
          font-size: 16px;
          background-color: #f2f2f2;
          line-height: 30px;
          text-align: center;
          cursor: pointer;
        }
        .part-secGoog {
          margin-top: 5px;
          display: flex;
          align-items: center;
          > p {
            margin-right: 10px;
            color: #4f9cdd;
          }
          > div {
            flex: 1;
            text-align: right;
            > i {
              cursor: pointer;
              color: red;
            }
          }
        }
      }
    }
    .right-area {
      padding-left: 10px;
      .right-title {
        display: flex;
        align-items: center;
        margin-bottom: 10px;
        font-size: 16px;
        > div:first-child {
          font-size: 18px;
        }
        > div:first-child + div {
          margin-left: 20px;
        }
        > div:last-child {
          flex: 1;
          text-align: right;
          font-size: 18px;
          color: red;
        }
      }
      .table-title {
        display: flex;
        align-items: center;
        line-height: 30px;
        background-color: #4f9cdd;
        color: #fff;
        > div {
          margin-left: 10px;
        }
        > div:last-child {
          flex: 1;
          display: flex;
          justify-content: flex-end;
          > .el-button--text {
            color: #fff;
          }
          > .el-button--text:last-child {
            margin-right: 10px;
          }
        }
      }
      .el-pagination {
        margin-top: 10px;
        padding: 0;
        text-align: right;
      }

      .toBePre-table {
        margin-bottom: 10px;
      }
    }
  }
  .totle-info {
    font-size: 20px;
    margin-top: 15px;
    > div {
      display: flex;
      margin-bottom: 5px;
    }
  }
  .button-area {
    text-align: center;
  }
}
</style>