<template>
	<u-popup 
		round="10" 
		:show="isShow" 
		:closeOnClickOverlay="false">
		<view class="dialog" :style="{'min-height': minHeight}">
			<view class="dialog-header">
				<view class="header">
					<view class="btn" @tap="cancelDialog">取消</view>
					<view class="title">{{title}}</view>
					<view class="btn" @tap="confirmDialog">确定</view>
				</view>
				<view class="search" v-if="isSearch">
					<u-search placeholder="请输入关键词" :showAction="false" v-model="keyword" @change="searchDialog"></u-search>
				</view>
			</view>
			<view class="dialog-content">
				<slot></slot>
			</view>
			<view class="dialog-footer">
				<slot name="footer"></slot>
			</view>
		</view>
	</u-popup>
</template>

<script>
	export default {
		props: {
			isShow: {
				type: Boolean,
				default: false
			},
			title: {
				type: String,
				default: '操作弹窗'
			},
			minHeight: {
				type: String,
				default: ''
			},
			isSearch: {
				type: Boolean,
				default: false
			},
		},
		
		data() {
			return {
				keyword: '',
			}
		},
		
		onLoad() {
			
		},
		
		methods: {
			cancelDialog() {
				this.keyword = '';
				this.$emit('cancel');
			},
			
			confirmDialog() {
				this.keyword = '';
				this.$emit('confirm');
			},
			
			searchDialog() {
				this.$emit('search', this.keyword);
			}
		}
	}
</script>

<style lang="scss" scoped>
	.dialog {
		background: #ffffff;
		max-height: 88vh;
		display: flex;
		flex-direction: column;
		border-radius: 20rpx 20rpx 0 0;
		.dialog-header {
			.header {
				flex-shrink: 0;
				height: 120rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding: 0 30rpx;
				.btn {
					font-size: 32rpx;
					color: $theme-color;
				}
				.title {
					font-size: 36rpx;
					font-weight: 600;
				}
			}
			.search {
				padding: 0 30rpx 30rpx;
			}
		}
		.dialog-content {
			flex: 1;
			overflow-y: scroll;
		}
		.dialog-footer {
			padding: 0 30rpx;
		}
	}
</style>
