<template>
	<view>
		<scroll-view scroll-y class="page">
			<cu-custom bgColor="bg-cyan" :isBack="true"><block slot="backText">返回</block><block slot="content">科室汇总</block></cu-custom>
			<!-- <view class="cu-bar bg-white">
				<view class="action">
					<text class="cuIcon-title text-green" style="color:#2CC9EA;"></text>
					<text style="color:#73828B;">科室汇总</text>
				</view>
			</view> -->
			<view class="cu-bar bg-white margin-top solid-bottom">
				<view class="action">
					<text class="cuIcon-title text-green" style="color:#2CC9EA;"></text>
					<text style="color:#73828B;">本周医废明细数据</text>
				</view>
			</view>
			<view class="cu-list menu" v-for="(value,index) in stockDetailsInfo" :key="index">
				<view class="cu-item">
					<view class="content">
						<text class="cuIcon-title text-green" style="color:#2CC9EA;"></text>
						<text class="text-grey" style="color:#73828B;">{{value.department}}--（{{value.departmentCount}}袋-{{value.departmentWeight}}kg)</text>
						
					</view>
				</view>
				<view class="cu-list menu-avatar">
					<view class="cu-item" v-for="(val,ind) in value.content" :key="ind">
						<!-- <view class="cu-avatar round lg" :style="'width:20px;height:20px;background-image:url('+val.image+');'"></view> -->
						
						<view class="content" style="left:28px;">
							<img :src="val.image" style="width:20px;height:20px;">
							<text class="text-grey" style="color:#73828B;margin-left:13px;">{{val.type}}</text>
							<text class="text-grey" style="color:#73828B;margin-left:20px;">{{val.totalCount}}袋</text>
							<text class="text-grey" style="color:#73828B;margin-left:20px;">{{val.totalWeight}}kg</text>
						</view>
					</view>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				menuBorder: false,
				menuCard: false,
				menuArrow: true,
				itemShow: true,
				hospital: '',
				sortHospital: '',
				department: '',
				name: '',
				duty: '',
				stockBasisInfo: [],
				stockDetailsInfo: []
			}
		},
		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
			this.getStockBasisInfo();
			this.getStockDetailsInfo();
		},
		methods: {
			onListOne() {
				if (this.itemShow === true) {
					this.itemShow = false
				} else {
					this.itemShow = true
				}
			},
			// 获取库存的基本信息
			getStockBasisInfo(){
				let that = this;
				uni.request({
					url: 'https://lekapi.opmonitor.com/?c=app_api&a=getStockBasisInfo',
					data: {hospital: that.hospital, sortHospital: that.sortHospital, department: that.department, duty: that.duty},
					header: {
						'Content-type': 'application/json'
					},
					success: function(res){
						that.stockBasisInfo = res.data.data
					},
					fail: () => {
						console.info('小程序域名不正确，请检查域名的正确性')
					}
				})
			},
			// 获取医废明细数据
			getStockDetailsInfo(){
				let that = this;
				uni.request({
					url: 'https://lekapi.opmonitor.com/?c=app_api&a=getStockDetailsInfoWeek',
					data: {hospital: that.hospital, sortHospital: that.sortHospital, department: that.department, duty: that.duty},
					header: {
						'Content-type': 'applicaation/json'
					},
					success: function(res){
						that.stockDetailsInfo = res.data.data
					},
					fail: () => {
						console.info('小程序域名不正确，请检查域名的正确性')
					}
				})
			}
		}
	}
</script>

<style>
	.page {
		width: 100vw;
		height: 100Vh;
	}
	
	.show {
		display: block;
	}
	
	.no-show {
		display: none;
	}
</style>
