@ramathibodi/nuxt-commons 0.1.74 → 4.0.1
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/README.md +9 -2
- package/dist/module.json +4 -4
- package/dist/module.mjs +4 -4
- package/dist/runtime/bridges/authentication.d.ts +21 -0
- package/dist/runtime/bridges/authentication.js +20 -0
- package/dist/runtime/bridges/graphql.d.ts +17 -0
- package/dist/runtime/bridges/graphql.js +45 -0
- package/dist/runtime/components/Alert.d.vue.ts +3 -0
- package/dist/runtime/components/Alert.vue +17 -26
- package/dist/runtime/components/Alert.vue.d.ts +3 -0
- package/dist/runtime/components/BarcodeReader.d.vue.ts +9 -0
- package/dist/runtime/components/BarcodeReader.vue +56 -81
- package/dist/runtime/components/BarcodeReader.vue.d.ts +9 -0
- package/dist/runtime/components/ExportCSV.d.vue.ts +55 -0
- package/dist/runtime/components/ExportCSV.vue +39 -76
- package/dist/runtime/components/ExportCSV.vue.d.ts +55 -0
- package/dist/runtime/components/FileBtn.d.vue.ts +53 -0
- package/dist/runtime/components/FileBtn.vue +23 -50
- package/dist/runtime/components/FileBtn.vue.d.ts +53 -0
- package/dist/runtime/components/ImportCSV.d.vue.ts +52 -0
- package/dist/runtime/components/ImportCSV.vue +60 -111
- package/dist/runtime/components/ImportCSV.vue.d.ts +52 -0
- package/dist/runtime/components/MrzReader.d.vue.ts +19 -0
- package/dist/runtime/components/MrzReader.vue +69 -109
- package/dist/runtime/components/MrzReader.vue.d.ts +19 -0
- package/dist/runtime/components/SplitterPanel.d.vue.ts +15 -0
- package/dist/runtime/components/SplitterPanel.vue +18 -35
- package/dist/runtime/components/SplitterPanel.vue.d.ts +15 -0
- package/dist/runtime/components/TabsGroup.d.vue.ts +19 -0
- package/dist/runtime/components/TabsGroup.vue +8 -20
- package/dist/runtime/components/TabsGroup.vue.d.ts +19 -0
- package/dist/runtime/components/TextBarcode.d.vue.ts +12 -0
- package/dist/runtime/components/TextBarcode.vue +22 -45
- package/dist/runtime/components/TextBarcode.vue.d.ts +12 -0
- package/dist/runtime/components/device/IdCardButton.d.vue.ts +57 -0
- package/dist/runtime/components/device/IdCardButton.vue +30 -67
- package/dist/runtime/components/device/IdCardButton.vue.d.ts +57 -0
- package/dist/runtime/components/device/IdCardWebSocket.d.vue.ts +55 -0
- package/dist/runtime/components/device/IdCardWebSocket.vue +104 -165
- package/dist/runtime/components/device/IdCardWebSocket.vue.d.ts +55 -0
- package/dist/runtime/components/device/Scanner.d.vue.ts +66 -0
- package/dist/runtime/components/device/Scanner.vue +97 -178
- package/dist/runtime/components/device/Scanner.vue.d.ts +66 -0
- package/dist/runtime/components/dialog/Confirm.d.vue.ts +37 -0
- package/dist/runtime/components/dialog/Confirm.vue +30 -59
- package/dist/runtime/components/dialog/Confirm.vue.d.ts +37 -0
- package/dist/runtime/components/dialog/Host.d.vue.ts +9 -0
- package/dist/runtime/components/dialog/Host.vue +34 -57
- package/dist/runtime/components/dialog/Host.vue.d.ts +9 -0
- package/dist/runtime/components/dialog/Index.d.vue.ts +24 -0
- package/dist/runtime/components/dialog/Index.vue +20 -40
- package/dist/runtime/components/dialog/Index.vue.d.ts +24 -0
- package/dist/runtime/components/dialog/Loading.d.vue.ts +21 -0
- package/dist/runtime/components/dialog/Loading.vue +12 -29
- package/dist/runtime/components/dialog/Loading.vue.d.ts +21 -0
- package/dist/runtime/components/dialog/default/Confirm.d.vue.ts +40 -0
- package/dist/runtime/components/dialog/default/Confirm.vue +29 -62
- package/dist/runtime/components/dialog/default/Confirm.vue.d.ts +40 -0
- package/dist/runtime/components/dialog/default/Loading.d.vue.ts +23 -0
- package/dist/runtime/components/dialog/default/Loading.vue +12 -29
- package/dist/runtime/components/dialog/default/Loading.vue.d.ts +23 -0
- package/dist/runtime/components/dialog/default/Notify.d.vue.ts +23 -0
- package/dist/runtime/components/dialog/default/Notify.vue +19 -48
- package/dist/runtime/components/dialog/default/Notify.vue.d.ts +23 -0
- package/dist/runtime/components/dialog/default/Printing.d.vue.ts +21 -0
- package/dist/runtime/components/dialog/default/Printing.vue +13 -29
- package/dist/runtime/components/dialog/default/Printing.vue.d.ts +21 -0
- package/dist/runtime/components/dialog/default/VerifyUser.d.vue.ts +29 -0
- package/dist/runtime/components/dialog/default/VerifyUser.vue +44 -82
- package/dist/runtime/components/dialog/default/VerifyUser.vue.d.ts +29 -0
- package/dist/runtime/components/document/Form.d.vue.ts +9 -0
- package/dist/runtime/components/document/Form.vue +27 -42
- package/dist/runtime/components/document/Form.vue.d.ts +9 -0
- package/dist/runtime/components/document/TemplateBuilder.d.vue.ts +24 -0
- package/dist/runtime/components/document/TemplateBuilder.vue +154 -194
- package/dist/runtime/components/document/TemplateBuilder.vue.d.ts +24 -0
- package/dist/runtime/components/form/ActionPad.d.vue.ts +114 -0
- package/dist/runtime/components/form/ActionPad.vue +48 -85
- package/dist/runtime/components/form/ActionPad.vue.d.ts +114 -0
- package/dist/runtime/components/form/Birthdate.d.vue.ts +38 -0
- package/dist/runtime/components/form/Birthdate.vue +44 -76
- package/dist/runtime/components/form/Birthdate.vue.d.ts +38 -0
- package/dist/runtime/components/form/CheckboxGroup.d.vue.ts +41 -0
- package/dist/runtime/components/form/CheckboxGroup.vue +34 -64
- package/dist/runtime/components/form/CheckboxGroup.vue.d.ts +41 -0
- package/dist/runtime/components/form/CodeEditor.d.vue.ts +25 -0
- package/dist/runtime/components/form/CodeEditor.vue +18 -36
- package/dist/runtime/components/form/CodeEditor.vue.d.ts +25 -0
- package/dist/runtime/components/form/Date.d.vue.ts +86 -0
- package/dist/runtime/components/form/Date.vue +109 -162
- package/dist/runtime/components/form/Date.vue.d.ts +86 -0
- package/dist/runtime/components/form/DateTime.d.vue.ts +36 -0
- package/dist/runtime/components/form/DateTime.vue +94 -143
- package/dist/runtime/components/form/DateTime.vue.d.ts +36 -0
- package/dist/runtime/components/form/Dialog.d.vue.ts +69 -0
- package/dist/runtime/components/form/Dialog.vue +60 -96
- package/dist/runtime/components/form/Dialog.vue.d.ts +69 -0
- package/dist/runtime/components/form/EditPad.d.vue.ts +113 -0
- package/dist/runtime/components/form/EditPad.vue +49 -85
- package/dist/runtime/components/form/EditPad.vue.d.ts +113 -0
- package/dist/runtime/components/form/File.d.vue.ts +65 -0
- package/dist/runtime/components/form/File.vue +112 -186
- package/dist/runtime/components/form/File.vue.d.ts +65 -0
- package/dist/runtime/components/form/Hidden.d.vue.ts +12 -0
- package/dist/runtime/components/form/Hidden.vue +17 -34
- package/dist/runtime/components/form/Hidden.vue.d.ts +12 -0
- package/dist/runtime/components/form/Iterator.d.vue.ts +279 -0
- package/dist/runtime/components/form/Iterator.vue +162 -252
- package/dist/runtime/components/form/Iterator.vue.d.ts +279 -0
- package/dist/runtime/components/form/Login.d.vue.ts +32 -0
- package/dist/runtime/components/form/Login.vue +23 -55
- package/dist/runtime/components/form/Login.vue.d.ts +32 -0
- package/dist/runtime/components/form/Pad.d.vue.ts +674 -0
- package/dist/runtime/components/form/Pad.vue +166 -265
- package/dist/runtime/components/form/Pad.vue.d.ts +674 -0
- package/dist/runtime/components/form/SignPad.d.vue.ts +62 -0
- package/dist/runtime/components/form/SignPad.vue +80 -126
- package/dist/runtime/components/form/SignPad.vue.d.ts +62 -0
- package/dist/runtime/components/form/System.d.vue.ts +34 -0
- package/dist/runtime/components/form/System.vue +18 -32
- package/dist/runtime/components/form/System.vue.d.ts +34 -0
- package/dist/runtime/components/form/Table.d.vue.ts +221 -0
- package/dist/runtime/components/form/Table.vue +123 -182
- package/dist/runtime/components/form/Table.vue.d.ts +221 -0
- package/dist/runtime/components/form/TableData.d.vue.ts +102 -0
- package/dist/runtime/components/form/TableData.vue +109 -139
- package/dist/runtime/components/form/TableData.vue.d.ts +102 -0
- package/dist/runtime/components/form/Time.d.vue.ts +49 -0
- package/dist/runtime/components/form/Time.vue +64 -99
- package/dist/runtime/components/form/Time.vue.d.ts +49 -0
- package/dist/runtime/components/form/images/Capture.d.vue.ts +96 -0
- package/dist/runtime/components/form/images/Capture.vue +104 -147
- package/dist/runtime/components/form/images/Capture.vue.d.ts +96 -0
- package/dist/runtime/components/form/images/Edit.d.vue.ts +29 -0
- package/dist/runtime/components/form/images/Edit.vue +57 -81
- package/dist/runtime/components/form/images/Edit.vue.d.ts +29 -0
- package/dist/runtime/components/form/images/Field.d.vue.ts +27 -0
- package/dist/runtime/components/form/images/Field.vue +136 -205
- package/dist/runtime/components/form/images/Field.vue.d.ts +27 -0
- package/dist/runtime/components/form/images/Pad.d.vue.ts +13 -0
- package/dist/runtime/components/form/images/Pad.vue +23 -40
- package/dist/runtime/components/form/images/Pad.vue.d.ts +13 -0
- package/dist/runtime/components/label/Date.d.vue.ts +13 -0
- package/dist/runtime/components/label/Date.vue +13 -29
- package/dist/runtime/components/label/Date.vue.d.ts +13 -0
- package/dist/runtime/components/label/DateAgo.d.vue.ts +20 -0
- package/dist/runtime/components/label/DateAgo.vue +43 -75
- package/dist/runtime/components/label/DateAgo.vue.d.ts +20 -0
- package/dist/runtime/components/label/DateCount.d.vue.ts +22 -0
- package/dist/runtime/components/label/DateCount.vue +58 -105
- package/dist/runtime/components/label/DateCount.vue.d.ts +22 -0
- package/dist/runtime/components/label/Field.d.vue.ts +38 -0
- package/dist/runtime/components/label/Field.vue +18 -40
- package/dist/runtime/components/label/Field.vue.d.ts +38 -0
- package/dist/runtime/components/label/FormatMoney.d.vue.ts +12 -0
- package/dist/runtime/components/label/FormatMoney.vue +12 -28
- package/dist/runtime/components/label/FormatMoney.vue.d.ts +12 -0
- package/dist/runtime/components/label/Mask.d.vue.ts +10 -0
- package/dist/runtime/components/label/Mask.vue +21 -38
- package/dist/runtime/components/label/Mask.vue.d.ts +10 -0
- package/dist/runtime/components/label/Object.d.vue.ts +8 -0
- package/dist/runtime/components/label/Object.vue +10 -20
- package/dist/runtime/components/label/Object.vue.d.ts +8 -0
- package/dist/runtime/components/master/Autocomplete.d.vue.ts +70 -0
- package/dist/runtime/components/master/Autocomplete.vue +25 -34
- package/dist/runtime/components/master/Autocomplete.vue.d.ts +70 -0
- package/dist/runtime/components/master/Combobox.d.vue.ts +70 -0
- package/dist/runtime/components/master/Combobox.vue +26 -35
- package/dist/runtime/components/master/Combobox.vue.d.ts +70 -0
- package/dist/runtime/components/master/RadioGroup.d.vue.ts +51 -0
- package/dist/runtime/components/master/RadioGroup.vue +44 -59
- package/dist/runtime/components/master/RadioGroup.vue.d.ts +51 -0
- package/dist/runtime/components/master/Select.d.vue.ts +68 -0
- package/dist/runtime/components/master/Select.vue +25 -34
- package/dist/runtime/components/master/Select.vue.d.ts +68 -0
- package/dist/runtime/components/master/label.d.vue.ts +24 -0
- package/dist/runtime/components/master/label.vue +22 -42
- package/dist/runtime/components/master/label.vue.d.ts +24 -0
- package/dist/runtime/components/model/Autocomplete.d.vue.ts +82 -0
- package/dist/runtime/components/model/Autocomplete.vue +50 -49
- package/dist/runtime/components/model/Autocomplete.vue.d.ts +82 -0
- package/dist/runtime/components/model/Combobox.d.vue.ts +82 -0
- package/dist/runtime/components/model/Combobox.vue +51 -49
- package/dist/runtime/components/model/Combobox.vue.d.ts +82 -0
- package/dist/runtime/components/model/Pad.d.vue.ts +72 -0
- package/dist/runtime/components/model/Pad.vue +50 -65
- package/dist/runtime/components/model/Pad.vue.d.ts +72 -0
- package/dist/runtime/components/model/Select.d.vue.ts +72 -0
- package/dist/runtime/components/model/Select.vue +42 -44
- package/dist/runtime/components/model/Select.vue.d.ts +72 -0
- package/dist/runtime/components/model/Table.d.vue.ts +272 -0
- package/dist/runtime/components/model/Table.vue +121 -145
- package/dist/runtime/components/model/Table.vue.d.ts +272 -0
- package/dist/runtime/components/model/iterator.d.vue.ts +321 -0
- package/dist/runtime/components/model/iterator.vue +148 -183
- package/dist/runtime/components/model/iterator.vue.d.ts +321 -0
- package/dist/runtime/components/model/label.d.vue.ts +26 -0
- package/dist/runtime/components/model/label.vue +25 -43
- package/dist/runtime/components/model/label.vue.d.ts +26 -0
- package/dist/runtime/components/pdf/Print.d.vue.ts +17 -0
- package/dist/runtime/components/pdf/Print.vue +27 -50
- package/dist/runtime/components/pdf/Print.vue.d.ts +17 -0
- package/dist/runtime/components/pdf/View.d.vue.ts +52 -0
- package/dist/runtime/components/pdf/View.vue +58 -95
- package/dist/runtime/components/pdf/View.vue.d.ts +52 -0
- package/dist/runtime/composables/api.js +4 -2
- package/dist/runtime/composables/assetFile.js +4 -2
- package/dist/runtime/composables/dialog.d.ts +1 -1
- package/dist/runtime/composables/document/template.js +3 -3
- package/dist/runtime/composables/document/templateFormTable.js +1 -0
- package/dist/runtime/composables/graphql.d.ts +2 -2
- package/dist/runtime/composables/graphql.js +5 -5
- package/dist/runtime/composables/graphqlModel.d.ts +6 -6
- package/dist/runtime/composables/graphqlModelItem.d.ts +4 -4
- package/dist/runtime/composables/graphqlModelOperation.d.ts +6 -6
- package/dist/runtime/composables/graphqlModelOperation.js +2 -1
- package/dist/runtime/composables/graphqlOperation.js +5 -1
- package/dist/runtime/composables/hostAgentWs.d.ts +1 -1
- package/dist/runtime/composables/lookupListMaster.js +3 -3
- package/dist/runtime/composables/menu.js +2 -2
- package/dist/runtime/composables/userPermission.d.ts +1 -1
- package/dist/runtime/composables/utils/fuzzy.d.ts +2 -1
- package/dist/runtime/labs/Calendar.d.vue.ts +35 -0
- package/dist/runtime/labs/Calendar.vue +47 -75
- package/dist/runtime/labs/Calendar.vue.d.ts +35 -0
- package/dist/runtime/labs/form/EditMobile.d.vue.ts +12 -0
- package/dist/runtime/labs/form/EditMobile.vue +19 -36
- package/dist/runtime/labs/form/EditMobile.vue.d.ts +12 -0
- package/dist/runtime/labs/form/TextFieldMask.d.vue.ts +21 -0
- package/dist/runtime/labs/form/TextFieldMask.vue +19 -25
- package/dist/runtime/labs/form/TextFieldMask.vue.d.ts +21 -0
- package/dist/runtime/plugins/dialogManager.js +2 -2
- package/dist/runtime/plugins/permission.js +3 -3
- package/dist/runtime/types/bridge.d.ts +14 -0
- package/dist/runtime/utils/datetime.js +1 -1
- package/dist/types.d.mts +2 -6
- package/package.json +71 -59
- package/scripts/ci-release.mjs +125 -0
- package/scripts/release-version.mjs +68 -0
- package/scripts/release.mjs +49 -0
- package/dist/module.cjs +0 -5
- package/dist/module.d.ts +0 -8
- package/dist/types.d.ts +0 -7
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @ramathibodi/nuxt-commons
|
|
2
2
|
|
|
3
|
-
Nuxt 3
|
|
3
|
+
Nuxt module for Nuxt 3 and Nuxt 4 that provides shared runtime building blocks for Rama projects:
|
|
4
4
|
- globally auto-imported UI components
|
|
5
5
|
- auto-imported composables
|
|
6
6
|
- runtime plugins for permission/dialog/default behavior
|
|
@@ -28,6 +28,8 @@ export default defineNuxtConfig({
|
|
|
28
28
|
})
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
+
Supported Nuxt versions: `^3.16.0 || ^4.0.0`
|
|
32
|
+
|
|
31
33
|
## What The Module Registers
|
|
32
34
|
|
|
33
35
|
Configured in `src/module.ts`:
|
|
@@ -109,7 +111,12 @@ Generated outputs:
|
|
|
109
111
|
|
|
110
112
|
## Publish Notes
|
|
111
113
|
|
|
114
|
+
`package.json` `version` is used to select the publish line by `major.minor`:
|
|
115
|
+
|
|
116
|
+
- Keep the same `major.minor` line to continue normal releases.
|
|
117
|
+
- Change it to `0.2.0`, `1.1.0`, etc. to start publishing that new line on the next release.
|
|
118
|
+
|
|
112
119
|
```bash
|
|
113
120
|
npm run dev:build
|
|
114
|
-
npm
|
|
121
|
+
npm run release
|
|
115
122
|
```
|
package/dist/module.json
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
"name": "@ramathibodi/nuxt-commons",
|
|
3
3
|
"configKey": "nuxt-commons",
|
|
4
4
|
"compatibility": {
|
|
5
|
-
"nuxt": "^3.
|
|
5
|
+
"nuxt": "^4.3.1"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.1
|
|
7
|
+
"version": "4.0.1",
|
|
8
8
|
"builder": {
|
|
9
|
-
"@nuxt/module-builder": "0.
|
|
10
|
-
"unbuild": "
|
|
9
|
+
"@nuxt/module-builder": "1.0.2",
|
|
10
|
+
"unbuild": "3.6.1"
|
|
11
11
|
}
|
|
12
12
|
}
|
package/dist/module.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { defineNuxtModule, createResolver, addComponentsDir, addImportsDir, addPlugin, addTypeTemplate } from '@nuxt/kit';
|
|
2
2
|
|
|
3
|
-
const module = defineNuxtModule({
|
|
3
|
+
const module$1 = defineNuxtModule({
|
|
4
4
|
meta: {
|
|
5
5
|
name: "@ramathibodi/nuxt-commons",
|
|
6
6
|
configKey: "nuxt-commons",
|
|
7
7
|
compatibility: {
|
|
8
|
-
nuxt: "^3.
|
|
8
|
+
nuxt: "^4.3.1"
|
|
9
9
|
}
|
|
10
10
|
},
|
|
11
11
|
// Default configuration options of the Nuxt module
|
|
@@ -36,7 +36,7 @@ const module = defineNuxtModule({
|
|
|
36
36
|
src: resolver.resolve("runtime/plugins/default"),
|
|
37
37
|
mode: "client"
|
|
38
38
|
});
|
|
39
|
-
const typeFiles = ["modules", "alert", "menu", "graphqlOperation", "formDialog", "dialogManager", "permission", "clientConfig"];
|
|
39
|
+
const typeFiles = ["modules", "alert", "menu", "graphqlOperation", "formDialog", "dialogManager", "permission", "clientConfig", "bridge"];
|
|
40
40
|
for (const file of typeFiles) {
|
|
41
41
|
addTypeTemplate({
|
|
42
42
|
src: resolver.resolve(`runtime/types/${file}.d.ts`),
|
|
@@ -58,4 +58,4 @@ const module = defineNuxtModule({
|
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
60
|
|
|
61
|
-
export { module as default };
|
|
61
|
+
export { module$1 as default };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface AuthenticationUserProfile {
|
|
2
|
+
username?: string;
|
|
3
|
+
[key: string]: any;
|
|
4
|
+
}
|
|
5
|
+
export interface AuthenticationKeycloakState {
|
|
6
|
+
token?: string;
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
}
|
|
9
|
+
export interface AuthenticationState {
|
|
10
|
+
isAuthenticated?: boolean;
|
|
11
|
+
token?: string;
|
|
12
|
+
keycloak?: AuthenticationKeycloakState | null;
|
|
13
|
+
userProfile?: AuthenticationUserProfile | null;
|
|
14
|
+
permissions?: string[];
|
|
15
|
+
hasPermission?: (permissionId: string) => boolean;
|
|
16
|
+
login?: (...args: any[]) => any;
|
|
17
|
+
logout?: (...args: any[]) => any;
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
}
|
|
20
|
+
export type AuthenticationBridgeInput = AuthenticationState | (() => AuthenticationState);
|
|
21
|
+
export declare function useAuthentication(): AuthenticationState;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useNuxtApp, useState } from "#imports";
|
|
2
|
+
function withPermissionFallback(state) {
|
|
3
|
+
const permissions = Array.isArray(state?.permissions) ? state.permissions : [];
|
|
4
|
+
return {
|
|
5
|
+
...state,
|
|
6
|
+
hasPermission: state?.hasPermission ?? ((permissionId) => permissions.includes(permissionId))
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export function useAuthentication() {
|
|
10
|
+
const nuxtApp = useNuxtApp();
|
|
11
|
+
const injected = nuxtApp.$appAuthentication;
|
|
12
|
+
if (typeof injected === "function") {
|
|
13
|
+
return withPermissionFallback(injected());
|
|
14
|
+
}
|
|
15
|
+
if (injected) {
|
|
16
|
+
return withPermissionFallback(injected);
|
|
17
|
+
}
|
|
18
|
+
const state = useState("authentication", () => ({}));
|
|
19
|
+
return withPermissionFallback(state.value);
|
|
20
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { graphqlInputObject, graphqlOperationObject, graphqlTypeObject } from '../types/graphqlOperation.js';
|
|
2
|
+
export interface GraphqlBridgeState {
|
|
3
|
+
scalarType: string[];
|
|
4
|
+
graphqlType: Record<string, graphqlTypeObject>;
|
|
5
|
+
graphqlInputType: Record<string, graphqlInputObject>;
|
|
6
|
+
graphqlOperation: Record<string, graphqlOperationObject<any, any>>;
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
}
|
|
9
|
+
export interface GraphqlBridgeInput {
|
|
10
|
+
scalarType?: string[];
|
|
11
|
+
graphqlType?: Record<string, graphqlTypeObject>;
|
|
12
|
+
graphqlInputType?: Record<string, graphqlInputObject>;
|
|
13
|
+
graphqlOperation?: Record<string, graphqlOperationObject<any, any>>;
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
}
|
|
16
|
+
export declare function useGraphqlBridge(): GraphqlBridgeState;
|
|
17
|
+
export declare function registerGraphqlObject(input: GraphqlBridgeInput): void;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { useNuxtApp } from "#imports";
|
|
2
|
+
const fallbackGraphqlState = {
|
|
3
|
+
scalarType: [
|
|
4
|
+
"Boolean",
|
|
5
|
+
"Date",
|
|
6
|
+
"DateTime",
|
|
7
|
+
"Float",
|
|
8
|
+
"ID",
|
|
9
|
+
"Int",
|
|
10
|
+
"JSON",
|
|
11
|
+
"String",
|
|
12
|
+
"Upload"
|
|
13
|
+
],
|
|
14
|
+
graphqlType: {},
|
|
15
|
+
graphqlInputType: {},
|
|
16
|
+
graphqlOperation: {}
|
|
17
|
+
};
|
|
18
|
+
export function useGraphqlBridge() {
|
|
19
|
+
const nuxtApp = useNuxtApp();
|
|
20
|
+
const injected = nuxtApp.$appGraphql;
|
|
21
|
+
return {
|
|
22
|
+
...fallbackGraphqlState,
|
|
23
|
+
...injected,
|
|
24
|
+
scalarType: injected?.scalarType?.length ? [.../* @__PURE__ */ new Set([...fallbackGraphqlState.scalarType, ...injected.scalarType])] : fallbackGraphqlState.scalarType,
|
|
25
|
+
graphqlType: injected?.graphqlType ?? fallbackGraphqlState.graphqlType,
|
|
26
|
+
graphqlInputType: injected?.graphqlInputType ?? fallbackGraphqlState.graphqlInputType,
|
|
27
|
+
graphqlOperation: injected?.graphqlOperation ?? fallbackGraphqlState.graphqlOperation
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export function registerGraphqlObject(input) {
|
|
31
|
+
const nuxtApp = useNuxtApp();
|
|
32
|
+
const bridge = nuxtApp.$appGraphql ?? fallbackGraphqlState;
|
|
33
|
+
const scalarType = bridge.scalarType ?? fallbackGraphqlState.scalarType;
|
|
34
|
+
const graphqlType = bridge.graphqlType ?? fallbackGraphqlState.graphqlType;
|
|
35
|
+
const graphqlInputType = bridge.graphqlInputType ?? fallbackGraphqlState.graphqlInputType;
|
|
36
|
+
const graphqlOperation = bridge.graphqlOperation ?? fallbackGraphqlState.graphqlOperation;
|
|
37
|
+
if (input.scalarType?.length) {
|
|
38
|
+
for (const scalar of input.scalarType) {
|
|
39
|
+
if (!scalarType.includes(scalar)) scalarType.push(scalar);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (input.graphqlType) Object.assign(graphqlType, input.graphqlType);
|
|
43
|
+
if (input.graphqlInputType) Object.assign(graphqlInputType, input.graphqlInputType);
|
|
44
|
+
if (input.graphqlOperation) Object.assign(graphqlOperation, input.graphqlOperation);
|
|
45
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -1,34 +1,25 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import type { AlertItem } from '../types/alert'
|
|
10
|
-
|
|
11
|
-
const isAlertOpen = ref(false)
|
|
12
|
-
const timeout = ref(3000)
|
|
13
|
-
const alert = useAlert()
|
|
14
|
-
const currentItem = ref<AlertItem | undefined>()
|
|
15
|
-
|
|
1
|
+
<script setup>
|
|
2
|
+
import { ref, watch } from "vue";
|
|
3
|
+
import { isEmpty } from "lodash-es";
|
|
4
|
+
import { useAlert } from "../composables/alert";
|
|
5
|
+
const isAlertOpen = ref(false);
|
|
6
|
+
const timeout = ref(3e3);
|
|
7
|
+
const alert = useAlert();
|
|
8
|
+
const currentItem = ref();
|
|
16
9
|
const renewAlert = () => {
|
|
17
10
|
if (alert?.hasAlert()) {
|
|
18
|
-
currentItem.value = alert?.takeAlert()
|
|
19
|
-
isAlertOpen.value = true
|
|
11
|
+
currentItem.value = alert?.takeAlert();
|
|
12
|
+
isAlertOpen.value = true;
|
|
13
|
+
} else {
|
|
14
|
+
currentItem.value = void 0;
|
|
15
|
+
isAlertOpen.value = false;
|
|
20
16
|
}
|
|
21
|
-
|
|
22
|
-
currentItem.value = undefined
|
|
23
|
-
isAlertOpen.value = false
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
17
|
+
};
|
|
27
18
|
watch(() => alert?.hasAlert(), (hasAlert) => {
|
|
28
19
|
if (hasAlert) {
|
|
29
|
-
renewAlert()
|
|
20
|
+
renewAlert();
|
|
30
21
|
}
|
|
31
|
-
})
|
|
22
|
+
});
|
|
32
23
|
</script>
|
|
33
24
|
|
|
34
25
|
<template>
|
|
@@ -52,7 +43,7 @@ watch(() => alert?.hasAlert(), (hasAlert) => {
|
|
|
52
43
|
v-bind="currentItem.alertIcon ? { icon: currentItem.alertIcon } : {}"
|
|
53
44
|
@click:close="renewAlert()"
|
|
54
45
|
>
|
|
55
|
-
{{ currentItem.statusCode ? currentItem.statusCode +
|
|
46
|
+
{{ currentItem.statusCode ? currentItem.statusCode + " " : "" }} {{ currentItem.message }} {{ !isEmpty(currentItem.data) ? currentItem.data : "" }}
|
|
56
47
|
</VAlert>
|
|
57
48
|
</VSnackbar>
|
|
58
49
|
</template>
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
2
|
+
error: (error: unknown) => any;
|
|
3
|
+
decode: (barcodeValue: string) => any;
|
|
4
|
+
}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{
|
|
5
|
+
onError?: ((error: unknown) => any) | undefined;
|
|
6
|
+
onDecode?: ((barcodeValue: string) => any) | undefined;
|
|
7
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
8
|
+
declare const _default: typeof __VLS_export;
|
|
9
|
+
export default _default;
|
|
@@ -1,102 +1,77 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
const barcodeReaderControl = ref()
|
|
15
|
-
|
|
16
|
-
const alert = useAlert()
|
|
17
|
-
const isLoading = ref<boolean>(false)
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Custom events emitted by BarcodeReader.
|
|
21
|
-
* Parents can listen to these events to react to user actions and internal state changes.
|
|
22
|
-
*/
|
|
23
|
-
const emit = defineEmits<{
|
|
24
|
-
(event: 'decode', barcodeValue: string): void
|
|
25
|
-
(event: 'error', error: string | unknown): void
|
|
26
|
-
}>()
|
|
27
|
-
|
|
28
|
-
const videoScreen = ref<HTMLVideoElement>()
|
|
29
|
-
|
|
30
|
-
const currentCameraId = ref<ConstrainDOMString | undefined>()
|
|
1
|
+
<script setup>
|
|
2
|
+
import { BrowserMultiFormatReader } from "@zxing/browser";
|
|
3
|
+
import {} from "@zxing/browser/esm";
|
|
4
|
+
import { computed, onBeforeUnmount, onMounted, ref, watchEffect } from "vue";
|
|
5
|
+
import { useAlert } from "../composables/alert";
|
|
6
|
+
import { useDevicesList, useUserMedia } from "@vueuse/core";
|
|
7
|
+
const barcodeReader = new BrowserMultiFormatReader();
|
|
8
|
+
const barcodeReaderControl = ref();
|
|
9
|
+
const alert = useAlert();
|
|
10
|
+
const isLoading = ref(false);
|
|
11
|
+
const emit = defineEmits(["decode", "error"]);
|
|
12
|
+
const videoScreen = ref();
|
|
13
|
+
const currentCameraId = ref();
|
|
31
14
|
const { videoInputs: cameras } = useDevicesList({
|
|
32
15
|
requestPermissions: true,
|
|
33
16
|
constraints: { audio: false, video: true },
|
|
34
17
|
onUpdated() {
|
|
35
|
-
if (!cameras.value.find(camera => camera.deviceId === currentCameraId.value))
|
|
36
|
-
currentCameraId.value = cameras.value[0]?.deviceId
|
|
37
|
-
}
|
|
38
|
-
})
|
|
39
|
-
const hasCamera = computed(()=>{
|
|
40
|
-
|
|
18
|
+
if (!cameras.value.find((camera) => camera.deviceId === currentCameraId.value))
|
|
19
|
+
currentCameraId.value = cameras.value[0]?.deviceId;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const hasCamera = computed(() => {
|
|
23
|
+
return !!currentCameraId.value;
|
|
24
|
+
});
|
|
41
25
|
const { stream, start: cameraStart, stop: cameraStop, enabled: cameraEnabled } = useUserMedia({
|
|
42
|
-
constraints: { video: { deviceId: currentCameraId.value}}
|
|
43
|
-
})
|
|
44
|
-
|
|
26
|
+
constraints: { video: { deviceId: currentCameraId.value } }
|
|
27
|
+
});
|
|
45
28
|
watchEffect(() => {
|
|
46
|
-
if (videoScreen.value) videoScreen.value.srcObject =
|
|
47
|
-
})
|
|
48
|
-
|
|
29
|
+
if (videoScreen.value) videoScreen.value.srcObject = stream.value ? stream.value : null;
|
|
30
|
+
});
|
|
49
31
|
function startCamera() {
|
|
50
32
|
if (!cameraEnabled.value) {
|
|
51
|
-
isLoading.value = true
|
|
52
|
-
cameraStart().then(()=>{
|
|
53
|
-
barcodeReader.decodeFromVideoDevice(currentCameraId.value, videoScreen.value, (result
|
|
33
|
+
isLoading.value = true;
|
|
34
|
+
cameraStart().then(() => {
|
|
35
|
+
barcodeReader.decodeFromVideoDevice(currentCameraId.value, videoScreen.value, (result, error, controls) => {
|
|
54
36
|
if (result) {
|
|
55
|
-
emit(
|
|
56
|
-
cameraStop()
|
|
37
|
+
emit("decode", result.getText());
|
|
38
|
+
cameraStop();
|
|
57
39
|
}
|
|
58
|
-
}).then((result
|
|
59
|
-
barcodeReaderControl.value = result
|
|
60
|
-
})
|
|
61
|
-
}).finally(()=>{
|
|
62
|
-
isLoading.value = false
|
|
63
|
-
})
|
|
40
|
+
}).then((result) => {
|
|
41
|
+
barcodeReaderControl.value = result;
|
|
42
|
+
});
|
|
43
|
+
}).finally(() => {
|
|
44
|
+
isLoading.value = false;
|
|
45
|
+
});
|
|
64
46
|
}
|
|
65
47
|
}
|
|
66
|
-
|
|
67
48
|
function stopCamera() {
|
|
68
|
-
if (barcodeReaderControl.value) barcodeReaderControl.value.stop()
|
|
69
|
-
if (cameraEnabled.value) cameraStop()
|
|
49
|
+
if (barcodeReaderControl.value) barcodeReaderControl.value.stop();
|
|
50
|
+
if (cameraEnabled.value) cameraStop();
|
|
70
51
|
}
|
|
71
|
-
|
|
72
|
-
function scanImageFile(selectedFile: File | File[] | undefined) {
|
|
52
|
+
function scanImageFile(selectedFile) {
|
|
73
53
|
if (!selectedFile) {
|
|
74
|
-
alert?.addAlert({ message:
|
|
75
|
-
return
|
|
54
|
+
alert?.addAlert({ message: "No file selected.", alertType: "error" });
|
|
55
|
+
return;
|
|
76
56
|
}
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
const reader = new FileReader()
|
|
57
|
+
const scanImageSingleFile = Array.isArray(selectedFile) ? selectedFile[0] : selectedFile;
|
|
58
|
+
const reader = new FileReader();
|
|
81
59
|
reader.onload = async (event) => {
|
|
82
60
|
try {
|
|
83
|
-
const result = await barcodeReader.decodeFromImageUrl(event.target?.result
|
|
84
|
-
emit(
|
|
61
|
+
const result = await barcodeReader.decodeFromImageUrl(event.target?.result);
|
|
62
|
+
emit("decode", result.getText());
|
|
63
|
+
} catch (e) {
|
|
64
|
+
void e;
|
|
85
65
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
reader.readAsDataURL(scanImageSingleFile)
|
|
66
|
+
};
|
|
67
|
+
reader.readAsDataURL(scanImageSingleFile);
|
|
91
68
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
stopCamera()
|
|
99
|
-
})
|
|
69
|
+
onMounted(() => {
|
|
70
|
+
startCamera();
|
|
71
|
+
});
|
|
72
|
+
onBeforeUnmount(() => {
|
|
73
|
+
stopCamera();
|
|
74
|
+
});
|
|
100
75
|
</script>
|
|
101
76
|
|
|
102
77
|
<template>
|
|
@@ -106,8 +81,8 @@ onBeforeUnmount( () => {
|
|
|
106
81
|
</v-card-text>
|
|
107
82
|
<v-card-text v-else>
|
|
108
83
|
<v-col v-if="hasCamera">
|
|
109
|
-
<div style="position: relative; display: inline-block; width: 100%;" :style="{maxWidth: '1024px'}">
|
|
110
|
-
<video autoplay ref="videoScreen" width="100%" :style="{maxWidth:'1024px'}"></video>
|
|
84
|
+
<div style="position: relative; display: inline-block; width: 100%;" :style="{ maxWidth: '1024px' }">
|
|
85
|
+
<video autoplay ref="videoScreen" width="100%" :style="{ maxWidth: '1024px' }"></video>
|
|
111
86
|
<div style="position: absolute; bottom: 10px; right: 10px; z-index: 2000;">
|
|
112
87
|
<FileBtn
|
|
113
88
|
accept="image/*"
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
2
|
+
error: (error: unknown) => any;
|
|
3
|
+
decode: (barcodeValue: string) => any;
|
|
4
|
+
}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{
|
|
5
|
+
onError?: ((error: unknown) => any) | undefined;
|
|
6
|
+
onDecode?: ((barcodeValue: string) => any) | undefined;
|
|
7
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
8
|
+
declare const _default: typeof __VLS_export;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { VBtn } from 'vuetify/components/VBtn';
|
|
2
|
+
interface ExportButtonProps extends /* @vue-ignore */ InstanceType<typeof VBtn['$props']> {
|
|
3
|
+
fileName?: string;
|
|
4
|
+
sheetName?: string;
|
|
5
|
+
modelValue?: object[];
|
|
6
|
+
stringFields?: Array<string>;
|
|
7
|
+
tooltip?: string | Record<string, any> | undefined;
|
|
8
|
+
}
|
|
9
|
+
declare var __VLS_12: never, __VLS_13: {};
|
|
10
|
+
type __VLS_Slots = {} & {
|
|
11
|
+
[K in NonNullable<typeof __VLS_12>]?: (props: typeof __VLS_13) => any;
|
|
12
|
+
};
|
|
13
|
+
declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<ExportButtonProps>, {
|
|
14
|
+
fileName: string;
|
|
15
|
+
sheetName: string;
|
|
16
|
+
stringFields: () => never[];
|
|
17
|
+
tooltip: () => {
|
|
18
|
+
text: string;
|
|
19
|
+
location: string;
|
|
20
|
+
};
|
|
21
|
+
}>>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<ExportButtonProps>, {
|
|
22
|
+
fileName: string;
|
|
23
|
+
sheetName: string;
|
|
24
|
+
stringFields: () => never[];
|
|
25
|
+
tooltip: () => {
|
|
26
|
+
text: string;
|
|
27
|
+
location: string;
|
|
28
|
+
};
|
|
29
|
+
}>>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
30
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
31
|
+
declare const _default: typeof __VLS_export;
|
|
32
|
+
export default _default;
|
|
33
|
+
type __VLS_TypePropsToOption<T> = {
|
|
34
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
35
|
+
type: import('vue').PropType<Required<T>[K]>;
|
|
36
|
+
} : {
|
|
37
|
+
type: import('vue').PropType<T[K]>;
|
|
38
|
+
required: true;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
type __VLS_WithDefaults<P, D> = {
|
|
42
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_PrettifyLocal<P[K] & {
|
|
43
|
+
default: D[K];
|
|
44
|
+
}> : P[K];
|
|
45
|
+
};
|
|
46
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
47
|
+
new (): {
|
|
48
|
+
$slots: S;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
52
|
+
[K in keyof T]: T[K];
|
|
53
|
+
} : {
|
|
54
|
+
[K in keyof T as K]: T[K];
|
|
55
|
+
}) & {};
|
|
@@ -1,88 +1,51 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
stringFields?: Array<string> // Field paths that must stay as string values (no nested object conversion).
|
|
16
|
-
tooltip?: string | Record<string,any> | undefined // Tooltip text or config object shown for the action control.
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Public props accepted by ExportCSV.
|
|
21
|
-
* Document each prop field with intent, defaults, and side effects for clear generated docs.
|
|
22
|
-
*/
|
|
23
|
-
const props = withDefaults(defineProps<ExportButtonProps>(), {
|
|
24
|
-
fileName: 'download',
|
|
25
|
-
sheetName: 'Sheet1',
|
|
26
|
-
stringFields: ()=>[],
|
|
27
|
-
tooltip: ()=>({text: 'Export', location: 'bottom'}),
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
const alert = useAlert()
|
|
31
|
-
const loading = ref(false)
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Triggers file export
|
|
35
|
-
*/
|
|
1
|
+
<script setup>
|
|
2
|
+
import { ref } from "vue";
|
|
3
|
+
import * as XLSX from "xlsx";
|
|
4
|
+
import { VBtn } from "vuetify/components/VBtn";
|
|
5
|
+
import { useAlert } from "../composables/alert";
|
|
6
|
+
const props = defineProps({
|
|
7
|
+
fileName: { type: String, required: false, default: "download" },
|
|
8
|
+
sheetName: { type: String, required: false, default: "Sheet1" },
|
|
9
|
+
modelValue: { type: Array, required: false },
|
|
10
|
+
stringFields: { type: Array, required: false, default: () => [] },
|
|
11
|
+
tooltip: { type: null, required: false, default: () => ({ text: "Export", location: "bottom" }) }
|
|
12
|
+
});
|
|
13
|
+
const alert = useAlert();
|
|
14
|
+
const loading = ref(false);
|
|
36
15
|
function exportFile() {
|
|
37
16
|
if (props.modelValue && Array.isArray(props.modelValue) && props.modelValue.length > 0) {
|
|
38
|
-
loading.value = true
|
|
39
|
-
|
|
17
|
+
loading.value = true;
|
|
40
18
|
try {
|
|
41
|
-
const workbook = XLSX.utils.book_new()
|
|
42
|
-
const worksheet = XLSX.utils.json_to_sheet(flattenNestedFields(props.modelValue))
|
|
43
|
-
const fileName = `${props.fileName}.xlsx
|
|
44
|
-
|
|
45
|
-
XLSX.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
alert?.addAlert({ message: `Export failed: ${error.message}`, alertType: 'error' })
|
|
19
|
+
const workbook = XLSX.utils.book_new();
|
|
20
|
+
const worksheet = XLSX.utils.json_to_sheet(flattenNestedFields(props.modelValue));
|
|
21
|
+
const fileName = `${props.fileName}.xlsx`;
|
|
22
|
+
XLSX.utils.book_append_sheet(workbook, worksheet, props.sheetName);
|
|
23
|
+
XLSX.writeFile(workbook, fileName);
|
|
24
|
+
} catch (error) {
|
|
25
|
+
alert?.addAlert({ message: `Export failed: ${error.message}`, alertType: "error" });
|
|
49
26
|
} finally {
|
|
50
|
-
loading.value = false
|
|
27
|
+
loading.value = false;
|
|
51
28
|
}
|
|
52
29
|
} else {
|
|
53
|
-
alert?.addAlert({ message:
|
|
30
|
+
alert?.addAlert({ message: "Invalid or no data to export", alertType: "error" });
|
|
54
31
|
}
|
|
55
32
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
*/
|
|
61
|
-
function flattenNestedFields(items: any[]) {
|
|
62
|
-
return items.map((item: any) => {
|
|
63
|
-
return flattenObject(item)
|
|
64
|
-
})
|
|
33
|
+
function flattenNestedFields(items) {
|
|
34
|
+
return items.map((item) => {
|
|
35
|
+
return flattenObject(item);
|
|
36
|
+
});
|
|
65
37
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
*/
|
|
73
|
-
function flattenObject(obj: any, parentKey = '', separator = '.') {
|
|
74
|
-
return Object.keys(obj).reduce((acc: any, key: string) => {
|
|
75
|
-
const newKey = parentKey ? `${parentKey}${separator}${key}` : key
|
|
76
|
-
const value = obj[key]
|
|
77
|
-
|
|
78
|
-
if (value && typeof value === 'object' && !Array.isArray(value) && !props.stringFields.includes(newKey)) {
|
|
79
|
-
Object.assign(acc, flattenObject(value, newKey, separator))
|
|
38
|
+
function flattenObject(obj, parentKey = "", separator = ".") {
|
|
39
|
+
return Object.keys(obj).reduce((acc, key) => {
|
|
40
|
+
const newKey = parentKey ? `${parentKey}${separator}${key}` : key;
|
|
41
|
+
const value = obj[key];
|
|
42
|
+
if (value && typeof value === "object" && !Array.isArray(value) && !props.stringFields.includes(newKey)) {
|
|
43
|
+
Object.assign(acc, flattenObject(value, newKey, separator));
|
|
80
44
|
} else {
|
|
81
|
-
acc[newKey] = typeof value ===
|
|
45
|
+
acc[newKey] = typeof value === "object" ? JSON.stringify(value) : value;
|
|
82
46
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}, {})
|
|
47
|
+
return acc;
|
|
48
|
+
}, {});
|
|
86
49
|
}
|
|
87
50
|
</script>
|
|
88
51
|
|
|
@@ -97,13 +60,13 @@ function flattenObject(obj: any, parentKey = '', separator = '.') {
|
|
|
97
60
|
v-tooltip="props.tooltip"
|
|
98
61
|
>
|
|
99
62
|
<template
|
|
100
|
-
v-for="(_, name, index) in
|
|
63
|
+
v-for="(_, name, index) in $slots"
|
|
101
64
|
:key="index"
|
|
102
65
|
#[name]="slotData"
|
|
103
66
|
>
|
|
104
67
|
<slot
|
|
105
68
|
:name="name"
|
|
106
|
-
v-bind="
|
|
69
|
+
v-bind="slotData || {}"
|
|
107
70
|
/>
|
|
108
71
|
</template>
|
|
109
72
|
</VBtn>
|