<template>
	<view>
		<image src="/static/icon/background.png" mode="" class="background"></image>
		<view class="" style="padding-top: 90rpx;">
			<back></back>
		</view>
		<view style="padding-top: 60rpx;">
			<view style="margin: 20rpx;">
				<u-input disabled placeholder="请选择巡检人员" @click="showName=true" v-model="userName"></u-input>
				
				<u-select v-model="showName" :list="workList"  label-name="name" value-name="id" @confirm="worker()" @cancel="cancelWorker()"></u-select>
					<u-search placeholder="请输入巡检柱名称" v-model="name" :action-style="{'font-size':'40rpx'}" 
						@custom="getProjectList()"></u-search>
			</view>

			<view v-for="(item,index) in list" :key="index">
				<view class="project-content" @click="gotoindex(item)">
					<view>
						<view class="font-forty-eight blue">
							{{item.name}}<u-icon name="arrow-right"></u-icon>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
	</view>
</template>

<script>
	import service from '@/api/index.js'
	export default {
		data() {
			return {
				params: {
					year: true,
					month: true,
					day: true,
					hour: true,
					minute: false,
					second: false
				},
				showName:false,
				showTime: false,
				list: [],
				workList: [],
				value: '',
				nameValue: '',
				name:'',
				userName:'',
				civilPower: '',
				form:{},
				userId:''
			}
			
		},
		onLoad() {
			this.getProjectList();
			this.getUserName();
			this.getWorker()
		},
		methods: {
			getWorker()
			{
				service.getWorker().then(res => {
					this.workList=res
				})
			},
			worker(e)
			{
				this.userName=e[0].label
				this.userId=e[0].value
			},
			cancelWorker()
			{
				this.userName=''
				this.userId=''
			},
			time(e)
			{
				 this.form.time=e
			},
			gotoindex(item) {
				console.log(item)
				uni.navigateTo({
					url:`/pages/noLogin/WarningPileForm/WarningPileForm?value=${item.id}`
				})
			},
			topage(url) {
				uni.navigateTo({
					url
				})
			},
			getProjectList() {
				service.getwarningPileList({name:this.name,userId:this.userId}).then(res => {
					console.log('getwarningPileList', res)
					if (res.length == 0) {
						this.$UTILS.showPrompt('暂无项目!')
					}
					this.list = res;
				})
			},
			getUserName() {
				service.getUserName().then(res => {
					this.civilPower = res.civilPower;
				})
			},
		},
	}
</script>

<style lang="scss" scoped>
	.background {
		z-index: -1;
		position: fixed;
		width: 100%;
		height: 100%;
		background-size: 100% 100%;
	}

	.project {
		border-radius: 72rpx;
		padding: 25rpx 0;
		text-align: center;
		margin: 170rpx 55rpx 0;
	}

	.project-content {
		border: 4rpx solid #3857F3;
		margin: 40rpx 55rpx 0;
		padding: 30rpx 20rpx;
		border-radius: 48rpx;
	}

	.position {
		position: absolute;
		bottom: 100rpx;
		right: 50rpx;

		.arrow {
			width: 152rpx;
			height: 152rpx;
			border-radius: 50%;
			padding: 25rpx;
			margin-left: 20rpx;
		}
	}
</style>