<template>


<div>
  <van-nav-bar title="加入申请" left-text="返回" @click-left="$route_back" left-arrow>

  </van-nav-bar>
  <div class="body_com has_header">
    <scroller>

      <div v-for="(item,index) in list" :key="index" style="padding-top:0.2rem; padding-left:0.2rem; padding-right:0.2rem;">
        <van-panel :title="item.name">
          <div style="padding:0.16rem 0.32rem; font-size:0.28rem; color:#666;">
            <p>申请加入{{item.company_name}}</p>
            <p>申请时间：{{item.create_time | datetime}}</p>

          </div>
          <div slot="footer" style="text-align: right;">
            <van-button size="small" :disabled="item.pass_loading" @click="reject(item.employee_id, index)" :loading="item.reject_loading">拒绝</van-button>
            <van-button size="small" :disabled="item.reject_loading" type="primary" @click="pass(item.employee_id, index)" :loading="item.pass_loading">同意</van-button>
          </div>
        </van-panel>

      </div>

    </scroller>
  </div>

</div>




</template>

<script>
  import Vue from 'vue';
  import moment from 'moment';
  import { Panel } from 'vant';

  Vue.use(Panel);
  import request from '@/utils/request'
  export default {
    name: 'join_review',
    data(){
      return {
        page:0,
        list:[],
      }
    },
    filters:{
      datetime(time){
        return moment(time*1000).format('YYYY-MM-DD HH:mm:ss')
      }
    },
    created(){
      this.get_user_list()
    },
    methods:{
      reject(id, index){
        let self = this
        self.$set(self.list[index], 'reject_loading', true)
        request('get','/addons/ems/employee/join_review_reject', {id:id}).then((res) => {
          self.$set(self.list[index], 'reject_loading', false)
          self.get_user_list()
        }).catch((e) => {
          self.$set(self.list[index], 'reject_loading', false)
        })
      },
      pass(id, index){
        let self = this
        self.$set(self.list[index], 'pass_loading', true)
        request('get','/addons/ems/employee/join_review_pass', {id:id}).then((res) => {
          self.$set(self.list[index], 'pass_loading', false)
          self.get_user_list()
        }).catch((e) => {
          self.$set(self.list[index], 'pass_loading', false)
        })
      },
      get_user_list(){
        request('get','/addons/ems/employee/get_join_review_list', {page:this.page}).then((res) => {
          for(let i in res.data.data.data){
            res.data.data.data[i]["pass_loading"] = false
            res.data.data.data[i]["reject_loading"] = false
          }
          this.list = res.data.data.data
        })
      }
    }
  }
</script>

<style scoped>
  .body_com{height: calc(100% - 1rem); position: relative; background-color: #f5f5f5;}
</style>
