<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-card dynamic" :class="isCard?'no-card':''">
				<view class="cu-item shadow"  v-for="(value,index) in DeptMwList" :key="index">
					<view class="cu-list menu-avatar comment solids-bottom">
						<view class="cu-item" style="padding: 30rpx;30rpx;30rpx;30rpx;">
							<view class="content">
								<view class="flex">
									<view>医废袋标识：</view>
									<view class="flex-sub text-black">{{ value.ribbon_code }}</view>
									<view class="flex-sub text-red">{{ value.ribbon_code_right }}</view>
								</view>
								
								<view v-if="value.waste_status == '误操作'" class="bg-grey padding-sm radius margin-top-sm" style="font-size:30rpx;">
									<view class="flex">
										<view>收集科室：</view>
										<view class="flex-sub">{{ value.dept_name }}</view>
									</view>
									<view class="flex">
										<view>交接人员：</view>
										<view class="flex-sub">{{ value.hand_name }}</view>
									</view>
									<view class="flex">
										<view>医废类型：</view>
										<view class="flex-sub">{{ value.waste_type }}</view>
									</view>
									<view class="flex">
										<view>医废状态：</view>
										<view class="flex-sub">{{ value.waste_status }}</view>
									</view>
									<view class="flex">
										<view>医废重量：</view>
										<view class="flex-sub">{{ value.weight }}</view>
									</view>
								</view>
								<view v-else class="bg-white padding-sm radius margin-top-sm" style="font-size:30rpx;">
									<view class="flex">
										<view>收集科室：</view>
										<view class="flex-sub">{{ value.dept_name }}</view>
									</view>
									<view class="flex">
										<view>交接人员：</view>
										<view class="flex-sub">{{ value.hand_name }}</view>
									</view>
									<view class="flex">
										<view>医废类型：</view>
										<view class="flex-sub">{{ value.waste_type }}</view>
									</view>
									<view class="flex">
										<view>医废状态：</view>
										<view class="flex-sub">{{ value.waste_status }}</view>
									</view>
									<view class="flex">
										<view>医废重量：</view>
										<view class="flex-sub">{{ value.weight }}</view>
									</view>
								</view>
								<view class="margin-top-sm flex justify-between">
									<view class="text-black" style="font-size: 30rpx;">{{ value.recl_time }}</view>
									<view>
										<button class="cu-btn sm bg-red" @click="buttonWcz(value.ribbon_code,value.ribbon_code_right)">标记误操作</button>
										<button class="cu-btn sm bg-blue" style="margin-left: 10rpx;" @click="buttonHf(value.ribbon_code,value.ribbon_code_right)">恢复</button>
									</view>
								</view>
							</view>
						</view>
					</view>
					<view class="solids-bottom" style="padding-top: 20rpx;background-color: #F1F1F1;"></view>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isCard: false,
				dept_code: '',
				DeptMwList: []
			}
		},
		onLoad(e) {
			this.dept_code = e.dept_code
			this.getDeptMwList(e.dept_code)
		},
		methods: {
			IsCard(e) {
				this.isCard = e.detail.value
			},
			getDeptMwList(){
				let that = this;
				uni.request({
					url: "https://mwapi.opmonitor.com/?c=app_api&a=dept_mw_list",
					data: {dept_code: that.dept_code},
					header: {
						'Content-type': 'application/json'
					},
					success: function(res){
						that.DeptMwList = res.data.data
					},
					fail: () => {
						console.info('小程序域名不正确，请检查域名的正确性')
					}
				})
			},
			buttonWcz(e,l) {
				let that = this;
				uni.request({
					url: "https://mwapi.opmonitor.com/?c=app_api&a=sign_wcz",
					data: {ribbon_code: e,ribbon_code_right: l},
					header: {
						'Content-type': 'application/json'
					},
					success: function(res){
						console.info(res.data.data)
						if(res.data.data === "success"){
							uni.navigateTo({
								url: '/pages/component/listDetails?dept_code='+that.dept_code
							})
						}else if(res.data.data === "false"){
							uni.navigateTo({
								url: '/pages/component/listDetails?dept_code='+that.dept_code
							})
						}
					},
					fail: () => {
						console.info('小程序域名不正确，请检查域名的正确性')
					}
				})
			},
			buttonHf(e,l) {
				let that = this;
				uni.request({
					url: "https://mwapi.opmonitor.com/?c=app_api&a=sign_hf",
					data: {ribbon_code: e,ribbon_code_right: l},
					header: {
						'Content-type': 'application/json'
					},
					success: function(res){
						console.info(res.data.data)
						if(res.data.data === "success"){
							uni.navigateTo({
								url: '/pages/component/listDetails?dept_code='+that.dept_code
							})
						}else if(res.data.data === "false"){
							uni.navigateTo({
								url: '/pages/component/listDetails?dept_code='+that.dept_code
							})
						}
					},
					fail: () => {
						console.info('小程序域名不正确，请检查域名的正确性')
					}
				})
			}
		}
	}
</script>

<style>
	.page {
		width: 100vw;
		height: 120Vh;
	}
	.photoView {
		padding-top: 50rpx;
		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);
	}
	.cu-form-group .title{
		min-width: calc(4em + 15px);
		font-weight: 600;
	}
	.picker {
		text-align: left;
	}
</style>
