<template>
	<view class="content">

		<view class="content-middle" :style="{'opacity':!screenShow?'0.4':''}">
			<view class="content-middle-one">
				<view class="middle-one">
					<view class="content-middle-search">
						<text class='iconfont icon-sousuo2'></text>
						<input type='text' :value='keyword' placeholder='点击搜索商品、店铺名称' placeholder-class='placeholder'
							@input="setValue"></input>
					</view>
					<view class="content-middle-sai" @click="screen">
						<view class="content-middle-saia">
							<image src="../../static/images/saixuan1.png" mode="aspectFit"></image>
						</view>
						<view class="content-middle-saib">
							筛选
						</view>
					</view>
				</view>

			</view>
			<view class="content-middle-two">
				<view class="middle-two" v-for="(item,i) in list" :key='i' @click="arryitem(item)">
					<view class="middle-twoa">
						<image :src="item.img" mode=""></image>
					</view>
					<view class="middle-twob">
						{{item.name}}
					</view>
				</view>
			</view>
			<view class="content-middle-three" v-if="list2.length>0">
				<view class="middle-three" v-for="(item,k) in list2" :key='k'>

					<view class="middle-threea">企业员工</view>
					<liu-swipe-action :index="k" @clickItem="clickItem(item)" :btnList='btnList'>
						<view class="middle-threeb">
							<view class="middle-threeb-a">
								<view class="threeb-a-a">
									<image src="@/static/images/gw.png" mode=""></image>
									
								</view>
								<view class="threeb-a-b">
									<view class="name">{{item.department}} <text>({{item.name}})</text></view>
									<view class="achor">{{item.position}}</view>
								</view>
							</view>
							<view class="middle-threeb-b" @click="editpart(item)">
								<image src="@/static/images/bianji.png" mode=""></image>
							</view>

						</view>
					</liu-swipe-action>

				</view>
			</view>
		</view>
		<view class="content-middle" :style="{'position':'absolute','top':0+'px','zIndex':999}" v-if="!screenShow">
			<view class="content-middle-one">
				<view class="middle-one">
					<view class="content-middle-search">
						<text class='iconfont icon-sousuo2'></text>
						<input type='text' :value='keyword' placeholder='点击搜索商品、店铺名称' placeholder-class='placeholder'
							@input="setValue"></input>
					</view>
					<view class="content-middle-sai" @click="screen" style="background-color: #3274F9;">
						<view class="content-middle-saia">
							<image src="../../static/images/saixuan.png" mode="aspectFit"></image>
						</view>
						<view class="content-middle-saib" style="color: #fff;">
							筛选
						</view>
					</view>
				</view>
				<view class="content-middle-search-detail">
					<view class="search-detail" v-for="(item,i) in list3" :key='i' @click="saixun(item)">
						<view class="search-detail-one">
							<view class="name">
								员工状态
							</view>
						</view>
						<view class="search-detail-two">
							{{item.title}}
						</view>
					</view>

				</view>
			</view>
		</view>

		<view class="content-bootom" @click="adddepart">
			<view class="content-bootom-one">
				<image src="@/static/images/ja.png" mode=""></image>
			</view>
			<view class="content-bootom-two">添加企业员工</view>
		</view>
		<u-empty v-if="loadConfig.status=='nomore'&& list2.length==0" text="没有信息"
			icon="/static/empty/data.png"></u-empty>
		<u-loadmore v-else :status="loadConfig.status" :loading-text="loadConfig.loadingText"
			:loadmore-text="loadConfig.loadmoreText" :nomore-text="loadConfig.nomoreText" />
	</view>
</template>

