|  | @@ -8,41 +8,36 @@
 | 
											
												
													
														|  |  import { ref } from 'vue';
 |  |  import { ref } from 'vue';
 | 
											
												
													
														|  |  import { ElIcon, ElMessage } from 'element-plus';
 |  |  import { ElIcon, ElMessage } from 'element-plus';
 | 
											
												
													
														|  |  import { Delete, EditPen, Picture as IconPicture, Search } from '@element-plus/icons-vue';
 |  |  import { Delete, EditPen, Picture as IconPicture, Search } from '@element-plus/icons-vue';
 | 
											
												
													
														|  | -import { useResponse } from '/@/utils/useResponse';
 |  | 
 | 
											
												
													
														|  |  import * as api from '/@/views/computer-information/api';
 |  |  import * as api from '/@/views/computer-information/api';
 | 
											
												
													
														|  |  import { useRouter } from 'vue-router';
 |  |  import { useRouter } from 'vue-router';
 | 
											
												
													
														|  |  import { usePagination } from '/@/utils/usePagination';
 |  |  import { usePagination } from '/@/utils/usePagination';
 | 
											
												
													
														|  | -import { useElTableData } from '/@/utils/useElTable';
 |  | 
 | 
											
												
													
														|  | 
 |  | +import { useTableData } from '/@/utils/useTableData';
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  const router = useRouter();
 |  |  const router = useRouter();
 | 
											
												
													
														|  | -const cardItems = ref([]);
 |  | 
 | 
											
												
													
														|  |  const loading = ref();
 |  |  const loading = ref();
 | 
											
												
													
														|  | -const { tableData, currentPage, pageSize ,total } = usePagination(fetchCardData)
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -// 分页参数
 |  | 
 | 
											
												
													
														|  | -// const currentPage = ref(1);
 |  | 
 | 
											
												
													
														|  | -// const pageSize = ref(10);
 |  | 
 | 
											
												
													
														|  | -// const total = ref(0);
 |  | 
 | 
											
												
													
														|  | 
 |  | +const { tableOptions, handlePageChange } = usePagination(fetchCardData);
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  async function fetchCardData() {
 |  |  async function fetchCardData() {
 | 
											
												
													
														|  | -  const query = {
 |  | 
 | 
											
												
													
														|  | -    page: currentPage.value,
 |  | 
 | 
											
												
													
														|  | -    limit: pageSize.value,
 |  | 
 | 
											
												
													
														|  | -  };
 |  | 
 | 
											
												
													
														|  | -  await useElTableData(api.getCardData, query, tableData, total, loading)
 |  | 
 | 
											
												
													
														|  | -	// const res = await useResponse(query, api.getCardData, loading);
 |  | 
 | 
											
												
													
														|  | -  // tableData.value = res.data;
 |  | 
 | 
											
												
													
														|  | -  // total.value = res.total;
 |  | 
 | 
											
												
													
														|  | -  // currentPage.value = res.page;
 |  | 
 | 
											
												
													
														|  | -  // pageSize.value = res.limit;
 |  | 
 | 
											
												
													
														|  | 
 |  | +	const query = {
 | 
											
												
													
														|  | 
 |  | +		page: tableOptions.value.page,
 | 
											
												
													
														|  | 
 |  | +		limit: tableOptions.value.limit,
 | 
											
												
													
														|  | 
 |  | +	};
 | 
											
												
													
														|  | 
 |  | +	await useTableData(api.getCardData, query, tableOptions);
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +const checkItem = (item) => {
 | 
											
												
													
														|  | 
 |  | +	router.push({
 | 
											
												
													
														|  | 
 |  | +		path: '/computer/detail',
 | 
											
												
													
														|  | 
 |  | +		query: { id: item.id },
 | 
											
												
													
														|  | 
 |  | +	});
 | 
											
												
													
														|  | 
 |  | +};
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  // 编辑和删除的事件处理
 |  |  // 编辑和删除的事件处理
 | 
											
												
													
														|  |  const editItem = (item) => {
 |  |  const editItem = (item) => {
 | 
											
												
													
														|  |  	router.push({
 |  |  	router.push({
 | 
											
												
													
														|  | -    path: '/computer/edit',
 |  | 
 | 
											
												
													
														|  | -    query: { computerNumber: item.computerNumber }
 |  | 
 | 
											
												
													
														|  | -  })
 |  | 
 | 
											
												
													
														|  | 
 |  | +		path: '/computer/edit',
 | 
											
												
													
														|  | 
 |  | +		query: { computerNumber: item.computerNumber },
 | 
											
												
													
														|  | 
 |  | +	});
 | 
											
												
													
														|  |  };
 |  |  };
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  const deleteItem = (item) => {
 |  |  const deleteItem = (item) => {
 | 
											
										
											
												
													
														|  | @@ -55,19 +50,20 @@ const deleteItem = (item) => {
 | 
											
												
													
														|  |  // 处理图片地址
 |  |  // 处理图片地址
 | 
											
												
													
														|  |  const getImageUrl = (images) => {
 |  |  const getImageUrl = (images) => {
 | 
											
												
													
														|  |  	// 如果有图片,返回第一个图片的 image_url,否则返回占位图
 |  |  	// 如果有图片,返回第一个图片的 image_url,否则返回占位图
 | 
											
												
													
														|  | -	return images.length > 0 ? images[0].image_url : 'https://via.placeholder.com/150';
 |  | 
 | 
											
												
													
														|  | 
 |  | +	return images.length > 0 ? images[0].image_url : '';
 | 
											
												
													
														|  |  };
 |  |  };
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  onMounted(() => {
 |  |  onMounted(() => {
 | 
											
												
													
														|  | -  fetchCardData();
 |  | 
 | 
											
												
													
														|  | 
 |  | +	fetchCardData();
 | 
											
												
													
														|  |  });
 |  |  });
 | 
											
												
													
														|  |  </script>
 |  |  </script>
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  <template>
 |  |  <template>
 | 
											
												
													
														|  | -		<!-- 卡片展示区域 -->
 |  | 
 | 
											
												
													
														|  | 
 |  | +	<!-- 卡片展示区域 -->
 | 
											
												
													
														|  | 
 |  | +	<el-card shadow="never" style="border: none; min-height: 850px; position: relative;">
 | 
											
												
													
														|  |  		<div class="card-container">
 |  |  		<div class="card-container">
 | 
											
												
													
														|  |  			<el-row :gutter="20">
 |  |  			<el-row :gutter="20">
 | 
											
												
													
														|  | -				<el-col v-for="(item, index) in tableData" :key="index" :span="4" class="my-2.5">
 |  | 
 | 
											
												
													
														|  | 
 |  | +				<el-col v-for="(item, index) in tableOptions.data" :key="index" :span="4" class="my-2.5">
 | 
											
												
													
														|  |  					<el-card class="item-card" shadow="hover">
 |  |  					<el-card class="item-card" shadow="hover">
 | 
											
												
													
														|  |  						<el-image :src="getImageUrl(item.images)" alt="电脑图片" class="card-image">
 |  |  						<el-image :src="getImageUrl(item.images)" alt="电脑图片" class="card-image">
 | 
											
												
													
														|  |  							<template #error>
 |  |  							<template #error>
 | 
											
										
											
												
													
														|  | @@ -87,33 +83,26 @@ onMounted(() => {
 | 
											
												
													
														|  |  							</div>
 |  |  							</div>
 | 
											
												
													
														|  |  						</div>
 |  |  						</div>
 | 
											
												
													
														|  |  						<div class="card-footer">
 |  |  						<div class="card-footer">
 | 
											
												
													
														|  | -              <el-button :icon="Search" circle type="primary" @click="editItem(item)" />
 |  | 
 | 
											
												
													
														|  | -							<el-button :icon="EditPen" circle type="primary" @click="editItem(item)" />
 |  | 
 | 
											
												
													
														|  | 
 |  | +							<el-button :icon="Search" circle type="primary" @click="checkItem(item)" />
 | 
											
												
													
														|  | 
 |  | +							<el-button :icon="EditPen" circle type="warning" @click="editItem(item)" />
 | 
											
												
													
														|  |  							<el-button :icon="Delete" circle type="danger" @click="deleteItem(item)" />
 |  |  							<el-button :icon="Delete" circle type="danger" @click="deleteItem(item)" />
 | 
											
												
													
														|  |  						</div>
 |  |  						</div>
 | 
											
												
													
														|  |  					</el-card>
 |  |  					</el-card>
 | 
											
												
													
														|  |  				</el-col>
 |  |  				</el-col>
 | 
											
												
													
														|  |  			</el-row>
 |  |  			</el-row>
 | 
											
												
													
														|  |  		</div>
 |  |  		</div>
 | 
											
												
													
														|  | -    <div class="pagination-container">
 |  | 
 | 
											
												
													
														|  | -      <!--<el-pagination-->
 |  | 
 | 
											
												
													
														|  | -      <!--    v-model:current-page="currentPage"-->
 |  | 
 | 
											
												
													
														|  | -      <!--    :page-size="pageSize"-->
 |  | 
 | 
											
												
													
														|  | -      <!--    :page-sizes="[10, 25, 50,100,200]"-->
 |  | 
 | 
											
												
													
														|  | -      <!--    :total="total"-->
 |  | 
 | 
											
												
													
														|  | -      <!--    background-->
 |  | 
 | 
											
												
													
														|  | -      <!--    layout="total,sizes,prev, next, jumper"-->
 |  | 
 | 
											
												
													
														|  | -      <!--    small-->
 |  | 
 | 
											
												
													
														|  | -      <!--/>-->
 |  | 
 | 
											
												
													
														|  | -      <el-pagination
 |  | 
 | 
											
												
													
														|  | -          v-model:current-page="currentPage"
 |  | 
 | 
											
												
													
														|  | -          v-model:page-size="pageSize"
 |  | 
 | 
											
												
													
														|  | -          :page-sizes="[10, 20, 30, 50, 100, 200]"
 |  | 
 | 
											
												
													
														|  | -          :total="total"
 |  | 
 | 
											
												
													
														|  | -          layout="sizes, prev, pager, next, total"
 |  | 
 | 
											
												
													
														|  | -          background
 |  | 
 | 
											
												
													
														|  | -          @change="handlePageChange"/>
 |  | 
 | 
											
												
													
														|  | -    </div>
 |  | 
 | 
											
												
													
														|  | 
 |  | +		<div class="pagination-container" style="position: absolute; right: 32px; bottom: 32px;">
 | 
											
												
													
														|  | 
 |  | +			<el-pagination
 | 
											
												
													
														|  | 
 |  | +				v-model:current-page="tableOptions.page"
 | 
											
												
													
														|  | 
 |  | +				v-model:page-size="tableOptions.limit"
 | 
											
												
													
														|  | 
 |  | +				:page-sizes="[5, 10, 25, 50, 100, 200]"
 | 
											
												
													
														|  | 
 |  | +				:total="tableOptions.total"
 | 
											
												
													
														|  | 
 |  | +				background
 | 
											
												
													
														|  | 
 |  | +				layout="sizes, prev, pager, next, total"
 | 
											
												
													
														|  | 
 |  | +				@change="handlePageChange"
 | 
											
												
													
														|  | 
 |  | +			/>
 | 
											
												
													
														|  | 
 |  | +		</div>
 | 
											
												
													
														|  | 
 |  | +	</el-card>
 | 
											
												
													
														|  |  </template>
 |  |  </template>
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  <style lang="scss" scoped>
 |  |  <style lang="scss" scoped>
 | 
											
										
											
												
													
														|  | @@ -145,8 +134,8 @@ onMounted(() => {
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  .pagination-container {
 |  |  .pagination-container {
 | 
											
												
													
														|  | -  display: flex;
 |  | 
 | 
											
												
													
														|  | -  justify-content: flex-end;
 |  | 
 | 
											
												
													
														|  | -  // margin-bottom: 20px;
 |  | 
 | 
											
												
													
														|  | 
 |  | +	display: flex;
 | 
											
												
													
														|  | 
 |  | +	justify-content: flex-end;
 | 
											
												
													
														|  | 
 |  | +	// margin-bottom: 20px;
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  </style>
 |  |  </style>
 |