|
@@ -9,18 +9,20 @@ import { MessageFu } from "@/utils/message";
|
|
|
|
|
|
function A2intro() {
|
|
|
const dispatch = useDispatch();
|
|
|
- const tableInfo = useSelector((state: RootState) => state.A2intro.tableInfo.map((i, idx) => ({
|
|
|
- ...i,
|
|
|
- key: `${idx}`,
|
|
|
- label: i.name,
|
|
|
- })));
|
|
|
- const [activeKey, setActiveKey] = useState('0');
|
|
|
+ const tableInfo = useSelector((state: RootState) =>
|
|
|
+ state.A2intro.tableInfo.map((i, idx) => ({
|
|
|
+ ...i,
|
|
|
+ key: `${idx}`,
|
|
|
+ label: i.name,
|
|
|
+ }))
|
|
|
+ );
|
|
|
+ const [activeKey, setActiveKey] = useState("0");
|
|
|
const [isLook, setIsLook] = useState(true);
|
|
|
const [loading, setLoading] = useState(false);
|
|
|
const ZRichTextRef = useRef<any>(null);
|
|
|
|
|
|
const getList = useCallback(async () => {
|
|
|
- const data = await getAboutListAPI()
|
|
|
+ const data = await getAboutListAPI();
|
|
|
ZRichTextRef.current?.ritxtShowFu(data[0].rtf);
|
|
|
dispatch({ type: "A2/getList", payload: data });
|
|
|
}, [dispatch]);
|
|
@@ -29,54 +31,54 @@ function A2intro() {
|
|
|
getList();
|
|
|
}, [getList]);
|
|
|
|
|
|
- const handleSave = async() => {
|
|
|
+ const handleSave = async () => {
|
|
|
try {
|
|
|
- setLoading(true)
|
|
|
- const val = ZRichTextRef.current?.fatherBtnOkFu().val
|
|
|
+ setLoading(true);
|
|
|
+ const val = ZRichTextRef.current?.fatherBtnOkFu().val;
|
|
|
await editAboutAPI({
|
|
|
id: tableInfo[Number(activeKey)].id,
|
|
|
- rtf: val
|
|
|
- })
|
|
|
- setIsLook(true)
|
|
|
- MessageFu.success('保存成功')
|
|
|
- const clone = [...tableInfo]
|
|
|
- clone[Number(activeKey)].rtf = val
|
|
|
+ rtf: val,
|
|
|
+ });
|
|
|
+ setIsLook(true);
|
|
|
+ MessageFu.success("保存成功");
|
|
|
+ const clone = [...tableInfo];
|
|
|
+ clone[Number(activeKey)].rtf = val;
|
|
|
dispatch({ type: "A2/getList", payload: clone });
|
|
|
} finally {
|
|
|
- setLoading(false)
|
|
|
+ setLoading(false);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
const cancelSave = () => {
|
|
|
- setIsLook(true)
|
|
|
+ setIsLook(true);
|
|
|
ZRichTextRef.current?.ritxtShowFu(tableInfo[Number(activeKey)].rtf);
|
|
|
- }
|
|
|
+ };
|
|
|
|
|
|
return (
|
|
|
<div className={styles.A2intro}>
|
|
|
<div className="pageTitle">简介管理</div>
|
|
|
|
|
|
- {/* @ts-ignore */}
|
|
|
- <Tabs items={tableInfo} onChange={v => {
|
|
|
- setActiveKey(v)
|
|
|
- setIsLook(true)
|
|
|
- ZRichTextRef.current?.ritxtShowFu(tableInfo[Number(v)].rtf);
|
|
|
- }} />
|
|
|
+ <Tabs
|
|
|
+ // @ts-ignore
|
|
|
+ items={tableInfo}
|
|
|
+ onChange={(v) => {
|
|
|
+ setActiveKey(v);
|
|
|
+ setIsLook(true);
|
|
|
+ ZRichTextRef.current?.ritxtShowFu(tableInfo[Number(v)].rtf);
|
|
|
+ }}
|
|
|
+ />
|
|
|
|
|
|
<div className="A2toolbar">
|
|
|
{isLook ? (
|
|
|
<Button onClick={() => setIsLook(false)}>编辑</Button>
|
|
|
- ) : <>
|
|
|
- <Button
|
|
|
- style={{marginRight: '10px'}}
|
|
|
- onClick={cancelSave}
|
|
|
- >取消</Button>
|
|
|
- <Button
|
|
|
- type="primary"
|
|
|
- loading={loading}
|
|
|
- onClick={handleSave}
|
|
|
- >保存</Button>
|
|
|
- </>}
|
|
|
+ ) : (
|
|
|
+ <>
|
|
|
+ <Button onClick={cancelSave}>取消</Button>
|
|
|
+ <Button type="primary" loading={loading} onClick={handleSave}>
|
|
|
+ 保存
|
|
|
+ </Button>
|
|
|
+ </>
|
|
|
+ )}
|
|
|
</div>
|
|
|
|
|
|
<div className="A2main">
|