种类管理
This commit is contained in:
@@ -252,6 +252,13 @@ const api = {
|
||||
createWithdraw: (data) => apiRequest.post('/withdrawals', data),
|
||||
},
|
||||
|
||||
categories: {
|
||||
getCategories: () => apiRequest.get('/category'),
|
||||
createCategory: (data) => apiRequest.post('/category', data),
|
||||
updateCategory: (id, data) => apiRequest.put(`/category/${id}`, data),
|
||||
deleteCategory: (id) => apiRequest.delete(`/category/${id}`)
|
||||
},
|
||||
|
||||
|
||||
|
||||
// 为了向后兼容,添加直接的 get、post 等方法
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -23,8 +23,8 @@
|
||||
<el-option
|
||||
v-for="category in categories"
|
||||
:key="category"
|
||||
:label="category"
|
||||
:value="category"
|
||||
:label="category.category_name"
|
||||
:value="category.category_name"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
@@ -32,6 +32,7 @@
|
||||
<el-select v-model="filters.status" placeholder="请选择状态" clearable style="display: inline-block; width: 150px;">
|
||||
<el-option label="上架" value="active" />
|
||||
<el-option label="下架" value="inactive" />
|
||||
<el-option label="待审核" value="pending" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
@@ -56,9 +57,9 @@
|
||||
</el-table-column>
|
||||
<el-table-column prop="name" label="商品名称" min-width="150" />
|
||||
<el-table-column prop="category" label="分类" width="120" />
|
||||
<el-table-column prop="points" label="积分价格" width="100">
|
||||
<el-table-column prop="points" label="积分价格" width="125">
|
||||
<template #default="{ row }">
|
||||
<span class="points-text">{{ row.points }} 积分</span>
|
||||
<span class="points-text">{{ row.points_price }} 积分</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="rongdou_price" label="融豆价格" width="100">
|
||||
@@ -70,16 +71,23 @@
|
||||
<template #default="{ row }">
|
||||
<div class="shop-info">
|
||||
<el-avatar v-if="row.shop_avatar" :src="getImageUrl(row.shop_avatar)" :size="24" />
|
||||
<span>{{ row.shop_name || '默认店铺' }}</span>
|
||||
<span>{{ row.shop_name || '平台上架' }}</span>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="stock" label="库存" width="80" />
|
||||
<el-table-column prop="sales" label="销量" width="80" />
|
||||
<el-table-column prop="status" label="状态" width="100">
|
||||
<el-table-column prop="free_shipping" label="包邮" width="80">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="row.status === 'active' ? 'success' : 'danger'">
|
||||
{{ row.status === 'active' ? '上架' : '下架' }}
|
||||
<el-tag :type="row.free_shipping ? 'success' : 'info'" size="small">
|
||||
{{ row.free_shipping ? '包邮' : '不包邮' }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="status" label="状态" width="110">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="row.status === 'active' ? 'warning' : row.status === 'pending' ? 'info' : 'success'">
|
||||
{{ row.status === 'active' ? '上架' : row.status === 'pending' ? '待审核' : '下架' }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -88,7 +96,7 @@
|
||||
{{ formatDate(row.created_at) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="280" fixed="right">
|
||||
<el-table-column label="操作" width="200" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
type="primary"
|
||||
@@ -97,11 +105,11 @@
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button type="info" size="small" @click="viewSpecCombinations(row.id)">
|
||||
<el-button type="info" size="small" @click="viewSpecCombinations(row.id)">
|
||||
规格管理
|
||||
</el-button>
|
||||
<el-button
|
||||
:type="row.status === 'active' ? 'warning' : 'success'"
|
||||
:type="row.status === 'active' ? 'warning' : row.status === 'pending' ? 'warning' : 'success'"
|
||||
size="small"
|
||||
@click="toggleStatus(row)"
|
||||
>
|
||||
@@ -151,7 +159,7 @@ const filters = reactive({
|
||||
status: ''
|
||||
})
|
||||
|
||||
const pagination = reactive({
|
||||
const pagination = ref({
|
||||
page: 1,
|
||||
limit: 20,
|
||||
total: 0
|
||||
@@ -162,14 +170,14 @@ const loadProducts = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const params = {
|
||||
page: pagination.page,
|
||||
limit: pagination.limit,
|
||||
page: pagination.value.page,
|
||||
limit: pagination.value.limit,
|
||||
...filters
|
||||
}
|
||||
|
||||
const {data} = await api.products.getProducts(params)
|
||||
products.value = data.data.products
|
||||
pagination.total = data.data.total
|
||||
pagination.value.total = data.data.pagination.total
|
||||
} catch (error) {
|
||||
ElMessage.error('加载商品列表失败')
|
||||
} finally {
|
||||
@@ -180,7 +188,7 @@ const loadProducts = async () => {
|
||||
// 加载商品分类
|
||||
const loadCategories = async () => {
|
||||
try {
|
||||
const {data} = await api.products.getCategories()
|
||||
const {data} = await api.categories.getCategories()
|
||||
categories.value = data.data.categories
|
||||
} catch (error) {
|
||||
console.error('加载分类失败:', error)
|
||||
@@ -194,7 +202,7 @@ const resetFilters = () => {
|
||||
category: '',
|
||||
status: ''
|
||||
})
|
||||
pagination.page = 1
|
||||
pagination.value.page = 1
|
||||
loadProducts()
|
||||
}
|
||||
|
||||
@@ -298,6 +306,12 @@ onMounted(() => {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.view-qualification {
|
||||
color: #409eff;
|
||||
cursor: pointer;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.points-text {
|
||||
color: #e6a23c;
|
||||
font-weight: 500;
|
||||
|
||||
Reference in New Issue
Block a user