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