feat: 分类管理添加是否可跨分类购物选项
Build and Push Docker Image / build-and-push (push) Successful in 1m0s
Build and Push Docker Image / deploy (push) Successful in 8s
Docker Build / Build and Push Docker Image (push) Has been cancelled
Docker Build / Deploy to Server (push) Has been cancelled

This commit is contained in:
2026-07-05 20:18:27 +08:00
parent 62df42d479
commit b26fea9621
4 changed files with 66 additions and 49 deletions
+13 -3
View File
@@ -14,6 +14,13 @@
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column label="跨分类购物" width="100">
<template #default="{ row }">
<el-tag :type="row.allow_cross_category ? 'success' : 'info'" size="small">
{{ row.allow_cross_category ? '允许' : '不允许' }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="操作" width="120">
<template #default="{ row }">
<el-button link type="primary" size="small" @click="editCat(row)">编辑</el-button>
@@ -41,6 +48,9 @@
<el-form-item label="最大数量"><el-input-number v-model="form.max_quantity" /></el-form-item>
<el-form-item label="最小重量"><el-input-number v-model="form.min_weight" :precision="2" /></el-form-item>
<el-form-item label="最大重量"><el-input-number v-model="form.max_weight" :precision="2" /></el-form-item>
<el-form-item label="跨分类购物">
<el-switch v-model="form.allow_cross_category" active-text="允许" inactive-text="不允许" />
</el-form-item>
</el-form>
<template #footer>
<el-button @click="showAdd = false">取消</el-button>
@@ -65,7 +75,7 @@ const paginatedCategories = computed(() => {
const start = (page.value - 1) * pageSize
return categories.value.slice(start, start + pageSize)
})
const form = reactive({ name: '', description: '', min_amount: undefined as number | undefined, max_amount: undefined as number | undefined, min_quantity: undefined as number | undefined, max_quantity: undefined as number | undefined, min_weight: undefined as number | undefined, max_weight: undefined as number | undefined })
const form = reactive({ name: '', description: '', min_amount: undefined as number | undefined, max_amount: undefined as number | undefined, min_quantity: undefined as number | undefined, max_quantity: undefined as number | undefined, min_weight: undefined as number | undefined, max_weight: undefined as number | undefined, allow_cross_category: false })
function handlePageChange() {
window.scrollTo({ top: 0, behavior: 'smooth' })
@@ -78,13 +88,13 @@ async function fetchCategories() {
function openAdd() {
editing.value = null
Object.assign(form, { name: '', description: '', min_amount: undefined, max_amount: undefined, min_quantity: undefined, max_quantity: undefined, min_weight: undefined, max_weight: undefined })
Object.assign(form, { name: '', description: '', min_amount: undefined, max_amount: undefined, min_quantity: undefined, max_quantity: undefined, min_weight: undefined, max_weight: undefined, allow_cross_category: false })
showAdd.value = true
}
function editCat(row: any) {
editing.value = row
Object.assign(form, { name: row.name, description: row.description || '', min_amount: row.min_amount, max_amount: row.max_amount, min_quantity: row.min_quantity, max_quantity: row.max_quantity, min_weight: row.min_weight, max_weight: row.max_weight })
Object.assign(form, { name: row.name, description: row.description || '', min_amount: row.min_amount, max_amount: row.max_amount, min_quantity: row.min_quantity, max_quantity: row.max_quantity, min_weight: row.min_weight, max_weight: row.max_weight, allow_cross_category: row.allow_cross_category || false })
showAdd.value = true
}