<template>
	<view>
		<view class="uni-container">
			<uni-table ref="table" :loading="loading" border stripe type="" emptyText="暂无更多数据" @selection-change="selectionChange">
				<uni-tr>
					<uni-th align="center">日期</uni-th>
					<uni-th align="center">订单号</uni-th>
					<uni-th align="center">班组</uni-th>
					<uni-th align="center">中班</uni-th>
					<uni-th align="center">晚班</uni-th>
					<uni-th align="center">早班</uni-th>
					<uni-th align="center">管理线</uni-th>
					<!-- <uni-th width="204" align="center">设置</uni-th> -->
				</uni-tr>
				<uni-tr v-for="(item, index) in tableData" :key="index">
					<uni-td align="center">{{ item.createDate }}</uni-td>
					<uni-td align="center">{{ item.filing.orderNo }}</uni-td>
					<uni-td align="center">{{ item.filing.workshop.zyProductWorkshop }}-{{ item.filing.team.zyTeam }}</uni-td>
					<uni-td align="center">{{ item.middle }}</uni-td>
					<uni-td align="center">{{ item.night }}</uni-td>
					<uni-td align="center">{{ item.morning }}</uni-td>
					<uni-td align="center">{{ item.admin }}</uni-td>
				</uni-tr>
				<uni-tr>
					<uni-td align="center"></uni-td>
					<uni-td align="center"></uni-td>
					<uni-td align="center">合计</uni-td>
					<uni-td align="center">{{ sumMiddle }}</uni-td>
					<uni-td align="center">{{ sumNight }}</uni-td>
					<uni-td align="center">{{ sumMorning }}</uni-td>
					<uni-td align="center">{{ sumAdmin }}</uni-td>
				</uni-tr>
			</uni-table>
			<view class="uni-pagination-box"></view>
		</view>
	</view>
</template>

<script>
import { count } from '@/api/biz/plan.js';
export default {
	data() {
		return {
			searchVal: '',
			tableData: [],
			// 每页数据量
			pageSize: 10,
			// 当前页
			pageCurrent: 1,
			// 数据总量
			total: 0,
			loading: false
		};
	},
	onLoad() {
		// this.selectedIndexs = []
		this.getData();
	},
	computed: {
		sumMiddle() {
			return this.tableData.map(row => row.middle).reduce((acc, cur) => parseFloat(cur) + acc, 0);
		},
		sumNight() {
			return this.tableData.map(row => row.night).reduce((acc, cur) => parseFloat(cur) + acc, 0);
		},
		sumMorning() {
			return this.tableData.map(row => row.morning).reduce((acc, cur) => parseFloat(cur) + acc, 0);
		},
		sumAdmin() {
			return this.tableData.map(row => row.admin).reduce((acc, cur) => parseFloat(cur) + acc, 0);
		}
	},
	methods: {
		// // 多选处理
		// selectedItems() {
		// 	return this.selectedIndexs.map(i => this.tableData[i])
		// },
		// // 多选
		// selectionChange(e) {
		// 	console.log(e.detail.index)
		// 	this.selectedIndexs = e.detail.index
		// },
		// //批量删除
		// delTable() {
		// 	console.log(this.selectedItems())
		// },
		// // 分页触发
		// change(e) {
		// 	this.$refs.table.clearSelection()
		// 	this.selectedIndexs.length = 0
		// 	this.getData(e.current)
		// },
		// // 搜索
		// search() {
		// 	this.getData(1, this.searchVal)
		// },
		// 获取数据
		getData() {
			count().then(res => {
				if (res.success) {
					this.tableData = res.data;
				} else {
				}
			});
			// this.loading = true
			// this.pageCurrent = pageCurrent
			// this.request({
			// 	pageSize: this.pageSize,
			// 	pageCurrent: pageCurrent,
			// 	value: value,
			// 	success: res => {
			// 		// console.log('data', res);
			// 		this.tableData = res.data
			// 		this.total = res.total
			// 		this.loading = false
			// 	}
			// })
		}
		// 伪request请求
		// request(options) {
		// 	const { pageSize, pageCurrent, success, value } = options
		// 	let total = tableData.length
		// 	let data = tableData.filter((item, index) => {
		// 		const idx = index - (pageCurrent - 1) * pageSize
		// 		return idx < pageSize && idx >= 0
		// 	})
		// 	if (value) {
		// 		data = []
		// 		tableData.forEach(item => {
		// 			if (item.name.indexOf(value) !== -1) {
		// 				data.push(item)
		// 			}
		// 		})
		// 		total = data.length
		// 	}

		// 	setTimeout(() => {
		// 		typeof success === 'function' &&
		// 			success({
		// 				data: data,
		// 				total: total
		// 			})
		// 	}, 500)
		// }
	}
};
</script>

<style>
/* #ifndef H5 */
/* page {
	padding-top: 85px;
} */
/* #endif */
.uni-group {
	display: flex;
	align-items: center;
}
</style>
