Browse Source

Import Nik

pull/2/head
Wahyu Ramadhan 2 years ago
parent
commit
fd4db0cb9a
  1. 1
      src/routes.js
  2. 2
      src/views/SimproV2/CreatedProyek/DialogGantt.js
  3. 53
      src/views/SimproV2/CreatedProyek/ImportActivity/index.js

1
src/routes.js

@ -57,6 +57,7 @@ const routes = [
{ path: '/dashboard-project/:PROJECT_ID/:GANTT_ID', exact: true, name: 'Dashboard Project', component: DashboardProject }, { path: '/dashboard-project/:PROJECT_ID/:GANTT_ID', exact: true, name: 'Dashboard Project', component: DashboardProject },
{ path: '/projects', exact: true, name: 'Projects', component: CreatedProyek }, { path: '/projects', exact: true, name: 'Projects', component: CreatedProyek },
{ path: '/projects/:id/import/activity', exact: true, name: 'Gantt Import Activity', component: GanttImportActivity }, { path: '/projects/:id/import/activity', exact: true, name: 'Gantt Import Activity', component: GanttImportActivity },
{ path: '/projects/:id/:project/import/activity', exact: true, name: 'Gantt Import Activity', component: GanttImportActivity },
{ path: '/projects/:id/:project/gantt', exact: true, name: 'Gantt', component: Gantt }, { path: '/projects/:id/:project/gantt', exact: true, name: 'Gantt', component: Gantt },
{ path: '/human-resource', exact: true, name: 'Human Resource', component: ResourceWorker }, { path: '/human-resource', exact: true, name: 'Human Resource', component: ResourceWorker },
{ path: '/material-resource', exact: true, name: 'Material Resource', component: ResourceMaterial }, { path: '/material-resource', exact: true, name: 'Material Resource', component: ResourceMaterial },

2
src/views/SimproV2/CreatedProyek/DialogGantt.js

@ -130,7 +130,7 @@ const DialogGantt = ({ openDialog, closeDialog, toggleDialog, idTask, proyekName
<Tooltip title="Gantt Permission"> <Tooltip title="Gantt Permission">
<Button size={"sm"} color='success' onClick={() => handleUserGant(text.id)}><i className="fa fa-users"></i></Button> <Button size={"sm"} color='success' onClick={() => handleUserGant(text.id)}><i className="fa fa-users"></i></Button>
</Tooltip>{" "} </Tooltip>{" "}
<Link to={`/projects/${text.id}/import/activity`}> <Link to={`/projects/${text.id}/${idTask}/import/activity`}>
{" "}<Tooltip title="Import Activity"> {" "}<Tooltip title="Import Activity">
<Button size={"sm"} color='success'> <Button size={"sm"} color='success'>
<i className="fa fa-file-excel-o"></i> <i className="fa fa-file-excel-o"></i>

53
src/views/SimproV2/CreatedProyek/ImportActivity/index.js

@ -6,7 +6,7 @@ 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 } 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';
// //
const config = { const config = {
@ -91,10 +91,52 @@ const ImportActivity = ({ params }) => {
const pageName = params.name; const pageName = params.name;
const [dataTable, setDatatable] = useState([]) const [dataTable, setDatatable] = useState([])
const [dataUserToProject, setdataUserToProject] = useState([])
// //
const [isMovePage, setIsMovePage] = useState(false); const [isMovePage, setIsMovePage] = useState(false);
const [isPreview, setIsPreview] = useState(false); const [isPreview, setIsPreview] = useState(false);
useEffect(() => {
getDataAssignHr();
}, [])
const getDataAssignHr = async () => {
let url = window.location.href;
let urlSplitted = url.split('/')
const payload = {
"paging": {
"start": 0,
"length": -1
},
"columns": [
{ "name": "name", "logic_operator": "ilike", "value": "", "table_name": "m_users" },
{ "name": "proyek_id", "logic_operator": "=", "value": urlSplitted[6] }
],
"joins": [
{ "name": "m_users", "column_join": "user_id", "column_results": ["name", "ktp_number"] },
{ "name": "m_role_proyek", "column_join": "project_role", "column_results": ["name"] },
],
"orders": {
"columns": [
"id"
],
"ascending": false
}
}
const URL = ASSIGN_HR_PROJECT_SEARCH
const result = await axios
.post(URL, payload, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
let dataRes = result.data.data || []
setdataUserToProject(dataRes);
} else {
NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
}
}
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"){
@ -152,6 +194,15 @@ const ImportActivity = ({ params }) => {
} }
} }
if(["nik"].includes(prop)){
if(columnData){
let index = dataUserToProject.findIndex((x) => columnData == x.join_first_ktp_number);
if(index >= 0) {
columnData = dataUserToProject[index].join_first_ktp_number;
}
}
}
if(prop == 'weight'){ if(prop == 'weight'){
if (columnData == null) { if (columnData == null) {
columnData = 0; columnData = 0;

Loading…
Cancel
Save