<!-- 默认复制 -->

<template>
	<view class="content">
		<view class="top-heder">
			<view class="t-left" @click="getback()">
				<uni-icons type="left" size="18"></uni-icons>
			</view>
			<view class="t-title">
				<text>设备管理</text>
			</view>
			<view class="t-you"></view>
		</view>

		<view class="cont">

		<view @click="goadd('add')" style="width: 100%; display: flex; justify-content: center;background:white; margin: 10px 0px; box-sizing: border-box; padding: 10px;font-weight: bold;border-radius: 8px;">
			<text >  + 新增设备</text>
		</view>
		<view class="bjimg" v-if="arrlist == ''">
			<image src="http://www.nuoyunr.com/lananRsc/detection/qs.png" mode=""></image>
		</view>
		<view class="c-box"  v-for="(item,index) in arrlist" :key="index" >
			<view class="box-top">
				<view class="">{{item.equName || '设备名称'}}</view>
				<view style="display: flex;align-items: center; justify-content: space-between; width: 25%;">
					<view style="color: #43A045;"  @click="goadd('edit',item.id)">编辑</view>
					<view style="color: #FF7272;" @click="dialogToggle(item.id)" >删除</view>
				</view>
			</view>
			<view class="box-hui">
				<view class="box-left">设备型号:</view>
				<view class="">{{item.equModel || ''}}</view>
			</view>
			<view class="box-hui">
				<view class="box-left">设备编号:</view>
				<view class="">{{item.equNumber || ''}}</view>
			</view>
			<view class="box-hui">
				<view class="box-left">检定/校准周期:</view>
				<view class="">{{item.equZq || ''}}</view>
			</view>
			<view class="box-hui">
				<view class="box-left">有效期:</view>
				<view class="">{{item.validTime || ''}}</view>
			</view>
			<view class="box-hui">
				<view class="box-left">检定单位:</view>
				<view class="">{{item.lastUnit || ''}}</view>
			</view>
			<view class="box-hui">
				<view class="box-left">计划检定时间:</view>
				<view class="">{{item.nextCheckTime || ''}}</view>
			</view>

		</view>
		<uni-popup ref="alertDialog" type="dialog">
						<uni-popup-dialog  cancelText="关闭" confirmText="同意" title="通知" content="您确认要删除吗" @confirm="dialogConfirm"
							@close="dialogClose"></uni-popup-dialog>
					</uni-popup>

		</view>


	</view>
</template>

<script>
	import config from '@/config'
import code from '../../uni_modules/uview-ui/libs/config/props/code';
	import request from '../../utils/request';

	export default{
		data(){
			return{

			partnerId:'',
			arrlist:[],
			pageNum: 1,//第几页
			pageSize: 20,//一页多少张
			totalPages: 0,//总数
			deleteid:'',
			}
		},

		onLoad(){
			this.partnerId = uni.getStorageSync('partnerId')
			this.getlistindex()
		},
		onShow() {
			this.getlistindex()

		},
		onReachBottom() {
			if (this.pageNum >= this.totalPages) {
				uni.showToast({
					title: '没有下一页数据',
					icon: 'none'
				})

			} else {
				this.pageNum++
				this.getlistindex()
			}
		},
		methods:{
			dialogToggle(id) {
						this.deleteid = id
							this.$refs.alertDialog.open()
						},
		async dialogConfirm(id) {

					let res = await request({
						url: '/system/equInfo/' + this.deleteid,
						method: 'delete',

					})
					if(res.code == 200){
							this.$refs.alertDialog.close()
							uni.showToast({
								icon:'none',
								title:'删除成功'
							})
							this.getlistindex()
					}

						},
				dialogClose() {
								this.$refs.alertDialog.close
							},
			 goadd(type,id){
				uni.navigateTo({
					url:'/pages/manage/informationAdd?type='+type+'&id='+id
				})

			},
			getback(){
				uni.navigateBack()
			},
		async getlistindex(){
			let res = await request({
				url: '/system/equInfo/list',
				method: 'get',
				data: {
					partnerId:this.partnerId,
					pageSize:this.pageSize,
					pageNum:this.pageNum
				}
			})
			// this.arrlist = res.rows
			if (this.pageNum != 1){
				this.arrlist = this.arrlist.concat(res.rows)

			}else{
				this.arrlist = res.rows
				}
			let total =  res.total
			this.totalPages = Math.ceil(total / this.pageSize);
		},


		},


	}
</script>

