info.vue 6.71 KB
<template>
  <div style="margin: 40px">
    <el-form
      ref="form"
      :model="form"
      label-width="200px"
      size="small"
      :disabled="disable"
    >
      <el-form-item label="航班号">
        <el-input
          v-model="form.purposeOfFlightNo"
          style="width: 30%"
        ></el-input>
      </el-form-item>

      <el-row :gutter="20">
        <el-col :span="10">
          <el-form-item label="站点包含">
            <el-input
              type="textarea"
              v-model="form.location"
              :rows="6"
              resize="none"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="站点不包含">
            <el-input
              type="textarea"
              v-model="form.notLocation"
              :rows="6"
              resize="none"
            ></el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row :gutter="20">
        <el-col :span="10">
          <el-form-item label="URSA包含">
            <el-input
              type="textarea"
              v-model="form.includeUrsa"
              :rows="6"
              resize="none"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="URSA不包含">
            <el-input
              type="textarea"
              v-model="form.notIncludeUrsa"
              :rows="6"
              resize="none"
            ></el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <el-form-item label="件数">
        <el-col :span="3">
          <el-input v-model="form.minNumOfPieces"></el-input>
        </el-col>
        <el-col style="text-align: center" :span="1">-</el-col>
        <el-col :span="3">
          <el-input v-model="form.maxNumOfPieces"></el-input>
        </el-col>
      </el-form-item>

      <el-form-item label="重量">
        <el-col :span="3">
          <el-input v-model="form.minWeight"></el-input>
        </el-col>
        <el-col style="text-align: center" :span="1">-</el-col>
        <el-col :span="3">
          <el-input v-model="form.maxWeight"></el-input>
        </el-col>
      </el-form-item>

      <el-form-item label="申报类别">
        <el-checkbox-group v-model="form.typeOfGoods">
          <el-checkbox
            v-for="item in cargoType"
            :key="item.id"
            :label="item.chineseName"
            :name="item.chineseName"
          ></el-checkbox>
        </el-checkbox-group>
      </el-form-item>

      <el-form-item label="货物类型">
        <el-checkbox-group v-model="form.declarationCategory">
          <el-checkbox
            v-for="item in cargoStatus"
            :key="item.id"
            :label="item.chineseName"
            :name="item.chineseName"
          ></el-checkbox>
        </el-checkbox-group>
      </el-form-item>

      <el-form-item label="Service Code">
        <el-checkbox-group v-model="form.serviceCode">
          <el-checkbox
            v-for="item in serviceCode"
            :key="item.id"
            :label="item.englishName"
            :name="item.englishName"
          ></el-checkbox>
        </el-checkbox-group>
      </el-form-item>

      <el-form-item label="Sub Category">
        <el-checkbox-group v-model="form.subCategory">
          <el-checkbox
            v-for="item in subCategory"
            :key="item.id"
            :label="item.englishName"
            :name="item.englishName"
          ></el-checkbox>
        </el-checkbox-group>
      </el-form-item>
    </el-form>
    <el-row style="margin-left: 200px">
      <el-button
        type="primary"
        size="small"
        v-if="$route.params.handle != 'detail'"
        @click="submit"
        :loading="btnLoading"
      >
        <span v-if="$route.params.handle === 'add'">添加</span>
        <span v-else>保存</span>
      </el-button>
      <el-button size="small" @click="close">取消</el-button>
    </el-row>
  </div>
</template>

<script>
import {
  findByFlightId,
  updateOrAddFlight,
  allDictData,
} from "@/api/destinationFlight";

export default {
  data() {
    return {
      form: {
        typeOfGoods: [],
        declarationCategory: [],
        serviceCode: [],
        subCategory: [],
      },
      typeOfGoods: [],
      declarationCategory: [],
      formServiceCode: [],
      formSubCategory: [],
      cargoType: [],
      cargoStatus: [],
      serviceCode: [],
      subCategory: [],
      disable: false,
      btnLoading: false,
    };
  },
  methods: {
    submit() {
      this.btnLoading = true;
      let handle = this.$route.params.handle;
      if (handle === "update") {
        //修改,获取id
        this.form.id = this.$route.params.id;
      }

      //调用接口
      this.typeOfGoods = this.form.typeOfGoods;
      this.declarationCategory = this.form.declarationCategory;
      this.formServiceCode = this.form.serviceCode;
      this.formSubCategory = this.form.subCategory;
      updateOrAddFlight(this.form).then((response) => {
        if (response.code === 200){
          this.$message({
          message: '成功',
          type: 'success'
        });
        }
        this.btnLoading = false;
      });
      this.form.typeOfGoods = this.typeOfGoods;
      this.form.declarationCategory = this.declarationCategory;
      this.form.serviceCode = this.formServiceCode;
      this.form.subCategory = this.formSubCategory;
      
    },
    close() {
      this.$store.state.tagsView.visitedViews.splice(
        this.$store.state.tagsView.visitedViews.findIndex(
          (item) => item.path === this.$route.path
        ),
        1
      );
      this.$router.push(
        this.$store.state.tagsView.visitedViews[
          this.$store.state.tagsView.visitedViews.length - 1
        ].path
      );
    },
  },
  created() {
    let handle = this.$route.params.handle;

    allDictData().then((response) => {
      let dict = response.data;
      this.cargoType = dict.cargoType;
      this.cargoStatus = dict.cargoStatus;
      this.serviceCode = dict.serviceCode;
      this.subCategory = dict.subCategory;
    });
    if (handle === "detail") {
      this.disable = true;
    }

    if (handle != "add") {
      let id = this.$route.params.id;

      //货物信息
      findByFlightId(id).then((response) => {
        let info = response.data.list;
        info.typeOfGoods = info.typeOfGoods ? info.typeOfGoods.split(";") : [];
        info.declarationCategory = info.declarationCategory
          ? info.declarationCategory.split(";")
          : [];
        info.serviceCode = info.serviceCode ? info.serviceCode.split(";") : [];
        info.subCategory = info.subCategory ? info.subCategory.split(";") : [];
        this.form = info;
      });
    }
  },
};
</script>