<template>
	<div class="selectFile">
		<!-- <i class="menu el-icon-notebook-2" @click.stop="isShowfolderList= !isShowfolderList" style="margin-left: -3px"></i>
		<div class="folderList" v-show="isShowfolderList">
			<ul v-if="!!folderList && folderList.length > 0">
				<li v-for="(item,index) of folderList" :key="index" :class="[item.id==folderId?'active':'']" @click="nodeClick(item)">
					<i class="folder_icon"></i>{{item['label']}}
				</li>
			</ul>
			<div v-else>暂无数据</div>
			<el-button size="mini" type="primary" style="margin-top: 15px;width: 100%;height:30px;" @click="fileUpload">上传文件
			</el-button>
		</div> -->
		<el-button type="default" size="mini" class="fr" @click="toViewOCR">
			<i class="el-icon-search" style="font-size:14px;margin-right:5px;z-index:100000;"></i>OCR查看
		</el-button>
	</div>
</template>
<script type="text/javascript">
	export default{
		name: 'Control',
		props: ['sceneId','folderId'],
		data(){
			return {
				folderList: [],
				isShowfolderList: false,
			}
		},
		mounted(){
			this.getFoderList();
			window.onclick = (e) => {
				let ev = e || window.event;
				if(ev.target.localName == 'i' && ev.target.className.indexOf('el-icon-notebook-2') >= 0){
					return false;
				}
				this.isShowfolderList = false;
			}
		},
		methods: {
			getFoderList(){
				this.$ocrhttp({
					url: '/folder/findFileBySceneId?sceneId=' + this.sceneId,
					success: (res) => {
						if(res.code == 200 && res.data instanceof Array){
							this.folderList = res.data.filter( (item) => {
								return !!item && !!item.id && item.label;
							});
						}
					},
					error: (err) => {

					}
				});
			},
			nodeClick(node){
				if(node instanceof Object){
					this.$bus.emit('updateFolderId',node.id);
				}
			},
			fileUpload(){
				this.$bus.emit('openFileUpload',true);
			},
			toViewOCR(){
				this.$router.push({path: '/viewOCR'});
			}
		}
	}

</script>
<style type="text/css" scoped>
	.menu{
		cursor: pointer;
	}

	.selectFile{
		position: relative;
		padding: 6px 20px;
		width: 100%;
		height: 46px;
	}

	.selectFile i{
		font-size: 25px;
	}

	.selectFile .folderList{
		position: absolute;
		top: 10px;
		left: 42px;
		padding: 15px;
		width: auto;
		max-height: 500px;
		background: #fff;
		border: 3px solid #eee;
		z-index: 100;
		overflow: auto;
	}

	.selectFile .folderList li{
		font-size: 14px;
		cursor: pointer;
		line-height: 25px;
	}

	.selectFile .folderList li .folder_icon{
		margin-right: 8px;
		vertical-align: -3px;
		display: inline-block;
		width: 20px;
		height: 20px;
		background: url(/static/image/icon/folder_default.png) no-repeat center center;
	}

	.selectFile .folderList li.active .folder_icon{
		background: url(/static/image/icon/folder_open.png) no-repeat center center;
	}

	.selectFile .folderList li.active,
	.selectFile .folderList li:hover{
		color: #FCB412;
	}

	.dialog-body{
		padding: 20px;
	}

	.querybox{
		margin-bottom: 10px;
		width: 100%;
		height: 30px;
	}
	.querybox .query{
		display:inline-block;
		margin-left: 20px;
		width: 64px;
		height: 30px;
		background: #2a76cd;
		border-radius: 4px;
		color:#fff;
	}

	.current-tatal{
		float: left;
		font-weight: 400;
	}
	.setPageSize{
		float: left;
		margin-left: 10px;
		font-weight: 400;
	}
</style>
<style type="text/css">
	.selectFile .el-dialog__header{
		border-bottom: 1px solid #dbdcdc;
	}
	.selectFile .el-dialog__body{
		padding: 10px 20px;
	    color: #606266;
	    font-size: 14px;
	    word-break: break-all;
	}
	.selectFile .el-dialog__header .el-dialog__title{
		font-size: 16px;
		font-weight: 900px;
	}

	.selectFile .el-tree--highlight-current .el-tree-node.is-current>.el-tree-node__content {
	    background-color: #B7DBFC;
	}

	.selectFile button{
		padding: 0px 15px;
		height: 35px;
		line-height: 35px;
	}

	.selectFile .el-table__header-wrapper{
		border: 1px solid #dbdcdc;
		font-size: 14px;
		font-weight: 900px;
		color: rgba(60,68,85,0.7);
	}
	.selectFile .el-table__header-wrapper th{
		background: #f3f4f6;
	}
	.selectFile .el-table__body-wrapper{
		font-size: 14px;
		color: #3c4455;
	}

	.selectFile .el-pagination {
		margin-top: 10px;
	    white-space: nowrap;
	    padding: 2px 5px;
	    color: #303133;
	    font-weight: 700;
	    text-align: right;
	}
	.selectFile .el-pagination__sizes {
		float: left;
	    margin: 0 10px 0 5px;
	    font-weight: 400;
	    color: #606266;
	}
</style>
