Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update white list optimize #261

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions web/src/api/white-list/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import {
IGetWhiteListsRequest,
IIWhiteListsDto,
IPostAddWhiteListsRequest,
IPostUpdateWhiteListsRequest,
IPostAddOrUpdateWhiteListsRequest,
IWhiteListsResponse,
} from "../../dtos/white-list";
import { Get, Post } from "../http-client";
Expand All @@ -16,22 +15,26 @@ export const GetWhiteLists = async (data: IGetWhiteListsRequest) => {
);
};

export const PostAddWhiteList = async (data: IPostAddWhiteListsRequest) => {
export const PostAddWhiteList = async (
data: IPostAddOrUpdateWhiteListsRequest
) => {
return await Post<IIWhiteListsDto>(
"/api/WeChat/work/meeting/whitelist/add",
"/api/WeChat/work/meeting/whitelists/add",
data
);
};

export const PostUpdateWhiteList = async (
data: IPostUpdateWhiteListsRequest
data: IPostAddOrUpdateWhiteListsRequest
) => {
return await Post<IIWhiteListsDto>(
"/api/WeChat/work/meeting/whitelist/update",
"/api/WeChat/work/meeting/whitelists/update",
data
);
};

export const PostDeleteWhiteList = async (id: string) => {
return await Post("/api/WeChat/work/meeting/whitelist/delete", { Ids: [id] });
return await Post("/api/WeChat/work/meeting/whitelist/delete", {
meetingCode: id,
});
};
18 changes: 9 additions & 9 deletions web/src/dtos/white-list/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ export interface IIWhiteListsDto {
createdDate: string;
}

export interface IWhiteListsResponse {
whitelist: IIWhiteListsDto[];
count: number;
export interface IMeetingGroupsDto {
meetingCode: string;
whitelists: IIWhiteListsDto;
}

export interface IPostAddWhiteListsRequest {
MeetingCode: string;
NotifyUserId: string;
export interface IWhiteListsResponse {
groups: IMeetingGroupsDto[];
count: number;
}

export interface IPostUpdateWhiteListsRequest
extends IPostAddWhiteListsRequest {
Id?: string;
export interface IPostAddOrUpdateWhiteListsRequest {
meetingCode: string;
notifyUserIds: string[];
}
5 changes: 4 additions & 1 deletion web/src/pages/meeting-list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ import ContentCopyIcon from "@mui/icons-material/ContentCopy";

const asyncTootip = (title: string, style: string) => {
return (
<Tooltip title={title} className={style}>
<Tooltip
title={<div style={{ maxHeight: 400, overflowY: "auto" }}>{title}</div>}
className={style}
>
<span>{title}</span>
</Tooltip>
);
Expand Down
21 changes: 11 additions & 10 deletions web/src/pages/meeting-white-list/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
PostDeleteWhiteList,
PostUpdateWhiteList,
} from "../../api/white-list";
import { IIWhiteListsDto } from "../../dtos/white-list";
import { IIWhiteListsDto, IMeetingGroupsDto } from "../../dtos/white-list";
import { IAddEditWhiteListDto, IWhiteListsRequest } from "./props";

const useAction = () => {
Expand Down Expand Up @@ -44,7 +44,7 @@ const useAction = () => {
Id: "",
});

const [rows, setRows] = useState<IIWhiteListsDto[]>([]);
const [rows, setRows] = useState<IMeetingGroupsDto[]>([]);

const handleCopyMeetingLink = (link: string) => {
if (link) {
Expand All @@ -65,8 +65,8 @@ const useAction = () => {

GetWhiteLists(data)
.then((res) => {
if (res && res.whitelist) {
setRows(res.whitelist);
if (res && res.groups) {
setRows(res.groups ?? []);
setWhiteListsRequest((prev) => ({ ...prev, rowCount: res.count }));
loadingAction.setFalse();
} else {
Expand All @@ -92,13 +92,14 @@ const useAction = () => {
: PostUpdateWhiteList;

setUpdateLoading(true);

const ids =
typeof addEditWhiteListDto.NotifyUserId !== "string"
? addEditWhiteListDto.NotifyUserId
: addEditWhiteListDto.NotifyUserId.split(",").filter((item) => item);
fun({
MeetingCode: addEditWhiteListDto.MeetingCode,
NotifyUserId: addEditWhiteListDto.NotifyUserId,
Id:
addEditWhiteListDto.type === "edit"
? addEditWhiteListDto.Id
: undefined,
meetingCode: addEditWhiteListDto.MeetingCode,
notifyUserIds: ids,
})
.then((res) => {
setAddEditWhiteListDto((prev) => ({
Expand Down
14 changes: 14 additions & 0 deletions web/src/pages/meeting-white-list/index.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,17 @@
font-size: 1.8rem;
cursor: pointer;
}

.userNameItem {
display: flex;
align-items: center;
width: 100%;
position: relative;
}

.addUsersTips {
margin-top: 0.5rem;
position: absolute;
font-size: 0.85rem;
color: #a19d9d;
}
98 changes: 63 additions & 35 deletions web/src/pages/meeting-white-list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
DialogTitle,
Snackbar,
TextField,
Tooltip,
} from "@mui/material";
import dayjs from "dayjs";
import CloseIcon from "@mui/icons-material/Close";
Expand All @@ -18,6 +19,7 @@ import { DataGrid, GridColDef } from "@mui/x-data-grid";
import useAction from "./hook";

import style from "./index.module.scss";
import { IIWhiteListsDto } from "../../dtos/white-list";

const MeetingWhiteList = () => {
const {
Expand Down Expand Up @@ -57,24 +59,41 @@ const MeetingWhiteList = () => {
minWidth: 100,
align: "center",
headerAlign: "center",
},

{
field: "createdDate",
headerName: "创建时间",
align: "center",
headerAlign: "center",
flex: 1,
minWidth: 160,
renderCell: (params) => {
let ids = "";
params.row.whitelists?.map((item: IIWhiteListsDto, index: number) => {
ids +=
item.notifyUserId +
(params.row.whitelists.length > 0 &&
index !== params.row.whitelists.length - 1
? ","
: "");
});

return (
<span>
{dayjs(params.row.createdDate).format("YYYY-MM-DD HH:mm:ss")}
</span>
<Tooltip
title={
<div style={{ maxHeight: 400, overflowY: "auto" }}>{ids}</div>
}
>
<div>
{params.row.whitelists?.map(
(item: IIWhiteListsDto, index: number) => {
return (
<span key={item.id}>
{item.notifyUserId}
{params.row.whitelists.length > 0 &&
index !== params.row.whitelists.length - 1 &&
","}
</span>
);
}
)}
</div>
</Tooltip>
);
},
},

{
field: "fun",
headerName: "操作",
Expand All @@ -88,13 +107,16 @@ const MeetingWhiteList = () => {
size="small"
style={{ marginRight: 16 }}
onClick={() => {
const ids = params.row.whitelists?.map(
(item: IIWhiteListsDto) => item.notifyUserId
);
setOpenAddWhiteList(true);
setAddEditWhiteListDto((prev) => ({
...prev,
MeetingCode: params.row.meetingCode,
NotifyUserId: params.row.notifyUserId,
NotifyUserId: ids,
type: "edit",
Id: params.row.id,
Id: params.row.meetingCode,
}));
}}
>
Expand All @@ -107,7 +129,7 @@ const MeetingWhiteList = () => {
confirmDialogAction.setTrue();
setAddEditWhiteListDto((prev) => ({
...prev,
Id: params.row.id,
Id: params.row.meetingCode,
}));
}}
>
Expand Down Expand Up @@ -168,6 +190,7 @@ const MeetingWhiteList = () => {
loading={loading}
paginationMode="server"
rowHeight={56}
getRowId={(row) => row.meetingCode}
style={{ height: 700, width: "95%" }}
rowCount={whiteListsRequest.rowCount}
onPageChange={(value) =>
Expand Down Expand Up @@ -226,24 +249,29 @@ const MeetingWhiteList = () => {
/>
</div>
</div>
<div className={style.fromItem}>
<div className={style.title}>用户企微名</div>
<div className={style.widthFull}>
<TextField
id="filled-start-adornment"
placeholder="用户企微名"
autoComplete="off"
className={style.input}
sx={{ width: "100%" }}
variant="outlined"
value={addEditWhiteListDto?.NotifyUserId}
onChange={(e) =>
setAddEditWhiteListDto((prev) => ({
...prev,
NotifyUserId: e.target.value,
}))
}
/>
<div className={style.widthFull}>
<div className={style.userNameItem}>
<div className={style.title}>用户企微名</div>
<div className={style.widthFull}>
<TextField
id="filled-start-adornment"
placeholder="用户企微名"
autoComplete="off"
className={style.input}
sx={{ width: "100%" }}
variant="outlined"
value={addEditWhiteListDto?.NotifyUserId}
onChange={(e) =>
setAddEditWhiteListDto((prev) => ({
...prev,
NotifyUserId: e.target.value,
}))
}
/>
<div className={style.addUsersTips}>
使用英文分隔符以添加多个用户到白名单(如:a,b)
</div>
</div>
</div>
</div>
</DialogContent>
Expand Down Expand Up @@ -277,7 +305,7 @@ const MeetingWhiteList = () => {
id="alert-dialog-title-cancel"
sx={{ backgroundColor: "#f2f3f4" }}
>
️提示
️ 提示
</DialogTitle>
<DialogContent sx={{ backgroundColor: "#f2f3f4" }}>
<DialogContentText id="alert-dialog-description-cancel">
Expand Down