<style>
  .modal-content{
    border-radius:10px;
  }
  .modal-header{
    border-radius:10px;
    height: 40px;;
    background-color:rgb(234, 239, 244);
  }
</style>
<template>
  <modal :show.sync="$parent.showModal" width="60%" class="modal-all"  v-ref:modal>
    <div slot="modal-header" class="modal-header">
      <button type="button" class="close" @click="cancel()"><span>&times;</span></button>
      <h5 class="modal-title text-left">
        信息审核
      </h5>
    </div>
    <div slot="modal-body" class="modal-body">
      <div class="row auto form-horizontal">
       <div class="form-group">
         <div class="col-sm-6">
        <label class="col-sm-4">用户编号：</label>
        <div class="col-sm-6"><input type="text" class="form-control" v-model="info.f_userinfo_code" readonly="true"></div>
        </div>
      </div>
        <hr>
      <div class="form-group">
        <div class="col-sm-12" v-if="info.f_modify_type == '用户档案'">
          <div :class="info.f_approved == '已审核'?'col-sm-4':'col-sm-6'" style="float:left">
            <img src="../../assets/档案信息.png" style="width: 20px;margin-bottom: 5px" alt="">
            <label>原档案信息：</label>
          <userinfo-modify  :content.sync="info.f_approved == '已审核'?history:nomodify"></userinfo-modify>
        </div>
          <div :class="info.f_approved == '已审核'?'col-sm-4':'col-sm-6'">
            <img src="../../assets/安检信息.png" style="width: 20px;margin-bottom: 5px" alt="">
            <label>安检信息：</label>
         <userinfo-modify  :content.sync="content"></userinfo-modify>
          </div>
          <div class="col-sm-4" style="float:right" v-if="info.f_approved == '已审核'">
            <img src="../../assets/档案信息.png" style="width: 20px;margin-bottom: 5px" alt="">
            <label>现档案信息：</label>
            <userinfo-modify  :content.sync="nomodify"></userinfo-modify>
          </div>
      </div>
        <div class="col-sm-12" v-if="info.f_modify_type == '表档案'">
          <div class="col-sm-6" style="float:left">
            档案信息：
          <meter-modify :content.sync="nomodify"></meter-modify>
          </div>
          <div class="col-sm-6" style="float:right">
            安检信息：
          <meter-modify :content.sync="content"></meter-modify>
          </div>
        </div>
      </div>
      </div>
    </div>
    <div slot="modal-footer" class="modal-footer" >
      <button type="button" class="btn btn-primary" style="border-radius: 3px" @click="$parent.todo(info)" v-if="info.f_approved == '未审核'">通过</button>
      <button type="button" class="btn" style="background-color: #5bc0de;border-radius: 3px" @click="$parent.undo(info)" v-if="info.f_approved == '未审核'">不通过</button>
    </div>
  </modal>
</template>

<script>
  import { PagedList,HttpResetClass} from 'vue-client'
  import Vue from 'vue'
  import * as Util from '../Util'
  import UserinfoModify from  './UserinfoModify'
  import MeterModify from  './MeterModify'

  export default {
    components: {
      'userinfo-modify': UserinfoModify,
      'meter-modify':MeterModify
    },
    title:'信息审核',
    props:['info'],
    data(){
          return {
            nomodify:{},
            content:{},
            history:{}
          }
    },
    methods:{
      cancel(){
        this.$parent.showModal = false
      }
    },
    watch:{
          'info'() {
            if (JSON.stringify(this.info) != '{}') {
              this.content = JSON.parse(this.info.f_content)
                if (this.info.f_modify_type == '用户档案') {
                this.$resetpost('api/af-safecheck/sql/查询用户原信息', {data: {id: this.info.f_userinfoid}},{resolveMsg: null, rejectMsg: null}).then((res) => {
                  this.nomodify = res.data[0]
              })
              let _http = new HttpResetClass()
                _http.load('POST', 'api/af-safecheck/sql/查询用户旧信息', {data: {id: this.info.id}},{resolveMsg: null, rejectMsg: null}).then((res)=>{
                this.history = res.data[0]
              })
              }
              if (this.info.f_modify_type == '表档案') {
                this.$resetpost('api/af-safecheck/sql/查询用户表原信息', {data: {id: this.info.f_plan_item_id}},{resolveMsg: null, rejectMsg: null}).then((res) => {
                  this.nomodify = res.data[0]
              })
              }
            }
          }
    }
  }
</script>

