<template>
  <view>
    <scroll-view scroll-y>
      <view class="wui-form-list">
        <view class="cu-form-group">
          <view class="title">
            <text>隐患描述</text>
          </view>
          <view>
            <text>{{ pd.HIDDENDESCR }}</text>
          </view>
        </view>
        <view class="cu-form-group">
          <view class="title">
            <text>隐患来源</text>
          </view>
          <view>
            <text v-if="pd.SOURCE=='1'">隐患快报</text>
            <text v-if="pd.SOURCE=='2'">风险管控清单检查</text>
            <text v-if="pd.SOURCE=='3'">风险管控清单检查</text>
            <text v-if="pd.SOURCE=='4'">安全检查</text>
            <text v-if="pd.SOURCE=='5'">安全检查</text>
            <text v-if="pd.SOURCE=='6'">消防管理检查(app端)</text>
          </view>
        </view>
        <view class="cu-form-group" v-if="pd.SOURCE==2">
          <view class="title">
            <text>风险点（单元）</text>
          </view>
          <view>
            <text>{{ pd.RISK_UNIT }}</text>
          </view>
        </view>
        <view class="cu-form-group bb-default" v-if="pd.SOURCE==2">
          <view class="title">
            <text>辨识部位</text>
          </view>
          <view style="flex: 1;padding: 20upx 0;">
            <text>{{ pd.IDENTIFICATION }}</text>
          </view>
        </view>
        <view class="cu-form-group" v-if="pd.SOURCE==2">
          <view class="title">
            <text>存在风险</text>
          </view>
          <view class="cu-form-p">
            <text>{{ pd.RISK_DESCR }}</text>
          </view>
        </view>
        <view class="cu-form-group bb-default" v-if="pd.SOURCE==2">
          <view class="title">
            <text>风险分级</text>
          </view>
          <view>
            <text>{{ pd.LEVEL }}</text>
          </view>
        </view>
        <view class="cu-form-group" v-if="pd.SOURCE==2">
          <view class="title">
            <text>检查内容</text>
          </view>
          <view class="cu-form-p">
            <text>{{ pd.CHECK_CONTENT }}</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.HIDDEN_DANGER_AREA_NAME }}</text>
          </view>
        </view>
        <view class="cu-form-group">
          <view class="title">
            <text>隐患标签</text>
          </view>
          <view>
            <text v-if="pd.HIDDEN_DANGER_LABEL == '1'">外施工</text>
            <text v-if="pd.HIDDEN_DANGER_LABEL == '2'">厂内</text>
            <text v-if="pd.HIDDEN_DANGER_LABEL == '3'">BOO、BOT项目</text>
          </view>
        </view>
        <view class="cu-form-group">
          <view class="title">
            <text>隐患分级</text>
          </view>
          <view>
            <text v-if="pd.HIDDEN_CLASSIFICATION == '0'">公司级</text>
            <text v-if="pd.HIDDEN_CLASSIFICATION == '1'">厂部级</text>
            <text v-if="pd.HIDDEN_CLASSIFICATION == '2'">车间级</text>
            <text v-if="pd.HIDDEN_CLASSIFICATION == '3'">班组级</text>
          </view>
        </view>
        <view class="cu-form-group">
          <view class="title">
            <text>发现人</text>
          </view>
          <view>
            <text>{{ pd.CREATORNAME }}</text>
          </view>
        </view>
        <view class="cu-form-group">
          <view class="title">
            <text>发现时间</text>
          </view>
          <view>
            <text>{{ pd.CREATTIME }}</text>
          </view>
        </view>
        <view class="cu-form-group">
          <view class="title">
            <text>隐患级别</text>
          </view>
          <view>
            <text>{{ pd.HIDDENLEVELNAME }}</text>
          </view>
        </view>
        <view v-if="pd.HIDDEN_CATEGORY && pd.HIDDEN_CATEGORY !== ''" class="cu-form-group">
          <view class="title">
            <text>隐患类别</text>
          </view>
          <view>
            <text>{{ pd.HIDDEN_CATEGORY_NAME }}</text>
          </view>
        </view>
        <view class="cu-form-group">
          <view class="title">
            <text>隐患类型</text>
          </view>
          <view>
            <text>{{ pd.HIDDENTYPE_NAME }}</text>
          </view>
        </view>
        <view class="cu-form-group">
          <view class="title">
            <text>整改类型</text>
          </view>
          <view>
            <text v-if="pd.RECTIFICATIONTYPE=='1'">立即整改</text>
            <text v-else-if="pd.RECTIFICATIONTYPE=='2'">限期整改</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 files" 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 class="de-item-sp" v-if="videoList.length>0">
          <view class="de-sub-title">
            <text class="text-grey">隐患视频</text>
          </view>
          <view class="de-sub-content" style="background-color: #000;width: 120upx;">
            <image src="/static/icon-apps/video.png" mode="aspectFill" @click="playVideo"
                   :data-src="baseImgPath + videoList[0].FILEPATH"
                   style="width: 120upx;height: 120upx;"></image>
          </view>
        </view>
      </view>
      <view v-if="confirmDataList.length > 0" class="wui-form-list" v-for="(item,index) in confirmDataList"
            :key="index">
        <view class="wui-sub-title">
          <text>隐患确认信息</text>
        </view>
        <view>
          <view class="cu-form-group">
            <view class="title">
              <text>确认意见</text>
            </view>
            <view>
              <text>{{ item.RECTIFY_ADVICE }}</text>
            </view>
          </view>
          <view class="cu-form-group">
            <view class="title">
              <text>确认状态</text>
            </view>
            <view>
              <text> {{ item.STATE === 1 ? "打回" : "通过" }}</text>
            </view>
          </view>
          <view v-if="item.STATE === 1" class="cu-form-group">
            <view class="title">
              <text>打回原因</text>
            </view>
            <view>
              <text>{{ item.REPULSE_CAUSE }}</text>
            </view>
          </view>
          <view class="cu-form-group">
            <view class="title">
              <text>隐患确认人部门</text>
            </view>
            <view>
              <text>{{ item.CONFIRM_DEPT_NAME }}</text>
            </view>
          </view>
          <view class="cu-form-group">
            <view class="title">
              <text>隐患确认人</text>
            </view>
            <view>
              <text>{{ item.CONFIRM_USER_NAME }}</text>
            </view>
          </view>
          <view class="cu-form-group">
            <view class="title">
              <text>隐患确认时间</text>
            </view>
            <view>
              <text>{{ item.CREATTIME }}</text>
            </view>
          </view>
          <view class="cu-form-group">
            <view class="title">
              <text>隐患整改人部门</text>
            </view>
            <view>
              <text>{{ item.RECTIFICATIONDEPT_NAME }}</text>
            </view>
          </view>
          <view class="cu-form-group">
            <view class="title">
              <text>隐患整改人</text>
            </view>
            <view>
              <text>{{ item.RECTIFICATIONOR_NAME }}</text>
            </view>
          </view>
        </view>
      </view>
      <view v-if="correctionRepulseDataList.length > 0" class="wui-form-list"
            v-for="(item,index) in correctionRepulseDataList" :key="index">
        <view class="wui-sub-title">
          <text>隐患整改打回信息</text>
        </view>
        <view>
          <view v-if="item.STATE === 1" class="cu-form-group">
            <view class="title">
              <text>无法整改原因</text>
            </view>
            <view>
              <text>{{ item.REPULSE_CAUSE }}</text>
            </view>
          </view>
          <view v-if="item.STATE === 1" class="cu-form-group">
            <view class="title">
              <text>打回时间</text>
            </view>
            <view>
              <text>{{ item.CREATTIME }}</text>
            </view>
          </view>
          <view class="cu-form-group">
            <view class="title">
              <text>隐患整改人部门</text>
            </view>
            <view>
              <text>{{ item.RECTIFICATIONDEPT_NAME }}</text>
            </view>
          </view>
          <view class="cu-form-group">
            <view class="title">
              <text>隐患整改人</text>
            </view>
            <view>
              <text>{{ item.RECTIFICATIONOR_NAME }}</text>
            </view>
          </view>
        </view>
      </view>
      <view v-if="delayedReviewDataList.length > 0" class="wui-form-list"
            v-for="(item,index) in delayedReviewDataList" :key="index">
        <view class="wui-sub-title">
          <text>隐患延期整改信息</text>
        </view>
        <view>
          <view v-if="item.STATE != -1" class="cu-form-group">
            <view class="title">
              <text>处置状态</text>
            </view>
            <view>
              <text v-if="item.STATE == -1">处置中</text>
              <text v-if="item.STATE == 1">未通过</text>
              <text v-if="item.STATE == 2">通过</text>
            </view>
          </view>
          <view class="cu-form-group">
            <view class="title">
              <text>处置意见</text>
            </view>
            <view>
              <text>{{ item.REPULSE_CAUSE }}</text>
            </view>
          </view>
          <view class="cu-form-group">
            <view class="title">
              <text>申请时间</text>
            </view>
            <view>
              <text>{{ item.CREATTIME }}</text>
            </view>
          </view>
          <view v-if="item.STATE !== -1" class="cu-form-group">
            <view class="title">
              <text>处置时间</text>
            </view>
            <view>
              <text>{{ item.OPERATTIME }}</text>
            </view>
          </view>
          <view class="cu-form-group">
            <view class="title">
              <text>原整改日期</text>
            </view>
            <view>
              <text>{{ item.RECTIFICATIONDEADLINE }}</text>
            </view>
          </view>
          <view class="cu-form-group">
            <view class="title">
              <text>申请延期日期</text>
            </view>
            <view>
              <text>{{ item.DELAY_TIME }}</text>
            </view>
          </view>
          <view class="cu-form-group">
            <view class="title">
              <text>申请延期原因</text>
            </view>
            <view>
              <text>{{ item.EXAMINE }}</text>
            </view>
          </view>
          <view class="cu-form-group">
            <view class="title">
              <text>申请延期期间防范措施</text>
            </view>
            <view>
              <text>{{ item.DISPOSAL_PLAN }}</text>
            </view>
          </view>
          <view class="cu-form-group">
            <view class="title">
              <text>延期申请人部门</text>
            </view>
            <view>
              <text>{{ item.RECTIFICATIONDEPT_NAME }}</text>
            </view>
          </view>
          <view class="cu-form-group">
            <view class="title">
              <text>延期申请人</text>
            </view>
            <view>
              <text>{{ item.RECTIFICATIONOR_NAME }}</text>
            </view>
          </view>
          <view class="cu-form-group">
            <view class="title">
              <text>延期审批人部门</text>
            </view>
            <view>
              <text>{{ item.DELAY_APPROVAL_DEPT_NAME }}</text>
            </view>
          </view>
          <view class="cu-form-group">
            <view class="title">
              <text>延期审批人</text>
            </view>
            <view>
              <text>{{ item.DELAY_APPROVAL_USER_NAME }}</text>
            </view>
          </view>
        </view>
      </view>
      <view v-if="pd.RECTIFYDESCR" class="wui-form-list">
        <view class="wui-sub-title">
          <text>隐患整改信息</text>
        </view>
        <view class="cu-form-group">
          <view class="title">
            <text>整改描述</text>
          </view>
          <view>
            <text>{{ pd.RECTIFYDESCR }}</text>
          </view>
        </view>
        <view class="cu-form-group">
          <view class="title">
            <text>整改部门</text>
          </view>
          <view>
            <text>{{ pd.RECTIFICATIONDEPTNAME }}</text>
          </view>
        </view>
        <view class="cu-form-group">
          <view class="title">
            <text>整改人</text>
          </view>
          <view>
            <text>{{ pd.RECTIFICATIONORNAME }}</text>
          </view>
        </view>
        <view class="cu-form-group bb-default">
          <view class="title">
            <text>整改时间</text>
          </view>
          <view>
            <text>{{ pd.RECTIFICATIONTIME }}</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 files2" 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-group">
          <view class="title">
            <text>整改方案</text>
          </view>
          <view>
            <text v-if="pd.HAVESCHEME==0">无</text>
            <text v-else-if="pd.HAVESCHEME==1">有</text>
            <text v-else></text>
          </view>
        </view>
        <view class="cu-form-group" v-if="hs && pd.HAVESCHEME==1">
          <view class="title">
            <text>治理标准要求</text>
          </view>
          <view>
            <text>{{ hs.GOVERNSTANDARDS }}</text>
          </view>
        </view>
        <view class="cu-form-group" v-if="hs && pd.HAVESCHEME==1">
          <view class="title">
            <text>治理方法</text>
          </view>
          <view>
            <text>{{ hs.GOVERNMETHOD }}</text>
          </view>
        </view>
        <view class="cu-form-group" v-if="hs && pd.HAVESCHEME==1">
          <view class="title">
            <text>经费和物资的落实</text>
          </view>
          <view>
            <text>{{ hs.EXPENDITURE }}</text>
          </view>
        </view>
        <view class="cu-form-group" v-if="hs && pd.HAVESCHEME==1">
          <view class="title">
            <text>负责治理人员</text>
          </view>
          <view>
            <text>{{ hs.PRINCIPAL }}</text>
          </view>
        </view>
        <view class="cu-form-group" v-if="hs && pd.HAVESCHEME==1">
          <view class="title">
            <text>工时安排</text>
          </view>
          <view>
            <text>{{ hs.PROGRAMMING }}</text>
          </view>
        </view>
        <view class="cu-form-group" v-if="hs && pd.HAVESCHEME==1">
          <view class="title">
            <text>时限要求</text>
          </view>
          <view>
            <text>{{ hs.TIMELIMITFOR }}</text>
          </view>
        </view>
        <view class="cu-form-group" v-if="hs && pd.HAVESCHEME==1">
          <view class="title">
            <text>工作要求</text>
          </view>
          <view>
            <text>{{ hs.JOBREQUIREMENT }}</text>
          </view>
        </view>
        <view class="cu-form-group" v-if="hs && pd.HAVESCHEME==1">
          <view class="title">
            <text>其他事项</text>
          </view>
          <view>
            <text>{{ hs.OTHERBUSINESS }}</text>
          </view>
        </view>
        <view class="cu-form-textarea" v-if="hs && pd.HAVESCHEME==1">
          <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 files4" 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 class="cu-form-group bb-default">
          <view class="title">
            <text>整改计划</text>
          </view>
          <view class="uni-flex-item text-right">
            <text v-if="pd.HAVEPLAN==1">有</text>
            <text v-else>无</text>
          </view>
        </view>
        <view class="cu-form-textarea" v-if="pd.HAVEPLAN==1">
          <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 files5" v-bind:key="index">
                <view class="imgs">
                  <image :src="baseImgPath+item.FILEPATH" :data-index="index" @click="ViewShowImage5" mode=""></image>
                </view>
              </view>
            </scroll-view>
          </view>
        </view>
      </view>
      <view v-if="pd.STATE==4" class="wui-form-list" v-for="(item,index) of checkList" :key="index"
            :data-id="item.HIDDENCHECK_ID">
        <view class="wui-sub-title">
          <text>验收信息</text>
        </view>
        <view class="cu-form-group">
          <view class="title">
            <text>验收描述</text>
          </view>
          <view>
            <text>{{ item.CHECKDESCR }}</text>
          </view>
        </view>
        <view class="cu-form-group">
          <view class="title">
            <text>是否合格</text>
          </view>
          <view>
            <text v-if="item.STATUS=='1'">是</text>
            <text v-else-if="item.STATUS=='0'">否</text>
          </view>
        </view>
        <view class="cu-form-group">
          <view class="title">
            <text>验收部门</text>
          </view>
          <view>
            <text>{{ item.CHECKDEPTNAME }}</text>
          </view>
        </view>
        <view class="cu-form-group">
          <view class="title">
            <text>验收部门负责人</text>
          </view>
          <view>
            <text>{{ item.CHECKORNAME }}</text>
          </view>
        </view>
        <view class="cu-form-group bb-default">
          <view class="title">
            <text>验收时间</text>
          </view>
          <view>
            <text>{{ item.CHECK_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="(item1,index1) in item.cImgs" v-bind:key="index1">
                <view class="imgs">
                  <image :src="baseImgPath+item1.FILEPATH" :data-index="index1"
                         @click="ViewShowImages(item.cImgs,index1)" mode=""></image>
                </view>
              </view>
            </scroll-view>
          </view>
        </view>
      </view>

    </scroll-view>
    <view :class="['cu-modal',{'show':modalShow}]" v-if="modalShow">
      <view class="cu-dialog">
        <view class="cu-bar bg-white justify-end">
          <view class="content">播放视频</view>
          <view class="action" @tap="modalShow = false">
            <text class="cuIcon-close text-red"></text>
          </view>
        </view>
        <video :src="videoSrc" :show-fullscreen-btn="false" :autoplay="true"
               @fullscreenchange="fullScreenHandler"></video>
        <view class="cu-bar bg-white justify-end">
          <view class="action">
            <button class="cu-btn line-green text-green" @click="modalShow = false">关闭</button>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import {basePath, loginUser, baseImgPath} from '@/common/tool.js';

export default {
  props: {
    hidden_id: {
      type: String,
      default: "",
    },
  },
  data() {
    return {
      RECTIFICATIONTIME: '',
      buttonloading: false,
      hs:{},
      pd: {},
      files: [],
      files2: [],
      files4: [],
      files5: [],
      confirmDataList: [],
      checkList: [],
      correctionDataList: [],
      correctionRepulseDataList: [],
      delayedReviewDataList: [],
      acceptRepulseDataList: [],
      basePath: basePath,
      baseImgPath: baseImgPath,
      HAVESCHEME: '0',
      HAVEPLAN: '0',
      HIDDENSCHEME_ID: '',
      treeNode: [], //部门下拉数据
      videoList: [],
      modalShow: false,
      videoSrc: '',
    }
  },
  mounted() {
    console.log('mounted')
    if (this.hidden_id) {
      this.getData();
    }
  },
  methods: {
    ViewShowImage5(e) {
      let files = [];
      for (var i = 0; i < this.files5.length; i++) {
        files.push(baseImgPath + this.files5[i].FILEPATH)
      }
      uni.previewImage({
        urls: files,
        current: e.currentTarget.dataset.index
      });
    },
    ViewShowImage4(e) {
      let files = [];
      for (var i = 0; i < this.files4.length; i++) {
        files.push(baseImgPath+this.files4[i].FILEPATH)
      }
      uni.previewImage({
        urls: files,
        current: e.currentTarget.dataset.index
      });
    },
    ViewShowImage2(e) {
      let files = [];
      for (var i = 0; i < this.files2.length; i++) {
        files.push(baseImgPath + this.files2[i].FILEPATH)
      }
      uni.previewImage({
        urls: files,
        current: e.currentTarget.dataset.index
      });
    },
    ViewShowImages(imgs, index) {
      let files = [];
      for (var i = 0; i < imgs.length; i++) {
        files.push(baseImgPath + imgs[i].FILEPATH)
      }
      uni.previewImage({
        urls: files,
        current: index
      });
    },
    fullScreenHandler(e) {
      if (uni.getSystemInfoSync().platform == "ios") {
        return
      }
    },
    getData() {
      var _this = this;
      uni.showLoading({
        title: '请稍候'
      })
      uni.request({
        url: basePath + '/app/hidden/goEdit',
        method: 'POST',
        dataType: 'json',
        header: {
          'Content-type': 'application/x-www-form-urlencoded'
        },
        data: {
          HIDDEN_ID: _this.hidden_id,
          CORPINFO_ID: loginUser.CORPINFO_ID,
          USER_ID: loginUser.USER_ID,
        },
        success: (res) => {
          if ("success" == res.data.result) {
            uni.hideLoading();
            _this.pd = res.data.pd; //参数map
            _this.hs = res.data.hs; //参数map
            for (let i = 0; i < res.data.hImgs.length; i++) {
              if (res.data.hImgs[i].FILEPATH.substring(res.data.hImgs[i].FILEPATH.lastIndexOf(".") + 1, res.data.hImgs[i].FILEPATH.length) === 'mp4') {
                _this.videoList.push(res.data.hImgs[i])
              } else {
                _this.files.push(res.data.hImgs[i])
              }
            }
            for (let i = 0; i < res.data.rImgs.length; i++) {
                _this.files2.push(res.data.rImgs[i])
            }
            // 计划图片
            _this.files5 = res.data.pImgs;
            // 方案图片
            _this.files4 = res.data.sImgs;

            _this.confirmDataList = res.data.confirmDataList;
            _this.correctionDataList = res.data.correctionDataList;
            _this.correctionRepulseDataList = res.data.correctionRepulseDataList;
            _this.delayedReviewDataList = res.data.delayedReviewDataList;
            _this.acceptRepulseDataList = res.data.acceptRepulseDataList;
            _this.checkList = res.data.checkList;
            this.$forceUpdate();//强制刷新
          } else if ("exception" == data.result) {
            uni.showToast({
              title: '错误',
              duration: 2000
            });
          }
        }
      });
    },
    ViewShowImage(e) {
      let files = [];
      for (var i = 0; i < this.files.length; i++) {
        files.push(baseImgPath + this.files[i].FILEPATH)
      }
      uni.previewImage({
        urls: files,
        current: e.currentTarget.dataset.index
      });
    },
    playVideo(e) {
      this.videoSrc = e.currentTarget.dataset.src
      this.modalShow = true
    },
  }
}
</script>

<style>


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

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

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

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