Browse Source

add company name

pull/1/head
wahyun 12 months ago
parent
commit
d0dc93183c
  1. 216
      src/views/SimproV2/CreatedProyek/index.js

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

@ -335,14 +335,30 @@ const CreatedProyek = ({ params, ...props }) => {
} }
const payload = { const payload = {
columns: [ columns: [],
{ group_column: {
name: "nama", "operator": "AND",
logic_operator: "ilike", "group_operator": "OR",
value: search, "where": [
operator: "AND", {
}, "name": "nama",
], "logic_operator": "~*",
"value": search,
},
{
"name": "name",
"logic_operator": "~*",
"value": search,
"table_name": "m_type_proyek"
},
{
"name": "name",
"logic_operator": "~*",
"value": search,
"table_name": "m_users"
}
]
},
select: [ select: [
"id", "id",
"nama", "nama",
@ -362,7 +378,7 @@ const CreatedProyek = ({ params, ...props }) => {
name: "m_type_proyek", name: "m_type_proyek",
column_join: "type_proyek_id", column_join: "type_proyek_id",
column_results: ["name", "description"], column_results: ["name", "description"],
}, }
], ],
orders: { columns: ["nama"], ascending: true }, orders: { columns: ["nama"], ascending: true },
paging: { start: start, length: rowsPerPage }, paging: { start: start, length: rowsPerPage },
@ -372,10 +388,18 @@ const CreatedProyek = ({ params, ...props }) => {
payload.columns.push( payload.columns.push(
{ name: "company_id", logic_operator: "like", value: company_id, operator: "AND" } { name: "company_id", logic_operator: "like", value: company_id, operator: "AND" }
); );
} else { }
if(role_name !== 'Super Admin') {
payload.columns.push( payload.columns.push(
{ name: "created_by_id", logic_operator: "IN", value: [JSON.parse(hierarchy)], operator: "AND" } { name: "created_by_id", logic_operator: "IN", value: [JSON.parse(hierarchy)], operator: "AND" }
); );
} else {
payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] }
)
payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" }
)
} }
const result = await axios const result = await axios
@ -560,7 +584,6 @@ const CreatedProyek = ({ params, ...props }) => {
const handleOpenDialogViewDetail = async (data) => { const handleOpenDialogViewDetail = async (data) => {
setLoading(true); setLoading(true);
setidTask(data.id); setidTask(data.id);
// setDataView(data)
await getDataProject(data.id); await getDataProject(data.id);
await getProjectMilestone(data.id); await getProjectMilestone(data.id);
await getProjectParticipant(data.id); await getProjectParticipant(data.id);
@ -571,7 +594,6 @@ const CreatedProyek = ({ params, ...props }) => {
await getK3toProject(data.id); await getK3toProject(data.id);
await getProjectAssignHR(data.id); await getProjectAssignHR(data.id);
await getProjectImage(data.id); await getProjectImage(data.id);
// await handleGetDataPm(data.id);
setPM(data.join_first_name); setPM(data.join_first_name);
setOpenDialogViewDetail(true); setOpenDialogViewDetail(true);
}; };
@ -670,7 +692,6 @@ const CreatedProyek = ({ params, ...props }) => {
orders: { columns: ["id"], ascending: true }, orders: { columns: ["id"], ascending: true },
paging: { start: 0, length: -1 }, paging: { start: 0, length: -1 },
}; };
// const url = PROJECT_MI(proyek_id)
const result = await axios const result = await axios
.post(PROJECT_MILESTONE_SEARCH, payload, HEADER) .post(PROJECT_MILESTONE_SEARCH, payload, HEADER)
.then((res) => res) .then((res) => res)
@ -1303,13 +1324,6 @@ const CreatedProyek = ({ params, ...props }) => {
const arr = await Promise.all(request) const arr = await Promise.all(request)
.then((values) => values) .then((values) => values)
.catch((err) => err.response); .catch((err) => err.response);
// if(arr)
// const result = arr.map(res => res.data.code !== 200)
// if (result.length > 0) {
// return "gagal"
// }
// return "berhasil"
}; };
const handleDelete = async (id) => { const handleDelete = async (id) => {
@ -1327,14 +1341,18 @@ const CreatedProyek = ({ params, ...props }) => {
const handleExportExcel = async () => { const handleExportExcel = async () => {
const payload = { const payload = {
columns: [ columns:[],
{ group_column: {
name: "nama", "operator": "AND",
logic_operator: "ilike", "group_operator": "OR",
value: search, "where": [
operator: "AND", {
}, "name": "nama",
], "logic_operator": "~*",
"value": search,
}
]
},
paging: { start: 0, length: -1 }, paging: { start: 0, length: -1 },
joins: [], joins: [],
orders: { columns: ["id"], ascending: false }, orders: { columns: ["id"], ascending: false },
@ -1344,10 +1362,19 @@ const CreatedProyek = ({ params, ...props }) => {
payload.columns.push( payload.columns.push(
{ name: "company_id", logic_operator: "like", value: company_id, operator: "AND" } { name: "company_id", logic_operator: "like", value: company_id, operator: "AND" }
); );
} else { }
if(role_name !== 'Super Admin') {
payload.columns.push( payload.columns.push(
{ name: "created_by_id", logic_operator: "IN", value: [JSON.parse(hierarchy)], operator: "AND" } { name: "created_by_id", logic_operator: "IN", value: [JSON.parse(hierarchy)], operator: "AND" }
); );
} else {
payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] }
)
payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" }
)
} }
const result = await axios const result = await axios
@ -1359,30 +1386,33 @@ const CreatedProyek = ({ params, ...props }) => {
let resData = result.data.data; let resData = result.data.data;
const excelData = []; const excelData = [];
resData.map((n, index) => { resData.map((n, index) => {
let dataRow = { let dataRow = {};
Sortname: n.kode_sortname ? n.kode_sortname : "", if (role_name === 'Super Admin') {
"Nama Project": n.nama ? n.nama : "", dataRow.Company = n.join_first_company_name;
"Tanggal Mulai": n.mulai_proyek }
dataRow.Sortname = n.kode_sortname ? n.kode_sortname : "";
dataRow["Nama Project"] = n.nama ? n.nama : "";
dataRow["Tanggal Mulai"] = n.mulai_proyek
? moment(n.mulai_proyek).format(format) ? moment(n.mulai_proyek).format(format)
: "-", : "-";
"Tanggal Selesai": n.akhir_proyek dataRow["Tanggal Selesai"] = n.akhir_proyek
? moment(n.akhir_proyek).format(format) ? moment(n.akhir_proyek).format(format)
: "-", : "-";
"Area Kerja": n.area_kerja ? n.area_kerja : "", dataRow["Area Kerja"] = n.area_kerja ? n.area_kerja : "";
Perusahaan: n.company ? n.company : "", dataRow["Perusahaan"] = n.company ? n.company : "";
Keterangan: n.keterangan ? n.keterangan : "", dataRow["Keterangan"] = n.keterangan ? n.keterangan : "";
"Dianggap sukses ketika": n.considered_success_when dataRow["Dianggap sukses ketika"] = n.considered_success_when
? n.considered_success_when ? n.considered_success_when
: "", : "";
"Tujuan Proyek": n.project_objectives ? n.project_objectives : "", dataRow["Tujuan Proyek"] = n.project_objectives ? n.project_objectives : "";
"Resiko potensial": n.potential_risk ? n.potential_risk : "", dataRow["Resiko potensial"] = n.potential_risk ? n.potential_risk : "";
"Rencana Biaya": n.rencana_biaya dataRow["Rencana Biaya"] = n.rencana_biaya
? formatThousand(n.rencana_biaya) ? formatThousand(n.rencana_biaya)
: "-", : "-";
"Testing Environment": n.testing_environment dataRow["Testing Environment"] = n.testing_environment
? n.testing_environment ? n.testing_environment
: "-", : "-";
};
excelData.push(dataRow); excelData.push(dataRow);
}); });
await setDataExport(excelData); await setDataExport(excelData);
@ -1393,19 +1423,35 @@ const CreatedProyek = ({ params, ...props }) => {
const handleExportPdf = async () => { const handleExportPdf = async () => {
const doc = new jsPDF(); const doc = new jsPDF();
let headers = [
const headers = [ [role_name === 'Super Admin' ? "Company" : null,"Project Name", "Budget", "Project Type", "PM", "Time Project"],
["Project Name", "Budget", "Project Type", "PM", "Time Project"],
]; ];
const payload = { const payload = {
columns: [ columns:[],
{ group_column: {
name: "nama", "operator": "AND",
logic_operator: "ilike", "group_operator": "OR",
value: search, "where": [
operator: "AND", {
}, "name": "nama",
], "logic_operator": "~*",
"value": search,
},
{
"name": "name",
"logic_operator": "~*",
"value": search,
"table_name": "m_type_proyek"
},
{
"name": "name",
"logic_operator": "~*",
"value": search,
"table_name": "m_users"
}
]
},
joins: [ joins: [
{ {
name: "m_users", name: "m_users",
@ -1425,10 +1471,18 @@ const CreatedProyek = ({ params, ...props }) => {
payload.columns.push( payload.columns.push(
{ name: "company_id", logic_operator: "like", value: company_id, operator: "AND" } { name: "company_id", logic_operator: "like", value: company_id, operator: "AND" }
); );
} else { }
if(role_name !== 'Super Admin') {
payload.columns.push( payload.columns.push(
{ name: "created_by_id", logic_operator: "IN", value: [JSON.parse(hierarchy)], operator: "AND" } { name: "created_by_id", logic_operator: "IN", value: [JSON.parse(hierarchy)], operator: "AND" }
); );
} else {
payload.joins.push(
{ name: "m_company", column_join: "company_id", column_results: ["company_name"] }
)
payload.group_column.where.push(
{ name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" }
)
} }
const result = await axios const result = await axios
@ -1438,6 +1492,7 @@ const CreatedProyek = ({ params, ...props }) => {
if (result && result.data && result.data.code == 200) { if (result && result.data && result.data.code == 200) {
let resData = result.data.data; let resData = result.data.data;
const data = resData.map((elt) => [ const data = resData.map((elt) => [
role_name === 'Super Admin' ? elt.join_third_company_name : null,
elt.nama, elt.nama,
`Rp. ${formatThousand(elt.rencana_biaya)}`, `Rp. ${formatThousand(elt.rencana_biaya)}`,
elt.join_second_name, elt.join_second_name,
@ -1458,34 +1513,6 @@ const CreatedProyek = ({ params, ...props }) => {
}); });
} }
doc.save("Project.pdf"); doc.save("Project.pdf");
// const unit = "pt";
// const size = "A4"; // Use A1, A2, A3 or A4
// const orientation = "portrait"; // portrait or landscape
// const marginLeft = 40;
// const doc = new jsPDF(orientation, unit, size);
// doc.setFontSize(15);
// const dataPeople = [
// { name: "Keanu Reeves", profession: "Actor" },
// { name: "Lionel Messi", profession: "Football Player" },
// { name: "Cristiano Ronaldo", profession: "Football Player" },
// { name: "Jack Nicklaus", profession: "Golf Player" },
// ];
// const title = "My Awesome Report";
// const headers = [["NAME", "PROFESSION"]];
// const data = dataPeople.map((elt) => [elt.name, elt.profession]);
// let content = {
// startY: 50,
// head: headers,
// body: data,
// };
// doc.text(title, marginLeft, 40);
// doc.autoTable(content);
// doc.save("report.pdf");
}; };
const exportExcel = () => { const exportExcel = () => {
@ -1699,12 +1726,21 @@ const CreatedProyek = ({ params, ...props }) => {
</> </>
), ),
}, },
{
title: role_name === 'Super Admin' ? "Company Name" : null,
dataIndex: "join_third_company_name",
key: "join_third_company_name",
render: (text, record) => {
return role_name === 'Super Admin' ? (
<span>{record.join_third_company_name}</span>
) : null;
}
},
{ title: "Project Name", dataIndex: "nama", key: "nama" }, { title: "Project Name", dataIndex: "nama", key: "nama" },
{ {
title: "Budget", title: "Budget",
dataIndex: "rencana_biaya", dataIndex: "rencana_biaya",
key: "rencana_biaya", key: "rencana_biaya",
// render: (text, record) => { return renderFormatRupiah(text, "Rp") }
render: (text, record) => { render: (text, record) => {
return record.currency_symbol return record.currency_symbol
? `${record.currency_symbol} ${formatThousand(text)}` ? `${record.currency_symbol} ${formatThousand(text)}`
@ -2033,7 +2069,7 @@ const CreatedProyek = ({ params, ...props }) => {
type="text" type="text"
name="search" name="search"
id="search" id="search"
placeholder={`Search Project Name`} placeholder={`Search...`}
style={{ width: 200 }} style={{ width: 200 }}
/> />
</Col> </Col>

Loading…
Cancel
Save