@amirjalili1374/ui-kit 1.6.5 → 1.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ui-kit.es.js
CHANGED
|
@@ -33096,99 +33096,95 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent$1({
|
|
|
33096
33096
|
const handleExportClientSide = () => {
|
|
33097
33097
|
const sourceItems = (props.items && props.items.length ? props.items : items.value) ?? [];
|
|
33098
33098
|
if (!sourceItems.length) return;
|
|
33099
|
-
const
|
|
33100
|
-
const
|
|
33099
|
+
const headers = props.headers.filter((h2) => h2.key && h2.title);
|
|
33100
|
+
const moneyTotals = {};
|
|
33101
|
+
const rows = sourceItems.map((item) => {
|
|
33101
33102
|
const row = {};
|
|
33102
|
-
|
|
33103
|
+
headers.forEach((h2) => {
|
|
33103
33104
|
var _a;
|
|
33104
|
-
let value2 =
|
|
33105
|
-
if (
|
|
33105
|
+
let value2 = h2.nestedKey ? (_a = item[h2.key]) == null ? void 0 : _a[h2.nestedKey] : item[h2.key];
|
|
33106
|
+
if (h2.type === "money") {
|
|
33106
33107
|
const num = Number(value2);
|
|
33107
33108
|
value2 = !isNaN(num) ? num : 0;
|
|
33109
|
+
moneyTotals[h2.title] = (moneyTotals[h2.title] || 0) + value2;
|
|
33108
33110
|
}
|
|
33109
|
-
if (typeof value2 === "boolean")
|
|
33110
|
-
|
|
33111
|
-
}
|
|
33112
|
-
row[header.title] = value2 ?? "";
|
|
33111
|
+
if (typeof value2 === "boolean") value2 = value2 ? "بله" : "خیر";
|
|
33112
|
+
row[h2.title] = value2 ?? "";
|
|
33113
33113
|
});
|
|
33114
33114
|
return row;
|
|
33115
33115
|
});
|
|
33116
33116
|
const totalRow = {};
|
|
33117
|
-
|
|
33118
|
-
if (
|
|
33119
|
-
|
|
33120
|
-
|
|
33121
|
-
totalRow[header.title] = "جمع کل";
|
|
33122
|
-
} else {
|
|
33123
|
-
totalRow[header.title] = "";
|
|
33124
|
-
}
|
|
33117
|
+
headers.forEach((h2, i) => {
|
|
33118
|
+
if (h2.type === "money") totalRow[h2.title] = moneyTotals[h2.title] || 0;
|
|
33119
|
+
else if (i === 0) totalRow[h2.title] = "جمع کل";
|
|
33120
|
+
else totalRow[h2.title] = "";
|
|
33125
33121
|
});
|
|
33126
|
-
|
|
33127
|
-
const
|
|
33128
|
-
const range = xlsx_minExports.utils.decode_range(
|
|
33129
|
-
|
|
33130
|
-
|
|
33131
|
-
|
|
33132
|
-
|
|
33133
|
-
|
|
33134
|
-
|
|
33135
|
-
|
|
33136
|
-
|
|
33122
|
+
rows.push(totalRow);
|
|
33123
|
+
const ws = xlsx_minExports.utils.json_to_sheet(rows);
|
|
33124
|
+
const range = xlsx_minExports.utils.decode_range(ws["!ref"]);
|
|
33125
|
+
ws["!freeze"] = { xSplit: 0, ySplit: 1 };
|
|
33126
|
+
ws["!autofilter"] = {
|
|
33127
|
+
ref: xlsx_minExports.utils.encode_range(range)
|
|
33128
|
+
};
|
|
33129
|
+
ws["!cols"] = headers.map((h2) => {
|
|
33130
|
+
let max = h2.title.length;
|
|
33131
|
+
rows.forEach((r) => {
|
|
33132
|
+
const len = String(r[h2.title] ?? "").length;
|
|
33133
|
+
if (len > max) max = len;
|
|
33137
33134
|
});
|
|
33138
|
-
return { wch:
|
|
33135
|
+
return { wch: max + 4 };
|
|
33139
33136
|
});
|
|
33140
|
-
|
|
33141
|
-
|
|
33142
|
-
|
|
33143
|
-
|
|
33137
|
+
const headerStyle = {
|
|
33138
|
+
font: { bold: true, name: "B Nazanin" },
|
|
33139
|
+
alignment: { horizontal: "center", vertical: "center" },
|
|
33140
|
+
fill: { fgColor: { rgb: "D9D9D9" } },
|
|
33141
|
+
border: {
|
|
33142
|
+
top: { style: "thin" },
|
|
33143
|
+
bottom: { style: "thin" },
|
|
33144
|
+
left: { style: "thin" },
|
|
33145
|
+
right: { style: "thin" }
|
|
33146
|
+
}
|
|
33147
|
+
};
|
|
33148
|
+
const zebraFill = { fgColor: { rgb: "F7F7F7" } };
|
|
33149
|
+
headers.forEach((h2, c) => {
|
|
33150
|
+
const headerCell = xlsx_minExports.utils.encode_cell({ r: 0, c });
|
|
33151
|
+
if (ws[headerCell]) ws[headerCell].s = headerStyle;
|
|
33152
|
+
for (let r = 1; r <= rows.length; r++) {
|
|
33153
|
+
const addr = xlsx_minExports.utils.encode_cell({ r, c });
|
|
33154
|
+
const cell = ws[addr];
|
|
33155
|
+
if (!cell) continue;
|
|
33156
|
+
const isTotalRow = r === rows.length;
|
|
33157
|
+
const zebra = r % 2 === 0;
|
|
33144
33158
|
cell.s = {
|
|
33145
|
-
font: {
|
|
33146
|
-
alignment: {
|
|
33147
|
-
|
|
33159
|
+
font: { name: "B Nazanin" },
|
|
33160
|
+
alignment: {
|
|
33161
|
+
horizontal: h2.type === "money" ? "center" : "right",
|
|
33162
|
+
vertical: "center"
|
|
33163
|
+
},
|
|
33148
33164
|
border: {
|
|
33149
33165
|
top: { style: "thin" },
|
|
33150
33166
|
bottom: { style: "thin" },
|
|
33151
33167
|
left: { style: "thin" },
|
|
33152
33168
|
right: { style: "thin" }
|
|
33153
|
-
}
|
|
33169
|
+
},
|
|
33170
|
+
fill: zebra && !isTotalRow ? zebraFill : void 0
|
|
33154
33171
|
};
|
|
33155
|
-
|
|
33156
|
-
|
|
33157
|
-
|
|
33158
|
-
|
|
33159
|
-
|
|
33160
|
-
|
|
33161
|
-
const cell = worksheet[addr];
|
|
33162
|
-
if (cell && typeof cell.v === "number") {
|
|
33163
|
-
cell.z = "#,##0;[Red]-#,##0";
|
|
33164
|
-
cell.s = {
|
|
33165
|
-
font: { name: "B Nazanin" },
|
|
33166
|
-
alignment: { horizontal: "center" }
|
|
33167
|
-
};
|
|
33168
|
-
}
|
|
33172
|
+
if (h2.type === "money" && typeof cell.v === "number") {
|
|
33173
|
+
cell.z = "#,##0;[Red]-#,##0";
|
|
33174
|
+
}
|
|
33175
|
+
if (isTotalRow) {
|
|
33176
|
+
cell.s.font = { bold: true, name: "B Nazanin" };
|
|
33177
|
+
cell.s.fill = { fgColor: { rgb: "EFEFEF" } };
|
|
33169
33178
|
}
|
|
33170
33179
|
}
|
|
33171
33180
|
});
|
|
33172
|
-
const
|
|
33173
|
-
|
|
33174
|
-
|
|
33175
|
-
const cell = worksheet[addr];
|
|
33176
|
-
if (cell) {
|
|
33177
|
-
cell.s = {
|
|
33178
|
-
font: { bold: true, name: "B Nazanin" },
|
|
33179
|
-
fill: { fgColor: { rgb: "EFEFEF" } },
|
|
33180
|
-
alignment: { horizontal: "center" }
|
|
33181
|
-
};
|
|
33182
|
-
}
|
|
33183
|
-
});
|
|
33184
|
-
worksheet["!freeze"] = { xSplit: 0, ySplit: 1 };
|
|
33185
|
-
worksheet["!autofilter"] = {
|
|
33186
|
-
ref: xlsx_minExports.utils.encode_range(range)
|
|
33181
|
+
const wb = xlsx_minExports.utils.book_new();
|
|
33182
|
+
wb.Workbook = {
|
|
33183
|
+
Views: [{ RTL: true }]
|
|
33187
33184
|
};
|
|
33188
|
-
|
|
33189
|
-
xlsx_minExports.utils.book_append_sheet(workbook, worksheet, "Report");
|
|
33185
|
+
xlsx_minExports.utils.book_append_sheet(wb, ws, "Report");
|
|
33190
33186
|
const fileName = `${props.exportFileName || "report"}.xlsx`;
|
|
33191
|
-
xlsx_minExports.writeFile(
|
|
33187
|
+
xlsx_minExports.writeFile(wb, fileName);
|
|
33192
33188
|
};
|
|
33193
33189
|
const handleExport = async () => {
|
|
33194
33190
|
var _a, _b, _c;
|