w-table-vue 1.0.13 → 1.0.14

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.
Files changed (42) hide show
  1. package/README.md +1 -1
  2. package/dist/w-table-vue.umd.js +3 -3
  3. package/dist/w-table-vue.umd.js.map +1 -1
  4. package/docs/examples/app.html +1 -1
  5. package/docs/examples/app.umd.js +2 -2
  6. package/docs/examples/app.umd.js.map +1 -1
  7. package/docs/examples/w-table-edit_default.html +26 -1
  8. package/docs/examples/w-table-edit_editable.html +26 -1
  9. package/docs/examples/w-table-edit_editable_checkId.html +26 -1
  10. package/docs/examples/w-table-edit_editable_checkId_opt.modifyDataWhenSave_save(call cmp. method).html +26 -1
  11. package/docs/examples/w-table-edit_editable_checkId_successMsgFromAddRow_errorMsgFromAddRow.html +26 -1
  12. package/docs/examples/w-table-edit_editable_inforPaddingStyle_menuBackgroundColor.html +26 -1
  13. package/docs/examples/w-table-edit_editable_language_checkId_tooltipAddRow.html +26 -1
  14. package/docs/examples/w-table-edit_editable_language_textLabelDataName_textPlaceholderDataName.html +26 -1
  15. package/docs/examples/w-table-edit_editable_no enableInfor.html +26 -1
  16. package/docs/examples/w-table-edit_editable_no enableMenu.html +26 -1
  17. package/docs/examples/w-table-edit_editable_opt.beforeAddRow.html +26 -1
  18. package/docs/examples/w-table-edit_editable_opt.kpCellFormat_no useCellFormatWhenDownload.html +543 -0
  19. package/docs/examples/w-table-edit_editable_opt.kpConvertKeysWhenUploadData.html +26 -1
  20. package/docs/examples/w-table-edit_editable_opt.optForUploadData.html +26 -1
  21. package/docs/examples/w-table-edit_editable_slot btns-right.html +26 -1
  22. package/docs/examples/w-table-edit_fixIds (fix id).html +26 -1
  23. package/docs/examples/w-table-edit_hideIds (hide mappingId).html +26 -1
  24. package/docs/examples/w-table-edit_name_description.html +26 -1
  25. package/docs/examples/w-table-edit_no enableInfor.html +26 -1
  26. package/docs/examples/w-table-edit_no enableMenu.html +26 -1
  27. package/docs/examples/w-table-edit_opt.kpCellFormat.html +539 -0
  28. package/docs/examples/w-table-edit_opt.kpHead.html +26 -1
  29. package/docs/examples/w-table-edit_removeIdsWhenDownload (remove id, mappingId, order, isActive).html +26 -1
  30. package/docs/examples/w-table-edit_slot btns-left.html +26 -1
  31. package/docs/examples/w-table-edit_slot btns-right.html +26 -1
  32. package/docs/examples/w-table-edit_slot cell-render.html +26 -1
  33. package/docs/examples/w-table-edit_slot cell-tooltip.html +26 -1
  34. package/docs/examples/w-table-edit_slot head-render.html +26 -1
  35. package/docs/examples/w-table-edit_slot head-tooltip.html +26 -1
  36. package/docs/examples/w-table-edit_slot infor (name_description).html +26 -1
  37. package/docs/examples/w-table-edit_sortColIds (sort by order).html +26 -1
  38. package/docs/index.html +1 -1
  39. package/docs/module-WTableEdit.html +27 -3
  40. package/package.json +2 -2
  41. package/src/AppZoneWTableEdit.vue +61 -0
  42. package/src/components/WTableEdit.vue +12 -5
@@ -43,7 +43,7 @@
43
43
  />
44
44
 
45
45
  <!-- w-table-vue -->
46
- <script src="https://cdn.jsdelivr.net/npm/w-table-vue@1.0.13/dist/w-table-vue.umd.js"></script>
46
+ <script src="https://cdn.jsdelivr.net/npm/w-table-vue@1.0.14/dist/w-table-vue.umd.js"></script>
47
47
 
