<template>
	<view>
		<view class="search">
			<view class="search-title">
				{{$t('dosugar.equipmentClientID')}}
			</view>
			<view class="search-input">
				<input type="text" :placeholder="$t('dosugar.placeholder')" v-model="searchClientId" />
			</view>
			<view class="search-button">
				<button type="primary" class="" @click="search()">
					<p class="">{{$t('dosugar.search')}}</P>
				</button>
			</view>
		</view>
		<view class="body">
			<uni-collapse :accordion="true">
				<uni-list>
					<view v-for="(equipment,index) in equipmentList" :key="index">
						<uni-list-item :title="equipment.name" :note="equipment.clientId" rightText="" clickable
							@click="onClick(equipment)" />
					</view>
				</uni-list>
			</uni-collapse>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapActions,
		mapMutations
	} from 'vuex';
	import uniCollapse from '@/components/uni-collapse/uni-collapse.vue';
	import uniCollapseItem from '@/components/uni-collapse-item/uni-collapse-item.vue';
	import uniList from '../../uni_modules/uni-list/components/uni-list/uni-list.vue';
	import uniListItem from '../../uni_modules/uni-list/components/uni-list-item/uni-list-item.vue';
	import uniIcons from '../../uni_modules/uni-icons/components/uni-icons/uni-icons.vue';
	export default {
		data() {
			return {
				equipmentName: null,
				equimentType: null,
				equipmentId: null,
				equipmentList: [],
				searchClientId: null
			}
		},
		onShow() {
			var token = uni.getStorageSync("token");
			this.globalUser = uni.getStorageSync("globalUser");
			if (token.length > 1) {
				// this.getEquipmentListData();
				// this.getParam();
			} else {
				uni.reLaunch({
					url: '../Login/Login',
				});
			}

		},
		methods: {
			search() {
				var token = uni.getStorageSync("token");
				var adminId = uni.getStorageSync("globalUser").id;
				uni.request({
					url: this.serverurl + '/TEquipment/getEquipmentListLikeClientId',
					data: {
						"clientId": this.searchClientId
					},
					header: {
						'token': token
					},
					method: "POST",
					success: (res) => {
						if (res.data.code) {
							this.equipmentList = res.data.data;
						}else{
							uni.showModal({
								title: "提示",
								content:res.data.message,
								success: (res) => {
								
								}
							})
						}
					},
				});
			},
			onClick(equipment){
				uni.navigateTo({
					url: 'jiebangDesc?equipment='+ encodeURIComponent(JSON.stringify(equipment)),
				});
			}
		}
	}
</script>

<style>
	.search {
		width: 100%;
		padding-top: 30upx;
		display: flex;
		flex-direction: row;
		justify-content: flex-start;
	}

	.search-title {
		width: 28%;
		text-align: center;
		font-size: 26upx;
		font-family: "PingFang-SC-Bold";
	}

	.search-input {
		width: 45%;
		text-align: center;
		font-size: 26upx;
		font-family: "PingFang-SC-Bold";
		box-shadow: 0upx 0upx 20upx #D3D3D3;
		border-radius: 5upx;
	}

	.search-button {
		width: 20%;
		padding-left: 7upx;
		text-align: center;
	}
</style>
