index.vue 12.8 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" />
huhaiqing's avatar
huhaiqing committed
30
              <el-table-column align="center" :label="$t('序号')" width="50" prop="tidanNum" />
31
              <el-table-column :label="$t('订单号')" align="center" prop="orderNo">
huhaiqing's avatar
huhaiqing committed
32 33 34 35 36
                <template slot-scope="scope">
                  <div>
                    {{scope.row.orderNo}}
                  </div>
                  <div style="color:blue;fontWeight:bold;">
zhoutong's avatar
zhoutong committed
37 38 39 40
                    {{ scope.row.isExternalWarehouse === 1 ? ('('+$t('外部仓')+')') : ''}}
                  </div>
                  <div style="color:red;fontWeight:bold;">
                    {{ scope.row.adjustToDestWarehouseId > 0 ? ('('+$t('调仓')+')') : ''}}
huhaiqing's avatar
huhaiqing committed
41 42 43
                  </div>
                </template>
              </el-table-column>
huhaiqing's avatar
huhaiqing committed
44 45 46 47
              <el-table-column :label="$t('商品信息')" width="250px" align="center" prop="">
                <template slot-scope="{row}">
                  {{$l(row,'prodTitle')}}
                </template>
48
              </el-table-column>
huhaiqing's avatar
huhaiqing committed
49
              <el-table-column :label="$t('备案')" align="center" prop="feeType">
huhaiqing's avatar
huhaiqing committed
50 51 52
                <template slot-scope="{row}">
                  <template v-if="row.brandName">{{row.brandName}}</template>
                  <dict-tag v-else :type="DICT_TYPE.ECW_IS_BRAND" :value="row.feeType" />
53 54
                </template>
              </el-table-column>
55 56
              <el-table-column :label="$t('报关方式')" align="center" prop="customsType">
                <template slot-scope="scope">
57 58 59
                  <div :class="scope.row.customsType !== 1 ? 'custom_type_red' : ''">
                    <dict-tag :type="DICT_TYPE.ECW_CUSTOMS_TYPE" :value="scope.row.customsType" />
                  </div>
60 61
                </template>
              </el-table-column>
62
              <el-table-column :label="$t('箱数')" align="center" prop="warehouseInInfo.cartonsNum">
huhaiqing's avatar
huhaiqing committed
63
                <template slot-scope="scope">
huhaiqing's avatar
huhaiqing committed
64
                  <el-link type="primary" @click.native="showWarehouseLogs(scope.row)">
65
                    {{scope.row.warehouseInInfo.cartonsNum}}
huhaiqing's avatar
huhaiqing committed
66
                  </el-link>
huhaiqing's avatar
huhaiqing committed
67 68 69 70 71
                  <div style="color:blue;fontWeight:bold;">
                    {{ scope.row.multiSpecification === true ? '(多规格)' : ''}}
                  </div>
                </template>
              </el-table-column>
72
              <el-table-column :label="$t('纸箱尺寸')" align="center" prop="warehouseInInfo.boxGauge">
73
              </el-table-column>
74
              <el-table-column :label="$t('体积')" align="center" prop="warehouseInInfo.volume">
75
              </el-table-column>
76
              <el-table-column :label="$t('重量')" align="center" prop="warehouseInInfo.weight">
77
              </el-table-column>
Marcus's avatar
Marcus committed
78
              <el-table-column :label="$t('数量(个)')" align="center" prop="quantity"></el-table-column>
79 80 81 82 83
              <el-table-column :label="$t('储位')" align="center" prop="positionNo" width="250px">
                <template slot-scope="scope">
                  {{notset(scope.row.positionNo)}}
                </template>
              </el-table-column>
84
              <el-table-column :label="$t('状态')" align="center" prop="tallyStatus">
85
                <template slot-scope="scope">
86
                  {{scope.row.tallyStatus === 1 ? $t('已理货') : $t('未理货')}}
87 88
                </template>
              </el-table-column>