<style scoped lang="scss">
	.content{
		width: 100%;
		height: calc(100vh);
		background-color: #F6F6F6;
		box-sizing: border-box;
		// padding-top: 45px;
	}
	.top-icon{
		margin-bottom: 45px;
	}
	.q-fab{
		position: fixed;
		bottom: 50px;
		right: 15px;
		width: 55px;
		height: 55px;
		border-radius: 50%;
		overflow: hidden;
		image{
			width: 100%;
			height: 100%;
		}
	}
	.fab-z1{
		position: fixed;
		bottom: 115px;
		right: 15px;
		width: 50px;
		height: 50px;
		border-radius: 50%;
		overflow: hidden;
		image{
			width: 100%;
			height: 100%;
		}
	}
	.fab-z2{
		position: fixed;
		bottom: 50px;
		right: 80px;
		width: 50px;
		height: 50px;
		border-radius: 50%;
		overflow: hidden;
		image{
			width: 100%;
			height: 100%;
		}
	}
	.c-tap{
		width: 100%;
		height: 40px;
		box-sizing: border-box;
		padding: 15px;
		display: flex;
		background-color: white;
		align-items: center;
	}
	.c-top{
	display: flex;
	align-items: center;
	justify-content: space-between;
	}
	.c-title{
		font-size: 18px;
		font-weight: bold
	}
	.cont{
		width: 100%;
		padding: 15px;
		padding-top: 0px ;
		box-sizing: border-box;
		background-color: #F6F6F6;

	}
	.hongdian{
		width: 15px;
		height: 15px;
		background-color: crimson;
		border-radius: 50%;
		overflow: hidden;
		position: absolute;
		top: 5px;
		right: 5px;
		z-index: 9999;
	}
	.c-box{
		width: 100%;
		box-sizing: border-box;
		padding: 10px;
		background-color: white;
		margin-top: 10px;
		border-radius: 10px;


	}
	.c-b-top{
		width: 100%;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	.t-left{
		width: 40%;
		height: 100px;
		border-radius: 7px;
		margin-right: 10px;
		overflow: hidden;
		image{
			width: 100%;
			height: 100%;
		}

	}
	.t-right{
		width: 60%;
	}
	.t-tilte{
		font-size: 20px;
		font-weight: bold;
		color: #333333;
		 white-space: nowrap;
		 overflow: hidden;
		 text-overflow: ellipsis;

	}
	.tw-tilte{
		width: 100%;
		text-align: right;
		font-size: 16px;
		font-weight: bold;
		color: #5e5e5e;
		 white-space: nowrap;
		 overflow: hidden;
		 text-overflow: ellipsis;

	}
	.t-zi{
		font-size: 14px;
		font-weight: 400;
		color: #666666;
		 overflow: hidden;
		  text-overflow: ellipsis;
		  display: -webkit-box;
		  -webkit-line-clamp: 3;
		  -webkit-box-orient: vertical;

	}
	.bjimg{
		width: 255px;
		height: 236px;
		margin: 0px auto;
		margin-top: 100px;
		image{
			width: 100%;
			height: 100%;
		}
	}
	.c-b-bom{
		width: 100%;
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-top: 5px;
	}
	.b-left{
		color: #0D2E8D;
		font-size: 14px;
	}
	.b-right{
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	.z-lv{
		display: flex;
		align-items: center;
		color: #0D2E8D;
		font-size: 15px;
		margin-right: 10px;
	}
	.y-hong{
		display: flex;
		align-items: center;
		color: #fa3534;
		font-size: 15px;
		margin-right: 15px;
	}
	.z-img{
		width: 20px;
		height: 15px;
		image{
			width: 100%;
			height: 100%;
		}
		margin-right: 2px;
	}
	.tap-box{
		width: 30%;
		text-align: center;
	}
	.gang{
		height: 4px;
		background: #0D2E8D;
		width: 80%;
		margin: 0px auto;
	}
	.lan{
		color: #0D2E8D;
	}
	.top-heder{
		width: 100%;
		height: 68px;
		background: white;
		display: flex;
		align-items: center;
		justify-content: space-between;
		box-sizing: border-box;
		padding: 5px 15px;
	}
	.t-title{
		font-size: 17px;
		font-weight: bold;
		color: #333333;
	}
	.t-left{
		width: 20%;
		height: 20px;
	}
	.t-you{
	width: 20%;
	height: 20px;
	}
	.box-top{
		font-size: 16px;
		font-weight: bold;
		color: #333333;
		box-sizing: border-box;
		padding-bottom: 10px;
		border-bottom: 1px solid #EEEEEE;
		margin-bottom: 10px;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}
	.box-hui{
		font-size: 15px;
		font-weight: 400;
		color: #999999;
		display: flex;
		margin-bottom: 5px;
	}
	.box-left{
		margin-right: 10px;
	}
</style>
