wjx il y a 1 an
Parent
commit
2f82978f11

+ 2 - 2
config/proxy.ts

@@ -11,13 +11,13 @@
   dev: {
     '/api/': {
       // target: 'http://test.api.zanxiangwl.com',
-      target: 'http://game.84game.cn',
+      target: 'https://game.84game.cn',
       changeOrigin: true,
       pathRewrite: { '/api': '' },
     },
     '/erpApi/': {
       // target: 'http://test.api.zanxiangwl.com',
-      target: 'http://api.zanxiangwl.com',
+      target: 'https://api.zanxiangwl.com',
       changeOrigin: true,
       pathRewrite: { '/erpApi': '' },
     },

+ 61 - 11
src/pages/gameDataStatistics/player/banGamePlayerManage/index.tsx

@@ -1,8 +1,12 @@
 import { useAjax } from "@/Hook/useAjax"
 import { gamePlayerBanListProps, getBanUserListApi, updateBanUserApi } from "@/services/gameData/player"
-import { Button, Card, Col, Form, Input, Row, Space, message } from "antd"
+import { Button, Card, Col, DatePicker, Form, Input, Row, Space, message } from "antd"
 import React, { useEffect, useState } from "react"
 import moment from "moment"
+import { getPresets } from "@/components/QueryForm/const"
+import style from '../../components/TableData/index.less'
+import Tables from "@/components/Tables"
+import columnsPos from "./tableConfig"
 
 /**
  * 封禁玩家管理
@@ -12,9 +16,8 @@ const BanGamePlayerManage: React.FC = () => {
 
     /*********************************/
     const [form] = Form.useForm()
-    const [initialValues, setInitialValues] = useState<any>({})
+    const [initialValues, _setInitialValues] = useState<any>({})
     const [queryFrom, setQueryForm] = useState<gamePlayerBanListProps>({ pageNum: 1, pageSize: 20 })
-    const [addShow, setAddShow] = useState<boolean>(false)
     const getBanUserList = useAjax((params: gamePlayerBanListProps) => getBanUserListApi(params))
     const updateBanUser = useAjax((params: { userId: string, status: number }) => updateBanUserApi(params))
     /*********************************/
@@ -24,18 +27,18 @@ const BanGamePlayerManage: React.FC = () => {
     }, [queryFrom])
 
     const onFinish = (data: any) => {
-        const { banTime, registerTime, ...value } = data
+        const { banDate, regDate, ...value } = data
         let params = { ...queryFrom, ...value }
-        if (banTime) {
-            params.beginDate = moment(banTime[0]).format('YYYY-MM-DD')
-            params.endDate = moment(banTime[1]).format('YYYY-MM-DD')
+        if (banDate) {
+            params.beginDate = moment(banDate[0]).format('YYYY-MM-DD')
+            params.endDate = moment(banDate[1]).format('YYYY-MM-DD')
         } else {
             delete params?.beginDate
             delete params?.endDate
         }
-        if (registerTime) {
-            params.regBeginTime = moment(registerTime[0]).format('YYYY-MM-DD')
-            params.regEndTime = moment(registerTime[1]).format('YYYY-MM-DD')
+        if (regDate) {
+            params.regBeginTime = moment(regDate[0]).format('YYYY-MM-DD')
+            params.regEndTime = moment(regDate[1]).format('YYYY-MM-DD')
         } else {
             delete params?.regBeginTime
             delete params?.regEndTime
@@ -71,7 +74,23 @@ const BanGamePlayerManage: React.FC = () => {
                     <Col><Form.Item name='userId'>
                         <Input placeholder="玩家ID" allowClear style={{ width: 140 }} />
                     </Form.Item></Col>
-                    
+
+                    <Col><Form.Item name='userName'>
+                        <Input placeholder="玩家账号" allowClear style={{ width: 140 }} />
+                    </Form.Item></Col>
+
+                    <Col><Form.Item name='userNickName'>
+                        <Input placeholder="玩家昵称" allowClear style={{ width: 140 }} />
+                    </Form.Item></Col>
+
+                    <Col><Form.Item name='regDate'>
+                        <DatePicker.RangePicker placeholder={['注册开始日期', '注册结束日期']} ranges={getPresets() as any} />
+                    </Form.Item></Col>
+
+                    <Col><Form.Item name='banDate'>
+                        <DatePicker.RangePicker placeholder={['封禁开始日期', '封禁结束日期']} ranges={getPresets() as any} />
+                    </Form.Item></Col>
+
                     <Col>
                         <Space>
                             <Button type="primary" htmlType="submit">搜索</Button>
@@ -80,6 +99,37 @@ const BanGamePlayerManage: React.FC = () => {
                     </Col>
                 </Row>
             </Form>
+
+            <div className={`${style['small']}`}>
+                <Tables
+                    className={`all_table content_table_body`}
+                    bordered
+                    sortDirections={['ascend', 'descend', null]}
+                    current={queryFrom.pageNum}
+                    pageSize={queryFrom.pageSize}
+                    columns={columnsPos(handle)}
+                    dataSource={getBanUserList?.data?.records}
+                    scroll={{ x: 1000, y: 600 }}
+                    onChange={(pagination: any, filters: any, sortData: any) => {
+                        let { current, pageSize } = pagination
+                        let newQueryForm = JSON.parse(JSON.stringify(queryFrom))
+                        if (sortData && sortData?.order) {
+                            newQueryForm['sortType'] = sortData?.order === 'ascend' ? 'asc' : 'desc'
+                            newQueryForm['sortFiled'] = sortData?.field
+                        } else {
+                            delete newQueryForm['sortType']
+                            delete newQueryForm['sortFiled']
+                        }
+                        newQueryForm.pageNum = current
+                        newQueryForm.pageSize = pageSize
+                        setQueryForm({ ...newQueryForm })
+                    }}
+                    size="small"
+                    total={getBanUserList?.data?.total}
+                    loading={getBanUserList?.loading}
+                    defaultPageSize={20}
+                />
+            </div>
         </Space>
     </Card>
 }

+ 75 - 0
src/pages/gameDataStatistics/player/banIpManage/addBanIp.tsx

@@ -0,0 +1,75 @@
+import { useAjax } from "@/Hook/useAjax"
+import { addBanIpApi } from "@/services/gameData/player"
+import { Form, Input, message, Modal, Select } from "antd"
+import React, { useState } from "react"
+
+interface Props {
+    gameList: any[]
+    visible?: boolean,
+    onChange?: () => void,
+    onClose?: () => void
+}
+/**
+ * 新增封禁IP
+ * @param props 
+ * @returns 
+ */
+const AddBanIp: React.FC<Props> = (props) => {
+
+    /** ----------变量开始------- */
+    const { visible, onChange, onClose, gameList } = props
+    const [form] = Form.useForm()
+    const [initialValues, _setinitialValues] = useState<any>({})
+    /** ----------变量结束------- */
+
+    const addBanIp = useAjax((params: { ipList: string[] }) => addBanIpApi(params))
+
+
+    // 确定
+    const handleOk = async () => {
+        form.submit()
+        let data = await form.validateFields()
+        let regexIP = /^((25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))$/
+        let ips = data.ips.split(/,|,/ig)
+        if (!ips?.every((ip: string) => regexIP.test(ip))) {
+            message.error('请正确输入ip地址')
+            return
+        }
+        addBanIp.run({ ipList: ips, gameId: data.gameId }).then(res => {
+            if (res) {
+                message.success('添加成功')
+                onChange && onChange()
+            }
+        })
+    }
+
+    return <Modal title="新增封禁IP" visible={visible} onOk={handleOk} onCancel={() => { onClose && onClose() }} confirmLoading={addBanIp.loading}>
+        <Form
+            name="basicBanIp"
+            form={form}
+            labelCol={{ span: 4 }}
+            wrapperCol={{ span: 20 }}
+            autoComplete="off"
+            initialValues={{ ...initialValues }}
+        >
+            <Form.Item label="游戏" name="gameId" rules={[{ required: true, message: '请选择游戏!' }]}>
+                <Select
+                    showSearch
+                    style={{ minWidth: 180 }}
+                    allowClear
+                    placeholder="选择游戏"
+                    filterOption={(input, option) =>
+                        (option?.children as any)?.toLowerCase().indexOf(input.toLowerCase()) >= 0
+                    }
+                >
+                    {gameList?.map((item: any) => <Select.Option value={item.id} key={item.id}>{item.name}</Select.Option>)}
+                </Select>
+            </Form.Item>
+            <Form.Item label="IP" name="ips" rules={[{ type: 'string', required: true, message: '请输入IP!' }]}>
+                <Input.TextArea rows={4} placeholder="请输入需要封禁的IP地址,多个IP请用逗号“,”隔开" />
+            </Form.Item>
+        </Form>
+    </Modal>
+}
+
+export default React.memo(AddBanIp)

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

@@ -1,5 +1,15 @@
-import React from "react"
-
+import { useAjax } from "@/Hook/useAjax"
+import { getPresets } from "@/components/QueryForm/const"
+import { getGameChoiceListApi } from "@/services/gameData"
+import { IpManageListProps, getIpManageListApi, updateBanIpApi } from "@/services/gameData/player"
+import { Button, Card, Col, DatePicker, Form, Input, Row, Select, Space, message } from "antd"
+import React, { useEffect, useState } from "react"
+import moment from "moment"
+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"
 
 /**
  * 封禁IP管理
@@ -8,12 +18,145 @@ import React from "react"
 const BanIpManage: React.FC = () => {
 
     /*************************/
-
+    const [form] = Form.useForm()
+    const [initialValues, _setInitialValues] = useState<any>({})
+    const [queryFrom, setQueryForm] = useState<IpManageListProps>({ pageNum: 1, pageSize: 20 })
+    const [addShow, setAddShow] = useState<boolean>(false)
+    
+    const getGameChoiceList = useAjax(() => getGameChoiceListApi())
+    const getIpManageList = useAjax((params: IpManageListProps) => getIpManageListApi(params))
+    const updateBanIp = useAjax((params: { ip: string, status: number }) => updateBanIpApi(params))
     /*************************/
 
-    return <div>
-        1111
-    </div>
+    useEffect(() => {
+        getGameChoiceList.run()
+    }, [])
+
+    useEffect(() => {
+        getIpManageList.run(queryFrom)
+    }, [queryFrom])
+
+    const onFinish = (data: any) => {
+        const { banDate, ...value } = data
+        let params = { ...queryFrom, ...value }
+        if (banDate) {
+            params.beginDate = moment(banDate[0]).format('YYYY-MM-DD')
+            params.endDate = moment(banDate[1]).format('YYYY-MM-DD')
+        } else {
+            delete params?.beginDate
+            delete params?.endDate
+        }
+        setQueryForm({ ...params, pageNum: 1 })
+    }
+
+    // 解封 封禁
+    const handle = (data: { ip: string, status: number }) => {
+        updateBanIp.run({ ip: data.ip, status: data.status === 0 ? 1 : 0 }).then(res => {
+            if (res) {
+                if (data.status === 0) {
+                    message.success('封禁成功')
+                } else {
+                    message.success('解封成功')
+                }
+                getIpManageList.refresh()
+            }
+        })
+    }
+
+    return <Card
+        style={{ borderRadius: 8 }}
+        headStyle={{ textAlign: 'left' }}
+        bodyStyle={{ padding: '5px 10px' }}
+    >
+        <div style={{ textAlign: 'center', fontWeight: 'bold', padding: '4px 6px 6px', fontSize: 16, marginBottom: 4, position: 'relative' }}>
+            封禁IP管理
+        </div>
+        <Space style={{ width: '100%' }} direction="vertical" size={10}>
+            <Form layout="inline" className='queryForm' initialValues={initialValues} name="basicGameServer" form={form} onFinish={onFinish}>
+                <Row gutter={[0, 6]}>
+                    <Col><Form.Item name='gameId'>
+                        <Select
+                            maxTagCount={1}
+                            showSearch
+                            style={{ minWidth: 140 }}
+                            allowClear
+                            placeholder={'请选择游戏'}
+                            filterOption={(input, option) =>
+                                (option?.children as any)?.toLowerCase().indexOf(input.toLowerCase()) >= 0
+                            }
+                        >
+                            {getGameChoiceList?.data?.map((item: any) => <Select.Option value={item.id} key={item.id}>{item.name}</Select.Option>)}
+                        </Select>
+                    </Form.Item></Col>
+
+                    <Col><Form.Item name='ip'>
+                        <Input placeholder="IP" allowClear style={{ width: 140 }} />
+                    </Form.Item></Col>
+
+                    <Col><Form.Item name='banDate'>
+                        <DatePicker.RangePicker placeholder={['封禁开始日期', '封禁结束日期']} ranges={getPresets() as any} />
+                    </Form.Item></Col>
+
+                    <Col><Form.Item name='status'>
+                        <Select
+                            maxTagCount={1}
+                            showSearch
+                            allowClear
+                            placeholder={'当前封禁状态'}
+                            filterOption={(input, option) =>
+                                (option?.children as any)?.toLowerCase().indexOf(input.toLowerCase()) >= 0
+                            }
+                        >
+                            <Select.Option value={'0'}>已解封</Select.Option>
+                            <Select.Option value={'1'}>未解封</Select.Option>
+                        </Select>
+                    </Form.Item></Col>
+
+                    <Col>
+                        <Space>
+                            <Button type="primary" htmlType="submit">搜索</Button>
+                            <Button onClick={() => form.resetFields()}>重置</Button>
+                            <Button type="primary" icon={<PlusOutlined />} onClick={() => setAddShow(true)}>新增封禁IP</Button>
+                        </Space>
+                    </Col>
+                </Row>
+            </Form>
+
+            <div className={`${style['small']}`}>
+                <Tables
+                    className={`all_table content_table_body`}
+                    bordered
+                    sortDirections={['ascend', 'descend', null]}
+                    current={queryFrom.pageNum}
+                    pageSize={queryFrom.pageSize}
+                    columns={columnsPos(handle)}
+                    dataSource={getIpManageList?.data?.records}
+                    scroll={{ x: 1000, y: 600 }}
+                    onChange={(pagination: any, filters: any, sortData: any) => {
+                        let { current, pageSize } = pagination
+                        let newQueryForm = JSON.parse(JSON.stringify(queryFrom))
+                        if (sortData && sortData?.order) {
+                            newQueryForm['sortType'] = sortData?.order === 'ascend' ? 'asc' : 'desc'
+                            newQueryForm['sortFiled'] = sortData?.field
+                        } else {
+                            delete newQueryForm['sortType']
+                            delete newQueryForm['sortFiled']
+                        }
+                        newQueryForm.pageNum = current
+                        newQueryForm.pageSize = pageSize
+                        setQueryForm({ ...newQueryForm })
+                    }}
+                    size="small"
+                    total={getIpManageList?.data?.total}
+                    loading={getIpManageList?.loading}
+                    defaultPageSize={20}
+                />
+            </div>
+        </Space>
+
+        {/* 新增封禁IP */}
+        {addShow && <AddBanIp gameList={getGameChoiceList?.data} visible={addShow} onClose={() => setAddShow(false)} onChange={() => { setAddShow(false); getIpManageList?.refresh() }} />}
+    </Card>
 }
 
 export default BanIpManage

+ 82 - 0
src/pages/gameDataStatistics/player/banIpManage/tableConfig.tsx

@@ -0,0 +1,82 @@
+import { Popconfirm, Tag } from "antd"
+import React from "react"
+
+function columnsPos(handle?: (data: any) => void) {
+
+    let newArr: any = [
+        {
+            title: 'ID',
+            dataIndex: 'id',
+            key: 'id',
+            align: 'center',
+            width: 60
+        },
+        {
+            title: '游戏名称',
+            dataIndex: 'gameName',
+            key: 'gameName',
+            align: 'center',
+            ellipsis: true,
+            width: 100
+        },
+        {
+            title: 'IP',
+            dataIndex: 'ip',
+            key: 'ip',
+            align: 'center',
+            ellipsis: true,
+            width: 180
+        },
+        {
+            title: '封禁时间',
+            dataIndex: 'banTime',
+            key: 'banTime',
+            align: 'center',
+            width: 160,
+            ellipsis: true,
+        },
+        {
+            title: '更新时间',
+            dataIndex: 'updateTime',
+            key: 'updateTime',
+            align: 'center',
+            width: 160,
+            ellipsis: true,
+        },
+        {
+            title: '当前封禁状态',
+            dataIndex: 'status',
+            key: 'status',
+            align: 'center',
+            width: 120,
+            render: (a: number) => {
+                if (a === 1) {
+                    return <Tag color="#f50">封禁</Tag>
+                }
+                return <Tag color="#108ee9">已解封</Tag>
+            }
+        },
+        {
+            title: '操作',
+            dataIndex: 'cz',
+            key: 'cz',
+            align: 'center',
+            width: 80,
+            fixed: 'right',
+            render: (a: string, b: any) => (
+                <Popconfirm
+                    title={b?.status === 1 ? '确定解封?' : '确定封禁?'}
+                    onConfirm={() => { handle && handle(b) }}
+                    okText="是"
+                    cancelText="否"
+                >
+                    <a style={{ fontSize: "12px", color: b?.status === 1 ? '#108ee9' : '#f50' }}> {b?.status === 1 ? '解封' : '封禁'}</a>
+                </Popconfirm>
+
+            )
+        }
+    ]
+    return newArr
+}
+
+export default columnsPos

+ 1 - 5
src/pages/gameDataStatistics/roleOperate/createRoleConfig/index.tsx

@@ -83,16 +83,12 @@ const CreateRoleConfig: React.FC = () => {
                         <Space>
                             <Button type="primary" htmlType="submit">搜索</Button>
                             <Button onClick={() => form.resetFields()}>重置</Button>
+                            <Button icon={<PlusOutlined />} type="primary" onClick={() => { setVisible(true); setInitialValues({}) }}>新增有效创角配置</Button>
                         </Space>
                     </Col>
                 </Row>
             </Form>
 
-            <Space wrap>
-                <Button icon={<PlusOutlined />} type="primary" onClick={() => { setVisible(true); setInitialValues({}) }}>新增有效创角配置</Button>
-            </Space>
-
-
             <div className={`${style['small']}`}>
                 <Tables
                     className={`all_table content_table_body`}

+ 3 - 7
src/pages/gameDataStatistics/roleOperate/gameServer/index.tsx

@@ -45,7 +45,6 @@ const GameServer: React.FC = () => {
         game_supper_list_api.run()
         getGameChoiceList.run()
     }, [])
-    console.log(game_supper_list_api)
 
     useEffect(() => {
         getGameServerList.run(queryFrom)
@@ -160,17 +159,14 @@ const GameServer: React.FC = () => {
                         <Space>
                             <Button type="primary" htmlType="submit">搜索</Button>
                             <Button onClick={() => form.resetFields()}>重置</Button>
+                            <Button icon={<PlusOutlined />} type="primary" onClick={() => { setVisible(true); setInitialValues({ startTime: moment().add(90, 'd') }) }}>新增游戏区服</Button>
+                            <Button icon={<PlusOutlined />} type="primary" onClick={() => { set_show(true) }}>新增合服</Button>
+                            <UploadExcel gameList={game_supper_list_api?.data} onChange={() => getGameServerList.refresh()} />
                         </Space>
                     </Col>
                 </Row>
             </Form>
 
-            <Space wrap>
-                <Button icon={<PlusOutlined />} type="primary" onClick={() => { setVisible(true); setInitialValues({ startTime: moment().add(90, 'd') }) }}>新增游戏区服</Button>
-                <Button icon={<PlusOutlined />} type="primary" onClick={() => { set_show(true) }}>新增合服</Button>
-                <UploadExcel gameList={game_supper_list_api?.data} onChange={() => getGameServerList.refresh()}/>
-            </Space>
-
             <div className={`${style['small']}`}>
                 <Tables
                     className={`all_table content_table_body`}

+ 1 - 4
src/pages/gameDataStatistics/roleOperate/pack/index.tsx

@@ -113,15 +113,12 @@ const Pack: React.FC = () => {
                         <Space>
                             <Button type="primary" htmlType="submit">搜索</Button>
                             <Button onClick={() => form.resetFields()}>重置</Button>
+                            <Button icon={<PlusOutlined />} type="primary" onClick={() => { setVisible(true); setInitialValues({}) }}>新增礼包</Button>
                         </Space>
                     </Col>
                 </Row>
             </Form>
 
-            <Space wrap>
-                <Button icon={<PlusOutlined />} type="primary" onClick={() => { setVisible(true); setInitialValues({}) }}>新增礼包</Button>
-            </Space>
-
             <div className={`${style['small']}`}>
                 <Tables
                     className={`all_table content_table_body`}

+ 1 - 1
src/services/api.ts

@@ -1,6 +1,6 @@
 // export let api: any = process.env.NODE_ENV === 'development' ? 'api' : 'http://test.api.zanxiangwl.com'
 // export let erpApi: any = process.env.NODE_ENV === 'development' ? 'erpApi' : 'http://test.api.zanxiangwl.com'
 // export let gameApi: any = process.env.NODE_ENV === 'development' ? 'gameApi' : `http://test.api.zanxiangwl.com`
-export let api: any = process.env.NODE_ENV === 'development' ? 'api' : 'http://game.84game.cn'
+export let api: any = process.env.NODE_ENV === 'development' ? 'api' : 'https://game.84game.cn'
 export let erpApi: any = process.env.NODE_ENV === 'development' ? 'erpApi' : 'https://api.zanxiangwl.com'
 export let gameApi: any = process.env.NODE_ENV === 'development' ? 'gameApi' : `https://game.84game.cn`

+ 45 - 0
src/services/gameData/player.ts

@@ -293,4 +293,49 @@ export async function getBanUserListApi(params: gamePlayerBanListProps) {
         method: 'POST',
         data: params,
     });
+}
+
+
+
+/** 获取玩家游戏角色列表 */
+export interface IpManageListProps {
+    pageNum: number,
+    pageSize: number,
+    ip?: string,       // 玩家ip
+    beginDate?: string,
+    endDate?: string,  // 封禁时间
+    status?: any,      // 当前封禁状态
+}
+
+/** 封禁IP列表查询 */
+export async function getIpManageListApi(params: IpManageListProps) {
+    return request(apiManage + '/ban/ip/list', {
+        method: 'POST',
+        data: params,
+    });
+}
+
+/**
+ * 添加封禁IP
+ * @param params 
+ * @returns 
+ */
+export async function addBanIpApi(params: { ipList: string[] }) {
+    return request(apiManage + '/ban/ip/add', {
+        method: 'POST',
+        data: params,
+    });
+}
+
+
+/**
+ * 解封 封禁
+ * @param params 
+ * @returns 
+ */
+export async function updateBanIpApi(params: { ip: string, status: number }) {
+    return request(apiManage + '/ban/ip/update', {
+        method: 'POST',
+        data: params,
+    });
 }