<template>
	<view class="calendar">
		<u-toast ref="uToast" />
		<view class="updata u-flex u-row-between u-col-center">
			<view class="updata-item1 u-flex u-row-center" @click="towenjuan" v-if="wisWjdc	== '允许' && wisWjdcUser == '1'">
				<text class="text">问卷调查</text>
				<!-- <image class="image1" src="../../static/img/right.png" mode=""></image> -->
				<image class="image2" src="../../static/img/wenjuan.png" mode=""></image>
			</view>
			<view class="updata-item2 u-flex u-row-center" @click="upload()" v-if="wisMhu	== '允许'">
				<text class="text">上传病历</text>
				<!-- <image class="image1" src="../../static/img/right.png" mode=""></image> -->
				<image class="image2" src="../../static/img/bingli.png" mode=""></image>
			</view>
		</view>
		<view class="" style="padding: 10rpx 0;text-align: center;" v-if="wisWjdc	== '允许' && wisWjdcUser == '1'">
			您本月提交调研问卷{{count || 0}}次
		</view>
		<view class="con" v-if="dataList.length == 0 && wisMhu == '允许'">
			<image class="no" src="../../static/img/no.png" mode=""></image>
			<view class="text">列表内容为空</view>
		</view>
		<view class="list" v-if="dataList.length > 0">
			<view class="h6">历史上传</view>
			<view class="li" v-for="(item,index) in dataList" :key="index" @click="uploadID(item)">
				<view v-if="item.allocation==2">
					<view class="flex one">
						<view class="type">{{item.title}}</view>
						<view class="name">{{item.name}}</view>
						<view class="status status1">初审已通过</view>
					</view>
					<view class="flex address">
						<view>{{item.city}}</view>
						<view>{{item.hospital}}</view>
					</view>
					<view class="flex" style="justify-content: space-between;">
						<view class="class">
							<view class="box">{{item.uploadingName}}</view>
							<view class="box">{{item.caseName}}</view>
						</view>
					</view>
				</view>
				<view v-else>
					<view class="flex one">
						<view class="type">{{item.title}}</view>
						<view class="name">{{item.name}}</view>
						<view class="status" v-if="item.firstTrial==0">未审核</view>
						<view class="status status1" v-else-if="item.firstTrial==2">初审已通过</view>
						<view class="status status2" v-else>未通过</view>
					</view>
					<view class="flex address">
						<view>{{item.city}}</view>
						<view>{{item.hospital}}</view>
					</view>
					<view class="flex" style="justify-content: space-between;">
						<view class="class">
							<view class="box">{{item.uploadingName}}</view>
							<view class="box">{{item.caseName}}</view>
						</view>
						<view class="btn" v-if="item.firstTrial==1">重新编辑</view>
						<view class="btn btn1" v-if="isup(item)">二次上传</view>
					</view>
				</view>
			</view>
		</view>
		<tabBar :pagePath="'/pages/index/calendar'"></tabBar>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				dataList: [],
				wisMhu: '',
				wisWjdc: '',
				wisWjdcUser:'',
				count:0
			}
		},
		onLoad(option) {
			this.getsetting()
		},
		onShow() {
			this.getuser()
			this.$http.getTopicNum().then(res => {
				this.count = res.data.result
			})
		},
		methods: {
			getsetting(){
				this.$http.configInfo().then(res => {
					if (res.data.code == 200) {
						this.wisWjdcUser = res.data.result.wisWjdcUser
					}
					
				})
			},
			getuser() {
				this.$http.getUserInfo().then(res => {
					if (res.data.code == 200) {
						this.wisWjdc = res.data.result.wisWjdc
						this.wisMhu = res.data.result.wisMhu
						if (this.wisMhu == '允许') {
							this.patientQuideByPhongList()
						}
					}

				})
			},
			towenjuan() {
				uni.navigateTo({
					url: "./wenjuan-list"
				})
			},
			isup(item) {
				if (item.isSecondaryUpload == 2) {
					if (item.firstTrial == 2 && item.secondaryUpload == 1) {
						return true
					} else {
						return false
					}
				} else {
					return false
				}
			},
			patientQuideByPhongList() {
				this.$http.patientQuideByPhongList()
					.then(res => {
						// console.log(res)
						if (res.data.code == 200) {
							this.dataList = res.data.result
						}
					})
			},
			uploadID(item) {
				uni.setStorageSync('uploadData', JSON.stringify(item));
				uni.navigateTo({
					url: '/pages/doctor/upload?id=' + item.id,
				})
			},
			upload() {
				uni.navigateTo({
					url: '/pages/doctor/upload',
				})
			},
		}
	}
