oak-general-business/es/components/wechatMenu/menu/web.pc.js

60 lines
2.7 KiB
JavaScript

import React, { useState } from 'react';
import Style from './web.module.less';
import { Modal } from 'antd';
import Preview from '../preview';
import ActionPhone from '../actionPhone';
import MenuInfo from '../menuInfo';
export default function Render(props) {
const { data, methods } = props;
const { id, oakFullpath, config, menuType, applicationId, actions, iState, tabKey } = data;
const { updateItem, execute, create, } = methods;
const [open, setOpen] = useState(false);
const [isPreview, setIsPreview] = useState(false);
const [selectedBtn, setSelectedBtn] = useState(0);
const [selectedSubBtn, setSelectedSubBtn] = useState(0);
const [currentIndex, setCurrentIndex] = useState(1);
const [errorIndex, setErrorIndex] = useState([]);
const changeConfig = (config) => {
updateItem({
menuConfig: config,
}, id);
};
const getSelectedBtn = (selectedBtn) => {
setSelectedBtn(selectedBtn);
};
const getSelectedSubBtn = (selectedSubBtn) => {
setSelectedSubBtn(selectedSubBtn);
};
const getCurrentIndex = (currentIndex) => {
setCurrentIndex(currentIndex);
};
const getErrorIndex = (errorIndex) => {
setErrorIndex(errorIndex);
};
const createMenu = () => {
create();
};
const changeIsPreview = (isPreview) => {
setIsPreview(isPreview);
};
const getOpen = (open) => {
setOpen(open);
};
if (oakFullpath) {
return (<div className={Style.container}>
<div className={Style.content}>
<div className={Style.leftBar}>
<ActionPhone oakAutoUnmount={true} config={config} changeConfig={changeConfig} menuType={menuType} getSelectedBtn={getSelectedBtn} getSelectedSubBtn={getSelectedSubBtn} getCurrentIndex={getCurrentIndex} errorIndex={errorIndex} isPreview={isPreview} open={open} tabKey={tabKey}/>
</div>
<div className={Style.rightBar}>
<MenuInfo oakAutoUnmount={true} config={config} changeConfig={changeConfig} selectedBtn={selectedBtn} selectedSubBtn={selectedSubBtn} currentIndex={currentIndex} getErrorIndex={getErrorIndex} createMenu={createMenu} changeIsPreview={changeIsPreview} getOpen={getOpen} menuType={menuType} applicationId={applicationId} actions={actions} iState={iState}/>
</div>
<Modal title='菜单预览' open={isPreview} onCancel={() => setIsPreview(false)} footer={null} width={424}>
<Preview button={config?.button} applicationId={applicationId}/>
</Modal>
</div>
</div>);
}
return null;
}