ViewAllowances.vue 2.93 KB
Newer Older
liang ce committed
1 2
<template>
  <div class="viewAllowances">
liang ce committed
3
    <a-button type="primary" @click="back()"><img style="margin-top:-4px;margin-right: 6px;width: 14px" src="../../../assets/back.png"/>返回</a-button>
liang ce committed
4
    <div class="title">查看津贴</div>
5
    <a-table :columns="columns" :dataSource="subsidyList" size="default" rowKey="couponId" :pagination="pagination" @change="handleTableChange">
liang ce committed
6 7 8 9 10 11 12 13
      <span slot="type" slot-scope="type">
        {{ type === 'travel' ? '交通补贴' : '餐补'}}
      </span>
      <span slot="initialAmount">发放金额</span>>
      <span slot="residueAmount">余额</span>
      <span slot="endTime" slot-scope="endTime">
        {{ timeToStr(endTime) }}
      </span>
liang ce committed
14 15
      <span slot="creatTime" slot-scope="createTime">
        {{ timeToStr(createTime) }}
16
      </span>
liang ce committed
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
    </a-table>
  </div>
</template>

<script>
import { $http } from './../../../api/axios.js'
export default {
  name: 'viewAllowances',
  data () {
    return {
      userId: '',
      columns: [{
        title: '津贴类型',
        dataIndex: 'type',
        scopedSlots: { customRender: 'type' }
      }, {
        title: '发放金额',
        dataIndex: 'initialAmount'
      }, {
        title: '余额',
        dataIndex: 'residueAmount'
      }, {
        title: '截止日期',
        dataIndex: 'endTime',
        scopedSlots: { customRender: 'endTime' }
42 43
      }, {
        title: '创建日期',
liang ce committed
44 45
        dataIndex: 'createTime',
        scopedSlots: { customRender: 'createTime' }
liang ce committed
46 47 48 49
      }],
      pagination: {
        current: 1,
        defaultCurrent: 10,
liang ce committed
50
        defaultPageSize: 10,
liang ce committed
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
        hideOnSinglePage: true,
        total: 0
      },
      subsidyList: []
    }
  },
  watch: {},
  computed: {},
  created: function () {
    this.userId = this.$route.params.userId
    this.querySubsidyList()
  },
  methods: {
    querySubsidyList () {
      let SubsidyListData = this.$qs.stringify({
        userId: this.userId,
        currentPage: this.pagination.current,
        pageNumber: this.pagination.defaultPageSize,
        orgId: sessionStorage.getItem('corpId')
      })
      $http.get(`/v1/account/query_subsidyList_by_user_id?${SubsidyListData}`).then((res) => {
        let data = res.data.data
        this.subsidyList = data.recordList
        this.pagination.total = parseInt(data.totalCount)
      })
    },
    // 表格时间处理
    timeToStr (time) {
      let timeData = new Date(parseInt(time))
      let year = timeData.getFullYear()
      let month = timeData.getMonth() + 1
      let date = timeData.getDate()
      let hour = timeData.getHours()
      let minute = timeData.getMinutes()
liang ce committed
85
      return `${year}${month}${date}日`
liang ce committed
86 87 88 89
    },
    handleTableChange (pagination, filters, sorter) {
      this.pagination.current = pagination.current
      this.querySubsidyList()
liang ce committed
90 91 92
    },
    back () {
      this.$router.go(-1)
liang ce committed
93 94 95 96 97 98 99 100 101
    }
  }
}
</script>

<style lang="less" scoped>
.title{
  font-weight: bold;
  margin-bottom: 20px;
liang ce committed
102
  margin-top: 20px;
liang ce committed
103 104
}
</style>