<template>
  <div>
    <!-- 案件受理 -->
    <el-dialog title="案件受理" :visible="showAcceptance" @close="cancel" :destroy-on-close="true" center>
      <el-form ref="courtReviewform" :model="courtReviewform">
        <el-form-item label="被申请人是否同意调解:">
          <el-radio-group v-model="courtReviewform.agreeFlag">
            <el-radio :label="1">是</el-radio>
            <el-radio :label="0">否</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="调解方式:" v-if="courtReviewform.agreeFlag == 1">
          <el-radio-group v-model="courtReviewform.mediationMethod">
            <el-radio :label="1">线上调解</el-radio>
            <el-radio :label="2">线下调解</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="是否纸质送达:" v-if="courtReviewform.agreeFlag == 1">
          <el-radio-group v-model="courtReviewform.paperFlag">
            <el-radio :label="1">是</el-radio>
            <el-radio :label="0">否</el-radio>
          </el-radio-group>
        </el-form-item>
        <!-- <el-form-item label="是否仲裁确认:" v-if="courtReviewform.agreeFlag == 1" >
          <el-radio-group v-model="courtReviewform.arbitrateConfirm">
            <el-radio :label="1">是</el-radio>
            <el-radio :label="0">否</el-radio>
          </el-radio-group>
        </el-form-item> -->
        <el-form-item v-if="courtReviewform.agreeFlag == 0" label="拒绝理由:" prop="rejectReason" :rules="[
      {
        required: true,
        message: '拒绝理由不能为空',
        trigger: 'blur',
      },
    ]">
          <el-input v-model="courtReviewform.rejectReason" type="textarea" :rows="8" />
        </el-form-item>
      </el-form>
      <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>
    </el-dialog>
  </div>
</template>

<script>
import { accept } from '@/api/caseManagement/caseManagement.js'
export default {
  name: "caseAcceptance",
  props: ["showAcceptance", "caseAcceptanceData", "getList", "queryParams"],
  data() {
    return {
      courtReviewform: {
        mediationMethod: 2,
        paperFlag: 0,
        arbitrateConfirm: 0,
        agreeFlag: 1
      },
    };
  },
  watch: {
    showAcceptance(val) {
      if (val) {
        console.log(this.caseAcceptanceData);
        this.courtReviewform = {
          mediationMethod: 2,
          paperFlag: 0,
          arbitrateConfirm: 0,
          agreeFlag: 1
        }
      }
    },
  },
  methods: {
    submitForm() {
      this.$refs["courtReviewform"].validate((valid) => {
        if (valid) {
          let paramsdata = {
            id: this.caseAcceptanceData.id,
            caseFlowId: this.caseAcceptanceData.caseFlowId,
            batchNumber: ""
          }
          let mergeValue = Object.assign({}, this.courtReviewform, paramsdata)
          accept(mergeValue).then((res) => {
            this.$modal.msgSuccess("确认成功");
            this.$emit("getList", this.queryParams)
            this.cancel();
          })
            .catch((err) => { });
        }
      });
    },
    cancel() {
      this.$emit("cancelAcceptance");
    },
  },
};
</script>

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

.el-form-item {
  margin-left: 10%;
}

.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;
    // line-height: 48px;
  }
}

.nowarbitrator {
  margin-left: 10%;
}

::v-deep .el-form-item__error {
  left: 90px;
}
</style>