startUnloading.vue 15.9 KB
Newer Older
zhoutong's avatar
zhoutong committed
1 2 3 4
<template>
  <div class="app-startUnloading">

    <!-- 自编号 -->
5
    <el-row>
6 7 8 9 10 11 12
      <p style="color:#D9001B;" v-if="pageData.boxCustomsBackVO&&pageData.boxCustomsBackVO.overMachineStatus==2&&pageData.boxCustomsBackVO.overMachineAbnormalStatus==2&&pageData.boxCustomsBackVO.weightMisreport==1">
        {{$t('过机重量异常')}}:{{$t('机场误差3%以内')}}
      </p>
      <p style="color:#D9001B;" v-if="pageData.boxCustomsBackVO&&pageData.boxCustomsBackVO.overMachineStatus==2&&pageData.boxCustomsBackVO.overMachineAbnormalStatus==2&&pageData.boxCustomsBackVO.weightMisreport==2">
        {{$t('过机重量异常')}}:{{$t('我司误差超10kg')}}
      </p>
      <p style="color:#D9001B;" v-if="pageData.boxCustomsBackVO&&pageData.boxCustomsBackVO.overMachineStatus==2&&pageData.boxCustomsBackVO.overMachineAbnormalStatus==2&&pageData.boxCustomsBackVO.overWeight>0">
我在何方's avatar
我在何方 committed
13
        {{$t('过机重量异常')}}:{{$t('超过机场重量')}}{{pageData.boxCustomsBackVO.overWeight}}kg
14
      </p>
15
      <p style="color:#D9001B;" v-if="pageData.boxCustomsBackVO&&pageData.boxCustomsBackVO.overMachineStatus==2&&pageData.boxCustomsBackVO.overMachineAbnormalStatus==2&&pageData.boxCustomsBackVO.weightMisreport==3">
16
       {{$t('过机重量异常')}}: {{$t('过机放行-未找到重货订单')}}
17 18
      </p>
      <p style="color:#D9001B;" v-if="pageData.boxCustomsBackVO&&pageData.boxCustomsBackVO.overMachineStatus==2&&pageData.boxCustomsBackVO.overMachineAbnormalStatus==2&&pageData.boxCustomsBackVO.weightMisreport==4">
19
       {{$t('过机重量异常')}}: {{$t('过机放行-已找到重货订单')}}:<span v-for="order in strToArray(pageData.boxCustomsBackVO.overOrders)" :key="order">{{ getOrders(order) }}</span>
20
      </p>
21
    </el-row>
zhoutong's avatar
zhoutong committed
22 23 24 25
    <el-row class="number-area">
      <p class="label-font"><span style="color:red">*</span>{{$t('到仓时间')}}</p>
      <el-date-picker type="datetime" :placeholder="$t('请选择日期')" v-model="ulWarehouseTime" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
    </el-row>
zhoutong's avatar
zhoutong committed
26 27 28 29 30
    <el-row class="number-area">
      <p class="label-font">{{$t('自编号')}}</p>
      <p class="label-font">{{selfNo}}</p>
      <el-input v-model="labelNo" :placeholder="$t('请输入')"></el-input>
      <div>
31
        <!-- <el-button type="primary" @click="modifyUnload">{{$t('提交')}}</el-button> -->
zhoutong's avatar
zhoutong committed
32
        <el-button type="primary" @click="modifyBatchUnload">{{$t('批量输入')}}</el-button>
33
        <el-button type="primary" @click="modifyAllUnload">{{$t('全部到仓')}}</el-button>
