index.vue 5.1 KB
Newer Older
huhaiqing's avatar
huhaiqing committed
1 2
<template>
  <div>
huhaiqing's avatar
huhaiqing committed
3
    <el-form ref="cabinetForm" :rules="rules" :model="cabinetObj" label-width="80px">
4 5
      <el-form-item :label="$t('到仓时间')">
        <el-date-picker type="datetime" :placeholder="$t('请选择日期')" v-model="cabinetObj.ldInWarehouseTime" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
huhaiqing's avatar
huhaiqing committed
6
      </el-form-item>
7 8
      <el-form-item :label="$t('仓库')">
        <el-select v-model="cabinetObj.ldWarehouseType" :placeholder="$t('请选择仓库')" filterable>
huhaiqing's avatar
huhaiqing committed
9
          <el-option v-for="warehouse in $attrs.warehouseList" :key="warehouse.id" :label="$l(warehouse,'title')" :value="warehouse.id"></el-option>
huhaiqing's avatar
huhaiqing committed
10 11
        </el-select>
      </el-form-item>
12 13
      <el-form-item :label="$t('装柜时间')" prop="ldBoxTime">
        <el-date-picker type="datetime" :placeholder="$t('请选择日期')" v-model="cabinetObj.ldBoxTime" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
huhaiqing's avatar
huhaiqing committed
14
      </el-form-item>
15 16
      <el-form-item :label="$t('出仓时间')">
        <el-date-picker type="datetime" :placeholder="$t('请选择日期')" v-model="cabinetObj.ldOutWarehouseTime" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
huhaiqing's avatar
huhaiqing committed
17
      </el-form-item>
18
      <el-form-item :label="$t('装柜图片')">
huhaiqing's avatar
huhaiqing committed
19
        <ImageUpload :limit="1" :isShowTip=false v-model="cabinetObj.ldPictures" />
huhaiqing's avatar
huhaiqing committed
20 21 22 23
      </el-form-item>
    </el-form>

    <!-- 开始装柜 -->
24
    <el-dialog :title="$t('开始装柜')" :visible.sync="dialogVisible" fullscreen :modal-append-to-body=false append-to-body>
25
      <startPacking v-bind="$attrs" v-if="dialogVisible" v-on="$listeners" @closeDialog1="closeDialog1" />
huhaiqing's avatar
huhaiqing committed
26 27 28 29
    </el-dialog>

    <!-- 操作 -->
    <el-row class="operate-button">
30 31 32 33
      <el-button type="primary" @click="onSubmit(1)">{{$t('保存')}}</el-button>
      <el-button type="success" @click="onSubmit(2)" :disabled="isSeal">{{$t('封柜')}}</el-button>
      <el-button @click="cancel">{{$t('关闭')}}</el-button>
      <el-button type="danger" @click="startCabinet" :disabled="isStartCabinet">{{$t('开始装柜')}}</el-button>
huhaiqing's avatar
huhaiqing committed
34 35 36 37 38 39
    </el-row>
  </div>
</template>

<script>
import startPacking from "./startPacking.vue";
huhaiqing's avatar
huhaiqing committed
40 41
import { cabinetCreate } from "@/api/ecw/boxSea";
import { formatDateStr, serviceMsg } from "../../utils";
huhaiqing's avatar
huhaiqing committed
42
import ImageUpload from "@/components/ImageUpload";
huhaiqing's avatar
huhaiqing committed
43 44 45 46 47 48

/**
 * 装柜
 */
