<template>
  <view>
    <!-- <view class="filter">
      <view @click="handleSort"
        >创建时间<u-icon :name="state.isUp ? 'arrow-up' : 'arrow-down'"></u-icon
      ></view>
      <view @click="state.isShowStatus = true"
        >状态<u-icon name="arrow-down"></u-icon
      ></view>
      <view style="width: 65%" @click="state.showTime = true">
        <u-input
          v-model="state.startTime"
          disabled
          disabledColor=""
          placeholder="开始时间"
        ></u-input>
        <text>-</text>
        <u-input
          v-model="state.endTime"
          disabled
          disabledColor=""
          placeholder="结束时间"
        ></u-input>
        <u-icon name="arrow-down"></u-icon>
      </view>
    </view> -->
    <page-view
      @loadList="
        (v) => {
          getList(v);
        }
      "
      :noMoreData="pageList.noMoreData"
      :list="pageList.list"
      :height="150"
      :isLoading="pageList.isLoading"
    >
      <view class="box">
        <scroll-view :enable-flex="true" scroll-x class="scroll-view">
          <uni-table stripe emptyText="">
            <!-- 表头行 -->
            <uni-tr>
              <uni-th v-for="(item, index) in tableTitleList" :key="index"
                >{{ item.name }}
              </uni-th>
            </uni-tr>
            <!-- 表格数据行 -->
            <uni-tr v-for="(item, index) in pageList.list" :key="index">
              <uni-td v-for="(tItem, index) in tableTitleList" :key="index">
                <view>
                  <text v-if="tItem.key === 'status'">
                    {{ item[tItem.key] ? "已处理" : "未处理" }}
                  </text>
                  <text v-else>
                    {{ item[tItem.key] }}
                  </text>
                </view></uni-td
              >
              <!-- <uni-td>
                <text class="btn" @click="handleCancel(item)"> 撤销 </text>
              </uni-td> -->
            </uni-tr>
          </uni-table>
        </scroll-view>
      </view>
    </page-view>

    <view class="btn-box-fix-btn">
      <view
        ><u-button type="primary" shape="circle" @click="goInquiry()"
          >加入我们</u-button
        >
      </view>
    </view>

    <!-- 状态 -->
    <!-- <u-action-sheet
      :closeOnClickOverlay="true"
      :closeOnClickAction="true"
      :actions="actionSheet.statusList"
      :title="'单据状态'"
      :show="state.isShowStatus"
      @select="handleSelectStatus"
      @close="state.isShowStatus = false"
    ></u-action-sheet>

    <TimeRangeFilter
      :show="state.showTime"
      @handleDialog="(v:boolean) => {state.showTime = v}"
      @handleOk="changeTime"
    /> -->
  </view>
</template>

<script setup lang="ts">
import PageView from "@/components/PageView/index.vue";
import TimeRangeFilter from "@/components/Dialog/TimeRangeFilter.vue";
import { SteelApi } from "@/services";
import pinia from "@/store";
import { useMemberStore } from "@/store/index";
import { onLoad, onShow } from "@dcloudio/uni-app";
const state = reactive({
  startTime: "",
  endTime: "",
  showTime: false,
  status: -1,
  isShowStatus: false,
  isUp: false,
});
const pageList: PageResult<any> = reactive({
  total: 0,
  list: [],
  pageNum: 1,
  pageSize: 100,
});
const resetPageList = () => {
  pageList.noMoreData = false;
  pageList.total = 0;
  pageList.list = [];
  pageList.pageNum = 1;
  pageList.pageSize = 100;
};
const tableTitleList = reactive([
  {
    name: "时间",
    key: "createdTime",
  },
  {
    name: "状态",
    key: "status",
  },
  {
    name: "公司名称",
    key: "companyName",
  },
]);

const goInquiry = () => {
  uni.navigateTo({
    url: "/pagesScrapSteel/registration", // 要跳转到的页面路径
  });
};

const getList = (v?: boolean) => {
  if (v) {
    if (Math.ceil(pageList.total / pageList.pageSize) > pageList.pageNum) {
      pageList.pageNum++;
    } else {
      pageList.noMoreData = true;
      return;
    }
  }
  let params: any = {
    pageSize: pageList.pageSize,
    pageNum: pageList.pageNum,
  };

  pageList.isLoading = true;
  SteelApi.getApplyList(params).then((res: any) => {
    if (res.code === 200) {
      pageList.isLoading = false;
      pageList.list = pageList.list = pageList.list.concat(res.data.list);
      pageList.total = res.data.total;
    }
  });
};

// function goDetail(item: any) {
//   uni.navigateTo({
//     url: "/pagesOrder/vehicle/detail?id=" + item.id + `&status=${item.status}`,
//   });
// }

onShow(() => {
  resetPageList()
  getList();
})



</script>
<style lang="scss" scoped>
.filter {
  display: flex;
  justify-content: space-around;
  font-size: 28rpx;
  padding: 10rpx 20rpx;
  > view {
    display: flex;
    align-items: center;
  }
  ::v-deep.u-input__content__field-wrapper__field {
    font-size: 14px !important;
  }
}
.box {
  padding: 28rpx 20rpx;
  .btn {
    color: $u-primary;
  }
  .scroll-view {
    white-space: nowrap;
    width: 100%;
    overflow: auto;
  }
  ::v-deep.uni-table {
    min-width: 300px !important;
  }
}
.btn-box-fix-btn {
  justify-content: center;
  view {
    width: 70%;
  }
}
.regis {
  font-size: 12px;
  text-align: center;
  padding-top: 15px;
  width: 100% !important;
  color: $u-primary;
  font-weight: bold;
}
</style>
