dialog.vue 3.99 KB
<template>
  <el-dialog
    class="entryDialog classCUploadDialog"
    title="运抵单申报"
    :visible.sync="outerVisible"
    :show-close="false"
    width="720px"
    :close-on-click-modal="false"
    :destroy-on-close="true"
    v-loading="loadings.dialogLoading"
    @close="close(false)"
  >
    <div class="modelItem">
      <el-form
        class="fedexFormStyle"
        ref="formData"
        :model="formData"
        label-position="top"
        size="small"
      >
        <el-row :gutter="5">
          <el-col :span="8">
            <Formitem label="监管场所" prop="operatorCode" type="edit">
              <el-select
                type="text"
                id="inputInner-edit-operatorCode"
                v-model="formData.operatorCode"
                clearable
                filterable
                placeholder=""
              >
                <el-option
                  v-for="item in operatorCode"
                  :key="item.operatorCode"
                  :label="item.operatorName"
                  :value="item.operatorCode"
                ></el-option>
              </el-select>
            </Formitem>
          </el-col>

          <el-col :span="8">
            <Formitem
              label="境内运输工具编码"
              prop="domesticTrafNo"
              type="edit"
            >
              <el-input
                type="text"
                class="inputShadow"
                id="inputInner-edit-domesticTrafNo"
                resize="none"
                v-model="formData.domesticTrafNo"
                clearable
                placeholder=""
              ></el-input>
            </Formitem>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div class="dialogOption entrySave">
      <el-button
        class="entrySaveButton"
        :disabled="loadings.submitLoading"
        @click="submit"
        >确 定</el-button
      >
      <el-button class="entrySaveButton" @click="close(false)">关 闭</el-button>
    </div>
  </el-dialog>
</template>

<script>
import {
  getCurrUserOperatorCode,
  declareUpload,
} from "@/api/declareData-api.js";
export default {
  props: {
    outerVisible: {
      type: Boolean,
      default: false,
    },
    selected: {
      type: Array,
      default: () => {
        return [];
      },
    },
  },
  watch: {
    outerVisible(val) {
      if (val) {
        this.loadings.dialogLoading = false;
        this.fetchOperatorCode();
      }
    },
  },
  data() {
    return {
      formData: {
        operatorCode: "",
        domesticTrafNo: "",
      },

      loadings: {
        dialogLoading: false,
        submitLoading: false,
      },
      loadingText: "",
      operatorCode: [],
    };
  },
  methods: {
    fetchOperatorCode() {
      getCurrUserOperatorCode().then((res) => {
        if (res.code === "200") {
          this.operatorCode = res.data;
        }
      });
    },

    //数据保存
    submit() {
      this.loadings.dialogLoading = true;
      let obj = {
        ...this.formData,
        declareIds: this.selected.map((item) => item.declareId),
        type: "arrivalIn",
      };
      this.$refs.formData.validate((valid) => {
        if (valid) {
          this.addapi(obj);
        } else {
          this.loadings.dialogLoading = false;
        }
      });
    },
    //新增
    addapi(val) {
      declareUpload(val)
        .then((res) => {
          if (res.code === "200") {
            this.msgSuccess(res.message);
            this.close(true);
          } else {
            this.alertWarningMsg(res.message);
            this.loadings.dialogLoading = false;
          }
        })
        .catch((err) => {
          console.log(err);
          this.loadings.dialogLoading = false;
        });
    },

    close(flag) {
      this.formData = {
        operatorCode: "",
        domesticTrafNo: "",
      };
      this.loadings.dialogLoading = false;
      this.$emit("close", flag);
    },
  },
};
</script>

<style lang="scss" scoped>
@import "@/assets/styles/variables.scss";
</style>