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 { Pagination, Button, Tooltip } from 'antd';
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';
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>
</Tooltip>
<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>
</Col>
</Row>
@ -307,10 +307,10 @@ const ChecklistK3 = ({ params }) => {
<tr key={n.id}>
<td className='nowrap'>
<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 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>
</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 headers = [
["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,
`Rp. ${formatThousand(elt.rencana_biaya)}`,
elt.join_second_name,
@ -816,8 +828,8 @@ const CreatedProyek = ({ params, ...props }) => {
head: headers,
body: data,
});
doc.save("table.pdf");
}
doc.save("Project.pdf");
// const unit = "pt";
// const size = "A4"; // Use A1, A2, A3 or A4
// 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 [dataDivisions, setDataDivisions] = useState([])
useEffect(() => {
getListDivision()
}, [])
useEffect(() => {
getDataProjectType()
}, [currentPage, rowsPerPage, search])
const getDataProjectType = async () => {
let start = 0;
useEffect(() => {
const cekData = dataExport || []
if (cekData.length > 0) {
exportExcel()
}
}, [dataExport])
const getListDivision = async () => {
const listDivions = await axios
.get(DIVISI_LIST, HEADER)
.then(res => res)
@ -76,11 +85,12 @@ const ProjectType = ({ params }) => {
} else {
NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
}
}
const getDataProjectType = async () => {
let start = 0;
if (currentPage !== 1 && currentPage > 1) {
start = (currentPage * rowsPerPage) - rowsPerPage
}
const payload = {
"columns": [
{
@ -101,19 +111,78 @@ const ProjectType = ({ params }) => {
"start": start
}
}
const result = await axios
.post(DIVISI_SEARCH, payload, config)
.post(DIVISI_SEARCH, payload, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
result.data.data.map((res) => {
res.key = res.id.toString()
});
setDatatable(result.data.data);
setTotalPage(result.data.totalRecord);
} else {
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 value = e.target.value
@ -248,10 +317,16 @@ const ProjectType = ({ params }) => {
<CardHeader style={{ display: "flex", justifyContent: "space-between" }}>
<h4 className="capitalize">{pageName}</h4>
<Row>
<Col>
<Input onChange={handleSearch} value={search} type="text" name="search" id="search" placeholder={`Cari Divisi`} />
</Col>
<Col>
<Tooltip title="Add Data">
<Button style={{ background: "#4caf50", color: "#fff" }} onClick={() => handleOpenDialog('Save')}><i className="fa fa-plus"></i></Button>
</Tooltip>
<Tooltip title="Export Excel">
<Button style={{ marginLeft: "5px" }} onClick={() => handleExportExcel()}><i className="fa fa-print"></i></Button>
</Tooltip>
</Col>
</Row>
</CardHeader>
@ -280,7 +355,7 @@ const ProjectType = ({ params }) => {
<i id="TooltipEdit" className="fa fa-edit" style={{ color: 'green', cursor: "pointer" }} onClick={() => handleEdit(n)}></i>
</Tooltip>
</td>
<td>{n.displayName}</td>
<td>{n.name}</td>
<td>{n.description}</td>
</tr>
)

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

@ -196,12 +196,13 @@ const Index = ({ params }) => {
let dataRow = {
"NIK/ID Card": val.join_first_ktp_number ? val.join_first_ktp_number : '-',
"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 Keluar": val.clock_out ? moment(val.clock_out).format("D-M-YYYY HH:mm:ss") : '-',
"Durasi Kerja": renderDurasiKerja(val.clock_in, val.clock_out),
"Clock-in Location": 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 Masuk": val.clock_in_loc && val.clock_in_loc !== '' ? val.clock_in_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)
})

Loading…
Cancel
Save