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

    <!-- 自编号 -->
    <el-row class="number-area">
6
      <p class="label-font">{{$t('自编号')}}</p>
7
      <p class="label-font">{{selfNo}}</p>
8
      <el-input v-model="labelNo" :placeholder="$t('请输入')"></el-input>
huhaiqing's avatar
huhaiqing committed
9
      <div>
10 11 12
        <el-button type="primary" @click="modifyUnload">{{$t('提交')}}</el-button>
        <el-button type="primary" @click="modifyBatchUnload">{{$t('批量输入')}}</el-button>
        <el-button type="primary" @click="modifyAllUnload">{{$t('一键卸柜')}}</el-button>
huhaiqing's avatar
huhaiqing committed
13 14 15 16 17
      </div>
    </el-row>

    <!-- 当前部分 -->
    <el-row class="number-area">
18 19 20
      <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>
21
        <el-option v-for="item in sectionList" :key="item.id" :label="item.title" :value="item.id"></el-option>
huhaiqing's avatar
huhaiqing committed
22 23
      </el-select>
      <p>
huhaiqing's avatar
huhaiqing committed
24
        {{getSectionInfo}}
huhaiqing's avatar
huhaiqing committed
25 26 27 28
      </p>
    </el-row>

    <!-- 表格 -->
29
    <el-row class="table-area">
huhaiqing's avatar
huhaiqing committed
30
      <el-table v-loading="loading" :data="pageData.sectionOrderList" border max-height="500px">
huhaiqing's avatar
huhaiqing committed
31
        <el-table-column :label="$t('序号')" align="center" width="50" prop="tidanNum" />
32
        <el-table-column :label="$t('订单号')" align="center" prop="orderNo">
huhaiqing's avatar
huhaiqing committed
33
          <template slot-scope="scope">
huhaiqing's avatar
huhaiqing committed
34
            {{ scope.row.orderNo }}
huhaiqing's avatar
huhaiqing committed
35
          </template>
36
        </el-table-column>
huhaiqing's avatar
huhaiqing committed
37
        <el-table-column :label="$t('商品信息')" align="center" prop="goodsList" width="200px">
38 39
          <template slot-scope="scope">
            <section class="table-goodList">
40
              <div v-for="(item, index) in scope.row.goodsList" :key="index" class="goodList-div">
huhaiqing's avatar
huhaiqing committed
41
                <p>{{$t('品名')}}{{$l(item, 'prodTitle')}}</p>
huhaiqing's avatar
huhaiqing committed
42
                <p>{{$t('品牌')}}:【<template v-if="item.brandName">{{item.brandName}}</template>
Marcus's avatar
Marcus committed
43
                  <dict-tag v-else :type="DICT_TYPE.ECW_IS_BRAND" :value="item.feeType" />{{ $t('】') }}</p>
44 45 46 47
              </div>
            </section>
          </template>
        </el-table-column>
48 49
        <el-table-column :label="$t('报关方式')" align="center" prop="customsType">
          <template slot-scope="scope">
50 51 52
            <div :class="scope.row.customsType !== 1 ? 'custom_type_red' : ''">
              <dict-tag :type="DICT_TYPE.ECW_CUSTOMS_TYPE" :value="scope.row.customsType" />
            </div>
53 54
          </template>
        </el-table-column>
55 56 57
        <el-table-column :label="$t('实装箱数')" align="center" prop="installNum" />
        <el-table-column :label="$t('卸柜箱数')" align="center" prop="unloadNum" />
        <el-table-column :label="$t('清关状态')" align="center" prop="">
58 59
          <template slot-scope="scope">{{clearStatus(scope.row)}}</template>
        </el-table-column>
60 61 62
        <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="">
huhaiqing's avatar
huhaiqing committed
63 64 65 66
          <template slot-scope="scope">
            {{getOrderError(scope.row, 'orderStatus')}}
          </template>
        </el-table-column>
67
        <el-table-column :label="$t('异常状态')" align="center" prop="">
huhaiqing's avatar
huhaiqing committed
68
          <template slot-scope="scope">
huhaiqing's avatar
huhaiqing committed
69
            <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>
huhaiqing's avatar
huhaiqing committed
70 71
          </template>
        </el-table-column>
72
        <el-table-column :label="$t('异常类型')" align="center" prop="">