48
48
  <style>
49
49
  .item {
@@ -484,6 +484,31 @@
484
484
  }
485
485
  return rows;
486
486
  }
487
+ },
488
+ opt8: {
489
+ keys: keys1,
490
+ kpHeadFilterType: kpHeadFilterType1,
491
+ rows: rows1,
492
+ kpCellFormat: {
493
+ //格式化僅影響顯示與下載, 排序、過濾、編輯與save回傳之rows仍為原值
494
+ make: function(value, key, row, params) {
495
+ //空值(null、undefined、空字串)會原樣傳入, 編輯模式新增列之各欄為空字串, 回傳null代表不格式化維持原值
496
+ if (value === null || value === undefined || value === "") {
497
+ return null;
498
+ }
499
+ return String(value).toUpperCase();
500
+ },
501
+ price: function(value, key, row, params) {
502
+ //空值不可直接Number(), 否則''與null會變成0.00
503
+ if (value === null || value === undefined || value === "") {
504
+ return null;
505
+ }
506
+ return Number(value).toLocaleString("en-US", {
507
+ minimumFractionDigits: 2,
508
+ maximumFractionDigits: 2
509
+ });
510
+ }
511
+ }
487
512
  }
488
513
  },
489
514
  actions: []
@@ -43,7 +43,7 @@
43
43
  />
44
44
 
45
45
  <!-- w-table-vue -->
46
- <script src="https://cdn.jsdelivr.net/npm/w-table-vue@1.0.13/dist/w-table-vue.umd.js"></script>
46
+ <script src="https://cdn.jsdelivr.net/npm/w-table-vue@1.0.14/dist/w-table-vue.umd.js"></script>
47
47
 
48
48
  <style>
49
49
  .item {
@@ -482,6 +482,31 @@
482
482
  }
483
483
  return rows;
484
484
  }
485
+ },
486
+ opt8: {
487
+ keys: keys1,
488
+ kpHeadFilterType: kpHeadFilterType1,
489
+ rows: rows1,
490
+ kpCellFormat: {
491
+ //格式化僅影響顯示與下載, 排序、過濾、編輯與save回傳之rows仍為原值
492
+ make: function(value, key, row, params) {
493
+ //空值(null、undefined、空字串)會原樣傳入, 編輯模式新增列之各欄為空字串, 回傳null代表不格式化維持原值
494
+ if (value === null || value === undefined || value === "") {
495
+ return null;
496
+ }
497
+ return String(value).toUpperCase();
498
+ },
499
+ price: function(value, key, row, params) {
500
+ //空值不可直接Number(), 否則''與null會變成0.00
501
+ if (value === null || value === undefined || value === "") {
502
+ return null;
503
+ }
504
+ return Number(value).toLocaleString("en-US", {
505
+ minimumFractionDigits: 2,
506
+ maximumFractionDigits: 2
507
+ });
508
+ }
509
+ }
485
510
  }
486
511
  },
487
512
  actions: []
@@ -43,7 +43,7 @@
43
43
  />
44
44
 
45
45
  <!-- w-table-vue -->
46
- <script src="https://cdn.jsdelivr.net/npm/w-table-vue@1.0.13/dist/w-table-vue.umd.js"></script>
46
+ <script src="https://cdn.jsdelivr.net/npm/w-table-vue@1.0.14/dist/w-table-vue.umd.js"></script>
47
47
 
48
48
  <style>
49
49
  .item {
@@ -483,6 +483,31 @@
483
483
  }
484
484
  return rows;
485
485
  }
