Parcourir la source

企业搜索分页

Xiao_123 il y a 9 mois
Parent
commit
12b021ecf8
1 fichiers modifiés avec 11 ajouts et 11 suppressions
  1. 11 11
      src/views/recruit/personal/company/index.vue

+ 11 - 11
src/views/recruit/personal/company/index.vue

@@ -14,8 +14,8 @@
       <companyItem class="mt-3" :list="items"></companyItem>
       <MPagination
         :total="total"
-        :page="pageInfo.pageNo"
-        :limit="pageInfo.pageSize"
+        :page="query.pageNo"
+        :limit="query.pageSize"
         @handleChange="handleChangePage"
       ></MPagination>
     </div>
@@ -43,12 +43,9 @@ const clear = ref(false)
 
 const total = ref(0)
 const items = ref([])
-const pageInfo = ref({
-  pageSize: 10,
-  pageNo: 1
-})
 const query = ref({
-  ...pageInfo.value
+  pageNo: 1,
+  pageSize: 12
 })
 
 const dealRouteQuery = (data) => {
@@ -74,15 +71,18 @@ const handleSearch = async (val, key) => {
 
 const getCompanyData = async () => {
   const { list, total: number } = await getEnterpriseSearch(query.value)
+  if (!list.length) {
+    list.value = []
+    total.value = 0
+    return
+  }
   total.value = number
   items.value = dealDictArrayData([], list)
 }
 
 const handleClear = () => {
   clear.value = true
-  query.value = {
-    ...pageInfo.value
-  }
+  query.value.pageNo = 1
   router.push(route.path)
   getCompanyData()
 }
@@ -103,7 +103,7 @@ if (Object.keys(route.query).length) {
 
 // 分页
 const handleChangePage = (index) => {
-  pageInfo.value.pageNo = index
+  query.value.pageNo = index
   getCompanyData()
 }
 </script>