|
@@ -1,4 +1,4 @@
|
|
-import { Button, Col, Drawer, Row } from "antd";
|
|
|
|
|
|
+import { Button, Col, Drawer, Input, message, Row, Space } from "antd";
|
|
import React, { useState, useImperativeHandle, forwardRef, useRef, useEffect, useMemo } from "react";
|
|
import React, { useState, useImperativeHandle, forwardRef, useRef, useEffect, useMemo } from "react";
|
|
import PageList from "./pageList";
|
|
import PageList from "./pageList";
|
|
import Content from "./content";
|
|
import Content from "./content";
|
|
@@ -7,9 +7,10 @@ import { useToken } from "@ant-design/pro-components";
|
|
import { useSize } from "ahooks";
|
|
import { useSize } from "ahooks";
|
|
import { useModel } from "@umijs/max";
|
|
import { useModel } from "@umijs/max";
|
|
import { useAjax } from "@/Hook/useAjax";
|
|
import { useAjax } from "@/Hook/useAjax";
|
|
-import { appComponentConfigGetAppPageList } from "@/services/miniApp/compConfig";
|
|
|
|
|
|
+import { appComponentConfigAddOrUpdate, appComponentConfigGetAppPageList } from "@/services/miniApp/compConfig";
|
|
// 定义组件的 Props 类型
|
|
// 定义组件的 Props 类型
|
|
interface Props {
|
|
interface Props {
|
|
|
|
+ listApi: any
|
|
}
|
|
}
|
|
|
|
|
|
// 使用 forwardRef 以支持传递 ref
|
|
// 使用 forwardRef 以支持传递 ref
|
|
@@ -22,8 +23,10 @@ const ModalForm = forwardRef((props: Props, ref) => {
|
|
const PageListRef = useRef<any>(null);
|
|
const PageListRef = useRef<any>(null);
|
|
const ContentRef = useRef<any>(null);
|
|
const ContentRef = useRef<any>(null);
|
|
const SetDataRef = useRef<any>(null);
|
|
const SetDataRef = useRef<any>(null);
|
|
|
|
+ const [templateName, setTemplateName] = useState("")
|
|
const AppComponentConfigGetAppPageList = useAjax((params) => appComponentConfigGetAppPageList(params))
|
|
const AppComponentConfigGetAppPageList = useAjax((params) => appComponentConfigGetAppPageList(params))
|
|
-
|
|
|
|
|
|
+ const AppComponentConfigAddOrUpdate = useAjax((params) => appComponentConfigAddOrUpdate(params))//添加
|
|
|
|
+ console.log("props", props)
|
|
// 接口公共参数
|
|
// 接口公共参数
|
|
let publicData = useMemo(() => {
|
|
let publicData = useMemo(() => {
|
|
return {
|
|
return {
|
|
@@ -41,17 +44,40 @@ const ModalForm = forwardRef((props: Props, ref) => {
|
|
|
|
|
|
// close 方法,用于关闭 Drawer
|
|
// close 方法,用于关闭 Drawer
|
|
const close = () => {
|
|
const close = () => {
|
|
|
|
+ dispatch({
|
|
|
|
+ type: 'setAll', params: {
|
|
|
|
+ tabs: 0,
|
|
|
|
+ isWorkDirection: false,
|
|
|
|
+ compAc: "",
|
|
|
|
+ index: 0,
|
|
|
|
+ activePage: "",
|
|
|
|
+ pageConfigList: []
|
|
|
|
+ }
|
|
|
|
+ })
|
|
setOpen(false); // 将 open 设置为 false,关闭 Drawer
|
|
setOpen(false); // 将 open 设置为 false,关闭 Drawer
|
|
};
|
|
};
|
|
|
|
|
|
const openDrawer = () => {
|
|
const openDrawer = () => {
|
|
setOpen(true); // 将 open 设置为 true,打开 Drawer
|
|
setOpen(true); // 将 open 设置为 true,打开 Drawer
|
|
};
|
|
};
|
|
|
|
+ // 保存
|
|
|
|
+ const save = () => {
|
|
|
|
+ if (!templateName) {
|
|
|
|
+ return message.error("请填写模板名称!")
|
|
|
|
+ }
|
|
|
|
+ AppComponentConfigAddOrUpdate.run({ templateName, pageConfigList: state.pageConfigList, ...publicData }).then(res => {
|
|
|
|
+ if (res.code === 200) {
|
|
|
|
+ props?.listApi?.refresh()
|
|
|
|
+ close()
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
|
|
|
|
+ }
|
|
// 使用 useImperativeHandle 暴露方法给父组件
|
|
// 使用 useImperativeHandle 暴露方法给父组件
|
|
useImperativeHandle(ref, () => ({
|
|
useImperativeHandle(ref, () => ({
|
|
close, // 暴露 close 方法
|
|
close, // 暴露 close 方法
|
|
openDrawer, // 也可以暴露打开的方法
|
|
openDrawer, // 也可以暴露打开的方法
|
|
|
|
+ save
|
|
}));
|
|
}));
|
|
return (
|
|
return (
|
|
<Drawer
|
|
<Drawer
|
|
@@ -60,7 +86,13 @@ const ModalForm = forwardRef((props: Props, ref) => {
|
|
open={open}
|
|
open={open}
|
|
onClose={close}
|
|
onClose={close}
|
|
width={'85vw'}
|
|
width={'85vw'}
|
|
- extra={<Button type='primary'>保存配置</Button>}
|
|
|
|
|
|
+ extra={<Space>
|
|
|
|
+ <Input placeholder="请输入模板名称" value={templateName} allowClear onChange={(e) => {
|
|
|
|
+ let value = e.target.value
|
|
|
|
+ setTemplateName(value)
|
|
|
|
+ }} />
|
|
|
|
+ <Button type='primary' onClick={save}>保存配置</Button>
|
|
|
|
+ </Space>}
|
|
maskClosable={false}
|
|
maskClosable={false}
|
|
>
|
|
>
|
|
<Row wrap style={{ height: `calc(100vh - ${(headerSize?.height || 0) + 50}px)` }}>
|
|
<Row wrap style={{ height: `calc(100vh - ${(headerSize?.height || 0) + 50}px)` }}>
|