yy-vue-easytable 2.27.2
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/LICENSE +22 -0
- package/README.md +187 -0
- package/libs/font/demo.css +539 -0
- package/libs/font/demo_index.html +400 -0
- package/libs/font/iconfont.css +57 -0
- package/libs/font/iconfont.eot +0 -0
- package/libs/font/iconfont.js +1 -0
- package/libs/font/iconfont.json +79 -0
- package/libs/font/iconfont.svg +56 -0
- package/libs/font/iconfont.ttf +0 -0
- package/libs/font/iconfont.woff +0 -0
- package/libs/font/iconfont.woff2 +0 -0
- package/libs/locale/lang/af-ZA.js +48 -0
- package/libs/locale/lang/en-US.js +48 -0
- package/libs/locale/lang/fr-FR.js +48 -0
- package/libs/locale/lang/ko-KR.js +48 -0
- package/libs/locale/lang/pt-BR.js +48 -0
- package/libs/locale/lang/ru-RU.js +48 -0
- package/libs/locale/lang/zh-CN.js +48 -0
- package/libs/locale/lang/zh-TW.js +48 -0
- package/libs/locale/lang/zu-ZA.js +48 -0
- package/libs/main.js +1 -0
- package/libs/theme-dark/base.css +1 -0
- package/libs/theme-dark/index.css +1253 -0
- package/libs/theme-dark/var.css +7 -0
- package/libs/theme-dark/ve-checkbox.css +150 -0
- package/libs/theme-dark/ve-contextmenu.css +71 -0
- package/libs/theme-dark/ve-dropdown.css +177 -0
- package/libs/theme-dark/ve-icon.css +10 -0
- package/libs/theme-dark/ve-loading.css +218 -0
- package/libs/theme-dark/ve-pagination.css +136 -0
- package/libs/theme-dark/ve-radio.css +111 -0
- package/libs/theme-dark/ve-select.css +50 -0
- package/libs/theme-dark/ve-table.css +385 -0
- package/libs/theme-default/base.css +1 -0
- package/libs/theme-default/index.css +1253 -0
- package/libs/theme-default/var.css +7 -0
- package/libs/theme-default/ve-checkbox.css +150 -0
- package/libs/theme-default/ve-contextmenu.css +71 -0
- package/libs/theme-default/ve-dropdown.css +177 -0
- package/libs/theme-default/ve-icon.css +10 -0
- package/libs/theme-default/ve-loading.css +218 -0
- package/libs/theme-default/ve-pagination.css +136 -0
- package/libs/theme-default/ve-radio.css +111 -0
- package/libs/theme-default/ve-select.css +50 -0
- package/libs/theme-default/ve-table.css +385 -0
- package/libs/umd/index.js +9 -0
- package/libs/ve-checkbox-group.js +1 -0
- package/libs/ve-checkbox.js +1 -0
- package/libs/ve-contextmenu.js +1 -0
- package/libs/ve-dropdown.js +1 -0
- package/libs/ve-icon.js +1 -0
- package/libs/ve-loading.js +1 -0
- package/libs/ve-locale.js +1 -0
- package/libs/ve-pagination.js +1 -0
- package/libs/ve-radio.js +1 -0
- package/libs/ve-select.js +1 -0
- package/libs/ve-table.js +1 -0
- package/package.json +142 -0
- package/packages/font/demo.css +539 -0
- package/packages/font/demo_index.html +400 -0
- package/packages/font/iconfont.css +57 -0
- package/packages/font/iconfont.eot +0 -0
- package/packages/font/iconfont.js +1 -0
- package/packages/font/iconfont.json +79 -0
- package/packages/font/iconfont.svg +56 -0
- package/packages/font/iconfont.ttf +0 -0
- package/packages/font/iconfont.woff +0 -0
- package/packages/font/iconfont.woff2 +0 -0
- package/packages/index.js +75 -0
- package/packages/src/comps/resize-observer/index.js +2 -0
- package/packages/src/comps/resize-observer/src/index.jsx +38 -0
- package/packages/src/directives/clickoutside.js +31 -0
- package/packages/src/directives/events-outside.js +79 -0
- package/packages/src/directives/focus.js +28 -0
- package/packages/src/locale/index.js +27 -0
- package/packages/src/locale/lang/af-ZA.js +29 -0
- package/packages/src/locale/lang/en-US.js +30 -0
- package/packages/src/locale/lang/fr-FR.js +29 -0
- package/packages/src/locale/lang/ko-KR.js +29 -0
- package/packages/src/locale/lang/pt-BR.js +29 -0
- package/packages/src/locale/lang/ru-RU.js +29 -0
- package/packages/src/locale/lang/zh-CN.js +30 -0
- package/packages/src/locale/lang/zh-TW.js +29 -0
- package/packages/src/locale/lang/zu-ZA.js +29 -0
- package/packages/src/mixins/emitter.js +39 -0
- package/packages/src/utils/animation-frame.js +39 -0
- package/packages/src/utils/auto-resize.js +179 -0
- package/packages/src/utils/constant.js +42 -0
- package/packages/src/utils/dom.js +239 -0
- package/packages/src/utils/event-key-codes.js +53 -0
- package/packages/src/utils/hooks-manager.js +76 -0
- package/packages/src/utils/index.js +161 -0
- package/packages/src/utils/mouse-event.js +24 -0
- package/packages/src/utils/random.js +6 -0
- package/packages/src/utils/request-animation-timeout.js +36 -0
- package/packages/src/utils/resize-event.js +40 -0
- package/packages/src/utils/scroll-bar.js +27 -0
- package/packages/style/ve-checkbox.less +179 -0
- package/packages/style/ve-contextmenu.less +76 -0
- package/packages/style/ve-dropdown.less +204 -0
- package/packages/style/ve-icon.less +3 -0
- package/packages/style/ve-loading.less +242 -0
- package/packages/style/ve-pagination.less +153 -0
- package/packages/style/ve-radio.less +126 -0
- package/packages/style/ve-select.less +48 -0
- package/packages/style/ve-table.less +539 -0
- package/packages/theme-dark/base.less +1 -0
- package/packages/theme-dark/index.less +12 -0
- package/packages/theme-dark/var.less +111 -0
- package/packages/theme-dark/ve-checkbox.less +2 -0
- package/packages/theme-dark/ve-contextmenu.less +2 -0
- package/packages/theme-dark/ve-dropdown.less +2 -0
- package/packages/theme-dark/ve-icon.less +2 -0
- package/packages/theme-dark/ve-loading.less +2 -0
- package/packages/theme-dark/ve-pagination.less +2 -0
- package/packages/theme-dark/ve-radio.less +2 -0
- package/packages/theme-dark/ve-select.less +2 -0
- package/packages/theme-dark/ve-table.less +2 -0
- package/packages/theme-default/base.less +1 -0
- package/packages/theme-default/index.less +12 -0
- package/packages/theme-default/var.less +111 -0
- package/packages/theme-default/ve-checkbox.less +2 -0
- package/packages/theme-default/ve-contextmenu.less +2 -0
- package/packages/theme-default/ve-dropdown.less +2 -0
- package/packages/theme-default/ve-icon.less +2 -0
- package/packages/theme-default/ve-loading.less +2 -0
- package/packages/theme-default/ve-pagination.less +2 -0
- package/packages/theme-default/ve-radio.less +2 -0
- package/packages/theme-default/ve-select.less +2 -0
- package/packages/theme-default/ve-table.less +2 -0
- package/packages/ve-checkbox/index.js +7 -0
- package/packages/ve-checkbox/src/index.jsx +175 -0
- package/packages/ve-checkbox/src/util/constant.js +14 -0
- package/packages/ve-checkbox/src/util/index.js +10 -0
- package/packages/ve-checkbox-group/index.js +7 -0
- package/packages/ve-checkbox-group/src/index.jsx +53 -0
- package/packages/ve-checkbox-group/src/util/constant.js +14 -0
- package/packages/ve-checkbox-group/src/util/index.js +10 -0
- package/packages/ve-contextmenu/index.js +7 -0
- package/packages/ve-contextmenu/src/index.jsx +731 -0
- package/packages/ve-contextmenu/src/util/constant.js +29 -0
- package/packages/ve-contextmenu/src/util/index.js +10 -0
- package/packages/ve-dropdown/index.js +7 -0
- package/packages/ve-dropdown/src/index.jsx +720 -0
- package/packages/ve-dropdown/src/util/constant.js +15 -0
- package/packages/ve-dropdown/src/util/index.js +10 -0
- package/packages/ve-icon/index.js +7 -0
- package/packages/ve-icon/src/index.jsx +52 -0
- package/packages/ve-icon/src/util/constant.js +10 -0
- package/packages/ve-icon/src/util/index.js +10 -0
- package/packages/ve-loading/index.js +8 -0
- package/packages/ve-loading/src/bounce.jsx +50 -0
- package/packages/ve-loading/src/flow.jsx +51 -0
- package/packages/ve-loading/src/grid.jsx +57 -0
- package/packages/ve-loading/src/index.js +106 -0
- package/packages/ve-loading/src/loading.jsx +63 -0
- package/packages/ve-loading/src/plane.jsx +38 -0
- package/packages/ve-loading/src/pulse.jsx +38 -0
- package/packages/ve-loading/src/util/constant.js +31 -0
- package/packages/ve-loading/src/util/index.js +10 -0
- package/packages/ve-loading/src/wave.jsx +53 -0
- package/packages/ve-locale/index.js +28 -0
- package/packages/ve-pagination/index.js +7 -0
- package/packages/ve-pagination/src/index.jsx +304 -0
- package/packages/ve-pagination/src/pager.jsx +166 -0
- package/packages/ve-pagination/src/util/constant.js +16 -0
- package/packages/ve-pagination/src/util/index.js +10 -0
- package/packages/ve-radio/index.js +7 -0
- package/packages/ve-radio/src/index.jsx +121 -0
- package/packages/ve-radio/src/util/constant.js +13 -0
- package/packages/ve-radio/src/util/index.js +10 -0
- package/packages/ve-select/index.js +7 -0
- package/packages/ve-select/src/index.jsx +193 -0
- package/packages/ve-select/src/util/constant.js +13 -0
- package/packages/ve-select/src/util/index.js +10 -0
- package/packages/ve-table/index.js +7 -0
- package/packages/ve-table/src/body/body-checkbox-content.jsx +126 -0
- package/packages/ve-table/src/body/body-radio-content.jsx +113 -0
- package/packages/ve-table/src/body/body-td.jsx +671 -0
- package/packages/ve-table/src/body/body-tr-scrolling.jsx +38 -0
- package/packages/ve-table/src/body/body-tr.jsx +383 -0
- package/packages/ve-table/src/body/expand-tr-icon.jsx +80 -0
- package/packages/ve-table/src/body/expand-tr.jsx +147 -0
- package/packages/ve-table/src/body/index.jsx +943 -0
- package/packages/ve-table/src/colgroup/index.jsx +48 -0
- package/packages/ve-table/src/column-resizer/index.jsx +318 -0
- package/packages/ve-table/src/editor/constant.js +5 -0
- package/packages/ve-table/src/editor/index.jsx +533 -0
- package/packages/ve-table/src/footer/footer-td.jsx +396 -0
- package/packages/ve-table/src/footer/footer-tr.jsx +249 -0
- package/packages/ve-table/src/footer/index.jsx +108 -0
- package/packages/ve-table/src/header/header-checkbox-content.jsx +69 -0
- package/packages/ve-table/src/header/header-filter-content.jsx +100 -0
- package/packages/ve-table/src/header/header-filter-custom-content.jsx +110 -0
- package/packages/ve-table/src/header/header-th.jsx +664 -0
- package/packages/ve-table/src/header/header-tr.jsx +255 -0
- package/packages/ve-table/src/header/index.jsx +195 -0
- package/packages/ve-table/src/index.jsx +4196 -0
- package/packages/ve-table/src/selection/constant.js +5 -0
- package/packages/ve-table/src/selection/index.jsx +1643 -0
- package/packages/ve-table/src/util/clipboard.js +428 -0
- package/packages/ve-table/src/util/constant.js +269 -0
- package/packages/ve-table/src/util/index.js +1585 -0
- package/packages/ve-table/src/util/store.js +14 -0
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
import { getFixedTotalWidthByColumnKey, clsName } from "../util";
|
|
2
|
+
import { getValByUnit } from "../../../src/utils/index.js";
|
|
3
|
+
|
|
4
|
+
import { COMPS_NAME } from "../util/constant";
|
|
5
|
+
import emitter from "../../../src/mixins/emitter";
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
name: COMPS_NAME.VE_TABLE_BODY_TD,
|
|
9
|
+
mixins: [emitter],
|
|
10
|
+
props: {
|
|
11
|
+
rowData: {
|
|
12
|
+
type: Object,
|
|
13
|
+
required: true,
|
|
14
|
+
},
|
|
15
|
+
column: {
|
|
16
|
+
type: Object,
|
|
17
|
+
required: true,
|
|
18
|
+
},
|
|
19
|
+
rowIndex: {
|
|
20
|
+
type: Number,
|
|
21
|
+
required: true,
|
|
22
|
+
},
|
|
23
|
+
colgroups: {
|
|
24
|
+
type: Array,
|
|
25
|
+
required: true,
|
|
26
|
+
},
|
|
27
|
+
rowKeyFieldName: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: null,
|
|
30
|
+
},
|
|
31
|
+
// cell span option
|
|
32
|
+
cellSpanOption: {
|
|
33
|
+
type: Object,
|
|
34
|
+
default: function () {
|
|
35
|
+
return null;
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
// cell style option
|
|
39
|
+
cellStyleOption: {
|
|
40
|
+
type: Object,
|
|
41
|
+
default: function () {
|
|
42
|
+
return null;
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
// event custom option
|
|
46
|
+
eventCustomOption: {
|
|
47
|
+
type: Object,
|
|
48
|
+
default: function () {
|
|
49
|
+
return null;
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
// cell selection key data
|
|
53
|
+
cellSelectionData: {
|
|
54
|
+
type: Object,
|
|
55
|
+
default: function () {
|
|
56
|
+
return null;
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
// footer rows
|
|
60
|
+
footerRows: {
|
|
61
|
+
type: Array,
|
|
62
|
+
default: function () {
|
|
63
|
+
return [];
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
// fixed footer
|
|
67
|
+
fixedFooter: {
|
|
68
|
+
type: Boolean,
|
|
69
|
+
default: true,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
computed: {
|
|
73
|
+
// is last left fixed column
|
|
74
|
+
isLastLeftFixedColumn() {
|
|
75
|
+
let result = false;
|
|
76
|
+
|
|
77
|
+
const { colgroups, column } = this;
|
|
78
|
+
|
|
79
|
+
const { fixed } = column;
|
|
80
|
+
|
|
81
|
+
if (fixed === "left") {
|
|
82
|
+
const { field } = column;
|
|
83
|
+
const leftFixedColumns = colgroups.filter(
|
|
84
|
+
(x) => x.fixed === "left",
|
|
85
|
+
);
|
|
86
|
+
const index = leftFixedColumns.findIndex(
|
|
87
|
+
(x) => x.field === field,
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
if (index === leftFixedColumns.length - 1) {
|
|
91
|
+
result = true;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return result;
|
|
95
|
+
},
|
|
96
|
+
// is first right fixed column
|
|
97
|
+
isfirstRightFixedColumn() {
|
|
98
|
+
let result = false;
|
|
99
|
+
|
|
100
|
+
const { colgroups, column } = this;
|
|
101
|
+
|
|
102
|
+
const { fixed } = column;
|
|
103
|
+
|
|
104
|
+
if (fixed === "right") {
|
|
105
|
+
const { field } = column;
|
|
106
|
+
const leftFixedColumns = colgroups.filter(
|
|
107
|
+
(x) => x.fixed === "right",
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
if (leftFixedColumns[0].field === field) {
|
|
111
|
+
result = true;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return result;
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
methods: {
|
|
118
|
+
/*
|
|
119
|
+
* @getBodyTdClass
|
|
120
|
+
* @desc get body td class
|
|
121
|
+
* @param {string} fixed - 固定方式
|
|
122
|
+
*/
|
|
123
|
+
getBodyTdClass({ fixed }) {
|
|
124
|
+
let result = {
|
|
125
|
+
[clsName("footer-td")]: true,
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const {
|
|
129
|
+
cellStyleOption,
|
|
130
|
+
rowData,
|
|
131
|
+
column,
|
|
132
|
+
rowIndex,
|
|
133
|
+
cellSelectionData,
|
|
134
|
+
rowKeyFieldName,
|
|
135
|
+
} = this;
|
|
136
|
+
|
|
137
|
+
// column fixed
|
|
138
|
+
if (fixed) {
|
|
139
|
+
result[clsName("fixed-left")] = fixed === "left";
|
|
140
|
+
result[clsName("fixed-right")] = fixed === "right";
|
|
141
|
+
result[clsName("last-left-fixed-column")] =
|
|
142
|
+
this.isLastLeftFixedColumn;
|
|
143
|
+
result[clsName("first-right-fixed-column")] =
|
|
144
|
+
this.isfirstRightFixedColumn;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// cell style option
|
|
148
|
+
if (
|
|
149
|
+
cellStyleOption &&
|
|
150
|
+
typeof cellStyleOption.footerCellClass === "function"
|
|
151
|
+
) {
|
|
152
|
+
const customClass = cellStyleOption.footerCellClass({
|
|
153
|
+
row: rowData,
|
|
154
|
+
column,
|
|
155
|
+
rowIndex,
|
|
156
|
+
});
|
|
157
|
+
if (customClass) {
|
|
158
|
+
result[customClass] = true;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
// cell selection option
|
|
162
|
+
if (cellSelectionData) {
|
|
163
|
+
const { rowKey, colKey } = cellSelectionData.currentCell;
|
|
164
|
+
if (
|
|
165
|
+
rowData[rowKeyFieldName] === rowKey &&
|
|
166
|
+
column["key"] === colKey
|
|
167
|
+
) {
|
|
168
|
+
result[clsName("cell-selection")] = true;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return result;
|
|
173
|
+
},
|
|
174
|
+
|
|
175
|
+
/*
|
|
176
|
+
* @getBodyTdStyle
|
|
177
|
+
* @desc get body td style
|
|
178
|
+
* @param {any} key - column key
|
|
179
|
+
* @param {string} align - 居中方式
|
|
180
|
+
* @param {bool} fixed - 固定方式
|
|
181
|
+
*/
|
|
182
|
+
getBodyTdStyle({ key, align, fixed }) {
|
|
183
|
+
let result = {};
|
|
184
|
+
|
|
185
|
+
const { colgroups, rowIndex, footerRows } = this;
|
|
186
|
+
|
|
187
|
+
// text align
|
|
188
|
+
result["text-align"] = align || "center";
|
|
189
|
+
|
|
190
|
+
// fixed left total width or right total width
|
|
191
|
+
if (fixed) {
|
|
192
|
+
let totalWidth = 0;
|
|
193
|
+
// column index
|
|
194
|
+
const columnIndex = colgroups.findIndex((x) => x.key === key);
|
|
195
|
+
if (
|
|
196
|
+
(fixed === "left" && columnIndex > 0) ||
|
|
197
|
+
(fixed === "right" && columnIndex < colgroups.length - 1)
|
|
198
|
+
) {
|
|
199
|
+
totalWidth = getFixedTotalWidthByColumnKey({
|
|
200
|
+
colgroups,
|
|
201
|
+
colKey: key,
|
|
202
|
+
fixed,
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
totalWidth = getValByUnit(totalWidth);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
result["left"] = fixed === "left" ? totalWidth : "";
|
|
209
|
+
result["right"] = fixed === "right" ? totalWidth : "";
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// footer rows th fixed bottom
|
|
213
|
+
if (this.fixedFooter) {
|
|
214
|
+
let rowHeight = 0;
|
|
215
|
+
if (rowIndex !== footerRows.length - 1) {
|
|
216
|
+
rowHeight = footerRows.reduce(
|
|
217
|
+
(total, currentVal, index) => {
|
|
218
|
+
return index > rowIndex
|
|
219
|
+
? currentVal.rowHeight + total
|
|
220
|
+
: total;
|
|
221
|
+
},
|
|
222
|
+
0,
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
rowHeight = getValByUnit(rowHeight);
|
|
226
|
+
|
|
227
|
+
result["bottom"] = rowHeight;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return result;
|
|
231
|
+
},
|
|
232
|
+
|
|
233
|
+
// get render content
|
|
234
|
+
getRenderContent(h) {
|
|
235
|
+
let content = null;
|
|
236
|
+
|
|
237
|
+
const { column, rowData, rowIndex } = this;
|
|
238
|
+
|
|
239
|
+
// has render function
|
|
240
|
+
if (typeof column.renderFooterCell === "function") {
|
|
241
|
+
const renderResult = column.renderFooterCell(
|
|
242
|
+
{
|
|
243
|
+
row: rowData,
|
|
244
|
+
column,
|
|
245
|
+
rowIndex,
|
|
246
|
+
},
|
|
247
|
+
h,
|
|
248
|
+
);
|
|
249
|
+
|
|
250
|
+
content = renderResult;
|
|
251
|
+
} else {
|
|
252
|
+
content = rowData[column.field];
|
|
253
|
+
}
|
|
254
|
+
return content;
|
|
255
|
+
},
|
|
256
|
+
|
|
257
|
+
// get cell span
|
|
258
|
+
getCellSpan() {
|
|
259
|
+
const { cellSpanOption, rowData, column, rowIndex } = this;
|
|
260
|
+
let rowspan = 1;
|
|
261
|
+
let colspan = 1;
|
|
262
|
+
|
|
263
|
+
if (cellSpanOption) {
|
|
264
|
+
const { footerCellSpan } = cellSpanOption;
|
|
265
|
+
|
|
266
|
+
if (typeof footerCellSpan === "function") {
|
|
267
|
+
const result = footerCellSpan({
|
|
268
|
+
row: rowData,
|
|
269
|
+
column,
|
|
270
|
+
rowIndex,
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
if (typeof result === "object") {
|
|
274
|
+
rowspan = result.rowspan;
|
|
275
|
+
colspan = result.colspan;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
return { rowspan, colspan };
|
|
281
|
+
},
|
|
282
|
+
// cell click
|
|
283
|
+
cellClick(e, fn) {
|
|
284
|
+
fn && fn(e);
|
|
285
|
+
},
|
|
286
|
+
// dblclick
|
|
287
|
+
cellDblclick(e, fn) {
|
|
288
|
+
fn && fn(e);
|
|
289
|
+
},
|
|
290
|
+
// contextmenu
|
|
291
|
+
cellContextmenu(e, fn) {
|
|
292
|
+
fn && fn(e);
|
|
293
|
+
},
|
|
294
|
+
// mouseenter
|
|
295
|
+
cellMouseenter(e, fn) {
|
|
296
|
+
fn && fn(e);
|
|
297
|
+
},
|
|
298
|
+
// mouseleave
|
|
299
|
+
cellMouseleave(e, fn) {
|
|
300
|
+
fn && fn(e);
|
|
301
|
+
},
|
|
302
|
+
// mousemove
|
|
303
|
+
cellMousemove(e, fn) {
|
|
304
|
+
fn && fn(e);
|
|
305
|
+
},
|
|
306
|
+
// mouseover
|
|
307
|
+
cellMouseover(e, fn) {
|
|
308
|
+
fn && fn(e);
|
|
309
|
+
},
|
|
310
|
+
// mousedown
|
|
311
|
+
cellMousedown(e, fn) {
|
|
312
|
+
fn && fn(e);
|
|
313
|
+
},
|
|
314
|
+
// mouseup
|
|
315
|
+
cellMouseup(e, fn) {
|
|
316
|
+
fn && fn(e);
|
|
317
|
+
},
|
|
318
|
+
},
|
|
319
|
+
render(h) {
|
|
320
|
+
const { column, rowData, rowIndex, eventCustomOption } = this;
|
|
321
|
+
|
|
322
|
+
const { rowspan, colspan } = this.getCellSpan();
|
|
323
|
+
if (!rowspan || !colspan) {
|
|
324
|
+
return null;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// custom on cell event
|
|
328
|
+
let customEvents = {};
|
|
329
|
+
if (eventCustomOption) {
|
|
330
|
+
const { footerCellEvents } = eventCustomOption;
|
|
331
|
+
customEvents = footerCellEvents
|
|
332
|
+
? footerCellEvents({ row: rowData, column, rowIndex })
|
|
333
|
+
: {};
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
const {
|
|
337
|
+
click,
|
|
338
|
+
dblclick,
|
|
339
|
+
contextmenu,
|
|
340
|
+
mouseenter,
|
|
341
|
+
mouseleave,
|
|
342
|
+
mousemove,
|
|
343
|
+
mouseover,
|
|
344
|
+
mousedown,
|
|
345
|
+
mouseup,
|
|
346
|
+
} = customEvents;
|
|
347
|
+
|
|
348
|
+
const events = {
|
|
349
|
+
click: (e) => {
|
|
350
|
+
this.cellClick(e, click);
|
|
351
|
+
},
|
|
352
|
+
dblclick: (e) => {
|
|
353
|
+
this.cellDblclick(e, dblclick);
|
|
354
|
+
},
|
|
355
|
+
contextmenu: (e) => {
|
|
356
|
+
this.cellContextmenu(e, contextmenu);
|
|
357
|
+
},
|
|
358
|
+
mouseenter: (e) => {
|
|
359
|
+
this.cellMouseenter(e, mouseenter);
|
|
360
|
+
},
|
|
361
|
+
mouseleave: (e) => {
|
|
362
|
+
this.cellMouseleave(e, mouseleave);
|
|
363
|
+
},
|
|
364
|
+
mousemove: (e) => {
|
|
365
|
+
this.cellMousemove(e, mousemove);
|
|
366
|
+
},
|
|
367
|
+
mouseover: (e) => {
|
|
368
|
+
this.cellMouseover(e, mouseover);
|
|
369
|
+
},
|
|
370
|
+
mousedown: (e) => {
|
|
371
|
+
this.cellMousedown(e, mousedown);
|
|
372
|
+
},
|
|
373
|
+
mouseup: (e) => {
|
|
374
|
+
this.cellMouseup(e, mouseup);
|
|
375
|
+
},
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
// td props
|
|
379
|
+
const tdProps = {
|
|
380
|
+
class: this.getBodyTdClass(column),
|
|
381
|
+
style: this.getBodyTdStyle(column),
|
|
382
|
+
attrs: {
|
|
383
|
+
rowspan,
|
|
384
|
+
colspan,
|
|
385
|
+
},
|
|
386
|
+
on: events,
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
return (
|
|
390
|
+
<td {...tdProps}>
|
|
391
|
+
{/* other cell content */}
|
|
392
|
+
{this.getRenderContent(h)}
|
|
393
|
+
</td>
|
|
394
|
+
);
|
|
395
|
+
},
|
|
396
|
+
};
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import FooterTd from "./footer-td";
|
|
2
|
+
import { clsName } from "../util";
|
|
3
|
+
import { COMPS_NAME, EMIT_EVENTS, COMPS_CUSTOM_ATTRS } from "../util/constant";
|
|
4
|
+
import VueDomResizeObserver from "../../../src/comps/resize-observer";
|
|
5
|
+
import emitter from "../../../src/mixins/emitter";
|
|
6
|
+
export default {
|
|
7
|
+
name: COMPS_NAME.VE_TABLE_BODY_TR,
|
|
8
|
+
mixins: [emitter],
|
|
9
|
+
props: {
|
|
10
|
+
rowData: {
|
|
11
|
+
type: Object,
|
|
12
|
+
required: true,
|
|
13
|
+
},
|
|
14
|
+
rowIndex: {
|
|
15
|
+
type: Number,
|
|
16
|
+
required: true,
|
|
17
|
+
},
|
|
18
|
+
colgroups: {
|
|
19
|
+
type: Array,
|
|
20
|
+
required: true,
|
|
21
|
+
},
|
|
22
|
+
rowKeyFieldName: {
|
|
23
|
+
type: String,
|
|
24
|
+
default: null,
|
|
25
|
+
},
|
|
26
|
+
// cell style option
|
|
27
|
+
cellStyleOption: {
|
|
28
|
+
type: Object,
|
|
29
|
+
default: function () {
|
|
30
|
+
return null;
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
// cell span option
|
|
34
|
+
cellSpanOption: {
|
|
35
|
+
type: Object,
|
|
36
|
+
default: function () {
|
|
37
|
+
return null;
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
// event custom option
|
|
41
|
+
eventCustomOption: {
|
|
42
|
+
type: Object,
|
|
43
|
+
default: function () {
|
|
44
|
+
return null;
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
// cell selection key data
|
|
48
|
+
cellSelectionData: {
|
|
49
|
+
type: Object,
|
|
50
|
+
default: function () {
|
|
51
|
+
return null;
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
// footer rows
|
|
55
|
+
footerRows: {
|
|
56
|
+
type: Array,
|
|
57
|
+
default: function () {
|
|
58
|
+
return [];
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
// fixed footer
|
|
62
|
+
fixedFooter: {
|
|
63
|
+
type: Boolean,
|
|
64
|
+
default: true,
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
computed: {
|
|
68
|
+
// current row key
|
|
69
|
+
currentRowKey() {
|
|
70
|
+
const { rowKeyFieldName } = this;
|
|
71
|
+
return rowKeyFieldName ? this.rowData[rowKeyFieldName] : null;
|
|
72
|
+
},
|
|
73
|
+
// tr class
|
|
74
|
+
trClass() {
|
|
75
|
+
let result = null;
|
|
76
|
+
|
|
77
|
+
result = {
|
|
78
|
+
[clsName("footer-tr")]: true,
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
return result;
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
methods: {
|
|
86
|
+
// tr height change
|
|
87
|
+
trHeightChange({ height }) {
|
|
88
|
+
/* this.$emit(EMIT_EVENTS.FOOTER_ROW_HEIGHT_CHANGE, {
|
|
89
|
+
rowIndex: this.rowIndex,
|
|
90
|
+
height: height
|
|
91
|
+
}); */
|
|
92
|
+
|
|
93
|
+
this.dispatch(
|
|
94
|
+
COMPS_NAME.VE_TABLE,
|
|
95
|
+
EMIT_EVENTS.FOOTER_ROW_HEIGHT_CHANGE,
|
|
96
|
+
{
|
|
97
|
+
rowIndex: this.rowIndex,
|
|
98
|
+
height: height,
|
|
99
|
+
},
|
|
100
|
+
);
|
|
101
|
+
},
|
|
102
|
+
// click
|
|
103
|
+
rowClick(e, fn) {
|
|
104
|
+
fn && fn(e);
|
|
105
|
+
|
|
106
|
+
/* this.dispatch(COMPS_NAME.VE_TABLE_BODY, EMIT_EVENTS.BODY_TR_CLICK, {
|
|
107
|
+
rowData,
|
|
108
|
+
rowIndex
|
|
109
|
+
}); */
|
|
110
|
+
},
|
|
111
|
+
// dblclick
|
|
112
|
+
rowDblclick(e, fn) {
|
|
113
|
+
fn && fn(e);
|
|
114
|
+
},
|
|
115
|
+
// contextmenu
|
|
116
|
+
rowContextmenu(e, fn) {
|
|
117
|
+
fn && fn(e);
|
|
118
|
+
},
|
|
119
|
+
// mouseenter
|
|
120
|
+
rowMouseenter(e, fn) {
|
|
121
|
+
fn && fn(e);
|
|
122
|
+
},
|
|
123
|
+
// mouseleave
|
|
124
|
+
rowMouseleave(e, fn) {
|
|
125
|
+
fn && fn(e);
|
|
126
|
+
},
|
|
127
|
+
// mousemove
|
|
128
|
+
rowMousemove(e, fn) {
|
|
129
|
+
fn && fn(e);
|
|
130
|
+
},
|
|
131
|
+
// mouseover
|
|
132
|
+
rowMouseover(e, fn) {
|
|
133
|
+
fn && fn(e);
|
|
134
|
+
},
|
|
135
|
+
// mousedown
|
|
136
|
+
rowMousedown(e, fn) {
|
|
137
|
+
fn && fn(e);
|
|
138
|
+
},
|
|
139
|
+
// mouseup
|
|
140
|
+
rowMouseup(e, fn) {
|
|
141
|
+
fn && fn(e);
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
|
|
145
|
+
render() {
|
|
146
|
+
const {
|
|
147
|
+
colgroups,
|
|
148
|
+
rowKeyFieldName,
|
|
149
|
+
rowIndex,
|
|
150
|
+
rowData,
|
|
151
|
+
cellStyleOption,
|
|
152
|
+
eventCustomOption,
|
|
153
|
+
} = this;
|
|
154
|
+
|
|
155
|
+
// get td content
|
|
156
|
+
const getTdContent = () => {
|
|
157
|
+
return colgroups.map((column) => {
|
|
158
|
+
const tdProps = {
|
|
159
|
+
key: column.key,
|
|
160
|
+
props: {
|
|
161
|
+
rowIndex,
|
|
162
|
+
rowData,
|
|
163
|
+
column,
|
|
164
|
+
colgroups,
|
|
165
|
+
rowKeyFieldName,
|
|
166
|
+
cellStyleOption,
|
|
167
|
+
cellSelectionData: this.cellSelectionData,
|
|
168
|
+
footerRows: this.footerRows,
|
|
169
|
+
fixedFooter: this.fixedFooter,
|
|
170
|
+
cellSpanOption: this.cellSpanOption,
|
|
171
|
+
eventCustomOption: this.eventCustomOption,
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
return <FooterTd {...tdProps} />;
|
|
175
|
+
});
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
// custom on row event
|
|
179
|
+
let customEvents = {};
|
|
180
|
+
if (eventCustomOption) {
|
|
181
|
+
const { footerRowEvents } = eventCustomOption;
|
|
182
|
+
customEvents = footerRowEvents
|
|
183
|
+
? footerRowEvents({ row: rowData, rowIndex })
|
|
184
|
+
: {};
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const {
|
|
188
|
+
click,
|
|
189
|
+
dblclick,
|
|
190
|
+
contextmenu,
|
|
191
|
+
mouseenter,
|
|
192
|
+
mouseleave,
|
|
193
|
+
mousemove,
|
|
194
|
+
mouseover,
|
|
195
|
+
mousedown,
|
|
196
|
+
mouseup,
|
|
197
|
+
} = customEvents;
|
|
198
|
+
|
|
199
|
+
const events = {
|
|
200
|
+
click: (e) => {
|
|
201
|
+
this.rowClick(e, click);
|
|
202
|
+
},
|
|
203
|
+
dblclick: (e) => {
|
|
204
|
+
this.rowDblclick(e, dblclick);
|
|
205
|
+
},
|
|
206
|
+
contextmenu: (e) => {
|
|
207
|
+
this.rowContextmenu(e, contextmenu);
|
|
208
|
+
},
|
|
209
|
+
mouseenter: (e) => {
|
|
210
|
+
this.rowMouseenter(e, mouseenter);
|
|
211
|
+
},
|
|
212
|
+
mouseleave: (e) => {
|
|
213
|
+
this.rowMouseleave(e, mouseleave);
|
|
214
|
+
},
|
|
215
|
+
mousemove: (e) => {
|
|
216
|
+
this.rowMousemove(e, mousemove);
|
|
217
|
+
},
|
|
218
|
+
mouseover: (e) => {
|
|
219
|
+
this.rowMouseover(e, mouseover);
|
|
220
|
+
},
|
|
221
|
+
mousedown: (e) => {
|
|
222
|
+
this.rowMousedown(e, mousedown);
|
|
223
|
+
},
|
|
224
|
+
mouseup: (e) => {
|
|
225
|
+
this.rowMouseup(e, mouseup);
|
|
226
|
+
},
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
const props = {
|
|
230
|
+
class: this.trClass,
|
|
231
|
+
props: {
|
|
232
|
+
tagName: "tr",
|
|
233
|
+
},
|
|
234
|
+
attrs: {
|
|
235
|
+
[COMPS_CUSTOM_ATTRS.BODY_ROW_KEY]: this.currentRowKey,
|
|
236
|
+
},
|
|
237
|
+
nativeOn: events,
|
|
238
|
+
on: {
|
|
239
|
+
"on-dom-resize-change": this.trHeightChange,
|
|
240
|
+
},
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
return (
|
|
244
|
+
<VueDomResizeObserver {...props}>
|
|
245
|
+
{getTdContent()}
|
|
246
|
+
</VueDomResizeObserver>
|
|
247
|
+
);
|
|
248
|
+
},
|
|
249
|
+
};
|