<template name="components">
	<view>
		<scroll-view scroll-y class="page">
		  <cu-custom bgColor="bg-blue"><block slot="content">工作台</block></cu-custom>
		  <!-- <view class="UCenter-bg">
		    <view class="photoView">
				<view class="photoImage">
					<open-data type="userAvatarUrl"></open-data>
				</view>
			</view>
		    <view class="text-xl">{{name}}
		    </view>
		    <view class="margin-top-sm">
		      <text>{{duty}}</text>
		    </view>
		  </view> -->
		  <!-- 扫码追溯 单独一行 -->
		  <view class="scan-wrapper">
			<view class="scan-row">
				<view class="scan-left" @tap="toPage(menuList[0].url)">
				  <view class="grid-icon">
				    <text :class="[menuList[0].icon, menuList[0].iconColor]"></text>
				  </view>
				  <view class="grid-text">{{menuList[0].name}}</view>
				</view>
				<view class="search-box">
					<input class="search-input" v-model="searchCode" placeholder="输入编码查询" confirm-type="search" @confirm="searchCodeHandle" />
					<button class="search-btn" @click="searchCodeHandle">确认</button>
				</view>
			</view>
		  </view>
		  <!-- 其他菜单 -->
		  <view class="grid-tab">
			<view class="grid-item" v-for="(item, index) in menuListOther" :key="index" @tap="toPage(item.url)">
			  <view class="grid-icon">
			    <text :class="[item.icon, item.iconColor]"></text>
			  </view>
			  <view class="grid-text">{{item.name}}</view>
			</view>
		  </view>
		  <view class="cu-tabbar-height"></view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				hospital: '',
				sortHospital: '',
				department: '',
				name: '',
				duty: '',
				searchCode: '',
				menuList: [
					{ name: '扫码追溯', icon: 'cuIcon-scan', iconColor: 'text-cyan', url: '/pages/component/home' }
				],
				menuListOther: [
					{ name: '医废收集', icon: 'cuIcon-add', iconColor: 'text-purple', url: '/pages/plugin/collectionMwims' },
					{ name: '交接列表', icon: 'cuIcon-copy', iconColor: 'text-green', url: '/pages/plugin/handList' },
					{ name: '入库列表', icon: 'cuIcon-down', iconColor: 'text-orange', url: '/pages/plugin/inList' },
					{ name: '出库列表', icon: 'cuIcon-upload',ik iconColor: 'text-pink', url: '/pages/plugin/outList' },
					{ name: '科室汇总', icon: 'cuIcon-list', iconColor: 'text-blue', url: '/pages/main/inventory' },
					{ name: '预警列表', icon: 'cuIcon-command', iconColor: 'text-red', url: '/pages/plugin/warnRecord' },
					{ name: '一键入库', icon: 'cuIcon-send', iconColor: 'text-cyan', url: '/pages/plugin/onekeyIn' },
					{ name: '一键出库', icon: 'cuIcon-deliver', iconColor: 'text-pink', url: '/pages/plugin/onekeyOut' },
					{ name: '箱袋入库', icon: 'cuIcon-goods', iconColor: 'text-cyan', url: '/pages/plugin/boxbagIn' },
					{ name: '周转箱出库', icon: 'cuIcon-cardboardfill', iconColor: 'text-brown', url: '/pages/plugin/boxOut' }
				]
			}
		},
		methods: {
			toPage(url) {
				uni.navigateTo({
					url: url
				})ik
			},ik
			searchCodeHandle() {ik
				if (!this.searchCode) {
					uni.showToast({
						title: '请输入医废编码',
						icon: 'none'
					})
					return
				}
				uni.request({
					url: 'https://lekapi.opmonitor.com/?c=app_api&a=getQrcodeType',
					data: { code: this.searchCode },
					header: {
						'Content-type': 'application/json'
					},
					success: (res) => {
						if (res.data.data.type === 'error') {
							uni.showModal({
								title: '提示',
								content: '不存在的医废二维码',
								showCancel: false
							})
						} else if (res.data.data.type === 'bag') {
							uni.navigateTo({
								url: '/pages/component/traceDetailsByMedical?id=' + res.data.data.id
							})
						} else if (res.data.data.type === 'box') {
							uni.navigateTo({
								url: '/pages/component/traceDetailsByBox?id=' + res.data.data.id
							})
						} else if (res.data.data.type === 'dept') {
							uni.navigateTo({
								url: '/pages/component/traceDetailsByDept?id=' + res.data.data.id
							})
						}
					},
					fail: () => {
						uni.showToast({
							title: '查询失败',
							icon: 'none'
						})
					}
				})
			}
		},
		mounted(){
			// 获取全局变量中的数据
			this.hospital = getApp().globalData.hospital
			this.sortHospital = getApp().globalData.sortHospital
			this.department = getApp().globalData.department
			this.name = getApp().globalData.name
			this.duty = getApp().globalData.duty
		}
	}
