<template>
	<view class="container">
		<view class="top_head">
			<view class="top_head1">待检报工单</view>
		</view>
		<view class="box">
			<t-table border=0>
				<t-tr font-size="16">
					<t-th style="min-width:200px;max-width:200px">报工单号</t-th>
					<t-th>工序</t-th>
					<t-th>物料</t-th>
					<t-th>批号</t-th>
					<t-th >操作工</t-th>
					<t-th >主计量单位</t-th>
					<t-th >完工数量(主单位)</t-th>
					<t-th >辅助单位</t-th>
					<t-th >完工数量(辅单位)</t-th>
					<t-th style="max-width:80px;min-width:80px">操作</t-th>
				</t-tr>
				<t-tr font-size="15" v-for="item in tableList" :key="item.id">
					<t-td style="min-width:200px;max-width:200px">{{item.code}}</t-td>
					<t-td>{{item.processName}}</t-td>
					<t-td>{{item.materialName}}</t-td>
					<t-td>{{item.batchNo}}</t-td>
					<t-td >{{item.operatorName}}</t-td>
					<t-td >{{item.unitName}}</t-td>
					<t-td >{{item.completionCount}}</t-td>
					<t-td >{{item.supportUomName}}</t-td>
					<t-td >{{item.completionCountSupport}}</t-td>
					<t-td style="max-width:80px;min-width:80px"><button @click="edit(item)" type="primary">检验</button></t-td>
				</t-tr>
				<view v-if="show_nodata" class="nodata" style="text-align: center;font-size: 18px;color: #999;line-height: 40px;">暂无数据</view>

			</t-table>
			<loading class="loading_container" ref="loading" :custom="false" :shadeShow="false" :shadeClick="true" :type="1"
			 height="0">
			</loading>
		</view>
		<uni-pagination show-icon="true" :pageSize="pagesize" :total="total_pages" :current="pageno" class="pagination" @change="changePages"></uni-pagination>
	</view>
</template>

<script>
	import {
		config
	} from '../../request/js/config.js'
	import tTable from '@/components/t-table/t-table.vue';
	import tTh from '@/components/t-table/t-th.vue';
	import tTr from '@/components/t-table/t-tr.vue';
	import tTd from '@/components/t-table/t-td.vue';
	import uniPagination from '@/components/uni-pagination/uni-pagination.vue';
	import loading from '../../components/xuan-loading/xuan-loading.vue'
	export default {
		components: {
			tTable,
			tTh,
			tTr,
			tTd,
			uniPagination,
			loading
		},
		data() {
			return {
				tableList: [],
				pageno: 1, //当前页数
				total_pages: 0, //总页数
				pagesize: 8, //1页几条数据
				show_nodata: false
			}
		},
		onLoad() {},
		mounted() {
			this.getList();
		},
		methods: {
			//加载列表
			getList() {
				this.$refs.loading.open();
				this.$http.request({
					url: '/apis/mes/processReport/listOfReport',
					method: 'post',
					params: {
						pageno: this.pageno,
						pagesize: this.pagesize,
						isExamine:1
					},
				}).then(res => {
					this.$refs.loading.close();
					if (res) {
						if (res.data.code == 0) {
							this.tableList = res.data.data ? res.data.data.datas : []
							this.tableList.forEach(item=>{
								item.leftCount=parseInt(item.planCount)-parseInt(item.alreadyCount)
							})
							if (this.tableList.length == 0) {
								this.show_nodata = true
							}
							this.total_pages = res.data.data ? res.data.data.totalPages * this.pagesize : 0
						}
					}
				});
			},
			changePages(e) {
				this.pageno = e.current;
				this.getList();

			},
			edit(item) {
				uni.navigateTo({
					url: '/pages/processCheck/edit?id=' + item.id
				});
			}
		},
		onBackPress(options) { //取消默认的返回事件.
			uni.reLaunch({
				url: "/pages/index/index"
			});
			return true;
		}
	}
</script>

<style scoped>
	.container {
		position: absolute;
		width: 100%;
		height: 100%;
		background-color: #f3f3f3;
		box-sizing: border-box;
	}

	.top_head {
		position: fixed;
		top: var(-window-top);
		width: 100%;
		height: 60px;
		background-color: #007AFF;
		color: #fff;
		padding-left: 20px;
		box-sizing: border-box;
		z-index: 1;
	}

	.top_head1 {
		font-size: 15px;
		line-height: 60px;
	}

	.box {
		position: relative;
		height:calc(100% - 80px - 60px);
		width: calc(100% - 40px);
		margin: auto;
		margin-top: 80px;
		box-sizing: border-box;
		background-color: #fff;
	}

	.t-table {
		position: relative;
		height: 100%;
		padding-bottom: 10px;
	}

	.t-table .t-tr:nth-child(2n) {
		background: #dce7f9;
		border-top: 1px solid #c3c3c3;
		border-bottom: 1px solid #c3c3c3;
	}

	.t-td {
		padding: 8px;
		box-sizing: border-box;
		width: calc((100% - 560px) / 5);
	}

	.t-tr {
		height: calc(100% / 9);
	}

	.t-th {
		padding: 8px 0;
		box-sizing: border-box;
		width: calc((100% - 560px) / 5);
	}

	uni-button[type=primary] {
		position: relative;
		height: 95%;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.pagination {
		position: absolute;
		bottom: 10px;
		margin: auto;
		left: 0;
		right: 0;

	}

	.loading_container {
		/* 	position: relative;
		width: 200px;
		height: 200px; */
	}
	uni-button{
		font-size: 15px;
	}
</style>
