<template>
	<view class="ali">
		<u-form ref="uForm">
			<view class="form_top">流程</view>
			<view class="content2">
				<view v-for="(item,index) in auditList" :key='index' class="audit">
					<view class="row" v-if='item.desc!="_PLACEHOLDER_"'>
						<view class="left">
							<view class="item1">
								<view class="item-content">{{item.operatorTitle}}</view>
								<view v-if="item.status=='success'" class='status success'>
									<u-icon name="checkmark" color="#2979ff" size="24"></u-icon>
								</view>
								<view v-if="item.status=='error'" class='status error'>
									<u-icon name="close" color="rgb(245, 108, 108)" size="24"></u-icon>
								</view>
								<view v-if="item.status=='question'" class='status question'>
									<u-icon name="question" color="#f9ae3d" size="24"></u-icon>
								</view>
							</view>
						</view>
						<view class="right">
							<view class="right-item">
								<view class="item2">
									<view class="name">{{item.operatorName}}
									</view>
									<!-- <view class='time'>{{item.updateDate}}</view> -->
									<view v-if="item.status=='success'" class="status success">
										{{item.commonStaffs1?item.staffscontent:item.desc}}<text
											v-if='!item.commonStaffs1&&index!=0'>已审核</text>
									</view>
									<view v-if="item.status=='error'" class="status error">
										{{item.commonStaffs1?item.staffscontent:item.operatorName}}<text
											v-if='!item.commonStaffs1'>{{item.workflowHistoricTasks ? "已驳回":''}}</text>
									</view>
									<view v-if="item.status=='question'" class="status question">
										{{item.commonStaffs1?item.staffscontent:''}}<text
											v-if='!item.commonStaffs1'>未审核</text>
									</view>
									<!-- <view  class="status success">吕波（已审核）</view> -->

								</view>
								<view v-if='index==0||item.workflowHistoricTasks&&item.workflowHistoricTasks.length>0'
									class='time'>
									{{item.updateDate}}
								</view>
							</view>
							<view class="">
								<view v-if='item.auditMind' class="right-content">
									{{item.auditMind}}
								</view>
								<view class="flex audit_img">
									<view v-for="(items,indexs) in item.fileUrl" class="url_css">
										<image :src="items" imageMode='aspectFill' class="url_img"
											@click="auditFile(items)"></image>
									</view>
								</view>
								<view v-if='item.commonReviewComments' v-for="item1 in item.commonReviewComments"
									style="display: flex; align-items: center; justify-content: space-between;margin-top: 20rpx;">
									<view class="right-content">
										{{item1.test}}
									</view>
									<view class="del" @click="del(item1)" v-if="item1.createUserId==userInfo.id">
										<image src="../static/delete.png" mode="widthFix" style="width: 30rpx;"></image>
									</view>
								</view>


							</view>

						</view>
						<view v-if='item.commonStaffs1' class="right">
							<u-icon @click='showcontent(item)' :name="item.showflow?'arrow-up':'arrow-down'" size="28">
							</u-icon>
						</view>
					</view>
					<view v-if='item.showflow' style='padding:10px 0 0 50px;'>
						<view class='row2'>
							<view v-for='item1 in item.commonStaffs1' style='margin:5px;text-align:center;'>
								<view class="item-content">
									<u-icon v-if='item1.status' name="checkmark" color="#fff" size="14"></u-icon>
									<u-icon v-if='!item1.status' name="question" color="#f9ae3d" size="14"></u-icon>
								</view>
								<view class="name">{{item1.staffName}}</view>
							</view>
						</view>
					</view>
					<view class="row-line" v-if="index!= auditList.length - 1&&item.desc!='_PLACEHOLDER_'"></view>
				</view>
			</view>
		</u-form>
		<view class="pl" @click="plClick">
			评论
		</view>
		<view v-if='show' class="shade">
			<view class="wrap">
				<view class="alert-top">
					<view class="title">
						评论
					</view>
					<u-icon name="close" class="close" color="#8890B1" @click="close()"></u-icon>
				</view>
				<view style='overflow-y: scroll;height: 732rpx;padding-bottom:102rpx;'>
					<view class="u-textarea-style">
						<view class="right-bottom">
							{{text.length}}/500个字
						</view>
						<textarea maxlength="500" v-model='text' placeholder="请在此输入评论内容" name="" id="" cols="30"
							rows="11"></textarea>

					</view>

				</view>
				<view @click='close()' class="cancel">取消</view>
				<view @click='passSubmit()' class="confirm">确定</view>
			</view>
		</view>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	export default {
		props: ["auditList"],
		data() {
			return {
				show: false,
				hisId: '',
				list: [],
				text: "",
				userInfo: {}
			}
		},
		watch: {
			auditList(val1, val2) {
				console.log(145)
				console.log(val1)
				this.list = val1
				this.userInfo = uni.getStorageSync("userInfo")
				for (let i = 0; i < this.list.length; i++) {
					// 获取当前人的hisId
					if (this.list[i].auditUsers && this.list[i].auditUsers == this.userInfo.id) {
						this.hisId = this.list[i].id

					}
				}
				console.log("this.hisId", this.hisId)

			}
		},
		methods: {
			del(val) {
				this.$api.doRequest('post', '/commonReviewComments/api/deleteInfo', {
						id: val.id,
					}).then(res => {
						console.log(res)
						uni.hideLoading()
						if (res.data.code == 200) {
							this.$emit('status', res.data.code)
						}
					})
					.catch(res => {
						uni.$u.toast(res.message);
					});
			},
			close() {
				this.show = false
			},
			passSubmit() {
				uni.showLoading({
					mask: true,
					title: "加载中"
				})
				this.$api.doRequest('post', '/commonReviewComments/api/addInfo', {
						hisId: this.hisId,
						test: this.text,

					}).then(res => {
						console.log(res)
						uni.hideLoading()
						if (res.data.code == 200) {
							this.show = false
							this.$emit('status', res.data.code)
						}
					})
					.catch(res => {
						uni.$u.toast(res.message);
					});
			},
			plClick() {
				this.text = ""
				this.show = true


			},
		},
	}
