修改每日菜谱
This commit is contained in:
1 parent
b4ff730fc8
commit
002f8ad6b1
6 files changed
+459
-336
No files matched your search
+4
-4
@@ -10,14 +10,14 @@ ENV = 'development'
|
||||
# ADMIN 服务地址
|
||||
VITE_ADMIN_PROXY_PATH = http://123.156.230.15:8089/api/ # 线上
|
||||
# VITE_ADMIN_PROXY_PATH = http://pjcloud.center.takin.cc/
|
||||
VITE_ADMIN_PROXY_PATH = http://localhost:9999/
|
||||
#VITE_ADMIN_PROXY_PATH = http://192.168.101.29:9999/ # 邓-本地
|
||||
# VITE_ADMIN_PROXY_PATH = http://localhost:9999/
|
||||
# VITE_ADMIN_PROXY_PATH = http://192.168.101.29:9999/ # 邓-本地
|
||||
|
||||
# 图片访问基础地址
|
||||
VITE_IMAGE_BASE_PATH = http://123.156.230.15:8089/api # 线上
|
||||
# VITE_IMAGE_BASE_PATH = http://pjcloud.center.takin.cc
|
||||
VITE_IMAGE_BASE_PATH = http://localhost:9999
|
||||
#VITE_IMAGE_BASE_PATH = http://192.168.101.29:9999 # 邓-本地
|
||||
# VITE_IMAGE_BASE_PATH = http://localhost:9999
|
||||
# VITE_IMAGE_BASE_PATH = http://192.168.101.29:9999 # 邓-本地
|
||||
|
||||
# 代码生成服务地址
|
||||
VITE_GEN_PROXY_PATH = http://192.168.110.156:5003
|
||||
@@ -1,67 +1,66 @@
|
||||
import request from "/@/utils/request"
|
||||
|
||||
export function fetchList(query?: Object) {
|
||||
return request({
|
||||
url: '/canteen/canteenDailyMenu/page',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
return request({
|
||||
url: "/canteen/canteenDailyMenu/page",
|
||||
method: "get",
|
||||
params: query,
|
||||
})
|
||||
}
|
||||
|
||||
export function addObj(obj?: Object) {
|
||||
return request({
|
||||
url: '/canteen/canteenDailyMenu',
|
||||
method: 'post',
|
||||
data: obj
|
||||
})
|
||||
return request({
|
||||
url: "/canteen/canteenDailyMenu",
|
||||
method: "post",
|
||||
data: obj,
|
||||
})
|
||||
}
|
||||
|
||||
export function getObj(id?: string) {
|
||||
return request({
|
||||
url: '/canteen/canteenDailyMenu/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
return request({
|
||||
url: "/canteen/canteenDailyMenu/" + id,
|
||||
method: "get",
|
||||
})
|
||||
}
|
||||
|
||||
export function delObjs(ids?: Object) {
|
||||
return request({
|
||||
url: '/canteen/canteenDailyMenu',
|
||||
method: 'delete',
|
||||
data: ids
|
||||
})
|
||||
export function delObjs(data?: Object) {
|
||||
return request({
|
||||
url: "/canteen/canteenDailyMenu",
|
||||
method: "delete",
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
export function putObj(obj?: Object) {
|
||||
return request({
|
||||
url: '/canteen/canteenDailyMenu',
|
||||
method: 'put',
|
||||
data: obj
|
||||
})
|
||||
return request({
|
||||
url: "/canteen/canteenDailyMenu",
|
||||
method: "put",
|
||||
data: obj,
|
||||
})
|
||||
}
|
||||
|
||||
export function selectFoodList(query?: Object) {
|
||||
return request({
|
||||
url: '/canteen/canteenDailyMenu/selectFoodList',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
return request({
|
||||
url: "/canteen/canteenDailyMenu/selectFoodList",
|
||||
method: "get",
|
||||
params: query,
|
||||
})
|
||||
}
|
||||
|
||||
//时间生成
|
||||
export function selectWeekInfo(query?: Object) {
|
||||
return request({
|
||||
url: '/canteen/canteenDailyMenu/selectWeekInfo',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
return request({
|
||||
url: "/canteen/canteenDailyMenu/selectWeekInfo",
|
||||
method: "get",
|
||||
params: query,
|
||||
})
|
||||
}
|
||||
|
||||
// //获取当前选中的菜品信息
|
||||
export function selectTimeFoodApi(query?: Object) {
|
||||
return request({
|
||||
url: '/canteen/canteenDailyMenu/selectTimeFood',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
return request({
|
||||
url: "/canteen/canteenDailyMenu/selectTimeFood",
|
||||
method: "get",
|
||||
params: query,
|
||||
})
|
||||
}
|
||||
|
||||
+69
-69
@@ -1,44 +1,44 @@
|
||||
import { CellStyle, ElMessage } from 'element-plus';
|
||||
import other from '/@/utils/other';
|
||||
import { CellStyle, ElMessage } from "element-plus"
|
||||
import other from "/@/utils/other"
|
||||
|
||||
/**
|
||||
* 表格组件基础配置属性
|
||||
*/
|
||||
export interface BasicTableProps {
|
||||
// 是否在创建页面时即调用数据列表接口,默认为true
|
||||
createdIsNeed?: boolean;
|
||||
createdIsNeed?: boolean
|
||||
// 是否需要分页,默认为true
|
||||
isPage?: boolean;
|
||||
isPage?: boolean
|
||||
// 查询条件表单对象,类型为any
|
||||
queryForm?: any;
|
||||
queryForm?: any
|
||||
// 数据列表数组
|
||||
dataList?: any[];
|
||||
dataList?: any[]
|
||||
// 分页属性对象
|
||||
pagination?: Pagination;
|
||||
pagination?: Pagination
|
||||
// 数据列表,loading状态标志,默认为false
|
||||
dataListLoading?: boolean;
|
||||
dataListLoading?: boolean
|
||||
// 数据列表多选项数组
|
||||
dataListSelections?: any[];
|
||||
dataListSelections?: any[]
|
||||
// 数据列表查询接口api方法,接收任意数量参数,返回Promise
|
||||
pageList?: (...arg: any) => Promise<any>;
|
||||
pageList?: (...arg: any) => Promise<any>
|
||||
// loading标志,默认为false
|
||||
loading?: Boolean;
|
||||
loading?: Boolean
|
||||
// 多选结果数组
|
||||
selectObjs?: any[];
|
||||
selectObjs?: any[]
|
||||
// 排序字段数组
|
||||
descs?: string[];
|
||||
descs?: string[]
|
||||
// 排序方式数组
|
||||
ascs?: string[];
|
||||
ascs?: string[]
|
||||
// props属性对象,类型为any
|
||||
props?: any;
|
||||
props?: any
|
||||
}
|
||||
|
||||
/**
|
||||
* 表格样式。
|
||||
*/
|
||||
export interface TableStyle {
|
||||
cellStyle: CellStyle<any>;
|
||||
headerCellStyle: CellStyle<any>;
|
||||
cellStyle: CellStyle<any>
|
||||
headerCellStyle: CellStyle<any>
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,15 +46,15 @@ export interface TableStyle {
|
||||
*/
|
||||
export interface Pagination {
|
||||
// 当前页码,默认为1
|
||||
current?: number;
|
||||
current?: number
|
||||
// 每页显示条数,默认为10
|
||||
size?: number;
|
||||
size?: number
|
||||
// 总条数,默认为0
|
||||
total?: number;
|
||||
total?: number
|
||||
// 每页显示条数选择器的选项数组,默认为[10,20,30,40]
|
||||
pageSizes?: any[];
|
||||
pageSizes?: any[]
|
||||
// 分页组件布局方式,可选值有 total,sizes,prev,jump,next,默认为'total,sizes,prev,jump,next'
|
||||
layout?: String;
|
||||
layout?: String
|
||||
}
|
||||
|
||||
export function useTable(options?: BasicTableProps) {
|
||||
@@ -75,7 +75,7 @@ export function useTable(options?: BasicTableProps) {
|
||||
size: 10,
|
||||
total: 0,
|
||||
pageSizes: [1, 10, 20, 50, 100, 200],
|
||||
layout: 'total, sizes, prev, pager, next, jumper',
|
||||
layout: "total, sizes, prev, pager, next, jumper",
|
||||
} as Pagination,
|
||||
// 当前选中的数据项,默认为空数组
|
||||
dataListSelections: [],
|
||||
@@ -89,10 +89,10 @@ export function useTable(options?: BasicTableProps) {
|
||||
ascs: [],
|
||||
// props属性配置对象,用于自定义数据属性,默认值为 {item:'records',totalCount:'total'}
|
||||
props: {
|
||||
item: 'records',
|
||||
totalCount: 'total',
|
||||
item: "records",
|
||||
totalCount: "total",
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 合并默认属性配置和自定义属性配置
|
||||
@@ -103,14 +103,14 @@ export function useTable(options?: BasicTableProps) {
|
||||
const mergeDefaultOptions = (options: any, props: any): BasicTableProps => {
|
||||
for (const key in options) {
|
||||
if (!Object.getOwnPropertyDescriptor(props, key)) {
|
||||
props[key] = options[key];
|
||||
props[key] = options[key]
|
||||
}
|
||||
}
|
||||
return props;
|
||||
};
|
||||
return props
|
||||
}
|
||||
|
||||
// 覆盖默认值
|
||||
const state = mergeDefaultOptions(defaultOptions, options);
|
||||
const state = mergeDefaultOptions(defaultOptions, options)
|
||||
|
||||
/**
|
||||
* 发起分页查询,并设置表格数据和分页信息
|
||||
@@ -120,36 +120,36 @@ export function useTable(options?: BasicTableProps) {
|
||||
if (state.pageList) {
|
||||
try {
|
||||
// 开始加载数据,设置state.loading为true
|
||||
state.loading = true;
|
||||
state.loading = true
|
||||
|
||||
// 调用state.pageList方法发起分页查询
|
||||
const res = await state.pageList({
|
||||
...state.queryForm,
|
||||
current: state.pagination?.current,
|
||||
size: state.pagination?.size,
|
||||
descs: state.descs?.join(','),
|
||||
ascs: state.ascs?.join(','),
|
||||
});
|
||||
descs: state.descs?.join(","),
|
||||
ascs: state.ascs?.join(","),
|
||||
})
|
||||
|
||||
// 设置表格展示的数据数组
|
||||
state.dataList = state.isPage ? res.data[state.props.item] : res.data;
|
||||
state.dataList = state.isPage ? res.data[state.props.item] : res.data
|
||||
// 设置分页信息中的总数据条数
|
||||
state.pagination!.total = state.isPage ? res.data[state.props.totalCount] : 0;
|
||||
state.pagination!.total = state.isPage ? res.data[state.props.totalCount] : 0
|
||||
} catch (err: any) {
|
||||
// 捕获异常并显示错误提示
|
||||
ElMessage.error(err.msg || err.data.msg);
|
||||
ElMessage.error(err.msg || err.data.msg)
|
||||
} finally {
|
||||
// 结束加载数据,设置state.loading为false
|
||||
state.loading = false;
|
||||
state.loading = false
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (state.createdIsNeed) {
|
||||
query();
|
||||
query()
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
/**
|
||||
* 分页大小改变事件处理函数
|
||||
@@ -157,10 +157,10 @@ export function useTable(options?: BasicTableProps) {
|
||||
*/
|
||||
const sizeChangeHandle = (val: number) => {
|
||||
// 修改state.pagination中的size属性
|
||||
state.pagination!.size = val;
|
||||
state.pagination!.size = val
|
||||
// 再次发起查询操作
|
||||
query();
|
||||
};
|
||||
query()
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前页码改变事件处理函数
|
||||
@@ -168,34 +168,34 @@ export function useTable(options?: BasicTableProps) {
|
||||
*/
|
||||
const currentChangeHandle = (val: number) => {
|
||||
// 修改state.pagination中的current属性
|
||||
state.pagination!.current = val;
|
||||
state.pagination!.current = val
|
||||
// 再次发起查询操作
|
||||
query();
|
||||
};
|
||||
query()
|
||||
}
|
||||
|
||||
// 排序触发事件
|
||||
const sortChangeHandle = (column: any) => {
|
||||
const prop = other.toUnderline(column.prop);
|
||||
if (column.order === 'descending') {
|
||||
state.descs?.push(prop);
|
||||
const prop = other.toUnderline(column.prop)
|
||||
if (column.order === "descending") {
|
||||
state.descs?.push(prop)
|
||||
if (state.ascs!.includes(prop)) {
|
||||
state.ascs?.splice(state.ascs.indexOf(prop), 1);
|
||||
state.ascs?.splice(state.ascs.indexOf(prop), 1)
|
||||
}
|
||||
} else if (column.order === 'ascending') {
|
||||
state.ascs?.push(prop);
|
||||
} else if (column.order === "ascending") {
|
||||
state.ascs?.push(prop)
|
||||
if (state.descs!.includes(prop)) {
|
||||
state.descs?.splice(state.descs.indexOf(prop), 1);
|
||||
state.descs?.splice(state.descs.indexOf(prop), 1)
|
||||
}
|
||||
} else {
|
||||
if (state.ascs!.includes(prop)) {
|
||||
state.ascs?.splice(state.ascs.indexOf(prop), 1);
|
||||
state.ascs?.splice(state.ascs.indexOf(prop), 1)
|
||||
}
|
||||
if (state.descs!.includes(prop)) {
|
||||
state.descs?.splice(state.descs.indexOf(prop), 1);
|
||||
state.descs?.splice(state.descs.indexOf(prop), 1)
|
||||
}
|
||||
}
|
||||
query();
|
||||
};
|
||||
query()
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据列表,并可选择是否刷新当前页码
|
||||
@@ -205,11 +205,11 @@ export function useTable(options?: BasicTableProps) {
|
||||
const getDataList = (refresh?: any) => {
|
||||
// 如果需要刷新,则将state.pagination.current重置为1
|
||||
if (refresh !== false) {
|
||||
state.pagination!.current = 1;
|
||||
state.pagination!.current = 1
|
||||
}
|
||||
// 再次发起查询操作
|
||||
query();
|
||||
};
|
||||
query()
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载文件
|
||||
@@ -219,21 +219,21 @@ export function useTable(options?: BasicTableProps) {
|
||||
* @returns 返回一个Promise对象,用于异步处理结果
|
||||
*/
|
||||
const downBlobFile = (url: string, query: any, fileName: string) => {
|
||||
return other.downBlobFile(url, query, fileName);
|
||||
};
|
||||
return other.downBlobFile(url, query, fileName)
|
||||
}
|
||||
|
||||
/**
|
||||
* 定义表格通用样式
|
||||
* @returns css
|
||||
*/
|
||||
const tableStyle: TableStyle = {
|
||||
cellStyle: { textAlign: 'center' },
|
||||
cellStyle: { textAlign: "center" },
|
||||
headerCellStyle: {
|
||||
textAlign: 'center',
|
||||
background: 'var(--el-table-row-hover-bg-color)',
|
||||
color: 'var(--el-text-color-primary)',
|
||||
textAlign: "center",
|
||||
background: "var(--el-table-row-hover-bg-color)",
|
||||
color: "var(--el-text-color-primary)",
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
tableStyle,
|
||||
@@ -242,5 +242,5 @@ export function useTable(options?: BasicTableProps) {
|
||||
currentChangeHandle,
|
||||
sortChangeHandle,
|
||||
downBlobFile,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -12,10 +12,14 @@
|
||||
<p v-else>未知类型</p>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="菜品" prop="spuId">
|
||||
<!-- <el-form-item label="菜品" prop="spuId">
|
||||
<el-select v-model="spuIds" placeholder="请选择菜品" multiple>
|
||||
<el-option v-for="item in foodData" :key="item.id" :label="item.name" :value="item.id" />
|
||||
<el-option v-for="item in foodList" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item> -->
|
||||
|
||||
<el-form-item label="选择菜品">
|
||||
<el-button @click="handleClickSelect">选择菜品</el-button>
|
||||
</el-form-item>
|
||||
|
||||
<!-- <el-col :span="12" class="mb20">
|
||||
@@ -27,7 +31,12 @@
|
||||
|
||||
<h1 style="font-size: 16px; font-weight: bold; color: #000000; margin: 20px 0">预览图</h1>
|
||||
<div style="width: 100%; display: flex; flex-wrap: wrap">
|
||||
<img style="width: 250px; height: 200px; margin: 10px" v-for="(image, index) in spuImages" :key="index" :src="image" />
|
||||
<img
|
||||
style="width: 250px; height: 200px; margin: 10px"
|
||||
v-for="(item, index) in selectedList"
|
||||
:key="item.id"
|
||||
:src="imageBaseUrl + item.picUrl"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
@@ -36,126 +45,219 @@
|
||||
<el-button type="primary" @click="onSubmit" :disabled="loading">确认</el-button>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<el-dialog v-model="selectDialogVisible" title="选择菜品" width="60%" :close-on-click-modal="false" draggable>
|
||||
<el-row>
|
||||
<el-form :model="state.queryForm" ref="queryRef" :inline="true" @keyup.enter="getDataList">
|
||||
<el-form-item label="商品名称" prop="name">
|
||||
<el-input placeholder="请输入商品名称" v-model="state.queryForm.name" />
|
||||
</el-form-item>
|
||||
<el-form-item label="商品分类" prop="categoryId">
|
||||
<select-ctcg v-model="state.queryForm.categoryId" style="width: 200px" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button icon="search" type="primary" @click="getDataList">查询</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-row>
|
||||
|
||||
<el-table
|
||||
:data="state.dataList"
|
||||
v-loading="loading"
|
||||
border
|
||||
:cell-style="tableStyle.cellStyle"
|
||||
:header-cell-style="tableStyle.headerCellStyle"
|
||||
@selection-change="selectionChangHandle"
|
||||
@sort-change="sortChangeHandle"
|
||||
>
|
||||
<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>
|
||||
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" />
|
||||
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="selectDialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="handleSelectDialogConfirm">确认</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="CanteenDailyMenuDialog">
|
||||
import { useDict } from '/@/hooks/dict';
|
||||
import { useMessage } from '/@/hooks/message';
|
||||
import { getObj, addObj, putObj } from '/@/api/canteen/canteenDailyMenu';
|
||||
import { selectFoodList } from '/@/api/canteen/canteenDailyMenu';
|
||||
import { rule } from '/@/utils/validate';
|
||||
import { useMessage } from "/@/hooks/message"
|
||||
import { rule } from "/@/utils/validate"
|
||||
import { BasicTableProps, useTable } from "/@/hooks/table"
|
||||
import { useDict } from "/@/hooks/dict"
|
||||
import { displayPrice } from "/@/utils/formatMoney"
|
||||
import { fetchList as getCanteenCategory } from "/@/api/canteen/canteenCategory"
|
||||
import { getObj, addObj, putObj } from "/@/api/canteen/canteenDailyMenu"
|
||||
import { fetchList } from "/@/api/canteen/canteenSpu"
|
||||
|
||||
const emit = defineEmits(['refresh']);
|
||||
const emit = defineEmits(["refresh"])
|
||||
|
||||
//业务变量
|
||||
const foodData = ref<any>([]);
|
||||
const spuIds = ref([]);
|
||||
const spuImages = ref<string[]>([]);
|
||||
// 定义变量内容
|
||||
const dataFormRef = ref();
|
||||
const visible = ref(false);
|
||||
const loading = ref(false);
|
||||
// 定义字典
|
||||
const { daily_menu } = useDict('daily_menu');
|
||||
const imageBaseUrl = import.meta.env.VITE_IMAGE_BASE_PATH;
|
||||
const dataFormRef = ref()
|
||||
const visible = ref(false)
|
||||
const queryRef = ref()
|
||||
const selectObjs = ref([]) as any // 表格多选的数据
|
||||
const selectedList = ref<any>([])
|
||||
const loading = ref(false)
|
||||
const selectDialogVisible = ref<boolean>(false) // 选择菜品对话框开关
|
||||
const { spu_status } = useDict("spu_status")
|
||||
const categoryOptions = ref<any>([]) // 商品分类选项
|
||||
const imageBaseUrl = import.meta.env.VITE_IMAGE_BASE_PATH
|
||||
const dataRules = ref({}) // 定义校验规则
|
||||
|
||||
// 提交表单数据
|
||||
const form = reactive<any>({
|
||||
id: '',
|
||||
startTime: '',
|
||||
spuId: '',
|
||||
hourType: '',
|
||||
merchantId: '',
|
||||
deptId: '',
|
||||
spuIds: '',
|
||||
});
|
||||
id: "",
|
||||
startTime: "",
|
||||
hourType: "",
|
||||
merchantId: "",
|
||||
})
|
||||
// 选择的菜品的id数组
|
||||
const spuIds = computed(() => {
|
||||
return selectedList.value?.map((item: any) => item.id)
|
||||
})
|
||||
|
||||
// 定义校验规则
|
||||
const dataRules = ref({});
|
||||
const state: BasicTableProps = reactive<BasicTableProps>({
|
||||
queryForm: {},
|
||||
pageList: fetchList,
|
||||
})
|
||||
|
||||
const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, tableStyle } = useTable(state)
|
||||
|
||||
// 多选选择菜品
|
||||
const selectionChangHandle = (objs: any) => {
|
||||
selectObjs.value = objs
|
||||
}
|
||||
|
||||
// 清空搜索条件
|
||||
const resetQuery = () => {
|
||||
// 清空搜索条件
|
||||
queryRef.value?.resetFields()
|
||||
// 清空多选
|
||||
selectObjs.value = []
|
||||
getDataList()
|
||||
}
|
||||
|
||||
// 打开弹窗
|
||||
const openDialog = (id: string, time?: string, hourType?: number, merchantId?: number) => {
|
||||
visible.value = true;
|
||||
form.id = '';
|
||||
visible.value = true
|
||||
form.id = ""
|
||||
|
||||
// 重置表单数据
|
||||
nextTick(() => {
|
||||
dataFormRef.value?.resetFields();
|
||||
});
|
||||
dataFormRef.value?.resetFields()
|
||||
selectObjs.value = []
|
||||
selectedList.value = []
|
||||
state.dataList = []
|
||||
|
||||
// 获取canteenDailyMenu信息
|
||||
if (id) {
|
||||
form.id = id;
|
||||
getcanteenDailyMenuData(id);
|
||||
form.id = id
|
||||
getcanteenDailyMenuData(id)
|
||||
}
|
||||
if (time) {
|
||||
form.startTime = time;
|
||||
form.startTime = time
|
||||
}
|
||||
if (hourType) {
|
||||
form.hourType = hourType;
|
||||
form.hourType = hourType
|
||||
}
|
||||
form.merchantId = merchantId;
|
||||
};
|
||||
watch(spuIds, (newValue, oldValue) => {
|
||||
spuImages.value = [];
|
||||
form.spuIds = newValue;
|
||||
//更新值
|
||||
if (newValue) {
|
||||
const newValues = newValue.toString().split(',');
|
||||
for (let index = 0; index < newValues.length; index++) {
|
||||
const data = newValues[index];
|
||||
foodData.value.forEach((sData: any) => {
|
||||
if (sData.id?.toString() === data) {
|
||||
spuImages.value.push(imageBaseUrl + sData.picUrl?.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
// 提交
|
||||
const onSubmit = async () => {
|
||||
if (spuIds.value.length <= 0) {
|
||||
useMessage().warning('请选择菜品');
|
||||
return;
|
||||
}
|
||||
const valid = await dataFormRef.value.validate().catch(() => {});
|
||||
if (!valid) return false;
|
||||
|
||||
try {
|
||||
loading.value = true;
|
||||
form.id ? await putObj(form) : await addObj(form);
|
||||
useMessage().success(form.id ? '修改成功' : '添加成功');
|
||||
visible.value = false;
|
||||
emit('refresh');
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
form.merchantId = merchantId
|
||||
}
|
||||
|
||||
// 初始化表单数据
|
||||
const getcanteenDailyMenuData = (id: string) => {
|
||||
// 获取数据
|
||||
loading.value = true;
|
||||
loading.value = true
|
||||
getObj(id)
|
||||
.then((res: any) => {
|
||||
Object.assign(form, res.data);
|
||||
Object.assign(form, res.data)
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
};
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
// 点击选择菜品
|
||||
const handleClickSelect = async () => {
|
||||
selectDialogVisible.value = true
|
||||
if (state.dataList && state.dataList?.length <= 0) {
|
||||
getDataList()
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await getCanteenCategory()
|
||||
categoryOptions.value = res.data.records
|
||||
} catch (error) {
|
||||
categoryOptions.value = []
|
||||
}
|
||||
}
|
||||
|
||||
// 选择菜品点击确认
|
||||
const handleSelectDialogConfirm = () => {
|
||||
selectDialogVisible.value = false
|
||||
selectedList.value = selectObjs.value
|
||||
}
|
||||
|
||||
// 提交
|
||||
const onSubmit = async () => {
|
||||
if (selectedList.value.length <= 0) {
|
||||
useMessage().warning("请选择菜品")
|
||||
return
|
||||
}
|
||||
|
||||
const valid = await dataFormRef.value.validate().catch(() => {})
|
||||
if (!valid) return false
|
||||
|
||||
try {
|
||||
loading.value = true
|
||||
form.id ? await putObj({ ...form, spuIds: spuIds.value }) : await addObj({ ...form, spuIds: spuIds.value })
|
||||
useMessage().success(form.id ? "修改成功" : "添加成功")
|
||||
visible.value = false
|
||||
emit("refresh")
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 暴露变量
|
||||
defineExpose({
|
||||
openDialog,
|
||||
});
|
||||
/** 初始化 **/
|
||||
onMounted(async () => {
|
||||
// 获取菜品列表
|
||||
let axiosResponse = await selectFoodList();
|
||||
foodData.value = axiosResponse.data;
|
||||
});
|
||||
})
|
||||
</script>
|
||||
@@ -26,171 +26,166 @@
|
||||
<tr>
|
||||
<td class="w-16 h-48 text-4xl text-center cursor-pointer text-blue-500" @click="addFood(1)">早餐</td>
|
||||
<td class="w-64 h-48 text-center" v-for="(item, index) in foodData1" :key="index">
|
||||
<img @click="delteData(item.tid)" :src="item.picUrl" class="p-3 w-full h-full object-cover" />
|
||||
<img
|
||||
@click="delteData(item.tid)"
|
||||
:src="imageBaseUrl + item.picUrl"
|
||||
class="p-3 w-full h-full object-contain"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="w-16 h-48 text-4xl text-center cursor-pointer text-blue-500" @click="addFood(2)">中餐</td>
|
||||
<td class="w-64 h-48 text-center" v-for="(item, index) in foodData2" :key="index">
|
||||
<img @click="delteData(item.tid)" :src="item.picUrl" class="p-3 w-full h-full object-cover" />
|
||||
<img
|
||||
@click="delteData(item.tid)"
|
||||
:src="imageBaseUrl + item.picUrl"
|
||||
class="p-3 w-full h-full object-contain"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="w-16 h-48 text-4xl text-center cursor-pointer text-blue-500" @click="addFood(3)">晚餐</td>
|
||||
<td class="w-64 h-48 text-center" v-for="(item, index) in foodData3" :key="index">
|
||||
<img @click="delteData(item.tid)" :src="item.picUrl" class="p-3 w-full h-full object-cover" />
|
||||
<img
|
||||
@click="delteData(item.tid)"
|
||||
:src="imageBaseUrl + item.picUrl"
|
||||
class="p-3 w-full h-full object-contain"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- 编辑、新增 -->
|
||||
<form-dialog ref="formDialogRef" @success="selectTimeFood" />
|
||||
<form-dialog ref="formDialogRef" @refresh="selectTimeFood" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="systemCanteenDailyMenu">
|
||||
import { delObjs, selectTimeFoodApi, selectWeekInfo } from '/@/api/canteen/canteenDailyMenu';
|
||||
import { useMessage, useMessageBox } from '/@/hooks/message';
|
||||
import { useDict } from '/@/hooks/dict';
|
||||
import { pageJoin } from '/@/api/wallet/mch-manage';
|
||||
import { delObjs, selectTimeFoodApi, selectWeekInfo } from "/@/api/canteen/canteenDailyMenu"
|
||||
import { useMessage, useMessageBox } from "/@/hooks/message"
|
||||
import { pageJoin } from "/@/api/wallet/mch-manage"
|
||||
|
||||
// 引入组件
|
||||
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
|
||||
const FormDialog = defineAsyncComponent(() => import("./form.vue"))
|
||||
const imageBaseUrl = import.meta.env.VITE_IMAGE_BASE_PATH
|
||||
|
||||
const { daily_menu } = useDict('daily_menu');
|
||||
// 定义变量内容
|
||||
const formDialogRef = ref();
|
||||
// 多选变量
|
||||
const loading = ref(true); // 列表的加载中
|
||||
const formDialogRef = ref()
|
||||
const loading = ref(true)
|
||||
|
||||
// ---------新增业务变量
|
||||
const message = useMessage(); // 消息弹窗
|
||||
const message = useMessage() // 消息弹窗
|
||||
|
||||
const foodData1 = ref<any>({});
|
||||
const foodData2 = ref<any>({});
|
||||
const foodData3 = ref<any>({});
|
||||
const foodData1 = ref<any>({})
|
||||
const foodData2 = ref<any>({})
|
||||
const foodData3 = ref<any>({})
|
||||
|
||||
let timedata = '';
|
||||
let isActive = ref(-1);
|
||||
let timedata = ""
|
||||
let isActive = ref(-1)
|
||||
const weekParams = reactive({
|
||||
index: 0,
|
||||
});
|
||||
})
|
||||
const weekData = reactive({
|
||||
data: [],
|
||||
}); //时间数组
|
||||
const merchantId = ref();
|
||||
const merchantInfo = ref<any>([]);
|
||||
}) //时间数组
|
||||
const merchantId = ref()
|
||||
const merchantInfo = ref<any>([])
|
||||
|
||||
const addFood = async (hourType: number) => {
|
||||
if (!merchantId.value) {
|
||||
useMessage().error('请选择商户再进行新增');
|
||||
return;
|
||||
useMessage().error("请选择商户再进行新增")
|
||||
return
|
||||
}
|
||||
//打开新增框
|
||||
formDialogRef.value.openDialog(null, timedata, hourType, merchantId.value);
|
||||
};
|
||||
formDialogRef.value.openDialog(null, timedata, hourType, merchantId.value)
|
||||
}
|
||||
//选中具体时间数据
|
||||
const timeClick = async (time: string, index: number) => {
|
||||
//数据查询操作
|
||||
if (time) {
|
||||
//时间处理
|
||||
time = time.substring(0, time.indexOf('('));
|
||||
timedata = time;
|
||||
time = time.substring(0, time.indexOf("("))
|
||||
timedata = time
|
||||
//选中
|
||||
isActive.value = index;
|
||||
selectTimeFood();
|
||||
isActive.value = index
|
||||
selectTimeFood()
|
||||
}
|
||||
};
|
||||
}
|
||||
//切换时间
|
||||
const addClick = async (index: number) => {
|
||||
//数据值操作
|
||||
weekParams.index = weekParams.index + index;
|
||||
fetchData();
|
||||
};
|
||||
weekParams.index = weekParams.index + index
|
||||
fetchData()
|
||||
}
|
||||
|
||||
watch(merchantId, () => {
|
||||
fetchData();
|
||||
});
|
||||
fetchData()
|
||||
})
|
||||
|
||||
const fetchData = async () => {
|
||||
const weekDataRes = await selectWeekInfo(weekParams);
|
||||
weekData.data = weekDataRes.data;
|
||||
isActive.value = 0;
|
||||
timedata = weekData.data[0];
|
||||
const weekDataRes = await selectWeekInfo(weekParams)
|
||||
weekData.data = weekDataRes.data
|
||||
isActive.value = 0
|
||||
timedata = weekData.data[0]
|
||||
// 时间格式
|
||||
timedata = timedata.substring(0, timedata.indexOf('('));
|
||||
selectTimeFood();
|
||||
};
|
||||
timedata = timedata.substring(0, timedata.indexOf("("))
|
||||
selectTimeFood()
|
||||
}
|
||||
|
||||
const selectTimeFood = async () => {
|
||||
foodData1.value = [];
|
||||
foodData2.value = [];
|
||||
foodData3.value = [];
|
||||
foodData1.value = []
|
||||
foodData2.value = []
|
||||
foodData3.value = []
|
||||
let params = {
|
||||
time: timedata,
|
||||
merchantId: merchantId.value,
|
||||
};
|
||||
}
|
||||
//最大长度
|
||||
let count = 0;
|
||||
const result = await selectTimeFoodApi(params);
|
||||
let count = 0
|
||||
const result = await selectTimeFoodApi(params)
|
||||
result.data.forEach((r: any) => {
|
||||
if (r.dailyMenuVOS.length > count) {
|
||||
count = r.dailyMenuVOS.length;
|
||||
count = r.dailyMenuVOS.length
|
||||
}
|
||||
switch (r.hourType) {
|
||||
case 1:
|
||||
foodData1.value = r.dailyMenuVOS;
|
||||
break;
|
||||
foodData1.value = r.dailyMenuVOS
|
||||
break
|
||||
case 2:
|
||||
foodData2.value = r.dailyMenuVOS;
|
||||
break;
|
||||
foodData2.value = r.dailyMenuVOS
|
||||
break
|
||||
case 3:
|
||||
foodData3.value = r.dailyMenuVOS;
|
||||
break;
|
||||
foodData3.value = r.dailyMenuVOS
|
||||
break
|
||||
}
|
||||
});
|
||||
};
|
||||
/** 删除数据源按钮 */
|
||||
})
|
||||
}
|
||||
|
||||
// 删除菜品
|
||||
const delteData = async (tid: number) => {
|
||||
await message.delConfirm('确定删除菜品吗?', '今日菜品?');
|
||||
await delObjs(tid);
|
||||
message.success('common.delSuccess');
|
||||
selectTimeFood();
|
||||
};
|
||||
|
||||
// 删除操作
|
||||
// const handleDelete = async (ids: string[]) => {
|
||||
// try {
|
||||
// await useMessageBox().confirm('此操作将永久删除');
|
||||
// } catch {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// try {
|
||||
// await delObjs(ids);
|
||||
// // getDataList();
|
||||
// useMessage().success('删除成功');
|
||||
// } catch (err: any) {
|
||||
// useMessage().error(err.msg);
|
||||
// }
|
||||
// };
|
||||
await message.delConfirm("确定删除菜品吗?", "今日菜品?")
|
||||
try {
|
||||
await delObjs([tid])
|
||||
message.success("删除成功")
|
||||
} catch (error) {
|
||||
message.error("删除失败")
|
||||
}
|
||||
selectTimeFood()
|
||||
}
|
||||
|
||||
/** 初始化下拉框 */
|
||||
const merchantInit = async () => {
|
||||
// 获取下拉框选项
|
||||
const res = await pageJoin({ current: 1, size: 9999 });
|
||||
merchantInfo.value = res.data.records;
|
||||
const res = await pageJoin({ current: 1, size: 9999 })
|
||||
merchantInfo.value = res.data.records
|
||||
|
||||
//默认选中第一个
|
||||
if (merchantInfo.value) {
|
||||
merchantId.value = merchantInfo.value[0].id;
|
||||
fetchData();
|
||||
merchantId.value = merchantInfo.value[0].id
|
||||
fetchData()
|
||||
}
|
||||
};
|
||||
}
|
||||
onMounted(() => {
|
||||
merchantInit();
|
||||
});
|
||||
merchantInit()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
@@ -17,10 +17,23 @@
|
||||
</el-row>
|
||||
<el-row>
|
||||
<div class="mb8" style="width: 100%">
|
||||
<el-button icon="folder-add" type="primary" class="ml10" @click="formDialogRef.openDialog()" v-auth="'canteen_canteenSpu_add'">
|
||||
<el-button
|
||||
icon="folder-add"
|
||||
type="primary"
|
||||
class="ml10"
|
||||
@click="formDialogRef.openDialog()"
|
||||
v-auth="'canteen_canteenSpu_add'"
|
||||
>
|
||||
新 增
|
||||
</el-button>
|
||||
<el-button plain :disabled="multiple" icon="Delete" type="primary" v-auth="'canteen_canteenSpu_del'" @click="handleDelete(selectObjs)">
|
||||
<el-button
|
||||
plain
|
||||
:disabled="multiple"
|
||||
icon="Delete"
|
||||
type="primary"
|
||||
v-auth="'canteen_canteenSpu_del'"
|
||||
@click="handleDelete(selectObjs)"
|
||||
>
|
||||
删 除
|
||||
</el-button>
|
||||
<right-toolbar
|
||||
@@ -80,10 +93,23 @@
|
||||
<el-table-column prop="createTime" label="创建时间" show-overflow-tooltip min-width="160" />
|
||||
<el-table-column label="操作" width="150" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button icon="edit-pen" text type="primary" v-auth="'canteen_canteenSpu_edit'" @click="formDialogRef?.openDialog(scope.row.id)">
|
||||
<el-button
|
||||
icon="edit-pen"
|
||||
text
|
||||
type="primary"
|
||||
v-auth="'canteen_canteenSpu_edit'"
|
||||
@click="formDialogRef?.openDialog(scope.row.id)"
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button icon="delete" text type="primary" v-auth="'canteen_canteenSpu_del'" @click="handleDelete([scope.row.id])">删除</el-button>
|
||||
<el-button
|
||||
icon="delete"
|
||||
text
|
||||
type="primary"
|
||||
v-auth="'canteen_canteenSpu_del'"
|
||||
@click="handleDelete([scope.row.id])"
|
||||
>删除</el-button
|
||||
>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -96,78 +122,79 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="systemCanteenSpu">
|
||||
import { BasicTableProps, useTable } from '/@/hooks/table';
|
||||
import { fetchList, delObjs } from '/@/api/canteen/canteenSpu';
|
||||
import { useMessage, useMessageBox } from '/@/hooks/message';
|
||||
import { useDict } from '/@/hooks/dict';
|
||||
import { displayPrice } from '/@/utils/formatMoney';
|
||||
import { fetchList as getCanteenCategory } from '/@/api/canteen/canteenCategory';
|
||||
import { BasicTableProps, useTable } from "/@/hooks/table"
|
||||
import { fetchList, delObjs } from "/@/api/canteen/canteenSpu"
|
||||
import { useMessage, useMessageBox } from "/@/hooks/message"
|
||||
import { useDict } from "/@/hooks/dict"
|
||||
import { displayPrice } from "/@/utils/formatMoney"
|
||||
import { fetchList as getCanteenCategory } from "/@/api/canteen/canteenCategory"
|
||||
|
||||
// 引入组件
|
||||
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
|
||||
const FormDialog = defineAsyncComponent(() => import("./form.vue"))
|
||||
|
||||
const { spu_status } = useDict('spu_status');
|
||||
const { spu_status } = useDict("spu_status")
|
||||
// 定义变量内容
|
||||
const formDialogRef = ref();
|
||||
const formDialogRef = ref()
|
||||
// 搜索变量
|
||||
const queryRef = ref();
|
||||
const showSearch = ref(true);
|
||||
const queryRef = ref()
|
||||
const showSearch = ref(true)
|
||||
// 多选变量
|
||||
const selectObjs = ref([]) as any;
|
||||
const multiple = ref(true);
|
||||
const categoryOptions = ref<any>([]); // 商品分类选项
|
||||
const selectObjs = ref([]) as any
|
||||
const multiple = ref(true)
|
||||
const categoryOptions = ref<any>([]) // 商品分类选项
|
||||
|
||||
const state: BasicTableProps = reactive<BasicTableProps>({
|
||||
queryForm: {},
|
||||
pageList: fetchList,
|
||||
});
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const res = await getCanteenCategory();
|
||||
categoryOptions.value = res.data.records;
|
||||
const res = await getCanteenCategory()
|
||||
categoryOptions.value = res.data.records
|
||||
} catch (error) {
|
||||
categoryOptions.value = [];
|
||||
categoryOptions.value = []
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
// table hook
|
||||
const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, downBlobFile, tableStyle } = useTable(state);
|
||||
const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, downBlobFile, tableStyle } =
|
||||
useTable(state)
|
||||
|
||||
// 清空搜索条件
|
||||
const resetQuery = () => {
|
||||
// 清空搜索条件
|
||||
queryRef.value?.resetFields();
|
||||
queryRef.value?.resetFields()
|
||||
// 清空多选
|
||||
selectObjs.value = [];
|
||||
getDataList();
|
||||
};
|
||||
selectObjs.value = []
|
||||
getDataList()
|
||||
}
|
||||
|
||||
// 导出excel
|
||||
const exportExcel = () => {
|
||||
downBlobFile('/canteen/canteenSpu/export', Object.assign(state.queryForm, { ids: selectObjs }), 'canteenSpu.xlsx');
|
||||
};
|
||||
downBlobFile("/canteen/canteenSpu/export", Object.assign(state.queryForm, { ids: selectObjs }), "canteenSpu.xlsx")
|
||||
}
|
||||
|
||||
// 多选事件
|
||||
const selectionChangHandle = (objs: { id: string }[]) => {
|
||||
selectObjs.value = objs.map(({ id }) => id);
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
selectObjs.value = objs.map(({ id }) => id)
|
||||
multiple.value = !objs.length
|
||||
}
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm('此操作将永久删除');
|
||||
await useMessageBox().confirm("此操作将永久删除")
|
||||
} catch {
|
||||
return;
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await delObjs(ids);
|
||||
getDataList();
|
||||
useMessage().success('删除成功');
|
||||
await delObjs(ids)
|
||||
getDataList()
|
||||
useMessage().success("删除成功")
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
useMessage().error(err.msg)
|
||||
}
|
||||
};
|
||||
}
|
||||
</script>
|
||||
Reference in new issue
Block a user