stellar-ui-plus 1.17.7 → 1.17.8
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/components/ste-badge/ste-badge.vue +1 -1
- package/components/ste-button/ste-button.vue +11 -20
- package/components/ste-icon/ste-icon.vue +1 -1
- package/components/ste-image/ste-image.vue +2 -2
- package/components/ste-input/ste-input.vue +1 -1
- package/components/ste-message-box/ste-message-box.vue +1 -1
- package/components/ste-notice-bar/ste-notice-bar.vue +2 -2
- package/components/ste-table/props.ts +54 -63
- package/components/ste-table/useData.ts +214 -230
- package/components/ste-table-column/ste-table-column.vue +1 -1
- package/package.json +1 -1
- package/store/color.ts +43 -19
- package/store/index.ts +0 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed, defineOptions, type CSSProperties
|
|
2
|
+
import { computed, defineOptions, type CSSProperties } from 'vue';
|
|
3
3
|
import { useColorStore } from '../../store/color';
|
|
4
|
-
let {
|
|
4
|
+
let { getColor } = useColorStore();
|
|
5
5
|
import propsData from './props';
|
|
6
6
|
import utils from '../../utils/utils';
|
|
7
7
|
import type {
|
|
@@ -29,13 +29,13 @@ defineOptions({
|
|
|
29
29
|
const props = defineProps(propsData);
|
|
30
30
|
|
|
31
31
|
const emits = defineEmits<{
|
|
32
|
-
(e: 'click', event?:
|
|
32
|
+
(e: 'click', event?: any): void;
|
|
33
33
|
(e: 'getphonenumber', event?: ButtonOnGetphonenumberEvent): void;
|
|
34
|
-
(e: 'getuserinfo', event?:
|
|
34
|
+
(e: 'getuserinfo', event?: any): void;
|
|
35
35
|
(e: 'error', event?: ButtonOnErrorEvent): void;
|
|
36
36
|
(e: 'opensetting', event?: ButtonOnOpensettingEvent): void;
|
|
37
37
|
(e: 'launchapp', event?: ButtonOnLaunchappEvent): void;
|
|
38
|
-
(e: 'contact', event?:
|
|
38
|
+
(e: 'contact', event?: any): void;
|
|
39
39
|
(e: 'chooseavatar', event?: ButtonOnChooseavatarEvent): void;
|
|
40
40
|
(e: 'agreeprivacyauthorization', event?: ButtonOnAgreeprivacyauthorizationEvent): void;
|
|
41
41
|
(e: 'addgroupapp', event?: ButtonOnAddgroupappEvent): void;
|
|
@@ -43,20 +43,12 @@ const emits = defineEmits<{
|
|
|
43
43
|
(e: 'chooseinvoicetitle', event?: ButtonOnChooseinvoicetitleEvent): void;
|
|
44
44
|
(e: 'subscribe', event?: ButtonOnSubscribeEvent): void;
|
|
45
45
|
(e: 'login', event?: ButtonOnLoginEvent): void;
|
|
46
|
-
(e: 'getrealtimephonenumber', event?:
|
|
47
|
-
(e: 'greeprivacyauthorization', event?:
|
|
48
|
-
(e: 'getAuthorize', event?:
|
|
49
|
-
(e: 'followLifestyle', event?:
|
|
46
|
+
(e: 'getrealtimephonenumber', event?: any): void;
|
|
47
|
+
(e: 'greeprivacyauthorization', event?: any): void;
|
|
48
|
+
(e: 'getAuthorize', event?: any): void;
|
|
49
|
+
(e: 'followLifestyle', event?: any): void;
|
|
50
50
|
}>();
|
|
51
51
|
|
|
52
|
-
watch(
|
|
53
|
-
() => color,
|
|
54
|
-
v => {
|
|
55
|
-
console.log('vvvv', v);
|
|
56
|
-
},
|
|
57
|
-
{ immediate: true, deep: true }
|
|
58
|
-
);
|
|
59
|
-
|
|
60
52
|
const cmpBtnStyle = computed(() => {
|
|
61
53
|
let style = {} as CSSProperties;
|
|
62
54
|
// 为解决支付宝动态类名时不兼容,尽量使用内联样式
|
|
@@ -116,9 +108,8 @@ const cmpBtnStyle = computed(() => {
|
|
|
116
108
|
style.fontSize = 'var(--font-size-28, 28rpx)';
|
|
117
109
|
break;
|
|
118
110
|
}
|
|
119
|
-
console.log('color', color);
|
|
120
111
|
// 背景色 & 字体色
|
|
121
|
-
style = { ...style, ...utils.bg2style(props.background ? props.background :
|
|
112
|
+
style = { ...style, ...utils.bg2style(props.background ? props.background : getColor().steThemeColor) };
|
|
122
113
|
style.color = props.color;
|
|
123
114
|
|
|
124
115
|
// 禁用 disabled | 加载 loading
|
|
@@ -137,7 +128,7 @@ const cmpBtnStyle = computed(() => {
|
|
|
137
128
|
return utils.deepMerge(style, props.rootStyle);
|
|
138
129
|
});
|
|
139
130
|
|
|
140
|
-
function handleClick(e:
|
|
131
|
+
function handleClick(e: any) {
|
|
141
132
|
if (props.disabled || props.loading) return;
|
|
142
133
|
emits('click', e);
|
|
143
134
|
}
|
|
@@ -16,7 +16,7 @@ const iconSize = ref(50);
|
|
|
16
16
|
const initializing = ref(true);
|
|
17
17
|
|
|
18
18
|
const emits = defineEmits<{
|
|
19
|
-
(e: 'click', event?:
|
|
19
|
+
(e: 'click', event?: any): void;
|
|
20
20
|
(e: 'load', event?: BaseEvent): void;
|
|
21
21
|
(e: 'error', event?: BaseEvent): void;
|
|
22
22
|
}>();
|
|
@@ -65,7 +65,7 @@ const onFault = (e?: BaseEvent) => {
|
|
|
65
65
|
emits('error', e);
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
-
const click = (e:
|
|
68
|
+
const click = (e: any) => {
|
|
69
69
|
emits('click', e);
|
|
70
70
|
};
|
|
71
71
|
|
|
@@ -14,7 +14,7 @@ const props = defineProps(propsData);
|
|
|
14
14
|
|
|
15
15
|
const emits = defineEmits<{
|
|
16
16
|
(e: 'end', value: string | number): void;
|
|
17
|
-
(e: 'close', value:
|
|
17
|
+
(e: 'close', value: any): void;
|
|
18
18
|
(e: 'click', value: string | number): void;
|
|
19
19
|
}>();
|
|
20
20
|
|
|
@@ -148,7 +148,7 @@ function doPause() {
|
|
|
148
148
|
function doRun() {
|
|
149
149
|
touch.value = false;
|
|
150
150
|
}
|
|
151
|
-
function handleClose(e:
|
|
151
|
+
function handleClose(e: any) {
|
|
152
152
|
closeShow.value = false;
|
|
153
153
|
emits('close', e);
|
|
154
154
|
}
|
|
@@ -1,72 +1,63 @@
|
|
|
1
|
-
import type { ExtractPropTypes, PropType } from 'vue'
|
|
2
|
-
import type { TableColumnProps } from '../ste-table-column/props'
|
|
1
|
+
import type { ExtractPropTypes, PropType } from 'vue';
|
|
2
|
+
import type { TableColumnProps } from '../ste-table-column/props';
|
|
3
3
|
|
|
4
|
-
const DEFAULT_SUM_TEXT = '合计'
|
|
5
|
-
export const CHECK_ICON_SIZE = 36
|
|
6
|
-
export const TABLE_KEY = Symbol('ste-table')
|
|
4
|
+
const DEFAULT_SUM_TEXT = '合计';
|
|
5
|
+
export const CHECK_ICON_SIZE = 36;
|
|
6
|
+
export const TABLE_KEY = Symbol('ste-table');
|
|
7
7
|
|
|
8
8
|
export const SELECTION_COLOR_CONFIG = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
9
|
+
main: '#3491FA',
|
|
10
|
+
unSelected: '#BBBBBB',
|
|
11
|
+
disabled: '#E6E6E6',
|
|
12
|
+
readonly: 'rgba(52, 145, 250, 0.4)',
|
|
13
|
+
};
|
|
14
14
|
|
|
15
15
|
const tableProps = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export type TableProps = ExtractPropTypes<typeof tableProps
|
|
51
|
-
|
|
52
|
-
// export type TableEmits = {
|
|
53
|
-
// (e: 'selectAll', selectionList: []): void;
|
|
54
|
-
// (e: 'select', selectionList: [], row: {}): void;
|
|
55
|
-
// (e: 'cellClick', row: {}, column: {}, event: Event): void;
|
|
56
|
-
// (e: 'rowClick', row: {}, event: Event): void;
|
|
57
|
-
// (e: 'headerClick', column: {}, event: Event): void;
|
|
58
|
-
// (e: 'scrollToLower'): void;
|
|
59
|
-
// };
|
|
16
|
+
data: { type: Array, default: () => [] },
|
|
17
|
+
sticky: Boolean,
|
|
18
|
+
offsetTop: { type: [Number, String], default: 0 },
|
|
19
|
+
border: Boolean,
|
|
20
|
+
stripe: { type: Boolean, default: true },
|
|
21
|
+
emptyText: String,
|
|
22
|
+
// 表尾显示合计行
|
|
23
|
+
showSummary: Boolean,
|
|
24
|
+
sumText: { type: String, default: DEFAULT_SUM_TEXT },
|
|
25
|
+
summaryMethod: { type: Function, default: () => {} },
|
|
26
|
+
selectable: { type: [Function], default: null },
|
|
27
|
+
readable: { type: [Function], default: null },
|
|
28
|
+
fixed: Boolean,
|
|
29
|
+
formatter: { type: [Function], default: null },
|
|
30
|
+
header: { type: [Function, String], default: null },
|
|
31
|
+
height: [Number, String],
|
|
32
|
+
headerRowClassName: [String, Function],
|
|
33
|
+
headerRowStyle: [Object, Function],
|
|
34
|
+
headerCellClassName: [String, Function],
|
|
35
|
+
headerCellStyle: [Object, Function],
|
|
36
|
+
rowClassName: [String, Function],
|
|
37
|
+
rowStyle: [Object, Function],
|
|
38
|
+
cellClassName: [String, Function],
|
|
39
|
+
cellStyle: [Object, Function],
|
|
40
|
+
highlightCurrentRow: Boolean,
|
|
41
|
+
highlightSelectionRow: Boolean,
|
|
42
|
+
showHeader: { type: Boolean, default: true },
|
|
43
|
+
maxHeight: [Number, String],
|
|
44
|
+
selectionIconColor: {
|
|
45
|
+
type: Object as PropType<typeof SELECTION_COLOR_CONFIG>,
|
|
46
|
+
default: () => SELECTION_COLOR_CONFIG,
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export type TableProps = ExtractPropTypes<typeof tableProps>;
|
|
60
51
|
|
|
61
52
|
export const tableEmits = {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
53
|
+
selectAll: (selectionList: object[]) => Array.isArray(selectionList),
|
|
54
|
+
select: (selectionList: object[], row: object) => Array.isArray(selectionList) && row instanceof Object,
|
|
55
|
+
cellClick: (row: object, column: TableColumnProps, event: any) => row instanceof Object && column instanceof Object && event,
|
|
56
|
+
rowClick: (row: object, event: any) => row instanceof Object && event,
|
|
57
|
+
headerClick: (column: TableColumnProps, event: any) => column instanceof Object && event,
|
|
58
|
+
scrollToLower: () => true,
|
|
59
|
+
};
|
|
69
60
|
|
|
70
|
-
export type TableEmits = typeof tableEmits
|
|
61
|
+
export type TableEmits = typeof tableEmits;
|
|
71
62
|
|
|
72
|
-
export default tableProps
|
|
63
|
+
export default tableProps;
|
|
@@ -1,233 +1,217 @@
|
|
|
1
|
-
import type { CSSProperties, SetupContext } from 'vue'
|
|
2
|
-
import { nextTick, ref } from 'vue'
|
|
3
|
-
import type { TableColumnProps } from '../ste-table-column/props'
|
|
4
|
-
import utils from '../../utils/utils'
|
|
5
|
-
import type { Obj } from '../../types'
|
|
6
|
-
import type { AllStateType, SelectColType } from './types'
|
|
7
|
-
import type { TableEmits, TableProps } from './props'
|
|
8
|
-
import { getStyleOrClass } from './utils'
|
|
1
|
+
import type { CSSProperties, SetupContext } from 'vue';
|
|
2
|
+
import { nextTick, ref } from 'vue';
|
|
3
|
+
import type { TableColumnProps } from '../ste-table-column/props';
|
|
4
|
+
import utils from '../../utils/utils';
|
|
5
|
+
import type { Obj } from '../../types';
|
|
6
|
+
import type { AllStateType, SelectColType } from './types';
|
|
7
|
+
import type { TableEmits, TableProps } from './props';
|
|
8
|
+
import { getStyleOrClass } from './utils';
|
|
9
9
|
|
|
10
10
|
export default function useData(props: TableProps, emits: SetupContext<TableEmits>['emit']) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
calcAllState()
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
//
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
getHeaderCellStyle,
|
|
218
|
-
getHeaderCellClass,
|
|
219
|
-
headerClick,
|
|
220
|
-
changeCheckAll,
|
|
221
|
-
handleScrollToLower,
|
|
222
|
-
getRowStyle,
|
|
223
|
-
getRowClass,
|
|
224
|
-
initSelection,
|
|
225
|
-
rowClick,
|
|
226
|
-
handleCheck,
|
|
227
|
-
cellClick,
|
|
228
|
-
toggleRowSelection,
|
|
229
|
-
toggleAllSelection,
|
|
230
|
-
clearSelection,
|
|
231
|
-
getSelection,
|
|
232
|
-
}
|
|
11
|
+
const tableData = ref<Obj[]>([]);
|
|
12
|
+
|
|
13
|
+
const columns = ref<TableColumnProps[]>([]);
|
|
14
|
+
const sumData = ref([]);
|
|
15
|
+
const currentRow = ref();
|
|
16
|
+
|
|
17
|
+
const checkStatesSet = ref(new Set<number>());
|
|
18
|
+
const checkStates = ref<number[]>([]);
|
|
19
|
+
const canCheckStates = ref<number[]>([]);
|
|
20
|
+
|
|
21
|
+
const checkAllState = ref<AllStateType>('none');
|
|
22
|
+
const selectType = ref<SelectColType>('checkbox');
|
|
23
|
+
|
|
24
|
+
function calcSum() {
|
|
25
|
+
if (!props.summaryMethod) return;
|
|
26
|
+
sumData.value = props.summaryMethod({ columns: columns.value, data: tableData.value });
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function loadSelectType() {
|
|
30
|
+
columns.value.forEach(e => {
|
|
31
|
+
if (e.type) selectType.value = e.type as SelectColType;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function loadCanCheckArr() {
|
|
36
|
+
const tmp: number[] = [];
|
|
37
|
+
tableData.value.forEach((e, index) => {
|
|
38
|
+
const selectFlag = props.selectable ? props.selectable(e, index) : true;
|
|
39
|
+
const readonlyFlag = props.readable ? !props.readable(e, index) : true;
|
|
40
|
+
|
|
41
|
+
if (selectFlag && readonlyFlag) tmp.push(index);
|
|
42
|
+
});
|
|
43
|
+
canCheckStates.value = tmp;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function initSelection() {
|
|
47
|
+
loadCanCheckArr();
|
|
48
|
+
checkStates.value = checkStates.value.filter(e => canCheckStates.value.includes(e));
|
|
49
|
+
calcAllState();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function calcAllState() {
|
|
53
|
+
// 处理当前全选框的状态
|
|
54
|
+
if (checkStates.value.length > 0) {
|
|
55
|
+
if (canCheckStates.value.length === checkStates.value.length) checkAllState.value = 'all';
|
|
56
|
+
else checkAllState.value = 'indeterminate';
|
|
57
|
+
} else {
|
|
58
|
+
checkAllState.value = 'none';
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function changeCheckAll() {
|
|
63
|
+
if (checkAllState.value !== 'all') {
|
|
64
|
+
emits(
|
|
65
|
+
'selectAll',
|
|
66
|
+
canCheckStates.value.map(e => tableData.value[e])
|
|
67
|
+
);
|
|
68
|
+
} else {
|
|
69
|
+
emits('selectAll', []);
|
|
70
|
+
}
|
|
71
|
+
toggleAllSelection();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// column组件更改Check状态
|
|
75
|
+
function handleCheck(row: Obj, isEmit = true) {
|
|
76
|
+
const rowIndex = row.rowIndex;
|
|
77
|
+
const state = !checkStatesSet.value.has(rowIndex);
|
|
78
|
+
if (selectType.value === 'radio') {
|
|
79
|
+
checkStatesSet.value = new Set();
|
|
80
|
+
checkStatesSet.value.add(rowIndex);
|
|
81
|
+
} else {
|
|
82
|
+
if (state) checkStatesSet.value.add(rowIndex);
|
|
83
|
+
else checkStatesSet.value.delete(rowIndex);
|
|
84
|
+
}
|
|
85
|
+
checkStates.value = Array.from(checkStatesSet.value);
|
|
86
|
+
|
|
87
|
+
isEmit && emits('select', getSelection(), row);
|
|
88
|
+
// this.currentRow = row;
|
|
89
|
+
calcAllState();
|
|
90
|
+
// this.$forceUpdate();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function cellClick(row: Obj, column: TableColumnProps, event: any) {
|
|
94
|
+
emits('cellClick', row, column, event);
|
|
95
|
+
}
|
|
96
|
+
function rowClick(row: Obj, event: any) {
|
|
97
|
+
currentRow.value = row;
|
|
98
|
+
emits('rowClick', row, event);
|
|
99
|
+
}
|
|
100
|
+
function headerClick(column: TableColumnProps, event: any) {
|
|
101
|
+
emits('headerClick', column, event);
|
|
102
|
+
}
|
|
103
|
+
function handleScrollToLower() {
|
|
104
|
+
emits('scrollToLower');
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// ***自定义class和style相关***
|
|
108
|
+
function getHeaderRowClass() {
|
|
109
|
+
const classes = [getStyleOrClass(props.headerRowClassName)];
|
|
110
|
+
return classes.join(' ');
|
|
111
|
+
}
|
|
112
|
+
function getHeaderRowStyle() {
|
|
113
|
+
return getStyleOrClass<object>(props.headerRowStyle);
|
|
114
|
+
}
|
|
115
|
+
function getHeaderCellClass(column: TableColumnProps, columnIndex: number) {
|
|
116
|
+
const classArr = [];
|
|
117
|
+
if (column.headerAlign && column.headerAlign !== 'left') classArr.push(`align-${column.headerAlign}`);
|
|
118
|
+
else if (column.align && column.align !== 'left') classArr.push(`align-${column.align}`);
|
|
119
|
+
|
|
120
|
+
classArr.push(getStyleOrClass(props.headerCellClassName, { columnIndex, column }));
|
|
121
|
+
return classArr.join(' ');
|
|
122
|
+
}
|
|
123
|
+
function getHeaderCellStyle(column: TableColumnProps, columnIndex: number, isProp = false) {
|
|
124
|
+
if (!isProp) {
|
|
125
|
+
const style = {} as CSSProperties;
|
|
126
|
+
if (column.width)
|
|
127
|
+
// style.width = utils.addUnit(column.width)
|
|
128
|
+
// style.flexBasis = utils.addUnit(column.width);
|
|
129
|
+
style.flex = `0 1 ${utils.addUnit(column.width)}`;
|
|
130
|
+
|
|
131
|
+
if (column.minWidth) style.minWidth = utils.addUnit(column.minWidth);
|
|
132
|
+
|
|
133
|
+
return style;
|
|
134
|
+
} else {
|
|
135
|
+
return getStyleOrClass<object>(props.headerCellStyle, { columnIndex, column });
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
function getRowClass(row: Obj, rowIndex: number) {
|
|
139
|
+
const classArr: any[] = [`row-${rowIndex}`];
|
|
140
|
+
if (props.highlightCurrentRow && utils.deepEqual(row, currentRow.value, ['rowIndex', 'colIndex'])) classArr.push('current-row');
|
|
141
|
+
|
|
142
|
+
if (props.highlightSelectionRow && checkStatesSet.value.has(rowIndex)) classArr.push('selection-row');
|
|
143
|
+
|
|
144
|
+
// const t = getStyleOrClass(props.rowClassName, { row, rowIndex })
|
|
145
|
+
classArr.push(getStyleOrClass(props.rowClassName, { row, rowIndex }));
|
|
146
|
+
return classArr.join(' ');
|
|
147
|
+
}
|
|
148
|
+
function getRowStyle(row: Obj, rowIndex: number) {
|
|
149
|
+
return getStyleOrClass(props.rowStyle, { row, rowIndex });
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// ***Table Methods 方法***
|
|
153
|
+
// 获取当前选择的数据
|
|
154
|
+
function getSelection() {
|
|
155
|
+
return checkStates.value.map(e => tableData.value[e]);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// 清空选择项
|
|
159
|
+
function clearSelection() {
|
|
160
|
+
checkStatesSet.value.clear();
|
|
161
|
+
checkStates.value = Array.from(checkStatesSet.value);
|
|
162
|
+
checkAllState.value = 'none';
|
|
163
|
+
}
|
|
164
|
+
// 切换某行的选中状态
|
|
165
|
+
function toggleRowSelection(row: Obj, isTriggerSelectEvent = true) {
|
|
166
|
+
nextTick(() => {
|
|
167
|
+
const index = tableData.value.findIndex(e => utils.deepEqual(row, e, ['rowIndex', 'colIndex']));
|
|
168
|
+
if (canCheckStates.value.indexOf(index) <= -1) return;
|
|
169
|
+
row.rowIndex = index;
|
|
170
|
+
handleCheck(row, isTriggerSelectEvent);
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
// 切换全选的状态
|
|
174
|
+
function toggleAllSelection() {
|
|
175
|
+
if (checkAllState.value === 'all') {
|
|
176
|
+
clearSelection();
|
|
177
|
+
} else {
|
|
178
|
+
canCheckStates.value.forEach(e => {
|
|
179
|
+
checkStatesSet.value.add(e);
|
|
180
|
+
});
|
|
181
|
+
checkStates.value = Array.from(checkStatesSet.value);
|
|
182
|
+
checkAllState.value = 'all';
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return {
|
|
187
|
+
tableData,
|
|
188
|
+
columns,
|
|
189
|
+
sumData,
|
|
190
|
+
currentRow,
|
|
191
|
+
checkStatesSet,
|
|
192
|
+
checkStates,
|
|
193
|
+
canCheckStates,
|
|
194
|
+
checkAllState,
|
|
195
|
+
selectType,
|
|
196
|
+
calcSum,
|
|
197
|
+
loadSelectType,
|
|
198
|
+
loadCanCheckArr,
|
|
199
|
+
getHeaderRowStyle,
|
|
200
|
+
getHeaderRowClass,
|
|
201
|
+
getHeaderCellStyle,
|
|
202
|
+
getHeaderCellClass,
|
|
203
|
+
headerClick,
|
|
204
|
+
changeCheckAll,
|
|
205
|
+
handleScrollToLower,
|
|
206
|
+
getRowStyle,
|
|
207
|
+
getRowClass,
|
|
208
|
+
initSelection,
|
|
209
|
+
rowClick,
|
|
210
|
+
handleCheck,
|
|
211
|
+
cellClick,
|
|
212
|
+
toggleRowSelection,
|
|
213
|
+
toggleAllSelection,
|
|
214
|
+
clearSelection,
|
|
215
|
+
getSelection,
|
|
216
|
+
};
|
|
233
217
|
}
|
|
@@ -120,7 +120,7 @@ function cellText(this: any) {
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
function cellClick(this: any, event:
|
|
123
|
+
function cellClick(this: any, event: any) {
|
|
124
124
|
parent?.cellClick(row.value, props, event);
|
|
125
125
|
// 扩大选中热区
|
|
126
126
|
if (props.type == 'checkbox' || props.type == 'radio') {
|
package/package.json
CHANGED
package/store/color.ts
CHANGED
|
@@ -1,21 +1,45 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { createStore } from 'vuex'; //导入createStore构造函数
|
|
2
|
+
const colorStore = createStore({
|
|
3
|
+
state: {
|
|
4
|
+
//Vuex的状态,实际上就是存数据的地方
|
|
5
|
+
color: {
|
|
6
|
+
steThemeColor: '#0090FF',
|
|
7
|
+
defaultColor: '#0090FF',
|
|
8
|
+
},
|
|
9
|
+
},
|
|
10
|
+
getters: {
|
|
11
|
+
//提供获取Vux状态的方式, 注意在组件中调用时getPerson是以属性的方式被访问
|
|
12
|
+
getColor(state) {
|
|
13
|
+
return state.color;
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
mutations: {
|
|
17
|
+
//提供直接操作Vuex的方法,注意mutations里的方法中不能有任何异步操做
|
|
18
|
+
setColor(state, value) {
|
|
19
|
+
//第一个参数state为Vuex状态;第二个参数为commit函数传来的值
|
|
20
|
+
Object.assign(state.color, value);
|
|
21
|
+
},
|
|
22
|
+
},
|
|
5
23
|
});
|
|
6
|
-
// 主题色内容
|
|
7
|
-
export function useColorStore() {
|
|
8
|
-
const getColor = () => {
|
|
9
|
-
return color;
|
|
10
|
-
};
|
|
11
|
-
const setColor = (value: any) => {
|
|
12
|
-
Object.assign(color, value);
|
|
13
|
-
console.log('color', color);
|
|
14
|
-
};
|
|
15
24
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
25
|
+
// import { reactive } from 'vue';
|
|
26
|
+
// const color = reactive({
|
|
27
|
+
// steThemeColor: '#0090FF',
|
|
28
|
+
// defaultColor: '#0090FF',
|
|
29
|
+
// });
|
|
30
|
+
// // 主题色内容
|
|
31
|
+
// export function useColorStore() {
|
|
32
|
+
// const getColor = () => {
|
|
33
|
+
// return color;
|
|
34
|
+
// };
|
|
35
|
+
// const setColor = (value: any) => {
|
|
36
|
+
// Object.assign(color, value);
|
|
37
|
+
// console.log('color', color);
|
|
38
|
+
// };
|
|
39
|
+
|
|
40
|
+
// return {
|
|
41
|
+
// color,
|
|
42
|
+
// getColor,
|
|
43
|
+
// setColor,
|
|
44
|
+
// };
|
|
45
|
+
// }
|