<template>
  <div>
      <div class="tim">
  <el-timeline>
    <el-timeline-item
      v-for="(activity, index) in activities"
      :key="index"
      :icon="activity.icon"
      :type="activity.type"
      :color="activity.color"
      :size="activity.size"
      :timestamp="activity.timestamp"
      :timestamp2="123">
      {{activity.content}}
      <p style="font-size:13px;color:#909399" v-show="activity.timestamp">审核人:{{activity.name}}</p>
      <p style="font-size:13px;color:#909399" v-show="activity.examineRemark">原因:{{activity.examineRemark}}</p>
    </el-timeline-item>
  </el-timeline>
  </div>
    <h2 class="imtil">基础信息</h2>
    <div class="wrap">
      <div class="masks"></div>
      <el-form ref="form" :model="form" class="form" label-width="auto">
        <el-form-item label="姓名">
          <el-input v-model="form.name"></el-input>
        </el-form-item>
        <el-form-item label="身份证号">
          <el-input v-model="form.identity_number"></el-input>
        </el-form-item>
        <el-form-item label="联系电话">
          <el-input v-model="form.telphoneValue"></el-input>
        </el-form-item>
        <el-form-item label="户籍地地址">
          <el-input v-model="form.address"></el-input>
        </el-form-item>
      </el-form>
      <el-form ref="form" :model="form" class="form" label-width="auto">
        <el-form-item label="性别">
          <el-input v-model="form.sex"></el-input>
        </el-form-item>
        <el-form-item label="民族">
          <el-input v-model="form.nation"></el-input>
        </el-form-item>
        <el-form-item label="户口类型">
          <el-input v-model="form.nation_type"></el-input>
        </el-form-item>
      </el-form>
    </div>
    <h2 class="imtil">升档改办信息</h2>
    <div class="wrap">
      <div class="masks"></div>
      <el-form ref="form" :model="form" class="form" label-width="auto">
        <el-form-item label="原缴费档次">
          <el-input v-model="form.old_Grade"></el-input>
        </el-form-item>
        <el-form-item label="缴费金额">
          <el-input v-model="form.pay_num"></el-input>
        </el-form-item>
        <el-form-item label="所属银行">
          <el-input v-model="form.bank_Name"></el-input>
        </el-form-item>
      </el-form>
      <el-form ref="form" :model="form" class="form" label-width="auto">
        <el-form-item label="升档缴费档次">
          <el-input v-model="form.new_Grade"></el-input>
        </el-form-item>
        <el-form-item label="缴费人员类型">
          <el-input v-model="form.personAplly_type"></el-input>
        </el-form-item>
      </el-form>
    </div>
    <h2 class="imtil">附件</h2>
    <div class="imgcon">
      <div class="demo-image__placeholder">
        <div v-show="bb" class="block">
          <p class="demonstration">{{itmebs}}</p>
          <el-image :src="urls[0]"></el-image>
        </div>
        <div class="block">
          <p class="demonstration">签名</p>
          <el-image :src="urls[1]">
            <div slot="placeholder" class="image-slot">
              加载中<span class="dot">...</span>
            </div>
          </el-image>
        </div>
        <div class="block">
          <p class="demonstration">身份证正面</p>
          <el-image :src="urls[2]">
            <div slot="placeholder" class="image-slot">
              加载中<span class="dot">...</span>
            </div>
          </el-image>
        </div>
        <div class="block">
          <p class="demonstration">身份证反面</p>
          <el-image :src="urls[3]">
            <div slot="placeholder" class="image-slot">
              加载中<span class="dot">...</span>
            </div>
          </el-image>
        </div>
      </div>
    </div>
    <div style="text-align:center;margin-bottom:40px" v-show="show">
      <el-button type="success" @click="pass"><i class="el-icon-circle-check"></i> 审核通过</el-button>
      <el-button type="danger" @click="nopass"><i class="el-icon-circle-close"></i> 审核不通过</el-button>
    </div>
  </div>
