<!-- 隐患库 -->
<template>
	<view class="risk-record-page">
		<view class="main">
			<view class="content-list">
				<common-card :dataSource="item" :arrow="false" v-for="item in lists">
					<view class="content">
						<view class="field">
							<text class="left">检查发起部门：</text>
							<text class="value">{{item.DEPARTMENT_NAME}}</text>
						</view>
						<view class="field">
							<text class="left">检查类型：</text>
							<text class="value">{{item.CHECKTYPE_NAME}}</text>
						</view>
						<view class="field">
							<text class="left">检查人员：</text>
							<text class="value">{{item.CHECKTYPE_USERS}}</text>
						</view>
						<view class="field">
							<text class="left">隐患地点：</text>
							<text class="value">{{item.ADDRESS}}</text>
						</view>
						<view class="field">
							<text class="left"> 整改人：</text>
							<text class="value">{{item.ACTURE_USERNAME}}</text>
						</view>
					</view>
				</common-card>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		initFilter,
		extendRule,
		extendInclude
	} from '../../../../utils/common'

	import {
		GetListRiskDetail
	} from '../../../../services/apply/subPages/BS/lib'

	import UniSearchBar from '../../../../uni_modules/uni-search-bar/components/uni-search-bar/uni-search-bar.vue'

	export default {
		data() {
			return {
				ID: '',
				pageIndex: 0,
				lists: [],
				currentTab: 0,
				text: '',
				keyword: '',
				total: '',
			}
		},
		onLoad(option) {
			this.ID = option.ID
			this.loadData()
		},
		methods: {
			handleSearch() {
				this.pageIndex = 0
				this.loadData(false)
			},
			loadData(paginate) {
				this.pageIndex++
				const orgId = uni.getStorageSync('orgId')
				let json = initFilter(orgId, "", "CREATE_TIME", 1, this.pageIndex);
				extendRule(json, 'ID', 1, this.ID);
				// if (this.keyword) {
				// 	extendRule(json, 'CHECKTYPE_TIME', 9, this.keyword);
				// }
				json.IgnoreDataRule = true
				GetListRiskDetail(json).then(res => {
					this.total = res.TotalCount
					const newRes = (res.Data || []).map(i => {
						return {
							...i,
							title: i.CHECKTYPE_TIME,
						}
					})
					if (paginate) {
						this.lists = this.lists.concat(newRes)
					} else {
						this.lists = newRes
					}
				})
			},
			// handleShowPicker(p) {
			// 	let column = []
			// 	if (p.name === 'dateRange') {
			// 		column = ['当天', '最近三天', '最近一周', '最近一月']
			// 	}
			// 	if (p.name === 'status') {
			// 		column = ['正常', '未处理']
			// 	}
			// 	this.comPickerInfo = {
			// 		showPicker: true,
			// 		title: p.title,
			// 		name: p.name,
			// 		columns: [column]
			// 	}
			// },
		},
		onReachBottom() {
			if (this.total > 10 * this.pageIndex)
				this.loadData(true)
		}
	}
</script>


<style>
	@import url("../../../../style/css/listTemplate.css");
</style>