超级老白兔
2025-08-12 11:33:55 +08:00
parent 1750dc13eb
commit faf8a6e234
9 changed files with 50 additions and 529 deletions

View File

@@ -29,6 +29,7 @@ interface FormData {
scenario: number;
posters: any[]; // 后续可替换为具体Poster类型
device: string[];
customTags: string[];
remarkType: string;
greeting: string;
addInterval: number;
@@ -50,6 +51,7 @@ export default function NewPlan() {
scenario: 1,
posters: [],
device: [],
customTags: [],
remarkType: "phone",
greeting: "你好,请通过",
addInterval: 1,
@@ -126,6 +128,23 @@ export default function NewPlan() {
// 处理保存
const handleSave = async () => {
if (isEdit && planId) {
// 编辑:拼接后端需要的完整参数
const editData = {
...formData,
...{ sceneId: Number(formData.scenario) },
id: Number(planId),
planId: Number(planId),
};
console.log("editData", editData);
} else {
// 新建
formData.sceneId = Number(formData.scenario);
console.log("formData", formData);
}
};
// 处理保存
const handleSave2 = async () => {
try {
if (isEdit && planId) {
// 编辑:拼接后端需要的完整参数

View File

@@ -51,7 +51,9 @@ const BasicSettings: React.FC<BasicSettingsProps> = ({
// 自定义标签相关状态
const [customTagInput, setCustomTagInput] = useState("");
const [customTags, setCustomTags] = useState(formData.customTags || []);
const [customTags, setCustomTags] = useState<string[]>(
formData.customTags || [],
);
const [tips, setTips] = useState(formData.tips || "");
const [selectedScenarioTags, setSelectedScenarioTags] = useState(
formData.scenarioTags || [],
@@ -107,10 +109,7 @@ const BasicSettings: React.FC<BasicSettingsProps> = ({
// 添加自定义标签
const handleAddCustomTag = () => {
if (!customTagInput.trim()) return;
const newTag = {
id: `custom-${Date.now()}`,
name: customTagInput.trim(),
};
const newTag = customTagInput.trim();
const updatedCustomTags = [...customTags, newTag];
setCustomTags(updatedCustomTags);
setCustomTagInput("");
@@ -118,13 +117,15 @@ const BasicSettings: React.FC<BasicSettingsProps> = ({
};
// 删除自定义标签
const handleRemoveCustomTag = (tagId: string) => {
const updatedCustomTags = customTags.filter((tag: any) => tag.id !== tagId);
const handleRemoveCustomTag = (tagName: string) => {
const updatedCustomTags = customTags.filter(
(tag: string) => tag !== tagName,
);
setCustomTags(updatedCustomTags);
onChange({ ...formData, customTags: updatedCustomTags });
// 同时从选中标签中移除
const updatedSelectedTags = selectedScenarioTags.filter(
(t: string) => t !== tagId,
(t: string) => t !== tagName,
);
setSelectedScenarioTags(updatedSelectedTags);
onChange({
@@ -134,19 +135,6 @@ const BasicSettings: React.FC<BasicSettingsProps> = ({
});
};
// 新增:自定义上传图片
const handleCustomPosterUpload = (urls: string[]) => {
if (urls && urls.length > 0) {
const newPoster: Material = {
id: `custom-${Date.now()}`,
name: "自定义海报",
type: "poster",
preview: urls[0],
};
setCustomPosters(prev => [...prev, newPoster]);
}
};
// 新增:删除自定义海报
const handleRemoveCustomPoster = (id: string) => {
setCustomPosters(prev => prev.filter(p => p.id !== id));
@@ -169,12 +157,6 @@ const BasicSettings: React.FC<BasicSettingsProps> = ({
}
};
// 移除已选素材
const handleRemoveMaterial = (id: string) => {
setSelectedMaterials([]);
onChange({ ...formData, materials: [] });
};
// 新增:全屏预览
const handlePreviewImage = (url: string) => {
setPreviewUrl(url);
@@ -266,16 +248,16 @@ const BasicSettings: React.FC<BasicSettingsProps> = ({
</Tag>
))}
{/* 自定义标签 */}
{customTags.map((tag: any) => (
{customTags.map((tag: string) => (
<Tag
key={tag.id}
color={selectedScenarioTags.includes(tag.id) ? "blue" : "default"}
onClick={() => handleScenarioTagToggle(tag.id)}
key={tag}
color={selectedScenarioTags.includes(tag) ? "blue" : "default"}
onClick={() => handleScenarioTagToggle(tag)}
closable
onClose={() => handleRemoveCustomTag(tag.id)}
onClose={() => handleRemoveCustomTag(tag)}
className={styles["basic-tag-item"]}
>
{tag.name}
{tag}
</Tag>
))}
</div>