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