mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-23 23:59:19 +08:00
1
This commit is contained in:
+17
-22
@@ -100,7 +100,7 @@ public class ImportTaskProcessorServiceImpl implements ImportTaskProcessorServic
|
||||
*/
|
||||
private static class StatusMapping {
|
||||
private String csvStatus;
|
||||
private String mappedStatus;
|
||||
private Long mappedStatusId;
|
||||
|
||||
// 无参构造函数(Jackson需要)
|
||||
public StatusMapping() {
|
||||
@@ -114,12 +114,12 @@ public class ImportTaskProcessorServiceImpl implements ImportTaskProcessorServic
|
||||
this.csvStatus = csvStatus;
|
||||
}
|
||||
|
||||
public String getMappedStatus() {
|
||||
return mappedStatus;
|
||||
public Long getMappedStatusId() {
|
||||
return mappedStatusId;
|
||||
}
|
||||
|
||||
public void setMappedStatus(String mappedStatus) {
|
||||
this.mappedStatus = mappedStatus;
|
||||
public void setMappedStatusId(Long mappedStatusId) {
|
||||
this.mappedStatusId = mappedStatusId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,11 +239,12 @@ public class ImportTaskProcessorServiceImpl implements ImportTaskProcessorServic
|
||||
MappingConfig mappingConfig = parseMappingConfig(task.getMapping());
|
||||
Map<String, MappingField> fieldMapping = mappingConfig.getFieldMapping().stream()
|
||||
.collect(Collectors.toMap(MappingField::getFieldName, field -> field, (v1, v2) -> v1));
|
||||
Map<String, String> statusMapping = mappingConfig.getStatusMapping() != null
|
||||
Map<String, Long> statusMapping = mappingConfig.getStatusMapping() != null
|
||||
? mappingConfig.getStatusMapping().stream()
|
||||
.filter(sm -> sm.getCsvStatus() != null && sm.getMappedStatusId() != null)
|
||||
.collect(Collectors.toMap(
|
||||
sm -> sm.getCsvStatus() != null ? sm.getCsvStatus().trim() : "",
|
||||
StatusMapping::getMappedStatus,
|
||||
sm -> sm.getCsvStatus().trim(),
|
||||
StatusMapping::getMappedStatusId,
|
||||
(v1, v2) -> v1))
|
||||
: java.util.Collections.emptyMap();
|
||||
Long companyId = task.getCompanyId();
|
||||
@@ -393,8 +394,8 @@ public class ImportTaskProcessorServiceImpl implements ImportTaskProcessorServic
|
||||
if (statusNode.has("csvStatus")) {
|
||||
statusMapping.setCsvStatus(statusNode.get("csvStatus").asText());
|
||||
}
|
||||
if (statusNode.has("mappedStatus")) {
|
||||
statusMapping.setMappedStatus(statusNode.get("mappedStatus").asText());
|
||||
if (statusNode.has("mappedStatusId")) {
|
||||
statusMapping.setMappedStatusId(statusNode.get("mappedStatusId").asLong());
|
||||
}
|
||||
statusMappings.add(statusMapping);
|
||||
}
|
||||
@@ -420,7 +421,7 @@ public class ImportTaskProcessorServiceImpl implements ImportTaskProcessorServic
|
||||
*
|
||||
* @param record CSV记录
|
||||
* @param fieldMapping 字段映射(fieldName -> MappingField)
|
||||
* @param statusMapping 状态映射(CSV状态文本 -> 状态名称)
|
||||
* @param statusMapping 状态映射(CSV状态文本 -> 状态ID)
|
||||
* @param shopId 店铺ID
|
||||
* @param defaultStatusId 默认订单状态ID
|
||||
* @param companyId 公司ID
|
||||
@@ -428,7 +429,7 @@ public class ImportTaskProcessorServiceImpl implements ImportTaskProcessorServic
|
||||
* @return 创建订单DTO
|
||||
*/
|
||||
private CreateOrderDTO parseOrderFromCSV(CSVRecord record, Map<String, MappingField> fieldMapping,
|
||||
Map<String, String> statusMapping, Long shopId, Long defaultStatusId,
|
||||
Map<String, Long> statusMapping, Long shopId, Long defaultStatusId,
|
||||
Long companyId, Long createBy) {
|
||||
CreateOrderDTO orderDTO = new CreateOrderDTO();
|
||||
orderDTO.setShopId(shopId);
|
||||
@@ -602,17 +603,11 @@ public class ImportTaskProcessorServiceImpl implements ImportTaskProcessorServic
|
||||
String trimmedStatus = orderStatusName.trim();
|
||||
Long statusId = null;
|
||||
|
||||
// 首先尝试通过状态映射转换(statusMapping中存储的是状态名称)
|
||||
// 首先尝试通过状态映射转换(statusMapping中存储的是状态ID)
|
||||
if (statusMapping != null && !statusMapping.isEmpty()) {
|
||||
String mappedStatusName = statusMapping.get(trimmedStatus);
|
||||
if (mappedStatusName != null) {
|
||||
// 根据状态名称查找状态ID
|
||||
statusId = findOrderStatusIdByName(companyId, mappedStatusName);
|
||||
if (statusId != null) {
|
||||
logger.debug("通过状态映射转换: '{}' -> '{}' -> ID: {}", trimmedStatus, mappedStatusName, statusId);
|
||||
} else {
|
||||
logger.warn("状态映射值 '{}' 对应的状态名称 '{}' 未找到", trimmedStatus, mappedStatusName);
|
||||
}
|
||||
statusId = statusMapping.get(trimmedStatus);
|
||||
if (statusId != null) {
|
||||
logger.debug("通过状态映射转换: '{}' -> ID: {}", trimmedStatus, statusId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,3 +4,4 @@
|
||||
|
||||
export * from './types.dto';
|
||||
export * from './types.vo';
|
||||
export * from './types.enum';
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { ImportMappingType } from './types.enum';
|
||||
|
||||
/**
|
||||
* 导入映射模块DTO类型定义
|
||||
*/
|
||||
@@ -5,8 +7,8 @@
|
||||
export namespace ImportMappingDTO {
|
||||
/** 创建导入映射参数 */
|
||||
export interface CreateImportMappingDTO {
|
||||
/** 导入类型(product-商品 order-订单) */
|
||||
type: string;
|
||||
/** 导入类型(PRODUCT-商品 ORDER-订单 ORDER_STATUS-订单状态) */
|
||||
type: ImportMappingType;
|
||||
/** 映射名称 */
|
||||
name: string;
|
||||
/** 字段映射(JSON格式) */
|
||||
@@ -23,8 +25,8 @@ export namespace ImportMappingDTO {
|
||||
|
||||
/** 导入映射过滤条件 */
|
||||
export interface ImportMappingFilterDTO {
|
||||
/** 导入类型(product-商品 order-订单) */
|
||||
type?: string;
|
||||
/** 导入类型(PRODUCT-商品 ORDER-订单 ORDER_STATUS-订单状态) */
|
||||
type?: ImportMappingType;
|
||||
/** 映射名称(模糊查询) */
|
||||
name?: string;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* 导入映射类型枚举
|
||||
*/
|
||||
export enum ImportMappingType {
|
||||
/** 商品 */
|
||||
PRODUCT = 'PRODUCT',
|
||||
/** 订单 */
|
||||
ORDER = 'ORDER',
|
||||
/** 订单状态 */
|
||||
ORDER_STATUS = 'ORDER_STATUS',
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入映射类型选项配置
|
||||
*/
|
||||
export const IMPORT_MAPPING_TYPE_OPTIONS = [
|
||||
{ label: '商品', value: ImportMappingType.PRODUCT },
|
||||
{ label: '订单', value: ImportMappingType.ORDER },
|
||||
{ label: '订单状态', value: ImportMappingType.ORDER_STATUS },
|
||||
];
|
||||
|
||||
/**
|
||||
* 根据导入映射类型枚举值获取中文名称
|
||||
*/
|
||||
export function getImportMappingTypeName(type: ImportMappingType): string {
|
||||
const option = IMPORT_MAPPING_TYPE_OPTIONS.find((opt) => opt.value === type);
|
||||
return option?.label || '未知类型';
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { ImportMappingType } from './types.enum';
|
||||
|
||||
/**
|
||||
* 导入映射模块VO类型定义
|
||||
*/
|
||||
@@ -9,8 +11,8 @@ export namespace ImportMappingVO {
|
||||
id: number;
|
||||
/** 所属公司ID */
|
||||
companyId?: number;
|
||||
/** 导入类型(product-商品 order-订单) */
|
||||
type: string;
|
||||
/** 导入类型(PRODUCT-商品 ORDER-订单 ORDER_STATUS-订单状态) */
|
||||
type: ImportMappingType;
|
||||
/** 映射名称 */
|
||||
name: string;
|
||||
/** 字段映射(JSON格式) */
|
||||
|
||||
@@ -10,40 +10,42 @@ import { requestClient } from '#/api/request';
|
||||
* 创建订单状态
|
||||
*/
|
||||
export async function createOrderStatusApi(data: OrderStatusDTO.Create) {
|
||||
return requestClient.post<number>('/ec/order-status', data);
|
||||
return requestClient.post<OrderStatusVO.Info>(
|
||||
'/ec/order-status/create',
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新订单状态
|
||||
*/
|
||||
export async function updateOrderStatusApi(data: OrderStatusDTO.Update) {
|
||||
return requestClient.put('/ec/order-status', data);
|
||||
export async function updateOrderStatusApi(
|
||||
id: number,
|
||||
data: OrderStatusDTO.Update,
|
||||
) {
|
||||
return requestClient.put<OrderStatusVO.Info>(
|
||||
`/ec/order-status/update/${id}`,
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除订单状态
|
||||
*/
|
||||
export async function deleteOrderStatusApi(id: number) {
|
||||
return requestClient.delete(`/ec/order-status/${id}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单状态详情
|
||||
*/
|
||||
export async function getOrderStatusByIdApi(id: number) {
|
||||
return requestClient.get<OrderStatusVO.Info>(`/ec/order-status/${id}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取启用的订单状态列表
|
||||
*/
|
||||
export async function getActiveOrderStatusListApi() {
|
||||
return requestClient.get<OrderStatusVO.Info[]>('/ec/order-status/active');
|
||||
return requestClient.delete(`/ec/order-status/delete/${id}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有订单状态列表
|
||||
*/
|
||||
export async function getAllOrderStatusListApi() {
|
||||
return requestClient.get<OrderStatusVO.Info[]>('/ec/order-status/all');
|
||||
return requestClient.get<OrderStatusVO.Info[]>('/ec/order-status/list');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单状态详情
|
||||
*/
|
||||
export async function getOrderStatusByIdApi(id: number) {
|
||||
return requestClient.get<OrderStatusVO.Info>(`/ec/order-status/detail/${id}`);
|
||||
}
|
||||
|
||||
@@ -5,27 +5,25 @@
|
||||
export namespace OrderStatusDTO {
|
||||
/** 创建订单状态参数 */
|
||||
export interface Create {
|
||||
/** 状态名称 */
|
||||
/** 状态名称(中文) */
|
||||
statusName: string;
|
||||
/** 状态描述 */
|
||||
description?: string;
|
||||
/** 排序 */
|
||||
sortOrder?: number;
|
||||
/** 是否启用 0禁用 1启用 */
|
||||
isActive?: number;
|
||||
/** 是否默认参与统计 0不参与 1参与 */
|
||||
isDefaultStat: number;
|
||||
}
|
||||
|
||||
/** 更新订单状态参数 */
|
||||
export interface Update {
|
||||
/** 状态ID */
|
||||
id: number;
|
||||
/** 状态名称 */
|
||||
/** 状态名称(中文) */
|
||||
statusName: string;
|
||||
/** 状态描述 */
|
||||
description?: string;
|
||||
/** 排序 */
|
||||
sortOrder?: number;
|
||||
/** 是否启用 0禁用 1启用 */
|
||||
isActive?: number;
|
||||
/** 是否默认参与统计 0不参与 1参与 */
|
||||
isDefaultStat: number;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,20 +5,18 @@
|
||||
export namespace OrderStatusVO {
|
||||
/** 订单状态信息 */
|
||||
export interface Info {
|
||||
/** 状态ID */
|
||||
/** 订单状态ID */
|
||||
id: number;
|
||||
/** 公司ID */
|
||||
companyId: number;
|
||||
/** 状态码 */
|
||||
statusCode: number;
|
||||
/** 状态名称 */
|
||||
companyId?: number;
|
||||
/** 状态名称(中文) */
|
||||
statusName: string;
|
||||
/** 状态描述 */
|
||||
description?: string;
|
||||
/** 排序 */
|
||||
sortOrder?: number;
|
||||
/** 是否启用 0禁用 1启用 */
|
||||
isActive: number;
|
||||
/** 是否默认参与统计 0不参与 1参与 */
|
||||
isDefaultStat: number;
|
||||
/** 创建时间 */
|
||||
createTime: string;
|
||||
/** 更新时间 */
|
||||
|
||||
@@ -4,3 +4,4 @@
|
||||
|
||||
export * from './types.dto';
|
||||
export * from './types.vo';
|
||||
export * from './types.enum';
|
||||
|
||||
@@ -14,15 +14,15 @@ export namespace OrderDTO {
|
||||
/** 商家实收金额 */
|
||||
receivedAmount: number;
|
||||
/** 下单时间 */
|
||||
orderDate: string;
|
||||
orderTime: string;
|
||||
/** 商品ID */
|
||||
productId: number;
|
||||
/** 商品规格ID */
|
||||
productSpecId?: number;
|
||||
/** 商品名称(冗余存储) */
|
||||
productName: string;
|
||||
/** 规格名称(冗余存储) */
|
||||
specName?: string;
|
||||
/** 链接商品名称(冗余存储) */
|
||||
linkProductName: string;
|
||||
/** 链接规格名称(冗余存储) */
|
||||
linkSpecName?: string;
|
||||
/** 数量 */
|
||||
quantity: number;
|
||||
/** 销售单价 */
|
||||
@@ -42,15 +42,15 @@ export namespace OrderDTO {
|
||||
/** 商家实收金额 */
|
||||
receivedAmount: number;
|
||||
/** 下单时间 */
|
||||
orderDate: string;
|
||||
orderTime: string;
|
||||
/** 商品ID */
|
||||
productId?: number;
|
||||
/** 商品规格ID */
|
||||
productSpecId?: number;
|
||||
/** 商品名称(冗余存储) */
|
||||
productName?: string;
|
||||
/** 规格名称(冗余存储) */
|
||||
specName?: string;
|
||||
/** 链接商品名称(冗余存储) */
|
||||
linkProductName?: string;
|
||||
/** 链接规格名称(冗余存储) */
|
||||
linkSpecName?: string;
|
||||
/** 数量 */
|
||||
quantity?: number;
|
||||
/** 销售单价 */
|
||||
@@ -72,9 +72,9 @@ export namespace OrderDTO {
|
||||
/** 实收金额范围-最大值 */
|
||||
maxReceivedAmount?: number;
|
||||
/** 下单时间范围-开始时间 */
|
||||
startOrderDate?: string;
|
||||
startOrderTime?: string;
|
||||
/** 下单时间范围-结束时间 */
|
||||
endOrderDate?: string;
|
||||
endOrderTime?: string;
|
||||
}
|
||||
|
||||
/** 批量导入订单参数 */
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* 订单状态枚举
|
||||
*/
|
||||
export enum OrderStatus {
|
||||
/** 未知状态 */
|
||||
UNKNOWN = 'UNKNOWN',
|
||||
/** 待发货 */
|
||||
PENDING_SHIPMENT = 'PENDING_SHIPMENT',
|
||||
/** 已发货 */
|
||||
SHIPPED = 'SHIPPED',
|
||||
/** 已完成 */
|
||||
COMPLETED = 'COMPLETED',
|
||||
/** 已取消 */
|
||||
CANCELLED = 'CANCELLED',
|
||||
/** 退款中 */
|
||||
REFUNDING = 'REFUNDING',
|
||||
/** 已退款 */
|
||||
REFUNDED = 'REFUNDED',
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单状态选项配置
|
||||
*/
|
||||
export const ORDER_STATUS_OPTIONS = [
|
||||
{ label: '未知状态', value: OrderStatus.UNKNOWN },
|
||||
{ label: '待发货', value: OrderStatus.PENDING_SHIPMENT },
|
||||
{ label: '已发货', value: OrderStatus.SHIPPED },
|
||||
{ label: '已完成', value: OrderStatus.COMPLETED },
|
||||
{ label: '已取消', value: OrderStatus.CANCELLED },
|
||||
{ label: '退款中', value: OrderStatus.REFUNDING },
|
||||
{ label: '已退款', value: OrderStatus.REFUNDED },
|
||||
];
|
||||
|
||||
/**
|
||||
* 根据订单状态枚举值获取中文名称
|
||||
*/
|
||||
export function getOrderStatusName(status: OrderStatus): string {
|
||||
const option = ORDER_STATUS_OPTIONS.find((opt) => opt.value === status);
|
||||
return option?.label || '未知状态';
|
||||
}
|
||||
|
||||
@@ -17,12 +17,12 @@ export namespace OrderVO {
|
||||
platformOrderNo: string;
|
||||
/** 订单状态ID */
|
||||
statusId: number;
|
||||
/** 订单状态名称 */
|
||||
/** 订单状态名称(中文) */
|
||||
statusName: string;
|
||||
/** 商家实收金额 */
|
||||
receivedAmount: number;
|
||||
/** 下单时间 */
|
||||
orderDate: string;
|
||||
orderTime: string;
|
||||
/** 创建时间 */
|
||||
createTime: string;
|
||||
/** 更新时间 */
|
||||
@@ -35,10 +35,10 @@ export namespace OrderVO {
|
||||
productId: number;
|
||||
/** 商品规格ID */
|
||||
productSpecId?: number;
|
||||
/** 商品名称(冗余存储) */
|
||||
productName: string;
|
||||
/** 规格名称(冗余存储) */
|
||||
specName?: string;
|
||||
/** 链接商品名称(冗余存储) */
|
||||
linkProductName: string;
|
||||
/** 链接规格名称(冗余存储) */
|
||||
linkSpecName?: string;
|
||||
/** 数量 */
|
||||
quantity: number;
|
||||
/** 销售单价 */
|
||||
|
||||
+10
-11
@@ -41,7 +41,7 @@ const currentRecord = ref<null | OrderStatusVO.Info>(null);
|
||||
const formData = ref<Partial<OrderStatusDTO.Create>>({
|
||||
statusName: '',
|
||||
description: '',
|
||||
isActive: 1,
|
||||
isDefaultStat: 1,
|
||||
sortOrder: 0,
|
||||
});
|
||||
|
||||
@@ -66,13 +66,13 @@ function open(edit: boolean, record?: OrderStatusVO.Info) {
|
||||
? {
|
||||
statusName: record.statusName,
|
||||
description: record.description || '',
|
||||
isActive: record.isActive,
|
||||
isDefaultStat: record.isDefaultStat,
|
||||
sortOrder: record.sortOrder || 0,
|
||||
}
|
||||
: {
|
||||
statusName: '',
|
||||
description: '',
|
||||
isActive: 1,
|
||||
isDefaultStat: 1,
|
||||
sortOrder: 0,
|
||||
};
|
||||
}
|
||||
@@ -93,20 +93,19 @@ async function handleSubmit() {
|
||||
if (isEdit.value && currentRecord.value) {
|
||||
// 更新订单状态
|
||||
const updateData: OrderStatusDTO.Update = {
|
||||
id: currentRecord.value.id,
|
||||
statusName: formData.value.statusName!,
|
||||
description: formData.value.description,
|
||||
isActive: formData.value.isActive,
|
||||
isDefaultStat: formData.value.isDefaultStat!,
|
||||
sortOrder: formData.value.sortOrder,
|
||||
};
|
||||
await updateOrderStatusApi(updateData);
|
||||
await updateOrderStatusApi(currentRecord.value.id, updateData);
|
||||
message.success('更新订单状态成功');
|
||||
} else {
|
||||
// 创建订单状态
|
||||
const createData: OrderStatusDTO.Create = {
|
||||
statusName: formData.value.statusName!,
|
||||
description: formData.value.description,
|
||||
isActive: formData.value.isActive,
|
||||
isDefaultStat: formData.value.isDefaultStat!,
|
||||
sortOrder: formData.value.sortOrder,
|
||||
};
|
||||
await createOrderStatusApi(createData);
|
||||
@@ -177,13 +176,13 @@ defineExpose({
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="启用状态" name="isActive">
|
||||
<Form.Item label="默认参与统计" name="isDefaultStat">
|
||||
<Switch
|
||||
v-model:checked="formData.isActive"
|
||||
v-model:checked="formData.isDefaultStat"
|
||||
:checked-value="1"
|
||||
:un-checked-value="0"
|
||||
checked-children="启用"
|
||||
un-checked-children="禁用"
|
||||
checked-children="参与"
|
||||
un-checked-children="不参与"
|
||||
/>
|
||||
</Form.Item>
|
||||
</div>
|
||||
|
||||
+12
-12
@@ -52,9 +52,9 @@ const gridOptions: VxeGridProps<any> = {
|
||||
minWidth: 'auto',
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
title: '是否默认参与统计',
|
||||
minWidth: 'auto',
|
||||
slots: { default: 'status' },
|
||||
slots: { default: 'isDefaultStat' },
|
||||
},
|
||||
{
|
||||
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: 'isActive',
|
||||
label: '状态',
|
||||
fieldName: 'isDefaultStat',
|
||||
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 #status="{ row }: { row: any }">
|
||||
<Tag :color="row.isActive === 1 ? 'green' : 'red'">
|
||||
{{ row.isActive === 1 ? '启用' : '禁用' }}
|
||||
<!-- 是否默认参与统计列 -->
|
||||
<template #isDefaultStat="{ row }: { row: OrderStatusVO.Info }">
|
||||
<Tag :color="row.isDefaultStat === 1 ? 'green' : 'default'">
|
||||
{{ row.isDefaultStat === 1 ? '参与统计' : '不参与统计' }}
|
||||
</Tag>
|
||||
</template>
|
||||
|
||||
|
||||
+514
-51
@@ -5,6 +5,7 @@ import type {
|
||||
ImportMappingVO,
|
||||
} from '#/api/ecommerce/import-mapping';
|
||||
import type { ImportTaskDTO } from '#/api/ecommerce/import-task';
|
||||
import type { OrderStatusVO } from '#/api/ecommerce/order-status';
|
||||
import type { ShopVO } from '#/api/ecommerce/shop/types';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
@@ -25,8 +26,11 @@ import { getFieldDefsByTypeApi } from '#/api/ecommerce/import-field-def';
|
||||
import {
|
||||
createImportMappingApi,
|
||||
getImportMappingPageApi,
|
||||
ImportMappingType,
|
||||
updateImportMappingApi,
|
||||
} from '#/api/ecommerce/import-mapping';
|
||||
import { createImportTaskApi } from '#/api/ecommerce/import-task';
|
||||
import { getAllOrderStatusListApi } from '#/api/ecommerce/order-status';
|
||||
import { getShopPageApi } from '#/api/ecommerce/shop';
|
||||
import { uploadFileApi } from '#/api/media/file';
|
||||
import { useImportTaskStore } from '#/store';
|
||||
@@ -43,6 +47,14 @@ interface FieldMappingItem {
|
||||
required: boolean;
|
||||
}
|
||||
|
||||
// 定义订单状态映射项数据结构
|
||||
interface StatusMappingItem {
|
||||
/** CSV中的订单状态值 */
|
||||
csvStatus: string;
|
||||
/** 映射到的订单状态ID */
|
||||
mappedStatusId: number;
|
||||
}
|
||||
|
||||
defineOptions({ name: 'CreateImportTaskModal' });
|
||||
|
||||
// 创建 vben modal
|
||||
@@ -60,6 +72,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||
const currentStep = ref(0);
|
||||
const loading = ref(false);
|
||||
const csvHeaders = ref<string[]>([]);
|
||||
const csvData = ref<any[]>([]);
|
||||
const selectedFile = ref<File | null>(null);
|
||||
|
||||
// 第一步:店铺选择
|
||||
@@ -90,6 +103,18 @@ const templateLoading = ref(false);
|
||||
const savingTemplate = ref(false);
|
||||
const templateName = ref('');
|
||||
|
||||
// 第三步:订单状态映射
|
||||
const statusMappings = ref<Record<string, number>>({});
|
||||
const uniqueStatusValues = ref<string[]>([]);
|
||||
const statusMappingTemplates = ref<ImportMappingVO.ImportMappingInfoVO[]>([]);
|
||||
const selectedStatusTemplateId = ref<number | undefined>();
|
||||
const statusTemplateLoading = ref(false);
|
||||
const savingStatusTemplate = ref(false);
|
||||
const statusTemplateName = ref('');
|
||||
// 订单状态列表
|
||||
const orderStatusList = ref<OrderStatusVO.Info[]>([]);
|
||||
const orderStatusLoading = ref(false);
|
||||
|
||||
// 创建保存模板的 vben modal
|
||||
const [SaveTemplateModal, saveTemplateModalApi] = useVbenModal({
|
||||
draggable: true,
|
||||
@@ -106,8 +131,21 @@ const [SaveTemplateModal, saveTemplateModalApi] = useVbenModal({
|
||||
},
|
||||
});
|
||||
|
||||
// 表单引用
|
||||
const formRef = ref();
|
||||
// 创建保存订单状态映射模板的 vben modal
|
||||
const [SaveStatusTemplateModal, saveStatusTemplateModalApi] = useVbenModal({
|
||||
draggable: true,
|
||||
class: 'w-[500px]',
|
||||
title: '保存订单状态映射模板',
|
||||
showCancelButton: true,
|
||||
showConfirmButton: true,
|
||||
confirmText: '保存',
|
||||
cancelText: '取消',
|
||||
onConfirm: handleConfirmSaveStatusTemplate,
|
||||
onCancel() {
|
||||
statusTemplateName.value = '';
|
||||
saveStatusTemplateModalApi.close();
|
||||
},
|
||||
});
|
||||
|
||||
// 导入任务store
|
||||
const importTaskStore = useImportTaskStore();
|
||||
@@ -124,6 +162,12 @@ const canGoToNextStep = computed(() => {
|
||||
return mapping && mapping.mappedHeader;
|
||||
});
|
||||
}
|
||||
if (currentStep.value === 2) {
|
||||
// 订单状态映射步骤:所有唯一的订单状态值都必须映射
|
||||
return uniqueStatusValues.value.every(
|
||||
(status) => statusMappings.value[status] !== undefined,
|
||||
);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -230,10 +274,19 @@ const fetchMappingTemplates = async () => {
|
||||
page: 1,
|
||||
pageSize: 100,
|
||||
filters: {
|
||||
type: 'order',
|
||||
type: ImportMappingType.ORDER,
|
||||
},
|
||||
});
|
||||
mappingTemplates.value = result.records || [];
|
||||
|
||||
// 修复:自动选择第一个模板并应用
|
||||
if (mappingTemplates.value.length > 0 && !selectedTemplateId.value) {
|
||||
const firstTemplate = mappingTemplates.value[0];
|
||||
if (firstTemplate?.id) {
|
||||
selectedTemplateId.value = firstTemplate.id;
|
||||
await handleSelectTemplate(firstTemplate.id);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取映射模板列表失败:', error);
|
||||
message.error('获取映射模板列表失败');
|
||||
@@ -242,10 +295,62 @@ const fetchMappingTemplates = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
// 获取订单状态列表
|
||||
const fetchOrderStatusList = async () => {
|
||||
if (orderStatusLoading.value) return;
|
||||
|
||||
try {
|
||||
orderStatusLoading.value = true;
|
||||
const result = await getAllOrderStatusListApi();
|
||||
orderStatusList.value = result || [];
|
||||
} catch (error) {
|
||||
console.error('获取订单状态列表失败:', error);
|
||||
message.error('获取订单状态列表失败');
|
||||
} finally {
|
||||
orderStatusLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 获取订单状态映射模板列表
|
||||
const fetchStatusMappingTemplates = async () => {
|
||||
try {
|
||||
statusTemplateLoading.value = true;
|
||||
const result = await getImportMappingPageApi({
|
||||
page: 1,
|
||||
pageSize: 100,
|
||||
filters: {
|
||||
type: ImportMappingType.ORDER_STATUS,
|
||||
},
|
||||
});
|
||||
statusMappingTemplates.value = result.records || [];
|
||||
|
||||
// 修复:自动选择第一个模板并应用
|
||||
if (
|
||||
statusMappingTemplates.value.length > 0 &&
|
||||
!selectedStatusTemplateId.value
|
||||
) {
|
||||
const firstTemplate = statusMappingTemplates.value[0];
|
||||
if (firstTemplate?.id) {
|
||||
selectedStatusTemplateId.value = firstTemplate.id;
|
||||
await handleSelectStatusTemplate(firstTemplate.id);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取订单状态映射模板列表失败:', error);
|
||||
message.error('获取订单状态映射模板列表失败');
|
||||
} finally {
|
||||
statusTemplateLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 选择映射模板
|
||||
const handleSelectTemplate = async (value: any) => {
|
||||
const templateId = typeof value === 'number' ? value : undefined;
|
||||
if (!templateId) {
|
||||
// 如果清空选择,重置映射
|
||||
if (fieldDefs.value.length > 0) {
|
||||
initFieldMappings();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -290,7 +395,43 @@ const handleSelectTemplate = async (value: any) => {
|
||||
}
|
||||
};
|
||||
|
||||
// 打开保存模板模态框
|
||||
// 选择订单状态映射模板
|
||||
const handleSelectStatusTemplate = async (value: any) => {
|
||||
const templateId = typeof value === 'number' ? value : undefined;
|
||||
if (!templateId) {
|
||||
// 如果清空选择,重置映射
|
||||
statusMappings.value = {};
|
||||
return;
|
||||
}
|
||||
|
||||
const template = statusMappingTemplates.value.find(
|
||||
(t) => t.id === templateId,
|
||||
);
|
||||
if (!template) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// 解析模板的 mapping JSON
|
||||
const mappingItems: StatusMappingItem[] = JSON.parse(template.mapping);
|
||||
|
||||
// 根据模板填充订单状态映射
|
||||
const mappings: typeof statusMappings.value = {};
|
||||
mappingItems.forEach((item) => {
|
||||
if (uniqueStatusValues.value.includes(item.csvStatus)) {
|
||||
mappings[item.csvStatus] = item.mappedStatusId;
|
||||
}
|
||||
});
|
||||
|
||||
statusMappings.value = mappings;
|
||||
message.success('已应用订单状态映射模板');
|
||||
} catch (error) {
|
||||
console.error('应用订单状态映射模板失败:', error);
|
||||
message.error('应用订单状态映射模板失败,模板格式可能不正确');
|
||||
}
|
||||
};
|
||||
|
||||
// 打开保存/更新模板模态框
|
||||
const handleSaveTemplate = () => {
|
||||
// 验证是否有映射数据
|
||||
const mappingItems: FieldMappingItem[] = Object.values(fieldMappings.value)
|
||||
@@ -307,11 +448,46 @@ const handleSaveTemplate = () => {
|
||||
return;
|
||||
}
|
||||
|
||||
templateName.value = '';
|
||||
// 如果选择了模板,使用模板名称;否则清空
|
||||
if (selectedTemplateId.value) {
|
||||
const template = mappingTemplates.value.find(
|
||||
(t) => t.id === selectedTemplateId.value,
|
||||
);
|
||||
templateName.value = template?.name || '';
|
||||
} else {
|
||||
templateName.value = '';
|
||||
}
|
||||
saveTemplateModalApi.open();
|
||||
};
|
||||
|
||||
// 确认保存映射模板
|
||||
// 打开保存/更新订单状态映射模板模态框
|
||||
const handleSaveStatusTemplate = () => {
|
||||
// 验证是否有映射数据
|
||||
const mappingItems: StatusMappingItem[] = uniqueStatusValues.value
|
||||
.filter((status) => statusMappings.value[status] !== undefined)
|
||||
.map((status) => ({
|
||||
csvStatus: status,
|
||||
mappedStatusId: statusMappings.value[status]!,
|
||||
}));
|
||||
|
||||
if (mappingItems.length === 0) {
|
||||
message.warning('请先完成订单状态映射');
|
||||
return;
|
||||
}
|
||||
|
||||
// 如果选择了模板,使用模板名称;否则清空
|
||||
if (selectedStatusTemplateId.value) {
|
||||
const template = statusMappingTemplates.value.find(
|
||||
(t) => t.id === selectedStatusTemplateId.value,
|
||||
);
|
||||
statusTemplateName.value = template?.name || '';
|
||||
} else {
|
||||
statusTemplateName.value = '';
|
||||
}
|
||||
saveStatusTemplateModalApi.open();
|
||||
};
|
||||
|
||||
// 确认保存/更新映射模板
|
||||
async function handleConfirmSaveTemplate() {
|
||||
if (!templateName.value.trim()) {
|
||||
message.warning('请输入模板名称');
|
||||
@@ -346,58 +522,209 @@ async function handleConfirmSaveTemplate() {
|
||||
required: m.fieldDef.required,
|
||||
}));
|
||||
|
||||
const createData: ImportMappingDTO.CreateImportMappingDTO = {
|
||||
type: 'order',
|
||||
name: templateName.value.trim(),
|
||||
mapping: JSON.stringify(mappingItems),
|
||||
};
|
||||
const mappingJson = JSON.stringify(mappingItems);
|
||||
|
||||
// 如果选择了模板,则更新;否则创建
|
||||
if (selectedTemplateId.value) {
|
||||
await updateImportMappingApi(selectedTemplateId.value, {
|
||||
name: templateName.value.trim(),
|
||||
mapping: mappingJson,
|
||||
});
|
||||
message.success('更新映射模板成功');
|
||||
} else {
|
||||
const createData: ImportMappingDTO.CreateImportMappingDTO = {
|
||||
type: ImportMappingType.ORDER,
|
||||
name: templateName.value.trim(),
|
||||
mapping: mappingJson,
|
||||
};
|
||||
await createImportMappingApi(createData);
|
||||
message.success('保存映射模板成功');
|
||||
}
|
||||
|
||||
await createImportMappingApi(createData);
|
||||
message.success('保存映射模板成功');
|
||||
templateName.value = '';
|
||||
saveTemplateModalApi.close();
|
||||
// 刷新模板列表
|
||||
await fetchMappingTemplates();
|
||||
// 清空选中的模板
|
||||
selectedTemplateId.value = undefined;
|
||||
// 如果是更新,保持选中状态;如果是创建,清空选中
|
||||
if (!selectedTemplateId.value) {
|
||||
selectedTemplateId.value = undefined;
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error('保存映射模板失败:', error);
|
||||
message.error(error?.message || '保存映射模板失败');
|
||||
console.error('保存/更新映射模板失败:', error);
|
||||
message.error(error?.message || '保存/更新映射模板失败');
|
||||
} finally {
|
||||
savingTemplate.value = false;
|
||||
saveTemplateModalApi.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
// 确认保存/更新订单状态映射模板
|
||||
async function handleConfirmSaveStatusTemplate() {
|
||||
if (!statusTemplateName.value.trim()) {
|
||||
message.warning('请输入模板名称');
|
||||
return;
|
||||
}
|
||||
|
||||
// 验证所有订单状态是否都已映射
|
||||
const unMappedStatuses = uniqueStatusValues.value.filter(
|
||||
(status) => statusMappings.value[status] === undefined,
|
||||
);
|
||||
|
||||
if (unMappedStatuses.length > 0) {
|
||||
message.warning(`请先映射所有订单状态:${unMappedStatuses.join('、')}`);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
savingStatusTemplate.value = true;
|
||||
saveStatusTemplateModalApi.lock();
|
||||
|
||||
// 构建映射数据(已验证所有状态都已映射,所以不会有 undefined)
|
||||
const mappingItems: StatusMappingItem[] = uniqueStatusValues.value.map(
|
||||
(status) => ({
|
||||
csvStatus: status,
|
||||
mappedStatusId: statusMappings.value[status]!,
|
||||
}),
|
||||
);
|
||||
|
||||
const mappingJson = JSON.stringify(mappingItems);
|
||||
|
||||
// 如果选择了模板,则更新;否则创建
|
||||
if (selectedStatusTemplateId.value) {
|
||||
await updateImportMappingApi(selectedStatusTemplateId.value, {
|
||||
name: statusTemplateName.value.trim(),
|
||||
mapping: mappingJson,
|
||||
});
|
||||
message.success('更新订单状态映射模板成功');
|
||||
} else {
|
||||
const createData: ImportMappingDTO.CreateImportMappingDTO = {
|
||||
type: ImportMappingType.ORDER_STATUS,
|
||||
name: statusTemplateName.value.trim(),
|
||||
mapping: mappingJson,
|
||||
};
|
||||
await createImportMappingApi(createData);
|
||||
message.success('保存订单状态映射模板成功');
|
||||
}
|
||||
|
||||
statusTemplateName.value = '';
|
||||
saveStatusTemplateModalApi.close();
|
||||
// 刷新模板列表
|
||||
await fetchStatusMappingTemplates();
|
||||
// 如果是更新,保持选中状态;如果是创建,清空选中
|
||||
if (!selectedStatusTemplateId.value) {
|
||||
selectedStatusTemplateId.value = undefined;
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error('保存/更新订单状态映射模板失败:', error);
|
||||
message.error(error?.message || '保存/更新订单状态映射模板失败');
|
||||
} finally {
|
||||
savingStatusTemplate.value = false;
|
||||
saveStatusTemplateModalApi.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
// 解析订单状态:从CSV数据中提取status字段映射列的所有唯一值
|
||||
const parseOrderStatuses = () => {
|
||||
// 查找status字段的映射
|
||||
const statusFieldDef = fieldDefs.value.find((f) => f.fieldName === 'status');
|
||||
if (!statusFieldDef) {
|
||||
uniqueStatusValues.value = [];
|
||||
statusMappings.value = {};
|
||||
return;
|
||||
}
|
||||
|
||||
const statusMapping = fieldMappings.value[statusFieldDef.id];
|
||||
if (!statusMapping || !statusMapping.mappedHeader) {
|
||||
uniqueStatusValues.value = [];
|
||||
statusMappings.value = {};
|
||||
return;
|
||||
}
|
||||
|
||||
// 从CSV数据中提取该列的所有唯一值
|
||||
const statusColumn = statusMapping.mappedHeader;
|
||||
const statusSet = new Set<string>();
|
||||
|
||||
csvData.value.forEach((row) => {
|
||||
const statusValue = row[statusColumn];
|
||||
if (
|
||||
statusValue !== null &&
|
||||
statusValue !== undefined &&
|
||||
statusValue !== ''
|
||||
) {
|
||||
statusSet.add(String(statusValue).trim());
|
||||
}
|
||||
});
|
||||
|
||||
uniqueStatusValues.value = [...statusSet].sort();
|
||||
|
||||
// 重置订单状态映射
|
||||
statusMappings.value = {};
|
||||
};
|
||||
|
||||
// 下一步
|
||||
const handleNext = () => {
|
||||
if (currentStep.value === 0) {
|
||||
if (!selectedShopId.value) {
|
||||
message.warning('请选择店铺');
|
||||
return;
|
||||
switch (currentStep.value) {
|
||||
case 0: {
|
||||
if (!selectedShopId.value) {
|
||||
message.warning('请选择店铺');
|
||||
return;
|
||||
}
|
||||
currentStep.value = 1;
|
||||
if (fieldDefs.value.length === 0) {
|
||||
fetchFieldDefs();
|
||||
}
|
||||
// 加载映射模板列表
|
||||
if (mappingTemplates.value.length === 0) {
|
||||
fetchMappingTemplates();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
currentStep.value = 1;
|
||||
if (fieldDefs.value.length === 0) {
|
||||
fetchFieldDefs();
|
||||
case 1: {
|
||||
// 验证必填字段
|
||||
const requiredFields = fieldDefs.value.filter((f) => f.required);
|
||||
const unMappedFields = requiredFields.filter((field) => {
|
||||
const mapping = fieldMappings.value[field.id];
|
||||
return !mapping || !mapping.mappedHeader;
|
||||
});
|
||||
if (unMappedFields.length > 0) {
|
||||
message.warning(
|
||||
`请先绑定必填字段:${unMappedFields.map((f) => f.fieldLabel).join('、')}`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// 在进入订单状态映射步骤前,解析所有订单状态
|
||||
parseOrderStatuses();
|
||||
|
||||
// 加载订单状态列表
|
||||
if (orderStatusList.value.length === 0) {
|
||||
fetchOrderStatusList();
|
||||
}
|
||||
|
||||
// 加载订单状态映射模板列表
|
||||
if (statusMappingTemplates.value.length === 0) {
|
||||
fetchStatusMappingTemplates();
|
||||
}
|
||||
|
||||
currentStep.value = 2;
|
||||
|
||||
break;
|
||||
}
|
||||
// 加载映射模板列表
|
||||
if (mappingTemplates.value.length === 0) {
|
||||
fetchMappingTemplates();
|
||||
}
|
||||
} else if (currentStep.value === 1) {
|
||||
// 验证必填字段
|
||||
const requiredFields = fieldDefs.value.filter((f) => f.required);
|
||||
const unMappedFields = requiredFields.filter((field) => {
|
||||
const mapping = fieldMappings.value[field.id];
|
||||
return !mapping || !mapping.mappedHeader;
|
||||
});
|
||||
if (unMappedFields.length > 0) {
|
||||
message.warning(
|
||||
`请先绑定必填字段:${unMappedFields.map((f) => f.fieldLabel).join('、')}`,
|
||||
case 2: {
|
||||
// 验证所有订单状态是否都已映射
|
||||
const unMappedStatuses = uniqueStatusValues.value.filter(
|
||||
(status) => statusMappings.value[status] === undefined,
|
||||
);
|
||||
return;
|
||||
if (unMappedStatuses.length > 0) {
|
||||
message.warning(`请先映射所有订单状态:${unMappedStatuses.join('、')}`);
|
||||
return;
|
||||
}
|
||||
currentStep.value = 3;
|
||||
|
||||
break;
|
||||
}
|
||||
currentStep.value = 2;
|
||||
// No default
|
||||
}
|
||||
};
|
||||
|
||||
@@ -454,12 +781,25 @@ const handleCreateTask = async () => {
|
||||
required: m.fieldDef.required,
|
||||
}));
|
||||
|
||||
// 构建订单状态映射 JSON(已验证所有状态都已映射,所以不会有 undefined)
|
||||
const statusMappingItems: StatusMappingItem[] =
|
||||
uniqueStatusValues.value.map((status) => ({
|
||||
csvStatus: status,
|
||||
mappedStatusId: statusMappings.value[status]!,
|
||||
}));
|
||||
|
||||
// 构建完整的映射JSON,包含字段映射和订单状态映射
|
||||
const fullMapping = {
|
||||
fieldMapping: mappingItems,
|
||||
statusMapping: statusMappingItems,
|
||||
};
|
||||
|
||||
const createData: ImportTaskDTO.CreateImportTaskDTO = {
|
||||
shopId: selectedShopId.value!,
|
||||
type: 'order',
|
||||
fileName: selectedFile.value.name,
|
||||
filePath: fileInfo.url,
|
||||
mapping: JSON.stringify(mappingItems),
|
||||
mapping: JSON.stringify(fullMapping),
|
||||
};
|
||||
|
||||
const task = await createImportTaskApi(createData);
|
||||
@@ -478,8 +818,13 @@ const handleCreateTask = async () => {
|
||||
currentStep.value = 0;
|
||||
selectedShopId.value = undefined;
|
||||
fieldMappings.value = {};
|
||||
statusMappings.value = {};
|
||||
uniqueStatusValues.value = [];
|
||||
csvHeaders.value = [];
|
||||
csvData.value = [];
|
||||
selectedFile.value = null;
|
||||
selectedTemplateId.value = undefined;
|
||||
selectedStatusTemplateId.value = undefined;
|
||||
modalApi.close();
|
||||
} catch (error: any) {
|
||||
message.destroy();
|
||||
@@ -491,17 +836,20 @@ const handleCreateTask = async () => {
|
||||
};
|
||||
|
||||
// 暴露给父组件的方法
|
||||
function open(headers: string[], file?: File) {
|
||||
function open(headers: string[], file?: File, data?: any[]) {
|
||||
const headersChanged =
|
||||
JSON.stringify(csvHeaders.value) !== JSON.stringify(headers);
|
||||
|
||||
csvHeaders.value = headers;
|
||||
csvData.value = data || [];
|
||||
selectedFile.value = file || null;
|
||||
// 步骤保持不变,不清空
|
||||
|
||||
// 如果 CSV 表头变化了,需要重新初始化字段映射
|
||||
if (headersChanged) {
|
||||
fieldMappings.value = {};
|
||||
statusMappings.value = {};
|
||||
uniqueStatusValues.value = [];
|
||||
// 如果已有字段定义,重新初始化映射
|
||||
if (fieldDefs.value.length > 0) {
|
||||
initFieldMappings();
|
||||
@@ -543,16 +891,13 @@ const shopOptions = computed(() => {
|
||||
<Steps :current="currentStep">
|
||||
<Steps.Step title="选择店铺" />
|
||||
<Steps.Step title="字段映射" />
|
||||
<Steps.Step title="订单状态映射" />
|
||||
<Steps.Step title="确认信息" />
|
||||
</Steps>
|
||||
|
||||
<!-- 第一步:选择店铺 -->
|
||||
<div v-if="currentStep === 0" class="py-4">
|
||||
<Form
|
||||
ref="formRef"
|
||||
:label-col="{ span: 6 }"
|
||||
:wrapper-col="{ span: 18 }"
|
||||
>
|
||||
<Form :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }">
|
||||
<Form.Item label="选择店铺" required>
|
||||
<Select
|
||||
v-model:value="selectedShopId"
|
||||
@@ -620,7 +965,10 @@ const shopOptions = computed(() => {
|
||||
</span>
|
||||
</Select.Option>
|
||||
</Select>
|
||||
<Button @click="handleSaveTemplate">保存为模板</Button>
|
||||
<Button v-if="!selectedTemplateId" @click="handleSaveTemplate">
|
||||
保存为模板
|
||||
</Button>
|
||||
<Button v-else @click="handleSaveTemplate"> 更新模板 </Button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="max-h-[400px] space-y-4 overflow-y-auto">
|
||||
@@ -662,8 +1010,89 @@ const shopOptions = computed(() => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 第三步:确认信息 -->
|
||||
<!-- 第三步:订单状态映射 -->
|
||||
<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
|
||||
v-model:value="selectedStatusTemplateId"
|
||||
placeholder="选择已有模板"
|
||||
class="w-[200px]"
|
||||
:loading="statusTemplateLoading"
|
||||
allow-clear
|
||||
@change="handleSelectStatusTemplate"
|
||||
>
|
||||
<template #notFoundContent>
|
||||
<div v-if="statusTemplateLoading" 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="template in statusMappingTemplates"
|
||||
:key="template.id"
|
||||
:value="template.id"
|
||||
>
|
||||
{{ template.name }}
|
||||
<span class="ml-2 text-xs text-gray-400">
|
||||
({{ new Date(template.createTime).toLocaleDateString() }})
|
||||
</span>
|
||||
</Select.Option>
|
||||
</Select>
|
||||
<Button
|
||||
v-if="!selectedStatusTemplateId"
|
||||
@click="handleSaveStatusTemplate"
|
||||
>
|
||||
保存为模板
|
||||
</Button>
|
||||
<Button v-else @click="handleSaveStatusTemplate"> 更新模板 </Button>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="uniqueStatusValues.length === 0"
|
||||
class="py-8 text-center text-gray-400"
|
||||
>
|
||||
未找到订单状态字段映射,请先在字段映射步骤中绑定status字段
|
||||
</div>
|
||||
<div v-else class="max-h-[400px] space-y-4 overflow-y-auto">
|
||||
<div
|
||||
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>
|
||||
<div class="mt-1 text-xs text-gray-500">CSV中的订单状态值</div>
|
||||
</div>
|
||||
<Select
|
||||
v-model:value="statusMappings[statusValue]"
|
||||
placeholder="请选择订单状态"
|
||||
class="w-[200px]"
|
||||
show-search
|
||||
:loading="orderStatusLoading"
|
||||
:options="
|
||||
orderStatusList.map((status) => ({
|
||||
label: status.statusName,
|
||||
value: status.id,
|
||||
}))
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 第四步:确认信息 -->
|
||||
<div v-if="currentStep === 3" class="py-4">
|
||||
<div class="space-y-4">
|
||||
<div class="rounded bg-gray-50 p-4">
|
||||
<div class="mb-2 font-medium">店铺信息</div>
|
||||
@@ -691,6 +1120,25 @@ const shopOptions = computed(() => {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="rounded bg-gray-50 p-4">
|
||||
<div class="mb-2 font-medium">订单状态映射</div>
|
||||
<div class="space-y-2">
|
||||
<div
|
||||
v-for="statusValue in uniqueStatusValues"
|
||||
:key="statusValue"
|
||||
class="flex justify-between text-sm"
|
||||
>
|
||||
<span class="text-gray-600">{{ statusValue }}:</span>
|
||||
<span class="font-medium">
|
||||
{{
|
||||
orderStatusList.find(
|
||||
(status) => status.id === statusMappings[statusValue],
|
||||
)?.statusName ?? '-'
|
||||
}}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -700,7 +1148,7 @@ const shopOptions = computed(() => {
|
||||
<div class="space-x-2">
|
||||
<Button v-if="currentStep > 0" @click="handlePrev">上一步</Button>
|
||||
<Button
|
||||
v-if="currentStep < 2"
|
||||
v-if="currentStep < 3"
|
||||
type="primary"
|
||||
:disabled="!canGoToNextStep"
|
||||
@click="handleNext"
|
||||
@@ -708,7 +1156,7 @@ const shopOptions = computed(() => {
|
||||
下一步
|
||||
</Button>
|
||||
<Button
|
||||
v-if="currentStep === 2"
|
||||
v-if="currentStep === 3"
|
||||
type="primary"
|
||||
:loading="loading"
|
||||
@click="handleCreateTask"
|
||||
@@ -733,6 +1181,21 @@ const shopOptions = computed(() => {
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</SaveTemplateModal>
|
||||
|
||||
<!-- 保存订单状态映射模板模态框 -->
|
||||
<SaveStatusTemplateModal :confirm-loading="savingStatusTemplate">
|
||||
<Form :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }">
|
||||
<Form.Item label="模板名称" required>
|
||||
<Input
|
||||
v-model:value="statusTemplateName"
|
||||
placeholder="请输入模板名称"
|
||||
:maxlength="50"
|
||||
show-count
|
||||
@press-enter="handleConfirmSaveStatusTemplate"
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</SaveStatusTemplateModal>
|
||||
</Modal>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -170,21 +170,40 @@ const handleCreateImportTask = () => {
|
||||
createImportTaskModalRef.value?.open(
|
||||
csvHeaders.value,
|
||||
currentFile.value ?? undefined,
|
||||
csvData.value,
|
||||
);
|
||||
};
|
||||
|
||||
// 清空数据
|
||||
const handleClearData = () => {
|
||||
csvData.value = [];
|
||||
csvHeaders.value = [];
|
||||
currentFile.value = null;
|
||||
// 更新表格
|
||||
updateTable();
|
||||
message.success('已清空数据');
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<!-- 顶部栏 -->
|
||||
<template #extra>
|
||||
<Button
|
||||
type="primary"
|
||||
:disabled="csvHeaders.length === 0"
|
||||
@click="handleCreateImportTask"
|
||||
>
|
||||
创建导入任务
|
||||
</Button>
|
||||
<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>
|
||||
</template>
|
||||
|
||||
<!-- 主体内容区域 -->
|
||||
|
||||
+53
-47
@@ -1,6 +1,5 @@
|
||||
<script lang="ts" setup>
|
||||
import type { OrderDTO, OrderVO } from '#/api/ecommerce/order';
|
||||
import type { OrderStatusVO } from '#/api/ecommerce/order-status';
|
||||
import type {
|
||||
ProductSpecDTO,
|
||||
ProductSpecVO,
|
||||
@@ -24,8 +23,12 @@ import {
|
||||
} from 'ant-design-vue';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import { createOrderApi, updateOrderApi } from '#/api/ecommerce/order';
|
||||
import { getActiveOrderStatusListApi } from '#/api/ecommerce/order-status';
|
||||
import {
|
||||
createOrderApi,
|
||||
updateOrderApi,
|
||||
} from '#/api/ecommerce/order';
|
||||
import { getAllOrderStatusListApi } from '#/api/ecommerce/order-status';
|
||||
import type { OrderStatusVO } from '#/api/ecommerce/order-status/types';
|
||||
import { getProductPageApi } from '#/api/ecommerce/product';
|
||||
import { getProductSpecPageApi } from '#/api/ecommerce/product-spec';
|
||||
import { getShopPageApi } from '#/api/ecommerce/shop';
|
||||
@@ -56,13 +59,13 @@ const currentRecord = ref<null | OrderVO.Info>(null);
|
||||
const formData = ref<Partial<OrderDTO.Create>>({
|
||||
shopId: undefined,
|
||||
platformOrderNo: '',
|
||||
statusId: undefined,
|
||||
statusId: undefined as number | undefined,
|
||||
receivedAmount: 0,
|
||||
orderDate: dayjs().format('YYYY-MM-DD'),
|
||||
orderTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
productId: undefined,
|
||||
productSpecId: undefined,
|
||||
productName: '',
|
||||
specName: '',
|
||||
linkProductName: '',
|
||||
linkSpecName: '',
|
||||
quantity: 1,
|
||||
unitPrice: 0,
|
||||
costPrice: 0,
|
||||
@@ -93,9 +96,11 @@ const rules = {
|
||||
receivedAmount: [
|
||||
{ required: true, message: '请输入实收金额', trigger: 'blur' },
|
||||
],
|
||||
orderDate: [{ required: true, message: '请选择下单时间', trigger: 'change' }],
|
||||
orderTime: [{ required: true, message: '请选择下单时间', trigger: 'change' }],
|
||||
productId: [{ required: true, message: '请选择商品', trigger: 'change' }],
|
||||
productName: [{ required: true, message: '请输入商品名称', trigger: 'blur' }],
|
||||
linkProductName: [
|
||||
{ required: true, message: '请输入链接商品名称', trigger: 'blur' },
|
||||
],
|
||||
quantity: [{ required: true, message: '请输入数量', trigger: 'blur' }],
|
||||
unitPrice: [{ required: true, message: '请输入销售单价', trigger: 'blur' }],
|
||||
costPrice: [{ required: true, message: '请输入成本价', trigger: 'blur' }],
|
||||
@@ -125,7 +130,7 @@ async function fetchShopOptions() {
|
||||
// 获取订单状态选项
|
||||
async function fetchOrderStatusOptions() {
|
||||
try {
|
||||
const data = await getActiveOrderStatusListApi();
|
||||
const data = await getAllOrderStatusListApi();
|
||||
orderStatusOptions.value = data.map((status: OrderStatusVO.Info) => ({
|
||||
label: status.statusName,
|
||||
value: status.id,
|
||||
@@ -199,14 +204,14 @@ function handleProductChange(productId: number | undefined) {
|
||||
(opt) => opt.value === productId,
|
||||
);
|
||||
if (selectedProduct) {
|
||||
formData.value.productName = selectedProduct.product.name;
|
||||
formData.value.linkProductName = selectedProduct.product.name;
|
||||
// 加载该商品的规格列表
|
||||
searchProductSpecs('');
|
||||
}
|
||||
} else {
|
||||
formData.value.productName = '';
|
||||
formData.value.linkProductName = '';
|
||||
formData.value.productSpecId = undefined;
|
||||
formData.value.specName = '';
|
||||
formData.value.linkSpecName = '';
|
||||
formData.value.costPrice = 0;
|
||||
productSpecOptions.value = [];
|
||||
}
|
||||
@@ -219,11 +224,11 @@ function handleProductSpecChange(specId: number | undefined) {
|
||||
(opt) => opt.value === specId,
|
||||
);
|
||||
if (selectedSpec) {
|
||||
formData.value.specName = selectedSpec.spec.name;
|
||||
formData.value.linkSpecName = selectedSpec.spec.name;
|
||||
formData.value.costPrice = selectedSpec.spec.costPrice;
|
||||
}
|
||||
} else {
|
||||
formData.value.specName = '';
|
||||
formData.value.linkSpecName = '';
|
||||
formData.value.costPrice = 0;
|
||||
}
|
||||
}
|
||||
@@ -247,8 +252,8 @@ async function open(edit: boolean, record?: OrderVO.Info) {
|
||||
currentRecord.value = record || null;
|
||||
|
||||
// 加载下拉选项数据
|
||||
fetchShopOptions();
|
||||
fetchOrderStatusOptions();
|
||||
await fetchShopOptions();
|
||||
await fetchOrderStatusOptions();
|
||||
|
||||
modalApi.open();
|
||||
|
||||
@@ -260,13 +265,13 @@ async function open(edit: boolean, record?: OrderVO.Info) {
|
||||
platformOrderNo: record.platformOrderNo || '',
|
||||
statusId: record.statusId,
|
||||
receivedAmount: record.receivedAmount,
|
||||
orderDate: record.orderDate
|
||||
? dayjs(record.orderDate).format('YYYY-MM-DD')
|
||||
: dayjs().format('YYYY-MM-DD'),
|
||||
orderTime: record.orderTime
|
||||
? dayjs(record.orderTime).format('YYYY-MM-DD HH:mm:ss')
|
||||
: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
productId: record.productId,
|
||||
productSpecId: record.productSpecId,
|
||||
productName: record.productName,
|
||||
specName: record.specName,
|
||||
linkProductName: record.linkProductName,
|
||||
linkSpecName: record.linkSpecName,
|
||||
quantity: record.quantity,
|
||||
unitPrice: record.unitPrice,
|
||||
costPrice: record.costPrice,
|
||||
@@ -276,11 +281,11 @@ async function open(edit: boolean, record?: OrderVO.Info) {
|
||||
platformOrderNo: '',
|
||||
statusId: undefined,
|
||||
receivedAmount: 0,
|
||||
orderDate: dayjs().format('YYYY-MM-DD'),
|
||||
orderTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
productId: undefined,
|
||||
productSpecId: undefined,
|
||||
productName: '',
|
||||
specName: '',
|
||||
linkProductName: '',
|
||||
linkSpecName: '',
|
||||
quantity: 1,
|
||||
unitPrice: 0,
|
||||
costPrice: 0,
|
||||
@@ -288,20 +293,20 @@ async function open(edit: boolean, record?: OrderVO.Info) {
|
||||
|
||||
// 如果是编辑模式且有商品ID,加载商品和规格选项
|
||||
if (edit && record?.productId) {
|
||||
await searchProducts(record.productName || '');
|
||||
await searchProducts(record.linkProductName || '');
|
||||
// 确保选中的商品在选项中
|
||||
if (!productOptions.value.some((opt) => opt.value === record.productId)) {
|
||||
productOptions.value.push({
|
||||
label: record.productName,
|
||||
label: record.linkProductName,
|
||||
value: record.productId,
|
||||
product: {
|
||||
id: record.productId,
|
||||
name: record.productName,
|
||||
name: record.linkProductName,
|
||||
} as ProductVO.Info,
|
||||
});
|
||||
}
|
||||
if (record.productSpecId) {
|
||||
await searchProductSpecs(record.specName || '');
|
||||
await searchProductSpecs(record.linkSpecName || '');
|
||||
// 确保选中的规格在选项中
|
||||
if (
|
||||
!productSpecOptions.value.some(
|
||||
@@ -309,11 +314,11 @@ async function open(edit: boolean, record?: OrderVO.Info) {
|
||||
)
|
||||
) {
|
||||
productSpecOptions.value.push({
|
||||
label: record.specName || '',
|
||||
label: record.linkSpecName || '',
|
||||
value: record.productSpecId,
|
||||
spec: {
|
||||
id: record.productSpecId,
|
||||
name: record.specName || '',
|
||||
name: record.linkSpecName || '',
|
||||
costPrice: record.costPrice,
|
||||
} as ProductSpecVO.Info,
|
||||
});
|
||||
@@ -342,11 +347,11 @@ async function handleSubmit() {
|
||||
platformOrderNo: formData.value.platformOrderNo,
|
||||
statusId: formData.value.statusId,
|
||||
receivedAmount: formData.value.receivedAmount!,
|
||||
orderDate: formData.value.orderDate!,
|
||||
orderTime: formData.value.orderTime!,
|
||||
productId: formData.value.productId,
|
||||
productSpecId: formData.value.productSpecId,
|
||||
productName: formData.value.productName,
|
||||
specName: formData.value.specName,
|
||||
linkProductName: formData.value.linkProductName,
|
||||
linkSpecName: formData.value.linkSpecName,
|
||||
quantity: formData.value.quantity,
|
||||
unitPrice: formData.value.unitPrice,
|
||||
costPrice: formData.value.costPrice,
|
||||
@@ -360,11 +365,11 @@ async function handleSubmit() {
|
||||
platformOrderNo: formData.value.platformOrderNo,
|
||||
statusId: formData.value.statusId!,
|
||||
receivedAmount: formData.value.receivedAmount!,
|
||||
orderDate: formData.value.orderDate!,
|
||||
orderTime: formData.value.orderTime!,
|
||||
productId: formData.value.productId!,
|
||||
productSpecId: formData.value.productSpecId,
|
||||
productName: formData.value.productName!,
|
||||
specName: formData.value.specName,
|
||||
linkProductName: formData.value.linkProductName!,
|
||||
linkSpecName: formData.value.linkSpecName,
|
||||
quantity: formData.value.quantity!,
|
||||
unitPrice: formData.value.unitPrice!,
|
||||
costPrice: formData.value.costPrice!,
|
||||
@@ -424,13 +429,14 @@ defineExpose({
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="下单时间" name="orderDate">
|
||||
<Form.Item label="下单时间" name="orderTime">
|
||||
<DatePicker
|
||||
v-model:value="formData.orderDate"
|
||||
v-model:value="formData.orderTime"
|
||||
placeholder="请选择下单时间"
|
||||
style="width: 100%"
|
||||
format="YYYY-MM-DD"
|
||||
value-format="YYYY-MM-DD"
|
||||
show-time
|
||||
format="YYYY-MM-DD HH:mm:ss"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
/>
|
||||
</Form.Item>
|
||||
</div>
|
||||
@@ -491,17 +497,17 @@ defineExpose({
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<Form.Item label="商品名称" name="productName">
|
||||
<Form.Item label="链接商品名称" name="linkProductName">
|
||||
<Input
|
||||
v-model:value="formData.productName"
|
||||
placeholder="请输入商品名称"
|
||||
v-model:value="formData.linkProductName"
|
||||
placeholder="请输入链接商品名称"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="规格名称" name="specName">
|
||||
<Form.Item label="链接规格名称" name="linkSpecName">
|
||||
<Input
|
||||
v-model:value="formData.specName"
|
||||
placeholder="请输入规格名称(可选)"
|
||||
v-model:value="formData.linkSpecName"
|
||||
placeholder="请输入链接规格名称"
|
||||
/>
|
||||
</Form.Item>
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import type { OrderDTO, OrderVO } from '#/api/ecommerce/order';
|
||||
import type { OrderStatusVO } from '#/api/ecommerce/order-status';
|
||||
import type { ShopVO } from '#/api/ecommerce/shop/types';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
@@ -13,8 +12,12 @@ import { createIconifyIcon } from '@vben/icons';
|
||||
import { Button, message, Popconfirm, Space, Tag } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { deleteOrderApi, getOrderPageApi } from '#/api/ecommerce/order';
|
||||
import { getActiveOrderStatusListApi } from '#/api/ecommerce/order-status';
|
||||
import {
|
||||
deleteOrderApi,
|
||||
getOrderPageApi,
|
||||
} from '#/api/ecommerce/order';
|
||||
import { getAllOrderStatusListApi } from '#/api/ecommerce/order-status';
|
||||
import type { OrderStatusVO } from '#/api/ecommerce/order-status/types';
|
||||
import { getShopPageApi } from '#/api/ecommerce/shop';
|
||||
|
||||
import OrderFormModal from './components/OrderFormModal.vue';
|
||||
@@ -79,7 +82,7 @@ const gridOptions: VxeGridProps<any> = {
|
||||
slots: { default: 'orderStatus' },
|
||||
},
|
||||
{
|
||||
field: 'orderDate',
|
||||
field: 'orderTime',
|
||||
title: '下单时间',
|
||||
minWidth: 'auto',
|
||||
},
|
||||
@@ -190,7 +193,7 @@ const formOptions = computed(() => ({
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
placeholder: '请选择状态',
|
||||
options: orderStatusOptions.value,
|
||||
options: orderStatusOptions,
|
||||
allowClear: true,
|
||||
},
|
||||
fieldName: 'statusId',
|
||||
@@ -230,7 +233,7 @@ async function fetchShopOptions() {
|
||||
// 获取订单状态选项
|
||||
async function fetchOrderStatusOptions() {
|
||||
try {
|
||||
const data = await getActiveOrderStatusListApi();
|
||||
const data = await getAllOrderStatusListApi();
|
||||
orderStatusOptions.value = data.map((status: OrderStatusVO.Info) => ({
|
||||
label: status.statusName,
|
||||
value: status.id,
|
||||
@@ -277,7 +280,8 @@ function handleModalSuccess() {
|
||||
|
||||
// 初始化
|
||||
onMounted(async () => {
|
||||
await Promise.all([fetchShopOptions(), fetchOrderStatusOptions()]);
|
||||
await fetchShopOptions();
|
||||
await fetchOrderStatusOptions();
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -297,10 +301,10 @@ onMounted(async () => {
|
||||
|
||||
<!-- 商品信息列 -->
|
||||
<template #productInfo="{ row }: { row: any }">
|
||||
<div v-if="row.productName">
|
||||
<div style="font-weight: bold">{{ row.productName }}</div>
|
||||
<div v-if="row.specName" style="color: #666; font-size: 12px">
|
||||
{{ row.specName }}
|
||||
<div v-if="row.linkProductName">
|
||||
<div style="font-weight: bold">{{ row.linkProductName }}</div>
|
||||
<div v-if="row.linkSpecName" style="color: #666; font-size: 12px">
|
||||
{{ row.linkSpecName }}
|
||||
</div>
|
||||
</div>
|
||||
<span v-else style="color: #999">暂无商品信息</span>
|
||||
@@ -321,11 +325,7 @@ onMounted(async () => {
|
||||
<!-- 订单状态列 -->
|
||||
<template #orderStatus="{ row }: { row: any }">
|
||||
<Tag color="blue">
|
||||
{{
|
||||
orderStatusOptions.find((s) => s.value === row.statusId)?.label ||
|
||||
row.statusName ||
|
||||
'未知状态'
|
||||
}}
|
||||
{{ row.statusName || '未知状态' }}
|
||||
</Tag>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -0,0 +1,526 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<!-- 修改: 禁止缩放,适应移动端全屏体验 -->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
<title>Grand Luxury Tree (Mouse Wheel Control)</title>
|
||||
<style>
|
||||
/* 修改: 禁用默认触摸动作,防止页面滚动 */
|
||||
body {
|
||||
margin: 0; overflow: hidden; background-color: #000000; font-family: 'Times New Roman', serif;
|
||||
touch-action: none;
|
||||
-webkit-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
#canvas-container { width: 100vw; height: 100vh; position: absolute; top: 0; left: 0; z-index: 1; }
|
||||
|
||||
/* Loading */
|
||||
#loader {
|
||||
position: absolute; top: 0; left: 0; width: 100%; height: 100%;
|
||||
background: #000; z-index: 100;
|
||||
display: flex; flex-direction: column; align-items: center; justify-content: center;
|
||||
transition: opacity 0.8s ease-out;
|
||||
}
|
||||
.loader-text {
|
||||
color: #d4af37; font-size: 14px; letter-spacing: 4px; margin-top: 20px;
|
||||
text-transform: uppercase; font-weight: 100;
|
||||
}
|
||||
.spinner {
|
||||
width: 40px; height: 40px; border: 1px solid rgba(212, 175, 55, 0.2);
|
||||
border-top: 1px solid #d4af37; border-radius: 50%;
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
|
||||
|
||||
#file-input { display: none; }
|
||||
</style>
|
||||
|
||||
<script type="importmap">
|
||||
{
|
||||
"imports": {
|
||||
"three": "https://cdn.jsdelivr.net/npm/three@0.160.0/build/three.module.js",
|
||||
"three/addons/": "https://cdn.jsdelivr.net/npm/three@0.160.0/examples/jsm/"
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="loader">
|
||||
<div class="spinner"></div>
|
||||
<div class="loader-text">Loading Holiday Magic</div>
|
||||
</div>
|
||||
|
||||
<div id="canvas-container"></div>
|
||||
<input type="file" id="file-input" multiple accept="image/*">
|
||||
|
||||
<script type="module">
|
||||
import * as THREE from 'three';
|
||||
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
|
||||
import { EffectComposer } from 'three/addons/postprocessing/EffectComposer.js';
|
||||
import { RenderPass } from 'three/addons/postprocessing/RenderPass.js';
|
||||
import { UnrealBloomPass } from 'three/addons/postprocessing/UnrealBloomPass.js';
|
||||
import { RoomEnvironment } from 'three/addons/environments/RoomEnvironment.js';
|
||||
|
||||
// --- CONFIGURATION ---
|
||||
const CONFIG = {
|
||||
colors: {
|
||||
bg: 0x000000,
|
||||
champagneGold: 0xffd966,
|
||||
deepGreen: 0x03180a,
|
||||
accentRed: 0x990000,
|
||||
},
|
||||
particles: {
|
||||
count: 1500,
|
||||
dustCount: 2500,
|
||||
treeHeight: 24,
|
||||
treeRadius: 8
|
||||
},
|
||||
camera: {
|
||||
z: 50
|
||||
}
|
||||
};
|
||||
|
||||
const STATE = {
|
||||
mode: 'TREE',
|
||||
focusIndex: -1,
|
||||
focusTarget: null,
|
||||
rotation: { x: 0, y: 0 },
|
||||
mouse: { x: 0, y: 0 } // 归一化鼠标坐标 (-1 到 1)
|
||||
};
|
||||
|
||||
let scene, camera, renderer, composer;
|
||||
let mainGroup;
|
||||
let clock = new THREE.Clock();
|
||||
let particleSystem = [];
|
||||
let photoMeshGroup = new THREE.Group();
|
||||
let caneTexture;
|
||||
|
||||
// Interaction variables
|
||||
const raycaster = new THREE.Raycaster();
|
||||
const pointer = new THREE.Vector2();
|
||||
|
||||
async function init() {
|
||||
initThree();
|
||||
setupEnvironment();
|
||||
setupLights();
|
||||
createTextures();
|
||||
createParticles();
|
||||
createDust();
|
||||
createDefaultPhotos();
|
||||
setupPostProcessing();
|
||||
setupEvents();
|
||||
|
||||
const loader = document.getElementById('loader');
|
||||
loader.style.opacity = 0;
|
||||
setTimeout(() => loader.remove(), 800);
|
||||
|
||||
animate();
|
||||
}
|
||||
|
||||
function initThree() {
|
||||
const container = document.getElementById('canvas-container');
|
||||
scene = new THREE.Scene();
|
||||
scene.background = new THREE.Color(CONFIG.colors.bg);
|
||||
scene.fog = new THREE.FogExp2(CONFIG.colors.bg, 0.01);
|
||||
|
||||
// 适应移动端纵横比
|
||||
camera = new THREE.PerspectiveCamera(42, window.innerWidth / window.innerHeight, 0.1, 1000);
|
||||
camera.position.set(0, 2, CONFIG.camera.z);
|
||||
|
||||
renderer = new THREE.WebGLRenderer({ antialias: true, alpha: false, powerPreference: "high-performance" });
|
||||
renderer.setSize(window.innerWidth, window.innerHeight);
|
||||
// 限制像素比以提升移动端性能
|
||||
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
|
||||
renderer.toneMapping = THREE.ReinhardToneMapping;
|
||||
renderer.toneMappingExposure = 2.2;
|
||||
container.appendChild(renderer.domElement);
|
||||
|
||||
mainGroup = new THREE.Group();
|
||||
scene.add(mainGroup);
|
||||
}
|
||||
|
||||
function setupEnvironment() {
|
||||
const pmremGenerator = new THREE.PMREMGenerator(renderer);
|
||||
scene.environment = pmremGenerator.fromScene(new RoomEnvironment(), 0.04).texture;
|
||||
}
|
||||
|
||||
function setupLights() {
|
||||
const ambient = new THREE.AmbientLight(0xffffff, 0.6);
|
||||
scene.add(ambient);
|
||||
|
||||
const innerLight = new THREE.PointLight(0xffaa00, 2, 20);
|
||||
innerLight.position.set(0, 5, 0);
|
||||
mainGroup.add(innerLight);
|
||||
|
||||
const spotGold = new THREE.SpotLight(0xffcc66, 1200);
|
||||
spotGold.position.set(30, 40, 40);
|
||||
spotGold.angle = 0.5;
|
||||
spotGold.penumbra = 0.5;
|
||||
scene.add(spotGold);
|
||||
|
||||
const spotBlue = new THREE.SpotLight(0x6688ff, 600);
|
||||
spotBlue.position.set(-30, 20, -30);
|
||||
scene.add(spotBlue);
|
||||
|
||||
const fill = new THREE.DirectionalLight(0xffeebb, 0.8);
|
||||
fill.position.set(0, 0, 50);
|
||||
scene.add(fill);
|
||||
}
|
||||
|
||||
function setupPostProcessing() {
|
||||
const renderScene = new RenderPass(scene, camera);
|
||||
const bloomPass = new UnrealBloomPass(new THREE.Vector2(window.innerWidth, window.innerHeight), 1.5, 0.4, 0.85);
|
||||
bloomPass.threshold = 0.7;
|
||||
bloomPass.strength = 0.45;
|
||||
bloomPass.radius = 0.4;
|
||||
|
||||
composer = new EffectComposer(renderer);
|
||||
composer.addPass(renderScene);
|
||||
composer.addPass(bloomPass);
|
||||
}
|
||||
|
||||
function createTextures() {
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.width = 128; canvas.height = 128;
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.fillStyle = '#ffffff';
|
||||
ctx.fillRect(0,0,128,128);
|
||||
ctx.fillStyle = '#880000';
|
||||
ctx.beginPath();
|
||||
for(let i=-128; i<256; i+=32) {
|
||||
ctx.moveTo(i, 0); ctx.lineTo(i+32, 128); ctx.lineTo(i+16, 128); ctx.lineTo(i-16, 0);
|
||||
}
|
||||
ctx.fill();
|
||||
caneTexture = new THREE.CanvasTexture(canvas);
|
||||
caneTexture.wrapS = THREE.RepeatWrapping;
|
||||
caneTexture.wrapT = THREE.RepeatWrapping;
|
||||
caneTexture.repeat.set(3, 3);
|
||||
}
|
||||
|
||||
class Particle {
|
||||
constructor(mesh, type, isDust = false) {
|
||||
this.mesh = mesh;
|
||||
this.type = type;
|
||||
this.isDust = isDust;
|
||||
|
||||
this.posTree = new THREE.Vector3();
|
||||
this.posScatter = new THREE.Vector3();
|
||||
this.baseScale = mesh.scale.x;
|
||||
|
||||
const speedMult = (type === 'PHOTO') ? 0.3 : 2.0;
|
||||
|
||||
this.spinSpeed = new THREE.Vector3(
|
||||
(Math.random() - 0.5) * speedMult,
|
||||
(Math.random() - 0.5) * speedMult,
|
||||
(Math.random() - 0.5) * speedMult
|
||||
);
|
||||
|
||||
this.calculatePositions();
|
||||
}
|
||||
|
||||
calculatePositions() {
|
||||
const h = CONFIG.particles.treeHeight;
|
||||
const halfH = h / 2;
|
||||
let t = Math.random();
|
||||
t = Math.pow(t, 0.8);
|
||||
const y = (t * h) - halfH;
|
||||
let rMax = CONFIG.particles.treeRadius * (1.0 - t);
|
||||
if (rMax < 0.5) rMax = 0.5;
|
||||
const angle = t * 50 * Math.PI + Math.random() * Math.PI;
|
||||
const r = rMax * (0.8 + Math.random() * 0.4);
|
||||
this.posTree.set(Math.cos(angle) * r, y, Math.sin(angle) * r);
|
||||
|
||||
let rScatter = this.isDust ? (12 + Math.random()*20) : (8 + Math.random()*12);
|
||||
const theta = Math.random() * Math.PI * 2;
|
||||
const phi = Math.acos(2 * Math.random() - 1);
|
||||
this.posScatter.set(
|
||||
rScatter * Math.sin(phi) * Math.cos(theta),
|
||||
rScatter * Math.sin(phi) * Math.sin(theta),
|
||||
rScatter * Math.cos(phi)
|
||||
);
|
||||
}
|
||||
|
||||
update(dt, mode, focusTargetMesh) {
|
||||
let target = this.posTree;
|
||||
|
||||
if (mode === 'SCATTER') target = this.posScatter;
|
||||
else if (mode === 'FOCUS') {
|
||||
if (this.mesh === focusTargetMesh) {
|
||||
const desiredWorldPos = new THREE.Vector3(0, 2, 35);
|
||||
const invMatrix = new THREE.Matrix4().copy(mainGroup.matrixWorld).invert();
|
||||
target = desiredWorldPos.applyMatrix4(invMatrix);
|
||||
} else {
|
||||
target = this.posScatter;
|
||||
}
|
||||
}
|
||||
|
||||
const lerpSpeed = (mode === 'FOCUS' && this.mesh === focusTargetMesh) ? 5.0 : 2.0;
|
||||
this.mesh.position.lerp(target, lerpSpeed * dt);
|
||||
|
||||
if (mode === 'SCATTER') {
|
||||
this.mesh.rotation.x += this.spinSpeed.x * dt;
|
||||
this.mesh.rotation.y += this.spinSpeed.y * dt;
|
||||
this.mesh.rotation.z += this.spinSpeed.z * dt;
|
||||
} else if (mode === 'TREE') {
|
||||
this.mesh.rotation.x = THREE.MathUtils.lerp(this.mesh.rotation.x, 0, dt);
|
||||
this.mesh.rotation.z = THREE.MathUtils.lerp(this.mesh.rotation.z, 0, dt);
|
||||
this.mesh.rotation.y += 0.5 * dt;
|
||||
}
|
||||
|
||||
if (mode === 'FOCUS' && this.mesh === focusTargetMesh) {
|
||||
this.mesh.lookAt(camera.position);
|
||||
}
|
||||
|
||||
let s = this.baseScale;
|
||||
if (this.isDust) {
|
||||
s = this.baseScale * (0.8 + 0.4 * Math.sin(clock.elapsedTime * 4 + this.mesh.id));
|
||||
if (mode === 'TREE') s = 0;
|
||||
} else if (mode === 'SCATTER' && this.type === 'PHOTO') {
|
||||
s = this.baseScale * 2.5;
|
||||
} else if (mode === 'FOCUS') {
|
||||
if (this.mesh === focusTargetMesh) s = 4.5;
|
||||
else s = this.baseScale * 0.8;
|
||||
}
|
||||
|
||||
this.mesh.scale.lerp(new THREE.Vector3(s,s,s), 4*dt);
|
||||
}
|
||||
}
|
||||
|
||||
// --- CREATION ---
|
||||
function createParticles() {
|
||||
const sphereGeo = new THREE.SphereGeometry(0.5, 32, 32);
|
||||
const boxGeo = new THREE.BoxGeometry(0.55, 0.55, 0.55);
|
||||
const curve = new THREE.CatmullRomCurve3([
|
||||
new THREE.Vector3(0, -0.5, 0), new THREE.Vector3(0, 0.3, 0),
|
||||
new THREE.Vector3(0.1, 0.5, 0), new THREE.Vector3(0.3, 0.4, 0)
|
||||
]);
|
||||
const candyGeo = new THREE.TubeGeometry(curve, 16, 0.08, 8, false);
|
||||
|
||||
const goldMat = new THREE.MeshStandardMaterial({
|
||||
color: CONFIG.colors.champagneGold,
|
||||
metalness: 1.0, roughness: 0.1,
|
||||
envMapIntensity: 2.0,
|
||||
emissive: 0x443300,
|
||||
emissiveIntensity: 0.3
|
||||
});
|
||||
|
||||
const greenMat = new THREE.MeshStandardMaterial({
|
||||
color: CONFIG.colors.deepGreen,
|
||||
metalness: 0.2, roughness: 0.8,
|
||||
emissive: 0x002200,
|
||||
emissiveIntensity: 0.2
|
||||
});
|
||||
|
||||
const redMat = new THREE.MeshPhysicalMaterial({
|
||||
color: CONFIG.colors.accentRed,
|
||||
metalness: 0.3, roughness: 0.2, clearcoat: 1.0,
|
||||
emissive: 0x330000
|
||||
});
|
||||
|
||||
const candyMat = new THREE.MeshStandardMaterial({ map: caneTexture, roughness: 0.4 });
|
||||
|
||||
for (let i = 0; i < CONFIG.particles.count; i++) {
|
||||
const rand = Math.random();
|
||||
let mesh, type;
|
||||
|
||||
if (rand < 0.40) {
|
||||
mesh = new THREE.Mesh(boxGeo, greenMat);
|
||||
type = 'BOX';
|
||||
} else if (rand < 0.70) {
|
||||
mesh = new THREE.Mesh(boxGeo, goldMat);
|
||||
type = 'GOLD_BOX';
|
||||
} else if (rand < 0.92) {
|
||||
mesh = new THREE.Mesh(sphereGeo, goldMat);
|
||||
type = 'GOLD_SPHERE';
|
||||
} else if (rand < 0.97) {
|
||||
mesh = new THREE.Mesh(sphereGeo, redMat);
|
||||
type = 'RED';
|
||||
} else {
|
||||
mesh = new THREE.Mesh(candyGeo, candyMat);
|
||||
type = 'CANE';
|
||||
}
|
||||
|
||||
const s = 0.4 + Math.random() * 0.5;
|
||||
mesh.scale.set(s,s,s);
|
||||
mesh.rotation.set(Math.random()*6, Math.random()*6, Math.random()*6);
|
||||
|
||||
mainGroup.add(mesh);
|
||||
particleSystem.push(new Particle(mesh, type, false));
|
||||
}
|
||||
|
||||
const starGeo = new THREE.OctahedronGeometry(1.2, 0);
|
||||
const starMat = new THREE.MeshStandardMaterial({
|
||||
color: 0xffdd88, emissive: 0xffaa00, emissiveIntensity: 1.0,
|
||||
metalness: 1.0, roughness: 0
|
||||
});
|
||||
const star = new THREE.Mesh(starGeo, starMat);
|
||||
star.position.set(0, CONFIG.particles.treeHeight/2 + 1.2, 0);
|
||||
mainGroup.add(star);
|
||||
|
||||
mainGroup.add(photoMeshGroup);
|
||||
}
|
||||
|
||||
function createDust() {
|
||||
const geo = new THREE.TetrahedronGeometry(0.08, 0);
|
||||
const mat = new THREE.MeshBasicMaterial({ color: 0xffeebb, transparent: true, opacity: 0.8 });
|
||||
|
||||
for(let i=0; i<CONFIG.particles.dustCount; i++) {
|
||||
const mesh = new THREE.Mesh(geo, mat);
|
||||
mesh.scale.setScalar(0.5 + Math.random());
|
||||
mainGroup.add(mesh);
|
||||
particleSystem.push(new Particle(mesh, 'DUST', true));
|
||||
}
|
||||
}
|
||||
|
||||
function createDefaultPhotos() {
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.width = 512; canvas.height = 512;
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.fillStyle = '#050505'; ctx.fillRect(0,0,512,512);
|
||||
ctx.strokeStyle = '#eebb66'; ctx.lineWidth = 15; ctx.strokeRect(20,20,472,472);
|
||||
ctx.font = '500 60px Times New Roman'; ctx.fillStyle = '#eebb66';
|
||||
ctx.textAlign = 'center';
|
||||
ctx.fillText("JOYEUX", 256, 230);
|
||||
ctx.fillText("NOEL", 256, 300);
|
||||
|
||||
const tex = new THREE.CanvasTexture(canvas);
|
||||
tex.colorSpace = THREE.SRGBColorSpace;
|
||||
addPhotoToScene(tex);
|
||||
}
|
||||
|
||||
function addPhotoToScene(texture) {
|
||||
const frameGeo = new THREE.BoxGeometry(1.4, 1.4, 0.05);
|
||||
const frameMat = new THREE.MeshStandardMaterial({ color: CONFIG.colors.champagneGold, metalness: 1.0, roughness: 0.1 });
|
||||
const frame = new THREE.Mesh(frameGeo, frameMat);
|
||||
|
||||
const photoGeo = new THREE.PlaneGeometry(1.2, 1.2);
|
||||
const photoMat = new THREE.MeshBasicMaterial({ map: texture });
|
||||
const photo = new THREE.Mesh(photoGeo, photoMat);
|
||||
photo.position.z = 0.04;
|
||||
|
||||
const group = new THREE.Group();
|
||||
group.add(frame);
|
||||
group.add(photo);
|
||||
|
||||
const s = 0.8;
|
||||
group.scale.set(s,s,s);
|
||||
|
||||
photoMeshGroup.add(group);
|
||||
particleSystem.push(new Particle(group, 'PHOTO', false));
|
||||
}
|
||||
|
||||
// --- INTERACTION ---
|
||||
function handleImageUpload(e) {
|
||||
const files = e.target.files;
|
||||
if(!files.length) return;
|
||||
Array.from(files).forEach(f => {
|
||||
const reader = new FileReader();
|
||||
reader.onload = (ev) => {
|
||||
new THREE.TextureLoader().load(ev.target.result, (t) => {
|
||||
t.colorSpace = THREE.SRGBColorSpace;
|
||||
addPhotoToScene(t);
|
||||
});
|
||||
}
|
||||
reader.readAsDataURL(f);
|
||||
});
|
||||
}
|
||||
|
||||
function onPointerDown(event) {
|
||||
// 触摸/点击坐标标准化
|
||||
pointer.x = (event.clientX / window.innerWidth) * 2 - 1;
|
||||
pointer.y = - (event.clientY / window.innerHeight) * 2 + 1;
|
||||
|
||||
raycaster.setFromCamera(pointer, camera);
|
||||
|
||||
const intersects = raycaster.intersectObjects(photoMeshGroup.children, true);
|
||||
|
||||
if (intersects.length > 0) {
|
||||
let target = intersects[0].object;
|
||||
while(target.parent !== photoMeshGroup && target.parent !== null) {
|
||||
target = target.parent;
|
||||
}
|
||||
|
||||
if (target.parent === photoMeshGroup) {
|
||||
STATE.focusTarget = target;
|
||||
STATE.mode = 'FOCUS';
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (STATE.mode === 'FOCUS') {
|
||||
STATE.mode = 'TREE';
|
||||
STATE.focusTarget = null;
|
||||
}
|
||||
}
|
||||
|
||||
function onDoubleClick(event) {
|
||||
// 双击触发文件选择
|
||||
document.getElementById('file-input').click();
|
||||
}
|
||||
|
||||
function onWheel(event) {
|
||||
event.preventDefault();
|
||||
// 滚轮向上:展开(SCATTER模式),滚轮向下:收起(TREE模式)
|
||||
if (event.deltaY < 0) {
|
||||
// 向上滚动,切换到 SCATTER 模式
|
||||
STATE.mode = 'SCATTER';
|
||||
STATE.focusTarget = null;
|
||||
} else {
|
||||
// 向下滚动,切换到 TREE 模式
|
||||
STATE.mode = 'TREE';
|
||||
STATE.focusTarget = null;
|
||||
}
|
||||
}
|
||||
|
||||
function onMouseMove(event) {
|
||||
// 将鼠标坐标归一化到 -1 到 1 的范围
|
||||
STATE.mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
|
||||
STATE.mouse.y = -(event.clientY / window.innerHeight) * 2 + 1;
|
||||
}
|
||||
|
||||
function setupEvents() {
|
||||
window.addEventListener('resize', () => {
|
||||
camera.aspect = window.innerWidth / window.innerHeight;
|
||||
camera.updateProjectionMatrix();
|
||||
renderer.setSize(window.innerWidth, window.innerHeight);
|
||||
composer.setSize(window.innerWidth, window.innerHeight);
|
||||
});
|
||||
|
||||
document.getElementById('file-input').addEventListener('change', handleImageUpload);
|
||||
|
||||
window.addEventListener('pointerdown', onPointerDown);
|
||||
window.addEventListener('dblclick', onDoubleClick);
|
||||
window.addEventListener('wheel', onWheel, { passive: false });
|
||||
window.addEventListener('mousemove', onMouseMove);
|
||||
}
|
||||
|
||||
function animate() {
|
||||
requestAnimationFrame(animate);
|
||||
const dt = clock.getDelta();
|
||||
|
||||
if (STATE.mode === 'SCATTER') {
|
||||
// SCATTER 模式下,根据鼠标位置控制旋转
|
||||
const targetRotY = STATE.mouse.x * Math.PI * 0.9;
|
||||
const targetRotX = STATE.mouse.y * Math.PI * 0.25;
|
||||
STATE.rotation.y += (targetRotY - STATE.rotation.y) * 3.0 * dt;
|
||||
STATE.rotation.x += (targetRotX - STATE.rotation.x) * 3.0 * dt;
|
||||
} else if(STATE.mode === 'TREE') {
|
||||
STATE.rotation.y += 0.3 * dt;
|
||||
STATE.rotation.x += (0 - STATE.rotation.x) * 2.0 * dt;
|
||||
} else {
|
||||
STATE.rotation.y += 0.1 * dt;
|
||||
}
|
||||
|
||||
mainGroup.rotation.y = STATE.rotation.y;
|
||||
mainGroup.rotation.x = STATE.rotation.x;
|
||||
|
||||
particleSystem.forEach(p => p.update(dt, STATE.mode, STATE.focusTarget));
|
||||
composer.render();
|
||||
}
|
||||
|
||||
init();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user