md-iview 1.0.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. package/README.md +2 -0
  2. package/package.json +116 -0
  3. package/src/components/libs/util.js +117 -0
  4. package/src/components/md-error-page/403.less +92 -0
  5. package/src/components/md-error-page/403.vue +34 -0
  6. package/src/components/md-error-page/404.less +60 -0
  7. package/src/components/md-error-page/404.vue +34 -0
  8. package/src/components/md-error-page/500.less +73 -0
  9. package/src/components/md-error-page/500.vue +36 -0
  10. package/src/components/md-error-page/demo/index.less +22 -0
  11. package/src/components/md-error-page/demo/index.vue +97 -0
  12. package/src/components/md-form-item/index.js +3 -0
  13. package/src/components/md-icon/icon.vue +77 -0
  14. package/src/components/md-icon/icons.js +5 -0
  15. package/src/components/md-icon/index.js +11 -0
  16. package/src/components/md-icon/style/index.less +1 -0
  17. package/src/components/md-loading/index.js +55 -0
  18. package/src/components/md-loading/index.vue +53 -0
  19. package/src/components/md-loading/md-loading.js +38 -0
  20. package/src/components/md-print/demo/index.vue +260 -0
  21. package/src/components/md-print/index.js +123 -0
  22. package/src/components/md-rich-editor/index.vue +69 -0
  23. package/src/components/md-rich-editor/module/image-extend/index.js +216 -0
  24. package/src/components/md-scroll-bar/demo/index.vue +102 -0
  25. package/src/components/md-scroll-bar/index.js +3 -0
  26. package/src/components/md-scroll-bar/index.less +90 -0
  27. package/src/components/md-scroll-bar/index.vue +250 -0
  28. package/src/components/md-select/index.js +7 -0
  29. package/src/components/md-select/select.vue +841 -0
  30. package/src/components/md-shrinkable-menu/components/sidebarMenu.vue +167 -0
  31. package/src/components/md-shrinkable-menu/components/sidebarMenuShrink.vue +119 -0
  32. package/src/components/md-shrinkable-menu/demo/data/cachePage.js +1 -0
  33. package/src/components/md-shrinkable-menu/demo/data/currentPath.js +9 -0
  34. package/src/components/md-shrinkable-menu/demo/data/menu.js +575 -0
  35. package/src/components/md-shrinkable-menu/demo/data/menu2.js +1017 -0
  36. package/src/components/md-shrinkable-menu/demo/data/pageTagsList.js +153 -0
  37. package/src/components/md-shrinkable-menu/demo/index.less +297 -0
  38. package/src/components/md-shrinkable-menu/demo/index.vue +285 -0
  39. package/src/components/md-shrinkable-menu/index.vue +112 -0
  40. package/src/components/md-shrinkable-menu/sidebar.vue +195 -0
  41. package/src/components/md-shrinkable-menu/styles/menu.less +5 -0
  42. package/src/components/md-shrinkable-menu/styles/sidebar.less +363 -0
  43. package/src/components/md-split-pane/demo/index.vue +101 -0
  44. package/src/components/md-split-pane/index.js +3 -0
  45. package/src/components/md-split-pane/index.less +93 -0
  46. package/src/components/md-split-pane/index.vue +230 -0
  47. package/src/components/md-table/action-tooltip.vue +45 -0
  48. package/src/components/md-table/can-edit-v2.vue +823 -0
  49. package/src/components/md-table/can-edit.vue +723 -0
  50. package/src/components/md-table/custom-cell.vue +71 -0
  51. package/src/components/md-table/date-picker-cell-v2.vue +48 -0
  52. package/src/components/md-table/date-picker-cell.vue +39 -0
  53. package/src/components/md-table/demo/data/search.js +67 -0
  54. package/src/components/md-table/demo/data/table2csv.js +200 -0
  55. package/src/components/md-table/demo/data/table2excel.js +239 -0
  56. package/src/components/md-table/demo/data/table_data.js +251 -0
  57. package/src/components/md-table/demo/editable-table.vue +144 -0
  58. package/src/components/md-table/demo/exportable-table.vue +124 -0
  59. package/src/components/md-table/demo/widgets/header-search.vue +88 -0
  60. package/src/components/md-table/drop-down-cell-v2.vue +87 -0
  61. package/src/components/md-table/drop-down-cell.vue +81 -0
  62. package/src/components/md-table/editable-expand.vue +143 -0
  63. package/src/components/md-table/expand.vue +97 -0
  64. package/src/components/md-table/index.vue +53 -0
  65. package/src/components/md-table/iview-table/cell.vue +99 -0
  66. package/src/components/md-table/iview-table/expand.js +21 -0
  67. package/src/components/md-table/iview-table/export-csv.js +76 -0
  68. package/src/components/md-table/iview-table/header.js +16 -0
  69. package/src/components/md-table/iview-table/index.js +2 -0
  70. package/src/components/md-table/iview-table/mixin.js +31 -0
  71. package/src/components/md-table/iview-table/table-body.vue +101 -0
  72. package/src/components/md-table/iview-table/table-head.vue +311 -0
  73. package/src/components/md-table/iview-table/table-tr.vue +31 -0
  74. package/src/components/md-table/iview-table/table.vue +1026 -0
  75. package/src/components/md-table/iview-table/util.js +93 -0
  76. package/src/components/md-table/libs/table2excel.js +100 -0
  77. package/src/components/md-table/select-cell-v2.vue +64 -0
  78. package/src/components/md-table/select-cell.vue +46 -0
  79. package/src/components/md-table/table.less +76 -0
  80. package/src/components/md-toolbar/index.vue +171 -0
  81. package/src/components/md-tree/index.js +2 -0
  82. package/src/components/md-tree/node.vue +238 -0
  83. package/src/components/md-tree/render.js +17 -0
  84. package/src/components/md-tree/tree.vue +241 -0
  85. package/src/components/utilities/can.js +35 -0
  86. package/src/directives/index.js +34 -0
  87. package/src/directives/resize.js +27 -0
  88. package/src/directives/scroll.js +27 -0
  89. package/src/directives/style/bg-color.js +23 -0
  90. package/src/directives/style/color.js +23 -0
  91. package/src/directives/style/font-size.js +23 -0
  92. package/src/directives/style/height.js +23 -0
  93. package/src/directives/style/lineHeight.js +23 -0
  94. package/src/directives/style/margin.js +48 -0
  95. package/src/directives/style/opacity.js +23 -0
  96. package/src/directives/style/padding.js +48 -0
  97. package/src/directives/style/width.js +24 -0
  98. package/src/index.js +442 -0
  99. package/src/locale/lang.js +5 -0
  100. package/src/mixins/colorable.js +51 -0
  101. package/src/style/color/bezierEasing.less +110 -0
  102. package/src/style/color/colorPalette.less +75 -0
  103. package/src/style/color/colors.less +146 -0
  104. package/src/style/color/tinyColor.less +1184 -0
  105. package/src/style/common.less +72 -0
  106. package/src/style/components/_ripple.less +60 -0
  107. package/src/style/components/_shrinkable-menu.less +46 -0
  108. package/src/style/components/_toolbar.less +96 -0
  109. package/src/style/components/index.less +3 -0
  110. package/src/style/components/rich-editor.less +6 -0
  111. package/src/style/index.less +10 -0
  112. package/src/style/theme.less +155 -0
  113. package/src/utils/color.js +46 -0
  114. package/src/utils/console.js +105 -0
  115. package/src/utils/load.js +79 -0
  116. package/src/utils/mask.js +139 -0
  117. package/src/utils/mixins.js +5 -0
  118. package/src/utils/validate.js +271 -0
