Browse Source

add company name

pull/1/head
wahyun 10 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 = {
columns: [
{
name: "nama",
logic_operator: "ilike",
value: search,
operator: "AND",
},
],
columns: [],
group_column: {
"operator": "AND",
"group_operator": "OR",
"where": [
{
"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: [
"id",
"nama",
@ -362,7 +378,7 @@ const CreatedProyek = ({ params, ...props }) => {
name: "m_type_proyek",
column_join: "type_proyek_id",
column_results: ["name", "description"],
},
}
],
orders: { columns: ["nama"], ascending: true },
paging: { start: start, length: rowsPerPage },
@ -372,10 +388,18 @@ const CreatedProyek = ({ params, ...props }) => {
payload.columns.push(
{ name: "company_id", logic_operator: "like", value: company_id, operator: "AND" }
);
} else {
}
if(role_name !== 'Super Admin') {
payload.columns.push(
{ 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
@ -560,7 +584,6 @@ const CreatedProyek = ({ params, ...props }) => {
const handleOpenDialogViewDetail = async (data) => {
setLoading(true);
setidTask(data.id);
// setDataView(data)
await getDataProject(data.id);
await getProjectMilestone(data.id);
await getProjectParticipant(data.id);
@ -571,7 +594,6 @@ const CreatedProyek = ({ params, ...props }) => {
await getK3toProject(data.id);
await getProjectAssignHR(data.id);
await getProjectImage(data.id);
// await handleGetDataPm(data.id);
setPM(data.join_first_name);
setOpenDialogViewDetail(true);
};
@ -670,7 +692,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)
@ -1303,13 +1324,6 @@ const CreatedProyek = ({ params, ...props }) => {
const arr = await Promise.all(request)
.then((values) => values)
.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) => {
@ -1327,14 +1341,18 @@ const CreatedProyek = ({ params, ...props }) => {
const handleExportExcel = async () => {
const payload = {
columns: [
{
name: "nama",
logic_operator: "ilike",
value: search,
operator: "AND",
},
],
columns:[],
group_column: {
"operator": "AND",
"group_operator": "OR",
"where": [
{
"name": "nama",
"logic_operator": "~*",
"value": search,
}
]
},
paging: { start: 0, length: -1 },
joins: [],
orders: { columns: ["id"], ascending: false },
@ -1344,10 +1362,19 @@ const CreatedProyek = ({ params, ...props }) => {
payload.columns.push(
{ name: "company_id", logic_operator: "like", value: company_id, operator: "AND" }
);
} else {
}
if(role_name !== 'Super Admin') {
payload.columns.push(
{ 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
@ -1359,30 +1386,33 @@ const CreatedProyek = ({ params, ...props }) => {
let resData = result.data.data;
const excelData = [];
resData.map((n, index) => {
let dataRow = {
Sortname: n.kode_sortname ? n.kode_sortname : "",
"Nama Project": n.nama ? n.nama : "",
"Tanggal Mulai": n.mulai_proyek
let dataRow = {};
if (role_name === 'Super Admin') {
dataRow.Company = n.join_first_company_name;
}
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)
: "-",
"Tanggal Selesai": n.akhir_proyek
: "-";
dataRow["Tanggal Selesai"] = n.akhir_proyek
? moment(n.akhir_proyek).format(format)
: "-",
"Area Kerja": n.area_kerja ? n.area_kerja : "",
Perusahaan: n.company ? n.company : "",
Keterangan: n.keterangan ? n.keterangan : "",
"Dianggap sukses ketika": n.considered_success_when
: "-";
dataRow["Area Kerja"] = n.area_kerja ? n.area_kerja : "";
dataRow["Perusahaan"] = n.company ? n.company : "";
dataRow["Keterangan"] = n.keterangan ? n.keterangan : "";
dataRow["Dianggap sukses ketika"] = n.considered_success_when
? n.considered_success_when
: "",
"Tujuan Proyek": n.project_objectives ? n.project_objectives : "",
"Resiko potensial": n.potential_risk ? n.potential_risk : "",
"Rencana Biaya": n.rencana_biaya
: "";
dataRow["Tujuan Proyek"] = n.project_objectives ? n.project_objectives : "";
dataRow["Resiko potensial"] = n.potential_risk ? n.potential_risk : "";
dataRow["Rencana Biaya"] = n.rencana_biaya
? formatThousand(n.rencana_biaya)
: "-",
"Testing Environment": n.testing_environment
: "-";
dataRow["Testing Environment"] = n.testing_environment
? n.testing_environment
: "-",
};
: "-";
excelData.push(dataRow);
});
await setDataExport(excelData);
@ -1393,19 +1423,35 @@ const CreatedProyek = ({ params, ...props }) => {
const handleExportPdf = async () => {
const doc = new jsPDF();
const headers = [
["Project Name", "Budget", "Project Type", "PM", "Time Project"],
let headers = [
[role_name === 'Super Admin' ? "Company" : null,"Project Name", "Budget", "Project Type", "PM", "Time Project"],
];
const payload = {
columns: [
{
name: "nama",
logic_operator: "ilike",
value: search,
operator: "AND",
},
],
columns:[],
group_column: {
"operator": "AND",
"group_operator": "OR",
"where": [
{
"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: [
{
name: "m_users",
@ -1425,10 +1471,18 @@ const CreatedProyek = ({ params, ...props }) => {
payload.columns.push(
{ name: "company_id", logic_operator: "like", value: company_id, operator: "AND" }
);
} else {
}
if(role_name !== 'Super Admin') {
payload.columns.push(
{ 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
@ -1438,6 +1492,7 @@ const CreatedProyek = ({ params, ...props }) => {
if (result && result.data && result.data.code == 200) {
let resData = result.data.data;
const data = resData.map((elt) => [
role_name === 'Super Admin' ? elt.join_third_company_name : null,
elt.nama,
`Rp. ${formatThousand(elt.rencana_biaya)}`,
elt.join_second_name,
@ -1458,34 +1513,6 @@ const CreatedProyek = ({ params, ...props }) => {
});
}
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 = () => {
@ -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: "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)}`
@ -2033,7 +2069,7 @@ const CreatedProyek = ({ params, ...props }) => {
type="text"
name="search"
id="search"
placeholder={`Search Project Name`}
placeholder={`Search...`}
style={{ width: 200 }}
/>
</Col>

Loading…
Cancel
Save