<template>
	<view>
		<cu-custom bgColor="bg-gradual-blueness" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">隐患详情</block>
		</cu-custom>
		<scroll-view scroll-y>
			<view class="wui-form-list">
				<view class="wui-form-title">
					<text>{{pd.HIDDENDESCR}}</text>
				</view>
        <view class="cu-form-group">
          <view class="title">
            <text>隐患编码</text>
          </view>
          <view>
            <text>{{pd.CODE}}</text>
          </view>
        </view>
				<view class="cu-form-group">
					<view class="title">
						<text>隐患部位</text>
					</view>
					<view>
						<text>{{pd.HIDDENPART}}</text>
					</view>
				</view>
				<view class="cu-form-group">
					<view class="title">
						<text>隐患级别</text>
					</view>
					<view>
						<text>{{pd.HIDDENLEVELNAME}}</text>
					</view>
				</view>
        <view class="cu-form-group">
          <view class="title">
            <text>检查人</text>
          </view>
          <view>
            <view style="display: flex; flex-direction: column; text-align: right;">
              <view v-for="(item, index) in pd.inspectUserList" :key="index">
                {{ item }}
              </view>
            </view>
          </view>
        </view>
				<view class="cu-form-group">
					<view class="title">
						<text>发现时间</text>
					</view>
					<view>
						<text>{{pd.DISCOVER_TIME}}</text>
					</view>
				</view>
				<view class="cu-form-group">
					<view class="title">
						<text>整改截止时间</text>
					</view>
					<view>
						<text>{{pd.RECTIFY_DEADLINE}}</text>
					</view>
				</view>
				<view class="cu-form-group">
					<view class="title">
						<text>整改意见</text>
					</view>
					<view>
						<text>{{pd.DISPOSE}}</text>
					</view>
				</view>
				<view class="cu-form-group">
					<view class="title">
						<text>隐患状态</text>
					</view>
					<view>
						<text v-if="pd.STATE=='1'">{{ pd.QUALIFIED === '0' ? '打回' : '' }}待整改</text>
						<text v-else-if="pd.STATE=='2'">待复查</text>
						<text v-else-if="pd.STATE=='3'">已复查</text>
						<text v-else></text>
					</view>
				</view>
        <view v-if="pd.QUALIFIED === '0' && pd.REVIEW_CONTENT" class="cu-form-group">
          <view class="title">
            <text>打回原因</text>
          </view>
          <view>
            <text>{{ pd.REVIEW_CONTENT }}</text>
          </view>
        </view>
				<view v-if="pd.RECTIFICATIONTYPE=='2'" class="cu-form-group bb-default">
					<view class="title">
						<text>整改期限</text>
					</view>
					<view>
						<text>{{pd.RECTIFICATIONDEADLINE}}</text>
					</view>
				</view>
				<view class="cu-form-textarea">
					<view class="title">
						<text>隐患照片</text>
					</view>
					<view class="cu-form-p">
						<scroll-view scroll-x class="bg-white nav" scroll-with-animation>
							<view class="cu-item" v-for="(item,index) in pd.hImgs" v-bind:key="index">
								<view class="imgs">
									<image :src="baseImgPath+item.FILEPATH" :data-index="index" @click="ViewShowImage"
										mode=""></image>
								</view>
							</view>
						</scroll-view>
					</view>
				</view>
        <view v-if="pd.QUALIFIED === '0' && pd.REVIEW_CONTENT" class="cu-form-group">
          <view class="title">
            <text>打回原因</text>
          </view>
          <view>
            <text>{{ pd.REVIEW_CONTENT }}</text>
          </view>
        </view>
        <view v-if="pd.QUALIFIED === '0' && pd.REVIEW_TIME" class="cu-form-group">
          <view class="title">
            <text>打回时间</text>
          </view>
          <view>
            <text>{{ pd.REVIEW_TIME }}</text>
          </view>
        </view>
        <view v-if="pd.QUALIFIED === '0' && pd.reviewImgs" class="cu-form-textarea">
          <view class="title">
            <text>现场复查图片</text>
          </view>
          <view class="cu-form-p">
            <scroll-view scroll-x class="bg-white nav" scroll-with-animation>
              <view class="cu-item" v-for="(item,index) in pd.reviewImgs" v-bind:key="index">
                <view class="imgs">
                  <image :src="baseImgPath+item.FILEPATH" :data-index="index" @click="ViewShowImage4"
                         mode=""></image>
                </view>
              </view>
            </scroll-view>
          </view>
        </view>
			</view>
			<view v-if="pd.STATE > 1" class="wui-form-list">
				<view class="wui-sub-title">
					<text>整改信息</text>
				</view>
				<view class="cu-form-textarea">
					<view class="title">
						<text>整改人</text>
					</view>
					<view class="cu-form-p">
						<text>{{pd.RECTIFYER_NAME}}</text>
					</view>
				</view>
        <view class="cu-form-textarea">
          <view class="title">
            <text>整改部门</text>
          </view>
          <view class="cu-form-p">
            <text>{{pd.RECTIFY_DEPT_NAME}}</text>
          </view>
        </view>
				<view class="cu-form-group">
					<view class="title">
						<text>整改时间</text>
					</view>
					<view>
						<text>{{pd.RECTIFY_TIME}}</text>
					</view>
				</view>
				<view class="cu-form-group">
					<view class="title">
						<text>整改措施</text>
					</view>
					<view>
						<text>{{pd.RECTIFY_DESCR}}</text>
					</view>
				</view>
				<view class="cu-form-textarea">
					<view class="title">
						<text>整改完成图片</text>
					</view>
					<view class="cu-form-p">
						<scroll-view scroll-x class="bg-white nav" scroll-with-animation>
							<view class="cu-item" v-for="(item,index) in pd.rImgs" v-bind:key="index">
								<view class="imgs">
									<image :src="baseImgPath+item.FILEPATH" :data-index="index" @click="ViewShowImage2"
										mode=""></image>
								</view>
							</view>
						</scroll-view>
					</view>
				</view>
        <view class="cu-form-textarea">
          <view class="title">
            <text>本次整改报告照片</text>
          </view>
          <view class="cu-form-p">
            <scroll-view scroll-x class="bg-white nav" scroll-with-animation>
              <view class="cu-item" v-for="(item,index) in pd.rfImgs" v-bind:key="index">
                <view class="imgs">
                  <image :src="baseImgPath+item.FILEPATH" :data-index="index" @click="ViewShowImage3"
                         mode=""></image>
                </view>
              </view>
            </scroll-view>
          </view>
        </view>
			</view>
			<view v-if="pd.STATE > 2"  class="wui-form-list">
				<view class="wui-sub-title">
					<text>复查信息</text>
				</view>
				<view class="cu-form-group bb-default">
					<view class="title">
						<text>是否合格</text>
					</view>
					<view>
						<text v-if="pd.QUALIFIED == '1'">是</text>
						<text v-else-if="pd.QUALIFIED == '0'">否</text>
					</view>
				</view>
				<view class="cu-form-group">
					<view class="title">
						<text>复查部门</text>
					</view>
					<view>
						<text>{{pd.REVIEW_DEPT_NAME}}</text>
					</view>
				</view>
        <view class="cu-form-group">
					<view class="title">
						<text>复查人</text>
					</view>
					<view>
						<text>{{pd.REVIEWER_NAME}}</text>
					</view>
				</view>
        <view class="cu-form-group">
					<view class="title">
						<text>复查时间</text>
					</view>
					<view>
						<text>{{pd.REVIEW_TIME}}</text>
					</view>
				</view>
        <view class="cu-form-textarea">
          <view class="title">
            <text>现场复查图片</text>
          </view>
          <view class="cu-form-p">
            <scroll-view scroll-x class="bg-white nav" scroll-with-animation>
              <view class="cu-item" v-for="(item,index) in pd.reviewImgs" v-bind:key="index">
                <view class="imgs">
                  <image :src="baseImgPath+item.FILEPATH" :data-index="index" @click="ViewShowImage4"
                         mode=""></image>
                </view>
              </view>
            </scroll-view>
          </view>
        </view>
			</view>
			<view class="padding flex flex-direction">
				<button class="cu-btn bg-green margin-tb-sm lg" @click="$noMultipleClicks(back)">返 回</button>
			</view>
			<view class="cu-tabbar-height"></view>
		</scroll-view>
	</view>
