<script setup>
import { userInfo } from '~/store/user'

const { uo_type } = userInfo
const isBureau = ref(false)// 当前用户是否局端
isBureau.value = uo_type === '1'

const list = ref([])
const loading = ref(false)
const finished = ref(false)
let page = 1
function onLoad() {
  loading.value = true
  request({
    url: '/jdbg/gwgl_gw/index',
    data: {
      page,
      limit: 20,
      gw_fb: 1,
      gw_fb_depart: isBureau ? '' : '1',
    },
  }).then((res) => {
    const data = res.data
    list.value = [...list.value, ...data.page_data]
    finished.value = data.total_page === page
    page++
    loading.value = false
  })
}
const router = useRouter()
function cellClick(gw_id) {
  router.push({ path: '/officialDocumentManager/documentLibrary/detail', query: { gw_id } })
}
</script>

<template>
  <div>
    <van-list v-model:loading="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
      <van-cell
        v-for="(item, index) in list" :key="item" :title="`${index + 1}. ${item.gw_title}`"
        @click="cellClick(item.gw_id)"
      />
    </van-list>
  </div>
</template>
