<template>
	<view class="container">
		<view class="grxx">
			<view class="grxxItem">
				<view class="sfzhm">
					<view class="uni-list-cell-left">
						临时流调名称
					</view>
					<view class="uni-list-cell-db">
						<input type="text" placeholder="请输入临时流调名称" v-model="name" />
					</view>
				</view>
			</view>
		</view>
		<editor id="editor" class="ql-container" :placeholder="placeholder" @ready="onEditorReady" @input="onEdiInput">
		</editor>
		<view class="">
			<button type="primary" @click="fqdo">保存</button>
		</view>
	</view>
</template>

<script>
	import {
		postRequest,
		getRequest
	} from '../../api/api.js'
	export default {
		data() {
			return {
				placeholder: '请输入风险区域...',
				riskyArea: '',
				name:''
			}
		},
		onLoad() {
			
		},
		methods: {
			onEditorReady() {
				// #ifdef MP-BAIDU
				this.editorCtx = requireDynamicLib('editorLib').createEditorContext('editorId');
				// #endif

				// #ifdef APP-PLUS || H5 ||MP-WEIXIN
				uni.createSelectorQuery().select('#editor').context((res) => {
					this.editorCtx = res.context
				}).exec()
				// #endif
			},
			onEdiInput(e) {
				this.riskyArea = e.detail.html
			},
			undo() {
				this.editorCtx.undo()
			},
			fqdo() {
				let data = {
					name: this.name,
					riskyArea: this.riskyArea,
				}
				postRequest('/dailyRegisterType/insert', data).then(res => {
					if (res.code == '200') {
						uni.navigateTo({
							url:'/pages/lsldList/lsldList'
						})
					}
				})
			}
		}
	}
</script>

<style>
	.container {
		padding: 10px;
	}

	#editor {
		width: 100%;
		height: 300px;
		background-color: #CCCCCC;
	}

	button {
		margin-top: 10px;
	}

	.grxxItem {
		border-radius: 5px;
		margin-bottom: 10px;
		box-shadow: 0px 2px 15px 3px rgba(0, 0, 0, 0.1);
	}

	/deep/.uni-combox__input {
		font-size: 14px;
	}

	.grxxItem .ygxm {
		padding: 10px;
		background-color: #3297ff;
		color: white;
	}

	.grxxItem .sfzhm {
		padding: 10px;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 10px;
		font-size: 84%;
		color: #999999;
		position: relative;
	}
	
	.sfzhm image {
		width: 28rpx;
		height: 30rpx;
	}

	.grxxItem .mdd {
		justify-content: left;
	}

	.grxxItem .mdd input {
		width: 70%;
		margin-left: 10px;
	}

	.hxx {
		position: absolute;
		color: red;
		left: 3px;
		top: 25%;
	}
	.uni-list-cell-db input{
		font-size: 14px;
	}
	.grxxItem .sfzhm:last-of-type {
		border: none;
	}
</style>
