<template>
	<view>
		<!-- 头部搜索框 -->
		 <view class="fixed cu-bar search  bg-blue" :style="style">
				<view class="action" @click="back()">
					<image class="login-img" src="/static/user/bask.png"></image>
				</view>		
		 		<view class="search-form round">
		 			<image src="/static/index/search-gray.png" class="login-img margin-left margin-right"></image>
		 			<input  disabled="" type="text" @click="back()" placeholder="请输入关键字搜索" v-model="searchValue" confirm-type="search"></input>
		 		    <image  style="padding: 0;" @click="back()" src="/static/index/delete-gray.png" class="login-img margin-right-sm"></image>
				</view>
		</view>
		<scroll-view scroll-y class="bg-white">
			<view :style="paddingTop"></view>
			<!-- 内容 -->
			<view class="cu-card article no-card">
				<view class="cu-item shadow solid-bottom" v-for="(item,index) in data" :key="item.id" @click="navTo(item)">
					<view class="content">
						<view class="desc">
							<view class="text-black text-lg padding-top"> 
							  {{item.name}}
							</view>
							<view class="padding-top-sm flex justify-between">
								<view class="" v-for="(items,index2) in item.projectFilesTypeChildren" :key="index2">
									<image v-if="items.fileType==1"  class="menuImageTask margin-right-sm" src="/static/task/excel.png"></image>
									<image v-if="items.fileType==2"  class="menuImageTask margin-right-sm" src="/static/task/word.png"></image>
									<image v-if="items.fileType==3"  class="menuImageTask margin-right-sm" src="/static/task/pdf.png"></image>
									<image v-if="items.fileType==4"  class="menuImageTask margin-right-sm" src="/static/task/image.png"></image> 
								</view>
								<view class="margin-top">
									<text class="text-gray">共{{item.projectFilesChildren !=null ? item.projectFilesChildren.length:0}}个文件</text>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
			
			<view v-if="data.length!=0 && show"  class="flex justify-center text-gray margin-top-lg" >没有更多内容了~</view>
			<view v-if="data.length==0 && show" class="text-center">
				<view>
					<image class="menuImageNoTask" src="../../static/task/noTask.png"></image>
				</view>
				<view style="padding:28rpx 0 132rpx;font-size: 26rpx;color: #8A8A8A;">没有找到符合条件的记录~</view>
			</view>
		</scroll-view>
			
	</view>
</template>

<script>
	export default {
		computed: {
			style() {
				var StatusBar = this.StatusBar;
				var CustomBar = this.CustomBar;
				var bgImage = this.bgImage;
				var style = `height:${CustomBar}px;padding-top:${StatusBar}px;`;
				if (this.bgImage) {
					style = `${style}background-image:url(${bgImage});`;
				}
				return style
			}
		},
		data() {
			return {
				searchValue:"",
				paddingTop:"height:"+(this.StatusBar+50)+"px",
				data:[],
				show:false
			}
		},
		onLoad(e) {
			this.searchValue=e.searchValue;
			this.findFileBack();
		},
		methods: {
			 navTo(data){
				 uni.navigateTo({
				 	url:"/pages/documentList/documentList?title="+data.name+"&id="+data.id
				 })
			 },
			 back(){
				 uni.$emit("clear")
				 uni.navigateBack({
				 	delta:1
				 })
			 },
			findFileBack(){
				var that =this;
				var projectId = uni.getStorageSync("porject"+"_"+uni.getStorageSync("userInfo").id).id;
				var fileId = uni.getStorageSync("fileId");
				that.http.request("/app/divideClient/findFileBack",{name:that.searchValue,parentId:fileId}).then((res)=>{
					if(res.datas.length!=0){
						console.log(res)
						that.data=res.datas;
					}else{
						that.$prompt.none("无数据");
					}
					that.show=true;
				})
			}
		},
	}
</script>

<style>
    page{
		background-color: white;
	}
	.text-black{
		   color:#101010;
	}
	.menuImageNoTask{width:162rpx;height: 105rpx;margin-top: 60rpx;}
</style>
