<template>
  <div>
    <!-- 组庭详情页面 -->
    <el-dialog
      title="组庭详情"
      :visible="showDetails"
      width="1000px"
      @close="cancel"
    >
      <!-- <el-form ref="form" label-width="150px" disabled>
        <el-row>
          <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="name">
              <el-input v-model="formData.name" 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="registerDate">
              <el-date-picker
                v-model="formData.registerDate"
                type="datetime"
                placeholder="立案日期"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="开庭日期：" prop="hearDate">
              <el-date-picker
                v-model="formData.hearDate"
                type="datetime"
                placeholder="开庭日期"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
          案件仲裁员
          <el-col :span="12">
            <el-form-item label="案件仲裁员：" prop="caseArbitrator">
              <el-input
                v-model="formData.caseArbitrator"
                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-row>
      </el-form> -->
      <!-- 案件信息 -->
      <el-form
        ref="form"
        :model="formData"
        label-width="150px"
        :disabled="true"
      >
        <p>案件信息：</p>
        <el-divider></el-divider>
        <el-row>
          <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="caseSubjectAmount">
              <el-input
                v-model="formData.caseSubjectAmount"
                placeholder="请输入案件标的"
              />
            </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="contractNumber">
              <el-input
                v-model="formData.contractNumber"
                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="claimInterestOwed">
              <el-input
                v-model="formData.claimInterestOwed"
                placeholder="请输入"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="申请人主张违约金：" prop="claimLiquidDamag">
              <el-input
                v-model="formData.claimLiquidDamag"
                placeholder="请输入"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item
              label="申请人案件证据资料上传："
              prop="applicantEvidence"
            >
              <el-upload
                class="upload-demo"
                action="https://jsonplaceholder.typicode.com/posts/"
                :on-preview="handlePreview"
                :on-remove="handleRemove"
                :before-remove="beforeRemove"
                multiple
                :limit="3"
                :on-exceed="handleExceed"
                :file-list="fileList"
              >
                <el-button size="small" type="primary">点击上传</el-button>
                <div slot="tip" class="el-upload__tip">
                  只能上传jpg/png文件，且不超过500kb
                </div>
              </el-upload>
            </el-form-item>
          </el-col>
          <!-- 仅详情展示 -->
          <el-col :span="12">
            <el-form-item
              label="被申请人案件证据资料上传："
              prop="respondentEvidence"
            >
              <el-upload
                class="upload-demo"
                action="https://jsonplaceholder.typicode.com/posts/"
                :on-preview="handlePreview"
                :on-remove="handleRemove"
                :before-remove="beforeRemove"
                multiple
                :limit="3"
                :on-exceed="handleExceed"
                :file-list="fileList"
              >
                <el-button size="small" type="primary">点击上传</el-button>
                <div slot="tip" class="el-upload__tip">
                  只能上传jpg/png文件，且不超过500kb
                </div>
              </el-upload>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <!-- 申请人主体信息 -->
      <el-form ref="form2" :model="form2" label-width="150px" :disabled="true">
        <div v-for="(item, index) in form2.paymentArr" :key="index">
          <div style="display: flex; justify-content: space-between">
            <p>申请人主体信息：</p>
          </div>
          <el-divider></el-divider>
          <el-row>
            <el-col :span="12">
              <el-form-item
                label="申请人姓名"
                :prop="'paymentArr.' + index + '.name'"
                :rules="[
                  {
                    required: true,
                    message: '申请人不能为空',
                    trigger: 'blur',
                  },
                ]"
              >
                <el-input v-model="item.name" placeholder="请输入" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="身份证号："
                :prop="'paymentArr.' + index + '.identityNum'"
                :rules="[
                  {
                    required: true,
                    message: '身份证号不能为空',
                    trigger: 'blur',
                  },
                ]"
              >
                <el-input v-model="item.identityNum" placeholder="请输入" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="联系电话："
                :prop="'paymentArr.' + index + '.contactTelphone'"
                :rules="[
                  {
                    required: true,
                    message: '联系电话不能为空',
                    trigger: 'blur',
                  },
                ]"
              >
                <el-input v-model="item.contactTelphone" placeholder="请输入" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="单位地址："
                :prop="'paymentArr.' + index + '.workAddress'"
                :rules="[
                  {
                    required: true,
                    message: '单位地址不能为空',
                    trigger: 'blur',
                  },
                ]"
              >
                <el-input v-model="item.workAddress" placeholder="请输入" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="单位电话："
                :prop="'paymentArr.' + index + '.workTelphone'"
                :rules="[
                  {
                    required: true,
                    message: '单位电话不能为空',
                    trigger: 'blur',
                  },
                ]"
              >
                <el-input v-model="item.workTelphone" placeholder="请输入" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="联系地址："
                :prop="'paymentArr.' + index + '.contactAddress'"
                :rules="[
                  {
                    required: true,
                    message: '联系地址不能为空',
                    trigger: 'blur',
                  },
                ]"
              >
                <el-input v-model="item.contactAddress" placeholder="请输入" />
              </el-form-item>
            </el-col>
          </el-row>
          <p>代理人信息：</p>
          <el-row>
            <el-col :span="12">
              <el-form-item
                label="姓名："
                :prop="'paymentArr.' + index + '.nameAgent'"
                :rules="[
                  {
                    required: true,
                    message: '姓名不能为空',
                    trigger: 'blur',
                  },
                ]"
              >
                <el-input v-model="item.nameAgent" placeholder="请输入" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="身份证号："
                :prop="'paymentArr.' + index + '.identityNumAgent'"
                :rules="[
                  {
                    required: true,
                    message: '身份证号不能为空',
                    trigger: 'blur',
                  },
                ]"
              >
                <el-input
                  v-model="item.identityNumAgent"
                  placeholder="请输入"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="联系电话："
                :prop="'paymentArr.' + index + '.contactTelphoneAgent'"
                :rules="[
                  {
                    required: true,
                    message: '联系电话不能为空',
                    trigger: 'blur',
                  },
                ]"
              >
                <el-input
                  v-model="item.contactTelphoneAgent"
                  placeholder="请输入"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="联系地址："
                :prop="'paymentArr.' + index + '.contactAddressAgent'"
                :rules="[
                  {
                    required: true,
                    message: '联系地址不能为空',
                    trigger: 'blur',
                  },
                ]"
              >
                <el-input
                  v-model="item.contactAddressAgent"
                  placeholder="请输入"
                />
              </el-form-item>
            </el-col>
          </el-row>
        </div>
      </el-form>
      <!-- 被申请人主体信息 -->
      <el-form ref="form3" label-width="150px" :disabled="true" :model="form3">
        <div
          v-for="(itm, index) in form3.paymentArr1"
          :key="index + form2.paymentArr.length"
        >
          <div style="display: flex; justify-content: space-between">
            <p>被申请人主体信息：</p>
          </div>
          <el-divider></el-divider>
          <el-row>
            <el-col :span="12">
              <el-form-item
                label="被申请人姓名"
                :prop="'paymentArr1.' + index + '.name'"
                :rules="[
                  {
                    required: true,
                    message: '被申请人不能为空',
                    trigger: 'blur',
                  },
                ]"
              >
                <el-input v-model="itm.name" placeholder="请输入" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="身份证号："
                :prop="'paymentArr1.' + index + '.identityNum'"
                :rules="[
                  {
                    required: true,
                    message: '身份证号不能为空',
                    trigger: 'blur',
                  },
                ]"
              >
                <el-input v-model="itm.identityNum" placeholder="请输入" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="联系电话："
                :prop="'paymentArr1.' + index + '.contactTelphone'"
                :rules="[
                  {
                    required: true,
                    message: '联系电话不能为空',
                    trigger: 'blur',
                  },
                ]"
              >
                <el-input v-model="itm.contactTelphone" placeholder="请输入" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="单位地址："
                :prop="'paymentArr1.' + index + '.workAddress'"
                :rules="[
                  {
                    required: true,
                    message: '单位地址不能为空',
                    trigger: 'blur',
                  },
                ]"
              >
                <el-input v-model="itm.workAddress" placeholder="请输入" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="单位电话："
                :prop="'paymentArr1.' + index + '.workTelphone'"
                :rules="[
                  {
                    required: true,
                    message: '单位电话不能为空',
                    trigger: 'blur',
                  },
                ]"
              >
                <el-input v-model="itm.workTelphone" placeholder="请输入" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="联系地址："
                :prop="'paymentArr1.' + index + '.contactAddress'"
                :rules="[
                  {
                    required: true,
                    message: '联系地址不能为空',
                    trigger: 'blur',
                  },
                ]"
              >
                <el-input v-model="itm.contactAddress" placeholder="请输入" />
              </el-form-item>
            </el-col>
          </el-row>
          <p>代理人信息：</p>
          <el-row>
            <el-col :span="12">
              <el-form-item
                label="姓名："
                :prop="'paymentArr1.' + index + '.nameAgent'"
                :rules="[
                  {
                    required: true,
                    message: '姓名不能为空',
                    trigger: 'blur',
                  },
                ]"
              >
                <el-input v-model="itm.nameAgent" placeholder="请输入" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="身份证号："
                :prop="'paymentArr1.' + index + '.identityNumAgent'"
                :rules="[
                  {
                    required: true,
                    message: '身份证号不能为空',
                    trigger: 'blur',
                  },
                ]"
              >
                <el-input v-model="itm.identityNumAgent" placeholder="请输入" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="联系电话："
                :prop="'paymentArr1.' + index + '.contactTelphoneAgent'"
                :rules="[
                  {
                    required: true,
                    message: '联系电话不能为空',
                    trigger: 'blur',
                  },
                ]"
              >
                <el-input
                  v-model="itm.contactTelphoneAgent"
                  placeholder="请输入"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                label="联系地址："
                :prop="'paymentArr1.' + index + '.contactAddressAgent'"
                :rules="[
                  {
                    required: true,
                    message: '联系地址不能为空',
                    trigger: 'blur',
                  },
                ]"
              >
                <el-input
                  v-model="itm.contactAddressAgent"
                  placeholder="请输入"
                />
              </el-form-item>
            </el-col>
          </el-row>
        </div>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "formateCourtdetailDaiog",
  props: ["formateListdata", "showDetails"],
  data() {
    return {
      formData: {},
      // key: value
      form2: {
        paymentArr: [
          {
            identityType: 1,
            name: "",
            identityNum: "",
            contactTelphone: "",
            workAddress: "",
            workTelphone: "",
            contactAddress: "",
            nameAgent: "",
            contactTelphoneAgent: "",
            contactAddressAgent: "",
          },
        ],
      }, //申请人主体信息
      form3: {
        paymentArr1: [
          {
            identityType: 2,
            name: "",
            identityNum: "",
            contactTelphone: "",
            workAddress: "",
            workTelphone: "",
            contactAddress: "",
            nameAgent: "",
            contactTelphoneAgent: "",
            contactAddressAgent: "",
          },
        ],
      },
      fileList:[]
    };
  },
  watch: {
    showDetails: {
      handler(val) {
        if (val) {
          this.formData = this.formateListdata;
        }
      },
    },
  },
  methods: {
    cancel() {
      this.$emit("cancelDetails");
    },
    handleRemove(file, fileList) {},
    handlePreview(file) {},
    handleExceed(files, fileList) {
      this.$message.warning(
        `当前限制选择 3 个文件，本次选择了 ${files.length} 个文件，共选择了 ${
          files.length + fileList.length
        } 个文件`
      );
    },
    beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${file.name}？`);
    },
  },
};
</script>

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