<template>
  <div>
    <el-dialog
      title="书面审理"
      :visible="showadjudicaterecord"
      width="1000px"
      @close="cancel"
      :destroy-on-close="true"
    >
      <el-form
        ref="form"
        :model="formData"
        label-width="150px"
        :disabled="true"
      >
        <p>案件信息：</p>
        <el-divider></el-divider>
        <el-col :span="12">
          <el-form-item label="案件编号：" prop="caseNum">
            <el-input v-model="formData.caseNum" placeholder="请输入案件编号" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="申请人：" prop="caseNum">
            <el-input v-model="formData.caseNum" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="被申请人：" prop="caseNum">
            <el-input v-model="formData.caseNum" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="借款开始日期：" prop="loanStartDate">
            <el-date-picker
              v-model="formData.loanStartDate"
              type="datetime"
              placeholder="借款开始日期"
            >
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="借款结束日期：" prop="loanEndDate">
            <el-date-picker
              v-model="formData.loanEndDate"
              type="datetime"
              placeholder="借款结束日期"
            >
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="案件标的：" prop="caseSubjectAmount">
            <el-input
              v-model="formData.caseSubjectAmount"
              placeholder="请输入案件标的"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="逾期天数：" prop="caseSubjectAmount">
            <el-input
              v-model="formData.caseSubjectAmount"
              placeholder="请输入逾期天数"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="仲裁费用：" prop="caseSubjectAmount">
            <el-input
              v-model="formData.caseSubjectAmount"
              placeholder="请输入仲裁费用"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="申请人主张欠本金：" prop="claimPrinciOwed">
            <el-input v-model="formData.claimPrinciOwed" placeholder="请输入" />
          </el-form-item>
        </el-col>
        <!-- <el-col :span="12">
          <el-form-item label="案件顾问：" prop="claimPrinciOwed">
            <el-input v-model="formData.claimPrinciOwed" placeholder="请输入" />
          </el-form-item>
        </el-col> -->
        <el-col :span="12">
          <el-form-item label="案件状态：" prop="caseStatus">
            <el-input v-model="formData.caseStatus" placeholder="请输入" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="仲裁员：" prop="claimPrinciOwed">
            <el-input v-model="formData.claimPrinciOwed" placeholder="请输入" />
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="开庭日期：" prop="loanEndDate">
            <el-date-picker
              v-model="formData.loanEndDate"
              type="datetime"
              placeholder="开庭日期"
            >
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="案件资料：" prop="claimPrinciOwed">
            <el-input v-model="formData.claimPrinciOwed" placeholder="请输入" />
          </el-form-item>
        </el-col>
      </el-form>
      <el-form ref="form2" :model="form2" label-width="150px">
        <el-col :span="24">
          <el-form-item
            label="案情描述："
            prop="accidentDescription"
            :rules="[
              {
                required: true,
                message: '请进行案情描述',
                trigger: 'blur',
              },
            ]"
          >
            <el-input
              type="textarea"
              autosize
              placeholder="请进行案情描述"
              v-model="form2.accidentDescription"
            >
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item
            label="仲裁结果："
            prop="arbitrationResult"
            :rules="[
              {
                required: true,
                message: '请输入仲裁结果',
                trigger: 'blur',
              },
            ]"
          >
            <el-input
              type="textarea"
              autosize
              placeholder="请输入仲裁结果"
              v-model="form2.arbitrationResult"
            >
            </el-input>
          </el-form-item>
        </el-col>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">提交仲裁结果</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { writtenHear } from "@/api/caseManagement/caseManagement.js";

export default {
  props: ["showadjudicaterecord", "form"],
  data() {
    return {
      formData: {},
      form2: {},
    };
  },
  watch: {
    showadjudicaterecord: {
      handler(val) {
        if (val) {
          this.formData = this.form;
          this.form2 = {};
        }
      },
    },
  },
  methods: {
    submitForm() {
      this.$refs["form2"].validate((valid) => {
        if (valid) {
          writtenHear(
            {
              accidentDescription: this.form2.accidentDescription,
              arbitrationResult: this.form2.arbitrationResult,
            },
            { id: this.formData.id }
          )
            .then((res) => {
              this.$modal.msgSuccess("提交成功");
              this.cancel();
              this.$emit("getcaseApply");
            })
            .catch((err) => {});
        }
      });
    },
    cancel() {
      this.$emit("canceladjudicaterecord");
    },
  },
};
</script>

<style lang="scss" scoped>
</style>