@lx-frontend/wrap-element-ui 1.0.0-beta.7 → 1.0.1-beta.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/dist/AddMembers/index.vue.d.ts +31 -0
- package/dist/AuditSteps/index.vue.d.ts +46 -0
- package/dist/DemoComponent/index.vue.d.ts +2 -0
- package/dist/EditableTable/index.vue.d.ts +186 -0
- package/dist/EditableTable/types.d.ts +123 -0
- package/dist/EditableTable/useCellHover.d.ts +11 -0
- package/dist/EditableTable/useColumnHeaderOperation.d.ts +106 -0
- package/dist/EditableTable/useDefaultOperation.d.ts +22 -0
- package/dist/EditableTable/useDragSort.d.ts +15 -0
- package/dist/EditableTable/usePagination.d.ts +13 -0
- package/dist/EditableTable/useRowBgColor.d.ts +16 -0
- package/dist/EditableTable/useViewSetting.d.ts +58 -0
- package/dist/Ellipsis/MultilineEllipsis.vue.d.ts +91 -0
- package/dist/Ellipsis/index.vue.d.ts +89 -0
- package/dist/LxTable/index.vue.d.ts +2 -0
- package/dist/PopoverForm/index.vue.d.ts +50 -0
- package/dist/SearchForm/index.vue.d.ts +105 -0
- package/dist/SearchSelect/index.vue.d.ts +53 -0
- package/dist/index.css +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.mjs +40826 -0
- package/dist/singleMessage/index.d.ts +4 -0
- package/package.json +3 -2
- package/src/components/AddMembers/index.vue +40 -32
- package/src/components/EditableTable/index.less +26 -34
- package/src/components/EditableTable/index.vue +35 -108
- package/src/components/EditableTable/types.ts +10 -32
- package/src/components/EditableTable/useColumnHeaderOperation.ts +28 -166
- package/src/components/EditableTable/useDefaultOperation.ts +10 -10
- package/src/components/EditableTable/useDragSort.ts +5 -4
- package/src/components/EditableTable/usePagination.ts +7 -4
- package/src/components/EditableTable/useRowBgColor.ts +3 -3
- package/src/components/EditableTable/useViewSetting.ts +1 -53
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import { computed, ref, watch, nextTick
|
|
2
|
-
import { IColumnConfig,
|
|
1
|
+
import { computed, ref, watch, nextTick } from "vue"
|
|
2
|
+
import { IColumnConfig, IProps } from './types';
|
|
3
3
|
|
|
4
4
|
interface IUseColumnHeaderOperationParams {
|
|
5
5
|
props: IProps
|
|
6
6
|
tableDomRef: any
|
|
7
7
|
sortFilterPopoverRef: any
|
|
8
|
-
emit: IEmits;
|
|
9
|
-
showingColumns: Ref<string[]>
|
|
10
8
|
}
|
|
11
9
|
|
|
12
|
-
export default function useColumnHeaderOperation({
|
|
10
|
+
export default function useColumnHeaderOperation({props, tableDomRef, sortFilterPopoverRef}: IUseColumnHeaderOperationParams) {
|
|
13
11
|
|
|
14
12
|
// column如果有sortable属性,点击列头部,会直接触发排序,为了在弹窗点确定时再触发排序,需要阻止点击立即排序
|
|
15
13
|
// 所以,初始渲染时,将sortable设置为false,在触发排序逻辑时再设置成真实的值,再利用el-table自身的排序逻辑触发排序
|
|
@@ -24,8 +22,8 @@ export default function useColumnHeaderOperation({ props, tableDomRef, sortFilte
|
|
|
24
22
|
const tempSortingColumn = ref<IColumnConfig | null>(null);
|
|
25
23
|
|
|
26
24
|
// 生效中的过滤配置 和 临时过滤配置
|
|
27
|
-
const filteredValue = ref<Record<string, string
|
|
28
|
-
const tempFilteredValue = ref<Record<string, string
|
|
25
|
+
const filteredValue = ref<Record<string, string[]>>({});
|
|
26
|
+
const tempFilteredValue = ref<Record<string, string[]>>({});
|
|
29
27
|
|
|
30
28
|
// 生效中的统计配置 和 临时统计配置
|
|
31
29
|
const tempSummaryList = ref<string[]>([]);
|
|
@@ -35,17 +33,14 @@ export default function useColumnHeaderOperation({ props, tableDomRef, sortFilte
|
|
|
35
33
|
const searchValue = ref<Record<string, string>>({});
|
|
36
34
|
const tempSearchValue = ref<Record<string, string>>({});
|
|
37
35
|
|
|
38
|
-
const isColumnFiltering = computed(() => Object.keys(tempFilteredValue.value).some(k =>
|
|
39
|
-
if (!Array.isArray(tempFilteredValue.value[k])) return tempFilteredValue.value[k]
|
|
40
|
-
return tempFilteredValue.value[k]?.length;
|
|
41
|
-
}));
|
|
36
|
+
const isColumnFiltering = computed(() => Object.keys(tempFilteredValue.value).some(k => tempFilteredValue.value[k]?.length));
|
|
42
37
|
|
|
43
|
-
const showColumnHeadSortIcon = (column: IColumnConfig) => column.filters || column.isColumnSortable || column.
|
|
38
|
+
const showColumnHeadSortIcon = (column: IColumnConfig) => column.filters || column.isColumnSortable || column.isColumnSearchAble || column.summary;
|
|
44
39
|
|
|
45
40
|
watch(
|
|
46
41
|
() => props.columnConfig,
|
|
47
42
|
(val) => {
|
|
48
|
-
filteredValue.value = val.reduce((prev, curr) => ({
|
|
43
|
+
filteredValue.value = val.reduce((prev, curr) => ({...prev, [curr.prop]: []}), {});
|
|
49
44
|
tempFilteredValue.value = { ...filteredValue.value };
|
|
50
45
|
},
|
|
51
46
|
{ immediate: true }
|
|
@@ -68,24 +63,14 @@ export default function useColumnHeaderOperation({ props, tableDomRef, sortFilte
|
|
|
68
63
|
sums[index] = summaryMethod(values);
|
|
69
64
|
}
|
|
70
65
|
})
|
|
71
|
-
|
|
66
|
+
|
|
72
67
|
return sums
|
|
73
68
|
}
|
|
74
69
|
|
|
75
70
|
const isColumnHeadActive = (column: IColumnConfig) => {
|
|
76
|
-
return
|
|
77
|
-
column.filters && (Array.isArray(column.filters)
|
|
78
|
-
? (filteredValue.value[column.prop] as any[]).length
|
|
79
|
-
: column.filters.type === 'radio'
|
|
80
|
-
? filteredValue.value[column.prop]
|
|
81
|
-
: (filteredValue.value[column.prop] as any[]).length)
|
|
82
|
-
) ||
|
|
83
|
-
(
|
|
84
|
-
column.search
|
|
85
|
-
? Array.isArray(column.search) && column.search?.some(v => searchValue.value[v.prop])
|
|
86
|
-
: searchValue.value[column.prop]
|
|
87
|
-
) ||
|
|
71
|
+
return filteredValue.value[column.prop]?.length ||
|
|
88
72
|
sortingColumn.value?.prop === column.prop ||
|
|
73
|
+
searchValue.value[column.prop] ||
|
|
89
74
|
summaryList.value.includes(column.prop);
|
|
90
75
|
}
|
|
91
76
|
|
|
@@ -97,7 +82,7 @@ export default function useColumnHeaderOperation({ props, tableDomRef, sortFilte
|
|
|
97
82
|
tempSortType.value = sortType.value;
|
|
98
83
|
tempSortingColumn.value = sortingColumn.value ? { ...sortingColumn.value } as IColumnConfig : null;
|
|
99
84
|
// 临时合计项设置成实际的合计项
|
|
100
|
-
tempSummaryList.value = [...summaryList.value];
|
|
85
|
+
tempSummaryList.value = [ ...summaryList.value ];
|
|
101
86
|
}
|
|
102
87
|
|
|
103
88
|
const closeSortAndFilterPopover = (exceptProp?: string) => {
|
|
@@ -113,81 +98,21 @@ export default function useColumnHeaderOperation({ props, tableDomRef, sortFilte
|
|
|
113
98
|
tempSortingColumn.value = column;
|
|
114
99
|
}
|
|
115
100
|
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
obj[column.prop] = column
|
|
120
|
-
})
|
|
121
|
-
return obj
|
|
122
|
-
})
|
|
123
|
-
|
|
124
|
-
const emitSearch = () => {
|
|
125
|
-
const params: Record<string, any> = {};
|
|
126
|
-
// 仅提交显示的列的相关数据
|
|
127
|
-
showingColumns.value.forEach(prop => {
|
|
128
|
-
const column = columnMap.value[prop]
|
|
129
|
-
if (column.filters) {
|
|
130
|
-
params[prop] = filteredValue.value[prop]
|
|
131
|
-
}
|
|
132
|
-
if (column.search) {
|
|
133
|
-
if (Array.isArray(column.search)) {
|
|
134
|
-
column.search.forEach(v => {
|
|
135
|
-
params[v.prop] = searchValue.value[v.prop]
|
|
136
|
-
})
|
|
137
|
-
} else {
|
|
138
|
-
params[prop] = searchValue.value[prop]
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
})
|
|
142
|
-
|
|
143
|
-
Object.keys(params).forEach(key => {
|
|
144
|
-
if (params[key] === undefined) delete params[key]
|
|
145
|
-
})
|
|
146
|
-
|
|
147
|
-
emit('search', params);
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
const handleHeaderOperationConfirm = async (column: IColumnConfig, scope) => {
|
|
151
|
-
if (column.search) {
|
|
152
|
-
// 校验
|
|
153
|
-
if (Array.isArray(column.search)) {
|
|
154
|
-
let validate = true;
|
|
155
|
-
column.search.forEach(v => {
|
|
156
|
-
if (!tempSearchValue.value[v.prop]) tempSearchValue.value[v.prop] = ''
|
|
157
|
-
if (!validate) return
|
|
158
|
-
if (v.validator) {
|
|
159
|
-
const result = v.validator(tempSearchValue.value[v.prop]);
|
|
160
|
-
if (validate && !result) validate = false;
|
|
161
|
-
}
|
|
162
|
-
})
|
|
163
|
-
// 校验未通过
|
|
164
|
-
if (!validate) return
|
|
165
|
-
} else {
|
|
166
|
-
if (!tempSearchValue.value[column.prop]) tempSearchValue.value[column.prop] = ''
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
summaryList.value = [...tempSummaryList.value];
|
|
171
|
-
sortingColumn.value = tempSortingColumn.value ? { ...tempSortingColumn.value } : null;
|
|
101
|
+
const handleHeaderOperationConfirm = async (scope) => {
|
|
102
|
+
summaryList.value = [ ...tempSummaryList.value ];
|
|
103
|
+
sortingColumn.value = tempSortingColumn.value ? {...tempSortingColumn.value} : null;
|
|
172
104
|
sortType.value = tempSortType.value;
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
tableDomRef.value?.sort(sortingColumn.value.prop, sortType.value);
|
|
180
|
-
inSorting.value = false
|
|
181
|
-
} else {
|
|
182
|
-
emit('sort-change', { order: sortType.value, prop: sortingColumn.value.prop });
|
|
183
|
-
}
|
|
105
|
+
if (sortingColumn.value) {
|
|
106
|
+
// 恢复列配置的sortable属性,只有列配置的sortable为true,才能用下面的sort方法
|
|
107
|
+
inSorting.value = true;
|
|
108
|
+
await nextTick();
|
|
109
|
+
tableDomRef.value?.sort(sortingColumn.value.prop, sortType.value);
|
|
110
|
+
inSorting.value = false
|
|
184
111
|
}
|
|
185
112
|
|
|
186
113
|
filteredValue.value = { ...tempFilteredValue.value };
|
|
187
114
|
searchValue.value = { ...tempSearchValue.value };
|
|
188
115
|
|
|
189
|
-
emitSearch();
|
|
190
|
-
|
|
191
116
|
filterColumns(scope.store);
|
|
192
117
|
|
|
193
118
|
closeSortAndFilterPopover();
|
|
@@ -195,52 +120,18 @@ export default function useColumnHeaderOperation({ props, tableDomRef, sortFilte
|
|
|
195
120
|
tableDomRef.value?.doLayout();
|
|
196
121
|
}
|
|
197
122
|
|
|
198
|
-
const
|
|
199
|
-
sortingColumn.value = null;
|
|
200
|
-
sortType.value = null;
|
|
201
|
-
if (props.localSort) { // 前端过滤
|
|
202
|
-
tableDomRef.value?.clearSort();
|
|
203
|
-
} else { // 接口过滤
|
|
204
|
-
emit('sort-change', { order: null, prop: '' });
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
const setSort = (params: { order: 'ascending' | 'descending', prop: string }) => {
|
|
209
|
-
const column = props.columnConfig.find(c => c.prop === params.prop);
|
|
210
|
-
if (column) {
|
|
211
|
-
sortingColumn.value = column;
|
|
212
|
-
sortType.value = params.order;
|
|
213
|
-
if (props.localSort) {
|
|
214
|
-
tableDomRef.value?.sort(params.prop, params.order);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
const handleHeaderOperationReset = async (column: IColumnConfig, scope) => {
|
|
123
|
+
const handleHeaderOperationReset = async (column, scope) => {
|
|
220
124
|
if (sortingColumn.value && sortingColumn.value.prop === column.prop) {
|
|
221
|
-
clearSort();
|
|
125
|
+
tableDomRef.value?.clearSort();
|
|
126
|
+
sortingColumn.value = null;
|
|
127
|
+
sortType.value = null;
|
|
222
128
|
}
|
|
223
129
|
|
|
224
130
|
// 合计
|
|
225
131
|
summaryList.value = summaryList.value.filter(item => item !== column.prop);
|
|
226
132
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
? []
|
|
230
|
-
: column.filters.default ?? []
|
|
231
|
-
}
|
|
232
|
-
if (column.search) {
|
|
233
|
-
if (!Array.isArray(column.search)) {
|
|
234
|
-
searchValue.value[column.prop] = '';
|
|
235
|
-
} else {
|
|
236
|
-
column.search.forEach(v => {
|
|
237
|
-
searchValue.value[v.prop] = '';
|
|
238
|
-
})
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
emitSearch();
|
|
243
|
-
|
|
133
|
+
filteredValue.value[column.prop] = [];
|
|
134
|
+
searchValue.value[column.prop] = '';
|
|
244
135
|
filterColumns(scope.store);
|
|
245
136
|
|
|
246
137
|
closeSortAndFilterPopover();
|
|
@@ -249,7 +140,6 @@ export default function useColumnHeaderOperation({ props, tableDomRef, sortFilte
|
|
|
249
140
|
}
|
|
250
141
|
|
|
251
142
|
const filterColumns = (store) => {
|
|
252
|
-
if (!props.localFilter) return
|
|
253
143
|
store.states.columns.forEach(column => {
|
|
254
144
|
if (filteredValue.value[column.property]) {
|
|
255
145
|
store.commit('filterChange', {
|
|
@@ -275,35 +165,7 @@ export default function useColumnHeaderOperation({ props, tableDomRef, sortFilte
|
|
|
275
165
|
store.states.data = data;
|
|
276
166
|
}
|
|
277
167
|
|
|
278
|
-
const setSearchParams = (params: Record<string, any>) => {
|
|
279
|
-
const _searchValue = {};
|
|
280
|
-
const _filteredValue = {};
|
|
281
|
-
|
|
282
|
-
// 设置搜索和过滤参数时,如果使用 showingColumns 遍历,会导致通过外部设置未显示的列的搜索和过滤参数丢失
|
|
283
|
-
props.columnConfig.forEach(column => {
|
|
284
|
-
if (column.search) {
|
|
285
|
-
if (Array.isArray(column.search)) {
|
|
286
|
-
column.search.forEach(v => {
|
|
287
|
-
_searchValue[v.prop] = params[v.prop];
|
|
288
|
-
});
|
|
289
|
-
} else {
|
|
290
|
-
_searchValue[column.prop] = params[column.prop] ?? '';
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
if (column.filters) {
|
|
294
|
-
const value = params[column.prop] ?? (Array.isArray(column.filters) ? [] : column.filters.default);
|
|
295
|
-
_filteredValue[column.prop] = value;
|
|
296
|
-
}
|
|
297
|
-
})
|
|
298
|
-
|
|
299
|
-
searchValue.value = { ...searchValue.value, ..._searchValue }
|
|
300
|
-
filteredValue.value = { ...filteredValue.value, ..._filteredValue }
|
|
301
|
-
}
|
|
302
|
-
|
|
303
168
|
return {
|
|
304
|
-
setSort,
|
|
305
|
-
clearSort,
|
|
306
|
-
setSearchParams,
|
|
307
169
|
isColumnHeadActive,
|
|
308
170
|
handleHeaderPopoverShow,
|
|
309
171
|
handleSort,
|
|
@@ -321,6 +183,6 @@ export default function useColumnHeaderOperation({ props, tableDomRef, sortFilte
|
|
|
321
183
|
sortingColumn,
|
|
322
184
|
isColumnFiltering,
|
|
323
185
|
searchValue,
|
|
324
|
-
inSorting
|
|
186
|
+
inSorting
|
|
325
187
|
}
|
|
326
188
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { Ref, ref } from "vue"
|
|
2
|
-
import { IEmits
|
|
2
|
+
import { IEmits } from "./types"
|
|
3
3
|
|
|
4
4
|
interface IParams {
|
|
5
5
|
emit: IEmits;
|
|
6
6
|
pageSize: Ref<number>;
|
|
7
|
-
|
|
7
|
+
currentPage: Ref<number>;
|
|
8
8
|
tableDomRef: Ref<any>;
|
|
9
9
|
hasExpandRow: boolean
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export default function useDefaultOperation({
|
|
12
|
+
export default function useDefaultOperation({emit, pageSize, currentPage, tableDomRef, hasExpandRow}: IParams) {
|
|
13
13
|
const operationPopoverRef = ref<any>(null);
|
|
14
14
|
const editingRowData = ref<Record<string, any>>({});
|
|
15
15
|
const editingRowIndex = ref<number>(-1);
|
|
@@ -18,7 +18,7 @@ export default function useDefaultOperation({ emit, pageSize, props, tableDomRef
|
|
|
18
18
|
emit('row-delete', {
|
|
19
19
|
row,
|
|
20
20
|
index,
|
|
21
|
-
page:
|
|
21
|
+
page: currentPage.value,
|
|
22
22
|
size: pageSize.value
|
|
23
23
|
})
|
|
24
24
|
closeOperationPopover();
|
|
@@ -39,9 +39,9 @@ export default function useDefaultOperation({ emit, pageSize, props, tableDomRef
|
|
|
39
39
|
// 折叠所有展开的行
|
|
40
40
|
closeAllExpandedRows();
|
|
41
41
|
const { row, $index: index } = scope;
|
|
42
|
-
editingRowData.value = {
|
|
42
|
+
editingRowData.value = {...row};
|
|
43
43
|
editingRowIndex.value = index;
|
|
44
|
-
emit('row-edit', { row, index, page:
|
|
44
|
+
emit('row-edit', { row, index, page: currentPage.value, size: pageSize.value});
|
|
45
45
|
closeOperationPopover();
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -52,9 +52,9 @@ export default function useDefaultOperation({ emit, pageSize, props, tableDomRef
|
|
|
52
52
|
...dataList.slice(0, index),
|
|
53
53
|
...dataList.slice(index + 1)
|
|
54
54
|
];
|
|
55
|
-
newList.unshift({
|
|
55
|
+
newList.unshift({...row, isPinned: true});
|
|
56
56
|
store.states.data = newList;
|
|
57
|
-
emit('row-pin-to-top', { row, rawIndex: index, page:
|
|
57
|
+
emit('row-pin-to-top', { row, rawIndex: index, page: currentPage.value, size: pageSize.value});
|
|
58
58
|
closeOperationPopover();
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -68,7 +68,7 @@ export default function useDefaultOperation({ emit, pageSize, props, tableDomRef
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
emit('row-edit-save', {
|
|
71
|
-
page:
|
|
71
|
+
page: currentPage.value,
|
|
72
72
|
size: pageSize.value,
|
|
73
73
|
row,
|
|
74
74
|
changedData
|
|
@@ -79,7 +79,7 @@ export default function useDefaultOperation({ emit, pageSize, props, tableDomRef
|
|
|
79
79
|
const handleEditCancel = (row) => {
|
|
80
80
|
editingRowIndex.value = -1;
|
|
81
81
|
editingRowData.value = {};
|
|
82
|
-
emit('row-edit-cancel', { row, page:
|
|
82
|
+
emit('row-edit-cancel', { row, page: currentPage.value, size: pageSize.value});
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
return {
|
|
@@ -8,10 +8,11 @@ interface IUseDragSortParams {
|
|
|
8
8
|
viewSettingDragSortOptions: Ref<IColumnConfig[]>
|
|
9
9
|
beforeDragStart: () => boolean
|
|
10
10
|
currScope: Ref<any>
|
|
11
|
+
currentPage: Ref<number>
|
|
11
12
|
pageSize: Ref<number>
|
|
12
13
|
tableDomRef: Ref<any>
|
|
13
14
|
}
|
|
14
|
-
export default function useDragSort({
|
|
15
|
+
export default function useDragSort({props, emit, viewSettingDragSortOptions, currentPage, pageSize, beforeDragStart, currScope, tableDomRef }: IUseDragSortParams) {
|
|
15
16
|
|
|
16
17
|
const draggingData = ref<IDraggingData>({}); // 拖拽相关数据
|
|
17
18
|
const isMouseDown = ref(false);
|
|
@@ -20,7 +21,7 @@ export default function useDragSort({ props, emit, viewSettingDragSortOptions, p
|
|
|
20
21
|
const isOperating = ref(false);
|
|
21
22
|
|
|
22
23
|
onMounted(() => {
|
|
23
|
-
tableDomRef.value.$el.addEventListener('mousedown', () => {
|
|
24
|
+
tableDomRef.value.$el.addEventListener('mousedown', () => {isOperating.value = true});
|
|
24
25
|
document.addEventListener('mousedown', handleDocumentMouseDown);
|
|
25
26
|
document.addEventListener('mousemove', handleDocumentMouseMove);
|
|
26
27
|
document.addEventListener('mouseup', handleDocumentMouseUp);
|
|
@@ -200,7 +201,7 @@ export default function useDragSort({ props, emit, viewSettingDragSortOptions, p
|
|
|
200
201
|
row: movedRow,
|
|
201
202
|
fromIndex: draggingIndex,
|
|
202
203
|
toIndex: dropIndex,
|
|
203
|
-
page:
|
|
204
|
+
page: currentPage.value,
|
|
204
205
|
size: pageSize.value
|
|
205
206
|
});
|
|
206
207
|
// 清理工作
|
|
@@ -209,7 +210,7 @@ export default function useDragSort({ props, emit, viewSettingDragSortOptions, p
|
|
|
209
210
|
|
|
210
211
|
const handleViewSettingDragMouseDown = (event, index) => {
|
|
211
212
|
const rowDoms = [...document.getElementsByClassName('view-setting-draggable-item')]
|
|
212
|
-
.reduce((pre, item, index) => ({
|
|
213
|
+
.reduce((pre, item, index) => ({...pre, [index]: [item]}), {});
|
|
213
214
|
draggingData.value.isDragging = true;
|
|
214
215
|
draggingData.value.rowDoms = rowDoms;
|
|
215
216
|
draggingData.value.draggingIndex = +index;
|
|
@@ -6,26 +6,29 @@ interface IParams {
|
|
|
6
6
|
beforePageChange: () => void
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export default function usePagination({
|
|
9
|
+
export default function usePagination({emit, beforePageChange}: IParams) {
|
|
10
10
|
|
|
11
11
|
const pageSize = ref(10);
|
|
12
|
+
const currentPage = ref(1);
|
|
12
13
|
|
|
13
14
|
const handlePageSizeChange = (size: number) => {
|
|
14
15
|
pageSize.value = size;
|
|
16
|
+
currentPage.value = 1;
|
|
15
17
|
// searchValue.value = {};
|
|
16
18
|
beforePageChange();
|
|
17
|
-
emit('page-change', {
|
|
19
|
+
emit('page-change', {size, page: currentPage.value});
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
const handleCurrPageChange = (curr: number) => {
|
|
21
23
|
// searchValue.value = {};
|
|
22
24
|
beforePageChange();
|
|
23
|
-
emit('page-change', {
|
|
25
|
+
emit('page-change', {size: pageSize.value, page: curr});
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
return {
|
|
27
29
|
pageSize,
|
|
30
|
+
currentPage,
|
|
28
31
|
handlePageSizeChange,
|
|
29
|
-
handleCurrPageChange
|
|
32
|
+
handleCurrPageChange
|
|
30
33
|
}
|
|
31
34
|
}
|
|
@@ -6,7 +6,7 @@ interface IUseRowBgColorParams {
|
|
|
6
6
|
emit: IEmits;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export default function useRowBgColor({
|
|
9
|
+
export default function useRowBgColor({colorList, emit}: IUseRowBgColorParams) {
|
|
10
10
|
const colorPopoverRef = ref<any>(null);
|
|
11
11
|
|
|
12
12
|
const isDefaultColor = (id: number) => {
|
|
@@ -31,11 +31,11 @@ export default function useRowBgColor({ colorList, emit }: IUseRowBgColorParams)
|
|
|
31
31
|
const handleColorChange = async (colorId: number, scope) => {
|
|
32
32
|
const { row, $index: rowIndex, store } = scope;
|
|
33
33
|
const dataList = store.states.data;
|
|
34
|
-
const curRow = {
|
|
34
|
+
const curRow = {...dataList[rowIndex], colorId: +colorId};
|
|
35
35
|
const newList = [...dataList];
|
|
36
36
|
newList.splice(rowIndex, 1, curRow);
|
|
37
37
|
store.states.data = newList;
|
|
38
|
-
emit('row-bg-change', {
|
|
38
|
+
emit('row-bg-change', {colorId, row, rowIndex});
|
|
39
39
|
await nextTick();
|
|
40
40
|
// TODO: 为什么不是数组?为什么关闭弹窗不生效了?
|
|
41
41
|
colorPopoverRef.value?.doClose();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ref, nextTick, watch, ComputedRef, Ref, onMounted
|
|
1
|
+
import { ref, nextTick, watch, ComputedRef, Ref, onMounted } from "vue"
|
|
2
2
|
import { IColumnConfig, IProps } from "./types"
|
|
3
3
|
|
|
4
4
|
interface IViewSettingParams {
|
|
@@ -13,53 +13,12 @@ export default function useViewSetting({ tableDomRef, showingColumns, actualColu
|
|
|
13
13
|
const columnsToBeShown = ref<string[]>([]); // 显示设置弹窗中勾选的列
|
|
14
14
|
const viewSettingVisible = ref(false);
|
|
15
15
|
const leftFixedColumnCount = ref(0);
|
|
16
|
-
const tempLeftFixedColumnCount = ref(0);
|
|
17
|
-
|
|
18
|
-
const storageKey = computed(() => `@lx-frontend/wrap-element-ui/table_setting_cloumns/${props.settingStorgeKey || (location.pathname === '/' ? location.hash : location.pathname)}`);
|
|
19
|
-
|
|
20
|
-
const saveSettingToStorge = () => localStorage.setItem(storageKey.value, JSON.stringify({
|
|
21
|
-
showingColumns: showingColumns.value,
|
|
22
|
-
leftFixedColumnCount: leftFixedColumnCount.value
|
|
23
|
-
}));
|
|
24
|
-
|
|
25
|
-
watch(
|
|
26
|
-
() => props.columnConfig,
|
|
27
|
-
(val) => {
|
|
28
|
-
const _keys = new Set(props.columnConfig.map(c => (c.prop)));
|
|
29
|
-
const _cache = localStorage.getItem(storageKey.value);
|
|
30
|
-
const setColumns = () => (showingColumns.value = val.filter(v => !v.defaultHide).map(c => c.prop));
|
|
31
|
-
if (!_cache) {
|
|
32
|
-
setColumns();
|
|
33
|
-
leftFixedColumnCount.value = props.leftFixedCount as number;
|
|
34
|
-
} else {
|
|
35
|
-
try {
|
|
36
|
-
// 缓存数据字段可能随着更新导致对不上,清理无效数据,防止出问题
|
|
37
|
-
const cache = JSON.parse(_cache);
|
|
38
|
-
if (!cache.showingColumns || !Array.isArray(cache.showingColumns)) {
|
|
39
|
-
setColumns();
|
|
40
|
-
} else {
|
|
41
|
-
showingColumns.value = cache.showingColumns.filter(key => _keys.has(key));
|
|
42
|
-
}
|
|
43
|
-
const _leftFixedColumnCount = Number(cache?.leftFixedColumnCount)
|
|
44
|
-
leftFixedColumnCount.value = isNaN(_leftFixedColumnCount) ? (props.leftFixedCount as number) : _leftFixedColumnCount;
|
|
45
|
-
// 写入清理后的数据
|
|
46
|
-
saveSettingToStorge();
|
|
47
|
-
} catch (error) {
|
|
48
|
-
console.error(error);
|
|
49
|
-
localStorage.removeItem(storageKey.value);
|
|
50
|
-
setColumns();
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
{ immediate: true }
|
|
55
|
-
)
|
|
56
16
|
|
|
57
17
|
watch(
|
|
58
18
|
() => columnsToBeShown.value,
|
|
59
19
|
(val) => {
|
|
60
20
|
viewSettingDragSortOptions.value = props.columnConfig
|
|
61
21
|
.filter(c => val.includes(c.prop));
|
|
62
|
-
if (tempLeftFixedColumnCount.value > val.length) tempLeftFixedColumnCount.value = val.length
|
|
63
22
|
},
|
|
64
23
|
{ immediate: true }
|
|
65
24
|
)
|
|
@@ -80,7 +39,6 @@ export default function useViewSetting({ tableDomRef, showingColumns, actualColu
|
|
|
80
39
|
const handleViewSettingShow = () => {
|
|
81
40
|
viewSettingDragSortOptions.value = actualColumns.value
|
|
82
41
|
.filter(c => columnsToBeShown.value.includes(c.prop));
|
|
83
|
-
tempLeftFixedColumnCount.value = leftFixedColumnCount.value;
|
|
84
42
|
viewSettingVisible.value = true;
|
|
85
43
|
}
|
|
86
44
|
|
|
@@ -93,25 +51,15 @@ export default function useViewSetting({ tableDomRef, showingColumns, actualColu
|
|
|
93
51
|
const handleViewSettingConfirm = async () => {
|
|
94
52
|
viewSettingVisible.value = false;
|
|
95
53
|
showingColumns.value = viewSettingDragSortOptions.value.map(c => c.prop);
|
|
96
|
-
leftFixedColumnCount.value = tempLeftFixedColumnCount.value;
|
|
97
|
-
saveSettingToStorge()
|
|
98
54
|
await nextTick();
|
|
99
55
|
tableDomRef.value?.doLayout();
|
|
100
56
|
}
|
|
101
57
|
|
|
102
|
-
const handleInputTempLeftFixedColumnCount = (value: string) => {
|
|
103
|
-
const _value = Number(value)
|
|
104
|
-
if (isNaN(_value)) return
|
|
105
|
-
tempLeftFixedColumnCount.value = Math.max(0, Math.min(columnsToBeShown.value.length, Math.floor(_value)))
|
|
106
|
-
}
|
|
107
|
-
|
|
108
58
|
return {
|
|
109
59
|
viewSettingDragSortOptions,
|
|
110
60
|
columnsToBeShown,
|
|
111
61
|
viewSettingVisible,
|
|
112
62
|
leftFixedColumnCount,
|
|
113
|
-
tempLeftFixedColumnCount,
|
|
114
|
-
handleInputTempLeftFixedColumnCount,
|
|
115
63
|
handleViewSettingShow,
|
|
116
64
|
handleViewSettingClose,
|
|
117
65
|
handleViewSettingConfirm
|