From 5c203d7f302d011f39e496803ae0a812e160da06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com> Date: Tue, 12 Aug 2025 12:42:58 +0800 Subject: [PATCH] =?UTF-8?q?refactor(shop):=20=E7=A7=BB=E9=99=A4=E5=93=81?= =?UTF-8?q?=E7=89=8C=E7=AE=A1=E7=90=86=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 删除了 shopBrand2 相关的 API、组件和页面 - 优化了 shopCoupon 和 shopExpress 页面的日期格式显示 - 更新了 shopCoupon 编辑组件,增加了日期选择器并优化了数据格式 --- src/api/shop/shopBrand2/index.ts | 105 -------- src/api/shop/shopBrand2/model/index.ts | 31 --- src/api/shop/shopCoupon/model/index.ts | 8 +- .../shop/shopBrand2/components/search.vue | 42 --- .../shopBrand2/components/shopBrand2Edit.vue | 208 --------------- src/views/shop/shopBrand2/index.vue | 244 ------------------ .../shopCoupon/components/shopCouponEdit.vue | 50 +++- src/views/shop/shopCoupon/index.vue | 7 + src/views/shop/shopExpress/index.vue | 2 +- 9 files changed, 56 insertions(+), 641 deletions(-) delete mode 100644 src/api/shop/shopBrand2/index.ts delete mode 100644 src/api/shop/shopBrand2/model/index.ts delete mode 100644 src/views/shop/shopBrand2/components/search.vue delete mode 100644 src/views/shop/shopBrand2/components/shopBrand2Edit.vue delete mode 100644 src/views/shop/shopBrand2/index.vue diff --git a/src/api/shop/shopBrand2/index.ts b/src/api/shop/shopBrand2/index.ts deleted file mode 100644 index 5d23b03..0000000 --- a/src/api/shop/shopBrand2/index.ts +++ /dev/null @@ -1,105 +0,0 @@ -import request from '@/utils/request'; -import type { ApiResult, PageResult } from '@/api'; -import type { ShopBrand2, ShopBrand2Param } from './model'; - -/** - * 分页查询品牌 - */ -export async function pageShopBrand2(params: ShopBrand2Param) { - const res = await request.get>>( - '/shop/shop-brand2/page', - { - params - } - ); - if (res.data.code === 0) { - return res.data.data; - } - return Promise.reject(new Error(res.data.message)); -} - -/** - * 查询品牌列表 - */ -export async function listShopBrand2(params?: ShopBrand2Param) { - const res = await request.get>( - '/shop/shop-brand2', - { - params - } - ); - if (res.data.code === 0 && res.data.data) { - return res.data.data; - } - return Promise.reject(new Error(res.data.message)); -} - -/** - * 添加品牌 - */ -export async function addShopBrand2(data: ShopBrand2) { - const res = await request.post>( - '/shop/shop-brand2', - data - ); - if (res.data.code === 0) { - return res.data.message; - } - return Promise.reject(new Error(res.data.message)); -} - -/** - * 修改品牌 - */ -export async function updateShopBrand2(data: ShopBrand2) { - const res = await request.put>( - '/shop/shop-brand2', - data - ); - if (res.data.code === 0) { - return res.data.message; - } - return Promise.reject(new Error(res.data.message)); -} - -/** - * 删除品牌 - */ -export async function removeShopBrand2(id?: number) { - const res = await request.delete>( - '/shop/shop-brand2/' + id - ); - if (res.data.code === 0) { - return res.data.message; - } - return Promise.reject(new Error(res.data.message)); -} - -/** - * 批量删除品牌 - */ -export async function removeBatchShopBrand2(data: (number | undefined)[]) { - const res = await request.delete>( - '/shop/shop-brand2/batch', - { - data - } - ); - if (res.data.code === 0) { - return res.data.message; - } - return Promise.reject(new Error(res.data.message)); -} - -/** - * 根据id查询品牌 - */ -export async function getShopBrand2(id: number) { - const res = await request.get>( - '/shop/shop-brand2/' + id - ); - if (res.data.code === 0 && res.data.data) { - return res.data.data; - } - return Promise.reject(new Error(res.data.message)); -} diff --git a/src/api/shop/shopBrand2/model/index.ts b/src/api/shop/shopBrand2/model/index.ts deleted file mode 100644 index b6a1471..0000000 --- a/src/api/shop/shopBrand2/model/index.ts +++ /dev/null @@ -1,31 +0,0 @@ -import type { PageParam } from '@/api'; - -/** - * 品牌 - */ -export interface ShopBrand2 { - // ID - brandId?: number; - // 品牌名称 - brandName?: string; - // 图标 - image?: string; - // 备注 - comments?: string; - // 状态 - status?: number; - // 排序号 - sortNumber?: number; - // 租户id - tenantId?: number; - // 创建时间 - createTime?: string; -} - -/** - * 品牌搜索条件 - */ -export interface ShopBrand2Param extends PageParam { - brandId?: number; - keywords?: string; -} diff --git a/src/api/shop/shopCoupon/model/index.ts b/src/api/shop/shopCoupon/model/index.ts index 1b8079c..e3e3867 100644 --- a/src/api/shop/shopCoupon/model/index.ts +++ b/src/api/shop/shopCoupon/model/index.ts @@ -25,9 +25,9 @@ export interface ShopCoupon { // 领取后生效-有效天数 expireDay?: number; // 有效期开始时间 - startTime?: string; + startTime?: string | Date; // 有效期结束时间 - endTime?: string; + endTime?: string | Date; // 适用范围(10全部商品 20指定商品 30指定分类) applyRange?: number; // 适用范围配置(json格式) @@ -45,9 +45,9 @@ export interface ShopCoupon { // 租户id tenantId?: number; // 创建时间 - createTime?: string; + createTime?: string | Date; // 修改时间 - updateTime?: string; + updateTime?: string | Date; // 发放总数量(-1表示无限制) totalCount?: number; // 已发放数量 diff --git a/src/views/shop/shopBrand2/components/search.vue b/src/views/shop/shopBrand2/components/search.vue deleted file mode 100644 index 82fea9d..0000000 --- a/src/views/shop/shopBrand2/components/search.vue +++ /dev/null @@ -1,42 +0,0 @@ - - - - diff --git a/src/views/shop/shopBrand2/components/shopBrand2Edit.vue b/src/views/shop/shopBrand2/components/shopBrand2Edit.vue deleted file mode 100644 index b96b331..0000000 --- a/src/views/shop/shopBrand2/components/shopBrand2Edit.vue +++ /dev/null @@ -1,208 +0,0 @@ - - - - diff --git a/src/views/shop/shopBrand2/index.vue b/src/views/shop/shopBrand2/index.vue deleted file mode 100644 index d6217ea..0000000 --- a/src/views/shop/shopBrand2/index.vue +++ /dev/null @@ -1,244 +0,0 @@ - - - - - - - diff --git a/src/views/shop/shopCoupon/components/shopCouponEdit.vue b/src/views/shop/shopCoupon/components/shopCouponEdit.vue index 740d0a8..c8d5536 100644 --- a/src/views/shop/shopCoupon/components/shopCouponEdit.vue +++ b/src/views/shop/shopCoupon/components/shopCouponEdit.vue @@ -86,17 +86,21 @@ @@ -288,6 +292,29 @@ const formData = { ...form }; + + // 处理日期格式转换 + if (formData.startTime && typeof formData.startTime === 'object') { + formData.startTime = formData.startTime.format ? formData.startTime.format('YYYY-MM-DD') : formData.startTime; + } + if (formData.endTime && typeof formData.endTime === 'object') { + formData.endTime = formData.endTime.format ? formData.endTime.format('YYYY-MM-DD') : formData.endTime; + } + + // 确保数值类型正确 + if (formData.type) formData.type = Number(formData.type); + if (formData.expireType) formData.expireType = Number(formData.expireType); + if (formData.applyRange) formData.applyRange = Number(formData.applyRange); + if (formData.status !== undefined) formData.status = Number(formData.status); + if (formData.enabled !== undefined) formData.enabled = Number(formData.enabled); + if (formData.expireDay !== undefined) formData.expireDay = Number(formData.expireDay); + if (formData.reducePrice !== undefined) formData.reducePrice = Number(formData.reducePrice); + if (formData.discount !== undefined) formData.discount = Number(formData.discount); + if (formData.minPrice !== undefined) formData.minPrice = Number(formData.minPrice); + if (formData.sortNumber !== undefined) formData.sortNumber = Number(formData.sortNumber); + if (formData.totalCount !== undefined) formData.totalCount = Number(formData.totalCount); + if (formData.limitPerUser !== undefined) formData.limitPerUser = Number(formData.limitPerUser); + if (applyItemListValue.value.length) { formData.couponApplyItemList = applyItemListValue.value.map(pk => { return { @@ -304,6 +331,8 @@ } }); }else formData.couponApplyCateList = [] + + console.log('提交的数据:', formData); const saveOrUpdate = isUpdate.value ? updateShopCoupon : addShopCoupon; saveOrUpdate(formData) .then((msg) => { @@ -341,6 +370,15 @@ await getGoodsCateList() if (props.data) { assignObject(form, props.data); + + // 处理日期字段转换为Date对象 + if (props.data.startTime && typeof props.data.startTime === 'string') { + form.startTime = new Date(props.data.startTime); + } + if (props.data.endTime && typeof props.data.endTime === 'string') { + form.endTime = new Date(props.data.endTime); + } + if (props.data.image) { images.value.push({ uid: uuid(), diff --git a/src/views/shop/shopCoupon/index.vue b/src/views/shop/shopCoupon/index.vue index 9dadc29..ab65b6c 100644 --- a/src/views/shop/shopCoupon/index.vue +++ b/src/views/shop/shopCoupon/index.vue @@ -178,12 +178,16 @@ dataIndex: 'startTime', key: 'startTime', align: 'center', + width: 120, + customRender: ({ text }) => text ? toDateString(text, 'yyyy-MM-dd') : '-' }, { title: '有效期结束时间', dataIndex: 'endTime', key: 'endTime', align: 'center', + width: 120, + customRender: ({ text }) => text ? toDateString(text, 'yyyy-MM-dd') : '-' }, { title: '适用范围', @@ -229,6 +233,9 @@ dataIndex: 'updateTime', key: 'updateTime', align: 'center', + width: 120, + ellipsis: true, + customRender: ({ text }) => text ? toDateString(text, 'yyyy-MM-dd HH:mm') : '-' }, { title: '发放总数量(-1表示无限制)', diff --git a/src/views/shop/shopExpress/index.vue b/src/views/shop/shopExpress/index.vue index c3d0da2..3185d87 100644 --- a/src/views/shop/shopExpress/index.vue +++ b/src/views/shop/shopExpress/index.vue @@ -149,7 +149,7 @@ align: 'center', sorter: true, ellipsis: true, - customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd') + customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd HH:mm:ss') }, { title: '修改时间',