wjx преди 1 година
родител
ревизия
f62dc1ef1e

+ 5 - 5
src/pages/gameDataStatistics/player/banIpManage/addBanIp.tsx

@@ -1,10 +1,11 @@
 import { useAjax } from "@/Hook/useAjax"
 import { addBanIpApi } from "@/services/gameData/player"
 import { Form, Input, message, Modal, Select } from "antd"
-import React, { useState } from "react"
+import React from "react"
 
 interface Props {
     gameList: any[]
+    initialValues?: any
     visible?: boolean,
     onChange?: () => void,
     onClose?: () => void
@@ -17,9 +18,8 @@ interface Props {
 const AddBanIp: React.FC<Props> = (props) => {
 
     /** ----------变量开始------- */
-    const { visible, onChange, onClose, gameList } = props
+    const { visible, onChange, onClose, gameList, initialValues = {} } = props
     const [form] = Form.useForm()
-    const [initialValues, _setinitialValues] = useState<any>({})
     /** ----------变量结束------- */
 
     const addBanIp = useAjax((params: { ipList: string[] }) => addBanIpApi(params))
@@ -43,7 +43,7 @@ const AddBanIp: React.FC<Props> = (props) => {
         })
     }
 
-    return <Modal title="新增封禁IP" visible={visible} onOk={handleOk} onCancel={() => { onClose && onClose() }} confirmLoading={addBanIp.loading}>
+    return <Modal title={Object.keys(initialValues).length > 0 ? "复制IP封禁" : `新增封禁IP`} visible={visible} onOk={handleOk} onCancel={() => { onClose && onClose() }} confirmLoading={addBanIp.loading}>
         <Form
             name="basicBanIp"
             form={form}
@@ -66,7 +66,7 @@ const AddBanIp: React.FC<Props> = (props) => {
                 </Select>
             </Form.Item>
             <Form.Item label="IP" name="ips" rules={[{ type: 'string', required: true, message: '请输入IP!' }]}>
-                <Input.TextArea rows={4} placeholder="请输入需要封禁的IP地址,多个IP请用逗号“,”隔开" />
+                <Input.TextArea rows={4} placeholder="请输入需要封禁的IP地址,多个IP请用逗号“,”隔开" disabled={Object.keys(initialValues).length > 0}/>
             </Form.Item>
         </Form>
     </Modal>

+ 65 - 6
src/pages/gameDataStatistics/player/banIpManage/index.tsx

@@ -9,7 +9,7 @@ import style from '../../components/TableData/index.less'
 import Tables from "@/components/Tables"
 import columnsPos from "./tableConfig"
 import AddBanIp from "./addBanIp"
-import { PlusOutlined } from "@ant-design/icons"
+import { CopyOutlined, PlusOutlined } from "@ant-design/icons"
 
 /**
  * 封禁IP管理
@@ -19,10 +19,11 @@ const BanIpManage: React.FC = () => {
 
     /*************************/
     const [form] = Form.useForm()
-    const [initialValues, _setInitialValues] = useState<any>({})
+    const [initialValues, setInitialValues] = useState<any>({})
     const [queryFrom, setQueryForm] = useState<IpManageListProps>({ pageNum: 1, pageSize: 20 })
     const [addShow, setAddShow] = useState<boolean>(false)
-    
+    const [selectedRows, setSelectedRows] = useState<any[]>([])
+
     const getGameChoiceList = useAjax(() => getGameChoiceListApi())
     const getIpManageList = useAjax((params: IpManageListProps) => getIpManageListApi(params))
     const updateBanIp = useAjax((params: { ip: string, status: number }) => updateBanIpApi(params))
@@ -72,7 +73,7 @@ const BanIpManage: React.FC = () => {
             封禁IP管理
         </div>
         <Space style={{ width: '100%' }} direction="vertical" size={10}>
-            <Form layout="inline" className='queryForm' initialValues={initialValues} name="basicGameServer" form={form} onFinish={onFinish}>
+            <Form layout="inline" className='queryForm' name="basicGameServer" form={form} onFinish={onFinish}>
                 <Row gutter={[0, 6]}>
                     <Col><Form.Item name='gameId'>
                         <Select
@@ -116,7 +117,19 @@ const BanIpManage: React.FC = () => {
                         <Space>
                             <Button type="primary" htmlType="submit">搜索</Button>
                             <Button onClick={() => form.resetFields()}>重置</Button>
-                            <Button type="primary" icon={<PlusOutlined />} onClick={() => setAddShow(true)}>新增封禁IP</Button>
+                            <Button type="primary" icon={<PlusOutlined />} onClick={() => { setInitialValues({}); setAddShow(true) }}>新增封禁IP</Button>
+                            <Button
+                                type="dashed"
+                                icon={<CopyOutlined />}
+                                disabled={selectedRows?.length === 0}
+                                onClick={() => {
+                                    setInitialValues({ ips: selectedRows?.map(item => item.ip)?.toString() })
+                                    setAddShow(true)
+                                }}
+                            >
+                                复制IP封禁
+                            </Button>
+                            <Button type="link" disabled={selectedRows?.length === 0} onClick={() => { setSelectedRows([]) }}>清空选择</Button>
                         </Space>
                     </Col>
                 </Row>
@@ -146,6 +159,40 @@ const BanIpManage: React.FC = () => {
                         newQueryForm.pageSize = pageSize
                         setQueryForm({ ...newQueryForm })
                     }}
+                    rowSelection={{
+                        selectedRowKeys: selectedRows.map(item => item.id + ''),
+                        onSelect: (record: { id: number }, selected: boolean) => {
+                            if (selected) {
+                                selectedRows.push({ ...record })
+                                setSelectedRows([...selectedRows])
+                            } else {
+                                let newSelectAccData = selectedRows.filter((item: { id: number }) => item.id !== record.id)
+                                setSelectedRows([...newSelectAccData])
+                            }
+                        },
+                        onSelectAll: (selected: boolean, selectedRowss: { id: number }[], changeRows: { id: number }[]) => {
+                            if (selected) {
+                                let newSelectAccData = [...selectedRows]
+                                changeRows.forEach((item: { id: number }) => {
+                                    let index = newSelectAccData.findIndex((ite: { id: number }) => ite.id === item.id)
+                                    if (index === -1) {
+                                        newSelectAccData.push({ ...item })
+                                    }
+                                })
+                                setSelectedRows([...newSelectAccData])
+                            } else {
+                                let newSelectAccData = selectedRows.filter((item: { id: number }) => {
+                                    let index = changeRows.findIndex((ite: { id: number }) => ite.id === item.id)
+                                    if (index !== -1) {
+                                        return false
+                                    } else {
+                                        return true
+                                    }
+                                })
+                                setSelectedRows([...newSelectAccData])
+                            }
+                        }
+                    }}
                     size="small"
                     total={getIpManageList?.data?.total}
                     loading={getIpManageList?.loading}
@@ -155,7 +202,19 @@ const BanIpManage: React.FC = () => {
         </Space>
 
         {/* 新增封禁IP */}
-        {addShow && <AddBanIp gameList={getGameChoiceList?.data} visible={addShow} onClose={() => setAddShow(false)} onChange={() => { setAddShow(false); getIpManageList?.refresh() }} />}
+        {addShow && <AddBanIp
+            initialValues={initialValues}
+            gameList={getGameChoiceList?.data}
+            visible={addShow}
+            onClose={() => {
+                setAddShow(false)
+                setInitialValues({})
+            }}
+            onChange={() => {
+                setAddShow(false);
+                setInitialValues({})
+                getIpManageList?.refresh()
+            }} />}
     </Card>
 }
 

+ 1 - 2
src/pages/gameDataStatistics/roleOperate/vip/tableConfig.tsx

@@ -13,8 +13,7 @@ function columnsPos(editPack: (data: any) => void, del: (id: number) => void) {
             dataIndex: 'vipLevel',
             key: 'vipLevel',
             align: 'center',
-            width: 90,
-            render: (a: string, b: any) => (<WidthEllipsis value={a} />)
+            width: 90
         },
         {
             title: '超父游戏名称',