mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 13:09:19 +08:00
1
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
import type { BrushOrderDTO, BrushOrderVO } from './types';
|
||||
|
||||
import type { PageQueryDTO, PageResultVO } from '#/types/common';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
/**
|
||||
* 刷单记录管理API
|
||||
*/
|
||||
|
||||
/**
|
||||
* 创建刷单记录
|
||||
*/
|
||||
export async function createBrushOrderApi(data: BrushOrderDTO.Create) {
|
||||
return requestClient.post<BrushOrderVO.Info>('/ec/brush-order/create', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新刷单记录
|
||||
*/
|
||||
export async function updateBrushOrderApi(
|
||||
id: number,
|
||||
data: BrushOrderDTO.Update,
|
||||
) {
|
||||
return requestClient.put<BrushOrderVO.Info>(
|
||||
`/ec/brush-order/update/${id}`,
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除刷单记录
|
||||
*/
|
||||
export async function deleteBrushOrderApi(id: number) {
|
||||
return requestClient.delete(`/ec/brush-order/delete/${id}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页获取刷单记录列表
|
||||
*/
|
||||
export async function getBrushOrderPageApi(
|
||||
params: PageQueryDTO<BrushOrderDTO.Filters>,
|
||||
) {
|
||||
return requestClient.post<PageResultVO<BrushOrderVO.Info>>(
|
||||
'/ec/brush-order/page',
|
||||
params,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取刷单记录详情
|
||||
*/
|
||||
export async function getBrushOrderByIdApi(id: number) {
|
||||
return requestClient.get<BrushOrderVO.Info>(`/ec/brush-order/detail/${id}`);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* 刷单记录管理模块API导出
|
||||
*/
|
||||
|
||||
export * from './apis';
|
||||
export * from './types';
|
||||
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* 刷单记录管理模块类型定义导出
|
||||
*/
|
||||
|
||||
export * from './types.dto';
|
||||
export * from './types.vo';
|
||||
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* 刷单记录相关DTO类型定义
|
||||
*/
|
||||
|
||||
export namespace BrushOrderDTO {
|
||||
/** 创建刷单记录参数 */
|
||||
export interface Create {
|
||||
/** 店铺ID */
|
||||
shopId: number;
|
||||
/** 商品ID(可选) */
|
||||
productId?: number;
|
||||
/** 商品规格ID(可选) */
|
||||
productSpecId?: number;
|
||||
/** 刷单金额 */
|
||||
brushAmount: number;
|
||||
/** 刷单时间 */
|
||||
brushTime: string;
|
||||
/** 平台订单号(可选) */
|
||||
platformOrderNo?: string;
|
||||
/** 刷单数量 */
|
||||
quantity?: number;
|
||||
/** 备注 */
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
/** 更新刷单记录参数 */
|
||||
export interface Update {
|
||||
/** 店铺ID */
|
||||
shopId: number;
|
||||
/** 商品ID(可选) */
|
||||
productId?: number;
|
||||
/** 商品规格ID(可选) */
|
||||
productSpecId?: number;
|
||||
/** 刷单金额 */
|
||||
brushAmount: number;
|
||||
/** 刷单时间 */
|
||||
brushTime: string;
|
||||
/** 平台订单号(可选) */
|
||||
platformOrderNo?: string;
|
||||
/** 刷单数量 */
|
||||
quantity?: number;
|
||||
/** 备注 */
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
/** 刷单记录过滤条件 */
|
||||
export interface Filters {
|
||||
/** 店铺ID */
|
||||
shopId?: number;
|
||||
/** 商品ID */
|
||||
productId?: number;
|
||||
/** 平台订单号(模糊查询) */
|
||||
platformOrderNo?: string;
|
||||
/** 刷单金额范围-最小值 */
|
||||
minBrushAmount?: number;
|
||||
/** 刷单金额范围-最大值 */
|
||||
maxBrushAmount?: number;
|
||||
/** 刷单时间范围-开始时间 */
|
||||
startBrushTime?: string;
|
||||
/** 刷单时间范围-结束时间 */
|
||||
endBrushTime?: string;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* 刷单记录相关VO类型定义
|
||||
*/
|
||||
|
||||
export namespace BrushOrderVO {
|
||||
/** 刷单记录信息 */
|
||||
export interface Info {
|
||||
/** 刷单记录ID */
|
||||
id: number;
|
||||
/** 公司ID */
|
||||
companyId: number;
|
||||
/** 店铺ID */
|
||||
shopId: number;
|
||||
/** 店铺名称 */
|
||||
shopName: string;
|
||||
/** 商品ID */
|
||||
productId?: number;
|
||||
/** 商品名称 */
|
||||
productName?: string;
|
||||
/** 商品规格ID */
|
||||
productSpecId?: number;
|
||||
/** 商品规格名称 */
|
||||
productSpecName?: string;
|
||||
/** 刷单金额 */
|
||||
brushAmount: number;
|
||||
/** 刷单时间 */
|
||||
brushTime: string;
|
||||
/** 平台订单号 */
|
||||
platformOrderNo?: string;
|
||||
/** 刷单数量 */
|
||||
quantity?: number;
|
||||
/** 备注 */
|
||||
remark?: string;
|
||||
/** 创建时间 */
|
||||
createTime: string;
|
||||
/** 更新时间 */
|
||||
updateTime: string;
|
||||
/** 创建人ID */
|
||||
createBy?: number;
|
||||
/** 更新人ID */
|
||||
updateBy?: number;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import type { CompanyOverviewDTO, CompanyOverviewVO } from './types';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
/**
|
||||
* 全店铺概览管理API
|
||||
*/
|
||||
|
||||
/**
|
||||
* 获取全店铺概览统计数据
|
||||
*/
|
||||
export async function getCompanyOverviewApi(data: CompanyOverviewDTO.Query) {
|
||||
return requestClient.post<CompanyOverviewVO.Info>(
|
||||
'/ec/company-overview/statistics',
|
||||
data,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* 全店铺概览管理模块API导出
|
||||
*/
|
||||
|
||||
export * from './apis';
|
||||
export * from './types';
|
||||
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* 全店铺概览管理模块类型定义导出
|
||||
*/
|
||||
|
||||
export * from './types.dto';
|
||||
export * from './types.vo';
|
||||
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* 全店铺概览相关DTO类型定义
|
||||
*/
|
||||
|
||||
export namespace CompanyOverviewDTO {
|
||||
/** 全店铺概览查询参数 */
|
||||
export interface Query {
|
||||
/** 日期范围数组(第一个是开始日期,第二个是结束日期,只有一个日期则返回当天数据) */
|
||||
dateRange: string[];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
/**
|
||||
* 全店铺概览相关VO类型定义
|
||||
*/
|
||||
|
||||
export namespace CompanyOverviewVO {
|
||||
/** 全店铺概览信息 */
|
||||
export interface Info {
|
||||
/** 全店总销售额 */
|
||||
totalSalesAmount: number;
|
||||
/** 较上月同期增长百分比 */
|
||||
monthOverMonthGrowth?: number;
|
||||
/** 全店总单量 */
|
||||
totalOrderCount: number;
|
||||
/** 总推广费支出 */
|
||||
totalPromotionFee: number;
|
||||
/** 平均费比(推广费/销售额) */
|
||||
averageFeeRatio?: number;
|
||||
/** 全店总净利(税后) */
|
||||
totalNetProfitAfterTax: number;
|
||||
/** 扣除总税额 */
|
||||
totalTaxAmount?: number;
|
||||
/** 各店铺销售占比排行 */
|
||||
shopSalesRatios?: ShopSalesRatio[];
|
||||
/** 店铺效率象限(ROI vs 净利) */
|
||||
shopEfficiencyQuadrants?: ShopEfficiencyQuadrant[];
|
||||
/** 多店铺数据横向对比(16维度) */
|
||||
shopComparisons?: ShopComparison[];
|
||||
/** 汇总ROI */
|
||||
totalROI?: number;
|
||||
/** 总税后盈亏 */
|
||||
totalProfitAfterTax?: number;
|
||||
}
|
||||
|
||||
/** 店铺销售占比 */
|
||||
export interface ShopSalesRatio {
|
||||
/** 店铺ID */
|
||||
shopId: number;
|
||||
/** 店铺名称 */
|
||||
shopName: string;
|
||||
/** 销售额 */
|
||||
salesAmount: number;
|
||||
/** 占比百分比 */
|
||||
ratio: number;
|
||||
}
|
||||
|
||||
/** 店铺效率象限 */
|
||||
export interface ShopEfficiencyQuadrant {
|
||||
/** 店铺ID */
|
||||
shopId: number;
|
||||
/** 店铺名称 */
|
||||
shopName: string;
|
||||
/** ROI */
|
||||
roi: number;
|
||||
/** 净利 */
|
||||
netProfit: number;
|
||||
/** 象限(1-高ROI高净利,2-高ROI低净利,3-低ROI高净利,4-低ROI低净利) */
|
||||
quadrant: number;
|
||||
}
|
||||
|
||||
/** 店铺对比数据(16维度) */
|
||||
export interface ShopComparison {
|
||||
/** 店铺ID */
|
||||
shopId: number;
|
||||
/** 店铺名称 */
|
||||
shopName: string;
|
||||
/** 平台 */
|
||||
platform?: string;
|
||||
/** 销售额 */
|
||||
salesAmount: number;
|
||||
/** ROI */
|
||||
roi?: number;
|
||||
/** 退款金额 */
|
||||
refundAmount?: number;
|
||||
/** 刷单费 */
|
||||
brushFee?: number;
|
||||
/** 推广费总和 */
|
||||
totalPromotionFee?: number;
|
||||
/** 税后盈亏 */
|
||||
profitAfterTax?: number;
|
||||
/** 订单数量 */
|
||||
orderCount?: number;
|
||||
/** 总成本 */
|
||||
totalCost?: number;
|
||||
/** 总利润(税前) */
|
||||
totalProfitBeforeTax?: number;
|
||||
/** 税额 */
|
||||
taxAmount?: number;
|
||||
/** 费比 */
|
||||
feeRatio?: number;
|
||||
/** 客单价 */
|
||||
averageOrderValue?: number;
|
||||
/** 利润率 */
|
||||
profitMargin?: number;
|
||||
/** 推广费占比 */
|
||||
promotionFeeRatio?: number;
|
||||
/** 退款率 */
|
||||
refundRate?: number;
|
||||
}
|
||||
}
|
||||
@@ -11,8 +11,8 @@ export namespace OrderStatusDTO {
|
||||
description?: string;
|
||||
/** 排序 */
|
||||
sortOrder?: number;
|
||||
/** 是否默认参与统计 0不参与 1参与 */
|
||||
isDefaultStat: number;
|
||||
/** 自动统计 0不参与 1参与 */
|
||||
autoStatistics: number;
|
||||
}
|
||||
|
||||
/** 更新订单状态参数 */
|
||||
@@ -23,7 +23,7 @@ export namespace OrderStatusDTO {
|
||||
description?: string;
|
||||
/** 排序 */
|
||||
sortOrder?: number;
|
||||
/** 是否默认参与统计 0不参与 1参与 */
|
||||
isDefaultStat: number;
|
||||
/** 自动统计 0不参与 1参与 */
|
||||
autoStatistics: number;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@ export namespace OrderStatusVO {
|
||||
description?: string;
|
||||
/** 排序 */
|
||||
sortOrder?: number;
|
||||
/** 是否默认参与统计 0不参与 1参与 */
|
||||
isDefaultStat: number;
|
||||
/** 自动统计 0不参与 1参与 */
|
||||
autoStatistics: number;
|
||||
/** 创建时间 */
|
||||
createTime: string;
|
||||
/** 更新时间 */
|
||||
|
||||
@@ -27,8 +27,14 @@ export namespace OrderDTO {
|
||||
quantity: number;
|
||||
/** 销售单价 */
|
||||
unitPrice: number;
|
||||
/** 成本价(下单时快照) */
|
||||
costPrice: number;
|
||||
/** 单件商品成本(下单时快照) */
|
||||
productCost: number;
|
||||
/** 单件运费成本(下单时快照) */
|
||||
shippingCost?: number;
|
||||
/** 单件其他成本(下单时快照) */
|
||||
otherCost?: number;
|
||||
/** 备注 */
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
/** 更新订单参数 */
|
||||
@@ -55,8 +61,14 @@ export namespace OrderDTO {
|
||||
quantity?: number;
|
||||
/** 销售单价 */
|
||||
unitPrice?: number;
|
||||
/** 成本价(下单时快照) */
|
||||
costPrice?: number;
|
||||
/** 单件商品成本(下单时快照) */
|
||||
productCost?: number;
|
||||
/** 单件运费成本(下单时快照) */
|
||||
shippingCost?: number;
|
||||
/** 单件其他成本(下单时快照) */
|
||||
otherCost?: number;
|
||||
/** 备注 */
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
/** 订单过滤条件 */
|
||||
|
||||
@@ -43,8 +43,14 @@ export namespace OrderVO {
|
||||
quantity: number;
|
||||
/** 销售单价 */
|
||||
unitPrice: number;
|
||||
/** 成本价(下单时快照) */
|
||||
costPrice: number;
|
||||
/** 单件商品成本(下单时快照) */
|
||||
productCost: number;
|
||||
/** 单件运费成本(下单时快照) */
|
||||
shippingCost?: number;
|
||||
/** 单件其他成本(下单时快照) */
|
||||
otherCost?: number;
|
||||
/** 备注 */
|
||||
remark?: string;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,18 +11,32 @@ export namespace ProductSpecDTO {
|
||||
name: string;
|
||||
/** 规格编码 */
|
||||
specCode?: string;
|
||||
/** 成本价 */
|
||||
costPrice: number;
|
||||
/** 商品成本 */
|
||||
productCost: number;
|
||||
/** 运费成本 */
|
||||
shippingCost?: number;
|
||||
/** 其他成本 */
|
||||
otherCost?: number;
|
||||
/** 备注 */
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
/** 更新商品规格参数 */
|
||||
export interface Update {
|
||||
/** 规格ID */
|
||||
id: number;
|
||||
/** 规格名称 */
|
||||
name: string;
|
||||
/** 规格编码 */
|
||||
specCode?: string;
|
||||
/** 成本价 */
|
||||
costPrice: number;
|
||||
/** 商品成本 */
|
||||
productCost: number;
|
||||
/** 运费成本 */
|
||||
shippingCost?: number;
|
||||
/** 其他成本 */
|
||||
otherCost?: number;
|
||||
/** 备注 */
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
/** 商品规格过滤条件 */
|
||||
|
||||
@@ -17,8 +17,14 @@ export namespace ProductSpecVO {
|
||||
name: string;
|
||||
/** 规格编码 */
|
||||
specCode?: string;
|
||||
/** 成本价 */
|
||||
costPrice: number;
|
||||
/** 商品成本 */
|
||||
productCost: number;
|
||||
/** 运费成本 */
|
||||
shippingCost?: number;
|
||||
/** 其他成本 */
|
||||
otherCost?: number;
|
||||
/** 备注 */
|
||||
remark?: string;
|
||||
/** 创建时间 */
|
||||
createTime: string;
|
||||
/** 更新时间 */
|
||||
|
||||
+449
@@ -0,0 +1,449 @@
|
||||
<script setup lang="ts">
|
||||
import type { BrushOrderDTO, BrushOrderVO } from '#/api/ecommerce/brush-order';
|
||||
import type {
|
||||
ProductSpecDTO,
|
||||
ProductSpecVO,
|
||||
} from '#/api/ecommerce/product-spec/types';
|
||||
import type { ProductDTO, ProductVO } from '#/api/ecommerce/product/types';
|
||||
import type { ShopVO } from '#/api/ecommerce/shop/types';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import {
|
||||
DatePicker,
|
||||
Form,
|
||||
Input,
|
||||
InputNumber,
|
||||
message,
|
||||
Select,
|
||||
Spin,
|
||||
} from 'ant-design-vue';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import {
|
||||
createBrushOrderApi,
|
||||
updateBrushOrderApi,
|
||||
} from '#/api/ecommerce/brush-order';
|
||||
import { getProductPageApi } from '#/api/ecommerce/product';
|
||||
import { getProductSpecPageApi } from '#/api/ecommerce/product-spec';
|
||||
import { getShopPageApi } from '#/api/ecommerce/shop';
|
||||
|
||||
defineOptions({ name: 'BrushOrderFormModal' });
|
||||
|
||||
const props = defineProps<Props>();
|
||||
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
// Props
|
||||
interface Props {
|
||||
open: boolean;
|
||||
brushOrderData?: null | BrushOrderVO.Info;
|
||||
}
|
||||
|
||||
// Emits
|
||||
interface Emits {
|
||||
(e: 'update:open', value: boolean): void;
|
||||
(e: 'success'): void;
|
||||
(e: 'cancel'): void;
|
||||
}
|
||||
|
||||
// 创建 vben modal
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
draggable: true,
|
||||
class: 'w-[800px]',
|
||||
onCancel() {
|
||||
handleCancel();
|
||||
},
|
||||
onConfirm() {
|
||||
handleOk();
|
||||
},
|
||||
});
|
||||
|
||||
// 响应式数据
|
||||
const formRef = ref();
|
||||
const isEdit = ref(false);
|
||||
|
||||
// 表单数据
|
||||
const formData = ref<BrushOrderDTO.Create>({
|
||||
shopId: undefined as any,
|
||||
productId: undefined,
|
||||
productSpecId: undefined,
|
||||
brushAmount: undefined as any,
|
||||
brushTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
platformOrderNo: undefined,
|
||||
quantity: 1,
|
||||
remark: undefined,
|
||||
});
|
||||
|
||||
// 表单验证规则
|
||||
const rules = {
|
||||
shopId: [{ required: true, message: '请选择店铺', trigger: 'change' }],
|
||||
brushAmount: [
|
||||
{ required: true, message: '请输入刷单金额', trigger: 'blur' },
|
||||
{ type: 'number', min: 0, message: '刷单金额必须大于等于0', trigger: 'blur' },
|
||||
],
|
||||
brushTime: [{ required: true, message: '请选择刷单时间', trigger: 'change' }],
|
||||
} as any;
|
||||
|
||||
// 店铺列表
|
||||
const shopList = ref<ShopVO.Info[]>([]);
|
||||
const shopListLoading = ref(false);
|
||||
|
||||
// 商品选项数据
|
||||
const productOptions = ref<
|
||||
{ label: string; product: ProductVO.Info; value: number }[]
|
||||
>([]);
|
||||
const productLoading = ref(false);
|
||||
const productSearchKeyword = ref('');
|
||||
|
||||
// 规格选项数据
|
||||
const productSpecOptions = ref<
|
||||
{ label: string; spec: ProductSpecVO.Info; value: number }[]
|
||||
>([]);
|
||||
const productSpecLoading = ref(false);
|
||||
const productSpecSearchKeyword = ref('');
|
||||
|
||||
// 处理日期选择器的双向绑定
|
||||
const brushTimeValue = computed({
|
||||
get() {
|
||||
return formData.value.brushTime
|
||||
? dayjs(formData.value.brushTime, 'YYYY-MM-DD HH:mm:ss')
|
||||
: null;
|
||||
},
|
||||
set(value: any) {
|
||||
formData.value.brushTime = value
|
||||
? value.format('YYYY-MM-DD HH:mm:ss')
|
||||
: '';
|
||||
},
|
||||
});
|
||||
|
||||
// 监听props变化
|
||||
watch(
|
||||
() => props.open,
|
||||
(newVal) => {
|
||||
if (newVal) {
|
||||
modalApi.open();
|
||||
isEdit.value = !!props.brushOrderData;
|
||||
if (props.brushOrderData) {
|
||||
// 编辑模式,填充表单数据
|
||||
formData.value = {
|
||||
shopId: props.brushOrderData.shopId,
|
||||
productId: props.brushOrderData.productId,
|
||||
productSpecId: props.brushOrderData.productSpecId,
|
||||
brushAmount: props.brushOrderData.brushAmount,
|
||||
brushTime: props.brushOrderData.brushTime
|
||||
? dayjs(props.brushOrderData.brushTime).format('YYYY-MM-DD HH:mm:ss')
|
||||
: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
platformOrderNo: props.brushOrderData.platformOrderNo,
|
||||
quantity: props.brushOrderData.quantity || 1,
|
||||
remark: props.brushOrderData.remark,
|
||||
};
|
||||
// 如果有商品ID,加载商品和规格选项
|
||||
if (props.brushOrderData.productId) {
|
||||
searchProducts('');
|
||||
if (props.brushOrderData.productSpecId) {
|
||||
searchProductSpecs('');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 新增模式,重置表单数据
|
||||
resetFormData();
|
||||
}
|
||||
} else {
|
||||
modalApi.close();
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
// 加载店铺列表
|
||||
const loadShopList = async () => {
|
||||
shopListLoading.value = true;
|
||||
try {
|
||||
const response = await getShopPageApi({
|
||||
page: 1,
|
||||
pageSize: 1000,
|
||||
filters: {},
|
||||
});
|
||||
shopList.value = response.records;
|
||||
} catch (error) {
|
||||
console.error('加载店铺列表失败:', error);
|
||||
} finally {
|
||||
shopListLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 搜索商品
|
||||
async function searchProducts(keyword: string) {
|
||||
productSearchKeyword.value = keyword;
|
||||
productLoading.value = true;
|
||||
try {
|
||||
const params: PageQueryDTO<ProductDTO.Filters> = {
|
||||
page: 1,
|
||||
pageSize: 50,
|
||||
filters: {
|
||||
name: keyword || undefined,
|
||||
},
|
||||
};
|
||||
const data = await getProductPageApi(params);
|
||||
productOptions.value = data.records.map((product: ProductVO.Info) => ({
|
||||
label: `${product.name}${product.productCode ? ` (${product.productCode})` : ''}`,
|
||||
value: product.id,
|
||||
product,
|
||||
}));
|
||||
} catch (error) {
|
||||
console.error('搜索商品失败:', error);
|
||||
message.error('搜索商品失败');
|
||||
} finally {
|
||||
productLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 搜索规格
|
||||
async function searchProductSpecs(keyword: string) {
|
||||
if (!formData.value.productId) {
|
||||
productSpecOptions.value = [];
|
||||
return;
|
||||
}
|
||||
productSpecSearchKeyword.value = keyword;
|
||||
productSpecLoading.value = true;
|
||||
try {
|
||||
const params: PageQueryDTO<ProductSpecDTO.Filters> = {
|
||||
page: 1,
|
||||
pageSize: 50,
|
||||
filters: {
|
||||
productId: formData.value.productId,
|
||||
name: keyword || undefined,
|
||||
},
|
||||
};
|
||||
const data = await getProductSpecPageApi(params);
|
||||
productSpecOptions.value = data.records.map((spec: ProductSpecVO.Info) => ({
|
||||
label: `${spec.name}${spec.specCode ? ` (${spec.specCode})` : ''}`,
|
||||
value: spec.id,
|
||||
spec,
|
||||
}));
|
||||
} catch (error) {
|
||||
console.error('搜索规格失败:', error);
|
||||
message.error('搜索规格失败');
|
||||
} finally {
|
||||
productSpecLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 处理商品选择
|
||||
function handleProductChange(productId: number | undefined) {
|
||||
if (!productId) {
|
||||
formData.value.productSpecId = undefined;
|
||||
productSpecOptions.value = [];
|
||||
} else {
|
||||
// 加载该商品的规格列表
|
||||
searchProductSpecs('');
|
||||
}
|
||||
}
|
||||
|
||||
// 监听商品ID变化,加载规格列表
|
||||
watch(
|
||||
() => formData.value.productId,
|
||||
(newProductId) => {
|
||||
if (newProductId) {
|
||||
searchProductSpecs('');
|
||||
} else {
|
||||
productSpecOptions.value = [];
|
||||
formData.value.productSpecId = undefined;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
// 重置表单数据
|
||||
const resetFormData = () => {
|
||||
formData.value = {
|
||||
shopId: undefined as any,
|
||||
productId: undefined,
|
||||
productSpecId: undefined,
|
||||
brushAmount: undefined as any,
|
||||
brushTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
platformOrderNo: undefined,
|
||||
quantity: 1,
|
||||
remark: undefined,
|
||||
};
|
||||
productOptions.value = [];
|
||||
productSpecOptions.value = [];
|
||||
};
|
||||
|
||||
// 确认操作
|
||||
const handleOk = async () => {
|
||||
try {
|
||||
await formRef.value?.validate();
|
||||
|
||||
if (isEdit.value && props.brushOrderData) {
|
||||
// 更新刷单记录
|
||||
await updateBrushOrderApi(props.brushOrderData.id, formData.value);
|
||||
message.success('更新成功');
|
||||
} else {
|
||||
// 创建刷单记录
|
||||
await createBrushOrderApi(formData.value);
|
||||
message.success('创建成功');
|
||||
}
|
||||
|
||||
emit('success');
|
||||
modalApi.close();
|
||||
emit('update:open', false);
|
||||
} catch (error) {
|
||||
if ((error as any)?.errorFields) {
|
||||
// 表单验证错误
|
||||
return;
|
||||
}
|
||||
console.error('操作失败:', error);
|
||||
message.error(isEdit.value ? '更新失败' : '创建失败');
|
||||
}
|
||||
};
|
||||
|
||||
// 取消操作
|
||||
const handleCancel = () => {
|
||||
emit('cancel');
|
||||
modalApi.close();
|
||||
emit('update:open', false);
|
||||
resetFormData();
|
||||
};
|
||||
|
||||
// 组件挂载时加载数据
|
||||
onMounted(() => {
|
||||
loadShopList();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="isEdit ? '编辑刷单记录' : '新增刷单记录'">
|
||||
<Form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="rules"
|
||||
:label-col="{ span: 6 }"
|
||||
:wrapper-col="{ span: 18 }"
|
||||
>
|
||||
<Form.Item label="店铺" name="shopId">
|
||||
<Select
|
||||
v-model:value="formData.shopId"
|
||||
placeholder="请选择店铺"
|
||||
:loading="shopListLoading"
|
||||
>
|
||||
<Select.Option
|
||||
v-for="shop in shopList"
|
||||
:key="shop.id"
|
||||
:value="shop.id"
|
||||
>
|
||||
{{ shop.name }}
|
||||
</Select.Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="商品" name="productId">
|
||||
<Select
|
||||
v-model:value="formData.productId"
|
||||
placeholder="请选择商品(可选)"
|
||||
show-search
|
||||
:filter-option="false"
|
||||
:loading="productLoading"
|
||||
allow-clear
|
||||
@search="searchProducts"
|
||||
@change="handleProductChange"
|
||||
>
|
||||
<template #notFoundContent>
|
||||
<div v-if="productLoading" class="py-4 text-center">
|
||||
<Spin size="small" />
|
||||
<div class="mt-2">加载中...</div>
|
||||
</div>
|
||||
<div v-else class="py-4 text-center text-gray-400">
|
||||
请输入关键词搜索商品
|
||||
</div>
|
||||
</template>
|
||||
<Select.Option
|
||||
v-for="option in productOptions"
|
||||
:key="option.value"
|
||||
:value="option.value"
|
||||
>
|
||||
{{ option.label }}
|
||||
</Select.Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="商品规格" name="productSpecId">
|
||||
<Select
|
||||
v-model:value="formData.productSpecId"
|
||||
placeholder="请选择商品规格(可选)"
|
||||
show-search
|
||||
:filter-option="false"
|
||||
:loading="productSpecLoading"
|
||||
:disabled="!formData.productId"
|
||||
allow-clear
|
||||
@search="searchProductSpecs"
|
||||
>
|
||||
<template #notFoundContent>
|
||||
<div v-if="productSpecLoading" class="py-4 text-center">
|
||||
<Spin size="small" />
|
||||
<div class="mt-2">加载中...</div>
|
||||
</div>
|
||||
<div v-else class="py-4 text-center text-gray-400">
|
||||
{{ formData.productId ? '请输入关键词搜索规格' : '请先选择商品' }}
|
||||
</div>
|
||||
</template>
|
||||
<Select.Option
|
||||
v-for="option in productSpecOptions"
|
||||
:key="option.value"
|
||||
:value="option.value"
|
||||
>
|
||||
{{ option.label }}
|
||||
</Select.Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="刷单金额" name="brushAmount">
|
||||
<InputNumber
|
||||
v-model:value="formData.brushAmount"
|
||||
placeholder="请输入刷单金额"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="刷单时间" name="brushTime">
|
||||
<DatePicker
|
||||
v-model:value="brushTimeValue"
|
||||
placeholder="请选择刷单时间"
|
||||
show-time
|
||||
format="YYYY-MM-DD HH:mm:ss"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="平台订单号" name="platformOrderNo">
|
||||
<Input
|
||||
v-model:value="formData.platformOrderNo"
|
||||
placeholder="请输入平台订单号(可选)"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="刷单数量" name="quantity">
|
||||
<InputNumber
|
||||
v-model:value="formData.quantity"
|
||||
placeholder="请输入刷单数量"
|
||||
:min="1"
|
||||
:precision="0"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="备注" name="remark">
|
||||
<Input.TextArea
|
||||
v-model:value="formData.remark"
|
||||
placeholder="请输入备注(可选)"
|
||||
:rows="3"
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
</template>
|
||||
@@ -0,0 +1,383 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import type { BrushOrderDTO, BrushOrderVO } from '#/api/ecommerce/brush-order';
|
||||
import type { ShopVO } from '#/api/ecommerce/shop/types';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
import { createIconifyIcon } from '@vben/icons';
|
||||
|
||||
import { Button, message, Popconfirm, Space } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
deleteBrushOrderApi,
|
||||
getBrushOrderPageApi,
|
||||
} from '#/api/ecommerce/brush-order';
|
||||
import { getShopPageApi } from '#/api/ecommerce/shop';
|
||||
|
||||
import BrushOrderFormModal from './components/BrushOrderFormModal.vue';
|
||||
|
||||
defineOptions({ name: 'BrushOrderManagement' });
|
||||
|
||||
// 创建图标组件
|
||||
const PlusIcon = createIconifyIcon('lucide:plus');
|
||||
|
||||
// 响应式数据
|
||||
const loading = ref(false);
|
||||
const formModalVisible = ref(false);
|
||||
const currentBrushOrderData = ref<BrushOrderVO.Info | null>(null);
|
||||
|
||||
// 搜索表单
|
||||
const searchForm = ref({
|
||||
platformOrderNo: '',
|
||||
shopId: undefined as number | undefined,
|
||||
productId: undefined as number | undefined,
|
||||
minBrushAmount: undefined as number | undefined,
|
||||
maxBrushAmount: undefined as number | undefined,
|
||||
startBrushTime: undefined as string | undefined,
|
||||
endBrushTime: undefined as string | undefined,
|
||||
});
|
||||
|
||||
// 店铺选项(从搜索表单中获取)
|
||||
const shopOptions = ref<{ label: string; value: number }[]>([]);
|
||||
|
||||
// VbenVxeGrid 表格配置
|
||||
const gridOptions: VxeGridProps<any> = {
|
||||
columns: [
|
||||
{
|
||||
type: 'seq' as const,
|
||||
minWidth: 'auto',
|
||||
title: '序号',
|
||||
},
|
||||
{
|
||||
field: 'platformOrderNo',
|
||||
title: '平台订单号',
|
||||
minWidth: 'auto',
|
||||
showOverflow: 'tooltip' as const,
|
||||
},
|
||||
{
|
||||
field: 'shopName',
|
||||
title: '店铺名称',
|
||||
minWidth: 'auto',
|
||||
showOverflow: 'tooltip' as const,
|
||||
},
|
||||
{
|
||||
title: '商品信息',
|
||||
minWidth: 'auto',
|
||||
slots: { default: 'productInfo' },
|
||||
},
|
||||
{
|
||||
field: 'quantity',
|
||||
title: '刷单数量',
|
||||
minWidth: 'auto',
|
||||
},
|
||||
{
|
||||
title: '刷单金额',
|
||||
minWidth: 'auto',
|
||||
slots: { default: 'brushAmount' },
|
||||
},
|
||||
{
|
||||
field: 'brushTime',
|
||||
title: '刷单时间',
|
||||
minWidth: 'auto',
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
minWidth: 'auto',
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
minWidth: 'auto',
|
||||
fixed: 'right' as const,
|
||||
slots: { default: 'action' },
|
||||
},
|
||||
],
|
||||
height: 'auto',
|
||||
border: true,
|
||||
stripe: true,
|
||||
highlightHoverRow: true,
|
||||
showOverflow: true,
|
||||
size: 'small',
|
||||
toolbarConfig: {
|
||||
custom: true,
|
||||
refresh: true,
|
||||
zoom: true,
|
||||
},
|
||||
data: [],
|
||||
pagerConfig: {
|
||||
enabled: true,
|
||||
pageSizes: [10, 20, 50, 100],
|
||||
layouts: [
|
||||
'PrevJump',
|
||||
'PrevPage',
|
||||
'Number',
|
||||
'NextPage',
|
||||
'NextJump',
|
||||
'Sizes',
|
||||
'FullJump',
|
||||
'Total',
|
||||
] as (
|
||||
| 'FullJump'
|
||||
| 'NextJump'
|
||||
| 'NextPage'
|
||||
| 'Number'
|
||||
| 'PrevJump'
|
||||
| 'PrevPage'
|
||||
| 'Sizes'
|
||||
| 'Total'
|
||||
)[],
|
||||
},
|
||||
// 配置远程加载
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }) => {
|
||||
try {
|
||||
loading.value = true;
|
||||
const params: PageQueryDTO<BrushOrderDTO.Filters> = {
|
||||
page: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
filters: {
|
||||
platformOrderNo: searchForm.value.platformOrderNo || undefined,
|
||||
shopId: searchForm.value.shopId,
|
||||
productId: searchForm.value.productId,
|
||||
minBrushAmount: searchForm.value.minBrushAmount,
|
||||
maxBrushAmount: searchForm.value.maxBrushAmount,
|
||||
startBrushTime: searchForm.value.startBrushTime,
|
||||
endBrushTime: searchForm.value.endBrushTime,
|
||||
},
|
||||
};
|
||||
const data = await getBrushOrderPageApi(params);
|
||||
return {
|
||||
items: data.records,
|
||||
total: data.total,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('获取刷单记录列表失败:', error);
|
||||
message.error('获取刷单记录列表失败');
|
||||
return {
|
||||
items: [],
|
||||
total: 0,
|
||||
};
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// 搜索表单配置
|
||||
const formOptions = computed(() => ({
|
||||
schema: [
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入平台订单号',
|
||||
},
|
||||
fieldName: 'platformOrderNo',
|
||||
label: '平台订单号',
|
||||
},
|
||||
{
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
placeholder: '请选择店铺',
|
||||
options: shopOptions.value,
|
||||
allowClear: true,
|
||||
},
|
||||
fieldName: 'shopId',
|
||||
label: '店铺',
|
||||
},
|
||||
{
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
placeholder: '最小金额',
|
||||
min: 0,
|
||||
precision: 2,
|
||||
style: { width: '100%' },
|
||||
},
|
||||
fieldName: 'minBrushAmount',
|
||||
label: '金额范围',
|
||||
},
|
||||
{
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
placeholder: '最大金额',
|
||||
min: 0,
|
||||
precision: 2,
|
||||
style: { width: '100%' },
|
||||
},
|
||||
fieldName: 'maxBrushAmount',
|
||||
label: '',
|
||||
},
|
||||
{
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
placeholder: '开始时间',
|
||||
showTime: true,
|
||||
format: 'YYYY-MM-DD HH:mm:ss',
|
||||
style: { width: '100%' },
|
||||
},
|
||||
fieldName: 'startBrushTime',
|
||||
label: '刷单时间',
|
||||
},
|
||||
{
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
placeholder: '结束时间',
|
||||
showTime: true,
|
||||
format: 'YYYY-MM-DD HH:mm:ss',
|
||||
style: { width: '100%' },
|
||||
},
|
||||
fieldName: 'endBrushTime',
|
||||
label: '',
|
||||
},
|
||||
],
|
||||
showDefaultActions: true,
|
||||
collapsed: true,
|
||||
collapsedRows: 1,
|
||||
}));
|
||||
|
||||
// 刷新表格数据
|
||||
function refreshTable() {
|
||||
if (gridApi) {
|
||||
gridApi.reload();
|
||||
}
|
||||
}
|
||||
|
||||
// 创建 VbenVxeGrid 实例
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions,
|
||||
formOptions: formOptions.value,
|
||||
showSearchForm: true,
|
||||
tableTitle: '刷单记录管理',
|
||||
});
|
||||
|
||||
// 处理新增
|
||||
const handleAdd = () => {
|
||||
currentBrushOrderData.value = null;
|
||||
formModalVisible.value = true;
|
||||
};
|
||||
|
||||
// 处理编辑
|
||||
const handleEdit = (record: BrushOrderVO.Info) => {
|
||||
currentBrushOrderData.value = record;
|
||||
formModalVisible.value = true;
|
||||
};
|
||||
|
||||
// 处理删除
|
||||
const handleDelete = async (id: number) => {
|
||||
try {
|
||||
await deleteBrushOrderApi(id);
|
||||
message.success('删除成功');
|
||||
refreshTable();
|
||||
} catch {
|
||||
message.error('删除失败');
|
||||
}
|
||||
};
|
||||
|
||||
// 处理表单成功
|
||||
const handleFormSuccess = () => {
|
||||
refreshTable();
|
||||
};
|
||||
|
||||
// 格式化金额
|
||||
const formatAmount = (amount: number) => {
|
||||
return `¥${amount.toFixed(2)}`;
|
||||
};
|
||||
|
||||
// 加载店铺选项
|
||||
const loadShopOptions = async () => {
|
||||
try {
|
||||
const response = await getShopPageApi({
|
||||
page: 1,
|
||||
pageSize: 1000,
|
||||
filters: {},
|
||||
});
|
||||
shopOptions.value = response.records.map((shop: ShopVO.Info) => ({
|
||||
label: shop.name,
|
||||
value: shop.id,
|
||||
}));
|
||||
} catch (error) {
|
||||
console.error('加载店铺列表失败:', error);
|
||||
}
|
||||
};
|
||||
|
||||
// 组件挂载时加载数据
|
||||
onMounted(() => {
|
||||
loadShopOptions();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page title="刷单记录管理" auto-content-height>
|
||||
<template #description>
|
||||
<div class="text-foreground/80 mt-2">
|
||||
管理店铺刷单记录,支持按店铺、商品、金额、时间等维度查询和统计
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #extra>
|
||||
<Space>
|
||||
<Button type="primary" @click="handleAdd">
|
||||
<PlusIcon class="mr-2 h-4 w-4" />
|
||||
新增刷单记录
|
||||
</Button>
|
||||
</Space>
|
||||
</template>
|
||||
|
||||
<!-- 数据表格 -->
|
||||
<Grid :loading="loading">
|
||||
<!-- 工具栏工具 -->
|
||||
<template #toolbar-tools>
|
||||
<Space>
|
||||
<span class="text-gray-500">
|
||||
支持按店铺、商品、金额、时间等维度查询刷单记录
|
||||
</span>
|
||||
</Space>
|
||||
</template>
|
||||
|
||||
<!-- 商品信息列 -->
|
||||
<template #productInfo="{ row }: { row: any }">
|
||||
<div v-if="row.productName">
|
||||
<div style="font-weight: bold">{{ row.productName }}</div>
|
||||
<div v-if="row.productSpecName" style="color: #666; font-size: 12px">
|
||||
{{ row.productSpecName }}
|
||||
</div>
|
||||
</div>
|
||||
<span v-else class="text-gray-400">-</span>
|
||||
</template>
|
||||
|
||||
<!-- 刷单金额列 -->
|
||||
<template #brushAmount="{ row }: { row: any }">
|
||||
<span class="font-medium text-green-600">
|
||||
{{ formatAmount(row.brushAmount || 0) }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<!-- 操作列 -->
|
||||
<template #action="{ row }: { row: any }">
|
||||
<Space>
|
||||
<Button size="small" @click="handleEdit(row)"> 编辑 </Button>
|
||||
<Popconfirm
|
||||
title="确定要删除这条刷单记录吗?"
|
||||
@confirm="handleDelete(row.id)"
|
||||
>
|
||||
<Button size="small" danger> 删除 </Button>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
</template>
|
||||
</Grid>
|
||||
|
||||
<!-- 表单弹窗 -->
|
||||
<BrushOrderFormModal
|
||||
v-model:open="formModalVisible"
|
||||
:brush-order-data="currentBrushOrderData"
|
||||
@success="handleFormSuccess"
|
||||
@cancel="formModalVisible = false"
|
||||
/>
|
||||
</Page>
|
||||
</template>
|
||||
@@ -0,0 +1,597 @@
|
||||
<script lang="ts" setup>
|
||||
import type { EchartsUIType } from '@vben/plugins/echarts';
|
||||
|
||||
import type {
|
||||
CompanyOverviewDTO,
|
||||
CompanyOverviewVO,
|
||||
} from '#/api/ecommerce/company-overview';
|
||||
|
||||
import { onMounted, ref, watch } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
|
||||
|
||||
import { Button, DatePicker, message, Spin } from 'ant-design-vue';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import { getCompanyOverviewApi } from '#/api/ecommerce/company-overview';
|
||||
import { getShopPageApi } from '#/api/ecommerce/shop';
|
||||
|
||||
defineOptions({ name: 'CompanyOverview' });
|
||||
|
||||
// 响应式数据
|
||||
const loading = ref(false);
|
||||
const overviewData = ref<CompanyOverviewVO.Info | null>(null);
|
||||
const shopCount = ref(0);
|
||||
|
||||
// 日期范围
|
||||
const dateRange = ref<[dayjs.Dayjs, dayjs.Dayjs]>([
|
||||
dayjs().subtract(30, 'day'),
|
||||
dayjs(),
|
||||
]);
|
||||
|
||||
// 当前选中的时间范围类型
|
||||
const activeTimeRange = ref<
|
||||
'7days' | '30days' | 'custom' | 'today' | 'yesterday'
|
||||
>('30days');
|
||||
|
||||
// 自定义日期范围
|
||||
const customDateRange = ref<[dayjs.Dayjs, dayjs.Dayjs] | undefined>(undefined);
|
||||
|
||||
// 切换时间范围
|
||||
const switchTimeRange = (
|
||||
type: '7days' | '30days' | 'custom' | 'today' | 'yesterday',
|
||||
) => {
|
||||
activeTimeRange.value = type;
|
||||
let startDate: dayjs.Dayjs;
|
||||
let endDate: dayjs.Dayjs = dayjs();
|
||||
|
||||
switch (type) {
|
||||
case '7days': {
|
||||
startDate = dayjs().subtract(7, 'day');
|
||||
break;
|
||||
}
|
||||
case '30days': {
|
||||
startDate = dayjs().subtract(30, 'day');
|
||||
break;
|
||||
}
|
||||
case 'custom': {
|
||||
if (customDateRange.value) {
|
||||
dateRange.value = customDateRange.value;
|
||||
}
|
||||
return;
|
||||
}
|
||||
case 'today': {
|
||||
startDate = dayjs();
|
||||
endDate = dayjs();
|
||||
break;
|
||||
}
|
||||
case 'yesterday': {
|
||||
startDate = dayjs().subtract(1, 'day');
|
||||
endDate = dayjs().subtract(1, 'day');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
dateRange.value = [startDate, endDate];
|
||||
};
|
||||
|
||||
// 自定义日期范围变化
|
||||
const handleCustomDateRangeChange = (
|
||||
value: [dayjs.Dayjs, dayjs.Dayjs] | [string, string] | null,
|
||||
_dateString?: [string, string],
|
||||
) => {
|
||||
if (value && Array.isArray(value) && value.length === 2) {
|
||||
// 确保是 dayjs 对象
|
||||
const dates = [
|
||||
dayjs.isDayjs(value[0]) ? value[0] : dayjs(value[0]),
|
||||
dayjs.isDayjs(value[1]) ? value[1] : dayjs(value[1]),
|
||||
] as [dayjs.Dayjs, dayjs.Dayjs];
|
||||
customDateRange.value = dates;
|
||||
activeTimeRange.value = 'custom';
|
||||
dateRange.value = dates;
|
||||
}
|
||||
};
|
||||
|
||||
// 图表引用
|
||||
const barChartRef = ref<EchartsUIType>();
|
||||
const scatterChartRef = ref<EchartsUIType>();
|
||||
const { renderEcharts: renderBarChart } = useEcharts(barChartRef);
|
||||
const { renderEcharts: renderScatterChart } = useEcharts(scatterChartRef);
|
||||
|
||||
// 格式化金额
|
||||
const formatAmount = (amount: number) => {
|
||||
return `¥${(amount / 10_000).toFixed(2)}万`;
|
||||
};
|
||||
|
||||
// 格式化金额(完整)
|
||||
const formatAmountFull = (amount: number) => {
|
||||
return `¥${amount.toLocaleString('zh-CN')}`;
|
||||
};
|
||||
|
||||
// 格式化百分比
|
||||
const formatPercent = (value: number | undefined) => {
|
||||
if (value === undefined) return '-';
|
||||
return `${value > 0 ? '+' : ''}${value.toFixed(1)}%`;
|
||||
};
|
||||
|
||||
// 加载店铺数量
|
||||
const loadShopCount = async () => {
|
||||
try {
|
||||
const response = await getShopPageApi({
|
||||
page: 1,
|
||||
pageSize: 1,
|
||||
filters: {},
|
||||
});
|
||||
shopCount.value = response.total || 0;
|
||||
} catch (error) {
|
||||
console.error('获取店铺数量失败:', error);
|
||||
}
|
||||
};
|
||||
|
||||
// 加载概览数据
|
||||
const loadOverviewData = async () => {
|
||||
try {
|
||||
loading.value = true;
|
||||
const params: CompanyOverviewDTO.Query = {
|
||||
dateRange: [
|
||||
dateRange.value[0].format('YYYY-MM-DD'),
|
||||
dateRange.value[1].format('YYYY-MM-DD'),
|
||||
],
|
||||
};
|
||||
const data = await getCompanyOverviewApi(params);
|
||||
overviewData.value = data;
|
||||
} catch (error) {
|
||||
console.error('获取全店概览数据失败:', error);
|
||||
message.error('获取全店概览数据失败');
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 渲染店铺销售占比排行图表
|
||||
const renderShopBarChart = () => {
|
||||
if (!barChartRef.value || !overviewData.value?.shopSalesRatios) return;
|
||||
|
||||
const ratios = overviewData.value.shopSalesRatios;
|
||||
const shopNames = ratios.map((r) => r.shopName).reverse();
|
||||
const salesAmounts = ratios.map((r) => r.salesAmount / 1000).reverse(); // 转换为千元
|
||||
|
||||
renderBarChart({
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
formatter: (params: any) => {
|
||||
const param = Array.isArray(params) ? params[0] : params;
|
||||
const index = param.dataIndex;
|
||||
const shop = ratios[ratios.length - 1 - index];
|
||||
if (!shop) return '';
|
||||
return `${shop.shopName}<br/>销售额: ${formatAmountFull(shop.salesAmount)}<br/>占比: ${shop.ratio.toFixed(2)}%`;
|
||||
},
|
||||
},
|
||||
xAxis: {
|
||||
type: 'value',
|
||||
show: false,
|
||||
},
|
||||
yAxis: {
|
||||
type: 'category',
|
||||
data: shopNames,
|
||||
axisLine: { show: false },
|
||||
},
|
||||
series: [
|
||||
{
|
||||
type: 'bar',
|
||||
data: salesAmounts,
|
||||
itemStyle: {
|
||||
color: {
|
||||
type: 'linear',
|
||||
x: 1,
|
||||
y: 0,
|
||||
x2: 0,
|
||||
y2: 0,
|
||||
colorStops: [
|
||||
{ offset: 0, color: '#6366f1' },
|
||||
{ offset: 1, color: '#a5b4fc' },
|
||||
],
|
||||
},
|
||||
borderRadius: [0, 10, 10, 0],
|
||||
},
|
||||
barWidth: 25,
|
||||
},
|
||||
],
|
||||
});
|
||||
};
|
||||
|
||||
// 渲染店铺效率象限图
|
||||
const renderShopScatterChart = () => {
|
||||
if (!scatterChartRef.value || !overviewData.value?.shopEfficiencyQuadrants)
|
||||
return;
|
||||
|
||||
const quadrants = overviewData.value.shopEfficiencyQuadrants;
|
||||
const data = quadrants.map((q) => [q.roi, q.netProfit / 1000]); // 净利转换为千元
|
||||
|
||||
renderScatterChart({
|
||||
grid: {
|
||||
top: '10%',
|
||||
bottom: '10%',
|
||||
left: '10%',
|
||||
right: '10%',
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'item',
|
||||
formatter: (params: any) => {
|
||||
const index = params.dataIndex;
|
||||
const shop = quadrants[index];
|
||||
if (!shop) return '';
|
||||
return `${shop.shopName}<br/>ROI: ${shop.roi.toFixed(2)}<br/>净利: ${formatAmountFull(shop.netProfit)}`;
|
||||
},
|
||||
},
|
||||
xAxis: {
|
||||
name: 'ROI',
|
||||
nameLocation: 'middle',
|
||||
nameGap: 30,
|
||||
splitLine: {
|
||||
lineStyle: {
|
||||
type: 'dashed',
|
||||
},
|
||||
},
|
||||
},
|
||||
yAxis: {
|
||||
name: '净利(千元)',
|
||||
nameLocation: 'middle',
|
||||
nameGap: 50,
|
||||
splitLine: {
|
||||
lineStyle: {
|
||||
type: 'dashed',
|
||||
},
|
||||
},
|
||||
},
|
||||
series: [
|
||||
{
|
||||
type: 'scatter',
|
||||
symbolSize: 40,
|
||||
data,
|
||||
itemStyle: {
|
||||
color: '#6366f1',
|
||||
opacity: 0.6,
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
};
|
||||
|
||||
// 监听数据变化,重新渲染图表
|
||||
watch(
|
||||
() => overviewData.value,
|
||||
() => {
|
||||
if (overviewData.value) {
|
||||
// 使用 setTimeout 确保 DOM 已更新
|
||||
setTimeout(() => {
|
||||
renderShopBarChart();
|
||||
renderShopScatterChart();
|
||||
}, 100);
|
||||
}
|
||||
},
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
// 监听日期范围变化
|
||||
watch(
|
||||
() => dateRange.value,
|
||||
() => {
|
||||
loadOverviewData();
|
||||
},
|
||||
);
|
||||
|
||||
// 初始化
|
||||
onMounted(async () => {
|
||||
await loadShopCount();
|
||||
await loadOverviewData();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page
|
||||
title="全店铺经营大盘"
|
||||
auto-content-height
|
||||
class="bg-gradient-to-br from-rose-50 via-indigo-50 to-green-50"
|
||||
>
|
||||
<template #description>
|
||||
<div class="font-bold text-indigo-600">
|
||||
Company Dashboard · 共 {{ shopCount }} 家在营店铺
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #extra>
|
||||
<div class="flex items-center gap-4">
|
||||
<!-- 汇总 ROI 和总税后盈亏 -->
|
||||
<div
|
||||
class="flex items-center gap-6 rounded-[2rem] border border-white/60 bg-white/50 px-6 py-3 shadow-[0_10px_30px_rgba(0,0,0,0.02)] backdrop-blur-[20px]"
|
||||
>
|
||||
<div class="text-center">
|
||||
<div class="text-[10px] font-bold uppercase text-slate-400">
|
||||
汇总 ROI
|
||||
</div>
|
||||
<div class="text-lg font-black">
|
||||
{{ overviewData?.totalROI?.toFixed(2) || '-' }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="h-8 w-px bg-slate-200"></div>
|
||||
<div class="text-center">
|
||||
<div class="text-[10px] font-bold uppercase text-slate-400">
|
||||
总税后盈亏
|
||||
</div>
|
||||
<div class="text-lg font-black text-emerald-600">
|
||||
{{
|
||||
overviewData?.totalProfitAfterTax
|
||||
? formatAmount(overviewData.totalProfitAfterTax)
|
||||
: '-'
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 时间选择器组件 -->
|
||||
<div
|
||||
class="flex flex-wrap items-center gap-2 rounded-2xl border border-white/60 bg-white/40 p-1.5 shadow-[0_8px_32px_0_rgba(31,38,135,0.05)] backdrop-blur-[16px]"
|
||||
>
|
||||
<!-- 快速选择按钮 -->
|
||||
<div class="flex rounded-xl bg-white/30 p-1">
|
||||
<Button
|
||||
:type="activeTimeRange === 'today' ? 'primary' : 'text'"
|
||||
size="small"
|
||||
class="!h-auto border-none !px-4 !py-1.5 !text-sm !font-bold"
|
||||
:class="
|
||||
activeTimeRange === 'today'
|
||||
? '!bg-indigo-600 !text-white !shadow-[0_4px_12px_rgba(99,102,241,0.3)]'
|
||||
: ''
|
||||
"
|
||||
@click="switchTimeRange('today')"
|
||||
>
|
||||
今日
|
||||
</Button>
|
||||
<Button
|
||||
:type="activeTimeRange === 'yesterday' ? 'primary' : 'text'"
|
||||
size="small"
|
||||
class="!h-auto border-none !px-4 !py-1.5 !text-sm !font-bold"
|
||||
:class="
|
||||
activeTimeRange === 'yesterday'
|
||||
? '!bg-indigo-600 !text-white !shadow-[0_4px_12px_rgba(99,102,241,0.3)]'
|
||||
: ''
|
||||
"
|
||||
@click="switchTimeRange('yesterday')"
|
||||
>
|
||||
昨日
|
||||
</Button>
|
||||
<Button
|
||||
:type="activeTimeRange === '7days' ? 'primary' : 'text'"
|
||||
size="small"
|
||||
class="!h-auto border-none !px-4 !py-1.5 !text-sm !font-bold"
|
||||
:class="
|
||||
activeTimeRange === '7days'
|
||||
? '!bg-indigo-600 !text-white !shadow-[0_4px_12px_rgba(99,102,241,0.3)]'
|
||||
: ''
|
||||
"
|
||||
@click="switchTimeRange('7days')"
|
||||
>
|
||||
近7日
|
||||
</Button>
|
||||
<Button
|
||||
:type="activeTimeRange === '30days' ? 'primary' : 'text'"
|
||||
size="small"
|
||||
class="!h-auto border-none !px-4 !py-1.5 !text-sm !font-bold"
|
||||
:class="
|
||||
activeTimeRange === '30days'
|
||||
? '!bg-indigo-600 !text-white !shadow-[0_4px_12px_rgba(99,102,241,0.3)]'
|
||||
: ''
|
||||
"
|
||||
@click="switchTimeRange('30days')"
|
||||
>
|
||||
近30日
|
||||
</Button>
|
||||
</div>
|
||||
<!-- 分隔线 -->
|
||||
<div class="mx-1 h-6 w-px bg-slate-300"></div>
|
||||
<!-- 自定义时间 -->
|
||||
<div
|
||||
class="flex items-center gap-2 rounded-xl bg-white/30 px-3 py-1.5"
|
||||
>
|
||||
<span class="text-[10px] font-bold uppercase text-slate-400">
|
||||
自定义
|
||||
</span>
|
||||
<DatePicker.RangePicker
|
||||
v-model:value="customDateRange"
|
||||
size="small"
|
||||
format="YYYY-MM-DD"
|
||||
:allow-clear="false"
|
||||
class="!border-none !bg-transparent"
|
||||
:class="
|
||||
activeTimeRange === 'custom'
|
||||
? '[&_.ant-picker-input>input]:!font-bold [&_.ant-picker-input>input]:!text-indigo-600'
|
||||
: ''
|
||||
"
|
||||
@change="handleCustomDateRangeChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<Spin :spinning="loading">
|
||||
<div class="mx-auto max-w-[1600px] space-y-8 p-6">
|
||||
<!-- 汇总卡片 -->
|
||||
<div class="grid grid-cols-1 gap-6 md:grid-cols-4">
|
||||
<!-- 全店总销售额 -->
|
||||
<div
|
||||
class="rounded-[2rem] border border-white/60 bg-white/50 bg-gradient-to-br from-indigo-500/10 to-transparent p-8 shadow-[0_10px_30px_rgba(0,0,0,0.02)] backdrop-blur-[20px]"
|
||||
>
|
||||
<div class="text-sm font-bold text-slate-500">全店总销售额</div>
|
||||
<div class="mt-1 text-3xl font-black">
|
||||
{{
|
||||
overviewData?.totalSalesAmount
|
||||
? formatAmount(overviewData.totalSalesAmount)
|
||||
: '-'
|
||||
}}
|
||||
</div>
|
||||
<div
|
||||
v-if="overviewData?.monthOverMonthGrowth !== undefined"
|
||||
class="mt-4 w-fit rounded-lg bg-emerald-50 px-2 py-1 text-xs font-bold text-emerald-500"
|
||||
>
|
||||
{{ formatPercent(overviewData.monthOverMonthGrowth) }} 较上月同期
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 全店总单量 -->
|
||||
<div
|
||||
class="rounded-[2rem] border border-white/60 bg-white/50 p-8 shadow-[0_10px_30px_rgba(0,0,0,0.02)] backdrop-blur-[20px]"
|
||||
>
|
||||
<div class="text-sm font-bold text-slate-500">全店总单量</div>
|
||||
<div class="mt-1 text-3xl font-black">
|
||||
{{
|
||||
overviewData?.totalOrderCount?.toLocaleString('zh-CN') || '-'
|
||||
}}
|
||||
</div>
|
||||
<div class="mt-4 text-xs font-bold italic text-slate-400">
|
||||
目标达成率 92%
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 总推广费支出 -->
|
||||
<div
|
||||
class="rounded-[2rem] border border-white/60 bg-white/50 p-8 shadow-[0_10px_30px_rgba(0,0,0,0.02)] backdrop-blur-[20px]"
|
||||
>
|
||||
<div class="text-sm font-bold text-slate-500">总推广费支出</div>
|
||||
<div class="mt-1 text-3xl font-black">
|
||||
{{
|
||||
overviewData?.totalPromotionFee
|
||||
? formatAmount(overviewData.totalPromotionFee)
|
||||
: '-'
|
||||
}}
|
||||
</div>
|
||||
<div class="mt-4 text-xs font-bold text-indigo-400">
|
||||
平均费比:
|
||||
{{
|
||||
overviewData?.averageFeeRatio
|
||||
? `${overviewData.averageFeeRatio.toFixed(1)}%`
|
||||
: '-'
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 全店总净利 -->
|
||||
<div
|
||||
class="rounded-[2rem] border border-white/60 bg-white/50 bg-gradient-to-br from-emerald-500/10 to-transparent p-8 shadow-[0_10px_30px_rgba(0,0,0,0.02)] backdrop-blur-[20px]"
|
||||
>
|
||||
<div class="text-sm font-bold text-slate-500">
|
||||
全店总净利 (税后)
|
||||
</div>
|
||||
<div class="mt-1 text-3xl font-black text-emerald-600">
|
||||
{{
|
||||
overviewData?.totalNetProfitAfterTax
|
||||
? formatAmount(overviewData.totalNetProfitAfterTax)
|
||||
: '-'
|
||||
}}
|
||||
</div>
|
||||
<div class="mt-4 text-xs font-bold text-slate-400">
|
||||
扣除总税额:
|
||||
{{
|
||||
overviewData?.totalTaxAmount
|
||||
? formatAmount(overviewData.totalTaxAmount)
|
||||
: '-'
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 各店对比分析 -->
|
||||
<div class="grid grid-cols-1 gap-8 lg:grid-cols-2">
|
||||
<!-- 店铺销售占比排行 -->
|
||||
<div
|
||||
class="rounded-[2rem] border border-white/60 bg-white/50 p-8 shadow-[0_10px_30px_rgba(0,0,0,0.02)] backdrop-blur-[20px]"
|
||||
>
|
||||
<h3 class="mb-6 text-xl font-bold">各店铺销售占比排行</h3>
|
||||
<div class="h-[400px]">
|
||||
<EchartsUI ref="barChartRef" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 店铺效率象限 -->
|
||||
<div
|
||||
class="rounded-[2rem] border border-white/60 bg-white/50 p-8 shadow-[0_10px_30px_rgba(0,0,0,0.02)] backdrop-blur-[20px]"
|
||||
>
|
||||
<h3 class="mb-6 text-xl font-bold">店铺效率象限 (ROI vs 净利)</h3>
|
||||
<div class="h-[400px]">
|
||||
<EchartsUI ref="scatterChartRef" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 店铺多维度对比表 -->
|
||||
<div
|
||||
class="overflow-hidden rounded-[2rem] border border-white/60 bg-white/50 shadow-[0_10px_30px_rgba(0,0,0,0.02)] backdrop-blur-[20px]"
|
||||
>
|
||||
<div class="flex items-center justify-between p-8">
|
||||
<h3 class="text-xl font-bold">多店铺数据横向对比</h3>
|
||||
</div>
|
||||
<div class="overflow-x-auto px-4 pb-6">
|
||||
<table class="w-full border-collapse whitespace-nowrap text-left">
|
||||
<thead
|
||||
class="border-b border-white/40 text-[11px] uppercase text-slate-400"
|
||||
>
|
||||
<tr>
|
||||
<th class="p-4 font-black">店铺名称</th>
|
||||
<th class="p-4 font-black">销售额</th>
|
||||
<th class="p-4 font-black text-indigo-600">ROI</th>
|
||||
<th class="p-4 font-black text-red-400">退款/刷单费</th>
|
||||
<th class="p-4 font-black">推广费总和</th>
|
||||
<th class="p-4 font-black text-emerald-600">税后盈亏</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="text-sm">
|
||||
<tr
|
||||
v-for="shop in overviewData?.shopComparisons"
|
||||
:key="shop.shopId"
|
||||
class="border-t border-white/20 transition hover:bg-white/40"
|
||||
>
|
||||
<td class="p-4 font-bold">{{ shop.shopName }}</td>
|
||||
<td class="p-4">
|
||||
{{ formatAmountFull(shop.salesAmount) }}
|
||||
</td>
|
||||
<td class="p-4 font-black text-indigo-600">
|
||||
{{ shop.roi?.toFixed(2) || '-' }}
|
||||
</td>
|
||||
<td class="p-4 text-red-400">
|
||||
{{ formatAmountFull(shop.refundAmount || 0) }} /
|
||||
{{ formatAmountFull(shop.brushFee || 0) }}
|
||||
</td>
|
||||
<td class="p-4">
|
||||
{{
|
||||
shop.totalPromotionFee
|
||||
? formatAmountFull(shop.totalPromotionFee)
|
||||
: '-'
|
||||
}}
|
||||
</td>
|
||||
<td class="p-4 font-black text-emerald-600">
|
||||
{{
|
||||
shop.profitAfterTax
|
||||
? formatAmountFull(shop.profitAfterTax)
|
||||
: '-'
|
||||
}}
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="!overviewData?.shopComparisons?.length">
|
||||
<td colspan="6" class="p-8 text-center text-gray-400">
|
||||
暂无数据
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Spin>
|
||||
</Page>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* 自定义样式 */
|
||||
</style>
|
||||
+7
-7
@@ -41,7 +41,7 @@ const currentRecord = ref<null | OrderStatusVO.Info>(null);
|
||||
const formData = ref<Partial<OrderStatusDTO.Create>>({
|
||||
statusName: '',
|
||||
description: '',
|
||||
isDefaultStat: 1,
|
||||
autoStatistics: 1,
|
||||
sortOrder: 0,
|
||||
});
|
||||
|
||||
@@ -66,13 +66,13 @@ function open(edit: boolean, record?: OrderStatusVO.Info) {
|
||||
? {
|
||||
statusName: record.statusName,
|
||||
description: record.description || '',
|
||||
isDefaultStat: record.isDefaultStat,
|
||||
autoStatistics: record.autoStatistics,
|
||||
sortOrder: record.sortOrder || 0,
|
||||
}
|
||||
: {
|
||||
statusName: '',
|
||||
description: '',
|
||||
isDefaultStat: 1,
|
||||
autoStatistics: 1,
|
||||
sortOrder: 0,
|
||||
};
|
||||
}
|
||||
@@ -95,7 +95,7 @@ async function handleSubmit() {
|
||||
const updateData: OrderStatusDTO.Update = {
|
||||
statusName: formData.value.statusName!,
|
||||
description: formData.value.description,
|
||||
isDefaultStat: formData.value.isDefaultStat!,
|
||||
autoStatistics: formData.value.autoStatistics!,
|
||||
sortOrder: formData.value.sortOrder,
|
||||
};
|
||||
await updateOrderStatusApi(currentRecord.value.id, updateData);
|
||||
@@ -105,7 +105,7 @@ async function handleSubmit() {
|
||||
const createData: OrderStatusDTO.Create = {
|
||||
statusName: formData.value.statusName!,
|
||||
description: formData.value.description,
|
||||
isDefaultStat: formData.value.isDefaultStat!,
|
||||
autoStatistics: formData.value.autoStatistics!,
|
||||
sortOrder: formData.value.sortOrder,
|
||||
};
|
||||
await createOrderStatusApi(createData);
|
||||
@@ -176,9 +176,9 @@ defineExpose({
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="默认参与统计" name="isDefaultStat">
|
||||
<Form.Item label="自动统计" name="autoStatistics">
|
||||
<Switch
|
||||
v-model:checked="formData.isDefaultStat"
|
||||
v-model:checked="formData.autoStatistics"
|
||||
:checked-value="1"
|
||||
:un-checked-value="0"
|
||||
checked-children="参与"
|
||||
|
||||
+12
-12
@@ -52,9 +52,9 @@ const gridOptions: VxeGridProps<any> = {
|
||||
minWidth: 'auto',
|
||||
},
|
||||
{
|
||||
title: '是否默认参与统计',
|
||||
title: '自动统计',
|
||||
minWidth: 'auto',
|
||||
slots: { default: 'isDefaultStat' },
|
||||
slots: { default: 'autoStatistics' },
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
@@ -128,15 +128,15 @@ const formOptions = computed(() => ({
|
||||
{
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
placeholder: '请选择是否参与统计',
|
||||
placeholder: '请选择是否自动统计',
|
||||
options: [
|
||||
{ label: '参与默认统计', value: 1 },
|
||||
{ label: '不参默认与统计', value: 0 },
|
||||
{ label: '参与自动统计', value: 1 },
|
||||
{ label: '不参与自动统计', value: 0 },
|
||||
],
|
||||
allowClear: true,
|
||||
},
|
||||
fieldName: 'isDefaultStat',
|
||||
label: '是否参与默认统计',
|
||||
fieldName: 'autoStatistics',
|
||||
label: '自动统计',
|
||||
},
|
||||
],
|
||||
showDefaultActions: true,
|
||||
@@ -191,7 +191,7 @@ function handleModalSuccess() {
|
||||
<Page title="订单状态配置" auto-content-height>
|
||||
<template #description>
|
||||
<div class="text-foreground/80 mt-2">
|
||||
管理订单状态类型,包括状态名称、描述和是否默认参与统计
|
||||
管理订单状态类型,包括状态名称、描述和自动统计
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -207,10 +207,10 @@ function handleModalSuccess() {
|
||||
</Space>
|
||||
</template>
|
||||
|
||||
<!-- 是否默认参与统计列 -->
|
||||
<template #isDefaultStat="{ row }: { row: OrderStatusVO.Info }">
|
||||
<Tag :color="row.isDefaultStat === 1 ? 'green' : 'default'">
|
||||
{{ row.isDefaultStat === 1 ? '参与统计' : '不参与统计' }}
|
||||
<!-- 自动统计列 -->
|
||||
<template #autoStatistics="{ row }: { row: OrderStatusVO.Info }">
|
||||
<Tag :color="row.autoStatistics === 1 ? 'green' : 'default'">
|
||||
{{ row.autoStatistics === 1 ? '参与统计' : '不参与统计' }}
|
||||
</Tag>
|
||||
</template>
|
||||
|
||||
|
||||
+22
-37
@@ -163,10 +163,8 @@ const canGoToNextStep = computed(() => {
|
||||
});
|
||||
}
|
||||
if (currentStep.value === 2) {
|
||||
// 订单状态映射步骤:所有唯一的订单状态值都必须映射
|
||||
return uniqueStatusValues.value.every(
|
||||
(status) => statusMappings.value[status] !== undefined,
|
||||
);
|
||||
// 订单状态映射步骤:允许不映射,所以总是返回 true
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
@@ -565,13 +563,13 @@ async function handleConfirmSaveStatusTemplate() {
|
||||
return;
|
||||
}
|
||||
|
||||
// 验证所有订单状态是否都已映射
|
||||
const unMappedStatuses = uniqueStatusValues.value.filter(
|
||||
(status) => statusMappings.value[status] === undefined,
|
||||
// 验证是否有映射数据(至少需要一个映射才能保存模板)
|
||||
const mappedStatuses = uniqueStatusValues.value.filter(
|
||||
(status) => statusMappings.value[status] !== undefined,
|
||||
);
|
||||
|
||||
if (unMappedStatuses.length > 0) {
|
||||
message.warning(`请先映射所有订单状态:${unMappedStatuses.join('、')}`);
|
||||
if (mappedStatuses.length === 0) {
|
||||
message.warning('请至少映射一个订单状态');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -579,13 +577,13 @@ async function handleConfirmSaveStatusTemplate() {
|
||||
savingStatusTemplate.value = true;
|
||||
saveStatusTemplateModalApi.lock();
|
||||
|
||||
// 构建映射数据(已验证所有状态都已映射,所以不会有 undefined)
|
||||
const mappingItems: StatusMappingItem[] = uniqueStatusValues.value.map(
|
||||
(status) => ({
|
||||
// 构建映射数据(只包含已映射的状态)
|
||||
const mappingItems: StatusMappingItem[] = uniqueStatusValues.value
|
||||
.filter((status) => statusMappings.value[status] !== undefined)
|
||||
.map((status) => ({
|
||||
csvStatus: status,
|
||||
mappedStatusId: statusMappings.value[status]!,
|
||||
}),
|
||||
);
|
||||
}));
|
||||
|
||||
const mappingJson = JSON.stringify(mappingItems);
|
||||
|
||||
@@ -712,14 +710,7 @@ const handleNext = () => {
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
// 验证所有订单状态是否都已映射
|
||||
const unMappedStatuses = uniqueStatusValues.value.filter(
|
||||
(status) => statusMappings.value[status] === undefined,
|
||||
);
|
||||
if (unMappedStatuses.length > 0) {
|
||||
message.warning(`请先映射所有订单状态:${unMappedStatuses.join('、')}`);
|
||||
return;
|
||||
}
|
||||
// 订单状态映射是可选的,可以直接进入下一步
|
||||
currentStep.value = 3;
|
||||
|
||||
break;
|
||||
@@ -781,9 +772,10 @@ const handleCreateTask = async () => {
|
||||
required: m.fieldDef.required,
|
||||
}));
|
||||
|
||||
// 构建订单状态映射 JSON(已验证所有状态都已映射,所以不会有 undefined)
|
||||
const statusMappingItems: StatusMappingItem[] =
|
||||
uniqueStatusValues.value.map((status) => ({
|
||||
// 构建订单状态映射 JSON(只包含已映射的状态)
|
||||
const statusMappingItems: StatusMappingItem[] = uniqueStatusValues.value
|
||||
.filter((status) => statusMappings.value[status] !== undefined)
|
||||
.map((status) => ({
|
||||
csvStatus: status,
|
||||
mappedStatusId: statusMappings.value[status]!,
|
||||
}));
|
||||
@@ -886,7 +878,7 @@ const shopOptions = computed(() => {
|
||||
|
||||
<template>
|
||||
<Modal title="创建导入任务" :loading="loading">
|
||||
<div class="space-y-6">
|
||||
<div class="space-y-3">
|
||||
<!-- 步骤条 -->
|
||||
<Steps :current="currentStep">
|
||||
<Steps.Step title="选择店铺" />
|
||||
@@ -1014,7 +1006,7 @@ const shopOptions = computed(() => {
|
||||
<div v-if="currentStep === 2" class="py-4">
|
||||
<div class="mb-4 flex items-center justify-between">
|
||||
<div class="text-sm text-gray-600">
|
||||
请为每个订单状态值映射到对应的系统订单状态,所有状态必须映射
|
||||
请为每个订单状态值映射到对应的系统订单状态(可选,可不映射)
|
||||
</div>
|
||||
<div class="flex items-center space-x-2">
|
||||
<Select
|
||||
@@ -1065,10 +1057,6 @@ const shopOptions = computed(() => {
|
||||
v-for="statusValue in uniqueStatusValues"
|
||||
:key="statusValue"
|
||||
class="flex items-center space-x-4 rounded border p-3"
|
||||
:class="{
|
||||
'border-red-300 bg-red-50':
|
||||
statusMappings[statusValue] === undefined,
|
||||
}"
|
||||
>
|
||||
<div class="flex-1">
|
||||
<div class="font-medium">{{ statusValue }}</div>
|
||||
@@ -1076,9 +1064,10 @@ const shopOptions = computed(() => {
|
||||
</div>
|
||||
<Select
|
||||
v-model:value="statusMappings[statusValue]"
|
||||
placeholder="请选择订单状态"
|
||||
placeholder="请选择订单状态(可选)"
|
||||
class="w-[200px]"
|
||||
show-search
|
||||
allow-clear
|
||||
:loading="orderStatusLoading"
|
||||
:options="
|
||||
orderStatusList.map((status) => ({
|
||||
@@ -1143,7 +1132,7 @@ const shopOptions = computed(() => {
|
||||
</div>
|
||||
|
||||
<!-- 操作按钮 -->
|
||||
<div class="flex justify-between border-t pt-4">
|
||||
<div class="flex justify-between">
|
||||
<Button @click="handleCancel">取消</Button>
|
||||
<div class="space-x-2">
|
||||
<Button v-if="currentStep > 0" @click="handlePrev">上一步</Button>
|
||||
@@ -1198,7 +1187,3 @@ const shopOptions = computed(() => {
|
||||
</SaveStatusTemplateModal>
|
||||
</Modal>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* 自定义样式 */
|
||||
</style>
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue';
|
||||
|
||||
import { Button, message } from 'ant-design-vue';
|
||||
|
||||
@@ -20,6 +18,8 @@ const csvData = ref<any[]>([]);
|
||||
const csvHeaders = ref<string[]>([]);
|
||||
const importLoading = ref(false);
|
||||
const currentFile = ref<File | null>(null);
|
||||
const tableContainerRef = ref<HTMLElement>();
|
||||
const tableHeight = ref<number>(600);
|
||||
|
||||
// 动态生成Grid列配置
|
||||
const gridColumns = computed(() => {
|
||||
@@ -53,7 +53,7 @@ const gridColumns = computed(() => {
|
||||
// VbenVxeGrid 表格配置
|
||||
const gridOptions: VxeGridProps<any> = {
|
||||
columns: [],
|
||||
height: 'auto',
|
||||
height: tableHeight.value,
|
||||
border: true,
|
||||
stripe: true,
|
||||
highlightHoverRow: true,
|
||||
@@ -122,11 +122,23 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
const updateTable = () => {
|
||||
gridApi.setGridOptions({
|
||||
columns: gridColumns.value,
|
||||
height: tableHeight.value,
|
||||
});
|
||||
// 触发重新加载数据
|
||||
gridApi.reload();
|
||||
};
|
||||
|
||||
// 监听表格高度变化,更新表格配置
|
||||
watch(
|
||||
tableHeight,
|
||||
(newHeight) => {
|
||||
gridApi.setGridOptions({
|
||||
height: newHeight,
|
||||
});
|
||||
},
|
||||
{ immediate: false },
|
||||
);
|
||||
|
||||
// 处理文件上传
|
||||
const handleFileUpload = async (file: File) => {
|
||||
importLoading.value = true;
|
||||
@@ -148,6 +160,10 @@ const handleFileUpload = async (file: File) => {
|
||||
|
||||
// 更新表格
|
||||
updateTable();
|
||||
// 重新计算表格高度
|
||||
nextTick(() => {
|
||||
calculateTableHeight();
|
||||
});
|
||||
|
||||
message.success(`成功解析 ${result.data.length} 条数据`);
|
||||
} catch (error: any) {
|
||||
@@ -183,45 +199,213 @@ const handleClearData = () => {
|
||||
updateTable();
|
||||
message.success('已清空数据');
|
||||
};
|
||||
|
||||
// 计算表格高度
|
||||
const calculateTableHeight = () => {
|
||||
nextTick(() => {
|
||||
if (tableContainerRef.value) {
|
||||
const rect = tableContainerRef.value.getBoundingClientRect();
|
||||
// 减去 padding (1.5rem * 2 = 3rem = 48px) 和其他元素的高度
|
||||
const headerHeight = 100; // 估算表头高度
|
||||
const padding = 48; // 1.5rem * 2
|
||||
const availableHeight = rect.height - padding - headerHeight;
|
||||
tableHeight.value = Math.max(400, availableHeight);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 监听窗口大小变化
|
||||
let resizeObserver: null | ResizeObserver = null;
|
||||
|
||||
onMounted(() => {
|
||||
calculateTableHeight();
|
||||
if (tableContainerRef.value) {
|
||||
resizeObserver = new ResizeObserver(() => {
|
||||
calculateTableHeight();
|
||||
});
|
||||
resizeObserver.observe(tableContainerRef.value);
|
||||
}
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
if (resizeObserver) {
|
||||
resizeObserver.disconnect();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<!-- 顶部栏 -->
|
||||
<template #extra>
|
||||
<div class="flex items-center space-x-2">
|
||||
<Button
|
||||
:disabled="csvData.length === 0"
|
||||
@click="handleClearData"
|
||||
>
|
||||
清空数据
|
||||
</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
:disabled="csvHeaders.length === 0"
|
||||
@click="handleCreateImportTask"
|
||||
>
|
||||
创建导入任务
|
||||
</Button>
|
||||
<div
|
||||
class="h-full overflow-hidden bg-gradient-to-br from-indigo-100 via-pink-100 to-slate-100 p-8"
|
||||
>
|
||||
<div class="mx-auto flex h-full w-[60%] flex-col overflow-hidden">
|
||||
<!-- 头部标题 -->
|
||||
<div class="mb-12 shrink-0 text-center">
|
||||
<h1 class="mb-2 text-4xl font-black tracking-tight text-slate-800">
|
||||
订单导入中心
|
||||
</h1>
|
||||
<p class="text-base font-medium text-slate-500">
|
||||
请上传 CSV 格式的订单原始数据进行分析
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 主体内容区域 -->
|
||||
<div
|
||||
v-if="csvData.length === 0"
|
||||
class="flex h-full items-center justify-center"
|
||||
>
|
||||
<FileUploadArea
|
||||
:loading="importLoading"
|
||||
@file-selected="handleFileUpload"
|
||||
/>
|
||||
<!-- 主体内容区域 -->
|
||||
<div
|
||||
v-if="csvData.length === 0"
|
||||
class="flex min-h-0 flex-1 flex-col overflow-hidden"
|
||||
>
|
||||
<div
|
||||
class="mb-8 grid shrink-0 grid-cols-1 gap-6 lg:grid-cols-[2fr_1fr]"
|
||||
>
|
||||
<!-- 左侧:导入区域 -->
|
||||
<div
|
||||
class="relative flex min-h-[400px] flex-col items-center justify-center overflow-hidden rounded-[2rem] border border-white/50 bg-white/45 p-8 shadow-[0_25px_50px_-12px_rgba(0,0,0,0.1)] backdrop-blur-2xl"
|
||||
>
|
||||
<div
|
||||
class="absolute -right-10 -top-10 h-32 w-32 rounded-full bg-indigo-400 opacity-10 blur-3xl"
|
||||
></div>
|
||||
<div
|
||||
class=":deep(.ant-spin-nested-loading) :deep(.ant-spin-container) w-full"
|
||||
>
|
||||
<FileUploadArea
|
||||
:loading="importLoading"
|
||||
@file-selected="handleFileUpload"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 右侧:指引与历史 -->
|
||||
<div class="flex flex-col gap-6">
|
||||
<!-- 操作指南卡片 -->
|
||||
<div
|
||||
class="relative flex flex-col gap-4 overflow-hidden rounded-[2rem] border border-white/50 bg-white/45 p-6 shadow-[0_25px_50px_-12px_rgba(0,0,0,0.1)] backdrop-blur-2xl"
|
||||
>
|
||||
<h3 class="m-0 text-base font-bold text-slate-800">操作指南</h3>
|
||||
<div class="flex flex-col gap-4">
|
||||
<div class="flex items-start gap-3">
|
||||
<div
|
||||
class="flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-indigo-600 text-xs font-bold text-white"
|
||||
>
|
||||
1
|
||||
</div>
|
||||
<p
|
||||
class="m-0 text-xs font-medium leading-relaxed text-slate-500"
|
||||
>
|
||||
从电商后台导出【订单详情】CSV文件
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex items-start gap-3">
|
||||
<div
|
||||
class="flex h-6 w-6 shrink-0 items-center justify-center rounded-full border border-indigo-100 bg-white text-xs font-bold text-indigo-600"
|
||||
>
|
||||
2
|
||||
</div>
|
||||
<p
|
||||
class="m-0 text-xs font-medium leading-relaxed text-slate-500"
|
||||
>
|
||||
检查文件是否包含【订单号】与【金额】列
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex items-start gap-3">
|
||||
<div
|
||||
class="flex h-6 w-6 shrink-0 items-center justify-center rounded-full border border-indigo-100 bg-white text-xs font-bold text-indigo-600"
|
||||
>
|
||||
3
|
||||
</div>
|
||||
<p
|
||||
class="m-0 text-xs font-medium leading-relaxed text-slate-500"
|
||||
>
|
||||
上传成功后,系统将自动解析并显示数据
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 底部全局按钮 -->
|
||||
<div class="flex justify-center gap-4 pt-4">
|
||||
<Button :disabled="csvData.length === 0" @click="handleClearData">
|
||||
清空当前选择
|
||||
</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
:disabled="csvHeaders.length === 0"
|
||||
@click="handleCreateImportTask"
|
||||
>
|
||||
创建导入任务
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 数据表格区域 -->
|
||||
<div v-else class="flex min-h-0 w-full flex-1 flex-col overflow-hidden">
|
||||
<div
|
||||
class="mb-6 flex shrink-0 flex-wrap items-start justify-between gap-4"
|
||||
>
|
||||
<div class="flex-1">
|
||||
<h2 class="mb-1 text-2xl font-bold text-slate-800">数据预览</h2>
|
||||
<p class="m-0 text-sm text-slate-500">
|
||||
共 {{ csvData.length }} 条数据,请检查数据后创建导入任务
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex gap-2">
|
||||
<Button @click="handleClearData">清空数据</Button>
|
||||
<Button type="primary" @click="handleCreateImportTask">
|
||||
创建导入任务
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
ref="tableContainerRef"
|
||||
class="flex min-h-0 flex-1 flex-col overflow-hidden rounded-[2rem] border border-white/50 bg-white/45 p-6 shadow-[0_25px_50px_-12px_rgba(0,0,0,0.1)] backdrop-blur-2xl"
|
||||
>
|
||||
<Grid />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<CreateImportTaskModal ref="createImportTaskModalRef" />
|
||||
</div>
|
||||
|
||||
<Grid v-else />
|
||||
<CreateImportTaskModal ref="createImportTaskModalRef" />
|
||||
</Page>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* 自定义样式 */
|
||||
/* 上传区域深度选择器样式 */
|
||||
:deep(.ant-spin-nested-loading),
|
||||
:deep(.ant-spin-container) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
:deep(.border-dashed) {
|
||||
background: transparent;
|
||||
border: 2px dashed rgba(99, 102, 241, 0.3);
|
||||
border-radius: 2rem;
|
||||
padding: 3rem;
|
||||
transition: all 0.3s ease;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
:deep(.border-dashed:hover) {
|
||||
border-color: #6366f1;
|
||||
background: rgba(99, 102, 241, 0.05);
|
||||
transform: scale(1.01);
|
||||
}
|
||||
|
||||
:deep(.border-blue-500) {
|
||||
border-color: #6366f1 !important;
|
||||
background: rgba(99, 102, 241, 0.05) !important;
|
||||
}
|
||||
|
||||
/* VxeGrid 表格样式 */
|
||||
:deep(.vxe-grid) {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
:deep(.vxe-grid--body-wrapper) {
|
||||
flex: 1;
|
||||
overflow: auto;
|
||||
}
|
||||
</style>
|
||||
|
||||
+66
-13
@@ -68,7 +68,10 @@ const formData = ref<Partial<OrderDTO.Create>>({
|
||||
linkSpecName: '',
|
||||
quantity: 1,
|
||||
unitPrice: 0,
|
||||
costPrice: 0,
|
||||
productCost: 0,
|
||||
shippingCost: 0,
|
||||
otherCost: 0,
|
||||
remark: '',
|
||||
});
|
||||
|
||||
// 下拉选项数据
|
||||
@@ -103,7 +106,7 @@ const rules = {
|
||||
],
|
||||
quantity: [{ required: true, message: '请输入数量', trigger: 'blur' }],
|
||||
unitPrice: [{ required: true, message: '请输入销售单价', trigger: 'blur' }],
|
||||
costPrice: [{ required: true, message: '请输入成本价', trigger: 'blur' }],
|
||||
productCost: [{ required: true, message: '请输入商品成本', trigger: 'blur' }],
|
||||
};
|
||||
|
||||
// 表单引用
|
||||
@@ -212,7 +215,9 @@ function handleProductChange(productId: number | undefined) {
|
||||
formData.value.linkProductName = '';
|
||||
formData.value.productSpecId = undefined;
|
||||
formData.value.linkSpecName = '';
|
||||
formData.value.costPrice = 0;
|
||||
formData.value.productCost = 0;
|
||||
formData.value.shippingCost = 0;
|
||||
formData.value.otherCost = 0;
|
||||
productSpecOptions.value = [];
|
||||
}
|
||||
}
|
||||
@@ -225,11 +230,15 @@ function handleProductSpecChange(specId: number | undefined) {
|
||||
);
|
||||
if (selectedSpec) {
|
||||
formData.value.linkSpecName = selectedSpec.spec.name;
|
||||
formData.value.costPrice = selectedSpec.spec.costPrice;
|
||||
formData.value.productCost = selectedSpec.spec.productCost;
|
||||
formData.value.shippingCost = selectedSpec.spec.shippingCost || 0;
|
||||
formData.value.otherCost = selectedSpec.spec.otherCost || 0;
|
||||
}
|
||||
} else {
|
||||
formData.value.linkSpecName = '';
|
||||
formData.value.costPrice = 0;
|
||||
formData.value.productCost = 0;
|
||||
formData.value.shippingCost = 0;
|
||||
formData.value.otherCost = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,7 +283,10 @@ async function open(edit: boolean, record?: OrderVO.Info) {
|
||||
linkSpecName: record.linkSpecName,
|
||||
quantity: record.quantity,
|
||||
unitPrice: record.unitPrice,
|
||||
costPrice: record.costPrice,
|
||||
productCost: record.productCost,
|
||||
shippingCost: record.shippingCost || 0,
|
||||
otherCost: record.otherCost || 0,
|
||||
remark: record.remark || '',
|
||||
}
|
||||
: {
|
||||
shopId: undefined,
|
||||
@@ -288,7 +300,10 @@ async function open(edit: boolean, record?: OrderVO.Info) {
|
||||
linkSpecName: '',
|
||||
quantity: 1,
|
||||
unitPrice: 0,
|
||||
costPrice: 0,
|
||||
productCost: 0,
|
||||
shippingCost: 0,
|
||||
otherCost: 0,
|
||||
remark: '',
|
||||
};
|
||||
|
||||
// 如果是编辑模式且有商品ID,加载商品和规格选项
|
||||
@@ -319,7 +334,9 @@ async function open(edit: boolean, record?: OrderVO.Info) {
|
||||
spec: {
|
||||
id: record.productSpecId,
|
||||
name: record.linkSpecName || '',
|
||||
costPrice: record.costPrice,
|
||||
productCost: record.productCost,
|
||||
shippingCost: record.shippingCost,
|
||||
otherCost: record.otherCost,
|
||||
} as ProductSpecVO.Info,
|
||||
});
|
||||
}
|
||||
@@ -354,7 +371,10 @@ async function handleSubmit() {
|
||||
linkSpecName: formData.value.linkSpecName,
|
||||
quantity: formData.value.quantity,
|
||||
unitPrice: formData.value.unitPrice,
|
||||
costPrice: formData.value.costPrice,
|
||||
productCost: formData.value.productCost,
|
||||
shippingCost: formData.value.shippingCost,
|
||||
otherCost: formData.value.otherCost,
|
||||
remark: formData.value.remark,
|
||||
};
|
||||
await updateOrderApi(currentRecord.value.id, updateData);
|
||||
message.success('更新订单成功');
|
||||
@@ -372,7 +392,10 @@ async function handleSubmit() {
|
||||
linkSpecName: formData.value.linkSpecName,
|
||||
quantity: formData.value.quantity!,
|
||||
unitPrice: formData.value.unitPrice!,
|
||||
costPrice: formData.value.costPrice!,
|
||||
productCost: formData.value.productCost!,
|
||||
shippingCost: formData.value.shippingCost,
|
||||
otherCost: formData.value.otherCost,
|
||||
remark: formData.value.remark,
|
||||
};
|
||||
await createOrderApi(createData);
|
||||
message.success('创建订单成功');
|
||||
@@ -532,10 +555,10 @@ defineExpose({
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="成本价" name="costPrice">
|
||||
<Form.Item label="商品成本" name="productCost">
|
||||
<InputNumber
|
||||
v-model:value="formData.costPrice"
|
||||
placeholder="请输入成本价"
|
||||
v-model:value="formData.productCost"
|
||||
placeholder="请输入商品成本"
|
||||
style="width: 100%"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
@@ -543,6 +566,36 @@ defineExpose({
|
||||
</Form.Item>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<Form.Item label="运费成本" name="shippingCost">
|
||||
<InputNumber
|
||||
v-model:value="formData.shippingCost"
|
||||
placeholder="请输入运费成本"
|
||||
style="width: 100%"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="其他成本" name="otherCost">
|
||||
<InputNumber
|
||||
v-model:value="formData.otherCost"
|
||||
placeholder="请输入其他成本"
|
||||
style="width: 100%"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
/>
|
||||
</Form.Item>
|
||||
</div>
|
||||
|
||||
<Form.Item label="备注" name="remark">
|
||||
<Input.TextArea
|
||||
v-model:value="formData.remark"
|
||||
placeholder="请输入备注"
|
||||
:rows="3"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="实收金额" name="receivedAmount">
|
||||
<InputNumber
|
||||
v-model:value="formData.receivedAmount"
|
||||
|
||||
+54
-16
@@ -51,7 +51,10 @@ const currentSpecId = ref<null | number>(null);
|
||||
const specFormData = ref({
|
||||
name: '',
|
||||
specCode: '',
|
||||
costPrice: 0,
|
||||
productCost: 0,
|
||||
shippingCost: 0,
|
||||
otherCost: 0,
|
||||
remark: '',
|
||||
});
|
||||
|
||||
// 声明模态框 API(稍后赋值)
|
||||
@@ -75,10 +78,11 @@ async function handleSpecSubmit() {
|
||||
specFormModalApi?.setState({ confirmLoading: true });
|
||||
|
||||
if (isEditSpec.value && currentSpecId.value) {
|
||||
await updateProductSpecApi(
|
||||
currentSpecId.value,
|
||||
specFormData.value as ProductSpecDTO.Update,
|
||||
);
|
||||
const updateData: ProductSpecDTO.Update = {
|
||||
id: currentSpecId.value,
|
||||
...specFormData.value,
|
||||
};
|
||||
await updateProductSpecApi(currentSpecId.value, updateData);
|
||||
message.success('更新成功');
|
||||
} else {
|
||||
if (!currentProduct.value) {
|
||||
@@ -149,12 +153,12 @@ const columns = [
|
||||
width: 150,
|
||||
},
|
||||
{
|
||||
title: '成本价',
|
||||
dataIndex: 'costPrice',
|
||||
key: 'costPrice',
|
||||
title: '商品成本',
|
||||
dataIndex: 'productCost',
|
||||
key: 'productCost',
|
||||
width: 120,
|
||||
customRender: ({ record }: { record: ProductSpecVO.Info }) => {
|
||||
return `¥${record.costPrice.toFixed(2)}`;
|
||||
return `¥${record.productCost.toFixed(2)}`;
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -236,7 +240,10 @@ function handleAddSpec() {
|
||||
specFormData.value = {
|
||||
name: '',
|
||||
specCode: '',
|
||||
costPrice: 0,
|
||||
productCost: 0,
|
||||
shippingCost: 0,
|
||||
otherCost: 0,
|
||||
remark: '',
|
||||
};
|
||||
specFormModalApi.setState({ title: '添加规格' });
|
||||
specFormModalApi.open();
|
||||
@@ -249,7 +256,10 @@ function handleEditSpec(record: ProductSpecVO.Info) {
|
||||
specFormData.value = {
|
||||
name: record.name,
|
||||
specCode: record.specCode || '',
|
||||
costPrice: record.costPrice,
|
||||
productCost: record.productCost,
|
||||
shippingCost: record.shippingCost || 0,
|
||||
otherCost: record.otherCost || 0,
|
||||
remark: record.remark || '',
|
||||
};
|
||||
specFormModalApi.setState({ title: '编辑规格' });
|
||||
specFormModalApi.open();
|
||||
@@ -358,18 +368,46 @@ defineExpose({
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label="成本价"
|
||||
name="costPrice"
|
||||
:rules="[{ required: true, message: '请输入成本价' }]"
|
||||
label="商品成本"
|
||||
name="productCost"
|
||||
:rules="[{ required: true, message: '请输入商品成本' }]"
|
||||
>
|
||||
<InputNumber
|
||||
v-model:value="specFormData.costPrice"
|
||||
placeholder="请输入成本价"
|
||||
v-model:value="specFormData.productCost"
|
||||
placeholder="请输入商品成本"
|
||||
style="width: 100%"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="运费成本" name="shippingCost">
|
||||
<InputNumber
|
||||
v-model:value="specFormData.shippingCost"
|
||||
placeholder="请输入运费成本"
|
||||
style="width: 100%"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="其他成本" name="otherCost">
|
||||
<InputNumber
|
||||
v-model:value="specFormData.otherCost"
|
||||
placeholder="请输入其他成本"
|
||||
style="width: 100%"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="备注" name="remark">
|
||||
<Input.TextArea
|
||||
v-model:value="specFormData.remark"
|
||||
placeholder="请输入备注"
|
||||
:rows="3"
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</SpecFormModal>
|
||||
</template>
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>订单导入中心 - 毛玻璃设计</title>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;600;700&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Plus Jakarta Sans', sans-serif;
|
||||
/* 延续统计页的柔和渐变背景 */
|
||||
background: linear-gradient(135deg, #e0e7ff 0%, #fae8ff 50%, #f1f5f9 100%);
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.glass {
|
||||
background: rgba(255, 255, 255, 0.45);
|
||||
backdrop-filter: blur(16px);
|
||||
-webkit-backdrop-filter: blur(16px);
|
||||
border: 1px solid rgba(255, 255, 255, 0.5);
|
||||
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
.drop-zone {
|
||||
border: 2px dashed rgba(99, 102, 241, 0.3);
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
.drop-zone:hover {
|
||||
border-color: #6366f1;
|
||||
background: rgba(99, 102, 241, 0.05);
|
||||
transform: scale(1.01);
|
||||
}
|
||||
.step-circle {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 50%;
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="p-4">
|
||||
|
||||
<div class="max-w-4xl w-full space-y-6">
|
||||
|
||||
<!-- 头部标题 -->
|
||||
<div class="text-center space-y-2 mb-8">
|
||||
<h1 class="text-4xl font-black text-slate-800 tracking-tight">订单导入中心</h1>
|
||||
<p class="text-slate-500 font-medium">请上传 CSV 格式的订单原始数据进行分析</p>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
|
||||
|
||||
<!-- 左侧:导入区域 -->
|
||||
<div class="lg:col-span-2 glass p-8 rounded-[2.5rem] flex flex-col justify-center items-center relative overflow-hidden">
|
||||
<!-- 装饰性光晕 -->
|
||||
<div class="absolute -top-10 -right-10 w-32 h-32 bg-indigo-400 opacity-10 blur-3xl"></div>
|
||||
|
||||
<div class="w-full drop-zone rounded-[2rem] p-12 flex flex-col items-center justify-center space-y-4 cursor-pointer">
|
||||
<div class="w-16 h-16 bg-indigo-100 text-indigo-600 rounded-2xl flex items-center justify-center shadow-inner">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-8 w-8" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12" />
|
||||
</svg>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<p class="text-lg font-bold text-slate-700">拖拽 CSV 文件到此处上传</p>
|
||||
<p class="text-sm text-slate-400 mt-1">支持标准电商平台导出格式,最大 20MB</p>
|
||||
</div>
|
||||
<button class="bg-indigo-600 text-white px-8 py-3 rounded-xl font-bold shadow-lg shadow-indigo-200 hover:bg-indigo-700 transition">
|
||||
选择本地文件
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- 导入选项 -->
|
||||
<div class="w-full mt-8 flex justify-between items-center text-sm">
|
||||
<div class="flex items-center gap-4">
|
||||
<label class="flex items-center gap-2 cursor-pointer">
|
||||
<input type="checkbox" class="rounded text-indigo-600 focus:ring-indigo-500">
|
||||
<span class="text-slate-500 font-medium">自动去重</span>
|
||||
</label>
|
||||
<label class="flex items-center gap-2 cursor-pointer">
|
||||
<input type="checkbox" checked class="rounded text-indigo-600 focus:ring-indigo-500">
|
||||
<span class="text-slate-500 font-medium">覆盖旧数据</span>
|
||||
</label>
|
||||
</div>
|
||||
<a href="#" class="text-indigo-600 font-bold hover:underline">下载导入模板</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 右侧:指引与历史 -->
|
||||
<div class="space-y-6">
|
||||
<!-- 步骤卡片 -->
|
||||
<div class="glass p-6 rounded-[2rem] space-y-4">
|
||||
<h3 class="font-bold text-slate-800 flex items-center gap-2">
|
||||
操作指南
|
||||
</h3>
|
||||
<div class="space-y-4">
|
||||
<div class="flex gap-3">
|
||||
<div class="step-circle bg-indigo-600 text-white">1</div>
|
||||
<p class="text-xs text-slate-500 leading-relaxed font-medium">从电商后台导出【订单详情】CSV文件</p>
|
||||
</div>
|
||||
<div class="flex gap-3">
|
||||
<div class="step-circle bg-white text-indigo-600 border border-indigo-100">2</div>
|
||||
<p class="text-xs text-slate-500 leading-relaxed font-medium">检查文件是否包含【订单号】与【金额】列</p>
|
||||
</div>
|
||||
<div class="flex gap-3">
|
||||
<div class="step-circle bg-white text-indigo-600 border border-indigo-100">3</div>
|
||||
<p class="text-xs text-slate-500 leading-relaxed font-medium">上传成功后,系统将自动跳转至统计页面</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 最近上传历史 -->
|
||||
<div class="glass p-6 rounded-[2rem] space-y-4">
|
||||
<div class="flex justify-between items-center">
|
||||
<h3 class="font-bold text-slate-800">最近导入</h3>
|
||||
<span class="text-[10px] font-bold text-indigo-500">查看全部</span>
|
||||
</div>
|
||||
<div class="space-y-3">
|
||||
<div class="flex items-center justify-between p-3 rounded-2xl bg-white/30 text-xs">
|
||||
<div>
|
||||
<p class="font-bold text-slate-700 italic">20231027_orders.csv</p>
|
||||
<p class="text-[10px] text-slate-400">10:20 · 1,280 行</p>
|
||||
</div>
|
||||
<span class="text-emerald-500 font-black">完成</span>
|
||||
</div>
|
||||
<div class="flex items-center justify-between p-3 rounded-2xl bg-white/30 text-xs">
|
||||
<div>
|
||||
<p class="font-bold text-slate-700 italic">temp_data_02.csv</p>
|
||||
<p class="text-[10px] text-slate-400">昨天 · 450 行</p>
|
||||
</div>
|
||||
<span class="text-slate-400 font-black">失效</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 底部全局按钮 -->
|
||||
<div class="flex justify-center gap-4 pt-4">
|
||||
<button class="glass px-10 py-3 rounded-2xl font-bold text-slate-500 hover:bg-white/60 transition">
|
||||
清空当前选择
|
||||
</button>
|
||||
<button class="bg-slate-900 text-white px-10 py-3 rounded-2xl font-bold shadow-2xl hover:bg-slate-800 transition">
|
||||
开始解析并创建任务
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,178 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>创建导入任务 - 毛玻璃组件</title>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;600;700&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Plus Jakarta Sans', sans-serif;
|
||||
background: linear-gradient(135deg, #e0e7ff 0%, #fae8ff 50%, #f1f5f9 100%);
|
||||
min-height: 100vh;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
}
|
||||
/* 延续之前的 Glass 核心类 */
|
||||
.glass {
|
||||
background: rgba(255, 255, 255, 0.45);
|
||||
backdrop-filter: blur(20px);
|
||||
-webkit-backdrop-filter: blur(20px);
|
||||
border: 1px solid rgba(255, 255, 255, 0.5);
|
||||
}
|
||||
/* 内部映射卡片 */
|
||||
.glass-inner-card {
|
||||
background: rgba(255, 255, 255, 0.3);
|
||||
border: 1px solid rgba(255, 255, 255, 0.4);
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
.glass-inner-card:hover { background: rgba(255, 255, 255, 0.5); transform: translateY(-2px); }
|
||||
|
||||
/* 步进器线条动画 */
|
||||
.step-line { height: 2px; background: rgba(99, 102, 241, 0.1); flex-grow: 1; margin: 0 1rem; position: relative; overflow: hidden; }
|
||||
.step-line-active::after { content: ""; position: absolute; left: 0; top: 0; height: 100%; width: 100%; background: #6366f1; animation: slide 1s ease-in-out; }
|
||||
|
||||
@keyframes slide { from { width: 0; } to { width: 100%; } }
|
||||
|
||||
.custom-scroll::-webkit-scrollbar { width: 4px; }
|
||||
.custom-scroll::-webkit-scrollbar-thumb { background: rgba(99, 102, 241, 0.2); border-radius: 10px; }
|
||||
</style>
|
||||
</head>
|
||||
<body class="p-4">
|
||||
|
||||
<!-- 弹窗主体容器 -->
|
||||
<div class="max-w-4xl w-full glass rounded-[3rem] shadow-2xl overflow-hidden flex flex-col max-h-[90vh]">
|
||||
|
||||
<!-- Header -->
|
||||
<div class="px-10 py-8 border-b border-white/40 flex justify-between items-center">
|
||||
<div>
|
||||
<h2 class="text-2xl font-black text-slate-800 tracking-tight">创建导入任务</h2>
|
||||
<p class="text-xs text-slate-500 font-bold mt-1 uppercase tracking-widest">Import Task Wizard</p>
|
||||
</div>
|
||||
<button class="w-10 h-10 glass rounded-full flex items-center justify-center text-slate-400 hover:text-slate-600 transition">✕</button>
|
||||
</div>
|
||||
|
||||
<!-- 步进器 Stepper -->
|
||||
<div class="px-12 py-10">
|
||||
<div class="flex items-center">
|
||||
<!-- Step 1: Done -->
|
||||
<div class="flex items-center">
|
||||
<div class="w-10 h-10 bg-indigo-100 text-indigo-600 rounded-2xl flex items-center justify-center font-bold shadow-inner">✓</div>
|
||||
<span class="ml-3 text-xs font-black text-indigo-600">选择店铺</span>
|
||||
</div>
|
||||
<div class="step-line step-line-active"></div>
|
||||
<!-- Step 2: Active -->
|
||||
<div class="flex items-center">
|
||||
<div class="w-10 h-10 bg-indigo-600 text-white rounded-2xl flex items-center justify-center font-bold shadow-lg shadow-indigo-200">2</div>
|
||||
<span class="ml-3 text-xs font-black text-slate-700">字段映射</span>
|
||||
</div>
|
||||
<div class="step-line"></div>
|
||||
<!-- Step 3: Pending -->
|
||||
<div class="flex items-center">
|
||||
<div class="w-10 h-10 glass rounded-2xl flex items-center justify-center font-bold text-slate-400">3</div>
|
||||
<span class="ml-3 text-xs font-bold text-slate-400">状态映射</span>
|
||||
</div>
|
||||
<div class="step-line"></div>
|
||||
<!-- Step 4: Pending -->
|
||||
<div class="flex items-center">
|
||||
<div class="w-10 h-10 glass rounded-2xl flex items-center justify-center font-bold text-slate-400">4</div>
|
||||
<span class="ml-3 text-xs font-bold text-slate-400">确认信息</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 内容区域 (这里以 Step 2 字段映射为例展示) -->
|
||||
<div class="px-12 pb-10 flex-1 overflow-y-auto custom-scroll space-y-6">
|
||||
|
||||
<!-- 顶部操作栏 -->
|
||||
<div class="flex justify-between items-center bg-white/20 p-4 rounded-2xl border border-white/40">
|
||||
<span class="text-sm font-medium text-slate-600">系统已根据 CSV 表头为您自动匹配了 5 个字段</span>
|
||||
<div class="flex gap-2">
|
||||
<select class="bg-white/50 border-none rounded-xl text-xs font-bold px-4 py-2 outline-none">
|
||||
<option>默认映射模板 (拼多多)</option>
|
||||
</select>
|
||||
<button class="text-xs font-bold text-indigo-600 hover:underline">保存为新模板</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 映射列表布局 -->
|
||||
<div class="grid grid-cols-1 gap-4">
|
||||
|
||||
<!-- 映射单元 1 -->
|
||||
<div class="glass-inner-card p-5 rounded-[1.5rem] flex items-center gap-8">
|
||||
<div class="w-1/3">
|
||||
<label class="text-[10px] font-black text-indigo-500 uppercase">系统标准字段</label>
|
||||
<h4 class="text-base font-bold text-slate-800">规格编码 <span class="text-rose-500">*</span></h4>
|
||||
<p class="text-[10px] text-slate-400">字段定义: spec_code</p>
|
||||
</div>
|
||||
<div class="flex-1 flex items-center gap-4">
|
||||
<div class="text-slate-300">
|
||||
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14 5l7 7m0 0l-7 7m7-7H3"/></svg>
|
||||
</div>
|
||||
<div class="flex-1">
|
||||
<select class="w-full bg-white/60 border border-white/80 rounded-2xl px-5 py-3 text-sm font-bold outline-none focus:ring-2 focus:ring-indigo-300 transition-all">
|
||||
<option>商家编码-规格维度 (CSV列)</option>
|
||||
<option>商品ID</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 映射单元 2 (错误示例) -->
|
||||
<div class="glass-inner-card p-5 rounded-[1.5rem] flex items-center gap-8 border-rose-200 bg-rose-50/20">
|
||||
<div class="w-1/3">
|
||||
<label class="text-[10px] font-black text-rose-500 uppercase">系统标准字段</label>
|
||||
<h4 class="text-base font-bold text-slate-800">商家实收金额 <span class="text-rose-500">*</span></h4>
|
||||
<p class="text-[10px] text-slate-400">字段定义: received_amount</p>
|
||||
</div>
|
||||
<div class="flex-1 flex items-center gap-4">
|
||||
<div class="text-rose-300">
|
||||
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14 5l7 7m0 0l-7 7m7-7H3"/></svg>
|
||||
</div>
|
||||
<div class="flex-1">
|
||||
<select class="w-full bg-rose-50/50 border border-rose-200 rounded-2xl px-5 py-3 text-sm font-bold outline-none text-rose-500">
|
||||
<option>-- 请选择 CSV 对应列 --</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 映射单元 3 -->
|
||||
<div class="glass-inner-card p-5 rounded-[1.5rem] flex items-center gap-8">
|
||||
<div class="w-1/3">
|
||||
<label class="text-[10px] font-black text-indigo-500 uppercase">系统标准字段</label>
|
||||
<h4 class="text-base font-bold text-slate-800">下单时间 <span class="text-rose-500">*</span></h4>
|
||||
</div>
|
||||
<div class="flex-1 flex items-center gap-4">
|
||||
<div class="text-slate-300">
|
||||
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14 5l7 7m0 0l-7 7m7-7H3"/></svg>
|
||||
</div>
|
||||
<div class="flex-1">
|
||||
<select class="w-full bg-white/60 border border-white/80 rounded-2xl px-5 py-3 text-sm font-bold outline-none">
|
||||
<option>支付时间 (Pay Time)</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Footer -->
|
||||
<div class="px-12 py-8 border-t border-white/40 bg-white/20 flex justify-between items-center">
|
||||
<button class="px-8 py-3 rounded-2xl font-bold text-slate-500 hover:bg-white/50 transition">
|
||||
取消导入
|
||||
</button>
|
||||
<div class="flex gap-4">
|
||||
<button class="glass px-8 py-3 rounded-2xl font-bold text-indigo-600 hover:bg-white/60 transition border border-indigo-100">
|
||||
上一步
|
||||
</button>
|
||||
<button class="bg-indigo-600 text-white px-10 py-3 rounded-2xl font-bold shadow-xl shadow-indigo-200 hover:bg-indigo-700 transition">
|
||||
下一步:状态映射
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,153 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>全店汇总毛玻璃看板</title>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.3/dist/echarts.min.js"></script>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;600;700&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Plus Jakarta Sans', sans-serif;
|
||||
background: linear-gradient(135deg, #fef2f2 0%, #eef2ff 50%, #f0fdf4 100%);
|
||||
min-height: 100vh;
|
||||
}
|
||||
.glass {
|
||||
background: rgba(255, 255, 255, 0.5);
|
||||
backdrop-filter: blur(20px);
|
||||
border: 1px solid rgba(255, 255, 255, 0.6);
|
||||
border-radius: 2rem;
|
||||
box-shadow: 0 10px 30px rgba(0,0,0,0.02);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="p-6 md:p-10">
|
||||
|
||||
<div class="max-w-[1600px] mx-auto space-y-8">
|
||||
<!-- 公司级头部 -->
|
||||
<header class="flex justify-between items-center">
|
||||
<div>
|
||||
<h1 class="text-4xl font-black text-slate-800 tracking-tight">全店铺经营大盘</h1>
|
||||
<p class="text-indigo-600 font-bold">Company Dashboard · 共 8 家在营店铺</p>
|
||||
</div>
|
||||
<div class="glass px-6 py-3 flex gap-8 items-center">
|
||||
<div class="text-center"><div class="text-[10px] uppercase font-bold text-slate-400">汇总 ROI</div><div class="text-lg font-black">4.05</div></div>
|
||||
<div class="w-px h-8 bg-slate-200"></div>
|
||||
<div class="text-center"><div class="text-[10px] uppercase font-bold text-slate-400">总税后盈亏</div><div class="text-lg font-black text-emerald-600">¥842,000</div></div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- 汇总卡片 -->
|
||||
<div class="grid grid-cols-1 md:grid-cols-4 gap-6">
|
||||
<div class="glass p-8 bg-gradient-to-br from-indigo-500/10 to-transparent">
|
||||
<div class="text-slate-500 text-sm font-bold">全店总销售额</div>
|
||||
<div class="text-3xl font-black mt-1">¥4,829,000</div>
|
||||
<div class="mt-4 text-xs font-bold text-emerald-500 bg-emerald-50 w-fit px-2 py-1 rounded-lg">↑ 18% 较上月同期</div>
|
||||
</div>
|
||||
<div class="glass p-8">
|
||||
<div class="text-slate-500 text-sm font-bold">全店总单量</div>
|
||||
<div class="text-3xl font-black mt-1">12,408</div>
|
||||
<div class="mt-4 text-xs font-bold text-slate-400 italic">目标达成率 92%</div>
|
||||
</div>
|
||||
<div class="glass p-8">
|
||||
<div class="text-slate-500 text-sm font-bold">总推广费支出</div>
|
||||
<div class="text-3xl font-black mt-1">¥1,192,000</div>
|
||||
<div class="mt-4 text-xs font-bold text-indigo-400">平均费比: 24.6%</div>
|
||||
</div>
|
||||
<div class="glass p-8 bg-gradient-to-br from-emerald-500/10 to-transparent">
|
||||
<div class="text-slate-500 text-sm font-bold">全店总净利 (税后)</div>
|
||||
<div class="text-3xl font-black mt-1 text-emerald-600">¥842,500</div>
|
||||
<div class="mt-4 text-xs font-bold text-slate-400">扣除总税额: ¥193,160</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 各店对比分析 -->
|
||||
<div class="grid grid-cols-1 lg:grid-cols-2 gap-8">
|
||||
<div class="glass p-8">
|
||||
<h3 class="font-bold text-xl mb-6">各店铺销售占比排行</h3>
|
||||
<div id="shopBarChart" style="height: 400px;"></div>
|
||||
</div>
|
||||
<div class="glass p-8">
|
||||
<h3 class="font-bold text-xl mb-6">店铺效率象限 (ROI vs 净利)</h3>
|
||||
<div id="shopScatterChart" style="height: 400px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 店铺多维度对比表 (包含16维度) -->
|
||||
<div class="glass overflow-hidden pb-6">
|
||||
<div class="p-8 flex justify-between items-center">
|
||||
<h3 class="font-bold text-xl">多店铺数据横向对比 (全16维度)</h3>
|
||||
</div>
|
||||
<div class="overflow-x-auto px-4">
|
||||
<table class="w-full text-left border-collapse whitespace-nowrap">
|
||||
<thead class="text-[11px] uppercase text-slate-400 border-b border-white/40">
|
||||
<tr>
|
||||
<th class="p-4 font-black">店铺名称</th>
|
||||
<th class="p-4 font-black">销售额</th>
|
||||
<th class="p-4 font-black text-indigo-600">ROI</th>
|
||||
<th class="p-4 font-black">目标达成</th>
|
||||
<th class="p-4 font-black text-red-400">退款/刷单费</th>
|
||||
<th class="p-4 font-black">推广费总和</th>
|
||||
<th class="p-4 font-black text-emerald-600">税后盈亏</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="text-sm">
|
||||
<tr class="hover:bg-white/40 transition">
|
||||
<td class="p-4 font-bold">旗舰店 A</td>
|
||||
<td class="p-4">¥1,284,000</td>
|
||||
<td class="p-4 font-black text-indigo-600">4.21</td>
|
||||
<td class="p-4"><div class="w-24 bg-slate-200 h-1 rounded-full"><div class="bg-indigo-500 h-full w-[85%]"></div></div></td>
|
||||
<td class="p-4 text-red-400">¥12,400 / ¥1,500</td>
|
||||
<td class="p-4">¥305,000</td>
|
||||
<td class="p-4 font-black text-emerald-600">¥124,500</td>
|
||||
</tr>
|
||||
<tr class="hover:bg-white/40 transition border-t border-white/20">
|
||||
<td class="p-4 font-bold">精品海外店 B</td>
|
||||
<td class="p-4">¥942,000</td>
|
||||
<td class="p-4 font-black text-indigo-600">3.85</td>
|
||||
<td class="p-4"><div class="w-24 bg-slate-200 h-1 rounded-full"><div class="bg-indigo-500 h-full w-[105%]"></div></div></td>
|
||||
<td class="p-4 text-red-400">¥8,200 / ¥2,100</td>
|
||||
<td class="p-4">¥240,000</td>
|
||||
<td class="p-4 font-black text-emerald-600">¥98,000</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// 店铺排行
|
||||
const barChart = echarts.init(document.getElementById('shopBarChart'));
|
||||
barChart.setOption({
|
||||
tooltip: { trigger: 'axis' },
|
||||
xAxis: { type: 'value', show: false },
|
||||
yAxis: { type: 'category', data: ['店 D', '店 C', '店 B', '旗舰店 A'], axisLine: {show: false} },
|
||||
series: [{
|
||||
type: 'bar',
|
||||
data: [420, 780, 942, 1284],
|
||||
itemStyle: {
|
||||
color: new echarts.graphic.LinearGradient(1, 0, 0, 0, [{offset: 0, color: '#6366f1'}, {offset: 1, color: '#a5b4fc'}]),
|
||||
borderRadius: [0, 10, 10, 0]
|
||||
},
|
||||
barWidth: 25
|
||||
}]
|
||||
});
|
||||
|
||||
// 效率象限图
|
||||
const scatterChart = echarts.init(document.getElementById('shopScatterChart'));
|
||||
scatterChart.setOption({
|
||||
grid: { top: '10%', bottom: '10%', left: '10%' },
|
||||
xAxis: { name: '销售额', splitLine: { lineStyle: { type: 'dashed' } } },
|
||||
yAxis: { name: 'ROI', splitLine: { lineStyle: { type: 'dashed' } } },
|
||||
series: [{
|
||||
type: 'scatter',
|
||||
symbolSize: 40,
|
||||
data: [[1284, 4.21], [942, 3.85], [780, 5.2], [420, 2.1]],
|
||||
itemStyle: { color: '#6366f1', opacity: 0.6 }
|
||||
}]
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,182 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>单店毛玻璃看板 - 时间筛选</title>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.3/dist/echarts.min.js"></script>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;600;700&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Plus Jakarta Sans', sans-serif;
|
||||
background: linear-gradient(135deg, #eef2ff 0%, #fae8ff 50%, #f1f5f9 100%);
|
||||
min-height: 100vh;
|
||||
color: #1e293b;
|
||||
}
|
||||
.glass {
|
||||
background: rgba(255, 255, 255, 0.4);
|
||||
backdrop-filter: blur(16px);
|
||||
-webkit-backdrop-filter: blur(16px);
|
||||
border: 1px solid rgba(255, 255, 255, 0.5);
|
||||
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.05);
|
||||
}
|
||||
/* 时间选择器激活状态 */
|
||||
.time-btn.active {
|
||||
background: #6366f1;
|
||||
color: white;
|
||||
box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
|
||||
}
|
||||
.time-btn { transition: all 0.3s ease; }
|
||||
.no-scrollbar::-webkit-scrollbar { display: none; }
|
||||
</style>
|
||||
</head>
|
||||
<body class="p-6">
|
||||
|
||||
<div class="max-w-7xl mx-auto space-y-6">
|
||||
<!-- 头部:店铺信息 & 增强型时间选择器 -->
|
||||
<header class="flex flex-col lg:flex-row justify-between items-start lg:items-center gap-6 pb-4">
|
||||
<div>
|
||||
<h1 class="text-3xl font-black text-slate-800">星辰优选旗舰店</h1>
|
||||
<p class="text-slate-500 font-medium">数据维度:全方位损益实时统计</p>
|
||||
</div>
|
||||
|
||||
<!-- 时间选择器组件 -->
|
||||
<div class="glass p-1.5 rounded-2xl flex flex-wrap items-center gap-2">
|
||||
<div class="flex bg-white/30 rounded-xl p-1">
|
||||
<button onclick="switchTime(this)" class="time-btn active px-4 py-1.5 rounded-lg text-sm font-bold">今日</button>
|
||||
<button onclick="switchTime(this)" class="time-btn px-4 py-1.5 rounded-lg text-sm font-bold">昨日</button>
|
||||
<button onclick="switchTime(this)" class="time-btn px-4 py-1.5 rounded-lg text-sm font-bold">近7日</button>
|
||||
<button onclick="switchTime(this)" class="time-btn px-4 py-1.5 rounded-lg text-sm font-bold">近30日</button>
|
||||
</div>
|
||||
<div class="h-6 w-px bg-slate-300 mx-1"></div>
|
||||
<!-- 自定义时间 -->
|
||||
<div class="flex items-center gap-2 px-3 py-1.5 bg-white/30 rounded-xl">
|
||||
<span class="text-[10px] font-bold text-slate-400 uppercase">自定义</span>
|
||||
<input type="date" class="bg-transparent text-xs font-bold outline-none border-none cursor-pointer">
|
||||
<span class="text-slate-400">-</span>
|
||||
<input type="date" class="bg-transparent text-xs font-bold outline-none border-none cursor-pointer">
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- 1. 核心 KPI (覆盖:销售额, ROI, 目标达成, 税后盈亏, 日单量, 客单价) -->
|
||||
<div class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4">
|
||||
<div class="glass p-5 rounded-3xl">
|
||||
<div class="text-[10px] font-bold text-indigo-500 uppercase">销售额</div>
|
||||
<div class="text-2xl font-black">¥128,400</div>
|
||||
</div>
|
||||
<div class="glass p-5 rounded-3xl border-l-4 border-l-indigo-500">
|
||||
<div class="text-[10px] font-bold text-indigo-500 uppercase">ROI / 费比</div>
|
||||
<div class="text-2xl font-black">4.21 <span class="text-xs text-slate-400 font-normal">/ 23%</span></div>
|
||||
</div>
|
||||
<div class="glass p-5 rounded-3xl">
|
||||
<div class="text-[10px] font-bold text-indigo-500 uppercase">达成率</div>
|
||||
<div class="text-2xl font-black text-indigo-600">85.4%</div>
|
||||
</div>
|
||||
<div class="glass p-5 rounded-3xl">
|
||||
<div class="text-[10px] font-bold text-indigo-500 uppercase">单量 / 客单价</div>
|
||||
<div class="text-2xl font-black">812 <span class="text-xs text-slate-400 font-normal">/ ¥158</span></div>
|
||||
</div>
|
||||
<div class="glass p-5 rounded-3xl">
|
||||
<div class="text-[10px] font-bold text-indigo-500 uppercase">推广费总和</div>
|
||||
<div class="text-2xl font-black">¥45,000</div>
|
||||
</div>
|
||||
<div class="glass p-5 rounded-3xl bg-emerald-500/10 border-l-4 border-l-emerald-500">
|
||||
<div class="text-[10px] font-bold text-emerald-600 uppercase">税后盈亏</div>
|
||||
<div class="text-2xl font-black text-emerald-600">¥12,450</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 2. 图表与财务损益拆解 -->
|
||||
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
|
||||
<div class="lg:col-span-2 glass p-6 rounded-[2rem]">
|
||||
<h3 class="font-bold text-lg mb-4">业绩趋势 (10/05 - 10/11)</h3>
|
||||
<div id="shopTrend" style="height: 380px;"></div>
|
||||
</div>
|
||||
|
||||
<!-- 16维度损益明细 -->
|
||||
<div class="glass p-6 rounded-[2rem] flex flex-col">
|
||||
<h3 class="font-bold text-lg mb-4">财务损益全维度 (P&L)</h3>
|
||||
<div class="space-y-3 text-sm flex-1 overflow-y-auto pr-2 no-scrollbar">
|
||||
<div class="flex justify-between p-2 rounded-xl bg-white/20"><span class="opacity-60">目标单量</span><span class="font-bold">2,000 单</span></div>
|
||||
<div class="flex justify-between p-2"><span class="opacity-60">成本运费</span><span class="font-bold text-red-500">-¥32,400</span></div>
|
||||
<div class="flex justify-between p-2"><span class="opacity-60">退款金额</span><span class="font-bold text-red-500">-¥8,200</span></div>
|
||||
<div class="flex justify-between p-2"><span class="opacity-60">推广费用(今日)</span><span class="font-bold">¥3,200</span></div>
|
||||
<div class="flex justify-between p-2"><span class="opacity-60">刷单费用</span><span class="font-bold text-orange-500">¥1,500</span></div>
|
||||
<div class="flex justify-between p-2 pt-4 border-t border-white/40"><span class="text-indigo-600 font-bold">税前盈亏</span><span class="font-bold text-indigo-600">¥17,586</span></div>
|
||||
<div class="flex justify-between p-2"><span class="opacity-40 italic text-xs">销售额 4% 税</span><span class="opacity-40 text-xs">¥5,136</span></div>
|
||||
<!-- 最终结果 -->
|
||||
<div class="flex justify-between p-4 rounded-2xl bg-gradient-to-r from-indigo-600 to-indigo-800 text-white shadow-xl shadow-indigo-100 mt-4">
|
||||
<span class="font-bold uppercase tracking-widest text-xs opacity-80">税后盈亏 (Final)</span>
|
||||
<span class="text-2xl font-black">¥12,450</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 3. 商品贡献列表 -->
|
||||
<div class="glass rounded-[2rem] overflow-hidden">
|
||||
<div class="p-6 border-b border-white/40">
|
||||
<h3 class="font-bold text-lg">核心商品利润排名</h3>
|
||||
</div>
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full text-left">
|
||||
<thead>
|
||||
<tr class="text-[10px] uppercase tracking-widest text-slate-400">
|
||||
<th class="p-5 font-bold">商品名/SKU</th>
|
||||
<th class="p-5 font-bold">销售额</th>
|
||||
<th class="p-5 font-bold">推广费</th>
|
||||
<th class="p-5 font-bold">ROI</th>
|
||||
<th class="p-5 font-bold text-emerald-600">单品净利</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="text-sm divide-y divide-white/20">
|
||||
<tr class="hover:bg-white/30 transition">
|
||||
<td class="p-5 font-bold italic">2023 智能降噪耳机 Pro</td>
|
||||
<td class="p-5">¥42,000</td>
|
||||
<td class="p-5">¥5,200</td>
|
||||
<td class="p-5"><span class="px-3 py-1 bg-indigo-100 text-indigo-600 rounded-lg font-bold">8.1</span></td>
|
||||
<td class="p-5 font-black text-emerald-600">¥12,400</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// 时间切换效果
|
||||
function switchTime(btn) {
|
||||
document.querySelectorAll('.time-btn').forEach(b => b.classList.remove('active'));
|
||||
btn.classList.add('active');
|
||||
}
|
||||
|
||||
// Echarts 初始化 (销售趋势图)
|
||||
const chart = echarts.init(document.getElementById('shopTrend'));
|
||||
chart.setOption({
|
||||
grid: { top: 20, left: 40, right: 20, bottom: 40 },
|
||||
tooltip: { trigger: 'axis', backgroundColor: 'rgba(255,255,255,0.9)' },
|
||||
xAxis: { type: 'category', data: ['10-05', '10-06', '10-07', '10-08', '10-09', '10-10', '10-11'] },
|
||||
yAxis: { type: 'value', splitLine: { lineStyle: { type: 'dashed', color: 'rgba(255,255,255,0.5)' } } },
|
||||
series: [{
|
||||
name: '销售额',
|
||||
type: 'line',
|
||||
smooth: true,
|
||||
symbol: 'circle',
|
||||
symbolSize: 10,
|
||||
lineStyle: { width: 4, color: '#6366f1' },
|
||||
itemStyle: { color: '#6366f1', borderColor: '#fff', borderWidth: 2 },
|
||||
areaStyle: {
|
||||
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
|
||||
{ offset: 0, color: 'rgba(99, 102, 241, 0.4)' },
|
||||
{ offset: 1, color: 'rgba(99, 102, 241, 0)' }
|
||||
])
|
||||
},
|
||||
data: [82, 93, 90, 120, 129, 133, 128]
|
||||
}]
|
||||
});
|
||||
window.onresize = chart.resize;
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user