hy-app 0.5.8 → 0.5.10
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/hy-action-sheet/index.scss +1 -1
- package/components/hy-address-picker/index.scss +1 -1
- package/components/hy-avatar/index.scss +1 -1
- package/components/hy-back-top/index.scss +1 -1
- package/components/hy-badge/index.scss +1 -1
- package/components/hy-button/index.scss +1 -1
- package/components/hy-calendar/index.scss +1 -1
- package/components/hy-card/hy-card.vue +1 -1
- package/components/hy-card/index.scss +1 -1
- package/components/hy-cell-item/hy-cell-item.vue +1 -0
- package/components/hy-cell-item/index.scss +1 -1
- package/components/hy-check-button/hy-check-button.vue +4 -4
- package/components/hy-checkbox/index.scss +1 -1
- package/components/hy-checkbox-group/index.scss +1 -1
- package/components/hy-checkbox-item/index.scss +1 -1
- package/components/hy-code-input/hy-code-input.vue +1 -1
- package/components/hy-code-input/index.scss +1 -1
- package/components/hy-config-provider/hy-config-provider.vue +4 -2
- package/components/hy-config-provider/index.scss +1 -1
- package/components/hy-count-down/index.scss +1 -1
- package/components/hy-count-to/index.scss +1 -1
- package/components/hy-coupon/index.scss +1 -1
- package/components/hy-datetime-picker/index.scss +1 -1
- package/components/hy-divider/index.scss +1 -1
- package/components/hy-dropdown/index.scss +1 -1
- package/components/hy-dropdown-item/index.scss +1 -1
- package/components/hy-empty/index.scss +1 -1
- package/components/hy-flex/index.scss +1 -1
- package/components/hy-float-button/index.scss +1 -1
- package/components/hy-folding-panel-item/index.scss +1 -1
- package/components/hy-form-item/index.scss +1 -1
- package/components/hy-grid/index.scss +1 -1
- package/components/hy-icon/index.scss +1 -1
- package/components/hy-image/index.scss +1 -1
- package/components/hy-input/hy-input.vue +1 -1
- package/components/hy-input/index.scss +6 -1
- package/components/hy-input/props.ts +1 -1
- package/components/hy-input/typing.d.ts +4 -0
- package/components/hy-line/index.scss +1 -1
- package/components/hy-line-progress/index.scss +2 -1
- package/components/hy-list/index.scss +1 -1
- package/components/hy-loading/index.scss +1 -1
- package/components/hy-menu/index.scss +1 -1
- package/components/hy-modal/index.scss +1 -1
- package/components/hy-navbar/hy-navbar.vue +26 -23
- package/components/hy-navbar/index.scss +2 -2
- package/components/hy-notice-bar/index.scss +1 -1
- package/components/hy-notify/index.scss +1 -1
- package/components/hy-number-step/index.scss +1 -1
- package/components/hy-overlay/index.scss +1 -1
- package/components/hy-pagination/index.scss +1 -1
- package/components/hy-picker/hy-picker.vue +92 -87
- package/components/hy-picker/index.scss +2 -2
- package/components/hy-picker/props.ts +1 -1
- package/components/hy-popover/index.scss +1 -1
- package/components/hy-popup/hy-popup.vue +3 -3
- package/components/hy-popup/index.scss +2 -1
- package/components/hy-price/index.scss +1 -1
- package/components/hy-qrcode/index.scss +1 -1
- package/components/hy-radio/index.scss +1 -1
- package/components/hy-rate/index.scss +1 -1
- package/components/hy-read-more/index.scss +2 -2
- package/components/hy-rolling-num/hy-rolling-num.vue +2 -12
- package/components/hy-rolling-num/index.scss +1 -1
- package/components/hy-scroll-list/index.scss +1 -1
- package/components/hy-search/index.scss +1 -1
- package/components/hy-signature/index.scss +1 -1
- package/components/hy-slider/index.scss +1 -1
- package/components/hy-status-bar/index.scss +1 -1
- package/components/hy-steps/index.scss +1 -1
- package/components/hy-sticky/index.scss +1 -1
- package/components/hy-submit-bar/index.scss +1 -1
- package/components/hy-subsection/index.scss +1 -1
- package/components/hy-swipe-action/index.scss +1 -1
- package/components/hy-swiper/index.scss +2 -2
- package/components/hy-switch/index.scss +1 -1
- package/components/hy-tabbar/index.scss +1 -1
- package/components/hy-tabbar-group/index.scss +1 -1
- package/components/hy-tabbar-item/index.scss +1 -1
- package/components/hy-table/hy-table.vue +358 -0
- package/components/hy-table/index.scss +197 -0
- package/components/hy-table/props.ts +47 -0
- package/components/hy-table/typing.d.ts +34 -0
- package/components/hy-tabs/index.scss +1 -1
- package/components/hy-tag/index.scss +1 -1
- package/components/hy-text/hy-text.vue +1 -1
- package/components/hy-text/index.scss +1 -1
- package/components/hy-textarea/hy-textarea.vue +1 -1
- package/components/hy-textarea/index.scss +6 -1
- package/components/hy-toast/index.scss +2 -1
- package/components/hy-tooltip/index.scss +2 -2
- package/components/hy-upload/index.scss +1 -1
- package/components/hy-warn/hy-warn.vue +2 -2
- package/components/hy-warn/index.scss +1 -1
- package/components/hy-waterfall/index.scss +1 -1
- package/components/hy-watermark/index.scss +1 -1
- package/index.scss +1 -1
- package/libs/css/{mixin.scss → _mixin.scss} +27 -13
- package/libs/css/theme.scss +5 -2
- package/libs/css/vars.scss +6 -0
- package/libs/utils/inside.ts +260 -271
- package/package.json +2 -2
- package/components/hy-rolling-num/README.md +0 -137
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="hy-table" :style="{ height: addUnit(height) }">
|
|
3
|
+
<!-- 主容器 -->
|
|
4
|
+
<view class="hy-table__container">
|
|
5
|
+
<!-- 表头区域 -->
|
|
6
|
+
<view class="hy-table__header">
|
|
7
|
+
<!-- 固定左列表头 -->
|
|
8
|
+
<view v-if="leftFixedColumns.length > 0" class="hy-table__header--left">
|
|
9
|
+
<view
|
|
10
|
+
class="hy-table__header__th"
|
|
11
|
+
v-for="(col, index) in leftFixedColumns"
|
|
12
|
+
:key="col.key || index"
|
|
13
|
+
:style="[getCellStyle(col, true)]"
|
|
14
|
+
@click="handleSort(col)"
|
|
15
|
+
>
|
|
16
|
+
<text class="hy-table__header__th--text">{{ col.title }}</text>
|
|
17
|
+
<!-- 排序图标 -->
|
|
18
|
+
<view v-if="col.sortable" class="hy-table__header__th--sort">
|
|
19
|
+
<hy-icon
|
|
20
|
+
:name="IconConfig.ARROW_UP_FILL"
|
|
21
|
+
size="10"
|
|
22
|
+
:custom-class="sortKey === col.key && sortType === 'asc' ? 'is-active' : ''"
|
|
23
|
+
/>
|
|
24
|
+
<hy-icon
|
|
25
|
+
:name="IconConfig.ARROW_DOWN_FILL"
|
|
26
|
+
size="10"
|
|
27
|
+
:custom-class="sortKey === col.key && sortType === 'desc' ? 'is-active' : ''"
|
|
28
|
+
/>
|
|
29
|
+
</view>
|
|
30
|
+
</view>
|
|
31
|
+
</view>
|
|
32
|
+
<!-- 中间表头 -->
|
|
33
|
+
<view class="hy-table__header--center" :style="{ paddingLeft: `${leftFixedWidth}px`, paddingRight: `${rightFixedWidth}px` }">
|
|
34
|
+
<view
|
|
35
|
+
class="hy-table__header__th"
|
|
36
|
+
v-for="(col, index) in scrollColumns"
|
|
37
|
+
:key="col.key || index"
|
|
38
|
+
:style="[getCellStyle(col, true)]"
|
|
39
|
+
@click="handleSort(col)"
|
|
40
|
+
>
|
|
41
|
+
<text class="hy-table__header__th--text">{{ col.title }}</text>
|
|
42
|
+
<!-- 排序图标 -->
|
|
43
|
+
<view v-if="col.sortable" class="hy-table__header__th--sort">
|
|
44
|
+
<hy-icon
|
|
45
|
+
:name="IconConfig.ARROW_UP_FILL"
|
|
46
|
+
size="10"
|
|
47
|
+
:custom-class="sortKey === col.key && sortType === 'asc' ? 'is-active' : ''"
|
|
48
|
+
/>
|
|
49
|
+
<hy-icon
|
|
50
|
+
:name="IconConfig.ARROW_DOWN_FILL"
|
|
51
|
+
size="10"
|
|
52
|
+
:custom-class="sortKey === col.key && sortType === 'desc' ? 'is-active' : ''"
|
|
53
|
+
/>
|
|
54
|
+
</view>
|
|
55
|
+
</view>
|
|
56
|
+
</view>
|
|
57
|
+
<!-- 固定右列表头 -->
|
|
58
|
+
<view v-if="rightFixedColumns.length > 0" class="hy-table__header--right">
|
|
59
|
+
<view
|
|
60
|
+
class="hy-table__header__th"
|
|
61
|
+
v-for="(col, index) in rightFixedColumns"
|
|
62
|
+
:key="col.key || index"
|
|
63
|
+
:style="[getCellStyle(col, true)]"
|
|
64
|
+
@click="handleSort(col)"
|
|
65
|
+
>
|
|
66
|
+
<text class="hy-table__header__th--text">{{ col.title }}</text>
|
|
67
|
+
<!-- 排序图标 -->
|
|
68
|
+
<view v-if="col.sortable" class="hy-table__header__th--sort">
|
|
69
|
+
<hy-icon
|
|
70
|
+
:name="IconConfig.ARROW_UP_FILL"
|
|
71
|
+
size="10"
|
|
72
|
+
:custom-class="sortKey === col.key && sortType === 'asc' ? 'is-active' : ''"
|
|
73
|
+
/>
|
|
74
|
+
<hy-icon
|
|
75
|
+
:name="IconConfig.ARROW_DOWN_FILL"
|
|
76
|
+
size="10"
|
|
77
|
+
:custom-class="sortKey === col.key && sortType === 'desc' ? 'is-active' : ''"
|
|
78
|
+
/>
|
|
79
|
+
</view>
|
|
80
|
+
</view>
|
|
81
|
+
</view>
|
|
82
|
+
</view>
|
|
83
|
+
|
|
84
|
+
<!-- 内容区域 -->
|
|
85
|
+
<scroll-view
|
|
86
|
+
class="hy-table__body"
|
|
87
|
+
scroll-y
|
|
88
|
+
:scroll-top="scrollTop"
|
|
89
|
+
@scroll="handleScroll"
|
|
90
|
+
>
|
|
91
|
+
<!-- 内容包装器 -->
|
|
92
|
+
<view class="hy-table__body__wrapper">
|
|
93
|
+
<!-- 固定左列内容 -->
|
|
94
|
+
<view v-if="leftFixedColumns.length > 0" class="hy-table__body--left">
|
|
95
|
+
<view
|
|
96
|
+
class="hy-table__body__tr"
|
|
97
|
+
v-for="(row, rowIndex) in tableData"
|
|
98
|
+
:key="`left-${row[rowKey] || rowIndex}`"
|
|
99
|
+
>
|
|
100
|
+
<view
|
|
101
|
+
class="hy-table__body__td"
|
|
102
|
+
v-for="(col, colIndex) in leftFixedColumns"
|
|
103
|
+
:key="col.key || colIndex"
|
|
104
|
+
:style="[getCellStyle(col, false)]"
|
|
105
|
+
@click.stop="handleCellClick(row, col)"
|
|
106
|
+
>
|
|
107
|
+
<slot name="default" :row="row" :col="col" :index="rowIndex">
|
|
108
|
+
<text :class="{ 'hy-table__body__td--ellipsis': col.ellipsis }">{{ row[col.key] }}</text>
|
|
109
|
+
</slot>
|
|
110
|
+
</view>
|
|
111
|
+
</view>
|
|
112
|
+
</view>
|
|
113
|
+
<!-- 中间内容 -->
|
|
114
|
+
<view class="hy-table__body--center" :style="{ paddingLeft: `${leftFixedWidth}px`, paddingRight: `${rightFixedWidth}px` }">
|
|
115
|
+
<view
|
|
116
|
+
class="hy-table__body__tr"
|
|
117
|
+
v-for="(row, rowIndex) in tableData"
|
|
118
|
+
:key="row[rowKey] || rowIndex"
|
|
119
|
+
@click="handleRowClick(row, rowIndex)"
|
|
120
|
+
>
|
|
121
|
+
<view
|
|
122
|
+
class="hy-table__body__td"
|
|
123
|
+
v-for="(col, colIndex) in scrollColumns"
|
|
124
|
+
:key="col.key || colIndex"
|
|
125
|
+
:style="[getCellStyle(col, false)]"
|
|
126
|
+
@click.stop="handleCellClick(row, col)"
|
|
127
|
+
>
|
|
128
|
+
<slot name="default" :row="row" :col="col" :index="rowIndex">
|
|
129
|
+
<text :class="{ 'hy-table__body__td--ellipsis': col.ellipsis }">{{ row[col.key] }}</text>
|
|
130
|
+
</slot>
|
|
131
|
+
</view>
|
|
132
|
+
</view>
|
|
133
|
+
</view>
|
|
134
|
+
<!-- 固定右列内容 -->
|
|
135
|
+
<view v-if="rightFixedColumns.length > 0" class="hy-table__body--right">
|
|
136
|
+
<view
|
|
137
|
+
class="hy-table__body__tr"
|
|
138
|
+
v-for="(row, rowIndex) in tableData"
|
|
139
|
+
:key="`right-${row[rowKey] || rowIndex}`"
|
|
140
|
+
>
|
|
141
|
+
<view
|
|
142
|
+
class="hy-table__body__td"
|
|
143
|
+
v-for="(col, colIndex) in rightFixedColumns"
|
|
144
|
+
:key="col.key || colIndex"
|
|
145
|
+
:style="[getCellStyle(col, false)]"
|
|
146
|
+
@click.stop="handleCellClick(row, col)"
|
|
147
|
+
>
|
|
148
|
+
<slot name="default" :row="row" :col="col" :index="rowIndex">
|
|
149
|
+
<text :class="{ 'hy-table__body__td--ellipsis': col.ellipsis }">{{ row[col.key] }}</text>
|
|
150
|
+
</slot>
|
|
151
|
+
</view>
|
|
152
|
+
</view>
|
|
153
|
+
</view>
|
|
154
|
+
</view>
|
|
155
|
+
|
|
156
|
+
<!-- 空状态 -->
|
|
157
|
+
<hy-empty
|
|
158
|
+
v-if="!loading && tableData.length === 0"
|
|
159
|
+
:description="emptyText"
|
|
160
|
+
></hy-empty>
|
|
161
|
+
|
|
162
|
+
<!-- 加载状态 -->
|
|
163
|
+
<hy-loading
|
|
164
|
+
v-if="loading"
|
|
165
|
+
text="加载中..."
|
|
166
|
+
mode="circle"
|
|
167
|
+
direction="column"
|
|
168
|
+
custom-class="hy-table__body--loading"
|
|
169
|
+
></hy-loading>
|
|
170
|
+
</scroll-view>
|
|
171
|
+
</view>
|
|
172
|
+
</view>
|
|
173
|
+
</template>
|
|
174
|
+
|
|
175
|
+
<script lang="ts">
|
|
176
|
+
export default {
|
|
177
|
+
name: 'hy-table',
|
|
178
|
+
options: {
|
|
179
|
+
addGlobalClass: true,
|
|
180
|
+
virtualHost: true,
|
|
181
|
+
styleIsolation: 'shared'
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
</script>
|
|
185
|
+
|
|
186
|
+
<script setup lang="ts">
|
|
187
|
+
import { computed, ref, watch } from 'vue'
|
|
188
|
+
import tableProps from './props'
|
|
189
|
+
import type { ITableColumn, ITableEmits, SortType } from './typing'
|
|
190
|
+
import { addUnit, IconConfig } from '../../libs'
|
|
191
|
+
// 组件
|
|
192
|
+
import HyEmpty from '../hy-empty/hy-empty.vue'
|
|
193
|
+
import HyLoading from '../hy-loading/hy-loading.vue'
|
|
194
|
+
import HyIcon from '../hy-icon/hy-icon.vue'
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* 用于展示多条结构类似的数据, 可对数据进行排序等操作。
|
|
198
|
+
* @displayName hy-table
|
|
199
|
+
*/
|
|
200
|
+
defineOptions({})
|
|
201
|
+
|
|
202
|
+
const props = defineProps(tableProps)
|
|
203
|
+
const emit = defineEmits<ITableEmits>()
|
|
204
|
+
|
|
205
|
+
// --- 状态管理 ---
|
|
206
|
+
const sortKey = ref<string>('')
|
|
207
|
+
const sortType = ref<SortType>('normal')
|
|
208
|
+
const tableData = ref<any[]>([]) // 内部维护的数据,用于排序展示
|
|
209
|
+
const scrollTop = ref<number>(0) // 滚动位置,用于控制表头定位
|
|
210
|
+
|
|
211
|
+
// --- 监听数据变化 ---
|
|
212
|
+
watch(
|
|
213
|
+
() => props.data,
|
|
214
|
+
(val) => {
|
|
215
|
+
tableData.value = [...val]
|
|
216
|
+
// 如果当前有排序状态,重新应用排序
|
|
217
|
+
if (sortKey.value && sortType.value) {
|
|
218
|
+
localSort()
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
{ immediate: true, deep: true }
|
|
222
|
+
)
|
|
223
|
+
|
|
224
|
+
// --- 计算固定列和滚动列 ---
|
|
225
|
+
const leftFixedColumns = computed(() => {
|
|
226
|
+
return props.columns.filter(col => col.fixed === 'left')
|
|
227
|
+
})
|
|
228
|
+
|
|
229
|
+
const rightFixedColumns = computed(() => {
|
|
230
|
+
return props.columns.filter(col => col.fixed === 'right')
|
|
231
|
+
})
|
|
232
|
+
|
|
233
|
+
const scrollColumns = computed(() => {
|
|
234
|
+
return props.columns.filter(col => !col.fixed)
|
|
235
|
+
})
|
|
236
|
+
|
|
237
|
+
// --- 计算固定列总宽度 ---
|
|
238
|
+
const leftFixedWidth = computed(() => {
|
|
239
|
+
let width = 0
|
|
240
|
+
leftFixedColumns.value.forEach(col => {
|
|
241
|
+
const w = parseInt(String(col.width || 100))
|
|
242
|
+
width += w
|
|
243
|
+
})
|
|
244
|
+
return width
|
|
245
|
+
})
|
|
246
|
+
|
|
247
|
+
const rightFixedWidth = computed(() => {
|
|
248
|
+
let width = 0
|
|
249
|
+
rightFixedColumns.value.forEach(col => {
|
|
250
|
+
const w = parseInt(String(col.width || 100))
|
|
251
|
+
width += w
|
|
252
|
+
})
|
|
253
|
+
return width
|
|
254
|
+
})
|
|
255
|
+
|
|
256
|
+
// --- 计算总宽度 (用于 scroll-view 横向滚动) ---
|
|
257
|
+
const totalMinWidth = computed(() => {
|
|
258
|
+
let width = 0
|
|
259
|
+
scrollColumns.value.forEach((col) => {
|
|
260
|
+
// 简单估算:如果有明确宽度则累加,否则给个默认值 100
|
|
261
|
+
const w = parseInt(String(col.width || 100))
|
|
262
|
+
width += w
|
|
263
|
+
})
|
|
264
|
+
return width
|
|
265
|
+
})
|
|
266
|
+
|
|
267
|
+
// --- 事件处理 ---
|
|
268
|
+
// 处理滚动事件
|
|
269
|
+
const handleScroll = (e: any) => {
|
|
270
|
+
scrollTop.value = e.detail.scrollTop
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// --- 样式计算 ---
|
|
274
|
+
const getCellStyle = (col: ITableColumn, isHeader: boolean) => {
|
|
275
|
+
const style: any = {}
|
|
276
|
+
|
|
277
|
+
// 处理宽度
|
|
278
|
+
if (col.width) {
|
|
279
|
+
const w = typeof col.width === 'number' ? `${col.width}px` : col.width
|
|
280
|
+
style.width = w
|
|
281
|
+
style.flex = `0 0 ${w}` // 固定宽度,不伸缩
|
|
282
|
+
} else {
|
|
283
|
+
style.flex = 1 // 自动填充
|
|
284
|
+
style.minWidth = '150rpx' // 最小宽度防止太挤
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// 处理对齐
|
|
288
|
+
style.justifyContent =
|
|
289
|
+
col.align === 'center' ? 'center' : col.align === 'right' ? 'flex-end' : 'flex-start'
|
|
290
|
+
style.textAlign = col.align || 'left'
|
|
291
|
+
|
|
292
|
+
return style
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// --- 排序逻辑 ---
|
|
296
|
+
const handleSort = (col: ITableColumn) => {
|
|
297
|
+
if (!col.sortable) return
|
|
298
|
+
|
|
299
|
+
// 切换排序状态: '' -> 'asc' -> 'desc' -> ''
|
|
300
|
+
if (sortKey.value !== col.key) {
|
|
301
|
+
sortKey.value = col.key
|
|
302
|
+
sortType.value = 'asc'
|
|
303
|
+
} else {
|
|
304
|
+
if (sortType.value === 'asc') sortType.value = 'desc'
|
|
305
|
+
else if (sortType.value === 'desc') sortType.value = 'normal'
|
|
306
|
+
else sortType.value = 'asc' // 逻辑闭环
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// 触发本地排序或远程排序事件
|
|
310
|
+
localSort()
|
|
311
|
+
emit('sort-change', { key: sortKey.value, type: sortType.value })
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
const localSort = () => {
|
|
315
|
+
if (!sortType.value) {
|
|
316
|
+
tableData.value = [...props.data] // 还原
|
|
317
|
+
return
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
tableData.value.sort((a, b) => {
|
|
321
|
+
const valA = a[sortKey.value]
|
|
322
|
+
const valB = b[sortKey.value]
|
|
323
|
+
|
|
324
|
+
// 简单的数字和字符串比较
|
|
325
|
+
if (valA === valB) return 0
|
|
326
|
+
|
|
327
|
+
let result = 0
|
|
328
|
+
if (typeof valA === 'number' && typeof valB === 'number') {
|
|
329
|
+
result = valA - valB
|
|
330
|
+
} else {
|
|
331
|
+
result = String(valA).localeCompare(String(valB))
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
return sortType.value === 'asc' ? result : -result
|
|
335
|
+
})
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
// --- 交互逻辑 ---
|
|
339
|
+
const handleRowClick = (row: any, index: number) => {
|
|
340
|
+
emit('row-click', row, index)
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// 处理单元格点击(主要用于Tooltip)
|
|
344
|
+
const handleCellClick = (row: any, col: ITableColumn) => {
|
|
345
|
+
// 如果开启了 tooltip,显示完整内容
|
|
346
|
+
if (col.tooltip && col.ellipsis) {
|
|
347
|
+
const content = row[col.key]
|
|
348
|
+
if (content) {
|
|
349
|
+
uni.showToast({ title: String(content), icon: 'none' })
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
emit('cell-click', row, col)
|
|
353
|
+
}
|
|
354
|
+
</script>
|
|
355
|
+
|
|
356
|
+
<style lang="scss" scoped>
|
|
357
|
+
@import './index.scss';
|
|
358
|
+
</style>
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
@use "../../libs/css/theme" as *;
|
|
2
|
+
@use "../../libs/css/mixin" as *;
|
|
3
|
+
|
|
4
|
+
/* 变量定义 */
|
|
5
|
+
$border-color: #ebeef5;
|
|
6
|
+
$header-bg: $hy-background--table-header;
|
|
7
|
+
$text-color: #606266;
|
|
8
|
+
$header-text-color: #909399;
|
|
9
|
+
$stripe-bg: $hy-background--table-header;
|
|
10
|
+
$hover-bg: #f5f7fa;
|
|
11
|
+
|
|
12
|
+
/*#1d1d1d*/
|
|
13
|
+
|
|
14
|
+
@include b(table) {
|
|
15
|
+
width: 100%;
|
|
16
|
+
background-color: $hy-background--container;
|
|
17
|
+
border: $hy-border-line;
|
|
18
|
+
position: relative;
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-direction: column;
|
|
21
|
+
|
|
22
|
+
@include e(container) {
|
|
23
|
+
display: flex;
|
|
24
|
+
flex-direction: column;
|
|
25
|
+
height: 100%;
|
|
26
|
+
width: 100%;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* 表头区域 */
|
|
30
|
+
@include e(header) {
|
|
31
|
+
display: flex;
|
|
32
|
+
position: sticky;
|
|
33
|
+
top: 0;
|
|
34
|
+
z-index: 10;
|
|
35
|
+
background-color: $header-bg;
|
|
36
|
+
border-bottom: $hy-border-line;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/* 左固定表头 */
|
|
40
|
+
@include e(header--left) {
|
|
41
|
+
position: absolute;
|
|
42
|
+
left: 0;
|
|
43
|
+
top: 0;
|
|
44
|
+
display: flex;
|
|
45
|
+
background-color: $header-bg;
|
|
46
|
+
z-index: 12;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/* 中间表头 */
|
|
50
|
+
@include e(header--center) {
|
|
51
|
+
display: flex;
|
|
52
|
+
flex: 1;
|
|
53
|
+
overflow-x: hidden;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/* 右固定表头 */
|
|
57
|
+
@include e(header--right) {
|
|
58
|
+
position: absolute;
|
|
59
|
+
right: 0;
|
|
60
|
+
top: 0;
|
|
61
|
+
display: flex;
|
|
62
|
+
background-color: $header-bg;
|
|
63
|
+
z-index: 12;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/* 表头单元格 */
|
|
67
|
+
@include e(header__th) {
|
|
68
|
+
@include flex(center);
|
|
69
|
+
padding: 0 20rpx;
|
|
70
|
+
height: 88rpx;
|
|
71
|
+
box-sizing: border-box;
|
|
72
|
+
background-color: $header-bg;
|
|
73
|
+
font-size: 28rpx;
|
|
74
|
+
color: $header-text-color;
|
|
75
|
+
font-weight: bold;
|
|
76
|
+
border-bottom: $hy-border-line;
|
|
77
|
+
border-right: $hy-border-line;
|
|
78
|
+
|
|
79
|
+
&:last-child {
|
|
80
|
+
border-right: none;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/* 表头文本 */
|
|
85
|
+
@include e(header__th--text) {
|
|
86
|
+
overflow: hidden;
|
|
87
|
+
text-overflow: ellipsis;
|
|
88
|
+
white-space: nowrap;
|
|
89
|
+
display: block;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/* 表头排序 */
|
|
93
|
+
@include e(header__th--sort) {
|
|
94
|
+
@include flex(column);
|
|
95
|
+
margin-left: 8rpx;
|
|
96
|
+
|
|
97
|
+
.hy-icon {
|
|
98
|
+
color: $text-color;
|
|
99
|
+
opacity: 0.3;
|
|
100
|
+
margin-bottom: 2rpx;
|
|
101
|
+
|
|
102
|
+
&:last-child {
|
|
103
|
+
margin-bottom: 0;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
&.is-active {
|
|
107
|
+
color: $hy-primary;
|
|
108
|
+
opacity: 1;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/* 内容区域 */
|
|
114
|
+
@include e(body) {
|
|
115
|
+
flex: 1;
|
|
116
|
+
overflow-y: auto;
|
|
117
|
+
position: relative;
|
|
118
|
+
z-index: 1;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/* 内容包装器 */
|
|
122
|
+
@include e(body__wrapper) {
|
|
123
|
+
display: flex;
|
|
124
|
+
width: 100%;
|
|
125
|
+
min-height: 100%;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/* 左固定内容 */
|
|
129
|
+
@include e(body--left) {
|
|
130
|
+
position: absolute;
|
|
131
|
+
left: 0;
|
|
132
|
+
top: 0;
|
|
133
|
+
display: flex;
|
|
134
|
+
flex-direction: column;
|
|
135
|
+
background-color: $hy-background--container;
|
|
136
|
+
z-index: 11;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/* 中间内容 */
|
|
140
|
+
@include e(body--center) {
|
|
141
|
+
display: flex;
|
|
142
|
+
flex-direction: column;
|
|
143
|
+
flex: 1;
|
|
144
|
+
overflow-x: hidden;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/* 右固定内容 */
|
|
148
|
+
@include e(body--right) {
|
|
149
|
+
position: absolute;
|
|
150
|
+
right: 0;
|
|
151
|
+
top: 0;
|
|
152
|
+
display: flex;
|
|
153
|
+
flex-direction: column;
|
|
154
|
+
background-color: $hy-background--container;
|
|
155
|
+
z-index: 11;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/* 行 */
|
|
159
|
+
@include e(body__tr) {
|
|
160
|
+
@include flex(row);
|
|
161
|
+
box-sizing: border-box;
|
|
162
|
+
width: 100%;
|
|
163
|
+
|
|
164
|
+
&:nth-child(even) {
|
|
165
|
+
background-color: $stripe-bg;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/* 单元格 */
|
|
170
|
+
@include e(body__td) {
|
|
171
|
+
@include flex(center);
|
|
172
|
+
padding: 0 20rpx;
|
|
173
|
+
height: 88rpx;
|
|
174
|
+
box-sizing: border-box;
|
|
175
|
+
font-size: 28rpx;
|
|
176
|
+
color: $text-color;
|
|
177
|
+
border-bottom: $hy-border-line;
|
|
178
|
+
border-right: $hy-border-line;
|
|
179
|
+
|
|
180
|
+
&:last-child {
|
|
181
|
+
border-right: none;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/* 省略号 */
|
|
186
|
+
@include e(body__td--ellipsis) {
|
|
187
|
+
overflow: hidden;
|
|
188
|
+
text-overflow: ellipsis;
|
|
189
|
+
white-space: nowrap;
|
|
190
|
+
display: block;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/* 加载状态 */
|
|
194
|
+
@include e(body--loading) {
|
|
195
|
+
min-height: 400rpx;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { PropType } from 'vue'
|
|
2
|
+
import type { ITableColumn } from './typing'
|
|
3
|
+
|
|
4
|
+
const tableProps = {
|
|
5
|
+
/** 数据源 */
|
|
6
|
+
data: {
|
|
7
|
+
type: Array,
|
|
8
|
+
default: () => []
|
|
9
|
+
},
|
|
10
|
+
/** 列配置 */
|
|
11
|
+
columns: {
|
|
12
|
+
type: Array as PropType<ITableColumn[]>,
|
|
13
|
+
default: () => []
|
|
14
|
+
},
|
|
15
|
+
/** 表格高度,如 '500rpx' */
|
|
16
|
+
height: {
|
|
17
|
+
type: [String, Number],
|
|
18
|
+
default: 'auto'
|
|
19
|
+
},
|
|
20
|
+
/** 是否斑马纹 */
|
|
21
|
+
stripe: {
|
|
22
|
+
type: Boolean,
|
|
23
|
+
default: false
|
|
24
|
+
},
|
|
25
|
+
/** 是否带有纵向边框 */
|
|
26
|
+
border: {
|
|
27
|
+
type: Boolean,
|
|
28
|
+
default: true
|
|
29
|
+
},
|
|
30
|
+
/** 加载状态 */
|
|
31
|
+
loading: {
|
|
32
|
+
type: Boolean,
|
|
33
|
+
default: false
|
|
34
|
+
},
|
|
35
|
+
/** 空数据提示 */
|
|
36
|
+
emptyText: {
|
|
37
|
+
type: String,
|
|
38
|
+
default: '暂无数据'
|
|
39
|
+
},
|
|
40
|
+
/** 行数据的唯一键名 */
|
|
41
|
+
rowKey: {
|
|
42
|
+
type: String,
|
|
43
|
+
default: 'id'
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default tableProps
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface ITableColumn {
|
|
2
|
+
/** 列标题 */
|
|
3
|
+
title: string
|
|
4
|
+
/** 对应数据字段名 */
|
|
5
|
+
key: string
|
|
6
|
+
/** 列宽 (数字默认 px) */
|
|
7
|
+
width?: number | string
|
|
8
|
+
/** 对齐方式 */
|
|
9
|
+
align?: HyApp.RowCenterType
|
|
10
|
+
/** 是否开启排序 */
|
|
11
|
+
sortable?: boolean
|
|
12
|
+
/** 是否固定 ('left' | 'right' | false) */
|
|
13
|
+
fixed?: 'left' | 'right' | false
|
|
14
|
+
/** 是否开启文本超长省略 */
|
|
15
|
+
ellipsis?: boolean
|
|
16
|
+
/** 开启省略后,是否开启点击显示完整内容(Tooltip) */
|
|
17
|
+
tooltip?: boolean
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type SortType = 'asc' | 'desc' | 'normal'
|
|
21
|
+
|
|
22
|
+
interface ISortParams {
|
|
23
|
+
key: string
|
|
24
|
+
type: SortType
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface ITableEmits {
|
|
28
|
+
/** 当某一行被点击时会触发该事件 */
|
|
29
|
+
(e: 'row-click', row: any, index: number): void
|
|
30
|
+
/** 单元格点击触发该事件 */
|
|
31
|
+
(e: 'cell-click', row: any, col: ITableColumn): void
|
|
32
|
+
/** 触发本地排序或远程排序事件 */
|
|
33
|
+
(e: 'sort-change', params: ISortParams): void
|
|
34
|
+
}
|
|
@@ -111,7 +111,7 @@ watch(
|
|
|
111
111
|
// 组件的类名
|
|
112
112
|
const textareaClass = computed(() => {
|
|
113
113
|
let classes: string[] = []
|
|
114
|
-
props.border === 'surround' && (classes = classes.concat(['hy-
|
|
114
|
+
props.border === 'surround' && (classes = classes.concat(['hy-textarea__border', 'hy-textarea__radius']))
|
|
115
115
|
props.border === 'bottom' &&
|
|
116
116
|
(classes = classes.concat(['hy-border__bottom', 'hy-textarea__no-radius']))
|
|
117
117
|
props.disabled && classes.push('hy-textarea__disabled')
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
@use "../../libs/css/theme" as *;
|
|
2
|
-
@use "../../libs/css/mixin
|
|
2
|
+
@use "../../libs/css/mixin" as *;
|
|
3
3
|
|
|
4
4
|
@include b(textarea) {
|
|
5
5
|
border-radius: $hy-border-radius-sm;
|
|
@@ -7,6 +7,11 @@
|
|
|
7
7
|
@include flex;
|
|
8
8
|
flex: 1;
|
|
9
9
|
padding: $hy-border-margin-padding-sm;
|
|
10
|
+
|
|
11
|
+
@include e(border) {
|
|
12
|
+
/* TODO: 先这样写,因为在某些pda中写$hy-border-line,边框不显示,后续排除问题 */
|
|
13
|
+
border: 1px solid #e8e8e8;
|
|
14
|
+
}
|
|
10
15
|
|
|
11
16
|
@include e(radius) {
|
|
12
17
|
border-radius: $hy-border-radius-sm;
|