aq-fe-framework 0.1.154 → 0.1.155
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/{IAQModule-Cn6xUy-6.d.mts → IAQModule-XZYlbivW.d.mts} +1 -1
- package/dist/chunk-5U2JSHSJ.mjs +22 -0
- package/dist/chunk-7ZCOFATU.mjs +42 -0
- package/dist/chunk-FWCSY2DS.mjs +37 -0
- package/dist/chunk-KWCUUD5Z.mjs +235 -0
- package/dist/chunk-PAHZ57DT.mjs +7634 -0
- package/dist/chunk-Y3YGC5IH.mjs +21 -0
- package/dist/chunk-Z6OQG54Q.mjs +39 -0
- package/dist/components/index.css +94 -0
- package/dist/components/index.mjs +143 -62
- package/dist/hooks/index.d.mts +1 -1
- package/dist/hooks/index.mjs +11 -2
- package/dist/modules-features/index.css +100 -0
- package/dist/modules-features/index.d.mts +1 -1
- package/dist/modules-features/index.mjs +4053 -79
- package/dist/stores/index.mjs +7 -1
- package/dist/utils/index.mjs +45 -9
- package/package.json +1 -1
@@ -0,0 +1,22 @@
|
|
1
|
+
// src/utils/utils_pdf.ts
|
2
|
+
import axios from "axios";
|
3
|
+
async function utils_pdf_download(url) {
|
4
|
+
try {
|
5
|
+
const response = await axios.get(url, {
|
6
|
+
responseType: "blob"
|
7
|
+
// Đảm bảo nhận dữ liệu dạng blob để tải file
|
8
|
+
});
|
9
|
+
const blob = new Blob([response.data], { type: "application/pdf" });
|
10
|
+
const link = document.createElement("a");
|
11
|
+
link.href = window.URL.createObjectURL(blob);
|
12
|
+
link.download = "file.pdf";
|
13
|
+
link.click();
|
14
|
+
window.URL.revokeObjectURL(link.href);
|
15
|
+
} catch (error) {
|
16
|
+
console.error("Error downloading PDF:", error);
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
export {
|
21
|
+
utils_pdf_download
|
22
|
+
};
|
@@ -0,0 +1,42 @@
|
|
1
|
+
// src/utils/utils_notification.ts
|
2
|
+
import { notifications } from "@mantine/notifications";
|
3
|
+
function utils_notification_show({ crudType = "create", message, color }) {
|
4
|
+
if (crudType == "create") {
|
5
|
+
notifications.show({
|
6
|
+
message: message ? message : "Th\xEAm th\xE0nh c\xF4ng!",
|
7
|
+
color: color ? color : "green"
|
8
|
+
});
|
9
|
+
return;
|
10
|
+
}
|
11
|
+
if (crudType == "update") {
|
12
|
+
notifications.show({
|
13
|
+
message: message ? message : "C\u1EADp nh\u1EADt th\xE0nh c\xF4ng!",
|
14
|
+
color: color ? color : "green"
|
15
|
+
});
|
16
|
+
return;
|
17
|
+
}
|
18
|
+
if (crudType == "delete") {
|
19
|
+
notifications.show({
|
20
|
+
message: message ? message : "X\xF3a th\xE0nh c\xF4ng!",
|
21
|
+
color: color ? color : "green"
|
22
|
+
});
|
23
|
+
return;
|
24
|
+
}
|
25
|
+
if (crudType == "error") {
|
26
|
+
notifications.show({
|
27
|
+
message: message ? message : "L\u1ED7i!",
|
28
|
+
color: color ? color : "red"
|
29
|
+
});
|
30
|
+
return;
|
31
|
+
}
|
32
|
+
if (crudType == "importSucess") {
|
33
|
+
notifications.show({
|
34
|
+
message: message ? message : "Import th\xE0nh c\xF4ng!"
|
35
|
+
});
|
36
|
+
return;
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
export {
|
41
|
+
utils_notification_show
|
42
|
+
};
|
@@ -0,0 +1,37 @@
|
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __defProps = Object.defineProperties;
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
8
|
+
var __spreadValues = (a, b) => {
|
9
|
+
for (var prop in b || (b = {}))
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
12
|
+
if (__getOwnPropSymbols)
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
14
|
+
if (__propIsEnum.call(b, prop))
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
16
|
+
}
|
17
|
+
return a;
|
18
|
+
};
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
20
|
+
var __objRest = (source, exclude) => {
|
21
|
+
var target = {};
|
22
|
+
for (var prop in source)
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
24
|
+
target[prop] = source[prop];
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
28
|
+
target[prop] = source[prop];
|
29
|
+
}
|
30
|
+
return target;
|
31
|
+
};
|
32
|
+
|
33
|
+
export {
|
34
|
+
__spreadValues,
|
35
|
+
__spreadProps,
|
36
|
+
__objRest
|
37
|
+
};
|
@@ -0,0 +1,235 @@
|
|
1
|
+
// src/utils/utils_converter.ts
|
2
|
+
var utils_converter_getLabelByValue = (data, value) => {
|
3
|
+
const numericValue = Number(value);
|
4
|
+
return data[numericValue] || "Kh\xF4ng x\xE1c \u0111\u1ECBnh";
|
5
|
+
};
|
6
|
+
var utils_converter_getKeyByValue = (obj, value) => {
|
7
|
+
var _a;
|
8
|
+
return (_a = Object.entries(obj).find(([_, v]) => v === value)) == null ? void 0 : _a[0];
|
9
|
+
};
|
10
|
+
function utils_converter_enumToSelectOptions(enumObject) {
|
11
|
+
const result = [];
|
12
|
+
const numericEnumKeys = Object.keys(enumObject).filter((key) => isNaN(Number(key)));
|
13
|
+
for (const key of numericEnumKeys) {
|
14
|
+
const enumValue = enumObject[key];
|
15
|
+
if (typeof enumValue === "number") {
|
16
|
+
result.push({
|
17
|
+
value: String(enumValue),
|
18
|
+
label: key
|
19
|
+
});
|
20
|
+
}
|
21
|
+
}
|
22
|
+
return result;
|
23
|
+
}
|
24
|
+
|
25
|
+
// src/utils/utils_currency.ts
|
26
|
+
function utils_currency_formatWithSuffix(amount, suffix = "") {
|
27
|
+
const formatter = new Intl.NumberFormat("vi-VN");
|
28
|
+
const formattedAmount = formatter.format(amount);
|
29
|
+
return `${formattedAmount}${suffix}`;
|
30
|
+
}
|
31
|
+
|
32
|
+
// src/utils/utils_date.ts
|
33
|
+
function U0DateToDDMMYYYString(date) {
|
34
|
+
if (!(date instanceof Date) || isNaN(date.getTime())) return "";
|
35
|
+
const day = String(date.getDate()).padStart(2, "0");
|
36
|
+
const month = String(date.getMonth() + 1).padStart(2, "0");
|
37
|
+
const year = date.getFullYear();
|
38
|
+
return `${day}/${month}/${year}`;
|
39
|
+
}
|
40
|
+
function utils_date_dateToDDMMYYYString(date) {
|
41
|
+
const day = String(date.getDate()).padStart(2, "0");
|
42
|
+
const month = String(date.getMonth() + 1).padStart(2, "0");
|
43
|
+
const year = date.getFullYear();
|
44
|
+
return `${day}/${month}/${year}`;
|
45
|
+
}
|
46
|
+
function utils_date_formatToDateTimeStartEnd(startDate, endDate) {
|
47
|
+
const startday = String(startDate.getDate()).padStart(2, "0");
|
48
|
+
const startmonth = String(startDate.getMonth() + 1).padStart(2, "0");
|
49
|
+
const startyear = startDate.getFullYear();
|
50
|
+
const starthour = String(startDate.getHours()).padStart(2, "0");
|
51
|
+
const startminute = String(startDate.getMinutes()).padStart(2, "0");
|
52
|
+
const endhour = String(endDate.getHours()).padStart(2, "0");
|
53
|
+
const endminuate = String(endDate.getMinutes()).padStart(2, "0");
|
54
|
+
return `${startday}/${startmonth}/${startyear} [${starthour}:${startminute} - ${endhour}:${endminuate}]`;
|
55
|
+
}
|
56
|
+
function utils_date_getHHmm(date) {
|
57
|
+
if (!(date instanceof Date) || isNaN(date.getTime())) return "";
|
58
|
+
const hour = String(date.getHours()).padStart(2, "0");
|
59
|
+
const minute = String(date.getMinutes()).padStart(2, "0");
|
60
|
+
return `${hour}:${minute}`;
|
61
|
+
}
|
62
|
+
|
63
|
+
// src/utils/utils_excel.ts
|
64
|
+
import saveAs from "file-saver";
|
65
|
+
function isObjectPath(path) {
|
66
|
+
return /^[a-zA-Z_$][a-zA-Z0-9_$]*(\.[a-zA-Z_$][a-zA-Z0-9_$]*)+$/.test(path);
|
67
|
+
}
|
68
|
+
function getValueByPath(obj, path) {
|
69
|
+
if (isObjectPath(path)) {
|
70
|
+
return path.split(".").reduce((acc, key) => acc == null ? void 0 : acc[key], obj);
|
71
|
+
}
|
72
|
+
return obj == null ? void 0 : obj[path];
|
73
|
+
}
|
74
|
+
async function utils_excel_exportExcel({
|
75
|
+
workbook,
|
76
|
+
sheetName,
|
77
|
+
data,
|
78
|
+
config
|
79
|
+
}) {
|
80
|
+
const sheet = workbook.addWorksheet(sheetName);
|
81
|
+
const fieldKeys = config.map((item) => String(item.fieldKey));
|
82
|
+
const headerMappings = {};
|
83
|
+
const markedColumns = [];
|
84
|
+
config.forEach((item) => {
|
85
|
+
const fieldKeyStr = String(item.fieldKey);
|
86
|
+
headerMappings[fieldKeyStr] = item.fieldName;
|
87
|
+
if (item.isRequired) markedColumns.push(fieldKeyStr);
|
88
|
+
});
|
89
|
+
sheet.columns = fieldKeys.map((fieldKey) => ({
|
90
|
+
key: fieldKey,
|
91
|
+
width: 20
|
92
|
+
}));
|
93
|
+
const displayRow = sheet.addRow(
|
94
|
+
fieldKeys.map(
|
95
|
+
(fieldKey) => markedColumns.includes(fieldKey) ? `${headerMappings[fieldKey]} *` : headerMappings[fieldKey] || fieldKey
|
96
|
+
)
|
97
|
+
);
|
98
|
+
const keyRow = sheet.addRow(fieldKeys);
|
99
|
+
data.forEach((item) => {
|
100
|
+
const rowData = {};
|
101
|
+
fieldKeys.forEach((fieldKey) => {
|
102
|
+
rowData[fieldKey] = getValueByPath(item, fieldKey);
|
103
|
+
});
|
104
|
+
sheet.addRow(rowData);
|
105
|
+
});
|
106
|
+
for (let i = 1; i <= fieldKeys.length; i++) {
|
107
|
+
const cell = displayRow.getCell(i);
|
108
|
+
cell.font = { bold: true };
|
109
|
+
cell.fill = {
|
110
|
+
type: "pattern",
|
111
|
+
pattern: "solid",
|
112
|
+
fgColor: { argb: "FFE0E0E0" }
|
113
|
+
};
|
114
|
+
}
|
115
|
+
for (let i = 1; i <= fieldKeys.length; i++) {
|
116
|
+
const cell = keyRow.getCell(i);
|
117
|
+
cell.font = { italic: true };
|
118
|
+
cell.fill = {
|
119
|
+
type: "pattern",
|
120
|
+
pattern: "solid",
|
121
|
+
fgColor: { argb: "FFF0F0F0" }
|
122
|
+
};
|
123
|
+
}
|
124
|
+
if (markedColumns.length > 0) {
|
125
|
+
for (let i = 1; i <= fieldKeys.length; i++) {
|
126
|
+
const cell = displayRow.getCell(i);
|
127
|
+
const text = cell.value;
|
128
|
+
if (typeof text === "string" && text.endsWith(" *")) {
|
129
|
+
cell.value = {
|
130
|
+
richText: [
|
131
|
+
{
|
132
|
+
text: text.slice(0, -2),
|
133
|
+
font: { bold: true }
|
134
|
+
},
|
135
|
+
{
|
136
|
+
text: " *",
|
137
|
+
font: { bold: true, color: { argb: "FFFF0000" } }
|
138
|
+
}
|
139
|
+
]
|
140
|
+
};
|
141
|
+
}
|
142
|
+
}
|
143
|
+
}
|
144
|
+
return workbook;
|
145
|
+
}
|
146
|
+
async function utils_excel_download({
|
147
|
+
workbook,
|
148
|
+
name
|
149
|
+
}) {
|
150
|
+
const buffer = await workbook.xlsx.writeBuffer();
|
151
|
+
const blob = new Blob([buffer], {
|
152
|
+
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
153
|
+
});
|
154
|
+
saveAs(blob, name);
|
155
|
+
}
|
156
|
+
|
157
|
+
// src/utils/utils_file.ts
|
158
|
+
import Docxtemplater from "docxtemplater";
|
159
|
+
import { saveAs as saveAs2 } from "file-saver";
|
160
|
+
import PizZip from "pizzip";
|
161
|
+
function utils_file_fileToAQDocumentType(file) {
|
162
|
+
return new Promise((resolve, reject) => {
|
163
|
+
const fileReader = new FileReader();
|
164
|
+
fileReader.onloadend = () => {
|
165
|
+
const fileName = file.name;
|
166
|
+
const fileExtension = file.name.split(".").pop();
|
167
|
+
const fileBase64String = fileReader.result;
|
168
|
+
resolve({
|
169
|
+
fileName,
|
170
|
+
fileExtension,
|
171
|
+
fileBase64String: fileBase64String.split(",")[1]
|
172
|
+
// Chỉ lấy phần base64 sau dấu phẩy
|
173
|
+
});
|
174
|
+
};
|
175
|
+
fileReader.onerror = reject;
|
176
|
+
fileReader.readAsDataURL(file);
|
177
|
+
});
|
178
|
+
}
|
179
|
+
async function utils_file_docxtemplaterDownload({
|
180
|
+
data,
|
181
|
+
filePath,
|
182
|
+
fileName
|
183
|
+
}) {
|
184
|
+
const response = await fetch(filePath);
|
185
|
+
const arrayBuffer = await response.arrayBuffer();
|
186
|
+
const zip = new PizZip(arrayBuffer);
|
187
|
+
const doc = new Docxtemplater(zip);
|
188
|
+
doc.render(data);
|
189
|
+
const buffer = doc.getZip().generate({ type: "blob" });
|
190
|
+
saveAs2(buffer, fileName || "output.docx");
|
191
|
+
}
|
192
|
+
|
193
|
+
// src/utils/utils_time.ts
|
194
|
+
var utils_time_convertTimeStringToSeconds = (time) => {
|
195
|
+
const [hours, minutes, seconds] = time.split(":").map(Number);
|
196
|
+
return hours * 3600 + minutes * 60 + seconds;
|
197
|
+
};
|
198
|
+
var utils_time_getCurrentTimeString = () => {
|
199
|
+
const formatTime = (number) => {
|
200
|
+
return number < 10 ? "0" + number : number;
|
201
|
+
};
|
202
|
+
const now = /* @__PURE__ */ new Date();
|
203
|
+
const hours = formatTime(now.getHours());
|
204
|
+
const minutes = formatTime(now.getMinutes());
|
205
|
+
const seconds = formatTime(now.getSeconds());
|
206
|
+
return `${hours}:${minutes}:${seconds}`;
|
207
|
+
};
|
208
|
+
|
209
|
+
// src/utils/utils_validateForm.ts
|
210
|
+
import { isNotEmpty } from "@mantine/form";
|
211
|
+
function U0MyValidateEmpty(message) {
|
212
|
+
return isNotEmpty(message ? message : "Kh\xF4ng \u0111\u01B0\u1EE3c \u0111\u1EC3 tr\u1ED1ng");
|
213
|
+
}
|
214
|
+
function U0MyValidateEmail(value) {
|
215
|
+
return /^\S+@\S+$/.test(value) ? null : "Email kh\xF4ng \u0111\xFAng \u0111\u1ECBnh d\u1EA1ng";
|
216
|
+
}
|
217
|
+
|
218
|
+
export {
|
219
|
+
U0DateToDDMMYYYString,
|
220
|
+
utils_date_dateToDDMMYYYString,
|
221
|
+
utils_date_formatToDateTimeStartEnd,
|
222
|
+
utils_date_getHHmm,
|
223
|
+
utils_file_fileToAQDocumentType,
|
224
|
+
utils_file_docxtemplaterDownload,
|
225
|
+
utils_converter_getLabelByValue,
|
226
|
+
utils_converter_getKeyByValue,
|
227
|
+
utils_converter_enumToSelectOptions,
|
228
|
+
utils_currency_formatWithSuffix,
|
229
|
+
utils_excel_exportExcel,
|
230
|
+
utils_excel_download,
|
231
|
+
utils_time_convertTimeStringToSeconds,
|
232
|
+
utils_time_getCurrentTimeString,
|
233
|
+
U0MyValidateEmpty,
|
234
|
+
U0MyValidateEmail
|
235
|
+
};
|