<script>
	import {
		comanyerlist,
		leavedelete
	} from '@/api/oa.js'
	import {
		HTTP_REQUEST_URL
	} from '@/config/app.js'
	import {
		Toast
	} from '@/libs/uniApi.js'

	export default {

		data() {
			return {

				name: '人力资源',
				keyword: '',
				list: [{
					name: '部门架构',
					id: 1,
					img: require('@/static/images/r1.png')

				}, {
					name: '岗位职称',
					id: 2,
					img: require('@/static/images/r2.png')

				}, {
					name: '人事调动',
					id: 3,
					img: require('@/static/images/r3.png')

				}, {
					name: '离职档案',
					id: 4,
					img: require('@/static/images/r4.png')

				}],

				list2: [],
				list3: [{
						title: '禁止登录',
						id: 0

					},
					{
						title: '正常',
						id: 1

					}, {
						title: '离职',
						id: 2

					}

				],
				btnList: [{
					id: '2',
					name: '删除',
					width: '100rpx',
					bgColor: '#ed656d',
					color: '#FFFFFF',
					fontSize: '28rpx'
				}],
				loadConfig: {
					page: 1,
					limit: 5,
					loadingText: '努力加载中',
					loadmoreText: '轻轻上拉',
					nomoreText: '我也是有底线的~~',
					status: 'loadmore'
				},
				status: '',
				merchantData: {

				},
				screenShow: true
			};
		},
		onLoad() {


		},
		onShow() {
			this.initList()
		},
		onReachBottom() {
			this.getDocumentList()
		},
		onPullDownRefresh() {
			uni.stopPullDownRefresh()
		},
		methods: {
			arryitem(item) {
				console.log(item.id)
				switch (item.id) {

					case 1:
						uni.navigateTo({
							url: '/pages/structure/index'
						})
						break;
					case 2:
						uni.navigateTo({
							url: '/pages/jobtitle/index'
						})
						break;
					case 3:
						uni.navigateTo({
							url: '/pages/personneltransfer/index'
						})

						break;
					case 4:
						uni.navigateTo({
							url: '/pages/resignationprofile/index'
						})
						break;
				}
			},
			screen() {
				this.screenShow = !this.screenShow
			},
			async initList() {
				this.loadConfig.page = 1;
				this.loadConfig.status = "loadmore";
				this.list2 = [];
				await this.getDocumentList();
			},
			//获取人事调动
			async getDocumentList() {


				if (this.loadConfig.status == "nomore") return;
				this.loadConfig.status = "loading"
				let res = await comanyerlist({
					page: this.loadConfig.page,
					limit: this.loadConfig.limit,
					status: this.status,
					keyword: this.keyword,
				})
				console.log(res.data.data)
				this.loadConfig.status = "loadmore"
				if (res.data.data.length < this.loadConfig.limit) {
					this.loadConfig.status = "nomore"
				} else {
					this.loadConfig.page++;
				}
				this.list2 = [...this.list2, ...res.data?.data]

			},
			//添加人事调动
			adddepart() {
				uni.navigateTo({
					url: '/pages/addemployees/index?type=' + 0
				})
			},
			//删除弹窗
			clickItem(data) {



				uni.showModal({
					content: '确定要删除吗',
					success: (e) => {
						if (e.confirm) {
							this.deleteDepartment(data.id)
							this.initList()
						}
					}
				})

			},

			//删除
			async deleteDepartment(id) {

				const res = await leavedelete({
					id: id
				})

				if (res.code == 0) {
					this.initList()
				}
				Toast(res.msg);

			},
			//编辑人事调动
			editpart(item) {

				uni.navigateTo({
					url: '/pages/addemployees/index?type=' + 1 + "&data=" + item.id
				})
			},
			//查询
			search() {
				this.initList()
			},
			//输入监听
			setValue(e) {
				this.keyword = e.detail.value
				this.initList()

			},
			//筛选
			saixun(item) {
				this.status = item.id
				this.initList()
				this.screenShow = true
			},
		}
	};
</script>

