Explorar el Código

feta 增加菜单

Young hace 4 meses
padre
commit
1117807276

+ 24 - 7
config/routes.ts

@@ -50,13 +50,35 @@ export default [
     icon: 'crown',
     routes: [
       {
-        path: '/peak/list',
-        name: 'peak_list',
+        path: '/peak/peaks',
+        name: 'peaks',
         component: './Peak/Peak',
       },
     ],
   },
   {
+    path: '/user',
+    name: 'user',
+    icon: 'crown',
+    routes: [
+      {
+        path: '/user/users',
+        name: 'users',
+        component: './User/Users',
+      },
+      {
+        path: '/user/userLevel',
+        name: 'userLevel',
+        component: './User/UserLevel',
+      },
+      {
+        path: '/user/factionLevel',
+        name: 'factionLevel',
+        component: './User/FactionLevel',
+      },
+    ],
+  },
+  {
     path: '/settings',
     name: 'settings',
     icon: 'crown',
@@ -71,11 +93,6 @@ export default [
         component: './Settings/Staff',
       },
       {
-        path: '/settings/users',
-        name: 'users',
-        component: './Settings/Users',
-      },
-      {
         path: '/settings/role',
         name: 'role',
         component: './Settings/Role',

+ 11 - 2
src/locales/zh-CN/menu.ts

@@ -11,8 +11,17 @@ export default {
   'menu.settings.role': '角色管理',
   'menu.settings.menu': '菜单管理',
 
-  'menu.settings.idols': '明星管理',
-  'menu.admin.sub-page': '二级管理页',
+
+
+  'menu.peak': '峰管理',
+  'menu.peak.peaks': '峰管理',
+
+  'menu.user': '用户管理',
+  'menu.user.users': '用户管理',
+  'menu.user.factionLevel': '宗门登记',
+  'menu.user.userLevel': '会员等级',
+
+
   'menu.login': '登录',
   'menu.register': '注册',
   'menu.register-result': '注册结果',

+ 261 - 0
src/pages/User/FactionLevel.tsx

@@ -0,0 +1,261 @@
+import {ActionType, PageContainer, ProForm, ProFormSelect, ProFormText, ProTable,} from '@ant-design/pro-components';
+import {Button, Card, Modal} from 'antd';
+import React, {useRef} from 'react';
+import {AddOutline} from 'antd-mobile-icons';
+import {EditBundle, useEdit} from '@/core/hooks/useEdit';
+import { deleteUserRemoveApi, getUserDetailsApi, postUserPageApi, postUserSaveApi } from '@/services/swagger/userAdmin';
+import {getPeakListApi} from "@/services/swagger/peakAdmin";
+import {getUserLevelListApi} from "@/services/swagger/userLevelAdmin";
+import {getFactionLevelListApi} from "@/services/swagger/factionLevelAdmin";
+
+const Edit: React.FC<{ bundle: EditBundle; onSuccess?: () => void }> = (props) => {
+  const {bundle} = props;
+  const [form] = ProForm.useForm<SectApi.UserSaveQuery>();
+  const [loading, setLoading] = React.useState(false);
+
+  return (
+    <Modal
+      confirmLoading={loading}
+      title={bundle.id ? '编辑用户' : '添加用户'}
+      open={bundle.open}
+      onOk={async () => {
+        await form.validateFields();
+
+        try {
+          setLoading(true);
+
+          await postUserSaveApi({
+            id: bundle.id,
+            ...form.getFieldsValue()
+          });
+        } finally {
+          setLoading(false);
+        }
+
+        props.onSuccess?.();
+        bundle.close();
+      }}
+      onCancel={() => {
+        form.resetFields();
+        bundle.close();
+      }}
+    >
+      <ProForm
+        className={'mt-5'}
+        form={form}
+        labelCol={{span: 4}}
+        layout={'horizontal'}
+        submitter={false}
+        request={async () => {
+          if (bundle.id !== undefined) {
+            console.log(bundle.id, 'bundle');
+            const res = await getUserDetailsApi({id: bundle.id});
+
+            return {
+              ...res.data
+            }
+          }
+
+          return Promise.resolve({});
+        }}
+      >
+        <ProFormText name="name" label={'用户名称'} rules={[{required: true, message: '请输入用户名称',}]} placeholder={'请输入用户名'}></ProFormText>
+        <ProFormText name="mobile" label={'手机号'} rules={[{required: true, message: '请输入手机号',}]} placeholder={'请输入手机号'}></ProFormText>
+        <ProFormText name="nickname" label={'昵称'} rules={[{required: true, message: '请输入昵称',}]} placeholder={'请输入昵称'}></ProFormText>
+        <ProFormText name="purpleCoin" label={'紫币'} rules={[{required: true, message: '请输入紫币',}]} placeholder={'请输入紫币'}></ProFormText>
+        <ProFormText name="purpleSpar" label={'紫晶'} rules={[{required: true, message: '请输入紫晶',}]} placeholder={'请输入紫晶'}></ProFormText>
+
+        <ProFormSelect
+          fieldProps={{
+            'mode': 'multiple',
+          }}
+          name="peakId"
+          label="所属峰"
+          request={async () => {
+            const res = await getPeakListApi();
+            const records = res.data ?? []
+            return records.map(record => ({
+              label: record.name,
+              value: record.id,
+            }))
+          }}
+          placeholder="请选择所属峰"
+          rules={[{required: true, message: '请选择所属峰'}]}
+        />
+        <ProFormSelect
+          fieldProps={{
+            'mode': 'multiple',
+          }}
+          name="userLevel"
+          label="会员等级"
+          request={async () => {
+            const res = await getUserLevelListApi();
+            const records = res.data ?? []
+            return records.map(record => ({
+              label: record.name,
+              value: record.id,
+            }))
+          }}
+          placeholder="请选择会员等级"
+          rules={[{required: true, message: '请选择会员等级'}]}
+        />
+        <ProFormSelect
+          fieldProps={{
+            'mode': 'multiple',
+          }}
+          name="factionLevel"
+          label="宗门等级"
+          request={async () => {
+            const res = await getFactionLevelListApi();
+            const records = res.data ?? []
+            return records.map(record => ({
+              label: record.name,
+              value: record.id,
+            }))
+          }}
+          placeholder="请选择宗门等级"
+          rules={[{required: true, message: '请选择宗门等级'}]}
+        />
+
+        <ProFormText.Password
+          name="password"
+          label="密码"
+          placeholder={'请输入密码'}
+          rules={[
+            {
+              required: true,
+              message: '请输入密码',
+            },
+            {
+              min: 6,
+              max: 50,
+              message: '密码长度必须在6-50之间',
+            },
+          ]}
+        />
+      </ProForm>
+    </Modal>
+  );
+};
+
+const Staff: React.FC = () => {
+  const bundle = useEdit();
+  const ref = useRef<ActionType>();
+
+
+
+  return (
+    <PageContainer content={''}>
+      {bundle.open && <Edit bundle={bundle} onSuccess={() => ref.current?.reload()}></Edit>}
+      <Card>
+        <ProTable<SectApi.StaffVO>
+          rowKey={'id'}
+
+          request={async (params, ...rest) => {
+            console.log(params, ...rest)
+
+            const res = await postUserPageApi(
+
+              {
+                current: params.current || 1,
+                size: params.pageSize || 10,
+              }
+              );
+
+            return {
+              success: res.success,
+              total: res.data.total,
+              data: res.data.records,
+            };
+          }}
+          columns={[
+            {
+              title: 'ID',
+              dataIndex: 'id',
+            },
+            {
+              title: '所属峰',
+              dataIndex: 'peakName',
+            },
+            {
+              title: '名称',
+              dataIndex: 'name',
+            },
+            {
+              title: '手机号码',
+              dataIndex: 'mobile',
+            },
+            {
+              title: '昵称',
+              dataIndex: 'nickname',
+            },
+            {
+              title: '会员等级',
+              dataIndex: 'userLevelName',
+            },
+            {
+              title: '宗门等级',
+              dataIndex: 'factionLevelName',
+            },
+            {
+              title: '紫币',
+              dataIndex: 'purpleCoin',
+            },
+            {
+              title: '紫晶',
+              dataIndex: 'purpleSpar',
+            },
+            {
+              title: '状态',
+              dataIndex: 'status',
+              render: (text, _) => {
+                return text === 1 ? "启用" : "禁用"
+              }
+            },
+            {
+              title: '操作',
+              valueType: 'option',
+              render: (_, record) => [
+                <a key={'edit'} onClick={() => bundle.update(record.id as number)}>
+                  编辑
+                </a>,
+                <a
+                  key={'delete'}
+                  onClick={async () => {
+                    if(record.id) {
+                      await deleteUserRemoveApi({id: record.id})
+                      ref.current?.reload();
+                    }
+                  }}
+                >
+                  删除
+                </a>,
+              ],
+            },
+          ]
+          }
+          search={{
+            labelWidth: 'auto',
+          }}
+          form={{
+            ignoreRules: false,
+          }}
+
+
+          actionRef={ref}
+          toolbar={{
+            actions: [
+              <Button icon={<AddOutline/>} key={'add'} type={'primary'} onClick={bundle.create}>
+                添加
+              </Button>,
+            ],
+            settings: [],
+          }}
+
+        ></ProTable>
+      </Card>
+    </PageContainer>
+  );
+};
+
+export default Staff;

+ 261 - 0
src/pages/User/UserLevel.tsx

@@ -0,0 +1,261 @@
+import {ActionType, PageContainer, ProForm, ProFormSelect, ProFormText, ProTable,} from '@ant-design/pro-components';
+import {Button, Card, Modal} from 'antd';
+import React, {useRef} from 'react';
+import {AddOutline} from 'antd-mobile-icons';
+import {EditBundle, useEdit} from '@/core/hooks/useEdit';
+import { deleteUserRemoveApi, getUserDetailsApi, postUserPageApi, postUserSaveApi } from '@/services/swagger/userAdmin';
+import {getPeakListApi} from "@/services/swagger/peakAdmin";
+import {getUserLevelListApi} from "@/services/swagger/userLevelAdmin";
+import {getFactionLevelListApi} from "@/services/swagger/factionLevelAdmin";
+
+const Edit: React.FC<{ bundle: EditBundle; onSuccess?: () => void }> = (props) => {
+  const {bundle} = props;
+  const [form] = ProForm.useForm<SectApi.UserSaveQuery>();
+  const [loading, setLoading] = React.useState(false);
+
+  return (
+    <Modal
+      confirmLoading={loading}
+      title={bundle.id ? '编辑用户' : '添加用户'}
+      open={bundle.open}
+      onOk={async () => {
+        await form.validateFields();
+
+        try {
+          setLoading(true);
+
+          await postUserSaveApi({
+            id: bundle.id,
+            ...form.getFieldsValue()
+          });
+        } finally {
+          setLoading(false);
+        }
+
+        props.onSuccess?.();
+        bundle.close();
+      }}
+      onCancel={() => {
+        form.resetFields();
+        bundle.close();
+      }}
+    >
+      <ProForm
+        className={'mt-5'}
+        form={form}
+        labelCol={{span: 4}}
+        layout={'horizontal'}
+        submitter={false}
+        request={async () => {
+          if (bundle.id !== undefined) {
+            console.log(bundle.id, 'bundle');
+            const res = await getUserDetailsApi({id: bundle.id});
+
+            return {
+              ...res.data
+            }
+          }
+
+          return Promise.resolve({});
+        }}
+      >
+        <ProFormText name="name" label={'用户名称'} rules={[{required: true, message: '请输入用户名称',}]} placeholder={'请输入用户名'}></ProFormText>
+        <ProFormText name="mobile" label={'手机号'} rules={[{required: true, message: '请输入手机号',}]} placeholder={'请输入手机号'}></ProFormText>
+        <ProFormText name="nickname" label={'昵称'} rules={[{required: true, message: '请输入昵称',}]} placeholder={'请输入昵称'}></ProFormText>
+        <ProFormText name="purpleCoin" label={'紫币'} rules={[{required: true, message: '请输入紫币',}]} placeholder={'请输入紫币'}></ProFormText>
+        <ProFormText name="purpleSpar" label={'紫晶'} rules={[{required: true, message: '请输入紫晶',}]} placeholder={'请输入紫晶'}></ProFormText>
+
+        <ProFormSelect
+          fieldProps={{
+            'mode': 'multiple',
+          }}
+          name="peakId"
+          label="所属峰"
+          request={async () => {
+            const res = await getPeakListApi();
+            const records = res.data ?? []
+            return records.map(record => ({
+              label: record.name,
+              value: record.id,
+            }))
+          }}
+          placeholder="请选择所属峰"
+          rules={[{required: true, message: '请选择所属峰'}]}
+        />
+        <ProFormSelect
+          fieldProps={{
+            'mode': 'multiple',
+          }}
+          name="userLevel"
+          label="会员等级"
+          request={async () => {
+            const res = await getUserLevelListApi();
+            const records = res.data ?? []
+            return records.map(record => ({
+              label: record.name,
+              value: record.id,
+            }))
+          }}
+          placeholder="请选择会员等级"
+          rules={[{required: true, message: '请选择会员等级'}]}
+        />
+        <ProFormSelect
+          fieldProps={{
+            'mode': 'multiple',
+          }}
+          name="factionLevel"
+          label="宗门等级"
+          request={async () => {
+            const res = await getFactionLevelListApi();
+            const records = res.data ?? []
+            return records.map(record => ({
+              label: record.name,
+              value: record.id,
+            }))
+          }}
+          placeholder="请选择宗门等级"
+          rules={[{required: true, message: '请选择宗门等级'}]}
+        />
+
+        <ProFormText.Password
+          name="password"
+          label="密码"
+          placeholder={'请输入密码'}
+          rules={[
+            {
+              required: true,
+              message: '请输入密码',
+            },
+            {
+              min: 6,
+              max: 50,
+              message: '密码长度必须在6-50之间',
+            },
+          ]}
+        />
+      </ProForm>
+    </Modal>
+  );
+};
+
+const Staff: React.FC = () => {
+  const bundle = useEdit();
+  const ref = useRef<ActionType>();
+
+
+
+  return (
+    <PageContainer content={''}>
+      {bundle.open && <Edit bundle={bundle} onSuccess={() => ref.current?.reload()}></Edit>}
+      <Card>
+        <ProTable<SectApi.StaffVO>
+          rowKey={'id'}
+
+          request={async (params, ...rest) => {
+            console.log(params, ...rest)
+
+            const res = await postUserPageApi(
+
+              {
+                current: params.current || 1,
+                size: params.pageSize || 10,
+              }
+              );
+
+            return {
+              success: res.success,
+              total: res.data.total,
+              data: res.data.records,
+            };
+          }}
+          columns={[
+            {
+              title: 'ID',
+              dataIndex: 'id',
+            },
+            {
+              title: '所属峰',
+              dataIndex: 'peakName',
+            },
+            {
+              title: '名称',
+              dataIndex: 'name',
+            },
+            {
+              title: '手机号码',
+              dataIndex: 'mobile',
+            },
+            {
+              title: '昵称',
+              dataIndex: 'nickname',
+            },
+            {
+              title: '会员等级',
+              dataIndex: 'userLevelName',
+            },
+            {
+              title: '宗门等级',
+              dataIndex: 'factionLevelName',
+            },
+            {
+              title: '紫币',
+              dataIndex: 'purpleCoin',
+            },
+            {
+              title: '紫晶',
+              dataIndex: 'purpleSpar',
+            },
+            {
+              title: '状态',
+              dataIndex: 'status',
+              render: (text, _) => {
+                return text === 1 ? "启用" : "禁用"
+              }
+            },
+            {
+              title: '操作',
+              valueType: 'option',
+              render: (_, record) => [
+                <a key={'edit'} onClick={() => bundle.update(record.id as number)}>
+                  编辑
+                </a>,
+                <a
+                  key={'delete'}
+                  onClick={async () => {
+                    if(record.id) {
+                      await deleteUserRemoveApi({id: record.id})
+                      ref.current?.reload();
+                    }
+                  }}
+                >
+                  删除
+                </a>,
+              ],
+            },
+          ]
+          }
+          search={{
+            labelWidth: 'auto',
+          }}
+          form={{
+            ignoreRules: false,
+          }}
+
+
+          actionRef={ref}
+          toolbar={{
+            actions: [
+              <Button icon={<AddOutline/>} key={'add'} type={'primary'} onClick={bundle.create}>
+                添加
+              </Button>,
+            ],
+            settings: [],
+          }}
+
+        ></ProTable>
+      </Card>
+    </PageContainer>
+  );
+};
+
+export default Staff;

+ 1 - 1
src/pages/Settings/Users.tsx

@@ -194,7 +194,7 @@ const Staff: React.FC = () => {
               dataIndex: 'userLevelName',
             },
             {
-              title: '宗门登记',
+              title: '宗门等级',
               dataIndex: 'factionLevelName',
             },
             {