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: "修改姓名" }, 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) { export function getText(id) {
return (dispatch) => return (dispatch) =>
basicAction({ 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 { export default {
getProfile, getProfile,
editProfile, editProfile,
editpassword, editpassword,
editName, editName,
getText, getText,
// modifyEmailEnable,
// modifyEmailDisable,
// modifySmsEnable,
// modifySmsDisable,
// midifyDndEnable,
// modifyDndDisable,
getPartyMember, getPartyMember,
}; };

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

@ -2,17 +2,12 @@
import React, { useState, useEffect } from "react"; import React, { useState, useEffect } from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { Spin, Tabs, Table } from "antd"; import { Spin, Tabs, Table } from "antd";
import { LayoutContent } from "@peace/components";
import classnames from "classnames/bind"; import classnames from "classnames/bind";
import styles from "./index.less"; import styles from "./index.less";
import { push } from "react-router-redux"; import { push } from "react-router-redux";
import moment from "moment"; import moment from "moment";
import { getPartyMember } from "../actions/profile"; import { getProject, getPeople, getWait } from "../actions/profile";
// const ROOTLESSNAME = "ly-alarm-configure-container-indexjs";
const CX = classnames.bind(styles); const CX = classnames.bind(styles);
// function cx_(name) {
// return CX(`${ROOTLESSNAME}${name}`);
// }
const topImg = "/assets/images/top.png"; const topImg = "/assets/images/top.png";
const pointImg = "/assets/images/point.png"; const pointImg = "/assets/images/point.png";
@ -22,29 +17,33 @@ function Management(props) {
const [dataSource, setDataSource] = useState([]) const [dataSource, setDataSource] = useState([])
const currentCol = [ const [projectData, setProjectData] = useState([])
const [peopleData, setPeopleData] = useState([])
const [waitData, setWaitData] = useState([])
const projectCol = [
{ {
title: '项目名称', title: '项目名称',
dataIndex: 'name', dataIndex: 'name_project',
key: 'name', key: 'name_project',
align: 'center' align: 'center'
}, },
{ {
title: '投入人力', title: '投入人力',
dataIndex: 'worker', dataIndex: 'part_people',
key: 'worker', key: 'part_people',
align: 'center' align: 'center'
}, },
{ {
title: '构建时间', title: '构建时间',
dataIndex: 'buildTime', dataIndex: 'build_time',
key: 'buildTime', key: 'build_time',
align: 'center' align: 'center'
}, },
{ {
title: '发布时间', title: '发布时间',
dataIndex: 'releaseTime', dataIndex: 'publish_time',
key: 'releaseTime', key: 'publish_time',
align: 'center' align: 'center'
}, },
{ {
@ -74,7 +73,7 @@ function Management(props) {
key: 'monday', key: 'monday',
align: 'center', align: 'center',
onCell: (record, index) => { onCell: (record, index) => {
console.log("record, index: ", record, index); // console.log("record, index: ", record, index);
return { return {
className: "cell-class", className: "cell-class",
colSpan: 2 colSpan: 2
@ -110,20 +109,20 @@ function Management(props) {
const waitCol = [ const waitCol = [
{ {
title: '项目', title: '项目',
dataIndex: 'name', dataIndex: 'name_project',
key: 'name', key: 'name_project',
align: 'center' align: 'center'
}, },
{ {
title: '需求来源', title: '需求来源',
dataIndex: 'source', dataIndex: 'from_project',
key: 'source', key: 'from_project',
align: 'center' align: 'center'
}, },
{ {
title: '对接人', title: '对接人',
dataIndex: 'head', dataIndex: 'contacts',
key: 'head', key: 'contacts',
align: 'center' align: 'center'
}, },
{ {
@ -135,7 +134,34 @@ function Management(props) {
]; ];
useEffect(() => { 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 = [] let nextData = []
for (let i = 1; i <= 34; i++) { for (let i = 1; i <= 34; i++) {
nextData.push({ nextData.push({
@ -158,7 +184,7 @@ function Management(props) {
<div className={CX("index-main-box-title")}>本周在研项目</div> <div className={CX("index-main-box-title")}>本周在研项目</div>
<div className={CX("index-main-box-en")}>/Research project this week</div> <div className={CX("index-main-box-en")}>/Research project this week</div>
<Spin spinning={false}> <Spin spinning={false}>
<Table dataSource={dataSource} columns={currentCol} size="middle" /> <Table dataSource={projectData} columns={projectCol} size="middle" />
</Spin> </Spin>
</div> </div>
<div className={CX("index-main-box")}> <div className={CX("index-main-box")}>
@ -171,7 +197,7 @@ function Management(props) {
<img className={CX("index-main-box-point")} src={pointImg} /> <img className={CX("index-main-box-point")} src={pointImg} />
<div className={CX("index-main-box-title")}>待研发项目</div> <div className={CX("index-main-box-title")}>待研发项目</div>
<div className={CX("index-main-box-en")}>/Project to be developed</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> </div>
</div> </div>
@ -203,13 +229,10 @@ function Management(props) {
); );
} }
function mapStateToProps(state) { function mapStateToProps(state) {
const { auth, global, party, articlesfrom } = state; const { auth, global } = state;
return { return {
loding: party.isRequesting,
user: auth.user, user: auth.user,
actions: global.actions, actions: global.actions,
articlesfrom: articlesfrom,
party: party || [],
}; };
} }
export default connect(mapStateToProps)(Management); 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"; import noCache from "superagent-no-cache";
export const ApiTable = { export const ApiTable = {
/* 研发看板 */
projectUrl: "outProject", // 在研项目
peopleUrl: "outPeople", // 人员情况
waitUrl: "outWait", // 待研项目
getDataList: "article/management", //全部资讯 getDataList: "article/management", //全部资讯
delDataList: "article/management", //删除资讯 delDataList: "article/management", //删除资讯
addArticle: "article/management", addArticle: "article/management",

Loading…
Cancel
Save