export default {
  name: "cabinet",
huhaiqing's avatar
huhaiqing committed
49
  inheritAttrs: false,
huhaiqing's avatar
huhaiqing committed
50
  components: { startPacking, ImageUpload },
huhaiqing's avatar
huhaiqing committed
51 52 53 54 55
  data() {
    return {
      // 弹窗
      dialogVisible: false,
      // 装柜对象
huhaiqing's avatar
huhaiqing committed
56
      cabinetObj: {},
huhaiqing's avatar
huhaiqing committed
57 58
      // 校验
      rules: {
huhaiqing's avatar
huhaiqing committed
59 60 61
        ldBoxTime: [
          { required: true, message: this.$t("必填"), trigger: "change" },
        ],
huhaiqing's avatar
huhaiqing committed
62 63 64
      },
    };
  },
huhaiqing's avatar
huhaiqing committed
65 66 67 68 69 70 71 72
  created() {
    const voName = this.$attrs.currNode.voName;
    let oldData = { ...this.$attrs.shipmentObj[voName] };
    oldData = formatDateStr(oldData, [
      "ldInWarehouseTime",
      "ldBoxTime",
      "ldOutWarehouseTime",
    ]);
huhaiqing's avatar
huhaiqing committed
73 74 75 76 77 78 79 80 81

    let pictures = oldData.ldPictures;
    if (oldData.ldPictures) {
      pictures = JSON.parse(oldData.ldPictures);
      if (Array.isArray(pictures)) {
        pictures = pictures.map((item) => item.url).join(",");
      }
    }

huhaiqing's avatar
huhaiqing committed
82 83 84 85
    this.cabinetObj = {
      ...oldData,
      ldWarehouseType:
        oldData.ldWarehouseType === 0 ? undefined : oldData.ldWarehouseType,
huhaiqing's avatar
huhaiqing committed
86
      ldPictures: pictures,
huhaiqing's avatar
huhaiqing committed
87
    };
huhaiqing's avatar
huhaiqing committed
88
  },
huhaiqing's avatar
huhaiqing committed
89 90
  methods: {
    /** 提交 */
huhaiqing's avatar
huhaiqing committed
91
    onSubmit(operateType) {
huhaiqing's avatar
huhaiqing committed
92 93
      this.$refs["cabinetForm"].validate((valid) => {
        if (valid) {
huhaiqing's avatar
huhaiqing committed
94 95 96 97
          if (operateType === 2) {
            const { currNode, shipmentObj } = this.$attrs;
            const status = shipmentObj[currNode.keyName];
            if (status !== 46) {
98
              this.$message.error(this.$t("请先进行装柜->审批->确认封柜"));
huhaiqing's avatar
huhaiqing committed
99 100 101
              return;
            }
          }
huhaiqing's avatar
huhaiqing committed
102 103
          const { ldPictures } = this.cabinetObj;
          let pictures = ldPictures?.split(",") ?? [];
huhaiqing's avatar
huhaiqing committed
104 105 106 107 108 109 110 111 112
          let newPictures = [];
          for (const item of pictures) {
            if (item) {
              newPictures.push({
                type: "image",
                url: item,
              });
            }
          }
huhaiqing's avatar
huhaiqing committed
113

huhaiqing's avatar
huhaiqing committed
114 115 116
          cabinetCreate({
            shipmentId: this.$attrs.shipmentObj.id,
            ...this.cabinetObj,
huhaiqing's avatar
huhaiqing committed
117
            ldPictures: newPictures.length ? JSON.stringify(newPictures) : "",
huhaiqing's avatar
huhaiqing committed
118 119
            operateType,
          }).then((res) => {
huhaiqing's avatar
huhaiqing committed
120 121 122
            serviceMsg(res, this).then(() => {
              this.cancel("submit");
            });
huhaiqing's avatar
huhaiqing committed
123
          });
huhaiqing's avatar
huhaiqing committed
124 125 126
        }
      });
    },
127
    closeDialog1(type) {
huhaiqing's avatar
huhaiqing committed
128 129 130
      this.dialogVisible = false;
      if (type) this.cancel(type);
    },
huhaiqing's avatar
huhaiqing committed
131
    /** 取消 */
huhaiqing's avatar
huhaiqing committed
132 133
    cancel(type) {
      this.$emit("closeDialog", type);
huhaiqing's avatar
huhaiqing committed
134 135 136 137 138 139
    },
    /** 开始装柜 */
    startCabinet() {
      this.dialogVisible = true;
    },
  },
140 141
  computed: {
    isStartCabinet() {
huhaiqing's avatar
huhaiqing committed
142 143 144 145 146
      const { currNode, shipmentObj } = this.$attrs;
      const status = shipmentObj[currNode.keyName];
      return [46, 47].includes(status) ? true : false;
    },
    isSeal() {
147 148
      const { currNode, shipmentObj } = this.$attrs;
      const status = shipmentObj[currNode.keyName];
149
      return status === 47 ? true : false;
150 151
    },
  },
huhaiqing's avatar
huhaiqing committed
152 153 154 155 156
};
</script>

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