index.vue 3.82 KB
Newer Older
zhoutong's avatar
zhoutong committed
1 2 3 4 5 6 7 8 9 10 11
<template>
  <div>
    <el-form ref="unloadingForm" :model="unloadingObj" label-width="100px">
      <el-form-item :label="$t('网点')">
        <el-select filterable v-model="unloadingObj.ulOutletsId" clearable :placeholder="$t('请选择')">
          <el-option v-for="node in nodes" :key="node.id" :label="$l(node, 'title')" :value="node.id"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item :label="$t('到仓时间')">
        <el-date-picker type="datetime" :placeholder="$t('请选择日期')" v-model="unloadingObj.ulWarehouseTime" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
      </el-form-item>
12
<!--      <el-form-item :label="$t('卸柜时间')">
zhoutong's avatar
zhoutong committed
13
        <el-date-picker type="datetime" :placeholder="$t('请选择日期')" v-model="unloadingObj.ulBoxTime" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
14
      </el-form-item> -->
zhoutong's avatar
zhoutong committed
15 16 17 18 19 20
    </el-form>

    <el-row class="operate-button">
      <el-button type="primary" @click="onSubmit(1)">{{$t('保存')}}</el-button>
      <el-button type="success" @click="onSubmit(2)">{{$t('提交')}}</el-button>
      <el-button @click="cancel">{{$t('关闭')}}</el-button>
21
      <el-button type="danger" @click="startUnloading" :disabled="isStartUnloading">{{$t('到仓')}}</el-button>
zhoutong's avatar
zhoutong committed
22 23 24
    </el-row>

    <!-- 开始卸柜 -->
25
    <el-dialog :title="$t('到仓')" :visible.sync="dialogVisible" fullscreen :modal-append-to-body=false append-to-body>
zhoutong's avatar
zhoutong committed
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
      <startUnloading v-if="dialogVisible" v-bind="$attrs" @closeStart="closeStart" />
    </el-dialog>
  </div>
</template>

<script>
import startUnloading from "./startUnloading.vue";
import { unloadCreate } from "@/api/ecw/boxSea";
import { formatDateStr, serviceMsg } from "../../utils";
import { getNodePage } from "@/api/ecw/node";

/**
 * 卸柜
 */
export default {
  name: "unloading",
  inheritAttrs: false,
  components: { startUnloading },
  data() {
    return {
      // 清关对象
      unloadingObj: {},
      // 弹窗状态
      dialogVisible: false,
      nodes: [],
    };
  },
  created() {
    const voName = this.$attrs.currNode.voName;
    let oldData = { ...this.$attrs.shipmentObj[voName] };
    oldData = formatDateStr(oldData, ["ulWarehouseTime", "ulBoxTime"]);
    this.unloadingObj = oldData;
    // 进入卸柜,仓库给了默认值为0,并且底下显示无匹配数据。应该默认为空,让手动去选择
    if(this.unloadingObj.ulOutletsId === 0) this.unloadingObj.ulOutletsId = ''
    getNodePage({ pageNo: 1, pageSize: 1000, status: 0 }).then((res) => {
      const { data } = res;
      this.nodes = data?.list ?? [];
    });
  },
  methods: {
    /** 提交 */
    onSubmit(operateType) {
      this.$refs["unloadingForm"].validate((valid) => {
        if (valid) {
          if (operateType === 2) {
            const { keyName } = this.$attrs.currNode;
            const ulStatus = this.$attrs.shipmentObj[keyName];
            if (ulStatus !== 185) {
              this.$message.error(this.$t("请先通过卸柜审批"));
              return;
            }
          }
          unloadCreate({
            ...this.unloadingObj,
            shipmentId: this.$attrs.shipmentObj.id,
            operateType,
          }).then((res) => {
            serviceMsg(res, this).then(() => {
              this.cancel("submit");
            });
          });
        }
      });
    },
    /** 取消 */
    cancel(type) {
      this.$emit("closeDialog", type);
    },
    /* 关闭弹窗 */
    closeStart(type) {
      this.dialogVisible = false;
      if (type) this.cancel(type);
    },
    // 开始卸柜
    startUnloading() {
      this.dialogVisible = true;
    },
  },
  computed: {
    isStartUnloading() {
      const { currNode, shipmentObj } = this.$attrs;
      const status = shipmentObj[currNode.keyName];
      return status === 186 ? true : false;
    },
  },
};
</script>

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