</script>

<style>
	.page {
		width: 100vw;
		height: 100Vh;
	}
	
.grid-tab {
		display: flex;
		flex-wrap: wrap;
		padding: 30rpx 20rpx;
	}

	.scan-wrapper {
		padding: 50rpx 20rpx 0 80rpx;
	}

	.scan-row {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding-bottom: 20rpx;
	}

	.scan-left {
		display: inline-flex;
		flex-direction: column;
		align-items: flex-start;
	}

	.search-box {
		display: flex;
		align-items: flex-start;
		flex: 1;
		margin-left: 30rpx;
		margin-top: -30rpx;
	}

	.search-input {
		flex: 1;
		height: 100rpx;
		background: #fff;
		border-radius: 50rpx;
		padding: 0 40rpx;
		font-size: 28rpx;
		box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.08);
		margin-top: -30rpx;
	}

	.search-btn {
		height: 80rpx;
		line-height: 80rpx;
		background: linear-gradient(135deg, #1c8cff 0%, #0077e6 100%);
		color: #fff;
		border: none;
		border-radius: 40rpx;
		padding: 0 40rpx;
		font-size: 28rpx;
		margin-left: 20rpx;
		box-shadow: 0 4rpx 12rpx rgba(0, 145, 255, 0.3);
		margin-top: -20rpx;
	}

	.search-btn::after {
		border: none;
	}

	.scan-item {
		width: 40%;
	}
	
	.grid-item {
		width: 33.33%;
		display: flex;
		flex-direction: column;
		align-items: center;
		padding: 20rpx 0;
	}
	
	.grid-icon {
		width: 100rpx;
		height: 100rpx;
		background: #fff;
		border-radius: 20rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.08);
		margin-bottom: 20rpx;
		transition: transform 0.2s ease;
	}
	
	.grid-icon:active {
		transform: scale(0.9);
	}
	
	.grid-icon text {
		font-size: 48rpx;
	}
	
	.grid-text {
		font-size: 28rpx;
		color: #333;
	}
	
	.UCenter-bg {
	  background:-webkit-linear-gradient(right,#4a90e2,#357abd);
	  background-size: cover;
	  height: 550rpx;
	  display: flex;
	  justify-content: center;
	  padding-top: 40rpx;
	  overflow: hidden;
	  position: relative;
	  flex-direction: column;
	  align-items: center;
	  color: #fff;
	  font-weight: 300;
	  text-shadow: 0 0 3px rgba(0, 0, 0, 0.3);
	}
	
	.UCenter-bg text {
	  opacity: 0.8;
	}
	
	.UCenter-bg image {
	  width: 200rpx;
	  height: 200rpx;
	}
	
	.UCenter-bg .gif-wave{
	  position: absolute;
	  width: 100%;
	  bottom: 0;
	  left: 0;
	  z-index: 99;
	  mix-blend-mode: screen;  
	  height: 100rpx;   
	}
	
	map,.mapBox{
	  left: 0;
	  z-index: 99;
	  mix-blend-mode: screen;  
	  height: 100rpx;   
	}
	
	map,.mapBox{
	  width: 750rpx;
	  height: 300rpx;
	}
	
	.png1 {
		border-radius: 50%;
	}
	
	.box {
		margin: 20upx 0;
	}
	
	.photoView {
			padding-top: 100rpx;
			position: relative;
			color: #fff;
			display: flex;
			flex-direction: column;
			align-items: center;
		}
		.photoImage {
			overflow:hidden;
			display: block;
			width: 200rpx;
			height: 200rpx;
			margin: 20rpx;
			border-radius: 50%;
			border: 2px solid #fff;
			box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.2);
		}
</style>
