From dfc6de49e0ad9a7e5d197994b616459144dfc56b Mon Sep 17 00:00:00 2001 From: ah--desktop Date: Fri, 31 Oct 2025 22:42:03 +0800 Subject: [PATCH] =?UTF-8?q?prettier:=20=E4=BB=A3=E7=A0=81=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apps/web-antd/src/api/core/auth.ts | 21 +- .../web-antd/src/api/core/organization.ts | 80 +- .../apps/web-antd/src/api/core/user.ts | 3 +- .../apps/web-antd/src/api/ecommerce/index.ts | 6 +- .../src/api/ecommerce/order-status.apis.ts | 8 +- .../web-antd/src/api/ecommerce/order.apis.ts | 17 +- .../api/ecommerce/promotion-fee-type.apis.ts | 28 +- .../web-antd/src/api/ecommerce/types/index.ts | 2 +- .../src/components/CompanyMenuDrawer.vue | 297 ++--- .../src/components/SwitchAccountModal.vue | 364 +++--- .../apps/web-antd/src/layouts/basic.vue | 12 +- .../apps/web-antd/src/store/auth.ts | 39 +- .../apps/web-antd/src/utils/csv-utils.ts | 165 +-- .../views/_core/authentication/register.vue | 6 +- .../views/ecommerce/data-analysis/index.vue | 27 +- .../components/EntityCreationModal.vue | 301 +++-- .../data-import/components/FieldMapping.vue | 227 ++-- .../components/FieldMappingModal.vue | 669 +++++----- .../data-import/components/FileUploadArea.vue | 190 +-- .../components/FileUploadModal.vue | 321 ++--- .../components/MatchSwitchModal.vue | 577 +++++---- .../src/views/ecommerce/data-import/index.vue | 1073 +++++++++-------- .../services/EntityMatchingService.ts | 559 +++++---- .../ecommerce/data-import/utils/csvParser.ts | 120 +- .../media/file/components/FileEditModal.vue | 159 +-- .../web-antd/src/views/media/file/index.vue | 114 +- .../media/image/components/ImageCard.vue | 123 -- .../media/image/components/ImageEditModal.vue | 160 +-- .../media/image/components/ImageGridView.vue | 272 ----- .../web-antd/src/views/media/image/index.vue | 188 +-- .../ImageGridView/components/ImageCard.vue | 191 +++ .../media/image/views/ImageGridView/index.vue | 247 ++++ .../components/SuperAccountFormModal.vue | 159 ++- .../organization/account-super/index.vue | 107 +- .../account/components/AccountFormModal.vue | 141 ++- .../src/views/organization/account/index.vue | 94 +- .../company/components/CompanyFormModal.vue | 363 +++--- .../src/views/organization/company/index.vue | 95 +- .../department/components/DepartmentModal.vue | 81 +- .../views/organization/department/index.vue | 89 +- .../position-permission/index.vue | 540 +++++---- .../position/components/PositionModal.vue | 55 +- .../src/views/organization/position/index.vue | 61 +- .../components/OrderStatusFormModal.vue | 84 +- .../shop/config/order-status-config/index.vue | 33 +- .../components/PromotionFeeTypeFormModal.vue | 98 +- .../promotion-fee-type-config/index.vue | 37 +- .../shop/order/components/OrderFormModal.vue | 191 +-- .../web-antd/src/views/shop/order/index.vue | 104 +- .../shop/product/components/ProductCard.vue | 120 +- .../product/components/ProductFormModal.vue | 452 ++++--- .../product/components/ProductSpecModal.vue | 268 ++-- .../web-antd/src/views/shop/product/index.vue | 449 +++---- .../components/PromotionFeeFormModal.vue | 427 +++---- .../src/views/shop/promotion-fee/index.vue | 87 +- .../shop/shop/components/ShopFormModal.vue | 184 ++- .../web-antd/src/views/shop/shop/index.vue | 75 +- .../system/menu/components/IconSelector.vue | 673 +++++++---- .../system/menu/components/MenuFormModal.vue | 186 +-- .../web-antd/src/views/system/menu/index.vue | 65 +- .../components/PermissionFormModal.vue | 96 +- .../src/views/system/permission/index.vue | 90 +- 62 files changed, 6814 insertions(+), 5256 deletions(-) delete mode 100644 ecom-dmb-frontend/apps/web-antd/src/views/media/image/components/ImageCard.vue delete mode 100644 ecom-dmb-frontend/apps/web-antd/src/views/media/image/components/ImageGridView.vue create mode 100644 ecom-dmb-frontend/apps/web-antd/src/views/media/image/views/ImageGridView/components/ImageCard.vue create mode 100644 ecom-dmb-frontend/apps/web-antd/src/views/media/image/views/ImageGridView/index.vue diff --git a/ecom-dmb-frontend/apps/web-antd/src/api/core/auth.ts b/ecom-dmb-frontend/apps/web-antd/src/api/core/auth.ts index ca90dc6c..e18a190b 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/api/core/auth.ts +++ b/ecom-dmb-frontend/apps/web-antd/src/api/core/auth.ts @@ -1,6 +1,7 @@ -import { baseRequestClient, requestClient } from '#/api/request'; import { useAccessStore } from '@vben/stores'; +import { baseRequestClient, requestClient } from '#/api/request'; + export namespace AuthApi { /** 登录接口参数 */ export interface LoginParams { @@ -73,16 +74,20 @@ export async function loginApi(data: AuthApi.LoginParams) { */ export async function refreshTokenApi() { const accessStore = useAccessStore(); - + if (!accessStore.refreshToken) { throw new Error('RefreshToken不存在,无法刷新token'); } - - return baseRequestClient.post('/auth/refresh', { - refreshToken: accessStore.refreshToken, - }, { - withCredentials: true, - }); + + return baseRequestClient.post( + '/auth/refresh', + { + refreshToken: accessStore.refreshToken, + }, + { + withCredentials: true, + }, + ); } /** diff --git a/ecom-dmb-frontend/apps/web-antd/src/api/core/organization.ts b/ecom-dmb-frontend/apps/web-antd/src/api/core/organization.ts index 57abb840..28b13fb0 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/api/core/organization.ts +++ b/ecom-dmb-frontend/apps/web-antd/src/api/core/organization.ts @@ -1,7 +1,7 @@ -import { requestClient } from '#/api/request'; - import type { PageQueryDTO, PageResultVO } from '#/types/common'; +import { requestClient } from '#/api/request'; + export namespace CompanyApi { /** 公司信息 */ export interface CompanyInfo { @@ -135,52 +135,92 @@ export namespace PositionApi { } // 公司管理API -export async function getCompanyPageApi(params: PageQueryDTO) { - return requestClient.post>('/company/page', params); +export async function getCompanyPageApi( + params: PageQueryDTO, +) { + return requestClient.post>( + '/company/page', + params, + ); } export async function createCompanyApi(data: CompanyApi.CreateCompanyParams) { return requestClient.post('/company/create', data); } -export async function updateCompanyApi(id: number, data: CompanyApi.UpdateCompanyParams) { - return requestClient.put(`/company/update/${id}`, data); +export async function updateCompanyApi( + id: number, + data: CompanyApi.UpdateCompanyParams, +) { + return requestClient.put( + `/company/update/${id}`, + data, + ); } export async function deleteCompanyApi(id: number) { - return requestClient.delete(`/company/delete/${id}`); + return requestClient.delete(`/company/delete/${id}`); } // 部门管理API -export async function getDepartmentPageApi(params: PageQueryDTO) { - return requestClient.post>('/department/page', params); +export async function getDepartmentPageApi( + params: PageQueryDTO, +) { + return requestClient.post>( + '/department/page', + params, + ); } -export async function createDepartmentApi(data: DepartmentApi.CreateDepartmentParams) { - return requestClient.post('/department/create', data); +export async function createDepartmentApi( + data: DepartmentApi.CreateDepartmentParams, +) { + return requestClient.post( + '/department/create', + data, + ); } -export async function updateDepartmentApi(id: number, data: DepartmentApi.UpdateDepartmentParams) { - return requestClient.put(`/department/update/${id}`, data); +export async function updateDepartmentApi( + id: number, + data: DepartmentApi.UpdateDepartmentParams, +) { + return requestClient.put( + `/department/update/${id}`, + data, + ); } export async function deleteDepartmentApi(id: number) { - return requestClient.delete(`/department/delete/${id}`); + return requestClient.delete(`/department/delete/${id}`); } // 岗位管理API -export async function getPositionPageApi(params: PageQueryDTO) { - return requestClient.post>('/position/page', params); +export async function getPositionPageApi( + params: PageQueryDTO, +) { + return requestClient.post>( + '/position/page', + params, + ); } -export async function createPositionApi(data: PositionApi.CreatePositionParams) { +export async function createPositionApi( + data: PositionApi.CreatePositionParams, +) { return requestClient.post('/position/create', data); } -export async function updatePositionApi(id: number, data: PositionApi.UpdatePositionParams) { - return requestClient.put(`/position/update/${id}`, data); +export async function updatePositionApi( + id: number, + data: PositionApi.UpdatePositionParams, +) { + return requestClient.put( + `/position/update/${id}`, + data, + ); } export async function deletePositionApi(id: number) { - return requestClient.delete(`/position/delete/${id}`); + return requestClient.delete(`/position/delete/${id}`); } diff --git a/ecom-dmb-frontend/apps/web-antd/src/api/core/user.ts b/ecom-dmb-frontend/apps/web-antd/src/api/core/user.ts index a429e34f..a1714c64 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/api/core/user.ts +++ b/ecom-dmb-frontend/apps/web-antd/src/api/core/user.ts @@ -1,5 +1,4 @@ -import type { UserInfo } from '@vben/types'; -import type { RouteRecordStringComponent } from '@vben/types'; +import type { RouteRecordStringComponent, UserInfo } from '@vben/types'; import { requestClient } from '#/api/request'; diff --git a/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/index.ts b/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/index.ts index c74de9a8..2608dc1b 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/index.ts +++ b/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/index.ts @@ -2,11 +2,11 @@ * 电商模块API导出 */ -// 订单相关API -export * from './order.apis'; - // 订单状态相关API export * from './order-status.apis'; +// 订单相关API +export * from './order.apis'; + // 推广费类型相关API export * from './promotion-fee-type.apis'; diff --git a/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/order-status.apis.ts b/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/order-status.apis.ts index 8f5df6ac..bfeb6770 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/order-status.apis.ts +++ b/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/order-status.apis.ts @@ -1,7 +1,7 @@ -import { requestClient } from '#/api/request'; - import type { OrderStatusDTO, OrderStatusVO } from './types'; +import { requestClient } from '#/api/request'; + /** * 订单状态管理API */ @@ -17,14 +17,14 @@ export async function createOrderStatusApi(data: OrderStatusDTO.Create) { * 更新订单状态 */ export async function updateOrderStatusApi(data: OrderStatusDTO.Update) { - return requestClient.put('/ec/order-status', data); + return requestClient.put('/ec/order-status', data); } /** * 删除订单状态 */ export async function deleteOrderStatusApi(id: number) { - return requestClient.delete(`/ec/order-status/${id}`); + return requestClient.delete(`/ec/order-status/${id}`); } /** diff --git a/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/order.apis.ts b/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/order.apis.ts index 635bb4ac..a1ad1dbd 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/order.apis.ts +++ b/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/order.apis.ts @@ -1,7 +1,8 @@ -import { requestClient } from '#/api/request'; +import type { BatchImportResultVO, OrderDTO, OrderVO } from './types'; import type { PageQueryDTO, PageResultVO } from '#/types/common'; -import type { OrderDTO, OrderVO, BatchImportResultVO } from './types'; + +import { requestClient } from '#/api/request'; /** * 订单管理API @@ -11,7 +12,10 @@ import type { OrderDTO, OrderVO, BatchImportResultVO } from './types'; * 分页获取订单列表 */ export async function getOrderPageApi(params: PageQueryDTO) { - return requestClient.post>('/ec/order/page', params); + return requestClient.post>( + '/ec/order/page', + params, + ); } /** @@ -32,7 +36,7 @@ export async function updateOrderApi(id: number, data: OrderDTO.Update) { * 删除订单 */ export async function deleteOrderApi(id: number) { - return requestClient.delete(`/ec/order/delete/${id}`); + return requestClient.delete(`/ec/order/delete/${id}`); } /** @@ -46,5 +50,8 @@ export async function getOrderByIdApi(id: number) { * 批量导入订单 */ export async function batchImportOrdersApi(data: OrderDTO.BatchImport) { - return requestClient.post('/ec/order/batch-import', data); + return requestClient.post( + '/ec/order/batch-import', + data, + ); } diff --git a/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/promotion-fee-type.apis.ts b/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/promotion-fee-type.apis.ts index 6cf2e07f..2a9f4373 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/promotion-fee-type.apis.ts +++ b/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/promotion-fee-type.apis.ts @@ -1,7 +1,7 @@ -import { requestClient } from '#/api/request'; - import type { PromotionFeeTypeDTO, PromotionFeeTypeVO } from './types'; +import { requestClient } from '#/api/request'; + /** * 推广费类型管理API */ @@ -9,41 +9,51 @@ import type { PromotionFeeTypeDTO, PromotionFeeTypeVO } from './types'; /** * 创建推广费类型 */ -export async function createPromotionFeeTypeApi(data: PromotionFeeTypeDTO.Create) { +export async function createPromotionFeeTypeApi( + data: PromotionFeeTypeDTO.Create, +) { return requestClient.post('/ec/promotion-fee-type', data); } /** * 更新推广费类型 */ -export async function updatePromotionFeeTypeApi(data: PromotionFeeTypeDTO.Update) { - return requestClient.put('/ec/promotion-fee-type', data); +export async function updatePromotionFeeTypeApi( + data: PromotionFeeTypeDTO.Update, +) { + return requestClient.put('/ec/promotion-fee-type', data); } /** * 删除推广费类型 */ export async function deletePromotionFeeTypeApi(id: number) { - return requestClient.delete(`/ec/promotion-fee-type/${id}`); + return requestClient.delete(`/ec/promotion-fee-type/${id}`); } /** * 获取推广费类型详情 */ export async function getPromotionFeeTypeByIdApi(id: number) { - return requestClient.get(`/ec/promotion-fee-type/${id}`); + return requestClient.get( + `/ec/promotion-fee-type/${id}`, + ); } /** * 获取启用的推广费类型列表 */ export async function getActivePromotionFeeTypeListApi() { - return requestClient.get('/ec/promotion-fee-type/active'); + return requestClient.get( + '/ec/promotion-fee-type/active', + ); } /** * 获取所有推广费类型列表 */ export async function getAllPromotionFeeTypeListApi() { - return requestClient.get('/ec/promotion-fee-type/all'); + return requestClient.get( + '/ec/promotion-fee-type/all', + ); } diff --git a/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/types/index.ts b/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/types/index.ts index 10303f33..1c619b40 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/types/index.ts +++ b/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/types/index.ts @@ -7,8 +7,8 @@ export * from './dto.order'; export * from './dto.order-status'; export * from './dto.promotion-fee-type'; +export * from './vo.batch-import-result'; // VO类型导出 export * from './vo.order'; export * from './vo.order-status'; export * from './vo.promotion-fee-type'; -export * from './vo.batch-import-result'; diff --git a/ecom-dmb-frontend/apps/web-antd/src/components/CompanyMenuDrawer.vue b/ecom-dmb-frontend/apps/web-antd/src/components/CompanyMenuDrawer.vue index 0c9fef2c..38a37390 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/components/CompanyMenuDrawer.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/components/CompanyMenuDrawer.vue @@ -1,56 +1,63 @@ diff --git a/ecom-dmb-frontend/apps/web-antd/src/store/auth.ts b/ecom-dmb-frontend/apps/web-antd/src/store/auth.ts index 73969048..5f3bdb17 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/store/auth.ts +++ b/ecom-dmb-frontend/apps/web-antd/src/store/auth.ts @@ -1,5 +1,7 @@ import type { Recordable, UserInfo } from '@vben/types'; +import type { AuthApi } from '#/api/core/auth'; + import { ref } from 'vue'; import { useRouter } from 'vue-router'; @@ -10,9 +12,14 @@ import { resetAllStores, useAccessStore, useUserStore } from '@vben/stores'; import { notification } from 'ant-design-vue'; import { defineStore } from 'pinia'; -import { getAccessCodesApi, getUserInfoApi, loginApi, logoutApi, registerApi } from '#/api'; +import { + getAccessCodesApi, + getUserInfoApi, + loginApi, + logoutApi, + registerApi, +} from '#/api'; import { $t } from '#/locales'; -import type { AuthApi } from '#/api/core/auth'; export const useAuthStore = defineStore('auth', () => { const accessStore = useAccessStore(); @@ -39,11 +46,21 @@ export const useAuthStore = defineStore('auth', () => { account: params.account, password: params.password, }; - const { accessToken, refreshToken, accessTokenExpiresAt, refreshTokenExpiresAt } = await loginApi(loginParams); + const { + accessToken, + refreshToken, + accessTokenExpiresAt, + refreshTokenExpiresAt, + } = await loginApi(loginParams); // 如果成功获取到 token if (accessToken) { - accessStore.setTokens(accessToken, refreshToken, accessTokenExpiresAt, refreshTokenExpiresAt); + accessStore.setTokens( + accessToken, + refreshToken, + accessTokenExpiresAt, + refreshTokenExpiresAt, + ); // 获取用户信息 userInfo = await fetchUserInfo(); @@ -103,11 +120,21 @@ export const useAuthStore = defineStore('auth', () => { let userInfo: null | UserInfo = null; try { loginLoading.value = true; - const { accessToken, refreshToken, accessTokenExpiresAt, refreshTokenExpiresAt } = await registerApi(params as any); + const { + accessToken, + refreshToken, + accessTokenExpiresAt, + refreshTokenExpiresAt, + } = await registerApi(params as any); // 如果成功获取到 token if (accessToken) { - accessStore.setTokens(accessToken, refreshToken, accessTokenExpiresAt, refreshTokenExpiresAt); + accessStore.setTokens( + accessToken, + refreshToken, + accessTokenExpiresAt, + refreshTokenExpiresAt, + ); // 获取用户信息 userInfo = await fetchUserInfo(); diff --git a/ecom-dmb-frontend/apps/web-antd/src/utils/csv-utils.ts b/ecom-dmb-frontend/apps/web-antd/src/utils/csv-utils.ts index 33be03cc..2ee7148d 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/utils/csv-utils.ts +++ b/ecom-dmb-frontend/apps/web-antd/src/utils/csv-utils.ts @@ -1,27 +1,27 @@ -import Papa from 'papaparse' +import Papa from 'papaparse'; export interface CSVParseResult { - data: any[] - headers: string[] - errors: any[] + data: any[]; + headers: string[]; + errors: any[]; } export interface FieldMapping { - csvField: string - standardField: string - customName?: string + csvField: string; + standardField: string; + customName?: string; } export interface ExportData { metadata: { - source: string - totalRecords: number - exportTime: string - fieldMappings: Record - customFieldNames: Record - shopName?: string - } - data: any[] + customFieldNames: Record; + exportTime: string; + fieldMappings: Record; + shopName?: string; + source: string; + totalRecords: number; + }; + data: any[]; } /** @@ -32,19 +32,19 @@ export function parseCSV(file: File): Promise { Papa.parse(file, { header: true, skipEmptyLines: true, - encoding: 'UTF-8', + encoding: 'utf8', complete: (results) => { resolve({ data: results.data, headers: results.meta.fields || [], - errors: results.errors - }) + errors: results.errors, + }); }, error: (error) => { - reject(error) - } - }) - }) + reject(error); + }, + }); + }); } /** @@ -53,20 +53,20 @@ export function parseCSV(file: File): Promise { export function transformDataWithMapping( csvData: any[], fieldMappings: Record, - customFieldNames: Record = {} + customFieldNames: Record = {}, ): any[] { - return csvData.map(row => { - const transformedRow: any = {} - + return csvData.map((row) => { + const transformedRow: any = {}; + Object.entries(fieldMappings).forEach(([csvField, standardField]) => { if (standardField && row[csvField] !== undefined) { - const fieldName = customFieldNames[csvField] || standardField - transformedRow[fieldName] = row[csvField] + const fieldName = customFieldNames[csvField] || standardField; + transformedRow[fieldName] = row[csvField]; } - }) - - return transformedRow - }) + }); + + return transformedRow; + }); } /** @@ -76,7 +76,7 @@ export function generateExportData( transformedData: any[], fieldMappings: Record, customFieldNames: Record = {}, - shopName?: string + shopName?: string, ): ExportData { return { metadata: { @@ -85,27 +85,27 @@ export function generateExportData( exportTime: new Date().toISOString(), fieldMappings, customFieldNames, - shopName + shopName, }, - data: transformedData - } + data: transformedData, + }; } /** * 下载JSON文件 */ export function downloadJSON(data: ExportData, filename?: string): void { - const jsonString = JSON.stringify(data, null, 2) - const blob = new Blob([jsonString], { type: 'application/json' }) - const url = URL.createObjectURL(blob) - - const link = document.createElement('a') - link.href = url - link.download = filename || `ecommerce-data-${new Date().getTime()}.json` - document.body.appendChild(link) - link.click() - document.body.removeChild(link) - URL.revokeObjectURL(url) + const jsonString = JSON.stringify(data, null, 2); + const blob = new Blob([jsonString], { type: 'application/json' }); + const url = URL.createObjectURL(blob); + + const link = document.createElement('a'); + link.href = url; + link.download = filename || `ecommerce-data-${Date.now()}.json`; + document.body.append(link); + link.click(); + link.remove(); + URL.revokeObjectURL(url); } /** @@ -113,67 +113,76 @@ export function downloadJSON(data: ExportData, filename?: string): void { */ export function extractShopNameFromFilename(filename: string): string { // 移除文件扩展名 - const nameWithoutExt = filename.replace(/\.[^/.]+$/, '') - return nameWithoutExt + const nameWithoutExt = filename.replace(/\.[^/.]+$/, ''); + return nameWithoutExt; } /** * 验证CSV数据格式 */ -export function validateCSVData(data: any[]): { isValid: boolean; errors: string[] } { - const errors: string[] = [] - +export function validateCSVData(data: any[]): { + errors: string[]; + isValid: boolean; +} { + const errors: string[] = []; + if (data.length === 0) { - errors.push('CSV文件为空') + errors.push('CSV文件为空'); } - + // 检查必要字段 - const requiredFields = ['商品', '订单号', '订单状态', '商品数量(件)', '商家实收金额(元)'] - const firstRow = data[0] - + const requiredFields = [ + '商品', + '订单号', + '订单状态', + '商品数量(件)', + '商家实收金额(元)', + ]; + const firstRow = data[0]; + if (firstRow) { - requiredFields.forEach(field => { + requiredFields.forEach((field) => { if (!(field in firstRow)) { - errors.push(`缺少必要字段: ${field}`) + errors.push(`缺少必要字段: ${field}`); } - }) + }); } - + return { isValid: errors.length === 0, - errors - } + errors, + }; } /** * 数据清洗和格式化 */ export function cleanAndFormatData(data: any[]): any[] { - return data.map(row => { - const cleanedRow: any = {} - + return data.map((row) => { + const cleanedRow: any = {}; + Object.entries(row).forEach(([key, value]) => { if (value !== null && value !== undefined) { // 去除首尾空格 - let cleanedValue = String(value).trim() - + let cleanedValue = String(value).trim(); + // 处理数字字段 if (key.includes('数量') || key.includes('金额')) { - cleanedValue = cleanedValue.replace(/[^\d.-]/g, '') - if (cleanedValue && !isNaN(Number(cleanedValue))) { - cleanedValue = Number(cleanedValue).toString() + cleanedValue = cleanedValue.replaceAll(/[^\d.-]/g, ''); + if (cleanedValue && !Number.isNaN(Number(cleanedValue))) { + cleanedValue = Number(cleanedValue).toString(); } } - + // 处理日期字段 if (key.includes('日期') || key.includes('时间')) { // 这里可以添加日期格式化逻辑 } - - cleanedRow[key] = cleanedValue + + cleanedRow[key] = cleanedValue; } - }) - - return cleanedRow - }) + }); + + return cleanedRow; + }); } diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/_core/authentication/register.vue b/ecom-dmb-frontend/apps/web-antd/src/views/_core/authentication/register.vue index 2816544e..1575ffb8 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/_core/authentication/register.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/_core/authentication/register.vue @@ -107,10 +107,10 @@ function handleSubmit(value: Recordable) { // 这里可以添加错误提示 return; } - + // 移除不需要的字段 - const { confirmPassword, agreePolicy, ...registerData } = value; - + const { ...registerData } = value; + authStore.authRegister(registerData); } diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/data-analysis/index.vue b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/data-analysis/index.vue index eedfac94..0edac9f4 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/data-analysis/index.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/data-analysis/index.vue @@ -1,21 +1,22 @@ + + - - diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/data-import/components/EntityCreationModal.vue b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/data-import/components/EntityCreationModal.vue index 41783d3a..def1f1eb 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/data-import/components/EntityCreationModal.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/data-import/components/EntityCreationModal.vue @@ -1,126 +1,17 @@ - - + + diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/data-import/components/FieldMapping.vue b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/data-import/components/FieldMapping.vue index 8e716a97..829201e8 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/data-import/components/FieldMapping.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/data-import/components/FieldMapping.vue @@ -1,81 +1,36 @@ - - + + diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/data-import/index.vue b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/data-import/index.vue index f5a307e0..81cf51c1 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/data-import/index.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/data-import/index.vue @@ -1,308 +1,63 @@ - - + + diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/data-import/services/EntityMatchingService.ts b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/data-import/services/EntityMatchingService.ts index 95313c23..f452772c 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/data-import/services/EntityMatchingService.ts +++ b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/data-import/services/EntityMatchingService.ts @@ -3,11 +3,15 @@ * 用于匹配CSV数据中的实体(店铺、商品、规格、订单状态)到数据库中的ID */ -import { getShopsByNamesApi } from '#/api/shop/shop'; -import { getProductsByNamesApi, getProductSpecsByProductAndSpecsApi } from '#/api/shop/product'; -import type { OrderDTO} from '#/api/ecommerce/types'; -import type { ShopVO } from '#/api/shop/shop/types'; +import type { OrderDTO } from '#/api/ecommerce/types'; import type { ProductVO } from '#/api/shop/product/types'; +import type { ShopVO } from '#/api/shop/shop/types'; + +import { + getProductsByNamesApi, + getProductSpecsByProductAndSpecsApi, +} from '#/api/shop/product'; +import { getShopsByNamesApi } from '#/api/shop/shop'; export interface EntityMatchingResult { /** 匹配成功的订单数据 */ @@ -16,8 +20,8 @@ export interface EntityMatchingResult { failedRecords: FailedRecord[]; /** 需要创建的实体 */ entitiesToCreate: { - shops: string[]; products: string[]; + shops: string[]; specs: { productName: string; specCode: string }[]; }; /** 匹配详情信息 */ @@ -30,7 +34,7 @@ export interface MatchDetail { /** 原始数据 */ originalData: CSVOrderData; /** 匹配状态 */ - status: 'matched' | 'failed' | 'partial'; + status: 'failed' | 'matched' | 'partial'; /** 匹配的店铺信息 */ matchedShop?: ShopVO.Info; /** 匹配的商品信息 */ @@ -74,15 +78,277 @@ export interface CSVOrderData { } export class EntityMatchingService { - private shopCache: Map = new Map(); - private productCache: Map = new Map(); - private specCache: Map = new Map(); private orderStatusMap: Map = new Map(); + private productCache: Map = new Map(); + private shopCache: Map = new Map(); + private specCache: Map = new Map(); constructor() { this.initializeOrderStatusMap(); } + /** + * 获取订单状态ID + */ + getOrderStatusId(statusName: string): number | undefined { + return this.orderStatusMap.get(statusName); + } + + /** + * 获取商品信息 + */ + getProductByName(name: string): ProductVO.Info | undefined { + return this.productCache.get(name); + } + + /** + * 获取商品规格信息 + */ + getProductSpecByKey( + productName: string, + specCode: string, + ): ProductVO.SpecInfo | undefined { + const key = `${productName}_${specCode}`; + return this.specCache.get(key); + } + + /** + * 获取店铺信息 + */ + getShopByName(name: string): ShopVO.Info | undefined { + return this.shopCache.get(name); + } + + /** + * 匹配实体并生成订单数据 + */ + async matchEntities(csvData: CSVOrderData[]): Promise { + // 清空缓存 + this.clearCache(); + + // 提取所有需要查询的实体名称 + const shopNames = [...new Set(csvData.map((row) => row.shopName))]; + const productNames = [...new Set(csvData.map((row) => row.productName))]; + + // 对规格查询进行去重处理 + const specQueriesMap = new Map< + string, + { productName: string; specCode: string } + >(); + csvData.forEach((row) => { + const key = `${row.productName}_${row.specCode}`; + if (!specQueriesMap.has(key)) { + specQueriesMap.set(key, { + productName: row.productName, + specCode: row.specCode, + }); + } + }); + const specQueries = [...specQueriesMap.values()]; + + // 批量查询所有实体 + await this.loadEntitiesBatch(shopNames, productNames, specQueries); + + const matchedOrders: OrderDTO.Create[] = []; + const failedRecords: FailedRecord[] = []; + const matchDetails: MatchDetail[] = []; + const entitiesToCreate = { + shops: new Set(), + products: new Set(), + specs: new Set<{ productName: string; specCode: string }>(), + }; + + for (const [i, row] of csvData.entries()) { + // 检查行数据是否存在 + if (!row) { + const failedRecord = { + rowIndex: i + 1, + originalData: null, + reason: '行数据为空', + }; + failedRecords.push(failedRecord); + matchDetails.push({ + rowIndex: i + 1, + originalData: row || ({} as CSVOrderData), + status: 'failed', + failureReason: '行数据为空', + }); + continue; + } + + try { + // 匹配店铺 + const shop = this.shopCache.get(row.shopName); + if (!shop) { + entitiesToCreate.shops.add(row.shopName); + const failedRecord = { + rowIndex: i + 1, + originalData: row, + reason: `店铺 "${row.shopName}" 不存在`, + }; + failedRecords.push(failedRecord); + matchDetails.push({ + rowIndex: i + 1, + originalData: row, + status: 'failed', + failureReason: `店铺 "${row.shopName}" 不存在`, + }); + continue; + } + + // 匹配商品 + const product = this.productCache.get(row.productName); + if (!product) { + entitiesToCreate.products.add(row.productName); + const failedRecord = { + rowIndex: i + 1, + originalData: row, + reason: `商品 "${row.productName}" 不存在`, + }; + failedRecords.push(failedRecord); + matchDetails.push({ + rowIndex: i + 1, + originalData: row, + status: 'failed', + matchedShop: shop, + failureReason: `商品 "${row.productName}" 不存在`, + }); + continue; + } + + // 匹配商品规格 + const specKey = `${row.productName}_${row.specCode}`; + const spec = this.specCache.get(specKey); + if (!spec) { + entitiesToCreate.specs.add({ + productName: row.productName, + specCode: row.specCode, + }); + const failedRecord = { + rowIndex: i + 1, + originalData: row, + reason: `商品规格 "${row.productName}" - "${row.specCode}" 不存在`, + }; + failedRecords.push(failedRecord); + matchDetails.push({ + rowIndex: i + 1, + originalData: row, + status: 'failed', + matchedShop: shop, + matchedProduct: product, + failureReason: `商品规格 "${row.productName}" - "${row.specCode}" 不存在`, + }); + continue; + } + + // 匹配订单状态 + const orderStatusId = this.orderStatusMap.get(row.orderStatusName); + if (!orderStatusId) { + const failedRecord = { + rowIndex: i + 1, + originalData: row, + reason: `订单状态 "${row.orderStatusName}" 不存在`, + }; + failedRecords.push(failedRecord); + matchDetails.push({ + rowIndex: i + 1, + originalData: row, + status: 'failed', + matchedShop: shop, + matchedProduct: product, + matchedSpec: spec, + failureReason: `订单状态 "${row.orderStatusName}" 不存在`, + }); + continue; + } + + // 从订单号中提取日期信息(格式:250913-341248633251447,前6位是日期) + let orderDate = new Date().toISOString(); // 默认使用当前时间 + if (row.orderNumber && row.orderNumber.length >= 6) { + try { + const dateStr = row.orderNumber.slice(0, 6); // 提取前6位 + const year = `20${dateStr.slice(0, 2)}`; // 25 -> 2025 + const month = dateStr.slice(2, 4); // 09 + const day = dateStr.slice(4, 6); // 13 + orderDate = new Date( + `${year}-${month}-${day}T00:00:00`, + ).toISOString(); + } catch { + console.warn( + '无法解析订单号中的日期,使用当前时间:', + row.orderNumber, + ); + } + } + + // 创建订单数据(新的合并结构) + const orderData: OrderDTO.Create = { + shopId: shop.id, + platformOrderNo: row.orderNumber, + statusId: orderStatusId, + receivedAmount: row.shopActualAmount, + shippingFee: 0, // 运费暂时设为0 + orderDate, + productId: product.id, + productSpecId: spec.id, + productName: row.productName, + specName: row.productSpecName, + quantity: row.quantity, + unitPrice: row.shopActualAmount / row.quantity, // 根据实收金额和数量计算单价 + costPrice: spec.costPrice || 0, // 使用规格的成本价 + costTotal: (spec.costPrice || 0) * row.quantity, // 成本小计 + }; + + matchedOrders.push(orderData); + + // 添加匹配成功的详情 + matchDetails.push({ + rowIndex: i + 1, + originalData: row, + status: 'matched', + matchedShop: shop, + matchedProduct: product, + matchedSpec: spec, + matchedOrderStatusId: orderStatusId, + orderData, + }); + } catch (error) { + const failedRecord = { + rowIndex: i + 1, + originalData: row, + reason: `处理失败: ${error instanceof Error ? error.message : '未知错误'}`, + }; + failedRecords.push(failedRecord); + matchDetails.push({ + rowIndex: i + 1, + originalData: row, + status: 'failed', + failureReason: `处理失败: ${error instanceof Error ? error.message : '未知错误'}`, + }); + } + } + + return { + matchedOrders, + failedRecords, + entitiesToCreate: { + shops: [...entitiesToCreate.shops], + products: [...entitiesToCreate.products], + specs: [...entitiesToCreate.specs], + }, + matchDetails, + }; + } + + /** + * 清空缓存 + */ + private clearCache(): void { + this.shopCache.clear(); + this.productCache.clear(); + this.specCache.clear(); + } + /** * 初始化订单状态映射 */ @@ -96,249 +362,46 @@ export class EntityMatchingService { // 可以根据需要添加更多状态映射 } - /** - * 匹配实体并生成订单数据 - */ - async matchEntities(csvData: CSVOrderData[]): Promise { - // 清空缓存 - this.clearCache(); - - // 提取所有需要查询的实体名称 - const shopNames = [...new Set(csvData.map(row => row.shopName))]; - const productNames = [...new Set(csvData.map(row => row.productName))]; - - // 对规格查询进行去重处理 - const specQueriesMap = new Map(); - csvData.forEach(row => { - const key = `${row.productName}_${row.specCode}`; - if (!specQueriesMap.has(key)) { - specQueriesMap.set(key, { productName: row.productName, specCode: row.specCode }); - } - }); - const specQueries = Array.from(specQueriesMap.values()); - - // 批量查询所有实体 - await this.loadEntitiesBatch(shopNames, productNames, specQueries); - - const matchedOrders: OrderDTO.Create[] = []; - const failedRecords: FailedRecord[] = []; - const matchDetails: MatchDetail[] = []; - const entitiesToCreate = { - shops: new Set(), - products: new Set(), - specs: new Set<{ productName: string; specCode: string }>() - }; - - for (let i = 0; i < csvData.length; i++) { - const row = csvData[i]; - - // 检查行数据是否存在 - if (!row) { - const failedRecord = { - rowIndex: i + 1, - originalData: null, - reason: '行数据为空' - }; - failedRecords.push(failedRecord); - matchDetails.push({ - rowIndex: i + 1, - originalData: row || {} as CSVOrderData, - status: 'failed', - failureReason: '行数据为空' - }); - continue; - } - - try { - // 匹配店铺 - const shop = this.shopCache.get(row.shopName); - if (!shop) { - entitiesToCreate.shops.add(row.shopName); - const failedRecord = { - rowIndex: i + 1, - originalData: row, - reason: `店铺 "${row.shopName}" 不存在` - }; - failedRecords.push(failedRecord); - matchDetails.push({ - rowIndex: i + 1, - originalData: row, - status: 'failed', - failureReason: `店铺 "${row.shopName}" 不存在` - }); - continue; - } - - // 匹配商品 - const product = this.productCache.get(row.productName); - if (!product) { - entitiesToCreate.products.add(row.productName); - const failedRecord = { - rowIndex: i + 1, - originalData: row, - reason: `商品 "${row.productName}" 不存在` - }; - failedRecords.push(failedRecord); - matchDetails.push({ - rowIndex: i + 1, - originalData: row, - status: 'failed', - matchedShop: shop, - failureReason: `商品 "${row.productName}" 不存在` - }); - continue; - } - - // 匹配商品规格 - const specKey = `${row.productName}_${row.specCode}`; - const spec = this.specCache.get(specKey); - if (!spec) { - entitiesToCreate.specs.add({ productName: row.productName, specCode: row.specCode }); - const failedRecord = { - rowIndex: i + 1, - originalData: row, - reason: `商品规格 "${row.productName}" - "${row.specCode}" 不存在` - }; - failedRecords.push(failedRecord); - matchDetails.push({ - rowIndex: i + 1, - originalData: row, - status: 'failed', - matchedShop: shop, - matchedProduct: product, - failureReason: `商品规格 "${row.productName}" - "${row.specCode}" 不存在` - }); - continue; - } - - // 匹配订单状态 - const orderStatusId = this.orderStatusMap.get(row.orderStatusName); - if (!orderStatusId) { - const failedRecord = { - rowIndex: i + 1, - originalData: row, - reason: `订单状态 "${row.orderStatusName}" 不存在` - }; - failedRecords.push(failedRecord); - matchDetails.push({ - rowIndex: i + 1, - originalData: row, - status: 'failed', - matchedShop: shop, - matchedProduct: product, - matchedSpec: spec, - failureReason: `订单状态 "${row.orderStatusName}" 不存在` - }); - continue; - } - - // 从订单号中提取日期信息(格式:250913-341248633251447,前6位是日期) - let orderDate = new Date().toISOString(); // 默认使用当前时间 - if (row.orderNumber && row.orderNumber.length >= 6) { - try { - const dateStr = row.orderNumber.substring(0, 6); // 提取前6位 - const year = '20' + dateStr.substring(0, 2); // 25 -> 2025 - const month = dateStr.substring(2, 4); // 09 - const day = dateStr.substring(4, 6); // 13 - orderDate = new Date(`${year}-${month}-${day}T00:00:00`).toISOString(); - } catch (error) { - console.warn('无法解析订单号中的日期,使用当前时间:', row.orderNumber); - } - } - - // 创建订单数据(新的合并结构) - const orderData: OrderDTO.Create = { - shopId: shop.id, - platformOrderNo: row.orderNumber, - statusId: orderStatusId, - receivedAmount: row.shopActualAmount, - shippingFee: 0, // 运费暂时设为0 - orderDate: orderDate, - productId: product.id, - productSpecId: spec.id, - productName: row.productName, - specName: row.productSpecName, - quantity: row.quantity, - unitPrice: row.shopActualAmount / row.quantity, // 根据实收金额和数量计算单价 - costPrice: spec.costPrice || 0, // 使用规格的成本价 - costTotal: (spec.costPrice || 0) * row.quantity, // 成本小计 - }; - - matchedOrders.push(orderData); - - // 添加匹配成功的详情 - matchDetails.push({ - rowIndex: i + 1, - originalData: row, - status: 'matched', - matchedShop: shop, - matchedProduct: product, - matchedSpec: spec, - matchedOrderStatusId: orderStatusId, - orderData: orderData - }); - } catch (error) { - const failedRecord = { - rowIndex: i + 1, - originalData: row, - reason: `处理失败: ${error instanceof Error ? error.message : '未知错误'}` - }; - failedRecords.push(failedRecord); - matchDetails.push({ - rowIndex: i + 1, - originalData: row, - status: 'failed', - failureReason: `处理失败: ${error instanceof Error ? error.message : '未知错误'}` - }); - } - } - - return { - matchedOrders, - failedRecords, - entitiesToCreate: { - shops: Array.from(entitiesToCreate.shops), - products: Array.from(entitiesToCreate.products), - specs: Array.from(entitiesToCreate.specs) - }, - matchDetails - }; - } - /** * 批量加载实体数据 */ private async loadEntitiesBatch( - shopNames: string[], - productNames: string[], - specQueries: { productName: string; specCode: string }[] + shopNames: string[], + productNames: string[], + specQueries: { productName: string; specCode: string }[], ): Promise { try { // 并行查询所有实体 const [shops, products, productsWithSpecs] = await Promise.all([ - shopNames.length > 0 ? getShopsByNamesApi(shopNames) : Promise.resolve([]), - productNames.length > 0 ? getProductsByNamesApi(productNames) : Promise.resolve([]), - specQueries.length > 0 ? getProductSpecsByProductAndSpecsApi(specQueries) : Promise.resolve([]) + shopNames.length > 0 + ? getShopsByNamesApi(shopNames) + : Promise.resolve([]), + productNames.length > 0 + ? getProductsByNamesApi(productNames) + : Promise.resolve([]), + specQueries.length > 0 + ? getProductSpecsByProductAndSpecsApi(specQueries) + : Promise.resolve([]), ]); // 缓存店铺数据 - shops.forEach(shop => { + shops.forEach((shop) => { this.shopCache.set(shop.name, shop); }); // 缓存商品数据 - products.forEach(product => { + products.forEach((product) => { this.productCache.set(product.name, product); }); // 缓存包含规格信息的商品数据 - productsWithSpecs.forEach(product => { + productsWithSpecs.forEach((product) => { // 更新商品缓存 this.productCache.set(product.name, product); - + // 缓存该商品的规格数据 if (product.specs && product.specs.length > 0) { - product.specs.forEach(spec => { + product.specs.forEach((spec) => { const key = `${product.name}_${spec.specCode || ''}`; this.specCache.set(key, spec); }); @@ -348,42 +411,4 @@ export class EntityMatchingService { console.error('批量加载实体数据失败:', error); } } - - /** - * 清空缓存 - */ - private clearCache(): void { - this.shopCache.clear(); - this.productCache.clear(); - this.specCache.clear(); - } - - /** - * 获取店铺信息 - */ - getShopByName(name: string): ShopVO.Info | undefined { - return this.shopCache.get(name); - } - - /** - * 获取商品信息 - */ - getProductByName(name: string): ProductVO.Info | undefined { - return this.productCache.get(name); - } - - /** - * 获取商品规格信息 - */ - getProductSpecByKey(productName: string, specCode: string): ProductVO.SpecInfo | undefined { - const key = `${productName}_${specCode}`; - return this.specCache.get(key); - } - - /** - * 获取订单状态ID - */ - getOrderStatusId(statusName: string): number | undefined { - return this.orderStatusMap.get(statusName); - } } diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/data-import/utils/csvParser.ts b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/data-import/utils/csvParser.ts index 664d0be7..adeb32d4 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/data-import/utils/csvParser.ts +++ b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/data-import/utils/csvParser.ts @@ -46,13 +46,11 @@ export async function parseOrderCSV(file: File): Promise { let headers: string[] = []; // 尝试多种编码格式 - const encodings = ['GBK', 'UTF-8', 'GB2312']; - let result: Papa.ParseResult | null = null; + const encodings = ['GBK', 'utf8', 'GB2312']; + let result: null | Papa.ParseResult = null; for (const encoding of encodings) { try { - console.log(`尝试使用${encoding}编码解析文件...`); - result = await new Promise>((resolve, reject) => { Papa.parse(file, { header: true, @@ -63,24 +61,22 @@ export async function parseOrderCSV(file: File): Promise { }, error: (error) => { reject(error); - } + }, }); }); // 检查是否成功解析出中文内容 if (result.data && result.data.length > 0) { const firstRow = result.data[0]; - const hasChineseContent = Object.values(firstRow).some(value => - typeof value === 'string' && /[\u4e00-\u9fa5]/.test(value) + const hasChineseContent = Object.values(firstRow).some( + (value) => typeof value === 'string' && /[\u4E00-\u9FA5]/.test(value), ); - + if (hasChineseContent) { - console.log(`成功使用${encoding}编码解析文件`); break; } } - } catch (error) { - console.log(`使用${encoding}编码解析失败:`, error); + } catch { continue; } } @@ -91,7 +87,9 @@ export async function parseOrderCSV(file: File): Promise { } if (result.errors.length > 0) { - errors.push(`CSV解析错误: ${result.errors.map(e => e.message).join(', ')}`); + errors.push( + `CSV解析错误: ${result.errors.map((e) => e.message).join(', ')}`, + ); } if (!result.data || result.data.length === 0) { @@ -101,23 +99,32 @@ export async function parseOrderCSV(file: File): Promise { // 获取表头 headers = result.meta.fields || []; - console.log('解析到的表头:', headers); - - // 验证表头 - 使用更灵活的表头匹配 - const requiredHeaders = ['商品', '订单号', '订单状态', '商品数量(件)', '商品id', '商品规格', '商家编码-规格维度', '售后状态', '商家实收金额(元)']; - const missingHeaders = requiredHeaders.filter(requiredHeader => { - // 检查是否有匹配的表头(支持部分匹配) - return !headers.some(header => - header.includes(requiredHeader) || requiredHeader.includes(header) - ); - }); - + + // 验证表头 - 使用更灵活的表头匹配 + const requiredHeaders = [ + '商品', + '订单号', + '订单状态', + '商品数量(件)', + '商品id', + '商品规格', + '商家编码-规格维度', + '售后状态', + '商家实收金额(元)', + ]; + const missingHeaders = requiredHeaders.filter((requiredHeader) => { + // 检查是否有匹配的表头(支持部分匹配) + return !headers.some( + (header) => + header.includes(requiredHeader) || requiredHeader.includes(header), + ); + }); + if (missingHeaders.length > 0) { - console.log('缺少的列:', missingHeaders); - console.log('实际表头:', headers); - console.log('期望表头:', requiredHeaders); // 不再阻止导入,只是记录警告 - errors.push(`警告:缺少部分列: ${missingHeaders.join(', ')},可以在导入后手动处理`); + errors.push( + `警告:缺少部分列: ${missingHeaders.join(', ')},可以在导入后手动处理`, + ); } // 解析数据行 @@ -129,8 +136,9 @@ export async function parseOrderCSV(file: File): Promise { data.push(rowData); } } catch (error) { - errors.push(`第${i + 2}行解析失败: ${error instanceof Error ? error.message : '未知错误'}`); - console.log(`第${i + 2}行解析错误:`, error); + errors.push( + `第${i + 2}行解析失败: ${error instanceof Error ? error.message : '未知错误'}`, + ); } } @@ -140,12 +148,19 @@ export async function parseOrderCSV(file: File): Promise { /** * 解析订单行数据 - 从papaparse对象格式 */ -function parseOrderRowFromObject(row: any, rowNumber: number): ParsedOrderData | null { +function parseOrderRowFromObject( + row: any, + rowNumber: number, +): null | ParsedOrderData { try { // 获取字段值,支持多种可能的字段名 const getValue = (fieldNames: string[]): string => { for (const fieldName of fieldNames) { - if (row[fieldName] !== undefined && row[fieldName] !== null && row[fieldName] !== '') { + if ( + row[fieldName] !== undefined && + row[fieldName] !== null && + row[fieldName] !== '' + ) { return String(row[fieldName]).trim(); } } @@ -155,13 +170,29 @@ function parseOrderRowFromObject(row: any, rowNumber: number): ParsedOrderData | const productName = getValue(['商品', '商品名称', 'productName']); const orderNumber = getValue(['订单号', '订单编号', 'orderNumber']); const orderStatusName = getValue(['订单状态', 'orderStatus', '状态']); - const quantityStr = getValue(['商品数量(件)', '商品数量', '数量', 'quantity']); + const quantityStr = getValue([ + '商品数量(件)', + '商品数量', + '数量', + 'quantity', + ]); const productId = getValue(['商品id', '商品ID', 'productId', '商品编码']); - const productSpecName = getValue(['商品规格', '规格', 'spec', 'productSpec']); + const productSpecName = getValue([ + '商品规格', + '规格', + 'spec', + 'productSpec', + ]); const specCode = getValue(['商家编码-规格维度', '规格编码', 'specCode']); // 店铺名称应该从文件名获取,这里不设置shopName const afterSaleStatus = getValue(['售后状态', '售后', 'afterSale']); - const shopActualAmountStr = getValue(['商家实收金额(元)', '店铺实际收入(元)', '店铺实际收入', '收入', 'amount']); + const shopActualAmountStr = getValue([ + '商家实收金额(元)', + '店铺实际收入(元)', + '店铺实际收入', + '收入', + 'amount', + ]); // 验证必填字段 - 只验证最核心的字段 if (!productName) { @@ -170,14 +201,14 @@ function parseOrderRowFromObject(row: any, rowNumber: number): ParsedOrderData | if (!orderNumber) { throw new Error('订单编号不能为空'); } - + // 其他字段可以为空,在后续处理中处理 // 解析数量 - 允许为0或空 - const quantity = parseFloat(quantityStr) || 0; + const quantity = Number.parseFloat(quantityStr) || 0; // 解析金额 - 允许为0或空 - const shopActualAmount = parseFloat(shopActualAmountStr) || 0; + const shopActualAmount = Number.parseFloat(shopActualAmountStr) || 0; return { productName, @@ -192,7 +223,9 @@ function parseOrderRowFromObject(row: any, rowNumber: number): ParsedOrderData | shopActualAmount, }; } catch (error) { - throw new Error(`第${rowNumber}行数据验证失败: ${error instanceof Error ? error.message : '未知错误'}`); + throw new Error( + `第${rowNumber}行数据验证失败: ${error instanceof Error ? error.message : '未知错误'}`, + ); } } @@ -207,8 +240,11 @@ export function extractShopNameFromFilename(filename: string): string { /** * 转换为EntityMatchingService需要的格式 */ -export function convertToCSVOrderData(parsedData: ParsedOrderData[], shopName: string): any[] { - return parsedData.map(row => ({ +export function convertToCSVOrderData( + parsedData: ParsedOrderData[], + shopName: string, +): any[] { + return parsedData.map((row) => ({ productName: row.productName, orderNumber: row.orderNumber, orderStatusName: row.orderStatusName, @@ -216,8 +252,8 @@ export function convertToCSVOrderData(parsedData: ParsedOrderData[], shopName: s productId: row.productId, productSpecName: row.productSpecName, specCode: row.specCode, - shopName: shopName, // 使用从文件名提取的店铺名称 + shopName, // 使用从文件名提取的店铺名称 afterSaleStatus: row.afterSaleStatus, - shopActualAmount: row.shopActualAmount + shopActualAmount: row.shopActualAmount, })); } diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/media/file/components/FileEditModal.vue b/ecom-dmb-frontend/apps/web-antd/src/views/media/file/components/FileEditModal.vue index 433f7a1a..78d1f9b4 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/media/file/components/FileEditModal.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/media/file/components/FileEditModal.vue @@ -1,3 +1,86 @@ + + - - diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/media/file/index.vue b/ecom-dmb-frontend/apps/web-antd/src/views/media/file/index.vue index 13ee3dd6..74b743af 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/media/file/index.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/media/file/index.vue @@ -1,21 +1,34 @@ - - - - diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/media/image/components/ImageEditModal.vue b/ecom-dmb-frontend/apps/web-antd/src/views/media/image/components/ImageEditModal.vue index 0cd87a16..3a53955b 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/media/image/components/ImageEditModal.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/media/image/components/ImageEditModal.vue @@ -1,3 +1,86 @@ + + - - diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/media/image/components/ImageGridView.vue b/ecom-dmb-frontend/apps/web-antd/src/views/media/image/components/ImageGridView.vue deleted file mode 100644 index 5e3a7687..00000000 --- a/ecom-dmb-frontend/apps/web-antd/src/views/media/image/components/ImageGridView.vue +++ /dev/null @@ -1,272 +0,0 @@ - - - - - diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/media/image/index.vue b/ecom-dmb-frontend/apps/web-antd/src/views/media/image/index.vue index 8e139256..a66bb4e5 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/media/image/index.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/media/image/index.vue @@ -1,30 +1,41 @@ + + + @@ -382,8 +414,8 @@ const getTagList = (tags: string | undefined) => {