zhoutong's avatar
zhoutong committed
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
      </div>
    </el-row>

    <!-- 当前部分 -->
    <el-row class="number-area">
      <p class="label-font">{{$t('当前部分')}}</p>
      <el-select :placeholder="$t('请选择')" v-model="sectionId" @change="sectionChange">
        <el-option key="0" :label="$t('全部')" value="0"></el-option>
        <el-option v-for="item in sectionList" :key="item.id" :label="item.title" :value="item.id"></el-option>
      </el-select>
      <p>
        {{getSectionInfo}}
      </p>
    </el-row>

    <!-- 表格 -->
    <el-row class="table-area">
      <el-table v-loading="loading" :data="pageData.sectionOrderList" border max-height="500px">
        <el-table-column :label="$t('序号')" align="center" width="50" prop="tidanNum" />
        <el-table-column :label="$t('订单号')" align="center" prop="orderNo">
          <template slot-scope="scope">
            {{ scope.row.orderNo }}
          </template>
        </el-table-column>
        <el-table-column :label="$t('商品信息')" align="center" prop="goodsList" width="200px">
          <template slot-scope="scope">
            <section class="table-goodList">
              <div v-for="(item, index) in scope.row.goodsList" :key="index" class="goodList-div">
                <p>{{$t('品名')}}{{$l(item, 'prodTitle')}}</p>
                <p>{{$t('品牌')}}:【<template v-if="item.brandName">{{item.brandName}}</template>
                  <dict-tag v-else :type="DICT_TYPE.ECW_IS_BRAND" :value="item.feeType" />{{ $t('】') }}</p>
              </div>
            </section>
          </template>
        </el-table-column>
        <el-table-column :label="$t('报关方式')" align="center" prop="customsType">
          <template slot-scope="scope">
            <div :class="scope.row.customsType !== 1 ? 'custom_type_red' : ''">
              <dict-tag :type="DICT_TYPE.ECW_CUSTOMS_TYPE" :value="scope.row.customsType" />
            </div>
          </template>
        </el-table-column>
        <el-table-column :label="$t('实装箱数')" align="center" prop="installNum" />
77
        <el-table-column :label="$t('到仓箱数')" align="center" prop="unloadNum" />
zhoutong's avatar
zhoutong committed
78 79 80 81 82 83 84
        <el-table-column :label="$t('清关状态')" align="center" prop="">
          <template slot-scope="scope">{{clearStatus(scope.row)}}</template>
        </el-table-column>
        <el-table-column :label="$t('体积')" align="center" prop="volume" />
        <el-table-column :label="$t('重量')" align="center" prop="weight" />
        <el-table-column :label="$t('订单状态')" align="center" prop="">
          <template slot-scope="scope">
zhoutong's avatar
zhoutong committed
85
            {{scope.row.statusMsg}}
zhoutong's avatar
zhoutong committed
86 87 88 89 90 91 92 93 94 95 96 97
          </template>
        </el-table-column>
        <el-table-column :label="$t('异常状态')" align="center" prop="">
          <template slot-scope="scope">
            <el-button v-if="scope.row.exceptionList" type="text" size="small" @click="handleError(scope.row)" icon="el-icon-edit">{{getOrderError(scope.row, 'errorStatus')}}</el-button>
          </template>
        </el-table-column>
        <el-table-column :label="$t('异常类型')" align="center" prop="">
          <template slot-scope="scope">
            {{getUnloadError(scope.row.exceptionList)}}
          </template>
        </el-table-column>
98 99 100 101
        <el-table-column :label="$t('操作')" align="center" width="170" class-name="small-padding fixed-width">
          <template slot-scope="scope"  >
            <div class="number-area">
              <el-button type="danger" size="small" @click="openError(scope.row)">{{$t('异常')}}</el-button>
102
              <el-button v-if="pageData.boxCustomsBackVO&&pageData.boxCustomsBackVO.overMachineStatus==2&&pageData.boxCustomsBackVO.overMachineAbnormalStatus==2" plain type="primary" size="small" @click="$router.push('/order/warehousing-update?id='+scope.row.orderId)">{{$t('入仓修改 ')}}</el-button>
103
            </div>
zhoutong's avatar
zhoutong committed
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
          </template>
        </el-table-column>
      </el-table>
    </el-row>

    <!-- 总计 -->
    <el-row>
      <div class="label-font">
        <p>
          <span>{{$t('总计')}}:</span>
          <span>{{getTotlContent(pageData.totalStatistics)}}</span>
        </p>
      </div>
      <div class="label-font">
        <p>
