<template>
	<view>
		<navbar 
		:title="title"
		leftClick @leftClick="$utils.navigateBack" />
		
		<view class="search">
			<uv-search 
			placeholder="请输入岗位/公司名称" 
			:showAction="false"
			search-icon-size="40rpx"
			@search="search"
			v-model="queryParams.title"></uv-search>
		</view>
		
		<!-- 筛选器 -->
		<!-- <screenWork @clickItem="clickItem" ref="screenWork"/> -->
		
		<!-- 老板看到的 -->
		<userList ref="workList" v-if="role"/>
		
		<!-- 工人看到的 -->
		<workList ref="workList" v-else/>
		
	</view>
</template>

<script>
	import screenWork from '@/components/screen/screenWork.vue'
	import workList from '@/components/list/workList/index.vue'
	import userList from '@/components/list/userList/index.vue'
	import {
		mapState,
	} from 'vuex'
	export default {
		components : {
			workList,
			screenWork,
			userList,
		},
		computed: {
			...mapState(['userInfo', 'role']),
		},
		data() {
			return {
				keyword : '',
				title : '',
				queryParams : {
				},
				screenWorkList : [],
			}
		},
		onPullDownRefresh(){
			this.$refs.workList.getData(this.screenWorkList, this.queryParams)
		},
		// 页面显示的时候触发
		onShow() {
			this.$refs.workList.getData(this.screenWorkList, this.queryParams)
		},
		onLoad({typeId, title, keyword}) {
			if(title){
				this.title = title
			}
			if(typeId){
				this.queryParams.typeId = typeId
			}
			if(keyword){
				this.queryParams.title = keyword
				this.title = keyword
			}
		},
		methods: {
			clickItem(result){
				console.log(result);
				this.screenWorkList = result
				this.$refs.workList.getData(this.screenWorkList, this.queryParams)
			},
			search(){
				this.$refs.workList.getData(this.screenWorkList, this.queryParams)
			},
		}
	}
</script>

<style scoped lang="scss">
.search{
	padding: 20rpx;
	display: flex;
	justify-content: center;
	background-color: #fff;
	/deep/ .uv-search__content__icon{
		padding: 10rpx 0;
	}
}
</style>
