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

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

    <!-- 当前部分 -->
    <el-row class="number-area">
      <p class="label-font">当前部分:</p>
18 19 20
      <el-select placeholder="请选择" v-model="sectionId" @change="sectionChange">
        <el-option key="0" label="全部" value="0"></el-option>
        <el-option v-for="item in sectionList" :key="item.id" :label="item.title" :value="item.id"></el-option>
huhaiqing's avatar
huhaiqing committed
21 22
      </el-select>
      <p>
huhaiqing's avatar
huhaiqing committed
23
        {{getSectionInfo}}
huhaiqing's avatar
huhaiqing committed
24 25 26 27
      </p>
    </el-row>

    <!-- 表格 -->
28
    <el-row class="table-area">
huhaiqing's avatar
huhaiqing committed
29
      <el-table v-loading="loading" :data="pageData.sectionOrderList" border max-height="500px">
30 31
        <el-table-column label="序号" type="index" align="center" width="50" />
        <el-table-column label="订单号" align="center" prop="orderNo">
huhaiqing's avatar
huhaiqing committed
32
          <template slot-scope="scope">
huhaiqing's avatar
huhaiqing committed
33
            {{ scope.row.orderNo }}
huhaiqing's avatar
huhaiqing committed
34
          </template>
35
        </el-table-column>
36
        <el-table-column label="商品信息" align="center" prop="goodsList">
37 38
          <template slot-scope="scope">
            <section class="table-goodList">
39
              <div v-for="(item, index) in scope.row.goodsList" :key="index" class="goodList-div">
40 41 42 43 44
                <p>{{index+1}}{{item.prodTitleZh}}</p>
              </div>
            </section>
          </template>
        </el-table-column>
45 46 47
        <el-table-column label="实装箱数" align="center" prop="installNum" />
        <el-table-column label="卸柜箱数" align="center" prop="unloadNum" />
        <el-table-column label="清关状态" align="center" prop="">
48 49
          <template slot-scope="scope">{{clearStatus(scope.row)}}</template>
        </el-table-column>
50 51
        <el-table-column label="体积" align="center" prop="volume" />
        <el-table-column label="重量" align="center" prop="weight" />
huhaiqing's avatar
huhaiqing committed
52 53 54 55 56 57 58
        <el-table-column label="订单状态" align="center" prop="">
          <template slot-scope="scope">
            {{getOrderError(scope.row, 'orderStatus')}}
          </template>
        </el-table-column>
        <el-table-column label="异常状态" align="center" prop="">
          <template slot-scope="scope">
huhaiqing's avatar
huhaiqing committed
59
            <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
60 61 62 63 64 65 66
          </template>
        </el-table-column>
        <el-table-column label="异常类型" align="center" prop="">
          <template slot-scope="scope">
            {{getUnloadError(scope.row.exceptionList)}}
          </template>
        </el-table-column>
67
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
huhaiqing's avatar
huhaiqing committed
68
          <template slot-scope="scope">
69
            <el-button type="danger" size="small" @click="openError(scope.row)">异常</el-button>
huhaiqing's avatar
huhaiqing committed
70 71 72 73 74 75 76
          </template>
        </el-table-column>
      </el-table>
    </el-row>

    <!-- 总计 -->
    <el-row>
77
      <div class="label-font">
huhaiqing's avatar
huhaiqing committed
78 79
        <p>
          <span>总计:</span>
80
          <span>{{getTotlContent(pageData.totalStatistics)}}</span>
huhaiqing's avatar
huhaiqing committed
81 82
        </p>
      </div>
83
      <div class="label-font">
huhaiqing's avatar
huhaiqing committed
84 85
        <p>
          <span>已卸:</span>
huhaiqing's avatar
huhaiqing committed
86
          <span>{{getUnLoadNumCount}}</span>
huhaiqing's avatar
huhaiqing committed
87 88 89 90
        </p>
      </div>
    </el-row>

huhaiqing's avatar
huhaiqing committed
91 92 93 94 95 96 97 98 99 100 101 102
    <!-- 审核流程 -->
    <el-row class="process-area">
      <div class="process">
        <div>审批流程</div>
        <work-flow xmlkey="unload_container" v-model="selectedUsers"></work-flow>
      </div>
      <!-- 操作 -->
      <div v-if="!isUnderReview">
        <el-button type="success" @click="onSubmit">卸柜完成</el-button>
        <el-button plain type="primary" @click="$emit('closeStart')">返回</el-button>
      </div>
      <div v-if="isUnderReview">
103
        <el-button type="primary" @click="jumpReviewDetail">卸柜审核中</el-button>
huhaiqing's avatar
huhaiqing committed
104 105 106
        <el-button plain type="primary" @click="canclAudit">取消审核</el-button>
        <el-button plain type="primary" @click="$emit('closeStart')">返回</el-button>
      </div>
huhaiqing's avatar
huhaiqing committed
107 108 109
    </el-row>

    <!-- 对话框 -->
110 111
    <el-dialog custom-class="shipping-dialog" title="异常" :visible.sync="dialogVisible" width="600px" :modal-append-to-body=false append-to-body>
      <unloadingError v-if="dialogVisible" @closeDialog="closeDialog" v-bind="$attrs" :currRow="currRow" />
huhaiqing's avatar
huhaiqing committed
112 113 114 115 116 117
    </el-dialog>
  </div>
</template>

<script>
import unloadingError from "./unloadingError.vue";
118 119 120 121 122
import {
  loadGoodsList,
  batchUnload,
  allUnload,
  approvalCreate,
huhaiqing's avatar
huhaiqing committed
123
  approvalCancel,
huhaiqing's avatar
huhaiqing committed
124
  getSectionList,
125
} from "@/api/ecw/boxSea";
126
import { serviceMsg, getTotlContent, toReviewDetail } from "../../utils";
huhaiqing's avatar
huhaiqing committed
127
import WorkFlow from "@/components/WorkFlow";
huhaiqing's avatar
huhaiqing committed
128

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