@tplc/wot 0.0.1
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/common/AbortablePromise.ts +36 -0
- package/components/common/abstracts/_config.scss +7 -0
- package/components/common/abstracts/_function.scss +76 -0
- package/components/common/abstracts/_mixin.scss +339 -0
- package/components/common/abstracts/variable.scss +1346 -0
- package/components/common/base64.ts +30 -0
- package/components/common/canvasHelper.ts +49 -0
- package/components/common/clickoutside.ts +34 -0
- package/components/common/dayjs.ts +157 -0
- package/components/common/event.ts +8 -0
- package/components/common/props.ts +51 -0
- package/components/common/util.ts +751 -0
- package/components/composables/useCell.ts +13 -0
- package/components/composables/useChildren.ts +122 -0
- package/components/composables/useCountDown.ts +138 -0
- package/components/composables/useLockScroll.ts +39 -0
- package/components/composables/useParent.ts +41 -0
- package/components/composables/usePopover.ts +193 -0
- package/components/composables/useQueue.ts +52 -0
- package/components/composables/useRaf.ts +37 -0
- package/components/composables/useTouch.ts +44 -0
- package/components/composables/useTranslate.ts +22 -0
- package/components/wd-action-sheet/index.scss +204 -0
- package/components/wd-action-sheet/types.ts +128 -0
- package/components/wd-action-sheet/wd-action-sheet.vue +174 -0
- package/components/wd-backtop/index.scss +25 -0
- package/components/wd-backtop/types.ts +37 -0
- package/components/wd-backtop/wd-backtop.vue +48 -0
- package/components/wd-badge/index.scss +59 -0
- package/components/wd-badge/types.ts +53 -0
- package/components/wd-badge/wd-badge.vue +69 -0
- package/components/wd-button/index.scss +340 -0
- package/components/wd-button/types.ts +112 -0
- package/components/wd-button/wd-button.vue +176 -0
- package/components/wd-calendar/index.scss +244 -0
- package/components/wd-calendar/types.ts +235 -0
- package/components/wd-calendar/wd-calendar.vue +456 -0
- package/components/wd-calendar-view/index.scss +9 -0
- package/components/wd-calendar-view/month/index.scss +151 -0
- package/components/wd-calendar-view/month/month.vue +391 -0
- package/components/wd-calendar-view/month/types.ts +19 -0
- package/components/wd-calendar-view/monthPanel/index.scss +89 -0
- package/components/wd-calendar-view/monthPanel/month-panel.vue +388 -0
- package/components/wd-calendar-view/monthPanel/types.ts +48 -0
- package/components/wd-calendar-view/types.ts +134 -0
- package/components/wd-calendar-view/utils.ts +451 -0
- package/components/wd-calendar-view/wd-calendar-view.vue +111 -0
- package/components/wd-calendar-view/year/index.scss +148 -0
- package/components/wd-calendar-view/year/types.ts +19 -0
- package/components/wd-calendar-view/year/year.vue +220 -0
- package/components/wd-calendar-view/yearPanel/index.scss +24 -0
- package/components/wd-calendar-view/yearPanel/types.ts +38 -0
- package/components/wd-calendar-view/yearPanel/year-panel.vue +140 -0
- package/components/wd-card/index.scss +70 -0
- package/components/wd-card/types.ts +30 -0
- package/components/wd-card/wd-card.vue +40 -0
- package/components/wd-cell/index.scss +189 -0
- package/components/wd-cell/types.ts +96 -0
- package/components/wd-cell/wd-cell.vue +135 -0
- package/components/wd-cell-group/index.scss +55 -0
- package/components/wd-cell-group/types.ts +41 -0
- package/components/wd-cell-group/wd-cell-group.vue +45 -0
- package/components/wd-checkbox/index.scss +285 -0
- package/components/wd-checkbox/types.ts +68 -0
- package/components/wd-checkbox/wd-checkbox.vue +185 -0
- package/components/wd-checkbox-group/index.scss +20 -0
- package/components/wd-checkbox-group/types.ts +59 -0
- package/components/wd-checkbox-group/wd-checkbox-group.vue +103 -0
- package/components/wd-circle/index.scss +18 -0
- package/components/wd-circle/types.ts +54 -0
- package/components/wd-circle/wd-circle.vue +318 -0
- package/components/wd-col/index.scss +19 -0
- package/components/wd-col/types.ts +15 -0
- package/components/wd-col/wd-col.vue +91 -0
- package/components/wd-col-picker/index.scss +241 -0
- package/components/wd-col-picker/types.ts +170 -0
- package/components/wd-col-picker/wd-col-picker.vue +550 -0
- package/components/wd-collapse/index.scss +55 -0
- package/components/wd-collapse/types.ts +63 -0
- package/components/wd-collapse/wd-collapse.vue +160 -0
- package/components/wd-collapse-item/index.scss +79 -0
- package/components/wd-collapse-item/types.ts +36 -0
- package/components/wd-collapse-item/wd-collapse-item.vue +182 -0
- package/components/wd-config-provider/types.ts +1023 -0
- package/components/wd-config-provider/wd-config-provider.vue +82 -0
- package/components/wd-count-down/index.scss +14 -0
- package/components/wd-count-down/types.ts +41 -0
- package/components/wd-count-down/utils.ts +52 -0
- package/components/wd-count-down/wd-count-down.vue +60 -0
- package/components/wd-count-to/index.scss +6 -0
- package/components/wd-count-to/types.ts +110 -0
- package/components/wd-count-to/wd-count-to.vue +134 -0
- package/components/wd-curtain/index.scss +80 -0
- package/components/wd-curtain/types.ts +45 -0
- package/components/wd-curtain/wd-curtain.vue +174 -0
- package/components/wd-datetime-picker/index.scss +243 -0
- package/components/wd-datetime-picker/types.ts +225 -0
- package/components/wd-datetime-picker/wd-datetime-picker.vue +827 -0
- package/components/wd-datetime-picker-view/index.scss +0 -0
- package/components/wd-datetime-picker-view/types.ts +137 -0
- package/components/wd-datetime-picker-view/wd-datetime-picker-view.vue +514 -0
- package/components/wd-divider/index.scss +32 -0
- package/components/wd-divider/types.ts +12 -0
- package/components/wd-divider/wd-divider.vue +29 -0
- package/components/wd-drop-menu/index.scss +89 -0
- package/components/wd-drop-menu/types.ts +38 -0
- package/components/wd-drop-menu/wd-drop-menu.vue +128 -0
- package/components/wd-drop-menu-item/index.scss +66 -0
- package/components/wd-drop-menu-item/types.ts +78 -0
- package/components/wd-drop-menu-item/wd-drop-menu-item.vue +230 -0
- package/components/wd-fab/index.scss +115 -0
- package/components/wd-fab/types.ts +61 -0
- package/components/wd-fab/wd-fab.vue +257 -0
- package/components/wd-form/index.scss +10 -0
- package/components/wd-form/types.ts +93 -0
- package/components/wd-form/wd-form.vue +185 -0
- package/components/wd-form-item/index.scss +17 -0
- package/components/wd-form-item/types.ts +22 -0
- package/components/wd-form-item/wd-form-item.vue +65 -0
- package/components/wd-gap/index.scss +9 -0
- package/components/wd-gap/types.ts +23 -0
- package/components/wd-gap/wd-gap.vue +39 -0
- package/components/wd-grid/index.scss +9 -0
- package/components/wd-grid/types.ts +54 -0
- package/components/wd-grid/wd-grid.vue +107 -0
- package/components/wd-grid-item/index.scss +137 -0
- package/components/wd-grid-item/types.ts +74 -0
- package/components/wd-grid-item/wd-grid-item.vue +181 -0
- package/components/wd-icon/index.scss +1222 -0
- package/components/wd-icon/types.ts +21 -0
- package/components/wd-icon/wd-icon.vue +53 -0
- package/components/wd-icon/wd-icons.ttf +0 -0
- package/components/wd-img/index.scss +19 -0
- package/components/wd-img/types.ts +53 -0
- package/components/wd-img/wd-img.vue +76 -0
- package/components/wd-img-cropper/index.scss +227 -0
- package/components/wd-img-cropper/types.ts +87 -0
- package/components/wd-img-cropper/wd-img-cropper.vue +659 -0
- package/components/wd-index-anchor/index.scss +34 -0
- package/components/wd-index-anchor/type.ts +9 -0
- package/components/wd-index-anchor/wd-index-anchor.vue +57 -0
- package/components/wd-index-bar/index.scss +39 -0
- package/components/wd-index-bar/type.ts +28 -0
- package/components/wd-index-bar/wd-index-bar.vue +158 -0
- package/components/wd-input/index.scss +326 -0
- package/components/wd-input/types.ts +182 -0
- package/components/wd-input/wd-input.vue +327 -0
- package/components/wd-input-number/index.scss +132 -0
- package/components/wd-input-number/types.ts +78 -0
- package/components/wd-input-number/wd-input-number.vue +221 -0
- package/components/wd-loading/index.scss +34 -0
- package/components/wd-loading/types.ts +31 -0
- package/components/wd-loading/wd-loading.vue +90 -0
- package/components/wd-loadmore/index.scss +39 -0
- package/components/wd-loadmore/types.ts +24 -0
- package/components/wd-loadmore/wd-loadmore.vue +53 -0
- package/components/wd-message-box/index.scss +121 -0
- package/components/wd-message-box/index.ts +95 -0
- package/components/wd-message-box/types.ts +116 -0
- package/components/wd-message-box/wd-message-box.vue +326 -0
- package/components/wd-navbar/index.scss +103 -0
- package/components/wd-navbar/types.ts +52 -0
- package/components/wd-navbar/wd-navbar.vue +142 -0
- package/components/wd-navbar-capsule/index.scss +65 -0
- package/components/wd-navbar-capsule/types.ts +0 -0
- package/components/wd-navbar-capsule/wd-navbar-capsule.vue +31 -0
- package/components/wd-notice-bar/index.scss +86 -0
- package/components/wd-notice-bar/types.ts +56 -0
- package/components/wd-notice-bar/wd-notice-bar.vue +223 -0
- package/components/wd-notify/index.scss +34 -0
- package/components/wd-notify/index.ts +59 -0
- package/components/wd-notify/types.ts +62 -0
- package/components/wd-notify/wd-notify.vue +83 -0
- package/components/wd-number-keyboard/index.scss +78 -0
- package/components/wd-number-keyboard/key/index.scss +79 -0
- package/components/wd-number-keyboard/key/index.vue +76 -0
- package/components/wd-number-keyboard/key/types.ts +11 -0
- package/components/wd-number-keyboard/types.ts +79 -0
- package/components/wd-number-keyboard/wd-number-keyboard.vue +173 -0
- package/components/wd-overlay/index.scss +17 -0
- package/components/wd-overlay/types.ts +25 -0
- package/components/wd-overlay/wd-overlay.vue +46 -0
- package/components/wd-pagination/index.scss +57 -0
- package/components/wd-pagination/types.ts +41 -0
- package/components/wd-pagination/wd-pagination.vue +121 -0
- package/components/wd-password-input/index.scss +123 -0
- package/components/wd-password-input/types.ts +48 -0
- package/components/wd-password-input/wd-password-input.vue +58 -0
- package/components/wd-picker/index.scss +216 -0
- package/components/wd-picker/types.ts +186 -0
- package/components/wd-picker/wd-picker.vue +409 -0
- package/components/wd-picker-view/index.scss +91 -0
- package/components/wd-picker-view/types.ts +162 -0
- package/components/wd-picker-view/wd-picker-view.vue +361 -0
- package/components/wd-popover/index.scss +123 -0
- package/components/wd-popover/types.ts +69 -0
- package/components/wd-popover/wd-popover.vue +216 -0
- package/components/wd-popup/index.scss +112 -0
- package/components/wd-popup/types.ts +68 -0
- package/components/wd-popup/wd-popup.vue +227 -0
- package/components/wd-progress/index.scss +62 -0
- package/components/wd-progress/types.ts +40 -0
- package/components/wd-progress/wd-progress.vue +201 -0
- package/components/wd-radio/index.scss +300 -0
- package/components/wd-radio/types.ts +42 -0
- package/components/wd-radio/wd-radio.vue +136 -0
- package/components/wd-radio-group/index.scss +23 -0
- package/components/wd-radio-group/types.ts +36 -0
- package/components/wd-radio-group/wd-radio-group.vue +54 -0
- package/components/wd-rate/index.scss +24 -0
- package/components/wd-rate/types.ts +91 -0
- package/components/wd-rate/wd-rate.vue +131 -0
- package/components/wd-resize/index.scss +26 -0
- package/components/wd-resize/types.ts +6 -0
- package/components/wd-resize/wd-resize.vue +155 -0
- package/components/wd-row/index.scss +10 -0
- package/components/wd-row/types.ts +16 -0
- package/components/wd-row/wd-row.vue +63 -0
- package/components/wd-search/index.scss +148 -0
- package/components/wd-search/types.ts +83 -0
- package/components/wd-search/wd-search.vue +237 -0
- package/components/wd-segmented/index.scss +97 -0
- package/components/wd-segmented/types.ts +68 -0
- package/components/wd-segmented/wd-segmented.vue +143 -0
- package/components/wd-select-picker/index.scss +177 -0
- package/components/wd-select-picker/types.ts +116 -0
- package/components/wd-select-picker/wd-select-picker.vue +486 -0
- package/components/wd-sidebar/index.scss +25 -0
- package/components/wd-sidebar/types.ts +28 -0
- package/components/wd-sidebar/wd-sidebar.vue +41 -0
- package/components/wd-sidebar-item/index.scss +93 -0
- package/components/wd-sidebar-item/types.ts +31 -0
- package/components/wd-sidebar-item/wd-sidebar-item.vue +114 -0
- package/components/wd-skeleton/index.scss +101 -0
- package/components/wd-skeleton/index.ts +1 -0
- package/components/wd-skeleton/types.ts +69 -0
- package/components/wd-skeleton/wd-skeleton.vue +135 -0
- package/components/wd-slider/index.scss +91 -0
- package/components/wd-slider/types.ts +104 -0
- package/components/wd-slider/wd-slider.vue +377 -0
- package/components/wd-sort-button/index.scss +86 -0
- package/components/wd-sort-button/types.ts +43 -0
- package/components/wd-sort-button/wd-sort-button.vue +76 -0
- package/components/wd-status-tip/index.scss +37 -0
- package/components/wd-status-tip/types.ts +59 -0
- package/components/wd-status-tip/wd-status-tip.vue +94 -0
- package/components/wd-step/index.scss +236 -0
- package/components/wd-step/types.ts +33 -0
- package/components/wd-step/wd-step.vue +151 -0
- package/components/wd-steps/index.scss +10 -0
- package/components/wd-steps/types.ts +59 -0
- package/components/wd-steps/wd-steps.vue +37 -0
- package/components/wd-sticky/index.scss +9 -0
- package/components/wd-sticky/types.ts +13 -0
- package/components/wd-sticky/wd-sticky.vue +190 -0
- package/components/wd-sticky-box/index.scss +6 -0
- package/components/wd-sticky-box/types.ts +20 -0
- package/components/wd-sticky-box/wd-sticky-box.vue +154 -0
- package/components/wd-swipe-action/index.scss +22 -0
- package/components/wd-swipe-action/types.ts +43 -0
- package/components/wd-swipe-action/wd-swipe-action.vue +307 -0
- package/components/wd-swiper/index.scss +23 -0
- package/components/wd-swiper/types.ts +189 -0
- package/components/wd-swiper/wd-swiper.vue +202 -0
- package/components/wd-swiper-nav/index.scss +153 -0
- package/components/wd-swiper-nav/types.ts +42 -0
- package/components/wd-swiper-nav/wd-swiper-nav.vue +37 -0
- package/components/wd-switch/index.scss +58 -0
- package/components/wd-switch/types.ts +56 -0
- package/components/wd-switch/wd-switch.vue +83 -0
- package/components/wd-tab/index.scss +8 -0
- package/components/wd-tab/types.ts +20 -0
- package/components/wd-tab/wd-tab.vue +100 -0
- package/components/wd-tabbar/index.scss +57 -0
- package/components/wd-tabbar/types.ts +88 -0
- package/components/wd-tabbar/wd-tabbar.vue +104 -0
- package/components/wd-tabbar-item/index.scss +52 -0
- package/components/wd-tabbar-item/types.ts +51 -0
- package/components/wd-tabbar-item/wd-tabbar-item.vue +101 -0
- package/components/wd-table/index.scss +132 -0
- package/components/wd-table/types.ts +69 -0
- package/components/wd-table/wd-table.vue +255 -0
- package/components/wd-table-col/index.scss +44 -0
- package/components/wd-table-col/types.ts +54 -0
- package/components/wd-table-col/wd-table-col.vue +149 -0
- package/components/wd-tabs/index.scss +280 -0
- package/components/wd-tabs/types.ts +71 -0
- package/components/wd-tabs/wd-tabs.vue +528 -0
- package/components/wd-tag/index.scss +115 -0
- package/components/wd-tag/types.ts +81 -0
- package/components/wd-tag/wd-tag.vue +154 -0
- package/components/wd-text/index.scss +34 -0
- package/components/wd-text/types.ts +98 -0
- package/components/wd-text/wd-text.vue +138 -0
- package/components/wd-textarea/index.scss +343 -0
- package/components/wd-textarea/types.ts +298 -0
- package/components/wd-textarea/wd-textarea.vue +303 -0
- package/components/wd-toast/index.scss +66 -0
- package/components/wd-toast/index.ts +109 -0
- package/components/wd-toast/types.ts +76 -0
- package/components/wd-toast/wd-toast.vue +212 -0
- package/components/wd-tooltip/index.scss +61 -0
- package/components/wd-tooltip/types.ts +102 -0
- package/components/wd-tooltip/wd-tooltip.vue +167 -0
- package/components/wd-transition/index.scss +91 -0
- package/components/wd-transition/types.ts +89 -0
- package/components/wd-transition/wd-transition.vue +221 -0
- package/components/wd-upload/index.scss +173 -0
- package/components/wd-upload/types.ts +378 -0
- package/components/wd-upload/utils.ts +152 -0
- package/components/wd-upload/wd-upload.vue +737 -0
- package/components/wd-video-preview/index.scss +34 -0
- package/components/wd-video-preview/types.ts +32 -0
- package/components/wd-video-preview/wd-video-preview.vue +76 -0
- package/components/wd-watermark/index.scss +18 -0
- package/components/wd-watermark/types.ts +82 -0
- package/components/wd-watermark/wd-watermark.vue +592 -0
- package/components/wot-design-uni/wot-design-uni.vue +14 -0
- package/global.d.ts +108 -0
- package/index.ts +30 -0
- package/locale/index.ts +41 -0
- package/locale/lang/en-US.ts +128 -0
- package/locale/lang/th-TH.ts +127 -0
- package/locale/lang/vi-VN.ts +89 -0
- package/locale/lang/zh-CN.ts +127 -0
- package/locale/lang/zh-HK.ts +84 -0
- package/locale/lang/zh-TW.ts +84 -0
- package/package.json +20 -0
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view :class="`wd-table ${border ? 'is-border' : ''} ${customClass}`" :style="tableStyle">
|
|
3
|
+
<scroll-view
|
|
4
|
+
:enable-flex="true"
|
|
5
|
+
:throttle="false"
|
|
6
|
+
:scrollLeft="reactiveState.scrollLeft"
|
|
7
|
+
:scroll-x="true"
|
|
8
|
+
class="wd-table__header"
|
|
9
|
+
@scroll="scroll"
|
|
10
|
+
v-if="showHeader"
|
|
11
|
+
>
|
|
12
|
+
<view
|
|
13
|
+
id="table-header"
|
|
14
|
+
class="wd-table__content"
|
|
15
|
+
:style="realWidthStyle"
|
|
16
|
+
style="position: sticky; top: 0; z-index: 2"
|
|
17
|
+
>
|
|
18
|
+
<view
|
|
19
|
+
:class="`wd-table__cell ${border ? 'is-border' : ''} ${column.fixed ? 'is-fixed' : ''} ${stripe ? 'is-stripe' : ''} is-${column.align} ${
|
|
20
|
+
getIsLastFixed(column) && reactiveState.scrollLeft ? 'is-shadow' : ''
|
|
21
|
+
}`"
|
|
22
|
+
:style="getCellStyle(index)"
|
|
23
|
+
v-for="(column, index) in children"
|
|
24
|
+
:key="index"
|
|
25
|
+
>
|
|
26
|
+
<wd-sort-button
|
|
27
|
+
v-model="column.$.exposed!.sortDirection.value"
|
|
28
|
+
allow-reset
|
|
29
|
+
:line="false"
|
|
30
|
+
:title="column.label"
|
|
31
|
+
@change="(data: any) => handleSortChange(data.value, index)"
|
|
32
|
+
v-if="column.sortable"
|
|
33
|
+
/>
|
|
34
|
+
<text v-else :class="`wd-table__value ${ellipsis ? 'is-ellipsis' : ''}`">
|
|
35
|
+
{{ column.label }}
|
|
36
|
+
</text>
|
|
37
|
+
</view>
|
|
38
|
+
</view>
|
|
39
|
+
</scroll-view>
|
|
40
|
+
<scroll-view
|
|
41
|
+
class="wd-table__body"
|
|
42
|
+
:style="bodyStyle"
|
|
43
|
+
:enable-flex="true"
|
|
44
|
+
:throttle="false"
|
|
45
|
+
:scroll-x="true"
|
|
46
|
+
@scroll="scroll"
|
|
47
|
+
:scrollLeft="reactiveState.scrollLeft"
|
|
48
|
+
>
|
|
49
|
+
<view id="table-body" class="wd-table__content" :style="realWidthStyle">
|
|
50
|
+
<wd-table-col
|
|
51
|
+
v-if="index !== false"
|
|
52
|
+
:prop="indexColumn.prop"
|
|
53
|
+
:label="indexColumn.label"
|
|
54
|
+
:width="indexColumn.width"
|
|
55
|
+
:sortable="indexColumn.sortable"
|
|
56
|
+
:fixed="indexColumn.fixed"
|
|
57
|
+
:align="indexColumn.align"
|
|
58
|
+
>
|
|
59
|
+
<template #value="{ index }">
|
|
60
|
+
<text>{{ index + 1 }}</text>
|
|
61
|
+
</template>
|
|
62
|
+
</wd-table-col>
|
|
63
|
+
<slot></slot>
|
|
64
|
+
</view>
|
|
65
|
+
</scroll-view>
|
|
66
|
+
</view>
|
|
67
|
+
</template>
|
|
68
|
+
|
|
69
|
+
<script lang="ts">
|
|
70
|
+
export default {
|
|
71
|
+
name: 'wd-table',
|
|
72
|
+
options: {
|
|
73
|
+
addGlobalClass: true,
|
|
74
|
+
virtualHost: true,
|
|
75
|
+
styleIsolation: 'shared',
|
|
76
|
+
},
|
|
77
|
+
}
|
|
78
|
+
</script>
|
|
79
|
+
|
|
80
|
+
<script lang="ts" setup>
|
|
81
|
+
import { type CSSProperties, computed, reactive, ref } from 'vue'
|
|
82
|
+
import { addUnit, debounce, isDef, isObj, objToStyle, uuid } from '../common/util'
|
|
83
|
+
import type {
|
|
84
|
+
SortDirection,
|
|
85
|
+
TableColumn,
|
|
86
|
+
TableColumnInstance,
|
|
87
|
+
TableColumnProps,
|
|
88
|
+
} from '../wd-table-col/types'
|
|
89
|
+
import { TABLE_KEY, tableProps, type TableProvide } from './types'
|
|
90
|
+
import WdTableCol from '../wd-table-col/wd-table-col.vue'
|
|
91
|
+
import { useTranslate } from '../composables/useTranslate'
|
|
92
|
+
import { useChildren } from '../composables/useChildren'
|
|
93
|
+
|
|
94
|
+
const { translate } = useTranslate('tableCol')
|
|
95
|
+
|
|
96
|
+
const props = defineProps(tableProps)
|
|
97
|
+
const emit = defineEmits(['sort-method', 'row-click'])
|
|
98
|
+
|
|
99
|
+
const reactiveState = reactive<TableProvide>({
|
|
100
|
+
props,
|
|
101
|
+
scrollLeft: 0,
|
|
102
|
+
rowClick,
|
|
103
|
+
getIsLastFixed,
|
|
104
|
+
getFixedStyle,
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
const { linkChildren, children } = useChildren<TableColumnInstance, TableProvide>(TABLE_KEY)
|
|
108
|
+
|
|
109
|
+
linkChildren(reactiveState)
|
|
110
|
+
|
|
111
|
+
const indexUUID = uuid()
|
|
112
|
+
const indexColumn = ref<TableColumnProps>({
|
|
113
|
+
prop: indexUUID,
|
|
114
|
+
label: translate('indexLabel'),
|
|
115
|
+
width: '100rpx',
|
|
116
|
+
sortable: false,
|
|
117
|
+
fixed: false,
|
|
118
|
+
align: 'left',
|
|
119
|
+
...(isObj(props.index) ? props.index : {}),
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
const scroll = debounce(handleScroll, 100, { leading: false }) // 滚动事件
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* 容器样式
|
|
126
|
+
*/
|
|
127
|
+
const tableStyle = computed(() => {
|
|
128
|
+
const style: CSSProperties = {}
|
|
129
|
+
if (isDef(props.height)) {
|
|
130
|
+
style['max-height'] = addUnit(props.height)
|
|
131
|
+
}
|
|
132
|
+
return `${objToStyle(style)};${props.customStyle}`
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
const realWidthStyle = computed(() => {
|
|
136
|
+
const style: CSSProperties = {
|
|
137
|
+
display: 'flex',
|
|
138
|
+
}
|
|
139
|
+
let width: string | number = ''
|
|
140
|
+
children.forEach((child) => {
|
|
141
|
+
width = width ? `${width} + ${addUnit(child.width)}` : addUnit(child.width)
|
|
142
|
+
})
|
|
143
|
+
style.width = `calc(${width})`
|
|
144
|
+
return objToStyle(style)
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
const bodyStyle = computed(() => {
|
|
148
|
+
const style: CSSProperties = {}
|
|
149
|
+
if (isDef(props.height)) {
|
|
150
|
+
style.height = isDef(props.rowHeight)
|
|
151
|
+
? `calc(${props.data.length} * ${addUnit(props.rowHeight)})`
|
|
152
|
+
: `calc(${props.data.length} * 50px)`
|
|
153
|
+
}
|
|
154
|
+
return `${objToStyle(style)};`
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* 是否最后一个固定元素
|
|
159
|
+
* @param column 列数据
|
|
160
|
+
*/
|
|
161
|
+
function getIsLastFixed(column: { fixed: boolean; prop: string }) {
|
|
162
|
+
let isLastFixed: boolean = false
|
|
163
|
+
if (column.fixed && isDef(children)) {
|
|
164
|
+
const columns = children.filter((child) => {
|
|
165
|
+
return child.fixed
|
|
166
|
+
})
|
|
167
|
+
if (columns.length && columns[columns.length - 1].prop === column.prop) {
|
|
168
|
+
isLastFixed = true
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return isLastFixed
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* 表头单元格样式
|
|
176
|
+
*/
|
|
177
|
+
function getCellStyle(columnIndex: number) {
|
|
178
|
+
let style: CSSProperties = {}
|
|
179
|
+
if (isDef(children[columnIndex].width)) {
|
|
180
|
+
style.width = addUnit(children[columnIndex].width)
|
|
181
|
+
}
|
|
182
|
+
if (children[columnIndex].fixed) {
|
|
183
|
+
style = getFixedStyle(columnIndex, style)
|
|
184
|
+
}
|
|
185
|
+
return objToStyle(style)
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* 获取固定列样式
|
|
190
|
+
* @param columnIndex
|
|
191
|
+
*/
|
|
192
|
+
function getFixedStyle(columnIndex: number, style: CSSProperties) {
|
|
193
|
+
if (columnIndex > 0) {
|
|
194
|
+
let left: string | number = ''
|
|
195
|
+
children.forEach((column, index) => {
|
|
196
|
+
if (index < columnIndex) {
|
|
197
|
+
left = left ? `${left} + ${addUnit(column.width)}` : addUnit(column.width)
|
|
198
|
+
}
|
|
199
|
+
})
|
|
200
|
+
style.left = `calc(${left})`
|
|
201
|
+
} else {
|
|
202
|
+
style.left = 0
|
|
203
|
+
}
|
|
204
|
+
return style
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* 排序
|
|
209
|
+
* @param value
|
|
210
|
+
* @param index
|
|
211
|
+
*/
|
|
212
|
+
function handleSortChange(value: SortDirection, index: number) {
|
|
213
|
+
children[index].$.exposed!.sortDirection.value = value
|
|
214
|
+
children.forEach((col, i) => {
|
|
215
|
+
if (index !== i) {
|
|
216
|
+
col.$.exposed!.sortDirection.value = 0
|
|
217
|
+
}
|
|
218
|
+
})
|
|
219
|
+
const column: TableColumn = {
|
|
220
|
+
// 列对应字段
|
|
221
|
+
prop: children[index].prop,
|
|
222
|
+
// 列对应字段标题
|
|
223
|
+
label: children[index].label,
|
|
224
|
+
// 列宽度
|
|
225
|
+
width: children[index].width,
|
|
226
|
+
// 是否开启列排序
|
|
227
|
+
sortable: children[index].sortable,
|
|
228
|
+
// 列的对齐方式,可选值left,center,right
|
|
229
|
+
align: children[index].align,
|
|
230
|
+
// 列的排序方向
|
|
231
|
+
sortDirection: value,
|
|
232
|
+
// 是否i固定列
|
|
233
|
+
fixed: children[index].fixed,
|
|
234
|
+
}
|
|
235
|
+
emit('sort-method', column)
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* 滚动事件
|
|
240
|
+
*/
|
|
241
|
+
function handleScroll(event: any) {
|
|
242
|
+
if (!props.showHeader) {
|
|
243
|
+
return
|
|
244
|
+
}
|
|
245
|
+
reactiveState.scrollLeft = event.detail.scrollLeft
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function rowClick(index: number) {
|
|
249
|
+
emit('row-click', { rowIndex: index })
|
|
250
|
+
}
|
|
251
|
+
</script>
|
|
252
|
+
|
|
253
|
+
<style lang="scss" scoped>
|
|
254
|
+
@import './index';
|
|
255
|
+
</style>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
@import '../common/abstracts/variable';
|
|
2
|
+
@import '../common/abstracts/mixin';
|
|
3
|
+
|
|
4
|
+
@import '../wd-table/index';
|
|
5
|
+
|
|
6
|
+
.wot-theme-dark {
|
|
7
|
+
@include b(table-col) {
|
|
8
|
+
@include when(shadow) {
|
|
9
|
+
&::after {
|
|
10
|
+
background: linear-gradient(270deg, rgba(17, 17, 17, 0.2) 0%, rgba(0, 0, 0, 0) 100%);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@include b(table-col) {
|
|
17
|
+
.wd-table__cell {
|
|
18
|
+
width: 100%;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@include m(fixed) {
|
|
22
|
+
position: sticky;
|
|
23
|
+
left: 0;
|
|
24
|
+
z-index: 1;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@include when(shadow) {
|
|
28
|
+
&::after {
|
|
29
|
+
position: absolute;
|
|
30
|
+
top: 0;
|
|
31
|
+
right: -30rpx;
|
|
32
|
+
width: 30rpx;
|
|
33
|
+
height: 100%;
|
|
34
|
+
content: ' ';
|
|
35
|
+
background: linear-gradient(270deg, rgba(255, 255, 255, 0) 0%, rgba(0, 0, 0, 0.04) 100%);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.wd-table__cell:last-child {
|
|
40
|
+
@include when(border) {
|
|
41
|
+
border-bottom: none;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { ComponentPublicInstance, ExtractPropTypes } from 'vue'
|
|
2
|
+
import { makeBooleanProp, makeNumericProp, makeRequiredProp, makeStringProp } from '../common/props'
|
|
3
|
+
|
|
4
|
+
export type AlignType = 'left' | 'center' | 'right' // 列的对齐方式
|
|
5
|
+
|
|
6
|
+
export type SortDirection = 0 | 1 | -1 // 列的排序方向
|
|
7
|
+
|
|
8
|
+
export interface TableColumn {
|
|
9
|
+
// 列对应字段
|
|
10
|
+
prop: string
|
|
11
|
+
// 列对应字段标题
|
|
12
|
+
label: string
|
|
13
|
+
// 列宽度
|
|
14
|
+
width: string | number
|
|
15
|
+
// 是否开启列排序
|
|
16
|
+
sortable?: boolean
|
|
17
|
+
// 列的对齐方式,可选值left,center,right
|
|
18
|
+
align?: AlignType
|
|
19
|
+
// 列的排序方向
|
|
20
|
+
sortDirection: SortDirection
|
|
21
|
+
// 是否i固定列
|
|
22
|
+
fixed?: boolean
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const tableColumnProps = {
|
|
26
|
+
/**
|
|
27
|
+
* 列对应字段
|
|
28
|
+
*/
|
|
29
|
+
prop: makeRequiredProp(String),
|
|
30
|
+
/**
|
|
31
|
+
* 列对应字段标题
|
|
32
|
+
*/
|
|
33
|
+
label: makeRequiredProp(String),
|
|
34
|
+
/**
|
|
35
|
+
* 列宽度,单位px
|
|
36
|
+
*/
|
|
37
|
+
width: makeNumericProp(100),
|
|
38
|
+
/**
|
|
39
|
+
* 是否开启列排序
|
|
40
|
+
*/
|
|
41
|
+
sortable: makeBooleanProp(false),
|
|
42
|
+
/**
|
|
43
|
+
* 是否固定本列
|
|
44
|
+
*/
|
|
45
|
+
fixed: makeBooleanProp(false),
|
|
46
|
+
/**
|
|
47
|
+
* 列的对齐方式,可选值left,center,right
|
|
48
|
+
*/
|
|
49
|
+
align: makeStringProp<AlignType>('left'),
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export type TableColumnProps = ExtractPropTypes<typeof tableColumnProps>
|
|
53
|
+
|
|
54
|
+
export type TableColumnInstance = ComponentPublicInstance<TableColumnProps>
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
:class="`wd-table-col ${fixed ? 'wd-table-col--fixed' : ''} ${isLastFixed && isDef(table) && table.scrollLeft ? 'is-shadow' : ''}`"
|
|
4
|
+
:style="columnStyle"
|
|
5
|
+
>
|
|
6
|
+
<view
|
|
7
|
+
:class="`wd-table__cell ${stripe && isOdd(index) ? 'is-stripe' : ''} ${border ? 'is-border' : ''} is-${align}`"
|
|
8
|
+
v-for="(row, index) in column"
|
|
9
|
+
:key="index"
|
|
10
|
+
:style="cellStyle"
|
|
11
|
+
@click="handleRowClick(index)"
|
|
12
|
+
>
|
|
13
|
+
<slot name="value" v-if="$slots.value" :row="getScope(index)" :index="index"></slot>
|
|
14
|
+
<text :class="`wd-table__value ${ellipsis ? 'is-ellipsis' : ''}`" v-else>{{ row }}</text>
|
|
15
|
+
</view>
|
|
16
|
+
</view>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script lang="ts">
|
|
20
|
+
export default {
|
|
21
|
+
name: 'wd-table-col',
|
|
22
|
+
options: {
|
|
23
|
+
addGlobalClass: true,
|
|
24
|
+
virtualHost: true,
|
|
25
|
+
styleIsolation: 'shared',
|
|
26
|
+
},
|
|
27
|
+
}
|
|
28
|
+
</script>
|
|
29
|
+
<script lang="ts" setup>
|
|
30
|
+
import { type CSSProperties, computed, ref, watch } from 'vue'
|
|
31
|
+
import { addUnit, isDef, objToStyle, isOdd, isFunction } from '../common/util'
|
|
32
|
+
import { tableColumnProps, type SortDirection } from './types'
|
|
33
|
+
import { useParent } from '../composables/useParent'
|
|
34
|
+
import { TABLE_KEY } from '../wd-table/types'
|
|
35
|
+
|
|
36
|
+
const props = defineProps(tableColumnProps)
|
|
37
|
+
|
|
38
|
+
const { parent: table, index: columnIndex } = useParent(TABLE_KEY)
|
|
39
|
+
|
|
40
|
+
const sortDirection = ref<SortDirection>(0) // 排序方向
|
|
41
|
+
|
|
42
|
+
// 是否开启斑马纹
|
|
43
|
+
const stripe = computed(() => {
|
|
44
|
+
if (isDef(table)) {
|
|
45
|
+
return table.props.stripe
|
|
46
|
+
} else {
|
|
47
|
+
return false
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* 是否有边框
|
|
53
|
+
*/
|
|
54
|
+
const border = computed(() => {
|
|
55
|
+
if (isDef(table)) {
|
|
56
|
+
return table.props.border
|
|
57
|
+
} else {
|
|
58
|
+
return false
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* 是否超出省略
|
|
64
|
+
*/
|
|
65
|
+
const ellipsis = computed(() => {
|
|
66
|
+
if (isDef(table)) {
|
|
67
|
+
return table.props.ellipsis
|
|
68
|
+
} else {
|
|
69
|
+
return false
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 是否最后一个固定元素
|
|
75
|
+
*/
|
|
76
|
+
const isLastFixed = computed(() => {
|
|
77
|
+
let isLastFixed: boolean = false
|
|
78
|
+
if (props.fixed && isDef(table)) {
|
|
79
|
+
isLastFixed = table.getIsLastFixed(props)
|
|
80
|
+
}
|
|
81
|
+
return isLastFixed
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* 列样式
|
|
86
|
+
*/
|
|
87
|
+
const columnStyle = computed(() => {
|
|
88
|
+
let style: CSSProperties = {}
|
|
89
|
+
if (isDef(props.width)) {
|
|
90
|
+
style.width = addUnit(props.width)
|
|
91
|
+
}
|
|
92
|
+
if (props.fixed && isDef(table) && isFunction(table.getFixedStyle)) {
|
|
93
|
+
style = table.getFixedStyle(columnIndex.value, style)
|
|
94
|
+
}
|
|
95
|
+
return style
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* 单元格样式
|
|
100
|
+
*/
|
|
101
|
+
const cellStyle = computed(() => {
|
|
102
|
+
let style: CSSProperties = {}
|
|
103
|
+
const rowHeight: string | number = isDef(table) ? table.props.rowHeight : '80rpx' // 自定义行高
|
|
104
|
+
if (isDef(rowHeight)) {
|
|
105
|
+
style.height = addUnit(rowHeight)
|
|
106
|
+
}
|
|
107
|
+
if (props.fixed && isDef(table) && isFunction(table.getFixedStyle)) {
|
|
108
|
+
style = table.getFixedStyle(columnIndex.value, style)
|
|
109
|
+
}
|
|
110
|
+
return objToStyle(style)
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
// 列数据
|
|
114
|
+
const column = computed(() => {
|
|
115
|
+
if (!isDef(table)) {
|
|
116
|
+
return []
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const column: any[] = table.props.data.map((item) => {
|
|
120
|
+
return item[props.prop]
|
|
121
|
+
})
|
|
122
|
+
return column
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* 行点击事件
|
|
127
|
+
* @param index 行下标
|
|
128
|
+
*/
|
|
129
|
+
function handleRowClick(index: number) {
|
|
130
|
+
if (!isDef(table)) {
|
|
131
|
+
return
|
|
132
|
+
}
|
|
133
|
+
isFunction(table.rowClick) && table.rowClick(index)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// 行数据
|
|
137
|
+
function getScope(index: number) {
|
|
138
|
+
if (!isDef(table)) {
|
|
139
|
+
return {}
|
|
140
|
+
}
|
|
141
|
+
return table.props.data[index] || {}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
defineExpose({ sortDirection })
|
|
145
|
+
</script>
|
|
146
|
+
|
|
147
|
+
<style lang="scss" scoped>
|
|
148
|
+
@import './index';
|
|
149
|
+
</style>
|