<template>
	<view class="content">
		<view class="search-bar">
			<u--form :model="searchForm" ref="searchForm">
				<u-form-item label="仓房名称:" prop="storehouseName" label-width="80px">
					<u--input v-model="searchForm.storehouseName"></u--input>

					<u-button type="primary" text="查询" class="btn" @tap="search"></u-button>
					<u-button text="重置" class="btn" @tap="reset"></u-button>
				</u-form-item>

			</u--form>
		</view>
		<uni-table border stripe emptyText="暂无更多数据" :loading="this.loading">
			<!-- 表头行 -->
			<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 align="center" width="200">操作</uni-th>
			</uni-tr>
			<!-- 表格数据行 -->
			<uni-tr v-for="(item, index) in tableData" :key="item.id">
				<uni-td align="center">{{ index + 1 }}</uni-td>
				<uni-td align="center">{{ item.orgName }}</uni-td>
				<uni-td align="center">{{ item.storehouseName }}</uni-td>
				<uni-td align="center">{{ item.warehouseName }}</uni-td>
				<uni-td align="center">{{ item.grainVarietyName }}</uni-td>
				<uni-td align="center">{{ item.harvestYear }}</uni-td>
				<uni-td align="center">{{ item.inspectionDate }}</uni-td>
				<uni-td align="center">
					<view class="opts">
						<u-button text="查看" @tap="view(item)" class="btn"></u-button>
						<u-button v-if="couldEdit(item)" text="修改" @tap="edit(item)" class="btn"></u-button>
					</view>
				</uni-td>
			</uni-tr>

		</uni-table>
		<uni-pagination show-icon="true" :total="pageInfo.total" :current="pageInfo.current" class="pagination"
			@change="paginationChang"></uni-pagination>
	</view>
</template>

<script>
	import simpleList from '@/components/simple-list/index'
	import {
		getList,
	} from '@/api/safeStorageInspect.js'
	import {
		server_host
	} from '@/config/system'
	import {
		errorMsg, isNull
	} from '@/utils/tools'
	export default {
		mixins: [simpleList],
		data() {
			return {
				editPath: '/pages/safeStorageInspect/safeStorageInspectEdit',
				searchForm: {
					storehouseName: null,
				},
			}
		},
		methods: {
			getListFun() {
				return getList
			},
			couldEdit(data) {
				return isNull(data.storehouseName) && isNull(data.warehouseName) && isNull(data.inspector) && isNull(data.inspectionDate)
			},
		}
	}
</script>

<style scoped lang="scss">
	.content {
		padding: 10px;

		.btn {
			width: 100px;
			margin-left: 5px;
		}

		.tip {
			color: red;
		}

		.exports {
			margin-bottom: 10px;
		}
	}

	.msg {
		padding-left: 10px;
	}

	.opts {
		width: 100%;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.search-bar {}
</style>