<template>
  <div>
    <!-- 案件信息 -->
    <el-form ref="form" :model="formData" label-width="180px" 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="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="feePayable">
            <el-input v-model="formData.feePayable" placeholder="请输入" />
          </el-form-item>
        </el-col>
        <!-- 申请人仲裁诉求 -->
        <el-col :span="24">
          <el-form-item label="申请人仲裁诉求" prop="arbitratClaims">
            <el-input
              v-model="formData.arbitratClaims"
              placeholder="请输入申请人仲裁诉求"
              type="textarea"
              :autosize="{ minRows: 4, maxRows: 8 }"
            />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="申请人案件证据资料：">
            <!-- <div v-for="(item, index) in applicateArr" :key="index">
              <a href="#" @click="toFile(item, index)" style="color: blue">
                {{ item.annexName }}
              </a>
            </div> -->
            <p
              @click="toFile(index, 2)"
              v-for="(item, index) in applicantFileArr"
              :key="index"
            >
              <a href="#">{{ item }}</a>
            </p>
          </el-form-item>
        </el-col>
        <!-- 仅详情展示 案件质证环节以后显示被申请人证据-->
        <el-col :span="24">
          <el-form-item
            label="被申请人案件证据资料："
            prop="respondentEvidence"
          >
            <!-- <div v-for="(item, index) in quiltArr" :key="index">
              <a href="#" @click="toFile1(item, index)" style="color: blue">
                {{ item.annexName }}
              </a>
            </div> -->
            <p
              v-for="(item, index) in respondentFileArr"
              :key="index"
              @click="toFile(index, 6)"
            >
              <a href="#">{{ item }}</a>
            </p>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="裁决书附件：">
            <p
              v-for="(item, index) in awardFileArr"
              :key="index"
              @click="toFile(index, 3)"
            >
              <a href="#">{{ item }}</a>
            </p>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <!-- 申请人主体信息 -->
    <el-form ref="form2" :model="form2" label-width="150px" disabled>
      <div v-for="(item, index) in form2.paymentArr" :key="index">
        <div style="display: flex; justify-content: space-between">
          <div style="display: inline-flex">
            <div class="infoIcon"></div>
            <div class="caseInfo">申请人主体信息：</div>
          </div>
        </div>
        <el-divider></el-divider>
        <el-row>
          <el-col :span="12">
            <el-form-item
              label="申请人(机构)："
              :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="代码：">
              <el-input v-model="item.identityNum" placeholder="请输入" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item
              label="联系电话："
              :rules="[
                {
                  required: true,
                  message: '联系电话不能为空',
                  trigger: 'blur',
                },
                {
                  pattern: /^[1][3,4,5,6,7,8,9][0-9]{9}$/,
                  message: '请输入正确的手机号码',
                  trigger: 'blur',
                },
              ]"
            >
              <el-input v-model="item.contactTelphone" placeholder="请输入" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item
              label="单位地址："
              :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="单位电话："
              :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="联系地址："
              :rules="[
                {
                  required: true,
                  message: '联系地址不能为空',
                  trigger: 'blur',
                },
              ]"
            >
              <el-input v-model="item.contactAddress" placeholder="请输入" />
            </el-form-item>
          </el-col>
        </el-row>
        <div style="display: inline-flex">
          <div class="infoIcon"></div>
          <div class="caseInfo2">代理人信息：</div>
        </div>
        <el-row>
          <el-col :span="12">
            <el-form-item
              label="姓名："
              :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="身份证号："
              :rules="[
                {
                  required: true,
                  message: '身份证号不能为空',
                  trigger: 'blur',
                },
                {
                  pattern:
                    /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/,
                  message: '请输入正确的身份证号码',
                  trigger: 'blur',
                },
              ]"
            >
              <el-input v-model="item.identityNumAgent" placeholder="请输入" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item
              label="联系电话："
              :rules="[
                {
                  required: true,
                  message: '联系电话不能为空',
                  trigger: 'blur',
                },
                {
                  pattern: /^[1][3,4,5,6,7,8,9][0-9]{9}$/,
                  message: '请输入正确的手机号码',
                  trigger: 'blur',
                },
              ]"
            >
              <el-input
                v-model="item.contactTelphoneAgent"
                placeholder="请输入"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item
              label="联系地址："
              :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 :model="form3">
      <div
        v-for="(itm, index) in form3.paymentArr1"
        :key="index + form2.paymentArr.length"
      >
        <div style="display: flex; justify-content: space-between">
          <div style="display: inline-flex">
            <div class="infoIcon"></div>
            <div class="caseInfo">被申请人主体信息：</div>
          </div>
        </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',
                },
                {
                  pattern:
                    /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/,
                  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',
                },
                {
                  pattern: /^[1][3,4,5,6,7,8,9][0-9]{9}$/,
                  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>
        <div style="display: inline-flex">
          <div class="infoIcon"></div>
          <div class="caseInfo2">代理人信息：</div>
        </div>
        <!-- <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',
                },
                {
                  pattern:
                    /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/,
                  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',
                },
                {
                  pattern: /^[1][3,4,5,6,7,8,9][0-9]{9}$/,
                  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>
</template>

<script>
export default {
  props: ["caseApplicationObj"],
  data() {
    return {
      formData: {},
      applicateArr: [],
      quiltArr: [],
      initpaymentArr: [],
      initpaymentArr1: [],
      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: "",
          },
        ],
      }, //被申请人主体信息
      applicantFileArr: [], //申请人
      applicantPathArr: [], //申请人
      respondentFileArr: [], //被申请人
      respondenPathArr: [], //被申请人
      awardFileArr: [], //裁决书
      awardPathArr: [], //裁决书
    };
  },
  created() {
    if (this.caseApplicationObj) {
      this.formData = this.caseApplicationObj;
    }
    console.log("this.formData", this.formData);
    if (this.caseApplicationObj && this.caseApplicationObj.caseAffiliates) {
      this.caseApplicationObj.caseAffiliates.forEach((item) => {
        if (item.identityType == 1) {
          this.initpaymentArr.push(item);
        } else {
          this.initpaymentArr1.push(item);
        }
        this.form2.paymentArr = this.initpaymentArr;
        this.form3.paymentArr1 = this.initpaymentArr1;
      });
    }
    if (this.caseApplicationObj && this.caseApplicationObj.caseAttachList) {
      this.caseApplicationObj.caseAttachList.forEach((item) => {
        if (item.annexType == 2) {
          this.applicantFileArr.push(item.annexName);
          this.applicantPathArr.push(item.annexPath);
        } else if (item.annexType == 6) {
          this.respondentFileArr.push(item.annexName);
          this.respondenPathArr.push(item.annexPath);
        } else if (item.annexType == 3) {
          this.awardFileArr.push(item.annexName);
          this.awardPathArr.push(item.annexPath);
        }
      });
    }
  },
  methods: {
    // 预览文件
    toFile(index, val) {
      let headPath = window.location.origin + "/API";
      if (val == 2) {
        window.open(headPath + this.applicantPathArr[index], "_blank");
      } else if (val == 6) {
        window.open(headPath + this.respondenPathArr[index], "_blank");
      } else if (val == 3) {
        window.open(headPath + this.awardPathArr[index], "_blank");
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.caseInfo {
  font-size: 17px;
  font-weight: 600;
}
.caseInfo2 {
  font-size: 15px;
  font-weight: 550;
}
.infoIcon {
  width: 4px;
  background-color: #0072ff;
  margin-right: 5px;
}
.el-date-editor {
  width: 100%;
}
a {
  color: blue;
}
</style>