refactor(shop): 重构商铺相关 API
- 移除 ApiResult 和 PageResult 的冗余导入 - 更新请求路径,移除 MODULES_API_URL 的使用 - 调整请求头,移除不必要的 Content-Type 设置 -统一处理 enabled 字段类型
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
VITE_APP_NAME=后台管理(开发环境)
|
||||
VITE_API_URL=http://127.0.0.1:9200/api
|
||||
#VITE_API_URL=http://127.0.0.1:9200/api
|
||||
#VITE_SERVER_API_URL=http://127.0.0.1:8000/api
|
||||
|
||||
|
||||
#VITE_API_URL=https://cms-api.s209.websoft.top/api
|
||||
VITE_API_URL=https://cms-api.websoft.top/api
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import request from '@/utils/request';
|
||||
import type { ApiResult, PageResult } from '@/api/index';
|
||||
import type { ApiResult, PageResult } from '@/api';
|
||||
import type { ShopCoupon, ShopCouponParam } from './model';
|
||||
import { MODULES_API_URL } from '@/config/setting';
|
||||
|
||||
/**
|
||||
* 分页查询优惠券
|
||||
*/
|
||||
export async function pageShopCoupon(params: ShopCouponParam) {
|
||||
const res = await request.get<ApiResult<PageResult<ShopCoupon>>>(
|
||||
MODULES_API_URL + '/shop/shop-coupon/page',
|
||||
'/shop/shop-coupon/page',
|
||||
{
|
||||
params
|
||||
}
|
||||
@@ -24,7 +23,7 @@ export async function pageShopCoupon(params: ShopCouponParam) {
|
||||
*/
|
||||
export async function listShopCoupon(params?: ShopCouponParam) {
|
||||
const res = await request.get<ApiResult<ShopCoupon[]>>(
|
||||
MODULES_API_URL + '/shop/shop-coupon',
|
||||
'/shop/shop-coupon',
|
||||
{
|
||||
params
|
||||
}
|
||||
@@ -40,13 +39,8 @@ export async function listShopCoupon(params?: ShopCouponParam) {
|
||||
*/
|
||||
export async function addShopCoupon(data: ShopCoupon) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-coupon',
|
||||
data,
|
||||
{
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}
|
||||
'/shop/shop-coupon',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
@@ -59,13 +53,8 @@ export async function addShopCoupon(data: ShopCoupon) {
|
||||
*/
|
||||
export async function updateShopCoupon(data: ShopCoupon) {
|
||||
const res = await request.put<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-coupon',
|
||||
data,
|
||||
{
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}
|
||||
'/shop/shop-coupon',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
@@ -78,7 +67,7 @@ export async function updateShopCoupon(data: ShopCoupon) {
|
||||
*/
|
||||
export async function removeShopCoupon(id?: number) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-coupon/' + id
|
||||
'/shop/shop-coupon/' + id
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
@@ -91,7 +80,7 @@ export async function removeShopCoupon(id?: number) {
|
||||
*/
|
||||
export async function removeBatchShopCoupon(data: (number | undefined)[]) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-coupon/batch',
|
||||
'/shop/shop-coupon/batch',
|
||||
{
|
||||
data
|
||||
}
|
||||
@@ -107,7 +96,7 @@ export async function removeBatchShopCoupon(data: (number | undefined)[]) {
|
||||
*/
|
||||
export async function getShopCoupon(id: number) {
|
||||
const res = await request.get<ApiResult<ShopCoupon>>(
|
||||
MODULES_API_URL + '/shop/shop-coupon/' + id
|
||||
'/shop/shop-coupon/' + id
|
||||
);
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { PageParam } from '@/api/index';
|
||||
import type { PageParam } from '@/api';
|
||||
|
||||
/**
|
||||
* 优惠券
|
||||
@@ -53,7 +53,7 @@ export interface ShopCoupon {
|
||||
// 每人限领数量(-1表示无限制)
|
||||
limitPerUser?: number;
|
||||
// 是否启用(0禁用 1启用)
|
||||
enabled?: boolean;
|
||||
enabled?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import request from '@/utils/request';
|
||||
import type { ApiResult, PageResult } from '@/api/index';
|
||||
import type { ApiResult, PageResult } from '@/api';
|
||||
import type { ShopDealerApply, ShopDealerApplyParam } from './model';
|
||||
import { MODULES_API_URL } from '@/config/setting';
|
||||
|
||||
/**
|
||||
* 分页查询分销商申请记录表
|
||||
*/
|
||||
export async function pageShopDealerApply(params: ShopDealerApplyParam) {
|
||||
const res = await request.get<ApiResult<PageResult<ShopDealerApply>>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-apply/page',
|
||||
'/shop/shop-dealer-apply/page',
|
||||
{
|
||||
params
|
||||
}
|
||||
@@ -24,7 +23,7 @@ export async function pageShopDealerApply(params: ShopDealerApplyParam) {
|
||||
*/
|
||||
export async function listShopDealerApply(params?: ShopDealerApplyParam) {
|
||||
const res = await request.get<ApiResult<ShopDealerApply[]>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-apply',
|
||||
'/shop/shop-dealer-apply',
|
||||
{
|
||||
params
|
||||
}
|
||||
@@ -40,7 +39,7 @@ export async function listShopDealerApply(params?: ShopDealerApplyParam) {
|
||||
*/
|
||||
export async function addShopDealerApply(data: ShopDealerApply) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-apply',
|
||||
'/shop/shop-dealer-apply',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
@@ -54,7 +53,7 @@ export async function addShopDealerApply(data: ShopDealerApply) {
|
||||
*/
|
||||
export async function updateShopDealerApply(data: ShopDealerApply) {
|
||||
const res = await request.put<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-apply',
|
||||
'/shop/shop-dealer-apply',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
@@ -68,7 +67,7 @@ export async function updateShopDealerApply(data: ShopDealerApply) {
|
||||
*/
|
||||
export async function removeShopDealerApply(id?: number) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-apply/' + id
|
||||
'/shop/shop-dealer-apply/' + id
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
@@ -81,7 +80,7 @@ export async function removeShopDealerApply(id?: number) {
|
||||
*/
|
||||
export async function removeBatchShopDealerApply(data: (number | undefined)[]) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-apply/batch',
|
||||
'/shop/shop-dealer-apply/batch',
|
||||
{
|
||||
data
|
||||
}
|
||||
@@ -97,7 +96,7 @@ export async function removeBatchShopDealerApply(data: (number | undefined)[]) {
|
||||
*/
|
||||
export async function getShopDealerApply(id: number) {
|
||||
const res = await request.get<ApiResult<ShopDealerApply>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-apply/' + id
|
||||
'/shop/shop-dealer-apply/' + id
|
||||
);
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { PageParam } from '@/api/index';
|
||||
import type { PageParam } from '@/api';
|
||||
|
||||
/**
|
||||
* 分销商申请记录表
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import request from '@/utils/request';
|
||||
import type { ApiResult, PageResult } from '@/api/index';
|
||||
import type { ApiResult, PageResult } from '@/api';
|
||||
import type { ShopDealerCapital, ShopDealerCapitalParam } from './model';
|
||||
import { MODULES_API_URL } from '@/config/setting';
|
||||
|
||||
/**
|
||||
* 分页查询分销商资金明细表
|
||||
*/
|
||||
export async function pageShopDealerCapital(params: ShopDealerCapitalParam) {
|
||||
const res = await request.get<ApiResult<PageResult<ShopDealerCapital>>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-capital/page',
|
||||
'/shop/shop-dealer-capital/page',
|
||||
{
|
||||
params
|
||||
}
|
||||
@@ -24,7 +23,7 @@ export async function pageShopDealerCapital(params: ShopDealerCapitalParam) {
|
||||
*/
|
||||
export async function listShopDealerCapital(params?: ShopDealerCapitalParam) {
|
||||
const res = await request.get<ApiResult<ShopDealerCapital[]>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-capital',
|
||||
'/shop/shop-dealer-capital',
|
||||
{
|
||||
params
|
||||
}
|
||||
@@ -40,7 +39,7 @@ export async function listShopDealerCapital(params?: ShopDealerCapitalParam) {
|
||||
*/
|
||||
export async function addShopDealerCapital(data: ShopDealerCapital) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-capital',
|
||||
'/shop/shop-dealer-capital',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
@@ -54,7 +53,7 @@ export async function addShopDealerCapital(data: ShopDealerCapital) {
|
||||
*/
|
||||
export async function updateShopDealerCapital(data: ShopDealerCapital) {
|
||||
const res = await request.put<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-capital',
|
||||
'/shop/shop-dealer-capital',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
@@ -68,7 +67,7 @@ export async function updateShopDealerCapital(data: ShopDealerCapital) {
|
||||
*/
|
||||
export async function removeShopDealerCapital(id?: number) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-capital/' + id
|
||||
'/shop/shop-dealer-capital/' + id
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
@@ -81,7 +80,7 @@ export async function removeShopDealerCapital(id?: number) {
|
||||
*/
|
||||
export async function removeBatchShopDealerCapital(data: (number | undefined)[]) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-capital/batch',
|
||||
'/shop/shop-dealer-capital/batch',
|
||||
{
|
||||
data
|
||||
}
|
||||
@@ -97,7 +96,7 @@ export async function removeBatchShopDealerCapital(data: (number | undefined)[])
|
||||
*/
|
||||
export async function getShopDealerCapital(id: number) {
|
||||
const res = await request.get<ApiResult<ShopDealerCapital>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-capital/' + id
|
||||
'/shop/shop-dealer-capital/' + id
|
||||
);
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { PageParam } from '@/api/index';
|
||||
import type { PageParam } from '@/api';
|
||||
|
||||
/**
|
||||
* 分销商资金明细表
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import request from '@/utils/request';
|
||||
import type { ApiResult, PageResult } from '@/api/index';
|
||||
import type { ApiResult, PageResult } from '@/api';
|
||||
import type { ShopDealerOrder, ShopDealerOrderParam } from './model';
|
||||
import { MODULES_API_URL } from '@/config/setting';
|
||||
|
||||
/**
|
||||
* 分页查询分销商订单记录表
|
||||
*/
|
||||
export async function pageShopDealerOrder(params: ShopDealerOrderParam) {
|
||||
const res = await request.get<ApiResult<PageResult<ShopDealerOrder>>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-order/page',
|
||||
'/shop/shop-dealer-order/page',
|
||||
{
|
||||
params
|
||||
}
|
||||
@@ -24,7 +23,7 @@ export async function pageShopDealerOrder(params: ShopDealerOrderParam) {
|
||||
*/
|
||||
export async function listShopDealerOrder(params?: ShopDealerOrderParam) {
|
||||
const res = await request.get<ApiResult<ShopDealerOrder[]>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-order',
|
||||
'/shop/shop-dealer-order',
|
||||
{
|
||||
params
|
||||
}
|
||||
@@ -40,7 +39,7 @@ export async function listShopDealerOrder(params?: ShopDealerOrderParam) {
|
||||
*/
|
||||
export async function addShopDealerOrder(data: ShopDealerOrder) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-order',
|
||||
'/shop/shop-dealer-order',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
@@ -54,7 +53,7 @@ export async function addShopDealerOrder(data: ShopDealerOrder) {
|
||||
*/
|
||||
export async function updateShopDealerOrder(data: ShopDealerOrder) {
|
||||
const res = await request.put<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-order',
|
||||
'/shop/shop-dealer-order',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
@@ -68,7 +67,7 @@ export async function updateShopDealerOrder(data: ShopDealerOrder) {
|
||||
*/
|
||||
export async function removeShopDealerOrder(id?: number) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-order/' + id
|
||||
'/shop/shop-dealer-order/' + id
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
@@ -81,7 +80,7 @@ export async function removeShopDealerOrder(id?: number) {
|
||||
*/
|
||||
export async function removeBatchShopDealerOrder(data: (number | undefined)[]) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-order/batch',
|
||||
'/shop/shop-dealer-order/batch',
|
||||
{
|
||||
data
|
||||
}
|
||||
@@ -97,7 +96,7 @@ export async function removeBatchShopDealerOrder(data: (number | undefined)[]) {
|
||||
*/
|
||||
export async function getShopDealerOrder(id: number) {
|
||||
const res = await request.get<ApiResult<ShopDealerOrder>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-order/' + id
|
||||
'/shop/shop-dealer-order/' + id
|
||||
);
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { PageParam } from '@/api/index';
|
||||
import type { PageParam } from '@/api';
|
||||
|
||||
/**
|
||||
* 分销商订单记录表
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import request from '@/utils/request';
|
||||
import type { ApiResult, PageResult } from '@/api/index';
|
||||
import type { ApiResult, PageResult } from '@/api';
|
||||
import type { ShopDealerReferee, ShopDealerRefereeParam } from './model';
|
||||
import { MODULES_API_URL } from '@/config/setting';
|
||||
|
||||
/**
|
||||
* 分页查询分销商推荐关系表
|
||||
*/
|
||||
export async function pageShopDealerReferee(params: ShopDealerRefereeParam) {
|
||||
const res = await request.get<ApiResult<PageResult<ShopDealerReferee>>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-referee/page',
|
||||
'/shop/shop-dealer-referee/page',
|
||||
{
|
||||
params
|
||||
}
|
||||
@@ -24,7 +23,7 @@ export async function pageShopDealerReferee(params: ShopDealerRefereeParam) {
|
||||
*/
|
||||
export async function listShopDealerReferee(params?: ShopDealerRefereeParam) {
|
||||
const res = await request.get<ApiResult<ShopDealerReferee[]>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-referee',
|
||||
'/shop/shop-dealer-referee',
|
||||
{
|
||||
params
|
||||
}
|
||||
@@ -40,7 +39,7 @@ export async function listShopDealerReferee(params?: ShopDealerRefereeParam) {
|
||||
*/
|
||||
export async function addShopDealerReferee(data: ShopDealerReferee) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-referee',
|
||||
'/shop/shop-dealer-referee',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
@@ -54,7 +53,7 @@ export async function addShopDealerReferee(data: ShopDealerReferee) {
|
||||
*/
|
||||
export async function updateShopDealerReferee(data: ShopDealerReferee) {
|
||||
const res = await request.put<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-referee',
|
||||
'/shop/shop-dealer-referee',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
@@ -68,7 +67,7 @@ export async function updateShopDealerReferee(data: ShopDealerReferee) {
|
||||
*/
|
||||
export async function removeShopDealerReferee(id?: number) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-referee/' + id
|
||||
'/shop/shop-dealer-referee/' + id
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
@@ -81,7 +80,7 @@ export async function removeShopDealerReferee(id?: number) {
|
||||
*/
|
||||
export async function removeBatchShopDealerReferee(data: (number | undefined)[]) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-referee/batch',
|
||||
'/shop/shop-dealer-referee/batch',
|
||||
{
|
||||
data
|
||||
}
|
||||
@@ -97,7 +96,7 @@ export async function removeBatchShopDealerReferee(data: (number | undefined)[])
|
||||
*/
|
||||
export async function getShopDealerReferee(id: number) {
|
||||
const res = await request.get<ApiResult<ShopDealerReferee>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-referee/' + id
|
||||
'/shop/shop-dealer-referee/' + id
|
||||
);
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { PageParam } from '@/api/index';
|
||||
import type { PageParam } from '@/api';
|
||||
|
||||
/**
|
||||
* 分销商推荐关系表
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import request from '@/utils/request';
|
||||
import type { ApiResult, PageResult } from '@/api/index';
|
||||
import type { ApiResult, PageResult } from '@/api';
|
||||
import type { ShopDealerSetting, ShopDealerSettingParam } from './model';
|
||||
import { MODULES_API_URL } from '@/config/setting';
|
||||
|
||||
/**
|
||||
* 分页查询分销商设置表
|
||||
*/
|
||||
export async function pageShopDealerSetting(params: ShopDealerSettingParam) {
|
||||
const res = await request.get<ApiResult<PageResult<ShopDealerSetting>>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-setting/page',
|
||||
'/shop/shop-dealer-setting/page',
|
||||
{
|
||||
params
|
||||
}
|
||||
@@ -24,7 +23,7 @@ export async function pageShopDealerSetting(params: ShopDealerSettingParam) {
|
||||
*/
|
||||
export async function listShopDealerSetting(params?: ShopDealerSettingParam) {
|
||||
const res = await request.get<ApiResult<ShopDealerSetting[]>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-setting',
|
||||
'/shop/shop-dealer-setting',
|
||||
{
|
||||
params
|
||||
}
|
||||
@@ -40,7 +39,7 @@ export async function listShopDealerSetting(params?: ShopDealerSettingParam) {
|
||||
*/
|
||||
export async function addShopDealerSetting(data: ShopDealerSetting) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-setting',
|
||||
'/shop/shop-dealer-setting',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
@@ -54,7 +53,7 @@ export async function addShopDealerSetting(data: ShopDealerSetting) {
|
||||
*/
|
||||
export async function updateShopDealerSetting(data: ShopDealerSetting) {
|
||||
const res = await request.put<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-setting',
|
||||
'/shop/shop-dealer-setting',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
@@ -68,7 +67,7 @@ export async function updateShopDealerSetting(data: ShopDealerSetting) {
|
||||
*/
|
||||
export async function removeShopDealerSetting(id?: number) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-setting/' + id
|
||||
'/shop/shop-dealer-setting/' + id
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
@@ -81,7 +80,7 @@ export async function removeShopDealerSetting(id?: number) {
|
||||
*/
|
||||
export async function removeBatchShopDealerSetting(data: (number | undefined)[]) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-setting/batch',
|
||||
'/shop/shop-dealer-setting/batch',
|
||||
{
|
||||
data
|
||||
}
|
||||
@@ -97,7 +96,7 @@ export async function removeBatchShopDealerSetting(data: (number | undefined)[])
|
||||
*/
|
||||
export async function getShopDealerSetting(id: number) {
|
||||
const res = await request.get<ApiResult<ShopDealerSetting>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-setting/' + id
|
||||
'/shop/shop-dealer-setting/' + id
|
||||
);
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { PageParam } from '@/api/index';
|
||||
import type { PageParam } from '@/api';
|
||||
|
||||
/**
|
||||
* 分销商设置表
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import request from '@/utils/request';
|
||||
import type { ApiResult, PageResult } from '@/api/index';
|
||||
import type { ApiResult, PageResult } from '@/api';
|
||||
import type { ShopDealerUser, ShopDealerUserParam } from './model';
|
||||
import { MODULES_API_URL } from '@/config/setting';
|
||||
|
||||
/**
|
||||
* 分页查询分销商用户记录表
|
||||
*/
|
||||
export async function pageShopDealerUser(params: ShopDealerUserParam) {
|
||||
const res = await request.get<ApiResult<PageResult<ShopDealerUser>>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-user/page',
|
||||
'/shop/shop-dealer-user/page',
|
||||
{
|
||||
params
|
||||
}
|
||||
@@ -24,7 +23,7 @@ export async function pageShopDealerUser(params: ShopDealerUserParam) {
|
||||
*/
|
||||
export async function listShopDealerUser(params?: ShopDealerUserParam) {
|
||||
const res = await request.get<ApiResult<ShopDealerUser[]>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-user',
|
||||
'/shop/shop-dealer-user',
|
||||
{
|
||||
params
|
||||
}
|
||||
@@ -40,7 +39,7 @@ export async function listShopDealerUser(params?: ShopDealerUserParam) {
|
||||
*/
|
||||
export async function addShopDealerUser(data: ShopDealerUser) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-user',
|
||||
'/shop/shop-dealer-user',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
@@ -54,7 +53,7 @@ export async function addShopDealerUser(data: ShopDealerUser) {
|
||||
*/
|
||||
export async function updateShopDealerUser(data: ShopDealerUser) {
|
||||
const res = await request.put<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-user',
|
||||
'/shop/shop-dealer-user',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
@@ -68,7 +67,7 @@ export async function updateShopDealerUser(data: ShopDealerUser) {
|
||||
*/
|
||||
export async function removeShopDealerUser(id?: number) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-user/' + id
|
||||
'/shop/shop-dealer-user/' + id
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
@@ -81,7 +80,7 @@ export async function removeShopDealerUser(id?: number) {
|
||||
*/
|
||||
export async function removeBatchShopDealerUser(data: (number | undefined)[]) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-user/batch',
|
||||
'/shop/shop-dealer-user/batch',
|
||||
{
|
||||
data
|
||||
}
|
||||
@@ -97,7 +96,7 @@ export async function removeBatchShopDealerUser(data: (number | undefined)[]) {
|
||||
*/
|
||||
export async function getShopDealerUser(id: number) {
|
||||
const res = await request.get<ApiResult<ShopDealerUser>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-user/' + id
|
||||
'/shop/shop-dealer-user/' + id
|
||||
);
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { PageParam } from '@/api/index';
|
||||
import type { PageParam } from '@/api';
|
||||
|
||||
/**
|
||||
* 分销商用户记录表
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import request from '@/utils/request';
|
||||
import type { ApiResult, PageResult } from '@/api/index';
|
||||
import type { ApiResult, PageResult } from '@/api';
|
||||
import type { ShopDealerWithdraw, ShopDealerWithdrawParam } from './model';
|
||||
import { MODULES_API_URL } from '@/config/setting';
|
||||
|
||||
/**
|
||||
* 分页查询分销商提现明细表
|
||||
*/
|
||||
export async function pageShopDealerWithdraw(params: ShopDealerWithdrawParam) {
|
||||
const res = await request.get<ApiResult<PageResult<ShopDealerWithdraw>>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-withdraw/page',
|
||||
'/shop/shop-dealer-withdraw/page',
|
||||
{
|
||||
params
|
||||
}
|
||||
@@ -24,7 +23,7 @@ export async function pageShopDealerWithdraw(params: ShopDealerWithdrawParam) {
|
||||
*/
|
||||
export async function listShopDealerWithdraw(params?: ShopDealerWithdrawParam) {
|
||||
const res = await request.get<ApiResult<ShopDealerWithdraw[]>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-withdraw',
|
||||
'/shop/shop-dealer-withdraw',
|
||||
{
|
||||
params
|
||||
}
|
||||
@@ -40,7 +39,7 @@ export async function listShopDealerWithdraw(params?: ShopDealerWithdrawParam) {
|
||||
*/
|
||||
export async function addShopDealerWithdraw(data: ShopDealerWithdraw) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-withdraw',
|
||||
'/shop/shop-dealer-withdraw',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
@@ -54,7 +53,7 @@ export async function addShopDealerWithdraw(data: ShopDealerWithdraw) {
|
||||
*/
|
||||
export async function updateShopDealerWithdraw(data: ShopDealerWithdraw) {
|
||||
const res = await request.put<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-withdraw',
|
||||
'/shop/shop-dealer-withdraw',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
@@ -68,7 +67,7 @@ export async function updateShopDealerWithdraw(data: ShopDealerWithdraw) {
|
||||
*/
|
||||
export async function removeShopDealerWithdraw(id?: number) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-withdraw/' + id
|
||||
'/shop/shop-dealer-withdraw/' + id
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
@@ -81,7 +80,7 @@ export async function removeShopDealerWithdraw(id?: number) {
|
||||
*/
|
||||
export async function removeBatchShopDealerWithdraw(data: (number | undefined)[]) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-withdraw/batch',
|
||||
'/shop/shop-dealer-withdraw/batch',
|
||||
{
|
||||
data
|
||||
}
|
||||
@@ -97,7 +96,7 @@ export async function removeBatchShopDealerWithdraw(data: (number | undefined)[]
|
||||
*/
|
||||
export async function getShopDealerWithdraw(id: number) {
|
||||
const res = await request.get<ApiResult<ShopDealerWithdraw>>(
|
||||
MODULES_API_URL + '/shop/shop-dealer-withdraw/' + id
|
||||
'/shop/shop-dealer-withdraw/' + id
|
||||
);
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { PageParam } from '@/api/index';
|
||||
import type { PageParam } from '@/api';
|
||||
|
||||
/**
|
||||
* 分销商提现明细表
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import request from '@/utils/request';
|
||||
import type { ApiResult, PageResult } from '@/api/index';
|
||||
import type { ApiResult, PageResult } from '@/api';
|
||||
import type { ShopUserCoupon, ShopUserCouponParam } from './model';
|
||||
import { MODULES_API_URL } from '@/config/setting';
|
||||
|
||||
/**
|
||||
* 分页查询用户优惠券
|
||||
*/
|
||||
export async function pageShopUserCoupon(params: ShopUserCouponParam) {
|
||||
const res = await request.get<ApiResult<PageResult<ShopUserCoupon>>>(
|
||||
MODULES_API_URL + '/shop/shop-user-coupon/page',
|
||||
'/shop/shop-user-coupon/page',
|
||||
{
|
||||
params
|
||||
}
|
||||
@@ -24,7 +23,7 @@ export async function pageShopUserCoupon(params: ShopUserCouponParam) {
|
||||
*/
|
||||
export async function listShopUserCoupon(params?: ShopUserCouponParam) {
|
||||
const res = await request.get<ApiResult<ShopUserCoupon[]>>(
|
||||
MODULES_API_URL + '/shop/shop-user-coupon',
|
||||
'/shop/shop-user-coupon',
|
||||
{
|
||||
params
|
||||
}
|
||||
@@ -40,7 +39,7 @@ export async function listShopUserCoupon(params?: ShopUserCouponParam) {
|
||||
*/
|
||||
export async function addShopUserCoupon(data: ShopUserCoupon) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-user-coupon',
|
||||
'/shop/shop-user-coupon',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
@@ -54,7 +53,7 @@ export async function addShopUserCoupon(data: ShopUserCoupon) {
|
||||
*/
|
||||
export async function updateShopUserCoupon(data: ShopUserCoupon) {
|
||||
const res = await request.put<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-user-coupon',
|
||||
'/shop/shop-user-coupon',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
@@ -68,7 +67,7 @@ export async function updateShopUserCoupon(data: ShopUserCoupon) {
|
||||
*/
|
||||
export async function removeShopUserCoupon(id?: number) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-user-coupon/' + id
|
||||
'/shop/shop-user-coupon/' + id
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
@@ -81,7 +80,7 @@ export async function removeShopUserCoupon(id?: number) {
|
||||
*/
|
||||
export async function removeBatchShopUserCoupon(data: (number | undefined)[]) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-user-coupon/batch',
|
||||
'/shop/shop-user-coupon/batch',
|
||||
{
|
||||
data
|
||||
}
|
||||
@@ -97,7 +96,7 @@ export async function removeBatchShopUserCoupon(data: (number | undefined)[]) {
|
||||
*/
|
||||
export async function getShopUserCoupon(id: number) {
|
||||
const res = await request.get<ApiResult<ShopUserCoupon>>(
|
||||
MODULES_API_URL + '/shop/shop-user-coupon/' + id
|
||||
'/shop/shop-user-coupon/' + id
|
||||
);
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { PageParam } from '@/api/index';
|
||||
import type { PageParam } from '@/api';
|
||||
|
||||
/**
|
||||
* 用户优惠券
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import request from '@/utils/request';
|
||||
import type { ApiResult, PageResult } from '@/api';
|
||||
import type { ShopUserReferee, ShopUserRefereeParam } from './model';
|
||||
import { MODULES_API_URL } from '@/config/setting';
|
||||
|
||||
/**
|
||||
* 分页查询用户推荐关系表
|
||||
*/
|
||||
export async function pageShopUserReferee(params: ShopUserRefereeParam) {
|
||||
const res = await request.get<ApiResult<PageResult<ShopUserReferee>>>(
|
||||
MODULES_API_URL + '/shop/shop-user-referee/page',
|
||||
'/shop/shop-user-referee/page',
|
||||
{
|
||||
params
|
||||
}
|
||||
@@ -24,7 +23,7 @@ export async function pageShopUserReferee(params: ShopUserRefereeParam) {
|
||||
*/
|
||||
export async function listShopUserReferee(params?: ShopUserRefereeParam) {
|
||||
const res = await request.get<ApiResult<ShopUserReferee[]>>(
|
||||
MODULES_API_URL + '/shop/shop-user-referee',
|
||||
'/shop/shop-user-referee',
|
||||
{
|
||||
params
|
||||
}
|
||||
@@ -40,7 +39,7 @@ export async function listShopUserReferee(params?: ShopUserRefereeParam) {
|
||||
*/
|
||||
export async function addShopUserReferee(data: ShopUserReferee) {
|
||||
const res = await request.post<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-user-referee',
|
||||
'/shop/shop-user-referee',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
@@ -54,7 +53,7 @@ export async function addShopUserReferee(data: ShopUserReferee) {
|
||||
*/
|
||||
export async function updateShopUserReferee(data: ShopUserReferee) {
|
||||
const res = await request.put<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-user-referee',
|
||||
'/shop/shop-user-referee',
|
||||
data
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
@@ -68,7 +67,7 @@ export async function updateShopUserReferee(data: ShopUserReferee) {
|
||||
*/
|
||||
export async function removeShopUserReferee(id?: number) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-user-referee/' + id
|
||||
'/shop/shop-user-referee/' + id
|
||||
);
|
||||
if (res.data.code === 0) {
|
||||
return res.data.message;
|
||||
@@ -81,7 +80,7 @@ export async function removeShopUserReferee(id?: number) {
|
||||
*/
|
||||
export async function removeBatchShopUserReferee(data: (number | undefined)[]) {
|
||||
const res = await request.delete<ApiResult<unknown>>(
|
||||
MODULES_API_URL + '/shop/shop-user-referee/batch',
|
||||
'/shop/shop-user-referee/batch',
|
||||
{
|
||||
data
|
||||
}
|
||||
@@ -97,7 +96,7 @@ export async function removeBatchShopUserReferee(data: (number | undefined)[]) {
|
||||
*/
|
||||
export async function getShopUserReferee(id: number) {
|
||||
const res = await request.get<ApiResult<ShopUserReferee>>(
|
||||
MODULES_API_URL + '/shop/shop-user-referee/' + id
|
||||
'/shop/shop-user-referee/' + id
|
||||
);
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
return res.data.data;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<!-- 编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="700"
|
||||
:width="800"
|
||||
:visible="visible"
|
||||
:maskClosable="false"
|
||||
:maxable="maxable"
|
||||
:title="isUpdate ? '编辑优惠券' : '添加优惠券'"
|
||||
:body-style="{ paddingBottom: '28px', maxHeight: '70vh', overflowY: 'auto' }"
|
||||
:body-style="{ paddingBottom: '28px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
>
|
||||
@@ -19,511 +19,321 @@
|
||||
styleResponsive ? { md: 19, sm: 19, xs: 24 } : { flex: '1' }
|
||||
"
|
||||
>
|
||||
<!-- 基本信息 -->
|
||||
<a-divider orientation="left">基本信息</a-divider>
|
||||
|
||||
<a-form-item
|
||||
label="优惠券名称"
|
||||
name="name"
|
||||
>
|
||||
<a-form-item label="优惠券名称" name="name">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入优惠券名称"
|
||||
v-model:value="form.name"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
label="优惠券类型"
|
||||
name="type"
|
||||
>
|
||||
<a-select
|
||||
placeholder="请选择优惠券类型"
|
||||
v-model:value="form.type"
|
||||
@change="onTypeChange"
|
||||
>
|
||||
<a-select-option :value="10">满减券</a-select-option>
|
||||
<a-select-option :value="20">折扣券</a-select-option>
|
||||
<a-select-option :value="30">免费券</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="优惠券描述" name="description">
|
||||
<a-textarea
|
||||
:rows="3"
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入优惠券描述"
|
||||
v-model:value="form.description"
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<!-- 优惠设置 -->
|
||||
<a-divider orientation="left">优惠设置</a-divider>
|
||||
|
||||
<a-form-item
|
||||
v-if="form.type === 10"
|
||||
label="减免金额"
|
||||
name="reducePrice"
|
||||
>
|
||||
<a-input-number
|
||||
:min="0"
|
||||
:precision="2"
|
||||
placeholder="请输入减免金额"
|
||||
<a-form-item label="优惠券类型(10满减券 20折扣券 30免费劵)" name="type">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入优惠券类型(10满减券 20折扣券 30免费劵)"
|
||||
v-model:value="form.type"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="满减券-减免金额" name="reducePrice">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入满减券-减免金额"
|
||||
v-model:value="form.reducePrice"
|
||||
style="width: 100%"
|
||||
>
|
||||
<template #addonAfter>元</template>
|
||||
</a-input-number>
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item
|
||||
v-if="form.type === 20"
|
||||
label="折扣率"
|
||||
name="discount"
|
||||
>
|
||||
<a-input-number
|
||||
:min="1"
|
||||
:max="99"
|
||||
:precision="1"
|
||||
placeholder="请输入折扣率"
|
||||
<a-form-item label="折扣券-折扣率(0-100)" name="discount">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入折扣券-折扣率(0-100)"
|
||||
v-model:value="form.discount"
|
||||
style="width: 100%"
|
||||
>
|
||||
<template #addonAfter>折</template>
|
||||
</a-input-number>
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item
|
||||
label="最低消费金额"
|
||||
name="minPrice"
|
||||
>
|
||||
<a-input-number
|
||||
:min="0"
|
||||
:precision="2"
|
||||
placeholder="0表示无门槛"
|
||||
<a-form-item label="最低消费金额" name="minPrice">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入最低消费金额"
|
||||
v-model:value="form.minPrice"
|
||||
style="width: 100%"
|
||||
>
|
||||
<template #addonAfter>元</template>
|
||||
</a-input-number>
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<!-- 有效期设置 -->
|
||||
<a-divider orientation="left">有效期设置</a-divider>
|
||||
|
||||
<a-form-item label="到期类型" name="expireType">
|
||||
<a-radio-group v-model:value="form.expireType" @change="onExpireTypeChange">
|
||||
<a-radio :value="10">领取后生效</a-radio>
|
||||
<a-radio :value="20">固定时间</a-radio>
|
||||
</a-radio-group>
|
||||
<a-form-item label="到期类型(10领取后生效 20固定时间)" name="expireType">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入到期类型(10领取后生效 20固定时间)"
|
||||
v-model:value="form.expireType"
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<div :gutter="16" v-if="form.expireType === 10">
|
||||
<a-form-item
|
||||
label="有效天数"
|
||||
name="expireDay"
|
||||
>
|
||||
<a-input-number
|
||||
:min="1"
|
||||
placeholder="请输入有效天数"
|
||||
v-model:value="form.expireDay"
|
||||
style="width: 100%"
|
||||
>
|
||||
<template #addonAfter>天</template>
|
||||
</a-input-number>
|
||||
</a-form-item>
|
||||
</div>
|
||||
|
||||
<div :gutter="16" v-if="form.expireType === 20">
|
||||
<a-form-item
|
||||
label="开始时间"
|
||||
name="startTime"
|
||||
>
|
||||
<a-date-picker
|
||||
placeholder="请选择开始时间"
|
||||
v-model:value="form.startTime"
|
||||
style="width: 100%"
|
||||
format="YYYY-MM-DD"
|
||||
valueFormat="YYYY-MM-DD"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
label="结束时间"
|
||||
name="endTime"
|
||||
>
|
||||
<a-date-picker
|
||||
placeholder="请选择结束时间"
|
||||
v-model:value="form.endTime"
|
||||
style="width: 100%"
|
||||
format="YYYY-MM-DD"
|
||||
valueFormat="YYYY-MM-DD"
|
||||
/>
|
||||
</a-form-item>
|
||||
</div>
|
||||
<!-- 适用范围 -->
|
||||
<a-divider orientation="left">适用范围</a-divider>
|
||||
|
||||
<a-form-item label="适用范围" name="applyRange">
|
||||
<a-select
|
||||
placeholder="请选择适用范围"
|
||||
<a-form-item label="领取后生效-有效天数" name="expireDay">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入领取后生效-有效天数"
|
||||
v-model:value="form.expireDay"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="有效期开始时间" name="startTime">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入有效期开始时间"
|
||||
v-model:value="form.startTime"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="有效期结束时间" name="endTime">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入有效期结束时间"
|
||||
v-model:value="form.endTime"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="适用范围(10全部商品 20指定商品 30指定分类)" name="applyRange">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入适用范围(10全部商品 20指定商品 30指定分类)"
|
||||
v-model:value="form.applyRange"
|
||||
>
|
||||
<a-select-option :value="10">全部商品</a-select-option>
|
||||
<a-select-option :value="20">指定商品</a-select-option>
|
||||
<a-select-option :value="30">指定分类</a-select-option>
|
||||
</a-select>
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item
|
||||
v-if="form.applyRange === 20 || form.applyRange === 30"
|
||||
label="范围配置"
|
||||
name="applyRangeConfig"
|
||||
>
|
||||
<a-textarea
|
||||
:rows="3"
|
||||
placeholder="请输入JSON格式的配置,如:[1,2,3]"
|
||||
<a-form-item label="适用范围配置(json格式)" name="applyRangeConfig">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入适用范围配置(json格式)"
|
||||
v-model:value="form.applyRangeConfig"
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<!-- 发放设置 -->
|
||||
<a-divider orientation="left">发放设置</a-divider>
|
||||
|
||||
<a-form-item
|
||||
label="发放总数量"
|
||||
name="totalCount"
|
||||
>
|
||||
<a-input-number
|
||||
:min="-1"
|
||||
placeholder="-1表示无限制"
|
||||
v-model:value="form.totalCount"
|
||||
style="width: 100%"
|
||||
>
|
||||
<template #addonAfter>张</template>
|
||||
</a-input-number>
|
||||
<a-form-item label="是否过期(0未过期 1已过期)" name="isExpire">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入是否过期(0未过期 1已过期)"
|
||||
v-model:value="form.isExpire"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
label="每人限领"
|
||||
name="limitPerUser"
|
||||
>
|
||||
<a-input-number
|
||||
:min="-1"
|
||||
placeholder="-1表示无限制"
|
||||
v-model:value="form.limitPerUser"
|
||||
style="width: 100%"
|
||||
>
|
||||
<template #addonAfter>张</template>
|
||||
</a-input-number>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item
|
||||
label="排序"
|
||||
name="sortNumber"
|
||||
>
|
||||
<a-form-item label="排序(数字越小越靠前)" name="sortNumber">
|
||||
<a-input-number
|
||||
:min="0"
|
||||
:max="9999"
|
||||
placeholder="数字越小越靠前"
|
||||
class="ele-fluid"
|
||||
placeholder="请输入排序号"
|
||||
v-model:value="form.sortNumber"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<!-- 状态设置 -->
|
||||
<a-divider orientation="left">状态设置</a-divider>
|
||||
|
||||
<a-form-item
|
||||
label="显示状态"
|
||||
name="status"
|
||||
>
|
||||
<a-form-item label="状态, 0正常, 1禁用" name="status">
|
||||
<a-radio-group v-model:value="form.status">
|
||||
<a-radio :value="0">显示</a-radio>
|
||||
<a-radio :value="1">隐藏</a-radio>
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
label="启用状态"
|
||||
name="enabled"
|
||||
>
|
||||
<a-radio-group v-model:value="form.enabled">
|
||||
<a-radio :value="true">启用</a-radio>
|
||||
<a-radio :value="false">禁用</a-radio>
|
||||
</a-radio-group>
|
||||
<a-form-item label="是否删除, 0否, 1是" name="deleted">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入是否删除, 0否, 1是"
|
||||
v-model:value="form.deleted"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="创建用户ID" name="userId">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入创建用户ID"
|
||||
v-model:value="form.userId"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="修改时间" name="updateTime">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入修改时间"
|
||||
v-model:value="form.updateTime"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="发放总数量(-1表示无限制)" name="totalCount">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入发放总数量(-1表示无限制)"
|
||||
v-model:value="form.totalCount"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="已发放数量" name="issuedCount">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入已发放数量"
|
||||
v-model:value="form.issuedCount"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="每人限领数量(-1表示无限制)" name="limitPerUser">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入每人限领数量(-1表示无限制)"
|
||||
v-model:value="form.limitPerUser"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="是否启用(0禁用 1启用)" name="enabled">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入是否启用(0禁用 1启用)"
|
||||
v-model:value="form.enabled"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {ref, reactive, watch} from 'vue';
|
||||
import {Form, message} from 'ant-design-vue';
|
||||
import {assignObject} from 'ele-admin-pro';
|
||||
import {addShopCoupon, updateShopCoupon} from '@/api/shop/shopCoupon';
|
||||
import {ShopCoupon} from '@/api/shop/shopCoupon/model';
|
||||
import {useThemeStore} from '@/store/modules/theme';
|
||||
import {storeToRefs} from 'pinia';
|
||||
import {ItemType} from 'ele-admin-pro/es/ele-image-upload/types';
|
||||
import {FormInstance} from 'ant-design-vue/es/form';
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { Form, message } from 'ant-design-vue';
|
||||
import { assignObject, uuid } from 'ele-admin-pro';
|
||||
import { addShopCoupon, updateShopCoupon } from '@/api/shop/shopCoupon';
|
||||
import { ShopCoupon } from '@/api/shop/shopCoupon/model';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
|
||||
import { FormInstance } from 'ant-design-vue/es/form';
|
||||
import { FileRecord } from '@/api/system/file/model';
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
const useForm = Form.useForm;
|
||||
// 是否开启响应式布局
|
||||
const themeStore = useThemeStore();
|
||||
const {styleResponsive} = storeToRefs(themeStore);
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: ShopCoupon | null;
|
||||
}>();
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
const useForm = Form.useForm;
|
||||
// 是否开启响应式布局
|
||||
const themeStore = useThemeStore();
|
||||
const { styleResponsive } = storeToRefs(themeStore);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: ShopCoupon | null;
|
||||
}>();
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
// 是否显示最大化切换按钮
|
||||
const maxable = ref(true);
|
||||
// 表格选中数据
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
const images = ref<ItemType[]>([]);
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 表单数据
|
||||
const form = reactive<ShopCoupon>({
|
||||
id: undefined,
|
||||
name: '',
|
||||
description: '',
|
||||
type: 10, // 默认满减券
|
||||
reducePrice: undefined,
|
||||
discount: undefined,
|
||||
minPrice: '', // 默认无门槛
|
||||
expireType: 10, // 默认领取后生效
|
||||
expireDay: 30, // 默认30天
|
||||
startTime: undefined,
|
||||
endTime: undefined,
|
||||
applyRange: 10, // 默认全部商品
|
||||
applyRangeConfig: '',
|
||||
isExpire: 0,
|
||||
sortNumber: 100,
|
||||
status: 0, // 默认显示
|
||||
deleted: 0,
|
||||
tenantId: undefined,
|
||||
totalCount: -1, // 默认无限制
|
||||
issuedCount: 0,
|
||||
limitPerUser: -1, // 默认无限制
|
||||
enabled: true, // 默认启用
|
||||
});
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
// 是否显示最大化切换按钮
|
||||
const maxable = ref(true);
|
||||
// 表格选中数据
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
const images = ref<ItemType[]>([]);
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
// 用户信息
|
||||
const form = reactive<ShopCoupon>({
|
||||
id: undefined,
|
||||
name: undefined,
|
||||
description: undefined,
|
||||
type: undefined,
|
||||
reducePrice: undefined,
|
||||
discount: undefined,
|
||||
minPrice: undefined,
|
||||
expireType: undefined,
|
||||
expireDay: undefined,
|
||||
startTime: undefined,
|
||||
endTime: undefined,
|
||||
applyRange: undefined,
|
||||
applyRangeConfig: undefined,
|
||||
isExpire: undefined,
|
||||
sortNumber: undefined,
|
||||
status: undefined,
|
||||
deleted: undefined,
|
||||
userId: undefined,
|
||||
tenantId: undefined,
|
||||
createTime: undefined,
|
||||
updateTime: undefined,
|
||||
totalCount: undefined,
|
||||
issuedCount: undefined,
|
||||
limitPerUser: undefined,
|
||||
enabled: undefined,
|
||||
shopCouponId: undefined,
|
||||
shopCouponName: '',
|
||||
status: 0,
|
||||
comments: '',
|
||||
sortNumber: 100
|
||||
});
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive({
|
||||
name: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入优惠券名称',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
type: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择优惠券类型',
|
||||
trigger: 'change'
|
||||
}
|
||||
],
|
||||
reducePrice: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入减免金额',
|
||||
trigger: 'blur',
|
||||
validator: (rule: any, value: any) => {
|
||||
if (form.type === 10 && (!value || value <= 0)) {
|
||||
return Promise.reject('减免金额必须大于0');
|
||||
}
|
||||
return Promise.resolve();
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive({
|
||||
shopCouponName: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请填写优惠券名称',
|
||||
trigger: 'blur'
|
||||
}
|
||||
}
|
||||
],
|
||||
discount: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入折扣率',
|
||||
trigger: 'blur',
|
||||
validator: (rule: any, value: any) => {
|
||||
if (form.type === 20 && (!value || value <= 0 || value >= 100)) {
|
||||
return Promise.reject('折扣率必须在1-99之间');
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
],
|
||||
expireType: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择到期类型',
|
||||
trigger: 'change'
|
||||
}
|
||||
],
|
||||
expireDay: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入有效天数',
|
||||
trigger: 'blur',
|
||||
validator: (rule: any, value: any) => {
|
||||
if (form.expireType === 10 && (!value || value <= 0)) {
|
||||
return Promise.reject('有效天数必须大于0');
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
],
|
||||
startTime: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择开始时间',
|
||||
trigger: 'change',
|
||||
validator: (rule: any, value: any) => {
|
||||
if (form.expireType === 20 && !value) {
|
||||
return Promise.reject('请选择开始时间');
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
],
|
||||
endTime: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择结束时间',
|
||||
trigger: 'change',
|
||||
validator: (rule: any, value: any) => {
|
||||
if (form.expireType === 20 && !value) {
|
||||
return Promise.reject('请选择结束时间');
|
||||
}
|
||||
if (form.expireType === 20 && form.startTime && value && value <= form.startTime) {
|
||||
return Promise.reject('结束时间必须晚于开始时间');
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
],
|
||||
applyRange: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择适用范围',
|
||||
trigger: 'change'
|
||||
}
|
||||
]
|
||||
});
|
||||
]
|
||||
});
|
||||
|
||||
const {resetFields} = useForm(form, rules);
|
||||
|
||||
/* 优惠券类型变化处理 */
|
||||
const onTypeChange = (value: number) => {
|
||||
// 清空相关字段
|
||||
if (value !== 10) {
|
||||
form.reducePrice = undefined;
|
||||
}
|
||||
if (value !== 20) {
|
||||
form.discount = undefined;
|
||||
}
|
||||
};
|
||||
|
||||
/* 到期类型变化处理 */
|
||||
const onExpireTypeChange = (e: any) => {
|
||||
const value = e.target.value;
|
||||
// 清空相关字段
|
||||
if (value !== 10) {
|
||||
form.expireDay = undefined;
|
||||
}
|
||||
if (value !== 20) {
|
||||
form.startTime = undefined;
|
||||
form.endTime = undefined;
|
||||
}
|
||||
};
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
|
||||
// 清理和准备提交数据
|
||||
const formData = {
|
||||
...form
|
||||
};
|
||||
|
||||
// 清理不需要的字段
|
||||
delete formData.shopCouponId;
|
||||
delete formData.shopCouponName;
|
||||
delete formData.comments;
|
||||
|
||||
// 确保数值类型正确
|
||||
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.deleted !== undefined) formData.deleted = Number(formData.deleted);
|
||||
if (formData.isExpire !== undefined) formData.isExpire = Number(formData.isExpire);
|
||||
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 (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);
|
||||
|
||||
// 清理空值
|
||||
Object.keys(formData).forEach(key => {
|
||||
if (formData[key] === undefined || formData[key] === null || formData[key] === '') {
|
||||
delete formData[key];
|
||||
}
|
||||
});
|
||||
|
||||
console.log('提交的数据:', formData);
|
||||
|
||||
const saveOrUpdate = isUpdate.value ? updateShopCoupon : addShopCoupon;
|
||||
saveOrUpdate(formData)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
console.error('保存失败:', e);
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
const chooseImage = (data: FileRecord) => {
|
||||
images.value.push({
|
||||
uid: data.id,
|
||||
url: data.path,
|
||||
status: 'done'
|
||||
});
|
||||
};
|
||||
form.image = data.path;
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
images.value = [];
|
||||
if (props.data) {
|
||||
assignObject(form, props.data);
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
const onDeleteItem = (index: number) => {
|
||||
images.value.splice(index, 1);
|
||||
form.image = '';
|
||||
};
|
||||
|
||||
const { resetFields } = useForm(form, rules);
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
},
|
||||
{immediate: true}
|
||||
);
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
const formData = {
|
||||
...form
|
||||
};
|
||||
const saveOrUpdate = isUpdate.value ? updateShopCoupon : addShopCoupon;
|
||||
saveOrUpdate(formData)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
images.value = [];
|
||||
if (props.data) {
|
||||
assignObject(form, props.data);
|
||||
if(props.data.image){
|
||||
images.value.push({
|
||||
uid: uuid(),
|
||||
url: props.data.image,
|
||||
status: 'done'
|
||||
})
|
||||
}
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
</script>
|
||||
|
||||
@@ -1,377 +1,346 @@
|
||||
<template>
|
||||
<a-page-header :title="getPageTitle()" @back="() => $router.go(-1)">
|
||||
<a-card :bordered="false" :body-style="{ padding: '16px' }">
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="id"
|
||||
:columns="columns"
|
||||
:datasource="datasource"
|
||||
:customRow="customRow"
|
||||
tool-class="ele-toolbar-form"
|
||||
class="sys-org-table"
|
||||
:scroll="{ x: 1400, y: 'calc(100vh - 320px)' }"
|
||||
size="middle"
|
||||
:pagination="{
|
||||
showSizeChanger: true,
|
||||
showQuickJumper: true,
|
||||
showTotal: (total, range) => `第 ${range[0]}-${range[1]} 条/共 ${total} 条`
|
||||
}"
|
||||
>
|
||||
<template #toolbar>
|
||||
<search
|
||||
@search="reload"
|
||||
:selection="selection"
|
||||
@add="openEdit"
|
||||
@remove="removeBatch"
|
||||
@batchMove="openMove"
|
||||
/>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'couponStatus'">
|
||||
<a-tag v-if="record.deleted === 1" color="red">已删除</a-tag>
|
||||
<a-tag v-else-if="record.enabled === 0" color="orange">已禁用</a-tag>
|
||||
<a-tag v-else-if="record.isExpire === 1" color="gray">已过期</a-tag>
|
||||
<a-tag v-else-if="record.status === 1" color="red">隐藏</a-tag>
|
||||
<a-tag v-else color="green">正常</a-tag>
|
||||
<a-card :bordered="false" :body-style="{ padding: '16px' }">
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="shopCouponId"
|
||||
:columns="columns"
|
||||
:datasource="datasource"
|
||||
:customRow="customRow"
|
||||
tool-class="ele-toolbar-form"
|
||||
class="sys-org-table"
|
||||
>
|
||||
<template #toolbar>
|
||||
<search
|
||||
@search="reload"
|
||||
:selection="selection"
|
||||
@add="openEdit"
|
||||
@remove="removeBatch"
|
||||
@batchMove="openMove"
|
||||
/>
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<a @click="openEdit(record)" class="ele-text-primary">
|
||||
<EditOutlined/>
|
||||
编辑
|
||||
</a>
|
||||
<a-divider type="vertical"/>
|
||||
<a-popconfirm
|
||||
title="确定要删除此优惠券吗?"
|
||||
@confirm="remove(record)"
|
||||
placement="topRight"
|
||||
>
|
||||
<a class="ele-text-danger">
|
||||
<DeleteOutlined/>
|
||||
删除
|
||||
</a>
|
||||
</a-popconfirm>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'image'">
|
||||
<a-image :src="record.image" :width="50" />
|
||||
</template>
|
||||
<template v-if="column.key === 'status'">
|
||||
<a-tag v-if="record.status === 0" color="green">显示</a-tag>
|
||||
<a-tag v-if="record.status === 1" color="red">隐藏</a-tag>
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a @click="openEdit(record)">修改</a>
|
||||
<a-divider type="vertical" />
|
||||
<a-popconfirm
|
||||
title="确定要删除此记录吗?"
|
||||
@confirm="remove(record)"
|
||||
>
|
||||
<a class="ele-text-danger">删除</a>
|
||||
</a-popconfirm>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
|
||||
<!-- 编辑弹窗 -->
|
||||
<ShopCouponEdit v-model:visible="showEdit" :data="current" @done="reload"/>
|
||||
<!-- 编辑弹窗 -->
|
||||
<ShopCouponEdit v-model:visible="showEdit" :data="current" @done="reload" />
|
||||
</a-page-header>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {createVNode, ref} from 'vue';
|
||||
import {message, Modal} from 'ant-design-vue';
|
||||
import {ExclamationCircleOutlined, EditOutlined, DeleteOutlined} from '@ant-design/icons-vue';
|
||||
import type {EleProTable} from 'ele-admin-pro';
|
||||
import {toDateString} from 'ele-admin-pro';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import Search from './components/search.vue';
|
||||
import {getPageTitle} from '@/utils/common';
|
||||
import ShopCouponEdit from './components/shopCouponEdit.vue';
|
||||
import {pageShopCoupon, removeShopCoupon, removeBatchShopCoupon} from '@/api/shop/shopCoupon';
|
||||
import type {ShopCoupon, ShopCouponParam} from '@/api/shop/shopCoupon/model';
|
||||
import { createVNode, ref } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro';
|
||||
import { toDateString } from 'ele-admin-pro';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import Search from './components/search.vue';
|
||||
import {getPageTitle} from '@/utils/common';
|
||||
import ShopCouponEdit from './components/shopCouponEdit.vue';
|
||||
import { pageShopCoupon, removeShopCoupon, removeBatchShopCoupon } from '@/api/shop/shopCoupon';
|
||||
import type { ShopCoupon, ShopCouponParam } from '@/api/shop/shopCoupon/model';
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
|
||||
// 表格选中数据
|
||||
const selection = ref<ShopCoupon[]>([]);
|
||||
// 当前编辑数据
|
||||
const current = ref<ShopCoupon | null>(null);
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
// 是否显示批量移动弹窗
|
||||
const showMove = ref(false);
|
||||
// 加载状态
|
||||
const loading = ref(true);
|
||||
// 表格选中数据
|
||||
const selection = ref<ShopCoupon[]>([]);
|
||||
// 当前编辑数据
|
||||
const current = ref<ShopCoupon | null>(null);
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
// 是否显示批量移动弹窗
|
||||
const showMove = ref(false);
|
||||
// 加载状态
|
||||
const loading = ref(true);
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({
|
||||
page,
|
||||
limit,
|
||||
where,
|
||||
orders,
|
||||
filters
|
||||
}) => {
|
||||
if (filters) {
|
||||
where.status = filters.status;
|
||||
}
|
||||
return pageShopCoupon({
|
||||
...where,
|
||||
...orders,
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({
|
||||
page,
|
||||
limit
|
||||
});
|
||||
};
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
title: 'ID',
|
||||
dataIndex: 'id',
|
||||
key: 'id',
|
||||
align: 'center',
|
||||
width: 80,
|
||||
fixed: 'left'
|
||||
},
|
||||
{
|
||||
title: '优惠券名称',
|
||||
dataIndex: 'name',
|
||||
key: 'name',
|
||||
align: 'left',
|
||||
width: 150,
|
||||
ellipsis: true,
|
||||
fixed: 'left'
|
||||
},
|
||||
{
|
||||
title: '类型',
|
||||
dataIndex: 'type',
|
||||
key: 'type',
|
||||
align: 'center',
|
||||
width: 100,
|
||||
customRender: ({text}) => {
|
||||
const typeMap: Record<number, string> = {
|
||||
10: '满减券',
|
||||
20: '折扣券',
|
||||
30: '免费券'
|
||||
};
|
||||
return typeMap[text] || text;
|
||||
limit,
|
||||
where,
|
||||
orders,
|
||||
filters
|
||||
}) => {
|
||||
if (filters) {
|
||||
where.status = filters.status;
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '优惠金额',
|
||||
key: 'couponValue',
|
||||
align: 'center',
|
||||
width: 120,
|
||||
customRender: ({record}) => {
|
||||
if (record.type === 10) {
|
||||
return `减${record.reducePrice}元`;
|
||||
} else if (record.type === 20) {
|
||||
return `${record.discount}折`;
|
||||
}
|
||||
return '免费';
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '最低消费',
|
||||
dataIndex: 'minPrice',
|
||||
key: 'minPrice',
|
||||
align: 'center',
|
||||
width: 100,
|
||||
customRender: ({text}) => text ? `满${text}元` : '无门槛'
|
||||
},
|
||||
{
|
||||
title: '有效期',
|
||||
key: 'validity',
|
||||
align: 'center',
|
||||
width: 180,
|
||||
customRender: ({record}) => {
|
||||
if (record.expireType === 10) {
|
||||
return `领取后${record.expireDay}天`;
|
||||
} else {
|
||||
return `${toDateString(record.startTime, 'MM-dd')} 至 ${toDateString(record.endTime, 'MM-dd')}`;
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '适用范围',
|
||||
dataIndex: 'applyRange',
|
||||
key: 'applyRange',
|
||||
align: 'center',
|
||||
width: 100,
|
||||
customRender: ({text}) => {
|
||||
const rangeMap: Record<number, string> = {
|
||||
10: '全部商品',
|
||||
20: '指定商品',
|
||||
30: '指定分类'
|
||||
};
|
||||
return rangeMap[text] || text;
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '发放情况',
|
||||
key: 'issueInfo',
|
||||
align: 'center',
|
||||
width: 120,
|
||||
customRender: ({record}) => {
|
||||
const total = record.totalCount === -1 ? '无限' : record.totalCount;
|
||||
return `${record.issuedCount}/${total}`;
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '限领数量',
|
||||
dataIndex: 'limitPerUser',
|
||||
key: 'limitPerUser',
|
||||
align: 'center',
|
||||
width: 100,
|
||||
customRender: ({text}) => text === -1 ? '无限制' : `${text}张/人`
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
key: 'couponStatus',
|
||||
align: 'center',
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
title: '排序',
|
||||
dataIndex: 'sortNumber',
|
||||
key: 'sortNumber',
|
||||
align: 'center',
|
||||
width: 80,
|
||||
sorter: true
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
align: 'center',
|
||||
width: 120,
|
||||
sorter: true,
|
||||
ellipsis: true,
|
||||
customRender: ({text}) => toDateString(text, 'yyyy-MM-dd')
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 150,
|
||||
fixed: 'right',
|
||||
align: 'center',
|
||||
hideInSetting: true
|
||||
}
|
||||
]);
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: ShopCouponParam) => {
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({where: where});
|
||||
};
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: ShopCoupon) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
/* 打开批量移动弹窗 */
|
||||
const openMove = () => {
|
||||
showMove.value = true;
|
||||
};
|
||||
|
||||
/* 删除单个 */
|
||||
const remove = (row: ShopCoupon) => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeShopCoupon(row.id)
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
return pageShopCoupon({
|
||||
...where,
|
||||
...orders,
|
||||
page,
|
||||
limit
|
||||
});
|
||||
};
|
||||
|
||||
/* 批量删除 */
|
||||
const removeBatch = () => {
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确定要删除选中的记录吗?',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
maskClosable: true,
|
||||
onOk: () => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeBatchShopCoupon(selection.value.map((d) => d.id))
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 查询 */
|
||||
const query = () => {
|
||||
loading.value = true;
|
||||
};
|
||||
|
||||
/* 自定义行属性 */
|
||||
const customRow = (record: ShopCoupon) => {
|
||||
return {
|
||||
// 行点击事件
|
||||
onClick: () => {
|
||||
// console.log(record);
|
||||
},
|
||||
// 行双击事件
|
||||
onDblclick: () => {
|
||||
openEdit(record);
|
||||
}
|
||||
};
|
||||
};
|
||||
query();
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
title: 'id',
|
||||
dataIndex: 'id',
|
||||
key: 'id',
|
||||
align: 'center',
|
||||
width: 90,
|
||||
},
|
||||
{
|
||||
title: '优惠券名称',
|
||||
dataIndex: 'name',
|
||||
key: 'name',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '优惠券描述',
|
||||
dataIndex: 'description',
|
||||
key: 'description',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '优惠券类型(10满减券 20折扣券 30免费劵)',
|
||||
dataIndex: 'type',
|
||||
key: 'type',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '满减券-减免金额',
|
||||
dataIndex: 'reducePrice',
|
||||
key: 'reducePrice',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '折扣券-折扣率(0-100)',
|
||||
dataIndex: 'discount',
|
||||
key: 'discount',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '最低消费金额',
|
||||
dataIndex: 'minPrice',
|
||||
key: 'minPrice',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '到期类型(10领取后生效 20固定时间)',
|
||||
dataIndex: 'expireType',
|
||||
key: 'expireType',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '领取后生效-有效天数',
|
||||
dataIndex: 'expireDay',
|
||||
key: 'expireDay',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '有效期开始时间',
|
||||
dataIndex: 'startTime',
|
||||
key: 'startTime',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '有效期结束时间',
|
||||
dataIndex: 'endTime',
|
||||
key: 'endTime',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '适用范围(10全部商品 20指定商品 30指定分类)',
|
||||
dataIndex: 'applyRange',
|
||||
key: 'applyRange',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '适用范围配置(json格式)',
|
||||
dataIndex: 'applyRangeConfig',
|
||||
key: 'applyRangeConfig',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '是否过期(0未过期 1已过期)',
|
||||
dataIndex: 'isExpire',
|
||||
key: 'isExpire',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '排序(数字越小越靠前)',
|
||||
dataIndex: 'sortNumber',
|
||||
key: 'sortNumber',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '状态, 0正常, 1禁用',
|
||||
dataIndex: 'status',
|
||||
key: 'status',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '是否删除, 0否, 1是',
|
||||
dataIndex: 'deleted',
|
||||
key: 'deleted',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '创建用户ID',
|
||||
dataIndex: 'userId',
|
||||
key: 'userId',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
align: 'center',
|
||||
sorter: true,
|
||||
ellipsis: true,
|
||||
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd')
|
||||
},
|
||||
{
|
||||
title: '修改时间',
|
||||
dataIndex: 'updateTime',
|
||||
key: 'updateTime',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '发放总数量(-1表示无限制)',
|
||||
dataIndex: 'totalCount',
|
||||
key: 'totalCount',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '已发放数量',
|
||||
dataIndex: 'issuedCount',
|
||||
key: 'issuedCount',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '每人限领数量(-1表示无限制)',
|
||||
dataIndex: 'limitPerUser',
|
||||
key: 'limitPerUser',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '是否启用(0禁用 1启用)',
|
||||
dataIndex: 'enabled',
|
||||
key: 'enabled',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 180,
|
||||
fixed: 'right',
|
||||
align: 'center',
|
||||
hideInSetting: true
|
||||
}
|
||||
]);
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: ShopCouponParam) => {
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({ where: where });
|
||||
};
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: ShopCoupon) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
/* 打开批量移动弹窗 */
|
||||
const openMove = () => {
|
||||
showMove.value = true;
|
||||
};
|
||||
|
||||
/* 删除单个 */
|
||||
const remove = (row: ShopCoupon) => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeShopCoupon(row.shopCouponId)
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
/* 批量删除 */
|
||||
const removeBatch = () => {
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确定要删除选中的记录吗?',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
maskClosable: true,
|
||||
onOk: () => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeBatchShopCoupon(selection.value.map((d) => d.shopCouponId))
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 查询 */
|
||||
const query = () => {
|
||||
loading.value = true;
|
||||
};
|
||||
|
||||
/* 自定义行属性 */
|
||||
const customRow = (record: ShopCoupon) => {
|
||||
return {
|
||||
// 行点击事件
|
||||
onClick: () => {
|
||||
// console.log(record);
|
||||
},
|
||||
// 行双击事件
|
||||
onDblclick: () => {
|
||||
openEdit(record);
|
||||
}
|
||||
};
|
||||
};
|
||||
query();
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'ShopCoupon'
|
||||
};
|
||||
export default {
|
||||
name: 'ShopCoupon'
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.sys-org-table {
|
||||
:deep(.ant-table) {
|
||||
.ant-table-thead > tr > th {
|
||||
background: #fafafa;
|
||||
font-weight: 600;
|
||||
color: #262626;
|
||||
border-bottom: 2px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.ant-table-tbody > tr > td {
|
||||
padding: 12px 8px;
|
||||
border-bottom: 1px solid #f5f5f5;
|
||||
}
|
||||
|
||||
.ant-table-tbody > tr:hover > td {
|
||||
background: #f8f9ff;
|
||||
}
|
||||
|
||||
.ant-tag {
|
||||
margin: 0;
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
padding: 2px 8px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.ele-text-primary {
|
||||
color: #1890ff;
|
||||
|
||||
&:hover {
|
||||
color: #40a9ff;
|
||||
}
|
||||
}
|
||||
|
||||
.ele-text-danger {
|
||||
color: #ff4d4f;
|
||||
|
||||
&:hover {
|
||||
color: #ff7875;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<style lang="less" scoped></style>
|
||||
|
||||
@@ -16,10 +16,8 @@
|
||||
<a-tab-pane key="undelivered" tab="待发货"/>
|
||||
<a-tab-pane key="unreceived" tab="待收货"/>
|
||||
<a-tab-pane key="completed" tab="已完成"/>
|
||||
<a-tab-pane key="cancelled" tab="已取消"/>
|
||||
<!-- <a-tab-pane key="unevaluated" tab="待评价"/>-->
|
||||
<a-tab-pane key="refunded" tab="已退款"/>
|
||||
<!-- <a-tab-pane key="deleted" tab="已删除"/>-->
|
||||
<a-tab-pane key="cancelled" tab="已取消"/>
|
||||
</a-tabs>
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="ele-body">
|
||||
<a-page-header :title="getPageTitle()" @back="() => $router.go(-1)">
|
||||
<a-card :bordered="false" :body-style="{ padding: '16px' }">
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
@@ -46,8 +45,7 @@
|
||||
|
||||
<!-- 编辑弹窗 -->
|
||||
<ShopUserRefereeEdit v-model:visible="showEdit" :data="current" @done="reload" />
|
||||
</div>
|
||||
</div>
|
||||
</a-page-header>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
@@ -61,6 +59,7 @@
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import Search from './components/search.vue';
|
||||
import {getPageTitle} from '@/utils/common';
|
||||
import ShopUserRefereeEdit from './components/shopUserRefereeEdit.vue';
|
||||
import { pageShopUserReferee, removeShopUserReferee, removeBatchShopUserReferee } from '@/api/shop/shopUserReferee';
|
||||
import type { ShopUserReferee, ShopUserRefereeParam } from '@/api/shop/shopUserReferee/model';
|
||||
|
||||
Reference in New Issue
Block a user