<style lang="scss">
	page {
		padding-bottom: 88rpx;
	}



	.content-middle {
		.content-middle-one {
			.middle-one {
				display: flex;
				background-color: #FFFFFF;
				padding: 28rpx 18rpx;

				.content-middle-search {
					display: flex;
					width: 527rpx;
					height: 63rpx;
					line-height: 63rpx;
					padding-left: 30rpx;
					background: #F7F7F7;
					border-radius: 35rpx 35rpx;
					font-size: 25rpx;

					input {
						width: 527rpx;
						height: 63rpx;
						line-height: 63rpx;
						padding-left: 30rpx;
					}

					.placeholder {
						font-size: 25rpx;
						font-family: PingFang SC-Regular, PingFang SC;
						font-weight: 400;
						color: #999999;
						padding-left: 30rpx;

					}


				}

				.content-middle-sai {
					display: flex;
					width: 149rpx;
					height: 63rpx;
					line-height: 63rpx;
					background: #FFFFFF;
					border-radius: 35rpx 35rpx;
					border: 2rpx solid #E6E5E5;
					margin-left: 18rpx;

					.content-middle-saia {

						width: 29rpx;
						height: 28rpx;
						margin-left: 25rpx;
						margin-right: 10rpx;

						image {
							width: 100%;
							height: 100%;
						}
					}

					.content-middle-saib {
						font-size: 28rpx;

						font-family: PingFang SC-Regular, PingFang SC;
						font-weight: 400;
					}
				}
			}

			.content-middle-search-detail {
				background-color: #FFFFFF;

				:nth-last-child(1) {
					border: none !important;
				}

				.search-detail {
					display: flex;
					justify-content: space-between;
					padding-right: 195rpx;
					padding: 18rpx 53rpx;
					border-bottom: 2rpx solid #E6E6E6;
					;


					.search-detail-one {}
				}

			}
		}

		.content-middle-two {

			margin-bottom: 25rpx;
			display: flex;
			background-color: #FFFFFF;
			padding: 28rpx 28rpx;

			.middle-two {
				width: 25%;
				text-align: center;

				.middle-twoa {
					width: 120rpx;
					height: 120rpx;
					margin: 0 auto;

					image {
						width: 100%;
						height: 100%;
					}
				}

				.middle-twob {
					font-size: 25rpx;
					font-family: PingFang SC-Regular, PingFang SC;
					font-weight: 400;
					color: #666666;
				}
			}
		}

		.content-middle-three {
			margin-top: 26rpx;
			background-color: #FFFFFF;
			padding: 28rpx 28rpx;

			.middle-three {
				.middle-threea {
					font-size: 35rpx;
					font-family: PingFang SC-Bold, PingFang SC;
					font-weight: bold;
					color: #3274F9;
					margin-bottom: 30rpx;
				}

				.middle-threeb {
					display: flex;
					justify-content: space-between;


					.middle-threeb-a {
						display: flex;


						.threeb-a-a {
							width: 98rpx;
							height: 98rpx;
							border-radius: 11rpx 11rpx;
							margin-right: 25rpx;

							image {
								width: 100%;
								height: 100%;
							}
						}

						.threeb-a-b {
							.name {
								font-size: 35rpx;
								font-family: PingFang SC-Bold, PingFang SC;
								font-weight: bold;
								color: #333333;

								text {
									font-size: 25rpx;
									font-family: PingFang SC-Regular, PingFang SC;
									font-weight: 400;
									color: #CCCCCC;
								}
							}

							.achor {
								font-size: 28rpx;
								font-family: PingFang SC-Regular, PingFang SC;
								font-weight: 400;
								color: #999999;
							}
						}

					}

					.middle-threeb-b {
						width: 80rpx;
						height: 80rpx;
						margin-top: 45rpx;


						image {
							width: 100%;
							height: 100%;
						}
					}

				}
			}

		}
	}

	.content-bootom {
		width: 485rpx;
		height: 88rpx;
		text-align: center;
		line-height: 88rpx;
		background: #3274F9;
		border-radius: 60px 60px 60px 60px;
		display: flex;
		left: 50%;
		margin-left: -252.5rpx;
		position: absolute;
		bottom: 150rpx;
		z-index: 9999 !important;
		position: fixed;

		.content-bootom-one {
			margin-left: 92rpx;
			margin-top: 5rpx;
			width: 32rpx;
			height: 32rpx;
			margin-right: 40rpx;

			image {
				width: 100%;
				height: 100%;
			}
		}


		.content-bootom-two {
			font-size: 35rpx;
			font-family: PingFang SC-Bold, PingFang SC;
			font-weight: bold;
			color: #FFFFFF;
		}
	}
</style>