资产授权增加筛选功能
This commit is contained in:
		| @ -2,6 +2,7 @@ import React, {useEffect, useState} from 'react'; | |||||||
| import {Form, Modal, Select} from "antd"; | import {Form, Modal, Select} from "antd"; | ||||||
| import authorisedApi from "../../api/authorised"; | import authorisedApi from "../../api/authorised"; | ||||||
| import strategyApi from "../../api/strategy"; | import strategyApi from "../../api/strategy"; | ||||||
|  | import commandFilterApi from "../../api/command-filter"; | ||||||
| import userApi from "../../api/user"; | import userApi from "../../api/user"; | ||||||
|  |  | ||||||
| const formItemLayout = { | const formItemLayout = { | ||||||
| @ -14,6 +15,7 @@ const AssetUserBind = ({id, visible, handleOk, handleCancel, confirmLoading}) => | |||||||
|  |  | ||||||
|     let [selectedUserIds, setSelectedUserIds] = useState([]); |     let [selectedUserIds, setSelectedUserIds] = useState([]); | ||||||
|     let [users, setUsers] = useState([]); |     let [users, setUsers] = useState([]); | ||||||
|  |     let [commandFilters, setCommandFilters] = useState([]); | ||||||
|     let [strategies, setStrategies] = useState([]); |     let [strategies, setStrategies] = useState([]); | ||||||
|  |  | ||||||
|     useEffect(() => { |     useEffect(() => { | ||||||
| @ -29,6 +31,9 @@ const AssetUserBind = ({id, visible, handleOk, handleCancel, confirmLoading}) => | |||||||
|  |  | ||||||
|             let strategies = await strategyApi.getAll(); |             let strategies = await strategyApi.getAll(); | ||||||
|             setStrategies(strategies); |             setStrategies(strategies); | ||||||
|  |  | ||||||
|  |             let commandFilters = await commandFilterApi.getAll(); | ||||||
|  |             setCommandFilters(commandFilters); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (visible) { |         if (visible) { | ||||||
| @ -38,6 +43,29 @@ const AssetUserBind = ({id, visible, handleOk, handleCancel, confirmLoading}) => | |||||||
|         } |         } | ||||||
|     }, [visible]) |     }, [visible]) | ||||||
|  |  | ||||||
|  |     let strategyOptions = strategies.map(item => { | ||||||
|  |         return { | ||||||
|  |             value: item.id, | ||||||
|  |             label: item.name | ||||||
|  |         } | ||||||
|  |     }); | ||||||
|  |  | ||||||
|  |     let commandFilterOptions = commandFilters.map(item => { | ||||||
|  |         return { | ||||||
|  |             value: item.id, | ||||||
|  |             label: item.name | ||||||
|  |         } | ||||||
|  |     }); | ||||||
|  |  | ||||||
|  |  | ||||||
|  |     let userOptions = users.map(item => { | ||||||
|  |         return { | ||||||
|  |             value: item.id, | ||||||
|  |             label: item.name, | ||||||
|  |             disabled: selectedUserIds.includes(item.id) | ||||||
|  |         } | ||||||
|  |     }); | ||||||
|  |  | ||||||
|     return ( |     return ( | ||||||
|         <Modal |         <Modal | ||||||
|             title={'用户授权'} |             title={'用户授权'} | ||||||
| @ -71,11 +99,28 @@ const AssetUserBind = ({id, visible, handleOk, handleCancel, confirmLoading}) => | |||||||
|                         allowClear |                         allowClear | ||||||
|                         style={{width: '100%'}} |                         style={{width: '100%'}} | ||||||
|                         placeholder="请选择用户" |                         placeholder="请选择用户" | ||||||
|  |                         showSearch | ||||||
|  |                         filterOption={(input, option) => | ||||||
|  |                             (option?.label ?? '').toLowerCase().includes(input.toLowerCase()) | ||||||
|  |                         } | ||||||
|  |                         options={userOptions} | ||||||
|                     > |                     > | ||||||
|                         {users.map(item => { |  | ||||||
|                             return <Select.Option key={item.id} |                     </Select> | ||||||
|                                                   disabled={selectedUserIds.includes(item.id)}>{item.nickname}</Select.Option> |                 </Form.Item> | ||||||
|                         })} |  | ||||||
|  |                 <Form.Item label="命令过滤器" name='commandFilterId' extra={'可控制授权用户允许或不允许执行某些指令'}> | ||||||
|  |                     <Select | ||||||
|  |                         allowClear | ||||||
|  |                         style={{width: '100%'}} | ||||||
|  |                         placeholder="此字段不是必填的" | ||||||
|  |                         showSearch | ||||||
|  |                         filterOption={(input, option) => | ||||||
|  |                             (option?.label ?? '').toLowerCase().includes(input.toLowerCase()) | ||||||
|  |                         } | ||||||
|  |                         options={commandFilterOptions} | ||||||
|  |                     > | ||||||
|  |  | ||||||
|                     </Select> |                     </Select> | ||||||
|                 </Form.Item> |                 </Form.Item> | ||||||
|  |  | ||||||
| @ -84,10 +129,13 @@ const AssetUserBind = ({id, visible, handleOk, handleCancel, confirmLoading}) => | |||||||
|                         allowClear |                         allowClear | ||||||
|                         style={{width: '100%'}} |                         style={{width: '100%'}} | ||||||
|                         placeholder="此字段不是必填的" |                         placeholder="此字段不是必填的" | ||||||
|  |                         showSearch | ||||||
|  |                         filterOption={(input, option) => | ||||||
|  |                             (option?.label ?? '').toLowerCase().includes(input.toLowerCase()) | ||||||
|  |                         } | ||||||
|  |                         options={strategyOptions} | ||||||
|                     > |                     > | ||||||
|                         {strategies.map(item => { |  | ||||||
|                             return <Select.Option key={item.id}>{item.name}</Select.Option> |  | ||||||
|                         })} |  | ||||||
|                     </Select> |                     </Select> | ||||||
|                 </Form.Item> |                 </Form.Item> | ||||||
|  |  | ||||||
|  | |||||||
| @ -2,6 +2,7 @@ import React, {useEffect, useState} from 'react'; | |||||||
| import {Form, Modal, Select} from "antd"; | import {Form, Modal, Select} from "antd"; | ||||||
| import assetApi from "../../../api/asset"; | import assetApi from "../../../api/asset"; | ||||||
| import strategyApi from "../../../api/strategy"; | import strategyApi from "../../../api/strategy"; | ||||||
|  | import commandFilterApi from "../../../api/command-filter"; | ||||||
| import authorisedApi from "../../../api/authorised"; | import authorisedApi from "../../../api/authorised"; | ||||||
|  |  | ||||||
| const formItemLayout = { | const formItemLayout = { | ||||||
| @ -14,6 +15,7 @@ const UserAuthorised = ({type, id, visible, handleOk, handleCancel, confirmLoadi | |||||||
|  |  | ||||||
|     let [selectedAssetIds, setSelectedAssetIds] = useState([]); |     let [selectedAssetIds, setSelectedAssetIds] = useState([]); | ||||||
|     let [assets, setAssets] = useState([]); |     let [assets, setAssets] = useState([]); | ||||||
|  |     let [commandFilters, setCommandFilters] = useState([]); | ||||||
|     let [strategies, setStrategies] = useState([]); |     let [strategies, setStrategies] = useState([]); | ||||||
|  |  | ||||||
|     useEffect(() => { |     useEffect(() => { | ||||||
| @ -35,6 +37,9 @@ const UserAuthorised = ({type, id, visible, handleOk, handleCancel, confirmLoadi | |||||||
|  |  | ||||||
|             let strategies = await strategyApi.GetAll(); |             let strategies = await strategyApi.GetAll(); | ||||||
|             setStrategies(strategies); |             setStrategies(strategies); | ||||||
|  |  | ||||||
|  |             let commandFilters = await commandFilterApi.GetAll(); | ||||||
|  |             setCommandFilters(commandFilters); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (visible) { |         if (visible) { | ||||||
| @ -44,6 +49,29 @@ const UserAuthorised = ({type, id, visible, handleOk, handleCancel, confirmLoadi | |||||||
|         } |         } | ||||||
|     }, [visible]) |     }, [visible]) | ||||||
|  |  | ||||||
|  |     let strategyOptions = strategies.map(item=>{ | ||||||
|  |         return { | ||||||
|  |             value: item.id, | ||||||
|  |             label: item.name | ||||||
|  |         } | ||||||
|  |     }); | ||||||
|  |  | ||||||
|  |     let commandFilterOptions = commandFilters.map(item=>{ | ||||||
|  |         return { | ||||||
|  |             value: item.id, | ||||||
|  |             label: item.name | ||||||
|  |         } | ||||||
|  |     }); | ||||||
|  |  | ||||||
|  |  | ||||||
|  |     let assetOptions = assets.map(item=>{ | ||||||
|  |         return { | ||||||
|  |             value: item.id, | ||||||
|  |             label: item.name, | ||||||
|  |             disabled: selectedAssetIds.includes(item.id) | ||||||
|  |         } | ||||||
|  |     }); | ||||||
|  |  | ||||||
|     return ( |     return ( | ||||||
|         <Modal |         <Modal | ||||||
|             title={'资产授权'} |             title={'资产授权'} | ||||||
| @ -77,11 +105,27 @@ const UserAuthorised = ({type, id, visible, handleOk, handleCancel, confirmLoadi | |||||||
|                         allowClear |                         allowClear | ||||||
|                         style={{width: '100%'}} |                         style={{width: '100%'}} | ||||||
|                         placeholder="请选择资产" |                         placeholder="请选择资产" | ||||||
|  |                         showSearch | ||||||
|  |                         filterOption={(input, option) => | ||||||
|  |                             (option?.label ?? '').toLowerCase().includes(input.toLowerCase()) | ||||||
|  |                         } | ||||||
|  |                         options={assetOptions} | ||||||
|  |                     > | ||||||
|  |  | ||||||
|  |                     </Select> | ||||||
|  |                 </Form.Item> | ||||||
|  |  | ||||||
|  |                 <Form.Item label="命令过滤器" name='commandFilterId' extra={'可控制授权用户允许或不允许执行某些指令'}> | ||||||
|  |                     <Select | ||||||
|  |                         allowClear | ||||||
|  |                         style={{width: '100%'}} | ||||||
|  |                         placeholder="此字段不是必填的" | ||||||
|  |                         showSearch | ||||||
|  |                         filterOption={(input, option) => | ||||||
|  |                             (option?.label ?? '').toLowerCase().includes(input.toLowerCase()) | ||||||
|  |                         } | ||||||
|  |                         options={commandFilterOptions} | ||||||
|                     > |                     > | ||||||
|                         {assets.map(item => { |  | ||||||
|                             return <Select.Option key={item.id} |  | ||||||
|                                                   disabled={selectedAssetIds.includes(item.id)}>{item.name}</Select.Option> |  | ||||||
|                         })} |  | ||||||
|                     </Select> |                     </Select> | ||||||
|                 </Form.Item> |                 </Form.Item> | ||||||
|  |  | ||||||
| @ -90,10 +134,13 @@ const UserAuthorised = ({type, id, visible, handleOk, handleCancel, confirmLoadi | |||||||
|                         allowClear |                         allowClear | ||||||
|                         style={{width: '100%'}} |                         style={{width: '100%'}} | ||||||
|                         placeholder="此字段不是必填的" |                         placeholder="此字段不是必填的" | ||||||
|  |                         showSearch | ||||||
|  |                         filterOption={(input, option) => | ||||||
|  |                             (option?.label ?? '').toLowerCase().includes(input.toLowerCase()) | ||||||
|  |                         } | ||||||
|  |                         options={strategyOptions} | ||||||
|                     > |                     > | ||||||
|                         {strategies.map(item => { |  | ||||||
|                             return <Select.Option key={item.id}>{item.name}</Select.Option> |  | ||||||
|                         })} |  | ||||||
|                     </Select> |                     </Select> | ||||||
|                 </Form.Item> |                 </Form.Item> | ||||||
|  |  | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user