<template>
	<view>
		<view v-if="null === data || undefined === data" style="text-align: center;padding: 50px 0;">
			<view>
				暂无数据
			</view>
		</view>
		<uni-list v-for="item in data">
			<uni-list-item :clickable="true" @click="toSlipPage(item.data)" :title="item.date"
				:note="'收入：'+item.fsalary+' 元'" />
		</uni-list>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				data: {}
			}
		},
		onLoad() {
			this.getSalarySlip()
		},
		onShow() {
			this.getSalarySlip()
		},
		methods: {
			toSlipPage(data) {
				uni.setStorageSync("salarySlipData", data)
				this.$goto("salarySlip")
			},
			async getSalarySlip() {
				const {
					data: res
				} = await this.$httpRequest({
					url: '/api/ci/sl/?un=' + uni.getStorageSync("setUserName") + "&oc=" + uni
						.getStorageSync("orgInfo").organizationCode,
					method: 'get',
				})
				if (res.code == 200) {
					this.data = res.data
				} else {

				}
			},
			dateResult(time, mode) {
				const timeFormat = uni.$u.timeFormat
				switch (mode) {
					case 'datetime':
						return timeFormat(time, 'yyyy-mm-dd hh:MM:ss')
					case 'date':
						return timeFormat(time, 'yyyy-mm-dd')
					case 'year-month':
						return timeFormat(time, 'yyyy-mm')
					case 'time':
						return time
					default:
						return ''
				}
			}
		}
	}
</script>

<style>
	page {
		padding: 5rpx;
	}

	.listBody {}

	.mylist {
		padding: 5px;
		border-bottom: 1px solid #ababab;
	}
</style>