huhaiqing's avatar
huhaiqing committed
73 74 75 76
          <template slot-scope="scope">
            {{getUnloadError(scope.row.exceptionList)}}
          </template>
        </el-table-column>
77
        <el-table-column :label="$t('操作')" align="center" class-name="small-padding fixed-width">
huhaiqing's avatar
huhaiqing committed
78
          <template slot-scope="scope">
79
            <el-button type="danger" size="small" @click="openError(scope.row)">{{$t('异常')}}</el-button>
huhaiqing's avatar
huhaiqing committed
80 81 82 83 84 85 86
          </template>
        </el-table-column>
      </el-table>
    </el-row>

    <!-- 总计 -->
    <el-row>
87
      <div class="label-font">
huhaiqing's avatar
huhaiqing committed
88
        <p>
89
          <span>{{$t('总计')}}:</span>
90
          <span>{{getTotlContent(pageData.totalStatistics)}}</span>
huhaiqing's avatar
huhaiqing committed
91 92
        </p>
      </div>
93
      <div class="label-font">
huhaiqing's avatar
huhaiqing committed
94
        <p>
95
          <span>{{$t('已卸')}}:</span>
huhaiqing's avatar
huhaiqing committed
96
          <span>{{getUnLoadNumCount}}</span>
huhaiqing's avatar
huhaiqing committed
97 98 99 100
        </p>
      </div>
    </el-row>

huhaiqing's avatar
huhaiqing committed
101 102 103
    <!-- 审核流程 -->
    <el-row class="process-area">
      <div class="process">
104
        <div>{{$t('审批流程')}}</div>
huhaiqing's avatar
huhaiqing committed
105 106 107 108
        <work-flow xmlkey="unload_container" v-model="selectedUsers"></work-flow>
      </div>
      <!-- 操作 -->
      <div v-if="!isUnderReview">
109 110
        <el-button type="success" @click="onSubmit">{{$t('卸柜完成')}}</el-button>
        <el-button plain type="primary" @click="$emit('closeStart')">{{$t('返回')}}</el-button>
huhaiqing's avatar
huhaiqing committed
111 112
      </div>
      <div v-if="isUnderReview">
113 114 115
        <el-button type="primary" @click="jumpReviewDetail">{{$t('卸柜审核中')}}</el-button>
        <el-button plain type="primary" @click="canclAudit">{{$t('取消审核')}}</el-button>
        <el-button plain type="primary" @click="$emit('closeStart')">{{$t('返回')}}</el-button>
huhaiqing's avatar
huhaiqing committed
116
      </div>
huhaiqing's avatar
huhaiqing committed
117 118 119
    </el-row>

    <!-- 对话框 -->
120
    <el-dialog custom-class="shipping-dialog" :title="$t('异常')" :visible.sync="dialogVisible" width="600px" :modal-append-to-body=false append-to-body>
121
      <unloadingError v-if="dialogVisible" @closeDialog="closeDialog" v-bind="$attrs" :currRow="currRow" />
huhaiqing's avatar
huhaiqing committed
122 123 124 125 126 127
    </el-dialog>
  </div>
</template>

<script>
import unloadingError from "./unloadingError.vue";
128 129 130 131 132
import {
  loadGoodsList,
  batchUnload,
  allUnload,
  approvalCreate,
huhaiqing's avatar
huhaiqing committed
133
  approvalCancel,
huhaiqing's avatar
huhaiqing committed
134
  getSectionList,
135
  singleUnload,
136
} from "@/api/ecw/boxSea";
137
import { serviceMsg, getTotlContent, toReviewDetail } from "../../utils";
huhaiqing's avatar
huhaiqing committed
138
import WorkFlow from "@/components/WorkFlow";
139
import Decimal from "decimal.js";
huhaiqing's avatar
huhaiqing committed
140

huhaiqing's avatar
huhaiqing committed
141 142 143 144 145
/**
 * 开始卸柜
 */
