<template>
  <view>
    <CuNavbar title="员工管理">
      <template #right>
        <text @click="goPage('/pages/user/update')" class="text-white"
          >添加</text
        >
      </template>
    </CuNavbar>
    <StoreDropDown></StoreDropDown>
    <MescrollApiOne
      :top="88"
      ref="mescrollItem"
      apiUrl="/hr/employee"
      :params="params"
    >
      <template v-slot="{ list }">
        <view class="space-y-15rpx p-base">
          <view v-for="(item, i) in list" :key="i">
            <Item :item="item"></Item>
          </view>
        </view>
      </template>
    </MescrollApiOne>
  </view>
</template>
<script setup>
import { ref } from 'vue'
import CuNavbar from '@/components/cu-navbar/index'
import StoreDropDown from '@/pages/home/components/store-drop-down/index.vue'
import Item from './components/item.vue'
import MescrollApiOne from '@/components/mescroll-api/one'
import { onPageScroll, onReachBottom, onLoad } from '@dcloudio/uni-app'
import useMescrollComp from '@/uni_modules/mescroll-uni/hooks/useMescrollComp.js'
const { mescrollItem } = useMescrollComp(onPageScroll, onReachBottom)
const params = ref(null)

onLoad(()=>{
  uni.$on('user:onRefresh',onRefresh)
})

const onRefresh = () => {
  // params.value = {
  //   city_code: 11,
  //   store_id: 12,
  // }
  mescrollItem.value.getMescroll().resetUpScroll()
}
const goPage = (url) => {
  uni.navigateTo({
    url,
  })
}
</script>
