<template>
	<!-- 设置扣点模态框 -->
	<view class="cu-modal" :class="isShow?'show':''">
		<view class="cu-dialog">
			<view class="cu-bar bg-white justify-end">
				<view class="content">设置扣点</view>
				<view class="action" @tap="hideModal">
					<text class="cuIcon-close text-red"></text>
				</view>
			</view>
			<view class="padding-xl">
				<view>设置区域代理扣点可按百分比扣取或金额扣取的方式（建议二选一进行申请）</view>
				<view class="flex justify-center align-center margin-top-sm">
					<text>扣点：</text>
					<input class="radius-input" type="digit" placeholder="请输入订单扣取的比例" v-model="rate"></input>
					<text>%</text>
				</view>
				<view class="flex justify-center align-center margin-top-sm">
					<text>金额：</text>
					<input class="radius-input" type="digit" placeholder="请输入按单扣取的金额" v-model="amount"></input>
					<text>元</text>
				</view>
			</view>
			<view class="cu-bar bg-white">
				<view class="action margin-0 flex-sub text-black" @tap="hideModal">取消</view>
				<view class="action margin-0 flex-sub text-main-color solid-left" @tap="hideModal"
					@click="confirm">提交申请</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: 'set-take-rate',
		emits: ['confirm'],
		props: {
			leaderTeamRate: {
				type: String,
				default: ""
			},
			leaderTeamMoney: {
				type: String,
				default: ""
			}
		},
		data() {
			return {
				isShow: false,
				rate: '',
				amount: ''
			}
		},
		methods: {
			showModal(e) {
				this.isShow = true;
				this.rate = this.leaderTeamRate ? this.leaderTeamRate : '';
				this.amount = this.leaderTeamMoney ? this.leaderTeamMoney : '';
			},
			hideModal(e) {
				this.isShow = false;
			},
			confirm() {
				this.$emit('confirm', {
					leaderTeamRate: this.rate ? this.rate/100 : 0,
					leaderTeamMoney: this.amount
				});
			}
		}
	}
</script>

<style>
</style>
