| | |
| | | import { PlusOutlined, ExportOutlined } from '@ant-design/icons'; |
| | | import Http from '@/utils/http'; |
| | | import Edit from './components/edit' |
| | | import Scope from './components/scope' |
| | | import { TextFilter, SelectFilter, DatetimeRangeFilter, LinkFilter } from '@/components/TableSearch' |
| | | import { statusMap } from '@/utils/enum-util' |
| | | |
| | |
| | | } |
| | | }; |
| | | |
| | | const handleScope = async (val) => { |
| | | const hide = message.loading('正在分配'); |
| | | try { |
| | | const resp = await Http.doPost('api/role/scope', val); |
| | | if (resp.code === 200) { |
| | | message.success('分配成功'); |
| | | return true; |
| | | } else { |
| | | message.error(resp.msg); |
| | | return false; |
| | | } |
| | | } catch (error) { |
| | | message.error('分配失败请重试!'); |
| | | return false; |
| | | } finally { |
| | | hide(); |
| | | } |
| | | }; |
| | | |
| | | const Main = () => { |
| | | const formTableRef = useRef(); |
| | |
| | | const [modalVisible, setModalVisible] = useState(false); |
| | | const [currentRow, setCurrentRow] = useState(); |
| | | const [searchParam, setSearchParam] = useState({}); |
| | | |
| | | const [scopeModalVisible, setScopeModalVisible] = useState(false); |
| | | |
| | | useEffect(() => { |
| | | |
| | |
| | | width: 140, |
| | | valueType: 'option', |
| | | render: (_, record) => [ |
| | | <Button |
| | | type="link" |
| | | key="scope" |
| | | onClick={() => { |
| | | setScopeModalVisible(true); |
| | | setCurrentRow(record); |
| | | }} |
| | | > |
| | | 分配权限 |
| | | </Button>, |
| | | <Button |
| | | type="link" |
| | | key="edit" |
| | |
| | | } |
| | | } |
| | | /> |
| | | |
| | | <Scope |
| | | open={scopeModalVisible} |
| | | values={currentRow || {}} |
| | | onCancel={ |
| | | () => { |
| | | setScopeModalVisible(false); |
| | | setCurrentRow(undefined); |
| | | } |
| | | } |
| | | onSubmit={async (values) => { |
| | | let ok = false; |
| | | if (values.id) { |
| | | ok = await handleScope({ ...values }) |
| | | } |
| | | if (ok) { |
| | | setScopeModalVisible(false); |
| | | setCurrentRow(undefined); |
| | | if (actionRef.current) { |
| | | actionRef.current.reload(); |
| | | } |
| | | } |
| | | }} |
| | | /> |
| | | </PageContainer> |
| | | ); |
| | | }; |