<template>
	<PageLayout navTitle="设备管理" :rightButtons="rightButtons">
		<!-- <view style="margin: 0 10px;" >
			<uni-segmented-control style="margin-top: 10px;margin-bottom: 10px" :current="current" :values="items"
				@clickItem="onClickItem" styleType="button"></uni-segmented-control>
		</view> -->
		<view class="content">
			<Personaldevices></Personaldevices>
		</view>
		<!-- 		<view class="content" >
			<view v-if="current === 0 ">
				<Personaldevices></Personaldevices>
			</view>
			<view v-if="current === 1 ">
				<text v-if="!isleader">您目前没有查看该页面权限！</text>
				<ALLleader v-if="isleader"></ALLleader>
				<ALLleader ></ALLleader>
			</view>
		</view> -->
	</PageLayout>
</template>

<script setup>
	import Personaldevices from './Personaldevices'
	import ALLleader from './ALLleader'
	//获取当前登陆人
	import {
		useUserStore
	} from '@/store/user'
	// import { navigateTo } from '@dcloudio/uni-app'

	const current = ref(0)
	const items = ref(['个人使用房间设备', '全部房间设备'])
	const userStore = useUserStore();
	const isleader = ref(false)

	// 定义右侧按钮配置
	const rightButtons = ref([{
		text: '跳转管理端',
		fontSize: '14px',
		color: '#007AFF',
		// 如果需要图标，可以添加 icon 属性
		// icon: 'https://example.com/icon.png'
	}])
	// 监听导航栏右侧按钮点击事件
	onNavigationBarButtonTap(() => {
		// 跳转到管理端页面
		uni.navigateTo({
			url: '@/pages-home/device-control/office/ALLleader'
		})
	})

	function onClickItem(e) {
		console.log("dianji le ---", current.value)
		if (current.value != e.currentIndex) {
			current.value = e.currentIndex;
		}
	}

	onLoad(() => {
		// 获取当前登录人的信息
		// f6817f48af4fb3af11b9e8bf182f618b管理员，
		//1455737078531104770 厂长，
		//1455737215009562625 厂书记，
		//1455737513371377665 厂领导，
		//1358226526012129281 厂主管领导
		// console.log("当前登陆人信息000", userStore.userInfo.roles)
		// console.log("当前登陆人信息222222222222", userStore.userInfo.roles.split(","))

		for (let a = 0; a < userStore.userInfo.roles.split(",").length; a++) {
			console.log("userStore.userInfo.roles.split(", ")[a]：", userStore.userInfo.roles.split(",")[a])
			let rolesid = userStore.userInfo.roles.split(",")[a];
			if (rolesid == "1455737078531104770" || rolesid ==
				"f6817f48af4fb3af11b9e8bf182f618b" || rolesid ==
				"1455737215009562625" || rolesid ==
				"1455737513371377665" || rolesid ==
				"1358226526012129281") { //判断人员
				isleader.value = true;
				// console.log("isleader-------", isleader.value)
			} else {
				isleader.value = false;
			}
		}
	});
</script>

<style>
</style>