修改每日菜品
This commit is contained in:
1 parent
a36df511ee
commit
b467fcd4db
4 files changed
+45
-11
No files matched your search
@@ -450,6 +450,10 @@ const open = (payload: {
|
||||
bizDate,
|
||||
mealNames: mealNames.length ? mealNames : [],
|
||||
mealName: mealNames.join(",") || r.mealName,
|
||||
id: r.id != null && r.id !== "" ? String(r.id) : r.id,
|
||||
spuId: r.spuId != null && r.spuId !== "" ? String(r.spuId) : r.spuId,
|
||||
childSpuId:
|
||||
r.childSpuId != null && r.childSpuId !== "" ? String(r.childSpuId) : r.childSpuId,
|
||||
}
|
||||
})
|
||||
mealFilters.value = [...ALL_MEALS]
|
||||
@@ -517,9 +521,10 @@ const submitConfirm = async () => {
|
||||
onlineStock: toNumberOrUndef(r.onlineStock),
|
||||
offlineStock: toNumberOrUndef(r.offlineStock),
|
||||
ingredients: r.ingredients,
|
||||
id: r.id,
|
||||
spuId: r.spuId,
|
||||
childSpuId: r.childSpuId,
|
||||
// 雪花 ID 必须始终以字符串回传,避免 JSON Number 丢末位精度
|
||||
id: r.id != null && r.id !== "" ? String(r.id) : undefined,
|
||||
spuId: r.spuId != null && r.spuId !== "" ? String(r.spuId) : undefined,
|
||||
childSpuId: r.childSpuId != null && r.childSpuId !== "" ? String(r.childSpuId) : undefined,
|
||||
}
|
||||
}),
|
||||
}
|
||||
|
||||
@@ -90,6 +90,10 @@
|
||||
<span class="mx-1">|</span>
|
||||
<span class="text-sm">{{ getCategoryName(item.categoryId) }}</span>
|
||||
</div>
|
||||
<div v-if="Number(item.spuType) === 2 && displayComboName(item) !== '-'"
|
||||
class="w-full text-xs text-orange-600 text-center mt-1 px-1">
|
||||
{{ displayComboName(item) }}
|
||||
</div>
|
||||
<div v-if="Number(item.spuType) === 2 && item.comboItems?.length"
|
||||
class="w-full text-xs text-gray-500 text-center mt-1 px-1">
|
||||
含:{{ formatComboItems(item.comboItems) }}
|
||||
@@ -113,6 +117,10 @@
|
||||
<span class="mx-1">|</span>
|
||||
<span class="text-sm">{{ getCategoryName(item.categoryId) }}</span>
|
||||
</div>
|
||||
<div v-if="Number(item.spuType) === 2 && displayComboName(item) !== '-'"
|
||||
class="w-full text-xs text-orange-600 text-center mt-1 px-1">
|
||||
{{ displayComboName(item) }}
|
||||
</div>
|
||||
<div v-if="Number(item.spuType) === 2 && item.comboItems?.length"
|
||||
class="w-full text-xs text-gray-500 text-center mt-1 px-1">
|
||||
含:{{ formatComboItems(item.comboItems) }}
|
||||
@@ -137,6 +145,10 @@
|
||||
<span class="mx-1">|</span>
|
||||
<span class="text-sm">{{ getCategoryName(item.categoryId) }}</span>
|
||||
</div>
|
||||
<div v-if="Number(item.spuType) === 2 && displayComboName(item) !== '-'"
|
||||
class="w-full text-xs text-orange-600 text-center mt-1 px-1">
|
||||
{{ displayComboName(item) }}
|
||||
</div>
|
||||
<div v-if="Number(item.spuType) === 2 && item.comboItems?.length"
|
||||
class="w-full text-xs text-gray-500 text-center mt-1 px-1">
|
||||
含:{{ formatComboItems(item.comboItems) }}
|
||||
@@ -223,6 +235,11 @@
|
||||
:max-height="listTableMaxHeight"
|
||||
:default-sort="{ prop: 'sort', order: 'ascending' }"
|
||||
:cell-style="tableStyle.cellStyle" :header-cell-style="tableStyle.headerCellStyle">
|
||||
<el-table-column label="套餐名" min-width="120" fixed="left" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
{{ displayComboName(row) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="菜品" min-width="200" fixed="left" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<div class="flex items-center gap-2">
|
||||
@@ -571,6 +588,12 @@ const getCategoryName = (categoryId?: number | string) =>
|
||||
const formatComboItems = (comboItems: any[] = []) =>
|
||||
comboItems.map((c: any) => c.name || c.childSpuName).filter(Boolean).join("、")
|
||||
|
||||
/** 列表展示套餐名:优先 comboName,其次 introduction;单品显示 - */
|
||||
const displayComboName = (row: any) => {
|
||||
if (Number(row?.spuType) !== 2) return "-"
|
||||
return String(row?.comboName || row?.introduction || "").trim() || "-"
|
||||
}
|
||||
|
||||
const hourTypeLabel = (hourType?: number) => HOUR_TYPE_LABEL[hourType || 0] || "-"
|
||||
|
||||
const hourTypeTagType = (hourType?: number) => {
|
||||
|
||||
@@ -33,6 +33,10 @@
|
||||
<span class="meta-label">日期</span>
|
||||
<span class="meta-value">{{ formatDate(detail.startTime) }}</span>
|
||||
</div>
|
||||
<div v-if="Number(detail.spuType) === 2" class="meta-item">
|
||||
<span class="meta-label">套餐名</span>
|
||||
<span class="meta-value">{{ detail.comboName || detail.introduction || "-" }}</span>
|
||||
</div>
|
||||
<div class="meta-item">
|
||||
<span class="meta-label">排序</span>
|
||||
<span class="meta-value">{{ detail.sort ?? "-" }}</span>
|
||||
@@ -85,6 +89,9 @@
|
||||
<span>{{ detail.name || "-" }}</span>
|
||||
<el-tag v-if="Number(detail.spuType) === 2" type="warning" size="small" class="ml-2">套餐</el-tag>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="Number(detail.spuType) === 2" label="套餐名" prop="comboName">
|
||||
<el-input v-model.trim="form.comboName" placeholder="打印/展示用套餐名,如 A套餐" maxlength="64" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="日期">
|
||||
<span>{{ formatDate(detail.startTime) }}</span>
|
||||
</el-form-item>
|
||||
@@ -146,6 +153,7 @@ const form = reactive({
|
||||
onlineStock: 600,
|
||||
offlineStock: 600,
|
||||
priceYuan: 0,
|
||||
comboName: "",
|
||||
description: "<p></p>",
|
||||
})
|
||||
|
||||
@@ -220,6 +228,7 @@ const openDialog = async (row: any, openMode: "view" | "edit" = "view") => {
|
||||
form.onlineStock = row.onlineStock ?? 600
|
||||
form.offlineStock = row.offlineStock ?? 600
|
||||
form.priceYuan = Number(displayPrice(row.price, "")) || 0
|
||||
form.comboName = row.comboName || row.introduction || ""
|
||||
form.description = row.ingredients || "<p></p>"
|
||||
|
||||
try {
|
||||
@@ -227,6 +236,8 @@ const openDialog = async (row: any, openMode: "view" | "edit" = "view") => {
|
||||
const res: any = await getSpu(row.spuId)
|
||||
const spu = res.data || {}
|
||||
detail.ingredients = spu.description || row.ingredients || ""
|
||||
detail.comboName = spu.comboName || spu.introduction || detail.comboName || ""
|
||||
detail.introduction = spu.introduction || detail.introduction || ""
|
||||
detail.categoryName = row.categoryName || detail.categoryName
|
||||
if (Array.isArray(spu.comboItems) && spu.comboItems.length) {
|
||||
detail.comboItems = spu.comboItems
|
||||
@@ -234,6 +245,7 @@ const openDialog = async (row: any, openMode: "view" | "edit" = "view") => {
|
||||
if (openMode === "edit") {
|
||||
form.sort = spu.sort ?? form.sort
|
||||
form.priceYuan = Number(displayPrice(spu.price, "")) || form.priceYuan
|
||||
form.comboName = spu.comboName || spu.introduction || form.comboName
|
||||
form.description = spu.description || "<p></p>"
|
||||
}
|
||||
}
|
||||
@@ -266,6 +278,8 @@ const onSubmit = async () => {
|
||||
price: storePrice(form.priceYuan),
|
||||
marketPrice: storePrice(form.priceYuan),
|
||||
description: form.description,
|
||||
comboName: Number(detail.spuType) === 2 ? form.comboName || "" : "",
|
||||
introduction: Number(detail.spuType) === 2 ? form.comboName || spu.introduction || "" : spu.introduction,
|
||||
comboItems: spu.comboItems || [],
|
||||
})
|
||||
useMessage().success("保存成功")
|
||||
|
||||
@@ -26,11 +26,6 @@
|
||||
<el-input v-model.trim="form.nameEn" placeholder="请输入菜品英文名称" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="14" class="mb20" v-if="form.spuType === 2">
|
||||
<el-form-item label="套餐名" prop="comboName">
|
||||
<el-input v-model.trim="form.comboName" placeholder="请输入套餐名" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="14" class="mb20">
|
||||
<el-form-item label="菜品分类" prop="categoryId">
|
||||
<select-ctcg v-model="form.categoryId" />
|
||||
@@ -219,7 +214,6 @@ const form = reactive({
|
||||
merchantId: "",
|
||||
name: "",
|
||||
nameEn: "",
|
||||
comboName: "",
|
||||
introduction: "",
|
||||
description: "<p></p>",
|
||||
categoryId: "",
|
||||
@@ -275,7 +269,6 @@ const dataRules = ref({
|
||||
const onSpuTypeChange = () => {
|
||||
if (form.spuType !== 2) {
|
||||
form.comboItems = []
|
||||
form.comboName = ""
|
||||
}
|
||||
}
|
||||
|
||||
@@ -351,7 +344,6 @@ const onSubmit = async () => {
|
||||
const _pa: any = {
|
||||
...form,
|
||||
spuType: isCombo ? 2 : 1,
|
||||
comboName: isCombo ? form.comboName : "",
|
||||
price: storePrice(form.price),
|
||||
marketPrice: storePrice(form.marketPrice),
|
||||
comboItems: isCombo
|
||||
|
||||
Reference in new issue
Block a user