Browse Source

首页接入部分数据

master
liujiangyong 2 years ago
parent
commit
f59e80b487
  1. 115
      web/client/src/sections/homePage/actions/profile.js
  2. 81
      web/client/src/sections/homePage/containers/index.js
  3. 5
      web/client/src/utils/webapi.js

115
web/client/src/sections/homePage/actions/profile.js

@ -65,72 +65,6 @@ export function editName(userId, params) {
msg: { option: "修改姓名" },
});
}
// export function modifyEmailEnable(userId) {
// return (dispatch) =>
// basicAction({
// type: "post",
// dispatch: dispatch,
// actionType: "MODIFY_EMAILENABLE",
// url: ApiTable.modifyEmailEnable.replace("{userId}", userId),
// msg: { option: "启用邮件通知" },
// });
// }
// export function modifyEmailDisable(userId) {
// return (dispatch) =>
// basicAction({
// type: "post",
// dispatch: dispatch,
// actionType: "MODIFY_EMAILDISABLE",
// url: ApiTable.modifyEmailDisable.replace("{userId}", userId),
// msg: { option: "禁用邮件通知" },
// });
// }
// export function modifySmsEnable(userId) {
// return (dispatch) =>
// basicAction({
// type: "post",
// dispatch: dispatch,
// actionType: "MODIFY_SMSENABLE",
// url: ApiTable.modifySmsEnable.replace("{userId}", userId),
// msg: { option: "启用短信通知" },
// });
// }
// export function modifySmsDisable(userId) {
// return (dispatch) =>
// basicAction({
// type: "post",
// dispatch: dispatch,
// actionType: "MODIFY_SMSDISABLE",
// url: ApiTable.modifySmsDisable.replace("{userId}", userId),
// msg: { option: "禁用短信通知" },
// });
// }
// export function midifyDndEnable(userId) {
// return (dispatch) =>
// basicAction({
// type: "post",
// dispatch: dispatch,
// actionType: "MIDIFY_DNDENABLE",
// url: ApiTable.midifyDndEnable.replace("{userId}", userId),
// msg: { option: "开启免打扰" },
// });
// }
// export function modifyDndDisable(userId) {
// return (dispatch) =>
// basicAction({
// type: "post",
// dispatch: dispatch,
// actionType: "MIDIFY_DNDDISABLE",
// url: ApiTable.modifyDndDisable.replace("{userId}", userId),
// msg: { option: "关闭免打扰" },
// });
// }
export function getText(id) {
return (dispatch) =>
basicAction({
@ -158,17 +92,54 @@ export function getPartyMember() {
},
});
}
export function getProject() {
return (dispatch) =>
basicAction({
type: "post",
dispatch: dispatch,
actionType: "PROJECT",
url: ApiTable.projectUrl,
msg: { option: "获取本周在研项目" },
reducer: {
name: "project",
},
});
}
export function getPeople() {
return (dispatch) =>
basicAction({
type: "post",
dispatch: dispatch,
actionType: "PEOPLE",
url: ApiTable.peopleUrl,
msg: { option: "获取人员情况" },
reducer: {
name: "people",
},
});
}
export function getWait() {
return (dispatch) =>
basicAction({
type: "post",
dispatch: dispatch,
actionType: "WAIT",
url: ApiTable.waitUrl,
msg: { option: "获取待研发项目" },
reducer: {
name: "wait",
},
});
}
export default {
getProfile,
editProfile,
editpassword,
editName,
getText,
// modifyEmailEnable,
// modifyEmailDisable,
// modifySmsEnable,
// modifySmsDisable,
// midifyDndEnable,
// modifyDndDisable,
getPartyMember,
};

81
web/client/src/sections/homePage/containers/index.js