89
              <el-table-column :label="$t('理货时间')" align="center" prop="tallyTime">
90 91 92 93
                <template slot-scope="scope">
                  {{formatDate(scope.row.tallyTime,'YYYY-MM-DD HH:mm:ss')}}
                </template>
              </el-table-column>
94
              <el-table-column :label="$t('操作')" align="center" width="160" class-name="small-padding fixed-width" fixed="right">
95
                <template slot-scope="scope">
96 97
                  <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>
98 99 100 101 102 103 104
                </template>
              </el-table-column>
            </el-table>
          </el-row>
        </el-row>

        <el-row style="margin-top: 15px" class="operate-button">
105 106
          <el-button size="small" type="primary" @click="tallyFinish">{{$t('完成理货')}}</el-button>
          <el-button size="small" @click="cancel">{{$t('取消')}}</el-button>
107 108 109 110 111 112 113
        </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>
huhaiqing's avatar
huhaiqing committed
114
    <warehouse-detail :order="order" :orderItemId="showWarehouseInItemId" v-if="showWarehouseInItemId" @close="showWarehouseInItemId=null" />
115 116 117 118 119 120 121
  </div>
</template>

<script>
import batchTally from "./batchTally.vue";
import { getTallyList, tallyRemove, tallyCommit } from "@/api/ecw/boxSea";
import { formatDate, serviceMsg } from "../../utils";
huhaiqing's avatar
huhaiqing committed
122
import WarehouseDetail from "./warehouseDetail";
huhaiqing's avatar
huhaiqing committed
123
import { getOrder } from "@/api/ecw/order";
124 125 126 127 128 129

