修改字段名
This commit is contained in:
parent
23edcea925
commit
05bc6c36ba
|
@ -67,7 +67,7 @@ const BannerList = (props) => {
|
|||
<div key={index}>
|
||||
<p className="text-[#00000080]">
|
||||
{hyperlink.action === "outward"
|
||||
? "外部链接:"
|
||||
? "打开新的浏览器页面:"
|
||||
: hyperlink.action === "webViewHeaderInward"
|
||||
? "应用内打开内链(带头):"
|
||||
: hyperlink.action === "webViewHeaderOutward"
|
||||
|
@ -80,7 +80,12 @@ const BannerList = (props) => {
|
|||
? "H5:"
|
||||
: "App:"}
|
||||
</p>
|
||||
<span>{hyperlink.url}</span>
|
||||
<span
|
||||
className="block"
|
||||
style={{ maxWidth: "200px", wordWrap: "break-word" }}
|
||||
>
|
||||
{hyperlink.url}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
@ -202,10 +207,13 @@ const BannerList = (props) => {
|
|||
</Space.Compact>
|
||||
<Space.Compact direction="vertical">
|
||||
<Button
|
||||
style={{ background: "#17d983", color: "#fff" }}
|
||||
style={{
|
||||
background: record.status === 1 ? "#ffe747" : "#17d983",
|
||||
color: record.status === 1 ? "#333" : "#fff",
|
||||
}}
|
||||
onClick={() => handleStopAndStart(record)}
|
||||
>
|
||||
暂停推送
|
||||
{record.status === 1 ? "继续推送" : "暂停推送"}
|
||||
</Button>
|
||||
</Space.Compact>
|
||||
</>
|
||||
|
@ -241,7 +249,7 @@ const BannerList = (props) => {
|
|||
formRef.current.submit();
|
||||
};
|
||||
//提交表单
|
||||
const handleSubmit = async (value) => {
|
||||
const handleSubmit = async (value, type) => {
|
||||
const {
|
||||
action,
|
||||
status,
|
||||
|
@ -288,7 +296,7 @@ const BannerList = (props) => {
|
|||
},
|
||||
];
|
||||
}
|
||||
if (!id) {
|
||||
if (typeof id !== "number") {
|
||||
if (!status && new Date(st).getTime() < new Date().getTime()) {
|
||||
messageApi.open({
|
||||
type: "warning",
|
||||
|
@ -322,10 +330,16 @@ const BannerList = (props) => {
|
|||
image: image?.images ? image : { image_ids: displayImageId },
|
||||
user_id: "",
|
||||
};
|
||||
if (id) {
|
||||
if (typeof id === "number") {
|
||||
delete dataObj.st;
|
||||
delete dataObj.et;
|
||||
}
|
||||
if (
|
||||
type === "stopStart" ||
|
||||
dataObj.priority === selectedStreamer?.priority
|
||||
) {
|
||||
delete dataObj.priority;
|
||||
}
|
||||
const base = baseRequest();
|
||||
const body = JSON.stringify({
|
||||
...dataObj,
|
||||
|
@ -350,7 +364,7 @@ const BannerList = (props) => {
|
|||
handleCancelModal();
|
||||
getData();
|
||||
} catch (error) {
|
||||
message.error("服务器错误");
|
||||
message.error("出现问题了");
|
||||
}
|
||||
};
|
||||
//获取数据
|
||||
|
@ -474,7 +488,7 @@ const BannerList = (props) => {
|
|||
.filter((it) => it.inward_action_type === "app")[0]
|
||||
.url.split("=")[1]
|
||||
: "";
|
||||
const action = hyperlinks.length > 1 ? "inward" : "outward";
|
||||
const action = hyperlinks.length > 1 ? "inward" : hyperlinks[0]?.action;
|
||||
const link = action === "inward" ? "" : hyperlinks[0].url;
|
||||
|
||||
const isCurrentPagePath = pagesOptions.filter(
|
||||
|
@ -485,6 +499,8 @@ const BannerList = (props) => {
|
|||
setPathMethod(action);
|
||||
setCurrentItem(data);
|
||||
setDisplayImageId(data.image.image_ids);
|
||||
setSelectedStreamer(data);
|
||||
await handleSearchMid(user_id);
|
||||
form.setFieldsValue({
|
||||
...data,
|
||||
st: newSt,
|
||||
|
@ -500,7 +516,7 @@ const BannerList = (props) => {
|
|||
});
|
||||
};
|
||||
const handleStopAndStart = (data) => {
|
||||
handleSubmit({ ...data, status: 1 });
|
||||
handleSubmit({ ...data, status: data.status === 0 ? 1 : 0 }, "stopStart");
|
||||
};
|
||||
const handleDeleteItem = async (id) => {
|
||||
try {
|
||||
|
@ -620,7 +636,7 @@ const BannerList = (props) => {
|
|||
}
|
||||
|
||||
return list;
|
||||
}, [currentPageName, pathMethod]);
|
||||
}, [currentPageName, pathMethod, selectedStreamer]);
|
||||
//搜索空间
|
||||
const handleSearchMid = async (mid) => {
|
||||
// const mid = form.getFieldValue("mid");
|
||||
|
@ -885,12 +901,17 @@ const BannerList = (props) => {
|
|||
// setSelectedStreamer(null);
|
||||
// }
|
||||
if (currentIt) {
|
||||
form.setFieldValue("mid", currentIt.mid);
|
||||
setSelectedStreamer({
|
||||
...currentIt,
|
||||
mid: currentIt.mid,
|
||||
});
|
||||
}
|
||||
}}
|
||||
onClear={() => {
|
||||
setSelectedStreamer(null);
|
||||
setZones(null);
|
||||
}}
|
||||
filterOption={false}
|
||||
onSearch={debounce(handleSearchMid, 1000)}
|
||||
notFoundContent={
|
||||
|
|
|
@ -60,6 +60,7 @@ const HotList = (props) => {
|
|||
key: "text",
|
||||
},
|
||||
{
|
||||
with: 120,
|
||||
title: "跳转链接",
|
||||
dataIndex: "hyperlinks",
|
||||
key: "hyperlinks",
|
||||
|
@ -69,7 +70,7 @@ const HotList = (props) => {
|
|||
<div key={index}>
|
||||
<p className="text-[#00000080]">
|
||||
{hyperlink.action === "outward"
|
||||
? "外部链接:"
|
||||
? "打开新的浏览器页面:"
|
||||
: hyperlink.action === "webViewHeaderInward"
|
||||
? "应用内打开内链(带头):"
|
||||
: hyperlink.action === "webViewHeaderOutward"
|
||||
|
@ -83,11 +84,18 @@ const HotList = (props) => {
|
|||
: "App:"}
|
||||
</p>
|
||||
{hyperlink.action === "outward" ? (
|
||||
<a href={hyperlink.url} target="_blank">
|
||||
<a
|
||||
href={hyperlink.url}
|
||||
target="_blank"
|
||||
className="block"
|
||||
style={{ maxWidth: "120px", wordWrap: "break-word" }}
|
||||
>
|
||||
{hyperlink.url}
|
||||
</a>
|
||||
) : (
|
||||
<span>{hyperlink.url}</span>
|
||||
<p style={{ maxWidth: "120px", wordWrap: "break-word" }}>
|
||||
{hyperlink.url}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
|
@ -191,7 +199,10 @@ const HotList = (props) => {
|
|||
</Space.Compact>
|
||||
<Space.Compact direction="vertical">
|
||||
<Button
|
||||
style={{ background: "#17d983", color: "#fff" }}
|
||||
style={{
|
||||
background: record.status === 1 ? "#ffe747" : "#17d983",
|
||||
color: record.status === 1 ? "#333" : "#fff",
|
||||
}}
|
||||
onClick={() =>
|
||||
handlePauseOrStopAndStart(
|
||||
record,
|
||||
|
@ -235,7 +246,7 @@ const HotList = (props) => {
|
|||
//给表单绑定ref
|
||||
const formRef = useRef(null);
|
||||
//提交表单
|
||||
const handleSubmit = async (value) => {
|
||||
const handleSubmit = async (value, type) => {
|
||||
const {
|
||||
action,
|
||||
status,
|
||||
|
@ -248,6 +259,7 @@ const HotList = (props) => {
|
|||
ueser_id,
|
||||
id,
|
||||
mid,
|
||||
innerMid,
|
||||
} = value;
|
||||
|
||||
let newHyperlinks = [];
|
||||
|
@ -284,7 +296,7 @@ const HotList = (props) => {
|
|||
},
|
||||
];
|
||||
}
|
||||
if (!id) {
|
||||
if (typeof id !== "number") {
|
||||
if (!status && new Date(st).getTime() < new Date().getTime()) {
|
||||
messageApi.open({
|
||||
type: "warning",
|
||||
|
@ -308,6 +320,7 @@ const HotList = (props) => {
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
//通过图片审核,如果是视频直接跳过
|
||||
const dataObj = {
|
||||
|
@ -317,12 +330,27 @@ const HotList = (props) => {
|
|||
hyperlinks: newHyperlinks,
|
||||
image: image?.images ? image : { image_ids: displayImageId },
|
||||
user_id: "",
|
||||
mid: selectedStreamer?.inputType === "outter" ? mid : null,
|
||||
mid:
|
||||
selectedStreamer?.inputType === "outter"
|
||||
? mid
|
||||
: innerMid
|
||||
? null
|
||||
: mid,
|
||||
};
|
||||
if (id) {
|
||||
|
||||
if (typeof id === "number") {
|
||||
delete dataObj.st;
|
||||
delete dataObj.et;
|
||||
}
|
||||
debugger;
|
||||
|
||||
if (
|
||||
type === "stopStart" ||
|
||||
dataObj.priority === selectedStreamer?.priority
|
||||
) {
|
||||
delete dataObj.priority;
|
||||
}
|
||||
|
||||
const base = baseRequest();
|
||||
const body = JSON.stringify({
|
||||
...dataObj,
|
||||
|
@ -360,7 +388,7 @@ const HotList = (props) => {
|
|||
const [currentStatus, setCurrentStatus] = useState(null);
|
||||
const [currentPageName, setCurrentPageName] = useState("");
|
||||
const [buttonAble, setButtonAble] = useState(false);
|
||||
const [formData] = useState({
|
||||
const [formData, setFormData] = useState({
|
||||
mid: null,
|
||||
title: "",
|
||||
image: "",
|
||||
|
@ -497,11 +525,11 @@ const HotList = (props) => {
|
|||
};
|
||||
const handleEditHot = async (data) => {
|
||||
setIsModalOpen(true);
|
||||
const { hyperlinks, st, et, mid, status, user_id, id } = data;
|
||||
const { hyperlinks, st, et, mid, status, user_id, id, innerMid } = data;
|
||||
const newSt = dayjs(st * 1000);
|
||||
const newEt = dayjs(et * 1000);
|
||||
const currentPageId = hyperlinks?.[0].frontend_route_id;
|
||||
const params = hyperlinks[0].url.split("?")[1];
|
||||
const params = hyperlinks[0]?.url?.split("?")[1];
|
||||
const action = hyperlinks[0].action;
|
||||
const link = action === "inward" ? "" : hyperlinks[0].url;
|
||||
|
||||
|
@ -524,6 +552,7 @@ const HotList = (props) => {
|
|||
setSelectedStreamer(data);
|
||||
setDisplayImageId(data?.image?.image_ids);
|
||||
await handleSearchMid(user_id);
|
||||
|
||||
form.setFieldsValue({
|
||||
...data,
|
||||
st: newSt,
|
||||
|
@ -534,6 +563,7 @@ const HotList = (props) => {
|
|||
params,
|
||||
hyperlinks: "",
|
||||
mid,
|
||||
innerMid: mid || parseInt(params?.split("=")[1]),
|
||||
user_id,
|
||||
id,
|
||||
});
|
||||
|
@ -550,13 +580,16 @@ const HotList = (props) => {
|
|||
action === "inward"
|
||||
? JSON.stringify(isCurrentPagePath[0])
|
||||
: hyperlinks[0].url;
|
||||
handleSubmit({
|
||||
...data,
|
||||
pageName,
|
||||
st: st * 1000,
|
||||
et: et * 1000,
|
||||
status,
|
||||
});
|
||||
handleSubmit(
|
||||
{
|
||||
...data,
|
||||
pageName,
|
||||
st: st * 1000,
|
||||
et: et * 1000,
|
||||
status,
|
||||
},
|
||||
"stopStart"
|
||||
);
|
||||
};
|
||||
//搜索空间
|
||||
const handleSearchMid = async (mid) => {
|
||||
|
@ -619,6 +652,7 @@ const HotList = (props) => {
|
|||
setZones(null);
|
||||
setDisplayImageId([]);
|
||||
setCurrentStatus(null);
|
||||
form.setFieldValue("mid", null);
|
||||
};
|
||||
|
||||
const currentStreamerImage = useMemo(() => {
|
||||
|
@ -703,7 +737,7 @@ const HotList = (props) => {
|
|||
}
|
||||
|
||||
return list;
|
||||
}, [currentPageName, pathMethod]);
|
||||
}, [currentPageName, pathMethod, selectedStreamer]);
|
||||
return (
|
||||
<div style={{ marginLeft: 20, marginRight: 20 }}>
|
||||
<div className="flex justify-between items-center">
|
||||
|
@ -763,74 +797,83 @@ const HotList = (props) => {
|
|||
layout="vertical"
|
||||
initialValues={formData}
|
||||
>
|
||||
<div style={{ marginBottom: 20 }} className="flex-1">
|
||||
<Form.Item
|
||||
label="ID"
|
||||
name="mid"
|
||||
layout="horizontal"
|
||||
style={{
|
||||
margin: 0,
|
||||
display:
|
||||
selectedStreamer?.inputType === "inner" ? "none" : "block",
|
||||
}}
|
||||
>
|
||||
<Select
|
||||
// style={{
|
||||
// width: 240,
|
||||
// }}
|
||||
disabled={selectedStreamer?.inputType === "inner"}
|
||||
className="w-full"
|
||||
showSearch
|
||||
allowClear
|
||||
placeholder="通过ID搜索主播"
|
||||
// optionFilterProp="label"
|
||||
onChange={(v) => {
|
||||
if (selectedStreamer?.inputType === "inner") return;
|
||||
const currentIt = zones?.filter((it) => it.mid == v)[0];
|
||||
if (currentIt) {
|
||||
setSelectedStreamer({ ...currentIt, inputType: "outter" });
|
||||
setDisplayImageId(currentIt.streamer_ext.avatar.image_ids);
|
||||
form.setFieldsValue({
|
||||
mid: v,
|
||||
title:
|
||||
form.getFieldValue("title") ||
|
||||
currentIt.streamer_ext.name,
|
||||
// image: displayImageId[0] || currentIt.streamer_ext.avatar,
|
||||
text: form.getFieldValue("text") || currentIt.profile,
|
||||
});
|
||||
} else {
|
||||
setSelectedStreamer(null);
|
||||
form.setFieldsValue({
|
||||
mid: null,
|
||||
});
|
||||
}
|
||||
{!currentStatus && (
|
||||
<div style={{ marginBottom: 20 }} className="flex-1">
|
||||
<Form.Item
|
||||
label="ID"
|
||||
name="mid"
|
||||
layout="horizontal"
|
||||
style={{
|
||||
margin: 0,
|
||||
display:
|
||||
selectedStreamer?.inputType === "inner" ? "none" : "block",
|
||||
}}
|
||||
filterOption={false}
|
||||
onSearch={debounce(handleSearchMid, 1000)}
|
||||
notFoundContent={isLoading ? <Spin size="small" /> : null}
|
||||
options={zones?.map((it) => ({
|
||||
value: it.mid,
|
||||
label: (
|
||||
<div className="flex">
|
||||
<p className="font-bold w-1/4 min-w-[150px]">
|
||||
ID:{it?.streamer_ext?.user_id}
|
||||
</p>
|
||||
<p className="font-bold w-3/4">
|
||||
昵称:{it?.streamer_ext.name}
|
||||
</p>
|
||||
</div>
|
||||
),
|
||||
}))}
|
||||
labelRender={({ value }) => {
|
||||
const currentIt = zones?.filter((it) => it.mid == value)[0];
|
||||
if (currentIt) {
|
||||
return currentIt.streamer_ext.name;
|
||||
}
|
||||
return <span>No option match</span>;
|
||||
}}
|
||||
/>
|
||||
</Form.Item>
|
||||
</div>
|
||||
>
|
||||
<Select
|
||||
// style={{
|
||||
// width: 240,
|
||||
// }}
|
||||
disabled={selectedStreamer?.inputType === "inner"}
|
||||
className="w-full"
|
||||
showSearch
|
||||
allowClear
|
||||
placeholder="通过ID搜索主播"
|
||||
// optionFilterProp="label"
|
||||
onChange={(v) => {
|
||||
if (selectedStreamer?.inputType === "inner") return;
|
||||
const currentIt = zones?.filter((it) => it.mid == v)[0];
|
||||
if (currentIt) {
|
||||
setSelectedStreamer({
|
||||
...currentIt,
|
||||
inputType: "outter",
|
||||
});
|
||||
setDisplayImageId(
|
||||
currentIt.streamer_ext.avatar.image_ids
|
||||
);
|
||||
form.setFieldsValue({
|
||||
mid: v,
|
||||
title:
|
||||
// form.getFieldValue("title") ||
|
||||
currentIt.streamer_ext.name,
|
||||
// image: displayImageId[0] || currentIt.streamer_ext.avatar,
|
||||
text:
|
||||
// form.getFieldValue("text") ||
|
||||
currentIt.profile,
|
||||
});
|
||||
} else {
|
||||
setSelectedStreamer(null);
|
||||
form.setFieldsValue({
|
||||
mid: null,
|
||||
});
|
||||
}
|
||||
}}
|
||||
filterOption={false}
|
||||
onSearch={debounce(handleSearchMid, 1000)}
|
||||
notFoundContent={isLoading ? <Spin size="small" /> : null}
|
||||
options={zones?.map((it) => ({
|
||||
value: it.mid,
|
||||
label: (
|
||||
<div className="flex">
|
||||
<p className="font-bold w-1/4 min-w-[150px]">
|
||||
ID:{it?.streamer_ext?.user_id}
|
||||
</p>
|
||||
<p className="font-bold w-3/4">
|
||||
昵称:{it?.streamer_ext.name}
|
||||
</p>
|
||||
</div>
|
||||
),
|
||||
}))}
|
||||
labelRender={({ value }) => {
|
||||
const currentIt = zones?.filter((it) => it.mid == value)[0];
|
||||
if (currentIt) {
|
||||
return currentIt.streamer_ext.name;
|
||||
}
|
||||
return <span>No option match</span>;
|
||||
}}
|
||||
/>
|
||||
</Form.Item>
|
||||
</div>
|
||||
)}
|
||||
<Form.Item
|
||||
label="主图"
|
||||
name="image"
|
||||
|
@ -925,6 +968,7 @@ const HotList = (props) => {
|
|||
params: "",
|
||||
hyperlinks: "",
|
||||
mid: null,
|
||||
innerMid: null,
|
||||
});
|
||||
setPathMethod(e);
|
||||
}}
|
||||
|
@ -1031,66 +1075,75 @@ const HotList = (props) => {
|
|||
direction="vertical"
|
||||
className="bg-white rounded-xl p-4"
|
||||
>
|
||||
<Select
|
||||
// style={{
|
||||
// width: 240,
|
||||
// }}
|
||||
className="w-full"
|
||||
style={{
|
||||
display:
|
||||
selectedStreamer?.inputType === "outter"
|
||||
? "none"
|
||||
: "block",
|
||||
}}
|
||||
showSearch
|
||||
allowClear
|
||||
placeholder="通过ID搜索主播"
|
||||
// optionFilterProp="label"
|
||||
onChange={(v) => {
|
||||
if (selectedStreamer?.inputType === "outter") return;
|
||||
const currentIt = zones?.filter(
|
||||
(it) => it.mid == v
|
||||
)[0];
|
||||
// if (currentIt) {
|
||||
// setSelectedStreamer(currentIt);
|
||||
// } else {
|
||||
// setSelectedStreamer(null);
|
||||
// }
|
||||
if (currentIt) {
|
||||
form.setFieldValue("mid", currentIt.mid);
|
||||
setSelectedStreamer({
|
||||
...currentIt,
|
||||
inputType: "inner",
|
||||
mid: currentIt.mid,
|
||||
});
|
||||
<Form.Item name="innerMid" className="mb-0">
|
||||
<Select
|
||||
// style={{
|
||||
// width: 240,
|
||||
// }}
|
||||
className="w-full"
|
||||
style={{
|
||||
display:
|
||||
selectedStreamer?.inputType === "outter"
|
||||
? "none"
|
||||
: "block",
|
||||
}}
|
||||
// value={selectedStreamer?.mid}
|
||||
showSearch
|
||||
allowClear
|
||||
placeholder="通过ID搜索主播"
|
||||
// optionFilterProp="label"
|
||||
onChange={(v) => {
|
||||
if (selectedStreamer?.inputType === "outter")
|
||||
return;
|
||||
const currentIt = zones?.filter(
|
||||
(it) => it.mid == v
|
||||
)[0];
|
||||
// if (currentIt) {
|
||||
// setSelectedStreamer(currentIt);
|
||||
// } else {
|
||||
// setSelectedStreamer(null);
|
||||
// }
|
||||
if (currentIt) {
|
||||
form.setFieldValue("innerMid", currentIt.mid);
|
||||
setSelectedStreamer({
|
||||
...currentIt,
|
||||
inputType: "inner",
|
||||
mid: currentIt.mid,
|
||||
});
|
||||
}
|
||||
}}
|
||||
onClear={() => {
|
||||
form.setFieldValue("innerMid", null);
|
||||
setSelectedStreamer(null);
|
||||
setZones(null);
|
||||
}}
|
||||
filterOption={false}
|
||||
onSearch={debounce(handleSearchMid, 1000)}
|
||||
notFoundContent={
|
||||
isLoading ? <Spin size="small" /> : null
|
||||
}
|
||||
}}
|
||||
filterOption={false}
|
||||
onSearch={debounce(handleSearchMid, 1000)}
|
||||
notFoundContent={
|
||||
isLoading ? <Spin size="small" /> : null
|
||||
}
|
||||
options={zones?.map((it) => ({
|
||||
value: it.mid,
|
||||
label: (
|
||||
<div>
|
||||
<p className="font-bold w-1/4">ID:{it?.mid}</p>
|
||||
<p className="font-bold w-3/4">
|
||||
昵称:{it?.streamer_ext.name}
|
||||
</p>
|
||||
</div>
|
||||
),
|
||||
}))}
|
||||
labelRender={({ value }) => {
|
||||
const currentIt = zones?.filter(
|
||||
(it) => it.mid == value
|
||||
)[0];
|
||||
if (currentIt) {
|
||||
return currentIt.streamer_ext.name;
|
||||
}
|
||||
return <span>No option match</span>;
|
||||
}}
|
||||
/>
|
||||
options={zones?.map((it) => ({
|
||||
value: it.mid,
|
||||
label: (
|
||||
<div>
|
||||
<p className="font-bold w-1/4">ID:{it?.mid}</p>
|
||||
<p className="font-bold w-3/4">
|
||||
昵称:{it?.streamer_ext.name}
|
||||
</p>
|
||||
</div>
|
||||
),
|
||||
}))}
|
||||
labelRender={({ value }) => {
|
||||
const currentIt = zones?.filter(
|
||||
(it) => it.mid == value
|
||||
)[0];
|
||||
if (currentIt) {
|
||||
return currentIt.streamer_ext.name;
|
||||
}
|
||||
return <span>No option match</span>;
|
||||
}}
|
||||
/>
|
||||
</Form.Item>
|
||||
{splitParams.map((it) => (
|
||||
<Form.Item
|
||||
name={it}
|
||||
|
|
|
@ -36,7 +36,7 @@ export default function HotManage() {
|
|||
<div>
|
||||
<Menu
|
||||
onClick={onClick}
|
||||
selectedKeys={[current]}
|
||||
selectedKeys={[pathname]}
|
||||
mode="horizontal"
|
||||
items={items}
|
||||
/>
|
||||
|
|
Loading…
Reference in New Issue