<template>
	<view>
		<u-form-item
			:label="label"
			:prop="prop"
			:required="required"
			@click="visible = true"
		>
			<view class="select_content">
				<u-input
					:value="name || '请选择'"
					border="none"
					input-align="right"
					readonly
				/>
				<u-icon name="arrow-right"></u-icon>
			</view>
		</u-form-item>
		<u-line />
		<hidden-position
			:value="id"
			:visible.sync="visible"
			@confirm="fnConfirm"
		/>
	</view>
</template>

<script>
import HiddenPosition from "./hidden_position.vue";

export default {
	components: { HiddenPosition },

	props: {
		name: {
			type: String,
			required: true,
		},
		id: {
			type: String,
			required: true,
		},
		label: {
			type: String,
			default: "隐患部位",
		},
		prop: {
			type: String,
			default: "",
		},
		required: {
			type: Boolean,
			default: true,
		},
	},

	data() {
		return {
			visible: false,
		};
	},

	methods: {
		fnConfirm(evt) {
			this.name = evt[0].name;
			this.id = evt[0].id;
			this.visible = false;
		},
	},
};
</script>
