Преглед на файлове

feat:新增开启思维芯权限

zhubo преди 2 години
родител
ревизия
62e4e6c00c
променени са 6 файла, в които са добавени 54 реда и са изтрити 7 реда
  1. 2 3
      src/layouts/BasicLayout.tsx
  2. 20 2
      src/models/user.ts
  3. 21 1
      src/pages/agent/list/detail.tsx
  4. 1 1
      src/pages/setting/banner/index.tsx
  5. 9 0
      src/services/agent.ts
  6. 1 0
      src/utils/request.ts

+ 2 - 3
src/layouts/BasicLayout.tsx

@@ -17,7 +17,6 @@ import Authorized from '@/utils/Authorized';
 import RightContent from '@/components/GlobalHeader/RightContent';
 import type { ConnectState } from '@/models/connect';
 import { getMatchMenu } from '@umijs/route-utils';
-import { BASE_URL } from '@/utils/eventkey';
 
 const noMatch = (
   <Result
@@ -95,11 +94,11 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
   useEffect(() => {
     console.log('hello');
 
+    const { origin } = window.location;
     if (!window.localStorage.getItem('token')) {
       if (process.env.NODE_ENV === 'development') {
-        window.location.href = `${BASE_URL}/#/user/login`;
+        window.location.href = `${origin}/#/user/login`;
       } else {
-        const { origin } = window.location;
         window.location.href = `${origin}/tieba-admin/#/user/login`;
       }
     }

+ 20 - 2
src/models/user.ts

@@ -69,10 +69,22 @@ const UserModel: UserModelType = {
     *getRoleList(_, { call, put }) {
       const { payload, callback } = _;
 
-      const r = yield call(getRoleListNew, payload);
+      const r = yield call(getRoleList, payload);
 
       yield put({
         type: 'saveRoleList',
+        payload: r.data.records,
+      });
+
+      callback();
+    },
+    *getRoleListNew(_, { call, put }) {
+      const { payload, callback } = _;
+
+      const r = yield call(getRoleListNew, payload);
+
+      yield put({
+        type: 'saveRoleListNew',
         payload: r.data,
       });
 
@@ -81,13 +93,19 @@ const UserModel: UserModelType = {
   },
 
   reducers: {
+    saveRoleListNew(state, action) {
+      console.log(action, 'action');
+
+      let newState = { ...state, roleList: action.payload || [] };
+      return newState;
+    },
     /**
      * @description 保存权限列表
      */
     saveRoleList(state, action) {
       console.log(action, 'action');
 
-      let newState = { ...state, roleList: action.payload || [] };
+      let newState = { ...state, roleList: action.payload.slice(1) || [] };
       return newState;
     },
 

+ 21 - 1
src/pages/agent/list/detail.tsx

@@ -13,13 +13,16 @@ import {
   Input,
   Popconfirm,
   message,
+  Radio,
 } from 'antd';
-import { getAgentDetail } from '@/services/agent';
+import { changeAdminManagement, getAgentDetail } from '@/services/agent';
 
 import { editAgentInfo } from '@/services/agent';
 
 import type { roleListType } from './index';
 
+import type { RadioChangeEvent } from 'antd';
+
 type DetailModalType = {
   visible: boolean;
   id: string;
@@ -226,6 +229,17 @@ const DetailModal: React.FC<DetailModalType> = ({ visible, id, closeModal }) =>
     );
   };
 
+  // 修改代理商权限
+  const changeAdmin = async (e: RadioChangeEvent) => {
+    const { code } = await changeAdminManagement(userInfo.id, e.target.value);
+
+    if (code === 0) {
+      message.success('修改成功');
+
+      setUserInfo({ ...userInfo, admin: e.target.value });
+    }
+  };
+
   return (
     <Modal title="详细信息" visible={visible} width={1200} onOk={closeModal} onCancel={closeModal}>
       <Spin spinning={spinning}>
@@ -250,6 +264,12 @@ const DetailModal: React.FC<DetailModalType> = ({ visible, id, closeModal }) =>
                 <Descriptions.Item span={1} label="角色">
                   {userInfo.authRoles && renderAuthRoles()}
                 </Descriptions.Item>
+                <Descriptions.Item span={1} label="是否开启发布思维芯·芯声">
+                  <Radio.Group onChange={changeAdmin} value={userInfo.admin}>
+                    <Radio value={1}>是</Radio>
+                    <Radio value={0}>否</Radio>
+                  </Radio.Group>
+                </Descriptions.Item>
               </Descriptions>
             </Space>
           </Col>

+ 1 - 1
src/pages/setting/banner/index.tsx

@@ -98,7 +98,7 @@ const Banner: React.FC<IProps> = ({ roleList, dispatch }) => {
   // 请求身份分类
   useEffect(() => {
     dispatch({
-      type: 'user/getRoleList',
+      type: 'user/getRoleListNew',
       payload: {
         curPage: 1,
         passSize: 100,

+ 9 - 0
src/services/agent.ts

@@ -33,3 +33,12 @@ export async function stopOrOpenAgent(id: string, params: stopOrOpenAgentType):
 export async function editAgentInfo(data: any) {
   return request(`/forum/admin/agent`, { method: 'PUT', data });
 }
+
+/**
+ * @description 开通或关闭管理员
+ * @author 朱波
+ * @date 2022/10/27
+ */
+export async function changeAdminManagement(userId: string, state: number | string) {
+  return request(`/forum/admin/agent/management/${userId}/${state}`, { method: 'PUT' });
+}

+ 1 - 0
src/utils/request.ts

@@ -84,6 +84,7 @@ request.interceptors.response.use(async (response, options) => {
   if (r.code === 5001) {
     const { origin } = window.location;
     if (process.env.NODE_ENV === 'development') {
+      // console.log(origin,'origin')
       window.location.href = `${origin}/#/user/login`;
     } else {
       window.location.href = `${origin}/tieba-admin/#/user/login`;