@jetlinks-web/components 2.0.32 → 2.0.33
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/FullPage/FullPage.js +1 -1
- package/es/ProTable/Alert.js +73 -0
- package/es/ProTable/Content.js +122 -0
- package/es/ProTable/Header.js +73 -0
- package/es/ProTable/Pagination.js +46 -0
- package/es/ProTable/ProTable.js +310 -0
- package/es/ProTable/index.js +1 -410
- package/es/ProTable/setting.js +119 -0
- package/es/ProTable/style/ProTable.less +83 -0
- package/es/ProTable/style/index.js +1 -1
- package/es/Search/Advanced/SaveHistory.js +1 -1
- package/es/Search/Item.js +1 -1
- package/es/Search/Search.js +1 -1
- package/es/style/index.css +20 -20
- package/es/style/index.less +7 -7
- package/lib/FullPage/FullPage.js +1 -1
- package/lib/ProTable/Alert.js +73 -0
- package/lib/ProTable/Content.js +122 -0
- package/lib/ProTable/Header.js +73 -0
- package/lib/ProTable/Pagination.js +46 -0
- package/lib/ProTable/ProTable.js +310 -0
- package/lib/ProTable/index.js +4 -412
- package/lib/ProTable/setting.js +126 -0
- package/lib/ProTable/style/ProTable.less +83 -0
- package/lib/ProTable/style/index.js +1 -1
- package/lib/Search/Advanced/SaveHistory.js +1 -1
- package/lib/Search/Item.js +1 -1
- package/lib/Search/Search.js +1 -1
- package/lib/style/components.less +0 -1
- package/lib/style/index.css +20 -20
- package/lib/style/index.less +7 -7
- package/package.json +1 -1
- package/es/ProTable/proTableTypes.js +0 -11
- package/es/ProTable/style/index.css +0 -69
- package/es/ProTable/style/index.less +0 -92
- package/lib/ProTable/proTableTypes.js +0 -17
- package/lib/ProTable/style/index.css +0 -69
- package/lib/ProTable/style/index.less +0 -92
|
@@ -0,0 +1,310 @@
|
|
|
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
|
+
"proTableProps": "setup-maybe-ref",
|
|
19
|
+
"Spin": "setup-maybe-ref",
|
|
20
|
+
"Header": "setup-const",
|
|
21
|
+
"Alert": "setup-const",
|
|
22
|
+
"Content": "setup-const",
|
|
23
|
+
"Pagination": "setup-const",
|
|
24
|
+
"useSlots": "setup-const",
|
|
25
|
+
"watch": "setup-const",
|
|
26
|
+
"onMounted": "setup-const",
|
|
27
|
+
"onUnmounted": "setup-const",
|
|
28
|
+
"computed": "setup-const",
|
|
29
|
+
"ref": "setup-const",
|
|
30
|
+
"reactive": "setup-const",
|
|
31
|
+
"debounce": "setup-maybe-ref",
|
|
32
|
+
"props": "setup-reactive-const",
|
|
33
|
+
"slots": "setup-maybe-ref",
|
|
34
|
+
"loading": "setup-ref",
|
|
35
|
+
"_dataSource": "setup-ref",
|
|
36
|
+
"_mode": "setup-ref",
|
|
37
|
+
"column": "setup-ref",
|
|
38
|
+
"page": "setup-reactive-const",
|
|
39
|
+
"extraSlots": "setup-const",
|
|
40
|
+
"showAlert": "setup-ref",
|
|
41
|
+
"showPagination": "setup-ref",
|
|
42
|
+
"onCheck": "setup-const",
|
|
43
|
+
"handleData": "setup-const",
|
|
44
|
+
"handleSearch": "setup-const",
|
|
45
|
+
"_debounceFn": "setup-maybe-ref",
|
|
46
|
+
"onPageChange": "setup-const",
|
|
47
|
+
"onClose": "setup-const",
|
|
48
|
+
"reload": "setup-const",
|
|
49
|
+
"_gridColumns": "setup-ref",
|
|
50
|
+
"windowChange": "setup-const"
|
|
51
|
+
} */
|
|
52
|
+
import { defineComponent as _defineComponent } from 'vue';
|
|
53
|
+
import { renderSlot as _renderSlot, withCtx as _withCtx, createVNode as _createVNode, openBlock as _openBlock, createBlock as _createBlock, createCommentVNode as _createCommentVNode, unref as _unref, normalizeProps as _normalizeProps, mergeProps as _mergeProps, renderList as _renderList, createSlots as _createSlots, createElementVNode as _createElementVNode, normalizeStyle as _normalizeStyle, createElementBlock as _createElementBlock } from "vue";
|
|
54
|
+
const _hoisted_1 = { class: "jtable-body" };
|
|
55
|
+
import { proTableProps } from "./setting";
|
|
56
|
+
import { Spin } from 'ant-design-vue';
|
|
57
|
+
import Header from './Header.js';
|
|
58
|
+
import Alert from './Alert.js';
|
|
59
|
+
import Content from './Content.js';
|
|
60
|
+
import Pagination from './Pagination.js';
|
|
61
|
+
import { useSlots, watch, onMounted, onUnmounted, computed, ref, reactive } from "vue";
|
|
62
|
+
import { debounce } from 'lodash-es';
|
|
63
|
+
const __sfc_main__ = _defineComponent({
|
|
64
|
+
...{
|
|
65
|
+
name: 'JProTable'
|
|
66
|
+
},
|
|
67
|
+
props: {
|
|
68
|
+
...proTableProps
|
|
69
|
+
},
|
|
70
|
+
setup(__props, { expose: __expose }) {
|
|
71
|
+
const props = __props;
|
|
72
|
+
const slots = useSlots();
|
|
73
|
+
const loading = ref(false);
|
|
74
|
+
const _dataSource = ref([]);
|
|
75
|
+
const _mode = ref(!props.mode ? (props.modeValue || 'CARD') : props.mode);
|
|
76
|
+
const column = ref(4);
|
|
77
|
+
const page = reactive({
|
|
78
|
+
pageIndex: 0,
|
|
79
|
+
pageSize: 12,
|
|
80
|
+
total: 0
|
|
81
|
+
});
|
|
82
|
+
const extraSlots = ['headerRightRender', 'headerLeftRender', 'paginationRender', 'alertRender'];
|
|
83
|
+
const showAlert = computed(() => {
|
|
84
|
+
return props.alertShow && _optionalChain([props, 'optionalAccess', _2 => _2.rowSelection, 'optionalAccess', _3 => _3.selectedRowKeys, 'optionalAccess', _4 => _4.length]);
|
|
85
|
+
});
|
|
86
|
+
const showPagination = computed(() => {
|
|
87
|
+
return !!_dataSource.value.length && !props.noPagination && props.type === 'PAGE';
|
|
88
|
+
});
|
|
89
|
+
const onCheck = (e) => {
|
|
90
|
+
_mode.value = e.target.value;
|
|
91
|
+
};
|
|
92
|
+
const handleData = (result) => {
|
|
93
|
+
if (props.type === 'PAGE') {
|
|
94
|
+
// 判断如果是最后一页且最后一页为空,就跳转到前一页
|
|
95
|
+
if (_optionalChain([result, 'optionalAccess', _5 => _5.total]) &&
|
|
96
|
+
_optionalChain([result, 'optionalAccess', _6 => _6.pageSize]) &&
|
|
97
|
+
_optionalChain([result, 'optionalAccess', _7 => _7.pageIndex]) &&
|
|
98
|
+
_optionalChain([result, 'optionalAccess', _8 => _8.data, 'optionalAccess', _9 => _9.length]) === 0) {
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
_dataSource.value = _optionalChain([result, 'optionalAccess', _10 => _10.data]) || [];
|
|
103
|
+
page.pageIndex = _optionalChain([result, 'optionalAccess', _11 => _11.pageIndex]) || 0;
|
|
104
|
+
page.pageSize = _optionalChain([result, 'optionalAccess', _12 => _12.pageSize]) || 12;
|
|
105
|
+
page.total = _optionalChain([result, 'optionalAccess', _13 => _13.total]) || 0;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
_dataSource.value = result || [];
|
|
110
|
+
}
|
|
111
|
+
return false;
|
|
112
|
+
};
|
|
113
|
+
const handleSearch = async (_params) => {
|
|
114
|
+
if (Array.isArray(props.dataSource)) {
|
|
115
|
+
_dataSource.value = [];
|
|
116
|
+
}
|
|
117
|
+
else if (props.request) {
|
|
118
|
+
const __params = {
|
|
119
|
+
pageIndex: page.pageIndex,
|
|
120
|
+
pageSize: Number(page.pageSize),
|
|
121
|
+
...props.defaultParams,
|
|
122
|
+
..._params,
|
|
123
|
+
terms: [
|
|
124
|
+
...(_optionalChain([props, 'access', _14 => _14.defaultParams, 'optionalAccess', _15 => _15.terms]) || []),
|
|
125
|
+
...(_optionalChain([_params, 'optionalAccess', _16 => _16.terms]) || []),
|
|
126
|
+
],
|
|
127
|
+
};
|
|
128
|
+
loading.value = true;
|
|
129
|
+
const resp = await props.request(__params).finally(() => {
|
|
130
|
+
loading.value = false;
|
|
131
|
+
});
|
|
132
|
+
if (resp.success) {
|
|
133
|
+
const flag = handleData(resp.result || {});
|
|
134
|
+
if (flag) { // 判断如果是最后一页且最后一页为空,就跳转到前一页
|
|
135
|
+
page.pageIndex = page.pageIndex > 0 ? page.pageIndex - 1 : 0;
|
|
136
|
+
handleSearch({
|
|
137
|
+
..._params,
|
|
138
|
+
pageSize: page.pageSize,
|
|
139
|
+
pageIndex: page.pageIndex,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
_dataSource.value = [];
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
_dataSource.value = [];
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
const _debounceFn = debounce(handleSearch, 300);
|
|
152
|
+
watch(() => props.params, (newValue) => {
|
|
153
|
+
_debounceFn(newValue || {});
|
|
154
|
+
}, { deep: true, immediate: true });
|
|
155
|
+
watch(() => props.dataSource, () => {
|
|
156
|
+
handleSearch(props.params);
|
|
157
|
+
}, { deep: true, immediate: true });
|
|
158
|
+
const onPageChange = (_page, size) => {
|
|
159
|
+
handleSearch({
|
|
160
|
+
...props.params,
|
|
161
|
+
pageSize: size,
|
|
162
|
+
pageIndex: page.pageSize === size ? (_page ? _page - 1 : 0) : 0
|
|
163
|
+
});
|
|
164
|
+
};
|
|
165
|
+
const onClose = () => {
|
|
166
|
+
_optionalChain([props, 'access', _17 => _17.rowSelection, 'optionalAccess', _18 => _18.onChange, 'optionalCall', _19 => _19([], [])]);
|
|
167
|
+
_optionalChain([props, 'access', _20 => _20.rowSelection, 'optionalAccess', _21 => _21.onSelectNone, 'optionalCall', _22 => _22()]);
|
|
168
|
+
};
|
|
169
|
+
/**
|
|
170
|
+
* 刷新数据
|
|
171
|
+
* @param _params
|
|
172
|
+
*/
|
|
173
|
+
const reload = (_params) => {
|
|
174
|
+
handleSearch({
|
|
175
|
+
...props.params,
|
|
176
|
+
..._params,
|
|
177
|
+
pageSize: page.pageSize || 12,
|
|
178
|
+
pageIndex: page.pageIndex || 0,
|
|
179
|
+
});
|
|
180
|
+
};
|
|
181
|
+
const _gridColumns = computed(() => {
|
|
182
|
+
if (_optionalChain([props, 'access', _23 => _23.gridColumns, 'optionalAccess', _24 => _24.length])) {
|
|
183
|
+
const arr = props.gridColumns;
|
|
184
|
+
const lastValue = _optionalChain([arr, 'access', _25 => _25.slice, 'call', _26 => _26(-1), 'optionalAccess', _27 => _27[0]]);
|
|
185
|
+
if (_optionalChain([arr, 'optionalAccess', _28 => _28.length]) < 4) {
|
|
186
|
+
while (arr.length < 4) {
|
|
187
|
+
arr.push(lastValue);
|
|
188
|
+
}
|
|
189
|
+
return arr;
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
return props.gridColumns.slice(0, 4);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
return [1, 2, 3, 4];
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
// 监听宽度,计算显示卡片个数
|
|
200
|
+
const windowChange = () => {
|
|
201
|
+
const ele = document.getElementById('jtable-body-spin');
|
|
202
|
+
if (ele) {
|
|
203
|
+
const styles = window.getComputedStyle(ele);
|
|
204
|
+
const width = parseFloat(styles.width);
|
|
205
|
+
if (width <= 992) {
|
|
206
|
+
column.value = _optionalChain([_gridColumns, 'access', _29 => _29.value, 'optionalAccess', _30 => _30[0]]) || 1;
|
|
207
|
+
}
|
|
208
|
+
else if (width > 992 && width <= 1440) {
|
|
209
|
+
column.value = _optionalChain([_gridColumns, 'access', _31 => _31.value, 'optionalAccess', _32 => _32[1]]) || 2;
|
|
210
|
+
}
|
|
211
|
+
else if (width > 1440 && width <= 1600) {
|
|
212
|
+
column.value = _optionalChain([_gridColumns, 'access', _33 => _33.value, 'optionalAccess', _34 => _34[2]]) || 3;
|
|
213
|
+
}
|
|
214
|
+
else if (width > 1600) {
|
|
215
|
+
column.value = _optionalChain([_gridColumns, 'access', _35 => _35.value, 'optionalAccess', _36 => _36[3]]) || 4;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
onMounted(() => {
|
|
220
|
+
windowChange(); // 初始化
|
|
221
|
+
window.onresize = () => {
|
|
222
|
+
windowChange();
|
|
223
|
+
};
|
|
224
|
+
});
|
|
225
|
+
onUnmounted(() => {
|
|
226
|
+
window.onresize = null;
|
|
227
|
+
});
|
|
228
|
+
__expose({ reload, dataSource: _dataSource });
|
|
229
|
+
return (_ctx, _cache) => {
|
|
230
|
+
return (_openBlock(), _createElementBlock("div", {
|
|
231
|
+
class: "jtable-body-spin",
|
|
232
|
+
style: _normalizeStyle(_ctx.bodyStyle),
|
|
233
|
+
id: "jtable-body-spin"
|
|
234
|
+
}, [
|
|
235
|
+
_createVNode(_unref(Spin), { spinning: loading.value }, {
|
|
236
|
+
default: _withCtx(() => [
|
|
237
|
+
_createElementVNode("div", _hoisted_1, [
|
|
238
|
+
_createVNode(Header, {
|
|
239
|
+
initMode: _ctx.mode,
|
|
240
|
+
mode: _mode.value,
|
|
241
|
+
modeValue: _ctx.modeValue,
|
|
242
|
+
onChange: onCheck
|
|
243
|
+
}, {
|
|
244
|
+
headerLeftRender: _withCtx(() => [
|
|
245
|
+
_renderSlot(_ctx.$slots, "headerLeftRender")
|
|
246
|
+
]),
|
|
247
|
+
headerRightRender: _withCtx(() => [
|
|
248
|
+
_renderSlot(_ctx.$slots, "headerRightRender")
|
|
249
|
+
]),
|
|
250
|
+
_: 3 /* FORWARDED */
|
|
251
|
+
}, 8 /* PROPS */, ["initMode", "mode", "modeValue"]),
|
|
252
|
+
(showAlert.value)
|
|
253
|
+
? (_openBlock(), _createBlock(Alert, {
|
|
254
|
+
key: 0,
|
|
255
|
+
rowSelection: _ctx.rowSelection,
|
|
256
|
+
onClose: onClose
|
|
257
|
+
}, {
|
|
258
|
+
default: _withCtx(() => [
|
|
259
|
+
_renderSlot(_ctx.$slots, "alertRender", {
|
|
260
|
+
rowSelection: _ctx.rowSelection,
|
|
261
|
+
onClose: onClose
|
|
262
|
+
})
|
|
263
|
+
]),
|
|
264
|
+
_: 3 /* FORWARDED */
|
|
265
|
+
}, 8 /* PROPS */, ["rowSelection"]))
|
|
266
|
+
: _createCommentVNode("v-if", true),
|
|
267
|
+
_createVNode(Content, _mergeProps(props, {
|
|
268
|
+
mode: _mode.value,
|
|
269
|
+
dataSource: _dataSource.value,
|
|
270
|
+
column: column.value
|
|
271
|
+
}), _createSlots({ _: 2 /* DYNAMIC */ }, [
|
|
272
|
+
_renderList(_unref(slots), (_, key) => {
|
|
273
|
+
return {
|
|
274
|
+
name: key,
|
|
275
|
+
fn: _withCtx((slotProps) => [
|
|
276
|
+
(!extraSlots.includes(key))
|
|
277
|
+
? _renderSlot(_ctx.$slots, key, _normalizeProps(_mergeProps({ key: 0 }, slotProps)))
|
|
278
|
+
: _createCommentVNode("v-if", true)
|
|
279
|
+
])
|
|
280
|
+
};
|
|
281
|
+
})
|
|
282
|
+
]), 1040 /* FULL_PROPS, DYNAMIC_SLOTS */, ["mode", "dataSource", "column"]),
|
|
283
|
+
(showPagination.value)
|
|
284
|
+
? (_openBlock(), _createBlock(Pagination, {
|
|
285
|
+
key: 1,
|
|
286
|
+
onChange: onPageChange,
|
|
287
|
+
total: page.total,
|
|
288
|
+
pageIndex: page.pageIndex,
|
|
289
|
+
pageSize: page.pageSize
|
|
290
|
+
}, {
|
|
291
|
+
default: _withCtx(() => [
|
|
292
|
+
_renderSlot(_ctx.$slots, "paginationRender", {
|
|
293
|
+
total: page.total,
|
|
294
|
+
pageSize: page.pageSize,
|
|
295
|
+
current: page.pageIndex + 1,
|
|
296
|
+
onChange: onPageChange
|
|
297
|
+
})
|
|
298
|
+
]),
|
|
299
|
+
_: 3 /* FORWARDED */
|
|
300
|
+
}, 8 /* PROPS */, ["total", "pageIndex", "pageSize"]))
|
|
301
|
+
: _createCommentVNode("v-if", true)
|
|
302
|
+
])
|
|
303
|
+
]),
|
|
304
|
+
_: 3 /* FORWARDED */
|
|
305
|
+
}, 8 /* PROPS */, ["spinning"])
|
|
306
|
+
], 4 /* STYLE */));
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
export default __sfc_main__;
|