新增:批量导入商品功能

This commit is contained in:
2025-12-31 09:55:31 +08:00
parent f4e6705f3f
commit 3be4a42fe8
6 changed files with 75 additions and 5 deletions

View File

@@ -2,7 +2,7 @@ VITE_APP_NAME=后台管理系统
VITE_SOCKET_URL=wss://shop-server-api.ggsxiangan.com VITE_SOCKET_URL=wss://shop-server-api.ggsxiangan.com
VITE_THINK_URL=https://server.websoft.top/api VITE_THINK_URL=https://server.websoft.top/api
#VITE_API_URL=https://clinic-api.websoft.top/api #VITE_API_URL=https://clinic-api.websoft.top/api
VITE_API_URL=/api #VITE_API_URL=/api
VITE_PROXY_TARGET=http://127.0.0.1:9013 VITE_API_URL=http://127.0.0.1:9013/api
VITE_SERVER_URL=https://server.websoft.top/api VITE_SERVER_URL=https://server.websoft.top/api

View File

@@ -0,0 +1,34 @@
# 仅在你必须跨域直连接口(不做同源反代)时使用:
# 将以下内容放到 clinic-api.websoft.top 的 nginx server{} / location{} 中。
#
# 注意:
# - 建议把 allow-origin 固定到你的前端域名,避免使用 *。
# - 如果你使用 cookiewithCredentials还需要加 Access-Control-Allow-Credentials: true
# 并且 allow-origin 不能是 *。
location /api/ {
# 预检请求
if ($request_method = OPTIONS) {
add_header Access-Control-Allow-Origin https://clinic.websoft.top always;
add_header Access-Control-Allow-Methods "GET,POST,PUT,DELETE,PATCH,OPTIONS" always;
add_header Access-Control-Allow-Headers "Authorization,Content-Type,TenantId,X-Requested-With" always;
add_header Access-Control-Max-Age 86400 always;
add_header Content-Length 0;
add_header Content-Type text/plain;
return 204;
}
add_header Access-Control-Allow-Origin https://clinic.websoft.top always;
add_header Access-Control-Expose-Headers Authorization always;
add_header Vary Origin always;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# TODO: 替换为真实 upstream
proxy_pass http://127.0.0.1:9013;
}

View File

@@ -0,0 +1,37 @@
server {
listen 443 ssl;
server_name clinic.websoft.top;
# TODO: 替换为你自己的证书路径
# ssl_certificate /path/to/fullchain.pem;
# ssl_certificate_key /path/to/privkey.pem;
root /home/wwwroot/clinic-admin/dist;
index index.html;
# SPA history
location / {
try_files $uri $uri/ /index.html;
}
# 模块接口(对应 VITE_API_URL=/api、VITE_THINK_URL=/api
location /api/ {
proxy_http_version 1.1;
proxy_set_header Host clinic-api.websoft.top;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass https://clinic-api.websoft.top/api/;
}
# 主接口(对应 VITE_SERVER_URL=/server-api
location /server-api/ {
proxy_http_version 1.1;
proxy_set_header Host server.websoft.top;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass https://server.websoft.top/api/;
}
}

BIN
public/goods-import.xlsx Normal file

Binary file not shown.

View File

@@ -151,7 +151,7 @@ export async function importGoodsExcelFile(
formData.append(key, String(value)); formData.append(key, String(value));
}); });
const res = await request.post<ApiResult<GoodsImportResult>>( const res = await request.post<ApiResult<GoodsImportResult>>(
MODULES_API_URL + '/shop/goods/import-excel', MODULES_API_URL + '/shop/goods/import',
formData, formData,
{ params } { params }
); );

View File

@@ -98,8 +98,7 @@
const params: GoodsImportExcelParam = { const params: GoodsImportExcelParam = {
sheetName: form.sheetName, sheetName: form.sheetName,
skipExisting: form.skipExisting, skipExisting: form.skipExisting,
createCategory: form.createCategory, createCategory: form.createCategory
defaultFiles: '[]'
}; };
const merchantId = getMerchantId(); const merchantId = getMerchantId();
if (merchantId) { if (merchantId) {