<template>
  <div>
    <!-- 选择仲裁方式页面 -->
    <el-dialog
      title="审核仲裁方式"
      :visible="showchoosetrialmethod"
      width="500px"
      @close="cancel"
      :destroy-on-close="true"
    >
        <div v-show="choosetrialmethodata.arbitraMethodIssame!=2">
          <el-descriptions>
            <el-descriptions-item label="当前仲裁方式：">
              <el-tag size="small">{{
                choosetrialmethodata.arbitratMethodName
              }}</el-tag>
            </el-descriptions-item>
          </el-descriptions>

          <!-- <div class="radiobox">
            <el-radio-group v-model="radio">
              <el-radio :label="0">拒绝开庭方式</el-radio>
              <el-radio :label="1">同意开庭方式</el-radio>
            </el-radio-group>
          </div> -->

          <!-- <div slot="footer" class="dialog-footer">
            <el-button type="primary" @click="submitForm" class="endbutton"
              ><span>提 交</span></el-button
            >
            <el-button @click="cancel" class="endbutton1"
              ><span> 取 消</span></el-button
            >
          </div> -->
            <div slot="footer" class="dialog-footer">
              <el-button type="primary" @click="submitForm(1)" class="endbutton"
                ><span>同 意</span></el-button
              >
              <el-button class="endbutton1" @click="submitForm(0)"
                ><span>拒 绝</span></el-button
              >
          </div>
        </div>
        <div v-show="choosetrialmethodata.arbitraMethodIssame==2">
          <el-descriptions>
            <el-descriptions-item label="当前案件开庭方式">{{choosetrialmethodata.arbitratMethodIllustrate}}</el-descriptions-item>
          </el-descriptions>
          <el-form :model="form" :rules="rules" ref="form">
            <el-form-item label="选择开庭方式"  prop="arbitratMethod">
                <el-radio-group v-model="form.arbitratMethod">
                  <el-radio :label=2>书面审理</el-radio>
                  <el-radio :label=1>开庭审理</el-radio>
                </el-radio-group>
            </el-form-item>
            <el-form-item>
              <el-button type="primary"  @click="determine(2)" :loading="loadingSubmit">确定</el-button>
              <el-button @click="cancel">取消</el-button>
            </el-form-item>
          </el-form>
        </div>
    </el-dialog>
  </div>
</template>

<script>
import { arbitrateMethod } from "@/api/caseManagement/caseManagement.js";
export default {
  name: "showchoosetrialmethodDialog",
  props: ["showchoosetrialmethod", "choosetrialmethodata", "queryParams"],
  data() {
    return {
      form:{},
      loadingSubmit: false,
      rules:{
        arbitratMethod: [
            { required: true, message: '请选择开庭方式', trigger: 'change' }
          ]
      }
    };
  },
  methods: {
    // 审核仲裁方式 arbitrateMethod
    submitForm(val) {
      let paramsdata = {
        opinion: val
      };
      let id = {
        id: this.choosetrialmethodata.id,
        arbitratMethod:this.choosetrialmethodata.arbitratMethod
      };
      arbitrateMethod(paramsdata,id)
        .then((res) => {
          this.$modal.msgSuccess("提交成功");
          this.cancel();
          this.$emit("getcaseApply", this.queryParams);
        })
        .catch((err) => {});
    },
    determine(val){
       this.$refs["form"].validate((valid) => {
          if (valid) {
            this.loadingSubmit = true;
            let paramsdata = {
              opinion: val,
              arbitratMethod:this.form.arbitratMethod
            };
            let id = {
            id: this.choosetrialmethodata.id,
          };
          arbitrateMethod(paramsdata,id)
            .then((res) => {
              this.$modal.msgSuccess("提交成功");
              this.cancel();
              this.$emit("getcaseApply", this.queryParams);
              this.loadingSubmit = false;
            })
            .catch((err) => {
              this.loadingSubmit = false;
            });
          } else {
            return false;
          }
        });
    },
    cancel() {
      this.$emit("cancelshowchoosetrialMethod");
    },
  },
};
</script>

<style lang="scss" scoped>
.radiobox {
  margin-left: 5%;
}
::v-deep .el-dialog {
  width: 800px;
  background: #ffffff;
  border-radius: 20px;
}
.endbutton {
  width: 124px;
  height: 37px;
  background: #0072ff;
  border-radius: 19px;
  span {
    width: 32px;
    height: 15px;
    font-size: 16px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #ffffff;
    // line-height: 48px;
  }
}
.endbutton1 {
  width: 124px;
  height: 37px;
  background: #ffffff;
  border: 1px solid #d0d0d0;
  border-radius: 19px;
  span {
    width: 31px;
    height: 13px;
    font-size: 16px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #959595;
  }
}
</style>