<template>
	<!-- 巡检管理搜索页 -->
	<view class="search-com">
		<view class="search-com-left">
			<uni-data-select v-if="!hiddenSearch.includes('inspectionType')" class="uni-search-item bigLong"
				v-model="searchFrom.inspectionType" :localdata="inspectArr" @change="(e) => change(e, 'inspectionType')"
				placeholder="类型"></uni-data-select>

			<uni-data-select v-if="!hiddenSearch.includes('synFlag')" class="uni-search-item" v-model="searchFrom.synFlag" :localdata="synchronization" placeholder="是否同步"
				@change="(e) => change(e, 'synFlag')"></uni-data-select>

			<uni-data-select v-if="!hiddenSearch.includes('isException')" class="uni-search-item"
				v-model="searchFrom.isException" :localdata="exceptionArr" placeholder="有无异常"
				@change="(e) => change(e, 'isException')" :key="new Date().getTime()"></uni-data-select>
		</view>

		<view class="search-com-right" v-if="!hiddenSearch.includes('inspectionTime')">
			<uni-datetime-picker class="uni-datetime-picker" type="daterange" v-model="searchFrom.inspectionTime"
				:border="false" @change="(e) => change(e, 'inspectionTime')" />
		</view>
	</view>
</template>
<script>
	export default {
		props: {
			hiddenSearch: {
				// 隐藏搜索项
				type: Array,
				default: () => {
					return [];
				},
			},
		},
		data() {
			return {
				searchFrom: {
					inspectionType: "", // 巡检类型
					synFlag: "", // 同部数据
					isException: "", // 有无异常
					inspectionTime: "", // 时间选择
				},

				inspectArr: [{
						value: "",
						text: "全部巡检"
					},
					{
						value: "1",
						text: "机房日常巡检"
					},
					{
						value: "2",
						text: "井道巡检"
					},
					{
						value: "3",
						text: "机房月度巡检"
					},
					{
						value: "4",
						text: "机房年度巡检"
					},
				],
				synchronization: [{
						value: "-1",
						text: "全部"
					},
					{
						value: "2",
						text: "编辑中"
					},
					{
						value: "0",
						text: "未同步"
					},
					{
						value: "1",
						text: "已同步"
					},
				],
				exceptionArr: [{
						value: "-1",
						text: "全部"
					},
					{
						value: "1",
						text: "有"
					},
					{
						value: "0",
						text: "无"
					},
				],
			};
		},
		methods: {
			change(e, key) {
				if(e == -1) e = ""
				this.searchFrom[key] = e;
				this.$emit("change", this.searchFrom);
			},
		},
	};
</script>

<style lang="less" scoped>
	.search-com {
		display: flex;
		align-items: center;
		margin-top: 8px;

		// width: 50%;
		.search-com-left {
			display: flex;
			align-items: center;
			::v-deep .uni-select{
				border: none !important;
			}
			.uni-search-item {
				height: 36px;
				margin-right: 16px;
				background: #fff;
				border-radius: 10px;
				border: none !important;
				&.bigLong{
					width: 240px;
				}
			}
		}

		.search-com-right {
			width: 300px;

			.uni-datetime-picker {
				height: 36px;
				background: #fff;
				border-radius: 10px;
				border: none !important;
			}
		}
	}
</style>