<template>
	<view class="list">
		<view class="list-header">
			<view class="list-header-text">
				<view class="list-header-text-neishi" @click="topgi">
					<view class="list-header-text-icon">
						<image src="https://cdn.bjtdba.com/vod/image/2022-08-11/20220811133828415.png" mode="widthFix">
						</image>
					</view>
				</view>

				<view class="list-header-text-title">
					员工管理
				</view>
			</view>
		</view>
		<view class="list-bumen">
			<view class="list-bumen-text">
				添加员工
			</view>
			<view class="list-bumen-icon" @click="tinjia">
				<image src="https://cdn.bjtdba.com/vod/image/2022-08-11/20220811165146454.png" mode="widthFix"></image>
			</view>
		</view>
		<view class="list-neilist">
			<view class="list-neilist-nibu" v-for="(item,index) in list" :key="index">
				<view class="nribyu">
					<view class="nribyu-left">
						<view class="nribyu-left-icon">
							<image :src="item.avatar" mode="widthFix"></image>
						</view>
						<view class="nribyu-left-jias">
							<view class="">
								部 门: {{item.departmentName}}
							</view>
							<view class="">
								姓 名: {{item.name}}
							</view>
							<view class="">
								手机号: {{item.phone.substr(0, 3) + '****' + item.phone.substr(7)}}
							</view>
							<!-- 	<view class="">
								密 码:
							</view> -->
						</view>
					</view>
					<view class="nribyu-right">
						<view class="nribyu-right-img">
							<image src="https://cdn.bjtdba.com/vod/image/2022-08-12/20220812110126708.png"
								mode="widthFix"></image>
						</view>
						<view class="" @click="Update(item)">
							编辑
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		queryStoreStaff
	} from '@/commit/api.js'
	export default {
		data() {
			return {
				merId: '',
				list: []
			}
		},
		onLoad() {
			let selectmerchant = uni.getStorageSync('selectmerchant')
			this.merId = selectmerchant.merId
			this.queryStoreStaff()
		},
		methods: {
			// 根据部门id查询所有员工
			queryStoreStaff() {
				queryStoreStaff({
					merId: this.merId
				}).then(res => {
					console.log(res.data.data, 99)
					if (res.data.status == 200) {
						this.list = res.data.data.storeStaffList
					}
				}, fail => {
					console.log(fail)
				})
			},
			// 修改门店员工信息
			Update(e) {
				console.log(e)
				let id = e.id
				let merId = e.merId
				let name = e.name
				let phone = e.phone
				let department = e.department
				let departmentName = e.departmentName
				uni.redirectTo({
					url: './listadd?id=' + id + "&merId=" + merId + "&name=" + name + "&phone=" + phone +
						"&department=" + department + "&departmentName=" + departmentName + "&can=" +
						1
				});
			},
			tinjia() {
				uni.redirectTo({
					url: './listadd'
				});
			},
			topgi() {
				uni.switchTab({
					url: '../../pages/storemanagement/index'
				});
			}
		}
	}
</script>

<style>
	page {
		background-color: #F7F8FC;
	}
</style>
<style lang="scss" scoped>
	.list {
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;

		.list-header {

			width: 100%;
			height: 176rpx;
			background: #FFFFFF;
			position: fixed;
			top: 0;
			left: 0;
			z-index: 111;
			display: flex;
			justify-content: center;

			.list-header-text {
				width: 686rpx;
				font-size: 36rpx;
				font-weight: 500;
				color: #333333;
				display: flex;
				margin-top: 107rpx;
				align-items: center;

				.list-header-text-neishi {
					width: 45rpx;
					height: 45rpx;
					margin-right: 17rpx;

					.list-header-text-icon {
						width: 36rpx;
						height: 36rpx;
						margin-top: 2rpx;

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

		.list-bumen {
			width: 686rpx;
			font-size: 32rpx;
			font-weight: 400;
			color: #333333;
			display: flex;
			justify-content: flex-start;
			align-items: center;
			margin: 202rpx 0 32rpx 0;

			.list-bumen-icon {
				width: 28rpx;
				height: 28rpx;
				margin-left: 12rpx;
				line-height: 28rpx;

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

		.list-neilist {
			width: 100%;
			height: 100%;
			display: flex;
			flex-direction: column;
			align-items: center;

			.list-neilist-nibu {
				display: flex;
				align-items: center;
				justify-content: center;
				width: 686rpx;
				height: 232rpx;
				background: #FFFFFF;
				border-radius: 8rpx;
				margin-bottom: 26rpx;

				.nribyu {
					width: 640rpx;
					height: 180rpx;
					display: flex;
					align-items: flex-start;
					justify-content: space-between;

					.nribyu-left {
						width: 532rpx;
						height: 100%;
						display: flex;
						justify-content: space-between;
						align-items: center;

						.nribyu-left-icon {
							width: 180rpx;
							height: 180rpx;
							border-radius: 12rpx;

							image {
								width: 100%;
								height: 100%;
								height: 100%;
								border-radius: 12rpx;
								overflow: hidden;
							}
						}

						.nribyu-left-jias {
							width: 327rpx;
							height: 100%;
							display: flex;
							flex-direction: column;
							justify-content: space-between;
							align-content: flex-start;
							font-size: 30rpx;
							font-weight: 400;
							color: #333333;
						}
					}

					.nribyu-right {
						width: 86rpx;
						height: 26rpx;
						display: flex;
						justify-content: space-between;
						align-items: center;
						font-size: 26rpx;
						font-weight: 400;
						color: #333333;

						.nribyu-right-img {
							width: 26rpx;
							height: 26rpx;
							line-height: 26rpx;

							image {
								width: 100%;
								height: 100%;
							}
						}
					}
				}
			}
		}
	}
</style>
