@wot-ui/ui 1.0.0 → 2.0.0-alpha.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.
- package/LICENSE +21 -0
- package/README.md +134 -0
- package/attributes.json +1 -0
- package/changelog.md +53 -0
- package/common/AbortablePromise.ts +28 -0
- package/common/canvasHelper.ts +49 -0
- package/common/clickoutside.ts +25 -0
- package/common/event.ts +8 -0
- package/common/formatDate.ts +68 -0
- package/common/interceptor.ts +43 -0
- package/common/props.ts +53 -0
- package/common/util.ts +836 -0
- package/components/wd-action-sheet/index.scss +232 -0
- package/components/wd-action-sheet/types.ts +155 -0
- package/components/wd-action-sheet/wd-action-sheet.vue +176 -0
- package/components/wd-avatar/index.scss +150 -0
- package/components/wd-avatar/types.ts +98 -0
- package/components/wd-avatar/wd-avatar.vue +184 -0
- package/components/wd-avatar-group/index.scss +11 -0
- package/components/wd-avatar-group/types.ts +61 -0
- package/components/wd-avatar-group/wd-avatar-group.vue +115 -0
- package/components/wd-backtop/index.scss +67 -0
- package/components/wd-backtop/types.ts +66 -0
- package/components/wd-backtop/wd-backtop.vue +57 -0
- package/components/wd-badge/index.scss +116 -0
- package/components/wd-badge/types.ts +94 -0
- package/components/wd-badge/wd-badge.vue +78 -0
- package/components/wd-button/index.scss +436 -0
- package/components/wd-button/types.ts +204 -0
- package/components/wd-button/wd-button.vue +210 -0
- package/components/wd-calendar/index.scss +97 -0
- package/components/wd-calendar/types.ts +221 -0
- package/components/wd-calendar/wd-calendar.vue +339 -0
- package/components/wd-calendar-view/index.scss +41 -0
- package/components/wd-calendar-view/month/index.scss +144 -0
- package/components/wd-calendar-view/month/month.vue +389 -0
- package/components/wd-calendar-view/month/types.ts +70 -0
- package/components/wd-calendar-view/monthPanel/index.scss +84 -0
- package/components/wd-calendar-view/monthPanel/month-panel.vue +541 -0
- package/components/wd-calendar-view/monthPanel/types.ts +151 -0
- package/components/wd-calendar-view/types.ts +166 -0
- package/components/wd-calendar-view/utils.ts +318 -0
- package/components/wd-calendar-view/wd-calendar-view.vue +117 -0
- package/components/wd-calendar-view/year/index.scss +148 -0
- package/components/wd-calendar-view/year/types.ts +74 -0
- package/components/wd-calendar-view/year/year.vue +206 -0
- package/components/wd-calendar-view/yearPanel/index.scss +42 -0
- package/components/wd-calendar-view/yearPanel/types.ts +96 -0
- package/components/wd-calendar-view/yearPanel/year-panel.vue +249 -0
- package/components/wd-card/index.scss +104 -0
- package/components/wd-card/types.ts +47 -0
- package/components/wd-card/wd-card.vue +38 -0
- package/components/wd-cascader/index.scss +154 -0
- package/components/wd-cascader/types.ts +191 -0
- package/components/wd-cascader/wd-cascader.vue +589 -0
- package/components/wd-cell/index.scss +244 -0
- package/components/wd-cell/types.ts +205 -0
- package/components/wd-cell/wd-cell.vue +172 -0
- package/components/wd-cell-group/index.scss +53 -0
- package/components/wd-cell-group/types.ts +97 -0
- package/components/wd-cell-group/wd-cell-group.vue +48 -0
- package/components/wd-checkbox/index.scss +166 -0
- package/components/wd-checkbox/types.ts +118 -0
- package/components/wd-checkbox/wd-checkbox.vue +216 -0
- package/components/wd-checkbox-group/index.scss +5 -0
- package/components/wd-checkbox-group/types.ts +93 -0
- package/components/wd-checkbox-group/wd-checkbox-group.vue +148 -0
- package/components/wd-circle/index.scss +28 -0
- package/components/wd-circle/types.ts +54 -0
- package/components/wd-circle/wd-circle.vue +306 -0
- package/components/wd-col/index.scss +5 -0
- package/components/wd-col/types.ts +16 -0
- package/components/wd-col/wd-col.vue +83 -0
- package/components/wd-collapse/index.scss +71 -0
- package/components/wd-collapse/types.ts +68 -0
- package/components/wd-collapse/wd-collapse.vue +165 -0
- package/components/wd-collapse-item/index.scss +86 -0
- package/components/wd-collapse-item/types.ts +62 -0
- package/components/wd-collapse-item/wd-collapse-item.vue +184 -0
- package/components/wd-config-provider/index.scss +10 -0
- package/components/wd-config-provider/types.ts +2063 -0
- package/components/wd-config-provider/wd-config-provider.vue +61 -0
- package/components/wd-count-down/index.scss +16 -0
- package/components/wd-count-down/types.ts +58 -0
- package/components/wd-count-down/utils.ts +52 -0
- package/components/wd-count-down/wd-count-down.vue +62 -0
- package/components/wd-count-to/index.scss +25 -0
- package/components/wd-count-to/types.ts +121 -0
- package/components/wd-count-to/wd-count-to.vue +126 -0
- package/components/wd-curtain/index.scss +96 -0
- package/components/wd-curtain/types.ts +82 -0
- package/components/wd-curtain/wd-curtain.vue +172 -0
- package/components/wd-datetime-picker/index.scss +133 -0
- package/components/wd-datetime-picker/types.ts +198 -0
- package/components/wd-datetime-picker/wd-datetime-picker.vue +526 -0
- package/components/wd-datetime-picker-view/types.ts +171 -0
- package/components/wd-datetime-picker-view/util.ts +30 -0
- package/components/wd-datetime-picker-view/wd-datetime-picker-view.vue +402 -0
- package/components/wd-dialog/index.scss +281 -0
- package/components/wd-dialog/index.ts +168 -0
- package/components/wd-dialog/types.ts +452 -0
- package/components/wd-dialog/wd-dialog.vue +586 -0
- package/components/wd-divider/index.scss +122 -0
- package/components/wd-divider/types.ts +50 -0
- package/components/wd-divider/wd-divider.vue +54 -0
- package/components/wd-drop-menu/index.scss +90 -0
- package/components/wd-drop-menu/types.ts +38 -0
- package/components/wd-drop-menu/wd-drop-menu.vue +168 -0
- package/components/wd-drop-menu-item/index.scss +96 -0
- package/components/wd-drop-menu-item/types.ts +93 -0
- package/components/wd-drop-menu-item/wd-drop-menu-item.vue +205 -0
- package/components/wd-empty/index.scss +46 -0
- package/components/wd-empty/types.ts +37 -0
- package/components/wd-empty/wd-empty.vue +47 -0
- package/components/wd-fab/index.scss +124 -0
- package/components/wd-fab/types.ts +119 -0
- package/components/wd-fab/wd-fab.vue +322 -0
- package/components/wd-floating-panel/index.scss +73 -0
- package/components/wd-floating-panel/type.ts +32 -0
- package/components/wd-floating-panel/wd-floating-panel.vue +142 -0
- package/components/wd-form/adapters/zod.ts +56 -0
- package/components/wd-form/types.ts +147 -0
- package/components/wd-form/wd-form.vue +121 -0
- package/components/wd-form-item/index.scss +26 -0
- package/components/wd-form-item/types.ts +134 -0
- package/components/wd-form-item/wd-form-item.vue +182 -0
- package/components/wd-gap/index.scss +9 -0
- package/components/wd-gap/types.ts +26 -0
- package/components/wd-gap/wd-gap.vue +38 -0
- package/components/wd-grid/index.scss +11 -0
- package/components/wd-grid/types.ts +97 -0
- package/components/wd-grid/wd-grid.vue +48 -0
- package/components/wd-grid-item/index.scss +187 -0
- package/components/wd-grid-item/types.ts +98 -0
- package/components/wd-grid-item/wd-grid-item.vue +295 -0
- package/components/wd-icon/index.scss +46 -0
- package/components/wd-icon/types.ts +44 -0
- package/components/wd-icon/wd-icon.vue +66 -0
- package/components/wd-image-preview/index.scss +94 -0
- package/components/wd-image-preview/index.ts +95 -0
- package/components/wd-image-preview/types.ts +165 -0
- package/components/wd-image-preview/wd-image-preview.vue +233 -0
- package/components/wd-img/index.scss +82 -0
- package/components/wd-img/types.ts +96 -0
- package/components/wd-img/wd-img.vue +91 -0
- package/components/wd-img-cropper/index.scss +259 -0
- package/components/wd-img-cropper/types.ts +101 -0
- package/components/wd-img-cropper/wd-img-cropper.vue +653 -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 +55 -0
- package/components/wd-index-bar/index.scss +68 -0
- package/components/wd-index-bar/type.ts +23 -0
- package/components/wd-index-bar/wd-index-bar.vue +157 -0
- package/components/wd-input/index.scss +129 -0
- package/components/wd-input/types.ts +165 -0
- package/components/wd-input/wd-input.vue +237 -0
- package/components/wd-input-number/index.scss +233 -0
- package/components/wd-input-number/types.ts +131 -0
- package/components/wd-input-number/wd-input-number.vue +473 -0
- package/components/wd-keyboard/constants.ts +81 -0
- package/components/wd-keyboard/index.scss +104 -0
- package/components/wd-keyboard/key/index.scss +103 -0
- package/components/wd-keyboard/key/index.vue +84 -0
- package/components/wd-keyboard/key/types.ts +44 -0
- package/components/wd-keyboard/types.ts +138 -0
- package/components/wd-keyboard/wd-keyboard.vue +236 -0
- package/components/wd-loading/index.scss +205 -0
- package/components/wd-loading/types.ts +61 -0
- package/components/wd-loading/wd-loading.vue +70 -0
- package/components/wd-loadmore/index.scss +62 -0
- package/components/wd-loadmore/types.ts +42 -0
- package/components/wd-loadmore/wd-loadmore.vue +68 -0
- package/components/wd-navbar/index.scss +96 -0
- package/components/wd-navbar/types.ts +74 -0
- package/components/wd-navbar/wd-navbar.vue +136 -0
- package/components/wd-navbar-capsule/index.scss +70 -0
- package/components/wd-navbar-capsule/types.ts +11 -0
- package/components/wd-navbar-capsule/wd-navbar-capsule.vue +48 -0
- package/components/wd-notice-bar/index.scss +94 -0
- package/components/wd-notice-bar/types.ts +97 -0
- package/components/wd-notice-bar/wd-notice-bar.vue +270 -0
- package/components/wd-notify/index.scss +114 -0
- package/components/wd-notify/index.ts +63 -0
- package/components/wd-notify/types.ts +130 -0
- package/components/wd-notify/wd-notify.vue +162 -0
- package/components/wd-overlay/index.scss +14 -0
- package/components/wd-overlay/types.ts +42 -0
- package/components/wd-overlay/wd-overlay.vue +55 -0
- package/components/wd-pagination/index.scss +71 -0
- package/components/wd-pagination/types.ts +69 -0
- package/components/wd-pagination/wd-pagination.vue +118 -0
- package/components/wd-password-input/index.scss +134 -0
- package/components/wd-password-input/types.ts +42 -0
- package/components/wd-password-input/wd-password-input.vue +51 -0
- package/components/wd-picker/index.scss +72 -0
- package/components/wd-picker/types.ts +141 -0
- package/components/wd-picker/wd-picker.vue +220 -0
- package/components/wd-picker-view/index.scss +93 -0
- package/components/wd-picker-view/types.ts +145 -0
- package/components/wd-picker-view/useSelection.ts +385 -0
- package/components/wd-picker-view/wd-picker-view.vue +227 -0
- package/components/wd-popover/index.scss +117 -0
- package/components/wd-popover/types.ts +106 -0
- package/components/wd-popover/wd-popover.vue +212 -0
- package/components/wd-popup/index.scss +89 -0
- package/components/wd-popup/types.ts +110 -0
- package/components/wd-popup/wd-popup.vue +174 -0
- package/components/wd-progress/index.scss +155 -0
- package/components/wd-progress/types.ts +94 -0
- package/components/wd-progress/wd-progress.vue +249 -0
- package/components/wd-radio/index.scss +189 -0
- package/components/wd-radio/types.ts +64 -0
- package/components/wd-radio/wd-radio.vue +164 -0
- package/components/wd-radio-group/index.scss +5 -0
- package/components/wd-radio-group/types.ts +70 -0
- package/components/wd-radio-group/wd-radio-group.vue +53 -0
- package/components/wd-rate/index.scss +57 -0
- package/components/wd-rate/types.ts +86 -0
- package/components/wd-rate/wd-rate.vue +168 -0
- package/components/wd-resize/index.scss +31 -0
- package/components/wd-resize/types.ts +14 -0
- package/components/wd-resize/wd-resize.vue +157 -0
- package/components/wd-root-portal/wd-root-portal.vue +77 -0
- package/components/wd-row/index.scss +6 -0
- package/components/wd-row/types.ts +36 -0
- package/components/wd-row/wd-row.vue +88 -0
- package/components/wd-search/index.scss +171 -0
- package/components/wd-search/types.ts +107 -0
- package/components/wd-search/wd-search.vue +198 -0
- package/components/wd-segmented/index.scss +155 -0
- package/components/wd-segmented/types.ts +81 -0
- package/components/wd-segmented/wd-segmented.vue +169 -0
- package/components/wd-select-picker/index.scss +72 -0
- package/components/wd-select-picker/types.ts +72 -0
- package/components/wd-select-picker/wd-select-picker.vue +371 -0
- package/components/wd-sidebar/index.scss +25 -0
- package/components/wd-sidebar/types.ts +34 -0
- package/components/wd-sidebar/wd-sidebar.vue +57 -0
- package/components/wd-sidebar-item/index.scss +91 -0
- package/components/wd-sidebar-item/types.ts +28 -0
- package/components/wd-sidebar-item/wd-sidebar-item.vue +118 -0
- package/components/wd-signature/index.scss +42 -0
- package/components/wd-signature/types.ts +295 -0
- package/components/wd-signature/wd-signature.vue +664 -0
- package/components/wd-skeleton/index.scss +112 -0
- package/components/wd-skeleton/types.ts +124 -0
- package/components/wd-skeleton/wd-skeleton.vue +110 -0
- package/components/wd-slide-verify/index.scss +112 -0
- package/components/wd-slide-verify/types.ts +98 -0
- package/components/wd-slide-verify/wd-slide-verify.vue +222 -0
- package/components/wd-slider/index.scss +485 -0
- package/components/wd-slider/types.ts +166 -0
- package/components/wd-slider/wd-slider.vue +529 -0
- package/components/wd-sort-button/index.scss +126 -0
- package/components/wd-sort-button/types.ts +68 -0
- package/components/wd-sort-button/wd-sort-button.vue +67 -0
- package/components/wd-step/index.scss +366 -0
- package/components/wd-step/types.ts +43 -0
- package/components/wd-step/wd-step.vue +181 -0
- package/components/wd-steps/index.scss +7 -0
- package/components/wd-steps/types.ts +50 -0
- package/components/wd-steps/wd-steps.vue +39 -0
- package/components/wd-sticky/index.scss +9 -0
- package/components/wd-sticky/types.ts +13 -0
- package/components/wd-sticky/wd-sticky.vue +192 -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 +157 -0
- package/components/wd-swipe-action/index.scss +22 -0
- package/components/wd-swipe-action/types.ts +87 -0
- package/components/wd-swipe-action/wd-swipe-action.vue +320 -0
- package/components/wd-swiper/index.scss +69 -0
- package/components/wd-swiper/types.ts +275 -0
- package/components/wd-swiper/wd-swiper.vue +332 -0
- package/components/wd-swiper-nav/index.scss +179 -0
- package/components/wd-swiper-nav/types.ts +42 -0
- package/components/wd-swiper-nav/wd-swiper-nav.vue +42 -0
- package/components/wd-switch/index.scss +177 -0
- package/components/wd-switch/types.ts +93 -0
- package/components/wd-switch/wd-switch.vue +107 -0
- package/components/wd-tab/index.scss +16 -0
- package/components/wd-tab/types.ts +45 -0
- package/components/wd-tab/wd-tab.vue +99 -0
- package/components/wd-tabbar/index.scss +71 -0
- package/components/wd-tabbar/types.ts +79 -0
- package/components/wd-tabbar/wd-tabbar.vue +109 -0
- package/components/wd-tabbar-item/index.scss +50 -0
- package/components/wd-tabbar-item/types.ts +45 -0
- package/components/wd-tabbar-item/wd-tabbar-item.vue +101 -0
- package/components/wd-table/index.scss +128 -0
- package/components/wd-table/types.ts +160 -0
- package/components/wd-table/wd-table.vue +331 -0
- package/components/wd-table-column/index.scss +15 -0
- package/components/wd-table-column/types.ts +81 -0
- package/components/wd-table-column/wd-table-column.vue +198 -0
- package/components/wd-tabs/index.scss +332 -0
- package/components/wd-tabs/types.ts +155 -0
- package/components/wd-tabs/wd-tabs.vue +508 -0
- package/components/wd-tag/index.scss +325 -0
- package/components/wd-tag/types.ts +90 -0
- package/components/wd-tag/wd-tag.vue +158 -0
- package/components/wd-text/index.scss +52 -0
- package/components/wd-text/types.ts +107 -0
- package/components/wd-text/wd-text.vue +141 -0
- package/components/wd-textarea/index.scss +112 -0
- package/components/wd-textarea/types.ts +151 -0
- package/components/wd-textarea/wd-textarea.vue +212 -0
- package/components/wd-toast/index.scss +92 -0
- package/components/wd-toast/index.ts +97 -0
- package/components/wd-toast/types.ts +190 -0
- package/components/wd-toast/wd-toast.vue +158 -0
- package/components/wd-tooltip/index.scss +77 -0
- package/components/wd-tooltip/types.ts +105 -0
- package/components/wd-tooltip/wd-tooltip.vue +169 -0
- package/components/wd-tour/index.scss +106 -0
- package/components/wd-tour/types.ts +268 -0
- package/components/wd-tour/wd-tour.vue +518 -0
- package/components/wd-transition/index.scss +67 -0
- package/components/wd-transition/types.ts +106 -0
- package/components/wd-transition/wd-transition.vue +238 -0
- package/components/wd-upload/index.scss +204 -0
- package/components/wd-upload/types.ts +390 -0
- package/components/wd-upload/wd-upload.vue +565 -0
- package/components/wd-video-preview/index.scss +54 -0
- package/components/wd-video-preview/index.ts +64 -0
- package/components/wd-video-preview/types.ts +66 -0
- package/components/wd-video-preview/wd-video-preview.vue +141 -0
- package/components/wd-watermark/index.scss +21 -0
- package/components/wd-watermark/types.ts +130 -0
- package/components/wd-watermark/wd-watermark.vue +718 -0
- package/components/wot-ui/wot-ui.vue +5 -0
- package/composables/index.ts +12 -0
- package/composables/useCell.ts +34 -0
- package/composables/useChildren.ts +120 -0
- package/composables/useConfigProvider.ts +45 -0
- package/composables/useCountDown.ts +138 -0
- package/composables/useDeviceInfo.ts +136 -0
- package/composables/useLockScroll.ts +37 -0
- package/composables/useParent.ts +51 -0
- package/composables/usePopover.ts +212 -0
- package/composables/useQueue.ts +52 -0
- package/composables/useRaf.ts +37 -0
- package/composables/useTouch.ts +43 -0
- package/composables/useTranslate.ts +12 -0
- package/composables/useUpload.ts +366 -0
- package/global.d.ts +106 -0
- package/index.ts +11 -0
- package/locale/index.ts +32 -0
- package/locale/lang/ar-SA.ts +150 -0
- package/locale/lang/de-DE.ts +150 -0
- package/locale/lang/en-US.ts +150 -0
- package/locale/lang/es-ES.ts +150 -0
- package/locale/lang/fr-FR.ts +150 -0
- package/locale/lang/ja-JP.ts +150 -0
- package/locale/lang/ko-KR.ts +150 -0
- package/locale/lang/pt-PT.ts +150 -0
- package/locale/lang/ru-RU.ts +150 -0
- package/locale/lang/th-TH.ts +150 -0
- package/locale/lang/tr-TR.ts +155 -0
- package/locale/lang/ug-CN.ts +154 -0
- package/locale/lang/vi-VN.ts +89 -0
- package/locale/lang/zh-CN.ts +154 -0
- package/locale/lang/zh-HK.ts +78 -0
- package/locale/lang/zh-TW.ts +78 -0
- package/package.json +1 -11
- package/styles/iconfont/iconfont.scss +1243 -0
- package/styles/mixin/_config.scss +7 -0
- package/styles/mixin/_function.scss +44 -0
- package/styles/mixin/_mixin.scss +473 -0
- package/styles/theme/base/color.scss +210 -0
- package/styles/theme/base/font.scss +13 -0
- package/styles/theme/base/index.scss +8 -0
- package/styles/theme/base/insets.scss +32 -0
- package/styles/theme/base/number.scss +36 -0
- package/styles/theme/base/opacity.scss +9 -0
- package/styles/theme/base/radius.scss +13 -0
- package/styles/theme/base/stroke.scss +9 -0
- package/styles/theme/base/typography.scss +44 -0
- package/styles/theme/dark.scss +101 -0
- package/styles/theme/index.scss +16 -0
- package/styles/theme/light.scss +101 -0
- package/styles/variable.scss +472 -0
- package/tags.json +1 -0
- package/web-types.json +1 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import type { ExtractPropTypes, InjectionKey, ComputedRef } from 'vue'
|
|
2
|
+
import { baseProps, makeBooleanProp, makeNumericProp, makeRequiredProp, numericProp } from '../../common/props'
|
|
3
|
+
import type { TableColumnProps } from '../wd-table-column/types'
|
|
4
|
+
import type { PropType } from 'vue'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* span-method 回调参数
|
|
8
|
+
*/
|
|
9
|
+
export interface SpanMethodParams {
|
|
10
|
+
/** 当前行的数据对象 */
|
|
11
|
+
row: Record<string, any>
|
|
12
|
+
/** 当前列的配置(字段名和标题) */
|
|
13
|
+
column: { prop: string; label: string }
|
|
14
|
+
/** 当前行索引(从 0 开始) */
|
|
15
|
+
rowIndex: number
|
|
16
|
+
/** 当前列索引(从 0 开始) */
|
|
17
|
+
columnIndex: number
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* span-method 返回值,定义单元格的合并行列数
|
|
22
|
+
*/
|
|
23
|
+
export interface SpanMethodResult {
|
|
24
|
+
/**
|
|
25
|
+
* 合并的行数
|
|
26
|
+
* 1 表示正常不合并,大于 1 表示向下合并 N 行,0 表示该单元格被合并隐藏
|
|
27
|
+
*/
|
|
28
|
+
rowspan: number
|
|
29
|
+
/**
|
|
30
|
+
* 合并的列数
|
|
31
|
+
* 1 表示正常不合并,大于 1 表示向右合并 N 列,0 表示该单元格被合并隐藏
|
|
32
|
+
*/
|
|
33
|
+
colspan: number
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 合并单元格的回调函数类型
|
|
38
|
+
* @param params - 包含行数据、列配置、行列索引
|
|
39
|
+
* @returns 返回合并配置 { rowspan, colspan },返回 void 时使用默认 { 1, 1 }
|
|
40
|
+
*/
|
|
41
|
+
export type SpanMethod = (params: SpanMethodParams) => SpanMethodResult | void
|
|
42
|
+
|
|
43
|
+
export const tableProps = {
|
|
44
|
+
...baseProps,
|
|
45
|
+
/**
|
|
46
|
+
* 表格显示的数据数组
|
|
47
|
+
* 类型: Record<string, any>[]
|
|
48
|
+
*/
|
|
49
|
+
data: makeRequiredProp(Array<Record<string, any>>),
|
|
50
|
+
/**
|
|
51
|
+
* 是否显示表格边框
|
|
52
|
+
* 默认值: true
|
|
53
|
+
*/
|
|
54
|
+
border: makeBooleanProp(true),
|
|
55
|
+
/**
|
|
56
|
+
* 是否显示斑马纹(奇偶行不同背景色)
|
|
57
|
+
* 默认值: true
|
|
58
|
+
*/
|
|
59
|
+
stripe: makeBooleanProp(true),
|
|
60
|
+
/**
|
|
61
|
+
* 表格最大高度,超出后纵向滚动
|
|
62
|
+
* 类型: string | number
|
|
63
|
+
*/
|
|
64
|
+
height: numericProp,
|
|
65
|
+
/**
|
|
66
|
+
* 是否显示表头
|
|
67
|
+
* 默认值: true
|
|
68
|
+
*/
|
|
69
|
+
showHeader: makeBooleanProp(true),
|
|
70
|
+
/**
|
|
71
|
+
* 单元格文本是否超出两行后省略
|
|
72
|
+
* 默认值: false
|
|
73
|
+
*/
|
|
74
|
+
ellipsis: makeBooleanProp(false),
|
|
75
|
+
/**
|
|
76
|
+
* 是否显示索引列,传入对象可自定义索引列配置
|
|
77
|
+
* 类型: boolean | Partial<TableColumnProps>
|
|
78
|
+
* 默认值: false
|
|
79
|
+
*/
|
|
80
|
+
index: {
|
|
81
|
+
type: [Object, Boolean] as PropType<boolean | Omit<Partial<TableColumnProps>, 'prop'>>,
|
|
82
|
+
default: false
|
|
83
|
+
},
|
|
84
|
+
/**
|
|
85
|
+
* 是否固定表头(使用 CSS sticky 定位)
|
|
86
|
+
* 默认值: true
|
|
87
|
+
*/
|
|
88
|
+
fixedHeader: makeBooleanProp(true),
|
|
89
|
+
/**
|
|
90
|
+
* 合并单元格的回调方法
|
|
91
|
+
* 类型: SpanMethod
|
|
92
|
+
* 默认值: undefined
|
|
93
|
+
*/
|
|
94
|
+
spanMethod: {
|
|
95
|
+
type: Function as PropType<SpanMethod>,
|
|
96
|
+
default: undefined
|
|
97
|
+
},
|
|
98
|
+
/**
|
|
99
|
+
* 是否开启虚拟滚动(大数据量时只渲染可视区域行)
|
|
100
|
+
* 默认值: false
|
|
101
|
+
*/
|
|
102
|
+
virtual: makeBooleanProp(false),
|
|
103
|
+
/**
|
|
104
|
+
* 行高(虚拟滚动时必填,用于计算可视行范围和总滚动高度)
|
|
105
|
+
* 类型: number
|
|
106
|
+
* 默认值: 44
|
|
107
|
+
*/
|
|
108
|
+
rowHeight: makeNumericProp(44),
|
|
109
|
+
/**
|
|
110
|
+
* 可视区域上下各额外预渲染的行数
|
|
111
|
+
* 类型: number
|
|
112
|
+
* 默认值: 5
|
|
113
|
+
*/
|
|
114
|
+
buffer: makeNumericProp(5)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** 表格 Props 类型 */
|
|
118
|
+
export type TableProps = ExtractPropTypes<typeof tableProps>
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* 表格组件通过 provide/inject 向子列组件提供的接口
|
|
122
|
+
*/
|
|
123
|
+
export type TableProvide = {
|
|
124
|
+
/** 表格 props(不含 index、customStyle、customClass) */
|
|
125
|
+
props: Omit<TableProps, 'index' | 'customStyle' | 'customClass'>
|
|
126
|
+
/** 表格滚动状态 */
|
|
127
|
+
state: {
|
|
128
|
+
/** 当前水平滚动偏移量,用于固定列阴影判断 */
|
|
129
|
+
scrollLeft: number
|
|
130
|
+
}
|
|
131
|
+
/** 当前可视行范围(虚拟滚动时只渲染此范围内的行) */
|
|
132
|
+
visibleRange: ComputedRef<{ start: number; end: number }>
|
|
133
|
+
/**
|
|
134
|
+
* 行点击事件回调
|
|
135
|
+
* @param index - 被点击行的索引
|
|
136
|
+
*/
|
|
137
|
+
rowClick: (index: number) => void
|
|
138
|
+
/**
|
|
139
|
+
* 判断指定列是否为最后一个固定列
|
|
140
|
+
* @param column - 列配置(含 fixed 和 prop)
|
|
141
|
+
* @returns 是否为最后一个固定列
|
|
142
|
+
*/
|
|
143
|
+
getIsLastFixed: (column: { fixed: boolean; prop: string }) => boolean
|
|
144
|
+
/**
|
|
145
|
+
* 获取指定列的固定 left 偏移量
|
|
146
|
+
* @param columnIndex - 列索引
|
|
147
|
+
* @returns CSS left 值字符串
|
|
148
|
+
*/
|
|
149
|
+
getFixedLeft: (columnIndex: number) => string
|
|
150
|
+
/**
|
|
151
|
+
* 获取指定单元格的合并信息
|
|
152
|
+
* @param rowIndex - 行索引
|
|
153
|
+
* @param columnIndex - 列索引
|
|
154
|
+
* @returns 合并配置 { rowspan, colspan }
|
|
155
|
+
*/
|
|
156
|
+
getSpan: (rowIndex: number, columnIndex: number) => SpanMethodResult
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** 表格组件的 InjectionKey */
|
|
160
|
+
export const TABLE_KEY: InjectionKey<TableProvide> = Symbol('wd-table')
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view :class="['wd-table', { 'is-border': border }, customClass]" :style="tableStyle">
|
|
3
|
+
<scroll-view :enable-flex="true" :throttle="false" :scroll-x="true" :scroll-y="scrollY" :style="scrollViewStyle" @scroll="handleScrollThrottled">
|
|
4
|
+
<view :style="contentWidthStyle">
|
|
5
|
+
<!-- 表头 -->
|
|
6
|
+
<view v-if="showHeader" :class="['wd-table__header', { 'is-sticky': fixedHeader }]" :style="gridColumnsStyle">
|
|
7
|
+
<view
|
|
8
|
+
v-for="(column, index) in children"
|
|
9
|
+
:key="index"
|
|
10
|
+
:class="[
|
|
11
|
+
'wd-table__cell',
|
|
12
|
+
'wd-table__cell--header',
|
|
13
|
+
{
|
|
14
|
+
'is-border': border,
|
|
15
|
+
'is-fixed': column.fixed,
|
|
16
|
+
'is-stripe': stripe,
|
|
17
|
+
'is-shadow': isLastFixed(index) && state.scrollLeft,
|
|
18
|
+
'is-last': index === children.length - 1
|
|
19
|
+
},
|
|
20
|
+
`is-${column.align}`
|
|
21
|
+
]"
|
|
22
|
+
:style="getHeaderCellStyle(index)"
|
|
23
|
+
>
|
|
24
|
+
<wd-sort-button
|
|
25
|
+
v-if="column.sortable"
|
|
26
|
+
v-model="column.$.exposed!.sortDirection.value"
|
|
27
|
+
allow-reset
|
|
28
|
+
:line="false"
|
|
29
|
+
:title="column.label"
|
|
30
|
+
@change="({ value }) => handleSortChange(value, index)"
|
|
31
|
+
/>
|
|
32
|
+
<text v-else :class="['wd-table__value', { 'is-ellipsis': ellipsis }]">{{ column.label }}</text>
|
|
33
|
+
</view>
|
|
34
|
+
</view>
|
|
35
|
+
|
|
36
|
+
<!-- 表体(CSS Grid 布局,虚拟滚动时包含 grid-template-rows) -->
|
|
37
|
+
<view class="wd-table__body" :style="bodyGridStyle">
|
|
38
|
+
<wd-table-column
|
|
39
|
+
v-if="showIndex"
|
|
40
|
+
:prop="indexColumn.prop"
|
|
41
|
+
:label="indexColumn.label"
|
|
42
|
+
:width="indexColumn.width"
|
|
43
|
+
:sortable="indexColumn.sortable"
|
|
44
|
+
:fixed="indexColumn.fixed"
|
|
45
|
+
:align="indexColumn.align"
|
|
46
|
+
>
|
|
47
|
+
<template #value="{ index }">
|
|
48
|
+
<text>{{ index + 1 }}</text>
|
|
49
|
+
</template>
|
|
50
|
+
</wd-table-column>
|
|
51
|
+
<slot></slot>
|
|
52
|
+
</view>
|
|
53
|
+
</view>
|
|
54
|
+
</scroll-view>
|
|
55
|
+
</view>
|
|
56
|
+
</template>
|
|
57
|
+
|
|
58
|
+
<script lang="ts">
|
|
59
|
+
export default {
|
|
60
|
+
name: 'wd-table',
|
|
61
|
+
options: {
|
|
62
|
+
addGlobalClass: true,
|
|
63
|
+
// #ifndef MP-TOUTIAO
|
|
64
|
+
virtualHost: true,
|
|
65
|
+
// #endif
|
|
66
|
+
styleIsolation: 'shared'
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
</script>
|
|
70
|
+
|
|
71
|
+
<script lang="ts" setup>
|
|
72
|
+
import wdSortButton from '../wd-sort-button/wd-sort-button.vue'
|
|
73
|
+
import { type CSSProperties, computed, reactive, ref } from 'vue'
|
|
74
|
+
import { addUnit, isDef, isObj, objToStyle, throttle, uuid, isFunction } from '../../common/util'
|
|
75
|
+
import type { SortDirection, TableColumn, TableColumnInstance, TableColumnProps } from '../wd-table-column/types'
|
|
76
|
+
import { TABLE_KEY, tableProps, type SpanMethodResult, type TableProvide } from './types'
|
|
77
|
+
import WdTableColumn from '../wd-table-column/wd-table-column.vue'
|
|
78
|
+
import { useTranslate } from '../../composables/useTranslate'
|
|
79
|
+
import { useChildren } from '../../composables/useChildren'
|
|
80
|
+
|
|
81
|
+
const { translate } = useTranslate('tableCol')
|
|
82
|
+
|
|
83
|
+
const props = defineProps(tableProps)
|
|
84
|
+
const emit = defineEmits(['sort-method', 'row-click'])
|
|
85
|
+
|
|
86
|
+
/** 滚动状态 */
|
|
87
|
+
const state = reactive({
|
|
88
|
+
scrollLeft: 0,
|
|
89
|
+
scrollTop: 0
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
const { linkChildren, children } = useChildren<TableColumnInstance, TableProvide>(TABLE_KEY)
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* 当前可视行范围
|
|
96
|
+
* @returns { start, end } 可视区域的行索引范围(含 buffer)
|
|
97
|
+
*/
|
|
98
|
+
const visibleRange = computed(() => {
|
|
99
|
+
const total = props.data.length
|
|
100
|
+
if (!props.virtual || total === 0) {
|
|
101
|
+
return { start: 0, end: Math.max(0, total - 1) }
|
|
102
|
+
}
|
|
103
|
+
const rowH = Number(props.rowHeight) || 44
|
|
104
|
+
const bufferSize = Number(props.buffer) || 5
|
|
105
|
+
const viewportHeight = Number(props.height) || 400
|
|
106
|
+
const start = Math.max(0, Math.floor(state.scrollTop / rowH) - bufferSize)
|
|
107
|
+
const end = Math.min(total - 1, Math.ceil((state.scrollTop + viewportHeight) / rowH) + bufferSize)
|
|
108
|
+
return { start, end }
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
linkChildren({ props, state, visibleRange, rowClick, getIsLastFixed, getFixedLeft, getSpan })
|
|
112
|
+
|
|
113
|
+
/** 索引列唯一标识 */
|
|
114
|
+
const indexUUID = uuid()
|
|
115
|
+
|
|
116
|
+
/** 索引列配置 */
|
|
117
|
+
const indexColumn = ref<TableColumnProps>({
|
|
118
|
+
prop: indexUUID,
|
|
119
|
+
label: translate('indexLabel'),
|
|
120
|
+
width: '100rpx',
|
|
121
|
+
sortable: false,
|
|
122
|
+
fixed: false,
|
|
123
|
+
align: 'left',
|
|
124
|
+
...(isObj(props.index) ? props.index : {})
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
/** 是否显示索引列 */
|
|
128
|
+
const showIndex = computed(() => props.index !== false)
|
|
129
|
+
|
|
130
|
+
/** 是否开启纵向滚动(设置了 height 时启用) */
|
|
131
|
+
const scrollY = computed(() => isDef(props.height))
|
|
132
|
+
|
|
133
|
+
/** 滚动事件处理(节流 16ms ≈ 60fps) */
|
|
134
|
+
const handleScrollThrottled = throttle(handleScroll, 16) as (event: any) => void
|
|
135
|
+
|
|
136
|
+
/** 外层容器样式 */
|
|
137
|
+
const tableStyle = computed(() => {
|
|
138
|
+
return `${props.customStyle}`
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* scroll-view 容器样式
|
|
143
|
+
* @returns 包含 max-height 的样式字符串(当设置了 height 时)
|
|
144
|
+
*/
|
|
145
|
+
const scrollViewStyle = computed(() => {
|
|
146
|
+
const style: CSSProperties = {
|
|
147
|
+
overflow: 'auto'
|
|
148
|
+
}
|
|
149
|
+
if (isDef(props.height)) {
|
|
150
|
+
style['max-height'] = addUnit(props.height)
|
|
151
|
+
}
|
|
152
|
+
return objToStyle(style)
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* 所有列宽度数组
|
|
157
|
+
* @returns 列宽字符串数组,如 ['100px', '150px', '200px']
|
|
158
|
+
*/
|
|
159
|
+
const columnWidths = computed(() => {
|
|
160
|
+
return children.map((child) => addUnit(child.width))
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* 内容总宽度样式,确保水平滚动时内容不被压缩
|
|
165
|
+
* @returns 所有列宽之和的 calc() 表达式
|
|
166
|
+
*/
|
|
167
|
+
const contentWidthStyle = computed(() => {
|
|
168
|
+
return objToStyle({ width: `calc(${columnWidths.value.join(' + ')})` })
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* CSS Grid 列定义样式,用于表头
|
|
173
|
+
* @returns 包含 display:grid 和 grid-template-columns 的样式字符串
|
|
174
|
+
*/
|
|
175
|
+
const gridColumnsStyle = computed(() => {
|
|
176
|
+
return objToStyle({
|
|
177
|
+
display: 'grid',
|
|
178
|
+
'grid-template-columns': columnWidths.value.join(' ')
|
|
179
|
+
})
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* 表体 Grid 样式(含列定义 + 虚拟滚动时的行定义)
|
|
184
|
+
* @returns 包含 grid-template-columns 和可选的 grid-template-rows 的样式字符串
|
|
185
|
+
*/
|
|
186
|
+
const bodyGridStyle = computed(() => {
|
|
187
|
+
const style: Record<string, string> = {
|
|
188
|
+
display: 'grid',
|
|
189
|
+
'grid-template-columns': columnWidths.value.join(' ')
|
|
190
|
+
}
|
|
191
|
+
if (props.virtual && props.data.length > 0) {
|
|
192
|
+
const rowH = Number(props.rowHeight) || 44
|
|
193
|
+
style['grid-template-rows'] = `repeat(${props.data.length}, ${rowH}px)`
|
|
194
|
+
}
|
|
195
|
+
return objToStyle(style)
|
|
196
|
+
})
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* 最后一个固定列的 prop 值
|
|
200
|
+
* @returns 最后一个 fixed=true 列的 prop,无固定列时返回 null
|
|
201
|
+
*/
|
|
202
|
+
const lastFixedProp = computed(() => {
|
|
203
|
+
const fixedCols = children.filter((c) => c.fixed)
|
|
204
|
+
return fixedCols.length ? fixedCols[fixedCols.length - 1].prop : null
|
|
205
|
+
})
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* 预计算每列的 left 偏移量
|
|
209
|
+
* @returns Map<列索引, CSS left 值>
|
|
210
|
+
*/
|
|
211
|
+
const fixedLeftMap = computed(() => {
|
|
212
|
+
const map = new Map<number, string>()
|
|
213
|
+
const leftParts: string[] = []
|
|
214
|
+
|
|
215
|
+
children.forEach((_col, i) => {
|
|
216
|
+
if (leftParts.length === 0) {
|
|
217
|
+
map.set(i, '0')
|
|
218
|
+
} else {
|
|
219
|
+
map.set(i, `calc(${leftParts.join(' + ')})`)
|
|
220
|
+
}
|
|
221
|
+
leftParts.push(addUnit(children[i].width))
|
|
222
|
+
})
|
|
223
|
+
return map
|
|
224
|
+
})
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* 判断指定索引的列是否为最后一个固定列(内部使用,用于表头渲染)
|
|
228
|
+
* @param colIndex - 列索引
|
|
229
|
+
* @returns 是否为最后一个固定列
|
|
230
|
+
*/
|
|
231
|
+
function isLastFixed(colIndex: number): boolean {
|
|
232
|
+
return children[colIndex]?.fixed && children[colIndex]?.prop === lastFixedProp.value
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* 判断指定列是否为最后一个固定列
|
|
237
|
+
* @param column - 列配置
|
|
238
|
+
* @returns 是否为最后一个固定列
|
|
239
|
+
*/
|
|
240
|
+
function getIsLastFixed(column: { fixed: boolean; prop: string }): boolean {
|
|
241
|
+
return column.fixed && column.prop === lastFixedProp.value
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* 获取指定列的固定 left 偏移量
|
|
246
|
+
* @param columnIndex - 列索引
|
|
247
|
+
* @returns CSS left 值字符串
|
|
248
|
+
*/
|
|
249
|
+
function getFixedLeft(columnIndex: number): string {
|
|
250
|
+
return fixedLeftMap.value.get(columnIndex) || '0'
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* 获取指定单元格的合并信息
|
|
255
|
+
* @param rowIndex - 行索引
|
|
256
|
+
* @param columnIndex - 列索引
|
|
257
|
+
* @returns 合并配置 { rowspan, colspan }
|
|
258
|
+
*/
|
|
259
|
+
function getSpan(rowIndex: number, columnIndex: number): SpanMethodResult {
|
|
260
|
+
if (!isFunction(props.spanMethod)) {
|
|
261
|
+
return { rowspan: 1, colspan: 1 }
|
|
262
|
+
}
|
|
263
|
+
const result = props.spanMethod({
|
|
264
|
+
row: props.data[rowIndex],
|
|
265
|
+
column: { prop: children[columnIndex].prop, label: children[columnIndex].label },
|
|
266
|
+
rowIndex,
|
|
267
|
+
columnIndex
|
|
268
|
+
})
|
|
269
|
+
return result || { rowspan: 1, colspan: 1 }
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* 获取表头单元格的内联样式(仅固定列需要 left 偏移)
|
|
274
|
+
* @param columnIndex - 列索引
|
|
275
|
+
* @returns 样式字符串
|
|
276
|
+
*/
|
|
277
|
+
function getHeaderCellStyle(columnIndex: number): string {
|
|
278
|
+
const style: CSSProperties = {}
|
|
279
|
+
if (children[columnIndex].fixed) {
|
|
280
|
+
style['left'] = fixedLeftMap.value.get(columnIndex) || '0'
|
|
281
|
+
}
|
|
282
|
+
return objToStyle(style)
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* 处理排序状态变更,重置其他列的排序方向并触发 sort-method 事件
|
|
287
|
+
* @param value - 新的排序方向
|
|
288
|
+
* @param index - 触发排序的列索引
|
|
289
|
+
*/
|
|
290
|
+
function handleSortChange(value: SortDirection, index: number) {
|
|
291
|
+
children[index].$.exposed!.sortDirection.value = value
|
|
292
|
+
children.forEach((col, i) => {
|
|
293
|
+
if (index != i) {
|
|
294
|
+
col.$.exposed!.sortDirection.value = 0
|
|
295
|
+
}
|
|
296
|
+
})
|
|
297
|
+
const column: TableColumn = {
|
|
298
|
+
prop: children[index].prop,
|
|
299
|
+
label: children[index].label,
|
|
300
|
+
width: children[index].width,
|
|
301
|
+
sortable: children[index].sortable,
|
|
302
|
+
align: children[index].align,
|
|
303
|
+
sortDirection: value,
|
|
304
|
+
fixed: children[index].fixed
|
|
305
|
+
}
|
|
306
|
+
emit('sort-method', column)
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* 处理滚动事件,更新水平和垂直滚动偏移量
|
|
311
|
+
* @param event - scroll-view 的滚动事件对象
|
|
312
|
+
*/
|
|
313
|
+
function handleScroll(event: any) {
|
|
314
|
+
state.scrollLeft = event.detail.scrollLeft
|
|
315
|
+
if (props.virtual) {
|
|
316
|
+
state.scrollTop = event.detail.scrollTop
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* 触发行点击事件
|
|
322
|
+
* @param index - 被点击行的索引
|
|
323
|
+
*/
|
|
324
|
+
function rowClick(index: number) {
|
|
325
|
+
emit('row-click', { rowIndex: index })
|
|
326
|
+
}
|
|
327
|
+
</script>
|
|
328
|
+
|
|
329
|
+
<style lang="scss">
|
|
330
|
+
@use './index.scss';
|
|
331
|
+
</style>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
@use '../../styles/mixin/mixin.scss'as *;
|
|
2
|
+
|
|
3
|
+
@use '../wd-table/index.scss' as *;
|
|
4
|
+
|
|
5
|
+
@include b(table-column) {
|
|
6
|
+
display: contents;
|
|
7
|
+
|
|
8
|
+
.wd-table__cell:last-child {
|
|
9
|
+
@include when(border) {
|
|
10
|
+
&::before {
|
|
11
|
+
border-bottom: none;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { ComponentPublicInstance, ExtractPropTypes } from 'vue'
|
|
2
|
+
import { makeBooleanProp, makeNumericProp, makeRequiredProp, makeStringProp } from '../../common/props'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 列的对齐方式
|
|
6
|
+
* 可选值: 'left' | 'center' | 'right'
|
|
7
|
+
*/
|
|
8
|
+
export type AlignType = 'left' | 'center' | 'right'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 列的排序方向
|
|
12
|
+
* 可选值: 0(未排序) | 1(升序) | -1(降序)
|
|
13
|
+
*/
|
|
14
|
+
export type SortDirection = 0 | 1 | -1
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 表格列配置信息,用于排序事件回调等场景
|
|
18
|
+
*/
|
|
19
|
+
export interface TableColumn {
|
|
20
|
+
/** 列对应的数据字段名 */
|
|
21
|
+
prop: string
|
|
22
|
+
/** 列的表头标题 */
|
|
23
|
+
label: string
|
|
24
|
+
/** 列宽度 */
|
|
25
|
+
width: string | number
|
|
26
|
+
/** 是否开启列排序 */
|
|
27
|
+
sortable?: boolean
|
|
28
|
+
/**
|
|
29
|
+
* 列的对齐方式
|
|
30
|
+
* 可选值: 'left' | 'center' | 'right'
|
|
31
|
+
*/
|
|
32
|
+
align?: AlignType
|
|
33
|
+
/**
|
|
34
|
+
* 当前排序方向
|
|
35
|
+
* 可选值: 0(未排序) | 1(升序) | -1(降序)
|
|
36
|
+
*/
|
|
37
|
+
sortDirection: SortDirection
|
|
38
|
+
/** 是否固定本列 */
|
|
39
|
+
fixed?: boolean
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const tableColumnProps = {
|
|
43
|
+
/**
|
|
44
|
+
* 列对应的数据字段名
|
|
45
|
+
* 类型: string
|
|
46
|
+
*/
|
|
47
|
+
prop: makeRequiredProp(String),
|
|
48
|
+
/**
|
|
49
|
+
* 列的表头标题
|
|
50
|
+
* 类型: string
|
|
51
|
+
*/
|
|
52
|
+
label: makeRequiredProp(String),
|
|
53
|
+
/**
|
|
54
|
+
* 列宽度
|
|
55
|
+
* 类型: string | number
|
|
56
|
+
* 默认值: 100
|
|
57
|
+
*/
|
|
58
|
+
width: makeNumericProp(100),
|
|
59
|
+
/**
|
|
60
|
+
* 是否开启列排序
|
|
61
|
+
* 默认值: false
|
|
62
|
+
*/
|
|
63
|
+
sortable: makeBooleanProp(false),
|
|
64
|
+
/**
|
|
65
|
+
* 是否固定本列(固定在左侧,不随水平滚动移动)
|
|
66
|
+
* 默认值: false
|
|
67
|
+
*/
|
|
68
|
+
fixed: makeBooleanProp(false),
|
|
69
|
+
/**
|
|
70
|
+
* 列的对齐方式
|
|
71
|
+
* 可选值: 'left' | 'center' | 'right'
|
|
72
|
+
* 默认值: 'left'
|
|
73
|
+
*/
|
|
74
|
+
align: makeStringProp<AlignType>('left')
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** 表格列 Props 类型 */
|
|
78
|
+
export type TableColumnProps = ExtractPropTypes<typeof tableColumnProps>
|
|
79
|
+
|
|
80
|
+
/** 表格列组件实例类型 */
|
|
81
|
+
export type TableColumnInstance = ComponentPublicInstance<TableColumnProps>
|