From c5a7d05821d4eae7197cbd0dba66f544ee214ecc Mon Sep 17 00:00:00 2001 From: dhb52 Date: Thu, 1 Jun 2023 18:08:23 +0800 Subject: [PATCH] =?UTF-8?q?style:=20=E6=B7=BB=E5=8A=A0VO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/mall/product/spu.ts | 5 +++ src/api/mall/promotion/coupon.ts | 6 +-- src/api/mall/promotion/couponTemplate.ts | 41 +++++++++++++++---- src/utils/constants.ts | 18 ++++++++ .../mall/promotion/couponTemplate/index.vue | 12 +++--- 5 files changed, 64 insertions(+), 18 deletions(-) diff --git a/src/api/mall/product/spu.ts b/src/api/mall/product/spu.ts index fd55e126..9fd87395 100644 --- a/src/api/mall/product/spu.ts +++ b/src/api/mall/product/spu.ts @@ -90,3 +90,8 @@ export const deleteSpu = (id: number) => { export const exportSpu = async (params) => { return await request.download({ url: '/product/spu/export', params }) } + +// 获得商品 SPU 精简列表 +export const getSpuSimpleList = async () => { + return request.get({ url: '/product/spu/get-simple-list' }) +} diff --git a/src/api/mall/promotion/coupon.ts b/src/api/mall/promotion/coupon.ts index 99e8a027..ab50c3cc 100755 --- a/src/api/mall/promotion/coupon.ts +++ b/src/api/mall/promotion/coupon.ts @@ -1,16 +1,16 @@ import request from '@/config/axios' // 删除优惠劵 -export function deleteCoupon(id) { +export const deleteCoupon = async (id: number) => { return request.delete({ url: `/promotion/coupon/delete?id=${id}` }) } // 获得优惠劵分页 -export function getCouponPage(query) { +export const getCouponPage = async (params: PageParam) => { return request.get({ url: '/promotion/coupon/page', - params: query + params: params }) } diff --git a/src/api/mall/promotion/couponTemplate.ts b/src/api/mall/promotion/couponTemplate.ts index a861b127..6a58876e 100755 --- a/src/api/mall/promotion/couponTemplate.ts +++ b/src/api/mall/promotion/couponTemplate.ts @@ -1,7 +1,30 @@ import request from '@/config/axios' +export interface CouponTemplateVO { + id: number + name: string + status: number + totalCount: number + takeLimitCount: number + takeType: number + usePrice: number + productScope: number + productSpuIds: string + validityType: number + validStartTime: Date + validEndTime: Date + fixedStartTerm: number + fixedEndTerm: number + discountType: number + discountPercent: number + discountPrice: number + discountLimitPrice: number + takeCount: number + useCount: number +} + // 创建优惠劵模板 -export function createCouponTemplate(data) { +export function createCouponTemplate(data: CouponTemplateVO) { return request.post({ url: '/promotion/coupon-template/create', data: data @@ -9,7 +32,7 @@ export function createCouponTemplate(data) { } // 更新优惠劵模板 -export function updateCouponTemplate(data) { +export function updateCouponTemplate(data: CouponTemplateVO) { return request.put({ url: '/promotion/coupon-template/update', data: data @@ -17,7 +40,7 @@ export function updateCouponTemplate(data) { } // 更新优惠劵模板的状态 -export function updateCouponTemplateStatus(id, status) { +export function updateCouponTemplateStatus(id: number, status: [0, 1]) { const data = { id, status @@ -29,32 +52,32 @@ export function updateCouponTemplateStatus(id, status) { } // 删除优惠劵模板 -export function deleteCouponTemplate(id) { +export function deleteCouponTemplate(id: number) { return request.delete({ url: '/promotion/coupon-template/delete?id=' + id }) } // 获得优惠劵模板 -export function getCouponTemplate(id) { +export function getCouponTemplate(id: number) { return request.get({ url: '/promotion/coupon-template/get?id=' + id }) } // 获得优惠劵模板分页 -export function getCouponTemplatePage(query) { +export function getCouponTemplatePage(params: PageParam) { return request.get({ url: '/promotion/coupon-template/page', - params: query + params: params }) } // 导出优惠劵模板 Excel -export function exportCouponTemplateExcel(query) { +export function exportCouponTemplateExcel(params: PageParam) { return request.get({ url: '/promotion/coupon-template/export-excel', - params: query, + params: params, responseType: 'blob' }) } diff --git a/src/utils/constants.ts b/src/utils/constants.ts index a9d41b90..58b4a931 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -221,6 +221,24 @@ export const PayRefundStatusEnum = { } } +/** + * 商品 SPU 状态 + */ +export const ProductSpuStatusEnum = { + RECYCLE: { + status: -1, + name: '回收站' + }, + DISABLE: { + status: 0, + name: '下架' + }, + ENABLE: { + status: 1, + name: '上架' + } +} + /** * 优惠劵模板的有限期类型的枚举 */ diff --git a/src/views/mall/promotion/couponTemplate/index.vue b/src/views/mall/promotion/couponTemplate/index.vue index a1424413..b63e93e1 100755 --- a/src/views/mall/promotion/couponTemplate/index.vue +++ b/src/views/mall/promotion/couponTemplate/index.vue @@ -491,7 +491,7 @@ const handleAdd = () => { } /** 修改按钮操作 */ -const handleUpdate = async (row) => { +const handleUpdate = async (row: any) => { reset() const id = row.id try { @@ -558,7 +558,7 @@ const submitForm = async () => { } /** 优惠劵模板状态修改 */ -const handleStatusChange = async (row) => { +const handleStatusChange = async (row: any) => { // 此时,row 已经变成目标状态了,所以可以直接提交请求和提示 let text = row.status === CommonStatusEnum.ENABLE ? '启用' : '停用' @@ -574,7 +574,7 @@ const handleStatusChange = async (row) => { } /** 删除按钮操作 */ -const handleDelete = async (row) => { +const handleDelete = async (row: any) => { const id = row.id try { await message.confirm('是否确认删除优惠劵编号为"' + id + '"的数据项?') @@ -583,7 +583,7 @@ const handleDelete = async (row) => { } // 格式化【优惠金额/折扣】 -const discountFormat = (row) => { +const discountFormat = (row: any) => { if (row.discountType === PromotionDiscountTypeEnum.PRICE.type) { return `¥${(row.discountPrice / 100.0).toFixed(2)}` } @@ -594,7 +594,7 @@ const discountFormat = (row) => { } // 格式化【领取上限】 -const takeLimitCountFormat = (row) => { +const takeLimitCountFormat = (row: any) => { if (row.takeLimitCount === -1) { return '无领取限制' } @@ -602,7 +602,7 @@ const takeLimitCountFormat = (row) => { } // 格式化【有效期限】 -const validityTypeFormat = (row) => { +const validityTypeFormat = (row: any) => { if (row.validityType === CouponTemplateValidityTypeEnum.DATE.type) { return `${formatDate(row.validStartTime)} 至 ${formatDate(row.validEndTime)}` }