<template>
  <!-- 送达裁决书页面 -->
  <div>
    <el-dialog
      title="是否确认发送裁决书"
      :visible="openMailawardDialog"
      @close="cancel"
      :destroy-on-close="true"
      center
    >
      <el-form ref="form" :model="formData" label-width="150px">
        <el-col :span="24">
          <el-form-item
            label="申请人电子邮件："
            prop="appEmail"
            :rules="[
              {
                required: true,
                message: '邮箱地址不能为空',
                trigger: 'blur',
              },
              {
                pattern:
                  /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/,
                message: '请输入正确的邮箱地址',
                trigger: 'blur',
              },
            ]"
          >
            <el-input
              v-model="formData.appEmail"
              placeholder="请输入电子邮件"
            />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item
            label="被申请人电子邮件："
            prop="resEmail"
            :rules="[
              {
                required: true,
                message: '邮箱地址不能为空',
                trigger: 'blur',
              },
              {
                pattern:
                  /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/,
                message: '请输入正确的邮箱地址',
                trigger: 'blur',
              },
            ]"
          >
            <el-input
              v-model="formData.resEmail"
              placeholder="请输入电子邮件"
            />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item
            label="申请人快递单号："
            prop="apptrackingNum"
            :rules="[
              {
                required: true,
                message: '快递单号不能为空',
                trigger: 'blur',
              },
            ]"
          >
            <el-input
              v-model="formData.apptrackingNum"
              placeholder="请输入快递单号"
            />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item
            label="被申请人快递单号："
            prop="restrackingNum"
            :rules="[
              {
                required: true,
                message: '快递单号不能为空',
                trigger: 'blur',
              },
            ]"
          >
            <el-input
              v-model="formData.restrackingNum"
              placeholder="请输入快递单号"
            />
          </el-form-item>
        </el-col>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button type="" @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { adjudicationDelivery } from "@/api/awardManagement/awardManagement";
export default {
  props: ["openMailawardDialog", "mailawardata"],
  data() {
    return {
      formData: {},
    };
  },
  mounted () {
    this.formData = {};
  },
  methods: {
    submitForm() {
      // adjudicationDelivery
      this.$refs["form"].validate((valid) => {
        if (valid) {
          adjudicationDelivery({
            id: this.mailawardata.id,
            ...this.formData,
          })
            .then((res) => {
              if (res.code == 200) {
                this.$emit("updataList");
                this.cancel();
              }
            })
            .catch((err) => {});
        }
      });
    },
    cancel() {
      this.$emit("closeMailaward");
    },
  },
};
</script>

<style lang="scss" scoped>
::v-deep .el-dialog {
  width: 550px;
  background: #ffffff;
  border-radius: 20px;
}
</style>