batchTally.vue 4.76 KB
Newer Older
1 2 3
<template>
  <div class="shipping-batchTally">
    <el-row v-if="$attrs.type === 'batchTally'">
4
      <el-button type="text" size="small" @click="()=>openStorage('all')">{{$t('批量修改储位')}}</el-button>
5 6 7 8 9
    </el-row>
    <el-scrollbar viewClass="tally-list">
      <el-row class="tally-detail" v-for="(item, index) in storageList" :key="item.id">
        <div class="status-number">{{++index}}</div>
        <div class="detail-info">
10 11
          <div>{{$t('入仓单号')}}{{item.orderNo}}</div>
          <div>{{$t('入仓统计')}}{{getTotlContent(item)}}</div>
12 13
          <div class="detail-modify">
            <el-tooltip effect="dark" :content="item.positionNo" placement="top">
14
              <div>{{$t('储位')}}{{item.positionNo}}</div>
15
            </el-tooltip>
16
            <el-button type="text" size="small" @click="()=>openStorage('single', item)">{{$t('修改')}}</el-button>
17 18 19 20 21 22
          </div>
        </div>
      </el-row>
    </el-scrollbar>

    <el-row class="operate-button">
23 24
      <el-button size="small" type="primary" @click="tallyModify">{{$t('确定')}}</el-button>
      <el-button size="small" @click="$emit('closeDialog')">{{$t('关闭')}}</el-button>
25 26
    </el-row>

huhaiqing's avatar
huhaiqing committed
27
    <warehouse-area-dialog ref="area" :visible.sync="visible" v-model="storageSpaces" :order-id="orderId" :warehouseId="warehouseId" :modal-append-to-body=false append-to-body />
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
  </div>
</template>

<script>
import { getTotlContent, serviceMsg } from "../../utils";
import WarehouseAreaDialog from "@/components/WarehouseAreaDialog";
import { deepClone } from "@/utils";
import { tallyLocationUpdate } from "@/api/ecw/boxSea";

export default {
  name: "batchTally",
  inheritAttrs: false,
  components: { WarehouseAreaDialog },
  props: {
    tallyRows: Array,
  },
  data() {
    return {
      visible: false,
      // 储位
      storageSpaces: [],
      // 订单ID
      orderId: -1,
      // 仓位数据
      storageList: deepClone(this.tallyRows),
huhaiqing's avatar
huhaiqing committed
53 54
      // 仓库id
      warehouseId: this.$attrs.shipmentObj.startWarehouseId,
55 56
    };
  },
57 58 59
  mounted() {
    this.$refs.area.updateArea()
  },
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
  methods: {
    getTotlContent,
    // 打开储位
    openStorage(type, item) {
      if (type === "all") {
        this.orderId = -1;
      } else {
        this.orderId = item.orderId;
      }
      this.visible = true;
    },
    // 修改储位
    tallyModify() {
      // 查找数据中存在storageList的订单
      let orderLocationList = [];
      this.storageList.forEach((item) => {
        const { storageList } = item;
        if (storageList && storageList.length) {
          storageList.forEach((sItem) => {
            orderLocationList.push({
              ...sItem,
              orderId: item.orderId,
            });
          });
        }
      });

      if (orderLocationList.length === 0) {
88
        this.$message.error(this.$t("没有需要修改储位的订单"));
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 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
        return;
      }

      tallyLocationUpdate({
        shipmentId: this.$attrs.shipmentObj.id,
        orderLocationList,
      }).then((res) => {
        serviceMsg(res, this).then(() => {
          this.$emit("closeDialog", "query");
        });
      });
    },
  },
  watch: {
    storageSpaces(val) {
      let newList = [];
      const { selected = [] } = this.$refs.area;
      // 批量修改储位
      if (this.orderId === -1) {
        newList = this.storageList.map((item) => {
          item.positionNo = selected.join(",");
          item.storageList = val;
          return item;
        });
      } else {
        newList = this.storageList.map((item) => {
          if (item.orderId === this.orderId) {
            item.positionNo = selected.join(",");
            item.storageList = val;
          }
          return item;
        });
      }

      this.storageList = newList;
    },
  },
};
</script>

<style lang="scss">
.shipping-batchTally {
  .el-scrollbar__wrap {
    max-height: 500px;
    .tally-list {
      .tally-detail {
        display: flex;
        padding: 10px 0px;
        border-bottom: 1px solid rgb(223, 230, 236);

        .status-number {
          width: 26px;
          height: 26px;
          border: 1px solid #ccc;
          border-radius: 50%;
          display: flex;
          align-items: center;
          justify-content: center;
          margin-right: 20px;
        }

        .detail-info {
          > div {
            height: 30px;
            line-height: 30px;
          }

          .detail-modify {
            display: flex;
            align-items: center;
            > :first-child {
              width: 150px;
              white-space: nowrap;
              overflow: hidden;
              text-overflow: ellipsis;
              margin-right: 10px;
            }
          }
        }
      }

      > .tally-detail:last-child {
        border-bottom: none;
      }
    }
  }
}
</style>