Эх сурвалжийг харах

添加应用权限校验&新增康程分类页面

code4eat 1 жил өмнө
parent
commit
e66ef6f39f

+ 5 - 1
config/config.ts

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2022-01-07 10:04:20
- * @LastEditTime: 2023-10-23 10:49:03
+ * @LastEditTime: 2023-11-07 18:53:42
  * @LastEditors: code4eat awesomedema@gmail.com
  * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  * @FilePath: /KC-MiddlePlatform/config/config.ts
@@ -144,6 +144,10 @@ export default defineConfig({
                   path: '/platform/setting/notificationTemplate',
                   component: '@/pages/platform/setting/notificationTemplate/index.tsx',
                 },
+                {
+                  path: '/platform/setting/kcClassification',
+                  component: '@/pages/platform/setting/kcClassification/index.tsx',
+                },
               ]
             },
           ],

+ 1 - 1
config/proxy.ts

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2022-01-07 10:00:52
- * @LastEditTime: 2023-10-27 09:43:05
+ * @LastEditTime: 2023-11-07 10:01:43
  * @LastEditors: code4eat awesomedema@gmail.com
  * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  * @FilePath: /KC-MiddlePlatform/config/proxy.ts

+ 5 - 2
src/app.tsx

@@ -121,7 +121,7 @@ const requestInterceptorsHandle = (url: string, options: RequestOptionsInit) =>
 
 const responseInterceptorsHandle = async (response: Response, options: RequestOptionsInit) => {
 
-
+  const {url} = options;
   const _response: {
     errorMessage: any;
     message: any;
@@ -137,10 +137,13 @@ const responseInterceptorsHandle = async (response: Response, options: RequestOp
       return _response.data;
     }
 
-    message.success({
+    if(url != '/centerSys/menu/checkKeygen'){
+      message.success({
         content:`操作成功!`,
         duration:1
     });
+    }
+
     return {
       status: _response.status,
       success: true,

+ 32 - 22
src/layouts/index.tsx

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2021-11-09 13:56:33
- * @LastEditTime: 2023-09-26 17:27:02
+ * @LastEditTime: 2023-11-07 20:40:14
  * @LastEditors: code4eat awesomedema@gmail.com
  * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  * @FilePath: /KC-MiddlePlatform/src/layouts/index.tsx
@@ -13,6 +13,8 @@ import ProLayout from '@ant-design/pro-layout';
 import TopBar from '@/components/topBar';
 import { Key, useEffect, useState } from 'react';
 import { getSpecifyMenuDetail, getUserPlatformNav } from '@/service/menu';
+import { getAppAccess } from '@/service';
+import { Modal } from 'antd';
 
 
 
@@ -26,33 +28,41 @@ const TopHoc = ({ currentSelectedSys, openedSysLists, navData,set_emptyPageConte
   };
 
   const onTabClickHandle = async (data: TopBar.Tab) => {
-
-    if(JSON.stringify(data) != '{}'){
-      await setInitialState((s) => ({ ...s, currentSelectedSys: data }));
-      console.log('onTabClickHandle');
-      // localStorage.removeItem('currentSelectedTab');
-      localStorage.removeItem('selectedKeys');
-      // localStorage.removeItem('visitedTabs');
-      localStorage.removeItem('openKeys');
-  
-      if(data.contentType == 4){
-          //空白页面
+    const {systemId} = data;
+    const resp  = await getAppAccess(systemId);
+    const {data:flag} = resp;
+    if(!flag){
+      if(JSON.stringify(data) != '{}'){
+        await setInitialState((s) => ({ ...s, currentSelectedSys: data }));
+        console.log('onTabClickHandle');
+        // localStorage.removeItem('currentSelectedTab');
+        localStorage.removeItem('selectedKeys');
+        // localStorage.removeItem('visitedTabs');
+        localStorage.removeItem('openKeys');
+    
+        if(data.contentType == 4){
+            //空白页面
+            if(data.isSetupMenu){
+              //体系菜单掩藏子应用的menu
+              localStorage.setItem('isChildShowMenu','false');
+            }
+            
+            history.push(`${data.path}?isEmpty=true&menuId=${data.menuId}`);
+        }else{
           if(data.isSetupMenu){
             //体系菜单掩藏子应用的menu
             localStorage.setItem('isChildShowMenu','false');
+          }else{
+            localStorage.setItem('isChildShowMenu','true');
           }
-          
-          history.push(`${data.path}?isEmpty=true&menuId=${data.menuId}`);
-      }else{
-        if(data.isSetupMenu){
-          //体系菜单掩藏子应用的menu
-          localStorage.setItem('isChildShowMenu','false');
-        }else{
-          localStorage.setItem('isChildShowMenu','true');
+       
+          history.push(data.path);
         }
-     
-        history.push(data.path);
       }
+    }else{
+        Modal.error({
+            title:'抱歉,你当前没有该应用权限,请联系管理员!'
+        });
     }
   };
 

+ 252 - 0
src/pages/platform/setting/kcClassification/index.tsx

@@ -0,0 +1,252 @@
+/*
+ * @Author: code4eat awesomedema@gmail.com
+ * @Date: 2023-03-03 11:30:33
+ * @LastEditors: code4eat awesomedema@gmail.com
+ * @LastEditTime: 2023-11-07 20:10:29
+ * @FilePath: /KC-MiddlePlatform/src/pages/platform/setting/pubDicTypeMana/index.tsx
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+
+
+import { KCInput } from '@/components/KCInput';
+import KCTable from '@/components/kcTable';
+import { getAllHosp } from '@/service/hospList';
+import { getUserRelaSeletData } from '@/service/user';
+import { ModalForm, ProFormCascader, ProFormDigit, ProFormSelect, ProFormText, ProFormTextArea } from '@ant-design/pro-form'
+import { ProColumns } from '@ant-design/pro-table';
+import { Popconfirm } from 'antd';
+import { useEffect, useState } from 'react'
+import { getSysLists } from '../paramsMana/service';
+import { addData, delData, editData, getData } from './service';
+
+import './style.less';
+import { findParents, renameChildListToChildren } from '@/utils';
+
+
+
+export default function KcClassification() {
+
+    const [tableDataFilterParams, set_tableDataFilterParams] = useState<any | undefined>();
+    const [tableDataSearchKeywords, set_tableDataSearchKeywords] = useState<string>('');
+    const [reload, set_reload] = useState(false);
+    const [currentEdit, set_currentEdit] = useState<any>(undefined);
+    const [tableData, set_tableData] = useState<any[]>([]);
+
+    //字典
+    const [dirData, set_dirData] = useState<any[]>([]);
+
+    const columns = [
+        {
+            title: '分类名称',
+            dataIndex: 'name',
+
+        },
+        {
+            title: '分类代码',
+            dataIndex: 'code',
+        },
+        {
+            title: '序号',
+            dataIndex: 'sort',
+        },
+        {
+            title: '说明',
+            dataIndex: 'description',
+        },
+        {
+            title: '操作',
+            key: 'option',
+            width: 120,
+            valueType: 'option',
+            render: (_: any, record: any) => {
+                return [
+                    <UpDataActBtn key={'act'} record={record} type='EDIT' />,
+                    <Popconfirm
+                        title="是否确认删除?"
+                        key="del"
+                        onConfirm={() => delTableData(record)}
+                    >
+                        <a>删除</a>
+                    </Popconfirm>,
+                    <UpDataActBtn key={'act2'} record={record} type='ADDCHILD' />,
+                ]
+            },
+        },
+
+    ]
+
+
+    const getTableData = async (params: any) => {
+        const resp = await getData(params);
+        set_reload(false);
+        if (resp) {
+            const data = renameChildListToChildren(resp, 'childList');
+            set_tableData(data);
+            return {
+                data: data,
+                success: true,
+            }
+        }
+        return []
+    }
+
+    const delTableData = async (record: any) => {
+        const resp = await delData(record.id);
+        if (resp) {
+            set_reload(true);
+            // message.success('操作成功!');
+        }
+    }
+
+
+    const getDirecData = async (key?: string) => {
+
+        const data = await getUserRelaSeletData(key);
+        if (data) {
+            set_dirData(data);
+        }
+    }
+
+
+    const updateTable = async (formVal: any, type: 'EDIT' | "ADD" | "ADDCHILD") => {
+        // const parents = findParents(tableData, 'id', formVal.id);
+        const result = {
+            code: formVal.code,
+            name: formVal.name,
+            value: '',
+            sort: formVal.sort,
+            parentCode: type == 'ADD' ? undefined : formVal.parentCode,
+            description: formVal.description
+        }
+        if (type == 'ADD') {
+            const resp = await addData({
+                ...result,
+                codePath: formVal.code,
+                levelName: formVal.name,
+            });
+            if (resp) {
+                set_reload(true);
+            }
+        }
+        if (type == 'ADDCHILD') {
+
+            const resp = await addData({
+                ...result,
+                codePath:`${formVal.codePath},${formVal.code}`,
+                levelName:`${formVal.levelName},${formVal.name}`,
+
+            });
+            if (resp) {
+                set_reload(true);
+            }
+        }
+        if (type == 'EDIT') {
+            // const parents = findParents(tableData,'id',formVal.id);
+            // console.log({parents});
+            
+            const resp = await editData({
+                ...result,
+                id: formVal.id,
+            });
+            if (resp) {
+                set_reload(true);
+            }
+        }
+
+
+    }
+
+    const UpDataActBtn = ({ record, type }: { record: any, type: 'EDIT' | 'ADD' | 'ADDCHILD' }) => {
+
+        return (
+            <ModalForm
+                title={`${type == 'EDIT' ? '编辑' :type == 'ADDCHILD'?'添加':'新增'}康程分类`}
+                width={350}
+                initialValues={type == 'EDIT' ? {
+                    ...record,
+                } : {}}
+                trigger={
+                    type == 'EDIT' ? <a key="edit" >编辑</a> : <a className='add'>{type == 'ADDCHILD'?'添加':'新增'}</a>
+                }
+                onFinish={(val) => {
+                    return updateTable(type == 'EDIT' ? { ...val, id: record.id } : type == 'ADDCHILD'?{...record,...val}:{ ...val }, type);
+                }}
+                colProps={{ span: 24 }}
+                grid
+            >
+
+                <ProFormText
+                    name="name"
+                    label="分类名称:"
+                    placeholder="请输入"
+                    rules={[{ required: true, message: '名称不能为空!' }]}
+                />
+                <ProFormText
+                    name="code"
+                    label="分类代码:"
+                    placeholder="请输入"
+                    rules={[{ required: true, message: '代码不能为空!' }]}
+                />
+                <ProFormDigit
+                    name="sort"
+                    label="序号:"
+                    placeholder="请输入"
+                    rules={[{ required: true, message: '序号不能为空!' }]}
+                />
+                <ProFormTextArea
+                    colProps={{ span: 24 }}
+                    name="description"
+                    label="说明:"
+                    placeholder="请输入"
+
+                />
+            </ModalForm>
+        )
+    }
+
+    const tableDataSearchHandle = (paramName: string) => {
+
+
+        set_tableDataFilterParams({
+            ...tableDataFilterParams,
+            [`${paramName}`]: tableDataSearchKeywords
+        })
+    }
+
+
+    useEffect(() => {
+        getDirecData();
+    }, [])
+
+    return (
+        <div className='KcClassification'>
+            <div className='toolBar'>
+                <div className='filter'>
+                    <div className='filterItem'>
+                        <span className='label'>分类名称:</span>
+                        <KCInput placeholder={'请输入'} style={{ width: 160 }} search allowClear
+                            onChange={(e) => {
+                                set_tableDataSearchKeywords(e.target.value);
+                                if (e.target.value.length == 0) {
+                                    set_tableDataFilterParams({
+                                        ...tableDataFilterParams,
+                                        name: ''
+                                    });
+                                }
+                            }}
+                            onSearch={() => tableDataSearchHandle('name')}
+
+                        />
+                    </div>
+                </div>
+                <div className='btnGroup'>
+                    <UpDataActBtn record type='ADD' />
+                </div>
+            </div>
+            <div style={{ marginTop: 16 }}>
+                <KCTable scroll={{ y: `calc(100vh - 250px)` }} columns={columns as ProColumns[]} reload={reload} rowKey='id' newVer params={tableDataFilterParams} request={(params) => getTableData(params)} />
+            </div>
+        </div>
+    )
+}

+ 91 - 0
src/pages/platform/setting/kcClassification/service.ts

@@ -0,0 +1,91 @@
+/*
+ * @Author: code4eat awesomedema@gmail.com
+ * @Date: 2023-03-03 16:31:27
+ * @LastEditors: code4eat awesomedema@gmail.com
+ * @LastEditTime: 2023-11-07 20:04:23
+ * @FilePath: /KC-MiddlePlatform/src/pages/platform/setting/pubDicTypeMana/service.ts
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+
+
+import { request } from 'umi';
+
+//获取table列表数据
+
+
+
+export type TableDataType = {
+  id:number;
+  hospId:string;
+  code:string;
+  name:string;
+  value:string,
+  sort:number,
+  parentCode:string,
+  codePath:string,
+  levelName:string,
+  description:string,
+  childList:TableDataType[]
+}
+
+
+export const getData = (params?:any) => {
+  return request<TableDataType[]>('/centerSys/kcClass/list', {
+    method: 'GET',
+    params:{...params}
+  });
+};
+
+
+//新增表格数据
+export type AddTableDataType = {
+  code:string,
+  name:string,
+  value:string,
+  sort:number,
+  parentCode:string,
+  codePath:string,
+  levelName:string,
+  description:string
+}
+export const addData = (data:AddTableDataType) => {
+  return request('/centerSys/kcClass/add', {
+    method: 'POST',
+    data
+  });
+};
+
+
+
+//编辑表格数据
+export type EditableDataType = {
+  id:number,
+  code:string,
+  name:string,
+  value:string,
+  sort:number,
+  description:string
+}
+export const editData = (data:EditableDataType) => {
+  return request('/centerSys/kcClass/edit', {
+    method: 'POST',
+    data
+  });
+};
+
+//删除表格操作
+export const delData = (id:string) => {
+  return request('/centerSys/kcClass/delete', {
+    method: 'POST',
+    params:{id}
+  });
+};
+
+
+
+
+
+
+
+

+ 42 - 0
src/pages/platform/setting/kcClassification/style.less

@@ -0,0 +1,42 @@
+.KcClassification {
+  padding: 16px;
+  background: #FFFFFF;
+  border-radius: 4px;
+
+  .toolBar {
+    display: flex;
+    flex-direction: row;
+    justify-content: space-between;
+    align-items: center;
+
+    .filter {
+      display: flex;
+      flex-direction: row;
+      justify-content: flex-start;
+      align-items: center;
+
+      .filterItem {
+        display: flex;
+        flex-direction: row;
+        justify-content: center;
+        align-items: center;
+      }
+    }
+
+    .btnGroup {
+      .add {
+        cursor: pointer;
+        display: inline-block;
+        font-size: 14px;
+        font-family: SourceHanSansCN-Normal, SourceHanSansCN;
+        font-weight: 400;
+        color: #FFFFFF;
+        line-height: 24px;
+        padding: 0 14px;
+        background: #3377FF;
+        border-radius: 4px;
+      }
+    }
+
+  }
+}

+ 9 - 1
src/service/index.ts

@@ -2,7 +2,7 @@
  * @Author: code4eat awesomedema@gmail.com
  * @Date: 2022-06-27 15:43:25
  * @LastEditors: code4eat awesomedema@gmail.com
- * @LastEditTime: 2023-04-13 18:25:20
+ * @LastEditTime: 2023-11-07 20:23:22
  * @FilePath: /KC-MiddlePlatform/src/service/index.ts
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  */
@@ -67,3 +67,11 @@ export const getAllParams = async () => {
   });
 };
 
+//校验是否具有应用使用权限
+
+export const getAppAccess = async (systemId:string) => {
+  return request('/centerSys/menu/checkKeygen', {
+    method: 'POST',
+    params:{systemId}
+  });
+};

+ 43 - 2
src/utils.ts

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2022-01-13 17:09:05
- * @LastEditTime: 2023-08-16 16:39:42
+ * @LastEditTime: 2023-11-07 19:42:22
  * @LastEditors: code4eat awesomedema@gmail.com
  * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  * @FilePath: /KC-MiddlePlatform/src/utils.js
@@ -9,6 +9,7 @@
 
 
 import axios from 'axios';
+import { Key } from 'react';
 
 export const randomString = (length: number) => {
   const chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_=-';
@@ -44,7 +45,6 @@ export const getValsFromTree = (data: TreeItemType[], key: string) => {
 export const searchTree = (treeData: TreeItemType[]) => {};
 
 
-
 export const downloadTemplateReq = (path:string) => {
 
   const userData = localStorage.getItem('userData');
@@ -142,6 +142,47 @@ export const findNodesBySomes = (node: TreeNode, keys: Set<string|number>,str:st
 
 
 
+//更改树结构集合的子集属性名
+
+export const renameChildListToChildren = (nodes: any[],key:string) => {
+  return nodes.map(node => {
+      // 创建当前节点的副本
+      const newNode = { ...node };
+
+      // 如果当前节点有 childList,则重命名为 children,并递归处理子节点
+      if (newNode[`${key}`]) {
+          newNode.children = renameChildListToChildren(newNode[`${key}`],key);
+      }
+
+      return newNode;
+  });
+}
+
+
+
+//获取目标节点的所有父节点,且以集合的方式返回
+
+export const  findParents = (tree: TreeNode[],targetNodeKeyName:string, targetNodeKeyVal:Key, path: TreeNode[] = []): TreeNode[] | null => {
+  for (const node of tree) {
+      // 如果找到目标节点,返回包含所有父节点的路径
+      if (node[`${targetNodeKeyName}`] === targetNodeKeyVal) {
+          return [...path, node];
+      }
+
+      // 如果当前节点有子节点,递归搜索子节点
+      if (node.children) {
+          const result = findParents(node.children,targetNodeKeyName, targetNodeKeyVal, [...path, node]);
+          if (result) {
+              return result;
+          }
+      }
+  }
+
+  // 如果在当前分支找不到目标节点,返回 null
+  return null;
+}
+
+