Browse Source

增加字段

master
xingyongchun 2 years ago
parent
commit
1a29c1411b
  1. 12
      web/client/src/sections/homePage/containers/index.js
  2. 163
      web/client/src/sections/wait/components/import_model.js
  3. 7
      web/client/src/sections/wait/components/modeal.js
  4. 8
      web/client/src/sections/wait/containers/index.js

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

@ -171,6 +171,11 @@ function Management(props) {
dataIndex: 'contacts',
key: 'contacts',
align: 'center'
},{
title: '评估工时',
dataIndex: 'consum_time',
key: 'consum_time',
align: 'center'
},
{
title: '处理进度',
@ -178,6 +183,7 @@ function Management(props) {
key: 'progress',
align: 'center'
},
];
return (
<>
@ -189,20 +195,20 @@ 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={projectData} columns={projectCol} size="middle" />
<Table dataSource={projectData} columns={projectCol} size="middle" pagination={false} scroll={{x:500}}/>
</Spin>
</div>
<div className={CX("index-main-box")}>
<img className={CX("index-main-box-point")} src={pointImg} />
<div className={CX("index-main-box-title")}>人员情况</div>
<div className={CX("index-main-box-en")}>/Information on Personnel</div>
<Table dataSource={peopleData} columns={peopleCol} size="middle" />
<Table dataSource={peopleData} columns={peopleCol} size="middle" pagination={false} scroll={{x:500}}/>
</div>
<div className={CX("index-main-box")}>
<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={waitData} columns={waitCol} size="middle" />
<Table dataSource={waitData} columns={waitCol} size="middle" pagination={false} scroll={{x:500}}/>
</div>
</div>
</div>

163
web/client/src/sections/wait/components/import_model.js

@ -1,163 +0,0 @@
/*
* @description :
* @Date : 2021-04-07 14:39:33
* @FilePath : \web\client\src\sections\user\components\userManagement\importUser.js
* @useStrict : use strict
*/
'use strict';
import React, { useState } from 'react';
import { connect } from 'react-redux';
import { Button, Input, Card, Modal, Upload, message } from 'antd';
import { Request } from '@peace/utils'
import request from 'superagent'
import XLSX from 'xlsx'
// import { userBulkAdd } from '../../actions'
//TODO 下载模板和上传文件读取
const ImportUser = props => {
const { user, dispatch, handleCancel, params,editData } = props
const [msg, setMsg] = useState('')
const [loading, setLoading] = useState('')
const [postData, setPostData] = useState([])
const confirm = () => {
if (postData.length) {
setLoading(true)
// dispatch(userBulkAdd(postData, params.departmentId ? params.departmentId : null)).then(res => {
// if (res.success) {
// }
// setLoading(false)
// })
} else {
message.warn('没有数据可以提交,请上传数据文件')
}
}
return (
<Modal
visible={props.importVisible}
onOk={confirm}
confirmLoading={loading}
onCancel={() => {
setMsg('')
setLoading(false)
setPostData([])
handleCancel()
}}
destroyOnClose
>
{/* <Button size="small" type='primary' onClick={() => {
Request.get(`attachments?src=upload/files/1.jpg&filename=${encodeURIComponent('1.jpg')}&token=${user.token}`).then(res => {
})
}}>下载模板</Button> */}
<a href={`/assets/人员信息.xlsx`} >
<Button size="small" type='primary' >下载模板</Button>
</a>
<div style={{ marginTop: 10 }}>下载模板后填写完整后上传</div>
<div style={{ marginTop: 10 }}>
<Upload {...{
name: 'user_d',
action: '/',
maxCount: 1,
showUploadList: {
showRemoveIcon: false
},
beforeUpload: (file) => {
setMsg('')
setPostData([])
const extNames = file.name.split('.');
let isDAE = false;
if (extNames.length > 0) {
let fileType = extNames[extNames.length - 1].toLowerCase();
isDAE = ['xlsx', 'xls'].some((f) => f == fileType);
}
if (!isDAE) {
setMsg(`只能上传 ${['xlsx', 'xls'].join()} 格式的文件!`);
return false;
}
},
onChange(info) {
},
customRequest: async (data) => {
const { file, onSuccess, onError } = data
const reader = new FileReader(); // 使用 FileReader 读取数据
reader.onload = function (e) { // 数据读取完成后的回调函数
const data = new Uint8Array(e.target.result);
const workbook = XLSX.read(data, { type: 'array' }); // workbook 是 xlsx 解析 excel 后返回的对象
const firstSheetName = workbook.SheetNames[0]; // 获取第一个 sheet 的名字
const worksheet = workbook.Sheets[firstSheetName]; // 获取第一个 sheet 的内容
const res = XLSX.utils.sheet_to_json(worksheet); // 使用 utils 里的方法转换内容为便于使用的数组
const error = (msg) => {
setMsg(msg)
onError({ message: msg })
}
if (res.length > 1000) {
error('一次性上传数据行数应小于1000行,请分批上传')
return
}
if (!res.length) {
error('请填写至少一行数据')
return
}
let postData = []
const pattern = /^1[3|4|5|6|7|8|9]\d{9}$/
for (let i = 0; i < res.length; i++) {
let d = res[i]
let name = String(d['姓名']).trim();
let phone = String(d['手机号码']).trim();
let account = String(d['账号']).trim();
let peopleCode = d['人员编号'] && String(d['人员编号']).trim();
if (!name || !phone || !account || !peopleCode) {
error(`${i + 1} 行有空值,请填写后重新上传`)
return
}
if (!pattern.test(phone)) {
error(`${i + 1} 行手机号码错误`)
return
}
if (name.length > 128 || account.length > 128) {
error(`${i + 1} 行数据字符长度大于 128,请更改后重新上传`)
return
}
if (postData.some(p => p.account == account)) {
error(`${i + 1} 行账号重复,请更改后重新上传`)
return
}
postData.push({
name, phone, account, peopleCode
})
}
if (postData.length) {
setPostData(postData)
}
let msg = '文件解析完成,点击确定按钮上传保存!'
setMsg(msg)
onSuccess({ message: msg })
};
reader.readAsArrayBuffer(file); // 读取数据
},
}}>
<Button>上传文件</Button>
</Upload>
<br />
<span>{msg}</span>
</div>
</Modal >
)
}
function mapStateToProps(state) {
const { auth, customizeList } = state;
return {
user: auth.user,
}
}
export default connect(mapStateToProps)(ImportUser);

7
web/client/src/sections/wait/components/modeal.js

@ -50,6 +50,13 @@ function modeal(props) {
label="对接人"
name="contacts"
rules={[{ required: true, message: '请输入对接人' }]}
>
<Input/>
</Form.Item>
<Form.Item
label="评估工时"
name="consum_time"
rules={[{ required: true, message: '请输入对接人' }]}
>
<Input/>
</Form.Item>

8
web/client/src/sections/wait/containers/index.js

@ -8,7 +8,6 @@ import moment from "moment";
import { push } from "react-router-redux";
import { Scroller } from "$components";
import ProjectModeal from "../components/modeal";
import ImportModeal from "../components/import_model";
export const Default = (props) => {
const { dispatch } = props;
@ -45,6 +44,11 @@ export const Default = (props) => {
render: (dom, record) => {
return record.contacts;
},
},{
title: '评估工时',
dataIndex: 'consum_time',
key: 'consum_time',
align: 'center'
},
{
title: "处理进度",
@ -114,6 +118,7 @@ export const Default = (props) => {
from_project: values.from_project,
contacts: values.contacts,
progress: values.progress,
consum_time:values.consum_time,
o_name_project: editData?.name_project,
},
];
@ -124,6 +129,7 @@ export const Default = (props) => {
from_project: values.from_project,
contacts: values.contacts,
progress: values.progress,
consum_time:values.consum_time,
},
];
}

Loading…
Cancel
Save