<template>
  <div class='container'>
    <div class="row">
      <span class="title">申请时间</span>
      <span class="cont">{{createDate}}</span>
    </div>
    <div class="row">
      <span class="title">申请人</span>
      <span class="cont">{{userName}}</span>
    </div>
    <div class="row">
      <span class="title">开始时间</span>
      <span class="cont">{{startDate}}</span>
    </div>
    <div class="row">
      <span class="title">结束时间</span>
      <span class="cont">{{endDate}}</span>
    </div>
    <div class="row">
      <span class="title">请假事由</span>
      <span class="cont">{{cause}}</span>
    </div>
    <div class="row">
      <span class="title">审批人</span>
      <span class="cont">{{name}}</span>
    </div>
    <div class="row">
      <span class="title">审批状态</span>
      <span class="cont">
        <span class="status ongoing" v-if="status==0">律所审核中</span>
        <span class="status ongoing" v-if="status==1">司法审核中</span>
        <span class="status finish" v-if="status==2">已审核</span>
      </span>
    </div>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        leave: null,
        id: null,
        sysNewsId: 1,
        createDate: null,
        userName: '',
        startDate: '',
        endDate: '',
        name: '',
        cause: '',
        status: '',
        loaded: false
      }
    },
    methods: {
      loadArticles () {
        this.getList()
      },
      getList(){
        wx.showLoading({ title: '正在加载' })
        wx.request({
          url: this.rootUrl + 'leave/getLeave',
          method: 'get',
          header: {'content-type': 'application/x-www-form-urlencoded'},
          data:{
            id: this.id,
            sessionID: wx.getStorageSync('sessionID'),
            sysNewsId: this.sysNewsId
          },
          success: res=> {
            if(res.statusCode=='500'){
              this.service.getUnionId(this.rootAvatar,this.rootUrl).then(res=>{
                console.log(res)
                this.loadArticles()
              })
            }else{
              console.log(res.data)
              this.createDate = this.service.correctTime(res.data.createDate, 'full')
              this.leave = res.data
              this.userName = res.data.user_name
              this.startDate = res.data.start_Date
              this.endDate = res.data.end_Date
              this.name = res.data.name
              this.cause = res.data.cause
              this.status = res.data.status
              // this.createDate = util.formatTime(res.data.createDate)
              wx.hideLoading()
            }
          },
          fail: res=> {
            console.log(res)
          }
        })
      },
    },
    onLoad(){
      this.id = this.$root.$mp.query.id
      this.sysNewsId = this.$root.$mp.query.sysNewsId
      this.getList()
    },
    onShow() {
      this.loadArticles()
    },
    onUnload(){
      this.leave = null
      this.id = null
      this.sysNewsId = 1
      this.loaded = false
    }
  }
</script>
<style lang="stylus" scoped>
.container
  position absolute
  Height_Width(100%)
  Background()
.row
  width 100%
  box-sizing border-box
  padding 25rpx
  background-color #fff
  border-bottom 1rpx solid #eee
  line-height 40rpx
.title
  color #888
.cont
  float right
  color #333
.status
  display inline-block
  padding 5rpx 10rpx
  border-radius 6rpx
  color #fff
  font-size 26rpx
.ongoing
  background-color #f6b35a
.finish
  background-color #00D49D
</style>

