stellar-ui-plus 1.16.18
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/README.md +176 -0
- package/common/css/common.scss +19 -0
- package/common/useProps.js +9 -0
- package/components/ste-animate/ATTRIBUTES.md +10 -0
- package/components/ste-animate/README.md +115 -0
- package/components/ste-animate/animate.scss +247 -0
- package/components/ste-animate/config.json +5 -0
- package/components/ste-animate/props.ts +9 -0
- package/components/ste-animate/ste-animate.easycom.json +39 -0
- package/components/ste-animate/ste-animate.scss +113 -0
- package/components/ste-animate/ste-animate.vue +67 -0
- package/components/ste-badge/ATTRIBUTES.md +17 -0
- package/components/ste-badge/README.md +162 -0
- package/components/ste-badge/config.json +5 -0
- package/components/ste-badge/props.ts +17 -0
- package/components/ste-badge/ste-badge.easycom.json +96 -0
- package/components/ste-badge/ste-badge.vue +157 -0
- package/components/ste-barcode/ATTRIBUTES.md +14 -0
- package/components/ste-barcode/README.md +28 -0
- package/components/ste-barcode/config.json +5 -0
- package/components/ste-barcode/encode.ts +317 -0
- package/components/ste-barcode/props.ts +7 -0
- package/components/ste-barcode/ste-barcode.easycom.json +44 -0
- package/components/ste-barcode/ste-barcode.vue +152 -0
- package/components/ste-button/ATTRIBUTES.md +32 -0
- package/components/ste-button/README.md +119 -0
- package/components/ste-button/config.json +5 -0
- package/components/ste-button/props.ts +21 -0
- package/components/ste-button/ste-button.easycom.json +168 -0
- package/components/ste-button/ste-button.vue +275 -0
- package/components/ste-calendar/ATTRIBUTES.md +31 -0
- package/components/ste-calendar/README.md +241 -0
- package/components/ste-calendar/config.json +5 -0
- package/components/ste-calendar/date.ts +110 -0
- package/components/ste-calendar/props.ts +26 -0
- package/components/ste-calendar/ste-calendar.easycom.json +172 -0
- package/components/ste-calendar/ste-calendar.vue +376 -0
- package/components/ste-calendar/useData.ts +30 -0
- package/components/ste-checkbox/ATTRIBUTES.md +25 -0
- package/components/ste-checkbox/README.md +302 -0
- package/components/ste-checkbox/config.json +5 -0
- package/components/ste-checkbox/props.ts +33 -0
- package/components/ste-checkbox/ste-checkbox.easycom.json +151 -0
- package/components/ste-checkbox/ste-checkbox.vue +206 -0
- package/components/ste-checkbox/type.d.ts +2 -0
- package/components/ste-checkbox-group/props.ts +34 -0
- package/components/ste-checkbox-group/ste-checkbox-group.vue +34 -0
- package/components/ste-code-input/ATTRIBUTES.md +22 -0
- package/components/ste-code-input/README.md +56 -0
- package/components/ste-code-input/config.json +5 -0
- package/components/ste-code-input/props.ts +19 -0
- package/components/ste-code-input/ste-code-input.easycom.json +99 -0
- package/components/ste-code-input/ste-code-input.vue +222 -0
- package/components/ste-date-picker/ATTRIBUTES.md +25 -0
- package/components/ste-date-picker/README.md +119 -0
- package/components/ste-date-picker/config.json +5 -0
- package/components/ste-date-picker/props.ts +62 -0
- package/components/ste-date-picker/ste-date-picker.easycom.json +137 -0
- package/components/ste-date-picker/ste-date-picker.vue +290 -0
- package/components/ste-date-picker/types.d.ts +3 -0
- package/components/ste-drag/ATTRIBUTES.md +13 -0
- package/components/ste-drag/README.md +88 -0
- package/components/ste-drag/config.json +5 -0
- package/components/ste-drag/props.ts +10 -0
- package/components/ste-drag/ste-drag.easycom.json +50 -0
- package/components/ste-drag/ste-drag.vue +172 -0
- package/components/ste-dropdown-menu/ATTRIBUTES.md +22 -0
- package/components/ste-dropdown-menu/README.md +325 -0
- package/components/ste-dropdown-menu/config.json +5 -0
- package/components/ste-dropdown-menu/constans.ts +4 -0
- package/components/ste-dropdown-menu/props.ts +30 -0
- package/components/ste-dropdown-menu/ste-dropdown-menu.easycom.json +111 -0
- package/components/ste-dropdown-menu/ste-dropdown-menu.scss +99 -0
- package/components/ste-dropdown-menu/ste-dropdown-menu.vue +223 -0
- package/components/ste-dropdown-menu-item/props.ts +17 -0
- package/components/ste-dropdown-menu-item/ste-dropdown-menu-item.scss +61 -0
- package/components/ste-dropdown-menu-item/ste-dropdown-menu-item.vue +84 -0
- package/components/ste-dropdown-menu-item/type.d.ts +4 -0
- package/components/ste-icon/ATTRIBUTES.md +19 -0
- package/components/ste-icon/README.md +72 -0
- package/components/ste-icon/config.json +5 -0
- package/components/ste-icon/iconfont.css +22 -0
- package/components/ste-icon/props.ts +14 -0
- package/components/ste-icon/ste-icon.easycom.json +71 -0
- package/components/ste-icon/ste-icon.vue +80 -0
- package/components/ste-image/ATTRIBUTES.md +21 -0
- package/components/ste-image/README.md +118 -0
- package/components/ste-image/config.json +5 -0
- package/components/ste-image/props.ts +15 -0
- package/components/ste-image/ste-image.easycom.json +189 -0
- package/components/ste-image/ste-image.vue +146 -0
- package/components/ste-index-item/props.ts +4 -0
- package/components/ste-index-item/ste-index-item.vue +83 -0
- package/components/ste-index-list/ATTRIBUTES.md +15 -0
- package/components/ste-index-list/README.md +138 -0
- package/components/ste-index-list/config.json +5 -0
- package/components/ste-index-list/props.ts +17 -0
- package/components/ste-index-list/ste-index-list.easycom.json +48 -0
- package/components/ste-index-list/ste-index-list.vue +109 -0
- package/components/ste-input/ATTRIBUTES.md +37 -0
- package/components/ste-input/README.md +130 -0
- package/components/ste-input/config.json +5 -0
- package/components/ste-input/props.ts +46 -0
- package/components/ste-input/ste-input.easycom.json +282 -0
- package/components/ste-input/ste-input.scss +124 -0
- package/components/ste-input/ste-input.vue +221 -0
- package/components/ste-loading/ATTRIBUTES.md +11 -0
- package/components/ste-loading/README.md +74 -0
- package/components/ste-loading/config.json +5 -0
- package/components/ste-loading/props.ts +8 -0
- package/components/ste-loading/ste-loading.easycom.json +54 -0
- package/components/ste-loading/ste-loading.vue +127 -0
- package/components/ste-media-preview/ATTRIBUTES.md +20 -0
- package/components/ste-media-preview/README.md +252 -0
- package/components/ste-media-preview/TouchScaleing.ts +117 -0
- package/components/ste-media-preview/config.json +5 -0
- package/components/ste-media-preview/props.ts +12 -0
- package/components/ste-media-preview/ste-media-preview.easycom.json +88 -0
- package/components/ste-media-preview/ste-media-preview.vue +201 -0
- package/components/ste-media-preview/useData.ts +63 -0
- package/components/ste-message-box/ATTRIBUTES.md +6 -0
- package/components/ste-message-box/README.md +222 -0
- package/components/ste-message-box/config.json +5 -0
- package/components/ste-message-box/constants.ts +25 -0
- package/components/ste-message-box/ste-message-box.easycom.json +14 -0
- package/components/ste-message-box/ste-message-box.ts +1 -0
- package/components/ste-message-box/ste-message-box.vue +355 -0
- package/components/ste-message-box/use-message-box.ts +26 -0
- package/components/ste-message-box/useData.ts +56 -0
- package/components/ste-notice-bar/ATTRIBUTES.md +22 -0
- package/components/ste-notice-bar/README.md +124 -0
- package/components/ste-notice-bar/config.json +5 -0
- package/components/ste-notice-bar/props.ts +15 -0
- package/components/ste-notice-bar/ste-notice-bar.easycom.json +109 -0
- package/components/ste-notice-bar/ste-notice-bar.vue +262 -0
- package/components/ste-number-keyboard/ATTRIBUTES.md +31 -0
- package/components/ste-number-keyboard/KeyboardVue.vue +142 -0
- package/components/ste-number-keyboard/README.md +192 -0
- package/components/ste-number-keyboard/config.json +5 -0
- package/components/ste-number-keyboard/props.ts +35 -0
- package/components/ste-number-keyboard/ste-number-keyboard.easycom.json +177 -0
- package/components/ste-number-keyboard/ste-number-keyboard.vue +81 -0
- package/components/ste-number-keyboard/useData.ts +144 -0
- package/components/ste-picker/props.ts +16 -0
- package/components/ste-picker/ste-picker.vue +194 -0
- package/components/ste-popup/ATTRIBUTES.md +24 -0
- package/components/ste-popup/README.md +135 -0
- package/components/ste-popup/config.json +6 -0
- package/components/ste-popup/event.ts +0 -0
- package/components/ste-popup/props.ts +19 -0
- package/components/ste-popup/ste-popup.easycom.json +122 -0
- package/components/ste-popup/ste-popup.vue +253 -0
- package/components/ste-price/ATTRIBUTES.md +26 -0
- package/components/ste-price/README.md +110 -0
- package/components/ste-price/config.json +5 -0
- package/components/ste-price/props.ts +23 -0
- package/components/ste-price/ste-price.easycom.json +154 -0
- package/components/ste-price/ste-price.vue +148 -0
- package/components/ste-progress/ATTRIBUTES.md +17 -0
- package/components/ste-progress/README.md +88 -0
- package/components/ste-progress/config.json +5 -0
- package/components/ste-progress/props.ts +16 -0
- package/components/ste-progress/ste-progress.easycom.json +80 -0
- package/components/ste-progress/ste-progress.vue +135 -0
- package/components/ste-qrcode/ATTRIBUTES.md +16 -0
- package/components/ste-qrcode/README.md +34 -0
- package/components/ste-qrcode/config.json +5 -0
- package/components/ste-qrcode/props.ts +16 -0
- package/components/ste-qrcode/ste-qrcode.easycom.json +56 -0
- package/components/ste-qrcode/ste-qrcode.vue +134 -0
- package/components/ste-qrcode/uqrcode.d.ts +57 -0
- package/components/ste-qrcode/uqrcode.js +34 -0
- package/components/ste-radio/ATTRIBUTES.md +25 -0
- package/components/ste-radio/README.md +260 -0
- package/components/ste-radio/config.json +5 -0
- package/components/ste-radio/props.ts +33 -0
- package/components/ste-radio/ste-radio.easycom.json +150 -0
- package/components/ste-radio/ste-radio.vue +188 -0
- package/components/ste-radio/type.d.ts +2 -0
- package/components/ste-radio-group/props.ts +33 -0
- package/components/ste-radio-group/ste-radio-group.vue +34 -0
- package/components/ste-rate/ATTRIBUTES.md +21 -0
- package/components/ste-rate/README.md +97 -0
- package/components/ste-rate/config.json +5 -0
- package/components/ste-rate/props.ts +16 -0
- package/components/ste-rate/ste-rate.easycom.json +85 -0
- package/components/ste-rate/ste-rate.vue +143 -0
- package/components/ste-read-more/ATTRIBUTES.md +16 -0
- package/components/ste-read-more/README.md +93 -0
- package/components/ste-read-more/config.json +5 -0
- package/components/ste-read-more/props.ts +9 -0
- package/components/ste-read-more/ste-read-more.easycom.json +54 -0
- package/components/ste-read-more/ste-read-more.vue +106 -0
- package/components/ste-rich-text/ATTRIBUTES.md +8 -0
- package/components/ste-rich-text/README.md +26 -0
- package/components/ste-rich-text/config.json +5 -0
- package/components/ste-rich-text/props.ts +8 -0
- package/components/ste-rich-text/ste-rich-text.easycom.json +40 -0
- package/components/ste-rich-text/ste-rich-text.vue +33 -0
- package/components/ste-scroll-to/ATTRIBUTES.md +11 -0
- package/components/ste-scroll-to/README.md +47 -0
- package/components/ste-scroll-to/config.json +5 -0
- package/components/ste-scroll-to/props.ts +17 -0
- package/components/ste-scroll-to/ste-scroll-to.easycom.json +25 -0
- package/components/ste-scroll-to/ste-scroll-to.vue +42 -0
- package/components/ste-scroll-to/useData.ts +214 -0
- package/components/ste-scroll-to-item/ste-scroll-to-item.vue +24 -0
- package/components/ste-search/ATTRIBUTES.md +39 -0
- package/components/ste-search/README.md +232 -0
- package/components/ste-search/config.json +5 -0
- package/components/ste-search/props.ts +124 -0
- package/components/ste-search/ste-search.easycom.json +232 -0
- package/components/ste-search/ste-search.vue +379 -0
- package/components/ste-search/useData.ts +34 -0
- package/components/ste-select/ATTRIBUTES.md +39 -0
- package/components/ste-select/README.md +324 -0
- package/components/ste-select/config.json +5 -0
- package/components/ste-select/datapager.vue +54 -0
- package/components/ste-select/datetime.vue +109 -0
- package/components/ste-select/defaultDate.ts +138 -0
- package/components/ste-select/props.ts +67 -0
- package/components/ste-select/ste-select.easycom.json +287 -0
- package/components/ste-select/ste-select.vue +437 -0
- package/components/ste-select/useData.ts +471 -0
- package/components/ste-signature/ATTRIBUTES.md +18 -0
- package/components/ste-signature/README.md +97 -0
- package/components/ste-signature/config.json +5 -0
- package/components/ste-signature/props.ts +12 -0
- package/components/ste-signature/ste-signature.easycom.json +74 -0
- package/components/ste-signature/ste-signature.vue +183 -0
- package/components/ste-signature/types.d.ts +4 -0
- package/components/ste-slider/ATTRIBUTES.md +25 -0
- package/components/ste-slider/README.md +149 -0
- package/components/ste-slider/config.json +5 -0
- package/components/ste-slider/props.ts +32 -0
- package/components/ste-slider/ste-slider.easycom.json +128 -0
- package/components/ste-slider/ste-slider.scss +150 -0
- package/components/ste-slider/ste-slider.vue +293 -0
- package/components/ste-slider/type.d.ts +4 -0
- package/components/ste-slider/useData.ts +79 -0
- package/components/ste-step/props.ts +10 -0
- package/components/ste-step/ste-step.scss +104 -0
- package/components/ste-step/ste-step.vue +122 -0
- package/components/ste-stepper/ATTRIBUTES.md +33 -0
- package/components/ste-stepper/README.md +172 -0
- package/components/ste-stepper/config.json +5 -0
- package/components/ste-stepper/props.ts +41 -0
- package/components/ste-stepper/ste-stepper.easycom.json +220 -0
- package/components/ste-stepper/ste-stepper.vue +249 -0
- package/components/ste-steps/ATTRIBUTES.md +12 -0
- package/components/ste-steps/README.md +139 -0
- package/components/ste-steps/config.json +5 -0
- package/components/ste-steps/props.ts +18 -0
- package/components/ste-steps/ste-steps.easycom.json +46 -0
- package/components/ste-steps/ste-steps.vue +44 -0
- package/components/ste-sticky/ATTRIBUTES.md +15 -0
- package/components/ste-sticky/README.md +56 -0
- package/components/ste-sticky/config.json +5 -0
- package/components/ste-sticky/props.ts +7 -0
- package/components/ste-sticky/ste-sticky.easycom.json +48 -0
- package/components/ste-sticky/ste-sticky.vue +88 -0
- package/components/ste-swipe-action/ATTRIBUTES.md +16 -0
- package/components/ste-swipe-action/README.md +195 -0
- package/components/ste-swipe-action/config.json +5 -0
- package/components/ste-swipe-action/props.ts +23 -0
- package/components/ste-swipe-action/ste-swipe-action.easycom.json +74 -0
- package/components/ste-swipe-action/ste-swipe-action.vue +138 -0
- package/components/ste-swipe-action/useData.ts +204 -0
- package/components/ste-swipe-action-group/ATTRIBUTES.md +17 -0
- package/components/ste-swipe-action-group/props.ts +22 -0
- package/components/ste-swipe-action-group/ste-swipe-action-group.easycom.json +90 -0
- package/components/ste-swipe-action-group/ste-swipe-action-group.vue +57 -0
- package/components/ste-swiper/ATTRIBUTES.md +24 -0
- package/components/ste-swiper/README.md +156 -0
- package/components/ste-swiper/config.json +5 -0
- package/components/ste-swiper/props.ts +41 -0
- package/components/ste-swiper/ste-swiper.easycom.json +123 -0
- package/components/ste-swiper/ste-swiper.vue +98 -0
- package/components/ste-swiper/useData.ts +365 -0
- package/components/ste-swiper-item/ste-swiper-item.vue +41 -0
- package/components/ste-switch/ATTRIBUTES.md +17 -0
- package/components/ste-switch/README.md +105 -0
- package/components/ste-switch/config.json +5 -0
- package/components/ste-switch/props.ts +9 -0
- package/components/ste-switch/ste-switch.easycom.json +60 -0
- package/components/ste-switch/ste-switch.vue +96 -0
- package/components/ste-tab/ATTRIBUTES.md +14 -0
- package/components/ste-tab/props.ts +25 -0
- package/components/ste-tab/ste-tab.easycom.json +56 -0
- package/components/ste-tab/ste-tab.vue +26 -0
- package/components/ste-table/ATTRIBUTES.md +41 -0
- package/components/ste-table/README.md +638 -0
- package/components/ste-table/config.json +5 -0
- package/components/ste-table/props.ts +72 -0
- package/components/ste-table/ste-table.easycom.json +188 -0
- package/components/ste-table/ste-table.vue +427 -0
- package/components/ste-table/types.d.ts +3 -0
- package/components/ste-table/useData.ts +233 -0
- package/components/ste-table/utils.ts +11 -0
- package/components/ste-table-column/checkbox-icon.vue +35 -0
- package/components/ste-table-column/common.scss +52 -0
- package/components/ste-table-column/props.ts +18 -0
- package/components/ste-table-column/radio-icon.vue +99 -0
- package/components/ste-table-column/ste-table-column.vue +169 -0
- package/components/ste-table-column/var.scss +1 -0
- package/components/ste-tabs/ATTRIBUTES.md +52 -0
- package/components/ste-tabs/README.md +165 -0
- package/components/ste-tabs/config.json +5 -0
- package/components/ste-tabs/props.ts +133 -0
- package/components/ste-tabs/ste-tabs.easycom.json +278 -0
- package/components/ste-tabs/ste-tabs.vue +447 -0
- package/components/ste-tabs/useData.ts +364 -0
- package/components/ste-text/ATTRIBUTES.md +9 -0
- package/components/ste-text/README.md +58 -0
- package/components/ste-text/config.json +6 -0
- package/components/ste-text/props.ts +10 -0
- package/components/ste-text/ste-text.easycom.json +30 -0
- package/components/ste-text/ste-text.vue +46 -0
- package/components/ste-toast/ATTRIBUTES.md +15 -0
- package/components/ste-toast/README.md +222 -0
- package/components/ste-toast/config.json +5 -0
- package/components/ste-toast/props.ts +7 -0
- package/components/ste-toast/ste-toast.easycom.json +73 -0
- package/components/ste-toast/ste-toast.vue +209 -0
- package/components/ste-toast/use-toast.ts +26 -0
- package/components/ste-touch-swipe/ATTRIBUTES.md +18 -0
- package/components/ste-touch-swipe/README.md +89 -0
- package/components/ste-touch-swipe/TouchEvent.ts +79 -0
- package/components/ste-touch-swipe/config.json +5 -0
- package/components/ste-touch-swipe/props.ts +23 -0
- package/components/ste-touch-swipe/ste-touch-swipe.easycom.json +83 -0
- package/components/ste-touch-swipe/ste-touch-swipe.vue +283 -0
- package/components/ste-touch-swipe/useData.ts +51 -0
- package/components/ste-touch-swipe-item/ste-touch-swipe-item.vue +32 -0
- package/components/ste-tour/ATTRIBUTES.md +26 -0
- package/components/ste-tour/README.md +134 -0
- package/components/ste-tour/config.json +5 -0
- package/components/ste-tour/props.ts +45 -0
- package/components/ste-tour/ste-tour.easycom.json +120 -0
- package/components/ste-tour/ste-tour.vue +152 -0
- package/components/ste-tour/useData.ts +220 -0
- package/components/ste-tree/ATTRIBUTES.md +19 -0
- package/components/ste-tree/README.md +217 -0
- package/components/ste-tree/config.json +5 -0
- package/components/ste-tree/props.ts +24 -0
- package/components/ste-tree/ste-tree.easycom.json +106 -0
- package/components/ste-tree/ste-tree.vue +140 -0
- package/components/ste-tree/useData.ts +219 -0
- package/components/ste-upload/ATTRIBUTES.md +35 -0
- package/components/ste-upload/README.md +208 -0
- package/components/ste-upload/ReadFile.ts +305 -0
- package/components/ste-upload/config.json +5 -0
- package/components/ste-upload/props.ts +25 -0
- package/components/ste-upload/ste-upload.easycom.json +267 -0
- package/components/ste-upload/ste-upload.vue +386 -0
- package/components/ste-upload/useData.ts +46 -0
- package/components/ste-video/ATTRIBUTES.md +34 -0
- package/components/ste-video/README.md +48 -0
- package/components/ste-video/config.json +5 -0
- package/components/ste-video/props.ts +86 -0
- package/components/ste-video/ste-video.easycom.json +226 -0
- package/components/ste-video/ste-video.scss +201 -0
- package/components/ste-video/ste-video.vue +390 -0
- package/components/ste-video/types.d.ts +4 -0
- package/components/ste-video/useData.ts +140 -0
- package/composables.ts +2 -0
- package/config/color.ts +16 -0
- package/config/index.ts +48 -0
- package/index.ts +118 -0
- package/package.json +22 -0
- package/store/color.ts +24 -0
- package/store/index.ts +12 -0
- package/store/message-box.ts +54 -0
- package/store/toast.ts +50 -0
- package/types/components.d.ts +124 -0
- package/types/event.d.ts +51 -0
- package/types/index.d.ts +112 -0
- package/types/refComponents.d.ts +118 -0
- package/utils/Color.ts +66 -0
- package/utils/System.ts +114 -0
- package/utils/mixin.ts +122 -0
- package/utils/utils.ts +520 -0
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import type { CSSProperties, SetupContext } from 'vue'
|
|
2
|
+
import { nextTick, ref } from 'vue'
|
|
3
|
+
import type { TableColumnProps } from '../ste-table-column/props'
|
|
4
|
+
import utils from '../../utils/utils'
|
|
5
|
+
import type { Obj } from '../../types'
|
|
6
|
+
import type { AllStateType, SelectColType } from './types'
|
|
7
|
+
import type { TableEmits, TableProps } from './props'
|
|
8
|
+
import { getStyleOrClass } from './utils'
|
|
9
|
+
|
|
10
|
+
export default function useData(props: TableProps, emits: SetupContext<TableEmits>['emit']) {
|
|
11
|
+
const tableData = ref<Obj[]>([])
|
|
12
|
+
|
|
13
|
+
const columns = ref<TableColumnProps[]>([])
|
|
14
|
+
const sumData = ref([])
|
|
15
|
+
const currentRow = ref()
|
|
16
|
+
|
|
17
|
+
const checkStatesSet = ref(new Set<number>())
|
|
18
|
+
const checkStates = ref<number[]>([])
|
|
19
|
+
const canCheckStates = ref<number[]>([])
|
|
20
|
+
|
|
21
|
+
const checkAllState = ref<AllStateType>('none')
|
|
22
|
+
const selectType = ref<SelectColType>('checkbox')
|
|
23
|
+
|
|
24
|
+
function calcSum() {
|
|
25
|
+
if (!props.summaryMethod)
|
|
26
|
+
return
|
|
27
|
+
sumData.value = props.summaryMethod({ columns: columns.value, data: tableData.value })
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function loadSelectType() {
|
|
31
|
+
columns.value.forEach((e) => {
|
|
32
|
+
if (e.type)
|
|
33
|
+
selectType.value = e.type as SelectColType
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function loadCanCheckArr() {
|
|
38
|
+
const tmp: number[] = []
|
|
39
|
+
tableData.value.forEach((e, index) => {
|
|
40
|
+
const selectFlag = props.selectable ? props.selectable(e, index) : true
|
|
41
|
+
const readonlyFlag = props.readable ? !props.readable(e, index) : true
|
|
42
|
+
|
|
43
|
+
if (selectFlag && readonlyFlag)
|
|
44
|
+
tmp.push(index)
|
|
45
|
+
})
|
|
46
|
+
canCheckStates.value = tmp
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function initSelection() {
|
|
50
|
+
loadCanCheckArr()
|
|
51
|
+
checkStates.value = checkStates.value.filter(e => canCheckStates.value.includes(e))
|
|
52
|
+
calcAllState()
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function calcAllState() {
|
|
56
|
+
// 处理当前全选框的状态
|
|
57
|
+
if (checkStates.value.length > 0) {
|
|
58
|
+
if (canCheckStates.value.length === checkStates.value.length)
|
|
59
|
+
checkAllState.value = 'all'
|
|
60
|
+
else checkAllState.value = 'indeterminate'
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
checkAllState.value = 'none'
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function changeCheckAll() {
|
|
68
|
+
if (checkAllState.value !== 'all') {
|
|
69
|
+
emits(
|
|
70
|
+
'selectAll',
|
|
71
|
+
canCheckStates.value.map(e => tableData.value[e]),
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
emits('selectAll', [])
|
|
76
|
+
}
|
|
77
|
+
toggleAllSelection()
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// column组件更改Check状态
|
|
81
|
+
function handleCheck(row: Obj, isEmit = true) {
|
|
82
|
+
const rowIndex = row.rowIndex
|
|
83
|
+
const state = !checkStatesSet.value.has(rowIndex)
|
|
84
|
+
if (selectType.value === 'radio') {
|
|
85
|
+
checkStatesSet.value = new Set()
|
|
86
|
+
checkStatesSet.value.add(rowIndex)
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
if (state)
|
|
90
|
+
checkStatesSet.value.add(rowIndex)
|
|
91
|
+
else checkStatesSet.value.delete(rowIndex)
|
|
92
|
+
}
|
|
93
|
+
checkStates.value = Array.from(checkStatesSet.value)
|
|
94
|
+
|
|
95
|
+
isEmit && emits('select', getSelection(), row)
|
|
96
|
+
// this.currentRow = row;
|
|
97
|
+
calcAllState()
|
|
98
|
+
// this.$forceUpdate();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function cellClick(row: Obj, column: TableColumnProps, event: Event) {
|
|
102
|
+
emits('cellClick', row, column, event)
|
|
103
|
+
}
|
|
104
|
+
function rowClick(row: Obj, event: Event) {
|
|
105
|
+
currentRow.value = row
|
|
106
|
+
emits('rowClick', row, event)
|
|
107
|
+
}
|
|
108
|
+
function headerClick(column: TableColumnProps, event: Event) {
|
|
109
|
+
emits('headerClick', column, event)
|
|
110
|
+
}
|
|
111
|
+
function handleScrollToLower() {
|
|
112
|
+
emits('scrollToLower')
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// ***自定义class和style相关***
|
|
116
|
+
function getHeaderRowClass() {
|
|
117
|
+
const classes = [getStyleOrClass(props.headerRowClassName)]
|
|
118
|
+
return classes.join(' ')
|
|
119
|
+
}
|
|
120
|
+
function getHeaderRowStyle() {
|
|
121
|
+
return getStyleOrClass<object>(props.headerRowStyle)
|
|
122
|
+
}
|
|
123
|
+
function getHeaderCellClass(column: TableColumnProps, columnIndex: number) {
|
|
124
|
+
const classArr = []
|
|
125
|
+
if (column.headerAlign && column.headerAlign !== 'left')
|
|
126
|
+
classArr.push(`align-${column.headerAlign}`)
|
|
127
|
+
else if (column.align && column.align !== 'left')
|
|
128
|
+
classArr.push(`align-${column.align}`)
|
|
129
|
+
|
|
130
|
+
classArr.push(getStyleOrClass(props.headerCellClassName, { columnIndex, column }))
|
|
131
|
+
return classArr.join(' ')
|
|
132
|
+
}
|
|
133
|
+
function getHeaderCellStyle(column: TableColumnProps, columnIndex: number, isProp = false) {
|
|
134
|
+
if (!isProp) {
|
|
135
|
+
const style = {} as CSSProperties
|
|
136
|
+
if (column.width)
|
|
137
|
+
// style.width = utils.addUnit(column.width)
|
|
138
|
+
// style.flexBasis = utils.addUnit(column.width);
|
|
139
|
+
style.flex = `0 1 ${utils.addUnit(column.width)}`
|
|
140
|
+
|
|
141
|
+
if (column.minWidth)
|
|
142
|
+
style.minWidth = utils.addUnit(column.minWidth)
|
|
143
|
+
|
|
144
|
+
return style
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
return getStyleOrClass<object>(props.headerCellStyle, { columnIndex, column })
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
function getRowClass(row: Obj, rowIndex: number) {
|
|
151
|
+
const classArr: any[] = [`row-${rowIndex}`]
|
|
152
|
+
if (props.highlightCurrentRow && utils.deepEqual(row, currentRow.value, ['rowIndex', 'colIndex']))
|
|
153
|
+
classArr.push('current-row')
|
|
154
|
+
|
|
155
|
+
if (props.highlightSelectionRow && checkStatesSet.value.has(rowIndex))
|
|
156
|
+
classArr.push('selection-row')
|
|
157
|
+
|
|
158
|
+
// const t = getStyleOrClass(props.rowClassName, { row, rowIndex })
|
|
159
|
+
classArr.push(getStyleOrClass(props.rowClassName, { row, rowIndex }))
|
|
160
|
+
return classArr.join(' ')
|
|
161
|
+
}
|
|
162
|
+
function getRowStyle(row: Obj, rowIndex: number) {
|
|
163
|
+
return getStyleOrClass(props.rowStyle, { row, rowIndex })
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// ***Table Methods 方法***
|
|
167
|
+
// 获取当前选择的数据
|
|
168
|
+
function getSelection() {
|
|
169
|
+
return checkStates.value.map(e => tableData.value[e])
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// 清空选择项
|
|
173
|
+
function clearSelection() {
|
|
174
|
+
checkStatesSet.value.clear()
|
|
175
|
+
checkStates.value = Array.from(checkStatesSet.value)
|
|
176
|
+
checkAllState.value = 'none'
|
|
177
|
+
}
|
|
178
|
+
// 切换某行的选中状态
|
|
179
|
+
function toggleRowSelection(row: Obj, isTriggerSelectEvent = true) {
|
|
180
|
+
nextTick(() => {
|
|
181
|
+
const index = tableData.value.findIndex(e => utils.deepEqual(row, e, ['rowIndex', 'colIndex']))
|
|
182
|
+
if (canCheckStates.value.indexOf(index) <= -1)
|
|
183
|
+
return
|
|
184
|
+
row.rowIndex = index
|
|
185
|
+
handleCheck(row, isTriggerSelectEvent)
|
|
186
|
+
})
|
|
187
|
+
}
|
|
188
|
+
// 切换全选的状态
|
|
189
|
+
function toggleAllSelection() {
|
|
190
|
+
if (checkAllState.value === 'all') {
|
|
191
|
+
clearSelection()
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
canCheckStates.value.forEach((e) => {
|
|
195
|
+
checkStatesSet.value.add(e)
|
|
196
|
+
})
|
|
197
|
+
checkStates.value = Array.from(checkStatesSet.value)
|
|
198
|
+
checkAllState.value = 'all'
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return {
|
|
203
|
+
tableData,
|
|
204
|
+
columns,
|
|
205
|
+
sumData,
|
|
206
|
+
currentRow,
|
|
207
|
+
checkStatesSet,
|
|
208
|
+
checkStates,
|
|
209
|
+
canCheckStates,
|
|
210
|
+
checkAllState,
|
|
211
|
+
selectType,
|
|
212
|
+
calcSum,
|
|
213
|
+
loadSelectType,
|
|
214
|
+
loadCanCheckArr,
|
|
215
|
+
getHeaderRowStyle,
|
|
216
|
+
getHeaderRowClass,
|
|
217
|
+
getHeaderCellStyle,
|
|
218
|
+
getHeaderCellClass,
|
|
219
|
+
headerClick,
|
|
220
|
+
changeCheckAll,
|
|
221
|
+
handleScrollToLower,
|
|
222
|
+
getRowStyle,
|
|
223
|
+
getRowClass,
|
|
224
|
+
initSelection,
|
|
225
|
+
rowClick,
|
|
226
|
+
handleCheck,
|
|
227
|
+
cellClick,
|
|
228
|
+
toggleRowSelection,
|
|
229
|
+
toggleAllSelection,
|
|
230
|
+
clearSelection,
|
|
231
|
+
getSelection,
|
|
232
|
+
}
|
|
233
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type StyleOrClassFunction<T> = (params: object) => T
|
|
2
|
+
type StyleOrClass<T> = T | StyleOrClassFunction<T> | undefined
|
|
3
|
+
|
|
4
|
+
function getStyleOrClass<T extends string | object>(fun: StyleOrClass<T>, params: object = {}): T | undefined {
|
|
5
|
+
if (typeof fun === 'function' && fun instanceof Function)
|
|
6
|
+
return (fun as StyleOrClassFunction<T>)(params)
|
|
7
|
+
else
|
|
8
|
+
return fun
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { getStyleOrClass }
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { SELECTION_COLOR_CONFIG } from '../ste-table/props';
|
|
3
|
+
import type { PropType } from 'vue';
|
|
4
|
+
|
|
5
|
+
const CHECK_ICON_SIZE = 36;
|
|
6
|
+
const props = defineProps({
|
|
7
|
+
checked: {
|
|
8
|
+
type: Boolean,
|
|
9
|
+
default: false,
|
|
10
|
+
},
|
|
11
|
+
disabled: {
|
|
12
|
+
type: Boolean,
|
|
13
|
+
default: false,
|
|
14
|
+
},
|
|
15
|
+
readonly: {
|
|
16
|
+
type: Boolean,
|
|
17
|
+
default: false,
|
|
18
|
+
},
|
|
19
|
+
iconColorConfig: {
|
|
20
|
+
type: Object as PropType<typeof SELECTION_COLOR_CONFIG>,
|
|
21
|
+
default: () => SELECTION_COLOR_CONFIG,
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<template>
|
|
27
|
+
<view class="ste-table-checkbox-icon">
|
|
28
|
+
<ste-icon code="" :color="iconColorConfig.disabled || SELECTION_COLOR_CONFIG.disabled" :size="CHECK_ICON_SIZE" v-if="disabled" />
|
|
29
|
+
<ste-icon code="" :color="iconColorConfig.readonly || SELECTION_COLOR_CONFIG.readonly" :size="CHECK_ICON_SIZE" v-else-if="props.readonly" />
|
|
30
|
+
<template v-else>
|
|
31
|
+
<ste-icon code="" :color="iconColorConfig.main || SELECTION_COLOR_CONFIG.main" :size="CHECK_ICON_SIZE" v-if="checked" />
|
|
32
|
+
<ste-icon code="" :color="iconColorConfig.unSelected || SELECTION_COLOR_CONFIG.unSelected" :size="CHECK_ICON_SIZE" v-else />
|
|
33
|
+
</template>
|
|
34
|
+
</view>
|
|
35
|
+
</template>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
@mixin cell {
|
|
2
|
+
flex: 1;
|
|
3
|
+
// padding: 24rpx 32rpx;
|
|
4
|
+
border-bottom: $default-border;
|
|
5
|
+
text-align: left;
|
|
6
|
+
min-height: 80rpx;
|
|
7
|
+
font-size: var(--font-size-24, 24rpx);
|
|
8
|
+
// vertical-align: middle;
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.cell-box {
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
padding: 24rpx 32rpx;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&.border {
|
|
20
|
+
border-right: $default-border;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&.selection {
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&.align-text-center {
|
|
27
|
+
text-align: center;
|
|
28
|
+
.cell-box {
|
|
29
|
+
text-align: center;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&.align-text-right {
|
|
34
|
+
text-align: right;
|
|
35
|
+
.cell-box {
|
|
36
|
+
text-align: right;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&.align-center {
|
|
41
|
+
justify-content: center;
|
|
42
|
+
.cell-box {
|
|
43
|
+
justify-content: center;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
&.align-right {
|
|
48
|
+
justify-content: flex-end;
|
|
49
|
+
.cell-box {
|
|
50
|
+
justify-content: flex-end;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ExtractPropTypes, PropType } from 'vue'
|
|
2
|
+
import type { AlignType } from '../../types'
|
|
3
|
+
import type { SelectColType } from '../ste-table/types'
|
|
4
|
+
|
|
5
|
+
const tableColumnProps = {
|
|
6
|
+
type: { type: String as PropType<SelectColType>, default: '' },
|
|
7
|
+
customKey: { type: String, default: '' },
|
|
8
|
+
label: { type: String, default: '' },
|
|
9
|
+
prop: { type: String, default: '' },
|
|
10
|
+
width: { type: [String, Number], default: '' },
|
|
11
|
+
minWidth: { type: String, default: '' },
|
|
12
|
+
align: { type: String as PropType<AlignType>, default: 'left' },
|
|
13
|
+
headerAlign: { type: String as PropType<AlignType>, default: 'left' },
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type TableColumnProps = ExtractPropTypes<typeof tableColumnProps>
|
|
17
|
+
|
|
18
|
+
export default tableColumnProps
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { computed } from 'vue';
|
|
3
|
+
import { SELECTION_COLOR_CONFIG } from '../ste-table/props';
|
|
4
|
+
import type { PropType } from 'vue';
|
|
5
|
+
import utils from '../../utils/utils';
|
|
6
|
+
|
|
7
|
+
const props = defineProps({
|
|
8
|
+
checked: {
|
|
9
|
+
type: Boolean,
|
|
10
|
+
default: false,
|
|
11
|
+
},
|
|
12
|
+
disabled: {
|
|
13
|
+
type: Boolean,
|
|
14
|
+
default: false,
|
|
15
|
+
},
|
|
16
|
+
readonly: {
|
|
17
|
+
type: Boolean,
|
|
18
|
+
default: false,
|
|
19
|
+
},
|
|
20
|
+
iconColorConfig: {
|
|
21
|
+
type: Object as PropType<typeof SELECTION_COLOR_CONFIG>,
|
|
22
|
+
default: () => SELECTION_COLOR_CONFIG,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const cmpRootClass = computed(() => {
|
|
27
|
+
let classArr = [];
|
|
28
|
+
if (props.checked) {
|
|
29
|
+
classArr.push('checked');
|
|
30
|
+
}
|
|
31
|
+
if (props.disabled) {
|
|
32
|
+
classArr.push('disabled');
|
|
33
|
+
}
|
|
34
|
+
if (props.readonly) {
|
|
35
|
+
classArr.push('readonly');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return classArr.join(' ');
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const cmpRootStyle = computed(() => {
|
|
42
|
+
return {
|
|
43
|
+
'--main-color': props.iconColorConfig.main || SELECTION_COLOR_CONFIG.main,
|
|
44
|
+
'--main-outer-color': utils.Color.formatColor(props.iconColorConfig.main || SELECTION_COLOR_CONFIG.main, 0.2),
|
|
45
|
+
'--disabled-color': props.iconColorConfig.disabled || SELECTION_COLOR_CONFIG.disabled,
|
|
46
|
+
'--un-selected-color': props.iconColorConfig.unSelected || SELECTION_COLOR_CONFIG.unSelected,
|
|
47
|
+
'--readonly-color': props.iconColorConfig.readonly || SELECTION_COLOR_CONFIG.readonly,
|
|
48
|
+
'--readonly-outer-color': utils.Color.formatColor(props.iconColorConfig.readonly || SELECTION_COLOR_CONFIG.readonly, 0.2),
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<template>
|
|
54
|
+
<view class="radio-icon-root" :class="[cmpRootClass]" :style="cmpRootStyle">
|
|
55
|
+
<view class="icon-1"></view>
|
|
56
|
+
</view>
|
|
57
|
+
</template>
|
|
58
|
+
|
|
59
|
+
<style lang="scss" scoped>
|
|
60
|
+
.radio-icon-root {
|
|
61
|
+
width: 32rpx;
|
|
62
|
+
height: 32rpx;
|
|
63
|
+
|
|
64
|
+
border-radius: 50%;
|
|
65
|
+
border: 2rpx solid var(--un-selected-color);
|
|
66
|
+
position: relative;
|
|
67
|
+
|
|
68
|
+
&.checked {
|
|
69
|
+
border: none;
|
|
70
|
+
background-color: var(--main-outer-color);
|
|
71
|
+
.icon-1 {
|
|
72
|
+
background-color: var(--main-color);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
&.readonly {
|
|
77
|
+
border: none;
|
|
78
|
+
background-color: var(--readonly-outer-color);
|
|
79
|
+
.icon-1 {
|
|
80
|
+
background-color: var(--readonly-color);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
&.disabled {
|
|
85
|
+
border: none;
|
|
86
|
+
background-color: var(--disabled-color);
|
|
87
|
+
}
|
|
88
|
+
.icon-1 {
|
|
89
|
+
width: 16rpx;
|
|
90
|
+
height: 16rpx;
|
|
91
|
+
border-radius: 50%;
|
|
92
|
+
|
|
93
|
+
position: absolute;
|
|
94
|
+
left: 50%;
|
|
95
|
+
top: 50%;
|
|
96
|
+
transform: translate(-50%, -50%);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
</style>
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { computed, ref, type CSSProperties, defineOptions } from 'vue';
|
|
3
|
+
import type { Obj } from '../../types';
|
|
4
|
+
import propsData from './props';
|
|
5
|
+
import utils from '../../utils/utils';
|
|
6
|
+
import { getStyleOrClass } from '../ste-table/utils';
|
|
7
|
+
import { useInject } from '../../utils/mixin';
|
|
8
|
+
import { TABLE_KEY, SELECTION_COLOR_CONFIG, type TableProps } from '../ste-table/props';
|
|
9
|
+
import CheckBoxIcon from './checkbox-icon.vue';
|
|
10
|
+
import RadioIcon from './radio-icon.vue';
|
|
11
|
+
|
|
12
|
+
const componentName = `ste-table-column`;
|
|
13
|
+
defineOptions({
|
|
14
|
+
name: componentName,
|
|
15
|
+
options: {
|
|
16
|
+
virtualHost: true,
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const props = defineProps(propsData);
|
|
21
|
+
|
|
22
|
+
const Parent = useInject<{ props: Required<TableProps>; checkStates: globalThis.Ref<number[]>; handleCheck: (...args: any[]) => void; cellClick: (...args: any[]) => void }>(TABLE_KEY);
|
|
23
|
+
const parent = Parent.parent;
|
|
24
|
+
const parentProps = Parent.parent?.props as TableProps;
|
|
25
|
+
|
|
26
|
+
const row = ref<Obj>({});
|
|
27
|
+
const selectionIconColor = ref<typeof SELECTION_COLOR_CONFIG>(parentProps.selectionIconColor);
|
|
28
|
+
|
|
29
|
+
defineExpose({ row });
|
|
30
|
+
|
|
31
|
+
const cmpRootStyle = computed(() => {
|
|
32
|
+
let style: CSSProperties = {};
|
|
33
|
+
if (props.width) {
|
|
34
|
+
// style.width = utils.addUnit(props.width);
|
|
35
|
+
// style.flexBasis = utils.addUnit(props.width);
|
|
36
|
+
// style.flexGrow = 0;
|
|
37
|
+
style.flex = `0 1 ${utils.addUnit(props.width)}`;
|
|
38
|
+
}
|
|
39
|
+
if (props.minWidth) {
|
|
40
|
+
style.minWidth = utils.addUnit(props.minWidth);
|
|
41
|
+
}
|
|
42
|
+
return style;
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const cmpCellStyle = computed(() => {
|
|
46
|
+
const cellClassParam = {
|
|
47
|
+
column: props,
|
|
48
|
+
columnIndex: row.value.colIndex,
|
|
49
|
+
row: row.value.row,
|
|
50
|
+
rowIndex: row.value.rowIndex,
|
|
51
|
+
};
|
|
52
|
+
return getStyleOrClass<object>(parentProps.cellStyle, cellClassParam);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const cmpRootClass = computed(() => {
|
|
56
|
+
let classArr = [];
|
|
57
|
+
classArr.push(props.type);
|
|
58
|
+
|
|
59
|
+
if (props.align && props.align !== 'left') {
|
|
60
|
+
classArr.push('align-' + props.align);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (parentProps.border) {
|
|
64
|
+
classArr.push('border');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const cellClassParam = {
|
|
68
|
+
column: props,
|
|
69
|
+
columnIndex: row.value.colIndex,
|
|
70
|
+
row: row.value.row,
|
|
71
|
+
rowIndex: row.value.rowIndex,
|
|
72
|
+
};
|
|
73
|
+
classArr.push(getStyleOrClass<string>(parentProps.cellClassName as any, cellClassParam));
|
|
74
|
+
|
|
75
|
+
return classArr.join(' ');
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const cmpShowCheck = computed(() => {
|
|
79
|
+
if (!parent?.checkStates.value || parent.checkStates.value.length == 0) return false;
|
|
80
|
+
let item = parent.checkStates.value.find((e: number) => e == row.value.rowIndex);
|
|
81
|
+
if (item != undefined) {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
return false;
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const cmpDisableCheck = computed(() => {
|
|
88
|
+
if (parentProps.selectable && props.type) {
|
|
89
|
+
return !parentProps.selectable(row.value, row.value.rowIndex);
|
|
90
|
+
}
|
|
91
|
+
return false;
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const cmpReadonlyCheck = computed(() => {
|
|
95
|
+
if (parentProps.readable && props.type) {
|
|
96
|
+
return parentProps.readable(row.value, row.value.rowIndex);
|
|
97
|
+
}
|
|
98
|
+
return false;
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
function changeCheck(this: any) {
|
|
102
|
+
if (!cmpDisableCheck.value && !cmpReadonlyCheck.value) {
|
|
103
|
+
parent?.handleCheck(row.value);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function cellText(this: any) {
|
|
108
|
+
if (parentProps.formatter) {
|
|
109
|
+
let text = parentProps.formatter(row.value, props.customKey);
|
|
110
|
+
if (!text) {
|
|
111
|
+
text = row.value[props.prop];
|
|
112
|
+
}
|
|
113
|
+
return text;
|
|
114
|
+
} else {
|
|
115
|
+
if (row.value[props.prop]) {
|
|
116
|
+
return row.value[props.prop];
|
|
117
|
+
} else {
|
|
118
|
+
return parentProps.emptyText || '-';
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function cellClick(this: any, event: Event) {
|
|
124
|
+
parent?.cellClick(row.value, props, event);
|
|
125
|
+
// 扩大选中热区
|
|
126
|
+
if (props.type == 'checkbox' || props.type == 'radio') {
|
|
127
|
+
changeCheck();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
</script>
|
|
131
|
+
|
|
132
|
+
<template>
|
|
133
|
+
<view class="ste-table-cell" :class="[cmpRootClass]" :style="[cmpRootStyle, cmpCellStyle as CSSProperties]" @click="cellClick">
|
|
134
|
+
<template v-if="type">
|
|
135
|
+
<view class="cell-box" v-if="type == 'checkbox'" @click.stop="changeCheck">
|
|
136
|
+
<check-box-icon :disabled="cmpDisableCheck" :readonly="cmpReadonlyCheck" :checked="cmpShowCheck" :icon-color-config="selectionIconColor" />
|
|
137
|
+
</view>
|
|
138
|
+
<view class="cell-box" v-if="type == 'radio'" @click.stop="changeCheck">
|
|
139
|
+
<radio-icon :disabled="cmpDisableCheck" :checked="cmpShowCheck" :readonly="cmpReadonlyCheck" :icon-color-config="selectionIconColor" />
|
|
140
|
+
</view>
|
|
141
|
+
<view class="cell-box" v-if="type == 'index'">
|
|
142
|
+
{{ row.rowIndex + 1 }}
|
|
143
|
+
</view>
|
|
144
|
+
</template>
|
|
145
|
+
<template v-else>
|
|
146
|
+
<slot v-if="row[prop] || !$slots.empty">
|
|
147
|
+
<view class="cell-box">
|
|
148
|
+
{{ cellText() }}
|
|
149
|
+
</view>
|
|
150
|
+
</slot>
|
|
151
|
+
<view class="cell-box" v-else>
|
|
152
|
+
<slot name="empty"><text>暂无数据</text></slot>
|
|
153
|
+
</view>
|
|
154
|
+
</template>
|
|
155
|
+
</view>
|
|
156
|
+
</template>
|
|
157
|
+
|
|
158
|
+
<style lang="scss" scoped>
|
|
159
|
+
.ste-table-cell {
|
|
160
|
+
@import './var.scss';
|
|
161
|
+
@import './common.scss';
|
|
162
|
+
@include cell;
|
|
163
|
+
|
|
164
|
+
&.row-span {
|
|
165
|
+
padding-top: 0;
|
|
166
|
+
padding-bottom: 0;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
$default-border: 2rpx solid #ebebeb;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#### Props
|
|
2
|
+
| 属性名 | 说明 | 类型 | 默认值 | 可选值 | 支持版本 |
|
|
3
|
+
| ----- | ----- | --- | ------- | ------ | -------- |
|
|
4
|
+
| `active` | 当前激活的选项支持v-model:active双向绑定(类型为number时绑定index,类型为string时绑定name) | `number / string` | `0` | - | - |
|
|
5
|
+
| `type` | 样式风格类型 | `string` | `line` | `line`:线型<br/>`card`:卡片型 | - |
|
|
6
|
+
| `showImage` | 是否显示图片 | `boolean` | `false` | - | - |
|
|
7
|
+
| `showTitle` | 是否显示主标题 | `boolean` | `true` | - | - |
|
|
8
|
+
| `showSubtitle` | 是否显示副标题 | `boolean` | `false` | - | - |
|
|
9
|
+
| `color` | 主题色(滑块颜色,边框颜色,选中的背景色,激活下拉列表中选项颜色) | `string` | `#0090FF` | - | - |
|
|
10
|
+
| `background` | 背景 | `string` | - | - | - |
|
|
11
|
+
| `radius` | 圆角,单位RPX | `number / string` | `0` | - | - |
|
|
12
|
+
| `duration` | 动画时间,单位秒,设置为 0 可以禁用动画 | `number / string` | `0.3` | - | - |
|
|
13
|
+
| `showLine` | 底部条是否显示(显示副标题的情况下会自动隐藏) | `boolean` | `true` | - | - |
|
|
14
|
+
| `lineWidth` | 底部条宽度,默认单位rpx | `number / string` | `52` | - | - |
|
|
15
|
+
| `lineHeight` | 底部条高度,默认单位rpx | `number / string` | `6` | - | - |
|
|
16
|
+
| `border` | 是否显示标签栏外边框,仅在 type=line 时有效 | `boolean` | `false` | - | - |
|
|
17
|
+
| `ellipsis` | 是否省略过长的标题文字 | `boolean` | `false` | - | - |
|
|
18
|
+
| `tabWidth` | tab内容的宽度 | `number / string` | `auto` | - | - |
|
|
19
|
+
| `tabPadding` | 选项内边距,默认24,单位rpx | `number / string` | `24` | - | - |
|
|
20
|
+
| `tabSpace` | tab间距rpx | `number / string` | `0` | - | - |
|
|
21
|
+
| `divideNum` | tab等分数量,设置为 0 ,则不等分 | `number / string` | `4` | - | - |
|
|
22
|
+
| `sticky` | 是否使用粘性布局 | `boolean` | `false` | - | - |
|
|
23
|
+
| `offsetTop` | 粘性布局下吸顶时与顶部的距离,单位rpx | `number / string` | `0` | - | - |
|
|
24
|
+
| `swipeable` | 是否开启手势左右滑动切换 | `boolean` | `false` | - | - |
|
|
25
|
+
| `titleColor` | 主标题字体颜色和下拉列表中选项颜色 | `string` | `#000000` | - | - |
|
|
26
|
+
| `activeTitleColor` | 激活主标题字体颜色 | `string` | `#000000` | - | - |
|
|
27
|
+
| `titleHeight` | 主标题高度 | `number / string` | `48` | - | - |
|
|
28
|
+
| `subColor` | 子标题字体颜色和下拉列表中选项颜色 | `string` | `#000000` | - | - |
|
|
29
|
+
| `activeSubColor` | 激活子标题字体颜色和下拉列表中选项颜色 | `string` | `#ffffff` | - | - |
|
|
30
|
+
| `subTitleHeight` | 子标题高度 | `number / string` | `42` | - | - |
|
|
31
|
+
| `subTitleRadius` | 子标题圆角 | `number / string` | `21` | - | - |
|
|
32
|
+
| `imageWidth` | 图片宽度,默认80,单位rpx | `number / string` | `80` | - | - |
|
|
33
|
+
| `imageHeight` | 图片高度,默认80,单位rpx | `number / string` | `80` | - | - |
|
|
34
|
+
| `imageRadius` | 图片圆角,默认50%,单位rpx | `number / string` | `50%` | - | - |
|
|
35
|
+
| `imageBorderWidth` | 选中图片边框宽度,默认4,单位rpx | `number / string` | `4` | - | - |
|
|
36
|
+
| `showGapLine` | 是否显示分隔符 | `boolean` | `false` | - | - |
|
|
37
|
+
| `lock` | 是否锁定tab(无法切换) | `boolean` | `false` | - | - |
|
|
38
|
+
| `disabled` | 是否禁用tab(所有功能失效) | `boolean` | `false` | - | - |
|
|
39
|
+
| `pullDown` | 是否有下拉选择按钮 | `boolean` | `false` | - | - |
|
|
40
|
+
| `placeholder` | 下拉占位符 | `string` | `请选择` | - | - |
|
|
41
|
+
| `maskTop` | 下拉蒙层顶部距离 | `number / string` | `0` | - | - |
|
|
42
|
+
| `maskRight` | 下拉蒙层右侧距离 | `number / string` | `0` | - | - |
|
|
43
|
+
| `maskBottom` | 下拉蒙层底部距离 | `number / string` | `0` | - | - |
|
|
44
|
+
| `maskLeft` | 下拉蒙层左侧距离 | `number / string` | `0` | - | - |
|
|
45
|
+
| `maskZindex` | 下拉蒙层层级 | `number / string` | `1001` | - | - |
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
#### Events
|
|
49
|
+
| 事件名 | 说明 | 事件参数 | 支持版本 |
|
|
50
|
+
| ----- | ----- | ------- | -------- |
|
|
51
|
+
| `click-tab` | 点击tab触发 | - | - |
|
|
52
|
+
| `change` | 切换tab触发 | - | - |
|