index.vue 13.9 KB
Newer Older
lanbaoming's avatar
lanbaoming committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 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 53 54 55 56 57 58 59 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 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 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 177 178 179 180 181 182 183 184 185 186 187 188 189 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 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358
<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>
            <el-descriptions-item :label="$t('自编号')">
              {{shipmentObj.selfNo}}
            </el-descriptions-item>
            <el-descriptions-item :label="$t('运输方式')">
              <dict-tag :type="DICT_TYPE.ECW_TRANSPORT_TYPE" :value="shipmentObj.transportType" />
            </el-descriptions-item>
            <el-descriptions-item :label="$t('始发地')">
              {{getCityName(shipmentObj.startWarehouseId)}}
            </el-descriptions-item>
            <el-descriptions-item :label="$t('目的地')">
              {{getCityName(shipmentObj.destWarehouseId)}}
            </el-descriptions-item>
          </el-descriptions>
        </el-card>

        <el-row style="margin-top: 15px">
          <el-row>
            <el-button size="small" type="primary" @click="()=>tallyClick('batch')">{{$t('批量理货')}}</el-button>
            <el-button size="small" type="primary" @click="()=>removeClick('batch')">{{$t('批量移出')}}</el-button>
          </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" />
              <el-table-column align="center" :label="$t('序号')" width="50" prop="tidanNum" />
              <el-table-column :label="$t('订单号')" align="center" prop="orderNo" width="200" >
                <template slot-scope="scope">
                  <div>
                    {{scope.row.orderNo}}
                  </div>
                  <div style="color:blue;fontWeight:bold;">
                    {{ scope.row.isExternalWarehouse === 1 ? ('('+$t('外部仓')+')') : ''}}
                  </div>
                  <div style="color:red;fontWeight:bold;">
                    {{ scope.row.adjustToDestWarehouseId > 0 ? ('('+$t('调仓')+')') : ''}}
                  </div>
                  <div style="display: flex;flex-wrap: wrap;" v-if="scope.row.advanceType">
                    <el-button @click="deleteSpecial(item.value,scope.row.orderId)"  size="mini" style="margin-left: 20px" type="danger" circle v-for="(item,index) in specialRendering(scope.row.advanceType)" :key="index">{{item.symbol}}</el-button>
                  </div>
                </template>
              </el-table-column>
              <el-table-column :label="$t('商品信息')" width="250px" align="center" prop="">
                <template slot-scope="{row}">
                  {{$l(row,'prodTitle')}}
                </template>
              </el-table-column>
              <el-table-column :label="$t('备案')" align="center" prop="feeType">
                <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" />
                </template>
              </el-table-column>
              <el-table-column :label="$t('报关方式')" align="center" prop="customsType">
                <template slot-scope="scope">
                  <div :class="scope.row.customsType !== 1 ? 'custom_type_red' : ''">
                    <dict-tag :type="DICT_TYPE.ECW_CUSTOMS_TYPE" :value="scope.row.customsType" />
                  </div>
                </template>
              </el-table-column>
              <el-table-column :label="$t('箱数')" align="center" prop="warehouseInInfo.cartonsNum">
                <template slot-scope="scope">
                  <el-link type="primary" @click.native="showWarehouseLogs(scope.row)">
                    {{scope.row.warehouseInInfo.cartonsNum}}
                  </el-link>
                  <div style="color:blue;fontWeight:bold;">
                    {{ scope.row.multiSpecification === true ? '(多规格)' : ''}}
                  </div>
                </template>
              </el-table-column>
              <el-table-column :label="$t('纸箱尺寸')" align="center" prop="warehouseInInfo.boxGauge">
              </el-table-column>
              <el-table-column :label="$t('体积')" align="center" prop="warehouseInInfo.volume">
              </el-table-column>
              <el-table-column :label="$t('重量')" align="center" prop="warehouseInInfo.weight">
              </el-table-column>
              <el-table-column :label="$t('数量(个)')" align="center" prop="quantity"></el-table-column>
              <el-table-column :label="$t('储位')" align="center" prop="positionNo" width="250px">
                <template slot-scope="scope">
                  {{notset(scope.row.positionNo)}}
                </template>
              </el-table-column>
              <el-table-column :label="$t('状态')" align="center" prop="tallyStatus">
                <template slot-scope="scope">
                  {{scope.row.tallyStatus === 1 ? $t('已理货') : $t('未理货')}}
                </template>
              </el-table-column>
              <el-table-column :label="$t('理货时间')" align="center" prop="tallyTime">
                <template slot-scope="scope">
                  {{formatDate(scope.row.tallyTime,'YYYY-MM-DD HH:mm:ss')}}
                </template>
              </el-table-column>
              <el-table-column :label="$t('操作')" align="center" width="160" class-name="small-padding fixed-width" fixed="right">
                <template slot-scope="scope">
                  <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>
                </template>
              </el-table-column>
            </el-table>
          </el-row>
        </el-row>

        <el-row style="margin-top: 15px" class="operate-button">
          <el-button size="small" type="primary" @click="tallyFinish">{{$t('完成理货')}}</el-button>
          <el-button size="small" @click="cancel">{{$t('取消')}}</el-button>
        </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>
    <warehouse-detail :order="order" :orderItemId="showWarehouseInItemId" v-if="showWarehouseInItemId" @close="showWarehouseInItemId=null" />
  </div>
