<template>
	<view class="container">
		<page-title>查询</page-title>
		<view class="cards-list">
			<view class="card only-card">
				<!-- 企业名称 -->
				<view class="card-item first-card-item">
					<view class="card-item-name">企业名称</view>
					<input v-model="params.title" class="card-item-input" placeholder="请填写企业名称" placeholder-style="color: #D8D8D8"
						maxlength="20" />
				</view>

				<!-- 审核状态 -->
				<view class="card-item" @click="showStatusChoose()">
					<view class="card-item-name">审核状态</view>
					<view class="card-item-description">
						<view v-if="params.status">{{params.status}}</view>
						<view v-else class="remind-text">请选择状态</view>
						<u-icon name="arrow-right" color="#343437" size="16" customStyle="margin-left:10rpx"></u-icon>
					</view>
				</view>
			</view>

			<view class="confirm-btn" @click="confirmParams()">确定</view>
		</view>

		<!-- 状态选择 -->
		<u-picker :show="statusShow" :columns="statusList" @confirm="statusClose" @cancel="statusClose" @close="statusClose"
			closeOnClickOverlay></u-picker>
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue'

	let params = ref({
		title: null,
		status: null,
	})

	let statusList = ref([
		["请选择", "暂存", "提交", "已审批"]
	])
	let statusShow = ref(false)

	function showStatusChoose() {
		statusShow.value = true
	}

	function statusClose(e) {
		if (e) params.value.status = e.value[0];
		statusShow.value = false;
	}

	function confirmParams() {
		let statusObj = {
			"请选择": "",
			"暂存": "0",
			"提交": "1",
			"已审批": "2"
		};

		let paramsData = {
			"title": params.value.title,
			"status": statusObj[params.value.status],
		};

		uni.$emit('enterpriseInfoSearch', paramsData);
		uni.navigateBack({});
	};
</script>

<style>
</style>