index.vue 9.13 KB
Newer Older
1 2 3 4 5 6
<template>
  <div class="shipping-tally">
    <el-row type="flex" style="margin-top: 15px; margin-bottom: 15px" justify="center">
      <el-col :xs="24" :sm="24" :md="24" :lg="20" :xl="22">
        <el-card>
          <el-descriptions :column="4" border>
7
            <el-descriptions-item :label="$t('自编号')">
8 9
              {{shipmentObj.selfNo}}
            </el-descriptions-item>
10
            <el-descriptions-item :label="$t('运输方式')">
11 12
              <dict-tag :type="DICT_TYPE.ECW_TRANSPORT_TYPE" :value="shipmentObj.transportType" />
            </el-descriptions-item>
13
            <el-descriptions-item :label="$t('始发地')">
14 15
              {{getCityName(shipmentObj.startWarehouseId)}}
            </el-descriptions-item>
16
            <el-descriptions-item :label="$t('目的地')">
17 18 19 20 21 22 23
              {{getCityName(shipmentObj.destWarehouseId)}}
            </el-descriptions-item>
          </el-descriptions>
        </el-card>

        <el-row style="margin-top: 15px">
          <el-row>
24 25
            <el-button size="small" type="primary" @click="()=>tallyClick('batch')">{{$t('批量理货')}}</el-button>
            <el-button size="small" type="primary" @click="()=>removeClick('batch')">{{$t('批量移出')}}</el-button>
26 27 28 29
          </el-row>
          <el-row style="margin-top: 5px">
            <el-table border :data="tallyList" @select="checkboxSelect" @select-all="checkboxSelect" max-height="600px">
              <el-table-column type="selection" align="center" width="55" fixed="left" />
30 31
              <el-table-column type="index" align="center" :label="$t('序号')" width="50" />
              <el-table-column :label="$t('订单号')" align="center" prop="orderNo">
huhaiqing's avatar
huhaiqing committed
32 33 34 35 36 37 38 39 40
                <template slot-scope="scope">
                  <div>
                    {{scope.row.orderNo}}
                  </div>
                  <div style="color:blue;fontWeight:bold;">
                    {{ scope.row.isExternalWarehouse === 1 ? '(外部仓)' : ''}}
                  </div>
                </template>
              </el-table-column>
41
              <el-table-column :label="$t('商品信息')" width="250px" align="center" prop="prodTitleZh">
42
              </el-table-column>
43
              <el-table-column :label="$t('备案')" align="center" prop="productRecord">
44 45 46 47
                <template v-slot="{row}">
                  <dict-tag :type="DICT_TYPE.PRODUCT_RECORD_ATTRIBUTE" :value="row.productRecord" />
                </template>
              </el-table-column>
48 49
              <el-table-column :label="$t('箱数')" align="center" prop="num" />
              <el-table-column :label="$t('纸箱尺寸')" align="center" prop="warehouseInInfo.boxGauge">
50
              </el-table-column>
51
              <el-table-column :label="$t('体积')" align="center" prop="volume">
52
              </el-table-column>
53
              <el-table-column :label="$t('重量')" align="center" prop="weight">
54 55
              </el-table-column>
              <el-table-column label="数量(个)" align="center" prop="quantity"></el-table-column>
56 57
              <el-table-column :label="$t('储位')" align="center" prop="positionNo" width="250px"></el-table-column>
              <el-table-column :label="$t('状态')" align="center" prop="tallyStatus">
58
                <template slot-scope="scope">
59
                  {{scope.row.tallyStatus === 1 ? $t('已理货') : $t('未理货')}}
60 61
                </template>
              </el-table-column>
62
              <el-table-column :label="$t('理货时间')" align="center" prop="tallyTime">
63 64 65 66
                <template slot-scope="scope">
                  {{formatDate(scope.row.tallyTime,'YYYY-MM-DD HH:mm:ss')}}
                </template>
              </el-table-column>
67
              <el-table-column :label="$t('操作')" align="center" width="160" class-name="small-padding fixed-width" fixed="right">
68
                <template slot-scope="scope">
69 70
                  <el-button type="text" size="small" @click="tallyClick('single',scope.row)">{{$t('理货')}}</el-button>
                  <el-button type="text" size="small" @click="removeClick('single',scope.row)">{{$t('移出')}}</el-button>
71 72 73 74 75 76 77
                </template>
              </el-table-column>
            </el-table>
          </el-row>
        </el-row>

        <el-row style="margin-top: 15px" class="operate-button">
