|  | @@ -1,11 +1,10 @@
 | 
												
													
														
															|  | -import { Button, Table } from 'antd'
 |  | 
 | 
												
													
														
															|  | 
 |  | +import { Button } from 'antd'
 | 
												
													
														
															|  |  import LeftMenu from './Components/LeftMenu'
 |  |  import LeftMenu from './Components/LeftMenu'
 | 
												
													
														
															|  |  import { SortableContainer, SortableElement, SortableHandle } from 'react-sortable-hoc'
 |  |  import { SortableContainer, SortableElement, SortableHandle } from 'react-sortable-hoc'
 | 
												
													
														
															|  |  import { arrayMoveImmutable } from 'array-move'
 |  |  import { arrayMoveImmutable } from 'array-move'
 | 
												
													
														
															|  |  import type { ColumnsType } from 'antd/lib/table'
 |  |  import type { ColumnsType } from 'antd/lib/table'
 | 
												
													
														
															|  |  import type { SortableContainerProps, SortEnd } from 'react-sortable-hoc'
 |  |  import type { SortableContainerProps, SortEnd } from 'react-sortable-hoc'
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -import { useState } from 'react'
 |  | 
 | 
												
													
														
															|  | 
 |  | +import { useRef, useState } from 'react'
 | 
												
													
														
															|  |  import { useRequest } from 'umi'
 |  |  import { useRequest } from 'umi'
 | 
												
													
														
															|  |  import {
 |  |  import {
 | 
												
													
														
															|  |    addDataSource,
 |  |    addDataSource,
 | 
												
											
												
													
														
															|  | @@ -33,15 +32,17 @@ type iState = {
 | 
												
													
														
															|  |    activeID: Nullable<string>
 |  |    activeID: Nullable<string>
 | 
												
													
														
															|  |    modalType: ModalType
 |  |    modalType: ModalType
 | 
												
													
														
															|  |    visible: boolean
 |  |    visible: boolean
 | 
												
													
														
															|  | 
 |  | +  menuDataItems: API.DataSourceItem[]
 | 
												
													
														
															|  |  }
 |  |  }
 | 
												
													
														
															|  |  const Option = () => {
 |  |  const Option = () => {
 | 
												
													
														
															|  | 
 |  | +  const formRef = useRef<FormInstance>(null)
 | 
												
													
														
															|  |    const [state, setState] = useState<iState>({
 |  |    const [state, setState] = useState<iState>({
 | 
												
													
														
															|  |      menuData: [],
 |  |      menuData: [],
 | 
												
													
														
															|  |      activeID: null,
 |  |      activeID: null,
 | 
												
													
														
															|  |      visible: false,
 |  |      visible: false,
 | 
												
													
														
															|  | -    modalType: ModalType.ADD
 |  | 
 | 
												
													
														
															|  | 
 |  | +    modalType: ModalType.ADD,
 | 
												
													
														
															|  | 
 |  | +    menuDataItems: []
 | 
												
													
														
															|  |    })
 |  |    })
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  |    const { run: tryFetchList } = useRequest(queryDataSource, {
 |  |    const { run: tryFetchList } = useRequest(queryDataSource, {
 | 
												
													
														
															|  |      onSuccess: (result: API.DataSourceMenuItem) => {
 |  |      onSuccess: (result: API.DataSourceMenuItem) => {
 | 
												
													
														
															|  |        setState({ ...state, menuData: result })
 |  |        setState({ ...state, menuData: result })
 | 
												
											
												
													
														
															|  | @@ -65,6 +66,12 @@ const Option = () => {
 | 
												
													
														
															|  |        render: () => <DragHandle />
 |  |        render: () => <DragHandle />
 | 
												
													
														
															|  |      },
 |  |      },
 | 
												
													
														
															|  |      {
 |  |      {
 | 
												
													
														
															|  | 
 |  | +      title: '序号',
 | 
												
													
														
															|  | 
 |  | +      dataIndex: 'num',
 | 
												
													
														
															|  | 
 |  | +      width: 50,
 | 
												
													
														
															|  | 
 |  | +      render: (num, record, index) => `${index + 1}`
 | 
												
													
														
															|  | 
 |  | +    },
 | 
												
													
														
															|  | 
 |  | +    {
 | 
												
													
														
															|  |        title: '选项名称',
 |  |        title: '选项名称',
 | 
												
													
														
															|  |        dataIndex: 'name'
 |  |        dataIndex: 'name'
 | 
												
													
														
															|  |      },
 |  |      },
 | 
												
											
												
													
														
															|  | @@ -84,7 +91,12 @@ const Option = () => {
 | 
												
													
														
															|  |        title: '操作',
 |  |        title: '操作',
 | 
												
													
														
															|  |        dataIndex: 'opreate',
 |  |        dataIndex: 'opreate',
 | 
												
													
														
															|  |        render: (_, record) => (
 |  |        render: (_, record) => (
 | 
												
													
														
															|  | -        <Button type="text" onClick={() => setState({ ...state, modalType: ModalType.UPDATE })}>
 |  | 
 | 
												
													
														
															|  | 
 |  | +        <Button
 | 
												
													
														
															|  | 
 |  | +          type="text"
 | 
												
													
														
															|  | 
 |  | +          onClick={() => {
 | 
												
													
														
															|  | 
 |  | +            formRef.current?.setFieldsValue({ ...record })
 | 
												
													
														
															|  | 
 |  | +            setState({ ...state, modalType: ModalType.UPDATE })
 | 
												
													
														
															|  | 
 |  | +          }}>
 | 
												
													
														
															|  |            编辑
 |  |            编辑
 | 
												
													
														
															|  |          </Button>
 |  |          </Button>
 | 
												
													
														
															|  |        )
 |  |        )
 | 
												
											
												
													
														
															|  | @@ -98,7 +110,7 @@ const Option = () => {
 | 
												
													
														
															|  |        )
 |  |        )
 | 
												
													
														
															|  |        const newMenuData = menuData.map(item => {
 |  |        const newMenuData = menuData.map(item => {
 | 
												
													
														
															|  |          const newItem = { ...item }
 |  |          const newItem = { ...item }
 | 
												
													
														
															|  | -        if (item.ID === activeID) {
 |  | 
 | 
												
													
														
															|  | 
 |  | +        if (item.ID === state.activeID) {
 | 
												
													
														
															|  |            newItem.items = newData
 |  |            newItem.items = newData
 | 
												
													
														
															|  |            return newItem
 |  |            return newItem
 | 
												
													
														
															|  |          }
 |  |          }
 | 
												
											
												
													
														
															|  | @@ -120,7 +132,7 @@ const Option = () => {
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  |    const DraggableBodyRow = ({ className, style, ...restProps }) => {
 |  |    const DraggableBodyRow = ({ className, style, ...restProps }) => {
 | 
												
													
														
															|  |      const index = state.menuData
 |  |      const index = state.menuData
 | 
												
													
														
															|  | -      .find(item => item.ID === activeID)
 |  | 
 | 
												
													
														
															|  | 
 |  | +      .find(item => item.ID === state.activeID)
 | 
												
													
														
															|  |        ?.items.findIndex(x => x.index === restProps['data-row-key'])
 |  |        ?.items.findIndex(x => x.index === restProps['data-row-key'])
 | 
												
													
														
															|  |      return <SortableItem index={index} {...restProps} />
 |  |      return <SortableItem index={index} {...restProps} />
 | 
												
													
														
															|  |    }
 |  |    }
 | 
												
											
												
													
														
															|  | @@ -128,7 +140,10 @@ const Option = () => {
 | 
												
													
														
															|  |    return (
 |  |    return (
 | 
												
													
														
															|  |      <div className="flex flex-nowrap h-full">
 |  |      <div className="flex flex-nowrap h-full">
 | 
												
													
														
															|  |        <LeftMenu
 |  |        <LeftMenu
 | 
												
													
														
															|  | -        onSelect={(key: string) => setState({ ...state, activeID: key })}
 |  | 
 | 
												
													
														
															|  | 
 |  | +        onSelect={(key: string, node) =>
 | 
												
													
														
															|  | 
 |  | +          setState({ ...state, activeID: key, menuDataItems: node.node.items })
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +        showDelIcon={!state.menuDataItems.length}
 | 
												
													
														
															|  |          options={state.menuData}
 |  |          options={state.menuData}
 | 
												
													
														
															|  |          initFn={() => tryFetchList()}
 |  |          initFn={() => tryFetchList()}
 | 
												
													
														
															|  |        />
 |  |        />
 | 
												
											
												
													
														
															|  | @@ -143,6 +158,7 @@ const Option = () => {
 | 
												
													
														
															|  |                <ModalForm
 |  |                <ModalForm
 | 
												
													
														
															|  |                  key="form"
 |  |                  key="form"
 | 
												
													
														
															|  |                  visible={state.visible}
 |  |                  visible={state.visible}
 | 
												
													
														
															|  | 
 |  | +                formRef={formRef}
 | 
												
													
														
															|  |                  onVisibleChange={visible => setState({ ...state, visible })}
 |  |                  onVisibleChange={visible => setState({ ...state, visible })}
 | 
												
													
														
															|  |                  onFinish={async values => {}}>
 |  |                  onFinish={async values => {}}>
 | 
												
													
														
															|  |                  <ProFormText
 |  |                  <ProFormText
 |