<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="cu-form-group">
          <view class="title">巡检人</view>
          <view>
            {{ pd.INSPECTOR }}
          </view>
        </view>
        <view class="cu-form-group">
          <view class="title">
            <text>巡检时间</text>
          </view>
          <view>
            <text>{{ pd.INSPECTIONTIME }}</text>
          </view>
        </view>
        <view class="cu-form-group">
          <view class="title">
            <text>巡检内容</text>
          </view>
          <view>
            <text>{{ pd.INSPECTIONCONTENT }}</text>
          </view>
        </view>
        <view class="cu-form-group">
          <view class="title">
            <text>是否有故障</text>
          </view>
          <view>
            <text>{{ pd.ISFAULT }}</text>
          </view>
        </view>
        <view class="cu-form-textarea" v-if="pd.ISFAULT=='是'">
          <view class="title">
            <text>故障照片</text>
          </view>
          <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(baseImgPath+item.FILEPATH)"
                           mode=""></image>
                  </view>
                </view>
              </scroll-view>
            </view>
          </view>
        </view>
        <view class="cu-form-textarea" v-if="pd.ISFAULT=='是'">
          <view class="title">
            <text>故障处理后照片</text>
          </view>
          <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="ViewShowImage(baseImgPath+item.FILEPATH)"
                           mode=""></image>
                  </view>
                </view>
              </scroll-view>
            </view>
          </view>
        </view>
        <view class="cu-form-textarea">
          <view class="title">
            <text>巡检照片</text>
          </view>
          <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 files3" v-bind:key="index">
                  <view class="imgs">
                    <image :src="baseImgPath+item.FILEPATH" :data-index="index"
                           @click="ViewShowImage(baseImgPath+item.FILEPATH)"
                           mode=""></image>
                  </view>
                </view>
              </scroll-view>
            </view>
          </view>
        </view>
        <view class="cu-form-group">
          <view class="title">
            <text>是否启动应急预案</text>
          </view>
          <view>
            <text>{{ pd.ISEMERGENCY == '0'? "否":"是" }}</text>
          </view>
        </view>
        <view class="cu-form-group" v-if=" pd.ISEMERGENCY == '1'">
          <view class="title">
            <text>事件类型</text>
          </view>
          <view>
            <text>{{ pd.EVENT_TYPE }}</text>
          </view>
        </view>
        <view class="cu-form-group" v-if=" pd.ISEMERGENCY == '1'">
          <view class="title">
            <text>预案类型</text>
          </view>
          <view>
            <text>{{ pd.PLAN_TYPE }}</text>
          </view>
        </view>
        <view class="cu-form-group" v-if=" pd.ISEMERGENCY == '1'">
          <view class="title">
            <text>报警人</text>
          </view>
          <view>
            <text>{{ pd.REPORT_USER_NAME }}</text>
          </view>
        </view>
        <view class="cu-form-group" v-if=" pd.ISEMERGENCY == '1'">
          <view class="title">
            <text>报警时间</text>
          </view>
          <view>
            <text>{{ pd.REPORT_TIME }}</text>
          </view>
        </view>
        <view class="cu-form-group" v-if=" pd.ISEMERGENCY == '1'">
          <view class="title">
            <text>经度</text>
          </view>
          <view>
            <text>{{ pd.LONGITUDE }}</text>
          </view>
        </view>
        <view class="cu-form-group" v-if=" pd.ISEMERGENCY == '1'">
          <view class="title">
            <text>纬度</text>
          </view>
          <view>
            <text>{{ pd.LATITUDE }}</text>
          </view>
        </view>
        <view class="cu-form-group" v-if=" pd.ISEMERGENCY == '1'">
          <view class="title">
            <text>备注</text>
          </view>
          <view>
            <text>{{ pd.BEIZHU }}</text>
          </view>
        </view>

      </view>
      <view class="cu-tabbar-height"></view>
    </scroll-view>
  </view>
</template>

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

export default {
  data() {
    return {
      noClick: true,
      SPECIALEQUIPMENTAQXJ_ID: '',
      pd: [],
      files: [],
      files2: [],
      files3: [],
      basePath: basePath,
      baseImgPath: baseImgPath
    }
  },
  onLoad(e) {
    this.SPECIALEQUIPMENTAQXJ_ID = e.SPECIALEQUIPMENTAQXJ_ID;
    this.getData();
  },
  methods: {
    getData() {
      var _this = this;
      uni.showLoading({
        title: '请稍候'
      })
      uni.request({
        url: basePath + '/app/specialequipmentaqxj/goEdit',
        method: 'POST',
        dataType: 'json',
        header: {
          'Content-type': 'application/x-www-form-urlencoded'
        },
        data: {
          SPECIALEQUIPMENTAQXJ_ID: _this.SPECIALEQUIPMENTAQXJ_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.files = res.data.faultImgs;
            _this.files2 = res.data.handleImgs;
            _this.files3 = res.data.inspectionImgs;
          } else if ("exception" == data.result) {
            uni.showToast({
              title: '错误',
              duration: 2000
            });
          }
        }
      });
    },
    ViewShowImage(url) {
      let files = [];
      files.push(url)
      uni.previewImage({
        urls: files,
        current: 0
      });
    },
  }
}
</script>

<style>

</style>
