diff --git a/.vscode/launch.json b/.vscode/launch.json index a1edc07..f060cb0 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -4,6 +4,26 @@ // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ + { + "type": "node", + "request": "launch", + "name": "启动 web", + "program": "${workspaceRoot}/web/server.js", + "env": { + "NODE_ENV": "development" + }, + "args": [ + "-p", "5700", + "-u","http://localhost:4700", + "--apiHrUrl", "http://localhost:4700", + // 测试 + "--qnak", "5XrM4wEB9YU6RQwT64sPzzE6cYFKZgssdP5Kj3uu", + "--qnsk", "w6j2ixR_i-aelc6I7S3HotKIX-ukMzcKmDfH6-M5", + "--qnbkt", "pep-process-report", + "--qndmn", "https://pepsource.anxinyun.cn", + "--wkys", "http://10.8.30.109:14000" + ] + }, { "type": "node", "request": "launch", @@ -15,31 +35,33 @@ "args": [ "-p 4700", // "-f http://localhost:4700", - // 研发 - "-g postgres://postgres:123456@10.8.16.184:5432/ReportCenter", + //南昌研发开始 + // "-g postgres://postgres:123456@10.8.16.184:5432/ReportCenter", + // "--redisHost localhost", + // "--redisPort 6378", + // "--apiEmisUrl http://localhost:4000", + //南昌研发结束 + // 镇江研发开始 + "-g postgres://FashionAdmin:123456@10.8.30.36:5432/data_center", "--redisHost localhost", - "--redisPort 6378", - // "--apiEmisUrl http://10.8.30.112:14000", + "--redisPort 6379", + "--apiEmisUrl http://localhost:14000", + // 镇江研发结束 // 测试 - "--apiEmisUrl http://localhost:4000", "--qnak XuDgkao6cL0HidoMAPnA5OB10Mc_Ew08mpIfRJK5", "--qnsk yewcieZLzKZuDfig0wLZ9if9jKp2P_1jd3CMJPSa", "--qnbkt dev-hr", // "--qndmn http://resources.anxinyun.cn", "--qndmn http://rjkwed13l.hn-bkt.clouddn.com", - // 似乎不能传空 先注释 * 2 // "--clickHouseUser ", // "--clickHousePassword ", - "--clickHousePort 30123", - // 开发 // "--clickHouseUrl http://10.8.30.71", // "--clickHousePepEmis pepca_dev", // "--clickHouseCamworkflow camworkflow", // "--clickHouseHr hr_dev", - // 测试 "--clickHouseUrl http://10.8.16.221", "--clickHousePepEmis pg_pepca", diff --git a/api/app/lib/controllers/auth/index.js b/api/app/lib/controllers/auth/index.js index 7c23a36..cfcc1f1 100644 --- a/api/app/lib/controllers/auth/index.js +++ b/api/app/lib/controllers/auth/index.js @@ -19,7 +19,7 @@ async function login (ctx, next) { emisLoginRes.authorized = true emisLoginRes.expired = moment().add(1, 'day') - emisLoginRes.hrUserInfo = undefined + emisLoginRes.dcUserInfo = undefined await ctx.redis.hmset(emisLoginRes.token, { expired: moment().add(1, 'day'), diff --git a/api/app/lib/controllers/report/index.js b/api/app/lib/controllers/report/index.js index ccf3581..5562e2f 100644 --- a/api/app/lib/controllers/report/index.js +++ b/api/app/lib/controllers/report/index.js @@ -2,15 +2,23 @@ // 查询储备项目统计表 async function getReserveItemReport(ctx, next) { - const { type } = ctx.request.query; + const { type } = ctx.params; let rslt = null; try { rslt = await ctx.fs.dc.models.ReserveItemReport.findAll({ order: [['year', 'DESC'], ['month', 'DESC']], where: { type: type } }) + let newReportData = rslt.map(e => { + return { + id: e.id, + date: e.year + '-' + e.month, + path: e.path, + type: e.type + } + }) ctx.status = 200 - ctx.body = rslt + ctx.body = newReportData } catch (error) { ctx.fs.logger.error(`path:${ctx.path},error:${error}`) ctx.status = 400; diff --git a/api/app/lib/routes/report/index.js b/api/app/lib/routes/report/index.js index 62b9527..0d4e04f 100644 --- a/api/app/lib/routes/report/index.js +++ b/api/app/lib/routes/report/index.js @@ -3,6 +3,6 @@ const report = require('../../controllers/report'); module.exports = function (app, router, opts) { - app.fs.api.logAttr['GET/getReserveItemReport'] = { content: '查询储备项目统计表', visible: false }; - router.get('/getReserveItemReport', report.getReserveItemReport); + app.fs.api.logAttr['GET/reserveItem/report/:type'] = { content: '查询储备项目统计表', visible: false }; + router.get('/reserveItem/report/:type', report.getReserveItemReport); }; \ No newline at end of file diff --git a/web/.vscode/extensions.json b/web/.vscode/extensions.json deleted file mode 100644 index 0925499..0000000 --- a/web/.vscode/extensions.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "recommendations": [ - "formulahendry.code-runner" - ] -} \ No newline at end of file diff --git a/web/.vscode/settings.json b/web/.vscode/settings.json deleted file mode 100644 index f5f67f5..0000000 --- a/web/.vscode/settings.json +++ /dev/null @@ -1,4 +0,0 @@ -// 将设置放入此文件中以覆盖默认值和用户设置。 -{ - "editor.fontSize": 16, -} \ No newline at end of file diff --git a/web/client/src/layout/actions/webSocket.js b/web/client/src/layout/actions/webSocket.js index 605748e..cd6cfce 100644 --- a/web/client/src/layout/actions/webSocket.js +++ b/web/client/src/layout/actions/webSocket.js @@ -2,19 +2,19 @@ import io from 'socket.io-client'; export const INIT_WEB_SOCKET = 'INIT_WEB_SOCKET' -export function initWebSocket ({ ioUrl, token, hrUserId }) { +export function initWebSocket ({ ioUrl, token, dcUserId }) { if (!ioUrl) { ioUrl = localStorage.getItem('apiRoot') ioUrl = JSON.parse(ioUrl).root } if (!token) { - let user = sessionStorage.getItem('hrUser') + let user = sessionStorage.getItem('dcUser') if (user) { user = JSON.parse(user) token = user.token } } - if (!ioUrl || !token || !hrUserId) { + if (!ioUrl || !token || !dcUserId) { return { type: '', } diff --git a/web/client/src/sections/auth/actions/auth.js b/web/client/src/sections/auth/actions/auth.js index d95db2b..afcb759 100644 --- a/web/client/src/sections/auth/actions/auth.js +++ b/web/client/src/sections/auth/actions/auth.js @@ -5,10 +5,10 @@ import { Request } from '@peace/utils'; export const INIT_AUTH = 'INIT_AUTH'; export function initAuth(userData) { - const sessionUser = JSON.parse(sessionStorage.getItem('hrUser')) + const sessionUser = JSON.parse(sessionStorage.getItem('dcUser')) const user = userData || sessionUser || {}; if (user.authorized && !sessionUser) { - sessionStorage.setItem('hrUser', JSON.stringify(user)) + sessionStorage.setItem('dcUser', JSON.stringify(user)) } return { type: INIT_AUTH, @@ -45,7 +45,7 @@ export function login(username, password) { return Request.post(ApiTable.login, { username, password, code: 'HR' }) .then(user => { - sessionStorage.setItem('hrUser', JSON.stringify(user)); + sessionStorage.setItem('dcUser', JSON.stringify(user)); return dispatch({ type: LOGIN_SUCCESS, payload: { user: user }, @@ -64,13 +64,13 @@ export function login(username, password) { export const LOGOUT = 'LOGOUT'; export function logout() { - const user = JSON.parse(sessionStorage.getItem('hrUser')) + const user = JSON.parse(sessionStorage.getItem('dcUser')) user && user.token ? Request.put(ApiTable.logout, { token: user.token, code: 'POMS' }) : null; - sessionStorage.removeItem('hrUser'); + sessionStorage.removeItem('dcUser'); localStorage.removeItem('poms_selected_sider'); localStorage.removeItem('poms_open_sider'); diff --git a/web/client/src/sections/auth/containers/login.jsx b/web/client/src/sections/auth/containers/login.jsx index b1f5f9d..4dfe39d 100644 --- a/web/client/src/sections/auth/containers/login.jsx +++ b/web/client/src/sections/auth/containers/login.jsx @@ -67,7 +67,7 @@ const Login = props => { dispatch(login(values.username, values.password)).then(res => { const data = res.payload.user localStorage.setItem('word', JSON.stringify(values.password)) - dispatch(actions.layout.initWebSocket({ ioUrl: apiRoot, token: data.token, hrUserId: data.hrUserInfo && hrUserInfo.id })) + dispatch(actions.layout.initWebSocket({ ioUrl: apiRoot, token: data.token, dcUserId: data.dcUserInfo && dcUserInfo.id })) }) }} getFormApi={formApi => form.current = formApi} diff --git a/web/client/src/sections/business/actions/index.js b/web/client/src/sections/business/actions/index.js index 970d06c..bc09861 100644 --- a/web/client/src/sections/business/actions/index.js +++ b/web/client/src/sections/business/actions/index.js @@ -1,5 +1,6 @@ 'use strict'; - +import * as reserveItem from './reserve-item'; export default { + ...reserveItem } \ No newline at end of file diff --git a/web/client/src/sections/business/actions/reserve-item.js b/web/client/src/sections/business/actions/reserve-item.js new file mode 100644 index 0000000..76ec1d1 --- /dev/null +++ b/web/client/src/sections/business/actions/reserve-item.js @@ -0,0 +1,13 @@ +'use strict'; +import { RouteTable, RouteRequest, ApiTable, basicAction } from '$utils'; + +export function getReserveItemReport(type) { + return dispatch => basicAction({ + type: 'get', + dispatch: dispatch, + actionType: 'GET_RESERVEITEM_REPORT', + url: `${ApiTable.getReserveItemReport.replace('{type}', type)}`, + msg: { error: '获取储备项目统计信息失败' }, + reducer: { name: 'reserveItemReport' } + }); +} \ No newline at end of file diff --git a/web/client/src/sections/business/actions/service.js b/web/client/src/sections/business/actions/service.js deleted file mode 100644 index 6ec0e10..0000000 --- a/web/client/src/sections/business/actions/service.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; -import { RouteTable, RouteRequest } from '$utils' - -export function getServiceUrl() { - return dispatch => { - return RouteRequest.get(RouteTable.getWeeklyService) - .then(res => { - return dispatch({ - type: "SERVER_WEEKLY_URL", - payload: res - }) - }); - } -} \ No newline at end of file diff --git a/web/client/src/sections/business/constants/index.js b/web/client/src/sections/business/constants/index.js new file mode 100644 index 0000000..0d9c9c0 --- /dev/null +++ b/web/client/src/sections/business/constants/index.js @@ -0,0 +1,5 @@ +export const RESERVEITEM_TYPE = { + periodicStatistics: 1, //周期统计 + depSummary: 2, + lostStatistic: 3 +} \ No newline at end of file diff --git a/web/client/src/sections/business/containers/pmLog.jsx b/web/client/src/sections/business/containers/pmLog.jsx index e6106a3..214e321 100644 --- a/web/client/src/sections/business/containers/pmLog.jsx +++ b/web/client/src/sections/business/containers/pmLog.jsx @@ -6,7 +6,7 @@ import { SkeletonScreen } from "$components"; import '../style.less' import { Setup } from "$components"; import moment from 'moment' -import { getServiceUrl } from '../actions/service'; +import { getServiceUrl } from '../actions/reserve-item'; const PMLog = (props) => { const { dispatch, actions, history, user, loading, socket } = props; diff --git a/web/client/src/sections/business/containers/reserveItemsDepSummary.jsx b/web/client/src/sections/business/containers/reserveItemsDepSummary.jsx index 5f46de5..bf9a4bc 100644 --- a/web/client/src/sections/business/containers/reserveItemsDepSummary.jsx +++ b/web/client/src/sections/business/containers/reserveItemsDepSummary.jsx @@ -1,11 +1,42 @@ import React, { useEffect, useState } from 'react'; import { connect } from 'react-redux'; -import { Select, Input, Button, RadioGroup, Radio, Tooltip } from '@douyinfe/semi-ui'; -import { IconSearch } from '@douyinfe/semi-icons'; +import { Select, Input, Table, Spin, Button } from '@douyinfe/semi-ui'; +import { RESERVEITEM_TYPE } from '../constants'; import '../style.less' -import moment from 'moment' const ReserveItemsDepSummary = (props) => { + const { dispatch, actions, isRequesting, reserveItemReport } = props; + const [downloadUrl, setDownloadUrl] = useState(null); + const [downloadKey, setDownloadKey] = useState(null); + useEffect(() => { + dispatch(actions.businessManagement.getReserveItemReport(RESERVEITEM_TYPE.depSummary)); + }, []); + + const exportReport = (url) => { + setDownloadUrl(`/_file-server${url}`); + setDownloadKey(Math.random()); + } + const columns = [ + { + title: '序号', + dataIndex: 'name', + render: (text, record, index) => index + 1 + }, + { + title: '时间', + dataIndex: 'date', + }, + { + title: '名称', + dataIndex: 'path', + }, + { + title: '操作', + dataIndex: 'action', + render: (text, record, indexe) => () + }, + ]; + return ( <> @@ -26,12 +57,17 @@ const ReserveItemsDepSummary = (props) => {
-
-
-
- 当前显示 -
-
+ { + downloadUrl ?