From b8b86598d8f38731cbd633f442e7ee365856832d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AC=94=E8=AE=B0=E6=9C=AC=E9=87=8C=E7=9A=84=E6=B0=B8?= =?UTF-8?q?=E5=B9=B3?= Date: Wed, 16 Jul 2025 11:06:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nkebao/src/api/utils.ts | 33 +++- .../scenarios/new/steps/BasicSettings.tsx | 148 +++++++++--------- 2 files changed, 110 insertions(+), 71 deletions(-) diff --git a/nkebao/src/api/utils.ts b/nkebao/src/api/utils.ts index 585d6395..c678120c 100644 --- a/nkebao/src/api/utils.ts +++ b/nkebao/src/api/utils.ts @@ -161,4 +161,35 @@ class RequestCancelManager { // 导出单例实例 export const requestDeduplicator = new RequestDeduplicator(); -export const requestCancelManager = new RequestCancelManager(); \ No newline at end of file +export const requestCancelManager = new RequestCancelManager(); + +/** + * 通用文件上传方法(支持图片、文件) + * @param {File} file - 要上传的文件对象 + * @param {string} [uploadUrl='/v1/attachment/upload'] - 上传接口地址 + * @returns {Promise} - 上传成功后返回文件url + */ +export async function uploadFile(file: File, uploadUrl: string = '/v1/attachment/upload'): Promise { + const formData = new FormData(); + formData.append('file', file); + const token = typeof window !== 'undefined' ? localStorage.getItem('token') : ''; + const headers: Record = {}; + if (token) headers['Authorization'] = `Bearer ${token}`; + try { + const response = await fetch(uploadUrl, { + method: 'POST', + headers, + body: formData, + }); + const res = await response.json(); + if (res?.url) { + return res.url; + } + if (res?.data?.url) { + return res.data.url; + } + throw new Error(res?.msg || '文件上传失败'); + } catch (e: any) { + throw new Error(e?.message || '文件上传失败'); + } +} \ No newline at end of file diff --git a/nkebao/src/pages/scenarios/new/steps/BasicSettings.tsx b/nkebao/src/pages/scenarios/new/steps/BasicSettings.tsx index 704af472..b62d7064 100644 --- a/nkebao/src/pages/scenarios/new/steps/BasicSettings.tsx +++ b/nkebao/src/pages/scenarios/new/steps/BasicSettings.tsx @@ -304,6 +304,7 @@ export function BasicSettings({ // 新增:用于文件选择的ref const uploadInputRef = useRef(null); + const uploadOrderInputRef = useRef(null); // 更新电话获客设置 const handlePhoneSettingsUpdate = () => { @@ -648,6 +649,9 @@ export function BasicSettings({ transition: "border 0.2s", textAlign: "center", position: "relative", + height: 180 + 12, // 图片高度180+上下padding + overflow: "hidden", + minHeight: 192, }} onClick={() => handleMaterialSelect(material)} > @@ -675,40 +679,31 @@ export function BasicSettings({ {/* 删除自定义海报按钮 */} {isCustom && ( - + × + )}
{material.name} @@ -753,7 +751,7 @@ export function BasicSettings({ flexDirection: "column", alignItems: "center", justifyContent: "center", - height: 220, + height: 190, }} onClick={() => uploadInputRef.current?.click()} > @@ -801,62 +799,75 @@ export function BasicSettings({ index={0} />
- {/* 订单导入区块 */} + {/* 订单导入区块优化 */}
- - -
- 导入订单 -
-
- +
订单表格上传
+
+ +
- {importedTags.length > 0 && ( - - )} - + + +
+ 支持 CSV、Excel 格式,上传后将文件保存到服务器 +
+ {/* 已导入数据表格可复用原有Table渲染 */} + {importedTags.length > 0 && ( +
+ )} {/* 电话获客设置区块,仅在选择电话获客场景时显示 */} - {formData.scenario === "phone" && ( + {formData.scenario === 5 && (
- - -
+
电话获客设置
-
+
-
-
+
)} {/* 微信群设置区块,仅在选择微信群场景时显示 */} - {formData.scenario === "weixinqun" && ( + {formData.scenario === 7 && (
)} -