From cb7a37fe9e74e54ad7feab6b601dbdb8eb64e0f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B6=85=E7=BA=A7=E8=80=81=E7=99=BD=E5=85=94?= Date: Fri, 19 Sep 2025 17:43:32 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=B5=81=E9=87=8F=E5=88=86=E5=8F=91?= =?UTF-8?q?=E8=A1=A8=E5=8D=95):=20=E4=BC=98=E5=8C=96=E6=B5=81=E9=87=8F?= =?UTF-8?q?=E6=B1=A0=E9=80=89=E6=8B=A9=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除未使用的流量池列表和搜索功能,改为使用受控组件管理流量池选择。新增流量池选择的校验逻辑,确保用户至少选择一个流量池。同时,简化了目标设置的逻辑,提升了代码可读性和用户体验。 --- Cunkebao/dist/.vite/manifest.json | 2 +- Cunkebao/dist/index.html | 2 +- .../traffic-distribution/form/index.tsx | 160 ++++-------------- 3 files changed, 39 insertions(+), 125 deletions(-) diff --git a/Cunkebao/dist/.vite/manifest.json b/Cunkebao/dist/.vite/manifest.json index 48503171..84b25020 100644 --- a/Cunkebao/dist/.vite/manifest.json +++ b/Cunkebao/dist/.vite/manifest.json @@ -33,7 +33,7 @@ "name": "vendor" }, "index.html": { - "file": "assets/index-Bx3nG52V.js", + "file": "assets/index-Czxez1-3.js", "name": "index", "src": "index.html", "isEntry": true, diff --git a/Cunkebao/dist/index.html b/Cunkebao/dist/index.html index 0e38d6c1..6e11cb6c 100644 --- a/Cunkebao/dist/index.html +++ b/Cunkebao/dist/index.html @@ -11,7 +11,7 @@ - + diff --git a/Cunkebao/src/pages/mobile/workspace/traffic-distribution/form/index.tsx b/Cunkebao/src/pages/mobile/workspace/traffic-distribution/form/index.tsx index b94b4214..02fbb104 100644 --- a/Cunkebao/src/pages/mobile/workspace/traffic-distribution/form/index.tsx +++ b/Cunkebao/src/pages/mobile/workspace/traffic-distribution/form/index.tsx @@ -19,18 +19,6 @@ import { import type { TrafficDistributionFormData } from "./data"; import dayjs from "dayjs"; -// const scenarioList = [...]; -const poolList = [ - { - id: "pool-1", - name: "高价值客户池", - userCount: 156, - tags: ["高价值", "优先添加"], - }, - { id: "pool-2", name: "潜在客户池", userCount: 289, tags: ["潜在客户"] }, - { id: "pool-3", name: "新用户池", userCount: 432, tags: ["新用户"] }, -]; - const stepList = [ { id: 1, title: "基本信息", subtitle: "基本信息" }, { id: 2, title: "目标设置", subtitle: "目标设置" }, @@ -57,14 +45,9 @@ const TrafficDistributionForm: React.FC = () => { const [loading, setLoading] = useState(false); const [detailLoading, setDetailLoading] = useState(false); - const [selectedPools, setSelectedPools] = useState([]); const [poolGroupsOptions, setPoolGroupsOptions] = useState< PoolSelectionItem[] >([]); - const [poolSearch, setPoolSearch] = useState(""); - const [targetSelectionTab, setTargetSelectionTab] = useState< - "device" | "account" - >("device"); // 编辑时的详情数据(不需要保存整份数据,仅回填表单与本地状态) @@ -122,8 +105,7 @@ const TrafficDistributionForm: React.FC = () => { form.setFieldsValue({ timeRange: [startTime, endTime] }); } - // 设置流量池 - setSelectedPools(config.pools.map((pool: any) => pool.id || pool)); + // 设置流量池 - 交由 PoolSelection 控件受控 } catch (error) { console.error("获取详情失败:", error); message.error("获取详情失败"); @@ -142,11 +124,15 @@ const TrafficDistributionForm: React.FC = () => { form.submit(); }; - // 移除未使用的 handleFinish3 - const handleFinish2 = async (values?: any) => { setLoading(true); try { + // 校验流量池至少选择一个 + if (!poolGroupsOptions || poolGroupsOptions.length === 0) { + message.error("请至少选择一个流量池"); + setLoading(false); + return; + } // 如果没有传递values参数,从表单中获取 const formValues = values || form.getFieldsValue(); @@ -168,9 +154,9 @@ const TrafficDistributionForm: React.FC = () => { formValues.timeType === 2 && formValues.timeRange?.[1] ? formValues.timeRange[1].format("HH:mm") : "", - deviceGroups: deviceGroups, + deviceGroups: deviceGroupsOptions.map(v => v.id), deviceGroupsOptions: deviceGroupsOptions, - accountGroups: accountGroups, + accountGroups: accountGroupsOptions.map(v => v.id), accountGroupsOptions: accountGroupsOptions, pools: poolGroupsOptions.map(v => v.id), enabled: true, @@ -208,10 +194,8 @@ const TrafficDistributionForm: React.FC = () => { // 第二步:目标设置至少需要选择设备或客服之一 const hasDevice = Array.isArray(selectedDevices) && selectedDevices.length > 0; - const hasAccount = - Array.isArray(selectedAccounts) && selectedAccounts.length > 0; - if (!hasDevice && !hasAccount) { - message.error("请至少选择一个设备或一个客服"); + if (!hasDevice) { + message.error("请至少选择一个设备"); return; } setCurrent(cur => cur + 1); @@ -221,9 +205,6 @@ const TrafficDistributionForm: React.FC = () => { }; const prev = () => setCurrent(cur => cur - 1); - // 过滤流量池 - const filteredPools = poolList.filter(pool => pool.name.includes(poolSearch)); - const handPoolAction = params => { setPoolGroupsOptions(params); }; @@ -355,107 +336,40 @@ const TrafficDistributionForm: React.FC = () => { /> )} + +
客服选择
+
+ { + setAccountGroupsOptions(accounts); + }} + placeholder="请选择客服" + showSelectedList={true} + selectedListMaxHeight={300} + accountGroups={accountGroups} + /> +
{current === 1 && (
目标设置
- - {/* Tab 切换 */} -
-
-
setTargetSelectionTab("device")} - > - 设备选择 -
-
setTargetSelectionTab("account")} - > - 客服选择 -
-
-
- - {/* Tab 内容 */} -
- {targetSelectionTab === "device" && ( -
- { - setSelectedDevices(devices); - setDeviceGroupsOptions(devices); - }} - placeholder="请选择设备" - showSelectedList={true} - selectedListMaxHeight={300} - deviceGroups={deviceGroups} - /> -
- )} - {targetSelectionTab === "account" && ( -
- { - setSelectedAccounts(accounts); - setAccountGroupsOptions(accounts); - }} - placeholder="请选择客服" - showSelectedList={true} - selectedListMaxHeight={300} - accountGroups={accountGroups} - /> -
- )} +
+ { + setSelectedDevices(devices); + setDeviceGroupsOptions(devices); + }} + placeholder="请选择设备" + showSelectedList={true} + selectedListMaxHeight={300} + deviceGroups={deviceGroups} + />
)} {current === 2 && ( - //
- //
流量池选择
- //
- // setPoolSearch(e.target.value)} - // style={{ marginBottom: 12 }} - // /> - //
- // {filteredPools.map(pool => ( - // - // ))} - //
- //
- // 已选流量池:{selectedPools.length} 个 - //
- //
- //