|
|
@ -4,7 +4,7 @@ import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap'; |
|
|
|
import { NotificationContainer, NotificationManager } from 'react-notifications'; |
|
|
|
import { NotificationContainer, NotificationManager } from 'react-notifications'; |
|
|
|
import { Button, Table, Form, Upload, Tooltip, Alert, Spin } from 'antd'; |
|
|
|
import { Button, Table, Form, Upload, Tooltip, Alert, Spin } from 'antd'; |
|
|
|
import { InboxOutlined, UploadOutlined } from '@ant-design/icons'; |
|
|
|
import { InboxOutlined, UploadOutlined } from '@ant-design/icons'; |
|
|
|
import {OutTable, ExcelRenderer} from 'react-excel-renderer'; |
|
|
|
import { OutTable, ExcelRenderer } from 'react-excel-renderer'; |
|
|
|
import './table.css'; |
|
|
|
import './table.css'; |
|
|
|
import { BASE_OSPRO, ASSIGN_HR_PROJECT_SEARCH } from '../../../../const/ApiConst'; |
|
|
|
import { BASE_OSPRO, ASSIGN_HR_PROJECT_SEARCH } from '../../../../const/ApiConst'; |
|
|
|
import { Prompt } from 'react-router-dom'; |
|
|
|
import { Prompt } from 'react-router-dom'; |
|
|
@ -137,7 +137,7 @@ const ImportActivity = ({ params }) => { |
|
|
|
|
|
|
|
|
|
|
|
const fileHandler = (file) => { |
|
|
|
const fileHandler = (file) => { |
|
|
|
setIsMovePage(true); |
|
|
|
setIsMovePage(true); |
|
|
|
if(file.name.slice(file.name.lastIndexOf('.')+1) === "xlsx"){ |
|
|
|
if (file.name.slice(file.name.lastIndexOf('.') + 1) === "xlsx") { |
|
|
|
// NotificationManager.info('Loading...',' ');
|
|
|
|
// NotificationManager.info('Loading...',' ');
|
|
|
|
setTimeout(() => { |
|
|
|
setTimeout(() => { |
|
|
|
previewHandler(file); |
|
|
|
previewHandler(file); |
|
|
@ -156,7 +156,7 @@ const ImportActivity = ({ params }) => { |
|
|
|
let dataMapped = [] |
|
|
|
let dataMapped = [] |
|
|
|
|
|
|
|
|
|
|
|
ExcelRenderer(fileObj, (err, resp) => { |
|
|
|
ExcelRenderer(fileObj, (err, resp) => { |
|
|
|
if(err){ |
|
|
|
if (err) { |
|
|
|
console.log(err) |
|
|
|
console.log(err) |
|
|
|
errorHandler() |
|
|
|
errorHandler() |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -167,7 +167,7 @@ const ImportActivity = ({ params }) => { |
|
|
|
return el.length > 0; |
|
|
|
return el.length > 0; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
for(let i = 5; i < rows.length; i++){ |
|
|
|
for (let i = 5; i < rows.length; i++) { |
|
|
|
let extractedRow = {} |
|
|
|
let extractedRow = {} |
|
|
|
|
|
|
|
|
|
|
|
for (var prop in columnToIndexs) { |
|
|
|
for (var prop in columnToIndexs) { |
|
|
@ -175,14 +175,14 @@ const ImportActivity = ({ params }) => { |
|
|
|
let columnData = rows[i][columnToIndexs[prop]] |
|
|
|
let columnData = rows[i][columnToIndexs[prop]] |
|
|
|
|
|
|
|
|
|
|
|
// remove leading whitespace
|
|
|
|
// remove leading whitespace
|
|
|
|
if(typeof(columnData) == 'string') { |
|
|
|
if (typeof (columnData) == 'string') { |
|
|
|
columnData = columnData.trim().replace(/ /g, '').replace(/<[^\/>][^>]*><\/[^>]+>/g, "") |
|
|
|
columnData = columnData.trim().replace(/ /g, '').replace(/<[^\/>][^>]*><\/[^>]+>/g, "") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(["nik"].includes(prop)){ |
|
|
|
if (["nik"].includes(prop)) { |
|
|
|
if(columnData){ |
|
|
|
if (columnData) { |
|
|
|
let index = dataUserToProject.findIndex((x) => columnData == x.join_first_ktp_number); |
|
|
|
let index = dataUserToProject.findIndex((x) => columnData == x.join_first_ktp_number); |
|
|
|
if(index >= 0) { |
|
|
|
if (index >= 0) { |
|
|
|
columnData = dataUserToProject[index].join_first_ktp_number; |
|
|
|
columnData = dataUserToProject[index].join_first_ktp_number; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
columnData = ''; |
|
|
|
columnData = ''; |
|
|
@ -190,7 +190,7 @@ const ImportActivity = ({ params }) => { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(prop == 'weight'){ |
|
|
|
if (prop == 'weight') { |
|
|
|
if (columnData == null) { |
|
|
|
if (columnData == null) { |
|
|
|
columnData = 0; |
|
|
|
columnData = 0; |
|
|
|
} |
|
|
|
} |
|
|
@ -268,7 +268,7 @@ const ImportActivity = ({ params }) => { |
|
|
|
key: 'name', |
|
|
|
key: 'name', |
|
|
|
render: (text, record) => { |
|
|
|
render: (text, record) => { |
|
|
|
let prepend = "" |
|
|
|
let prepend = "" |
|
|
|
for(let i = 1; i < record.level; i++) { |
|
|
|
for (let i = 1; i < record.level; i++) { |
|
|
|
prepend = prepend + "--" |
|
|
|
prepend = prepend + "--" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -329,7 +329,7 @@ const ImportActivity = ({ params }) => { |
|
|
|
listType="text" |
|
|
|
listType="text" |
|
|
|
accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" |
|
|
|
accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" |
|
|
|
maxCount={1} |
|
|
|
maxCount={1} |
|
|
|
beforeUpload={(file)=> fileHandler(file)} |
|
|
|
beforeUpload={(file) => fileHandler(file)} |
|
|
|
showUploadList={false} |
|
|
|
showUploadList={false} |
|
|
|
> |
|
|
|
> |
|
|
|
<Button icon={<UploadOutlined />}>Import Excel</Button> |
|
|
|
<Button icon={<UploadOutlined />}>Import Excel</Button> |
|
|
@ -338,11 +338,11 @@ const ImportActivity = ({ params }) => { |
|
|
|
</Form.Item> |
|
|
|
</Form.Item> |
|
|
|
</Form> |
|
|
|
</Form> |
|
|
|
</Col> |
|
|
|
</Col> |
|
|
|
<Col span={2} style={{display: 'flex', justifyContent: 'flex-end'}}> |
|
|
|
<Col span={2} style={{ display: 'flex', justifyContent: 'flex-end' }}> |
|
|
|
<Button |
|
|
|
<Button |
|
|
|
style={{ marginLeft: "5px", marginRight: "10px" }} |
|
|
|
style={{ marginLeft: "5px", marginRight: "10px" }} |
|
|
|
disabled={dataTable.length > 0 ? false : true} |
|
|
|
disabled={dataTable.length > 0 ? false : true} |
|
|
|
onClick={(e)=> saveHandler(e)} |
|
|
|
onClick={(e) => saveHandler(e)} |
|
|
|
> |
|
|
|
> |
|
|
|
<i className="fa fa-save" style={{ marginRight: "5px" }}></i> Save |
|
|
|
<i className="fa fa-save" style={{ marginRight: "5px" }}></i> Save |
|
|
|
</Button> |
|
|
|
</Button> |
|
|
@ -397,7 +397,7 @@ const ImportActivity = ({ params }) => { |
|
|
|
listType="text" |
|
|
|
listType="text" |
|
|
|
accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" |
|
|
|
accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" |
|
|
|
maxCount={1} |
|
|
|
maxCount={1} |
|
|
|
beforeUpload={(file)=> fileHandler(file)} |
|
|
|
beforeUpload={(file) => fileHandler(file)} |
|
|
|
showUploadList={false} |
|
|
|
showUploadList={false} |
|
|
|
> |
|
|
|
> |
|
|
|
<Button icon={<UploadOutlined />}>Import Excel</Button> |
|
|
|
<Button icon={<UploadOutlined />}>Import Excel</Button> |
|
|
@ -406,11 +406,11 @@ const ImportActivity = ({ params }) => { |
|
|
|
</Form.Item> |
|
|
|
</Form.Item> |
|
|
|
</Form> |
|
|
|
</Form> |
|
|
|
</Col> |
|
|
|
</Col> |
|
|
|
<Col span={2} style={{display: 'flex', justifyContent: 'flex-end'}}> |
|
|
|
<Col span={2} style={{ display: 'flex', justifyContent: 'flex-end' }}> |
|
|
|
<Button |
|
|
|
<Button |
|
|
|
style={{ marginLeft: "5px", marginRight: "10px" }} |
|
|
|
style={{ marginLeft: "5px", marginRight: "10px" }} |
|
|
|
disabled={dataTable.length > 0 ? false : true} |
|
|
|
disabled={dataTable.length > 0 ? false : true} |
|
|
|
onClick={(e)=> saveHandler(e)} |
|
|
|
onClick={(e) => saveHandler(e)} |
|
|
|
> |
|
|
|
> |
|
|
|
<i className="fa fa-save" style={{ marginRight: "5px" }}></i> Save |
|
|
|
<i className="fa fa-save" style={{ marginRight: "5px" }}></i> Save |
|
|
|
</Button> |
|
|
|
</Button> |
|
|
|