@jetlinks-web/components 3.1.14 → 3.2.0
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/es/EditTable/CellRender.js +69 -3
- package/es/EditTable/EditTable.js +108 -165
- package/es/EditTable/FormItem.js +234 -96
- package/es/EditTable/consts.js +13 -13
- package/es/EditTable/context.js +3 -2
- package/es/EditTable/fieldPool.js +166 -0
- package/es/EditTable/hooks/index.js +4 -2
- package/es/EditTable/hooks/useValidate.js +121 -51
- package/es/EditTable/hooks/useVirtualTreeTable.js +111 -0
- package/es/EditTable/index.js +0 -4
- package/es/EditTable/style/body.js +15 -2
- package/es/EditTable/style/form.js +2 -2
- package/es/EditTable/style/header.js +2 -2
- package/es/EditTable/style/table.js +2 -1
- package/es/Icon/icon.js +3 -3
- package/es/ProTable/Content.js +3 -4
- package/es/ProTable/ProTable.js +5 -0
- package/es/ProTable/setting.js +1 -1
- package/es/Search/Advanced/index.js +2 -1
- package/es/Search/Search.js +2 -1
- package/es/VirtualTable/Table.js +367 -0
- package/es/VirtualTable/VirtualBody.js +94 -0
- package/es/VirtualTable/data.js +43 -1
- package/es/VirtualTable/index.js +1 -1
- package/es/VirtualTable/style/index.js +6 -0
- package/es/VirtualTable/useTreeData.js +243 -0
- package/es/VirtualTable/useVirtualScroll.js +159 -0
- package/lib/EditTable/CellRender.js +69 -3
- package/lib/EditTable/EditTable.js +108 -165
- package/lib/EditTable/FormItem.js +234 -96
- package/lib/EditTable/consts.js +13 -13
- package/lib/EditTable/context.js +3 -2
- package/lib/EditTable/fieldPool.js +173 -0
- package/lib/EditTable/hooks/index.js +15 -2
- package/lib/EditTable/hooks/useValidate.js +120 -50
- package/lib/EditTable/hooks/useVirtualTreeTable.js +117 -0
- package/lib/EditTable/index.js +0 -4
- package/lib/EditTable/style/body.js +15 -2
- package/lib/EditTable/style/form.js +2 -2
- package/lib/EditTable/style/header.js +2 -2
- package/lib/EditTable/style/table.js +2 -1
- package/lib/Icon/icon.js +3 -3
- package/lib/ProTable/Content.js +3 -4
- package/lib/ProTable/ProTable.js +5 -0
- package/lib/ProTable/setting.js +1 -1
- package/lib/Search/Advanced/index.js +2 -1
- package/lib/Search/Search.js +2 -1
- package/lib/VirtualTable/Table.js +374 -0
- package/lib/VirtualTable/VirtualBody.js +100 -0
- package/lib/VirtualTable/data.js +44 -2
- package/lib/VirtualTable/index.js +4 -4
- package/lib/VirtualTable/style/index.js +6 -0
- package/lib/VirtualTable/useTreeData.js +250 -0
- package/lib/VirtualTable/useVirtualScroll.js +165 -0
- package/package.json +3 -3
- package/es/EditTable/Body.js +0 -312
- package/es/EditTable/Header.js +0 -164
- package/es/EditTable/HeaderRender.js +0 -12
- package/es/VirtualTable/VirtualTable.js +0 -407
- package/lib/EditTable/Body.js +0 -312
- package/lib/EditTable/Header.js +0 -164
- package/lib/EditTable/HeaderRender.js +0 -12
- package/lib/VirtualTable/VirtualTable.js +0 -407
package/lib/EditTable/Body.js
DELETED
|
@@ -1,312 +0,0 @@
|
|
|
1
|
-
function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) {
|
|
2
|
-
const op = ops[i];
|
|
3
|
-
const fn = ops[i + 1];
|
|
4
|
-
i += 2;
|
|
5
|
-
if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) {
|
|
6
|
-
return undefined;
|
|
7
|
-
}
|
|
8
|
-
if (op === 'access' || op === 'optionalAccess') {
|
|
9
|
-
lastAccessLHS = value;
|
|
10
|
-
value = fn(value);
|
|
11
|
-
}
|
|
12
|
-
else if (op === 'call' || op === 'optionalCall') {
|
|
13
|
-
value = fn((...args) => value.call(lastAccessLHS, ...args));
|
|
14
|
-
lastAccessLHS = undefined;
|
|
15
|
-
}
|
|
16
|
-
} return value; }
|
|
17
|
-
/* Analyzed bindings: {
|
|
18
|
-
"groupKey": "props",
|
|
19
|
-
"width": "props",
|
|
20
|
-
"readonly": "props",
|
|
21
|
-
"ContextMenu": "setup-maybe-ref",
|
|
22
|
-
"useHScroll": "setup-maybe-ref",
|
|
23
|
-
"useRightMenuContext": "setup-maybe-ref",
|
|
24
|
-
"randomString": "setup-maybe-ref",
|
|
25
|
-
"bodyProps": "setup-maybe-ref",
|
|
26
|
-
"ref": "setup-const",
|
|
27
|
-
"reactive": "setup-const",
|
|
28
|
-
"computed": "setup-const",
|
|
29
|
-
"watch": "setup-const",
|
|
30
|
-
"onMounted": "setup-const",
|
|
31
|
-
"onBeforeUnmount": "setup-const",
|
|
32
|
-
"nextTick": "setup-const",
|
|
33
|
-
"Empty": "setup-const",
|
|
34
|
-
"CellRender": "setup-const",
|
|
35
|
-
"genEditTableStyle": "setup-maybe-ref",
|
|
36
|
-
"props": "setup-reactive-const",
|
|
37
|
-
"emit": "setup-const",
|
|
38
|
-
"prefixCls": "setup-ref",
|
|
39
|
-
"wrapSSR": "setup-maybe-ref",
|
|
40
|
-
"hashId": "setup-maybe-ref",
|
|
41
|
-
"viewScrollRef": "setup-ref",
|
|
42
|
-
"tableCenterRef": "setup-ref",
|
|
43
|
-
"virtualRang": "setup-reactive-const",
|
|
44
|
-
"containerStyle": "setup-ref",
|
|
45
|
-
"context": "setup-maybe-ref",
|
|
46
|
-
"hScroll": "setup-maybe-ref",
|
|
47
|
-
"scrollLock": "setup-let",
|
|
48
|
-
"menuInstance": "setup-let",
|
|
49
|
-
"maxLen": "setup-ref",
|
|
50
|
-
"selectedRowKeys": "setup-ref",
|
|
51
|
-
"virtualData": "setup-ref",
|
|
52
|
-
"onScroll": "setup-const",
|
|
53
|
-
"scrollTo": "setup-const",
|
|
54
|
-
"showContextMenu": "setup-const",
|
|
55
|
-
"rowClick": "setup-const",
|
|
56
|
-
"updateSelectedKeys": "setup-const"
|
|
57
|
-
} */
|
|
58
|
-
import { unref as _unref, normalizeStyle as _normalizeStyle, createElementVNode as _createElementVNode, renderList as _renderList, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock, renderSlot as _renderSlot, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, createCommentVNode as _createCommentVNode, createBlock as _createBlock, withModifiers as _withModifiers, normalizeClass as _normalizeClass, createVNode as _createVNode } from "vue";
|
|
59
|
-
const _hoisted_1 = { style: { position: 'relative' } };
|
|
60
|
-
const _hoisted_2 = ["data-row-key", "onContextmenu", "onClick"];
|
|
61
|
-
const _hoisted_3 = {
|
|
62
|
-
key: 0,
|
|
63
|
-
class: "body-cell-box"
|
|
64
|
-
};
|
|
65
|
-
const _hoisted_4 = {
|
|
66
|
-
key: 1,
|
|
67
|
-
class: "body-cell-box"
|
|
68
|
-
};
|
|
69
|
-
const _hoisted_5 = {
|
|
70
|
-
key: 1,
|
|
71
|
-
class: "readonly-mask"
|
|
72
|
-
};
|
|
73
|
-
const _hoisted_6 = { class: "jetlinks-edit-table-body-empty" };
|
|
74
|
-
import ContextMenu from './components/ContextMenu';
|
|
75
|
-
import { useHScroll, useRightMenuContext } from "./hooks";
|
|
76
|
-
import { randomString } from "@jetlinks-web/utils";
|
|
77
|
-
import { bodyProps } from "./props";
|
|
78
|
-
import { ref, reactive, computed, watch, onMounted, onBeforeUnmount, nextTick } from 'vue';
|
|
79
|
-
import Empty from '../Empty/Empty.js';
|
|
80
|
-
import CellRender from './CellRender.js';
|
|
81
|
-
import genEditTableStyle from './style';
|
|
82
|
-
const __sfc_main__ = Object.assign({
|
|
83
|
-
name: 'JEditTableBody'
|
|
84
|
-
}, {
|
|
85
|
-
props: {
|
|
86
|
-
...bodyProps(),
|
|
87
|
-
groupKey: {
|
|
88
|
-
type: [String, Number],
|
|
89
|
-
default: undefined
|
|
90
|
-
},
|
|
91
|
-
width: {
|
|
92
|
-
type: Number
|
|
93
|
-
},
|
|
94
|
-
readonly: {
|
|
95
|
-
type: Boolean,
|
|
96
|
-
default: false
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
emits: ['update:dataSource', 'scrollDown'],
|
|
100
|
-
setup(__props, { expose: __expose, emit: __emit }) {
|
|
101
|
-
const props = __props;
|
|
102
|
-
const emit = __emit;
|
|
103
|
-
const prefixCls = computed(() => 'jetlinks-edit-table');
|
|
104
|
-
const [wrapSSR, hashId] = genEditTableStyle(prefixCls);
|
|
105
|
-
const viewScrollRef = ref();
|
|
106
|
-
const tableCenterRef = ref();
|
|
107
|
-
const virtualRang = reactive({
|
|
108
|
-
start: 0,
|
|
109
|
-
end: 15
|
|
110
|
-
});
|
|
111
|
-
const containerStyle = ref(0);
|
|
112
|
-
const context = useRightMenuContext();
|
|
113
|
-
const hScroll = useHScroll();
|
|
114
|
-
let scrollLock = ref(false);
|
|
115
|
-
let menuInstance;
|
|
116
|
-
const maxLen = computed(() => {
|
|
117
|
-
return Math.trunc(props.height / props.cellHeight);
|
|
118
|
-
});
|
|
119
|
-
const selectedRowKeys = ref([]);
|
|
120
|
-
const virtualData = computed(() => {
|
|
121
|
-
const array = props.dataSource.slice(virtualRang.start, virtualRang.end);
|
|
122
|
-
if (tableCenterRef.value) {
|
|
123
|
-
// tableCenterRef.value.style.webkitTransform = `translateY(${virtualRang.start * props.cellHeight}px)`
|
|
124
|
-
}
|
|
125
|
-
return array;
|
|
126
|
-
});
|
|
127
|
-
const onScroll = () => {
|
|
128
|
-
if (!viewScrollRef.value)
|
|
129
|
-
return;
|
|
130
|
-
const height = viewScrollRef.value.scrollTop;
|
|
131
|
-
const clientHeight = viewScrollRef.value.clientHeight;
|
|
132
|
-
const scrollHeight = viewScrollRef.value.scrollHeight;
|
|
133
|
-
const _index = Math.round(height / props.cellHeight) - 1;
|
|
134
|
-
const start = _index < 0 ? 0 : _index;
|
|
135
|
-
const end = start + maxLen.value + 4;
|
|
136
|
-
if (height + clientHeight >= props.dataSource.length * props.cellHeight && !scrollLock.value) { // 滚动到底
|
|
137
|
-
emit('scrollDown');
|
|
138
|
-
scrollLock.value = true;
|
|
139
|
-
}
|
|
140
|
-
virtualRang.start = start;
|
|
141
|
-
virtualRang.end = end;
|
|
142
|
-
};
|
|
143
|
-
const scrollTo = (index) => {
|
|
144
|
-
if (viewScrollRef.value) {
|
|
145
|
-
viewScrollRef.value.scrollTop = index * props.cellHeight;
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
const showContextMenu = (e, record, _index) => {
|
|
149
|
-
e.preventDefault();
|
|
150
|
-
if (props.disableMenu) {
|
|
151
|
-
record = {
|
|
152
|
-
...record,
|
|
153
|
-
__index: _index
|
|
154
|
-
};
|
|
155
|
-
menuInstance = ContextMenu(e, record, context);
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
const rowClick = (record) => {
|
|
159
|
-
if (_optionalChain([props, 'access', _ => _.rowSelection, 'optionalAccess', _2 => _2.selectedRowKeys])) {
|
|
160
|
-
const rowSet = new Set(selectedRowKeys.value);
|
|
161
|
-
const key = record[props.rowKey];
|
|
162
|
-
const selected = !rowSet.has(key);
|
|
163
|
-
if (selected) {
|
|
164
|
-
rowSet.delete(key);
|
|
165
|
-
}
|
|
166
|
-
else {
|
|
167
|
-
rowSet.add(key);
|
|
168
|
-
}
|
|
169
|
-
_optionalChain([props, 'access', _3 => _3.rowSelection, 'access', _4 => _4.onSelect, 'optionalCall', _5 => _5(record, selected)]);
|
|
170
|
-
selectedRowKeys.value = [...rowSet.values()];
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
const updateSelectedKeys = (keys) => {
|
|
174
|
-
selectedRowKeys.value = keys;
|
|
175
|
-
};
|
|
176
|
-
onMounted(() => {
|
|
177
|
-
nextTick(() => {
|
|
178
|
-
onScroll();
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
onBeforeUnmount(() => {
|
|
182
|
-
_optionalChain([menuInstance, 'optionalAccess', _6 => _6.destroy, 'call', _7 => _7()]);
|
|
183
|
-
_optionalChain([menuInstance, 'optionalAccess', _8 => _8.cleanCopy, 'call', _9 => _9()]);
|
|
184
|
-
});
|
|
185
|
-
watch(() => JSON.stringify(_optionalChain([props, 'access', _10 => _10.rowSelection, 'optionalAccess', _11 => _11.selectedRowKeys])), (val) => {
|
|
186
|
-
selectedRowKeys.value = JSON.parse(val || '[]');
|
|
187
|
-
}, { immediate: true });
|
|
188
|
-
watch(() => props.dataSource, (val, oldVal) => {
|
|
189
|
-
props.dataSource.forEach((item, index) => {
|
|
190
|
-
if (!item.__key) {
|
|
191
|
-
item.__key = randomString();
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
}, {
|
|
195
|
-
immediate: true,
|
|
196
|
-
deep: true
|
|
197
|
-
});
|
|
198
|
-
watch(() => props.dataSource.length, () => {
|
|
199
|
-
scrollLock.value = false;
|
|
200
|
-
containerStyle.value = {
|
|
201
|
-
height: props.dataSource.length * props.cellHeight + 'px'
|
|
202
|
-
};
|
|
203
|
-
if (props.dataSource.length <= maxLen.value || props.dataSource.length === 0) {
|
|
204
|
-
emit('scrollDown', maxLen.value - props.dataSource.length + 3);
|
|
205
|
-
}
|
|
206
|
-
}, { immediate: true });
|
|
207
|
-
watch(() => props.groupKey, () => {
|
|
208
|
-
if (props.openGroup) {
|
|
209
|
-
scrollTo(0);
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
__expose({
|
|
213
|
-
scrollTo,
|
|
214
|
-
updateSelectedKeys
|
|
215
|
-
});
|
|
216
|
-
return (_ctx, _cache) => {
|
|
217
|
-
return (_ctx.dataSource.length)
|
|
218
|
-
? (_openBlock(), _createElementBlock("div", {
|
|
219
|
-
key: 0,
|
|
220
|
-
ref_key: "viewScrollRef",
|
|
221
|
-
ref: viewScrollRef,
|
|
222
|
-
class: _normalizeClass(['jetlinks-edit-table-body-viewport', _unref(hashId)]),
|
|
223
|
-
style: _normalizeStyle({ ..._ctx.style, height: _ctx.height + 'px' }),
|
|
224
|
-
onScroll: onScroll
|
|
225
|
-
}, [
|
|
226
|
-
_createElementVNode("div", _hoisted_1, [
|
|
227
|
-
_createElementVNode("div", {
|
|
228
|
-
class: "jetlinks-edit-scrollbar",
|
|
229
|
-
style: _normalizeStyle(containerStyle.value)
|
|
230
|
-
}, null, 4 /* STYLE */),
|
|
231
|
-
_createElementVNode("div", {
|
|
232
|
-
class: "jetlinks-edit-table-center",
|
|
233
|
-
ref_key: "tableCenterRef",
|
|
234
|
-
ref: tableCenterRef,
|
|
235
|
-
style: _normalizeStyle({
|
|
236
|
-
transform: `translate3d(-${_unref(hScroll) || 0}px, ${virtualRang.start * _ctx.cellHeight}px, 0)`,
|
|
237
|
-
width: __props.width + 'px'
|
|
238
|
-
})
|
|
239
|
-
}, [
|
|
240
|
-
(virtualData.value.length)
|
|
241
|
-
? (_openBlock(true), _createElementBlock(_Fragment, { key: 0 }, _renderList(virtualData.value, (item, index) => {
|
|
242
|
-
return (_openBlock(), _createElementBlock("div", {
|
|
243
|
-
class: _normalizeClass({
|
|
244
|
-
'jetlinks-edit-table-row': true,
|
|
245
|
-
'jetlinks-edit-table-row-selected': _optionalChain([selectedRowKeys, 'access', _12 => _12.value, 'optionalAccess', _13 => _13.includes, 'call', _14 => _14(item[_ctx.rowKey] || virtualRang.start + index + 1)])
|
|
246
|
-
}),
|
|
247
|
-
key: `record_${item.__key}`,
|
|
248
|
-
style: _normalizeStyle({
|
|
249
|
-
height: `${_ctx.cellHeight}px`,
|
|
250
|
-
transform: `-${_unref(hScroll) || 0}px`
|
|
251
|
-
}),
|
|
252
|
-
"data-row-key": item[_ctx.rowKey] || virtualRang.start + index + 1,
|
|
253
|
-
onContextmenu: _withModifiers((e) => showContextMenu(e, item, virtualRang.start + index), ["right"]),
|
|
254
|
-
onClick: _withModifiers(() => rowClick(item), ["stop"])
|
|
255
|
-
}, [
|
|
256
|
-
(_openBlock(true), _createElementBlock(_Fragment, null, _renderList(_ctx.columns, (column, __index) => {
|
|
257
|
-
return (_openBlock(), _createElementBlock("div", {
|
|
258
|
-
class: "jetlinks-edit-table-cell",
|
|
259
|
-
style: _normalizeStyle({
|
|
260
|
-
width: `${column.width}px`,
|
|
261
|
-
left: `${column.left || 200 * __index}px`,
|
|
262
|
-
})
|
|
263
|
-
}, [
|
|
264
|
-
(column.dataIndex === '__serial')
|
|
265
|
-
? (_openBlock(), _createElementBlock("div", _hoisted_3, [
|
|
266
|
-
_renderSlot(_ctx.$slots, "serial", {
|
|
267
|
-
record: item,
|
|
268
|
-
index: item.__dataIndex,
|
|
269
|
-
column: column
|
|
270
|
-
}, () => [
|
|
271
|
-
_createTextVNode(_toDisplayString(virtualRang.start + index + 1), 1 /* TEXT */)
|
|
272
|
-
])
|
|
273
|
-
]))
|
|
274
|
-
: (_openBlock(), _createElementBlock("div", _hoisted_4, [
|
|
275
|
-
_renderSlot(_ctx.$slots, column.dataIndex, {
|
|
276
|
-
record: item,
|
|
277
|
-
index: item.__dataIndex,
|
|
278
|
-
column: column
|
|
279
|
-
}, () => [
|
|
280
|
-
(column.customRender)
|
|
281
|
-
? (_openBlock(), _createBlock(CellRender, {
|
|
282
|
-
key: 0,
|
|
283
|
-
record: item,
|
|
284
|
-
value: item[column.dataIndex],
|
|
285
|
-
index: item.__dataIndex,
|
|
286
|
-
"render-fn": column.customRender
|
|
287
|
-
}, null, 8 /* PROPS */, ["record", "value", "index", "render-fn"]))
|
|
288
|
-
: (_openBlock(), _createElementBlock(_Fragment, { key: 1 }, [
|
|
289
|
-
_createTextVNode(_toDisplayString(item[column.dataIndex]), 1 /* TEXT */)
|
|
290
|
-
], 64 /* STABLE_FRAGMENT */))
|
|
291
|
-
])
|
|
292
|
-
]))
|
|
293
|
-
], 4 /* STYLE */));
|
|
294
|
-
}), 256 /* UNKEYED_FRAGMENT */))
|
|
295
|
-
], 46 /* CLASS, STYLE, PROPS, NEED_HYDRATION */, _hoisted_2));
|
|
296
|
-
}), 128 /* KEYED_FRAGMENT */))
|
|
297
|
-
: _createCommentVNode("v-if", true),
|
|
298
|
-
(__props.readonly)
|
|
299
|
-
? (_openBlock(), _createElementBlock("div", _hoisted_5))
|
|
300
|
-
: _createCommentVNode("v-if", true)
|
|
301
|
-
], 4 /* STYLE */)
|
|
302
|
-
])
|
|
303
|
-
], 38 /* CLASS, STYLE, NEED_HYDRATION */))
|
|
304
|
-
: _renderSlot(_ctx.$slots, "empty", { key: 1 }, () => [
|
|
305
|
-
_createElementVNode("div", _hoisted_6, [
|
|
306
|
-
_createVNode(Empty)
|
|
307
|
-
])
|
|
308
|
-
]);
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
});
|
|
312
|
-
export default __sfc_main__;
|
package/lib/EditTable/Header.js
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) {
|
|
2
|
-
const op = ops[i];
|
|
3
|
-
const fn = ops[i + 1];
|
|
4
|
-
i += 2;
|
|
5
|
-
if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) {
|
|
6
|
-
return undefined;
|
|
7
|
-
}
|
|
8
|
-
if (op === 'access' || op === 'optionalAccess') {
|
|
9
|
-
lastAccessLHS = value;
|
|
10
|
-
value = fn(value);
|
|
11
|
-
}
|
|
12
|
-
else if (op === 'call' || op === 'optionalCall') {
|
|
13
|
-
value = fn((...args) => value.call(lastAccessLHS, ...args));
|
|
14
|
-
lastAccessLHS = undefined;
|
|
15
|
-
}
|
|
16
|
-
} return value; }
|
|
17
|
-
/* Analyzed bindings: {
|
|
18
|
-
"columns": "props",
|
|
19
|
-
"searchColumns": "props",
|
|
20
|
-
"serial": "props",
|
|
21
|
-
"style": "props",
|
|
22
|
-
"SearchModal": "setup-maybe-ref",
|
|
23
|
-
"Sort": "setup-maybe-ref",
|
|
24
|
-
"reactive": "setup-const",
|
|
25
|
-
"computed": "setup-const",
|
|
26
|
-
"useHScroll": "setup-maybe-ref",
|
|
27
|
-
"useTableTool": "setup-maybe-ref",
|
|
28
|
-
"HeaderItemRender": "setup-const",
|
|
29
|
-
"useEditTableStyle": "setup-maybe-ref",
|
|
30
|
-
"props": "setup-reactive-const",
|
|
31
|
-
"prefixCls": "setup-ref",
|
|
32
|
-
"wrapSSR": "setup-maybe-ref",
|
|
33
|
-
"hashId": "setup-maybe-ref",
|
|
34
|
-
"tableTool": "setup-maybe-ref",
|
|
35
|
-
"hScroll": "setup-maybe-ref",
|
|
36
|
-
"searchData": "setup-reactive-const",
|
|
37
|
-
"showFilter": "setup-const",
|
|
38
|
-
"sortClick": "setup-const"
|
|
39
|
-
} */
|
|
40
|
-
import { unref as _unref, renderList as _renderList, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock, createBlock as _createBlock, createCommentVNode as _createCommentVNode, toDisplayString as _toDisplayString, createElementVNode as _createElementVNode, resolveComponent as _resolveComponent, mergeProps as _mergeProps, normalizeClass as _normalizeClass, normalizeStyle as _normalizeStyle } from "vue";
|
|
41
|
-
const _hoisted_1 = ["id"];
|
|
42
|
-
const _hoisted_2 = { class: "table-header-cell-title" };
|
|
43
|
-
const _hoisted_3 = { class: "cell-title-box" };
|
|
44
|
-
const _hoisted_4 = { key: 1 };
|
|
45
|
-
const _hoisted_5 = {
|
|
46
|
-
key: 0,
|
|
47
|
-
class: "header-cell-required"
|
|
48
|
-
};
|
|
49
|
-
const _hoisted_6 = {
|
|
50
|
-
key: 0,
|
|
51
|
-
class: "table-header-cell-trigger"
|
|
52
|
-
};
|
|
53
|
-
import { SearchModal, Sort } from './components/Search';
|
|
54
|
-
import { reactive, computed } from 'vue';
|
|
55
|
-
import { useHScroll, useTableTool } from "./hooks";
|
|
56
|
-
import HeaderItemRender from './HeaderRender.js';
|
|
57
|
-
import useEditTableStyle from './style';
|
|
58
|
-
const __sfc_main__ = Object.assign({
|
|
59
|
-
name: 'JEditTableHeader'
|
|
60
|
-
}, {
|
|
61
|
-
props: {
|
|
62
|
-
columns: {
|
|
63
|
-
type: Array,
|
|
64
|
-
default: () => []
|
|
65
|
-
},
|
|
66
|
-
searchColumns: {
|
|
67
|
-
type: Array,
|
|
68
|
-
default: undefined
|
|
69
|
-
},
|
|
70
|
-
serial: {
|
|
71
|
-
type: Boolean,
|
|
72
|
-
default: false
|
|
73
|
-
},
|
|
74
|
-
style: {
|
|
75
|
-
type: Object,
|
|
76
|
-
default: undefined
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
setup(__props) {
|
|
80
|
-
const props = __props;
|
|
81
|
-
const prefixCls = computed(() => 'jetlinks-edit-table');
|
|
82
|
-
const [wrapSSR, hashId] = useEditTableStyle(prefixCls);
|
|
83
|
-
const tableTool = useTableTool();
|
|
84
|
-
const hScroll = useHScroll();
|
|
85
|
-
const searchData = reactive({
|
|
86
|
-
visible: false,
|
|
87
|
-
key: undefined
|
|
88
|
-
});
|
|
89
|
-
const showFilter = (key) => {
|
|
90
|
-
searchData.visible = true;
|
|
91
|
-
searchData.key = key;
|
|
92
|
-
};
|
|
93
|
-
const sortClick = () => {
|
|
94
|
-
searchData.visible = false;
|
|
95
|
-
};
|
|
96
|
-
return (_ctx, _cache) => {
|
|
97
|
-
const _component_AIcon = _resolveComponent("AIcon");
|
|
98
|
-
return (_openBlock(), _createElementBlock("div", {
|
|
99
|
-
class: _normalizeClass(['jetlinks-edit-table-header-container', _unref(hashId)]),
|
|
100
|
-
style: _normalizeStyle(__props.style)
|
|
101
|
-
}, [
|
|
102
|
-
(_openBlock(true), _createElementBlock(_Fragment, null, _renderList(__props.columns, (item, index) => {
|
|
103
|
-
return (_openBlock(), _createElementBlock("div", {
|
|
104
|
-
class: "jetlinks-edit-table-header-cell",
|
|
105
|
-
id: item.dataIndex,
|
|
106
|
-
style: _normalizeStyle({ width: `${item.width}px`, left: `${item.left || (200 * index)}px` })
|
|
107
|
-
}, [
|
|
108
|
-
_createElementVNode("div", {
|
|
109
|
-
class: _normalizeClass({ 'jetlinks-edit-table-header-cell-box': true, 'header-cell-box-tool': !!(item.sort || item.filter) })
|
|
110
|
-
}, [
|
|
111
|
-
_createElementVNode("div", _hoisted_2, [
|
|
112
|
-
_createElementVNode("div", _hoisted_3, [
|
|
113
|
-
(item.render)
|
|
114
|
-
? (_openBlock(), _createBlock(HeaderItemRender, {
|
|
115
|
-
key: 0,
|
|
116
|
-
"render-fn": item.render,
|
|
117
|
-
value: item.title
|
|
118
|
-
}, null, 8 /* PROPS */, ["render-fn", "value"]))
|
|
119
|
-
: (_openBlock(), _createElementBlock("span", _hoisted_4, _toDisplayString(item.title), 1 /* TEXT */))
|
|
120
|
-
]),
|
|
121
|
-
(_optionalChain([item, 'access', _ => _.form, 'optionalAccess', _2 => _2.required]))
|
|
122
|
-
? (_openBlock(), _createElementBlock("span", _hoisted_5, "*"))
|
|
123
|
-
: _createCommentVNode("v-if", true)
|
|
124
|
-
]),
|
|
125
|
-
(!!(item.sort || item.filter))
|
|
126
|
-
? (_openBlock(), _createElementBlock("div", _hoisted_6, [
|
|
127
|
-
(item.filter)
|
|
128
|
-
? (_openBlock(), _createBlock(_component_AIcon, {
|
|
129
|
-
key: 0,
|
|
130
|
-
type: "SearchOutlined",
|
|
131
|
-
style: { "color": "rgba(0,0,0, 0.25)" },
|
|
132
|
-
onClick: () => { showFilter(item.filter.key || item.dataIndex); }
|
|
133
|
-
}, null, 8 /* PROPS */, ["onClick"]))
|
|
134
|
-
: _createCommentVNode("v-if", true),
|
|
135
|
-
(item.sort)
|
|
136
|
-
? (_openBlock(), _createBlock(_unref(Sort), _mergeProps({
|
|
137
|
-
key: 1,
|
|
138
|
-
ref_for: true
|
|
139
|
-
}, item.sort, {
|
|
140
|
-
key: item.dataIndex,
|
|
141
|
-
active: _unref(tableTool).sortData.dataIndex === item.dataIndex,
|
|
142
|
-
selectedRowKeys: _unref(tableTool).sortData.dataIndex === item.dataIndex ? _unref(tableTool).sortData.orderKeys : [],
|
|
143
|
-
dataIndex: item.dataIndex,
|
|
144
|
-
onClick: sortClick
|
|
145
|
-
}), null, 16 /* FULL_PROPS */, ["active", "selectedRowKeys", "dataIndex"]))
|
|
146
|
-
: _createCommentVNode("v-if", true)
|
|
147
|
-
]))
|
|
148
|
-
: _createCommentVNode("v-if", true)
|
|
149
|
-
], 2 /* CLASS */)
|
|
150
|
-
], 12 /* STYLE, PROPS */, _hoisted_1));
|
|
151
|
-
}), 256 /* UNKEYED_FRAGMENT */)),
|
|
152
|
-
(searchData.visible)
|
|
153
|
-
? (_openBlock(), _createBlock(_unref(SearchModal), {
|
|
154
|
-
key: 0,
|
|
155
|
-
searchKey: searchData.key,
|
|
156
|
-
columns: __props.searchColumns,
|
|
157
|
-
onClose: _cache[0] || (_cache[0] = $event => (searchData.visible = false))
|
|
158
|
-
}, null, 8 /* PROPS */, ["searchKey", "columns"]))
|
|
159
|
-
: _createCommentVNode("v-if", true)
|
|
160
|
-
], 6 /* CLASS, STYLE */));
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
export default __sfc_main__;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/* Analyzed bindings: {} */
|
|
2
|
-
import { defineComponent } from 'vue';
|
|
3
|
-
const __sfc_main__ = defineComponent({
|
|
4
|
-
name: "HeaderItemRender",
|
|
5
|
-
props: ['renderFn', 'value'],
|
|
6
|
-
setup(props) {
|
|
7
|
-
return () => {
|
|
8
|
-
return props.renderFn(props.value);
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
export default __sfc_main__;
|