</script>

<style lang="scss">
	.calendar {
		padding-bottom: 120rpx;

		.updata {
			position: relative;
			width: 680rpx;
			margin: 24rpx auto 0;
			border-radius: 24rpx;
			// padding: 68rpx 0;
			text-align: center;

			// font-size: 32rpx;
			// color: $color;
			.updata-item2 {
				flex: 1;
				margin: 0 8rpx;
				height: 168rpx;
				background: linear-gradient(180deg, #22F5FB 0%, #9AFFF8 100%);
				border-radius: 24rpx;

				// padding: 0 12rpx 0 20rpx;
				.text {
					font-size: 36rpx;
					font-family: PingFangSC-Semibold, PingFang SC;
					font-weight: 600;
					color: #FFFFFF;
					margin-right: 26rpx;
				}

				.image1 {
					width: 40rpx;
					height: 40rpx;
					margin-right: 40rpx;
				}

				.image2 {
					width: 128rpx;
					height: 136rpx;
				}
			}

			.updata-item1 {
				flex: 1;
				margin: 0 8rpx;
				height: 168rpx;
				background: linear-gradient(180deg, #FFCE7D 0%, #FFDCB3 100%);
				border-radius: 24rpx;

				// padding: 0 12rpx 0 20rpx;
				.text {
					font-size: 36rpx;
					font-family: PingFangSC-Semibold, PingFang SC;
					font-weight: 600;
					color: #FFFFFF;
					margin-right: 32rpx;
				}

				.image1 {
					width: 40rpx;
					height: 40rpx;
					margin-right: 40rpx;
				}

				.image2 {
					width: 118rpx;
					height: 134rpx;
				}
			}

		}

		.con {
			width: 680rpx;
			margin: 24rpx auto;
			padding: 32rpx;
			background-color: #fff;
			border-radius: 24rpx;
			text-align: center;

			.no {
				width: 520rpx;
				height: 340rpx;
			}

			.text {
				font-size: 28rpx;
				color: rgba(0, 0, 0, 0.35);
				padding-bottom: 80rpx;
			}
		}

		.list {
			width: 680rpx;
			margin: 24rpx auto;
			box-sizing: border-box;
			// padding: 0 20rpx;
			background-color: #fff;
			border-radius: 24rpx;
			margin-top: 24rpx;

			.h6 {
				padding-top: 32rpx;
				font-size: 34rpx;
				color: $color;
				font-weight: 700;
				padding-left: 32rpx;
			}

			.li {
				font-size: 28rpx;
				color: rgba(0, 0, 0, 0.6);
				padding: 24rpx 32rpx;

				.flex {
					margin-bottom: 14rpx;
				}

				.address {
					view {
						margin-right: 20rpx;
					}
				}

				.class {
					display: flex;
					flex-direction: row;
					align-items: center;

					.box {
						padding: 4rpx 16rpx;
						background: rgba(22, 127, 255, 0.1);
						color: #167FFF;
						font-size: 24rpx;
						margin-right: 16rpx;
						border-radius: 24rpx;
					}
				}

				.btn {
					padding: 6rpx 24rpx;
					background: #F02E2F;
					color: #fff;
					font-size: 28rpx;
					border-radius: 24rpx;
				}

				.btn1 {
					background-color: $color;
				}

				.one {
					color: rgba(0, 0, 0, 0.8);

					.type {
						max-width: 280rpx;
						white-space: nowrap;
						overflow: hidden;
						text-overflow: ellipsis;
						font-size: 32rpx;
						color: rgba(0, 0, 0, 0.8);
						margin-right: 24rpx;
						font-weight: bold;
					}

					.name {
						flex: 1;
					}

					.status {
						position: relative;
					}

					.status1 {
						color: $color;
					}

					.status2 {
						color: #F02E2F;
					}

					.status::after {
						content: '';
						position: absolute;
						left: -30rpx;
						top: 50%;
						transform: translateY(-50%);
						width: 10rpx;
						height: 10rpx;
						border-radius: 50%;
						background: #F0A22E;
					}

					.status1::after {
						content: '';
						position: absolute;
						left: -30rpx;
						top: 50%;
						transform: translateY(-50%);
						width: 10rpx;
						height: 10rpx;
						border-radius: 50%;
						background: $color;
					}

					.status2::after {
						content: '';
						position: absolute;
						left: -30rpx;
						top: 50%;
						transform: translateY(-50%);
						width: 10rpx;
						height: 10rpx;
						border-radius: 50%;
						background: #F02E2F;
					}
				}
			}
		}
	}
</style>
