<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="请输入电子邮件"
              disabled
            />
          </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="请输入电子邮件"
              disabled
            />
          </el-form-item>
        </el-col>
        <!-- <el-col :span="24">
          <el-form-item
            label="申请人快递单号："
            prop="apptrackingNum"
          >
            <el-input
              v-model="formData.apptrackingNum"
              placeholder="请输入快递单号"
            />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item
            label="被申请人快递单号："
            prop="restrackingNum"
          >
            <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, adjudicationService } from "@/api/awardManagement/awardManagement";
export default {
  props: ["openMailawardDialog", "mailawardata", "emailobj"],
  data() {
    return {
      formData: this.emailobj,
    };
  },
  watch: {
    emailobj: {
      handler(val) {
        if (val) {
          this.formData = this.emailobj
        }
      },
    },
  },
  methods: {
    submitForm() {
      // adjudicationDelivery
      this.$refs["form"].validate((valid) => {
        if (valid) {
          // adjudicationDelivery({
            delete this.formData.id
            delete this.formData.apptrackingNum
            delete this.formData.restrackingNum
          adjudicationService({
            id: this.mailawardata.id,
            ...this.formData,
          })
            .then((res) => {
              if (res.code == 200) {
                this.$modal.msgSuccess("提交成功");
                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>