</script>

<style scoped lang="scss">
	.shade {
		position: fixed;
		top: 0;
		bottom: 0;
		left: 0;
		width: 100%;
		background: rgba(0, 0, 0, 0.4);
		z-index: 13;

		.wrap {
			position: absolute;
			left: 0;
			top: 0;
			right: 0;
			bottom: 0;
			margin: auto;
			background: #fff;
			width: calc(100% - 198rpx);
			height: 836rpx;
			border-radius: 20rpx;
			// overflow-y: scroll;

			.alert-top {
				padding: 33rpx;
				display: flex;
				justify-content: center;
				align-items: center;
				position: relative;
			}

			.title {
				font-size: 32rpx;
				font-weight: 600;
				color: #333333;
			}

			.close {
				position: absolute;
				right: 33rpx;
			}
		}
	}

	.cancel,
	.confirm {
		position: absolute;
		display: inline-block;
		width: 50%;
		text-align: center;
		bottom: 0;
		padding: 10px;
		border-top: 1px solid #eee;
		font-size: 34rpx;
		z-index: 10;
		background: #fff;
	}

	.cancel {
		left: 0;
		border-right: 1px solid #eee;
		color: #AFB3BF;
	}

	.confirm {
		right: 0;
		color: #22C572;
	}

	.textarea,
	.textarea1 {
		margin: 18rpx auto;
		width: 100%;
		background: #F9F9FA;
		border-radius: 10px;
		border: 1px solid #EEEEEE;
		font-size: 28rpx;
		padding: 10px;
	}

	.textCss {
		display: flex;
		justify-content: flex-end;
		width: 100%;
		text-align: right;
		color: #333333;
	}

	.u-textarea-style {
		margin: 20rpx;
		background: #F9F9FA;
		border-radius: 10px;
		border: 1px solid #EEEEEE;
		padding: 10rpx 20rpx;
		position: relative;

		height: 240px;

		/deep/.uni-textarea-textarea {
			width: 80%;
		}

		.right-bottom {
			position: absolute;
			right: 20rpx;
			bottom: 20rpx;
			color: #AFB3BF;
		}
	}

	/deep/.u-input__textarea {
		height: 300rpx !important;
	}

	/deep/.textarea1 .u-input__textarea {
		height: 200rpx !important;
	}

	.pl {
		background-color: #fff;
		border-radius: 50rpx;
		padding: 20rpx;
		text-align: center;
		color: #22C572;
		margin-bottom:30rpx;
	}

	.form_top {
		border-bottom: 1px solid #F5F6FA;
		padding-bottom: 10px;
		margin-bottom: 18rpx;
		font-size: 30rpx;
		font-weight: 600;
	}

	.content2 {
		background: white;
		margin: 20rpx 0;
		border-radius: 20rpx;
		padding: 20rpx;

		.row {
			display: flex;
			align-items: flex-start;

			.left {
				display: flex;
				align-items: center;

				.item1 {
					position: relative;

					.item-content {
						background: #617AE0;
						width: 44px;
						height: 44px;
						border-radius: 22px;
						line-height: 44px;
						text-align: center;
						font-size: 15px;
						color: #fff;
					}

					.status {
						position: absolute;
						border-radius: 50%;
						padding: 0px 8rpx;
						width: 40rpx;
						height: 40rpx;
						right: -3px;
						bottom: -3px;
						background: #fff;
					}

					.status.success {
						border: 1px solid rgb(60, 156, 255);
					}

					.status.error {
						border: 1px solid rgb(245, 108, 108);
					}

					.status.question {
						border: 1px solid #f9ae3d;
					}
				}

			}

			.right {
				width: 80%;
				// color: #B0B1B5;
				margin-top: 10px;

				.right-content {
					background: #F3F4F6;
					margin: 0 20rpx;
					padding: 10px;
					border-radius: 5px;
					color: #676D76;
					border-radius: 50rpx;
				}

				.right-item {
					display: flex;
					justify-content: space-between;

					.time {
						color: #999;
					}

					.item2 {
						margin-left: 20rpx;
						margin-top: -7px;

						.name {
							font-size: 28rpx;
							font-weight: 800;
							margin-bottom: 4px;
						}

						.status.success {
							color: #AFB3BF;
						}

						.status.error {
							color: rgb(245, 108, 108);
						}

						.status.question {
							color: #f9ae3d;
						}
					}
				}

				.audit_img {
					flex-wrap: wrap;
					// margin: 0 10rpx;
					margin-left: 20rpx;

					.url_css {
						border: 1px solid #999999;
						border-radius: 10px;
						margin-top: 10px;
						margin-right: 4px;
						overflow: hidden;
						width: 73px;
						height: 73px;

						.url_img {
							width: 73px;
							height: 73px;
							// border-radius: 10px;
						}
					}
				}
			}
		}

		.row2 {
			display: flex;

			.item-content {
				background: #22C572;
				width: 30px;
				height: 30px;
				border-radius: 50%;
				line-height: 30px;
				text-align: center;
				font-size: 12px;
				color: #fff;
				padding: 0 2px;
				margin: 0 auto;
			}

			.status {
				position: absolute;
				top: 0;
				right: 0;
			}
		}

		.row-line {
			width: 1px;
			height: 30px;
			background: #F2F2F2;
			margin: 10rpx 50rpx;

		}

		.audit {
			margin-top: 20rpx;
		}
	}

	.del {}
</style>
