<template>
	<view class="modal-view">
    <view class="content">
      <view class="title">
      	<text>方案名称</text>
      </view>
			<!-- <view class="label">
				<text>请输入方案的名称</text>
			</view> -->
			<view class="input-box">
			  <input
				  class="input"
					maxlength="16"
					placeholder="限2~16个字符"
					placeholder-style="color: #A1A7B3"
					@blur="changeImproveScheme"
				/>
			</view>
			<view class="btn-box">
				<view class="btn" @click="close">
					<text>取消</text>
				</view>
				<view class="btn" @click="save">
					<text>保存</text>
				</view>
			</view>
    </view>
	</view>
</template>

<script>
	// 不认可原因
	export default {
    data() {
      return {
        // 方案名称
        improveScheme: ''
      }
    },
    methods: {
			changeImproveScheme(e) {
        this.improveScheme = e.detail.value;
        this.checkImproveScheme(e.detail.value);
      },
      // 校验方案名称
			checkImproveScheme(name) {
			  if(name.length < 2 || name.length > 16){
					uni.showToast({
						title: '限2~16个字符！',
						icon: 'none',
						duration: 500
          });
          return true;
				}
      },
      // 保存
      save() {
        if(this.checkImproveScheme(this.improveScheme)) return;
        this.$emit('sure', this.improveScheme);
      },
      close() {
        this.$emit('close');
      }
    }
	}
</script>

<style lang="less">
	.modal-view {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
		display: flex;
		align-items: center;
		justify-content: center;
    background: rgba(18, 20, 26, .5);

    .content {
			width: 562.5rpx;
			border-radius: 15rpx;
			background-color: #fff;
			overflow: hidden;

			.title {
				display: flex;
				align-items: center;
				justify-content: center;
				height: 95rpx;
				font-size: 25rpx;
				font-weight: bold;
				color: #292C33;
			}

			.label {
				display: flex;
				align-items: center;
				height: 78.75rpx;
				padding-left: 25rpx;
				font-size: 22.5rpx;
				color: #B8BECC;
			}

			.input-box {
				border-top: 0.62rpx solid #DADEE6;
				border-bottom: 0.62rpx solid #DADEE6;

				.input {
					width: 100%;
					min-height: 103.12rpx;
					padding: 0 25rpx;
					line-height: 26.25rpx;
					font-size: 22.5rpx;
					color: #525866;
					box-sizing: border-box;
				}
			}

			.btn-box {
				display: flex;
				height: 75rpx;

				.btn {
					display: flex;
					align-items: center;
					justify-content: center;
					flex: 1;
					font-size: 22.5rpx;
					color: #3377FF;

				  &:last-child {
				  	background-color: #007AFF;
				  	color: #fff;
			  	}
				}
			}
    }
	}
</style>
