Merge remote-tracking branch 'origin/master'

This commit is contained in:
zjf committed 2025-01-16 11:15:13 +08:00
commit 2c6c5214ed
3 files changed
+127 -101

No files matched your search

+52 -46
View File
@@ -1,72 +1,78 @@
<!-- 图片预览 -->
<script lang="ts" setup name="PreviewImage">
type Props = {
src?: string
width?: string | number
height?: string | number
src?: string
width?: string | number
height?: string | number
}
const props = withDefaults(defineProps<Props>(), {
width: 50,
height: 50,
width: 50,
height: 50,
})
const realSrc = computed(() => {
if (!props.src) return "";
let real_src = props.src.split(",")[0];
return dispatchUrl(real_src) ?? "";
if (!props.src) return ""
let real_src = props.src.split(",")[0]
return dispatchUrl(real_src) ?? ""
})
const realSrcList = computed(() => {
if (!props.src) return "";
let real_src = props.src.split(",")?.map(v => dispatchUrl(v));
return real_src ?? [];
if (!props.src) return ""
let real_src = props.src.split(",")?.map((v) => dispatchUrl(v))
return real_src ?? []
})
const realWidth = computed(() => typeof props.width == "string" ? props.width : `${props.width}px`)
const realHeight = computed(() => typeof props.height == "string" ? props.height : `${props.height}px`)
const realWidth = computed(() => (typeof props.width == "string" ? props.width : `${props.width}px`))
const realHeight = computed(() => (typeof props.height == "string" ? props.height : `${props.height}px`))
function dispatchUrl(url?: string) {
if (!url) return ""
return url.includes('http') ? url : import.meta.env.VITE_IMAGE_BASE_PATH + url
if (!url) return ""
return url.includes("http") ? url : import.meta.env.VITE_IMAGE_BASE_PATH + url
}
</script>
<template>
<el-image v-if="props.src" hide-on-click-modal preview-teleported :src="`${realSrc}`" fit="cover"
:style="`width:${realWidth};height:${realHeight};`" :preview-src-list="realSrcList">
<template #error>
<div class="image-slot">
<i class="el-icon-picture-outline"></i>
</div>
</template>
</el-image>
<div v-else :style="`width:${realWidth};height:${realHeight};`" />
<el-image
v-if="props.src"
hide-on-click-modal
preview-teleported
:src="`${realSrc}`"
fit="cover"
:style="`width:${realWidth};height:${realHeight};`"
:preview-src-list="realSrcList"
loading="lazy"
>
<template #error>
<div class="image-slot">
<i class="el-icon-picture-outline"></i>
</div>
</template>
</el-image>
<div v-else :style="`width:${realWidth};height:${realHeight};`" />
</template>
<style lang="scss" scoped>
.el-image {
border-radius: 5px;
background-color: #ebeef5;
box-shadow: 0 0 5px 1px #ccc;
border-radius: 5px;
background-color: #ebeef5;
box-shadow: 0 0 5px 1px #ccc;
:deep(.el-image__inner) {
transition: all 0.3s;
cursor: pointer;
:deep(.el-image__inner) {
transition: all 0.3s;
cursor: pointer;
&:hover {
transform: scale(1.2);
}
}
&:hover {
transform: scale(1.2);
}
}
:deep(.image-slot) {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
color: #909399;
font-size: 30px;
}
:deep(.image-slot) {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
color: #909399;
font-size: 30px;
}
}
</style>
</style>
+42 -40
View File
@@ -92,46 +92,48 @@
</el-form>
</el-row>
<el-table
ref="foodMultipleTableRef"
:data="foodDataList"
v-loading="loading"
@selection-change="selectionChangeHandle"
>
<el-table-column type="selection" width="40" align="center" />
<el-table-column type="index" label="#" width="50" />
<el-table-column prop="name" label="商品名称" width="120px" show-overflow-tooltip />
<el-table-column prop="categoryId" label="商品分类" width="100px" show-overflow-tooltip>
<template #default="{ row }">
{{ categoryOptions?.find((item: any) => item?.id === row?.categoryId)?.name }}
</template>
</el-table-column>
<el-table-column prop="picUrl" label="商品封面图" align="center" width="160px" show-overflow-tooltip>
<template #default="scope">
<preview-image :src="scope.row.picUrl" />
</template>
</el-table-column>
<el-table-column prop="sort" label="排序字段" show-overflow-tooltip />
<el-table-column prop="status" label="上架状态" show-overflow-tooltip>
<template #default="scope">
<dict-tag :options="spu_status" :value="scope.row.status" />
</template>
</el-table-column>
<el-table-column prop="price" label="商品价格" show-overflow-tooltip>
<template #default="scope">
{{ displayPrice(scope.row.price) }}
</template>
</el-table-column>
<el-table-column prop="marketPrice" label="市场价" show-overflow-tooltip>
<template #default="scope">
{{ displayPrice(scope.row.marketPrice) }}
</template>
</el-table-column>
<el-table-column prop="costPrice" label="成本价" show-overflow-tooltip />
<el-table-column prop="stock" label="库存" show-overflow-tooltip />
<el-table-column prop="salesCount" label="商品销量" show-overflow-tooltip />
<el-table-column prop="createTime" label="创建时间" show-overflow-tooltip min-width="160" />
</el-table>
<div style="overflow: auto; max-height: 60vh">
<el-table
ref="foodMultipleTableRef"
:data="foodDataList"
v-loading="loading"
@selection-change="selectionChangeHandle"
>
<el-table-column type="selection" width="40" align="center" />
<el-table-column type="index" label="#" width="50" align="center" />
<el-table-column prop="name" label="商品名称" width="100px" align="center" show-overflow-tooltip />
<el-table-column prop="categoryId" label="商品分类" width="100px" align="center" show-overflow-tooltip>
<template #default="{ row }">
{{ categoryOptions?.find((item: any) => item?.id === row?.categoryId)?.name }}
</template>
</el-table-column>
<el-table-column prop="picUrl" label="商品封面图" align="center" show-overflow-tooltip>
<template #default="scope">
<preview-image :src="scope.row.picUrl" />
</template>
</el-table-column>
<el-table-column prop="sort" label="排序字段" align="center" show-overflow-tooltip />
<el-table-column prop="status" label="上架状态" align="center" show-overflow-tooltip>
<template #default="scope">
<dict-tag :options="spu_status" :value="scope.row.status" />
</template>
</el-table-column>
<el-table-column prop="price" label="商品价格" align="center" show-overflow-tooltip>
<template #default="scope">
{{ displayPrice(scope.row.price) }}
</template>
</el-table-column>
<el-table-column prop="marketPrice" label="市场价" align="center" show-overflow-tooltip>
<template #default="scope">
{{ displayPrice(scope.row.marketPrice) }}
</template>
</el-table-column>
<el-table-column prop="costPrice" label="成本价" align="center" show-overflow-tooltip />
<el-table-column prop="stock" label="库存" align="center" show-overflow-tooltip />
<el-table-column prop="salesCount" label="商品销量" align="center" show-overflow-tooltip />
<el-table-column prop="createTime" label="创建时间" align="center" show-overflow-tooltip />
</el-table>
</div>
<!-- <pagination
@size-change="sizeChangeHandle"
@current-change="currentChangeHandle"
+33 -15
View File
@@ -12,7 +12,7 @@
v-for="(item, index) in weekData.data"
:key="index"
@click="timeClick(item, index)"
:class="{ selectedSpan: isActive === index ? 'selected' : '' }"
:class="{ selectedSpan: isActive === index }"
class="border-2 border-solid border-gray-200 text-center"
>
<span>{{ item }}</span>
@@ -55,7 +55,12 @@
<td v-if="!loading" class="text-center" @click="addFood(3)">晚餐</td>
<div class="food_list">
<td class="food_list_item" v-for="(item, index) in foodData3" :key="index" @click="delteData(item.tid)">
<el-image style="width: 80px; height: 80px" :src="imageBaseUrl + item.picUrl" fit="cover" />
<el-image
style="width: 80px; height: 80px"
loading="lazy"
:src="imageBaseUrl + item.picUrl"
fit="cover"
/>
<div class="w-full flex justify-around items-center text-black mt-2">
<span>{{ item.name }}</span>
<span class="mx-1">|</span>
@@ -74,6 +79,7 @@
</template>
<script setup lang="ts" name="systemCanteenDailyMenu">
import { ElMessageBox } from "element-plus"
import { delObjs, selectTimeFoodApi, selectWeekInfo } from "/@/api/canteen/canteenDailyMenu"
import { fetchList } from "/@/api/canteen/canteenCategory"
import { useMessage } from "/@/hooks/message"
@@ -114,7 +120,7 @@ const addFood = async (hourType: number) => {
//选中具体时间数据
const timeClick = async (time: string, index: number) => {
//数据查询操作
if (time) {
if (time && isActive.value !== index) {
//时间处理
time = time.substring(0, time.indexOf("("))
timedata = time
@@ -138,7 +144,7 @@ const fetchData = async () => {
const weekDataRes = await selectWeekInfo(weekParams).finally(() => (loading.value = false))
weekData.data = weekDataRes.data
isActive.value = new Date().getDay() === 0 ? 6 : new Date().getDay() - 1
timedata = weekData.data[0]
timedata = weekData.data[isActive.value]
// 时间格式
timedata = timedata.substring(0, timedata.indexOf("("))
selectTimeFood()
@@ -176,17 +182,28 @@ const selectTimeFood = async () => {
// 删除菜品
const delteData = async (tid: number) => {
await message.delConfirm("确定删除菜品吗?", "今日菜品?")
try {
loading.value = true
await delObjs([tid], merchantId.value)
message.success("删除成功")
} catch (error) {
message.error("删除失败")
} finally {
loading.value = false
}
selectTimeFood()
ElMessageBox.confirm("确定删除菜品吗?", "今日菜品?", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(async () => {
try {
loading.value = true
const { code } = await delObjs([tid], merchantId.value)
if (code === 0) {
message.success("删除成功")
selectTimeFood()
} else {
message.error("删除失败")
}
} catch (error) {
message.error("删除失败")
} finally {
loading.value = false
}
})
.catch(() => {})
}
// 获取下拉框选项
@@ -265,6 +282,7 @@ onMounted(async () => {
border-left: 2px solid transparent;
color: rgb(255, 187, 0);
position: relative;
cursor: default;
}
.selectedSpan::before {
content: "";