export default {
  name: "tally",
  inheritAttrs: false,
  components: {
    batchTally,
huhaiqing's avatar
huhaiqing committed
130
    WarehouseDetail,
131 132 133 134 135 136
  },
  props: {
    shipmentObj: Object,
  },
  data() {
    return {
huhaiqing's avatar
huhaiqing committed
137 138
      showWarehouseInItemId: null,
      order: null,
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
      tallyList: [],
      // 理货数据
      tallyRows: [],
      // 勾选行
      selectedRows: [],
      // 弹窗配置
      dialogConfig: {
        title: "",
        dialogVisible: false,
        width: "30%",
        type: "",
        fullscreen: false,
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    // 格式化日期
    formatDate,
160 161 162 163 164 165 166
    //去重
    notset(string){
      if(!string) return string
      let arr = string.split(',')
      arr = arr.filter((item,index)=>{return arr.indexOf(item)==index})
      return arr.toString()
    },
167 168 169 170 171 172
    // 查询理货列表
    getList() {
      getTallyList({ shipmentId: this.shipmentObj.id }).then((res) => {
        let list = [];
        res.data.forEach((item) => {
          item.orderItemList.forEach((oItem) => {
173 174 175 176 177
            let warehouseInInfo = {};
            if (oItem.warehouseInInfo) {
              warehouseInInfo = JSON.parse(oItem.warehouseInInfo ?? {});
            }

178 179
            list.push({
              ...oItem,
180
              warehouseInInfo,
181
              multiSpecification: oItem.multiSpecification,
182
              positionNo: oItem.positionNo,
183 184 185 186 187
              tallyStatus: item.tallyStatus,
              tallyTime: item.tallyTime,
            });
          });
        });
188 189 190 191 192 193 194 195 196 197
        // let relist = []
        // list.forEach(l=>{
        //   let index = relist.findIndex(i=>i.orderId == l.orderId && i.positionNo == l.positionNo)
        //   if(index == -1){
        //     relist.push(l)
        //   }else{
        //     relist[index].warehouseInInfo.cartonsNum = parseInt(relist[index].warehouseInInfo.cartonsNum)+parseInt(l.warehouseInInfo.cartonsNum)
        //   }
        // })
        this.tallyList = list;
198 199 200 201 202 203 204 205 206 207
      });
    },
    // 选中
    checkboxSelect(selection) {
      this.selectedRows = selection;
    },
    // 理货点击
    tallyClick(type, data) {
      if (type === "batch") {
        if (this.selectedRows.length === 0) {
208
          this.$message.error(this.$t("请选择需要理货的订单"));
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
          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) {
224
          this.$message.error(this.$t("请选择需要移出的订单"));
225 226 227 228 229 230 231 232 233
          return;
        }
        orderNos = this.selectedRows.map((item) => item.orderNo);
        orderIds = this.selectedRows.map((item) => item.orderId);
      } else {
        orderNos = [data.orderNo];
        orderIds = [data.orderId];
      }

huhaiqing's avatar
huhaiqing committed
234
      let msgTitle = this.$t("您确定要将 {no} 移出 {selfNo} 吗?", {
235
        no: orderNos.join(""),
huhaiqing's avatar
huhaiqing committed
236
        selfNo: this.shipmentObj.selfNo,
237
      });
238

239
      this.$confirm(msgTitle, this.$t("提示"), {
240 241 242
        type: "warning",
      })
        .then((_) => {
243
          let param = {
244 245
            orderIdLIst: orderIds,
            shipmentId: this.shipmentObj.id,
246 247
          }
          tallyRemove(param).then((res) => {
248 249 250
            serviceMsg(res, this).then(() => {
              this.getList();
            });
251 252
          }).catch((res) => {
        if (res.code === 666) {
253
              this.$confirm("<div style='max-height:500px;overflow:auto'>"+res.msg+this.$t('是否需要一起移出?')+"</div>", this.$t("提示"), {
zhoutong's avatar
zhoutong committed
254 255 256 257
                dangerouslyUseHTMLString: true,
                distinguishCancelAndClose: true,
                confirmButtonText: '确定移出',
                cancelButtonText: '仅移出当前订单'
258 259 260 261 262 263 264 265
              })
                .then((_) => {
                  tallyRemove({ ...param, deleteType: 2 }).then((res) => {
                    serviceMsg(res, this).then(() => {
                      this.getList();
                    });
                  });
                })
zhoutong's avatar
zhoutong committed
266 267 268 269 270 271
                .catch(action => {
                  if(action =='cancel'){
                    tallyRemove({ ...param, deleteType: 1 }).then((res) => {
                      serviceMsg(res, this).then(() => {
                        this.getList();
                      });
272
                    });
zhoutong's avatar
zhoutong committed
273
                  }
274 275 276
                });
            }
      });
277 278 279 280 281 282 283 284 285 286 287 288 289 290
        })
        .catch((_) => {});
    },
    // 关闭弹窗
    closeDialog(type) {
      this.$set(this.dialogConfig, "dialogVisible", false);
      if (type === "query") {
        this.getList();
      }
    },
    // 打开弹窗
    showDialog(type) {
      switch (type) {
        case "batchTally":
291
          this.$set(this.dialogConfig, "title", this.$t("批量理货"));
292 293 294
          this.$set(this.dialogConfig, "width", "500px");
          break;
        case "singleTally":
295
          this.$set(this.dialogConfig, "title", this.$t("理货确认"));
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313
          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");
        });
      });
    },
huhaiqing's avatar
huhaiqing committed
314 315 316 317 318 319 320
    // 显示入仓记录
    showWarehouseLogs(row) {
      getOrder(row.orderId).then((response) => {
        this.order = response.data;
        this.showWarehouseInItemId = row.orderItemId;
      });
    },
321 322 323 324 325 326
  },
  computed: {
    /* 获取仓库 */
    getCityName() {
      return (id) => {
        let arr = this.$attrs.warehouseList.filter((item) => item.id == id);
huhaiqing's avatar
huhaiqing committed
327
        return arr.length > 0 ? this.$l(arr[0], "title") : this.$t("");
328 329 330 331 332 333 334 335
      };
    },
  },
};
</script>

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