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.
@@ -15,7 +15,7 @@ defineOptions({
15
15
  const props = defineProps(propsData);
16
16
 
17
17
  const emits = defineEmits<{
18
- (e: 'click', event?: Event): void;
18
+ (e: 'click', event?: any): void;
19
19
  }>();
20
20
 
21
21
  const cmpContentStyle = computed(() => {
@@ -1,7 +1,7 @@
1
1
  <script setup lang="ts">
2
- import { computed, defineOptions, type CSSProperties, watch } from 'vue';
2
+ import { computed, defineOptions, type CSSProperties } from 'vue';
3
3
  import { useColorStore } from '../../store/color';
4
- let { color } = useColorStore();
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?: Event): void;
32
+ (e: 'click', event?: any): void;
33
33
  (e: 'getphonenumber', event?: ButtonOnGetphonenumberEvent): void;
34
- (e: 'getuserinfo', event?: Event): void;
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?: Event): void;
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?: Event): void;
47
- (e: 'greeprivacyauthorization', event?: Event): void;
48
- (e: 'getAuthorize', event?: Event): void;
49
- (e: 'followLifestyle', event?: Event): void;
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 : color.steThemeColor) };
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: Event) {
131
+ function handleClick(e: any) {
141
132
  if (props.disabled || props.loading) return;
142
133
  emits('click', e);
143
134
  }
@@ -14,7 +14,7 @@ defineOptions({
14
14
 
15
15
  const props = defineProps(propsData);
16
16
  const emits = defineEmits<{
17
- (e: 'click', event?: Event): void;
17
+ (e: 'click', event?: any): void;
18
18
  }>();
19
19
 
20
20
  let defaultFontFamily = 'ste-iconfont-1709689042473';
@@ -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?: Event): void;
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: Event) => {
68
+ const click = (e: any) => {
69
69
  emits('click', e);
70
70
  };
71
71
 
@@ -93,7 +93,7 @@ watch(
93
93
  }
94
94
  );
95
95
 
96
- function onInput(e: Event) {
96
+ function onInput(e: any) {
97
97
  const baseEvent = e as unknown as BaseEvent;
98
98
  if (!props.disabled && !props.readonly) {
99
99
  if (!props.allowSpace) {
@@ -110,7 +110,7 @@ function closeBox() {
110
110
  show.value = false;
111
111
  }, DURATION);
112
112
  }
113
- function handleInput(e: Event) {
113
+ function handleInput(e: any) {
114
114
  const baseEvent = e as unknown as BaseEvent;
115
115
  inputValue.value = baseEvent.detail.value;
116
116
  }
@@ -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: Event): void;
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: Event) {
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
- main: '#3491FA',
10
- unSelected: '#BBBBBB',
11
- disabled: '#E6E6E6',
12
- readonly: 'rgba(52, 145, 250, 0.4)',
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
- 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>
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
- selectAll: (selectionList: object[]) => Array.isArray(selectionList),
63
- select: (selectionList: object[], row: object) => Array.isArray(selectionList) && row instanceof Object,
64
- cellClick: (row: object, column: TableColumnProps, event: Event) => row instanceof Object && column instanceof Object && event instanceof Event,
65
- rowClick: (row: object, event: Event) => row instanceof Object && event instanceof Event,
66
- headerClick: (column: TableColumnProps, event: Event) => column instanceof Object && event instanceof Event,
67
- scrollToLower: () => true,
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
- 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)
26
- return
27
- sumData.value = props.summaryMethod({ columns: columns.value, data: tableData.value })
28
- }
29
-
30
- function loadSelectType() {
31
- columns.value.forEach((e) => {
32
- if (e.type)
33
- selectType.value = e.type as SelectColType
34
- })
35
- }
36
-
37
- function loadCanCheckArr() {
38
- const tmp: number[] = []
39
- tableData.value.forEach((e, index) => {
40
- const selectFlag = props.selectable ? props.selectable(e, index) : true
41
- const readonlyFlag = props.readable ? !props.readable(e, index) : true
42
-
43
- if (selectFlag && readonlyFlag)
44
- tmp.push(index)
45
- })
46
- canCheckStates.value = tmp
47
- }
48
-
49
- function initSelection() {
50
- loadCanCheckArr()
51
- checkStates.value = checkStates.value.filter(e => canCheckStates.value.includes(e))
52
- calcAllState()
53
- }
54
-
55
- function calcAllState() {
56
- // 处理当前全选框的状态
57
- if (checkStates.value.length > 0) {
58
- if (canCheckStates.value.length === checkStates.value.length)
59
- checkAllState.value = 'all'
60
- else checkAllState.value = 'indeterminate'
61
- }
62
- else {
63
- checkAllState.value = 'none'
64
- }
65
- }
66
-
67
- function changeCheckAll() {
68
- if (checkAllState.value !== 'all') {
69
- emits(
70
- 'selectAll',
71
- canCheckStates.value.map(e => tableData.value[e]),
72
- )
73
- }
74
- else {
75
- emits('selectAll', [])
76
- }
77
- toggleAllSelection()
78
- }
79
-
80
- // column组件更改Check状态
81
- function handleCheck(row: Obj, isEmit = true) {
82
- const rowIndex = row.rowIndex
83
- const state = !checkStatesSet.value.has(rowIndex)
84
- if (selectType.value === 'radio') {
85
- checkStatesSet.value = new Set()
86
- checkStatesSet.value.add(rowIndex)
87
- }
88
- else {
89
- if (state)
90
- checkStatesSet.value.add(rowIndex)
91
- else checkStatesSet.value.delete(rowIndex)
92
- }
93
- checkStates.value = Array.from(checkStatesSet.value)
94
-
95
- isEmit && emits('select', getSelection(), row)
96
- // this.currentRow = row;
97
- calcAllState()
98
- // this.$forceUpdate();
99
- }
100
-
101
- function cellClick(row: Obj, column: TableColumnProps, event: Event) {
102
- emits('cellClick', row, column, event)
103
- }
104
- function rowClick(row: Obj, event: Event) {
105
- currentRow.value = row
106
- emits('rowClick', row, event)
107
- }
108
- function headerClick(column: TableColumnProps, event: Event) {
109
- emits('headerClick', column, event)
110
- }
111
- function handleScrollToLower() {
112
- emits('scrollToLower')
113
- }
114
-
115
- // ***自定义class和style相关***
116
- function getHeaderRowClass() {
117
- const classes = [getStyleOrClass(props.headerRowClassName)]
118
- return classes.join(' ')
119
- }
120
- function getHeaderRowStyle() {
121
- return getStyleOrClass<object>(props.headerRowStyle)
122
- }
123
- function getHeaderCellClass(column: TableColumnProps, columnIndex: number) {
124
- const classArr = []
125
- if (column.headerAlign && column.headerAlign !== 'left')
126
- classArr.push(`align-${column.headerAlign}`)
127
- else if (column.align && column.align !== 'left')
128
- classArr.push(`align-${column.align}`)
129
-
130
- classArr.push(getStyleOrClass(props.headerCellClassName, { columnIndex, column }))
131
- return classArr.join(' ')
132
- }
133
- function getHeaderCellStyle(column: TableColumnProps, columnIndex: number, isProp = false) {
134
- if (!isProp) {
135
- const style = {} as CSSProperties
136
- if (column.width)
137
- // style.width = utils.addUnit(column.width)
138
- // style.flexBasis = utils.addUnit(column.width);
139
- style.flex = `0 1 ${utils.addUnit(column.width)}`
140
-
141
- if (column.minWidth)
142
- style.minWidth = utils.addUnit(column.minWidth)
143
-
144
- return style
145
- }
146
- else {
147
- return getStyleOrClass<object>(props.headerCellStyle, { columnIndex, column })
148
- }
149
- }
150
- function getRowClass(row: Obj, rowIndex: number) {
151
- const classArr: any[] = [`row-${rowIndex}`]
152
- if (props.highlightCurrentRow && utils.deepEqual(row, currentRow.value, ['rowIndex', 'colIndex']))
153
- classArr.push('current-row')
154
-
155
- if (props.highlightSelectionRow && checkStatesSet.value.has(rowIndex))
156
- classArr.push('selection-row')
157
-
158
- // const t = getStyleOrClass(props.rowClassName, { row, rowIndex })
159
- classArr.push(getStyleOrClass(props.rowClassName, { row, rowIndex }))
160
- return classArr.join(' ')
161
- }
162
- function getRowStyle(row: Obj, rowIndex: number) {
163
- return getStyleOrClass(props.rowStyle, { row, rowIndex })
164
- }
165
-
166
- // ***Table Methods 方法***
167
- // 获取当前选择的数据
168
- function getSelection() {
169
- return checkStates.value.map(e => tableData.value[e])
170
- }
171
-
172
- // 清空选择项
173
- function clearSelection() {
174
- checkStatesSet.value.clear()
175
- checkStates.value = Array.from(checkStatesSet.value)
176
- checkAllState.value = 'none'
177
- }
178
- // 切换某行的选中状态
179
- function toggleRowSelection(row: Obj, isTriggerSelectEvent = true) {
180
- nextTick(() => {
181
- const index = tableData.value.findIndex(e => utils.deepEqual(row, e, ['rowIndex', 'colIndex']))
182
- if (canCheckStates.value.indexOf(index) <= -1)
183
- return
184
- row.rowIndex = index
185
- handleCheck(row, isTriggerSelectEvent)
186
- })
187
- }
188
- // 切换全选的状态
189
- function toggleAllSelection() {
190
- if (checkAllState.value === 'all') {
191
- clearSelection()
192
- }
193
- else {
194
- canCheckStates.value.forEach((e) => {
195
- checkStatesSet.value.add(e)
196
- })
197
- checkStates.value = Array.from(checkStatesSet.value)
198
- checkAllState.value = 'all'
199
- }
200
- }
201
-
202
- return {
203
- tableData,
204
- columns,
205
- sumData,
206
- currentRow,
207
- checkStatesSet,
208
- checkStates,
209
- canCheckStates,
210
- checkAllState,
211
- selectType,
212
- calcSum,
213
- loadSelectType,
214
- loadCanCheckArr,
215
- getHeaderRowStyle,
216
- getHeaderRowClass,
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: 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stellar-ui-plus",
3
- "version": "1.17.7",
3
+ "version": "1.17.8",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "license": "MIT",
package/store/color.ts CHANGED
@@ -1,21 +1,45 @@
1
- import { reactive } from 'vue';
2
- const color = reactive({
3
- steThemeColor: '#0090FF',
4
- defaultColor: '#0090FF',
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
- return {
17
- color,
18
- getColor,
19
- setColor,
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
+ // }
package/store/index.ts CHANGED
@@ -1,5 +1,3 @@
1
- const store = {};
2
- export default store;
3
1
  // 模块统一导出
4
2
  // export * from './toast';
5
3
  // export * from './message-box';