feat: 在投标列表中添加置顶功能

This commit is contained in:
dmy
2026-01-13 21:20:30 +08:00
parent f050d38140
commit d1e64596aa

View File

@@ -12,6 +12,20 @@
</el-select> </el-select>
</div> </div>
<el-table :data="bids" v-loading="loading" style="width: 100%"> <el-table :data="bids" v-loading="loading" style="width: 100%">
<el-table-column label="Pin" width="60" align="center">
<template #default="scope">
<el-icon
:style="{
color: scope.row.pin ? '#f56c6c' : '#909399',
cursor: 'pointer',
fontSize: '18px'
}"
@click="togglePin(scope.row)"
>
<Paperclip />
</el-icon>
</template>
</el-table-column>
<el-table-column prop="title" label="Title"> <el-table-column prop="title" label="Title">
<template #default="scope"> <template #default="scope">
<a :href="scope.row.url" target="_blank">{{ scope.row.title }}</a> <a :href="scope.row.url" target="_blank">{{ scope.row.title }}</a>
@@ -37,6 +51,9 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref } from 'vue' import { ref } from 'vue'
import axios from 'axios'
import { ElMessage } from 'element-plus'
import { Paperclip } from '@element-plus/icons-vue'
interface Props { interface Props {
bids: any[] bids: any[]
@@ -75,6 +92,18 @@ const handleSizeChange = (size: number) => {
currentPage.value = 1 currentPage.value = 1
emit('fetch', currentPage.value, pageSize.value, selectedSource.value || undefined) emit('fetch', currentPage.value, pageSize.value, selectedSource.value || undefined)
} }
// 切换 Pin 状态
const togglePin = async (item: any) => {
try {
const newPinStatus = !item.pin
await axios.patch(`/api/bids/${encodeURIComponent(item.title)}/pin`, { pin: newPinStatus })
item.pin = newPinStatus
ElMessage.success(newPinStatus ? '已置顶' : '已取消置顶')
} catch (error) {
ElMessage.error('操作失败')
}
}
</script> </script>
<style scoped> <style scoped>