<template>
  <div>
    <el-dialog
      title="确认调解书"
      v-if="confirmTionVisable"
      :visible="confirmTionVisable"
      @close="cancel"
      width="800px"
      append-to-body
      :destroy-on-close="true"
      center
    >
      <el-form ref="form" :model="formData" label-width="180px">
        <div class="caseInfo">案件信息：</div>
        <el-row>
          <el-col :span="12">
            <el-form-item label="案件编号：" prop="caseNum">
              <el-input v-model="formData.caseNum" placeholder="请输入案件编号" :disabled="true" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="申请人：" prop="affiliate.applicationName">
              <el-input v-model="formData.affiliate.applicationName" :disabled="true" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="被申请人：" prop="respondentName">
              <el-input v-model="formData.affiliate.respondentName" :disabled="true" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="案件标的：" prop="caseSubjectAmount">
              <el-input
                v-model="formData.caseSubjectAmount"
                placeholder="请输入案件标的"
                :disabled="true"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="调解费用：" prop="feePayable">
              <el-input v-model="formData.feePayable" placeholder="请输入仲裁费用" :disabled="true" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="调解员：" prop="mediatorName">
              <el-input v-model="formData.mediatorName" placeholder="请输入" :disabled="true" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="调解书:">
                   <div v-for="(item, index) in formData.caseAttachList" :key="index" v-if="item.annexType==7">
                      <div style="color: blue;cursor: pointer;" @click="fileDetil(item.annexPath)">{{
                      item.annexName }}</div>
                    </div>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="是否和解:" prop="isReconci">
                  <el-radio-group v-model="isReconci">
                      <el-radio :label="1">是</el-radio>
                      <el-radio :label="0">否</el-radio>
                  </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <div class="payupload">
          <span>上传修改后调解书</span>
          <div class="uploadBtn">
            <el-upload
              class="upload-demo"
              ref="upload"
              :action="UploadUrl()"
              :headers="headers"
              :data="filedata"
              :on-preview="handlePreview"
              :on-remove="handleRemove"
              :on-change="beforeUpload"
              :on-success="handlSuccess"
              :file-list="fileList"
            >
              <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
              <!-- <el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload">上传到服务器</el-button> -->
              <div slot="tip" class="el-upload__tip">只能上传word文件</div>
            </el-upload>
          </div>
        </div>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel" class="endbutton1" round>
          <span>取 消</span>
        </el-button>
        <el-button @click="submitMediator" type="primary" class="endbutton1" round>
          <span>确 认</span>
        </el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { casePay, confirmPayDig } from "@/api/pay/pay";
import { caseApplicationSelectById,confirmMediation } from "@/api/caseManagement/caseManagement.js";
import { getToken } from "@/utils/auth";
export default {
  props: ["confirmTionVisable", "queryParams", "confirmTionData"],
  data() {
    return {
      fileList: [],
      formData: {
        affiliate: {},
        
      },
      isReconci:0,
      fileURL: window.location.origin + "/API",
      annexId:null,
      headers: {
        Authorization: "Bearer " + getToken()
      },
      filedata: {
        annexType: 7
      }
    };
  },
  methods: {
    /** 获取案件详情信息 */
    caseApplicationSelectByIdFn(data) {
      caseApplicationSelectById(data).then(res => {
        this.formData = res.data;
      });
    },
    /** 查看申请书 */
    fileDetil(val) {
            window.open(this.fileURL + val)
    },
    UploadUrl() {
      return window.location.origin + "/API/common/upload";
    },
    beforeUpload(flie, fileList) {
      this.fileList = fileList;
    },
    // 文件上传成功
    handlSuccess(res, file) {
      this.annexId = res.annexId;
    },
    submitMediator() {
      confirmMediation({
        caseAppliId: this.confirmTionData.id,
        caseFlowId: this.confirmTionData.caseFlowId,
        annexId: this.annexId,
        isReconci:this.isReconci,
      }).then(res => {
        this.$modal.msgSuccess("成功");
        this.cancel();
        this.$emit("getList", this.queryParams);
      });
    },
    handleRemove(file, fileList) {},
    handlePreview(file) {},
    cancel() {
      this.$emit("cancelConfirmTion");
    }
  },
  watch: {
    confirmTionVisable(val) {
      if (val) {
        this.annexId = '';
        this.caseApplicationSelectByIdFn({
          id: this.confirmTionData.id
        });
      }
    }
  }
};
</script>

<style lang="scss" scoped>
.payType {
  height: 80px;
  line-height: 80px;
  display: flex;

  .icon-weixinzhifu {
    font-size: 24px;
    color: #27a56f;
    margin-right: 15px;
  }

  .icon-zhifubao {
    font-size: 24px;
    color: #1d76cc;
  }
}

.paySelectType {
  margin-top: 20px;
  margin-bottom: 20px;
}

.payupload {
  display: flex;

  .uploadBtn {
    margin-left: 20px;
  }
}

.payImg {
  width: 100%;
  display: flex;
  justify-content: center;
}

.payTitle {
  margin-top: 20px;
  width: 100%;
  text-align: center;
}

::v-deep .el-dialog {
  width: 800px;
  background: #ffffff;
  border-radius: 20px;
}

.endbutton {
  width: 154px;
  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>