<template>
  <view class="content">
    <u-list v-if="list.length > 0">
      <u-list-item v-for="(item, index) in list" :key="index">
        <view>
          <view class="flex-between main-title">
            <text class="u-line-1">申辩意见：{{ item.INSPECTED_EXPLAIN }}</text>
          </view>
          <view class="flex-between mt-10 subtitle">
            <text>申辩时间：{{ item.CREATTIME }}</text>
          </view>
          <view class="flex-between mt-10 subtitle">
            <text>申辩状态： {{ item.ISPASS === '0' ? '待审核' : (item.ISPASS === '1' ? '申辩成功' : item.ISPASS === '2' ? '申辩驳回' : '历史数据')
              }}</text>
          </view>
          <view class="flex-warp mt-10 subtitle" style="align-items: center">
            <text>签字图片：</text>
            <u--image :showLoading="true" :src="$store.state.filePath + item.INSPECTED_SITEUSER_SIGN_IMG" width="40px"
              height="40px" mode="scaleToFill"
              @click="previewImage($store.state.filePath + item.INSPECTED_SITEUSER_SIGN_IMG)"></u--image>
          </view>
          <view v-if="item.INSPECTED_EXPLAIN_FILENAME" class="flex-between mt-10 subtitle">
            <text>申辩附件名称： {{ item.INSPECTED_EXPLAIN_FILENAME }}</text>
          </view>
          <view v-if="item.INSPECTED_EXPLAIN_FILEPATH" class="flex-between mt-10 subtitle">
            <view class="uni-flex-item text-right">
              <u-button class="bth" type="primary" @click="downloadAppendix(item.INSPECTED_EXPLAIN_FILEPATH)">
                申辩附件下载
              </u-button>
            </view>
          </view>
          <view v-if="item.ISPASS === '2'" class="flex-warp mt-10 subtitle" style="align-items: center">
            <text>检查人签字：</text>
            <u--image :showLoading="true" :src="$store.state.filePath + item.INSPECTION_ORIGINATOR_SIGN_IMG"
              width="40px" height="40px" mode="scaleToFill"
              @click="previewImage($store.state.filePath + item.INSPECTION_ORIGINATOR_SIGN_IMG)"></u--image>
          </view>
          <view v-if="item.ISPASS === '2'" class="flex-between mt-10 subtitle">
            <text>检查人意见： {{ item.INSPECTED_EXPLAIN_REFUSE }}</text>
          </view>
          <view v-if="item.ISPASS === '2'" class="flex-between mt-10 subtitle">
            <text>审批时间： {{ item.INSPECTION_ORIGINATOR_SIGN_TIME }}</text>
          </view>
          <view v-if="item.ISPASS === '1'" class="flex-between mt-10 subtitle">
            <text>审批时间： {{ item.OPERATTIME }}</text>
          </view>
        </view>
      </u-list-item>
    </u-list>
    <empty v-else></empty>
  </view>
</template>

<script>
import { getSafetyenvironmentalExplain } from "../../api";
import { exPlainList } from '../../../Mock/safetyEnvirData';

export default {
  data() {
    return {
      INSPECTION_ID: '',
      list: [],
    }
  },
  onLoad(event) {
    this.INSPECTION_ID = event.INSPECTION_ID
    this.getData()
  },
  computed: {
    userInfo() {
      return this.$store.getters.getUserInfo
    }
  },
  methods: {
    async getData() {
      // let resData = await getSafetyenvironmentalExplain({
      //   INSPECTION_ID: this.INSPECTION_ID,
      //   CORPINFO_ID: this.userInfo.CORPINFO_ID
      // });
      // this.list = resData.list;

      this.list = exPlainList;
    },
    previewImage(current) {
      uni.previewImage({
        urls: [current],
        current
      });
    },
    downloadAppendix(url) {
      console.log(url)
      plus.runtime.openURL(this.$store.state.filePath + url, function (res) {
        console.log(res);
      });
    },
  }
}
</script>

<style scoped></style>
