aq-fe-framework 0.1.40 → 0.1.41
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/chunk-2MRECBKN.mjs +206 -0
- package/dist/{chunk-D3WAMOI2.mjs → chunk-7C3TEWTW.mjs} +727 -1100
- package/dist/components/index.d.mts +57 -57
- package/dist/components/index.mjs +1 -1
- package/dist/modules-features/admin/core/index.d.mts +51 -50
- package/dist/modules-features/admin/core/index.mjs +441 -835
- package/dist/utils/index.d.mts +1 -5
- package/dist/utils/index.mjs +9 -138
- package/package.json +1 -1
- package/dist/chunk-GHGYRQUR.mjs +0 -67
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
// src/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/date.ts
|
|
26
|
+
function U0DateToDDMMYYYString(date) {
|
|
27
|
+
const day = String(date.getDate()).padStart(2, "0");
|
|
28
|
+
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
29
|
+
const year = date.getFullYear();
|
|
30
|
+
return `${day}/${month}/${year}`;
|
|
31
|
+
}
|
|
32
|
+
function utils_date_dateToDDMMYYYString(date) {
|
|
33
|
+
const day = String(date.getDate()).padStart(2, "0");
|
|
34
|
+
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
35
|
+
const year = date.getFullYear();
|
|
36
|
+
return `${day}/${month}/${year}`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// src/utils/excel.ts
|
|
40
|
+
import saveAs from "file-saver";
|
|
41
|
+
async function utils_excel_exportExcel({
|
|
42
|
+
workbook,
|
|
43
|
+
sheetName,
|
|
44
|
+
data,
|
|
45
|
+
config
|
|
46
|
+
}) {
|
|
47
|
+
const sheet = workbook.addWorksheet(sheetName);
|
|
48
|
+
const fieldNames = config.map((item) => String(item.fieldKey));
|
|
49
|
+
const headerMappings = {};
|
|
50
|
+
const markedColumns = [];
|
|
51
|
+
config.forEach((item) => {
|
|
52
|
+
const fieldKeyStr = String(item.fieldKey);
|
|
53
|
+
headerMappings[fieldKeyStr] = item.fieldName;
|
|
54
|
+
if (item.isRequired) {
|
|
55
|
+
markedColumns.push(fieldKeyStr);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
const columns = fieldNames.map((fieldName) => {
|
|
59
|
+
return {
|
|
60
|
+
key: fieldName,
|
|
61
|
+
width: 20
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
sheet.columns = columns;
|
|
65
|
+
const displayRow = sheet.addRow(
|
|
66
|
+
fieldNames.map((fieldName) => {
|
|
67
|
+
const displayName = headerMappings[fieldName] || fieldName;
|
|
68
|
+
return markedColumns.includes(fieldName) ? `${displayName} *` : displayName;
|
|
69
|
+
})
|
|
70
|
+
);
|
|
71
|
+
const keyRow = sheet.addRow(fieldNames);
|
|
72
|
+
data.forEach((item) => {
|
|
73
|
+
const rowData = {};
|
|
74
|
+
fieldNames.forEach((field) => {
|
|
75
|
+
rowData[field] = item[field];
|
|
76
|
+
});
|
|
77
|
+
sheet.addRow(rowData);
|
|
78
|
+
});
|
|
79
|
+
for (let i = 1; i <= fieldNames.length; i++) {
|
|
80
|
+
const cell = displayRow.getCell(i);
|
|
81
|
+
cell.font = { bold: true };
|
|
82
|
+
cell.fill = {
|
|
83
|
+
type: "pattern",
|
|
84
|
+
pattern: "solid",
|
|
85
|
+
fgColor: { argb: "FFE0E0E0" }
|
|
86
|
+
// Light gray background
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
for (let i = 1; i <= fieldNames.length; i++) {
|
|
90
|
+
const cell = keyRow.getCell(i);
|
|
91
|
+
cell.font = { italic: true };
|
|
92
|
+
cell.fill = {
|
|
93
|
+
type: "pattern",
|
|
94
|
+
pattern: "solid",
|
|
95
|
+
fgColor: { argb: "FFF0F0F0" }
|
|
96
|
+
// Lighter gray background
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
if (markedColumns.length > 0) {
|
|
100
|
+
for (let i = 1; i <= fieldNames.length; i++) {
|
|
101
|
+
const cell = displayRow.getCell(i);
|
|
102
|
+
const text = cell.value;
|
|
103
|
+
if (typeof text === "string" && text.endsWith(" *")) {
|
|
104
|
+
cell.value = {
|
|
105
|
+
richText: [
|
|
106
|
+
{
|
|
107
|
+
text: text.substring(0, text.length - 2),
|
|
108
|
+
font: { bold: true }
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
text: " *",
|
|
112
|
+
font: { bold: true, color: { argb: "FFFF0000" } }
|
|
113
|
+
// Red color
|
|
114
|
+
}
|
|
115
|
+
]
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return workbook;
|
|
121
|
+
}
|
|
122
|
+
async function utils_excel_download({
|
|
123
|
+
workbook,
|
|
124
|
+
name
|
|
125
|
+
}) {
|
|
126
|
+
const buffer = await workbook.xlsx.writeBuffer();
|
|
127
|
+
const blob = new Blob([buffer], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" });
|
|
128
|
+
saveAs(blob, name);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// src/utils/file.ts
|
|
132
|
+
import Docxtemplater from "docxtemplater";
|
|
133
|
+
import { saveAs as saveAs2 } from "file-saver";
|
|
134
|
+
import PizZip from "pizzip";
|
|
135
|
+
function utils_file_fileToAQDocumentType(file) {
|
|
136
|
+
return new Promise((resolve, reject) => {
|
|
137
|
+
const fileReader = new FileReader();
|
|
138
|
+
fileReader.onloadend = () => {
|
|
139
|
+
const fileName = file.name;
|
|
140
|
+
const fileExtension = file.name.split(".").pop();
|
|
141
|
+
const fileBase64String = fileReader.result;
|
|
142
|
+
resolve({
|
|
143
|
+
fileName,
|
|
144
|
+
fileExtension,
|
|
145
|
+
fileBase64String: fileBase64String.split(",")[1]
|
|
146
|
+
// Chỉ lấy phần base64 sau dấu phẩy
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
fileReader.onerror = reject;
|
|
150
|
+
fileReader.readAsDataURL(file);
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
async function utils_file_docxtemplaterDownload({
|
|
154
|
+
data,
|
|
155
|
+
filePath,
|
|
156
|
+
fileName
|
|
157
|
+
}) {
|
|
158
|
+
const response = await fetch(filePath);
|
|
159
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
160
|
+
const zip = new PizZip(arrayBuffer);
|
|
161
|
+
const doc = new Docxtemplater(zip);
|
|
162
|
+
doc.render(data);
|
|
163
|
+
const buffer = doc.getZip().generate({ type: "blob" });
|
|
164
|
+
saveAs2(buffer, fileName || "output.docx");
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// src/utils/time.ts
|
|
168
|
+
var utils_time_convertTimeStringToSeconds = (time) => {
|
|
169
|
+
const [hours, minutes, seconds] = time.split(":").map(Number);
|
|
170
|
+
return hours * 3600 + minutes * 60 + seconds;
|
|
171
|
+
};
|
|
172
|
+
var utils_time_getCurrentTimeString = () => {
|
|
173
|
+
const formatTime = (number) => {
|
|
174
|
+
return number < 10 ? "0" + number : number;
|
|
175
|
+
};
|
|
176
|
+
const now = /* @__PURE__ */ new Date();
|
|
177
|
+
const hours = formatTime(now.getHours());
|
|
178
|
+
const minutes = formatTime(now.getMinutes());
|
|
179
|
+
const seconds = formatTime(now.getSeconds());
|
|
180
|
+
return `${hours}:${minutes}:${seconds}`;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
// src/utils/validateForm.ts
|
|
184
|
+
import { isNotEmpty } from "@mantine/form";
|
|
185
|
+
function U0MyValidateEmpty(message) {
|
|
186
|
+
return isNotEmpty(message ? message : "Kh\xF4ng \u0111\u01B0\u1EE3c \u0111\u1EC3 tr\u1ED1ng");
|
|
187
|
+
}
|
|
188
|
+
function U0MyValidateEmail(value) {
|
|
189
|
+
return /^\S+@\S+$/.test(value) ? null : "Email kh\xF4ng \u0111\xFAng \u0111\u1ECBnh d\u1EA1ng";
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export {
|
|
193
|
+
utils_converter_getLabelByValue,
|
|
194
|
+
utils_converter_getKeyByValue,
|
|
195
|
+
utils_converter_enumToSelectOptions,
|
|
196
|
+
U0DateToDDMMYYYString,
|
|
197
|
+
utils_date_dateToDDMMYYYString,
|
|
198
|
+
utils_excel_exportExcel,
|
|
199
|
+
utils_excel_download,
|
|
200
|
+
utils_file_fileToAQDocumentType,
|
|
201
|
+
utils_file_docxtemplaterDownload,
|
|
202
|
+
utils_time_convertTimeStringToSeconds,
|
|
203
|
+
utils_time_getCurrentTimeString,
|
|
204
|
+
U0MyValidateEmpty,
|
|
205
|
+
U0MyValidateEmail
|
|
206
|
+
};
|