</template>

<script>
  import { decryptAes } from "@/common/aesUtil";
	import {
		basePath,
		loginUserId,
		loginSession,
		baseImgPath,
		corpinfoId
	} from '@/common/tool.js';
	export default {
		data() {
			return {
				noClick: true,
				date: '',
				RECTIFICATIONTIME: '',
				CHECK_TIME: '',
				imgList: [],
				id: '',
				pd: [],
				hs: [],
				files: [],
				files2: [],
				files3: [],
				files4: [],
				CHECKDESCR: '',
				basePath: basePath,
				baseImgPath: baseImgPath,
				ISQUALIFIED: '1',
				check: [],

			}
		},
		onLoad(e) {
			this.id = e.id;
			this.getData();
			loginSession();
		},
		methods: {
			getData() {
				var _this = this;
				uni.showLoading({
					title: '请稍候'
				})
				uni.request({
					url: basePath + '/app/specialRectificationInspectHidden/goEdit',
					method: 'POST',
					dataType: 'json',
					header: {
						'Content-type': 'application/x-www-form-urlencoded'
					},
					data: {
						SPECIAL_RECTIFICATION_INSPECT_HIDDEN_ID: _this.id,
					},
					success: (res) => {
            res.data = decryptAes(res.data);
						if ("success" == res.data.result) {
							uni.hideLoading();
              const inspectUserList = [];
              res.data.pd.INSPECT_USER_NAME.split("_").forEach((user) => {
                inspectUserList.push(user ? user.replace(/,/g, "/") : "");
              });
              res.data.pd.inspectUserList = inspectUserList;
							_this.pd = res.data.pd; //参数map
						} else if ("exception" == data.result) {
							uni.showToast({
								title: '错误',
								duration: 2000
							});
						}
					}
				});
			},
			ViewShowImage(e) {
				let files = [];
				for (var i = 0; i < this.pd.hImgs.length; i++) {
					files.push(baseImgPath + this.pd.hImgs[i].FILEPATH)
				}
				uni.previewImage({
					urls: files,
					current: e.currentTarget.dataset.index
				});
			},
			ViewShowImage2(e) {
				let files = [];
				for (var i = 0; i < this.pd.rImgs.length; i++) {
					files.push(baseImgPath + this.pd.rImgs[i].FILEPATH)
				}
				uni.previewImage({
					urls: files,
					current: e.currentTarget.dataset.index
				});
			},
      ViewShowImage3(e) {
        let files = [];
        for (var i = 0; i < this.pd.rfImgs.length; i++) {
          files.push(baseImgPath + this.pd.rfImgs[i].FILEPATH)
        }
        uni.previewImage({
          urls: files,
          current: e.currentTarget.dataset.index
        });
      },
      ViewShowImage4(e) {
        let files = [];
        for (var i = 0; i < this.pd.reviewImgs.length; i++) {
          files.push(baseImgPath + this.pd.reviewImgs[i].FILEPATH)
        }
        uni.previewImage({
          urls: files,
          current: e.currentTarget.dataset.index
        });
      },
			back(){
				var pages = getCurrentPages(); // 获取当前页面栈
				var prePage = pages[pages.length - 2]; // 上一个页面
				prePage.$vm.initflag = true; // A 页面 init方法 为true
				uni.navigateBack({});
				uni.hideLoading();
			}
		}
	}
</script>

<style>
	.selected {
		display: flex;
		align-items: center;
	}

	.selected .radio {
		transform: scale(0.75);
		margin-right: 10upx;
	}

	.cu-btn {
		border-radius: 0;
		width: 100%;
		height: 84upx;
		font-weight: bold;
	}

	.group {
		display: flex;
		align-items: center;
	}
</style>
