<script setup>
const router = useRouter();
function cellClick(xm_id) {
  router.push({ path: "/sanZhongYiDa/projectApply/detail", query: { xm_id } });
}

const listMyApplyFor = ref([]);
const loadingMyApplyFor = ref(false);
const finishedMyApplyFor = ref(false);
let pageMyApplyFor = 1;
const param = $ref({
  keyword: "",
});
function onLoadMyApplyFor() {
  loadingMyApplyFor.value = true;
  request({
    url: "/jdbg/xmlxsb_xmsq/index",
    data: {
      page: pageMyApplyFor,
      limit: 20,
      xm_status: 5,
      ...param,
    },
  }).then((res) => {
    const data = res.data;
    listMyApplyFor.value = [...listMyApplyFor.value, ...data.page_data];
    finishedMyApplyFor.value = data.total_page === pageMyApplyFor;
    pageMyApplyFor++;
    loadingMyApplyFor.value = false;
  });
}
function onClickSearch() {
  reGetList();
}
function reGetList() {
  pageMyApplyFor = 1;
  listMyApplyFor.value = [];
  finishedMyApplyFor.value = false;
  onLoadMyApplyFor();
}
</script>

<template>
  <van-search
    v-model="param.keyword"
    :clearable="false"
    show-action
    placeholder="请输入搜索关键词"
    @search="onClickSearch"
  >
    <template #action>
      <div @click="onClickSearch">搜索</div>
    </template>
  </van-search>
  <van-list
    v-model:loading="loadingMyApplyFor"
    :finished="finishedMyApplyFor"
    finished-text="没有更多了"
    @load="onLoadMyApplyFor"
  >
    <van-cell
      v-for="(item, index) in listMyApplyFor"
      :key="item"
      :title="`${index + 1}.\u00A0\u00A0${item.xm_name}`"
      @click="cellClick(item.xm_id)"
    />
  </van-list>
</template>
