<template>
	<view class="page">
<!-- 		<view class="head-search">
			<u-search bg-color="#fff" placeholder="请输入关键词" v-model="query.title" :show-action="false" @search="search"></u-search>
			<u-button type="success" @click="search">搜索</u-button>
		</view> -->
		<view style="margin: 20rpx 0;background-color: #FFFFFF;border-radius: 18rpx;border: 2rpx solid #E8E8E8;	margin: 22rpx 24rpx;overflow: hidden;" >
			<u-search :action-style="{'background':'#19be6b','color':'#fff','height':'32px','line-height':'32px','border-radius':'18rpx'}" bg-color="#fff" placeholder="请输入关键词" v-model="query.title" action-text="搜索" @clear="search" @search="search" @custom="search"></u-search>
		</view>
		<view class="screen-list">
			<view class="list" @click="show = true">
				<text>问卷类型</text>
				<image  :src="$imgUrl('/down.png')"></image>
				<u-select v-model="show" :list="areList" @confirm="(v) => {queryChange('questionnaireType', v)}"></u-select>
			</view>
			<!-- <view class="list" @click="setList(1)">
				<text>最新发布</text>
				<image :src="$imgUrl('/down.png')"></image>
			</view> -->
		</view>
		
		<view class="list-scorll">
			<view class='listbox' v-for="(item,index) in tableData" @click="go(`/pages/questionnaire/questDetail/questDetail?detail=${JSON.stringify(item)}`)">
				 <view class="img">
					 <image :src="$img+item.coverImage"></image>
				 </view>
				 <view class="info">
					 <view class="title" >{{item.title}}</view>
					 <view class="info-item">填写时长：<span>{{item.estimatedTime}}分钟</span></view>
					 <view class="info-item">填写时段：<span>{{item.startDate}}至{{item.endDate}}</span></view>
					 <view class="info-item">问卷类型：<span>{{item.questionnaireType}}</span></view>
				 </view>
			</view>
		</view>
	<!-- 	<view style="height: 120rpx;"></view>
		<view class="page-footer">
			<u-button type="success" @click="createWen">创建问卷</u-button>
		</view> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show: false,
				areList: [
					{value: '物业问卷', label: '物业问卷'},
					{value: '招商问卷', label: '招商问卷'},
					{value: '满意度问卷', label: '满意度问卷'},
					{value: '社会调查问卷', label: '社会调查问卷'},
				], // 区域列表
				query: {
					questionnaireType: '',
					title: '',
			pageNumber: 0,
			pageSize: 10,
				},
				tableData:[],
				pagesize:{
				pageNumber: 0,
				pageSize: 10,
				}
			};
		},
		mounted() {
			this.getAll()
			
		},
		methods:{
			getAll(){
				
				this.$http.sendRequest('/cereQuestionnaireTable/queryByPage', 'POST', this.pagesize,1).then(res => {
					//成功回调
					this.tableData = res.data.data.content
				})
			},
			go(urls){
				uni.navigateTo({
					url: urls
				})
			},
			queryChange(key, val) {
				this.query[`${key}`] = val[0].value;
				this.search();
			},
			search() {
				this.$http.sendRequest('/cereQuestionnaireTable/queryByPage', 'POST', this.query,1).then(res => {
					//成功回调
					this.tableData = res.data.data.content
					this.query =  {
					questionnaireType: '',
					title: '',
					pageNumber: 1,
					pageSize: 2
					}
				})
			},
			createWen(){
				uni.navigateTo({
					url: '/pages/createQuestionnaire/createQuestionnaire'
				})
			}
		}
	}
</script>

<style scoped lang="scss">
@import 'questionnaire.scss';
</style>
