ToolButtonNavMore.tsx 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { SettingOutlined } from "@ant-design/icons";
  2. import { Button, Dropdown, type MenuProps } from "antd"
  3. interface IWidget {
  4. onSliceChange?: Function;
  5. }
  6. const CaseFormulaWidget = ({ onSliceChange }: IWidget) => {
  7. const sliceOption = new Array(8).fill(1).map((_item, index) => {
  8. return { key: index + 2, label: index + 2 };
  9. });
  10. const items: MenuProps["items"] = [
  11. {
  12. label: "分组",
  13. key: "slice",
  14. children: [
  15. {
  16. label: "不分组",
  17. key: 1,
  18. },
  19. ...sliceOption,
  20. ],
  21. },
  22. ];
  23. return (
  24. <Dropdown
  25. menu={{
  26. items: items,
  27. onClick: (e) => {
  28. console.log("click ", e.key);
  29. if (typeof onSliceChange !== "undefined") {
  30. onSliceChange(e.key);
  31. }
  32. },
  33. }}
  34. placement="bottomRight"
  35. >
  36. <Button
  37. type="text"
  38. size="small"
  39. icon={<SettingOutlined />}
  40. onClick={(e) => e.preventDefault()}
  41. />
  42. </Dropdown>
  43. );
  44. };
  45. export default CaseFormulaWidget;