@@ -0,0 +1,823 @@
1
+ <template>
2
+ <div>
3
+ <Table
4
+ :ref="refs"
5
+ :loading="loading"
6
+ :columns="columnsList"
7
+ :data="thisTableData"
8
+ :border="border"
9
+ :show-header="showHeader"
10
+ v-bind="$attrs"
11
+ v-on="$listeners"
12
+ @on-selection-change="onSelectionChangeTable"
13
+ disabled-hover
14
+ >
15
+ <template slot="header">
16
+ <slot name="header"></slot>
17
+ </template>
18
+ <template slot="footer">
19
+ <slot name="footer"></slot>
20
+ </template>
21
+ <template slot="loading">
22
+ <slot name="loading"></slot>
23
+ </template>
24
+ </Table>
25
+ </div>
26
+ </template>
27
+
28
+ <script>
29
+ import Vue from "vue";
30
+ import DropDownCell from "./drop-down-cell-v2";
31
+ import DatePickerCell from "./date-picker-cell-v2";
32
+ import SelectCell from "./select-cell-v2";
33
+ import _isArray from "lodash/isArray";
34
+ import dayjs from "dayjs";
35
+ import _isObject from "lodash/isObject";
36
+ const cancelButton = (vm, h, currentRow, index) => {
37
+ return h(
38
+ "div",
39
+ {
40
+ style: {
41
+ margin: "0 5px"
42
+ },
43
+ class: "cursor-pointer",
44
+ on: {
45
+ click: () => {
46
+ vm.edittingStore[index] = currentRow;
47
+ vm.edittingStore[index].saving = true;
48
+ vm.thisTableData = JSON.parse(JSON.stringify(vm.edittingStore));
49
+ let edittingRow = vm.edittingStore[index];
50
+ edittingRow.editting = false;
51
+ edittingRow.saving = false;
52
+ vm.thisTableData = JSON.parse(JSON.stringify(vm.edittingStore));
53
+ vm.$emit("input", vm.handleBackdata(vm.thisTableData));
54
+ }
55
+ }
56
+ },
57
+ [
58
+ h("md-tooltip",{
59
+ props:{
60
+ content:'取消',
61
+ transfer:true,
62
+ }
63
+ }, [
64
+ h("md-icon", {
65
+ props: {
66
+ type: "md-close",
67
+ size:16,
68
+ }
69
+ })
70
+ ])
71
+
72
+ ]
73
+ );
74
+ };
75
+ const editButton = (vm, h, currentRow, index) => {
76
+ return h(
77
+ "div",
78
+ {
79
+ style: {
80
+ margin: "0 5px"
81
+ },
82
+ class: "cursor-pointer",
83
+ on: {
84
+ click: () => {
85
+ if (!currentRow.editting) {
86
+ if (currentRow.edittingCell) {
87
+ for (let name in currentRow.edittingCell) {
88
+ currentRow.edittingCell[name] = false;
89
+ vm.edittingStore[index].edittingCell[name] = false;
90
+ }
91
+ }
92
+ vm.edittingStore[index].editting = true;
93
+ vm.thisTableData = JSON.parse(JSON.stringify(vm.edittingStore));
94
+ vm.$emit("on-edit", false);
95
+ } else {
96
+ vm.edittingStore[index].saving = true;
97
+ vm.thisTableData = JSON.parse(JSON.stringify(vm.edittingStore));
98
+ let edittingRow = vm.edittingStore[index];
99
+ edittingRow.editting = false;
100
+ edittingRow.saving = false;
101
+ vm.thisTableData = JSON.parse(JSON.stringify(vm.edittingStore));
102
+ vm.$emit("on-edit", true);
103
+ vm.$emit("input", vm.handleBackdata(vm.thisTableData));
104
+ vm.$emit(
105
+ "on-change",
106
+ vm.handleBackdata(vm.thisTableData),
107
+ index,
108
+ vm.handleBackdata(vm.thisTableData)[index]
109
+ );
110
+ }
111
+ }
112
+ }
113
+ },
114
+ [
115
+ h("md-tooltip",{
116
+ props:{
117
+ content:currentRow.editting ? '保存' : '编辑',
118
+ transfer:true,
119
+ }
120
+ }, [
121
+ h("md-icon", {
122
+ props: {
123
+ type: currentRow.editting ? "md-checkmark" : "md-create",
124
+ size:16,
125
+ }
126
+ })
127
+ ])
128
+
129
+ ]
130
+ );
131
+ };
132
+ const placeholderButton = (vm, h, currentRow, index) => {
133
+ return h("div", {
134
+ style: {
135
+ margin: "0 5px",
136
+ minWidth: "20px"
137
+ },
138
+ class: "cursor-pointer"
139
+ });
140
+ };
141
+ const deleteButton = (vm, h, currentRow, index) => {
142
+ let isDelete = false;
143
+ return h("div", {}, [
144
+ h("md-modal", {
145
+ props: {
146
+ title: "您确定要删除这条数据吗?"
147
+ // transfer: true
148
+ },
149
+ on: {
150
+ input: () => {
151
+ this.$emit("input", isDelete);
152
+ },
153
+ "on-ok": () => {
154
+ vm.thisTableData.splice(index, 1);
155
+ vm.$emit("input", vm.handleBackdata(vm.thisTableData));
156
+ vm.$emit(
157
+ "on-delete",
158
+ vm.handleBackdata(vm.thisTableData),
159
+ index,
160
+ currentRow
161
+ );
162
+ }
163
+ }
164
+ }),
165
+ h(
166
+ "div",
167
+ {
168
+ class: "cursor-pointer",
169
+ style: {
170
+ margin: "0 5px"
171
+ },
172
+ props: {
173
+ type: "error",
174
+ placement: "top"
175
+ },
176
+ on: {
177
+ click: () => {
178
+ Vue.prototype.$MdModal.confirm({
179
+ title: vm.modalMsg, //"您确定要删除这条数据吗?",
180
+ // msg:"您确定要删除这条数据吗?",
181
+ onOk: () => {
182
+ vm.thisTableData.splice(index, 1);
183
+ vm.$emit("input", vm.handleBackdata(vm.thisTableData));
184
+ vm.$emit(
185
+ "on-delete",
186
+ vm.handleBackdata(vm.thisTableData),
187
+ index,
188
+ currentRow
189
+ );
190
+ }
191
+
192
+ // content: '<p>Content of dialog</p><p>Content of dialog</p>',
193
+ });
194
+ // isDelete = true;
195
+ }
196
+ }
197
+ },
198
+ [
199
+ h("md-tooltip",{
200
+ props:{
201
+ content:'删除',
202
+ transfer:true,
203
+ }
204
+ },
205
+ [
206
+ h("md-icon", {
207
+ props: {
208
+ type: "md-trash",
209
+ size:16,
210
+ }
211
+ })
212
+ ]
213
+ )
214
+
215
+ ]
216
+ )
217
+ ]);
218
+ };
219
+ const enableButton = (vm, h, currentRow, index) => {
220
+ return h(
221
+ "div",
222
+ {
223
+ style: {
224
+ margin: "0 5px"
225
+ },
226
+ class: "cursor-pointer",
227
+ on: {
228
+ click: () => {
229
+ currentRow.status = parseInt(currentRow.status) ? 0 : 1;
230
+ vm.$emit("input", vm.handleBackdata(vm.thisTableData));
231
+ vm.$emit(
232
+ "on-enable",
233
+ vm.handleBackdata(vm.thisTableData),
234
+ index,
235
+ currentRow
236
+ );
237
+ }
238
+ }
239
+ },
240
+ [
241
+ h('md-tooltip', {
242
+ props:{
243
+ content:'启动',
244
+ transfer:true,
245
+ },
246
+ },h("md-icon", {
247
+ props: {
248
+ type: parseInt(currentRow.status)
249
+ ? "remove_circle_outline"
250
+ : "finished"
251
+ // loading: currentRow.saving
252
+ }
253
+ }))
254
+ ]
255
+ );
256
+ };
257
+ const customButton = (vm, h, currentRow, index, item) => {
258
+ return h(
259
+ "div",
260
+ {
261
+ style: {
262
+ margin: "0 5px"
263
+ },
264
+ class: "cursor-pointer",
265
+ on: {
266
+ click: () => {
267
+ if (item.action) {
268
+ item.action(
269
+ vm.handleBackdata(vm.thisTableData),
270
+ index,
271
+ vm.handleBackdata(vm.thisTableData)[index]
272
+ );
273
+ }
274
+ vm.$emit(
275
+ "on-custom",
276
+ vm.handleBackdata(vm.thisTableData),
277
+ index,
278
+ vm.handleBackdata(vm.thisTableData)[index]
279
+ );
280
+ }
281
+ }
282
+ },
283
+ [
284
+ h("md-icon", {
285
+ props: {
286
+ type: item.icon //currentRow.editting ? "done" : "mode_edit"
287
+ // loading: currentRow.saving
288
+ }
289
+ })
290
+ ]
291
+ );
292
+ };
293
+ const drawerButton = (vm, h, currentRow, index) => {
294
+ return h(
295
+ "div",
296
+ {
297
+ style: {
298
+ margin: "0 5px"
299
+ },
300
+ class: "cursor-pointer",
301
+ on: {
302
+ click: () => {
303
+ vm.$emit(
304
+ "on-drawer",
305
+ vm.handleBackdata(vm.thisTableData),
306
+ index,
307
+ vm.handleBackdata(vm.thisTableData)[index]
308
+ );
309
+ }
310
+ }
311
+ },
312
+ [
313
+ h("md-icon", {
314
+ props: {
315
+ type: currentRow.editting ? "done" : "mode_edit"
316
+ // loading: currentRow.saving
317
+ }
318
+ })
319
+ ]
320
+ );
321
+ };
322
+ const incellEditBtn = (vm, h, param) => {
323
+ if (vm.hoverShow) {
324
+ return h(
325
+ "div",
326
+ {
327
+ class: {
328
+ "show-edit-btn": vm.hoverShow
329
+ }
330
+ },
331
+ [
332
+ h(
333
+ "div",
334
+ {
335
+ props: {
336
+ type: "text"
337
+ },
338
+ style: {
339
+ cursor: "pointer"
340
+ },
341
+ on: {
342
+ click: event => {
343
+ vm.edittingStore[param.index].edittingCell[
344
+ param.column.key
345
+ ] = true;
346
+ vm.thisTableData = JSON.parse(JSON.stringify(vm.edittingStore));
347
+ }
348
+ }
349
+ },
350
+ [
351
+ h("md-icon", {
352
+ props: {
353
+ type: "md-create",
354
+ size:16,
355
+ }
356
+ })
357
+ ]
358
+ )
359
+ ]
360
+ );
361
+ } else {
362
+ return h(
363
+ "div",
364
+ {
365
+ props: {
366
+ type: "text"
367
+ },
368
+ style: {
369
+ cursor: "pointer"
370
+ },
371
+ on: {
372
+ click: event => {
373
+ vm.edittingStore[param.index].edittingCell[param.column.key] = true;
374
+ vm.thisTableData = JSON.parse(JSON.stringify(vm.edittingStore));
375
+ }
376
+ }
377
+ },
378
+ [
379
+ h("md-icon", {
380
+ props: {
381
+ type: "md-create",
382
+ size:16,
383
+ }
384
+ })
385
+ ]
386
+ );
387
+ }
388
+ };
389
+ const saveIncellEditBtn = (vm, h, param) => {
390
+ return h(
391
+ "div",
392
+ {
393
+ props: {
394
+ type: "text"
395
+ },
396
+ style: {
397
+ cursor: "pointer"
398
+ },
399
+ on: {
400
+ click: event => {
401
+ vm.edittingStore[param.index].edittingCell[param.column.key] = false;
402
+ vm.thisTableData = JSON.parse(JSON.stringify(vm.edittingStore));
403
+ vm.$emit("input", vm.handleBackdata(vm.thisTableData));
404
+ vm.$emit(
405
+ "on-cell-change",
406
+ vm.handleBackdata(vm.thisTableData),
407
+ param.index,
408
+ param.column.key
409
+ );
410
+ }
411
+ }
412
+ },
413
+ [
414
+ h("md-icon", {
415
+ props: {
416
+ type: "md-checkmark",
417
+ size:16,
418
+ }
419
+ })
420
+ ]
421
+ );
422
+ };
423
+ const cellInput = (vm, h, param, item) => {
424
+ return h("Input", {
425
+ props: {
426
+ type: "text",
427
+ value: vm.edittingStore[param.index][item.key]
428
+ },
429
+ on: {
430
+ "on-change"(event) {
431
+ let key = item.key;
432
+ vm.edittingStore[param.index][key] = event.target.value;
433
+ this.$emit(
434
+ "on-change-input",
435
+ vm.edittingStore[param.index][key],
436
+ param.index,
437
+ key
438
+ );
439
+ }
440
+ }
441
+ });
442
+ };
443
+ export default {
444
+ name: "canEditTable",
445
+ props: {
446
+ refs: String,
447
+ columnsList: Array,
448
+ value: Array,
449
+ url: String,
450
+ border: {
451
+ type: Boolean | String,
452
+ default: true
453
+ },
454
+ showHeader: {
455
+ type: Boolean,
456
+ default: true
457
+ },
458
+ loading: {
459
+ type: Boolean,
460
+ default: false
461
+ },
462
+ editIncell: {
463
+ type: Boolean,
464
+ default: false
465
+ },
466
+ hoverShow: {
467
+ type: Boolean,
468
+ default: false
469
+ },
470
+ modalMsg: {
471
+ type: String,
472
+ default: "您确定要删除这条数据吗"
473
+ }
474
+ },
475
+ data() {
476
+ return {
477
+ columns: [],
478
+ thisTableData: [],
479
+ edittingStore: []
480
+ };
481
+ },
482
+ created() {
483
+ this.init();
484
+ },
485
+ methods: {
486
+ init() {
487
+ let vm = this;
488
+ let editableCell = this.columnsList.filter(item => {
489
+ if (item.editable) {
490
+ if (item.editable === true) {
491
+ return item;
492
+ }
493
+ }
494
+ });
495
+ let cloneData = JSON.parse(JSON.stringify(this.value));
496
+ let res = [];
497
+ cloneData = cloneData ? cloneData : [];
498
+ res = cloneData.map((item, index) => {
499
+ let isEditting = false;
500
+ if (this.thisTableData[index]) {
501
+ if (this.thisTableData[index].editting) {
502
+ isEditting = true;
503
+ } else {
504
+ for (const cell in this.thisTableData[index].edittingCell) {
505
+ if (this.thisTableData[index].edittingCell[cell] === true) {
506
+ isEditting = true;
507
+ }
508
+ }
509
+ }
510
+ }
511
+ if (isEditting) {
512
+ return this.thisTableData[index];
513
+ } else {
514
+ this.$set(item, "editting", false);
515
+ let edittingCell = {};
516
+ editableCell.forEach(item => {
517
+ edittingCell[item.key] = false;
518
+ });
519
+ this.$set(item, "edittingCell", edittingCell);
520
+ return item;
521
+ }
522
+ });
523
+
524
+ this.thisTableData = res;
525
+ this.edittingStore = JSON.parse(JSON.stringify(this.thisTableData));
526
+ this.thisTableData && this.thisTableData.length && this.columnsList.forEach(item => {
527
+ if (item.editable) {
528
+ item.render = (h, param) => {
529
+ let currentRow = this.thisTableData[param.index];
530
+ // console.log("this.thisTableData[param.index];", this.thisTableData, this.thisTableData[param.index], param.index);
531
+ if (!currentRow.editting) {
532
+ if (this.editIncell) {
533
+ return h(
534
+ "Row",
535
+ {
536
+ props: {
537
+ type: "flex",
538
+ align: "middle",
539
+ justify: "center"
540
+ }
541
+ },
542
+ [
543
+ h(
544
+ "Col",
545
+ {
546
+ props: {
547
+ span: "22"
548
+ }
549
+ },
550
+ [
551
+ !currentRow.edittingCell[param.column.key]
552
+ ? h("span", currentRow[item.key])
553
+ : cellInput(this, h, param, item)
554
+ ]
555
+ ),
556
+ h(
557
+ "Col",
558
+ {
559
+ props: {
560
+ span: "2"
561
+ }
562
+ },
563
+ [
564
+ currentRow.edittingCell[param.column.key]
565
+ ? saveIncellEditBtn(this, h, param)
566
+ : incellEditBtn(this, h, param)
567
+ ]
568
+ )
569
+ ]
570
+ );
571
+ } else {
572
+ if(item.formatter) {
573
+ return h("span", item.formatter(param));
574
+ }
575
+
576
+ // if (item.dropdown && item.dropdown[currentRow[item.key]]) {
577
+ // return h("span", item.dropdown[currentRow[item.key]]);
578
+ // }
579
+
580
+ if (item.date) {
581
+ let val = currentRow[item.key] || item.date.default;
582
+ return h("span", dayjs(val).format(item.date.format));
583
+ }
584
+ /* if (item.date === true || item.date === false) {
585
+ let val = currentRow[item.key];
586
+ return h("span", dayjs(val).format("YYYY-MM-DD HH:mm:ss"));
587
+ }*/
588
+ /* if (item.date) {
589
+ // console.log(currentRow[item.key], item.key);
590
+ let val = currentRow[item.key];
591
+ return h("span", dayjs(val).format("YYYY-MM-DD HH:mm:ss"));
592
+ }*/
593
+ if (item.select) {
594
+ if (!item.select.multiple) {
595
+ if(item.formatter) {
596
+ return h("span", item.formatter(param));
597
+ }
598
+ return h("span", currentRow[item.key]);
599
+ }
600
+ let array = currentRow[item.key].toString().split(",");
601
+ let val = [];
602
+
603
+ for (let key in item.select.option) {
604
+ let elem = item.select.option[key];
605
+ let has = array.indexOf(elem.value) >= 0;
606
+ if (has) {
607
+ val.push(elem.label);
608
+ }
609
+ }
610
+
611
+ let tags = [];
612
+ val.forEach(elem => {
613
+ let obj = h("Tag", elem);
614
+ tags.push(obj);
615
+ });
616
+ return "div", tags;
617
+ }
618
+ return h("span", currentRow[item.key]);
619
+ }
620
+ } else {
621
+
622
+ if (item.dropdown) {
623
+ return h(DropDownCell, {
624
+ props: {
625
+ value:param.row[param.column.key],
626
+ editable: item.editable,
627
+ option:item.dropdown.option,
628
+ transfer:true,
629
+ },
630
+ on: {
631
+ "on-change": val => {
632
+ let key = param.column.key;
633
+ vm.edittingStore[param.index][key] = val;
634
+ }
635
+ }
636
+ });
637
+ }
638
+
639
+ if (item.select) {
640
+ let multiple = Boolean(item.select.multiple);
641
+ let value = [];
642
+ if (!multiple) {
643
+ item.select.option.map(item => {
644
+ if (item.value === param.row[param.column.key]) {
645
+ value.push(item.value);
646
+ }
647
+ });
648
+ } else {
649
+ value = param.row[param.column.key].toString().split(",");
650
+ }
651
+ return h(SelectCell, {
652
+ props: {
653
+ option: item.select.option,
654
+ value: value,
655
+ multiple: multiple,
656
+ transfer:true,
657
+ },
658
+ on: {
659
+ "on-change": val => {
660
+ let key = param.column.key;
661
+ if (_isArray(val)) {
662
+ let array = [...val]
663
+ val && (vm.edittingStore[param.index][key] = array.join(","));
664
+ } else {
665
+ val && (vm.edittingStore[param.index][key] = val);
666
+ }
667
+ }
668
+ }
669
+ });
670
+ }
671
+
672
+ if (item.date) {
673
+ let dateFormat = item.date.format;
674
+ let date = param.row.key || item.date.default
675
+ return h(DatePickerCell, {
676
+ props: {
677
+ date: date,//param.row.key,
678
+ transfer:true,
679
+ dateFormat:dateFormat,
680
+ },
681
+ on: {
682
+ "on-change": val => {
683
+ let key = param.column.key;
684
+ vm.edittingStore[param.index][key] = val;
685
+ //item.dropdown[cell.row[key]];
686
+ // vm.thisTableData = JSON.parse(JSON.stringify(vm.edittingStore));
687
+ // vm.$emit('input', vm.handleBackdata(vm.thisTableData));
688
+ }
689
+ }
690
+ });
691
+ }
692
+ return h("Input", {
693
+ props: {
694
+ type: "text",
695
+ value: currentRow[item.key]
696
+ },
697
+ on: {
698
+ "on-change"(event) {
699
+ let key = param.column.key;
700
+ vm.edittingStore[param.index][key] = event.target.value;
701
+ vm.$emit(
702
+ "on-change-input",
703
+ vm.edittingStore[param.index],
704
+ param.index,
705
+ key
706
+ );
707
+ }
708
+ }
709
+ });
710
+ }
711
+ };
712
+ } else {
713
+ if (!item.render && item.formatter) {
714
+ item.render = (h, param)=>{
715
+ let currentRow = this.thisTableData[param.index];
716
+ if(item.formatter) {
717
+ return h("span", item.formatter(param));
718
+ }
719
+ return h("span", currentRow[item.key]);
720
+ }
721
+ }
722
+ }
723
+ if (item.handle) {
724
+ item.render = (h, param) => {
725
+ let currentRowData = this.thisTableData[param.index];
726
+ let children = [];
727
+ item.handle.forEach(item => {
728
+ if (item === "edit") {
729
+ children.push(editButton(this, h, currentRowData, param.index));
730
+ if (currentRowData.editting) {
731
+ children.push(cancelButton(this, h, currentRowData, param.index))
732
+ }
733
+ } else if (item === "delete") {
734
+ children.push(
735
+ deleteButton(this, h, currentRowData, param.index)
736
+ );
737
+ } else if (item === "enable") {
738
+ children.push(
739
+ enableButton(this, h, currentRowData, param.index)
740
+ );
741
+ } else if (item === "drawer") {
742
+ children.push(
743
+ drawerButton(this, h, currentRowData, param.index)
744
+ );
745
+ } else if (item === "" || item === "placeholder") {
746
+ children.push(
747
+ placeholderButton(this, h, currentRowData, param.index)
748
+ );
749
+ } /*else if (item === 'cancel') {
750
+ children.push(cancelButton(this, h, currentRowData, param.index))
751
+ }*/
752
+
753
+ if (_isObject(item)) {
754
+ if (item.type === "custom") {
755
+ children.push(
756
+ customButton(this, h, currentRowData, param.index, item)
757
+ );
758
+ }
759
+ }
760
+ });
761
+ return h(
762
+ "div",
763
+ {
764
+ class: ["display-flex", "align-items-center", "table-column-operation"]
765
+ },
766
+ children
767
+ );
768
+ };
769
+ }
770
+ });
771
+ },
772
+ handleBackdata(data) {
773
+ let clonedData = JSON.parse(JSON.stringify(data));
774
+ clonedData.forEach(item => {
775
+ delete item.editting;
776
+ delete item.edittingCell;
777
+ delete item.saving;
778
+ });
779
+ return clonedData;
780
+ },
781
+ onSelectionChangeTable(selection) {
782
+ this.$emit("on-selection-change", selection);
783
+ }
784
+ },
785
+ watch: {
786
+ columnsList(to) {
787
+ this.init();
788
+ },
789
+ value(data) {
790
+ if (data) {
791
+ this.init();
792
+ }
793
+ },
794
+ columnsList(data) {
795
+ if (data) {
796
+ this.init();
797
+ }
798
+ }
799
+ }
800
+ };
801
+ </script>
802
+
803
+ <style lang="less">
804
+ .ivu-table-cell {
805
+ padding: 0 !important;
806
+ height: 47px;
807
+ line-height: 47px;
808
+ .ivu-input-wrapper {
809
+ height: inherit;
810
+ .ivu-input{
811
+ /*border: 0 !important;*/
812
+ height: inherit;
813
+ border-radius: 0px !important;
814
+ /*border:1px solid #d9d9d9*/
815
+ }
816
+ }
817
+ }
818
+
819
+ .table-column-operation {
820
+ padding: 0 16px;
821
+ }
822
+ </style>
823
+