stellar-ui-v2 1.35.3

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.
Files changed (141) hide show
  1. package/common/css/common.scss +61 -0
  2. package/components/ste-animate/README.md +117 -0
  3. package/components/ste-animate/animate.scss +247 -0
  4. package/components/ste-animate/ste-animate.vue +200 -0
  5. package/components/ste-badge/README.md +171 -0
  6. package/components/ste-badge/ste-badge.vue +238 -0
  7. package/components/ste-barcode/README.md +36 -0
  8. package/components/ste-barcode/encode2.js +317 -0
  9. package/components/ste-barcode/ste-barcode.vue +213 -0
  10. package/components/ste-button/README.md +129 -0
  11. package/components/ste-button/ste-button.vue +345 -0
  12. package/components/ste-calendar/README.md +304 -0
  13. package/components/ste-calendar/self-date.js +119 -0
  14. package/components/ste-calendar/ste-calendar.vue +578 -0
  15. package/components/ste-checkbox/README.md +297 -0
  16. package/components/ste-checkbox/ste-checkbox.vue +305 -0
  17. package/components/ste-checkbox-group/ste-checkbox-group.vue +133 -0
  18. package/components/ste-code-input/README.md +67 -0
  19. package/components/ste-code-input/ste-code-input.vue +302 -0
  20. package/components/ste-date-picker/README.md +135 -0
  21. package/components/ste-date-picker/ste-date-picker.vue +407 -0
  22. package/components/ste-drag/README.md +103 -0
  23. package/components/ste-drag/ste-drag.vue +203 -0
  24. package/components/ste-dropdown-menu/README.md +358 -0
  25. package/components/ste-dropdown-menu/ste-dropdown-menu.vue +405 -0
  26. package/components/ste-dropdown-menu-item/ste-dropdown-menu-item.vue +176 -0
  27. package/components/ste-icon/README.md +90 -0
  28. package/components/ste-icon/iconfont.css +8 -0
  29. package/components/ste-icon/ste-icon.vue +147 -0
  30. package/components/ste-image/README.md +154 -0
  31. package/components/ste-image/ste-image.vue +218 -0
  32. package/components/ste-index-item/ste-index-item.vue +96 -0
  33. package/components/ste-index-list/README.md +153 -0
  34. package/components/ste-index-list/ste-index-list.vue +128 -0
  35. package/components/ste-input/README.md +146 -0
  36. package/components/ste-input/ste-input.vue +480 -0
  37. package/components/ste-loading/README.md +81 -0
  38. package/components/ste-loading/ste-loading.vue +166 -0
  39. package/components/ste-media-preview/README.md +243 -0
  40. package/components/ste-media-preview/TouchScaleing.js +102 -0
  41. package/components/ste-media-preview/ste-media-preview.vue +267 -0
  42. package/components/ste-message-box/README.md +217 -0
  43. package/components/ste-message-box/ste-message-box.js +72 -0
  44. package/components/ste-message-box/ste-message-box.vue +380 -0
  45. package/components/ste-notice-bar/README.md +129 -0
  46. package/components/ste-notice-bar/ste-notice-bar.vue +331 -0
  47. package/components/ste-number-keyboard/README.md +246 -0
  48. package/components/ste-number-keyboard/keyboard.vue +140 -0
  49. package/components/ste-number-keyboard/ste-number-keyboard.vue +240 -0
  50. package/components/ste-picker/ste-picker.vue +258 -0
  51. package/components/ste-popup/README.md +148 -0
  52. package/components/ste-popup/ste-popup.vue +337 -0
  53. package/components/ste-price/README.md +129 -0
  54. package/components/ste-price/ste-price.vue +258 -0
  55. package/components/ste-progress/README.md +87 -0
  56. package/components/ste-progress/ste-progress.vue +200 -0
  57. package/components/ste-qrcode/README.md +50 -0
  58. package/components/ste-qrcode/ste-qrcode.vue +164 -0
  59. package/components/ste-qrcode/uqrcode.js +34 -0
  60. package/components/ste-radio/README.md +286 -0
  61. package/components/ste-radio/ste-radio.vue +293 -0
  62. package/components/ste-radio-group/ste-radio-group.vue +128 -0
  63. package/components/ste-rate/README.md +115 -0
  64. package/components/ste-rate/ste-rate.vue +202 -0
  65. package/components/ste-read-more/README.md +111 -0
  66. package/components/ste-read-more/ste-read-more.vue +133 -0
  67. package/components/ste-rich-text/README.md +31 -0
  68. package/components/ste-rich-text/ste-rich-text.vue +70 -0
  69. package/components/ste-scroll-to/README.md +68 -0
  70. package/components/ste-scroll-to/mixin.js +173 -0
  71. package/components/ste-scroll-to/ste-scroll-to.vue +45 -0
  72. package/components/ste-scroll-to-item/ste-scroll-to-item.vue +25 -0
  73. package/components/ste-search/README.md +262 -0
  74. package/components/ste-search/ste-search.vue +547 -0
  75. package/components/ste-select/README.md +434 -0
  76. package/components/ste-select/datapager.vue +62 -0
  77. package/components/ste-select/datetime.vue +106 -0
  78. package/components/ste-select/defaultDate.js +142 -0
  79. package/components/ste-select/ste-select.vue +843 -0
  80. package/components/ste-signature/README.md +105 -0
  81. package/components/ste-signature/ste-signature.vue +220 -0
  82. package/components/ste-slider/README.md +165 -0
  83. package/components/ste-slider/ste-slider.vue +544 -0
  84. package/components/ste-step/ste-step.vue +264 -0
  85. package/components/ste-stepper/README.md +170 -0
  86. package/components/ste-stepper/ste-stepper.vue +373 -0
  87. package/components/ste-steps/README.md +132 -0
  88. package/components/ste-steps/ste-steps.vue +65 -0
  89. package/components/ste-sticky/README.md +52 -0
  90. package/components/ste-sticky/ste-sticky.vue +127 -0
  91. package/components/ste-swipe-action/README.md +197 -0
  92. package/components/ste-swipe-action/ste-swipe-action.vue +303 -0
  93. package/components/ste-swipe-action-group/ste-swipe-action-group.vue +104 -0
  94. package/components/ste-swiper/README.md +173 -0
  95. package/components/ste-swiper/ste-swiper.vue +462 -0
  96. package/components/ste-swiper-item/ste-swiper-item.vue +41 -0
  97. package/components/ste-switch/README.md +110 -0
  98. package/components/ste-switch/ste-switch.vue +144 -0
  99. package/components/ste-tab/ste-tab.vue +87 -0
  100. package/components/ste-table/README.md +785 -0
  101. package/components/ste-table/common.js +8 -0
  102. package/components/ste-table/ste-table.vue +666 -0
  103. package/components/ste-table/utils.js +20 -0
  104. package/components/ste-table-column/checkbox-icon.vue +65 -0
  105. package/components/ste-table-column/common.scss +65 -0
  106. package/components/ste-table-column/radio-icon.vue +110 -0
  107. package/components/ste-table-column/ste-table-column.vue +255 -0
  108. package/components/ste-table-column/sub-table.vue +116 -0
  109. package/components/ste-table-column/table-popover.vue +204 -0
  110. package/components/ste-table-column/var.scss +1 -0
  111. package/components/ste-tabs/README.md +475 -0
  112. package/components/ste-tabs/props.js +212 -0
  113. package/components/ste-tabs/ste-tabs.vue +758 -0
  114. package/components/ste-text/README.md +66 -0
  115. package/components/ste-text/ste-text.vue +72 -0
  116. package/components/ste-toast/README.md +243 -0
  117. package/components/ste-toast/ste-toast.js +69 -0
  118. package/components/ste-toast/ste-toast.vue +231 -0
  119. package/components/ste-touch-swipe/README.md +104 -0
  120. package/components/ste-touch-swipe/TouchEvent.js +72 -0
  121. package/components/ste-touch-swipe/ste-touch-swipe.vue +327 -0
  122. package/components/ste-touch-swipe-item/ste-touch-swipe-item.vue +33 -0
  123. package/components/ste-tour/README.md +194 -0
  124. package/components/ste-tour/ste-tour.vue +355 -0
  125. package/components/ste-tree/README.md +240 -0
  126. package/components/ste-tree/ste-tree.vue +350 -0
  127. package/components/ste-upload/README.md +276 -0
  128. package/components/ste-upload/ReadFile.js +229 -0
  129. package/components/ste-upload/ste-upload.vue +526 -0
  130. package/components/ste-video/README.md +60 -0
  131. package/components/ste-video/props.js +149 -0
  132. package/components/ste-video/ste-video.vue +647 -0
  133. package/config/color.js +22 -0
  134. package/index.js +2 -0
  135. package/package.json +19 -0
  136. package/utils/Color.js +66 -0
  137. package/utils/System.js +110 -0
  138. package/utils/dayjs.min.js +1 -0
  139. package/utils/mixin.js +67 -0
  140. package/utils/store.js +7 -0
  141. package/utils/utils.js +604 -0