</template>
<script>
  import CryptoJS from 'crypto-js'

  import {Loading} from 'element-ui';

  export default {
    data() {
      return {
         activities:[],
        itmebs: "",
        show: "",
        bb: false,
        form: {
          bank_Account: "",
          bank_Name: "",
          groupName: "",
          idBackPic: "",
          idFortPic: "",
          identity_number: "",
          nation: "",
          nation_type: "",
          new_Grade: "",
          old_Grade: "",
          pay_num: "",
          personAplly_type: "",
          recordType: "",
          sex: "",
          sign_photo: "",
          telphoneValue: "",
          townName: "",
          villageName: "",
          wuserId: ""
        },
        urls: [],
      }
    },
    methods: {
      //审核通过
      pass() {
        this.$confirm('是否审核通过?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
        }).then(() => {
          Loading.service();
          var data = {
            recordId: this.$route.params.upgReo.recordId,
            examineState: 1,
            remark: "",
            userId: 1
          };
          this.$api.getlist.shenhe(data).then((res) => {
            let loadingInstance = Loading.service();
            this.$nextTick(() => { // 以服务的方式调用的 Loading 需要异步关闭
              loadingInstance.close();
            });
            if (res.code === 200) {
              this.$message({
                type: 'success',
                message: res.data
              });
              this.$router.push({
                name: "升档改办审核"
              })
            } else {
              this.$message({
                type: 'info',
                message: res.message
              });
            }
            this.$router.back();
            // 关闭当前标签
            let closeAll = document.querySelectorAll(".el-icon-close");
            for(let j = 0, len = closeAll.length; j < len; j++) {
              if (closeAll[j].previousSibling != null && closeAll[j].previousSibling.innerText === "升档改办审核 ") {
                closeAll[j].click();
                return;
              }
            }
          }).catch((res) => {
            let loadingInstance = Loading.service();
            this.$nextTick(() => { // 以服务的方式调用的 Loading 需要异步关闭
              loadingInstance.close();
            });
            this.$message({
              type: 'info',
              message: '操作失败!' + res
            });
          });
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消操作'
          });
        });
      },
      //审核不通过
      nopass() {
        // var that = this
        this.$prompt('请输入原因', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
        }).then(({value}) => {
          if (value) {
            Loading.service();
            let data = {
              recordId: this.$route.params.upgReo.recordId,
              examineState: 2,
              remark: value,
              userId: 1
            };
            this.$api.getlist.shenhe(data).then((res) => {
              let loadingInstance = Loading.service();
              this.$nextTick(() => { // 以服务的方式调用的 Loading 需要异步关闭
                loadingInstance.close();
              });
              if (res.code === 200) {
                this.$message({
                  type: 'success',
                  message: res.data
                });
                // this.$router.push({
                //   name:"Xxsh"
                // })
              } else {
                this.$message({
                  type: 'info',
                  message: res.message
                });
              }
              this.$router.back();
              // 关闭当前标签
              let closeAll = document.querySelectorAll(".el-icon-close");
              for(let j = 0, len = closeAll.length; j < len; j++) {
                if (closeAll[j].previousSibling != null && closeAll[j].previousSibling.innerText === "升档改办审核 ") {
                  closeAll[j].click();
                  return;
                }
              }
            }).catch((res) => {
              let loadingInstance = Loading.service();
              this.$nextTick(() => { // 以服务的方式调用的 Loading 需要异步关闭
                loadingInstance.close();
              });
              this.$message({
                type: 'info',
                message: '操作失败!' + res
              });
            });
          } else {
            let loadingInstance = Loading.service();
            this.$nextTick(() => { // 以服务的方式调用的 Loading 需要异步关闭
              loadingInstance.close();
            });
            this.$message({
              type: 'info',
              message: '请输入原因'
            });
          }
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消输入'
          });
        });
      },
      decrypt(word) {
        var key = CryptoJS.enc.Utf8.parse("KkweInfo23255625");
        var decrypt = CryptoJS.AES.decrypt(word, key, {mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7});
        return CryptoJS.enc.Utf8.stringify(decrypt).toString();
      },
      decryptByDES(ciphertext) {
        var keyHex = CryptoJS.enc.Utf8.parse("KkweFace95271124");
        var decrypted = CryptoJS.DES.decrypt({
          ciphertext: CryptoJS.enc.Base64.parse(ciphertext)
        }, keyHex, {
          mode: CryptoJS.mode.ECB,
          padding: CryptoJS.pad.Pkcs7
        });
        return decrypted.toString(CryptoJS.enc.Utf8);
      }
    },
    created() {
        this.activities=JSON.parse(sessionStorage.getItem("progress"))
      if (typeof(this.$route.params.upgReo) !== "undefined" && this.$route.params.upgReo.info) {
        this.show = this.$route.params.upgReo.show;
        sessionStorage.setItem("upgReoInfo", this.$route.params.upgReo.info);
        sessionStorage.setItem("upgReoItems", JSON.stringify(this.$route.params.upgReo));
      }
      let obj = JSON.parse(sessionStorage.getItem("upgReoItems"));
      this.form = JSON.parse(sessionStorage.getItem("upgReoInfo"));
      this.form.name = this.form.name ? this.decrypt(this.form.name) : obj.name;
      this.form.identity_number = this.form.identity_number ? this.decrypt(this.form.identity_number) : "";
      this.form.telphoneValue = this.form.telphoneValue ? this.decrypt(this.form.telphoneValue) : "";
      if (obj.bankpic) {
        this.bb = true;
        this.itmebs = "银行卡";
        this.urls.push("http://socialsecurity.oss-cn-beijing.aliyuncs.com/" + obj.bankpic);
      } else if (obj.bookPic) {
        this.bb = true;
        this.itmebs = "户口本";
        this.urls.push("http://socialsecurity.oss-cn-beijing.aliyuncs.com/" + obj.bookPic);
      } else if (obj.specialPhotoPic) {
        this.bb = true;
        this.itmebs = "特殊身份证明";
        this.urls.push("http://socialsecurity.oss-cn-beijing.aliyuncs.com/" + obj.specialPhotoPic);
      } else {
        this.itmebs = "";
        this.urls.push("");
      }
      this.urls.push("http://socialsecurity.oss-cn-beijing.aliyuncs.com/" + obj.signpic);
      this.urls.push("http://socialsecurity.oss-cn-beijing.aliyuncs.com/" + obj.idcardfrontpic);
      this.urls.push("http://socialsecurity.oss-cn-beijing.aliyuncs.com/" + obj.idcardbackpic);
      this.form.sex = this.form.sex === 1 ? "男" : "女";
    }
  }
</script>
<style>
  .wrap {
    overflow: hidden;
    position: relative;
  }
.tim{
  width: 180px;
  position: fixed;
  right: 0;
  top: 30%;
  border-radius: 10px;
  background:#ffffff

}
  .masks {
    width: 100%;
    height: 100%;
    position: absolute;
    left: 0;
    top: 0;
    z-index: 200
  }

  .form {
    float: left;
    width: 45%;
    margin-left: 20px
  }

  .imgcon {
    margin: 0 auto;
    box-shadow: 0 0 15px lightgray;
    overflow: hidden;
    margin-bottom: 40px
  }

  .block {
    width: 23%
  }

  .block {
    float: left;
    height: 100%;
    margin-right: 20px
  }

  .imtil {
    padding: 0 0 20px 0
  }
</style>
