1
+ <script setup>
2
+ import { ref , computed , onMounted } from " vue" ;
3
+ import LocalVueUiTable from ' ../src/components/vue-ui-table.vue' ;
4
+ import LocalVueDataUi from ' ../src/components/vue-data-ui.vue' ;
5
+ import Box from " ./Box.vue" ;
6
+ import convertArrayToObject from " ./convertModel" ;
7
+ import { useArena } from " ../src/useArena" ;
8
+
9
+ const { local , build , vduiLocal , vduiBuild , toggleTable } = useArena ()
10
+
11
+ const head = ref ([
12
+ {
13
+ name: " touchpoint" ,
14
+ type: " text" ,
15
+ average: false ,
16
+ decimals: undefined ,
17
+ sum: false ,
18
+ isSort: true ,
19
+ isSearch: true ,
20
+ isMultiselect: true ,
21
+ isPercentage: false ,
22
+ percentageTo: undefined ,
23
+ suffix: " " ,
24
+ prefix: " " ,
25
+ rangeFilter: false ,
26
+ },
27
+ {
28
+ name: " category" ,
29
+ type: " text" ,
30
+ average: false ,
31
+ decimals: undefined ,
32
+ sum: false ,
33
+ isSort: false ,
34
+ isSearch: false ,
35
+ isMultiselect: true ,
36
+ isPercentage: false ,
37
+ percentageTo: undefined ,
38
+ suffix: " " ,
39
+ prefix: " " ,
40
+ rangeFilter: false ,
41
+ },
42
+ {
43
+ name: " date" ,
44
+ type: " date" ,
45
+ average: false ,
46
+ decimals: undefined ,
47
+ sum: false ,
48
+ isSort: true ,
49
+ isSearch: false ,
50
+ isMultiselect: false ,
51
+ isPercentage: false ,
52
+ percentageTo: undefined ,
53
+ suffix: " " ,
54
+ prefix: " " ,
55
+ rangeFilter: false ,
56
+ },
57
+ {
58
+ name: " base" ,
59
+ type: " numeric" ,
60
+ average: true ,
61
+ decimals: 0 ,
62
+ sum: true ,
63
+ isSort: true ,
64
+ isSearch: false ,
65
+ isMultiselect: false ,
66
+ isPercentage: false ,
67
+ percentageTo: undefined ,
68
+ suffix: " " ,
69
+ prefix: " " ,
70
+ rangeFilter: false ,
71
+ },
72
+ {
73
+ name: " rating" ,
74
+ type: " numeric" ,
75
+ decimals: 1 ,
76
+ average: true ,
77
+ sum: false ,
78
+ isSort: true ,
79
+ isSearch: false ,
80
+ isMultiselect: false ,
81
+ isPercentage: false ,
82
+ percentageTo: undefined ,
83
+ suffix: " " ,
84
+ prefix: " " ,
85
+ rangeFilter: true ,
86
+ },
87
+ {
88
+ name: " spend" ,
89
+ type: " numeric" ,
90
+ decimals: 1 ,
91
+ average: true ,
92
+ sum: true ,
93
+ isSort: true ,
94
+ isSearch: false ,
95
+ isMultiselect: false ,
96
+ isPercentage: false ,
97
+ percentageTo: undefined ,
98
+ suffix: " €" ,
99
+ prefix: " " ,
100
+ rangeFilter: true ,
101
+ },
102
+ {
103
+ name: " percentage" ,
104
+ type: " numeric" ,
105
+ decimals: 1 ,
106
+ average: false ,
107
+ sum: false ,
108
+ isSort: true ,
109
+ isSearch: false ,
110
+ isMultiselect: false ,
111
+ isPercentage: true , // requires an empty slot in the body td arrays!
112
+ percentageTo: " base" ,
113
+ suffix: " " ,
114
+ prefix: " " ,
115
+ rangeFilter: false ,
116
+ },
117
+ {
118
+ name: " happy" ,
119
+ type: " numeric" ,
120
+ decimals: 0 ,
121
+ average: true ,
122
+ sum: true ,
123
+ isSort: true ,
124
+ isSearch: false ,
125
+ isMultiselect: false ,
126
+ isPercentage: false ,
127
+ percentageTo: " base" ,
128
+ suffix: " " ,
129
+ prefix: " " ,
130
+ rangeFilter: false ,
131
+ },
132
+ {
133
+ name: " sad" ,
134
+ type: " numeric" ,
135
+ decimals: 0 ,
136
+ average: true ,
137
+ sum: true ,
138
+ isSort: true ,
139
+ isSearch: false ,
140
+ isMultiselect: false ,
141
+ isPercentage: false ,
142
+ percentageTo: " base" ,
143
+ suffix: " " ,
144
+ prefix: " " ,
145
+ rangeFilter: false ,
146
+ },
147
+ ]);
148
+
149
+ function makeBody (n ) {
150
+ const categories = [" Accueil" , " Magasin" , " Caisse" , " SAV" ];
151
+ const itemNames = [
152
+ " Qualité du service" ,
153
+ " Rapidité de livraison" ,
154
+ " Efficacité du personnel" ,
155
+ " Variété des produits" ,
156
+ " Propreté des lieux" ,
157
+ " Réactivité du support" ,
158
+ " Prix compétitifs" ,
159
+ " Expérience utilisateur" ,
160
+ " Fiabilité du matériel" ,
161
+ ];
162
+
163
+ function generateRandomData () {
164
+ const items = [];
165
+
166
+ for (let i = 0 ; i < n; i += 1 ) {
167
+ const itemName = getRandomItemName ();
168
+ const category = getRandomCategory ();
169
+ let accueil = Math .random () * 100 ;
170
+ const date = getRandomDate ();
171
+ const data = [
172
+ itemName,
173
+ category,
174
+ date,
175
+ accueil,
176
+ Number ((Math .random () * 5 ).toFixed (1 )),
177
+ Math .random () * 200 ,
178
+ " " ,
179
+ Math .random () * (Math .random () > 0.5 ? 150 : - 30 ),
180
+ Math .random () * 350 ,
181
+ ];
182
+ items .push ({ td: data });
183
+ }
184
+
185
+ return items;
186
+ }
187
+
188
+ function getRandomItemName () {
189
+ const randomIndex = Math .floor (Math .random () * itemNames .length );
190
+ return itemNames[randomIndex];
191
+ }
192
+
193
+ function getRandomCategory () {
194
+ const randomIndex = Math .floor (Math .random () * categories .length );
195
+ return categories[randomIndex];
196
+ }
197
+
198
+ function getRandomDate () {
199
+ const start = new Date (2023 , 0 , 1 ).getTime ();
200
+ const end = new Date (2023 , 11 , 31 ).getTime ();
201
+ const randomTime = Math .random () * (end - start) + start;
202
+ const randomDate = new Date (randomTime);
203
+ const formattedDate = randomDate .toISOString ().split (" T" )[0 ];
204
+ return formattedDate;
205
+ }
206
+ return generateRandomData ();
207
+ }
208
+
209
+ const body = ref (makeBody (100 ))
210
+
211
+ const dataset = ref ( {
212
+ header: head .value ,
213
+ body: body .value ,
214
+ })
215
+
216
+ onMounted (() => {
217
+ setTimeout (() => {
218
+ dataset .value .body = makeBody (200 )
219
+ }, 3000 )
220
+ })
221
+
222
+ </script >
223
+
224
+ <template >
225
+ <div style =" background : white " >
226
+ <LocalVueUiTable :dataset =" dataset" />
227
+ </div >
228
+ </template >
0 commit comments