486
+ },
487
+ opt8: {
488
+ keys: keys1,
489
+ kpHeadFilterType: kpHeadFilterType1,
490
+ rows: rows1,
491
+ kpCellFormat: {
492
+ //格式化僅影響顯示與下載, 排序、過濾、編輯與save回傳之rows仍為原值
493
+ make: function(value, key, row, params) {
494
+ //空值(null、undefined、空字串)會原樣傳入, 編輯模式新增列之各欄為空字串, 回傳null代表不格式化維持原值
495
+ if (value === null || value === undefined || value === "") {
496
+ return null;
497
+ }
498
+ return String(value).toUpperCase();
499
+ },
500
+ price: function(value, key, row, params) {
501
+ //空值不可直接Number(), 否則''與null會變成0.00
502
+ if (value === null || value === undefined || value === "") {
503
+ return null;
504
+ }
505
+ return Number(value).toLocaleString("en-US", {
506
+ minimumFractionDigits: 2,
507
+ maximumFractionDigits: 2
508
+ });
509
+ }
510
+ }
486
511
  }
487
512
  },
488
513
  actions: []
@@ -43,7 +43,7 @@
43
43
  />
44
44
 
45
45
  <!-- w-table-vue -->
46
- <script src="https://cdn.jsdelivr.net/npm/w-table-vue@1.0.13/dist/w-table-vue.umd.js"></script>
46
+ <script src="https://cdn.jsdelivr.net/npm/w-table-vue@1.0.14/dist/w-table-vue.umd.js"></script>
47
47
 
48
48
  <style>
49
49
  .item {
@@ -483,6 +483,31 @@
483
483
  }
484
484
  return rows;
485
485
  }
486
+ },
487
+ opt8: {
488
+ keys: keys1,
489
+ kpHeadFilterType: kpHeadFilterType1,
490
+ rows: rows1,
491
+ kpCellFormat: {
492
+ //格式化僅影響顯示與下載, 排序、過濾、編輯與save回傳之rows仍為原值
493
+ make: function(value, key, row, params) {
494
+ //空值(null、undefined、空字串)會原樣傳入, 編輯模式新增列之各欄為空字串, 回傳null代表不格式化維持原值
495
+ if (value === null || value === undefined || value === "") {
496
+ return null;
497
+ }
498
+ return String(value).toUpperCase();
499
+ },
500
+ price: function(value, key, row, params) {
501
+ //空值不可直接Number(), 否則''與null會變成0.00
502
+ if (value === null || value === undefined || value === "") {
503
+ return null;
504
+ }
505
+ return Number(value).toLocaleString("en-US", {
506
+ minimumFractionDigits: 2,
507
+ maximumFractionDigits: 2
508
+ });
509
+ }
510
+ }
486
511
  }
487
512
  },
488
513
  actions: []
