sadais-piui 1.2.7-beta15 → 1.2.7-beta151
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/.prettierrc +8 -0
- package/components/pi-action-sheet/index.vue +260 -247
- package/components/pi-badge/index.vue +11 -1
- package/components/pi-bottom-bar/index.vue +1 -1
- package/components/pi-calendar/index.vue +207 -182
- package/components/pi-calendar-input/index.vue +61 -30
- package/components/pi-calendar-panel/components/calendar-days/index.vue +91 -52
- package/components/pi-calendar-panel/index.vue +28 -12
- package/components/pi-canvas/index.vue +8 -1
- package/components/pi-cascader/index.vue +601 -0
- package/components/pi-checkbox/index.vue +8 -4
- package/components/pi-checkbox-group/index.vue +12 -11
- package/components/pi-circle-progress/index.vue +53 -16
- package/components/pi-code-input/index.vue +11 -3
- package/components/pi-collapse/index.vue +16 -6
- package/components/pi-collapse-item/index.vue +35 -22
- package/components/pi-date-picker/index.vue +512 -391
- package/components/pi-date-picker-input/index.vue +61 -30
- package/components/pi-dropdown/components/dropdown-tab.vue +33 -23
- package/components/pi-dropdown/index.vue +34 -19
- package/components/pi-dropdown-item/index.vue +70 -58
- package/components/pi-form-item/index.vue +98 -20
- package/components/pi-grid/index.vue +1 -1
- package/components/pi-grid-item/index.vue +4 -4
- package/components/pi-img/index.vue +275 -267
- package/components/pi-img-cropper/index.vue +6 -3
- package/components/pi-input/index.vue +97 -36
- package/components/pi-list-item/index.vue +1 -1
- package/components/pi-marquee/index.vue +322 -310
- package/components/pi-marquee-pure-css/index.vue +267 -0
- package/components/pi-mask/index.vue +3 -1
- package/components/pi-modal/index.vue +311 -303
- package/components/pi-pagination/index.vue +13 -0
- package/components/pi-picker/index.vue +332 -317
- package/components/pi-popup/index.vue +4 -1
- package/components/pi-popup-select/index.vue +13 -4
- package/components/pi-radio/index.vue +12 -11
- package/components/pi-radio-group/index.vue +25 -5
- package/components/pi-regions-select/index.vue +6 -1
- package/components/pi-regions-select-input/index.vue +69 -31
- package/components/pi-search/index.vue +37 -2
- package/components/pi-section/index.vue +1 -1
- package/components/pi-select/index.vue +237 -22
- package/components/pi-select-input/index.vue +106 -41
- package/components/pi-stepper/index.vue +135 -121
- package/components/pi-steps/index.vue +115 -36
- package/components/pi-swiper/index.vue +22 -7
- package/components/pi-switch/index.vue +5 -1
- package/components/pi-table/index.vue +351 -0
- package/components/pi-tabs/index.vue +46 -10
- package/components/pi-upload-img/index.vue +895 -44
- package/components/pi-webview/index.vue +95 -82
- package/config/actionSheet.js +0 -1
- package/config/calendarInput.js +2 -1
- package/config/calendarPanel.js +2 -1
- package/config/cascader.js +22 -0
- package/config/circleProgress.js +12 -4
- package/config/codeInput.js +2 -1
- package/config/datePicker.js +29 -24
- package/config/datePickerInput.js +2 -1
- package/config/dropdown.js +3 -1
- package/config/input.js +5 -3
- package/config/marqueePureCss.js +18 -0
- package/config/regionsSelectInput.js +2 -1
- package/config/select.js +13 -1
- package/config/selectInput.js +2 -1
- package/config/steps.js +1 -1
- package/config/table.js +9 -0
- package/config/uploadImg.js +33 -11
- package/mixin/emitter.js +8 -1
- package/mixin/value-sync.js +5 -0
- package/package.json +5 -2
- package/scss/common.scss +11 -14
- package/scss/icon/icon.scss +2 -1
- package/scss/mixin.scss +5 -5
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<view
|
|
2
|
+
<view
|
|
3
|
+
class="pi-steps pi-of-hidden"
|
|
4
|
+
:style="[customStyle, { flexDirection: direction }]"
|
|
5
|
+
:class="customClass"
|
|
6
|
+
>
|
|
3
7
|
<view
|
|
4
8
|
v-for="(item, index) in getItems"
|
|
5
9
|
:key="index"
|
|
@@ -8,42 +12,62 @@
|
|
|
8
12
|
:class="[itemClass, item.mode, direction, { active: index < val }]"
|
|
9
13
|
>
|
|
10
14
|
<view class="step-icon pi-flex-row-center" :style="[item.style]">
|
|
11
|
-
<
|
|
12
|
-
<
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
<
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
15
|
+
<view class="step-icon-inner">
|
|
16
|
+
<template v-if="item.mode === 'dot'">
|
|
17
|
+
<view class="item-dot pi-radius-round" :style="[item.dotStyle]" />
|
|
18
|
+
</template>
|
|
19
|
+
<!-- 数字-->
|
|
20
|
+
<template v-if="item.mode === 'number'">
|
|
21
|
+
<text v-if="index >= val">
|
|
22
|
+
{{ index + 1 }}
|
|
23
|
+
</text>
|
|
24
|
+
<pi-icon v-else name="check" color="#ffffff" />
|
|
25
|
+
</template>
|
|
26
|
+
<!-- 图标 -->
|
|
27
|
+
<pi-icon
|
|
28
|
+
v-if="item.mode === 'icon'"
|
|
29
|
+
:custom-style="item.icon.customStyle"
|
|
30
|
+
:custom-class="item.icon.customClass"
|
|
31
|
+
:name="item.icon.name"
|
|
32
|
+
:dot="item.icon.dot"
|
|
33
|
+
:dot-radius="item.icon.dotRadius"
|
|
34
|
+
:badge="item.icon.badge"
|
|
35
|
+
:color="item.icon.color"
|
|
36
|
+
:size="item.icon.size"
|
|
37
|
+
:class-prefix="item.icon.classPrefix"
|
|
38
|
+
/>
|
|
39
|
+
</view>
|
|
34
40
|
</view>
|
|
35
41
|
|
|
36
42
|
<!-- 文字 -->
|
|
37
43
|
<view :class="['pi-steps-item-text']" :style="{ color: item.style.fontColor }">
|
|
38
|
-
<slot
|
|
44
|
+
<slot
|
|
45
|
+
name="item"
|
|
46
|
+
:item="item"
|
|
47
|
+
:index="index"
|
|
48
|
+
:length="getItemsLength"
|
|
49
|
+
:active="index < val"
|
|
50
|
+
>
|
|
39
51
|
<view>{{ item.name }}</view>
|
|
40
|
-
<text class="pi-fz-20" style="word-break:break-all">
|
|
52
|
+
<text v-if="item.desc" class="pi-fz-20 pi-mg-top-10" style="word-break:break-all">
|
|
53
|
+
{{ item.desc }}
|
|
54
|
+
</text>
|
|
41
55
|
</slot>
|
|
42
56
|
</view>
|
|
43
57
|
|
|
44
58
|
<!-- 中线 -->
|
|
45
|
-
<view
|
|
46
|
-
|
|
59
|
+
<view
|
|
60
|
+
v-if="items.length === 1 || index < items.length - 1"
|
|
61
|
+
class="pi-steps-item-line"
|
|
62
|
+
:style="[lineStyle, item.lineStyle]"
|
|
63
|
+
>
|
|
64
|
+
<pi-line
|
|
65
|
+
:direction="direction"
|
|
66
|
+
length="100%"
|
|
67
|
+
:hair-line="false"
|
|
68
|
+
:color="item.icon.color"
|
|
69
|
+
border-style="dashed"
|
|
70
|
+
/>
|
|
47
71
|
</view>
|
|
48
72
|
</view>
|
|
49
73
|
</view>
|
|
@@ -138,7 +162,10 @@ export default {
|
|
|
138
162
|
}
|
|
139
163
|
},
|
|
140
164
|
data() {
|
|
141
|
-
return {
|
|
165
|
+
return {
|
|
166
|
+
iconsRect: [],
|
|
167
|
+
itemsRect: []
|
|
168
|
+
}
|
|
142
169
|
},
|
|
143
170
|
computed: {
|
|
144
171
|
getDotMaxSize() {
|
|
@@ -150,7 +177,7 @@ export default {
|
|
|
150
177
|
},
|
|
151
178
|
lineStyle() {
|
|
152
179
|
const style = {}
|
|
153
|
-
const size = this.getDotMaxSize / 2 + 'rpx'
|
|
180
|
+
const size = this.getDotMaxSize / 2 - 2 + 'rpx'
|
|
154
181
|
this.direction === 'column' ? (style.left = size) : (style.top = size)
|
|
155
182
|
return style
|
|
156
183
|
},
|
|
@@ -191,16 +218,18 @@ export default {
|
|
|
191
218
|
} else {
|
|
192
219
|
style.backgroundColor = this.getCurrentColor
|
|
193
220
|
}
|
|
221
|
+
item.icon.color = this.getCurrentColor
|
|
194
222
|
} else if (index < this.val && this.activeColor) {
|
|
195
223
|
// 已激活步骤
|
|
196
224
|
style.fontColor = this.activeColor
|
|
197
225
|
if (item.mode === 'icon') {
|
|
198
226
|
style.color = this.activeColor
|
|
199
227
|
} else if (item.mode === 'dot') {
|
|
200
|
-
item.dotStyle.backgroundColor = this.
|
|
228
|
+
item.dotStyle.backgroundColor = this.activeColor
|
|
201
229
|
} else {
|
|
202
230
|
style.backgroundColor = this.activeColor
|
|
203
231
|
}
|
|
232
|
+
item.icon.color = this.activeColor
|
|
204
233
|
} else if (index > this.val) {
|
|
205
234
|
// 未激活步骤
|
|
206
235
|
style.fontColor = this.color
|
|
@@ -213,14 +242,64 @@ export default {
|
|
|
213
242
|
if (item.mode === 'number') {
|
|
214
243
|
style.backgroundColor = this.color
|
|
215
244
|
}
|
|
245
|
+
item.icon.color = this.color
|
|
216
246
|
}
|
|
217
247
|
item.style = style
|
|
248
|
+
item.lineStyle = {}
|
|
249
|
+
if (
|
|
250
|
+
this.direction === 'column' &&
|
|
251
|
+
this.itemsRect.length &&
|
|
252
|
+
this.iconsRect.length &&
|
|
253
|
+
(this.itemsRect.length === 1 || index < this.itemsRect.length - 1) &&
|
|
254
|
+
(this.iconsRect.length === 1 || index < this.iconsRect.length - 1)
|
|
255
|
+
) {
|
|
256
|
+
// 动态计算线的位置和高度
|
|
257
|
+
item.lineStyle.top = `${this.iconsRect[index].top -
|
|
258
|
+
this.itemsRect[index].top +
|
|
259
|
+
this.iconsRect[index].height +
|
|
260
|
+
2}px`
|
|
261
|
+
const nextIconsRectHeight = this.iconsRect[index + 1]
|
|
262
|
+
? this.iconsRect[index + 1].height
|
|
263
|
+
: 0
|
|
264
|
+
item.lineStyle.height = `${this.itemsRect[index].height - nextIconsRectHeight}px`
|
|
265
|
+
}
|
|
218
266
|
return item
|
|
219
267
|
})
|
|
268
|
+
},
|
|
269
|
+
getItemsLength() {
|
|
270
|
+
return this.items.length
|
|
220
271
|
}
|
|
221
272
|
},
|
|
222
|
-
watch: {
|
|
223
|
-
|
|
273
|
+
watch: {
|
|
274
|
+
items: {
|
|
275
|
+
deep: true,
|
|
276
|
+
immediate: true,
|
|
277
|
+
handler(value) {
|
|
278
|
+
this.init()
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
mounted() {
|
|
283
|
+
// 防止在某些组件slot里面还没渲染,导致获取不到正确的宽高
|
|
284
|
+
setTimeout(() => {
|
|
285
|
+
this.init()
|
|
286
|
+
}, 200)
|
|
287
|
+
},
|
|
288
|
+
methods: {
|
|
289
|
+
async init() {
|
|
290
|
+
console.log(TAG, '初始化计算步骤条')
|
|
291
|
+
if (!this.items?.length) return
|
|
292
|
+
this.iconsRect = await this.$pi.common.queryRect(this, '.step-icon-inner', true)
|
|
293
|
+
this.itemsRect = await this.$pi.common.queryRect(this, '.pi-steps-item', true)
|
|
294
|
+
if (this.iconsRect.length !== this.itemsRect.length) {
|
|
295
|
+
setTimeout(() => {
|
|
296
|
+
this.init()
|
|
297
|
+
}, 200)
|
|
298
|
+
} else {
|
|
299
|
+
console.log(TAG, '计算.pi-steps布局', this.itemsRect, this.iconsRect)
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
224
303
|
}
|
|
225
304
|
</script>
|
|
226
305
|
|
|
@@ -256,7 +335,7 @@ export default {
|
|
|
256
335
|
display: flex;
|
|
257
336
|
flex-direction: row;
|
|
258
337
|
justify-content: flex-start;
|
|
259
|
-
align-items:
|
|
338
|
+
align-items: baseline;
|
|
260
339
|
min-height: 120rpx;
|
|
261
340
|
.pi-steps-item-text {
|
|
262
341
|
width: 95%;
|
|
@@ -266,15 +345,15 @@ export default {
|
|
|
266
345
|
}
|
|
267
346
|
.pi-steps-item-line {
|
|
268
347
|
position: absolute;
|
|
269
|
-
top: 75%;
|
|
270
348
|
z-index: 0;
|
|
271
|
-
height: 50%;
|
|
272
349
|
}
|
|
273
350
|
}
|
|
274
351
|
.item-dot,
|
|
275
352
|
.step-icon {
|
|
276
353
|
border-radius: 50%;
|
|
277
354
|
overflow: hidden;
|
|
355
|
+
position: relative;
|
|
356
|
+
z-index: 2;
|
|
278
357
|
}
|
|
279
358
|
|
|
280
359
|
&.active {
|
|
@@ -13,16 +13,21 @@
|
|
|
13
13
|
:previous-margin="effect3d ? effect3dPreviousMargin + 'rpx' : '0'"
|
|
14
14
|
:next-margin="effect3d ? effect3dPreviousMargin + 'rpx' : '0'"
|
|
15
15
|
:style="[swiperStyle]"
|
|
16
|
-
@
|
|
16
|
+
@animationfinish="handleSwiperChange"
|
|
17
17
|
>
|
|
18
|
-
<swiper-item
|
|
18
|
+
<swiper-item
|
|
19
|
+
v-for="(img, index) in imgs"
|
|
20
|
+
:key="index"
|
|
21
|
+
class="swiper-item"
|
|
22
|
+
>
|
|
19
23
|
<view
|
|
20
24
|
class="swiper-image-wrap"
|
|
21
25
|
:class="[val != index ? 'list-scale' : '']"
|
|
22
26
|
:style="[
|
|
23
27
|
{
|
|
24
28
|
borderRadius: `${borderRadius}rpx`,
|
|
25
|
-
transform:
|
|
29
|
+
transform:
|
|
30
|
+
effect3d && val !== index ? 'scaleY(0.9)' : 'scaleY(1)',
|
|
26
31
|
padding: effect3d && val !== index ? '0 20rpx' : 0
|
|
27
32
|
}
|
|
28
33
|
]"
|
|
@@ -40,10 +45,16 @@
|
|
|
40
45
|
</view>
|
|
41
46
|
</swiper-item>
|
|
42
47
|
</swiper>
|
|
43
|
-
<view
|
|
48
|
+
<view
|
|
49
|
+
v-if="indicatorType !== 'none'"
|
|
50
|
+
class="swiper-indicator"
|
|
51
|
+
:style="[swiperIndicatorStyle]"
|
|
52
|
+
>
|
|
44
53
|
<!-- 数字形式展示 -->
|
|
45
54
|
<template v-if="indicatorType === 'number'">
|
|
46
|
-
<view class="indicator-item number"
|
|
55
|
+
<view class="indicator-item number"
|
|
56
|
+
>{{ val + 1 }}/{{ imgs.length }}</view
|
|
57
|
+
>
|
|
47
58
|
</template>
|
|
48
59
|
<!-- 点,矩形 -->
|
|
49
60
|
<template v-else>
|
|
@@ -257,8 +268,12 @@ export default {
|
|
|
257
268
|
methods: {
|
|
258
269
|
handleSwiperChange(e) {
|
|
259
270
|
const current = e.detail.current
|
|
260
|
-
|
|
261
|
-
|
|
271
|
+
const source = e.detail.source
|
|
272
|
+
if (source === 'autoplay' || source === 'touch') {
|
|
273
|
+
// 只有在自动轮播和用户主动触发才去改变current值
|
|
274
|
+
this.val = current
|
|
275
|
+
this.handleEmitChange()
|
|
276
|
+
}
|
|
262
277
|
},
|
|
263
278
|
handleSwiperClick(index) {
|
|
264
279
|
// 点击时触发 | index, 当前页的索引
|
|
@@ -132,6 +132,10 @@ export default {
|
|
|
132
132
|
}
|
|
133
133
|
},
|
|
134
134
|
computed: {
|
|
135
|
+
getDisabled() {
|
|
136
|
+
const parent = this.$pi.parent(this, 'PiFormItem')
|
|
137
|
+
return this.disabled || (parent && parent.getDisabled)
|
|
138
|
+
},
|
|
135
139
|
getSize() {
|
|
136
140
|
return this.$pi.common.addUnit(this.size)
|
|
137
141
|
},
|
|
@@ -177,7 +181,7 @@ export default {
|
|
|
177
181
|
methods: {
|
|
178
182
|
handleSwitchToggle() {
|
|
179
183
|
// 禁用开关
|
|
180
|
-
if (this.
|
|
184
|
+
if (this.getDisabled) return
|
|
181
185
|
this.val = this.val === this.activeValue ? this.inactiveValue : this.activeValue
|
|
182
186
|
if (this.vibrateShort) uni.vibrateShort()
|
|
183
187
|
this.handleEmitChange()
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="table-wrap" :class="{ bounce }">
|
|
3
|
+
<view class="table">
|
|
4
|
+
<view class="row">
|
|
5
|
+
<view
|
|
6
|
+
v-for="(col, idx) in cols"
|
|
7
|
+
:key="idx"
|
|
8
|
+
class="head"
|
|
9
|
+
:class="{ fixed: !!col.fixed }"
|
|
10
|
+
:style="[
|
|
11
|
+
col.style,
|
|
12
|
+
cellPaddingStyle,
|
|
13
|
+
headStyle,
|
|
14
|
+
leftMap[idx],
|
|
15
|
+
rightMap[idx],
|
|
16
|
+
]"
|
|
17
|
+
>
|
|
18
|
+
{{ col.name }}
|
|
19
|
+
</view>
|
|
20
|
+
</view>
|
|
21
|
+
<view class="table-body" :data-empty-text="emptyText">
|
|
22
|
+
<block v-if="data.length > 0">
|
|
23
|
+
<view
|
|
24
|
+
v-for="(row, idx) in data"
|
|
25
|
+
:key="idx"
|
|
26
|
+
class="row"
|
|
27
|
+
:class="{ odd: stripe && idx % 2 > 0 }"
|
|
28
|
+
>
|
|
29
|
+
<view
|
|
30
|
+
v-for="(col, colIdx) in cols"
|
|
31
|
+
:key="colIdx"
|
|
32
|
+
class="cell"
|
|
33
|
+
:class="{ fixed: !!col.fixed }"
|
|
34
|
+
:style="[cellStyle, leftMap[colIdx], rightMap[colIdx]]"
|
|
35
|
+
>
|
|
36
|
+
<view
|
|
37
|
+
class="cell-content-wrap-ph"
|
|
38
|
+
:style="[
|
|
39
|
+
{
|
|
40
|
+
width: col.style.width,
|
|
41
|
+
whiteSpace: col.whiteSpace || 'normal',
|
|
42
|
+
},
|
|
43
|
+
]"
|
|
44
|
+
>
|
|
45
|
+
<image
|
|
46
|
+
v-if="col.slot && col.slot.type === 'img'"
|
|
47
|
+
:src="row[col.prop]"
|
|
48
|
+
:style="[col.slot.style]"
|
|
49
|
+
/>
|
|
50
|
+
<image
|
|
51
|
+
v-else-if="
|
|
52
|
+
col.slot &&
|
|
53
|
+
col.slot.type === 'rank' &&
|
|
54
|
+
idx < col.slot.condition
|
|
55
|
+
"
|
|
56
|
+
:src="row[col.prop]"
|
|
57
|
+
:style="[col.slot.style]"
|
|
58
|
+
/>
|
|
59
|
+
<view
|
|
60
|
+
v-else-if="col.slot && col.slot.type === 'link'"
|
|
61
|
+
class="pi-align-center"
|
|
62
|
+
>
|
|
63
|
+
<text
|
|
64
|
+
v-for="(link, linkIdx) in col.slot.links"
|
|
65
|
+
:key="linkIdx"
|
|
66
|
+
class="link"
|
|
67
|
+
:style="[link.style]"
|
|
68
|
+
>{{ link.name }}</text
|
|
69
|
+
>
|
|
70
|
+
</view>
|
|
71
|
+
<block v-else>{{ row[col.prop] }}</block>
|
|
72
|
+
</view>
|
|
73
|
+
<view class="cell-content-wrap" :style="[cellContentWrapStyle]">
|
|
74
|
+
<image
|
|
75
|
+
v-if="col.slot && col.slot.type === 'img'"
|
|
76
|
+
:src="row[col.prop]"
|
|
77
|
+
:style="[col.slot.style]"
|
|
78
|
+
/>
|
|
79
|
+
<image
|
|
80
|
+
v-else-if="
|
|
81
|
+
col.slot &&
|
|
82
|
+
col.slot.type === 'rank' &&
|
|
83
|
+
idx < col.slot.condition
|
|
84
|
+
"
|
|
85
|
+
:src="row[col.prop]"
|
|
86
|
+
:style="[col.slot.style]"
|
|
87
|
+
/>
|
|
88
|
+
<view
|
|
89
|
+
v-else-if="col.slot && col.slot.type === 'link'"
|
|
90
|
+
class="pi-align-center"
|
|
91
|
+
>
|
|
92
|
+
<text
|
|
93
|
+
v-for="(link, linkIdx) in col.slot.links"
|
|
94
|
+
:key="linkIdx"
|
|
95
|
+
class="link"
|
|
96
|
+
:style="[link.style]"
|
|
97
|
+
@click="
|
|
98
|
+
handleClickLink({ row, link, linkIdx, rowIdx: idx })
|
|
99
|
+
"
|
|
100
|
+
>{{ link.name }}</text
|
|
101
|
+
>
|
|
102
|
+
</view>
|
|
103
|
+
<block v-else>{{ row[col.prop] }}</block>
|
|
104
|
+
</view>
|
|
105
|
+
</view>
|
|
106
|
+
</view>
|
|
107
|
+
</block>
|
|
108
|
+
</view>
|
|
109
|
+
</view>
|
|
110
|
+
</view>
|
|
111
|
+
</template>
|
|
112
|
+
|
|
113
|
+
<script>
|
|
114
|
+
import { getConfig } from "../../config";
|
|
115
|
+
const { table: tableConfig } = getConfig();
|
|
116
|
+
export default {
|
|
117
|
+
name: "PiTable",
|
|
118
|
+
props: {
|
|
119
|
+
// 是否开启滚动反弹效果
|
|
120
|
+
bounce: {
|
|
121
|
+
// `Boolean`
|
|
122
|
+
type: Boolean,
|
|
123
|
+
// `false`
|
|
124
|
+
default: tableConfig.bounce,
|
|
125
|
+
},
|
|
126
|
+
// 列配置项
|
|
127
|
+
columns: {
|
|
128
|
+
type: Array,
|
|
129
|
+
// `[]`
|
|
130
|
+
default: () => tableConfig.columns,
|
|
131
|
+
},
|
|
132
|
+
// 表格数据源
|
|
133
|
+
data: {
|
|
134
|
+
type: Array,
|
|
135
|
+
// `[]`
|
|
136
|
+
default: () => tableConfig.data,
|
|
137
|
+
},
|
|
138
|
+
// 无数据提示语
|
|
139
|
+
emptyText: {
|
|
140
|
+
// `'暂无数据'`
|
|
141
|
+
default: tableConfig.emptyText,
|
|
142
|
+
},
|
|
143
|
+
// 是否条纹显示
|
|
144
|
+
stripe: {
|
|
145
|
+
// `true`
|
|
146
|
+
default: tableConfig.stripe,
|
|
147
|
+
},
|
|
148
|
+
// 头部样式
|
|
149
|
+
headStyle: {
|
|
150
|
+
type: Object,
|
|
151
|
+
// `{}`
|
|
152
|
+
default: () => tableConfig.headStyle,
|
|
153
|
+
},
|
|
154
|
+
// 单元格样式
|
|
155
|
+
cellStyle: {
|
|
156
|
+
type: Object,
|
|
157
|
+
// `{}`
|
|
158
|
+
default: () => tableConfig.cellStyle,
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
data() {
|
|
162
|
+
return {
|
|
163
|
+
cellPadding: 16,
|
|
164
|
+
leftMap: {},
|
|
165
|
+
rightMap: {},
|
|
166
|
+
};
|
|
167
|
+
},
|
|
168
|
+
computed: {
|
|
169
|
+
cellPaddingStyle() {
|
|
170
|
+
return {
|
|
171
|
+
padding: `${this.cellPadding}rpx`,
|
|
172
|
+
};
|
|
173
|
+
},
|
|
174
|
+
cellContentWrapStyle() {
|
|
175
|
+
return {
|
|
176
|
+
padding: `${this.cellPadding}rpx`,
|
|
177
|
+
};
|
|
178
|
+
},
|
|
179
|
+
cols() {
|
|
180
|
+
const list = (this.columns || []).map((i) => {
|
|
181
|
+
const t = { ...i };
|
|
182
|
+
const w = (t.width && `${t.width}rpx`) || "auto";
|
|
183
|
+
t.style = { width: w };
|
|
184
|
+
return t;
|
|
185
|
+
});
|
|
186
|
+
return list;
|
|
187
|
+
},
|
|
188
|
+
reCompute() {
|
|
189
|
+
return this.cols.length + this.data.length;
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
watch: {
|
|
193
|
+
reCompute: {
|
|
194
|
+
immediate: true,
|
|
195
|
+
handler() {
|
|
196
|
+
this.$nextTick(() => {
|
|
197
|
+
this.computeColumnWidth();
|
|
198
|
+
});
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
methods: {
|
|
203
|
+
computeColumnWidth() {
|
|
204
|
+
const query = uni.createSelectorQuery().in(this);
|
|
205
|
+
query
|
|
206
|
+
.selectAll(".head")
|
|
207
|
+
.boundingClientRect()
|
|
208
|
+
.exec((res) => {
|
|
209
|
+
const list = res[0] || [];
|
|
210
|
+
let left = 0;
|
|
211
|
+
const isLeft = (i) => i.fixed === true || i.fixed === "left";
|
|
212
|
+
const isRight = (i) => i.fixed === "right";
|
|
213
|
+
const leftMap = {};
|
|
214
|
+
for (let i = 0; i < list.length; i++) {
|
|
215
|
+
const col = this.cols[i];
|
|
216
|
+
leftMap[i] = { left: isLeft(col) ? `${left}px` : "auto" };
|
|
217
|
+
left += isLeft(col) ? list[i].width : 0;
|
|
218
|
+
}
|
|
219
|
+
const rightMap = {};
|
|
220
|
+
let right = 0;
|
|
221
|
+
for (let i = list.length - 1; i >= 0; i--) {
|
|
222
|
+
const col = this.cols[i];
|
|
223
|
+
rightMap[i] = { right: isRight(col) ? `${right}px` : "auto" };
|
|
224
|
+
right += isRight(col) ? list[i].width : 0;
|
|
225
|
+
}
|
|
226
|
+
this.leftMap = leftMap;
|
|
227
|
+
this.rightMap = rightMap;
|
|
228
|
+
});
|
|
229
|
+
},
|
|
230
|
+
handleClickLink(info) {
|
|
231
|
+
this.$emit("link", info);
|
|
232
|
+
},
|
|
233
|
+
},
|
|
234
|
+
};
|
|
235
|
+
</script>
|
|
236
|
+
|
|
237
|
+
<style lang="scss" scoped>
|
|
238
|
+
.table-wrap {
|
|
239
|
+
position: relative;
|
|
240
|
+
width: 100%;
|
|
241
|
+
overflow: auto hidden;
|
|
242
|
+
overscroll-behavior: none;
|
|
243
|
+
&.bounce {
|
|
244
|
+
overscroll-behavior: auto;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
.table {
|
|
248
|
+
display: table;
|
|
249
|
+
min-width: 100%;
|
|
250
|
+
background: #ffffff;
|
|
251
|
+
border: none;
|
|
252
|
+
box-sizing: border-box;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
$even-row-color: #f4f8fd;
|
|
256
|
+
.row {
|
|
257
|
+
display: table-row;
|
|
258
|
+
border: none;
|
|
259
|
+
background: #ffffff;
|
|
260
|
+
&.odd {
|
|
261
|
+
background: $even-row-color;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
.head {
|
|
265
|
+
display: table-cell;
|
|
266
|
+
padding: 16rpx;
|
|
267
|
+
background: $even-row-color;
|
|
268
|
+
white-space: nowrap;
|
|
269
|
+
text-align: center;
|
|
270
|
+
font-size: 28rpx;
|
|
271
|
+
color: #333333;
|
|
272
|
+
font-weight: bold;
|
|
273
|
+
border: none;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
$fixed-shadow: 0 0 40rpx rgba(11, 101, 209, 0.2);
|
|
277
|
+
.head.fixed {
|
|
278
|
+
position: sticky;
|
|
279
|
+
left: 0;
|
|
280
|
+
z-index: 1;
|
|
281
|
+
box-shadow: $fixed-shadow;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
.cell {
|
|
285
|
+
position: relative;
|
|
286
|
+
display: table-cell;
|
|
287
|
+
padding: 16rpx;
|
|
288
|
+
background: inherit;
|
|
289
|
+
overflow: hidden;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
.cell.fixed {
|
|
293
|
+
position: sticky;
|
|
294
|
+
left: 0;
|
|
295
|
+
z-index: 1;
|
|
296
|
+
box-shadow: $fixed-shadow;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
.cell-content-wrap-ph {
|
|
300
|
+
opacity: 0;
|
|
301
|
+
white-space: normal;
|
|
302
|
+
word-wrap: break-word;
|
|
303
|
+
overflow: hidden;
|
|
304
|
+
text-align: center;
|
|
305
|
+
font-size: 28rpx;
|
|
306
|
+
line-height: 1.5;
|
|
307
|
+
min-width: 80rpx;
|
|
308
|
+
}
|
|
309
|
+
.cell-content-wrap {
|
|
310
|
+
position: absolute;
|
|
311
|
+
top: 0;
|
|
312
|
+
left: 0;
|
|
313
|
+
width: 100%;
|
|
314
|
+
height: 100%;
|
|
315
|
+
display: flex;
|
|
316
|
+
align-items: center;
|
|
317
|
+
justify-content: center;
|
|
318
|
+
white-space: normal;
|
|
319
|
+
word-wrap: break-word;
|
|
320
|
+
overflow: hidden;
|
|
321
|
+
font-size: 28rpx;
|
|
322
|
+
color: #333333;
|
|
323
|
+
line-height: 1.5;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
.table-body {
|
|
327
|
+
position: relative;
|
|
328
|
+
display: table-row-group;
|
|
329
|
+
&:empty {
|
|
330
|
+
&::before {
|
|
331
|
+
display: table-row;
|
|
332
|
+
content: "";
|
|
333
|
+
height: 200rpx;
|
|
334
|
+
width: 100%;
|
|
335
|
+
}
|
|
336
|
+
&::after {
|
|
337
|
+
display: block;
|
|
338
|
+
text-align: center;
|
|
339
|
+
content: attr(data-empty-text);
|
|
340
|
+
font-size: 36rpx;
|
|
341
|
+
color: #888888;
|
|
342
|
+
position: absolute;
|
|
343
|
+
white-space: nowrap;
|
|
344
|
+
top: 50%;
|
|
345
|
+
left: 50%;
|
|
346
|
+
transform: translate(-50%, -50%);
|
|
347
|
+
margin-top: 20rpx;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
</style>
|