</template>

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

export default {
  name: "tally",
  inheritAttrs: false,
  components: {
    batchTally,
    WarehouseDetail,
  },
  props: {
    shipmentObj: Object,
  },
  data() {
    return {
      showWarehouseInItemId: null,
      order: null,
      tallyList: [],
      // 理货数据
      tallyRows: [],
      // 勾选行
      selectedRows: [],
      // 弹窗配置
      dialogConfig: {
        title: "",
        dialogVisible: false,
        width: "30%",
        type: "",
        fullscreen: false,
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    // 格式化日期
    formatDate,
    //去重
    notset(string){
      if(!string) return string
      let arr = string.split(',')
      arr = arr.filter((item,index)=>{return arr.indexOf(item)==index})
      return arr.toString()
    },
    // 查询理货列表
    getList() {
      getTallyList({ shipmentId: this.shipmentObj.id }).then((res) => {
        let list = [];
        res.data.forEach((item) => {
          item.orderItemList.forEach((oItem) => {
            let warehouseInInfo = {};
            if (oItem.warehouseInInfo) {
              warehouseInInfo = JSON.parse(oItem.warehouseInInfo ?? {});
            }
            list.push({
              ...oItem,
              warehouseInInfo,
              advanceType:oItem.advanceType,
              multiSpecification: oItem.multiSpecification,
              positionNo: oItem.positionNo,
              tallyStatus: item.tallyStatus,
              tallyTime: item.tallyTime,
            });
          });
        });
        // 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;
      });
    },
    specialRendering(val){
      console.log('val', val)
      if(val !== undefined){
        let i = val.split(',')
        return this.getDictDatas(this.DICT_TYPE.ORDER_SPECIAL_NEEDS).filter(e => {
          return i.indexOf(e.value) > -1
        }).map(item => {
          // 打字开头的用最后一个字,否则取第一个字
          item.symbol = item.label[0] == '' ? item.label[item.label.length-1]: item.label[0]
          return item
        })
      }
    },
    deleteSpecial(id,orderId){
      this.$confirm(this.$t('确定删除此特需么?')).then(() => {
        return orderSpecialNeed({orderId:orderId,advanceType:id})
      }).then(() => {
        this.getList()
      })
    },
    // 选中
    checkboxSelect(selection) {
      this.selectedRows = selection;
    },
    // 理货点击
    tallyClick(type, data) {
      if (type === "batch") {
        if (this.selectedRows.length === 0) {
          this.$message.error(this.$t("请选择需要理货的订单"));
          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) {
          this.$message.error(this.$t("请选择需要移出的订单"));
          return;
        }
        orderNos = this.selectedRows.map((item) => item.orderNo);
        orderIds = this.selectedRows.map((item) => item.orderId);
      } else {
        orderNos = [data.orderNo];
        orderIds = [data.orderId];
      }

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

      this.$confirm(msgTitle, this.$t("提示"), {
        type: "warning",
      })
        .then((_) => {
          let param = {
            orderIdLIst: orderIds,
            shipmentId: this.shipmentObj.id,
          }
          tallyRemove(param).then((res) => {
            serviceMsg(res, this).then(() => {
              this.getList();
            });
          }).catch((res) => {
        if (res.code === 666) {
              this.$confirm("<div style='max-height:500px;overflow:auto'>"+res.msg+this.$t('是否需要一起移出?')+"</div>", this.$t("提示"), {
                dangerouslyUseHTMLString: true,
                distinguishCancelAndClose: true,
                confirmButtonText: '确定移出',
                cancelButtonText: '仅移出当前订单'
              })
                .then((_) => {
                  tallyRemove({ ...param, deleteType: 2 }).then((res) => {
                    serviceMsg(res, this).then(() => {
                      this.getList();
                    });
                  });
                })
                .catch(action => {
                  if(action =='cancel'){
                    tallyRemove({ ...param, deleteType: 1 }).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":
          this.$set(this.dialogConfig, "title", this.$t("批量理货"));
          this.$set(this.dialogConfig, "width", "500px");
          break;
        case "singleTally":
          this.$set(this.dialogConfig, "title", this.$t("理货确认"));
          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");
        });
      });
    },
    // 显示入仓记录
    showWarehouseLogs(row) {
      getOrder(row.orderId).then((response) => {
        this.order = response.data;
        this.showWarehouseInItemId = row.orderItemId;
      });
    },
  },
  computed: {
    /* 获取仓库 */
    getCityName() {
      return (id) => {
        let arr = this.$attrs.warehouseList.filter((item) => item.id == id);
        return arr.length > 0 ? this.$l(arr[0], "title") : this.$t("");
      };
    },
  },
};
</script>

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