master
Joe 2 years ago
parent 505a7fa7f1
commit b4da146492

@ -14,20 +14,6 @@ body,
min-height: 100vh; min-height: 100vh;
} }
.ant-upload.ant-upload-select-picture-card {
width: 200px !important;
height: 200px !important;
}
.avatar-uploader {
.ant-upload-list {
display: none !important;
}
.ant-upload-list-text {
display: none !important;
}
}
.row-active { .row-active {
background-color: @table-row-hover-bg; background-color: @table-row-hover-bg;
.ant-table-cell-fix-left, .ant-table-cell-fix-right { .ant-table-cell-fix-left, .ant-table-cell-fix-right {

@ -199,20 +199,14 @@ const handleRemove = async (id?: number, type?: number) => {
const dateFormat = 'YYYYMMDD'; const dateFormat = 'YYYYMMDD';
const getBase64 = (img: RcFile, callback: (url: string) => void) => {
const reader = new FileReader();
reader.addEventListener('load', () => callback(reader.result as string));
reader.readAsDataURL(img);
};
const beforeUpload = (file: RcFile) => { const beforeUpload = (file: RcFile) => {
const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png'; const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png';
if (!isJpgOrPng) { if (!isJpgOrPng) {
message.error('You can only upload JPG/PNG file!'); message.error('你只能上传JPG/PNG文件!');
} }
const isLt2M = file.size / 1024 / 1024 < 2; const isLt2M = file.size / 1024 / 1024 < 1;
if (!isLt2M) { if (!isLt2M) {
message.error('Image must smaller than 2MB!'); message.error('图片必须小于1MB!');
} }
return isJpgOrPng && isLt2M; return isJpgOrPng && isLt2M;
}; };
@ -675,6 +669,8 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
const [imageUrl, setImageUrl] = useState<string>(props.values.employeeName && props.values.cardNo ? `http://localhost:8888/upload/${props.values.employeeName}_${props.values.cardNo}.jpg`:''); const [imageUrl, setImageUrl] = useState<string>(props.values.employeeName && props.values.cardNo ? `http://localhost:8888/upload/${props.values.employeeName}_${props.values.cardNo}.jpg`:'');
const handleChange: UploadProps['onChange'] = (info: UploadChangeParam<UploadFile>) => { const handleChange: UploadProps['onChange'] = (info: UploadChangeParam<UploadFile>) => {
console.log(info.file)
setFileList(info.fileList)
if (info.file.status === 'uploading') { if (info.file.status === 'uploading') {
setLoading(true); setLoading(true);
return; return;
@ -682,6 +678,15 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
if (info.file.status === 'done') { if (info.file.status === 'done') {
console.log(info.file.response) console.log(info.file.response)
setLoading(false); setLoading(false);
if (fileList.length > 0) {
let newFileList = [...fileList]
newFileList[0].status = 'done'
newFileList[0].url = info.file.response
newFileList[0].preview = info.file.response
newFileList[0].thumbUrl = info.file.response
console.log(newFileList)
setFileList(newFileList)
}
setImageUrl(info.file.response); setImageUrl(info.file.response);
} }
}; };
@ -729,6 +734,8 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
// }, // },
}); });
const [fileList, setFileList] = useState<UploadFile[]>([]);
useEffect(() => { useEffect(() => {
@ -738,6 +745,14 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
getData(props.values.employeeNo, 3); getData(props.values.employeeNo, 3);
getData(props.values.employeeNo, 4); getData(props.values.employeeNo, 4);
} }
if (props.values.employeeName && props.values.cardNo) {
setFileList([{
uid: '-1',
name: 'image.png',
status: 'done',
url: `http://localhost:8888/upload/${props.values.employeeName}_${props.values.cardNo}.jpg`
}])
}
}, [props.values.employeeNo]); }, [props.values.employeeNo]);
console.log(imageUrl) console.log(imageUrl)
@ -784,17 +799,18 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
name="file" name="file"
listType="picture-card" listType="picture-card"
className="avatar-uploader" className="avatar-uploader"
showUploadList={false} fileList={fileList}
action="http://localhost:8888/api/employee/uploadImage" action="http://localhost:8888/api/employee/uploadImage"
beforeUpload={beforeUpload} beforeUpload={beforeUpload}
disabled={!!imageUrl}
onChange={handleChange} onChange={handleChange}
> >
{imageUrl ? <Image {fileList.length > 0 ? null : uploadButton}
{/* <Image
style={{ objectFit: 'contain' }}
width={200} width={200}
height={200}
src={imageUrl} src={imageUrl}
fallback={EmptyImage} /> */}
/> : uploadButton}
</Upload> </Upload>
</div> </div>

@ -110,23 +110,28 @@ const UserList: React.FC<{}> = () => {
const columns: ProColumns<TableListItem>[] = [ const columns: ProColumns<TableListItem>[] = [
{ {
title: '姓名', title: '姓名',
width: 70,
dataIndex: 'employeeName', dataIndex: 'employeeName',
}, },
{ {
title: '员工编号', title: '员工编号',
width: 80,
dataIndex: 'employeeNo', dataIndex: 'employeeNo',
}, },
{ {
title: '手机号', title: '手机号',
width: 100,
dataIndex: 'mobile', dataIndex: 'mobile',
}, },
{ {
title: '出生日期', title: '出生日期',
width: 80,
dataIndex: 'birthday', dataIndex: 'birthday',
search: false search: false
}, },
{ {
title: '性别', title: '性别',
width: 60,
dataIndex: 'sex', dataIndex: 'sex',
valueType: 'select', valueType: 'select',
fieldProps: { fieldProps: {
@ -142,6 +147,7 @@ const UserList: React.FC<{}> = () => {
}, },
{ {
title: '年龄', title: '年龄',
width: 60,
dataIndex: 'age', dataIndex: 'age',
fieldProps: { fieldProps: {
mode: "multiple" mode: "multiple"
@ -203,6 +209,7 @@ const UserList: React.FC<{}> = () => {
{ {
title: '部门', title: '部门',
dataIndex: 'departmentId', dataIndex: 'departmentId',
width: 120,
valueType: 'select', valueType: 'select',
fieldProps: { fieldProps: {
mode: "multiple" mode: "multiple"
@ -225,6 +232,7 @@ const UserList: React.FC<{}> = () => {
}, },
{ {
title: '单位', title: '单位',
width: 320,
dataIndex: 'unitId', dataIndex: 'unitId',
valueType: 'select', valueType: 'select',
fieldProps: { fieldProps: {
@ -248,6 +256,7 @@ const UserList: React.FC<{}> = () => {
}, },
{ {
title: '现岗位', title: '现岗位',
width: 110,
dataIndex: 'postId', dataIndex: 'postId',
valueType: 'select', valueType: 'select',
fieldProps: { fieldProps: {
@ -271,6 +280,7 @@ const UserList: React.FC<{}> = () => {
}, },
{ {
title: '班组', title: '班组',
width: 140,
dataIndex: 'groupsId', dataIndex: 'groupsId',
valueType: 'select', valueType: 'select',
fieldProps: { fieldProps: {
@ -295,6 +305,7 @@ const UserList: React.FC<{}> = () => {
{ {
title: '最高学历', title: '最高学历',
dataIndex: 'highestEducationId', dataIndex: 'highestEducationId',
width: 110,
valueType: 'select', valueType: 'select',
fieldProps: { fieldProps: {
mode: "multiple" mode: "multiple"
@ -319,6 +330,7 @@ const UserList: React.FC<{}> = () => {
title: '专业技术资格', title: '专业技术资格',
dataIndex: 'ptqId', dataIndex: 'ptqId',
valueType: 'select', valueType: 'select',
width: 130,
fieldProps: { fieldProps: {
mode: "multiple" mode: "multiple"
}, },
@ -342,6 +354,7 @@ const UserList: React.FC<{}> = () => {
title: '技能等级', title: '技能等级',
dataIndex: 'skillLevelId', dataIndex: 'skillLevelId',
valueType: 'select', valueType: 'select',
width: 80,
fieldProps: { fieldProps: {
mode: "multiple" mode: "multiple"
}, },
@ -393,6 +406,7 @@ const UserList: React.FC<{}> = () => {
{ {
title: "操作", title: "操作",
dataIndex: "option", dataIndex: "option",
width: 80,
hideInSearch: true, hideInSearch: true,
render: (text: any, record: TableListItem) => ( render: (text: any, record: TableListItem) => (
<span> <span>
@ -419,7 +433,7 @@ const UserList: React.FC<{}> = () => {
options={false} options={false}
formRef={ref} formRef={ref}
scroll={{ scroll={{
x: 'max-content' y: 'calc(100vh - 500px)'
}} }}
pagination={{ pagination={{
defaultPageSize: 10, defaultPageSize: 10,

Loading…
Cancel
Save