119
          <span>{{$t('到仓')}}:</span>
zhoutong's avatar
zhoutong committed
120 121 122 123 124 125 126 127 128 129 130 131 132
          <span>{{getUnLoadNumCount}}</span>
        </p>
      </div>
    </el-row>

    <!-- 审核流程 -->
    <el-row class="process-area">
      <div class="process">
        <div>{{$t('审批流程')}}</div>
        <work-flow xmlkey="unload_container" v-model="selectedUsers"></work-flow>
      </div>
      <!-- 操作 -->
      <div v-if="!isUnderReview">
133
        <el-button type="success" @click="onSubmit">{{$t('提交完成到仓审核')}}</el-button>
zhoutong's avatar
zhoutong committed
134
        <el-button plain type="primary" @click="$emit('closeDialog')">{{$t('返回')}}</el-button>
zhoutong's avatar
zhoutong committed
135 136
      </div>
      <div v-if="isUnderReview">
137
        <el-button type="primary" @click="jumpReviewDetail">{{$t('到仓审核中')}}</el-button>
zhoutong's avatar
zhoutong committed
138
        <el-button plain type="primary" @click="canclAudit">{{$t('取消审核')}}</el-button>
zhoutong's avatar
zhoutong committed
139
        <el-button plain type="primary" @click="$emit('closeDialog')">{{$t('返回')}}</el-button>
zhoutong's avatar
zhoutong committed
140 141 142 143 144 145 146 147 148 149 150 151 152 153
      </div>
    </el-row>

    <!-- 对话框 -->
    <el-dialog custom-class="shipping-dialog" :title="$t('异常')" :visible.sync="dialogVisible" width="600px" :modal-append-to-body=false append-to-body>
      <unloadingError v-if="dialogVisible" @closeDialog="closeDialog" v-bind="$attrs" :currRow="currRow" />
    </el-dialog>
  </div>
</template>

<script>
import unloadingError from "./unloadingError.vue";
import {
  loadGoodsList,
wanglh1's avatar
wanglh1 committed
154 155
  airBatchUnload,
  airAllUnload,
zhoutong's avatar
zhoutong committed
156 157 158
  approvalCreate,
  approvalCancel,
  getSectionList,
wanglh1's avatar
wanglh1 committed
159
  airSingleUnload,
160
  boxGoodsDetail
zhoutong's avatar
zhoutong committed
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
} from "@/api/ecw/boxSea";
import { serviceMsg, getTotlContent, toReviewDetail } from "../../utils";
import WorkFlow from "@/components/WorkFlow";
import Decimal from "decimal.js";

/**
 * 开始卸柜
 */
