Commit fa72a36e by 杨明

fixed

1 parent e0aec565
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
File mode changed
<!--
* @Author: yangming yangming@didihu.com.cn
* @Date: 2023-03-03 10:30:06
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-03-09 09:33:06
* @FilePath: \achievements-system-front\index.html
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
This diff could not be displayed because it is too large.
{
"name": "scrm-achievements-front",
"version": "0.1.0",
"name": "react_manage",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite --open",
"build": "tsc && vite build",
"preview": "vite preview"
},
"dependencies": {
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"@ant-design/icons": "^5.0.1",
"antd": "^5.2.2",
"axios": "^1.3.3",
"echarts": "^5.4.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
"react-redux": "^7.2.8",
"react-router-dom": "^6.3.0",
"redux": "^4.1.2",
"reset-css": "^5.0.1"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
"devDependencies": {
"@types/node": "^18.14.0",
"@types/react": "^18.0.27",
"@types/react-dom": "^18.0.10",
"@vitejs/plugin-react": "^3.1.0",
"dayjs": "^1.11.7",
"less": "^2.7.3",
"less-loader": "^11.1.0",
"moment": "^2.29.4",
"sass": "^1.58.3",
"typescript": "^4.9.3",
"vite": "^4.1.0",
"vite-plugin-style-import": "^1.4.1"
}
}
No preview for this file type
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
\ No newline at end of file
.App {
text-align: center;
}
.App-logo {
height: 40vmin;
pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}
.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}
.App-link {
color: #61dafb;
}
@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
import logo from './logo.svg';
import './App.css';
function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
);
}
export default App;
import { render, screen } from '@testing-library/react';
import App from './App';
test('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});
import RouterBeforeEach from "./router/routes";
function App() {
return (
<div className="App">
{/* {outlet} */}
<RouterBeforeEach />
</div>
);
}
export default App;
\ No newline at end of file
/*
* @Author: yangming yangming@didihu.com.cn
* @Date: 2023-03-06 17:00:05
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-03-16 16:23:20
* @FilePath: \achievements-system-front\src\api\request\emp.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 = {
getEmpList: "/emp/list",
empDelete: "/emp/delete",
empAdd: "/emp/add",
empUpdate: "/emp/update",
getEmpDetail: "/emp/detail",
downExcel: "/emp/downExcel",
};
export const getEmpListApi = (params: any) => {
return request.get(serverUrl.getEmpList, params);
};
export const empDeleteApi = (params: any) => {
return request.post(serverUrl.empDelete, params);
};
export const empAddApi = (params: any) => {
return request.post(serverUrl.empAdd, params);
};
export const empUpdateApi = (params: any) => {
return request.post(serverUrl.empUpdate, params);
};
export const getEmpDetailApi = (params: any) => {
return request.post(serverUrl.getEmpDetail, params);
};
export const downExcelApi = (params: any) => {
return request.get(serverUrl.downExcel, params);
};
/*
* @Author: yangming yangming@didihu.com.cn
* @Date: 2023-03-03 10:30:06
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-03-06 15:52:42
* @FilePath: \achievements-system-front\src\api\globalApi.ts
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import request from "@/api/request";
// import qs from "qs";
const serverUrl = {
login: "/login",
getGradeList: "/grade/list",
getEmpList: "/emp/list",
getProjectList: "/project/list"
};
// export const register = (params:any) => {
// return request.post(serverUrl.register, params)
// }
// export const getExistsemail = (params:any) => {
// return request.get(serverUrl.existsemail + '?' + qs.stringify(params))
// }
export const loginApi = (params: UserMessage) => {
return request.post(serverUrl.login, params);
};
export const getGradeListApi = (params: any) => {
return request.get(serverUrl.getGradeList, params);
};
export const getEmpListApi = (params: any) => {
return request.get(serverUrl.getEmpList, params);
};
export const getProjectListApi = (params: any) => {
return request.get(serverUrl.getProjectList, params);
};
/*
* @Author: yangming yangming@didihu.com.cn
* @Date: 2023-03-06 17:00:05
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-03-08 18:14:21
* @FilePath: \achievements-system-front\src\api\request\Project.ts
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import request from "@/api/request/index";
const serverUrl = {
getGradeList: "/grade/list",
gradeDelete: "/grade/delete",
gradeAdd: "/grade/add",
gradeUpdate: "/grade/update",
getGradeDetail: "/grade/detail",
};
export const getGradeListApi = (params: any) => {
return request.get(serverUrl.getGradeList, params);
};
export const gradeDeleteApi = (params: any) => {
return request.post(serverUrl.gradeDelete, params);
};
export const gradeAddApi = (params: any) => {
return request.post(serverUrl.gradeAdd, params);
};
export const gradeUpdateApi = (params: any) => {
return request.post(serverUrl.gradeUpdate, params);
};
export const getGradeDetailApi = (params: any) => {
return request.post(serverUrl.getGradeDetail, params);
};
/*
* @Author: yangming yangming@didihu.com.cn
* @Date: 2023-03-06 17:00:05
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-03-08 16:48:42
* @FilePath: \achievements-system-front\src\api\request\Project.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 = {
getProjectList: "/project/list",
projectDelete: "/project/delete",
projectAdd: "/project/add",
projectUpdate: "/project/update",
getProjectDetail: "/project/detail",
};
export const getProjectListApi = (params: any) => {
return request.get(serverUrl.getProjectList, params);
};
export const projectDeleteApi = (params: any) => {
return request.post(serverUrl.projectDelete, params);
};
export const projectAddApi = (params: any) => {
return request.post(serverUrl.projectAdd, params);
};
export const projectUpdateApi = (params: any) => {
return request.post(serverUrl.projectUpdate, params);
};
export const getProjectDetailApi = (params: any) => {
return request.post(serverUrl.getProjectDetail, params);
};
import HttpRequest from "./request";
const config = {
baseUrl: {
dev: "http://192.168.1.127:7001",
prod: "http://config-center-backend.glsx.com", //test环境
},
};
const baseUrl =
process.env.NODE_ENV === "development"
? config.baseUrl.dev
: config.baseUrl.prod;
const axios = new HttpRequest(baseUrl);
export default axios;
/*
* @Author: yangming yangming@didihu.com.cn
* @Date: 2023-03-03 10:30:06
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-03-17 11:25:12
* @FilePath: \achievements-system-front\src\api\request\request.ts
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
// 以class类来实现axios实例化
import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from "axios";
// 自定义 promise interface
class HttpRequest {
private baseUrl: string;
constructor(baseUrl: string) {
this.baseUrl = baseUrl;
}
// 获取axios实例的配置
getInsideConfig() {
const config = {
baseURL: this.baseUrl,
headers: {
"Content-Type": "application/json;charset=utf-8",
},
timeout: 1000 * 10,
};
return config;
}
// 设定拦截器
interceptors(instance: AxiosInstance) {
// 添加请求拦截器
instance.interceptors.request.use(
(config) => {
// 添加token
const token = sessionStorage.getItem("token") || "";
if (token) {
(config.headers as any).Authorization = "Bearer " + token;
}
// console.log('config:' + JSON.stringify(config))
// 在发送请求之前做些什么
return config;
},
(error: Error) => {
// 对请求错误做些什么
return Promise.reject(error);
}
);
// 添加响应拦截器
instance.interceptors.response.use(
(response) => {
const code = response.data.code;
console.log(code);
// 对响应数据做点什么
if (code === 401) {
sessionStorage.clear();
window.location.replace("/login");
// 跟上边直接返回都是一样的(也可以不加Promise.resolve)
return Promise.resolve(response.data);
} else if ( response.status == 200) {
return Promise.resolve(response.data);
} else {
return Promise.reject(response);
}
},
(error: Error) => {
return Promise.reject(Error);
}
);
}
// 创建实例
request(options: AxiosRequestConfig) {
const instance = axios.create();
const newOptions = Object.assign(this.getInsideConfig(), options);
this.interceptors(instance);
return instance(newOptions);
}
get(url: string, config?: AxiosRequestConfig): Promise<HttpResponse> {
const options = Object.assign(
{
method: "get",
url: url,
},
config
);
return this.request(options);
}
post(url: string, data?: any): Promise<HttpResponse> {
return this.request({
method: "post",
url: url,
data: data,
});
}
}
export default HttpRequest;
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>
\ No newline at end of file
$themeColor: #5261a1;
body {
// user-select: none;
}
img {
// -webkit-user-drag: none;
}
.page-user {
padding: 20px;
}
.ant-form {
margin-bottom: 20px;
}
.add-btn {
margin-bottom: 20px;
}
.flex-between {
display: flex;
justify-content: space-between;
}
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3"><g fill="#61DAFB"><path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/><circle cx="420.9" cy="296.5" r="45.7"/><path d="M520.5 78.1z"/></g></svg>
\ No newline at end of file
import React from 'react'
import ReactDOM from 'react-dom/client'
import 'reset-css'
import '@/assets/styles/global.scss'
import App from './App'
import { BrowserRouter } from "react-router-dom";
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
<React.StrictMode>
<BrowserRouter>
<App />
</BrowserRouter>
</React.StrictMode>
)
const reportWebVitals = onPerfEntry => {
if (onPerfEntry && onPerfEntry instanceof Function) {
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
getCLS(onPerfEntry);
getFID(onPerfEntry);
getFCP(onPerfEntry);
getLCP(onPerfEntry);
getTTFB(onPerfEntry);
});
}
};
export default reportWebVitals;
/*
* @Author: yangming yangming@didihu.com.cn
* @Date: 2023-03-03 10:30:06
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-03-17 11:26:44
* @FilePath: \achievements-system-front\src\router\index.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import React from "react";
import { lazy } from "react";
import { Navigate } from "react-router-dom";
const Home = lazy(() => import("@/views/Home/index"));
const Grade = lazy(() => import("@/views/Grade/index"));
const Classify = lazy(() => import("@/views/Classify/index"));
const Emp = lazy(() => import("@/views/Emp/index"));
const Login = lazy(() => import("@/views/Login/index"));
const WithLoadingComponent = (comp: any) => {
return (
<React.Suspense fallback={<div>Loading...</div>}>{comp}</React.Suspense>
);
};
const routers = [
{
path: "/",
element: <Navigate to="/login" />,
},
{
path: "/login",
element: <Login />,
},
{
path: "/",
element: <Home />,
children: [
{
path: "/grade",
element: WithLoadingComponent(<Grade />),
},
{
path: "/classify",
element: WithLoadingComponent(<Classify />),
},
{
path: "/emp",
element: WithLoadingComponent(<Emp />),
},
],
},
];
export default routers;
/*
* @Author: yangming yangming@didihu.com.cn
* @Date: 2023-03-03 10:30:06
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-03-17 13:31:04
* @FilePath: \achievements-system-front\src\router\routes.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import { useNavigate, useLocation } from "react-router-dom";
import { useRoutes } from "react-router-dom";
import { useEffect } from "react";
import router from "./index";
import { message } from "antd";
const RouterBeforeEach = () => {
const navigate = useNavigate();
const location = useLocation();
const outlet = useRoutes(router);
useEffect(() => {
if (location.pathname != "/login" && !sessionStorage.getItem("token")) {
message.error("请您先登录");
navigate("/login", { replace: true });
}
if (location.pathname == "/login" || location.pathname == "/") {
sessionStorage.clear();
}
}, [location.pathname]);
return outlet;
};
export default RouterBeforeEach;
// jest-dom adds custom jest matchers for asserting on DOM nodes.
// allows you to do things like:
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom';
/**
* 存放公共的类型声明文件
*/
interface HttpResponse {
code?: number;
data?: any;
message?: any; // 定义 字符串,对象类型
[propname: string]: any;
}
//项目分类
interface ProjectItem {
id?: number;
name: string;
addr: string;
remark: string;
[property: string]: any;
}
//项目分类里api
interface ProjectApi {
id?: number;
projectId: number;
method: string;
url: string;
baseUrl?: string;
remark: string;
content: string;
createDate?: Date;
updateDate?: Date;
}
//项目条件判断
interface ConditionItem {
id?: number;
name: string;
content: string;
createDate?: Date;
updateDate?: Date;
}
//员工相关信息
interface UserMessage {
username?: string;
password: string;
}
/*
* @Author: yangming yangming@didihu.com.cn
* @Date: 2023-03-07 16:09:51
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-03-07 16:13:01
* @FilePath: \achievements-system-front\src\utils\constant.ts
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
interface IItem {
id: number | string;
name: string;
[key: string]: any;
}
// 性别
const Gender: IItem[] = [
{
id: "0",
name: "男",
},
{
id: "1",
name: "女",
},
];
export { Gender };
/*
* @Author: yangming yangming@didihu.com.cn
* @Date: 2023-03-15 15:11:33
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-03-15 15:52:21
* @FilePath: \achievements-system-front\src\utils\util.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
const util = {};
const downFile = (content: any, filename: any) => {
// 创建隐藏的可下载链接
var eleLink = document.createElement("a");
eleLink.download = filename;
eleLink.style.display = "none";
// 字符内容转变成blob地址
var blob = new Blob([content]);
eleLink.href = URL.createObjectURL(blob);
document.body.appendChild(eleLink);
// 触发点击
eleLink.click();
// 然后移除
document.body.removeChild(eleLink);
};
export default {
downFile,
};
import React, { useEffect, useState } from "react";
import { Drawer, Form, Input, Radio, Button, message } from "antd";
import {
projectUpdateApi,
projectAddApi,
getProjectDetailApi,
} from "@/api/project";
import { Gender } from "@/utils/constant";
// const roleList: any = constantMng.formatGroup("role", "value", "label");
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({
projectScore: "",
projectName: "",
projectDesc: "",
});
// 获取员工详情
useEffect(() => {
if (!id) {
setDetail({
projectScore: "",
projectName: "",
projectDesc: "",
});
return;
}
getProjectDetailApi({ id }).then((res) => {
setDetail(res.data);
});
}, [id]);
const handleSubmit = (values: any) => {
if (id) {
projectUpdateApi({ ...values, id }).then((res) => {
if (res.code == 200) {
onClose();
message.success("修改成功");
}
});
} else {
projectAddApi(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={600}
open={visible}
onClose={onClose}
footer={null}
destroyOnClose={true}
>
<Form
layout="horizontal"
colon
labelAlign="left"
{...formItemLayout}
onFinish={handleSubmit}
onFinishFailed={handleFinishFailed}
>
<Form.Item
label="奖惩分类项"
name="projectName"
initialValue={detail.projectName}
rules={[
{
required: true,
message: "请输入奖惩分类项!",
},
]}
>
<Input placeholder="请输入奖惩分类项" />
</Form.Item>
<Form.Item
label="分类描述"
name="projectDesc"
initialValue={detail.projectDesc}
rules={[
{
required: true,
message: "请输入分类描述!",
},
]}
>
<Input placeholder="请输入分类描述" />
</Form.Item>
<Form.Item
label="分数"
name="projectScore"
initialValue={detail.projectScore}
rules={[
{
required: true,
message: "请输入分数!",
},
() => ({
validator(_, value) {
if (/^-?\d*(\.\d*)?$/.test(value)) {
return Promise.resolve();
}
return Promise.reject(new Error("请输入数字"));
},
}),
]}
>
<Input placeholder="请输入分数" />
</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,
Modal,
Popconfirm,
Table,
message,
DatePicker,
Form,
} from "antd";
import { PlusOutlined, MinusOutlined } from "@ant-design/icons";
import { Gender } from "@/utils/constant";
import Edit from "./components/Edit";
import { IProject } from "./model";
import { getProjectListApi, projectDeleteApi } from "@/api/project";
const { Column } = Table;
const User = () => {
// 查询参数
const [params, setParams] = useState<IParams>({
pageNum: 1,
pageSize: 10,
});
// 表格当前页显示的数据
const [list, setList] = useState<IProject[]>([]);
// 数据总数
const [total, setTotal] = useState(0);
// 表格loading状态
const [loading, setLoading] = useState(false);
// 编辑模态窗是否显示
const [editVisible, setEditVisible] = useState(false);
// 多选的表格行
const [selectedRows, setSelectedRows] = useState<IProject[]>([]);
// 当前正在编辑的分类的id
const [projectId, setProjectId] = useState<number>(0);
const getClassifyList = useCallback(async () => {
setLoading(true);
const res = await getProjectListApi({ params });
setLoading(false);
setList(res.data.rows);
setTotal(res.data.count);
}, [params]);
// 获取分类列表
useEffect(() => {
getClassifyList();
}, [getClassifyList]);
const search = {
projectName: "",
};
// 搜索
const handleSearch = (values: any) => {
setParams((state: any) => ({ ...state, ...values }));
};
// 翻页
const handlePagination = (pageNumber: number, pageSize?: number) => {
setParams((state: any) => ({ ...state, pageNumber, pageSize: pageSize! }));
};
// 新增或编辑
const handleEdit = (id: number) => {
setProjectId(id);
setTimeout(() => {
setEditVisible(true);
}, 300);
};
// 单个删除
const handleDeleteSingle = async (record: IProject) => {
const { id, name } = record;
await projectDeleteApi({ id });
message.success(`成功删除“${name}”!`);
getClassifyList();
};
// 批量删除
const handleDeleteBatch = () => {
if (selectedRows.length > 0) {
const ids = selectedRows.map((row) => row.id);
const names = selectedRows.map((row) => row.projectName).join(",");
Modal.confirm({
title: "确认删除以下该数据吗?",
content: names,
onOk: async () => {
await projectDeleteApi(ids);
message.success(`成功删除“${names}”!`);
getClassifyList();
},
});
} else {
message.warning("请选择要删除的数据");
}
};
// 多选
const handleChangeRows = (
selectedRowKeys: React.ReactText[],
selectedRows: IProject[]
) => {
setSelectedRows(selectedRows);
};
// 取消
const handleClose = () => {
setEditVisible(false);
getClassifyList();
};
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 layout="inline" colon labelAlign="left" onFinish={handleSearch}>
<Form.Item
label="奖项分类项"
name="projectName"
initialValue={search.projectName}
>
<Input placeholder="请输入奖项分类项" />
</Form.Item>
<Form.Item wrapperCol={{ offset: 8 }}>
<Button type="primary" htmlType="submit">
查询
</Button>
</Form.Item>
</Form>
</Row>
<Table<IProject>
dataSource={list}
rowKey="id"
loading={loading}
pagination={{
total,
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="projectName" />
<Column title="奖项分类描述" dataIndex="projectDesc" />
<Column title="奖项分类分" dataIndex="projectScore" />
<Column title="创建时间" dataIndex="createDate" />
<Column<IProject>
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={projectId} onClose={handleClose} />
</div>
);
};
export default User;
/*
* @Author: yangming yangming@didihu.com.cn
* @Date: 2023-03-08 16:45:32
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-03-08 16:45:47
* @FilePath: \achievements-system-front\src\views\Classify\model.ts
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
// 员工信息
export interface IProject {
projectName?: string;
projectDesc?: string;
projectScore?: number;
[key: string]: any;
}
import React, { useEffect, useState } from "react";
import { Drawer, Form, Input, Radio, Button, message } from "antd";
import { empUpdateApi, empAddApi, getEmpDetailApi } from "@/api/emp";
import { Gender } from "@/utils/constant";
// const roleList: any = constantMng.formatGroup("role", "value", "label");
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({
name: "",
sex: "",
department: "",
position: "",
score: "",
});
// 获取员工详情
useEffect(() => {
if (!id) {
setDetail({
name: "",
sex: "0",
department: "",
position: "",
score: "",
});
return;
}
getEmpDetailApi({ id }).then((res) => {
setDetail(res.data);
});
}, [id]);
const handleSubmit = (values: any) => {
if (id) {
empUpdateApi({ ...values, id }).then((res) => {
if (res.code == 200) {
onClose();
message.success("修改成功");
}
});
} else {
empAddApi(values).then((res) => {
if (res.code == 200) {
onClose();
message.success("新增成功");
}
});
}
};
const handleFinishFailed = () => {
message.warning("请按照正确格式填写信息!");
};
return (
<Drawer
title={`${id ? "修改" : "新增"}员工`}
width={600}
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="department"
initialValue={detail.department}
rules={[
{
required: true,
message: "请输入部门!",
},
]}
>
<Input placeholder="请输入部门" />
</Form.Item>
<Form.Item
label="职位"
name="position"
initialValue={detail.position}
rules={[
{
required: true,
message: "请输入职位!",
},
]}
>
<Input placeholder="请输入职位" />
</Form.Item>
<Form.Item
label="性别"
name="sex"
initialValue={detail.sex}
rules={[
{
required: true,
message: "请选择员工性别!",
},
]}
>
<Radio.Group>
{Gender.map((item) => (
<Radio key={item.id} value={item.id}>
{item.name}
</Radio>
))}
</Radio.Group>
</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 }}>
<Button onClick={onClose}>取消</Button>
<Button
type="primary"
htmlType="submit"
style={{ marginLeft: "20px" }}
>
确认
</Button>
</Form.Item>
</Form>
</Drawer>
);
};
export default Edit;
import React, { useEffect, useState } from "react";
import { Drawer, Form, Input, Button, message, Select, DatePicker } from "antd";
import moment from "moment";
import { gradeUpdateApi, gradeAddApi, getGradeDetailApi } from "@/api/grade";
import { getProjectListApi } from "@/api/project";
import { IProject } from "@/views/Classify/model";
import { Gender } from "@/utils/constant";
// const roleList: any = constantMng.formatGroup("role", "value", "label");
const { RangePicker } = DatePicker;
const formItemLayout = {
labelCol: { span: 4 },
wrapperCol: { span: 20 },
};
const dateFormat = "YYYY/MM/DD";
interface IProps {
visible: boolean;
id: number;
gradeId?: number;
empName: string;
onClose: () => void;
}
interface IDetail {
title: string;
empName: string;
projectId: string;
startTime: any;
}
const Edit: React.FC<IProps> = (props) => {
const { id, visible, onClose, empName, gradeId } = props;
// 提交时的loading状态
// const [loading, setLoading] = useState(false)
const [porjectList, setPorjectList] = useState<IProject[]>([]);
const [detail, setDetail] = useState<IDetail>({
title: "",
empName: "",
projectId: "",
startTime: "",
});
// 获取详情
useEffect(() => {
getProjectList();
setDetail({
title: "",
projectId: "",
startTime: "",
empName,
});
if (gradeId) {
getGradeDetailApi({ id: gradeId }).then((res) => {
const { title, projectId, empName, startTime } = res.data;
setDetail({
title,
projectId,
empName,
startTime: moment(startTime),
});
});
}
}, [id, gradeId]);
const handleSubmit = (values: any) => {
const startTime = moment(values.startTime).format("YYYY-MM-DD");
if (gradeId) {
gradeUpdateApi({ ...values, empId: id, startTime, id: gradeId }).then(
(res) => {
if (res.code == 200) {
onClose();
message.success("新增成功");
}
}
);
} else {
gradeAddApi({ ...values, empId: id, startTime }).then((res) => {
if (res.code == 200) {
onClose();
message.success("新增成功");
}
});
}
};
const getProjectList = async () => {
const res = await getProjectListApi({
params: { pageNum: 1, pageSize: 1000 },
});
console.log(res.data);
setPorjectList(res.data.rows);
};
const handleFinishFailed = () => {
message.warning("请按照正确格式填写信息!");
};
return (
<Drawer
title={`${id ? "修改" : "新增"}信息`}
width={600}
open={visible}
onClose={onClose}
footer={null}
destroyOnClose={true}
>
<Form
layout="horizontal"
colon
labelAlign="left"
{...formItemLayout}
onFinish={handleSubmit}
onFinishFailed={handleFinishFailed}
>
<Form.Item
label="员工姓名"
name="empName"
initialValue={detail.empName}
>
<Input disabled={true} />
</Form.Item>
<Form.Item
label="奖惩分类"
name="projectId"
initialValue={detail.projectId}
rules={[
{
required: true,
message: "请选择奖惩分类!",
},
]}
>
<Select
style={{ width: 120 }}
options={porjectList}
fieldNames={{ label: "projectName", value: "id" }}
/>
</Form.Item>
<Form.Item
label="奖惩描述"
name="title"
initialValue={detail.title}
rules={[
{
required: true,
message: "请输入奖惩描述!",
},
]}
>
<Input placeholder="请输入奖惩描述" />
</Form.Item>
<Form.Item
label="统计时间"
name="startTime"
initialValue={detail.startTime}
>
<DatePicker format={dateFormat} />
</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,
Modal,
Popconfirm,
Table,
message,
DatePicker,
Form,
} from "antd";
import { PlusOutlined, MinusOutlined } from "@ant-design/icons";
import { Gender } from "@/utils/constant";
import util from "@/utils/util";
import Edit from "./components/Edit";
import Prize from "./components/Prize";
import { IEmp } from "./model";
import { getEmpListApi, empDeleteApi, downExcelApi } from "@/api/emp";
import dayjs from "dayjs";
import "./style.scss";
import Search from "antd/es/transfer/search";
const { Column } = Table;
const { RangePicker } = DatePicker;
const User = () => {
// 查询参数
const [params, setParams] = useState<IParams>({
pageNum: 1,
pageSize: 10,
});
// 表格当前页显示的数据
const [list, setList] = useState<IEmp[]>([]);
// 数据总数
const [total, setTotal] = useState(0);
// 表格loading状态
const [loading, setLoading] = useState(false);
// 编辑模态窗是否显示
const [editVisible, setEditVisible] = useState(false);
const [prizeVisible, setPrizeVisible] = useState(false);
// 多选的表格行
const [selectedRows, setSelectedRows] = useState<IEmp[]>([]);
// 当前正在编辑的员工的id
const [empId, setempId] = useState<number>(0);
const [empName, setempName] = useState<string>("");
const getUserList = useCallback(async () => {
setLoading(true);
const res = await getEmpListApi({ params });
setLoading(false);
setList(res.data.rows);
setTotal(res.data.count);
}, [params]);
const dateFormat = "YYYY/MM/DD";
// 获取员工列表
useEffect(() => {
getUserList();
}, [getUserList]);
const search = {
name: "",
time: "",
};
const formatTime = (values: any[]) => {
if (values) {
return {
startTime: dayjs(values[0]).format("YYYY-MM-DD"),
endTime: dayjs(values[1]).format("YYYY-MM-DD"),
};
}
};
// 搜索
const handleSearch = (values: any) => {
if (values.time) {
values.startTime = dayjs(values.time[0]).format("YYYY-MM-DD");
values.endTime = dayjs(values.time[1]).format("YYYY-MM-DD");
delete values.time;
} else {
values.startTime = "";
values.endTime = "";
}
setParams((state: any) => ({ ...state, ...values }));
};
const changeTime = (value: any) => {
setParams((state: any) => ({ ...state, ...formatTime(value) }));
};
//导出
const exportUrl = useCallback(async () => {
let paramsTime = {};
const { startTime, endTime } = params;
console.log(startTime, endTime);
if (startTime) {
paramsTime = {
startTime,
endTime,
};
}
const url = await downExcelApi({
params: paramsTime,
responseType: "blob",
});
console.log(url);
util.downFile(url, "员工信息.xlsx");
}, [search]);
// 翻页
const handlePagination = (pageNumber: number, pageSize?: number) => {
setParams((state: any) => ({ ...state, pageNumber, pageSize: pageSize! }));
};
// 新增或编辑
const handleEdit = (id: number) => {
setempId(id);
setTimeout(() => {
setEditVisible(true);
}, 300);
};
const handlePrize = (record: IEmp) => {
const { id, name } = record;
setempId(id);
setempName(name);
setTimeout(() => {
setPrizeVisible(true);
}, 300);
};
// 单个删除
const handleDeleteSingle = async (record: IEmp) => {
const { id, name } = record;
await empDeleteApi({ id });
message.success(`成功删除员工“${name}”!`);
getUserList();
};
// 批量删除
const handleDeleteBatch = () => {
if (selectedRows.length > 0) {
const ids = selectedRows.map((row) => row.id);
const names = selectedRows.map((row) => row.name).join(",");
Modal.confirm({
title: "确认删除以下员工吗?",
content: names,
onOk: async () => {
await empDeleteApi(ids);
message.success(`成功删除员工“${names}”!`);
getUserList();
},
});
} else {
message.warning("请选择要删除的员工");
}
};
// 取消
const handleClose = () => {
setEditVisible(false);
setPrizeVisible(false);
getUserList();
};
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 layout="inline" colon labelAlign="left" onFinish={handleSearch}>
<Form.Item label="姓名" name="name" initialValue={search.name}>
<Input placeholder="请输入姓名" />
</Form.Item>
<Form.Item label="统计时间" name="time" initialValue={search.time}>
<RangePicker format={dateFormat} onChange={changeTime} />
</Form.Item>
<Form.Item wrapperCol={{ offset: 8 }}>
<Button type="primary" htmlType="submit">
查询
</Button>
</Form.Item>
<Form.Item wrapperCol={{ offset: 8 }}>
<Button type="primary" htmlType="button" onClick={exportUrl}>
导出
</Button>
</Form.Item>
</Form>
</Row>
<Table<IEmp>
dataSource={list}
rowKey="id"
loading={loading}
pagination={{
total,
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="sex"
render={(value) => Gender.find((i: any) => i.id == value)?.name}
/>
<Column title="部门" dataIndex="position" />
<Column title="职位" dataIndex="department" />
<Column title="总成绩" dataIndex="score" />
<Column title="创建时间" dataIndex="createDate" />
<Column<IEmp>
title="操作"
dataIndex="operate"
width={210}
render={(value, record) => (
<div>
<Button
type="link"
size="small"
onClick={handlePrize.bind(null, record)}
>
奖惩
</Button>
<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={empId} onClose={handleClose} />
<Prize
visible={prizeVisible}
id={empId}
empName={empName}
onClose={handleClose}
/>
</div>
);
};
export default User;
// 员工信息
export interface IEmp {
id: number;
name: string;
position: string;
sex: string;
department: string;
score: string;
[key: string]: any;
}
page-user {
padding: 24px;
background-color: #fff;
.section-title {
display: inline-block;
margin-right: 10px;
.section-title__tag {
display: inline-block;
width: 6px;
height: 18px;
// background-color: @theme-color;
border-radius: 50%;
vertical-align: middle;
}
.section-title__name {
font-size: 18px;
margin-left: 10px;
vertical-align: middle;
}
}
}
\ No newline at end of file
import React, { useEffect, useState, useCallback } from "react";
import {
Button,
Divider,
Input,
Row,
Col,
Modal,
Popconfirm,
Table,
message,
DatePicker,
Form,
} from "antd";
import { PlusOutlined, MinusOutlined } from "@ant-design/icons";
import Edit from "../Emp/components/Prize";
import { IGrade } from "./model";
import dayjs from "dayjs";
import { getGradeListApi, gradeDeleteApi } from "@/api/grade";
import Search from "antd/es/transfer/search";
const { Column } = Table;
const { RangePicker } = DatePicker;
const User = () => {
// 查询参数
const [params, setParams] = useState<IParams>({
pageNum: 1,
pageSize: 10,
});
// 表格当前页显示的数据
const [list, setList] = useState<IGrade[]>([]);
// 数据总数
const [total, setTotal] = useState(0);
// 表格loading状态
const [loading, setLoading] = useState(false);
// 编辑模态窗是否显示
const [editVisible, setEditVisible] = useState(false);
// 多选的表格行
const [selectedRows, setSelectedRows] = useState<IGrade[]>([]);
// 当前正在编辑的奖惩的id
const [gradeId, setGradeId] = useState<number>(0);
const [empId, setEmpId] = useState<number>(0);
const [empName, setEmpName] = useState<string>("");
const getGradeList = useCallback(async () => {
setLoading(true);
const res = await getGradeListApi({ params });
setLoading(false);
setList(res.data.rows);
setTotal(res.data.count);
}, [params]);
const dateFormat = "YYYY/MM/DD";
// 获取列表
useEffect(() => {
getGradeList();
}, [getGradeList]);
const search = {
empName: "",
time: [],
};
const handleSearch = (values: any) => {
console.log(values.time, 111);
if (values.time && values.time.length) {
values.startTime = dayjs(values.time[0]).format("YYYY-MM-DD");
values.endTime = dayjs(values.time[1]).format("YYYY-MM-DD");
delete values.time;
} else {
values.startTime = "";
values.endTime = "";
}
console.log(values);
setParams((state: any) => ({ ...state, ...values }));
};
// 翻页
const handlePagination = (pageNumber: number, pageSize?: number) => {
setParams((state: any) => ({ ...state, pageNumber, pageSize: pageSize! }));
};
// 新增或编辑
const handleEdit = (record: IGrade) => {
const { id, empId, empName } = record;
setGradeId(id);
setEmpId(empId);
setEmpName(empName);
setTimeout(() => {
setEditVisible(true);
}, 300);
};
// 单个删除
const handleDeleteSingle = async (record: IGrade) => {
const { id, name } = record;
await gradeDeleteApi({ id });
message.success(`成功删除该数据!`);
getGradeList();
};
// 批量删除
const handleDeleteBatch = () => {
if (selectedRows.length > 0) {
const ids = selectedRows.map((row) => row.id);
const names = selectedRows.map((row) => row.projectName).join(",");
Modal.confirm({
title: "确认删除以下该数据吗?",
content: names,
onOk: async () => {
await gradeDeleteApi(ids);
message.success(`成功删除“${names}”!`);
getGradeList();
},
});
} else {
message.warning("请选择要删除的数据");
}
};
// 多选
const handleChangeRows = (
selectedRowKeys: React.ReactText[],
selectedRows: IGrade[]
) => {
setSelectedRows(selectedRows);
};
// 取消
const handleClose = () => {
setEditVisible(false);
getGradeList();
};
return (
<div className="page-user">
<Row>
<Form layout="inline" colon labelAlign="left" onFinish={handleSearch}>
<Form.Item label="姓名" name="empName" initialValue={search.empName}>
<Input placeholder="请输入姓名" />
</Form.Item>
<Form.Item label="统计时间" name="time" initialValue={search.time}>
<RangePicker format={dateFormat} />
</Form.Item>
<Form.Item wrapperCol={{ offset: 8 }}>
<Button type="primary" htmlType="submit">
查询
</Button>
</Form.Item>
</Form>
</Row>
<Table<IGrade>
dataSource={list}
rowKey="id"
loading={loading}
pagination={{
total,
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="empName" />
<Column title="奖惩描述" dataIndex="title" />
<Column title="部门" dataIndex="position" />
<Column title="职位" dataIndex="department" />
<Column title="奖项分类项" dataIndex="projectName" />
<Column title="奖项分类描述" dataIndex="projectDesc" />
<Column title="奖项分类分" dataIndex="projectScore" />
<Column title="统计时间" dataIndex="startTime" />
<Column title="创建时间" dataIndex="createDate" />
<Column<IGrade>
title="操作"
dataIndex="operate"
width={140}
render={(value, record) => (
<div>
<Button
type="link"
size="small"
onClick={handleEdit.bind(null, record)}
>
编辑
</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={empId}
gradeId={gradeId}
empName={empName}
onClose={handleClose}
/>
</div>
);
};
export default User;
/*
* @Author: yangming yangming@didihu.com.cn
* @Date: 2023-03-08 18:02:32
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-03-08 18:03:17
* @FilePath: \achievements-system-front\src\views\Grade\model.ts
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
// 员工信息
export interface IGrade {
[key: string]: any;
}
/*
* @Author: yangming yangming@didihu.com.cn
* @Date: 2023-03-03 10:30:06
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-03-17 14:14:55
* @FilePath: \achievements-system-front\src\views\Home\index.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import React, { useState } from "react";
import {
ProfileOutlined,
AppstoreOutlined,
UserOutlined,
ShopOutlined,
} from "@ant-design/icons";
import { Menu, Dropdown, MenuProps, Button } from "antd";
import { useNavigate, Outlet } from "react-router-dom";
const menus = [
{
label: "员工管理",
key: "emp",
icon: <UserOutlined />,
},
{
label: "绩效明细",
key: "grade",
icon: <ProfileOutlined />,
},
{
label: "绩效分类",
key: "classify",
icon: <AppstoreOutlined />,
},
];
function Home() {
const username = JSON.parse(sessionStorage.getItem("userInfo")!)?.username;
const [current, setCurrent] = useState("emp");
const navigateTo = useNavigate();
const onClick = (e: any) => {
navigateTo(e.key);
setCurrent(e.key);
};
const logout = () => {
window.location.replace("/login");
sessionStorage.clear();
};
const items: MenuProps["items"] = [
{
key: "1",
label: <a onClick={logout}>退出登录</a>,
},
];
return (
<>
<div className="flex-between">
<Menu
onClick={onClick}
selectedKeys={[current]}
mode="horizontal"
items={menus}
/>
<Dropdown menu={{ items }} placement="bottom" arrow>
<Button size="large" type="link">
{username}
</Button>
</Dropdown>
</div>
<Outlet />
</>
);
}
export default Home;
.ctnr {
display: flex;
background: url('https://wx.glsx.com.cn/upload/biz/918f8b69-f055-4092-994d-5a16f10d55ff.jpeg') center/cover no-repeat;
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
.title {
font-size: 24px;
font-weight: 600;
font-family: fangsong;
padding: 10px 10px 20px;
text-align: center;
}
.form {
position: fixed;
border-radius: 8px;
left: 50%;
transform: translate(-50%, 200px);
width: 520px;
height: 350px;
background-color: #fff;
.btn {
width: 200px;
height: 42px;
font-size: 18px;
}
}
}
\ No newline at end of file
/*
* @Author: yangming yangming@didihu.com.cn
* @Date: 2023-03-03 10:30:06
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-03-17 14:37:08
* @FilePath: \achievements-system-front\src\views\Login\index.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import { useNavigate } from "react-router-dom";
import { loginApi } from "@/api/globalApi";
import styles from "./index.module.scss";
import { Button, Checkbox, Form, Input, message } from "antd";
const App = () => {
const navigate = useNavigate();
const onFinish = (values: any) => {
const { username, password } = values;
const params = { username, password };
loginApi(params)
.then(({ code, data, msg }) => {
console.log(code);
if (code === 200) {
window.sessionStorage.setItem("token", data && data.token);
window.sessionStorage.setItem(
"userInfo",
data && data.user && JSON.stringify(data.user)
);
navigate("/emp");
} else {
message.error(msg);
}
})
.catch(({ message: msg }) => {
message.error(msg);
});
};
const onFinishFailed = (errorInfo: any) => {
console.log("Failed:", errorInfo);
};
return (
<div className={styles.ctnr}>
<Form
name="basic"
labelCol={{ span: 6 }}
wrapperCol={{ span: 16 }}
style={{ maxWidth: 600 }}
initialValues={{ remember: true }}
onFinish={onFinish}
onFinishFailed={onFinishFailed}
autoComplete="off"
className={styles.form}
>
<div className={styles.title}>绩效系统</div>
<Form.Item
label="员工姓名"
name="username"
rules={[{ required: true, message: "请输入员工姓名" }]}
>
<Input />
</Form.Item>
<Form.Item
label="密码"
name="password"
rules={[{ required: true, message: "请输入密码" }]}
>
<Input.Password />
</Form.Item>
<Form.Item
name="remember"
valuePropName="checked"
wrapperCol={{ offset: 6, span: 16 }}
>
<Checkbox>记住密码</Checkbox>
</Form.Item>
<Form.Item wrapperCol={{ offset: 8, span: 24 }}>
<Button className={styles.btn} type="primary" htmlType="submit">
登录
</Button>
</Form.Item>
</Form>
</div>
);
};
export default App;
import React, { useState } from 'react';
function Mine() {
return <div>Mine</div>
}
export default Mine
\ No newline at end of file
/*
* @Author: yangming yangming@didihu.com.cn
* @Date: 2023-03-03 10:30:06
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-03-06 15:53:10
* @FilePath: \achievements-system-front\src\views\Ranking\index.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import { useEffect } from 'react';
import * as echarts from 'echarts';
import { echartData } from '@/views/constantData'
import { getGradeListApi,getEmpListApi,getProjectListApi } from "@/api/globalApi";
let echartOptions = echartData
function Ranking() {
let myChart: any = null;
const initChart = () => {
let element: any = document.getElementById('chartDom');
myChart = echarts.init(element);
myChart.clear()
echartOptions && myChart.setOption(echartOptions);
}
const getGradeList = async () => {
const gradeList = await getGradeListApi({params: { pageSize: 13, pageNum: 1 }})
await getEmpListApi({params: { pageSize: 13, pageNum: 1 }})
await getProjectListApi({params: { pageSize: 13, pageNum: 1 }})
console.log(gradeList, 'gradeList')
}
getGradeList()
useEffect(() => {
initChart()
window.addEventListener("resize", () => {
myChart && myChart.resize();
});
// 组件销毁前卸载监听方法
return () => {
window.removeEventListener("resize", () => {
myChart && myChart.resize();
});
}
}, [])
return (
<div id='chartDom' style={{ width: '80%', margin: '0 auto', height: '600px' }}></div>
)
}
export default Ranking
\ No newline at end of file
const echartData = {
legend: {},
tooltip: {},
dataset: {
dimensions: ["product", "2015", "2016", "2017"],
source: [
["product", "2015", "2016", "2017"],
["Matcha Latte", 43.3, 85.8, 93.7],
["Milk Tea", 83.1, 73.4, 55.1],
["Cheese Cocoa", 86.4, 65.2, 82.5],
["Walnut Brownie", 72.4, 53.9, 39.1],
],
},
xAxis: { type: "category" },
yAxis: {},
// Declare several bar series, each will be mapped
// to a column of dataset.source by default.
series: [{ type: "bar" }, { type: "bar" }, { type: "bar" }],
};
export { echartData };
/// <reference types="vite/client" />
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"baseUrl": "./",
"paths": {
"@/*" : [
"src/*"
]
}
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}
{
"compilerOptions": {
"composite": true,
"module": "ESNext",
"moduleResolution": "Node",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}
/*
* @Author: yangming yangming@didihu.com.cn
* @Date: 2023-03-03 10:30:06
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-03-10 10:21:15
* @FilePath: \achievements-system-front\vite.config.ts
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import * as path from "path";
import styleImport, { AntdResolve } from "vite-plugin-style-import";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
styleImport({
resolves: [AntdResolve()],
}),
],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
server: {
host: "0.0.0.0",
port: 7005,
// 是否开启 https
https: false,
},
css: {
preprocessorOptions: {
less: {
// additionalData: `@import "${path.resolve(__dirname, 'src/theme.module.less')}";`,
javascriptEnabled: true,
},
},
},
});
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!