Browse Source

update search, icon, export presence, project

pull/2/head
farhan048 2 years ago
parent
commit
18f50fe6ee
  1. 8
      src/views/SimproV2/ChecklistK3/index.js
  2. 20
      src/views/SimproV2/CreatedProyek/index.js
  3. 91
      src/views/SimproV2/Divisi/index.js
  4. 7
      src/views/SimproV2/Presence/index.js

8
src/views/SimproV2/ChecklistK3/index.js

@ -7,7 +7,7 @@ import { Card, CardBody, CardHeader, Col, Row, Input, Table } from 'reactstrap';
import { NotificationContainer, NotificationManager } from 'react-notifications'; import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Button, Tooltip } from 'antd'; import { Pagination, Button, Tooltip } from 'antd';
import { import {
CHECKLIST_K3_ADD, CHECKLIST_K3_EDIT, CHECKLIST_K3_DELETE,CHECKLIST_K3_SEARCH CHECKLIST_K3_ADD, CHECKLIST_K3_EDIT, CHECKLIST_K3_DELETE, CHECKLIST_K3_SEARCH
} from '../../../const/ApiConst'; } from '../../../const/ApiConst';
const token = window.localStorage.getItem('token'); const token = window.localStorage.getItem('token');
@ -283,7 +283,7 @@ const ChecklistK3 = ({ params }) => {
<Button style={{ background: "#4caf50", color: "#fff" }} onClick={() => handleOpenDialog('Save')}><i className="fa fa-plus"></i></Button> <Button style={{ background: "#4caf50", color: "#fff" }} onClick={() => handleOpenDialog('Save')}><i className="fa fa-plus"></i></Button>
</Tooltip> </Tooltip>
<Tooltip title="Export Excel"> <Tooltip title="Export Excel">
<Button style={{marginLeft:"5px"}} color="primary" onClick={()=> handleExportExcel()}><i className="fa fa-print"></i></Button> <Button style={{ marginLeft: "5px" }} color="primary" onClick={() => handleExportExcel()}><i className="fa fa-print"></i></Button>
</Tooltip> </Tooltip>
</Col> </Col>
</Row> </Row>
@ -307,10 +307,10 @@ const ChecklistK3 = ({ params }) => {
<tr key={n.id}> <tr key={n.id}>
<td className='nowrap'> <td className='nowrap'>
<Tooltip title="Hapus"> <Tooltip title="Hapus">
<i id="TooltipDelete" className="cil-trash fa-lg" style={{ color: 'red', marginRight: 10, cursor: "pointer" }} onClick={() => handleDelete(n.id)}></i> <i id="TooltipDelete" className="fa fa-trash" style={{ color: 'red', marginRight: 10, cursor: "pointer" }} onClick={() => handleDelete(n.id)}></i>
</Tooltip> </Tooltip>
<Tooltip title="Edit"> <Tooltip title="Edit">
<i id="TooltipEdit" className="cil-pencil fa-lg" style={{ color: 'green', cursor: "pointer" }} onClick={() => handleEdit(n)}></i> <i id="TooltipEdit" className="fa fa-edit" style={{ color: 'green', cursor: "pointer" }} onClick={() => handleEdit(n)}></i>
</Tooltip> </Tooltip>
</td> </td>
<td>{n.name}</td> <td>{n.name}</td>

20
src/views/SimproV2/CreatedProyek/index.js

@ -791,13 +791,25 @@ const CreatedProyek = ({ params, ...props }) => {
} }
}; };
const handleExportPdf = () => { const handleExportPdf = async () => {
const doc = new jsPDF(); const doc = new jsPDF();
const headers = [ const headers = [
["Project Name", "Budget", "Project Type", "PM", "Time Project"], ["Project Name", "Budget", "Project Type", "PM", "Time Project"],
]; ];
const data = dataTable.map((elt) => [ const payload = {
paging: { start: 0, length: -1 },
joins: [],
orders: { columns: ["id"], ascending: false },
};
const result = await axios
.post(PROYEK_SEARCH, payload, HEADER)
.then((res) => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
let resData = result.data.data;
const data = resData.map((elt) => [
elt.nama, elt.nama,
`Rp. ${formatThousand(elt.rencana_biaya)}`, `Rp. ${formatThousand(elt.rencana_biaya)}`,
elt.join_second_name, elt.join_second_name,
@ -816,8 +828,8 @@ const CreatedProyek = ({ params, ...props }) => {
head: headers, head: headers,
body: data, body: data,
}); });
}
doc.save("table.pdf"); doc.save("Project.pdf");
// const unit = "pt"; // const unit = "pt";
// const size = "A4"; // Use A1, A2, A3 or A4 // const size = "A4"; // Use A1, A2, A3 or A4
// const orientation = "portrait"; // portrait or landscape // const orientation = "portrait"; // portrait or landscape

91
src/views/SimproV2/Divisi/index.js

@ -54,14 +54,23 @@ const ProjectType = ({ params }) => {
const [typeDialog, setTypeDialog] = useState('Save') const [typeDialog, setTypeDialog] = useState('Save')
const [dataDivisions, setDataDivisions] = useState([]) const [dataDivisions, setDataDivisions] = useState([])
useEffect(() => {
getListDivision()
}, [])
useEffect(() => { useEffect(() => {
getDataProjectType() getDataProjectType()
}, [currentPage, rowsPerPage, search]) }, [currentPage, rowsPerPage, search])
const getDataProjectType = async () => { useEffect(() => {
const cekData = dataExport || []
let start = 0; if (cekData.length > 0) {
exportExcel()
}
}, [dataExport])
const getListDivision = async () => {
const listDivions = await axios const listDivions = await axios
.get(DIVISI_LIST, HEADER) .get(DIVISI_LIST, HEADER)
.then(res => res) .then(res => res)
@ -76,11 +85,12 @@ const ProjectType = ({ params }) => {
} else { } else {
NotificationManager.error('Gagal Mengambil Data!!', 'Failed'); NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
} }
}
const getDataProjectType = async () => {
let start = 0;
if (currentPage !== 1 && currentPage > 1) { if (currentPage !== 1 && currentPage > 1) {
start = (currentPage * rowsPerPage) - rowsPerPage start = (currentPage * rowsPerPage) - rowsPerPage
} }
const payload = { const payload = {
"columns": [ "columns": [
{ {
@ -101,19 +111,78 @@ const ProjectType = ({ params }) => {
"start": start "start": start
} }
} }
const result = await axios const result = await axios
.post(DIVISI_SEARCH, payload, config) .post(DIVISI_SEARCH, payload, HEADER)
.then(res => res) .then(res => res)
.catch((error) => error.response); .catch((error) => error.response);
if (result && result.data && result.data.code == 200) { if (result && result.data && result.data.code == 200) {
result.data.data.map((res) => {
res.key = res.id.toString()
});
setDatatable(result.data.data); setDatatable(result.data.data);
setTotalPage(result.data.totalRecord); setTotalPage(result.data.totalRecord);
} else { } else {
NotificationManager.error('Gagal Mengambil Data!!', 'Failed'); NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
} }
} }
const handleExportExcel = async () => {
let start = 0;
if (currentPage !== 1 && currentPage > 1) {
start = (currentPage * rowsPerPage) - rowsPerPage
}
const payload = {
"columns": [
{
"name": "name",
"logic_operator": "like",
"value": search,
"operator": "AND"
}
],
"orders": {
"ascending": true,
"columns": [
'id'
]
},
"paging": {
"length": rowsPerPage,
"start": start
}
}
const result = await axios
.post(DIVISI_SEARCH, payload, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
let resData = result.data.data;
const excelData = [];
resData.map((val, index) => {
let dataRow = {
"Nama Divisi": val.name,
"Deskripsi": val.description,
}
excelData.push(dataRow)
})
await setDataExport(excelData)
} else {
NotificationManager.error('Gagal Export Data!!', 'Failed');
}
}
const exportExcel = () => {
const dataExcel = dataExport || [];
const fileName = `Data ${pageName}.xlsx`;
const ws = XLSX.utils.json_to_sheet(dataExcel);
const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, `Data ${pageName}`);
XLSX.writeFile(wb, fileName);
setDataExport([])
}
const handleSearch = e => { const handleSearch = e => {
const value = e.target.value const value = e.target.value
@ -248,10 +317,16 @@ const ProjectType = ({ params }) => {
<CardHeader style={{ display: "flex", justifyContent: "space-between" }}> <CardHeader style={{ display: "flex", justifyContent: "space-between" }}>
<h4 className="capitalize">{pageName}</h4> <h4 className="capitalize">{pageName}</h4>
<Row> <Row>
<Col>
<Input onChange={handleSearch} value={search} type="text" name="search" id="search" placeholder={`Cari Divisi`} />
</Col>
<Col> <Col>
<Tooltip title="Add Data"> <Tooltip title="Add Data">
<Button style={{ background: "#4caf50", color: "#fff" }} onClick={() => handleOpenDialog('Save')}><i className="fa fa-plus"></i></Button> <Button style={{ background: "#4caf50", color: "#fff" }} onClick={() => handleOpenDialog('Save')}><i className="fa fa-plus"></i></Button>
</Tooltip> </Tooltip>
<Tooltip title="Export Excel">
<Button style={{ marginLeft: "5px" }} onClick={() => handleExportExcel()}><i className="fa fa-print"></i></Button>
</Tooltip>
</Col> </Col>
</Row> </Row>
</CardHeader> </CardHeader>
@ -280,7 +355,7 @@ const ProjectType = ({ params }) => {
<i id="TooltipEdit" className="fa fa-edit" style={{ color: 'green', cursor: "pointer" }} onClick={() => handleEdit(n)}></i> <i id="TooltipEdit" className="fa fa-edit" style={{ color: 'green', cursor: "pointer" }} onClick={() => handleEdit(n)}></i>
</Tooltip> </Tooltip>
</td> </td>
<td>{n.displayName}</td> <td>{n.name}</td>
<td>{n.description}</td> <td>{n.description}</td>
</tr> </tr>
) )

7
src/views/SimproV2/Presence/index.js

@ -196,12 +196,13 @@ const Index = ({ params }) => {
let dataRow = { let dataRow = {
"NIK/ID Card": val.join_first_ktp_number ? val.join_first_ktp_number : '-', "NIK/ID Card": val.join_first_ktp_number ? val.join_first_ktp_number : '-',
"Nama Human Resource": val.join_first_name ? val.join_first_name : '', "Nama Human Resource": val.join_first_name ? val.join_first_name : '',
"Tanggal Kehadiran": val.date_presence ? moment(val.date_presence).format("D-M-YYYY") : '-',
"Jam Masuk": val.clock_in ? moment(val.clock_in).format("D-M-YYYY HH:mm:ss") : '-', "Jam Masuk": val.clock_in ? moment(val.clock_in).format("D-M-YYYY HH:mm:ss") : '-',
"Jam Keluar": val.clock_out ? moment(val.clock_out).format("D-M-YYYY HH:mm:ss") : '-', "Jam Keluar": val.clock_out ? moment(val.clock_out).format("D-M-YYYY HH:mm:ss") : '-',
"Durasi Kerja": renderDurasiKerja(val.clock_in, val.clock_out), "Durasi Kerja": renderDurasiKerja(val.clock_in, val.clock_out),
"Clock-in Location": val.clock_in_loc && val.clock_in_loc !== '' ? val.clock_in_loc : '-', "Lokasi Masuk": val.clock_in_loc && val.clock_in_loc !== '' ? val.clock_in_loc : '-',
"Clock-out Location": val.clock_out_loc && val.clock_out_loc !== '' ? val.clock_out_loc : '-' "Lokasi Pulang": val.clock_out_loc && val.clock_out_loc !== '' ? val.clock_out_loc : '-',
"Area Kerja In": val.clock_in_boundary ? "Sesuai" : "Tidak Sesuai",
"Area Kerja Out": val.clock_out_boundary == null ? "-" : val.clock_out_boundary ? "Sesuai" : "Tidak Sesuai",
} }
excelData.push(dataRow) excelData.push(dataRow)
}) })

Loading…
Cancel
Save