<template>
	<view>
		<!-- 吸顶搜索框 start -->
		<key-word-search-input
			:inputSearchValue="searchForm.HIDDENDESCR"
			@search="resetList"
			@showPicker="showPicker"
		/>
		<!-- 吸顶搜索框 end -->

		<!-- 列表渲染 start -->
		<list :list="list" @scrollToLower="scrollToLower">
			<template #default="{ item }">
				<view class="flex-between main-title">
					<text>被检查单位：{{ item.INSPECTED_CORPINFO_ID_NAME }}</text>
				</view>
				<view class="flex-between mt-10 subtitle">
					<text>检查发起人：{{ item.INSPECTION_ORIGINATOR_NAME }}</text>
					<text>检查类型：{{ item.INSPECTION_TYPE_NAME }}</text>
				</view>
				<view class="flex-between mt-10 subtitle">
					<text
						>检查时间：自 {{ item.INSPECTION_TIME_START }} 至
						{{ item.INSPECTION_TIME_END }} 止</text
					>
				</view>
				<view class="flex-between mt-10 subtitle">
					<text>
						状态：
						<template v-if="item.INSPECTION_STATUS == '0'"
							>待检查人核实</template
						>
						<template v-else-if="item.INSPECTION_STATUS == '1'"
							>检查人核实中</template
						>
						<template v-else-if="item.INSPECTION_STATUS == '2'"
							>待被检查人确认</template
						>
						<template v-else-if="item.INSPECTION_STATUS == '3'"
							>待指派</template
						>
						<template v-else-if="item.INSPECTION_STATUS == '4'"
							>指派中</template
						>
						<template v-else-if="item.INSPECTION_STATUS == '5'"
							>指派完成</template
						>
						<template v-else-if="item.INSPECTION_STATUS == '6'"
							>检查待验收</template
						>
						<template v-else-if="item.INSPECTION_STATUS == '7'"
							>检查已验收</template
						>
						<template v-else-if="item.INSPECTION_STATUS == '8'"
							>已归档</template
						>
						<template v-else-if="item.INSPECTION_STATUS == '-1'"
							>检查人核实打回</template
						>
						<template v-else-if="item.INSPECTION_STATUS == '-2'"
							>被检查人申辩</template
						>
					</text>
				</view>

				<view class="flex-end">
					<u-button
						type="primary"
						text="申辩记录"
						size="mini"
						shape="circle"
						@click="fnNavigatorPlead(item.INSPECTION_ID)"
					/>
				</view>
			</template>
		</list>
    <!-- 列表渲染 end -->
	</view>
</template>

<script>
import { getpleadList, getSafetyenvironmentalList } from "../../api";
import keyWordSearchInput from "@/components/keyWordSearchInput/index.vue";
import List from "@/components/list/list.vue";
import { initiateList } from "../../../Mock/safetyEnvirData";

export default {
	components: { keyWordSearchInput, List },

	data() {
		return {
			searchForm: {
				HIDDENDESCR: "",
			},
			pageSize: 10,
			currentPage: 1,
			totalPage: 0,
			list: [],
		};
	},
	computed: {
		userInfo() {
			return this.$store.getters.getUserInfo;
		},
	},
	onShow() {
		this.resetList();
	},
	methods: {
		async getData() {
			uni.showLoading({
				title: "加载中",
			});
			// TODO: 目前因后端资源接口未完成,故注释接口数据接入逻辑
			// let resData = await getpleadList({
			//   loginUserId: this.userInfo.USER_ID,
			//   supDeparIds: this.userInfo.supDeparIds,
			//   roleLevel: this.userInfo.roleLevel,
			//   CORPINFO_ID: this.userInfo.CORPINFO_ID,
			//   KEYWORDS: this.keyword,
			//   showCount: this.pageSize,
			//   currentPage: this.currentPage,
			// });
			// this.list = [...this.list, ...resData.varList];
			// this.totalPage = resData.page.totalPage;

			// 虚拟 mock 数据渲染
			setTimeout(() => {
				this.list = initiateList;
				this.totalPage = initiateList.length;
				uni.hideLoading();
			}, 400);
		},
		resetList() {
			this.pageSize = 10;
			this.currentPage = 1;
			this.list = [];
			this.getData();
		},
		fnNavigatorPlead(INSPECTION_ID) {
			uni.$u.route({
				url: "/safetyEnvirSubPackages/pages/defense-record/plead-list",
				params: {
					INSPECTION_ID,
				},
			});
		},
		scrolltolower() {
			this.currentPage++;
			if (this.totalPage >= this.currentPage) this.getData();
		},
	},
};
</script>

<style scoped></style>
