mirror of
https://github.com/PlayEdu/backend
synced 2025-06-28 04:02:45 +08:00
commit
f07741892a
@ -54,3 +54,7 @@ export function dropDiffClass(id: number, parent_id: number, ids: number[]) {
|
||||
export function checkDestroy(id: number) {
|
||||
return client.get(`/backend/v1/department/${id}/destroy`, {});
|
||||
}
|
||||
|
||||
export function ldapSync() {
|
||||
return client.post(`/backend/v1/department/ldap-sync`, {});
|
||||
}
|
||||
|
@ -37,16 +37,16 @@ const items = [
|
||||
<i className="iconfont icon-icon-category" />,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
"resource-category-menu"
|
||||
),
|
||||
getItem(
|
||||
"资源管理",
|
||||
"resource",
|
||||
<i className="iconfont icon-icon-file" />,
|
||||
[
|
||||
getItem("视频", "/videos", null, null, null, null),
|
||||
getItem("图片", "/images", null, null, null, null),
|
||||
getItem("课件", "/courseware", null, null, null, null),
|
||||
getItem("视频", "/videos", null, null, null, "resource-menu"),
|
||||
getItem("图片", "/images", null, null, null, "resource-menu"),
|
||||
getItem("课件", "/courseware", null, null, null, "resource-menu"),
|
||||
],
|
||||
null,
|
||||
null
|
||||
@ -92,7 +92,6 @@ const items = [
|
||||
"admin-user-index"
|
||||
),
|
||||
getItem("管理日志", "/system/adminlog", null, null, null, "admin-log"),
|
||||
// getItem("角色配置", "/system/adminroles", null, null, null, null),
|
||||
],
|
||||
null,
|
||||
null
|
||||
@ -120,6 +119,7 @@ export const LeftMenu: React.FC = () => {
|
||||
}
|
||||
return [];
|
||||
};
|
||||
|
||||
const openKeyMerge = (pathname: string): string[] => {
|
||||
let newOpenKeys = hit(pathname);
|
||||
for (let i = 0; i < openKeys.length; i++) {
|
||||
@ -166,8 +166,14 @@ export const LeftMenu: React.FC = () => {
|
||||
|
||||
for (let i in items) {
|
||||
let menuItem = items[i];
|
||||
if (!menuItem.children) {
|
||||
// 一级菜单不做权限控制
|
||||
// 一级菜单=>没有子菜单&配置了权限
|
||||
if (menuItem.children === null) {
|
||||
if (
|
||||
menuItem.permission !== null &&
|
||||
typeof permissions[menuItem.permission] === "undefined"
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
menus.push(menuItem);
|
||||
continue;
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ interface PropInterface {
|
||||
p: string;
|
||||
class: string;
|
||||
icon: any;
|
||||
onClick: () => void;
|
||||
onClick?: () => void;
|
||||
disabled: any;
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ export const PerButton = (props: PropInterface) => {
|
||||
danger
|
||||
icon={props.icon}
|
||||
onClick={() => {
|
||||
props.onClick();
|
||||
props.onClick && props.onClick();
|
||||
}}
|
||||
disabled={props.disabled}
|
||||
>
|
||||
@ -43,7 +43,7 @@ export const PerButton = (props: PropInterface) => {
|
||||
type={props.type}
|
||||
icon={props.icon}
|
||||
onClick={() => {
|
||||
props.onClick();
|
||||
props.onClick && props.onClick();
|
||||
}}
|
||||
disabled={props.disabled}
|
||||
>
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Tree } from "antd";
|
||||
import { useState, useEffect } from "react";
|
||||
import { resourceCategory } from "../../api/index";
|
||||
import { useSelector } from "react-redux";
|
||||
|
||||
interface Option {
|
||||
key: string | number;
|
||||
@ -17,8 +17,10 @@ interface PropInterface {
|
||||
|
||||
export const TreeCategory = (props: PropInterface) => {
|
||||
const [treeData, setTreeData] = useState<any>([]);
|
||||
const [loading, setLoading] = useState<boolean>(true);
|
||||
const [selectKey, setSelectKey] = useState<number[]>([]);
|
||||
const resourceCategories = useSelector(
|
||||
(state: any) => state.systemConfig.value.resourceCategories
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (props.selected && props.selected.length > 0) {
|
||||
@ -27,21 +29,17 @@ export const TreeCategory = (props: PropInterface) => {
|
||||
}, [props.selected]);
|
||||
|
||||
useEffect(() => {
|
||||
resourceCategory.resourceCategoryList().then((res: any) => {
|
||||
const categories: CategoriesBoxModel = res.data.categories;
|
||||
if (JSON.stringify(categories) !== "{}") {
|
||||
const new_arr: Option[] = checkArr(categories, 0);
|
||||
if (props.type === "no-cate") {
|
||||
new_arr.unshift({
|
||||
key: 0,
|
||||
title: <span className="tree-title-elli">未分类</span>,
|
||||
});
|
||||
}
|
||||
|
||||
setTreeData(new_arr);
|
||||
if (JSON.stringify(resourceCategories) !== "{}") {
|
||||
const new_arr: Option[] = checkArr(resourceCategories, 0);
|
||||
if (props.type === "no-cate") {
|
||||
new_arr.unshift({
|
||||
key: 0,
|
||||
title: <span className="tree-title-elli">未分类</span>,
|
||||
});
|
||||
}
|
||||
});
|
||||
}, []);
|
||||
setTreeData(new_arr);
|
||||
}
|
||||
}, [resourceCategories]);
|
||||
|
||||
const checkArr = (categories: CategoriesBoxModel, id: number) => {
|
||||
const arr = [];
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { Button, Input, message, Tree } from "antd";
|
||||
import { Tree } from "antd";
|
||||
import { useState, useEffect } from "react";
|
||||
import { department } from "../../api/index";
|
||||
import { useSelector } from "react-redux";
|
||||
|
||||
interface Option {
|
||||
key: string | number;
|
||||
@ -9,19 +10,21 @@ interface Option {
|
||||
}
|
||||
|
||||
interface PropInterface {
|
||||
type: string;
|
||||
text: string;
|
||||
refresh: boolean;
|
||||
showNum: boolean;
|
||||
selected: any;
|
||||
depUserCount?: KeyNumberObject;
|
||||
userCount?: number;
|
||||
onUpdate: (keys: any, title: any) => void;
|
||||
}
|
||||
|
||||
export const TreeDepartment = (props: PropInterface) => {
|
||||
const [treeData, setTreeData] = useState<any>([]);
|
||||
const [loading, setLoading] = useState<boolean>(true);
|
||||
const [selectKey, setSelectKey] = useState<number[]>([]);
|
||||
const [userTotal, setUserTotal] = useState(0);
|
||||
// 本地缓存
|
||||
const localDepartments = useSelector(
|
||||
(state: any) => state.systemConfig.value.departments
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (props.selected && props.selected.length > 0) {
|
||||
@ -30,32 +33,25 @@ export const TreeDepartment = (props: PropInterface) => {
|
||||
}, [props.selected]);
|
||||
|
||||
useEffect(() => {
|
||||
setLoading(true);
|
||||
department.departmentList().then((res: any) => {
|
||||
const departments: DepartmentsBoxModel = res.data.departments;
|
||||
const departCount: DepIdsModel = res.data.dep_user_count;
|
||||
setUserTotal(res.data.user_total);
|
||||
if (JSON.stringify(departments) !== "{}") {
|
||||
if (props.showNum) {
|
||||
const new_arr: any[] = checkNewArr(departments, 0, departCount);
|
||||
setTreeData(new_arr);
|
||||
} else {
|
||||
const new_arr: any[] = checkArr(departments, 0);
|
||||
setTreeData(new_arr);
|
||||
}
|
||||
if (JSON.stringify(localDepartments) !== "{}") {
|
||||
let data: any[] = [];
|
||||
if (props.depUserCount) {
|
||||
data = checkNewArr(localDepartments, 0, props.depUserCount);
|
||||
} else {
|
||||
const new_arr: Option[] = [
|
||||
{
|
||||
key: "",
|
||||
title: "全部",
|
||||
children: [],
|
||||
},
|
||||
];
|
||||
setTreeData(new_arr);
|
||||
data = checkArr(localDepartments, 0);
|
||||
}
|
||||
setLoading(false);
|
||||
});
|
||||
}, [props.refresh]);
|
||||
setTreeData(data);
|
||||
} else {
|
||||
const data: Option[] = [
|
||||
{
|
||||
key: "",
|
||||
title: "全部",
|
||||
children: [],
|
||||
},
|
||||
];
|
||||
setTreeData(data);
|
||||
}
|
||||
}, [localDepartments, props.depUserCount]);
|
||||
|
||||
const checkNewArr = (
|
||||
departments: DepartmentsBoxModel,
|
||||
@ -157,7 +153,7 @@ export const TreeDepartment = (props: PropInterface) => {
|
||||
onClick={() => onSelect([], "")}
|
||||
>
|
||||
全部{props.text}
|
||||
{props.showNum && userTotal ? "(" + userTotal + ")" : ""}
|
||||
{props.showNum && props.userCount ? "(" + props.userCount + ")" : ""}
|
||||
</div>
|
||||
{treeData.length > 0 && (
|
||||
<Tree
|
||||
|
@ -159,15 +159,7 @@ export const UploadVideoSub = (props: PropsInterface) => {
|
||||
<>
|
||||
<Row style={{ width: 752, minHeight: 520 }}>
|
||||
<Col span={7}>
|
||||
{init && (
|
||||
<div className="float-left text-center mt-30">
|
||||
<Spin></Spin>
|
||||
</div>
|
||||
)}
|
||||
<div
|
||||
className="float-left"
|
||||
style={{ display: init ? "none" : "block" }}
|
||||
>
|
||||
<div className="float-left">
|
||||
<TreeCategory
|
||||
selected={[]}
|
||||
type="no-cate"
|
||||
|
@ -1,5 +1,3 @@
|
||||
@import "./assets/iconfont/iconfont.css";
|
||||
|
||||
@primaryColor: #ff4d4f;
|
||||
|
||||
body {
|
||||
|
@ -1,4 +1,5 @@
|
||||
import ReactDOM from "react-dom/client";
|
||||
import "./assets/iconfont/iconfont.css";
|
||||
import "./index.less";
|
||||
import App from "./App";
|
||||
import reportWebVitals from "./reportWebVitals";
|
||||
|
@ -20,7 +20,7 @@ import {
|
||||
import type { MenuProps } from "antd";
|
||||
import type { ColumnsType } from "antd/es/table";
|
||||
import { dateFormat } from "../../utils/index";
|
||||
import { useNavigate, useLocation } from "react-router-dom";
|
||||
import { useNavigate, useLocation, useSearchParams } from "react-router-dom";
|
||||
import { TreeDepartment, TreeCategory, PerButton } from "../../compenents";
|
||||
import type { TabsProps } from "antd";
|
||||
import { CourseCreate } from "./compenents/create";
|
||||
@ -42,17 +42,30 @@ interface DataType {
|
||||
title: string;
|
||||
}
|
||||
|
||||
interface LocalSearchParamsInterface {
|
||||
page?: number;
|
||||
size?: number;
|
||||
title?: string;
|
||||
}
|
||||
|
||||
const CoursePage = () => {
|
||||
const result = new URLSearchParams(useLocation().search);
|
||||
|
||||
const [searchParams, setSearchParams] = useSearchParams({
|
||||
page: "1",
|
||||
size: "10",
|
||||
title: "",
|
||||
});
|
||||
const page = parseInt(searchParams.get("page") || "1");
|
||||
const size = parseInt(searchParams.get("size") || "10");
|
||||
const title = searchParams.get("title");
|
||||
|
||||
const navigate = useNavigate();
|
||||
const [list, setList] = useState<DataType[]>([]);
|
||||
const [refresh, setRefresh] = useState(false);
|
||||
const [page, setPage] = useState(1);
|
||||
const [size, setSize] = useState(10);
|
||||
const [total, setTotal] = useState(0);
|
||||
const [refresh, setRefresh] = useState(false);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [category_ids, setCategoryIds] = useState<number[]>([]);
|
||||
const [title, setTitle] = useState("");
|
||||
const [dep_ids, setDepIds] = useState<number[]>([]);
|
||||
const [selLabel, setLabel] = useState<string>(
|
||||
result.get("label") ? String(result.get("label")) : "全部分类"
|
||||
@ -105,7 +118,9 @@ const CoursePage = () => {
|
||||
type=""
|
||||
text={"分类"}
|
||||
onUpdate={(keys: any, title: any) => {
|
||||
setPage(1);
|
||||
resetLocalSearchParams({
|
||||
page: 1,
|
||||
});
|
||||
setCategoryIds(keys);
|
||||
if (typeof title === "string") {
|
||||
setLabel(title);
|
||||
@ -124,12 +139,12 @@ const CoursePage = () => {
|
||||
<div className="float-left">
|
||||
<TreeDepartment
|
||||
selected={dep_ids}
|
||||
refresh={refresh}
|
||||
showNum={false}
|
||||
type="no-course"
|
||||
text={"部门"}
|
||||
onUpdate={(keys: any, title: any) => {
|
||||
setPage(1);
|
||||
resetLocalSearchParams({
|
||||
page: 1,
|
||||
});
|
||||
setDepIds(keys);
|
||||
setDepLabel(title);
|
||||
}}
|
||||
@ -346,7 +361,7 @@ const CoursePage = () => {
|
||||
depIds = dep_ids.join(",");
|
||||
}
|
||||
course
|
||||
.courseList(page, size, "", "", title, depIds, categoryIds)
|
||||
.courseList(page, size, "", "", title ? title : "", depIds, categoryIds)
|
||||
.then((res: any) => {
|
||||
setTotal(res.data.total);
|
||||
setList(res.data.data);
|
||||
@ -362,10 +377,12 @@ const CoursePage = () => {
|
||||
};
|
||||
// 重置列表
|
||||
const resetList = () => {
|
||||
setPage(1);
|
||||
setSize(10);
|
||||
resetLocalSearchParams({
|
||||
page: 1,
|
||||
size: 10,
|
||||
title: "",
|
||||
});
|
||||
setList([]);
|
||||
setTitle("");
|
||||
setRefresh(!refresh);
|
||||
};
|
||||
|
||||
@ -379,8 +396,28 @@ const CoursePage = () => {
|
||||
};
|
||||
|
||||
const handlePageChange = (page: number, pageSize: number) => {
|
||||
setPage(page);
|
||||
setSize(pageSize);
|
||||
resetLocalSearchParams({
|
||||
page: page,
|
||||
size: pageSize,
|
||||
});
|
||||
};
|
||||
|
||||
const resetLocalSearchParams = (params: LocalSearchParamsInterface) => {
|
||||
setSearchParams(
|
||||
(prev) => {
|
||||
if (typeof params.title !== "undefined") {
|
||||
prev.set("title", params.title);
|
||||
}
|
||||
if (typeof params.page !== "undefined") {
|
||||
prev.set("page", params.page + "");
|
||||
}
|
||||
if (typeof params.size !== "undefined") {
|
||||
prev.set("size", params.size + "");
|
||||
}
|
||||
return prev;
|
||||
},
|
||||
{ replace: true }
|
||||
);
|
||||
};
|
||||
|
||||
const onChange = (key: string) => {
|
||||
@ -419,9 +456,11 @@ const CoursePage = () => {
|
||||
<div className="d-flex mr-24">
|
||||
<Typography.Text>课程名称:</Typography.Text>
|
||||
<Input
|
||||
value={title}
|
||||
value={title || ""}
|
||||
onChange={(e) => {
|
||||
setTitle(e.target.value);
|
||||
resetLocalSearchParams({
|
||||
title: e.target.value,
|
||||
});
|
||||
}}
|
||||
allowClear
|
||||
style={{ width: 160 }}
|
||||
@ -435,7 +474,9 @@ const CoursePage = () => {
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() => {
|
||||
setPage(1);
|
||||
resetLocalSearchParams({
|
||||
page: 1,
|
||||
});
|
||||
setRefresh(!refresh);
|
||||
}}
|
||||
>
|
||||
|
@ -150,7 +150,7 @@ const CourseUserPage = () => {
|
||||
dataIndex: "id",
|
||||
render: (_, record: any) => (
|
||||
<>
|
||||
{records[record.id] ? (
|
||||
{records[record.id] && records[record.id].finished_at ? (
|
||||
<span>{dateFormat(String(records[record.id].finished_at))}</span>
|
||||
) : (
|
||||
<span>-</span>
|
||||
|
@ -8,7 +8,8 @@ import type { DataNode, TreeProps } from "antd/es/tree";
|
||||
import { DepartmentCreate } from "./compenents/create";
|
||||
import { DepartmentUpdate } from "./compenents/update";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useSelector } from "react-redux";
|
||||
import { useSelector, useDispatch } from "react-redux";
|
||||
import { saveDepartmentsAction } from "../../store/system/systemConfigSlice";
|
||||
|
||||
const { confirm } = Modal;
|
||||
|
||||
@ -19,6 +20,7 @@ interface Option {
|
||||
}
|
||||
|
||||
const DepartmentPage = () => {
|
||||
const dispatch = useDispatch();
|
||||
const navigate = useNavigate();
|
||||
const permissions = useSelector(
|
||||
(state: any) => state.loginUser.value.permissions
|
||||
@ -32,6 +34,8 @@ const DepartmentPage = () => {
|
||||
const [updateVisible, setUpdateVisible] = useState(false);
|
||||
const [did, setDid] = useState<number>(0);
|
||||
const [modal, contextHolder] = Modal.useModal();
|
||||
|
||||
// 是否启用LDAP
|
||||
const ldapEnabled = useSelector(
|
||||
(state: any) => state.systemConfig.value["ldap-enabled"]
|
||||
);
|
||||
@ -55,6 +59,7 @@ const DepartmentPage = () => {
|
||||
const getData = () => {
|
||||
department.departmentList().then((res: any) => {
|
||||
const departments: DepartmentsBoxModel = res.data.departments;
|
||||
dispatch(saveDepartmentsAction(res.data.departments));
|
||||
if (JSON.stringify(departments) !== "{}") {
|
||||
const new_arr: Option[] = checkArr(departments, 0);
|
||||
setTreeData(new_arr);
|
||||
@ -389,9 +394,22 @@ const DepartmentPage = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const ldapSync = () => {
|
||||
if (loading) {
|
||||
message.warning("正在同步,请稍后...");
|
||||
return;
|
||||
}
|
||||
setLoading(true);
|
||||
department.ldapSync().then(() => {
|
||||
message.success("操作成功");
|
||||
setLoading(false);
|
||||
resetData();
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
{!ldapEnabled && (
|
||||
{
|
||||
<div className="playedu-main-top mb-24">
|
||||
{contextHolder}
|
||||
<div className="d-flex">
|
||||
@ -404,9 +422,21 @@ const DepartmentPage = () => {
|
||||
onClick={() => setCreateVisible(true)}
|
||||
disabled={null}
|
||||
/>
|
||||
|
||||
{ldapEnabled ? (
|
||||
<PerButton
|
||||
type="primary"
|
||||
text="一键同步LDAP部门架构"
|
||||
class="mr-16"
|
||||
icon={null}
|
||||
p="department-cud"
|
||||
onClick={() => ldapSync()}
|
||||
disabled={null}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
}
|
||||
<div className="playedu-main-body">
|
||||
{loading && (
|
||||
<div className="float-left text-center mt-30">
|
||||
|
@ -27,6 +27,8 @@ const InitPage = (props: Props) => {
|
||||
systemH5Url: props.configData["system.h5_url"],
|
||||
memberDefaultAvatar: props.configData["member.default_avatar"],
|
||||
courseDefaultThumbs: props.configData["default.course_thumbs"],
|
||||
departments: props.configData["departments"],
|
||||
resourceCategories: props.configData["resource_categories"],
|
||||
};
|
||||
dispatch(saveConfigAction(config));
|
||||
}
|
||||
|
@ -67,6 +67,8 @@ const LoginPage = () => {
|
||||
systemH5Url: res.data["system.h5_url"],
|
||||
memberDefaultAvatar: res.data["member.default_avatar"],
|
||||
courseDefaultThumbs: res.data["default.course_thumbs"],
|
||||
departments: res.data["departments"],
|
||||
resourceCategories: res.data["resource_categories"],
|
||||
};
|
||||
dispatch(saveConfigAction(data));
|
||||
};
|
||||
|
@ -117,17 +117,17 @@ const MemberDepartmentProgressPage = () => {
|
||||
setSize(pageSize);
|
||||
};
|
||||
|
||||
const getTotalHours = (params: any) => {
|
||||
if (params) {
|
||||
let value = 0;
|
||||
for (let key in params) {
|
||||
value += params[key].hour_count;
|
||||
}
|
||||
return value;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
// const getTotalHours = (params: any) => {
|
||||
// if (params) {
|
||||
// let value = 0;
|
||||
// for (let key in params) {
|
||||
// value += params[key].hour_count;
|
||||
// }
|
||||
// return value;
|
||||
// } else {
|
||||
// return 0;
|
||||
// }
|
||||
// };
|
||||
|
||||
const getFinishedHours = (params: any) => {
|
||||
if (params) {
|
||||
@ -164,7 +164,17 @@ const MemberDepartmentProgressPage = () => {
|
||||
let sheetName = "sheet1";
|
||||
let data = [];
|
||||
let arr = ["学员"];
|
||||
courses.map((item: any) => {
|
||||
let data2 = res.data.courses;
|
||||
let arr2: any = [];
|
||||
let value = 0;
|
||||
for (let key in data2) {
|
||||
arr2.push(data2[key]);
|
||||
value += data2[key].class_hour;
|
||||
}
|
||||
let w_totalHour = value;
|
||||
let w_courses = arr2;
|
||||
let w_records = res.data.user_course_records;
|
||||
w_courses.map((item: any) => {
|
||||
arr.push(item.title);
|
||||
});
|
||||
arr.push("总计课时");
|
||||
@ -172,21 +182,23 @@ const MemberDepartmentProgressPage = () => {
|
||||
|
||||
res.data.data.forEach((item: any) => {
|
||||
let arr = [item.name];
|
||||
courses.map((it: any) => {
|
||||
if (records && records[item.id] && records[item.id][it.id]) {
|
||||
if (records && records[item.id][it.id].is_finished === 1) {
|
||||
w_courses.map((it: any) => {
|
||||
if (w_records && w_records[item.id] && w_records[item.id][it.id]) {
|
||||
if (w_records && w_records[item.id][it.id].is_finished === 1) {
|
||||
arr.push("已学完");
|
||||
} else {
|
||||
arr.push(
|
||||
records &&
|
||||
records[item.id][it.id].finished_count + " / " + it.class_hour
|
||||
w_records &&
|
||||
w_records[item.id][it.id].finished_count +
|
||||
" / " +
|
||||
it.class_hour
|
||||
);
|
||||
}
|
||||
} else {
|
||||
arr.push(0 + " / " + it.class_hour);
|
||||
}
|
||||
});
|
||||
arr.push(getFinishedHours(records[item.id]) + " / " + totalHour);
|
||||
arr.push(getFinishedHours(w_records[item.id]) + " / " + w_totalHour);
|
||||
data.push(arr);
|
||||
});
|
||||
|
||||
|
@ -20,7 +20,7 @@ import {
|
||||
} from "@ant-design/icons";
|
||||
import { user } from "../../api/index";
|
||||
import { dateFormat } from "../../utils/index";
|
||||
import { Link, Navigate, useLocation } from "react-router-dom";
|
||||
import { Link, useLocation, useSearchParams } from "react-router-dom";
|
||||
import { useSelector } from "react-redux";
|
||||
import { TreeDepartment, PerButton } from "../../compenents";
|
||||
import { MemberCreate } from "./compenents/create";
|
||||
@ -46,17 +46,34 @@ interface DataType {
|
||||
verify_at?: string;
|
||||
}
|
||||
|
||||
interface LocalSearchParamsInterface {
|
||||
page?: number;
|
||||
size?: number;
|
||||
nickname?: string;
|
||||
email?: string;
|
||||
}
|
||||
|
||||
const MemberPage = () => {
|
||||
const result = new URLSearchParams(useLocation().search);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [page, setPage] = useState(1);
|
||||
const [size, setSize] = useState(10);
|
||||
|
||||
const [searchParams, setSearchParams] = useSearchParams({
|
||||
page: "1",
|
||||
size: "10",
|
||||
nickname: "",
|
||||
email: "",
|
||||
});
|
||||
const page = parseInt(searchParams.get("page") || "1");
|
||||
const size = parseInt(searchParams.get("size") || "10");
|
||||
const nickname = searchParams.get("nickname");
|
||||
const email = searchParams.get("email");
|
||||
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [list, setList] = useState<DataType[]>([]);
|
||||
const [total, setTotal] = useState(0);
|
||||
const [pureTotal, setPureTotal] = useState(0);
|
||||
const [refresh, setRefresh] = useState(false);
|
||||
const [depUserCount, setDepUserCount] = useState<KeyNumberObject>();
|
||||
|
||||
const [nickname, setNickname] = useState("");
|
||||
const [email, setEmail] = useState("");
|
||||
const [dep_ids, setDepIds] = useState<number[]>([]);
|
||||
const [selLabel, setLabel] = useState<string>(
|
||||
result.get("label") ? String(result.get("label")) : "全部部门"
|
||||
@ -211,30 +228,45 @@ const MemberPage = () => {
|
||||
getData();
|
||||
}, [refresh, page, size, dep_ids]);
|
||||
|
||||
useEffect(() => {
|
||||
const handlePageBack = () => {
|
||||
getData();
|
||||
};
|
||||
window.addEventListener("popstate", handlePageBack);
|
||||
return () => {
|
||||
window.removeEventListener("popstate", handlePageBack);
|
||||
};
|
||||
}, []);
|
||||
|
||||
const getData = () => {
|
||||
let depIds = dep_ids.join(",");
|
||||
if (loading) {
|
||||
return;
|
||||
}
|
||||
setLoading(true);
|
||||
user
|
||||
.userList(page, size, {
|
||||
name: nickname,
|
||||
email: email,
|
||||
id_card: "",
|
||||
dep_ids: depIds,
|
||||
dep_ids: dep_ids.join(","),
|
||||
})
|
||||
.then((res: any) => {
|
||||
setList(res.data.data);
|
||||
setDepartments(res.data.departments);
|
||||
setUserDepIds(res.data.user_dep_ids);
|
||||
setTotal(res.data.total);
|
||||
setPureTotal(res.data.pure_total);
|
||||
setDepUserCount(res.data.dep_user_count);
|
||||
setLoading(false);
|
||||
});
|
||||
};
|
||||
|
||||
const resetData = () => {
|
||||
setNickname("");
|
||||
setEmail("");
|
||||
setPage(1);
|
||||
setSize(10);
|
||||
resetLocalSearchParams({
|
||||
page: 1,
|
||||
size: 10,
|
||||
nickname: "",
|
||||
email: "",
|
||||
});
|
||||
setList([]);
|
||||
setRefresh(!refresh);
|
||||
};
|
||||
@ -249,8 +281,31 @@ const MemberPage = () => {
|
||||
};
|
||||
|
||||
const handlePageChange = (page: number, pageSize: number) => {
|
||||
setPage(page);
|
||||
setSize(pageSize);
|
||||
resetLocalSearchParams({
|
||||
page: page,
|
||||
size: pageSize,
|
||||
});
|
||||
};
|
||||
|
||||
const resetLocalSearchParams = (params: LocalSearchParamsInterface) => {
|
||||
setSearchParams(
|
||||
(prev) => {
|
||||
if (typeof params.nickname !== "undefined") {
|
||||
prev.set("nickname", params.nickname);
|
||||
}
|
||||
if (typeof params.email !== "undefined") {
|
||||
prev.set("email", params.email);
|
||||
}
|
||||
if (typeof params.page !== "undefined") {
|
||||
prev.set("page", params.page + "");
|
||||
}
|
||||
if (typeof params.size !== "undefined") {
|
||||
prev.set("size", params.size + "");
|
||||
}
|
||||
return prev;
|
||||
},
|
||||
{ replace: true }
|
||||
);
|
||||
};
|
||||
|
||||
const delUser = (id: number) => {
|
||||
@ -282,12 +337,14 @@ const MemberPage = () => {
|
||||
<div className="left-box">
|
||||
<TreeDepartment
|
||||
selected={dep_ids}
|
||||
refresh={refresh}
|
||||
showNum={true}
|
||||
type=""
|
||||
userCount={pureTotal}
|
||||
depUserCount={depUserCount}
|
||||
text={"部门"}
|
||||
onUpdate={(keys: any, title: any) => {
|
||||
setPage(1);
|
||||
resetLocalSearchParams({
|
||||
page: 1,
|
||||
});
|
||||
setDepIds(keys);
|
||||
var index = title.indexOf("(");
|
||||
if (index !== -1) {
|
||||
@ -324,7 +381,6 @@ const MemberPage = () => {
|
||||
class="mr-16"
|
||||
icon={null}
|
||||
p="user-store"
|
||||
onClick={() => null}
|
||||
disabled={null}
|
||||
/>
|
||||
</Link>
|
||||
@ -342,7 +398,6 @@ const MemberPage = () => {
|
||||
class="mr-16"
|
||||
icon={null}
|
||||
p="department-user-learn"
|
||||
onClick={() => null}
|
||||
disabled={null}
|
||||
/>
|
||||
</Link>
|
||||
@ -352,9 +407,11 @@ const MemberPage = () => {
|
||||
<div className="d-flex mr-24">
|
||||
<Typography.Text>姓名:</Typography.Text>
|
||||
<Input
|
||||
value={nickname}
|
||||
value={nickname || ""}
|
||||
onChange={(e) => {
|
||||
setNickname(e.target.value);
|
||||
resetLocalSearchParams({
|
||||
nickname: e.target.value,
|
||||
});
|
||||
}}
|
||||
style={{ width: 160 }}
|
||||
placeholder="请输入姓名关键字"
|
||||
@ -364,9 +421,11 @@ const MemberPage = () => {
|
||||
<div className="d-flex mr-24">
|
||||
<Typography.Text>邮箱:</Typography.Text>
|
||||
<Input
|
||||
value={email}
|
||||
value={email || ""}
|
||||
onChange={(e) => {
|
||||
setEmail(e.target.value);
|
||||
resetLocalSearchParams({
|
||||
email: e.target.value,
|
||||
});
|
||||
}}
|
||||
style={{ width: 160 }}
|
||||
placeholder="请输入邮箱账号"
|
||||
@ -380,7 +439,9 @@ const MemberPage = () => {
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() => {
|
||||
setPage(1);
|
||||
resetLocalSearchParams({
|
||||
page: 1,
|
||||
});
|
||||
setRefresh(!refresh);
|
||||
}}
|
||||
>
|
||||
|
@ -260,7 +260,7 @@ const MemberLearnPage = () => {
|
||||
dataIndex: "finished_at",
|
||||
render: (_, record: any) => (
|
||||
<>
|
||||
{records[record.id] ? (
|
||||
{records[record.id] && records[record.id].finished_at ? (
|
||||
<span>{dateFormat(String(records[record.id].finished_at))}</span>
|
||||
) : (
|
||||
<span>-</span>
|
||||
|
@ -8,7 +8,8 @@ import type { DataNode, TreeProps } from "antd/es/tree";
|
||||
import { ResourceCategoryCreate } from "./compenents/create";
|
||||
import { ResourceCategoryUpdate } from "./compenents/update";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useSelector } from "react-redux";
|
||||
import { useSelector, useDispatch } from "react-redux";
|
||||
import { saveCategoriesAction } from "../../../store/system/systemConfigSlice";
|
||||
|
||||
const { confirm } = Modal;
|
||||
|
||||
@ -19,6 +20,7 @@ interface Option {
|
||||
}
|
||||
|
||||
const ResourceCategoryPage = () => {
|
||||
const dispatch = useDispatch();
|
||||
const navigate = useNavigate();
|
||||
const permissions = useSelector(
|
||||
(state: any) => state.loginUser.value.permissions
|
||||
@ -53,6 +55,7 @@ const ResourceCategoryPage = () => {
|
||||
setLoading(true);
|
||||
resourceCategory.resourceCategoryList().then((res: any) => {
|
||||
const categories: CategoriesBoxModel = res.data.categories;
|
||||
dispatch(saveCategoriesAction(res.data.categories));
|
||||
if (JSON.stringify(categories) !== "{}") {
|
||||
const new_arr: Option[] = checkArr(categories, 0);
|
||||
setTreeData(new_arr);
|
||||
|
@ -259,6 +259,8 @@ const SystemConfigPage = () => {
|
||||
systemH5Url: res.data["system.h5_url"],
|
||||
memberDefaultAvatar: res.data["member.default_avatar"],
|
||||
courseDefaultThumbs: res.data["default.course_thumbs"],
|
||||
departments: res.data["departments"],
|
||||
resourceCategories: res.data["resource_categories"],
|
||||
};
|
||||
dispatch(saveConfigAction(data));
|
||||
});
|
||||
|
4
src/playedu.d.ts
vendored
4
src/playedu.d.ts
vendored
@ -1,4 +1,8 @@
|
||||
declare global {
|
||||
interface KeyNumberObject {
|
||||
[key: number]: number;
|
||||
}
|
||||
|
||||
interface FileItem {
|
||||
id: string; //上传文件的唯一id
|
||||
file: File; //上传的文件资源
|
||||
|
@ -9,21 +9,32 @@ type SystemConfigStoreInterface = {
|
||||
systemName?: string;
|
||||
memberDefaultAvatar?: string;
|
||||
courseDefaultThumbs?: string[];
|
||||
departments?: any;
|
||||
resourceCategories?: any;
|
||||
};
|
||||
|
||||
let defaultValue: SystemConfigStoreInterface = {};
|
||||
|
||||
const systemConfigSlice = createSlice({
|
||||
name: "systemConfig",
|
||||
initialState: {
|
||||
value: {},
|
||||
value: defaultValue,
|
||||
},
|
||||
reducers: {
|
||||
saveConfigAction(stage, e) {
|
||||
stage.value = e.payload;
|
||||
},
|
||||
saveDepartmentsAction(stage, e) {
|
||||
stage.value.departments = e.payload;
|
||||
},
|
||||
saveCategoriesAction(stage, e) {
|
||||
stage.value.resourceCategories = e.payload;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export default systemConfigSlice.reducer;
|
||||
export const { saveConfigAction } = systemConfigSlice.actions;
|
||||
export const { saveConfigAction, saveDepartmentsAction, saveCategoriesAction } =
|
||||
systemConfigSlice.actions;
|
||||
|
||||
export type { SystemConfigStoreInterface };
|
||||
|
Loading…
x
Reference in New Issue
Block a user