Commit 66909758 by 杨明

fixed

1 parent fa72a36e
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: yangming yangming@didihu.com.cn * @Author: yangming yangming@didihu.com.cn
* @Date: 2023-03-03 10:30:06 * @Date: 2023-03-03 10:30:06
* @LastEditors: yangming yangming@didihu.com.cn * @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-03-09 09:33:06 * @LastEditTime: 2023-03-17 17:57:37
* @FilePath: \achievements-system-front\index.html * @FilePath: \achievements-system-front\index.html
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
--> -->
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> <link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title> <title>绩效系统</title>
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>
......
/* /*
* @Author: yangming yangming@didihu.com.cn * @Author: yangming yangming@didihu.com.cn
* @Date: 2023-03-06 17:00:05 * @Date: 2023-03-06 17:00:05
* @LastEditors: yangming yangming@didihu.com.cn * @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2023-03-16 16:23:20 * @LastEditTime: 2023-03-29 13:57:04
* @FilePath: \achievements-system-front\src\api\request\emp.ts * @FilePath: \achievements-system-front\src\api\request\emp.ts
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/ */
...@@ -15,6 +15,7 @@ const serverUrl = { ...@@ -15,6 +15,7 @@ const serverUrl = {
empUpdate: "/emp/update", empUpdate: "/emp/update",
getEmpDetail: "/emp/detail", getEmpDetail: "/emp/detail",
downExcel: "/emp/downExcel", downExcel: "/emp/downExcel",
downDetailExcel: "/emp/downExcelDetail",
}; };
export const getEmpListApi = (params: any) => { export const getEmpListApi = (params: any) => {
return request.get(serverUrl.getEmpList, params); return request.get(serverUrl.getEmpList, params);
...@@ -34,3 +35,6 @@ export const getEmpDetailApi = (params: any) => { ...@@ -34,3 +35,6 @@ export const getEmpDetailApi = (params: any) => {
export const downExcelApi = (params: any) => { export const downExcelApi = (params: any) => {
return request.get(serverUrl.downExcel, params); return request.get(serverUrl.downExcel, params);
}; };
export const downDetailExcelApi = (params: any) => {
return request.get(serverUrl.downDetailExcel, params);
};
import HttpRequest from "./request"; import HttpRequest from "./request";
const config = { const config = {
baseUrl: { baseUrl: {
dev: "http://192.168.1.127:7001", dev: "http://192.168.3.115:8101/",
prod: "http://config-center-backend.glsx.com", //test环境 prod: "http://config-center-backend.glsx.com", //test环境
}, },
}; };
......
/*
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2023-04-27 11:23:59
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2023-04-27 11:24:52
* @FilePath: \achievements-system-front\src\api\target.ts
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import request from "@/api/request/index";
// import qs from "qs";
const serverUrl = {
getTargetList: "/target/list",
targetDelete: "/target/delete",
targetAdd: "/target/add",
targetUpdate: "/target/update",
getTargetDetail: "/target/detail",
};
export const getTargetListApi = (params: any) => {
return request.get(serverUrl.getTargetList, params);
};
export const targetDeleteApi = (params: any) => {
return request.post(serverUrl.targetDelete, params);
};
export const targetAddApi = (params: any) => {
return request.post(serverUrl.targetAdd, params);
};
export const targetUpdateApi = (params: any) => {
return request.post(serverUrl.targetUpdate, params);
};
export const getTargetDetailApi = (params: any) => {
return request.post(serverUrl.getTargetDetail, params);
};
...@@ -15,6 +15,7 @@ const Grade = lazy(() => import("@/views/Grade/index")); ...@@ -15,6 +15,7 @@ const Grade = lazy(() => import("@/views/Grade/index"));
const Classify = lazy(() => import("@/views/Classify/index")); const Classify = lazy(() => import("@/views/Classify/index"));
const Emp = lazy(() => import("@/views/Emp/index")); const Emp = lazy(() => import("@/views/Emp/index"));
const Login = lazy(() => import("@/views/Login/index")); const Login = lazy(() => import("@/views/Login/index"));
const Target = lazy(() => import("@/views/Target/index"));
const WithLoadingComponent = (comp: any) => { const WithLoadingComponent = (comp: any) => {
return ( return (
...@@ -47,6 +48,10 @@ const routers = [ ...@@ -47,6 +48,10 @@ const routers = [
path: "/emp", path: "/emp",
element: WithLoadingComponent(<Emp />), element: WithLoadingComponent(<Emp />),
}, },
{
path: "/target",
element: WithLoadingComponent(<Target />),
},
], ],
}, },
]; ];
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: yangming yangming@didihu.com.cn * @Author: yangming yangming@didihu.com.cn
* @Date: 2023-03-03 10:30:06 * @Date: 2023-03-03 10:30:06
* @LastEditors: yangming yangming@didihu.com.cn * @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-03-17 13:31:04 * @LastEditTime: 2023-03-17 16:54:18
* @FilePath: \achievements-system-front\src\router\routes.tsx * @FilePath: \achievements-system-front\src\router\routes.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/ */
...@@ -17,7 +17,6 @@ const RouterBeforeEach = () => { ...@@ -17,7 +17,6 @@ const RouterBeforeEach = () => {
const outlet = useRoutes(router); const outlet = useRoutes(router);
useEffect(() => { useEffect(() => {
if (location.pathname != "/login" && !sessionStorage.getItem("token")) { if (location.pathname != "/login" && !sessionStorage.getItem("token")) {
message.error("请您先登录");
navigate("/login", { replace: true }); navigate("/login", { replace: true });
} }
if (location.pathname == "/login" || location.pathname == "/") { if (location.pathname == "/login" || location.pathname == "/") {
......
/* /*
* @Author: yangming yangming@didihu.com.cn * @Author: yangming yangming@didihu.com.cn
* @Date: 2023-03-07 16:09:51 * @Date: 2023-03-07 16:09:51
* @LastEditors: yangming yangming@didihu.com.cn * @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2023-03-07 16:13:01 * @LastEditTime: 2023-05-12 19:06:20
* @FilePath: \achievements-system-front\src\utils\constant.ts * @FilePath: \achievements-system-front\src\utils\constant.ts
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/ */
...@@ -22,4 +22,25 @@ const Gender: IItem[] = [ ...@@ -22,4 +22,25 @@ const Gender: IItem[] = [
name: "女", name: "女",
}, },
]; ];
export { Gender };
// 类型
const TargetType: IItem[] = [
{
id: 1,
name: "前端员工",
},
{
id: 2,
name: "前端经理",
},
];
// 类型
const TargetTypeFilter: IItem[] = [
{
id: '',
name: "全部",
},
...TargetType
];
export { Gender, TargetType,TargetTypeFilter };
/* /*
* @Author: yangming yangming@didihu.com.cn * @Author: yangming yangming@didihu.com.cn
* @Date: 2023-03-15 15:11:33 * @Date: 2023-03-15 15:11:33
* @LastEditors: yangming yangming@didihu.com.cn * @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2023-03-15 15:52:21 * @LastEditTime: 2023-05-04 11:04:52
* @FilePath: \achievements-system-front\src\utils\util.js * @FilePath: \achievements-system-front\src\utils\util.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/ */
...@@ -21,7 +21,46 @@ const downFile = (content: any, filename: any) => { ...@@ -21,7 +21,46 @@ const downFile = (content: any, filename: any) => {
// 然后移除 // 然后移除
document.body.removeChild(eleLink); document.body.removeChild(eleLink);
}; };
const getObjType = (obj: any) => {
return Object.prototype.toString.call(obj).toString();
};
const deepClone = (data: any) => {
const type = getObjType(data);
let obj: any;
if (type === "[object Array]") {
obj = [];
} else if (type === "[object Object]") {
obj = {};
} else {
// 不再具有下一层次
return data;
}
if (type === "[object Array]") {
const len = data.length;
for (let i = 0; i < len; i++) {
data[i] = (() => {
if (data[i] === 0) {
return data[i];
}
return data[i];
})();
if (data[i]) {
delete data[i].$parent;
}
obj.push(deepClone(data[i]));
}
} else if (type === "[object Object]") {
for (const key in data) {
if (data) {
delete data.$parent;
}
obj[key] = deepClone(data[key]);
}
}
return obj;
};
export default { export default {
downFile, downFile,
deepClone,
}; };
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react";
import { Drawer, Form, Input, Radio, Button, message } from "antd"; import {
Drawer,
Form,
Space,
Input,
Button,
message,
Select,
InputNumber,
} from "antd";
import { import {
projectUpdateApi, projectUpdateApi,
projectAddApi, projectAddApi,
getProjectDetailApi, getProjectDetailApi,
} from "@/api/project"; } from "@/api/project";
import { getTargetListApi } from "@/api/target";
import { Gender } from "@/utils/constant"; import { ITarget } from "@/views/Target/model";
import { TargetType } from "@/utils/constant";
// const roleList: any = constantMng.formatGroup("role", "value", "label"); // const roleList: any = constantMng.formatGroup("role", "value", "label");
const formItemLayout = { const formItemLayout = {
labelCol: { span: 4 }, labelCol: { span: 4 },
wrapperCol: { span: 20 }, wrapperCol: { span: 20 },
...@@ -19,33 +28,46 @@ interface IProps { ...@@ -19,33 +28,46 @@ interface IProps {
id: number; id: number;
onClose: () => void; onClose: () => void;
} }
const Edit: React.FC<IProps> = (props) => { const Edit: React.FC<IProps> = (props) => {
const [form] = Form.useForm();
const { id, visible, onClose } = props; const { id, visible, onClose } = props;
// 提交时的loading状态 // 提交时的loading状态
// const [loading, setLoading] = useState(false) // const [loading, setLoading] = useState(false)
const [detail, setDetail] = useState({ // const [detail, setDetail] = useState({
projectScore: "", // type: 1,
projectName: "", // projectScore: "",
projectDesc: "", // targetId: "",
}); // targetName: "",
// projectName: "",
// 获取员工详情 // projectDesc: "",
// });
const [targetList, setTargetList] = useState<ITarget[]>([]);
// 获取详情
useEffect(() => { useEffect(() => {
if (!id) { if (!id) {
setDetail({ form.resetFields();
projectScore: "", getTargetList(form.getFieldValue("type"));
projectName: "",
projectDesc: "",
});
return; return;
} }
getProjectDetailApi({ id }).then((res) => { getProjectDetailApi({ id }).then((res) => {
setDetail(res.data); form.setFieldsValue(res.data);
getTargetList(form.getFieldValue("type"));
}); });
}, [id]); }, [id]);
const changeTarget = () => {
form.setFieldsValue({ targetId: "", targetName: "" });
getTargetList(form.getFieldValue("type"));
};
const getTargetList = async (values: any) => {
const res = await getTargetListApi({
params: { pageNum: 1, pageSize: 1000, type: values },
});
setTargetList(res.data.rows);
};
const handleSubmit = (values: any) => { const handleSubmit = (values: any) => {
values.targetName = targetList.find(
(item) => item.id == values.targetId
)?.name;
if (id) { if (id) {
projectUpdateApi({ ...values, id }).then((res) => { projectUpdateApi({ ...values, id }).then((res) => {
if (res.code == 200) { if (res.code == 200) {
...@@ -86,15 +108,49 @@ const Edit: React.FC<IProps> = (props) => { ...@@ -86,15 +108,49 @@ const Edit: React.FC<IProps> = (props) => {
<Form <Form
layout="horizontal" layout="horizontal"
colon colon
form={form}
initialValues={{ type: 1 }}
labelAlign="left" labelAlign="left"
{...formItemLayout} {...formItemLayout}
onFinish={handleSubmit} onFinish={handleSubmit}
onFinishFailed={handleFinishFailed} onFinishFailed={handleFinishFailed}
> >
<Form.Item <Form.Item
label="奖惩表类型"
name="type"
rules={[
{
required: true,
message: "请选择奖惩表类型!",
},
]}
>
<Select
style={{ width: 300 }}
options={TargetType}
onChange={changeTarget}
fieldNames={{ label: "name", value: "id" }}
/>
</Form.Item>
<Form.Item
label="所属指标"
name="targetId"
rules={[
{
required: true,
message: "请选择所属指标!",
},
]}
>
<Select
style={{ width: 300 }}
options={targetList}
fieldNames={{ label: "name", value: "id" }}
/>
</Form.Item>
<Form.Item
label="奖惩分类项" label="奖惩分类项"
name="projectName" name="projectName"
initialValue={detail.projectName}
rules={[ rules={[
{ {
required: true, required: true,
...@@ -104,11 +160,9 @@ const Edit: React.FC<IProps> = (props) => { ...@@ -104,11 +160,9 @@ const Edit: React.FC<IProps> = (props) => {
> >
<Input placeholder="请输入奖惩分类项" /> <Input placeholder="请输入奖惩分类项" />
</Form.Item> </Form.Item>
<Form.Item <Form.Item
label="分类描述" label="分类描述"
name="projectDesc" name="projectDesc"
initialValue={detail.projectDesc}
rules={[ rules={[
{ {
required: true, required: true,
...@@ -118,10 +172,9 @@ const Edit: React.FC<IProps> = (props) => { ...@@ -118,10 +172,9 @@ const Edit: React.FC<IProps> = (props) => {
> >
<Input placeholder="请输入分类描述" /> <Input placeholder="请输入分类描述" />
</Form.Item> </Form.Item>
<Form.Item {/* <Form.Item
label="分数" label="分数"
name="projectScore" name="min_score"
initialValue={detail.projectScore}
rules={[ rules={[
{ {
required: true, required: true,
...@@ -138,6 +191,17 @@ const Edit: React.FC<IProps> = (props) => { ...@@ -138,6 +191,17 @@ const Edit: React.FC<IProps> = (props) => {
]} ]}
> >
<Input placeholder="请输入分数" /> <Input placeholder="请输入分数" />
</Form.Item> */}
<Form.Item label="分数范围">
<Space align="start">
<Form.Item name="min_score">
<InputNumber />
</Form.Item>
{"-"}
<Form.Item name="max_score">
<InputNumber />
</Form.Item>
</Space>
</Form.Item> </Form.Item>
<Form.Item wrapperCol={{ offset: 8 }}> <Form.Item wrapperCol={{ offset: 8 }}>
<Button onClick={onClose}>取消</Button> <Button onClick={onClose}>取消</Button>
......
...@@ -11,12 +11,14 @@ import { ...@@ -11,12 +11,14 @@ import {
message, message,
DatePicker, DatePicker,
Form, Form,
Select,
} from "antd"; } from "antd";
import { PlusOutlined, MinusOutlined } from "@ant-design/icons"; import { PlusOutlined, MinusOutlined } from "@ant-design/icons";
import { Gender } from "@/utils/constant"; import { Gender } from "@/utils/constant";
import Edit from "./components/Edit"; import Edit from "./components/Edit";
import { IProject } from "./model"; import { IProject, IParams } from "./model";
import { getProjectListApi, projectDeleteApi } from "@/api/project"; import { getProjectListApi, projectDeleteApi } from "@/api/project";
import { TargetTypeFilter } from "@/utils/constant";
const { Column } = Table; const { Column } = Table;
const User = () => { const User = () => {
// 查询参数 // 查询参数
...@@ -50,6 +52,7 @@ const User = () => { ...@@ -50,6 +52,7 @@ const User = () => {
}, [getClassifyList]); }, [getClassifyList]);
const search = { const search = {
projectName: "", projectName: "",
type: "",
}; };
// 搜索 // 搜索
const handleSearch = (values: any) => { const handleSearch = (values: any) => {
...@@ -132,6 +135,13 @@ const User = () => { ...@@ -132,6 +135,13 @@ const User = () => {
> >
<Input placeholder="请输入奖项分类项" /> <Input placeholder="请输入奖项分类项" />
</Form.Item> </Form.Item>
<Form.Item label="指标归属" name="type" initialValue={search.type}>
<Select
style={{ width: 220 }}
options={TargetTypeFilter}
fieldNames={{ label: "name", value: "id" }}
/>
</Form.Item>
<Form.Item wrapperCol={{ offset: 8 }}> <Form.Item wrapperCol={{ offset: 8 }}>
<Button type="primary" htmlType="submit"> <Button type="primary" htmlType="submit">
查询 查询
...@@ -162,7 +172,21 @@ const User = () => { ...@@ -162,7 +172,21 @@ const User = () => {
/> />
<Column title="奖项分类项" dataIndex="projectName" /> <Column title="奖项分类项" dataIndex="projectName" />
<Column title="奖项分类描述" dataIndex="projectDesc" /> <Column title="奖项分类描述" dataIndex="projectDesc" />
<Column title="奖项分类分" dataIndex="projectScore" /> <Column
title="分数范围"
render={(value, record: IProject) => {
return record.min_score + " - " + record.max_score + "分";
}}
/>
<Column title="所属指标" dataIndex="targetName" />
<Column
title="指标归属"
width={100}
dataIndex="type"
render={(value) =>
TargetTypeFilter.find((i: any) => i.id == value)?.name
}
/>
<Column title="创建时间" dataIndex="createDate" /> <Column title="创建时间" dataIndex="createDate" />
<Column<IProject> <Column<IProject>
title="操作" title="操作"
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: yangming yangming@didihu.com.cn * @Author: yangming yangming@didihu.com.cn
* @Date: 2023-03-08 16:45:32 * @Date: 2023-03-08 16:45:32
* @LastEditors: yangming yangming@didihu.com.cn * @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-03-08 16:45:47 * @LastEditTime: 2023-06-09 16:17:49
* @FilePath: \achievements-system-front\src\views\Classify\model.ts * @FilePath: \achievements-system-front\src\views\Classify\model.ts
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/ */
...@@ -10,6 +10,11 @@ ...@@ -10,6 +10,11 @@
export interface IProject { export interface IProject {
projectName?: string; projectName?: string;
projectDesc?: string; projectDesc?: string;
projectScore?: number; min_socre?: number;
max_socre?: number;
[key: string]: any; [key: string]: any;
} }
export interface IParams {
pageNum: number;
pageSize: number;
}
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react";
import { Drawer, Form, Input, Radio, Button, message } from "antd"; import { Drawer, Form, Input, Radio, Button, message, Select } from "antd";
import { empUpdateApi, empAddApi, getEmpDetailApi } from "@/api/emp"; import { empUpdateApi, empAddApi, getEmpDetailApi } from "@/api/emp";
import { TargetType, Gender } from "@/utils/constant";
import { Gender } from "@/utils/constant";
// const roleList: any = constantMng.formatGroup("role", "value", "label"); // const roleList: any = constantMng.formatGroup("role", "value", "label");
const formItemLayout = { const formItemLayout = {
...@@ -26,6 +25,7 @@ const Edit: React.FC<IProps> = (props) => { ...@@ -26,6 +25,7 @@ const Edit: React.FC<IProps> = (props) => {
department: "", department: "",
position: "", position: "",
score: "", score: "",
type: 1,
}); });
// 获取员工详情 // 获取员工详情
...@@ -37,6 +37,7 @@ const Edit: React.FC<IProps> = (props) => { ...@@ -37,6 +37,7 @@ const Edit: React.FC<IProps> = (props) => {
department: "", department: "",
position: "", position: "",
score: "", score: "",
type: 1,
}); });
return; return;
} }
...@@ -124,6 +125,23 @@ const Edit: React.FC<IProps> = (props) => { ...@@ -124,6 +125,23 @@ const Edit: React.FC<IProps> = (props) => {
<Input placeholder="请输入职位" /> <Input placeholder="请输入职位" />
</Form.Item> </Form.Item>
<Form.Item <Form.Item
label="指标归属"
name="type"
initialValue={detail.type}
rules={[
{
required: true,
message: "请选择指标归属!",
},
]}
>
<Select
style={{ width: 220 }}
options={TargetType}
fieldNames={{ label: "name", value: "id" }}
/>
</Form.Item>
<Form.Item
label="性别" label="性别"
name="sex" name="sex"
initialValue={detail.sex} initialValue={detail.sex}
...@@ -142,27 +160,6 @@ const Edit: React.FC<IProps> = (props) => { ...@@ -142,27 +160,6 @@ const Edit: React.FC<IProps> = (props) => {
))} ))}
</Radio.Group> </Radio.Group>
</Form.Item> </Form.Item>
<Form.Item
label="总分数"
name="score"
initialValue={detail.score}
rules={[
{
required: true,
message: "请输入总分数!",
},
() => ({
validator(_, value) {
if (/^\d*(\.\d*)?$/.test(value)) {
return Promise.resolve();
}
return Promise.reject(new Error("请输入数字"));
},
}),
]}
>
<Input placeholder="请输入总分数" disabled={id ? true : false} />
</Form.Item>
<Form.Item wrapperCol={{ offset: 8 }}> <Form.Item wrapperCol={{ offset: 8 }}>
<Button onClick={onClose}>取消</Button> <Button onClick={onClose}>取消</Button>
<Button <Button
......
...@@ -14,19 +14,19 @@ const formItemLayout = { ...@@ -14,19 +14,19 @@ const formItemLayout = {
const dateFormat = "YYYY/MM/DD"; const dateFormat = "YYYY/MM/DD";
interface IProps { interface IProps {
visible: boolean; visible: boolean;
id: number;
gradeId?: number; gradeId?: number;
empName: string;
onClose: () => void; onClose: () => void;
empInfo: any;
} }
interface IDetail { interface IDetail {
title: string; title: string;
empName: string; empName: string | undefined;
projectId: string; projectId: string;
startTime: any; startTime: any;
score: null;
} }
const Edit: React.FC<IProps> = (props) => { const Edit: React.FC<IProps> = (props) => {
const { id, visible, onClose, empName, gradeId } = props; const { visible, onClose, gradeId, empInfo } = props;
// 提交时的loading状态 // 提交时的loading状态
// const [loading, setLoading] = useState(false) // const [loading, setLoading] = useState(false)
const [porjectList, setPorjectList] = useState<IProject[]>([]); const [porjectList, setPorjectList] = useState<IProject[]>([]);
...@@ -35,52 +35,63 @@ const Edit: React.FC<IProps> = (props) => { ...@@ -35,52 +35,63 @@ const Edit: React.FC<IProps> = (props) => {
empName: "", empName: "",
projectId: "", projectId: "",
startTime: "", startTime: "",
score: null,
}); });
// 获取详情 // 获取详情
useEffect(() => { useEffect(() => {
console.log(empInfo, "empInfo");
getProjectList(); getProjectList();
setDetail({ setDetail({
title: "", title: "",
projectId: "", projectId: "",
startTime: "", startTime: "",
empName, empName: empInfo?.name,
score: null,
}); });
if (gradeId) { if (gradeId) {
getGradeDetailApi({ id: gradeId }).then((res) => { getGradeDetailApi({ id: gradeId }).then((res) => {
const { title, projectId, empName, startTime } = res.data; const { title, projectId, empName, startTime, score } = res.data;
setDetail({ setDetail({
title, title,
projectId, projectId,
empName, empName,
startTime: moment(startTime), startTime: moment(startTime),
score,
}); });
}); });
} }
}, [id, gradeId]); }, [empInfo, gradeId]);
const handleSubmit = (values: any) => { const handleSubmit = (values: any) => {
const startTime = moment(values.startTime).format("YYYY-MM-DD"); const startTime = moment(values.startTime).format("YYYY-MM-DD");
if (gradeId) { if (gradeId) {
gradeUpdateApi({ ...values, empId: id, startTime, id: gradeId }).then( gradeUpdateApi({
(res) => { ...values,
empId: empInfo?.id,
startTime,
id: gradeId,
}).then((res) => {
if (res.code == 200) { if (res.code == 200) {
onClose(); onClose();
message.success("新增成功"); message.success("新增成功");
} else {
message.error(res.msg);
} }
} });
);
} else { } else {
gradeAddApi({ ...values, empId: id, startTime }).then((res) => { gradeAddApi({ ...values, empId: empInfo?.id, startTime }).then((res) => {
if (res.code == 200) { if (res.code == 200) {
onClose(); onClose();
message.success("新增成功"); message.success("新增成功");
} else {
message.error(res.msg);
} }
}); });
} }
}; };
const getProjectList = async () => { const getProjectList = async () => {
const res = await getProjectListApi({ const res = await getProjectListApi({
params: { pageNum: 1, pageSize: 1000 }, params: { pageNum: 1, pageSize: 1000, type: empInfo?.type },
}); });
console.log(res.data); console.log(res.data);
setPorjectList(res.data.rows); setPorjectList(res.data.rows);
...@@ -91,7 +102,7 @@ const Edit: React.FC<IProps> = (props) => { ...@@ -91,7 +102,7 @@ const Edit: React.FC<IProps> = (props) => {
return ( return (
<Drawer <Drawer
title={`${id ? "修改" : "新增"}信息`} title={`${empInfo?.id ? "修改" : "新增"}信息`}
width={600} width={600}
open={visible} open={visible}
onClose={onClose} onClose={onClose}
...@@ -125,7 +136,7 @@ const Edit: React.FC<IProps> = (props) => { ...@@ -125,7 +136,7 @@ const Edit: React.FC<IProps> = (props) => {
]} ]}
> >
<Select <Select
style={{ width: 120 }} style={{ width: 220 }}
options={porjectList} options={porjectList}
fieldNames={{ label: "projectName", value: "id" }} fieldNames={{ label: "projectName", value: "id" }}
/> />
...@@ -144,6 +155,19 @@ const Edit: React.FC<IProps> = (props) => { ...@@ -144,6 +155,19 @@ const Edit: React.FC<IProps> = (props) => {
<Input placeholder="请输入奖惩描述" /> <Input placeholder="请输入奖惩描述" />
</Form.Item> </Form.Item>
<Form.Item <Form.Item
label="奖惩分数"
name="score"
initialValue={detail.score}
rules={[
{
required: true,
message: "请输入奖惩分数!",
},
]}
>
<Input placeholder="请输入奖惩分数" />
</Form.Item>
<Form.Item
label="统计时间" label="统计时间"
name="startTime" name="startTime"
initialValue={detail.startTime} initialValue={detail.startTime}
......
/*
* @Author: yangming yangming@didihu.com.cn
* @Date: 2023-03-06 16:20:09
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-06-09 16:19:27
* @FilePath: \achievements-system-front\src\views\Emp\index.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import React, { useEffect, useState, useCallback } from "react"; import React, { useEffect, useState, useCallback } from "react";
import { import {
Button, Button,
...@@ -13,12 +21,17 @@ import { ...@@ -13,12 +21,17 @@ import {
Form, Form,
} from "antd"; } from "antd";
import { PlusOutlined, MinusOutlined } from "@ant-design/icons"; import { PlusOutlined, MinusOutlined } from "@ant-design/icons";
import { Gender } from "@/utils/constant"; import { Gender, TargetType } from "@/utils/constant";
import util from "@/utils/util"; import util from "@/utils/util";
import Edit from "./components/Edit"; import Edit from "./components/Edit";
import Prize from "./components/Prize"; import Prize from "./components/Prize";
import { IEmp } from "./model"; import { IEmp, IParams } from "./model";
import { getEmpListApi, empDeleteApi, downExcelApi } from "@/api/emp"; import {
getEmpListApi,
empDeleteApi,
downExcelApi,
downDetailExcelApi,
} from "@/api/emp";
import dayjs from "dayjs"; import dayjs from "dayjs";
import "./style.scss"; import "./style.scss";
import Search from "antd/es/transfer/search"; import Search from "antd/es/transfer/search";
...@@ -43,7 +56,7 @@ const User = () => { ...@@ -43,7 +56,7 @@ const User = () => {
const [selectedRows, setSelectedRows] = useState<IEmp[]>([]); const [selectedRows, setSelectedRows] = useState<IEmp[]>([]);
// 当前正在编辑的员工的id // 当前正在编辑的员工的id
const [empId, setempId] = useState<number>(0); const [empId, setempId] = useState<number>(0);
const [empName, setempName] = useState<string>(""); const [empInfo, setEmpInfo] = useState<IEmp>();
const getUserList = useCallback(async () => { const getUserList = useCallback(async () => {
setLoading(true); setLoading(true);
const res = await getEmpListApi({ params }); const res = await getEmpListApi({ params });
...@@ -101,6 +114,23 @@ const User = () => { ...@@ -101,6 +114,23 @@ const User = () => {
console.log(url); console.log(url);
util.downFile(url, "员工信息.xlsx"); util.downFile(url, "员工信息.xlsx");
}, [search]); }, [search]);
const exportDetailUrl = useCallback(async () => {
let paramsTime = {};
const { startTime, endTime } = params;
console.log(startTime, endTime);
if (startTime) {
paramsTime = {
startTime,
endTime,
};
}
const url = await downDetailExcelApi({
params: paramsTime,
responseType: "blob",
});
console.log(url);
util.downFile(url, "员工信息.xlsx");
}, [search]);
// 翻页 // 翻页
const handlePagination = (pageNumber: number, pageSize?: number) => { const handlePagination = (pageNumber: number, pageSize?: number) => {
setParams((state: any) => ({ ...state, pageNumber, pageSize: pageSize! })); setParams((state: any) => ({ ...state, pageNumber, pageSize: pageSize! }));
...@@ -116,7 +146,7 @@ const User = () => { ...@@ -116,7 +146,7 @@ const User = () => {
const handlePrize = (record: IEmp) => { const handlePrize = (record: IEmp) => {
const { id, name } = record; const { id, name } = record;
setempId(id); setempId(id);
setempName(name); setEmpInfo(record);
setTimeout(() => { setTimeout(() => {
setPrizeVisible(true); setPrizeVisible(true);
}, 300); }, 300);
...@@ -183,8 +213,13 @@ const User = () => { ...@@ -183,8 +213,13 @@ const User = () => {
</Button> </Button>
</Form.Item> </Form.Item>
<Form.Item wrapperCol={{ offset: 8 }}> <Form.Item wrapperCol={{ offset: 8 }}>
<Button type="primary" htmlType="button" onClick={exportUrl}> {/* <Button type="primary" htmlType="button" onClick={exportUrl}>
导出 导出
</Button> */}
</Form.Item>
<Form.Item wrapperCol={{ offset: 8 }}>
<Button type="primary" htmlType="button" onClick={exportDetailUrl}>
导出详情
</Button> </Button>
</Form.Item> </Form.Item>
</Form> </Form>
...@@ -218,7 +253,12 @@ const User = () => { ...@@ -218,7 +253,12 @@ const User = () => {
/> />
<Column title="部门" dataIndex="position" /> <Column title="部门" dataIndex="position" />
<Column title="职位" dataIndex="department" /> <Column title="职位" dataIndex="department" />
<Column title="总成绩" dataIndex="score" /> <Column
title="指标归属"
width={120}
dataIndex="type"
render={(value) => TargetType.find((i: any) => i.id == value)?.name}
/>
<Column title="创建时间" dataIndex="createDate" /> <Column title="创建时间" dataIndex="createDate" />
<Column<IEmp> <Column<IEmp>
title="操作" title="操作"
...@@ -255,12 +295,7 @@ const User = () => { ...@@ -255,12 +295,7 @@ const User = () => {
</Table> </Table>
<Edit visible={editVisible} id={empId} onClose={handleClose} /> <Edit visible={editVisible} id={empId} onClose={handleClose} />
<Prize <Prize visible={prizeVisible} empInfo={empInfo} onClose={handleClose} />
visible={prizeVisible}
id={empId}
empName={empName}
onClose={handleClose}
/>
</div> </div>
); );
}; };
......
...@@ -8,3 +8,8 @@ export interface IEmp { ...@@ -8,3 +8,8 @@ export interface IEmp {
score: string; score: string;
[key: string]: any; [key: string]: any;
} }
export interface IParams {
pageNum: number;
pageSize: number;
[key: string]: any;
}
...@@ -14,7 +14,7 @@ import { ...@@ -14,7 +14,7 @@ import {
} from "antd"; } from "antd";
import { PlusOutlined, MinusOutlined } from "@ant-design/icons"; import { PlusOutlined, MinusOutlined } from "@ant-design/icons";
import Edit from "../Emp/components/Prize"; import Edit from "../Emp/components/Prize";
import { IGrade } from "./model"; import { IGrade, IParams } from "./model";
import dayjs from "dayjs"; import dayjs from "dayjs";
import { getGradeListApi, gradeDeleteApi } from "@/api/grade"; import { getGradeListApi, gradeDeleteApi } from "@/api/grade";
import Search from "antd/es/transfer/search"; import Search from "antd/es/transfer/search";
...@@ -38,8 +38,7 @@ const User = () => { ...@@ -38,8 +38,7 @@ const User = () => {
const [selectedRows, setSelectedRows] = useState<IGrade[]>([]); const [selectedRows, setSelectedRows] = useState<IGrade[]>([]);
// 当前正在编辑的奖惩的id // 当前正在编辑的奖惩的id
const [gradeId, setGradeId] = useState<number>(0); const [gradeId, setGradeId] = useState<number>(0);
const [empId, setEmpId] = useState<number>(0); const [empInfo, setEmpInfo] = useState<IGrade>();
const [empName, setEmpName] = useState<string>("");
const getGradeList = useCallback(async () => { const getGradeList = useCallback(async () => {
setLoading(true); setLoading(true);
const res = await getGradeListApi({ params }); const res = await getGradeListApi({ params });
...@@ -71,16 +70,15 @@ const User = () => { ...@@ -71,16 +70,15 @@ const User = () => {
}; };
// 翻页 // 翻页
const handlePagination = (pageNumber: number, pageSize?: number) => { const handlePagination = (pageNum: number, pageSize?: number) => {
setParams((state: any) => ({ ...state, pageNumber, pageSize: pageSize! })); setParams((state: any) => ({ ...state, pageNum, pageSize: pageSize! }));
}; };
// 新增或编辑 // 新增或编辑
const handleEdit = (record: IGrade) => { const handleEdit = (record: IGrade) => {
const { id, empId, empName } = record; const { id, empId, empName, type } = record;
setGradeId(id); setGradeId(id);
setEmpId(empId); setEmpInfo({ type, name: empName, id: empId });
setEmpName(empName);
setTimeout(() => { setTimeout(() => {
setEditVisible(true); setEditVisible(true);
}, 300); }, 300);
...@@ -171,7 +169,7 @@ const User = () => { ...@@ -171,7 +169,7 @@ const User = () => {
<Column title="职位" dataIndex="department" /> <Column title="职位" dataIndex="department" />
<Column title="奖项分类项" dataIndex="projectName" /> <Column title="奖项分类项" dataIndex="projectName" />
<Column title="奖项分类描述" dataIndex="projectDesc" /> <Column title="奖项分类描述" dataIndex="projectDesc" />
<Column title="奖项分类分" dataIndex="projectScore" /> <Column title="奖项分类分数" dataIndex="score" />
<Column title="统计时间" dataIndex="startTime" /> <Column title="统计时间" dataIndex="startTime" />
<Column title="创建时间" dataIndex="createDate" /> <Column title="创建时间" dataIndex="createDate" />
<Column<IGrade> <Column<IGrade>
...@@ -203,9 +201,8 @@ const User = () => { ...@@ -203,9 +201,8 @@ const User = () => {
<Edit <Edit
visible={editVisible} visible={editVisible}
id={empId}
gradeId={gradeId} gradeId={gradeId}
empName={empName} empInfo={empInfo}
onClose={handleClose} onClose={handleClose}
/> />
</div> </div>
......
...@@ -10,3 +10,7 @@ ...@@ -10,3 +10,7 @@
export interface IGrade { export interface IGrade {
[key: string]: any; [key: string]: any;
} }
export interface IParams {
pageNum: number,
pageSize: number,
}
\ No newline at end of file \ No newline at end of file
/* /*
* @Author: yangming yangming@didihu.com.cn * @Author: yangming yangming@didihu.com.cn
* @Date: 2023-03-03 10:30:06 * @Date: 2023-03-03 10:30:06
* @LastEditors: yangming yangming@didihu.com.cn * @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2023-03-17 14:14:55 * @LastEditTime: 2023-05-12 18:49:59
* @FilePath: \achievements-system-front\src\views\Home\index.tsx * @FilePath: \achievements-system-front\src\views\Home\index.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/ */
...@@ -14,7 +14,7 @@ import { ...@@ -14,7 +14,7 @@ import {
ShopOutlined, ShopOutlined,
} from "@ant-design/icons"; } from "@ant-design/icons";
import { Menu, Dropdown, MenuProps, Button } from "antd"; import { Menu, Dropdown, MenuProps, Button } from "antd";
import { useNavigate, Outlet } from "react-router-dom"; import { useNavigate, Outlet, useLocation } from "react-router-dom";
const menus = [ const menus = [
{ {
...@@ -32,11 +32,17 @@ const menus = [ ...@@ -32,11 +32,17 @@ const menus = [
key: "classify", key: "classify",
icon: <AppstoreOutlined />, icon: <AppstoreOutlined />,
}, },
{
label: "指标",
key: "target",
icon: <ShopOutlined />,
},
]; ];
function Home() { function Home() {
const username = JSON.parse(sessionStorage.getItem("userInfo")!)?.username; const username = JSON.parse(sessionStorage.getItem("userInfo")!)?.username;
const [current, setCurrent] = useState("emp"); const location = useLocation();
const [current, setCurrent] = useState(location.pathname.replace(/\//, ""));
const navigateTo = useNavigate(); const navigateTo = useNavigate();
const onClick = (e: any) => { const onClick = (e: any) => {
navigateTo(e.key); navigateTo(e.key);
......
.ctnr { .ctnr {
display: flex; display: flex;
background: url('https://wx.glsx.com.cn/upload/biz/918f8b69-f055-4092-994d-5a16f10d55ff.jpeg') center/cover no-repeat; background: url("https://wx.glsx.com.cn/upload/biz/918f8b69-f055-4092-994d-5a16f10d55ff.jpeg") center/cover no-repeat;
position: fixed; position: fixed;
top: 0; top: 0;
right: 0; right: 0;
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
font-size: 24px; font-size: 24px;
font-weight: 600; font-weight: 600;
font-family: fangsong; font-family: fangsong;
padding: 10px 10px 20px; padding: 40px 10px 20px;
text-align: center; text-align: center;
} }
...@@ -30,5 +30,4 @@ ...@@ -30,5 +30,4 @@
font-size: 18px; font-size: 18px;
} }
} }
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: yangming yangming@didihu.com.cn * @Author: yangming yangming@didihu.com.cn
* @Date: 2023-03-03 10:30:06 * @Date: 2023-03-03 10:30:06
* @LastEditors: yangming yangming@didihu.com.cn * @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-03-17 14:37:08 * @LastEditTime: 2023-03-21 15:31:57
* @FilePath: \achievements-system-front\src\views\Login\index.tsx * @FilePath: \achievements-system-front\src\views\Login\index.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/ */
...@@ -53,9 +53,9 @@ const App = () => { ...@@ -53,9 +53,9 @@ const App = () => {
> >
<div className={styles.title}>绩效系统</div> <div className={styles.title}>绩效系统</div>
<Form.Item <Form.Item
label="员工姓名" label="用户名"
name="username" name="username"
rules={[{ required: true, message: "请输入员工姓名" }]} rules={[{ required: true, message: "请输入用户名" }]}
> >
<Input /> <Input />
</Form.Item> </Form.Item>
......
import React, { useEffect, useState } from "react";
import {
Drawer,
Form,
Input,
Select,
Button,
message,
InputNumber,
} from "antd";
import {
targetUpdateApi,
targetAddApi,
getTargetDetailApi,
} from "@/api/target";
import { TargetType } from "@/utils/constant";
// const roleList: any = constantMng.formatGroup("role", "value", "label");
const { TextArea } = Input;
const formItemLayout = {
labelCol: { span: 4 },
wrapperCol: { span: 20 },
};
interface IProps {
visible: boolean;
id: number;
onClose: () => void;
}
const Edit: React.FC<IProps> = (props) => {
const { id, visible, onClose } = props;
// 提交时的loading状态
// const [loading, setLoading] = useState(false)
const [detail, setDetail] = useState({
type: 1,
name: "",
weight: "",
illustrate: "",
module: "",
height: 0,
order: 1,
});
// 获取员工详情
useEffect(() => {
if (!id) {
setDetail({
type: 1,
name: "",
weight: "",
illustrate: "",
height: 0,
order: 1,
module: "",
});
return;
}
getTargetDetailApi({ id }).then((res) => {
setDetail(res.data);
});
}, [id]);
const handleSubmit = (values: any) => {
if (id) {
targetUpdateApi({ ...values, id }).then((res) => {
if (res.code == 200) {
onClose();
message.success("修改成功");
}
});
} else {
targetAddApi(values).then((res) => {
if (res.code == 200) {
onClose();
message.success("新增成功");
}
});
}
};
// const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
// const { value: inputValue } = e.target;
// console.log(inputValue);
// const reg = /^-?\d*(\.\d*)?$/;
// if (reg.test(inputValue) || inputValue === "" || inputValue === "-") {
// return 8;
// }
// };
const handleFinishFailed = () => {
message.warning("请按照正确格式填写信息!");
};
return (
<Drawer
title={`${id ? "修改" : "新增"}信息`}
width={800}
open={visible}
onClose={onClose}
footer={null}
destroyOnClose={true}
>
<Form
layout="horizontal"
colon
labelAlign="left"
{...formItemLayout}
onFinish={handleSubmit}
onFinishFailed={handleFinishFailed}
>
<Form.Item
label="指标"
name="name"
initialValue={detail.name}
rules={[
{
required: true,
message: "请输入指标!",
},
]}
>
<Input placeholder="请输入指标" />
</Form.Item>
<Form.Item
label="指标说明"
name="illustrate"
initialValue={detail.illustrate}
rules={[
{
required: true,
message: "请输入指标说明!",
},
]}
>
<TextArea rows={6} placeholder="请输入指标说明" />
</Form.Item>
<Form.Item
label="权重"
name="weight"
initialValue={detail.weight}
rules={[
{
required: true,
message: "请输入权重!",
},
]}
>
<Input placeholder="请输入权重" />
</Form.Item>
<Form.Item
label="高度"
name="height"
initialValue={detail.height}
rules={[
{
required: true,
message: "请输入高度!",
},
]}
>
<Input placeholder="请输入高度" />
</Form.Item>
<Form.Item
label="模块"
name="module"
initialValue={detail.module}
rules={[
{
required: true,
message: "请输入模块!",
},
]}
>
<Input placeholder="请输入模块" />
</Form.Item>
<Form.Item
label="排序"
name="order"
initialValue={detail.order}
rules={[
{
required: true,
message: "请输入排序!",
},
]}
>
<InputNumber placeholder="请输入排序" min={1} max={100} />
</Form.Item>
<Form.Item
label="指标归属"
name="type"
initialValue={detail.type}
rules={[
{
required: true,
message: "请输入指标说明!",
},
]}
>
<Select
style={{ width: 120 }}
options={TargetType}
fieldNames={{ label: "name", value: "id" }}
/>
</Form.Item>
<Form.Item wrapperCol={{ offset: 8 }}>
<Button onClick={onClose}>取消</Button>
<Button
type="primary"
htmlType="submit"
style={{ marginLeft: "20px" }}
>
确认
</Button>
</Form.Item>
</Form>
</Drawer>
);
};
export default Edit;
import React, { useEffect, useState, useCallback } from "react";
import {
Button,
Divider,
Input,
Row,
Col,
Popconfirm,
Table,
message,
Select,
Form,
} from "antd";
import { PlusOutlined, MinusOutlined } from "@ant-design/icons";
import Edit from "./components/Edit";
import { ITarget, IParams } from "./model";
import { TargetTypeFilter } from "@/utils/constant";
import { getTargetListApi, targetDeleteApi } from "@/api/target";
const { Column } = Table;
const User = () => {
const [search] = Form.useForm();
// 查询参数
const [params, setParams] = useState<IParams>({
pageNum: 1,
pageSize: 10,
});
// 表格当前页显示的数据
const [list, setList] = useState<ITarget[]>([]);
// 数据总数
const [total, setTotal] = useState(0);
// 表格loading状态
const [loading, setLoading] = useState(false);
// 编辑模态窗是否显示
const [editVisible, setEditVisible] = useState(false);
// 当前正在编辑的分类的id
const [targetId, setTargetId] = useState<number>(0);
const getTargetList = useCallback(async () => {
setLoading(true);
const res = await getTargetListApi({ params });
setLoading(false);
setList(res.data.rows);
setTotal(res.data.count);
}, [params]);
// 获取分类列表
useEffect(() => {
getTargetList();
}, [getTargetList]);
// 搜索
const handleSearch = (values: any) => {
setParams((state: any) => ({ ...state, ...values, pageNum: 1 }));
};
// 翻页
const handlePagination = (pageNum: number, pageSize?: number) => {
setParams((state: any) => ({
...state,
pageNum,
pageSize: pageSize!,
// type: search.getFieldValue("type"),
}));
};
// 新增或编辑
const handleEdit = (id: number) => {
setTargetId(id);
setTimeout(() => {
setEditVisible(true);
}, 300);
};
// 单个删除
const handleDeleteSingle = async (record: ITarget) => {
const { id, name } = record;
await targetDeleteApi({ id });
message.success(`成功删除“${name}”!`);
getTargetList();
};
// 取消
const handleClose = () => {
setEditVisible(false);
getTargetList();
};
return (
<div className="page-user">
<div className="add-btn">
<Button.Group>
<Button
type="primary"
icon={<PlusOutlined />}
onClick={handleEdit.bind(null, 0)}
>
新增
</Button>
</Button.Group>
</div>
<Row>
<Form
form={search}
layout="inline"
colon
labelAlign="left"
onFinish={handleSearch}
>
<Form.Item label="指标归属" name="type">
<Select
style={{ width: 220 }}
options={TargetTypeFilter}
fieldNames={{ label: "name", value: "id" }}
/>
</Form.Item>
<Form.Item wrapperCol={{ offset: 8 }}>
<Button type="primary" htmlType="submit">
查询
</Button>
</Form.Item>
</Form>
</Row>
<Table<ITarget>
dataSource={list}
rowKey="id"
loading={loading}
pagination={{
total,
current: params.pageNum,
pageSize: params.pageSize,
showQuickJumper: true,
showSizeChanger: true,
showTotal: (total) => `共${total}个分类`,
onChange: handlePagination,
}}
>
<Column
title="序号"
dataIndex="number"
width={80}
render={(value, record, index) =>
(params.pageNum - 1) * params.pageSize + index + 1
}
/>
<Column title="指标" dataIndex="name" />
<Column title="指标说明" dataIndex="illustrate" />
<Column title="权重" width={80} dataIndex="weight" />
<Column title="高度" width={80} dataIndex="height" />
<Column title="排序" width={80} dataIndex="order" />
<Column title="模块" width={100} dataIndex="module" />
<Column
title="指标归属"
width={100}
dataIndex="type"
render={(value) =>
TargetTypeFilter.find((i: any) => i.id == value)?.name
}
/>
<Column title="创建时间" width={180} dataIndex="createDate" />
<Column<ITarget>
title="操作"
dataIndex="operate"
width={140}
render={(value, record) => (
<div>
<Button
type="link"
size="small"
onClick={handleEdit.bind(null, record.id)}
>
编辑
</Button>
<Divider type="vertical" />
<Popconfirm
title="确定删除这条数据吗?"
onConfirm={handleDeleteSingle.bind(null, record)}
>
<Button type="link" size="small" danger={true}>
删除
</Button>
</Popconfirm>
</div>
)}
/>
</Table>
<Edit visible={editVisible} id={targetId} onClose={handleClose} />
</div>
);
};
export default User;
/*
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2023-04-27 10:49:26
* @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2023-04-27 10:50:59
* @FilePath: \achievements-system-front\src\views\Target\model.ts
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
// 指标信息
export interface ITarget {
name?: string;
type?: number;
illustrate?: string;
[key: string]: any;
}
export interface IParams {
pageNum: number,
pageSize: number,
}
\ No newline at end of file \ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: yangming yangming@didihu.com.cn * @Author: yangming yangming@didihu.com.cn
* @Date: 2023-03-03 10:30:06 * @Date: 2023-03-03 10:30:06
* @LastEditors: yangming yangming@didihu.com.cn * @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-03-10 10:21:15 * @LastEditTime: 2023-06-09 18:36:48
* @FilePath: \achievements-system-front\vite.config.ts * @FilePath: \achievements-system-front\vite.config.ts
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/ */
...@@ -32,8 +32,8 @@ export default defineConfig({ ...@@ -32,8 +32,8 @@ export default defineConfig({
css: { css: {
preprocessorOptions: { preprocessorOptions: {
less: { less: {
// additionalData: `@import "${path.resolve(__dirname, 'src/theme.module.less')}";`, additionalData: `@import "${path.resolve(__dirname, 'src/theme.module.less')}";`,
javascriptEnabled: true, // javascriptEnabled: true,
}, },
}, },
}, },
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!