<template>
	<view class="gradingControl">
		<scroll-view scroll-y @scrolltolower="scrollGet" class="for-max-box">
			<img class="null-img" v-if="!dataList[0]" :src="imagesUrl('commonality/null-data-1.png')">
			<view class="for-box" v-for="(item,index) in dataList" :key="index" @click="tableButton(item)">
				<view class="for-box-left">
					<view class="for-name-box">
						<view>{{item.name}}</view>
						<view :class="item.status == 1?'colorA':'colorB'">{{item.status == 1?'已执行':'未执行'}}</view>
					</view>
					<view class="for-dept-box">{{item.deptName}}</view>
					<view class="for-type-box">
						<view>{{item.typeName}}</view>
						<view>{{item.levelName}}</view>
					</view>
				</view>
				<view class="for-box-right">
					<img :src="imagesUrl('commonality/icon_04.png')">
				</view>
			</view>
			<view class="get-data-null-p" v-if="getDataType">- 没有更多数据 -</view>
		</scroll-view>
	</view>
</template>

<script>
	import {
		laboratoryGradeManageList,
	} from '@/pages_manage/api/index.js'
	export default {
		name: "gradingControl",
		data() {
			return {
				// 查询参数
				queryParams: {
					page: 1,
					pageSize: 10,
					name: "",
					deptId: null,
					typeId: null,
					levelId: null,
				},
				getDataType: false,
				//列表数据
				dataList: [],
			}
		},

		onLoad(option) {
			
		},
		onShow() {
			
		},
		mounted() {
			this.getList();
		},
		methods: {
			//滚动加载事件
			scrollGet() {
				let self = this;
				if (self.total / self.queryParams.pageSize <= self.queryParams.page) {
					this.$set(this, 'getDataType', true);
				} else {
					this.queryParams.page += 1;
					this.$nextTick(() => {
						this.getList();
					})
				}
			},
			//获取分级管控列表
			async getList() {
				let self = this;
				let obj = JSON.parse(JSON.stringify(this.queryParams));
				obj.executionUserId = uni.getStorageSync('userId')
				const {
					data
				} = await laboratoryGradeManageList(obj);
				if (data.code == 200) {
					if (self.queryParams.page == 1) {
						this.dataList = data.data.records;
						this.total = data.data.total;
						if (data.data.total / self.queryParams.pageSize <= self.queryParams.page) {
							this.$set(this, 'getDataType', true);
						}
					} else {
						this.dataList = [...this.dataList, ...data.data.records]
						this.total = data.data.total;
						if (data.data.total / self.queryParams.pageSize <= self.queryParams.page) {
							this.$set(this, 'getDataType', true);
						}
					}
				}
			},
			tableButton(item) {
				uni.navigateTo({
					url: '/pages_manage/views/gradingControl/infoPage?infoData=' + encodeURIComponent(JSON.stringify(item))
				});
			},
		}
	}
</script>

<style lang="stylus" scoped>
	.gradingControl {
		height: 100%;
		display: flex;
		flex-direction: column;

		.for-max-box {
			flex: 1;
			overflow-y scroll;

			.null-img {
				display block;
				width: 276rpx;
				height: 321rpx;
				position absolute;
				top: 200rpx;
				left: 274rpx;
			}

			.for-box:nth-child(1) {
				border-top: none;
			}

			.for-box {
				display: flex;
				padding: 10px;
				border-top: 4rpx solid #dedede;
				overflow hidden;
				background #ffffff;

				view {
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
					font-size: 32rpx;
					color: #333;
					line-height: 60rpx;
				}

				.for-box-left {
					flex: 1;

					.for-name-box {
						display: flex;
						view:nth-child(1) {
							flex: 1;
							font-size: 36rpx;
						}

						view:nth-child(2) {
							width: 100rpx;
							margin-left: 20rpx;
						}

						.colorA {
							color: #0183FA;
						}

						.colorB {
							color: #999;
						}

					}

					.for-dept-box {}

					.for-type-box {
						display: flex;

						view {
							flex: 1;
						}
					}
				}

				.for-box-right {
					img {
						margin-top: 80rpx;
						width: 12rpx;
						height: 24rpx;
					}
				}

			}

			.get-data-null-p {
				text-align: center;
				line-height: 80rpx;
				padding-bottom: 40px;
				color: #999;
			}
		}
	}
</style>