@@ -0,0 +1,539 @@
1
+ <!doctype html>
2
+ <html xmlns="http://www.w3.org/1999/xhtml" lang="zh-tw">
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
5
+ <meta
6
+ name="viewport"
7
+ content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui"
8
+ />
9
+ <meta http-equiv="X-UA-Compatible" content="ie=edge" />
10
+ <title>w-table-vue</title>
11
+
12
+ <!-- @babel/polyfill -->
13
+ <script
14
+ nomodule
15
+ src="https://cdn.jsdelivr.net/npm/@babel/polyfill/dist/polyfill.min.js"
16
+ ></script>
17
+
18
+ <!-- vue -->
19
+ <script src="https://cdn.jsdelivr.net/npm/vue@2.x/dist/vue.min.js"></script>
20
+
21
+ <!-- extractHtml已自動添加@babel/polyfill與vue -->
22
+
23
+ <!-- fontawesome -->
24
+ <link
25
+ href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.4.2/css/all.min.css"
26
+ rel="stylesheet"
27
+ />
28
+
29
+ <!-- mdi, 各組件使用mdi/js會於轉單頁時改為mdi icon, 故需引用mdi/css -->
30
+ <link
31
+ href="https://cdn.jsdelivr.net/npm/@mdi/font@7.4.47/css/materialdesignicons.min.css"
32
+ rel="stylesheet"
33
+ />
34
+
35
+ <!-- google, 各組件使用mdi/js故不需引用 -->
36
+ <link
37
+ _href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900"
38
+ rel="stylesheet"
39
+ />
40
+ <link
41
+ _href="https://fonts.googleapis.com/css?family=Material+Icons"
42
+ rel="stylesheet"
43
+ />
44
+
45
+ <!-- w-table-vue -->
46
+ <script src="https://cdn.jsdelivr.net/npm/w-table-vue@1.0.14/dist/w-table-vue.umd.js"></script>
47
+
48
+ <style>
49
+ .item {
50
+ /* 因item位於demolink, 提取各範例html後會刪除demolink, 故得額外補上 */
51
+ border-left: 3px solid #ffba75;
52
+ margin: 5px 5px 8px 0px;
53
+ padding: 3px 3px 5px 10px;
54
+ font-size: 0.9rem;
55
+ display: flex;
56
+ justify-content: flex-start;
57
+ align-items: center;
58
+ }
59
+ .head1 {
60
+ padding: 0px 0px 20px 0px;
61
+ font-size: 2.5rem;
62
+ }
63
+ .bkh {
64
+ /* 寬 */
65
+ padding: 20px;
66
+ }
67
+ @media screen and (max-width: 800px) {
68
+ /* 中 */
69
+ .bkh {
70
+ padding: 10px;
71
+ }
72
+ }
73
+ @media screen and (max-width: 400px) {
74
+ /* 窄 */
75
+ .bkh {
76
+ padding: 5px;
77
+ }
78
+ }
79
+ .bk {
80
+ /* 寬 */
81
+ display: inline-block;
82
+ vertical-align: top;
83
+ padding: 0px 80px 60px 0px;
84
+ }
85
+ @media screen and (max-width: 1000px) {
86
+ /* 中窄 */
87
+ .bk {
88
+ display: block;
89
+ padding: 0px 0px 50px 0px;
90
+ }
91
+ }
92
+ </style>
93
+ </head>
94
+ <body
95
+ style="font-family:'Microsoft JhengHei','Avenir','Helvetica'; padding:0px; margin:0px;"
96
+ >
97
+ <div id="app" class="bkh" style>
98
+ <div class="head1">
99
+ <span
100
+ style="cursor:pointer;"
101
+ title="open for copy link to view component"
102
+ onclick="window.open('//yuda-lyu.github.io/w-table-vue/examples/app.html?cmp='+this.innerText,'_blank')"
103
+ >w-table-edit</span>
104
+ </div>
105
+ <div class="bk">
106
+ <div class="item">opt.kpCellFormat</div>
107
+
108
+ <w-table-edit
109
+ style="width:600px; height:400px;"
110
+ :name="WTableEdit.name"
111
+ :description="WTableEdit.description"
112
+ :opt="WTableEdit.opt8"
113
+ @success="evSuccess"
114
+ @error="evError"
115
+ ></w-table-edit>
116
+ </div>
117
+ </div>
118
+
119
+ <script>
120
+ //install
121
+ Vue.use(window["w-table-vue"]);
122
+
123
+ //initialize
124
+ new Vue({
125
+ el: "#app",
126
+
127
+ data: function() {
128
+ let keys1 = ["make", "model", "price"];
129
+ let kpHeadFilterType1 = {
130
+ //default: num (num,text,time,set)
131
+ make: "text",
132
+ model: "text",
133
+ price: "num"
134
+ };
135
+ let rows1 = [
136
+ { make: "Toyota", model: "Celica", price: 35000 },
137
+ { make: "Ford", model: "Mondeo", price: 32000 },
138
+ { make: "Porsche", model: "Boxter", price: 72000 },
139
+ { make: "BMW", model: "Sedan", price: 66000 },
140
+ { make: "Nissan", model: "March", price: 61000 },
141
+ { make: "Lexus", model: "RX", price: 56000 },
142
+ { make: "Audi", model: "A6 Allroad", price: 45000 },
143
+ { make: "Mazda", model: "MX-5", price: 36000 },
144
+ { make: "Mercedes-Benz", model: "Cabriolet", price: 86000 },
145
+ { make: "Volkswagen", model: "Beetle", price: 68000 },
146
+ { make: "Honda", model: "City", price: 69000 },
147
+ { make: "Volvo", model: "S60", price: 71000 },
148
+ { make: "Subaru", model: "BRZ", price: 48000 }
149
+ ];
150
+ let keys2 = [
151
+ "id",
152
+ "mappingId",
153
+ "order",
154
+ "make",
155
+ "model",
156
+ "price",
157
+ "isActive"
158
+ ];
159
+ let kpHeadFilterType2 = {
160
+ //default: num (num,text,time,set)
161
+ id: "text",
162
+ mappingId: "text",
163
+ order: "num",
164
+ make: "text",
165
+ model: "text",
166
+ price: "num",
167
+ isActive: "text"
168
+ };
169
+ let rows2 = [
170
+ {
171
+ id: "id-Toyota",
172
+ mappingId: "car_table",
173
+ order: 0,
174
+ make: "Toyota",
175
+ model: "Celica",
176
+ price: 35000,
177
+ isActive: "y"
178
+ },
179
+ {
180
+ id: "id-Ford",
181
+ mappingId: "car_table",
182
+ order: 1,
183
+ make: "Ford",
184
+ model: "Mondeo",
185
+ price: 32000,
186
+ isActive: "y"
187
+ },
188
+ {
189
+ id: "id-Porsche",
190
+ mappingId: "car_table",
191
+ order: 2,
192
+ make: "Porsche",
193
+ model: "Boxter",
194
+ price: 72000,
195
+ isActive: "y"
196
+ },
197
+ {
198
+ id: "id-BMW",
199
+ mappingId: "car_table",
200
+ order: 11,
201
+ make: "BMW",
202
+ model: "Sedan",
203
+ price: 66000,
204
+ isActive: "y"
205
+ },
206
+ {
207
+ id: "id-Nissan",
208
+ mappingId: "car_table",
209
+ order: 8,
210
+ make: "Nissan",
211
+ model: "March",
212
+ price: 61000,
213
+ isActive: "y"
214
+ },
215
+ {
216
+ id: "id-Lexus",
217
+ mappingId: "car_table",
218
+ order: 4,
219
+ make: "Lexus",
220
+ model: "RX",
221
+ price: 56000,
222
+ isActive: "y"
223
+ },
224
+ {
225
+ id: "id-Audi",
226
+ mappingId: "car_table",
227
+ order: 5,
228
+ make: "Audi",
229
+ model: "A6 Allroad",
230
+ price: 45000,
231
+ isActive: "y"
232
+ },
233
+ {
234
+ id: "id-Mazda",
235
+ mappingId: "car_table",
236
+ order: 6,
237
+ make: "Mazda",
238
+ model: "MX-5",
239
+ price: 36000,
240
+ isActive: "y"
241
+ },
242
+ {
243
+ id: "id-Mercedes",
244
+ mappingId: "car_table",
245
+ order: 7,
246
+ make: "Mercedes-Benz",
247
+ model: "Cabriolet",
248
+ price: 86000,
249
+ isActive: "y"
250
+ },
251
+ {
252
+ id: "id-Volkswagen",
253
+ mappingId: "car_table",
254
+ order: 9,
255
+ make: "Volkswagen",
256
+ model: "Beetle",
257
+ price: 68000,
258
+ isActive: "y"
259
+ },
260
+ {
261
+ id: "id-Honda",
262
+ mappingId: "car_table",
263
+ order: 10,
264
+ make: "Honda",
265
+ model: "City",
266
+ price: 69000,
267
+ isActive: "y"
268
+ },
269
+ {
270
+ id: "id-Volvo",
271
+ mappingId: "car_table",
272
+ order: 12,
273
+ make: "Volvo",
274
+ model: "S60",
275
+ price: 71000,
276
+ isActive: "y"
277
+ },
278
+ {
279
+ id: "id-Subaru",
280
+ mappingId: "car_table",
281
+ order: 3,
282
+ make: "Subaru",
283
+ model: "BRZ",
284
+ price: 48000,
285
+ isActive: "y"
286
+ }
287
+ ];
288
+ let keys3 = [
289
+ "id",
290
+ "mappingId",
291
+ "order",
292
+ "make",
293
+ "model",
294
+ "price",
295
+ "isActive"
296
+ ];
297
+ let kpHeadFilterType3 = {
298
+ //default: num (num,text,time,set)
299
+ id: "text",
300
+ mappingId: "text",
301
+ order: "num",
302
+ make: "text",
303
+ model: "text",
304
+ price: "num",
305
+ isActive: "text"
306
+ };
307
+ let rows3 = [
308
+ {
309
+ id: "",
310
+ mappingId: "",
311
+ order: 0,
312
+ make: "Toyota",
313
+ model: "Celica",
314
+ price: 35000
315
+ },
316
+ {
317
+ id: "",
318
+ mappingId: "",
319
+ order: 1,
320
+ make: "Ford",
321
+ model: "Mondeo",
322
+ price: 32000
323
+ },
324
+ {
325
+ id: "",
326
+ mappingId: "",
327
+ order: 2,
328
+ make: "Porsche",
329
+ model: "Boxter",
330
+ price: 72000
331
+ },
332
+ {
333
+ id: "",
334
+ mappingId: "",
335
+ order: 11,
336
+ make: "BMW",
337
+ model: "Sedan",
338
+ price: 66000
339
+ },
340
+ {
341
+ id: "",
342
+ mappingId: "",
343
+ order: 8,
344
+ make: "Nissan",
345
+ model: "March",
346
+ price: 61000
347
+ },
348
+ {
349
+ id: "",
350
+ mappingId: "",
351
+ order: 4,
352
+ make: "Lexus",
353
+ model: "RX",
354
+ price: 56000
355
+ },
356
+ {
357
+ id: "",
358
+ mappingId: "",
359
+ order: 5,
360
+ make: "Audi",
361
+ model: "A6 Allroad",
362
+ price: 45000
363
+ },
364
+ {
365
+ id: "",
366
+ mappingId: "",
367
+ order: 6,
368
+ make: "Mazda",
369
+ model: "MX-5",
370
+ price: 36000
371
+ },
372
+ {
373
+ id: "",
374
+ mappingId: "",
375
+ order: 7,
376
+ make: "Mercedes-Benz",
377
+ model: "Cabriolet",
378
+ price: 86000
379
+ },
380
+ {
381
+ id: "",
382
+ mappingId: "",
383
+ order: 9,
384
+ make: "Volkswagen",
385
+ model: "Beetle",
386
+ price: 68000
387
+ },
388
+ {
389
+ id: "",
390
+ mappingId: "",
391
+ order: 10,
392
+ make: "Honda",
393
+ model: "City",
394
+ price: 69000
395
+ },
396
+ {
397
+ id: "",
398
+ mappingId: "",
399
+ order: 12,
400
+ make: "Volvo",
401
+ model: "S60",
402
+ price: 71000
403
+ },
404
+ {
405
+ id: "",
406
+ mappingId: "",
407
+ order: 3,
408
+ make: "Subaru",
409
+ model: "BRZ",
410
+ price: 48000
411
+ }
412
+ ];
413
+ return {
414
+ WTableEdit: {
415
+ name: "Car Price",
416
+ description:
417
+ "The relationship between different car types and prices",
418
+ opt1: {
419
+ keys: keys1,
420
+ kpHeadFilterType: kpHeadFilterType1,
421
+ rows: rows1
422
+ },
423
+ opt2: {
424
+ keys: keys2,
425
+ kpHeadFilterType: kpHeadFilterType2,
426
+ rows: rows2
427
+ },
428
+ opt3: {
429
+ keys: keys2,
430
+ kpHeadFilterType: kpHeadFilterType2,
431
+ rows: rows2,
432
+ kpHead: {
433
+ id: "主鍵",
434
+ mappingId: "所屬主鍵",
435
+ order: "順序",
436
+ make: "Ecirp",
437
+ model: "Ledom",
438
+ price: "Ecirp",
439
+ isActive: "有效"
440
+ }
441
+ },
442
+ opt4: {
443
+ keys: keys2,
444
+ kpHeadFilterType: kpHeadFilterType2,
445
+ rows: rows2,
446
+ beforeAddRow: function(newRow) {
447
+ newRow.id = "id-random-" + Math.random();
448
+ return newRow;
449
+ }
450
+ },
451
+ opt5: {
452
+ keys: keys2,
453
+ kpHeadFilterType: kpHeadFilterType2,
454
+ rows: rows2,
455
+ kpConvertKeysWhenUploadData: {
456
+ makeTemp: "make",
457
+ modelTemp: "model",
458
+ priceTemp: "price"
459
+ }
460
+ },
461
+ opt6: {
462
+ keys: keys2,
463
+ rows: rows2,
464
+ optForUploadData: {
465
+ //input for uploadData in w-aggrid-vue, https://github.com/yuda-lyu/w-aggrid-vue
466
+ beforeUpload: null,
467
+ parseSheetInd: 1 //取第2個sheet, 預設0(取第1個sheet)
468
+ }
469
+ },
470
+ opt7: {
471
+ keys: keys3,
472
+ kpHeadFilterType: kpHeadFilterType3,
473
+ rows: rows3,
474
+ modifyDataWhenSave: function(rows) {
475
+ console.log("modifyDataWhenSave", rows);
476
+ for (let k = 0; k < rows.length; k++) {
477
+ let v = rows[k];
478
+ v.id = "id-random-" + Math.random();
479
+ v.mappingId = "auto_car_table";
480
+ v.order = k;
481
+ v.isActive = "y";
482
+ }
483
+ return rows;
484
+ }
485
+ },
486
+ opt8: {
487
+ keys: keys1,
488
+ kpHeadFilterType: kpHeadFilterType1,
489
+ rows: rows1,
490
+ kpCellFormat: {
491
+ //格式化僅影響顯示與下載, 排序、過濾、編輯與save回傳之rows仍為原值
492
+ make: function(value, key, row, params) {
493
+ //空值(null、undefined、空字串)會原樣傳入, 編輯模式新增列之各欄為空字串, 回傳null代表不格式化維持原值
494
+ if (value === null || value === undefined || value === "") {
495
+ return null;
496
+ }
497
+ return String(value).toUpperCase();
498
+ },
499
+ price: function(value, key, row, params) {
500
+ //空值不可直接Number(), 否則''與null會變成0.00
501
+ if (value === null || value === undefined || value === "") {
502
+ return null;
503
+ }
504
+ return Number(value).toLocaleString("en-US", {
505
+ minimumFractionDigits: 2,
506
+ maximumFractionDigits: 2
507
+ });
508
+ }
509
+ }
510
+ }
511
+ },
512
+ actions: []
513
+ };
514
+ },
515
+ mounted: function() {
516
+ return {};
517
+ },
518
+ computed: {},
519
+ methods: {
520
+ evSuccess: function(msg) {
521
+ console.log("evSuccess:", msg);
522
+ },
523
+ evError: function(msg) {
524
+ console.log("evError:", msg);
525
+ },
526
+ saveData: function() {
527
+ let data = this.$refs.table.save();
528
+ document.querySelector("#disp-save-data").innerHTML = JSON.stringify(
529
+ data,
530
+ null,
531
+ 2
532
+ );
533
+ console.log("saveData:", data);
534
+ }
535
+ }
536
+ });
537
+ </script>
538
+ </body>
539
+ </html>