ship.vue 2.26 KB
Newer Older
huhaiqing's avatar
huhaiqing committed
1 2
<template>
  <div>
huhaiqing's avatar
huhaiqing committed
3
    <el-form ref="shipForm" :model="shipObj" :rules="rules" label-width="80px">
4
      <el-form-item :label="$t('状态')" prop="saExmtStatus">
huhaiqing's avatar
huhaiqing committed
5
        <el-radio-group v-model="shipObj.saExmtStatus">
huhaiqing's avatar
huhaiqing committed
6 7 8
          <el-radio v-for="item in status" :key="item.value" :label="item.value">{{item.label}}</el-radio>
        </el-radio-group>
      </el-form-item>
9 10
      <el-form-item :label="$t('配船时间')" v-show="shipObj.saExmtStatus === '2'">
        <el-date-picker type="datetime" :placeholder="$t('请选择日期')" v-model="shipObj.configTime" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
huhaiqing's avatar
huhaiqing committed
11 12 13 14
      </el-form-item>
    </el-form>

    <el-row class="operate-button">
15 16 17
      <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>
huhaiqing's avatar
huhaiqing committed
18 19 20 21 22
    </el-row>
  </div>
</template>

<script>
huhaiqing's avatar
huhaiqing committed
23 24 25 26 27 28 29
import { shipConfigure } from "@/api/ecw/boxSea";
import {
  formatNumberString,
  formatDateStr,
  constantDict,
  serviceMsg,
} from "../utils";
huhaiqing's avatar
huhaiqing committed
30 31 32 33 34
/**
 * 配船
 */
export default {
  name: "ship",
huhaiqing's avatar
huhaiqing committed
35
  inheritAttrs: false,
huhaiqing's avatar
huhaiqing committed
36 37 38
  props: {
    shipmentObj: Object,
  },
huhaiqing's avatar
huhaiqing committed
39 40 41 42 43
  data() {
    return {
      // 配船对象
      shipObj: {},
      // 状态
huhaiqing's avatar
huhaiqing committed
44
      status: constantDict.saExmtStatus,
huhaiqing's avatar
huhaiqing committed
45 46
      // 校验
      rules: {
47
        saExmtStatus: [{ required: true, message: this.$t("必填"), trigger: "change" }],
huhaiqing's avatar
huhaiqing committed
48
      },
huhaiqing's avatar
huhaiqing committed
49 50
    };
  },
huhaiqing's avatar
huhaiqing committed
51 52 53 54
  created() {
    const voName = this.$attrs.currNode.voName;
    let oldData = { ...this.shipmentObj[voName] };
    oldData = formatNumberString(oldData, ["saExmtStatus"]);
huhaiqing's avatar
huhaiqing committed
55
    oldData = formatDateStr(oldData, ["configTime"]);
huhaiqing's avatar
huhaiqing committed
56 57
    this.shipObj = oldData;
  },
huhaiqing's avatar
huhaiqing committed
58 59
  methods: {
    /** 提交 */
huhaiqing's avatar
huhaiqing committed
60
    onSubmit(operateType) {
huhaiqing's avatar
huhaiqing committed
61 62
      this.$refs["shipForm"].validate((valid) => {
        if (valid) {
huhaiqing's avatar
huhaiqing committed
63 64 65 66 67 68
          shipConfigure({
            operateType,
            shipmentId: this.shipmentObj.id,
            ...this.shipObj,
          }).then((res) => {
            serviceMsg(res, this).then(() => {
huhaiqing's avatar
huhaiqing committed
69
              this.cancel("submit");
huhaiqing's avatar
huhaiqing committed
70 71
            });
          });
huhaiqing's avatar
huhaiqing committed
72 73 74 75
        }
      });
    },
    /** 取消 */
huhaiqing's avatar
huhaiqing committed
76 77
    cancel(type) {
      this.$emit("closeDialog", type);
huhaiqing's avatar
huhaiqing committed
78 79 80 81 82 83 84
    },
  },
};
</script>

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