Merge pull request #39 from maggieyyy/main

fix: english version & tags id bugs
This commit is contained in:
maggieyyy
2024-09-14 14:38:08 +08:00
committed by GitHub
13 changed files with 104 additions and 63 deletions
@@ -3,8 +3,10 @@ import { GetProp, TransferProps, TreeDataNode, theme, Transfer, Tree, Spin } fro
import { DataNode, TreeProps } from "antd/es/tree";
import { Ref, forwardRef, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
import { ApartmentOutlined, LoadingOutlined, UserOutlined } from "@ant-design/icons";
import { debounce } from "lodash-es";
import { cloneDeep, debounce } from "lodash-es";
import { ColumnsType } from "antd/es/table";
import { $t } from "@common/locales";
import { useGlobalContext } from "@common/contexts/GlobalStateContext";
type TransferItem = GetProp<TransferProps, 'dataSource'>[number];
@@ -138,7 +140,7 @@ const TransferTree = (props)=>{
const [dataSource, setDataSource] = useState<DataNode[] >([])
const parentRef = useRef<HTMLDivElement>(null);
const [loading, setLoading] = useState<boolean>(false)
const {state} = useGlobalContext()
useEffect(()=>{
setTargetKeys(disabledData)
@@ -158,7 +160,7 @@ const TransferTree = (props)=>{
const transferDataSource: TransferItem[] = useMemo(()=>{
function flatten(list: TreeDataNode[] = [], res:TransferItem[]) {
list.forEach((item) => {
res.push(item as TransferItem);
res.push({...item, title:item.title === '所有成员' ? $t((item as unknown as {title:string}).title):item.title }as TransferItem);
flatten(item.children,res);
});
}
@@ -166,9 +168,17 @@ const TransferTree = (props)=>{
flatten(dataSource,res);
return res
},[
dataSource
dataSource, state.language
])
const translatedDataSource = useMemo(()=>dataSource.map((item)=>({
...item,
name:item.name === '所有成员' ? $t((item as unknown as {name:string}).name):item.name,
})),[dataSource, state.language])
let memo: Record<string, boolean> = {};
const handlerFilterOption = (inputValue: string, item: any, parentResult: boolean = false, childrenSet: Set<string> = new Set()): boolean => {
@@ -241,7 +251,7 @@ useEffect(() => {
>
{({ direction, onItemSelect, selectedKeys,onItemSelectAll ,filteredItems}) => {
const treeProps = {
dataSource, direction, onItemSelect, selectedKeys,onItemSelectAll ,filteredItems,token,tableHeight,targetKeys,disabledData
dataSource:translatedDataSource, direction, onItemSelect, selectedKeys,onItemSelectAll ,filteredItems,token,tableHeight,targetKeys,disabledData
}
if (direction === 'left') {
const checkedKey = [...selectedKeys, ...targetKeys as string[]];
@@ -276,7 +276,8 @@ export const PUBLISH_APPROVAL_VERSION_INNER_TABLE_COLUMN : PageProColumns<Publis
{
title:('版本说明'),
dataIndex: 'remark',
ellipsis:true
ellipsis:true,
width:160,
},
{
title:('创建版本时间'),
@@ -298,7 +299,7 @@ export const PUBLISH_APPROVAL_VERSION_INNER_TABLE_COLUMN : PageProColumns<Publis
title:('创建人'),
dataIndex: ['creator','name'],
ellipsis: true,
width:88,
width:120,
filters: true,
onFilter: true,
valueType: 'select',
@@ -323,17 +324,19 @@ export const PUBLISH_APPROVAL_RECORD_INNER_TABLE_COLUMN : PageProColumns<Publish
{
title:('版本号'),
dataIndex: 'version',
ellipsis:true
ellipsis:true,
width:130,
},
{
title:('版本说明'),
dataIndex: 'remark',
ellipsis:true
ellipsis:true,
width:160,
},
{
title:('发布状态'),
dataIndex: 'status',
ellipsis:true
ellipsis:true,
},
{
title:('备注'),
@@ -673,5 +673,10 @@
"K71753476": "Allow Access",
"K597435c5": "Runtime",
"Kde9d6e8e": "When interception is enabled, the gateway will block all traffic of this API path.",
"K4758140d": "Routes"
"K4758140d": "Routes",
"K7c97c5df": "Unassign Department",
"K1362a512": "Disable Member",
"K6e1289b1": "Enable Member",
"K1f4b5385": "Delete Member",
"Kf85b83a0": "Enter URL to Search Route"
}
@@ -1,3 +1,7 @@
{
"K4758140d": "路由列表"
"K7c97c5df": "移出当前部门",
"K1362a512": "禁用成员",
"K6e1289b1": "启用成员",
"K1f4b5385": "删除成员",
"Kf85b83a0": "输入 URL 查找路由"
}
@@ -1,3 +1,7 @@
{
"K4758140d": "路由列表"
"K7c97c5df": "移出当前部门",
"K1362a512": "禁用成员",
"K6e1289b1": "启用成员",
"K1f4b5385": "删除成员",
"Kf85b83a0": "输入 URL 查找路由"
}
@@ -29,7 +29,7 @@ export const PARTITION_CERT_TABLE_COLUMNS: PageProColumns<PartitionCertTableList
title:('过期日期'),
ellipsis: true,
dataIndex: 'notAfter',
width:100,
width:140,
renderText: (value: string) => value ? value.split(' ')?.[0] : '-',
sorter: (a,b)=> {
return a.notAfter.localeCompare(b.notAfter)
@@ -31,6 +31,7 @@ const AddToDepartment = forwardRef<AddToDepartmentHandle,AddToDepartmentProps>((
const { message } = App.useApp()
const [expandedKeys, setExpandedKeys] = useState<string[]>([])
const {fetchData} = useFetch()
const { state} = useGlobalContext()
const save:()=>Promise<boolean | string> = ()=>{
return new Promise((resolve, reject)=>{
fetchData<BasicResponse<null>>('user/department/member',{method:'POST',eoBody:({userIds:selectedUserIds,departmentIds:selectedKeys}),eoTransformKeys:['departmentIds','userIds']}).then(response=>{
@@ -71,6 +72,13 @@ const AddToDepartment = forwardRef<AddToDepartmentHandle,AddToDepartmentProps>((
})
}
const translatedTreeData = useMemo(()=>
treeData?.map((x:DataNode)=>({...x,
name:$t((x as unknown as {name:string}).name),
checkable:false,
children:x.children?.map((y)=>({...y,checkable:false}))
})),[state.language,treeData])
const onCheck: TreeProps['onCheck'] = (checkedKeys:string[]) => {
setSelectedKeys(checkedKeys.checked)
@@ -94,10 +102,10 @@ const AddToDepartment = forwardRef<AddToDepartmentHandle,AddToDepartmentProps>((
selectable={false}
onCheck={onCheck}
onExpand={(expandedKeys:string[])=>{setExpandedKeys(expandedKeys)}}
treeData={treeData}
treeData={translatedTreeData}
selectedKeys={[selectedKeys]}
expandedKeys={expandedKeys}
fieldNames={{title:$t('name'),key:'id',children:'children'}}
fieldNames={{title:'name',key:'id',children:'children'}}
/>
</div>
</div>)
@@ -386,11 +394,11 @@ const MemberList = ()=>{
onRowClick={handleRowClick}
tableClickAccess="system.organization.member.edit"
afterNewBtn={[
selectedRowKeys.length > 0 && memberGroupId &&<WithPermission key="removeFromDepPermission" access="system.organization.member.edit"><Button className="mr-btnbase" key="removeFromDep" onClick={()=>handleMemberAction('removeFromDep').then((res)=>{if(res === true){refreshGroup && refreshGroup();manualReloadTable()}})}></Button></WithPermission>,
selectedRowKeys.length > 0 && memberGroupId &&<WithPermission key="addToDepPermission" access="system.organization.member.edit"><Button className="mr-btnbase" key="addToDep" onClick={()=>openModal('addToDep')}></Button></WithPermission>,
selectedRowKeys.length > 0 && memberGroupId !== 'disable' &&<WithPermission key="blockedPermission" access="system.organization.member.block"><Button className="mr-btnbase" key="blocked" onClick={()=>handleMemberAction('blocked').then((res)=>{if(res === true){refreshGroup && refreshGroup();manualReloadTable()}})}></Button></WithPermission>,
selectedRowKeys.length > 0 && <WithPermission key="activatePermission" access="system.organization.member.block"><Button className="mr-btnbase" key="activate" onClick={()=>handleMemberAction('activate').then((res)=>{if(res === true){refreshGroup && refreshGroup();manualReloadTable()}})}></Button></WithPermission>,
selectedRowKeys.length > 0 &&<WithPermission key="deletePermission" access="system.organization.member.delete"><Button className="mr-btnbase" key="delete" onClick={()=>openModal('delete')}></Button></WithPermission>,
selectedRowKeys.length > 0 && memberGroupId &&<WithPermission key="removeFromDepPermission" access="system.organization.member.edit"><Button className="mr-btnbase" key="removeFromDep" onClick={()=>handleMemberAction('removeFromDep').then((res)=>{if(res === true){refreshGroup && refreshGroup();manualReloadTable()}})}>{$t('移出当前部门')}</Button></WithPermission>,
selectedRowKeys.length > 0 && memberGroupId &&<WithPermission key="addToDepPermission" access="system.organization.member.edit"><Button className="mr-btnbase" key="addToDep" onClick={()=>openModal('addToDep')}>{$t('加入部门')}</Button></WithPermission>,
selectedRowKeys.length > 0 && memberGroupId !== 'disable' &&<WithPermission key="blockedPermission" access="system.organization.member.block"><Button className="mr-btnbase" key="blocked" onClick={()=>handleMemberAction('blocked').then((res)=>{if(res === true){refreshGroup && refreshGroup();manualReloadTable()}})}>{$t('禁用成员')}</Button></WithPermission>,
selectedRowKeys.length > 0 && <WithPermission key="activatePermission" access="system.organization.member.block"><Button className="mr-btnbase" key="activate" onClick={()=>handleMemberAction('activate').then((res)=>{if(res === true){refreshGroup && refreshGroup();manualReloadTable()}})}>{$t('启用成员')}</Button></WithPermission>,
selectedRowKeys.length > 0 &&<WithPermission key="deletePermission" access="system.organization.member.delete"><Button className="mr-btnbase" key="delete" onClick={()=>openModal('delete')}>{$t('删除成员')}</Button></WithPermission>,
]}
onSearchWordChange={(e) => {
setSearchWord(e.target.value)
@@ -1,19 +1,22 @@
import { FolderOpenOutlined, FolderOutlined } from "@ant-design/icons"
import { App, TreeProps, Alert, Tree } from "antd"
import { forwardRef, useState, useImperativeHandle, useEffect } from "react"
import { forwardRef, useState, useImperativeHandle, useEffect, useMemo } from "react"
import { BasicResponse, RESPONSE_TIPS, STATUS_CODE } from "@common/const/const"
import { AddToDepartmentHandle, AddToDepartmentProps, DepartmentListItem } from "../../../const/member/type"
import { useFetch } from "@common/hooks/http"
import {v4 as uuidv4} from 'uuid'
import { $t } from "@common/locales"
import { useGlobalContext } from "@common/contexts/GlobalStateContext"
import { DataNode } from "antd/es/tree"
const AddToDepartmentModal = forwardRef<AddToDepartmentHandle,AddToDepartmentProps>((props,ref)=>{
const {selectedUserIds} = props
const [selectedKeys, setSelectedKeys] = useState<string[]>([])
const [treeData,setTreeData] = useState<unknown[]>()
const [treeData,setTreeData] = useState<DataNode[]>()
const { message } = App.useApp()
const [expandedKeys, setExpandedKeys] = useState<string[]>([])
const {fetchData} = useFetch()
const {state} = useGlobalContext()
const save:()=>Promise<boolean | string> = ()=>{
return new Promise((resolve, reject)=>{
fetchData<BasicResponse<null>>('user/department/member',{method:'POST',eoBody:({userIds:selectedUserIds,departmentIds:selectedKeys}),eoTransformKeys:['departmentIds','userIds']}).then(response=>{
@@ -54,6 +57,13 @@ const AddToDepartmentModal = forwardRef<AddToDepartmentHandle,AddToDepartmentPro
})
}
const translatedTreeData = useMemo(()=>
treeData?.map((x:DataNode)=>({...x,
name:$t((x as unknown as {name:string}).name),
checkable:false,
children:x.children?.map((y)=>({...y,checkable:false}))
})),[state.language,treeData])
const onCheck: TreeProps['onCheck'] = (checkedKeys:string[]) => {
setSelectedKeys(checkedKeys.checked)
@@ -77,10 +87,10 @@ const AddToDepartmentModal = forwardRef<AddToDepartmentHandle,AddToDepartmentPro
selectable={false}
onCheck={onCheck}
onExpand={(expandedKeys:string[])=>{setExpandedKeys(expandedKeys)}}
treeData={treeData}
treeData={translatedTreeData}
selectedKeys={[selectedKeys]}
expandedKeys={expandedKeys}
fieldNames={{title:$t('name'),key:'id',children:'children'}}
fieldNames={{title:'name',key:'id',children:'children'}}
/>
</div>
</div>)
@@ -100,7 +100,7 @@ const SystemConfig = forwardRef<SystemConfigHandle>((_,ref) => {
const {code,data,msg} = response
if(code === STATUS_CODE.SUCCESS){
setTagOptionList(data.tags?.map((x:EntityItem)=>{return {
label:x.name, value:x.id
label:x.name, value:x.name
}})||[])
setServiceClassifyOptionList(data.catalogues)
@@ -121,7 +121,7 @@ const SystemConfig = forwardRef<SystemConfigHandle>((_,ref) => {
...data.service,
team:data.service.team.id,
catalogue:data.service.catalogue?.id,
tags:data.service.tags?.map((x:EntityItem)=>x.id),
tags:data.service.tags?.map((x:EntityItem)=>x.name),
logoFile:[
{
uid: '-1', // 文件唯一标识
@@ -52,7 +52,7 @@ const TeamInsideMember:FC = ()=>{
const [modalVisible, setModalVisible] = useState<boolean>(false)
const [addMemberBtnDisabled, setAddMemberBtnDisabled] = useState<boolean>(true)
const [allMemberSelectedDepartIds, setAllMemberSelectedDepartIds] = useState<string[]>([])
const [columns,setColumns] = useState<PageProColumns<TeamMemberTableListItem>[]>([])
const [roleList, setRoleList] = useState<EntityItem[]>([])
const operation:PageProColumns<TeamMemberTableListItem>[] =[
{
@@ -230,36 +230,10 @@ const TeamInsideMember:FC = ()=>{
}
const getRoleList = ()=>{
fetchData<BasicResponse<{roles:Array<{id:string,name:string}>}>>('simple/roles', {method: 'GET', eoParams: {group:'team'}}).then(response => {
fetchData<BasicResponse<{roles:EntityItem[]}>>('simple/roles', {method: 'GET', eoParams: {group:'team'}}).then(response => {
const {code, data,msg} = response
if (code === STATUS_CODE.SUCCESS) {
const newCol = [...TEAM_MEMBER_TABLE_COLUMNS]
for(const col of newCol){
//console.log(col)
if(col.dataIndex === 'roles'){
col.render = (_,entity)=>(
<WithPermission access="team.team.member.edit">
<Select
className="w-full"
mode="multiple"
value={entity.roles?.map((x:EntityItem)=>x.id)}
options={data.roles?.map((x:{id:string,name:string})=>({label:x.name, value:x.id}))}
onChange={(value)=>{
changeMemberInfo(value,entity ).then((res)=>{
if(res) manualReloadTable()
})
}}
/>
</WithPermission>
)
col.filters = data.roles?.map((x:{id:string,name:string})=>({text:x.name, value:x.id}))
col.onFilter = (value: unknown, record:TeamMemberTableListItem) =>{
return record.roles ? record.roles?.map((x)=>x.id).indexOf(value as string) !== -1 : false;}
}
}
setColumns(newCol)
setRoleList(data.roles)
return
} else {
message.error(msg || $t(RESPONSE_TIPS.error))
@@ -268,10 +242,34 @@ const TeamInsideMember:FC = ()=>{
}
const translatedCol = useMemo(()=>{
const res = columns?.map(x=>{
const res = TEAM_MEMBER_TABLE_COLUMNS?.map(x=>{
if(x.dataIndex === 'roles'){
return {
...x,
title: typeof x.title === 'string' ? $t(x.title as string) : x.title,
render: (_,entity)=>(
<WithPermission access="team.team.member.edit">
<Select
className="w-full"
mode="multiple"
value={entity.roles?.map((x:EntityItem)=>x.id)}
options={roleList?.map((x:{id:string,name:string})=>({label:$t(x.name), value:x.id}))}
onChange={(value)=>{
changeMemberInfo(value,entity ).then((res)=>{
if(res) manualReloadTable()
})
}}
/>
</WithPermission>
),
filters:roleList?.map((x:{id:string,name:string})=>({text:x.name, value:x.id})),
onFilter:(value: unknown, record:TeamMemberTableListItem) =>{
return record.roles ? record.roles?.map((x)=>x.id).indexOf(value as string) !== -1 : false;}
}
}
return({...x, title: typeof x.title === 'string' ? $t(x.title as string) : x.title}) })
return res
},[columns, state.language])
},[ state.language,roleList])
useEffect(() => {
getRoleList()
@@ -32,7 +32,7 @@ const TeamInsidePage:FC = ()=> {
};
const TEAM_INSIDE_MENU_ITEMS = useMemo(()=> [
getItem(('管理'), 'grp', null,
getItem($t('管理'), 'grp', null,
[
getItem(<Link to="member">{$t('成员')}</Link>, 'member',undefined, undefined, undefined,'team.team.member.view'),
getItem(<Link to="setting">{$t('设置')}</Link>, 'setting',undefined,undefined,undefined,'team.team.team.view')],
@@ -85,7 +85,6 @@ const TeamList:FC = ()=>{
};
const openModal = async (type:'add'|'edit'|'delete',entity?:TeamTableListItem)=>{
//console.log(type,entity)
let title:string = ''
let content:string | React.ReactNode= ''
switch (type){
@@ -62,8 +62,8 @@ const MonitorPieGraph: FC<PieGraphProps> = ({ className,title, pieData, labelNam
},
textStyle: {
rich: {
title: { fontSize: 14, color: '#666666', lineHeight: 22, padding: [8, 0, 8, 0] },
percent: { fontSize: 14, color: '#666666', width: 60, lineHeight: 22, align: 'right', padding: [8, 0, 8, 8] }
title: { fontSize: 14, color: '#666666',lineHeight: 22, width:state.language === 'en' ? 134 :70,padding: [8, 0, 8, 0] },
percent: { fontSize: 14, color: '#666666', width: 60, lineHeight: 22, align:'right', padding: [8, 0, 8, 8] }
}
}
},
@@ -79,7 +79,7 @@ const MonitorPieGraph: FC<PieGraphProps> = ({ className,title, pieData, labelNam
label: {
show: true,
position: 'center',
formatter: '{text|' + $t(labelName) + '}\n{value|' + labelValue + '}',
formatter: '{text|' + $t(labelName) + '}{value|' + labelValue + '}',
rich: {
text: { fontSize: 14, color: '#666666', lineHeight: 22, padding: [0, 0, 6, 0] },
value: { fontSize: 20, color: '#333333', lineHeight: 32, padding: [0, 0, 6, 0] },