<template>
	<view class="com-plan-content">
		<view class="title">
			<text>{{ title }}</text>
		</view>
		<view class="item-container">
			<view class="label-view">
				<text>{{ label }}</text>
			</view>
			<view class="content">
				<textarea class="textarea" :key="title" placeholder="请输入" placeholder-style="color: #B8BECC"
					:maxlength="500" auto-height :value="defaultValue" :disabled="disabled" @input="changeVal" />
			</view>
		</view>
		<view class="bottomBtn" @click="goToPrevPage" v-if="disabled">返回改善任务详情</view>
	</view>
</template>

<script>
	// 单个多行输入框 (改善计划（Plan）/oneTextarea)

	export default {
		props: {
			// 类型 (plan 和 action)
			type: {
				type: String,
				default: 'plan'
			},
			// 对策处置默认值
			defaultValue: {
				type: String,
				default: ''
			},
			// 是否禁用
			disabled: {
				type: Boolean,
				default: false
			},
		},
		computed: {
			// 多行文本框标题
			title() {
				return this.type === 'plan' ? '改善计划（Plan）' : '对策处置（Action）'
			},
			// 多行文本框子标题
			label() {
				return this.type === 'plan' ? '改善计划' : '对策处置'
			}
		},
		methods: {
			changeVal(e) {
				this.$emit('changeTextare', this.type, e.target.value);
			},
			goToPrevPage(){
				window.history.back();
			},
		},
	}
</script>

<style lang="less">
	.com-plan-content {
		height: 100%;
		padding-top: 35rpx;

		.bottomBtn {
			position: fixed;
			bottom: 0;
			width: 100%;
			height: 75rpx;
			line-height: 75rpx;
			text-align: center;
			font-size: 22.5rpx;
			font-family: SourceHanSansCN-Normal, SourceHanSansCN;
			font-weight: 400;
			color: #FFFFFF;
			background: #3377FF;
		}

		.title {
			line-height: 35rpx;
			padding: 0 25rpx;

			text {
				font-size: 35rpx;
				color: #292C33;
			}
		}

		.item-container {
			display: flex;
			margin-top: 25rpx;
			padding-left: 25rpx;
			background-color: #FFFFFF;

			.label-view {
				width: 175rpx;
				line-height: 37.5rpx;
				padding: 25rpx 0;

				>text {
					font-size: 22.5rpx;
					color: #666F80;
				}
			}

			.content {
				flex: 1;
				padding: 25rpx 0;

				.textarea {
					width: 100%;
					min-height: 810rpx;
					padding: 0 25rpx;
					line-height: 37.5rpx;
					font-size: 22.5rpx;
					color: #525866;
					box-sizing: border-box;
				}
			}
		}
	}
</style>
