From 002f8ad6b1fc39b21c0e91a1fcb6352c3a74b2fe Mon Sep 17 00:00:00 2001 From: ctw <> Date: Sun, 12 Jan 2025 15:42:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=AF=8F=E6=97=A5=E8=8F=9C?= =?UTF-8?q?=E8=B0=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 8 +- src/api/canteen/canteenDailyMenu.ts | 81 +++--- src/hooks/table.ts | 138 ++++----- src/views/canteen/canteenDailyMenu/form.vue | 282 +++++++++++++------ src/views/canteen/canteenDailyMenu/index.vue | 179 ++++++------ src/views/canteen/canteenSpu/index.vue | 107 ++++--- 6 files changed, 459 insertions(+), 336 deletions(-) diff --git a/.env.development b/.env.development index 02523a1..e1223e0 100644 --- a/.env.development +++ b/.env.development @@ -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 diff --git a/src/api/canteen/canteenDailyMenu.ts b/src/api/canteen/canteenDailyMenu.ts index 8a2d58d..b703539 100644 --- a/src/api/canteen/canteenDailyMenu.ts +++ b/src/api/canteen/canteenDailyMenu.ts @@ -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, + }) } - diff --git a/src/hooks/table.ts b/src/hooks/table.ts index 3a80609..1a6b296 100644 --- a/src/hooks/table.ts +++ b/src/hooks/table.ts @@ -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; + pageList?: (...arg: any) => Promise // 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; - headerCellStyle: CellStyle; + cellStyle: CellStyle + headerCellStyle: CellStyle } /** @@ -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, - }; + } } diff --git a/src/views/canteen/canteenDailyMenu/form.vue b/src/views/canteen/canteenDailyMenu/form.vue index c980747..06d7f51 100644 --- a/src/views/canteen/canteenDailyMenu/form.vue +++ b/src/views/canteen/canteenDailyMenu/form.vue @@ -12,10 +12,14 @@

未知类型

- + + + + 选择菜品 - +