export default {
  name: "startUnloading",
  inheritAttrs: false,
  components: { unloadingError, WorkFlow },
  data() {
    return {
      // 标签号
      labelNo: "",
      // 当前部分
      currPart: "",
      // loading
      loading: false,
      // 页面数据
      pageData: {},
      // 弹窗配置
      dialogVisible: false,
      // 自编号
      selfNo: this.$attrs.shipmentObj.selfNo,
      // 当前行
      currRow: {},
      // 部分
      sectionList: [],
      // 已选部分
      sectionId: "0",
      // 部分订单商品
      sectionObj: {
        secStatistics: {},
        sectionOrderList: [],
        totalStatistics: {},
      },
      selectedUsers: [],
zhoutong's avatar
zhoutong committed
200 201
      sectionOrderList: [],
      ulWarehouseTime: null
zhoutong's avatar
zhoutong committed
202 203 204 205 206 207 208 209 210 211 212 213 214
    };
  },
  created() {
    this.getLoadGoodsList();
    // 部分
    getSectionList({ shipmentId: this.$attrs.shipmentObj.id }).then((res) => {
      this.sectionList = res.data.map((item, index) => {
        return {
          ...item,
          title: this.$t("第{index}部分", { index: index + 1 }),
        };
      });
    });
215 216 217 218 219 220
    boxGoodsDetail({
      shipmentId: this.$attrs.shipmentObj.id,
      secId: 0
    }).then((res) => {
      this.sectionOrderList = res.data.sectionOrderList
    })
zhoutong's avatar
zhoutong committed
221 222 223
  },
  methods: {
    getTotlContent,
224 225 226 227 228 229 230 231 232 233 234 235 236 237
    getOrders(id) {
      let order = this.sectionOrderList.find((item) => item.orderId == id)
      if (order) {
        return order.orderNo
      }
      return ''
    },
    strToArray(str) {
      if (!str) return []
      let array = str?.split(',') ?? []
      return array.map((item) => {
        return Number(item)
      })
    },
zhoutong's avatar
zhoutong committed
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256
    /* 获取卸柜数据 */
    getLoadGoodsList() {
      this.loading = true;
      let params = {
        secId: this.sectionId,
        shipmentId: this.$attrs.shipmentObj.id,
      };
      loadGoodsList(params).then((res) => {
        const { data } = res;
        this.pageData = data;
        this.loading = false;
      });
    },
    /* 单个卸柜 */
    modifyUnload() {
      if (!this.labelNo) {
        this.$message.error(this.$t("请输入箱号标签"));
        return;
      }
wanglh1's avatar
wanglh1 committed
257
      airSingleUnload({
zhoutong's avatar
zhoutong committed
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272
        orderNumCode: this.labelNo,
        shipmentId: this.$attrs.shipmentObj.id,
      }).then((res) => {
        serviceMsg(res, this).then((res) => {
          this.labelNo = "";
          this.getLoadGoodsList();
        });
      });
    },
    /* 批量输入 */
    modifyBatchUnload() {
      if (!this.labelNo) {
        this.$message.error(this.$t("请输入订单号"));
        return;
      }
zhoutong's avatar
zhoutong committed
273 274 275 276
      if (!this.ulWarehouseTime) {
        this.$message.error(this.$t("请选择到仓时间"));
        return;
      }
wanglh1's avatar
wanglh1 committed
277
      airBatchUnload({
zhoutong's avatar
zhoutong committed
278 279
        orderNo: this.labelNo,
        shipmentId: this.$attrs.shipmentObj.id,
zhoutong's avatar
zhoutong committed
280
        unloadTime: this.ulWarehouseTime
zhoutong's avatar
zhoutong committed
281 282 283 284 285 286 287 288 289
      }).then((res) => {
        serviceMsg(res, this).then((res) => {
          this.labelNo = "";
          this.getLoadGoodsList();
        });
      });
    },
    /* 一键卸柜 */
    modifyAllUnload() {
zhoutong's avatar
zhoutong committed
290 291 292 293
      if (!this.ulWarehouseTime) {
        this.$message.error(this.$t("请选择到仓时间"));
        return;
      }
294
      this.$confirm(this.$t("确认到仓?"), this.$t("提示"), {
zhoutong's avatar
zhoutong committed
295 296 297
        type: "warning",
      })
        .then((_) => {
wanglh1's avatar
wanglh1 committed
298
          airAllUnload({ shipmentId: this.$attrs.shipmentObj.id, unloadTime: this.ulWarehouseTime }).then((res) => {
zhoutong's avatar
zhoutong committed
299 300 301 302 303 304 305 306 307
            serviceMsg(res, this).then((res) => {
              this.getLoadGoodsList();
            });
          });
        })
        .catch((_) => {});
    },
    /** 提交 */
    onSubmit() {
308 309 310 311
      if(this.getUnLoadNumCount>0){
        approvalCreate({
            shipmentId: this.$attrs.shipmentObj.id,
            approvalStatus: 0,
312
            approvalType: 15, // 卸柜
313 314 315
            copyUserId: this.selectedUsers,
          }).then((res) => {
            serviceMsg(res, this).then(() => {
316
              this.cancel("submit");
317
            });
zhoutong's avatar
zhoutong committed
318
        });
319 320 321 322
      }else{
        this.$message.error(this.$t("货物到仓数小于实装数,请确认"));
      }
      
zhoutong's avatar
zhoutong committed
323 324
    },
    /** 取消 */
325 326
    cancel(type) {
      this.$emit('closeDialog', type)
zhoutong's avatar
zhoutong committed
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
    },
    /* 关闭弹窗 */
    closeDialog(type) {
      this.dialogVisible = false;
      if (type === "query") this.getLoadGoodsList();
    },
    /* 打开异常 */
    openError(row) {
      this.currRow = row;
      this.dialogVisible = true;
    },
    /* 清关状态 */
    clearStatus(row) {
      const { installNum, unloadNum } = row;
      if (installNum === unloadNum) {
        return this.$t("全部清关");
      }
      if (installNum >= unloadNum) {
        return this.$t("部分清关");
      }
      if (unloadNum === 0) {
        return this.$t("未清关");
      }
    },
    // 部分切换
    sectionChange() {
      this.getLoadGoodsList();
    },
    /* 取消审核 */
    canclAudit() {
      const { shipmentObj } = this.$attrs;
      approvalCancel({
        applyReason: this.$t("取消审核"),
        id: shipmentObj["cabinetUnloadApprovalInfo"].id,
        shipmentId: shipmentObj.id,
      }).then((res) => {
        serviceMsg(res, this).then(() => {
364
          this.cancel("submit");
zhoutong's avatar
zhoutong committed
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
        });
      });
    },
    // 获取异常类型
    getUnloadError(exceptionList) {
      if (!exceptionList) return exceptionList;
      const codes = this.getDictDatas(this.DICT_TYPE.ORDER_ERROR_TYPE);
      let errorLabels = [];
      exceptionList.forEach((item) => {
        const errObj = codes.find(
          (cItem) => cItem.value === item.orderExceptionType
        );
        if (errObj) errorLabels.push(errObj.label);
      });
      return errorLabels.join(",");
    },
    // 订单异常
    getOrderError(row, type) {
      if (row.exceptionList && row.exceptionList.length) {
        return type === "orderStatus" ? this.$t("卸柜异常") : this.$t("待处理");
      }
      return type === "orderStatus" ? this.$t("已到港") : "";
    },
    // 处理异常
    handleError(row) {
      this.$emit("closeStart", "close");
      this.$router.push({
        path: `/order/pending?id=${row.orderId}`,
      });
    },
    jumpReviewDetail() {
      const { cabinetUnloadApprovalInfo } = this.$attrs.shipmentObj;
      toReviewDetail.apply(this, [cabinetUnloadApprovalInfo.bpmProcessId]);
      this.$emit("closeStart", "close");
    },
  },
  computed: {
    /* 是否审核中 */
    isUnderReview() {
      const { currNode, shipmentObj } = this.$attrs;
      return shipmentObj[currNode.keyName] === 183 ? true : false;
    },
    // 部分信息
    getSectionInfo() {
      const { totalStatistics, secStatistics } = this.pageData;
      if (!this.sectionId) {
        return getTotlContent(totalStatistics);
      } else {
        return getTotlContent(secStatistics);
      }
    },
    /* 已卸总数 */
    getUnLoadNumCount() {
      let count = 0;
      if (this.pageData.sectionOrderList) {
        this.pageData.sectionOrderList.forEach((item) => {
          count = Decimal.add(count, item.unloadNum).toNumber();
        });
      }
      return count;
    },
  },
};
</script>

<style lang="scss" scoped>
.app-startUnloading {
  p {
    margin: 0;
    > span {
      margin-right: 5px;
    }
  }
  .el-row {
    margin-bottom: 15px;
  }
  .label-font {
    font-size: 16px;
    font-weight: bolder;
  }
  .number-area {
    display: flex;
    align-items: center;
    > * {
      margin-right: 10px;
    }
    > .el-input {
      width: 200px;
    }
  }
  .table-area {
    .table-goodList {
      .goodList-div {
        border-bottom: 1px solid #e6ebf5;
        > p {
          text-align: left;
          > span {
            margin-right: 0px;
          }
        }
      }
      > div:last-child {
        border-bottom: none;
      }
    }
  }
}
</style>