78 79
          <el-button size="small" type="primary" @click="tallyFinish">{{$t('完成理货')}}</el-button>
          <el-button size="small" @click="cancel">{{$t('取消')}}</el-button>
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
        </el-row>
      </el-col>
    </el-row>
    <!-- 对话框 -->
    <el-dialog custom-class="shipping-dialog" :title="dialogConfig.title" :visible.sync="dialogConfig.dialogVisible" :fullscreen="dialogConfig.fullscreen" :width="dialogConfig.width" :modal-append-to-body=false append-to-body>
      <batchTally v-if="dialogConfig.dialogVisible" v-bind="$attrs" @closeDialog="closeDialog" :type="dialogConfig.type" :tallyRows="tallyRows" :shipmentObj="shipmentObj" />
    </el-dialog>
  </div>
</template>

<script>
import batchTally from "./batchTally.vue";
import { getTallyList, tallyRemove, tallyCommit } from "@/api/ecw/boxSea";
import { formatDate, serviceMsg } from "../../utils";

export default {
  name: "tally",
  inheritAttrs: false,
  components: {
    batchTally,
  },
  props: {
    shipmentObj: Object,
  },
  data() {
    return {
      tallyList: [],
      // 理货数据
      tallyRows: [],
      // 勾选行
      selectedRows: [],
      // 弹窗配置
      dialogConfig: {
        title: "",
        dialogVisible: false,
        width: "30%",
        type: "",
        fullscreen: false,
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    // 格式化日期
    formatDate,
    // 查询理货列表
    getList() {
      getTallyList({ shipmentId: this.shipmentObj.id }).then((res) => {
        let list = [];
        res.data.forEach((item) => {
          item.orderItemList.forEach((oItem) => {
133 134 135 136 137
            let warehouseInInfo = {};
            if (oItem.warehouseInInfo) {
              warehouseInInfo = JSON.parse(oItem.warehouseInInfo ?? {});
            }

138 139
            list.push({
              ...oItem,
140
              warehouseInInfo,
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
              positionNo: item.positionNo,
              tallyStatus: item.tallyStatus,
              tallyTime: item.tallyTime,
            });
          });
        });
        this.tallyList = list;
      });
    },
    // 选中
    checkboxSelect(selection) {
      this.selectedRows = selection;
    },
    // 理货点击
    tallyClick(type, data) {
      if (type === "batch") {
        if (this.selectedRows.length === 0) {
158
          this.$message.error(this.$t("请选择需要理货的订单"));
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
          return;
        }
        this.tallyRows = this.selectedRows;
        this.showDialog("batchTally");
      } else {
        this.tallyRows = [data];
        this.showDialog("singleTally");
      }
    },
    // 移出点击
    removeClick(type, data) {
      let orderNos = [],
        orderIds = [];
      if (type === "batch") {
        if (this.selectedRows.length === 0) {
174
          this.$message.error(this.$t("请选择需要移出的订单"));
175 176 177 178 179 180 181 182 183
          return;
        }
        orderNos = this.selectedRows.map((item) => item.orderNo);
        orderIds = this.selectedRows.map((item) => item.orderId);
      } else {
        orderNos = [data.orderNo];
        orderIds = [data.orderId];
      }

184 185 186 187
      let msgTitle = this.$t('您确定要将 {no} 移出 {selfNo} 吗?', {
        no: orderNos.join(""),
        selfNo: this.shipmentObj.selfNo
      });
188

189
      this.$confirm(msgTitle, this.$t("提示"), {
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
        type: "warning",
      })
        .then((_) => {
          tallyRemove({
            orderIdLIst: orderIds,
            shipmentId: this.shipmentObj.id,
          }).then((res) => {
            serviceMsg(res, this).then(() => {
              this.getList();
            });
          });
        })
        .catch((_) => {});
    },
    // 关闭弹窗
    closeDialog(type) {
      this.$set(this.dialogConfig, "dialogVisible", false);
      if (type === "query") {
        this.getList();
      }
    },
    // 打开弹窗
    showDialog(type) {
      switch (type) {
        case "batchTally":
215
          this.$set(this.dialogConfig, "title", this.$t("批量理货"));
216 217 218
          this.$set(this.dialogConfig, "width", "500px");
          break;
        case "singleTally":
219
          this.$set(this.dialogConfig, "title", this.$t("理货确认"));
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243
          this.$set(this.dialogConfig, "width", "500px");
          break;
      }
      this.$set(this.dialogConfig, "type", type);
      this.$set(this.dialogConfig, "dialogVisible", true);
    },
    /** 取消 */
    cancel(type) {
      this.$emit("closeDialog", type);
    },
    // 理货完成
    tallyFinish() {
      tallyCommit({ shipmentId: this.shipmentObj.id }).then((res) => {
        serviceMsg(res, this).then(() => {
          this.$emit("closeDialog", "submit");
        });
      });
    },
  },
  computed: {
    /* 获取仓库 */
    getCityName() {
      return (id) => {
        let arr = this.$attrs.warehouseList.filter((item) => item.id == id);
244
        return arr.length > 0 ? this.$l(arr[0], 'title') : this.$t("");
245 246 247 248 249 250 251 252
      };
    },
  },
};
</script>

<style lang="scss" scoped>
</style>