FEAT => 本次更新项目为:新增获取京东社交媒体和推广站点列表的接口,并优化相关组件的状态管理与数据处理
This commit is contained in:
@@ -5,7 +5,7 @@ import React, {
|
|||||||
forwardRef,
|
forwardRef,
|
||||||
} from "react";
|
} from "react";
|
||||||
import { Form, Select, Card } from "antd";
|
import { Form, Select, Card } from "antd";
|
||||||
import request from "@/api/request";
|
import { fetchSocialMediaList, fetchPromotionSiteList } from "../index.api";
|
||||||
|
|
||||||
// 京东社交媒体接口
|
// 京东社交媒体接口
|
||||||
interface JdSocialMedia {
|
interface JdSocialMedia {
|
||||||
@@ -73,71 +73,31 @@ const JingDongLink = forwardRef<JingDongLinkRef, JingDongLinkProps>(
|
|||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// 获取京东社交媒体列表
|
|
||||||
const fetchSocialMediaList = async () => {
|
|
||||||
setLoadingSocialMedia(true);
|
|
||||||
try {
|
|
||||||
const response = await request(
|
|
||||||
"/v1/workbench/getJdSocialMedia",
|
|
||||||
{},
|
|
||||||
"GET",
|
|
||||||
);
|
|
||||||
if (response && Array.isArray(response)) {
|
|
||||||
setSocialMediaList(response);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error("获取京东社交媒体列表失败:", error);
|
|
||||||
} finally {
|
|
||||||
setLoadingSocialMedia(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// 获取京东推广站点列表
|
|
||||||
const fetchPromotionSiteList = async (socialMediaId: string) => {
|
|
||||||
setLoadingPromotionSite(true);
|
|
||||||
try {
|
|
||||||
const response = await request(
|
|
||||||
"/v1/workbench/getJdPromotionSite",
|
|
||||||
{ socialMediaId },
|
|
||||||
"GET",
|
|
||||||
);
|
|
||||||
if (response && Array.isArray(response)) {
|
|
||||||
setPromotionSiteList(response);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error("获取京东推广站点列表失败:", error);
|
|
||||||
} finally {
|
|
||||||
setLoadingPromotionSite(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// 组件挂载时获取社交媒体列表
|
// 组件挂载时获取社交媒体列表
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchSocialMediaList();
|
fetchSocialMediaList().then(res => {
|
||||||
|
setSocialMediaList(res);
|
||||||
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// 监听社交媒体选择变化
|
// 监听社交媒体选择变化
|
||||||
const handleSocialMediaChange = (value: string) => {
|
const handleSocialMediaChange = (value: number) => {
|
||||||
|
form.setFieldsValue({ socialMediaId: value });
|
||||||
// 清空推广站点选择
|
// 清空推广站点选择
|
||||||
form.setFieldsValue({ promotionSiteId: undefined });
|
form.setFieldsValue({ promotionSiteId: undefined });
|
||||||
setPromotionSiteList([]);
|
setPromotionSiteList([]);
|
||||||
|
|
||||||
if (value) {
|
if (value) {
|
||||||
fetchPromotionSiteList(value);
|
fetchPromotionSiteList(value).then(res => {
|
||||||
|
setPromotionSiteList(res);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{ marginBottom: 24 }}>
|
<div style={{ marginBottom: 24 }}>
|
||||||
<Card title="京东联盟">
|
<Card title="京东联盟">
|
||||||
<Form
|
<Form form={form} layout="vertical" initialValues={defaultValues}>
|
||||||
form={form}
|
|
||||||
layout="vertical"
|
|
||||||
initialValues={defaultValues}
|
|
||||||
onValuesChange={(changedValues, allValues) => {
|
|
||||||
// 可以在这里处理表单值变化
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{/* 京东社交媒体选择 */}
|
{/* 京东社交媒体选择 */}
|
||||||
<Form.Item label="京东联盟" style={{ marginBottom: 16 }}>
|
<Form.Item label="京东联盟" style={{ marginBottom: 16 }}>
|
||||||
<div style={{ display: "flex", gap: 12, alignItems: "flex-end" }}>
|
<div style={{ display: "flex", gap: 12, alignItems: "flex-end" }}>
|
||||||
|
|||||||
@@ -1,6 +1,14 @@
|
|||||||
import request from "@/api/request";
|
import request from "@/api/request";
|
||||||
export async function createGroupPushTask(
|
export function createGroupPushTask(taskData) {
|
||||||
taskData: Partial<GroupPushTask>,
|
|
||||||
): Promise<ApiResponse> {
|
|
||||||
return request("/v1/workspace/group-push/tasks", taskData, "POST");
|
return request("/v1/workspace/group-push/tasks", taskData, "POST");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取京东社交媒体列表
|
||||||
|
export const fetchSocialMediaList = async () => {
|
||||||
|
return request("/v1/workbench/getJdSocialMedia", {}, "GET");
|
||||||
|
};
|
||||||
|
|
||||||
|
// 获取京东推广站点列表
|
||||||
|
export const fetchPromotionSiteList = async (id: number) => {
|
||||||
|
return request("/v1/workbench/getJdPromotionSite", { id }, "GET");
|
||||||
|
};
|
||||||
|
|||||||
@@ -112,8 +112,8 @@ const NewGroupPush: React.FC = () => {
|
|||||||
isLoopPush: formData.isLoopPush,
|
isLoopPush: formData.isLoopPush,
|
||||||
isImmediatePush: formData.isImmediatePush,
|
isImmediatePush: formData.isImmediatePush,
|
||||||
isEnabled: formData.isEnabled,
|
isEnabled: formData.isEnabled,
|
||||||
targetGroups: formData.wechatGroups,
|
wechatGroups: formData.wechatGroups,
|
||||||
contentLibraries: formData.contentGroups,
|
contentGroups: formData.contentGroups,
|
||||||
// 京东联盟数据
|
// 京东联盟数据
|
||||||
socialMediaId: jingDongLinkValues?.socialMediaId,
|
socialMediaId: jingDongLinkValues?.socialMediaId,
|
||||||
promotionSiteId: jingDongLinkValues?.promotionSiteId,
|
promotionSiteId: jingDongLinkValues?.promotionSiteId,
|
||||||
|
|||||||
Reference in New Issue
Block a user