<template>
  <u-sticky class="shadow-default" bgColor="#fff" style="top: 0">
    <u-tabs
      :list="state.tabsList"
      :current="state.tabsCurrent"
      @click="tabsClick"
      lineColor="#333"
      :activeStyle="{ color: '#333', fontSize: '14px' }"
      :inactiveStyle="{ color: '#909399', fontSize: '14px' }"
      :scrollable="false"
    ></u-tabs>
  </u-sticky>

  <oa-scroll
    customClass="fastMail-container scroll-height"
    :pageSize="state.pageSize"
    :total="state.total"
    :isSticky="true"
    :refresherLoad="true"
    :refresherEnabled="true"
    :refresherDefaultStyle="'none'"
    :refresherThreshold="44"
    :refresherBackground="'#f5f6f7'"
    @load="load"
    @refresh="refresh"
    :data-theme="'theme-' + proxy.$settingStore.themeColor.name"
  >
    <view v-show="state.tabsCurrent == 1 || state.tabsCurrent == 0">
      <view class="content-area menu-list mlr0" v-for="data in state.dataList" :key="data">
        <view class="list-cell" style="color: #666666; line-height: 30px" @click="toDetail(data)">
          <view class="content-area-row_wrap menu-item">
            <view class="content-area-row_wrap-view" style="margin-right: auto">
              {{ data.eventName }}
            </view>
            <view class="content-area-row_wrap-view flexend">{{ data.createTime ? data.createTime.replace("T", " ") : "" }}</view>
            <view class="content-area-row_wrap-view">{{ proxy.$common.mapping("label", "value", data.eventType, patrol_event_type) }} </view>
          </view>
        </view>
      </view>
    </view>
  </oa-scroll>
</template>
<script setup>
/*----------------------------------依赖引入-----------------------------------*/
import { onLoad, onShow, onReady, onHide, onLaunch, onNavigationBarButtonTap, onPageScroll } from "@dcloudio/uni-app";
import { ref, reactive, getCurrentInstance, toRefs } from "vue";
/*----------------------------------接口引入-----------------------------------*/
import { errorApi } from "@/api/business/zhaf/xunJian";
/*----------------------------------组件引入-----------------------------------*/
/*----------------------------------store引入-----------------------------------*/
/*----------------------------------公共方法引入-----------------------------------*/
/*----------------------------------公共变量-----------------------------------*/
const { proxy } = getCurrentInstance();
const { patrol_event_classify, patrol_event_grade, patrol_event_type } = proxy.useDict("patrol_event_classify", "patrol_event_grade", "patrol_event_type");
/*----------------------------------变量声明-----------------------------------*/
const state = reactive({
  tabsList: [{ name: "未完成事件" }, { name: "已完成事件" }],
  tabsCurrent: 0,

  dataList: [],
  pageSize: 20,
  current: 1,
  total: 0,
});

/**
 * @页面初始化
 */
function init() {
  pageQueryApi();
}

function pageQueryApi() {
  errorApi()
    .Select({
      pageNum: state.current,
      pageSize: state.pageSize,
      handleStatus: state.tabsCurrent,
    })
    .then((res) => {
      state.dataList = res.data.records;
      state.total = res.data.total;
    });
}

/**
 * @复制粘贴板
 */
function toDetail(row) {
  proxy.$tab.navigateTo(`/pages/business/zhaf/xunJian/error/errorListDetail?id=${row.id}`);
}

/**
 * @tabs点击事件
 */
function tabsClick(e) {
  state.tabsCurrent = e.index;
  pageQueryApi();
}

/**
 * @scrollView加载数据
 */
function load() {
  state.pageSize += 10;
  init();
}

/**
 * @scrollView刷新数据
 */
function refresh() {
  state.pageSize = 20;
  init();
}

onLoad((options) => {
  init();
});

onReady(() => {});

onShow(() => {
  //调用系统主题颜色
  proxy.$settingStore.systemThemeColor([1]);
  init();
});

// 自定义导航事件
onNavigationBarButtonTap((e) => {
  if (e.float == "right") {
  }
});
</script>

<style lang="scss" scoped>
:deep(.uni-page-head__title) {
  opacity: 1 !important;
}

.fastMail-container {
  .content-area {
    &-top {
      font-size: 16px;
      font-weight: 600;
      color: #000000;
    }

    &-row_wrap {
      font-size: 13px;
      flex-flow: row wrap;

      &-view {
        min-width: 50%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        > .iconfont {
          font-size: 14px;
          color: #909399;
          margin-left: 5px;
        }
      }
    }
  }
}
.flexend {
  flex: 1;
  display: block;
  text-align: right;
}
</style>
