Browse Source

remove comments

pull/2/head
Muhammad Sulaiman Yusuf 2 years ago
parent
commit
783d75fcd1
  1. 36
      src/views/Master/ConfigAlert/index.js
  2. 169
      src/views/Master/MasterBroadcast/index.js
  3. 104
      src/views/Master/MasterMenu/index.js
  4. 111
      src/views/Master/MasterRoles/index.js
  5. 103
      src/views/Master/RoleProject/index.js
  6. 49
      src/views/SimproV2/ChecklistK3/index.js
  7. 165
      src/views/SimproV2/Closing/index.js
  8. 9
      src/views/SimproV2/ControlMonitoring/index.js
  9. 137
      src/views/SimproV2/CreatedProyek/index.js
  10. 58
      src/views/SimproV2/Divisi/index.js
  11. 87
      src/views/SimproV2/PanicButton/index.js
  12. 94
      src/views/SimproV2/ProjectType/index.js
  13. 98
      src/views/SimproV2/ResourceMaterial/index.js
  14. 78
      src/views/SimproV2/ResourceTools/index.js
  15. 115
      src/views/SimproV2/ResourceWorker/index.js
  16. 53
      src/views/SimproV2/Satuan/index.js

36
src/views/Master/ConfigAlert/index.js

@ -1,20 +1,21 @@
import Bell from '@iconify/icons-ion/notifications-outline';
import BellOff from '@iconify/icons-ion/notifications-off-outline';
import React, { useState, useEffect } from 'react';
import { Card, CardBody, CardHeader, Input } from 'reactstrap';
import axios from 'axios';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Card as ACard,Row, Col, Switch } from 'antd';
import { CALERTUSER_SEARCH,CONFIGALERT_SEARCH,CALERTUSER_DELETE, CALERTUSER_ADD } from '../../../const/ApiConst.js';
import { Card as ACard,Row, Col, Switch } from 'antd';
import { Card, CardBody, CardHeader, Input } from 'reactstrap';
import { Icon } from '@iconify/react';
import Bell from '@iconify/icons-ion/notifications-outline';
import BellOff from '@iconify/icons-ion/notifications-off-outline';
import { NotificationContainer, NotificationManager } from 'react-notifications';
const token = window.localStorage.getItem('token');
const userID = window.localStorage.getItem('user_id');
const Index = ({params}) => {
const [dataTable, setDatatable] = useState([])
const [alertUser, setAlertUser] = useState([])
const [checked, setChecked] = useState({})
const [dataTable, setDatatable] = useState([])
const [onSetSwitch, setOnSetSwitch] = useState(false)
const pageName = params.name;
@ -26,18 +27,14 @@ const Index = ({params}) => {
}
};
useEffect(()=> {
getDataConfigAlert();
// getDataConfigAlertUser();
},[])
useEffect(() => {
getDataConfigAlertUser();
},[dataTable])
const getDataConfigAlert = async () => {
const payload = {
"paging": {"start": 0, "length": -1},
@ -48,15 +45,11 @@ const Index = ({params}) => {
"orders": {"columns": ["id"], "ascending": false}
}
const result = await axios
.post(CONFIGALERT_SEARCH, payload, config)
.then(res => res)
.catch((error) => error.response);
// console.log(result)
if(result && result.data && result.data.code == 200){
let resData = result.data.data
let checkedAlert = {}
@ -65,7 +58,6 @@ const Index = ({params}) => {
});
setChecked(checkedAlert);
setDatatable(resData);
// getDataConfigAlertUser();
}else{
NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
}
@ -86,27 +78,20 @@ const Index = ({params}) => {
.then(res => res)
.catch((error) => error.response);
if(result && result.data && result.data.code == 200){
let resData = result.data.data
// console.log("resData", resData)
// console.log("dataTable", dataTable)
let configAlert = [];
resData.map((val, index) => {
configAlert.push(val.config_alert_id);
let indexRes = dataTable.findIndex(x => x.id === val.config_alert_id);
// console.log("indexRes", indexRes)
if(indexRes >= 0){
let id = dataTable[indexRes].id;
let tempChecked = checked;
tempChecked[id] = true;
// console.log("tempChecked", tempChecked)
setChecked(tempChecked);
}
});
window.localStorage.setItem('userConfigAlert', configAlert.join());
console.log("configAlert.join()", configAlert.join())
setOnSetSwitch(false)
setAlertUser(result.data.data);
}else{
@ -116,7 +101,6 @@ const Index = ({params}) => {
const onChange = (checked, id) => {
setOnSetSwitch(true)
// console.log(`switch to ${checked} ${id}`);
if(checked){
addConfigAlertUser(id);
}else{
@ -136,33 +120,27 @@ const Index = ({params}) => {
if(result && result.data && result.data.code===200){
getDataConfigAlertUser();
// NotificationManager.success(`Data menu berhasil ditambah`, 'Success!!');
}
}
const setDeleteConfigAlertUser = async (id) => {
let indexCek = alertUser.findIndex(x => x.user_id === parseInt(localStorage.getItem('user_id')) && x.config_alert_id === id);
// console.log("cekcekckecke", indexCek)
if(indexCek >= 0){
let idAlert = alertUser[indexCek].id
// console.log("cek idAlert", idAlert);
deleteConfigAlertUser(idAlert)
}
}
const deleteConfigAlertUser = async (id) => {
const url = CALERTUSER_DELETE(id)
const result = await axios.delete(url, config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
getDataConfigAlert();
}
}
return (
<div>
<NotificationContainer />

169
src/views/Master/MasterBroadcast/index.js

@ -1,17 +1,16 @@
import { DatePicker, Pagination } from 'antd';
import axios from 'axios';
import moment from 'moment';
import * as XLSX from 'xlsx';
import DialogDetail from './DialogDetail';
import DialogForm from './DialogForm';
import React, { Component } from 'react';
import SweetAlert from 'react-bootstrap-sweetalert';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Button, Card, CardBody, CardHeader, DropdownItem, DropdownMenu, DropdownToggle, Input, InputGroup, InputGroupButtonDropdown, Table, Row, Col } from 'reactstrap';
import * as XLSX from 'xlsx';
import axios from 'axios';
import moment from 'moment';
import { API_BROADCAST_SIMPRO, BASE_SIMPRO, BASE_URL_GEOHR_API2 } from '../../../const/ApiConst';
import DialogForm from './DialogForm';
import DialogDetail from './DialogDetail';
import { Button, Card, CardBody, CardHeader, DropdownItem, DropdownMenu, DropdownToggle, Input, InputGroup, InputGroupButtonDropdown, Table, Row, Col } from 'reactstrap';
import { DatePicker, Pagination } from 'antd';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Tooltip } from 'reactstrap';
const { RangePicker } = DatePicker;
const token = window.localStorage.getItem('token');
const config = {
@ -27,7 +26,6 @@ const roleName = window.localStorage.getItem('role_name');
const column = [
{ name: "Aksi" },
{ name: "Judul" },
{ name: "Pesan" },
{ name: "Deskripsi" },
@ -41,40 +39,40 @@ export default class index extends Component {
constructor(props) {
super(props)
this.state = {
dataTable: [],
dataExport: [],
openDialog: false,
typeDialog: 'Save',
dataEdit: null,
alertBroadcast: false,
alertDelete: false,
idDelete: 0,
currentDay: 'today',
currentPage: 1,
dataDetail:[],
dataEdit: null,
dataExport: [],
dataExport:[],
dataGs: [],
dataIdHo: [],
search: "",
dataTable: [],
endDate: moment(moment().format("YYYY-M-D")),
idDelete: 0,
idSend: 0,
openDialog: false,
openDialogDetail: false,
page: 0,
rowsPerPage: LENGTH_DATA,
currentPage: 1,
totalPage: 0,
tooltipEdit: false,
tooltipDelete: false,
typeClock: "All",
startDate: moment(moment().format("YYYY-M-D")),
endDate: moment(moment().format("YYYY-M-D")),
dataExport:[],
currentDay: 'today',
search: "",
searchDetail: "Judul",
searchDetailField: "title_notif",
splitButtonOpen: false,
alertBroadcast: false,
startDate: moment(moment().format("YYYY-M-D")),
statusSend: '',
idSend: 0,
dataDetail:[],
openDialogDetail: false,
toltipDetail:false,
tooltipDelete: false,
tooltipEdit: false,
tooltipExport:false,
tooltipTambah:false,
tooltipresend:false,
tooltipsend:false,
tooltipTambah:false,
tooltipExport:false,
totalPage: 0,
typeClock: "All",
typeDialog: 'Save',
}
}
@ -94,7 +92,6 @@ export default class index extends Component {
};
getDataBroadcast = async () => {
// let url = `${API_BROADCAST}/search`;
let url = BASE_SIMPRO + `/broadcast/search`;
const { searchDetail } = this.state
@ -134,41 +131,8 @@ export default class index extends Component {
}
}
// const formData = new FormData();
// formData.append("start", start);
// formData.append("id_org", id_org);
// formData.append("length", this.state.rowsPerPage);
// formData.append("startDate", dateStart.format("YYYY-M-D")+" 00:00:00");
// formData.append("endDate", dateEnd.format("YYYY-M-D")+" 23:59:59");
// formData.append('field', this.state.searchDetailField);
if(this.state.search!=="" && this.state.search!==null){
// formData.append('value', this.state.search);
}
// const param = {
// "paging": { "start": start, "length": this.state.rowsPerPage },
// ...searchDetail === "Semua" &&
// {
// "filter_columns": [
// { "name": "title_notif", "value": this.state.search.toString() },
// { "name": "message_notif", "value": this.state.search.toString() },
// { "name": "description", "value": this.state.search.toString() },
// { "name": "status_send", "value": this.state.search.toString() },
// ],
// },
// ...searchDetail !== "Semua" &&
// {
// "columns": [
// { "name": this.state.searchDetailField, "logic_operator": "like", "operator": "and", "value": this.state.search.toString() }
// ]
// },
// "orders": { "columns": ["created_date"], "descending": true }
// }
// const result = await axios
// .post(url, param)
// .then(res => res)
// .catch((error) => error.response);
}
const result = await axios
.post(url, payload, config)
@ -183,15 +147,6 @@ export default class index extends Component {
} else {
NotificationManager.error('Failed retreiving data!!', 'Failed');
}
// console.log("data result", result)
// if(result && result.data){
// if (result.status === 200) {
// this.setState({ dataTable: result.data.data, totalPage: result.data.totalRecord });
// } else {
// NotificationManager.error('Gagal Menerima Data!!', 'Failed');
// }
// }
}
handleOpenDialog = (type) => {
@ -232,14 +187,7 @@ export default class index extends Component {
}
saveBroadcast = async (type, data) => {
// let url = `${API_BROADCAST}/add`;
let url = BASE_SIMPRO + `/broadcast/add`;
// const param = {
// "title_notif": data.title,
// "message_notif": data.message,
// "description": data.description,
// "status_send": type
// }
const param = {
"title_notif": data.title,
@ -266,43 +214,11 @@ export default class index extends Component {
"description": data.description,
"send_to_id": data.id.map((id, index) => id)
}
// const formData = new FormData();
// formData.append("title", data.title);
// formData.append("message", data.message);
// formData.append("description", data.description);
// formData.append("send_to_type", data.send_to_type);
// if(type==="send"){
// formData.append('status_send', "complete");
// }else{
// formData.append('status_send', "registered");
// }
// if(data.send_to_type==="roles"){
// formData.append('id', data.id);
// }else if(data.send_to_type==="users"){
// data.id.map((id, index)=> {
// formData.append('id[]', id);
// console.log("test", id);
// })
// }else{
// formData.append('id', "all");
// }
// const param = {
// "title_notif": data.title,
// "message_notif": data.message,
// "description": data.description,
// "status_send": type,
// "send_to_type": data.send_to_type,
// "send_to_id": data.id
// }
// console.log("cek param", param)
if(data.send_to_type === "all") {
const result = await axios.post(url, param, config)
.then(res => res)
.catch((error) => error.response);
if (result) {
if(result.data){
if(result.data.code===200){
@ -317,13 +233,10 @@ export default class index extends Component {
}else{
NotificationManager.error(`${result.data.message}`, 'Failed!!');
}
} else if(data.send_to_type === "roles") {
const result = await axios.post(url, paramRoles, config)
.then(res => res)
.catch((error) => error.response);
console.log('test result broadcast all', result)
if (result) {
if(result.data){
if(result.data.code===200){
@ -338,12 +251,10 @@ export default class index extends Component {
}else{
NotificationManager.error(`${result.data.message}`, 'Failed!!');
}
} else if(data.send_to_type === "users") {
const result = await axios.post(url, paramUsers, config)
.then(res => res)
.catch((error) => error.response);
if (result) {
if(result.data){
if(result.data.code === 200){
@ -438,21 +349,14 @@ export default class index extends Component {
this.exportExcel();
});
}else{
// NotificationManager.error('Failed retreiving data!!', 'Failed');
}
} else {
// NotificationManager.error('Failed retreiving data!!', 'Failed');
}
}
exportExcel = () => {
const dataExcel = this.state.dataExport || [];
const dataExport = [];
// <td>{n.title_notif}</td>
// <td>{n.message_notif !== "" ? n.message_notif : "-"}</td>
// <td>{n.description !== "" ? n.description : "-"}</td>
// <td>{n.status_send !== "" ? n.status_send : "-"}</td>
// <td>{n.created_date !== "" ? moment.utc(n.created_date).for
dataExcel.map((val) => {
let row = {
"Tanggal Broadcast": moment(val.created_date).format("YYYY-MM-DD HH:mm:ss"),
@ -493,7 +397,6 @@ export default class index extends Component {
renderBtnResend = (n) => {
return (
<Col>
{/* <Button onClick={() => this.handleEdit(n.id, 'resend')} color="warning">Kirim Ulang</Button> */}
<i id="Tooltipresend" className="cil-reload fa-lg" style={{ color: 'orange', cursor: "pointer" }} onClick={() => this.handleEdit(n, 'resend')}></i>
<Tooltip placement="right" isOpen={this.state.tooltipresend} target="Tooltipresend" toggle={() => this.toggleTooltip("resend")}>
Kirim Ulang
@ -503,7 +406,6 @@ export default class index extends Component {
}
renderBtnSend = (n) => {
// <Button onClick={() => this.handleEdit(n.id, 'send')} color="warning" >Kirim</Button>
return (
<Col>
<i id="TooltipSend" className="cil-send fa-lg" style={{ color: 'orange', cursor: "pointer" }} onClick={() => this.handleEdit(n, 'send')}></i>
@ -567,21 +469,18 @@ export default class index extends Component {
const val = e.target.value;
this.setState({ currentDay:val });
if(val==="today"){
// console.log("test 1 test",val);
this.setState({
startDate:moment(moment().format("YYYY-M-D")),
endDate:moment(moment().format("YYYY-M-D")),
currentPage: 1
})
}else if(val==="3 day"){
// console.log("test test",val);
this.setState({
startDate:moment(moment().subtract(3, "days").format("YYYY-M-D")),
endDate:moment(moment().format("YYYY-M-D")),
currentPage: 1
})
}else if(val==="7 day"){
// console.log("test test",val);
this.setState({
startDate:moment(moment().subtract(7, "days").format("YYYY-M-D")),
endDate:moment(moment().format("YYYY-M-D")),
@ -639,7 +538,6 @@ export default class index extends Component {
<Col >
<Button id="TooltipTambah" color="success" onClick={() => this.handleOpenDialog('Save')}><i className="fa fa-plus"></i></Button>
<Button style={{marginLeft:"5px"}} id="TooltipExport" color="primary" onClick={()=> this.handleExportExcel()}><i className="fa fa-print"></i></Button>
{/* <Button color="primary" onClick={() => this.handleOpenDialog('Save')}>Tambah Divisi Karyawan</Button> */}
<Tooltip placement="right" isOpen={tooltipTambah} target="TooltipTambah" toggle={() => this.toggle("tambah")}>
Tambah Broadcast
</Tooltip>
@ -672,11 +570,6 @@ export default class index extends Component {
>
<DropdownToggle split outline />
<DropdownMenu>
{/* <DropdownItem onClick={
() => this.setState({
searchDetail: "Nama Karyawan",
searchDetailField: "name"
})}>Nama Karyawan</DropdownItem> */}
<DropdownItem onClick={
() => this.setState({
searchDetail: "Judul",

104
src/views/Master/MasterMenu/index.js

@ -1,13 +1,13 @@
import React, { useState, useEffect, useMemo } from 'react';
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import { Button } from 'reactstrap';
import axios from 'axios';
import * as XLSX from 'xlsx';
import SweetAlert from 'react-bootstrap-sweetalert';
import DialogForm from './DialogForm';
import React, { useState, useEffect, useMemo } from 'react';
import SweetAlert from 'react-bootstrap-sweetalert';
import axios from 'axios';
import { Button } from 'reactstrap';
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import { MENU_ADD,MENU_SEARCH,MENU_EDIT,MENU_DELETE } from '../../../const/ApiConst.js';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Tooltip, Table } from 'antd';
import { MENU_ADD,MENU_SEARCH,MENU_EDIT,MENU_DELETE } from '../../../const/ApiConst.js';
const token = window.localStorage.getItem('token');
@ -21,23 +21,23 @@ const column = [
]
const Index = ({params}) => {
const [dataTable, setDatatable] = useState([])
const [search, setSearch] = useState('')
const [currentPage, setCurrentPage] = useState(1)
const [totalPage, setTotalPage] = useState(0)
const [openDialog, setOpenDialog] = useState(false)
const [typeDialog, setTypeDialog] = useState('Save')
const [idDelete, setIdDelete] = useState(0)
const [alertDelete, setAlertDelete] = useState(false)
const [allDataMenu, setAllDataMenu] = useState([])
const [clickOpenModal, setClickOpenModal] = useState(false)
const [currentPage, setCurrentPage] = useState(1)
const [dataEdit, setDataEdit] = useState([])
const [dataExport, setDataExport] = useState([])
const [dataTable, setDatatable] = useState([])
const [idDelete, setIdDelete] = useState(0)
const [openDialog, setOpenDialog] = useState(false)
const [rowsPerPage, setRowsPerPage] = useState(10)
const [search, setSearch] = useState('')
const [tooltipDelete, setTooltipDelete] = useState(false)
const [tooltipEdit, setTooltipEdit] = useState(false)
const [tooltipTambah, setTooltipTambah] = useState(false)
const [tooltipExport, setTooltipExport] = useState(false)
const [clickOpenModal, setClickOpenModal] = useState(false)
const [dataExport, setDataExport] = useState([])
const [allDataMenu, setAllDataMenu] = useState([])
const [tooltipTambah, setTooltipTambah] = useState(false)
const [totalPage, setTotalPage] = useState(0)
const [typeDialog, setTypeDialog] = useState('Save')
const pageName = params.name;
@ -51,10 +51,8 @@ const Index = ({params}) => {
useEffect(()=> {
// for select in form add or edit
getDataMenu();
getDataAllMenu();
console.log("cek config", config)
},[])
useEffect(()=> {
@ -75,7 +73,6 @@ const Index = ({params}) => {
};
const getDataAllMenu = async () => {
const payload = {
"paging": {"start": 0, "length": -1},
"columns": [
@ -84,26 +81,18 @@ const Index = ({params}) => {
"joins": [],
"orders": {"columns": ["id"], "ascending": false}
}
const result = await axios
.post(MENU_SEARCH, payload, config)
.then(res => res)
.catch((error) => error.response);
// console.log(result)
if(result && result.data && result.data.code == 200){
setAllDataMenu(result.data.data);
}else{
// NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
}
}
const getDataMenu = async () => {
let start = 0;
if (currentPage !== 1 && currentPage > 1) {
@ -125,18 +114,13 @@ const Index = ({params}) => {
"orders": {"columns": ["id"], "ascending": false}
}
const result = await axios
.post(MENU_SEARCH, payload, config)
.then(res => res)
.catch((error) => error.response);
// console.log(result)
if(result && result.data && result.data.code == 200){
setDatatable(result.data.data);
console.log("resdata", result.data.data)
setTotalPage(result.data.totalRecord);
}else{
NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
@ -163,13 +147,10 @@ const Index = ({params}) => {
}
const onConfirmDelete = async () => {
const url = MENU_DELETE(idDelete)
const result = await axios.delete(url, config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
getDataMenu()
setIdDelete(0)
@ -200,7 +181,6 @@ const Index = ({params}) => {
}
const editMenu = async (data) => {
console.log("cek data edit", data)
const formData = data
const url = MENU_EDIT(data.id)
const result = await axios.put(url, formData, config)
@ -213,11 +193,8 @@ const Index = ({params}) => {
} else {
NotificationManager.error(`Data menu gagal di edit`, `Failed!!`);
}
}
const handleEdit = (data) => {
setDataEdit(data)
handleOpenDialog('Edit');
@ -249,7 +226,6 @@ const Index = ({params}) => {
}
const handleExportExcel = async () => {
const payload = {
"paging": {"start": 0, "length": -1},
"columns": [
@ -265,18 +241,13 @@ const Index = ({params}) => {
"orders": {"columns": ["id"], "ascending": false}
}
const result = await axios
.post(MENU_SEARCH, payload, config)
.then(res => res)
.catch((error) => error.response);
// console.log(result)
if(result && result.data && result.data.code == 200){
let resData = result.data.data;
console.log("resdata", resData)
const excelData = [];
resData.map((val, index) => {
let dataRow = {
@ -289,9 +260,7 @@ const Index = ({params}) => {
}
excelData.push(dataRow)
})
// console.log("cek excel data", excelData)
await setDataExport(excelData);
// exportExcel();
}else{
NotificationManager.error('Gagal Export Data!!', 'Failed');
}
@ -303,7 +272,6 @@ const Index = ({params}) => {
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([])
}
@ -389,44 +357,6 @@ const Index = ({params}) => {
</Row>
</CardHeader>
<CardBody>
{/* <Table responsive striped hover>
<thead>
<tr>
<th className="capitalize">{`Aksi`}</th>
{column.map((i, index) => {
return (
<th key={index} scope="row">{i.name}</th>
)
})}
</tr>
</thead>
<tbody>
{dataTable.length<=0 ?
<tr>
<td colSpan="7" align="center">No Data Available</td>
</tr> : null}
{dataTable.map((n, index) => {
return (
<tr key={index}>
<td>
<Tooltip title="Delete">
<i id="TooltipDelete" className="fa fa-trash" style={{ color: 'red', marginRight: '10px', cursor: "pointer" }} onClick={() => handleDelete(n.id)}></i>
</Tooltip>
<Tooltip title="Edit">
<i id="TooltipEdit" className="fa fa-pencil" style={{ color: 'green', cursor: "pointer" }} onClick={() => handleEdit(n)}></i>
</Tooltip>
</td>
<td>{n.name}</td>
<td>{n.url}</td>
<td>{n.icon}</td>
<td>{n.alias_name}</td>
<td>{n.sequence}</td>
<td>{n.join_first_name ? n.join_first_name : "-"}</td>
</tr>
)
})}
</tbody>
</Table> */}
{renderTable}
<Pagination
style={{marginTop:"25px"}}

111
src/views/Master/MasterRoles/index.js

@ -1,14 +1,13 @@
import React, { Component, useMemo } from 'react';
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import { Button } from 'reactstrap';
import axios from 'axios';
import * as XLSX from 'xlsx';
import SweetAlert from 'react-bootstrap-sweetalert';
import DialogForm from './DialogForm';
import DialogMenuRoles from './DialogMenuRoles';
import React, { Component, useMemo } from 'react';
import SweetAlert from 'react-bootstrap-sweetalert';
import axios from 'axios';
import { Button } from 'reactstrap';
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Tooltip, Table } from 'antd';
import { ROLE_ADD, ROLE_SEARCH, ROLE_EDIT, ROLE_DELETE, ROLEMENU_ADD, ROLEMENU_SEARCH, ROLEMENU_DELETE_ROLE } from '../../../const/ApiConst.js';
const token = window.localStorage.getItem('token');
@ -25,38 +24,36 @@ const config = {
const momentFormat = 'HH:mm';
const LENGTH_DATA = 10
export default class index extends Component {
constructor(props) {
super(props)
this.state = {
dataTable: [],
openDialog: false,
dialogMenuForm: false,
typeDialog: 'Save',
dataEdit: null,
alertDelete: false,
alertNotDelete: false,
idDelete: 0,
currentPage: 1,
dataEdit: null,
dataExport:[],
dataGs: [],
dataIdHo: [],
search: "",
dataTable: [],
dialogMenuForm: false,
idDelete: 0,
idRoles:0,
menuRoles:[],
openDialog: false,
page: 0,
rowsPerPage: LENGTH_DATA,
currentPage: 1,
totalPage: 0,
tooltipEdit: false,
search: "",
tooltipDelete: false,
tooltipEdit: false,
tooltipExport:false,
tooltipImport:false,
tooltipMenu: false,
idRoles:0,
menuRoles:[],
tooltipTambah:false,
tooltipImport:false,
tooltipExport:false,
dataExport:[]
totalPage: 0,
typeDialog: 'Save',
}
this.columns = [
@ -99,9 +96,7 @@ export default class index extends Component {
};
getDataRoles = async () => {
let start = 0;
if (this.state.currentPage !== 1 && this.state.currentPage > 1) {
start = (this.state.currentPage * this.state.rowsPerPage) - this.state.rowsPerPage
}
@ -119,7 +114,6 @@ export default class index extends Component {
.post(ROLE_SEARCH, formData, config)
.then(res => res)
.catch((error) => error.response);
// console.log(result)
if(result && result.data && result.data.code == 200){
this.setState({ dataTable: result.data.data, totalPage: result.data.totalRecord });
@ -133,23 +127,20 @@ export default class index extends Component {
this.showChildDialog();
}
handleCloseDialog = (type, data) => {
if (type === "save") {
this.saveRole(data);
} else if (type === "edit") {
this.editRole(data);
}
this.setState({ openDialog: false })
}
handleOpenDialogMr = () => {
this.setState({ dialogMenuForm: true })
this.showMenuRolesDialog();
}
handleCloseDialogMr = (type, data) => {
if(type==="save"){
this.saveMenuRoles(data)
@ -201,7 +192,6 @@ export default class index extends Component {
}
editRole = async (data) => {
const formData = {
name:data.name,
description:data.description
@ -217,10 +207,8 @@ export default class index extends Component {
} else {
NotificationManager.error(`Data role gagal di edit`, `Failed!!`);
}
}
handleEdit = (data) => {
this.setState({ dataEdit: data });
this.handleOpenDialog('Edit');
@ -268,7 +256,6 @@ export default class index extends Component {
}
handleMenuRoles = async (id) => {
const formData = {
"paging": {"start": 0, "length": -1},
"columns": [
@ -282,25 +269,21 @@ export default class index extends Component {
.post(ROLEMENU_SEARCH, formData, config)
.then(res => res)
.catch((error) => error.response);
// console.log(result)
if (result && result.data && result.data.code == 200) {
this.setState({ menuRoles:result.data.data,idRoles:id },() => {
this.handleOpenDialogMr();
});
} else {
// NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
}
}
saveMenuRoles = async (dataArray) => {
let payloadArray = dataArray || []
// console.log("cek", payloadArray[0])
if(payloadArray.length > 0){
await this.deleteCurrentRoleMenu(payloadArray[0].roles_id)
}
let promises = []
let result = []
console.log("test test", dataArray)
dataArray.map((val, index)=> {
if(val.checked===true){
const formData = {
@ -323,7 +306,6 @@ export default class index extends Component {
}
}
}
}
deleteCurrentRoleMenu = async (id) => {
@ -331,7 +313,6 @@ export default class index extends Component {
const result = await axios.delete(urlDel, config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
return true
} else {
@ -348,21 +329,13 @@ export default class index extends Component {
if(this.state.search !== ""){
formData.append('value', this.state.search);
}
// console.log("test", url);
const result = await axios
.post(url,formData)
.then(res => res)
.catch((error) => error.response);
// console.log("result", result);
if (result && result.data && result.statusText == "OK") {
const dataRes = result.data.data|| [];
console.log("data result", dataRes);
const dataExport = [];
// <td>{n.name}</td>
// <td>{n.url}</td>
// <td>{n.alias_name}</td>
// <td>{n.icon}</td>
// <td>{n.parent_name || "-"}</td>
dataRes.map((val,index)=> {
let row = {
Nama:val.name,
@ -370,7 +343,6 @@ export default class index extends Component {
}
dataExport.push(row);
})
console.log("data Export", dataExport);
this.setState({ dataExport:dataExport },()=> {
this.exportExcel();
});
@ -385,7 +357,6 @@ export default class index extends Component {
const ws = XLSX.utils.json_to_sheet(dataExcel);
const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, 'Data Roles');
XLSX.writeFile(wb, fileName);
}
@ -411,12 +382,10 @@ export default class index extends Component {
<SweetAlert
show={this.state.alertNotDelete}
warning
// showCancel
confirmBtnText="Can't Delete"
confirmBtnBsStyle="danger"
title="Data can't be delete!"
onConfirm={() => this.setState({ alertNotDelete: false})}
// focusCancelBtn
>
Data tipe roles tidak dapat di hapus!!
</SweetAlert>
@ -435,7 +404,6 @@ export default class index extends Component {
idRoles={this.state.idRoles}
showDialog={showDialog => this.showMenuRolesDialog = showDialog}
menuRoles={this.state.menuRoles}
/>
<Card>
<CardHeader style={{ display: "flex", justifyContent: "space-between" }}>
@ -463,43 +431,6 @@ export default class index extends Component {
pagination={false}
bordered={false}
/>
{/* <Table responsive striped hover>
<thead>
<tr>
<th>Aksi</th>
{column.map((i, index) => {
return (
<th key={index} scope="row">{i.name}</th>
)
})}
</tr>
</thead>
<tbody>
{this.dataNotAvailable()}
{dataTable.map((n, index) => {
return (
<tr key={n.id}>
<td>
<Tooltip title="Roles Menu">
<i id={`TooltipMenu-${n.id}`} className="cil-menu fa-lg" style={{ color: 'green', marginRight: 10, cursor: "pointer" }} onClick={() => this.handleMenuRoles(n.id)}></i>
</Tooltip>
<Tooltip title="Hapus">
<i id="TooltipDelete" className="cil-trash fa-lg" style={{ color: 'red', marginRight: 10, cursor: "pointer" }} onClick={() => this.handleDelete(n.id)}></i>
</Tooltip>
<Tooltip title="Edit">
<i id="TooltipEdit" className="cil-pencil fa-lg" style={{ color: 'green', cursor: "pointer" }} onClick={() => this.handleEdit(n)}></i>
</Tooltip>
</td>
<td>{n.name}</td>
<td>{n.description}</td>
</tr>
)
})}
</tbody>
</Table> */}
<Pagination
style={{marginTop:"25px"}}
showSizeChanger

103
src/views/Master/RoleProject/index.js

@ -1,14 +1,13 @@
import React, { Component } from 'react';
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import { Button } from 'reactstrap';
import axios from 'axios';
import * as XLSX from 'xlsx';
import SweetAlert from 'react-bootstrap-sweetalert';
import DialogForm from './DialogForm';
import React, { Component } from 'react';
import SweetAlert from 'react-bootstrap-sweetalert';
import axios from 'axios';
import { Button } from 'reactstrap';
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Tooltip, Table } from 'antd';
import { PROJECT_ROLE_ADD, PROJECT_ROLE_SEARCH, PROJECT_ROLE_EDIT, PROJECT_ROLE_DELETE, ROLEMENU_ADD, ROLEMENU_SEARCH, ROLEMENU_DELETE_ROLE } from '../../../const/ApiConst.js';
import { Pagination, Tooltip, Table } from 'antd';
const token = window.localStorage.getItem('token');
@ -55,30 +54,30 @@ export default class index extends Component {
constructor(props) {
super(props)
this.state = {
dataTable: [],
openDialog: false,
dialogMenuForm: false,
typeDialog: 'Save',
dataEdit: null,
alertDelete: false,
alertNotDelete: false,
idDelete: 0,
currentPage: 1,
dataEdit: null,
dataExport:[],
dataGs: [],
dataIdHo: [],
search: "",
dataTable: [],
dialogMenuForm: false,
idDelete: 0,
idRoles:0,
menuRoles:[],
openDialog: false,
page: 0,
rowsPerPage: LENGTH_DATA,
currentPage: 1,
totalPage: 0,
tooltipEdit: false,
search: "",
tooltipDelete: false,
tooltipEdit: false,
tooltipExport:false,
tooltipImport:false,
tooltipMenu: false,
idRoles:0,
menuRoles:[],
tooltipTambah:false,
tooltipImport:false,
tooltipExport:false,
dataExport:[]
totalPage: 0,
typeDialog: 'Save',
}
}
@ -97,9 +96,7 @@ export default class index extends Component {
};
getDataRoles = async () => {
let start = 0;
if (this.state.currentPage !== 1 && this.state.currentPage > 1) {
start = (this.state.currentPage * this.state.rowsPerPage) - this.state.rowsPerPage
}
@ -117,7 +114,6 @@ export default class index extends Component {
.post(PROJECT_ROLE_SEARCH, formData, config)
.then(res => res)
.catch((error) => error.response);
// console.log(result)
if(result && result.data && result.data.code == 200){
this.setState({ dataTable: result.data.data, totalPage: result.data.totalRecord });
@ -131,16 +127,12 @@ export default class index extends Component {
this.showChildDialog();
}
handleCloseDialog = (type, data) => {
if (type === "save") {
this.saveRole(data);
} else if (type === "edit") {
this.editRole(data);
}
this.setState({ openDialog: false })
}
@ -273,21 +265,14 @@ export default class index extends Component {
"joins": [],
"orders": {"columns": ["id"], "ascending": false}
}
// console.log("test", url);
const result = await axios
.post(PROJECT_ROLE_SEARCH, payload)
.then(res => res)
.catch((error) => error.response);
// console.log("result", result);
if (result && result.data && result.statusText == "OK") {
const dataRes = result.data.data|| [];
console.log("data result", dataRes);
const dataExport = [];
// <td>{n.name}</td>
// <td>{n.url}</td>
// <td>{n.alias_name}</td>
// <td>{n.icon}</td>
// <td>{n.parent_name || "-"}</td>
dataRes.map((val,index)=> {
let row = {
Nama:val.name,
@ -295,7 +280,6 @@ export default class index extends Component {
}
dataExport.push(row);
})
console.log("data Export", dataExport);
this.setState({ dataExport:dataExport },()=> {
this.exportExcel();
});
@ -310,7 +294,6 @@ export default class index extends Component {
const ws = XLSX.utils.json_to_sheet(dataExcel);
const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, 'Data Project Role');
XLSX.writeFile(wb, fileName);
}
@ -336,12 +319,10 @@ export default class index extends Component {
<SweetAlert
show={this.state.alertNotDelete}
warning
// showCancel
confirmBtnText="Can't Delete"
confirmBtnBsStyle="danger"
title="Data can't be delete!"
onConfirm={() => this.setState({ alertNotDelete: false})}
// focusCancelBtn
>
Data project role tidak dapat di hapus!!
</SweetAlert>
@ -354,14 +335,6 @@ export default class index extends Component {
showDialog={showDialog => this.showChildDialog = showDialog}
dataHs={this.state.dataIdHo}
/>
{/* <DialogMenuRoles
openDialog={dialogMenuForm}
closeDialog={this.handleCloseDialogMr}
idRoles={this.state.idRoles}
showDialog={showDialog => this.showMenuRolesDialog = showDialog}
menuRoles={this.state.menuRoles}
/> */}
<Card>
<CardHeader style={{ display: "flex", justifyContent: "space-between" }}>
<h4>{this.props.params.name}</h4>
@ -380,40 +353,6 @@ export default class index extends Component {
</Row>
</CardHeader>
<CardBody>
{/* <Table responsive striped hover>
<thead>
<tr>
<th>Aksi</th>
{column.map((i, index) => {
return (
<th key={index} scope="row">{i.name}</th>
)
})}
</tr>
</thead>
<tbody>
{this.dataNotAvailable()}
{dataTable.map((n, index) => {
return (
<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={() => this.handleDelete(n.id)}></i>
</Tooltip>
<Tooltip title="Edit">
<i id="TooltipEdit" className="cil-pencil fa-lg" style={{ color: 'green', cursor: "pointer" }} onClick={() => this.handleEdit(n)}></i>
</Tooltip>
</td>
<td>{n.name}</td>
<td>{n.description}</td>
</tr>
)
})}
</tbody>
</Table> */}
<Table
rowKey="id"
size="small"

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

@ -1,9 +1,9 @@
import React, { useState, useEffect, useMemo } from 'react';
import { Card, CardBody, CardHeader, Col, Row, Input, Table } from 'reactstrap';
import axios from "../../../const/interceptorApi"
import * as XLSX from 'xlsx';
import SweetAlert from 'react-bootstrap-sweetalert';
import DialogForm from './DialogForm';
import React, { useState, useEffect, useMemo } from 'react';
import SweetAlert from 'react-bootstrap-sweetalert';
import axios from "../../../const/interceptorApi"
import { Card, CardBody, CardHeader, Col, Row, Input, Table } from 'reactstrap';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Button, Tooltip } from 'antd';
import {
@ -18,12 +18,10 @@ const config = {
"Content-type": `application/json`
}
};
const column = [
{ name: "Nama" },
{ name: "Deskripsi" },
]
const ChecklistK3 = ({ params }) => {
const token = localStorage.getItem("token")
const HEADER = {
@ -32,20 +30,21 @@ const ChecklistK3 = ({ params }) => {
"Authorization": `Bearer ${token}`
}
}
const pageName = params.name;
const [search, setSearch] = useState('')
const [alertDelete, setAlertDelete] = useState(false)
const [allDataMenu, setAllDataMenu] = useState([])
const [clickOpenModal, setClickOpenModal] = useState(false)
const [currentPage, setCurrentPage] = useState(1)
const [openDialog, setOpenDialog] = useState(false)
const [typeDialog, setTypeDialog] = useState('Save')
const [dataExport, setDataExport] = useState([])
const [rowsPerPage, setRowsPerPage] = useState(10)
const [dataEdit, setDataEdit] = useState([])
const [alertDelete, setAlertDelete] = useState(false)
const [idDelete, setIdDelete] = useState(0)
const [dataExport, setDataExport] = useState([])
const [dataTable, setDatatable] = useState([])
const [clickOpenModal, setClickOpenModal] = useState(false)
const [allDataMenu, setAllDataMenu] = useState([])
const [idDelete, setIdDelete] = useState(0)
const [openDialog, setOpenDialog] = useState(false)
const [rowsPerPage, setRowsPerPage] = useState(10)
const [search, setSearch] = useState('')
const [totalPage, setTotalPage] = useState(0)
const [typeDialog, setTypeDialog] = useState('Save')
useEffect(() => {
getDataChecklistK3()
@ -86,17 +85,12 @@ const ChecklistK3 = ({ params }) => {
"start": start
}
}
// console.log("payload ", payload)
const result = await axios
.post(CHECKLIST_K3_SEARCH, payload, config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
console.log("get data ", result.data)
setDatatable(result.data.data);
setTotalPage(result.data.totalRecord);
} else {
@ -116,7 +110,6 @@ const ChecklistK3 = ({ params }) => {
}
const handleExportExcel = async () => {
console.log("cek cek cek cke")
const payload = {
"paging": { "start": 0, "length": -1 },
"columns": [
@ -126,15 +119,11 @@ const ChecklistK3 = ({ params }) => {
"orders": { "columns": ["id"], "ascending": false }
}
const result = await axios
.post(CHECKLIST_K3_SEARCH, payload, config)
.then(res => res)
.catch((error) => error.response);
// console.log(result)
if (result && result.data && result.data.code == 200) {
let resData = result.data.data;
const excelData = [];
@ -145,9 +134,7 @@ const ChecklistK3 = ({ params }) => {
}
excelData.push(dataRow)
})
// console.log("cek excel data", resData)
await setDataExport(excelData);
// exportExcel();
} else {
NotificationManager.error('Gagal Export Data!!', 'Failed');
}
@ -155,7 +142,6 @@ const ChecklistK3 = ({ params }) => {
const exportExcel = () => {
const dataExcel = dataExport || [];
console.log("cek data excel", dataExcel)
const fileName = `Data ${pageName}.xlsx`;
const ws = XLSX.utils.json_to_sheet(dataExcel);
const wb = XLSX.utils.book_new();
@ -202,9 +188,6 @@ const ChecklistK3 = ({ params }) => {
let urlEdit = CHECKLIST_K3_EDIT(data.id)
const formData = data
console.log("from data edit ", formData)
const result = await axios.put(urlEdit, formData, HEADER)
.then(res => res)
.catch((error) => error.response);
@ -263,8 +246,6 @@ const ChecklistK3 = ({ params }) => {
}
}
return (
<div>
<NotificationContainer />
@ -325,11 +306,9 @@ const ChecklistK3 = ({ params }) => {
return (
<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>
</Tooltip>
<Tooltip title="Edit">
<i id="TooltipEdit" className="cil-pencil fa-lg" style={{ color: 'green', cursor: "pointer" }} onClick={() => handleEdit(n)}></i>
</Tooltip>

165
src/views/SimproV2/Closing/index.js

@ -1,15 +1,15 @@
import * as XLSX from 'xlsx';
import DialogForm from './DialogForm';
import React, { useState, useEffect, useMemo } from 'react';
import SweetAlert from 'react-bootstrap-sweetalert';
import axios from "../../../const/interceptorApi";
import moment from 'moment'
import { BASE_SIMPRO, PROYEK_ADD, PROYEK_SEARCH, PROYEK_EDIT, PROYEK_DELETE } from '../../../const/ApiConst';
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import { DownloadOutlined } from '@ant-design/icons';
import axios from "../../../const/interceptorApi";
import * as XLSX from 'xlsx';
import SweetAlert from 'react-bootstrap-sweetalert';
import DialogForm from './DialogForm';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Table, Button, Tooltip } from 'antd';
import { BASE_SIMPRO, PROYEK_ADD, PROYEK_SEARCH, PROYEK_EDIT, PROYEK_DELETE } from '../../../const/ApiConst';
import { formatRupiah } from '../../../const/CustomFunc'
import moment from 'moment'
const url = "";
const proyek_id = localStorage.getItem('proyek_id');
@ -25,29 +25,29 @@ const Closing = ({ params, ...props }) => {
}
}
const [idTask, setidTask] = useState(0);
const [dataTable, setDatatable] = useState([])
const [search, setSearch] = useState('')
const [alertClose, setAlertClose] = useState(false)
const [alertDelete, setAlertDelete] = useState(false)
const [allDataMenu, setAllDataMenu] = useState([])
const [clickOpenModal, setClickOpenModal] = useState(false)
const [currentPage, setCurrentPage] = useState(1)
const [totalPage, setTotalPage] = useState(0)
const [dataCharter, setDataCharter] = useState(null)
const [dataEdit, setDataEdit] = useState([])
const [dataEditSub, setDataEditSub] = useState([])
const [dataExport, setDataExport] = useState([])
const [dataTable, setDatatable] = useState([])
const [dataView, setDataView] = useState([])
const [idDelete, setIdDelete] = useState(0)
const [idTask, setidTask] = useState(0);
const [openDialog, setOpenDialog] = useState(false)
const [openDialogMap, setOpenDialogMap] = useState(false)
const [openDialogResource, setOpenDialogResource] = useState(false)
const [openDialogViewDetail, setOpenDialogViewDetail] = useState(false)
const [openDialogMap, setOpenDialogMap] = useState(false)
const [rowsPerPage, setRowsPerPage] = useState(10)
const [search, setSearch] = useState('')
const [totalPage, setTotalPage] = useState(0)
const [typeDialog, setTypeDialog] = useState('Save');
const [typeDialogSub, setTypeDialogSub] = useState('Save')
const [idDelete, setIdDelete] = useState(0)
const [alertDelete, setAlertDelete] = useState(false)
const [alertClose, setAlertClose] = useState(false)
const [dataEdit, setDataEdit] = useState([])
const [dataEditSub, setDataEditSub] = useState([])
const [rowsPerPage, setRowsPerPage] = useState(10)
const [clickOpenModal, setClickOpenModal] = useState(false)
const [dataExport, setDataExport] = useState([])
const [allDataMenu, setAllDataMenu] = useState([])
const [userProyek, setUserProyek] = useState([]);
const [dataCharter, setDataCharter] = useState(null)
const [dataView, setDataView] = useState([])
const pageName = params.name;
useEffect(() => {
@ -62,7 +62,6 @@ const Closing = ({ params, ...props }) => {
const getDataProyek = async () => {
let start = 0;
if (currentPage !== 1 && currentPage > 1) {
@ -76,7 +75,6 @@ const Closing = ({ params, ...props }) => {
"joins": [
{ "name": "m_users", "column_join": "pm_id", "column_results": ["name", "username"] },
{ "name": "m_type_proyek", "column_join": "type_proyek_id", "column_results": ["name", "description"] },
// { "name": "subproyeks.m_subproyek", "column_join": "parent_id", "column_results": ["nama", "biaya", "color_progress", "jumlah_pekerja", "pic", "mulai_proyek", "akhir_proyek", "biaya_actual", "persentase_progress_plan", "persentase_progress_actual"] }
],
"orders": { "columns": ["id"], "ascending": true },
"paging": { "start": 0, "length": 25 }
@ -89,18 +87,13 @@ const Closing = ({ params, ...props }) => {
]
}
// console.log("cek payload", payload)
const URL = `${BASE_SIMPRO}/proyek/search-detail`
const result = await axios
.post(URL, payload, HEADER)
.then(res => res)
.catch((error) => error.response);
// console.log("data sub proyek", result)
if (result && result.data && result.data.code == 200) {
console.log("cek proyek", result.data.data)
let dataRes = result.data.data || []
setDatatable(dataRes);
@ -122,7 +115,6 @@ const Closing = ({ params, ...props }) => {
}
const handleOpenDialogViewDetail = (data) => {
console.log('handleOpenDialogViewDetail', data);
setOpenDialogViewDetail(true)
setidTask(data.id)
setDataView(data)
@ -138,18 +130,10 @@ const Closing = ({ params, ...props }) => {
}
const handleCloseDialogResource = (type, payload) => {
// if (type === "add") saveProyek(payload);
// if (type === "edit") editProyek(payload);
setOpenDialogResource(false)
}
const handleCloseDialogView = (type, payload) => {
// if (type === "add") saveProyek(payload);
// if (type === "edit") editProyek(payload);
setOpenDialogViewDetail(false)
}
@ -164,7 +148,6 @@ const Closing = ({ params, ...props }) => {
const result = await axios.delete(urlDel, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
getDataProyek()
setIdDelete(0)
@ -178,21 +161,6 @@ const Closing = ({ params, ...props }) => {
}
const onConfirmClose = async () => {
// let urlDel = PROYEK_DELETE(idDelete)
// const result = await axios.delete(urlDel, HEADER)
// .then(res => res)
// .catch((error) => error.response);
// if (result && result.data && result.data.code === 200) {
// getDataProyek()
// setIdDelete(0)
// setAlertDelete(false)
// NotificationManager.success(`Data proyek berhasil dihapus`, 'Success!!');
// } else {
// setIdDelete(0)
// setAlertDelete(false)
// NotificationManager.error(`Data proyek gagal dihapus`, 'Failed!!');
// }
setIdDelete(0)
setAlertClose(false)
NotificationManager.success(`Data proyek berhasil diclose`, 'Success!!');
@ -215,7 +183,6 @@ const Closing = ({ params, ...props }) => {
}
const editProyek = async (data) => {
let urlEdit = PROYEK_EDIT(data.id)
const formData = data
@ -229,19 +196,14 @@ const Closing = ({ params, ...props }) => {
} else {
NotificationManager.error(`Data proyek gagal di edit`, `Failed!!`);
}
}
const handleDelete = async (id) => {
// console.log('Delete')
await setAlertDelete(true)
await setIdDelete(id)
}
const handleCloseProject = async (id) => {
// console.log('Delete')
await setAlertClose(true)
await setIdDelete(id)
}
@ -258,9 +220,6 @@ const Closing = ({ params, ...props }) => {
const payload = {
"paging": { "start": 0, "length": -1 },
// "columns": [
// { "name": "nama", "logic_operator": "like", "value": search, "operator": "AND" }
// ],
"joins": [],
"orders": { "columns": ["id"], "ascending": false }
}
@ -271,25 +230,14 @@ const Closing = ({ params, ...props }) => {
]
}
const result = await axios
.post(PROYEK_SEARCH, payload, HEADER)
.then(res => res)
.catch((error) => error.response);
// console.log(result)
if (result && result.data && result.data.code == 200) {
let resData = result.data.data;
const excelData = [];
// <td>{n.nama}</td>
// <td>{n.biaya}</td>
// <td style={{textAlign:"center"}}><div style={{borderRadius:"50%",height:"25px",width:"25px",backgroundColor:n.color_progress}}></div></td>
// <td>{n.jumlah_pekerja}</td>
// <td>{n.pic}</td>
// <td>{n.mulai_proyek ? moment(n.mulai_proyek).format("DD-MM-YYYY") : "-"}</td>
// <td>{n.akhir_proyek ? moment(n.akhir_proyek).format("DD-MM-YYYY") : "-"}</td>
resData.map((n, index) => {
let dataRow = {
"Nama Proyek": n.nama,
@ -301,9 +249,7 @@ const Closing = ({ params, ...props }) => {
}
excelData.push(dataRow)
})
// console.log("cek excel data", excelData)
await setDataExport(excelData);
// exportExcel();
} else {
NotificationManager.error('Gagal Export Data!!', 'Failed');
}
@ -339,10 +285,8 @@ const Closing = ({ params, ...props }) => {
}
const handleClickGantt = (id) => {
// props.history.push("/gantt")
props.history.push({
pathname: '/gantt',
// search: `?proyek_id=${id}`,
state: { proyek_id: id }
})
}
@ -354,24 +298,6 @@ const Closing = ({ params, ...props }) => {
dataIndex: '',
key: 'x',
render: (text, record) => <>
{/* <Tooltip title="View Project">
<Button size="small" type="link" style={{ color: 'blue' }} onClick={() => handleOpenDialogViewDetail(text)}><i className="fa fa-eye"></i></Button>
</Tooltip>
<Tooltip title="Add Resources">
<Button size="small" type="link" style={{ color: 'green' }} onClick={() => handleOpenDialogResource(text)}><i className="fa fa-plus"></i></Button>
</Tooltip>
<Tooltip title="Gantt">
<Button size="small" type="link" style={{ color: 'lightblue' }} onClick={() => handleClickGantt(text.id)}><i className="fa fa-bars"></i></Button>
</Tooltip>
<Tooltip title="Edit Proyek">
<Button size="small" type="link" style={{ color: 'orange' }} onClick={() => handleOpenDialog(text.id)}><i className="fa fa-edit"></i></Button>
</Tooltip>
<Tooltip title="Hapus Proyek">
<Button size="small" type="link" style={{ color: 'red' }} onClick={() => handleDelete(text.id)}><i className="fa fa-trash"></i></Button>
</Tooltip> */}
{/* <Tooltip title="Close">
<Button size="small" type="link" style={{ color: 'green' }} onClick={() => handleCloseProject(text.id)}><i className="fa fa-close"></i></Button>
</Tooltip> */}
<Tooltip title="Report">
<Button size="small" type="link" style={{ color: 'orange' }} onClick={() => handleOpenDialog(text.id)}><i className="fa fa-print"></i></Button>
</Tooltip>
@ -406,10 +332,6 @@ const Closing = ({ params, ...props }) => {
<Table
size="small"
columns={columns}
// expandable={{
// expandedRowRender: record => <SubProyekComp getDataProyek={getDataProyek} idParentTask={record.id} nameProyek={record.nama} data={record.subproyeks2} />,
// rowExpandable: record => record.subproyeks2,
// }}
dataSource={dataTable}
/>
)
@ -424,43 +346,9 @@ const Closing = ({ params, ...props }) => {
/>
), [openDialog])
// const RenderDialogFormResources = useMemo(() => (
// <DialogFormResource
// openDialog={openDialogResource}
// closeDialog={handleCloseDialogResource}
// toggleDialog={() => toggleAddDialogResource}
// idTask={idTask}
// userProyek={userProyek}
// />
// ), [openDialogResource])
// const ViewProyek = useMemo(() => (
// <ViewProject
// openDialog={openDialogViewDetail}
// closeDialog={handleCloseDialogView}
// toggleDialog={() => toggleAddDialogView}
// idTask={idTask}
// dataView={dataView}
// dataCharter={dataCharter}
// />
// ), [openDialogViewDetail])
return (
<div>
<NotificationContainer />
{/* <SweetAlert
show={alertDelete}
warning
showCancel
confirmBtnText="Delete"
confirmBtnBsStyle="danger"
title={`Are you sure?`}
onConfirm={onConfirmDelete}
onCancel={() => cancelDelete()}
focusCancelBtn
>
Delete this data
</SweetAlert> */}
<SweetAlert
show={alertClose}
warning
@ -482,18 +370,9 @@ const Closing = ({ params, ...props }) => {
<Col>
<Input onChange={handleSearch} value={search} type="text" name="search" id="search" placeholder={`Cari nama proyek`} />
</Col>
{/* <Col>
<Tooltip title="Tambah Proyek">
<Button style={{ background: "#4caf50", color: "#fff" }} onClick={() => handleOpenDialog(0)}><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>
<CardBody>
{RenderTable}
</CardBody>
</Card>

9
src/views/SimproV2/ControlMonitoring/index.js

@ -1,11 +1,11 @@
import * as XLSX from 'xlsx';
import React, { useState, useEffect, useMemo } from 'react';
import SweetAlert from 'react-bootstrap-sweetalert';
import axios from "../../../const/interceptorApi";
import moment from 'moment'
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import { DownloadOutlined } from '@ant-design/icons';
import axios from "../../../const/interceptorApi";
import * as XLSX from 'xlsx';
import SweetAlert from 'react-bootstrap-sweetalert';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import moment from 'moment'
const ControlMonitoring = ({params}) => {
const token = localStorage.getItem("token")
@ -18,7 +18,6 @@ const ControlMonitoring = ({params}) => {
useEffect(() => {
}, [])
return (
<div>
<NotificationContainer />

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

@ -1,12 +1,24 @@
import React, { useState, useEffect, useMemo } from 'react';
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import axios from "../../../const/interceptorApi"
import * as XLSX from 'xlsx';
import SweetAlert from 'react-bootstrap-sweetalert';
import AssignHrProject from './AsignHrProject';
import AssignK3Project from './AssignK3Project';
import DialogDocument from './DialogDocument';
import DialogForm from './DialogForm';
import DialogFormMaterial from './DataRequestMaterial';
import DialogFormProyek from './DialogFormProyek';
import DialogGantt from './DialogGantt';
import DialogInitDocument from './DialogInitDocument';
import DialogTableTools from './DialogTableTools';
import React, { useState, useEffect, useMemo } from 'react';
import SweetAlert from 'react-bootstrap-sweetalert';
import ViewProject from './ViewProject';
import axios from "../../../const/interceptorApi"
import moment from 'moment'
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import { Icon } from '@iconify/react';
import { Link } from 'react-router-dom';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Table, Button, Tooltip, Popover, Skeleton, Divider } from 'antd';
import { formatNumber, formatRupiah, formatThousand, renderFormatRupiah } from '../../../const/CustomFunc'
import {
PROJECT_APPROVAL_ADD, PROJECT_APPROVAL_EDIT, PROJECT_PARTICIPANT_ADD, PROJECT_PARTICIPANT_EDIT,
PROJECT_MILESTONE_ADD, PROJECT_MILESTONE_EDIT, PROJECT_PARTICIPANT_DELETE_BY_PROYEK, PROJECT_MILESTONE_DELETE_BY_PROYEK, PROJECT_APPROVAL_DELETE_BY_PROYEK,
@ -14,18 +26,6 @@ import {
PROYEK_GET_ID, PROJECT_MILESTONE_SEARCH, PROJECT_PARTICIPANT_SEARCH, PROJECT_APPROVAL_SEARCH, CHECKLIST_K3_LIST,
VERSION_GANTT_SEARCH
} from '../../../const/ApiConst';
import { formatNumber, formatRupiah, formatThousand, renderFormatRupiah } from '../../../const/CustomFunc'
import moment from 'moment'
import DialogFormMaterial from './DataRequestMaterial';
import DialogTableTools from './DialogTableTools';
import DialogDocument from './DialogDocument';
import DialogInitDocument from './DialogInitDocument';
import DialogGantt from './DialogGantt';
import AssignHrProject from './AsignHrProject';
import AssignK3Project from './AssignK3Project';
import ViewProject from './ViewProject';
import { Icon } from '@iconify/react';
import { Link } from 'react-router-dom';
const url = "";
const proyek_id = localStorage.getItem('proyek_id');
@ -41,35 +41,35 @@ const CreatedProyek = ({ params, ...props }) => {
}
}
const [idTask, setidTask] = useState(0);
const [dataTable, setDatatable] = useState([])
const [search, setSearch] = useState('')
const [currentPage, setCurrentPage] = useState(1)
const [totalPage, setTotalPage] = useState(0)
const [openDialog, setOpenDialog] = useState(false)
const [openDialogViewDetail, setOpenDialogViewDetail] = useState(false)
const [openDialogMaterial, setOpenDialogMaterial] = useState(false)
const [openDialogTools, setOpenDialogTools] = useState(false)
const [openDialogGantt, setOpenDialogGantt] = useState(false)
const [openDialogAsignHR, setOpenDialogAsignHR] = useState(false)
const [openDialogAssignK3, setOpenDialogAssignK3] = useState(false)
const [dataK3, setDataK3] = useState([]) // transfer list
const [idDelete, setIdDelete] = useState(0)
const [alertDelete, setAlertDelete] = useState(false)
const [rowsPerPage, setRowsPerPage] = useState(10)
const [dataExport, setDataExport] = useState([])
const [userProyek, setUserProyek] = useState([])
const [materialProyek, setMaterialProyek] = useState([])
const [currentPage, setCurrentPage] = useState(1)
const [dataCharter, setDataCharter] = useState(null)
const [dataExport, setDataExport] = useState([])
const [dataK3, setDataK3] = useState([])
const [dataPm, setDataPM] = useState([])
const [dataTable, setDatatable] = useState([])
const [dataTypeProyek, setDataTypeProyek] = useState([])
const [dataView, setDataView] = useState([])
const [idDelete, setIdDelete] = useState(0)
const [idTask, setidTask] = useState(0);
const [materialProyek, setMaterialProyek] = useState([])
const [materialResource, setMaterialResource] = useState([])
const [toolsResource, setToolsResource] = useState([])
const [dataTypeProyek, setDataTypeProyek] = useState([])
const [dataPm, setDataPM] = useState([])
const [openDialog, setOpenDialog] = useState(false)
const [openDialogAsignHR, setOpenDialogAsignHR] = useState(false)
const [openDialogAssignK3, setOpenDialogAssignK3] = useState(false)
const [openDialogDoc, setOpenDialogDoc] = useState(false)
const [proyekName, setProyekName] = useState("");
const [openDialogGantt, setOpenDialogGantt] = useState(false)
const [openDialogMaterial, setOpenDialogMaterial] = useState(false)
const [openDialogProyek, setOpenDialogProyek] = useState(false)
// project charter
const [openDialogTools, setOpenDialogTools] = useState(false)
const [openDialogViewDetail, setOpenDialogViewDetail] = useState(false)
const [proyekName, setProyekName] = useState("");
const [rowsPerPage, setRowsPerPage] = useState(10)
const [search, setSearch] = useState('')
const [toolsResource, setToolsResource] = useState([])
const [totalPage, setTotalPage] = useState(0)
const [userProyek, setUserProyek] = useState([])
const [projectCharter, setProjectCharter] = useState(null)
const [projectParticipant, setProjectParticipant] = useState(null)
const [projectMilestone, setProjectMilestone] = useState(null)
@ -81,7 +81,6 @@ const CreatedProyek = ({ params, ...props }) => {
const pageName = params.name;
useEffect(() => {
// getDataUserResource()
getDataMaterialResource()
getDataToolsResource()
handleGetTipeProject()
@ -113,7 +112,6 @@ const CreatedProyek = ({ params, ...props }) => {
const handleGetTipeProject = async () => {
const result = await axios.get(TYPE_PROYEK, HEADER).then(res => res).catch(err => err.response)
console.log(result)
if (result && result.data && result.data.code === 200) {
setDataTypeProyek(result.data.data);
} else {
@ -123,7 +121,6 @@ const CreatedProyek = ({ params, ...props }) => {
const handleGetDataPm = async () => {
const result = await axios.get(USER_LIST, HEADER).then(res => res).catch(err => err.response)
console.log(result)
if (result && result.data && result.data.code === 200) {
setDataPM(result.data.data)
} else {
@ -147,7 +144,6 @@ const CreatedProyek = ({ params, ...props }) => {
"joins": [
{ "name": "m_users", "column_join": "pm_id", "column_results": ["name", "username"] },
{ "name": "m_type_proyek", "column_join": "type_proyek_id", "column_results": ["name", "description"] },
// { "name": "subproyeks.m_subproyek", "column_join": "parent_id", "column_results": ["nama", "biaya", "color_progress", "jumlah_pekerja", "pic", "mulai_proyek", "akhir_proyek", "biaya_actual", "persentase_progress_plan", "persentase_progress_actual"] }
],
"orders": { "columns": ["id"], "ascending": false },
"paging": { "start": start, "length": rowsPerPage }
@ -160,17 +156,14 @@ const CreatedProyek = ({ params, ...props }) => {
]
}
// console.log("cek payload", payload)
const result = await axios
.post(PROYEK_SEARCH, payload, HEADER)
.then(res => res)
.catch((error) => error.response);
// console.log("data sub proyek", result)
if (result && result.data && result.data.code == 200) {
// console.log("cek proyek", result)
let dataRes = result.data.data || []
setDatatable(dataRes);
@ -187,7 +180,6 @@ const CreatedProyek = ({ params, ...props }) => {
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
console.log("cek material resource", result.data.data)
let dataRes = result.data.data || []
setMaterialResource(dataRes);
} else {
@ -222,7 +214,6 @@ const CreatedProyek = ({ params, ...props }) => {
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
console.log("cek tools resource", result.data.data)
let dataRes = result.data.data || []
setToolsResource(dataRes);
} else {
@ -237,7 +228,6 @@ const CreatedProyek = ({ params, ...props }) => {
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
console.log("cek k3 list", result.data.data)
let dataRes = result.data.data || []
const finalData = []
if (dataRes.length > 0) {
@ -261,7 +251,6 @@ const CreatedProyek = ({ params, ...props }) => {
}
const handleOpenDialogProyek = (id) => {
console.log('handleOpenDialogProyek', id);
setOpenDialogProyek(true)
setidTask(id)
}
@ -301,21 +290,17 @@ const CreatedProyek = ({ params, ...props }) => {
const handleOpenDialogTools = (data) => {
setOpenDialogTools(true)
console.log('handleOpenDialogTools', data);
setidTask(data.id)
setProyekName(data.nama)
setUserProyek(data.user_proyeks)
}
const handleOpenDialogViewDetail = async (data) => {
// console.log('handleOpenDialogViewDetail', data);
setidTask(data.id)
// setDataView(data)
await getDataProject(data.id)
await getProjectMilestone(data.id)
await getProjectParticipant(data.id)
await getProjectApproval(data.id)
// await getDataProjectCharter(data.id);
setOpenDialogViewDetail(true)
}
@ -329,7 +314,6 @@ const CreatedProyek = ({ params, ...props }) => {
if (result && result.data && result.data.code == 200) {
let dataRes = result.data.data;
setProjectCharter(dataRes);
// console.log("cek project-charter resource", dataRes);
} else {
NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
}
@ -344,7 +328,6 @@ const CreatedProyek = ({ params, ...props }) => {
"orders": { "columns": ["id"], "ascending": true },
"paging": { "start": 0, "length": -1 }
}
// const url = PROJECT_MI(proyek_id)
const result = await axios
.post(PROJECT_MILESTONE_SEARCH, payload, HEADER)
.then(res => res)
@ -353,7 +336,6 @@ const CreatedProyek = ({ params, ...props }) => {
if (result && result.data && result.data.code == 200) {
let dataRes = result.data.data;
setProjectMilestone(dataRes);
// console.log("cek project milestone", dataRes);
} else {
NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
}
@ -368,7 +350,6 @@ const CreatedProyek = ({ params, ...props }) => {
"orders": { "columns": ["id"], "ascending": true },
"paging": { "start": 0, "length": -1 }
}
// const url = PROJECT_MI(proyek_id)
const result = await axios
.post(PROJECT_PARTICIPANT_SEARCH, payload, HEADER)
.then(res => res)
@ -378,7 +359,6 @@ const CreatedProyek = ({ params, ...props }) => {
let dataRes = result.data.data;
setProjectParticipant(dataRes);
// console.log("cek project participant", dataRes);
} else {
NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
}
@ -393,7 +373,6 @@ const CreatedProyek = ({ params, ...props }) => {
"orders": { "columns": ["id"], "ascending": true },
"paging": { "start": 0, "length": -1 }
}
// const url = PROJECT_MI(proyek_id)
const result = await axios
.post(PROJECT_APPROVAL_SEARCH, payload, HEADER)
.then(res => res)
@ -402,7 +381,6 @@ const CreatedProyek = ({ params, ...props }) => {
if (result && result.data && result.data.code == 200) {
let dataRes = result.data.data;
setProjectApproval(dataRes);
// console.log("cek project approval", dataRes);
} else {
NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
}
@ -471,15 +449,12 @@ const CreatedProyek = ({ params, ...props }) => {
const result = await axios.post(PROYEK_ADD, formData, HEADER)
.then(res => res)
.catch((error) => error.response);
console.log(result)
if (result && result.data && result.data.code === 200) {
const { participants, milestones, approval } = data.projectCharter
const resultParticipant = await saveParticipant(result.data.data_result.id, participants)
const resultMilestone = await saveMilestone(result.data.data_result.id, milestones)
const resultApproval = await saveApproval(result.data.data_result.id, approval)
console.log({ resultApproval, resultMilestone, resultParticipant })
if (resultParticipant === "berhasil" && resultMilestone === "berhasil" && resultApproval === "berhasil") {
// getDataProyek();
NotificationManager.success(`Data proyek berhasil ditambah`, 'Success!!');
} else {
NotificationManager.success(`${result.data.message}`, 'Success!!');
@ -502,9 +477,7 @@ const CreatedProyek = ({ params, ...props }) => {
}
return axios.post(PROJECT_PARTICIPANT_ADD, payload, HEADER)
})
console.log(request)
const arr = await Promise.all(request).then(values => values).catch(err => err.response);
console.log('result participant', arr)
const result = arr.map(res => res.data.code == 200)
if (result.length > 0) {
return "gagal"
@ -523,9 +496,7 @@ const CreatedProyek = ({ params, ...props }) => {
}
return axios.post(PROJECT_MILESTONE_ADD, payload, HEADER)
})
console.log(request)
const arr = await Promise.all(request).then(values => values).catch(err => err.response);
console.log('result milestone', arr)
const result = arr.map(res => res.data.code !== 200)
if (result.length > 0) {
return "gagal"
@ -545,9 +516,7 @@ const CreatedProyek = ({ params, ...props }) => {
}
return axios.post(PROJECT_APPROVAL_ADD, payload, HEADER)
})
console.log(request)
const arr = await Promise.all(request).then(values => values).catch(err => err.response);
console.log('result approval', arr)
const result = arr.map(res => res.data.code !== 200)
if (result.length > 0) {
return "gagal"
@ -565,7 +534,6 @@ const CreatedProyek = ({ params, ...props }) => {
const result = await axios.put(urlEdit, formData, HEADER)
.then(res => res)
.catch((error) => error.response);
console.log("cek result", result)
const resultParticipant = await editParticipant(data.id, participants)
const resultMilestone = await editMilestone(data.id, milestones)
const resultApproval = await editApproval(data.id, approval)
@ -580,7 +548,6 @@ const CreatedProyek = ({ params, ...props }) => {
const editParticipant = async (id, data) => {
await axios.delete(PROJECT_PARTICIPANT_DELETE_BY_PROYEK(id), HEADER)
// if (restDelete){
const request = data.map(res => {
const payload = {
proyek_id: parseInt(id),
@ -589,10 +556,7 @@ const CreatedProyek = ({ params, ...props }) => {
}
return axios.post(PROJECT_PARTICIPANT_ADD, payload, HEADER)
})
console.log(request)
const arr = await Promise.all(request).then(values => values).catch(err => err.response);
console.log('result participant', arr)
// let dataTittle = arr.data.tittle
const result = arr.map(res => res.data.code !== 200)
if (result.length > 0) {
return "gagal"
@ -604,7 +568,6 @@ const CreatedProyek = ({ params, ...props }) => {
const editMilestone = async (id, data) => {
await axios.delete(PROJECT_MILESTONE_DELETE_BY_PROYEK(id), HEADER)
console.log("res due", data)
const request = data.map(res => {
const payload = {
proyek_id: parseInt(id),
@ -614,9 +577,7 @@ const CreatedProyek = ({ params, ...props }) => {
}
return axios.post(PROJECT_MILESTONE_ADD, payload, HEADER)
})
console.log(request)
const arr = await Promise.all(request).then(values => values).catch(err => err.response);
console.log('result milestone', arr)
const result = arr.map(res => res.data.code !== 200)
if (result.length > 0) {
return "gagal"
@ -625,7 +586,6 @@ const CreatedProyek = ({ params, ...props }) => {
}
const editApproval = async (id, data) => {
console.log("cek data edit approval", data)
await axios.delete(PROJECT_APPROVAL_DELETE_BY_PROYEK(id), HEADER)
const request = data.map(res => {
const payload = {
@ -636,20 +596,11 @@ const CreatedProyek = ({ params, ...props }) => {
}
return axios.post(PROJECT_APPROVAL_ADD, payload, HEADER)
})
console.log(request)
const arr = await Promise.all(request).then(values => values).catch(err => err.response);
console.log('result approval', arr)
// if(arr)
// const result = arr.map(res => res.data.code !== 200)
// if (result.length > 0) {
// return "gagal"
// }
// return "berhasil"
}
const handleDelete = async (id) => {
// console.log('Delete')
await setAlertDelete(true)
await setIdDelete(id)
}
@ -666,9 +617,6 @@ const CreatedProyek = ({ params, ...props }) => {
const payload = {
"paging": { "start": 0, "length": -1 },
// "columns": [
// { "name": "nama", "logic_operator": "like", "value": search, "operator": "AND" }
// ],
"joins": [],
"orders": { "columns": ["id"], "ascending": false }
}
@ -686,11 +634,9 @@ const CreatedProyek = ({ params, ...props }) => {
.then(res => res)
.catch((error) => error.response);
// console.log(result)
if (result && result.data && result.data.code == 200) {
let resData = result.data.data;
console.log("resData", resData);
const excelData = [];
resData.map((n, index) => {
let dataRow = {
@ -709,9 +655,7 @@ const CreatedProyek = ({ params, ...props }) => {
}
excelData.push(dataRow)
})
// console.log("cek excel data", excelData)
await setDataExport(excelData);
// exportExcel();
} else {
NotificationManager.error('Gagal Export Data!!', 'Failed');
}
@ -836,7 +780,6 @@ const CreatedProyek = ({ params, ...props }) => {
title: 'Budget',
dataIndex: 'rencana_biaya',
key: 'rencana_biaya',
// render: (text, record) => { return renderFormatRupiah(text, "Rp") }
render: (text, record) => { return record.currency_symbol ? `${record.currency_symbol} ${formatThousand(text)}` : `${formatThousand(text)}` }
},
{
@ -937,7 +880,6 @@ const CreatedProyek = ({ params, ...props }) => {
/>
), [openDialogTools])
// DialogAsignHr
const RenderDialogAsignHr = useMemo(() => (
<AssignHrProject
openDialog={openDialogAsignHR}
@ -950,7 +892,6 @@ const CreatedProyek = ({ params, ...props }) => {
), [openDialogAsignHR])
// DialogAssignK3
const RenderDialogAssignK3 = useMemo(() => (
<AssignK3Project
openDialog={openDialogAssignK3}

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

@ -1,18 +1,15 @@
import * as XLSX from 'xlsx';
import DialogForm from './DialogForm';
import React, { useState, useEffect, useMemo } from 'react';
import SweetAlert from 'react-bootstrap-sweetalert';
import axios from "../../../const/interceptorApi"
import moment from 'moment'
import { Card, CardBody, CardHeader, Col, Row, Input, Table } from 'reactstrap';
import { DIVISI_ADD, DIVISI_EDIT, DIVISI_DELETE, DIVISI_SEARCH} from '../../../const/ApiConst';
import { DownloadOutlined } from '@ant-design/icons';
import axios from "../../../const/interceptorApi"
import * as XLSX from 'xlsx';
import SweetAlert from 'react-bootstrap-sweetalert';
import DialogForm from './DialogForm';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Button, Tooltip } from 'antd';
import { formatRupiah, formatNumber } from '../../../const/CustomFunc'
import {
DIVISI_ADD, DIVISI_EDIT, DIVISI_DELETE,
DIVISI_SEARCH
} from '../../../const/ApiConst';
import moment from 'moment'
const url = "";
const proyek_id = localStorage.getItem('proyek_id');
@ -41,19 +38,20 @@ const ProjectType = ({ params }) => {
}
}
const pageName = params.name;
const [search, setSearch] = useState('')
const [alertDelete, setAlertDelete] = useState(false)
const [allDataMenu, setAllDataMenu] = useState([])
const [clickOpenModal, setClickOpenModal] = useState(false)
const [currentPage, setCurrentPage] = useState(1)
const [openDialog, setOpenDialog] = useState(false)
const [typeDialog, setTypeDialog] = useState('Save')
const [dataExport, setDataExport] = useState([])
const [rowsPerPage, setRowsPerPage] = useState(10)
const [dataEdit, setDataEdit] = useState([])
const [alertDelete, setAlertDelete] = useState(false)
const [idDelete, setIdDelete] = useState(0)
const [dataExport, setDataExport] = useState([])
const [dataTable, setDatatable] = useState([])
const [clickOpenModal, setClickOpenModal] = useState(false)
const [allDataMenu, setAllDataMenu] = useState([])
const [idDelete, setIdDelete] = useState(0)
const [openDialog, setOpenDialog] = useState(false)
const [rowsPerPage, setRowsPerPage] = useState(10)
const [search, setSearch] = useState('')
const [totalPage, setTotalPage] = useState(0)
const [typeDialog, setTypeDialog] = useState('Save')
useEffect(() => {
getDataProjectType()
@ -95,16 +93,12 @@ const ProjectType = ({ params }) => {
}
}
// console.log("payload ", payload)
const result = await axios
.post(DIVISI_SEARCH, payload, config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
console.log("get data ", result.data)
setDatatable(result.data.data);
setTotalPage(result.data.totalRecord);
} else {
@ -124,9 +118,7 @@ const ProjectType = ({ params }) => {
}
const handleExportExcel = async () => {
let start = 0;
const payload = {
"paging": { "start": start, "length": -1 },
"columns": [
@ -136,15 +128,11 @@ const ProjectType = ({ params }) => {
"orders": { "columns": ["id"], "ascending": false }
}
const result = await axios
.post(DIVISI_SEARCH, payload)
.then(res => res)
.catch((error) => error.response);
// console.log(result)
if (result && result.data && result.data.code == 200) {
let resData = result.data.data;
const excelData = [];
@ -155,9 +143,7 @@ const ProjectType = ({ params }) => {
}
excelData.push(dataRow)
})
// console.log("cek excel data", excelData)
await setDataExport(excelData);
// exportExcel();
} else {
NotificationManager.error('Gagal Export Data!!', 'Failed');
}
@ -169,7 +155,6 @@ const ProjectType = ({ params }) => {
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([])
}
@ -199,28 +184,20 @@ const ProjectType = ({ params }) => {
const result = await axios.post(DIVISI_ADD, formData, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
getDataProjectType()
// console.log("data material s ", formData)
NotificationManager.success(`Data project type berhasil ditambah`, 'Success!!');
} else {
// console.log("data material fail ", formData)
NotificationManager.error(`${result.data.message}`, 'Failed!!');
}
}
const editMaterialR = async (data) => {
let urlEdit = DIVISI_EDIT(data.id)
const formData = data
console.log("from data edit ", formData)
const result = await axios.put(urlEdit, formData, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
getDataProjectType();
NotificationManager.success(`Data project type berhasil diedit`, 'Success!!');
@ -235,7 +212,6 @@ const ProjectType = ({ params }) => {
const onConfirmDelete = async () => {
let url = DIVISI_DELETE(idDelete);
const result = await axios.delete(url, config)
.then(res => res)
.catch((error) => error.response);
@ -275,8 +251,6 @@ const ProjectType = ({ params }) => {
}
}
return (
<div>
<NotificationContainer />

87
src/views/SimproV2/PanicButton/index.js

@ -1,16 +1,16 @@
import * as XLSX from 'xlsx';
import DialogEdit from './DialogEdit';
import DialogForm from './DialogForm';
import React, { Component } from 'react';
import { Card, CardBody, CardHeader, Col, Row, Table, Input, InputGroup } from 'reactstrap';
import { Button } from 'reactstrap';
import SweetAlert from 'react-bootstrap-sweetalert';
import axios from 'axios';
import moment from 'moment';
import SweetAlert from 'react-bootstrap-sweetalert';
import DialogForm from './DialogForm';
import DialogEdit from './DialogEdit';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Tooltip } from 'antd';
import { Button } from 'reactstrap';
import { Card, CardBody, CardHeader, Col, Row, Table, Input, InputGroup } from 'reactstrap';
import { DatePicker } from 'antd';
import * as XLSX from 'xlsx';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { PANIC_BUTTON_UPDATE, PANIC_BUTTON_SEARCH } from '../../../const/ApiConst';
import { Pagination, Tooltip } from 'antd';
const id_org = window.localStorage.getItem('id_org');
const roleName = window.localStorage.getItem('role_name');
@ -24,7 +24,6 @@ const config = {
}
};
const { RangePicker } = DatePicker;
const momentFormat = 'HH:mm';
@ -42,29 +41,29 @@ export default class index extends Component {
constructor(props) {
super(props)
this.state = {
dataTable: [],
dataExport: [],
openDialog: false,
openDialogEdit:false,
typeDialog: 'Save',
dataEdit: null,
alertDelete: false,
idDelete: 0,
currentDay: 'today',
currentPage: 1,
dataEdit: null,
dataExport: [],
dataGs: [],
dataIdHo: [],
search: "",
dataMap:"",
dataTable: [],
endDate:moment(moment().format("YYYY-M-D")),
idDelete: 0,
openDialog: false,
openDialogEdit:false,
page: 0,
rowsPerPage: LENGTH_DATA,
currentPage: 1,
totalPage: 0,
tooltipMap: false,
tooltipDelete: false,
typeClock: "All",
search: "",
startDate:moment(moment().format("YYYY-M-D")),
endDate:moment(moment().format("YYYY-M-D")),
currentDay: 'today',
dataMap:"",
tooltipDelete: false,
tooltipExport:false,
tooltipMap: false,
totalPage: 0,
typeClock: "All",
typeDialog: 'Save',
}
}
@ -84,8 +83,6 @@ export default class index extends Component {
};
getDataPanicButton = async () => {
// let url = BASE_URL + `panic_button.php?act=get_data&role_name=${roleName}`;
let start = 0;
if (this.state.currentPage !== 1) {
start = (this.state.currentPage * this.state.rowsPerPage) - this.state.rowsPerPage
@ -131,7 +128,6 @@ export default class index extends Component {
.post(PANIC_BUTTON_SEARCH, payload, config)
.then(res => res)
.catch((error) => error.response);
console.log('test panic button', result);
if(result && result.data){
if (result && result.data && result.data.code == 200) {
this.setState({ dataTable: result.data.data, totalPage: result.data.totalRecord,dataExport:result.data.data_export });
@ -243,8 +239,6 @@ export default class index extends Component {
}
updateStatusResponse = async (data) => {
console.log('test data', data)
let url = PANIC_BUTTON_UPDATE(data.id);
let payload = {
"user_id" : data.user_id,
@ -255,18 +249,10 @@ export default class index extends Component {
}
// let url = BASE_URL + `panic_button.php?act=edit&id=${data.id}`;
// const formData = new FormData();
// formData.append("lat", data.lat);
// formData.append("lon", data.lon);
// formData.append("status_response", data.status_response);
const result = await axios
.put(url, payload, config)
.then(res => res)
.catch((error) => error.response);
// console.log(result)
if(result && result.data){
if (result.data.code == 200) {
this.getDataPanicButton()
@ -285,10 +271,6 @@ export default class index extends Component {
return (
<tr key={n.id}>
<td>
{/* <i id="TooltipDelete" className="cil-trash fa-lg" style={{ color: 'red', marginRight: '10px', cursor: "pointer" }} onClick={() => this.handleDelete(n.id)}></i>
<Tooltip placement="right" isOpen={this.state.tooltipDelete} target="TooltipDelete" toggle={() => this.toggle("delete")}>
Delete
</Tooltip>*/}
<Tooltip title="Edit">
<i id="TooltipEdit" className="cil-pencil fa-lg" style={{ color: 'green', cursor: "pointer", marginRight: 15 }} onClick={() => this.handleEdit(n)}></i>
</Tooltip>
@ -299,7 +281,6 @@ export default class index extends Component {
<td>{ n.created_date!==null ? moment(n.created_at).format("DD-MM-YYYY HH:mm:ss") : "-" }</td>
<td>{ n.join_first_name !==null ? n.join_first_name : "-" }</td>
<td>{ n.status_response!==null ? n.status_response : "-" }</td>
{/* <td>{ n.clock_out_time!==null ? moment(n.clock_out_time).format("HH:mm:ss") : "-" }</td> */}
</tr>
)
}) : <tr>
@ -314,28 +295,24 @@ export default class index extends Component {
const val = e.target.value;
this.setState({ currentDay:val });
if(val==="today"){
console.log("test 1 test",val);
this.setState({
startDate:moment(moment().format("YYYY-M-D")),
endDate:moment(moment().format("YYYY-M-D")),
currentPage: 1
})
}else if(val==="3 day"){
console.log("test test",val);
this.setState({
startDate:moment(moment().subtract(3, "days").format("YYYY-M-D")),
endDate:moment(moment().format("YYYY-M-D")),
currentPage: 1
})
}else if(val==="7 day"){
console.log("test test",val);
this.setState({
startDate:moment(moment().subtract(7, "days").format("YYYY-M-D")),
endDate:moment(moment().format("YYYY-M-D")),
currentPage: 1
})
}else{
console.log("test 2 test",val);
this.setState({
startDate:moment(moment().format("YYYY-M-D")),
endDate:moment(moment().format("YYYY-M-D")),
@ -349,19 +326,6 @@ export default class index extends Component {
return (
<div>
<NotificationContainer />
{/* <SweetAlert
show={this.state.alertDelete}
warning
showCancel
confirmBtnText="Delete"
confirmBtnBsStyle="danger"
title="Are you sure?"
onConfirm={this.onConfirmDelete}
onCancel={() => this.setState({ alertDelete: false, idDelete: 0 })}
focusCancelBtn
>
Data tipe karyawan akan terhapus!!
</SweetAlert> */}
<DialogForm
openDialog={openDialog}
closeDialog={this.handleCloseDialog}
@ -380,7 +344,6 @@ export default class index extends Component {
<CardHeader style={{ display: "flex", justifyContent: "space-between" }}>
<h4>Panic Button</h4>
<div>
{/* <Button color="primary" onClick={() => this.handleOpenDialog('Save')}>Tambah Broadcast</Button>{' '} */}
<Tooltip title="Export Excel">
<Button id="TooltipExport" color="primary" onClick={()=> this.handleExportExcel()}><i className="fa fa-print"></i></Button>
</Tooltip>
@ -401,12 +364,10 @@ export default class index extends Component {
<Button color="primary" onClick={() => this.getDataPanicButton()}>Cari</Button>
</div>
</div>
{/* <Input onChange={this.handleSearch} value={search} type="text" name="search" id="search" placeholder="Cari nama karyawan" style={{ maxWidth: "200px", marginBottom: "20px" }} /> */}
</div>
<Table responsive striped hover>
<thead>
<tr>
{/* <th>Actions</th> */}
{column.map((i, index) => {
return (
<th key={index} scope="row">{i.name}</th>

94
src/views/SimproV2/ProjectType/index.js

@ -1,16 +1,15 @@
import * as XLSX from 'xlsx';
import DialogForm from './DialogForm';
import DialogInitialGantt from './DialogInitialGantt';
import React, { useState, useEffect, useMemo } from 'react';
import SweetAlert from 'react-bootstrap-sweetalert';
import axios from "../../../const/interceptorApi"
import moment from 'moment'
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import { DownloadOutlined } from '@ant-design/icons';
import axios from "../../../const/interceptorApi"
import * as XLSX from 'xlsx';
import SweetAlert from 'react-bootstrap-sweetalert';
import DialogForm from './DialogForm';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { PROJECT_TYPE_ADD, PROJECT_TYPE_EDIT, PROJECT_TYPE_DELETE, PROJECT_TYPE_SEARCH } from '../../../const/ApiConst';
import { Pagination, Button, Tooltip, Table} from 'antd';
import DialogInitialGantt from './DialogInitialGantt';
import { PROJECT_TYPE_ADD, PROJECT_TYPE_EDIT, PROJECT_TYPE_DELETE,
PROJECT_TYPE_SEARCH } from '../../../const/ApiConst';
import moment from 'moment'
const url = "";
const proyek_id = localStorage.getItem('proyek_id');
@ -39,21 +38,22 @@ const ProjectType = ({params}) => {
}
}
const pageName = params.name;
const [search, setSearch] = useState('')
const [alertDelete, setAlertDelete] = useState(false)
const [allDataMenu, setAllDataMenu] = useState([])
const [clickOpenModal, setClickOpenModal] = useState(false)
const [currentPage, setCurrentPage] = useState(1)
const [openDialog, setOpenDialog] = useState(false)
const [typeDialog, setTypeDialog] = useState('Save')
const [dataExport, setDataExport] = useState([])
const [rowsPerPage, setRowsPerPage] = useState(10)
const [dataEdit, setDataEdit] = useState([])
const [alertDelete, setAlertDelete] = useState(false)
const [idDelete, setIdDelete] = useState(0)
const [dataExport, setDataExport] = useState([])
const [dataTable, setDatatable] = useState([])
const [clickOpenModal, setClickOpenModal] = useState(false)
const [allDataMenu, setAllDataMenu] = useState([])
const [totalPage, setTotalPage] = useState(0)
const [openDialogIG, setOpenDialogIG] = useState(false)
const [idDelete, setIdDelete] = useState(0)
const [idTypeProject, setIdTypeProject] = useState(0)
const [openDialog, setOpenDialog] = useState(false)
const [openDialogIG, setOpenDialogIG] = useState(false)
const [rowsPerPage, setRowsPerPage] = useState(10)
const [search, setSearch] = useState('')
const [totalPage, setTotalPage] = useState(0)
const [typeDialog, setTypeDialog] = useState('Save')
useEffect(() => {
getDataProjectType()
@ -95,16 +95,12 @@ const ProjectType = ({params}) => {
}
}
// console.log("payload ", payload)
const result = await axios
.post(PROJECT_TYPE_SEARCH, payload, config)
.then(res => res)
.catch((error) => error.response);
if(result && result.data && result.data.code == 200){
console.log("get data ", result.data)
setDatatable(result.data.data);
setTotalPage(result.data.totalRecord);
}else{
@ -124,7 +120,6 @@ const ProjectType = ({params}) => {
}
const handleExportExcel = async () => {
let start = 0;
const payload = {
@ -136,15 +131,11 @@ const ProjectType = ({params}) => {
"orders": { "columns": ["id"], "ascending": false }
}
const result = await axios
.post(PROJECT_TYPE_SEARCH, payload)
.then(res => res)
.catch((error) => error.response);
// console.log(result)
if (result && result.data && result.data.code == 200) {
let resData = result.data.data;
const excelData = [];
@ -155,9 +146,7 @@ const ProjectType = ({params}) => {
}
excelData.push(dataRow)
})
// console.log("cek excel data", excelData)
await setDataExport(excelData);
// exportExcel();
} else {
NotificationManager.error('Gagal Export Data!!', 'Failed');
}
@ -169,7 +158,6 @@ const ProjectType = ({params}) => {
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([])
}
@ -202,21 +190,16 @@ const ProjectType = ({params}) => {
if (result && result.data && result.data.code === 200) {
getDataProjectType()
// console.log("data material s ", formData)
NotificationManager.success(`Data project type berhasil ditambah`, 'Success!!');
} else {
// console.log("data material fail ", formData)
NotificationManager.error(`${result.data.message}`, 'Failed!!');
}
}
const editMaterialR = async (data) => {
let urlEdit = PROJECT_TYPE_EDIT(data.id)
const formData = data
console.log("from data edit ", formData)
const result = await axios.put(urlEdit, formData, HEADER)
.then(res => res)
.catch((error) => error.response);
@ -325,8 +308,6 @@ const ProjectType = ({params}) => {
)
}, [dataTable])
return (
<div>
<NotificationContainer />
@ -376,39 +357,6 @@ const ProjectType = ({params}) => {
</Row>
</CardHeader>
<CardBody>
{/* <Table responsive striped hover>
<thead>
<tr>
<th>Aksi</th>
{column.map((i, index) => {
return (
<th key={index} scope="row">{i.name}</th>
)
})}
</tr>
</thead>
<tbody>
{dataNotAvailable()}
{dataTable.map((n, index) => {
return (
<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>
</Tooltip>
<Tooltip title="Edit">
<i id="TooltipEdit" className="cil-pencil fa-lg" style={{ color: 'green', cursor: "pointer" }} onClick={() => handleEdit(n)}></i>
</Tooltip>
</td>
<td>{n.name}</td>
<td>{n.description}</td>
</tr>
)
})}
</tbody>
</Table> */}
{renderTable}
<Pagination
style={{marginTop:"25px"}}
@ -424,6 +372,6 @@ const ProjectType = ({params}) => {
</Card>
</div>
)
}
}
export default ProjectType;
export default ProjectType;

98
src/views/SimproV2/ResourceMaterial/index.js

@ -1,9 +1,11 @@
import * as XLSX from 'xlsx';
import DialogForm from './DialogForm';
import React, { useState, useEffect, useMemo } from 'react';
import SweetAlert from 'react-bootstrap-sweetalert';
import axios from "../../../const/interceptorApi"
import moment from 'moment'
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import { DownloadOutlined } from '@ant-design/icons';
import * as XLSX from 'xlsx';
import SweetAlert from 'react-bootstrap-sweetalert';
import DialogForm from './DialogForm';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Table, Button, Tooltip, Tabs, Collapse } from 'antd';
import { formatRupiah, formatNumber, renderLabelStatus } from '../../../const/CustomFunc'
@ -14,8 +16,6 @@ import {
REQUEST_MATERIAL_SEARCH, REQUEST_MATERIAL_EDIT,
REQUEST_MATERIAL_UPDATE_WAREHOUSE_SITE
} from '../../../const/ApiConst';
import moment from 'moment'
import axios from "../../../const/interceptorApi"
const { TabPane } = Tabs;
const { Panel } = Collapse;
@ -26,15 +26,12 @@ const role_id = localStorage.getItem('role_id');
const format = "DD-MM-YYYY";
const groupBy = (array, key) => {
// Return the end result
return array.reduce((result, currentValue) => {
// If an array already present for key, push it to the array. Else create an array and push the object
(result[currentValue[key]] = result[currentValue[key]] || []).push(
currentValue
);
// Return the current iteration `result` value, this will be taken as next iteration `result` value and accumulate
return result;
}, {}); // empty object is the initial value for result object
}, {});
};
const Resource = ({ params }) => {
@ -45,22 +42,23 @@ const Resource = ({ params }) => {
"Authorization": `Bearer ${token}`
}
}
const pageName = params.name;
const [search, setSearch] = useState('')
const [alertDelete, setAlertDelete] = useState(false)
const [allDataMenu, setAllDataMenu] = useState([])
const [clickOpenModal, setClickOpenModal] = useState(false)
const [currentPage, setCurrentPage] = useState(1)
const [openDialog, setOpenDialog] = useState(false)
const [typeDialog, setTypeDialog] = useState('Save')
const [dataExport, setDataExport] = useState([])
const [rowsPerPage, setRowsPerPage] = useState(10)
const [dataDelvMaterial, setDataDelvMaterial] = useState([])
const [dataEdit, setDataEdit] = useState([])
const [alertDelete, setAlertDelete] = useState(false)
const [idDelete, setIdDelete] = useState(0)
const [dataExport, setDataExport] = useState([])
const [dataReqMaterial, setDataReqMaterial] = useState([])
const [dataTable, setDatatable] = useState([])
const [clickOpenModal, setClickOpenModal] = useState(false)
const [allDataMenu, setAllDataMenu] = useState([])
const [idDelete, setIdDelete] = useState(0)
const [openDialog, setOpenDialog] = useState(false)
const [rowsPerPage, setRowsPerPage] = useState(10)
const [search, setSearch] = useState('')
const [totalPage, setTotalPage] = useState(0)
const [dataReqMaterial, setDataReqMaterial] = useState([])
const [dataDelvMaterial, setDataDelvMaterial] = useState([])
const [typeDialog, setTypeDialog] = useState('Save')
const pageName = params.name;
useEffect(() => {
getDataReqMaterial()
@ -99,16 +97,12 @@ const Resource = ({ params }) => {
}
}
// console.log("payload ", payload)
const result = await axios
.post(MATERIAL_RESOURCE_SEARCH, payload, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
console.log("get data ", result.data)
setDatatable(result.data.data);
setTotalPage(result.data.totalRecord);
} else {
@ -120,7 +114,6 @@ const Resource = ({ params }) => {
const payload = {
"columns": [
{ "name": "description", "logic_operator": "like", "value": "", "operator": "AND" },
// { "name": "proyek_id", "logic_operator": "=", "value": idTask, "operator": "AND" }
],
"joins": [
{ "name": "m_proyek", "column_join": "proyek_id", "column_results": ["kode_sortname", "nama"] }
@ -133,7 +126,6 @@ const Resource = ({ params }) => {
.post(REQUEST_MATERIAL_SEARCH, payload, HEADER)
.then(res => res)
.catch((error) => error.response);
console.log("result getDataReqMaterial", result)
if (result && result.status == 200) {
if (result.data.data && result.data.data.length > 0) {
@ -149,9 +141,6 @@ const Resource = ({ params }) => {
}
})
// const groupedProject = groupBy(result.data.data, 'proyek_id');
// console.log('dataReqMaterial', groupedProject);
const groupedProjectReq = groupBy(filtered_matReq, 'proyek_id');
const groupedProjectDelv = groupBy(filtered_matDelv, 'proyek_id');
@ -178,9 +167,6 @@ const Resource = ({ params }) => {
const payload = {
"paging": { "start": 0, "length": -1 },
// "columns": [
// { "name": "nama", "logic_operator": "like", "value": search, "operator": "AND" }
// ],
"joins": [],
"orders": { "columns": ["id"], "ascending": false }
}
@ -196,18 +182,10 @@ const Resource = ({ params }) => {
.then(res => res)
.catch((error) => error.response);
// console.log(result)
if (result && result.data && result.data.code == 200) {
let resData = result.data.data;
const excelData = [];
// <td>{n.nama}</td>
// <td>{n.biaya}</td>
// <td style={{textAlign:"center"}}><div style={{borderRadius:"50%",height:"25px",width:"25px",backgroundColor:n.color_progress}}></div></td>
// <td>{n.jumlah_pekerja}</td>
// <td>{n.pic}</td>
// <td>{n.mulai_proyek ? moment(n.mulai_proyek).format("DD-MM-YYYY") : "-"}</td>
// <td>{n.akhir_proyek ? moment(n.akhir_proyek).format("DD-MM-YYYY") : "-"}</td>
resData.map((n, index) => {
let dataRow = {
"Nama Proyek": n.nama,
@ -219,9 +197,7 @@ const Resource = ({ params }) => {
}
excelData.push(dataRow)
})
// console.log("cek excel data", excelData)
await setDataExport(excelData);
// exportExcel();
} else {
NotificationManager.error('Gagal Export Data!!', 'Failed');
}
@ -261,23 +237,14 @@ const Resource = ({ params }) => {
const saveMaterialResource = async (data) => {
const formData = data
// {
// 'name': data.materialName,
// 'description': data.description,
// 'unit_price': parseInt(data.unitPrice),
// 'uom': data.uom
// }
// console.log("data material ", formData)
const result = await axios.post(MATERIAL_RESOURCE_ADD, formData, HEADER)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code === 200) {
getDataMaterialR()
// console.log("data material s ", formData)
NotificationManager.success(`Data material resource berhasil ditambah`, 'Success!!');
} else {
// console.log("data material fail ", formData)
NotificationManager.error(`${result.data.message}`, 'Failed!!');
}
}
@ -287,7 +254,6 @@ const Resource = ({ params }) => {
let urlEdit = MATERIAL_RESOURCE_EDIT(data.id)
const formData = data
console.log("from data edit ", formData)
const result = await axios.put(urlEdit, formData, HEADER)
.then(res => res)
@ -305,7 +271,6 @@ const Resource = ({ params }) => {
let urlEdit = REQUEST_MATERIAL_EDIT(data.id)
const formData = data
console.log("from data edit ", formData)
const result = await axios.put(urlEdit, formData, HEADER)
.then(res => res)
@ -323,7 +288,6 @@ const Resource = ({ params }) => {
let urlEdit = REQUEST_MATERIAL_EDIT(data.id)
const formData = data
console.log("from data edit ", formData)
const result = await axios.put(urlEdit, formData, HEADER)
.then(res => res)
@ -392,10 +356,6 @@ const Resource = ({ params }) => {
{ title: 'Material Name', dataIndex: 'name', key: 'name' },
{ title: 'QTY', dataIndex: 'qty', key: 'qty' },
{ title: 'UOM', dataIndex: 'uom', key: 'uom' },
// {
// title: 'Unit Price', dataIndex: 'unit_price', key: 'unit_price',
// render: (text, record) => { return renderFormatNumber(text, "Rp") }
// },
{ title: 'Description', dataIndex: 'description', key: 'description' },
{ title: 'Status', dataIndex: 'status', key: 'status' }
];
@ -417,14 +377,6 @@ const Resource = ({ params }) => {
dataIndex: '',
key: 'id',
className: "nowrap",
// render: (text, record) => <>
// {text.status=="fom" ? <><Tooltip title="Delete Request Resource">
// <Button size="small" type="link" style={{color:'red'}} onClick={() => handleDelete(text.id)}><i className="fa fa-trash"></i></Button>
// </Tooltip>{" "}<Tooltip title="Edit Request Resource">
// <Button size="small" type="link" style={{color:'orange'}} onClick={() => handleEdit(text, 'EditMatReq')}><i className="fa fa-edit"></i></Button>
// </Tooltip></> : "-"}
// </>,
render: (text, record) => <>
<Tooltip title="Edit Request Resource">
<Button size="small" type="link" style={{ color: 'orange' }} onClick={() => handleEdit(text, 'EditMatReq')}><i className="fa fa-edit"></i></Button>
@ -451,9 +403,7 @@ const Resource = ({ params }) => {
let componentGroup = [];
for (const proyek_id in dataReqMaterial) {
// console.log('proyek_id', proyek_id);
const title = `${dataReqMaterial[proyek_id][0]['join_first_kode_sortname']} - ${dataReqMaterial[proyek_id][0]['join_first_nama']}`;
// console.log('title', title);
componentGroup.push(
<Panel header={title} key={proyek_id}>
<Table
@ -466,7 +416,6 @@ const Resource = ({ params }) => {
)
}
// console.log('componentGroup', componentGroup);
return componentGroup.map((item, index) => {
return item;
})
@ -507,9 +456,7 @@ const Resource = ({ params }) => {
let componentGroup = [];
for (const proyek_id in dataDelvMaterial) {
// console.log('proyek_id', proyek_id);
const title = `${dataDelvMaterial[proyek_id][0]['join_first_kode_sortname']} - ${dataDelvMaterial[proyek_id][0]['join_first_nama']}`;
// console.log('title', title);
componentGroup.push(
<Panel header={title} key={proyek_id}>
<Table
@ -522,7 +469,6 @@ const Resource = ({ params }) => {
)
}
// console.log('componentGroup', componentGroup);
return componentGroup.map((item, index) => {
return item;
})
@ -574,9 +520,6 @@ const Resource = ({ params }) => {
<Input onChange={handleSearch} value={search} type="text" name="search" id="search" placeholder={`Search...`} />
</Col>
<Col>
{/* <Tooltip title="Add Material Resource">
<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>
@ -602,9 +545,6 @@ const Resource = ({ params }) => {
<Input onChange={handleSearch} value={search} type="text" name="search" id="search" placeholder={`Search...`} />
</Col>
<Col>
{/* <Tooltip title="Add Material Resource">
<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>

78
src/views/SimproV2/ResourceTools/index.js

@ -1,20 +1,19 @@
import * as XLSX from 'xlsx';
import DialogForm from './DialogForm';
import DialogTools from './DialogEditReqTools';
import React, { useState, useEffect, useMemo } from 'react';
import SweetAlert from 'react-bootstrap-sweetalert';
import _, { initial } from 'underscore'
import axios from "../../../const/interceptorApi"
import moment from 'moment'
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import { DownloadOutlined } from '@ant-design/icons';
import * as XLSX from 'xlsx';
import SweetAlert from 'react-bootstrap-sweetalert';
import DialogForm from './DialogForm';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Table, Button, Tooltip, Tabs, Collapse } from 'antd';
import { renderLabelStatus } from '../../../const/CustomFunc';
import {
// AXIOS,
TOOLS_RESOURCE_ADD, TOOLS_RESOURCE_SEARCH, REQUEST_TOOLS_SEARCH, TOOLS_RESOURCE_EDIT, TOOLS_RESOURCE_DELETE
} from '../../../const/ApiConst';
import moment from 'moment'
import _, { initial } from 'underscore'
import DialogTools from './DialogEditReqTools';
import axios from "../../../const/interceptorApi"
import { renderLabelStatus } from '../../../const/CustomFunc';
const { TabPane } = Tabs;
const { Panel } = Collapse;
@ -40,24 +39,25 @@ const ResourceWorker = ({ params }) => {
"Authorization": `Bearer ${token}`
}
}
const pageName = params.name;
const [search, setSearch] = useState('')
const [currentPage, setCurrentPage] = useState(1)
const [openDialog, setOpenDialog] = useState(false)
const [typeDialog, setTypeDialog] = useState('Save')
const [dataExport, setDataExport] = useState([])
const [rowsPerPage, setRowsPerPage] = useState(10)
const [dataEdit, setDataEdit] = useState(null)
const [alertDelete, setAlertDelete] = useState(false)
const [idDelete, setIdDelete] = useState(0)
const [dataTable, setDatatable] = useState([])
const [clickOpenModal, setClickOpenModal] = useState(false)
const [totalPage, setTotalPage] = useState(0)
const [roleList, setRoleList] = useState([])
const [dataReqTools, setDataReqTools] = useState([]);
const [currentPage, setCurrentPage] = useState(1)
const [dataDeliveryTools, setDataDeliveryTools] = useState([]);
const [openDialogFormTools, setOpenDialogFormTools] = useState(false);
const [dataEdit, setDataEdit] = useState(null)
const [dataExport, setDataExport] = useState([])
const [dataReqTools, setDataReqTools] = useState([]);
const [dataTable, setDatatable] = useState([])
const [idDelete, setIdDelete] = useState(0)
const [idTask, setIdTask] = useState(0);
const [openDialog, setOpenDialog] = useState(false)
const [openDialogFormTools, setOpenDialogFormTools] = useState(false);
const [roleList, setRoleList] = useState([])
const [rowsPerPage, setRowsPerPage] = useState(10)
const [search, setSearch] = useState('')
const [totalPage, setTotalPage] = useState(0)
const [typeDialog, setTypeDialog] = useState('Save')
const pageName = params.name;
useEffect(() => {
getDataReqTools()
@ -112,7 +112,6 @@ const ResourceWorker = ({ params }) => {
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
console.log(result.data.data)
setDatatable(result.data.data);
setTotalPage(result.data.totalRecord);
} else {
@ -155,12 +154,10 @@ const ResourceWorker = ({ params }) => {
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
// console.log(result.data.data)
const group = _.chain(result.data.data)
.groupBy("join_first_nama")
.map((value, key) => ({ header: key, data: value }))
.value()
console.log("req tools", group)
setDataReqTools(group);
} else {
NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
@ -206,7 +203,6 @@ const ResourceWorker = ({ params }) => {
.groupBy("join_first_nama")
.map((value, key) => ({ header: key, data: value }))
.value()
console.log("delivery tools", group)
setDataDeliveryTools(group);
} else {
NotificationManager.error('Gagal Mengambil Data!!', 'Failed');
@ -228,9 +224,6 @@ const ResourceWorker = ({ params }) => {
const payload = {
"paging": { "start": 0, "length": -1 },
// "columns": [
// { "name": "nama", "logic_operator": "like", "value": search, "operator": "AND" }
// ],
"joins": [],
"orders": { "columns": ["id"], "ascending": false }
}
@ -245,18 +238,10 @@ const ResourceWorker = ({ params }) => {
.then(res => res)
.catch((error) => error.response);
// console.log(result)
if (result && result.data && result.data.code == 200) {
let resData = result.data.data;
const excelData = [];
// <td>{n.nama}</td>
// <td>{n.biaya}</td>
// <td style={{textAlign:"center"}}><div style={{borderRadius:"50%",height:"25px",width:"25px",backgroundColor:n.color_progress}}></div></td>
// <td>{n.jumlah_pekerja}</td>
// <td>{n.pic}</td>
// <td>{n.mulai_proyek ? moment(n.mulai_proyek).format("DD-MM-YYYY") : "-"}</td>
// <td>{n.akhir_proyek ? moment(n.akhir_proyek).format("DD-MM-YYYY") : "-"}</td>
resData.map((n, index) => {
let dataRow = {
"Nama Proyek": n.nama,
@ -268,9 +253,7 @@ const ResourceWorker = ({ params }) => {
}
excelData.push(dataRow)
})
// console.log("cek excel data", excelData)
await setDataExport(excelData);
// exportExcel();
} else {
NotificationManager.error('Gagal Export Data!!', 'Failed');
}
@ -363,10 +346,7 @@ const ResourceWorker = ({ params }) => {
key: 'x',
className: 'nowrap',
render: (text, record) => <>
{/* <Tooltip title="Tambah Sub">
<Button size="small" type="link" style={{color:'green'}} onClick={() => handleOpenDialogSub('Save', text)}><i className="fa fa-plus"></i></Button>
</Tooltip> */}
<Tooltip title="Edit">
<Tooltip titl="Edit">
<Button size="small" type="link" style={{ color: 'orange' }} onClick={() => handleEdit(text)}><i className="fa fa-edit"></i></Button>
</Tooltip>
<Tooltip title="Hapus">
@ -380,7 +360,6 @@ const ResourceWorker = ({ params }) => {
{ title: 'QTY', dataIndex: 'qty', key: 'qty' },
{ title: 'Description', dataIndex: 'description', key: 'description' },
];
// console.log("columns", columns)
return (
<Table
rowKey="id"
@ -461,7 +440,6 @@ const ResourceWorker = ({ params }) => {
{ title: 'Asset Type', dataIndex: 'asset_type', key: 'asset_type' },
{ title: 'UOM', dataIndex: 'uom', key: 'uom' },
{ title: 'QTY', dataIndex: 'qty', key: 'qty' },
// { title: 'Description', dataIndex: 'description', key: 'description' },
];
if (type === 'request') {
@ -470,8 +448,6 @@ const ResourceWorker = ({ params }) => {
columns.push({ title: 'Ownership Status', dataIndex: 'ownership_status', key: 'ownership_status' });
columns.push({ title: 'Ownership Name', dataIndex: 'ownership_name', key: 'ownership_name' });
// console.log("columns", columns)
return (
<Table
rowKey="id"
@ -490,9 +466,6 @@ const ResourceWorker = ({ params }) => {
<Input onChange={handleSearch} value={search} type="text" name="search" id="search" placeholder={`Search...`} />
</Col>
<Col>
{/* <Tooltip title="Add Resource">
<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>
@ -524,9 +497,6 @@ const ResourceWorker = ({ params }) => {
<Input onChange={handleSearch} value={search} type="text" name="search" id="search" placeholder={`Search...`} />
</Col>
<Col>
{/* <Tooltip title="Add Resource">
<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>

115
src/views/SimproV2/ResourceWorker/index.js

@ -1,17 +1,17 @@
import React, { useState, useEffect, useMemo } from 'react';
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import { DownloadOutlined } from '@ant-design/icons';
import axios from "../../../const/interceptorApi"
import * as XLSX from 'xlsx';
import SweetAlert from 'react-bootstrap-sweetalert';
import DialogForm from './DialogForm';
import DialogFormUserShift from './DialogFormUserShift';
import React, { useState, useEffect, useMemo } from 'react';
import SweetAlert from 'react-bootstrap-sweetalert';
import axios from "../../../const/interceptorApi"
import moment from 'moment'
import { Card, CardBody, CardHeader, Col, Row, Input } from 'reactstrap';
import { DownloadOutlined } from '@ant-design/icons';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Table, Button, Tooltip } from 'antd';
import {
PROYEK_SEARCH, USER_ADD, USER_SEARCH, USER_EDIT, USER_DELETE, ROLE_SEARCH, DIVISI_SEARCH, USER_SHIFT_ADD
} from '../../../const/ApiConst';
import moment from 'moment'
const url = "";
const proyek_id = localStorage.getItem('proyek_id');
@ -34,24 +34,24 @@ const ResourceWorker = ({ params }) => {
"Authorization": `Bearer ${token}`
}
}
const pageName = params.name;
const [search, setSearch] = useState('')
const [alertDelete, setAlertDelete] = useState(false)
const [clickOpenModal, setClickOpenModal] = useState(false)
const [clickOpenModalShift, setClickOpenModalShift] = useState(false)
const [currentPage, setCurrentPage] = useState(1)
const [dataEdit, setDataEdit] = useState([])
const [dataExport, setDataExport] = useState([])
const [dataTable, setDatatable] = useState([])
const [divisiList, setDivisiList] = useState([])
const [idDelete, setIdDelete] = useState(0)
const [openDialog, setOpenDialog] = useState(false)
const [openDialogShift, setOpenDialogShift] = useState(false)
const [typeDialog, setTypeDialog] = useState('Save')
const [typeDialogShift, setTypeDialogShift] = useState('Save')
const [dataExport, setDataExport] = useState([])
const [roleList, setRoleList] = useState([])
const [rowsPerPage, setRowsPerPage] = useState(10)
const [dataEdit, setDataEdit] = useState([])
const [alertDelete, setAlertDelete] = useState(false)
const [idDelete, setIdDelete] = useState(0)
const [dataTable, setDatatable] = useState([])
const [clickOpenModal, setClickOpenModal] = useState(false)
const [clickOpenModalShift, setClickOpenModalShift] = useState(false)
const [search, setSearch] = useState('')
const [totalPage, setTotalPage] = useState(0)
const [roleList, setRoleList] = useState([])
const [divisiList, setDivisiList] = useState([])
const [typeDialog, setTypeDialog] = useState('Save')
const [typeDialogShift, setTypeDialogShift] = useState('Save')
const pageName = params.name;
useEffect(() => {
getRoleList()
@ -60,7 +60,6 @@ const ResourceWorker = ({ params }) => {
useEffect(() => {
getDataUser()
console.log("cek token", token)
}, [search, rowsPerPage, currentPage])
const onShowSizeChange = (current, pageSize) => {
@ -81,7 +80,6 @@ const ResourceWorker = ({ params }) => {
.post(ROLE_SEARCH, formData, config)
.then(res => res)
.catch((error) => error.response);
// console.log(result)
if (result && result.data && result.data.code == 200) {
setRoleList(result.data.data);
@ -100,7 +98,6 @@ const ResourceWorker = ({ params }) => {
.post(DIVISI_SEARCH, formData, config)
.then(res => res)
.catch((error) => error.response);
// console.log(result)
if (result && result.data && result.data.code == 200) {
setDivisiList(result.data.data);
@ -117,44 +114,6 @@ const ResourceWorker = ({ params }) => {
start = (currentPage * rowsPerPage) - rowsPerPage
}
// const payload = {
// "paging": {
// "start": start,
// "length": rowsPerPage
// },
// "columns": [
// {
// "name": "name",
// "logic_operator": "like",
// "value": search,
// "operator": "AND"
// }
// ],
// "joins": [
// {
// "name": "m_roles",
// "column_join": "role_id",
// "column_results": [
// "name",
// "description"
// ]
// },
// {
// "name": "m_divisi",
// "column_join": "divisi_id",
// "column_results": [
// "name",
// ]
// }
// ],
// "orders": {
// "columns": [
// "id"
// ],
// "ascending": false
// }
// }
const payload = {
"paging": {
"start": start,
@ -240,7 +199,6 @@ const ResourceWorker = ({ params }) => {
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
console.log("cek resource", result.data.data)
setDatatable(result.data.data);
setTotalPage(result.data.totalRecord);
} else {
@ -288,18 +246,9 @@ const ResourceWorker = ({ params }) => {
.then(res => res)
.catch((error) => error.response);
// console.log(result)
if (result && result.data && result.data.code == 200) {
let resData = result.data.data;
const excelData = [];
// <td>{n.nama}</td>
// <td>{n.biaya}</td>
// <td style={{textAlign:"center"}}><div style={{borderRadius:"50%",height:"25px",width:"25px",backgroundColor:n.color_progress}}></div></td>
// <td>{n.jumlah_pekerja}</td>
// <td>{n.pic}</td>
// <td>{n.mulai_proyek ? moment(n.mulai_proyek).format("DD-MM-YYYY") : "-"}</td>
// <td>{n.akhir_proyek ? moment(n.akhir_proyek).format("DD-MM-YYYY") : "-"}</td>
resData.map((n, index) => {
let dataRow = {
"Nama Proyek": n.nama,
@ -311,9 +260,7 @@ const ResourceWorker = ({ params }) => {
}
excelData.push(dataRow)
})
// console.log("cek excel data", excelData)
await setDataExport(excelData);
// exportExcel();
} else {
NotificationManager.error('Gagal Export Data!!', 'Failed');
}
@ -350,13 +297,9 @@ const ResourceWorker = ({ params }) => {
}
const handleCloseDialogShift = (type, data) => {
console.log(data)
if (type === "save") {
saveUserShift(data);
}
// else if (type === "edit") {
// editUser(data);
// }
setDataEdit([])
setOpenDialogShift(false)
}
@ -393,7 +336,6 @@ const ResourceWorker = ({ params }) => {
let urlEdit = USER_EDIT(data.id)
const formData = data
console.log("cek form data", formData)
const result = await axios.put(urlEdit, formData, HEADER)
.then(res => res)
@ -446,9 +388,6 @@ const ResourceWorker = ({ params }) => {
dataIndex: '',
key: 'x',
render: (text, record) => <>
{/* <Tooltip title="Tambah Sub">
<Button size="small" type="link" style={{color:'green'}} onClick={() => handleOpenDialogSub('Save', text)}><i className="fa fa-plus"></i></Button>
</Tooltip> */}
<Tooltip title="Edit">
<Button size="small" type="link" style={{ color: 'orange' }} onClick={() => handleEdit(text)}><i className="fa fa-edit"></i></Button>
</Tooltip>
@ -459,9 +398,6 @@ const ResourceWorker = ({ params }) => {
<Tooltip title="Set User">
<Button size="small" type="link" style={{ color: 'lightblue' }} onClick={() => handleSetWorker(text)}><i className="fa fa-key"></i></Button>
</Tooltip>
{/* <Tooltip title="Set Shift">
<Button size="small" type="link" style={{ color: '#0080ff' }} onClick={() => handleSetUserShift(text)}><i className="cil-alarm"></i></Button>
</Tooltip> */}
</>,
},
@ -478,20 +414,7 @@ const ResourceWorker = ({ params }) => {
{ title: 'Phone No.', dataIndex: 'phone_number', key: 'phone_number' },
{ title: 'Email', dataIndex: 'email', key: 'email' },
{ title: 'Status', dataIndex: 'status_resource', key: 'status_status' }
// {
// title: 'Aktifitas Mulai',
// dataIndex: 'mulai_proyek',
// key: 'mulai_proyek',
// render: (text, record) => <>{moment(text).format(format)}</>,
// },
// {
// title: 'Aktifitas Selesai',
// dataIndex: 'akhir_proyek',
// key: 'akhir_proyek',
// render: (text, record) => <>{moment(text).format(format)}</>,
// },
];
// console.log("columns", columns)
return (
<Table
rowKey="id"

53
src/views/SimproV2/Satuan/index.js

@ -1,14 +1,12 @@
import React, { useState, useEffect, useMemo } from 'react';
import { Card, CardBody, CardHeader, Col, Row, Input, Table } from 'reactstrap';
import axios from "../../../const/interceptorApi"
import * as XLSX from 'xlsx';
import SweetAlert from 'react-bootstrap-sweetalert';
import DialogForm from './DialogForm';
import React, { useState, useEffect, useMemo } from 'react';
import SweetAlert from 'react-bootstrap-sweetalert';
import axios from "../../../const/interceptorApi"
import { Card, CardBody, CardHeader, Col, Row, Input, Table } from 'reactstrap';
import { NotificationContainer, NotificationManager } from 'react-notifications';
import { Pagination, Button, Tooltip } from 'antd';
import {
SATUAN_ADD, SATUAN_EDIT, SATUAN_DELETE,SATUAN_SEARCH
} from '../../../const/ApiConst';
import { SATUAN_ADD, SATUAN_EDIT, SATUAN_DELETE,SATUAN_SEARCH} from '../../../const/ApiConst';
const token = window.localStorage.getItem('token');
const config = {
@ -33,19 +31,20 @@ const Satuan = ({ params }) => {
}
}
const pageName = params.name;
const [search, setSearch] = useState('')
const [alertDelete, setAlertDelete] = useState(false)
const [allDataMenu, setAllDataMenu] = useState([])
const [clickOpenModal, setClickOpenModal] = useState(false)
const [currentPage, setCurrentPage] = useState(1)
const [openDialog, setOpenDialog] = useState(false)
const [typeDialog, setTypeDialog] = useState('Save')
const [dataExport, setDataExport] = useState([])
const [rowsPerPage, setRowsPerPage] = useState(10)
const [dataEdit, setDataEdit] = useState([])
const [alertDelete, setAlertDelete] = useState(false)
const [idDelete, setIdDelete] = useState(0)
const [dataExport, setDataExport] = useState([])
const [dataTable, setDatatable] = useState([])
const [clickOpenModal, setClickOpenModal] = useState(false)
const [allDataMenu, setAllDataMenu] = useState([])
const [idDelete, setIdDelete] = useState(0)
const [openDialog, setOpenDialog] = useState(false)
const [rowsPerPage, setRowsPerPage] = useState(10)
const [search, setSearch] = useState('')
const [totalPage, setTotalPage] = useState(0)
const [typeDialog, setTypeDialog] = useState('Save')
useEffect(() => {
getDataSatuan()
@ -87,16 +86,11 @@ const Satuan = ({ params }) => {
}
}
// console.log("payload ", payload)
const result = await axios
.post(SATUAN_SEARCH, payload, config)
.then(res => res)
.catch((error) => error.response);
if (result && result.data && result.data.code == 200) {
console.log("get data ", result.data)
setDatatable(result.data.data);
setTotalPage(result.data.totalRecord);
} else {
@ -116,7 +110,6 @@ const Satuan = ({ params }) => {
}
const handleExportExcel = async () => {
console.log("cek cek cek cke")
const payload = {
"paging": { "start": 0, "length": -1 },
"columns": [
@ -125,16 +118,10 @@ const Satuan = ({ params }) => {
"joins": [],
"orders": { "columns": ["id"], "ascending": false }
}
const result = await axios
.post(SATUAN_SEARCH, payload, config)
.then(res => res)
.catch((error) => error.response);
// console.log(result)
if (result && result.data && result.data.code == 200) {
let resData = result.data.data;
const excelData = [];
@ -145,9 +132,7 @@ const Satuan = ({ params }) => {
}
excelData.push(dataRow)
})
// console.log("cek excel data", resData)
await setDataExport(excelData);
// exportExcel();
} else {
NotificationManager.error('Gagal Export Data!!', 'Failed');
}
@ -155,7 +140,6 @@ const Satuan = ({ params }) => {
const exportExcel = () => {
const dataExcel = dataExport || [];
console.log("cek data excel", dataExcel)
const fileName = `Data ${pageName}.xlsx`;
const ws = XLSX.utils.json_to_sheet(dataExcel);
const wb = XLSX.utils.book_new();
@ -192,21 +176,16 @@ const Satuan = ({ params }) => {
if (result && result.data && result.data.code === 200) {
getDataSatuan()
// console.log("data material s ", formData)
NotificationManager.success(`Data project type berhasil ditambah`, 'Success!!');
} else {
// console.log("data material fail ", formData)
NotificationManager.error(`${result.data.message}`, 'Failed!!');
}
}
const editMaterialR = async (data) => {
let urlEdit = SATUAN_EDIT(data.id)
const formData = data
console.log("from data edit ", formData)
const result = await axios.put(urlEdit, formData, HEADER)
.then(res => res)
.catch((error) => error.response);
@ -265,8 +244,6 @@ const Satuan = ({ params }) => {
}
}
return (
<div>
<NotificationContainer />

Loading…
Cancel
Save