@ -2,17 +2,12 @@
import React, { useState, useEffect } from "react";
import { connect } from "react-redux";
import { Spin, Tabs, Table } from "antd";
import { LayoutContent } from "@peace/components";
import classnames from "classnames/bind";
import styles from "./index.less";
import { push } from "react-router-redux";
import moment from "moment";
import { getPartyMember } from "../actions/profile";
// const ROOTLESSNAME = "ly-alarm-configure-container-indexjs";
import { getProject, getPeople, getWait } from "../actions/profile";
const CX = classnames.bind(styles);
// function cx_(name) {
// return CX(`${ROOTLESSNAME}${name}`);
// }
const topImg = "/assets/images/top.png";
const pointImg = "/assets/images/point.png";
@ -22,29 +17,33 @@ function Management(props) {
const [dataSource, setDataSource] = useState([])
const currentCol = [
const [projectData, setProjectData] = useState([])
const [peopleData, setPeopleData] = useState([])
const [waitData, setWaitData] = useState([])
const projectCol = [
{
title: '项目名称',
dataIndex: 'name',
key: 'name',
dataIndex: 'name_project',
key: 'name_project',
align: 'center'
},
{
title: '投入人力',
dataIndex: 'worker',
key: 'worker',
dataIndex: 'part_people',
key: 'part_people',
align: 'center'
},
{
title: '构建时间',
dataIndex: 'buildTime',
key: 'buildTime',
dataIndex: 'build_time',
key: 'build_time',
align: 'center'
},
{
title: '发布时间',
dataIndex: 'releaseTime',
key: 'releaseTime',
dataIndex: 'publish_time',
key: 'publish_time',
align: 'center'
},
{
@ -74,7 +73,7 @@ function Management(props) {
key: 'monday',
align: 'center',
onCell: (record, index) => {
console.log("record, index: ", record, index);
// console.log("record, index: ", record, index);
return {
className: "cell-class",
colSpan: 2
@ -110,20 +109,20 @@ function Management(props) {
const waitCol = [
{
title: '项目',
dataIndex: 'name',
key: 'name',
dataIndex: 'name_project',
key: 'name_project',
align: 'center'
},
{
title: '需求来源',
dataIndex: 'source',
key: 'source',
dataIndex: 'from_project',
key: 'from_project',
align: 'center'
},
{
title: '对接人',
dataIndex: 'head',
key: 'head',
dataIndex: 'contacts',
key: 'contacts',
align: 'center'
},
{
@ -135,7 +134,34 @@ function Management(props) {
];
useEffect(() => {
// dispatch(getPartyMember()).then((res) => { });
dispatch(getProject()).then((res) => {
if (res.success) {
const nextData = res.payload?.data?.projects?.map((d, i) => ({
...d,
key: i,
build_time: moment(d.build_time).format("YYYY/MM/DD"),
publish_time: moment(d.publish_time).format("YYYY/MM/DD"),
part_people: d.part_people?.map(p => p.name_people).join(),
}));
setProjectData(nextData)
}
})
dispatch(getPeople()).then((res) => {
console.log(res, 'getPeople')
})
dispatch(getWait()).then((res) => {
if (res.success) {
const nextData = res.payload?.data?.projects?.map((d, i) => ({
...d,
key: i,
}));
setWaitData(nextData)
}
})
let nextData = []
for (let i = 1; i <= 34; i++) {
nextData.push({
@ -158,7 +184,7 @@ function Management(props) {
<div className={CX("index-main-box-title")}>本周在研项目</div>
<div className={CX("index-main-box-en")}>/Research project this week</div>
<Spin spinning={false}>
<Table dataSource={dataSource} columns={currentCol} size="middle" />
<Table dataSource={projectData} columns={projectCol} size="middle" />
</Spin>
</div>
<div className={CX("index-main-box")}>
@ -171,7 +197,7 @@ function Management(props) {
<img className={CX("index-main-box-point")} src={pointImg} />
<div className={CX("index-main-box-title")}>待研发项目</div>
<div className={CX("index-main-box-en")}>/Project to be developed</div>
<Table dataSource={dataSource} columns={waitCol} size="middle" />
<Table dataSource={waitData} columns={waitCol} size="middle" />
</div>
</div>
</div>
@ -203,13 +229,10 @@ function Management(props) {
);
}
function mapStateToProps(state) {
const { auth, global, party, articlesfrom } = state;
const { auth, global } = state;
return {
loding: party.isRequesting,
user: auth.user,
actions: global.actions,
articlesfrom: articlesfrom,
party: party || [],
};
}
export default connect(mapStateToProps)(Management);

5
web/client/src/utils/webapi.js

@ -2,6 +2,11 @@ import request from "superagent";
import noCache from "superagent-no-cache";
export const ApiTable = {
/* 研发看板 */
projectUrl: "outProject", // 在研项目
peopleUrl: "outPeople", // 人员情况
waitUrl: "outWait", // 待研项目
getDataList: "article/management", //全部资讯
delDataList: "article/management", //删除资讯
addArticle: "article/management",

Loading…
Cancel
Save