@@ -0,0 +1,65 @@
1
+ <template>
2
+ <view class="ste-table-checkbox-icon">
3
+ <ste-icon
4
+ code="&#xe6ae;"
5
+ :color="iconColorConfig.disabled || selectionColor.disabled"
6
+ :size="checkIconSize"
7
+ v-if="disabled"
8
+ />
9
+ <ste-icon
10
+ code="&#xe6ac;"
11
+ :color="iconColorConfig.readonly || selectionColor.readonly"
12
+ :size="checkIconSize"
13
+ v-else-if="readonly"
14
+ />
15
+ <template v-else>
16
+ <ste-icon
17
+ code="&#xe6ac;"
18
+ :color="iconColorConfig.main || selectionColor.main"
19
+ :size="checkIconSize"
20
+ v-if="checked"
21
+ />
22
+ <ste-icon
23
+ code="&#xe6af;"
24
+ :color="iconColorConfig.unSelected || selectionColor.unSelected"
25
+ :size="checkIconSize"
26
+ v-else
27
+ />
28
+ </template>
29
+ </view>
30
+ </template>
31
+
32
+ <script>
33
+ import { selectionColorConfig } from '../ste-table/common';
34
+ export default {
35
+ options: {
36
+ virtualHost: true,
37
+ },
38
+ props: {
39
+ checked: {
40
+ type: [Boolean, null],
41
+ default: false,
42
+ },
43
+ disabled: {
44
+ type: [Boolean, null],
45
+ default: false,
46
+ },
47
+ readonly: {
48
+ type: [Boolean, null],
49
+ default: false,
50
+ },
51
+ iconColorConfig: {
52
+ type: [Object, null],
53
+ default: () => selectionColorConfig,
54
+ },
55
+ },
56
+ data() {
57
+ return {
58
+ checkIconSize: 36,
59
+ selectionColor: selectionColorConfig,
60
+ };
61
+ },
62
+ };
63
+ </script>
64
+
65
+ <style lang="scss" scoped></style>
@@ -0,0 +1,65 @@
1
+ @mixin cell {
2
+ flex: 1;
3
+ // padding: 24rpx 32rpx;
4
+ border-bottom: $default-border;
5
+ text-align: left;
6
+ min-height: 80rpx;
7
+ font-size: 24rpx;
8
+ // vertical-align: middle;
9
+ display: flex;
10
+ align-items: center;
11
+ }
12
+
13
+ &.popover {
14
+ overflow-x: hidden;
15
+ .cell-box {
16
+ // overflow: hidden;
17
+ max-width: 100%;
18
+ // white-space: nowrap;
19
+ // text-overflow: ellipsis;
20
+ // /* 防止文本被选中,提升移动端体验 */
21
+ // user-select: none;
22
+ // -webkit-user-select: none;
23
+ }
24
+ }
25
+
26
+ .cell-box {
27
+ // display: flex;
28
+ // align-items: center;
29
+ padding: 24rpx 32rpx;
30
+ }
31
+
32
+ &.border {
33
+ border-right: $default-border;
34
+ }
35
+
36
+ &.selection {
37
+ }
38
+
39
+ &.align-text-center {
40
+ text-align: center;
41
+ .cell-box {
42
+ text-align: center;
43
+ }
44
+ }
45
+
46
+ &.align-text-right {
47
+ text-align: right;
48
+ .cell-box {
49
+ text-align: right;
50
+ }
51
+ }
52
+
53
+ &.align-center {
54
+ justify-content: center;
55
+ .cell-box {
56
+ text-align: center;
57
+ }
58
+ }
59
+
60
+ &.align-right {
61
+ justify-content: flex-end;
62
+ .cell-box {
63
+ text-align: right;
64
+ }
65
+ }
@@ -0,0 +1,110 @@
1
+ <template>
2
+ <view class="radio-icon-root" :class="[cmpRootClass]" :style="[comRootStyle]">
3
+ <view class="icon-1"></view>
4
+ </view>
5
+ </template>
6
+
7
+ <script>
8
+ import utils from '../../utils/utils.js';
9
+ import { selectionColorConfig } from '../ste-table/common';
10
+ export default {
11
+ options: {
12
+ virtualHost: true,
13
+ },
14
+ props: {
15
+ checked: {
16
+ type: [Boolean, null],
17
+ default: false,
18
+ },
19
+ disabled: {
20
+ type: [Boolean, null],
21
+ default: false,
22
+ },
23
+ readonly: {
24
+ type: [Boolean, null],
25
+ default: false,
26
+ },
27
+ iconColorConfig: {
28
+ type: [Object, null],
29
+ default: () => selectionColorConfig,
30
+ },
31
+ },
32
+ data() {
33
+ return {
34
+ selectionColor: selectionColorConfig,
35
+ };
36
+ },
37
+ computed: {
38
+ cmpRootClass() {
39
+ let classArr = [];
40
+ if (this.checked) {
41
+ classArr.push('checked');
42
+ }
43
+ if (this.disabled) {
44
+ classArr.push('disabled');
45
+ }
46
+ if (this.readonly) {
47
+ classArr.push('readonly');
48
+ }
49
+
50
+ return classArr.join(' ');
51
+ },
52
+ comRootStyle() {
53
+ let tmpCorloConfig = selectionColorConfig;
54
+ if (this.iconColorConfig) {
55
+ tmpCorloConfig = this.iconColorConfig;
56
+ }
57
+ return {
58
+ '--main-color': tmpCorloConfig.main,
59
+ '--main-outer-color': utils.Color.formatColor(tmpCorloConfig.main, 0.2),
60
+ '--disabled-color': tmpCorloConfig.disabled,
61
+ '--un-selected-color': tmpCorloConfig.unSelected,
62
+ '--readonly-color': tmpCorloConfig.readonly,
63
+ '--readonly-outer-color': utils.Color.formatColor(tmpCorloConfig.readonly, 0.2),
64
+ };
65
+ },
66
+ },
67
+ };
68
+ </script>
69
+
70
+ <style lang="scss" scoped>
71
+ .radio-icon-root {
72
+ width: 32rpx;
73
+ height: 32rpx;
74
+
75
+ border-radius: 50%;
76
+ border: 2rpx solid var(--un-selected-color);
77
+ position: relative;
78
+
79
+ &.checked {
80
+ border: none;
81
+ background-color: var(--main-outer-color);
82
+ .icon-1 {
83
+ background-color: var(--main-color);
84
+ }
85
+ }
86
+
87
+ &.readonly {
88
+ border: none;
89
+ background-color: var(--readonly-outer-color);
90
+ .icon-1 {
91
+ background-color: var(--readonly-color);
92
+ }
93
+ }
94
+
95
+ &.disabled {
96
+ border: none;
97
+ background-color: var(--disabled-color);
98
+ }
99
+ .icon-1 {
100
+ width: 16rpx;
101
+ height: 16rpx;
102
+ border-radius: 50%;
103
+
104
+ position: absolute;
105
+ left: 50%;
106
+ top: 50%;
107
+ transform: translate(-50%, -50%);
108
+ }
109
+ }
110
+ </style>
@@ -0,0 +1,255 @@
1
+ <template>
2
+ <view class="ste-table-cell" :class="[cmpRootClass]" :style="[cmpRootStyle, cmpCellStyle]" @click="cellClick">
3
+ <template v-if="type">
4
+ <view class="cell-box" v-if="type == 'checkbox'" @click.stop="changeCheck">
5
+ <check-box-icon
6
+ :disabled="cmpDisableCheck"
7
+ :readonly="cmpReadonlyCheck"
8
+ :checked="cmpShowCheck"
9
+ :iconColorConfig="cmpSelectionIconColor"
10
+ />
11
+ </view>
12
+ <view class="cell-box" v-if="type == 'radio'" @click.stop="changeCheck">
13
+ <radio-icon
14
+ :disabled="cmpDisableCheck"
15
+ :readonly="cmpReadonlyCheck"
16
+ :checked="cmpShowCheck"
17
+ :iconColorConfig="cmpSelectionIconColor"
18
+ />
19
+ </view>
20
+ <view class="cell-box" v-if="type == 'index'">
21
+ {{ row.rowIndex + 1 }}
22
+ </view>
23
+ </template>
24
+ <template v-else>
25
+ <slot v-if="row[prop] || !$slots.empty">
26
+ <sub-table :rows="row[prop]" v-if="rowSpan" :border="cmpBorder" />
27
+ <view class="cell-box" v-else>
28
+ <!-- <text>{{ cellText() }}</text> -->
29
+ <table-popover :text="cellText()"></table-popover>
30
+ </view>
31
+ </slot>
32
+ <view class="cell-box" v-else>
33
+ <slot name="empty"><text>暂无数据</text></slot>
34
+ </view>
35
+ </template>
36
+ </view>
37
+ </template>
38
+
39
+ <script>
40
+ import RadioIcon from './radio-icon.vue';
41
+ import CheckBoxIcon from './checkbox-icon.vue';
42
+ import TablePopover from './table-popover.vue';
43
+ import SubTable from './sub-table.vue';
44
+ import utils from '../../utils/utils.js';
45
+ import { getStyleOrClass } from '../ste-table/utils';
46
+ import { childMixin } from '../../utils/mixin.js';
47
+ /**
48
+ * ste-table-column 表格列
49
+ * @description 表格列组件
50
+ * @tutorial https://stellar-ui.intecloud.com.cn/pc/index/index?name=ste-table
51
+ * @property {String} type 对应列的类型
52
+ * @property {String} label 显示的标题
53
+ * @property {String} prop 对应列内容的字段名
54
+ * @property {String} width 对应列的宽度
55
+ * @property {String} minWidth 对应列的最小宽度
56
+ * @property {String} align 对齐方式
57
+ * @property {String} textAlign 文字对齐方式,对应到css的text-align属性
58
+ * @property {String} headerAlign,表头对齐方式,若不设置该项,则使用表格的对齐方式
59
+ * @property {String} headerTextAlign,表头对齐方式,若不设置该项,则使用表格的对齐方式,对应到css的text-align属性
60
+ */
61
+ export default {
62
+ name: 'ste-table-column',
63
+ mixins: [childMixin('ste-table')],
64
+ components: { RadioIcon, CheckBoxIcon, SubTable, TablePopover },
65
+ options: {
66
+ virtualHost: true,
67
+ },
68
+ props: {
69
+ // 列类型:checkbox 可多选、radio 单选、index 从1开始展示索引
70
+ type: {
71
+ type: [String, null],
72
+ default: '',
73
+ },
74
+ customKey: {
75
+ type: [String, null],
76
+ default: '',
77
+ },
78
+ label: {
79
+ type: [String, null],
80
+ default: '',
81
+ },
82
+ prop: {
83
+ type: [String, null],
84
+ default: '',
85
+ },
86
+ width: {
87
+ type: [String, Number, null],
88
+ default: '',
89
+ },
90
+ minWidth: {
91
+ type: [String, null],
92
+ default: '',
93
+ },
94
+ align: {
95
+ type: [String, null],
96
+ default: 'left',
97
+ },
98
+ textAlign: {
99
+ type: [String, null],
100
+ default: 'left',
101
+ },
102
+ headerAlign: {
103
+ type: [String, null],
104
+ default: 'left',
105
+ },
106
+ headerTextAlign: {
107
+ type: [String, null],
108
+ default: 'left',
109
+ },
110
+ },
111
+ data() {
112
+ return {
113
+ row: {},
114
+ rowIndex: 0,
115
+ colIndex: 0,
116
+ rowSpan: false,
117
+ };
118
+ },
119
+ created() {},
120
+ watch: {
121
+ row: {
122
+ handler(val) {
123
+ if (Array.isArray(val[this.prop])) {
124
+ this.rowSpan = true;
125
+ }
126
+ },
127
+ immediate: true,
128
+ },
129
+ },
130
+ computed: {
131
+ cmpSelectionIconColor() {
132
+ return this.parent.selectionIconColor;
133
+ },
134
+ cmpRootStyle() {
135
+ let style = {};
136
+ if (this.width) {
137
+ // style.width = utils.addUnit(this.width);
138
+ // style.flexBasis = utils.addUnit(this.width);
139
+ style.flex = `0 1 ${utils.addUnit(this.width)}`;
140
+ }
141
+ if (this.minWidth) {
142
+ style.minWidth = utils.addUnit(this.minWidth);
143
+ }
144
+ return style;
145
+ },
146
+ cmpCellStyle() {
147
+ const cellClassParam = {
148
+ column: this.props,
149
+ columnIndex: this.row.colIndex,
150
+ row: this.row,
151
+ rowIndex: this.row.rowIndex,
152
+ };
153
+ return getStyleOrClass(this.parent.cellStyle, cellClassParam);
154
+ },
155
+ cmpRootClass() {
156
+ let classArr = [];
157
+ classArr.push(this.type);
158
+
159
+ if (this.align && this.align !== 'left') {
160
+ classArr.push('align-' + this.align);
161
+ }
162
+
163
+ if (this.textAlign && this.textAlign !== 'left') {
164
+ classArr.push('align-text-' + this.align);
165
+ }
166
+
167
+ if (this.parent.border) {
168
+ classArr.push('border');
169
+ }
170
+
171
+ if (this.parent.isPopover) {
172
+ classArr.push('popover');
173
+ }
174
+
175
+ if (this.rowSpan) {
176
+ classArr.push('row-span');
177
+ }
178
+
179
+ const cellClassParam = {
180
+ column: this.props,
181
+ columnIndex: this.row.colIndex,
182
+ row: this.row,
183
+ rowIndex: this.row.rowIndex,
184
+ };
185
+ classArr.push(getStyleOrClass(this.parent.cellClassName, cellClassParam, false));
186
+
187
+ return classArr.join(' ');
188
+ },
189
+ cmpShowCheck() {
190
+ if (!this.parent.checkStates || this.parent.checkStates.length == 0) return false;
191
+ let item = this.parent.checkStates.find((e) => e == this.row.rowIndex);
192
+ if (item != undefined) {
193
+ return true;
194
+ }
195
+ return false;
196
+ },
197
+ cmpDisableCheck() {
198
+ if (this.parent.selectable && this.type) {
199
+ return !this.parent.selectable(this.row, this.row.rowIndex);
200
+ }
201
+ return false;
202
+ },
203
+ cmpReadonlyCheck() {
204
+ if (this.parent.readable && this.type) {
205
+ return this.parent.readable(this.row, this.row.rowIndex);
206
+ }
207
+ return false;
208
+ },
209
+ cmpBorder() {
210
+ return this.parent.border;
211
+ },
212
+ },
213
+ methods: {
214
+ changeCheck() {
215
+ if (!this.cmpDisableCheck && !this.cmpReadonlyCheck) {
216
+ this.parent.handleCheck(this.row);
217
+ }
218
+ },
219
+ cellText(e) {
220
+ if (this.parent.formatter) {
221
+ let text = this.parent.formatter(this.row, this.customKey);
222
+ if (!text) {
223
+ text = this.row[this.prop];
224
+ }
225
+ return text;
226
+ } else {
227
+ if (this.row[this.prop]) {
228
+ return this.row[this.prop];
229
+ } else {
230
+ return this.parent.emptyText || '-';
231
+ }
232
+ }
233
+ },
234
+ cellClick(event) {
235
+ this.parent.cellClick(this.row, this._props, event);
236
+ // 扩大选中热区
237
+ if (this.type == 'checkbox' || this.type == 'radio') {
238
+ this.changeCheck();
239
+ }
240
+ },
241
+ },
242
+ };
243
+ </script>
244
+ <style lang="scss" scoped>
245
+ .ste-table-cell {
246
+ @import './var.scss';
247
+ @import './common.scss';
248
+ @include cell;
249
+
250
+ &.row-span {
251
+ padding-top: 0;
252
+ padding-bottom: 0;
253
+ }
254
+ }
255
+ </style>
@@ -0,0 +1,116 @@
1
+ <template>
2
+ <view class="sub-table-root" :class="[cmpRootClass]">
3
+ <view class="row" v-for="(v, i) in rows" :key="i" :style="[cmpRowStyle]">
4
+ <view class="cell">
5
+ {{ v }}
6
+ </view>
7
+ </view>
8
+ </view>
9
+ </template>
10
+
11
+ <script>
12
+ import utils from '../../utils/utils.js';
13
+
14
+ function findMaxInRange(tolerance, numbers = []) {
15
+ if (numbers.length === 0) return 0;
16
+
17
+ let max = Math.max(...numbers);
18
+ let min = Math.min(...numbers);
19
+
20
+ // 如果最大值和最小值的差值在浮动范围内,返回 0
21
+ if (max - min <= tolerance) {
22
+ return 0;
23
+ }
24
+
25
+ // 返回最大值
26
+ return max;
27
+ }
28
+ export default {
29
+ options: {
30
+ virtualHost: true,
31
+ },
32
+ props: {
33
+ rows: {
34
+ type: [Array, null],
35
+ default: () => [],
36
+ },
37
+ border: {
38
+ type: [Boolean, null],
39
+ default: false,
40
+ },
41
+ },
42
+ data() {
43
+ return {
44
+ rowEls: [],
45
+ };
46
+ },
47
+ mounted() {
48
+ utils.querySelector('.sub-table-root .row', this, true).then((rec) => {
49
+ this.rowEls = rec;
50
+ });
51
+ },
52
+ computed: {
53
+ cmpRootClass() {
54
+ let classArr = [];
55
+ if (this.border) {
56
+ classArr.push('border');
57
+ }
58
+ return classArr.join(' ');
59
+ },
60
+ cmpRowStyle() {
61
+ let style = {};
62
+ if (this.rowEls.length > 0) {
63
+ let maxHeight = findMaxInRange(
64
+ 0.5,
65
+ this.rowEls.map((e) => e.height)
66
+ );
67
+ if (maxHeight > 0) {
68
+ style.flexBasis = maxHeight + 'px';
69
+ style.flexGrow = 0;
70
+ }
71
+ }
72
+ return style;
73
+ },
74
+ },
75
+ };
76
+ </script>
77
+
78
+ <style lang="scss" scoped>
79
+ @import './var.scss';
80
+ .sub-table-root {
81
+ width: 100%;
82
+ height: 100%;
83
+ display: flex;
84
+ flex-direction: column;
85
+
86
+ &.border {
87
+ .row {
88
+ .cell {
89
+ border-bottom: $default-border;
90
+ }
91
+ }
92
+ }
93
+
94
+ .row {
95
+ // margin-left: -32rpx;
96
+ // width: calc(100% + 64rpx);
97
+ width: 100%;
98
+ display: flex;
99
+ justify-content: space-between;
100
+ flex: 1;
101
+ .cell {
102
+ @import './common.scss';
103
+ @include cell;
104
+ // padding-right: 0;
105
+
106
+ border-bottom: none;
107
+ padding: 24rpx 32rpx;
108
+ }
109
+ &:nth-last-child(1) {
110
+ .cell {
111
+ border-bottom: none;
112
+ }
113
+ }
114
+ }
115
+ }
116
+ </style>