export default {
  name: "startUnloading",
146
  inheritAttrs: false,
huhaiqing's avatar
huhaiqing committed
147
  components: { unloadingError, WorkFlow },
huhaiqing's avatar
huhaiqing committed
148 149 150 151 152 153 154 155
  data() {
    return {
      // 标签号
      labelNo: "",
      // 当前部分
      currPart: "",
      // loading
      loading: false,
156 157
      // 页面数据
      pageData: {},
huhaiqing's avatar
huhaiqing committed
158 159
      // 弹窗配置
      dialogVisible: false,
160 161 162 163
      // 自编号
      selfNo: this.$attrs.shipmentObj.selfNo,
      // 当前行
      currRow: {},
huhaiqing's avatar
huhaiqing committed
164 165 166 167 168 169 170 171 172 173
      // 部分
      sectionList: [],
      // 已选部分
      sectionId: "0",
      // 部分订单商品
      sectionObj: {
        secStatistics: {},
        sectionOrderList: [],
        totalStatistics: {},
      },
huhaiqing's avatar
huhaiqing committed
174
      selectedUsers: [],
huhaiqing's avatar
huhaiqing committed
175 176
    };
  },
177 178
  created() {
    this.getLoadGoodsList();
huhaiqing's avatar
huhaiqing committed
179 180 181 182 183
    // 部分
    getSectionList({ shipmentId: this.$attrs.shipmentObj.id }).then((res) => {
      this.sectionList = res.data.map((item, index) => {
        return {
          ...item,
184
          title: this.$t("第{index}部分", { index: index + 1 }),
huhaiqing's avatar
huhaiqing committed
185 186 187
        };
      });
    });
188
  },
huhaiqing's avatar
huhaiqing committed
189
  methods: {
190
    getTotlContent,
191
    /* 获取卸柜数据 */
huhaiqing's avatar
huhaiqing committed
192
    getLoadGoodsList() {
193
      this.loading = true;
huhaiqing's avatar
huhaiqing committed
194 195
      let params = {
        secId: this.sectionId,
196 197 198 199 200 201 202 203
        shipmentId: this.$attrs.shipmentObj.id,
      };
      loadGoodsList(params).then((res) => {
        const { data } = res;
        this.pageData = data;
        this.loading = false;
      });
    },
204 205 206
    /* 单个卸柜 */
    modifyUnload() {
      if (!this.labelNo) {
207
        this.$message.error(this.$t("请输入箱号标签"));
208 209 210 211 212 213 214 215 216 217 218 219
        return;
      }
      singleUnload({
        orderNumCode: this.labelNo,
        shipmentId: this.$attrs.shipmentObj.id,
      }).then((res) => {
        serviceMsg(res, this).then((res) => {
          this.labelNo = "";
          this.getLoadGoodsList();
        });
      });
    },
220 221 222
    /* 批量输入 */
    modifyBatchUnload() {
      if (!this.labelNo) {
223
        this.$message.error(this.$t("请输入订单号"));
224 225 226
        return;
      }
      batchUnload({
227
        orderNo: this.labelNo,
228 229 230
        shipmentId: this.$attrs.shipmentObj.id,
      }).then((res) => {
        serviceMsg(res, this).then((res) => {
huhaiqing's avatar
huhaiqing committed
231
          this.labelNo = "";
232 233 234 235 236 237
          this.getLoadGoodsList();
        });
      });
    },
    /* 一键卸柜 */
    modifyAllUnload() {
238
      this.$confirm(this.$t("确认卸柜?"), this.$t("提示"), {
239 240 241 242 243 244 245 246 247 248 249
        type: "warning",
      })
        .then((_) => {
          allUnload({ shipmentId: this.$attrs.shipmentObj.id }).then((res) => {
            serviceMsg(res, this).then((res) => {
              this.getLoadGoodsList();
            });
          });
        })
        .catch((_) => {});
    },
huhaiqing's avatar
huhaiqing committed
250 251
    /** 提交 */
    onSubmit() {
252 253 254 255
      approvalCreate({
        shipmentId: this.$attrs.shipmentObj.id,
        approvalStatus: 0,
        approvalType: 3, // 卸柜
huhaiqing's avatar
huhaiqing committed
256
        copyUserId: this.selectedUsers,
257 258 259 260
      }).then((res) => {
        serviceMsg(res, this).then(() => {
          this.cancel();
        });
huhaiqing's avatar
huhaiqing committed
261 262 263 264
      });
    },
    /** 取消 */
    cancel() {
huhaiqing's avatar
huhaiqing committed
265
      this.$emit("closeStart", "submit");
266 267
    },
    /* 关闭弹窗 */
268
    closeDialog(type) {
269
      this.dialogVisible = false;
270
      if (type === "query") this.getLoadGoodsList();
huhaiqing's avatar
huhaiqing committed
271
    },
272
    /* 打开异常 */
273 274
    openError(row) {
      this.currRow = row;
huhaiqing's avatar
huhaiqing committed
275 276
      this.dialogVisible = true;
    },
277 278 279 280
    /* 清关状态 */
    clearStatus(row) {
      const { installNum, unloadNum } = row;
      if (installNum === unloadNum) {
281
        return this.$t("全部清关");
282 283
      }
      if (installNum >= unloadNum) {
284
        return this.$t("部分清关");
285 286
      }
      if (unloadNum === 0) {
287
        return this.$t("未清关");
288 289
      }
    },
huhaiqing's avatar
huhaiqing committed
290 291 292 293
    // 部分切换
    sectionChange() {
      this.getLoadGoodsList();
    },
huhaiqing's avatar
huhaiqing committed
294 295
    /* 取消审核 */
    canclAudit() {
huhaiqing's avatar
huhaiqing committed
296
      const { shipmentObj } = this.$attrs;
huhaiqing's avatar
huhaiqing committed
297
      approvalCancel({
298
        applyReason: this.$t("取消审核"),
huhaiqing's avatar
huhaiqing committed
299
        id: shipmentObj["cabinetUnloadApprovalInfo"].id,
huhaiqing's avatar
huhaiqing committed
300 301 302 303 304 305 306
        shipmentId: shipmentObj.id,
      }).then((res) => {
        serviceMsg(res, this).then(() => {
          this.cancel();
        });
      });
    },
huhaiqing's avatar
huhaiqing committed
307
    // 获取异常类型
huhaiqing's avatar
huhaiqing committed
308 309
    getUnloadError(exceptionList) {
      if (!exceptionList) return exceptionList;
huhaiqing's avatar
huhaiqing committed
310 311 312 313 314 315 316 317 318 319 320 321 322
      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) {
323
        return type === "orderStatus" ? this.$t("卸柜异常") : this.$t("待处理");
huhaiqing's avatar
huhaiqing committed
324
      }
325
      return type === "orderStatus" ? this.$t("已到港") : "";
huhaiqing's avatar
huhaiqing committed
326 327 328 329 330 331 332 333
    },
    // 处理异常
    handleError(row) {
      this.$emit("closeStart", "close");
      this.$router.push({
        path: `/order/pending?id=${row.orderId}`,
      });
    },
334 335 336 337 338
    jumpReviewDetail() {
      const { cabinetUnloadApprovalInfo } = this.$attrs.shipmentObj;
      toReviewDetail.apply(this, [cabinetUnloadApprovalInfo.bpmProcessId]);
      this.$emit("closeStart", "close");
    },
huhaiqing's avatar
huhaiqing committed
339 340
  },
  computed: {
huhaiqing's avatar
huhaiqing committed
341 342 343 344 345
    /* 是否审核中 */
    isUnderReview() {
      const { currNode, shipmentObj } = this.$attrs;
      return shipmentObj[currNode.keyName] === 183 ? true : false;
    },
huhaiqing's avatar
huhaiqing committed
346 347 348 349 350 351 352 353 354
    // 部分信息
    getSectionInfo() {
      const { totalStatistics, secStatistics } = this.pageData;
      if (!this.sectionId) {
        return getTotlContent(totalStatistics);
      } else {
        return getTotlContent(secStatistics);
      }
    },
huhaiqing's avatar
huhaiqing committed
355 356 357 358 359
    /* 已卸总数 */
    getUnLoadNumCount() {
      let count = 0;
      if (this.pageData.sectionOrderList) {
        this.pageData.sectionOrderList.forEach((item) => {
360
          count = Decimal.add(count, item.unloadNum).toNumber();
huhaiqing's avatar
huhaiqing committed
361 362 363 364
        });
      }
      return count;
    },
huhaiqing's avatar
huhaiqing 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
  },
};
</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;
    }
  }
394 395 396
  .table-area {
    .table-goodList {
      .goodList-div {
huhaiqing's avatar
huhaiqing committed
397
        border-bottom: 1px solid #e6ebf5;
398 399 400
        > p {
          text-align: left;
          > span {
huhaiqing's avatar
huhaiqing committed
401
            margin-right: 0px;
402 403 404
          }
        }
      }
huhaiqing's avatar
huhaiqing committed
405 406 407
      > div:last-child {
        border-bottom: none;
      }
408 409
    }
  }
huhaiqing's avatar
huhaiqing committed
410 411
}
</style>