@kyfe/ks-query-table 0.0.21 → 0.0.22
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/.bitmap +38 -0
- package/.editorconfig +5 -0
- package/.env.dev +2 -0
- package/.env.gray +2 -0
- package/.env.prod +2 -0
- package/.env.stg +3 -0
- package/.env.uat +2 -0
- package/.eslintignore +1 -0
- package/.eslintrc.js +25 -0
- package/.gitmodules +4 -0
- package/.prettierrc +11 -0
- package/README.md +15 -0
- package/babel.config.js +10 -0
- package/build-apm.sh +9 -0
- package/build.sh +16 -0
- package/config/index.js +20 -0
- package/jsconfig.json +7 -0
- package/kuasheng-sdk/index.js +80 -0
- package/kuasheng-sdk/lib/assets.js +304 -0
- package/kuasheng-sdk/lib/context.js +199 -0
- package/kuasheng-sdk/lib/layout.js +346 -0
- package/kuasheng-sdk/lib/location.js +46 -0
- package/kuasheng-sdk/lib/media.js +342 -0
- package/kuasheng-sdk/lib/navigation.js +30 -0
- package/kuasheng-sdk/lib/request.js +76 -0
- package/kuasheng-sdk/lib/system.js +190 -0
- package/kuasheng-sdk/lib/userinfo.js +98 -0
- package/kuasheng-sdk/util/check.js +102 -0
- package/kuasheng-sdk/util/config.js +47 -0
- package/kuasheng-sdk/util/device.js +25 -0
- package/kuasheng-sdk/util/error.js +19 -0
- package/kuasheng-sdk/util/funtional.js +153 -0
- package/kuasheng-sdk/util/mixin.js +36 -0
- package/kuasheng-sdk/util/requestUtil.js +41 -0
- package/kuasheng-sdk/util/response.js +33 -0
- package/kuasheng-sdk/util/warn.js +35 -0
- package/kuasheng-ui/CHANGELOG.md +9 -0
- package/kuasheng-ui/components/card.vue +57 -0
- package/kuasheng-ui/components/ks-area-select/README.md +43 -0
- package/kuasheng-ui/components/ks-area-select/area-picker.vue +554 -0
- package/kuasheng-ui/components/ks-area-select/area-search.vue +363 -0
- package/kuasheng-ui/components/ks-area-select/areas-pop.vue +56 -0
- package/kuasheng-ui/components/ks-area-select/common.js +183 -0
- package/kuasheng-ui/components/ks-area-select/index.vue +355 -0
- package/kuasheng-ui/components/ks-area-select/mixins.js +216 -0
- package/kuasheng-ui/components/ks-area-single-select/README.md +50 -0
- package/kuasheng-ui/components/ks-area-single-select/hot-city.js +45 -0
- package/kuasheng-ui/components/ks-area-single-select/index.vue +324 -0
- package/kuasheng-ui/components/ks-calendar/index.vue +269 -0
- package/kuasheng-ui/components/ks-call-phone/call-tips.vue +70 -0
- package/kuasheng-ui/components/ks-call-phone/call.vue +178 -0
- package/kuasheng-ui/components/ks-call-phone/index.js +48 -0
- package/kuasheng-ui/components/ks-call-phone/index.vue +131 -0
- package/kuasheng-ui/components/ks-call-phone//345/221/274/345/217/253/347/273/204/344/273/266.md +0 -0
- package/kuasheng-ui/components/ks-date-picker/README.md +23 -0
- package/kuasheng-ui/components/ks-date-picker/date-picker-bottom.vue +123 -0
- package/kuasheng-ui/components/ks-date-picker/date-picker-dropdown.vue +80 -0
- package/kuasheng-ui/components/ks-date-picker/date-picker-right.vue +87 -0
- package/kuasheng-ui/components/ks-date-picker/date-picker-top.vue +88 -0
- package/kuasheng-ui/components/ks-date-picker/date-picker.js +15 -0
- package/kuasheng-ui/components/ks-date-picker/date-range-select.vue +92 -0
- package/kuasheng-ui/components/ks-date-picker/date-select.vue +65 -0
- package/kuasheng-ui/components/ks-date-picker/date-week-month.vue +131 -0
- package/kuasheng-ui/components/ks-date-picker/index.js +12 -0
- package/kuasheng-ui/components/ks-date-picker/mixin.js +92 -0
- package/kuasheng-ui/components/ks-date-picker/month-range-select.vue +129 -0
- package/kuasheng-ui/components/ks-date-picker/month-select.vue +85 -0
- package/kuasheng-ui/components/ks-date-picker/quarter-select.vue +94 -0
- package/kuasheng-ui/components/ks-date-picker/style.less +121 -0
- package/kuasheng-ui/components/ks-date-picker/utils.js +109 -0
- package/kuasheng-ui/components/ks-date-picker/week-select.vue +99 -0
- package/kuasheng-ui/components/ks-decrypt/index.vue +159 -0
- package/kuasheng-ui/components/ks-employee/README.md +78 -0
- package/kuasheng-ui/components/ks-employee/employee-input.vue +173 -0
- package/kuasheng-ui/components/ks-employee/employee-list.vue +662 -0
- package/kuasheng-ui/components/ks-employee/employee-popup.vue +197 -0
- package/kuasheng-ui/components/ks-employee/employee-search.vue +250 -0
- package/kuasheng-ui/components/ks-employee/employee-selected.vue +173 -0
- package/kuasheng-ui/components/ks-employee/index.js +17 -0
- package/kuasheng-ui/components/ks-employee/package-lock.json +5 -0
- package/kuasheng-ui/components/ks-employee/package.json +15 -0
- package/kuasheng-ui/components/ks-employee/yarn.lock +4 -0
- package/kuasheng-ui/components/ks-field-money/index.js +8 -0
- package/kuasheng-ui/components/ks-field-money/index.vue +212 -0
- package/kuasheng-ui/components/ks-field-money/package.json +11 -0
- package/kuasheng-ui/components/ks-field-money/utils.js +65 -0
- package/kuasheng-ui/components/ks-field-money//351/207/221/351/242/235/350/275/254/346/215/242/345/231/250.md +0 -0
- package/kuasheng-ui/components/ks-history-search/history-input.vue +131 -0
- package/kuasheng-ui/components/ks-history-search/history-list.vue +188 -0
- package/kuasheng-ui/components/ks-history-search/img/delete.png +0 -0
- package/kuasheng-ui/components/ks-history-search/index.js +9 -0
- package/kuasheng-ui/components/ks-history-search/index.vue +125 -0
- package/kuasheng-ui/components/ks-history-search/package-lock.json +5 -0
- package/kuasheng-ui/components/ks-history-search/package.json +15 -0
- package/kuasheng-ui/components/ks-history-search/utils.js +35 -0
- package/kuasheng-ui/components/ks-input-search/index.vue +106 -0
- package/kuasheng-ui/components/ks-list/index.vue +75 -0
- package/kuasheng-ui/components/ks-loading/index.js +16 -0
- package/kuasheng-ui/components/ks-month/index.vue +47 -0
- package/kuasheng-ui/components/ks-month/package.json +3 -0
- package/kuasheng-ui/components/ks-month/range.vue +172 -0
- package/kuasheng-ui/components/ks-month/single.vue +136 -0
- package/kuasheng-ui/components/ks-month/style.less +125 -0
- package/kuasheng-ui/components/ks-month/utils.js +35 -0
- package/kuasheng-ui/components/ks-nav/index.vue +264 -0
- package/kuasheng-ui/components/ks-nav-bar.js +35 -0
- package/kuasheng-ui/components/ks-org/ks-org-tree.vue +247 -0
- package/kuasheng-ui/components/ks-org/ks-popup-tree.vue +154 -0
- package/kuasheng-ui/components/ks-org/ks-tree-input.vue +240 -0
- package/kuasheng-ui/components/ks-org/ks-tree-node.vue +94 -0
- package/kuasheng-ui/components/ks-org/ks-tree.vue +229 -0
- package/kuasheng-ui/components/ks-org/utils.js +54 -0
- package/kuasheng-ui/components/ks-popover/index.vue +457 -0
- package/kuasheng-ui/components/ks-popover/mixin.js +28 -0
- package/kuasheng-ui/components/ks-popover/utils.js +60 -0
- package/kuasheng-ui/components/ks-pull-refresh/index.vue +43 -0
- package/kuasheng-ui/components/ks-quarter/index.vue +256 -0
- package/kuasheng-ui/components/ks-table/README.md +103 -0
- package/kuasheng-ui/components/ks-table/cell.vue +31 -0
- package/kuasheng-ui/components/ks-table/index.js +8 -0
- package/kuasheng-ui/components/ks-table/index.less +486 -0
- package/kuasheng-ui/components/ks-table/index.vue +1088 -0
- package/kuasheng-ui/components/ks-table/package.json +12 -0
- package/kuasheng-ui/components/ks-table/release.md +7 -0
- package/kuasheng-ui/components/ks-toast.js +35 -0
- package/kuasheng-ui/components/ks-upload/index.vue +174 -0
- package/kuasheng-ui/components/ks-user-access.vue +229 -0
- package/kuasheng-ui/components/no-data/README.md +45 -0
- package/kuasheng-ui/components/no-data/image.js +1 -0
- package/kuasheng-ui/components/no-data/index.vue +83 -0
- package/kuasheng-ui/components/notice-bar.vue +16 -0
- package/kuasheng-ui/components/steps.js +11 -0
- package/kuasheng-ui/components/tabs.vue +40 -0
- package/kuasheng-ui/index.js +239 -0
- package/kuasheng-ui/patch/datetime-picker/datetimePicker.md +0 -0
- package/kuasheng-ui/patch/datetime-picker/index.js +46 -0
- package/kuasheng-ui/patch/datetime-picker/utils.js +78 -0
- package/kuasheng-ui/patch/field/field.md +1 -0
- package/kuasheng-ui/patch/field/index.js +122 -0
- package/kuasheng-ui/patch/field/utils.js +36 -0
- package/kuasheng-ui/patch/form/form.md +7 -0
- package/kuasheng-ui/patch/form/index.js +106 -0
- package/kuasheng-ui/patch/index.js +12 -0
- package/kuasheng-ui/patch/pagination/index.js +78 -0
- package/kuasheng-ui/style/animation-ui.less +31 -0
- package/kuasheng-ui/style/font/number/font-number1.otf +0 -0
- package/kuasheng-ui/style/font/number/font-number2.ttf +0 -0
- package/kuasheng-ui/style/images/checked.svg +1 -0
- package/kuasheng-ui/style/images/success.svg +1 -0
- package/kuasheng-ui/style/index.less +6 -0
- package/kuasheng-ui/style/kuasheng-ui.less +207 -0
- package/kuasheng-ui/style/reset-vant.less +307 -0
- package/kuasheng-ui/style/vant-var.less +138 -0
- package/kuasheng-ui/utils/apis.js +17 -0
- package/kuasheng-ui/utils/axios-adapter.js +47 -0
- package/kuasheng-ui/utils/bem.js +39 -0
- package/kuasheng-ui/utils/bus.js +97 -0
- package/kuasheng-ui/utils/common.js +88 -0
- package/kuasheng-ui/utils/decrypt/config.js +12 -0
- package/kuasheng-ui/utils/decrypt/decrypt-api.js +139 -0
- package/kuasheng-ui/utils/decrypt/index.js +6 -0
- package/kuasheng-ui/utils/decrypt/mask.js +36 -0
- package/kuasheng-ui/utils/decrypt/virtual.js +44 -0
- package/kuasheng-ui/utils/directive.js +57 -0
- package/kuasheng-ui/utils/directive.md +23 -0
- package/kuasheng-ui/utils/drcheck-plugin.js +219 -0
- package/kuasheng-ui/utils/error-plugin.js +88 -0
- package/kuasheng-ui/utils/filter.js +149 -0
- package/kuasheng-ui/utils/http-interceptors.js +18 -0
- package/kuasheng-ui/utils/http.js +140 -0
- package/kuasheng-ui/utils/index.js +5 -0
- package/kuasheng-ui/utils/init-event.js +20 -0
- package/kuasheng-ui/utils/log.js +309 -0
- package/kuasheng-ui/utils/token.js +9 -0
- package/kuasheng-ui/utils/type.js +45 -0
- package/kuasheng-ui/utils/validate.js +20 -0
- package/kuasheng-ui/utils/watermark.js +67 -0
- package/kuasheng-ui/version.js +1 -0
- package/ky-apm/client.js +37 -0
- package/ky-apm/customHttp.js +38 -0
- package/ky-apm/index.js +68 -0
- package/ky-apm/plugins/performance.js +84 -0
- package/ky-apm/plugins/self-error.js +26 -0
- package/ky-apm/warn-log.js +3 -0
- package/package.json +81 -10
- package/plugin/ks-chii-webpack-html/index.js +53 -0
- package/plugin/ks-chii-webpack-html/package.json +16 -0
- package/postcss.config.js +15 -0
- package/public/capsule-positon.js +50 -0
- package/public/fonts/DingTalkJinBuTi.ttf +0 -0
- package/public/framework/axios@0.19.0.min.js +9 -0
- package/public/framework/fastclick@1.0.6.min.js +1 -0
- package/public/framework/iconfont/iconfont.css +91 -0
- package/public/framework/iconfont/iconfont.js +1 -0
- package/public/framework/iconfont/iconfont.json +142 -0
- package/public/framework/iconfont/iconfont.ttf +0 -0
- package/public/framework/iconfont/iconfont.woff +0 -0
- package/public/framework/iconfont/iconfont.woff2 +0 -0
- package/public/framework/vant@2.5.6.min.js +7 -0
- package/public/framework/vue-router@3.1.3.min.js +6 -0
- package/public/framework/vue@2.6.10.runtime.min.js +6 -0
- package/public/framework/vuex@3.1.1.min.js +6 -0
- package/public/index.html +260 -0
- package/public/ks@3.0.8.umd.min.js +1 -0
- package/public/ksui@4.0.27.umd.min.js +10 -0
- package/public/status-bar-preset.js +39 -0
- package/{index.js → qt-npm/index.js} +3 -3
- package/qt-npm/package.json +13 -0
- package/src/App.vue +204 -0
- package/src/README.md +15 -0
- package/src/common/README.md +94 -0
- package/src/common/http/axios-adapter.js +47 -0
- package/src/common/http/common.js +88 -0
- package/src/common/http/http-interceptors.js +18 -0
- package/src/common/http/http-lock.js +45 -0
- package/src/common/http/index.js +163 -0
- package/src/common/http/token.js +9 -0
- package/src/common/styles/font/AlibabaSans102Ver2-Md.ttf +0 -0
- package/src/common/styles/font.less +12 -0
- package/src/common/styles/variables.less +43 -0
- package/src/common/utils/index.js +1 -0
- package/src/common/utils/platform/README.md +1 -0
- package/src/common/utils/platform/android/.gitkeep +0 -0
- package/src/common/utils/platform/core/index.js +24 -0
- package/src/common/utils/platform/index.js +164 -0
- package/src/common/utils/platform/ios/.gitkeep +0 -0
- package/src/common/utils/platform/subscribe/helper.js +38 -0
- package/src/common/utils/platform/subscribe/index.js +204 -0
- package/src/common/utils/platform/subscribe/table-animation.js +75 -0
- package/src/config/index.js +31 -0
- package/src/config.js +1 -0
- package/src/main.js +73 -0
- package/src/router.js +52 -0
- package/src/view/home/config.js +101 -0
- package/src/view/home/demo1.vue +223 -0
- package/src/view/home/demo2.vue +124 -0
- package/src/view/home/demo3.vue +51 -0
- package/src/view/home/demo4.vue +140 -0
- package/src/view/home/index.vue +97 -0
- package/src/view/home/query-table/README.md +45 -0
- package/src/view/home/query-table/api/index.js +12 -0
- package/src/view/home/query-table/assets/horizontal-back.svg +1 -0
- package/src/view/home/query-table/components/pe-table/cell.js +181 -0
- package/src/view/home/query-table/components/pe-table/collapse.js +334 -0
- package/src/view/home/query-table/components/pe-table/empty.vue +48 -0
- package/src/view/home/query-table/components/pe-table/header.js +328 -0
- package/src/view/home/query-table/components/pe-table/images/abnormal.png +0 -0
- package/src/view/home/query-table/components/pe-table/images/empty.png +0 -0
- package/src/view/home/query-table/components/pe-table/images/fold.svg +1 -0
- package/src/view/home/query-table/components/pe-table/images/sort.svg +1 -0
- package/src/view/home/query-table/components/pe-table/images/sorting.svg +1 -0
- package/src/view/home/query-table/components/pe-table/images/unfold.svg +1 -0
- package/src/view/home/query-table/components/pe-table/index.vue +847 -0
- package/src/view/home/query-table/components/pe-table/load-more.js +46 -0
- package/src/view/home/query-table/components/pe-table/props/index.js +193 -0
- package/src/view/home/query-table/components/pe-table/row.vue +118 -0
- package/src/view/home/query-table/components/pe-table/scrollbar.js +424 -0
- package/src/view/home/query-table/components/pe-table/stretch-damping.js +112 -0
- package/src/view/home/query-table/components/pe-table/style/cell.less +89 -0
- package/src/view/home/query-table/components/pe-table/style/empty.less +48 -0
- package/src/view/home/query-table/components/pe-table/style/header.less +141 -0
- package/src/view/home/query-table/components/pe-table/style/index.less +88 -0
- package/src/view/home/query-table/components/pe-table/style/load-more.less +61 -0
- package/src/view/home/query-table/components/pe-table/style/row.less +6 -0
- package/src/view/home/query-table/components/pe-table/table-loading.vue +120 -0
- package/src/view/home/query-table/components/pe-table/table-total.vue +57 -0
- package/src/view/home/query-table/components/pe-table/utils/animate.js +80 -0
- package/src/view/home/query-table/components/pe-table/utils/columns.js +290 -0
- package/src/view/home/query-table/components/pe-table/utils/data.js +12 -0
- package/src/view/home/query-table/components/pe-table/utils/fixed.js +69 -0
- package/src/view/home/query-table/components/pe-table/utils/formatter.js +327 -0
- package/src/view/home/query-table/components/pe-table/utils/render-cells.js +424 -0
- package/src/view/home/query-table/components/pe-table/utils/slot.js +28 -0
- package/src/view/home/query-table/components/pe-table/utils/tools.js +84 -0
- package/src/view/home/query-table/components/pe-table/utils/touch-scroll.js +417 -0
- package/src/view/home/query-table/components/query-table/index.vue +497 -0
- package/src/view/home/query-table/components/query-table/mixins/column-mixin.js +102 -0
- package/src/view/home/query-table/components/query-table/mixins/column-setting.js +143 -0
- package/src/view/home/query-table/components/query-table/mixins/data-mixin.js +519 -0
- package/src/view/home/query-table/components/query-table/mixins/pagination-mixin.js +26 -0
- package/src/view/home/query-table/components/query-table/mixins/table-fixed.js +130 -0
- package/src/view/home/query-table/components/query-table/mixins/table-horizontal.js +119 -0
- package/src/view/home/query-table/components/table-horizontal.vue +99 -0
- package/src/view/home/query-table/components/table-pagination.vue +32 -0
- package/src/view/home/query-table/components/table-settings/assets/arrpw-up.svg +1 -0
- package/src/view/home/query-table/components/table-settings/assets/disabled-down.svg +1 -0
- package/src/view/home/query-table/components/table-settings/assets/disabled-up.svg +1 -0
- package/src/view/home/query-table/components/table-settings/assets/down.svg +1 -0
- package/src/view/home/query-table/components/table-settings/assets/up.svg +1 -0
- package/src/view/home/query-table/components/table-settings/index.less +294 -0
- package/src/view/home/query-table/components/table-settings/index.vue +260 -0
- package/src/view/home/query-table/components/table-settings/settings.vue +479 -0
- package/src/view/home/query-table/components/table-settings/test.js +626 -0
- package/src/view/home/query-table/components/table-settings//344/270/252/346/200/247/350/256/276/347/275/256.md +0 -0
- package/src/view/home/query-table/components/tooltip.js +124 -0
- package/src/view/home/query-table/hooks/use-cache-promise.js +27 -0
- package/src/view/home/query-table/hooks/use-column-config.js +190 -0
- package/src/view/home/query-table/hooks/use-encryption.js +0 -0
- package/src/view/home/query-table/hooks/use-generic-search.js +95 -0
- package/src/view/home/query-table/index.js +7 -0
- package/src/view/home/query-table/store/column-store.js +0 -0
- package/src/view/home/query-table/styles/table.less +24 -0
- package/src/view/home/query-table/utils/column.js +36 -0
- package/src/view/home/query-table/utils/config.js +12 -0
- package/src/view/home/query-table/utils/encryption.js +32 -0
- package/src/view/home/query-table/utils/http.js +1 -0
- package/src/view/home/query-table/utils/localStorage.js +35 -0
- package/src/view/home//351/246/226/351/241/265.md +0 -0
- package/src/web.js +99 -0
- package/vue.config.js +131 -0
|
@@ -0,0 +1,1088 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div ref="root" class="ks-table-box">
|
|
3
|
+
<div ref="verticalTableWrapper" class="ks-table-wrapper">
|
|
4
|
+
<div ref="verticalTable" class="ks-table">
|
|
5
|
+
<ks-sticky :offset-top="offsetTop" :container="stickyContainer" @scroll="stickyScroll">
|
|
6
|
+
<div ref="title" v-if="isHorizontal" class="ks-table__title">
|
|
7
|
+
<slot name="ksTableTitle">
|
|
8
|
+
<div class="ks-table__title-left" @click="closeHorizontal">
|
|
9
|
+
<img src="https://erphostjs.kye-erp.com/kuasheng-h5/assets/ks-table/back.png"/>
|
|
10
|
+
<div>{{headerTitle}}</div>
|
|
11
|
+
</div>
|
|
12
|
+
<div class="ks-table__title-right" @click="closeHorizontal">
|
|
13
|
+
<img src="https://erphostjs.kye-erp.com/kuasheng-h5/assets/ks-table/horizontal.png"/>
|
|
14
|
+
</div>
|
|
15
|
+
</slot>
|
|
16
|
+
</div>
|
|
17
|
+
<div class="ks-table__header-wrapper">
|
|
18
|
+
<div ref="head" class="ks-table__header">
|
|
19
|
+
<table cellspacing="0" cellpadding="0" border="0" :width="`${tableWidth}px`" :class="{ 'ks-table-border': border }">
|
|
20
|
+
<thead>
|
|
21
|
+
<tr :style="{ height: `${headerHeight}px`, lineHeight: `${headerHeight}px` }">
|
|
22
|
+
<td v-if="selection" width="40" class="checkbox-column" :class="checkboxClass" @click.stop="handleCheckAll">
|
|
23
|
+
<ks-checkbox shape="square" icon-size="16" v-model="checkedAll"></ks-checkbox>
|
|
24
|
+
</td>
|
|
25
|
+
<td v-if="index" :width="indexWidth" class="index-column ks-table__header-title" :style="{ height: `${headerHeight}px` }">序号</td>
|
|
26
|
+
<td
|
|
27
|
+
v-for="column of showColumns"
|
|
28
|
+
:key="column.key"
|
|
29
|
+
:style="{ width: `${column.width || 50}px`, height: `${headerHeight}px` }"
|
|
30
|
+
@click="handleSort(column)"
|
|
31
|
+
>
|
|
32
|
+
<render-header
|
|
33
|
+
v-if="headerFormatter[column.key] || (column.children && column.children.length)"
|
|
34
|
+
:formatter="headerFormatter[column.key] || defaultHeaderFormatter"
|
|
35
|
+
:column="column"
|
|
36
|
+
:currentSortKey="currentSortKey"
|
|
37
|
+
:currentSortType="currentSortType"
|
|
38
|
+
@sort="handleSort"
|
|
39
|
+
/>
|
|
40
|
+
<template v-else>
|
|
41
|
+
<div class="ks-table__header-wrapper-sort">
|
|
42
|
+
<span class="ks-table__header-title">{{ column.title }}</span>
|
|
43
|
+
<div v-if="column.sort" class="ks-table__header-sort">
|
|
44
|
+
<div class="ks-table__header-sort__asc" :class="{ 'asc-active': currentSortType === 'asc' && column.key === currentSortKey }"></div>
|
|
45
|
+
<div
|
|
46
|
+
class="ks-table__header-sort__desc"
|
|
47
|
+
:class="{ 'desc-active': currentSortType === 'desc' && column.key === currentSortKey }"
|
|
48
|
+
></div>
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
</template>
|
|
52
|
+
</td>
|
|
53
|
+
</tr>
|
|
54
|
+
</thead>
|
|
55
|
+
</table>
|
|
56
|
+
</div>
|
|
57
|
+
<div v-if="isFixed" class="ks-table__header-fixed">
|
|
58
|
+
<table cellspacing="0" cellpadding="0" border="0" :width="`${fixedTableWidth}px`" :class="{ 'ks-table-border': border }">
|
|
59
|
+
<thead>
|
|
60
|
+
<tr :style="{ height: `${headerHeight}px`, lineHeight: `${headerHeight}px` }">
|
|
61
|
+
<td v-if="selection" width="40" class="checkbox-column" :class="checkboxClass" @click.stop="handleCheckAll">
|
|
62
|
+
<ks-checkbox shape="square" icon-size="16" v-model="checkedAll"></ks-checkbox>
|
|
63
|
+
</td>
|
|
64
|
+
<td v-if="index" :width="indexWidth" class="index-column ks-table__header-title" :style="{ height: `${headerHeight}px` }">序号</td>
|
|
65
|
+
<td
|
|
66
|
+
v-for="column of fixedColumns"
|
|
67
|
+
:key="column.key"
|
|
68
|
+
:style="{ width: `${column.width || 50}px`, height: `${headerHeight}px` }"
|
|
69
|
+
@click="handleSort(column)"
|
|
70
|
+
>
|
|
71
|
+
<render-header
|
|
72
|
+
v-if="headerFormatter[column.key] || (column.children && column.children.length)"
|
|
73
|
+
:formatter="headerFormatter[column.key] || defaultHeaderFormatter"
|
|
74
|
+
:column="column"
|
|
75
|
+
:currentSortKey="currentSortKey"
|
|
76
|
+
:currentSortType="currentSortType"
|
|
77
|
+
@sort="handleSort"
|
|
78
|
+
/>
|
|
79
|
+
<template v-else>
|
|
80
|
+
<div class="ks-table__header-wrapper-sort">
|
|
81
|
+
<span class="ks-table__header-title">{{ column.title }}</span>
|
|
82
|
+
<div v-if="column.sort" class="ks-table__header-sort">
|
|
83
|
+
<div class="ks-table__header-sort__asc" :class="{ 'asc-active': currentSortType === 'asc' && column.key === currentSortKey }"></div>
|
|
84
|
+
<div
|
|
85
|
+
class="ks-table__header-sort__desc"
|
|
86
|
+
:class="{ 'desc-active': currentSortType === 'desc' && column.key === currentSortKey }"
|
|
87
|
+
></div>
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
</template>
|
|
91
|
+
</td>
|
|
92
|
+
</tr>
|
|
93
|
+
</thead>
|
|
94
|
+
</table>
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
</ks-sticky>
|
|
98
|
+
<div class="ks-table__body-wrapper">
|
|
99
|
+
<div ref="body" class="ks-table__body" :style="{ height: isHorizontal ? horizontalTableHeight : verticalTableHeight }">
|
|
100
|
+
<table cellspacing="0" cellpadding="0" border="0" :width="`${tableWidth}px`" :class="{ 'ks-table-border': border, 'ks-table-stripe': stripe }">
|
|
101
|
+
<tr v-for="(item, i) of currentData" :key="item.id" :style="{ height: `${lineHeight}px`, backgroundColor: highlightRow(item) }">
|
|
102
|
+
<td v-if="selection" width="40" class="checkbox-column" @click.stop="handleCheck(item)">
|
|
103
|
+
<ks-checkbox shape="square" icon-size="16" v-model="item._checked"></ks-checkbox>
|
|
104
|
+
</td>
|
|
105
|
+
<td v-if="index" :width="indexWidth" class="index-column">
|
|
106
|
+
{{ pagination ? (page - 1) * pageSize + i + 1 : i + 1 }}
|
|
107
|
+
</td>
|
|
108
|
+
<td
|
|
109
|
+
v-for="column of showColumns"
|
|
110
|
+
:key="column.key"
|
|
111
|
+
:style="{ width: `${column.width || 50}px`, color: column.color }"
|
|
112
|
+
align="left"
|
|
113
|
+
@click.stop="(e) => handleCellClick(item, column, i, e)"
|
|
114
|
+
>
|
|
115
|
+
<render-cell
|
|
116
|
+
v-if="formatter[column.key] || (column.children && column.children.length)"
|
|
117
|
+
:formatter="formatter[column.key] || defaultCellFormatter"
|
|
118
|
+
:allFormatter="formatter"
|
|
119
|
+
:row="item"
|
|
120
|
+
:index="i"
|
|
121
|
+
:column="column"
|
|
122
|
+
:lineHeight="lineHeight"
|
|
123
|
+
:border="border"
|
|
124
|
+
@cell-click="(e, col) => handleCellClick2(item, col, i, e)"
|
|
125
|
+
/>
|
|
126
|
+
<!-- <template v-else> -->
|
|
127
|
+
<!-- <ks-popover
|
|
128
|
+
v-if="column.showPopover"
|
|
129
|
+
v-model="item[`showPopover_${column.key}`]"
|
|
130
|
+
trigger="click"
|
|
131
|
+
theme="dark"
|
|
132
|
+
:placement="column.popoverPlacement || 'bottom'"
|
|
133
|
+
>
|
|
134
|
+
<div class="ks-table__cell-popover">{{ item[column.popoverCustomKey] || item[column.key] }}</div>
|
|
135
|
+
<template #reference>
|
|
136
|
+
<span :style="{ width: `${(column.width || 50) - 8}px` }">{{ item[column.key] }}</span>
|
|
137
|
+
</template>
|
|
138
|
+
</ks-popover> -->
|
|
139
|
+
<span v-else :style="{ width: `${(column.width || 50) - 8}px` }">{{ item[column.key] }}</span>
|
|
140
|
+
<!-- </template> -->
|
|
141
|
+
</td>
|
|
142
|
+
</tr>
|
|
143
|
+
</table>
|
|
144
|
+
|
|
145
|
+
<div
|
|
146
|
+
v-if="parseInt(isHorizontal ? horizontalTableHeight : verticalTableHeight) >= lineHeight * currentData.length"
|
|
147
|
+
:style="{
|
|
148
|
+
height: `${parseInt(isHorizontal ? horizontalTableHeight : verticalTableHeight) - lineHeight * currentData.length}px`,
|
|
149
|
+
width: `${tableWidth}px`
|
|
150
|
+
}"
|
|
151
|
+
>
|
|
152
|
+
<div class="ks-table__body__no-data" v-if="currentData.length === 0">
|
|
153
|
+
<slot name="noData" >
|
|
154
|
+
暂无数据
|
|
155
|
+
</slot>
|
|
156
|
+
</div>
|
|
157
|
+
</div>
|
|
158
|
+
</div>
|
|
159
|
+
<div
|
|
160
|
+
v-if="isFixed"
|
|
161
|
+
ref="fixedBody"
|
|
162
|
+
class="ks-table__body-fixed"
|
|
163
|
+
:style="{
|
|
164
|
+
height:
|
|
165
|
+
parseInt(isHorizontal ? horizontalTableHeight : verticalTableHeight) >= lineHeight * currentData.length
|
|
166
|
+
? `${lineHeight * currentData.length}px`
|
|
167
|
+
: isHorizontal
|
|
168
|
+
? horizontalTableHeight
|
|
169
|
+
: verticalTableHeight
|
|
170
|
+
}"
|
|
171
|
+
>
|
|
172
|
+
<table cellspacing="0" cellpadding="0" border="0" :width="`${fixedTableWidth}px`" :class="{ 'ks-table-border': border, 'ks-table-stripe': stripe }">
|
|
173
|
+
<tr v-for="(item, i) of currentData" :key="item.id" :style="{ height: `${lineHeight}px`, backgroundColor: highlightRow(item) }">
|
|
174
|
+
<td v-if="selection" width="40" class="checkbox-column" @click.stop="handleCheck(item)">
|
|
175
|
+
<ks-checkbox shape="square" icon-size="16" v-model="item._checked"></ks-checkbox>
|
|
176
|
+
</td>
|
|
177
|
+
<td v-if="index" :width="indexWidth" class="index-column">
|
|
178
|
+
{{ pagination ? (page - 1) * pageSize + i + 1 : i + 1 }}
|
|
179
|
+
</td>
|
|
180
|
+
<td
|
|
181
|
+
v-for="column of fixedColumns"
|
|
182
|
+
:key="column.key"
|
|
183
|
+
:style="{ width: `${column.width || 50}px`, color: column.color }"
|
|
184
|
+
align="left"
|
|
185
|
+
@click.stop="(e) => handleCellClick(item, column, i, e)"
|
|
186
|
+
>
|
|
187
|
+
<render-cell
|
|
188
|
+
v-if="formatter[column.key] || (column.children && column.children.length)"
|
|
189
|
+
:formatter="formatter[column.key] || defaultCellFormatter"
|
|
190
|
+
:allFormatter="formatter"
|
|
191
|
+
:row="item"
|
|
192
|
+
:index="i"
|
|
193
|
+
:column="column"
|
|
194
|
+
:lineHeight="lineHeight"
|
|
195
|
+
@cell-click="(e, col) => handleCellClick2(item, col, i, e)"
|
|
196
|
+
/>
|
|
197
|
+
<!-- <template v-else>
|
|
198
|
+
<ks-popover
|
|
199
|
+
v-if="column.showPopover"
|
|
200
|
+
v-model="item[`showPopover_${column.key}`]"
|
|
201
|
+
trigger="click"
|
|
202
|
+
theme="dark"
|
|
203
|
+
:placement="column.popoverPlacement || 'bottom'"
|
|
204
|
+
>
|
|
205
|
+
<div class="ks-table__cell-popover">{{ item[column.popoverCustomKey] || item[column.key] }}</div>
|
|
206
|
+
<template #reference>
|
|
207
|
+
<span :style="{ width: `${(column.width || 50) - 8}px` }">{{ item[column.key] }}</span>
|
|
208
|
+
</template>
|
|
209
|
+
</ks-popover> -->
|
|
210
|
+
<span v-else :style="{ width: `${(column.width || 50) - 8}px` }">{{ item[column.key] }}</span>
|
|
211
|
+
<!-- </template> -->
|
|
212
|
+
</td>
|
|
213
|
+
</tr>
|
|
214
|
+
</table>
|
|
215
|
+
</div>
|
|
216
|
+
</div>
|
|
217
|
+
<div class="ks-table__footer" v-if="pagination">
|
|
218
|
+
<ks-pagination :value="page" :total-items="total" :items-per-page="pageSize" :show-page-size="3" force-ellipses @change="handleChangePage" />
|
|
219
|
+
</div>
|
|
220
|
+
</div>
|
|
221
|
+
</div>
|
|
222
|
+
<ks-popup :value="isHorizontal" get-container="body" class="ks-table-popup" :closeable="false" :close-on-click-overlay="false" :close-on-popstate="true">
|
|
223
|
+
<div class="ks-table-popup__wrapper" :style="{ height: `${clientWidth}px` }">
|
|
224
|
+
<div
|
|
225
|
+
ref="horizontalTable"
|
|
226
|
+
class="ks-table-wrapper"
|
|
227
|
+
:class="{ 'ks-table-popup-center': tableWidth < horizontalTableMaxWidth }"
|
|
228
|
+
:style="{ width: tableWidth < horizontalTableMaxWidth ? `${tableWidth}px` : '' }"
|
|
229
|
+
></div>
|
|
230
|
+
<!-- <div class="ks-table-popup__button">
|
|
231
|
+
<ks-button class="handle-btn" size="mini" type="primary" @click="closeHorizontal">
|
|
232
|
+
<svg viewBox="0 0 1024 1024" version="1.1" width="20" height="20">
|
|
233
|
+
<path
|
|
234
|
+
d="M448 128a106.666667 106.666667 0 0 1 106.666667 106.666667v576a106.666667 106.666667 0 0 1-106.666667 106.666666H128a106.666667 106.666667 0 0 1-106.666667-106.666666V234.666667a106.666667 106.666667 0 0 1 106.666667-106.666667h320z m448 256a106.666667 106.666667 0 0 1 106.666667 106.666667v320a106.666667 106.666667 0 0 1-106.666667 106.666666H661.333333a42.666667 42.666667 0 1 1 0-85.333333h234.666667a21.333333 21.333333 0 0 0 21.333333-21.333333V490.666667a21.333333 21.333333 0 0 0-21.333333-21.333334H661.333333a42.666667 42.666667 0 1 1 0-85.333333z m-448-170.666667H128a21.333333 21.333333 0 0 0-21.333333 21.333334v554.666666a21.333333 21.333333 0 0 0 21.333333 21.333334h320a21.333333 21.333333 0 0 0 21.333333-21.333334V234.666667a21.333333 21.333333 0 0 0-21.333333-21.333334z m-64 458.666667a32 32 0 0 1 0 64h-170.666667a32 32 0 0 1 0-64z"
|
|
235
|
+
p-id="744"
|
|
236
|
+
fill="#ffffff"
|
|
237
|
+
></path>
|
|
238
|
+
</svg>
|
|
239
|
+
转竖屏
|
|
240
|
+
</ks-button>
|
|
241
|
+
</div> -->
|
|
242
|
+
</div>
|
|
243
|
+
</ks-popup>
|
|
244
|
+
<ks-popup
|
|
245
|
+
:value="!isHorizontal && showSettings"
|
|
246
|
+
get-container="body"
|
|
247
|
+
class="ks-table-setting-popup"
|
|
248
|
+
:closeable="false"
|
|
249
|
+
:close-on-popstate="true"
|
|
250
|
+
position="right"
|
|
251
|
+
@click-overlay="showSettings = false"
|
|
252
|
+
>
|
|
253
|
+
<div class="ks-table-setting__wrapper">
|
|
254
|
+
<div class="ks-table-setting__header">
|
|
255
|
+
<h3><ks-icon @click="showSettings = false" name="arrow-left" />表格自定义<strong>可拖动排序</strong></h3>
|
|
256
|
+
<div class="ks-table-setting__header__table-title">
|
|
257
|
+
<span class="ks-table-setting__field-name">字段名</span>
|
|
258
|
+
<span class="ks-table-setting__switch">显示/隐藏</span>
|
|
259
|
+
<span class="ks-table-setting__sortable">排序</span>
|
|
260
|
+
</div>
|
|
261
|
+
</div>
|
|
262
|
+
<div class="ks-table-setting__list-wrapper">
|
|
263
|
+
<ul class="ks-table-setting__list">
|
|
264
|
+
<draggable v-model="currentColumns" draggable=".draggable-li" delay="50">
|
|
265
|
+
<li v-for="column of currentColumns" :key="column.key" :class="{ 'draggable-li': !column.fixed }">
|
|
266
|
+
<span class="ks-table-setting__list-title">{{ column.title }}</span>
|
|
267
|
+
<ks-checkbox v-model="column.show" :disabled="column.fixed" />
|
|
268
|
+
<svg class="svg-icon" viewBox="0 0 1024 1024" version="1.1" width="16" height="16">
|
|
269
|
+
<path
|
|
270
|
+
d="M689.024 137.28l4.608 3.776 218.56 218.624a29.248 29.248 0 0 1-36.736 45.12l-4.608-3.776L702.08 232.32V906.88a29.248 29.248 0 0 1-57.984 5.312l-0.512-5.312v-736l0.32-4.8a29.248 29.248 0 0 1 45.056-28.8zM364.928 117.12c14.336 0 26.24 10.304 28.8 24l0.448 5.248v736l-0.128 2.048a29.248 29.248 0 0 1-44.416 31.616l-4.544-3.712-219.456-218.624a29.248 29.248 0 0 1 36.736-45.184l4.544 3.712 168.704 168.064V146.304c0-16.192 13.12-29.248 29.312-29.248z"
|
|
271
|
+
fill="#837E7E"
|
|
272
|
+
p-id="1328"
|
|
273
|
+
></path>
|
|
274
|
+
</svg>
|
|
275
|
+
</li>
|
|
276
|
+
</draggable>
|
|
277
|
+
</ul>
|
|
278
|
+
</div>
|
|
279
|
+
<div class="ks-table-setting__footer">
|
|
280
|
+
<ks-grid column-num="2" :border="false">
|
|
281
|
+
<ks-grid-item>
|
|
282
|
+
<ks-button type="primary" size="large" plain @click="resetSettings">重置</ks-button>
|
|
283
|
+
</ks-grid-item>
|
|
284
|
+
<ks-grid-item>
|
|
285
|
+
<ks-button type="primary" size="large" @click="saveSettings">保存</ks-button>
|
|
286
|
+
</ks-grid-item>
|
|
287
|
+
</ks-grid>
|
|
288
|
+
</div>
|
|
289
|
+
</div>
|
|
290
|
+
</ks-popup>
|
|
291
|
+
<ks-popover v-model="showPopover" theme="dark" placement="top" :style="popoverStyle">
|
|
292
|
+
<div class="ks-table__cell-popover">{{ this.popoverContent }}</div>
|
|
293
|
+
</ks-popover>
|
|
294
|
+
</div>
|
|
295
|
+
</template>
|
|
296
|
+
<script>
|
|
297
|
+
import draggable from 'vuedraggable'
|
|
298
|
+
import IScroll from 'iscroll/build/iscroll-probe'
|
|
299
|
+
import './index.less';
|
|
300
|
+
const Toast = window.ksui && window.ksui.Toast
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* 状态栏及导航栏高度
|
|
304
|
+
*/
|
|
305
|
+
const getOffsetTop = () => {
|
|
306
|
+
var isIos = navigator.userAgent.includes('iPhone')
|
|
307
|
+
if (isIos) {
|
|
308
|
+
var ratio = window.devicePixelRatio || 1
|
|
309
|
+
var screen = {
|
|
310
|
+
width: window.screen.width * ratio,
|
|
311
|
+
height: window.screen.height * ratio
|
|
312
|
+
}
|
|
313
|
+
if (
|
|
314
|
+
(isIos && screen.width == 1125 && screen.height === 2436) ||
|
|
315
|
+
(isIos && screen.width == 828 && screen.height === 1792) ||
|
|
316
|
+
(isIos && screen.width == 1125 && screen.height === 2436) ||
|
|
317
|
+
(isIos && screen.width == 1242 && screen.height === 2688)
|
|
318
|
+
) {
|
|
319
|
+
return '88'
|
|
320
|
+
}
|
|
321
|
+
return '64'
|
|
322
|
+
}
|
|
323
|
+
return '44'
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// 单元格jsx函数组件
|
|
327
|
+
const renderCell = {
|
|
328
|
+
functional: true,
|
|
329
|
+
props: ['formatter', 'row', 'column', 'index', 'lineHeight', 'border', 'allFormatter'],
|
|
330
|
+
render(h, self) {
|
|
331
|
+
return self.props.formatter(h, {
|
|
332
|
+
row: self.props.row,
|
|
333
|
+
column: self.props.column,
|
|
334
|
+
index: self.props.index,
|
|
335
|
+
onCellClick: self.listeners['cell-click'],
|
|
336
|
+
lineHeight: self.props.lineHeight,
|
|
337
|
+
border: self.props.border,
|
|
338
|
+
allFormatter: self.props.allFormatter
|
|
339
|
+
})
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// 表头jsx函数组件
|
|
344
|
+
const renderHeader = {
|
|
345
|
+
functional: true,
|
|
346
|
+
props: ['formatter', 'column', 'currentSortKey', 'currentSortType'],
|
|
347
|
+
render(h, self) {
|
|
348
|
+
return self.props.formatter(h, {
|
|
349
|
+
column: self.props.column,
|
|
350
|
+
currentSortKey: self.props.currentSortKey,
|
|
351
|
+
currentSortType: self.props.currentSortType,
|
|
352
|
+
onSort: self.listeners.sort
|
|
353
|
+
})
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
// 多级表头默认渲染函数
|
|
358
|
+
const defaultHeaderFormatter = (h, { column, currentSortKey, currentSortType, onSort }) => {
|
|
359
|
+
let firstStyle = {
|
|
360
|
+
width: `${column.width}px`
|
|
361
|
+
}
|
|
362
|
+
let list = column.children.map((item, i) => {
|
|
363
|
+
let itemStyle = {
|
|
364
|
+
width: `${(i === 0 ? item.width : item.width - 1) || 50}px`
|
|
365
|
+
}
|
|
366
|
+
let itemTitleStyle = {}
|
|
367
|
+
if (item.sort) {
|
|
368
|
+
let ascClass = 'ks-table__header-sort__asc' + (currentSortType === 'asc' && item.key === currentSortKey ? ' asc-active' : '')
|
|
369
|
+
let descClass = 'ks-table__header-sort__desc' + (currentSortType === 'desc' && item.key === currentSortKey ? ' desc-active' : '')
|
|
370
|
+
return (
|
|
371
|
+
<div class="ks-table__header-title-multiple__second-item ks-table__header-wrapper-sort" style={itemStyle} onClick={onSort.bind(null, item)}>
|
|
372
|
+
<div class="ks-table__header-title-multiple__second-item-title" style={itemTitleStyle}>
|
|
373
|
+
{item.title}
|
|
374
|
+
</div>
|
|
375
|
+
<div class="ks-table__header-sort">
|
|
376
|
+
<div class={ascClass}></div>
|
|
377
|
+
<div class={descClass}></div>
|
|
378
|
+
</div>
|
|
379
|
+
</div>
|
|
380
|
+
)
|
|
381
|
+
} else {
|
|
382
|
+
return (
|
|
383
|
+
<div class="ks-table__header-title-multiple__second-item" style={itemStyle}>
|
|
384
|
+
<div class="ks-table__header-title-multiple__second-item-title" style={itemTitleStyle}>
|
|
385
|
+
{item.title}
|
|
386
|
+
</div>
|
|
387
|
+
</div>
|
|
388
|
+
)
|
|
389
|
+
}
|
|
390
|
+
})
|
|
391
|
+
return (
|
|
392
|
+
<div class="ks-table__header-title-multiple">
|
|
393
|
+
<div class="ks-table__header-title-multiple__first" style={firstStyle}>
|
|
394
|
+
{column.title}
|
|
395
|
+
</div>
|
|
396
|
+
<div class="ks-table__header-title-multiple__second">{list}</div>
|
|
397
|
+
</div>
|
|
398
|
+
)
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// 多级表头列单元格默认渲染函数
|
|
402
|
+
const defaultCellFormatter = (h, { row, column, index, lineHeight, border, onCellClick, allFormatter }) => {
|
|
403
|
+
let list = column.children.map((item, i) => {
|
|
404
|
+
let itemStyle = {
|
|
405
|
+
width: `${(i === 0 ? item.width : item.width - (border ? 1 : 0)) || 50}px`,
|
|
406
|
+
lineHeight: `${lineHeight}px`
|
|
407
|
+
}
|
|
408
|
+
let itemTextStyle = {
|
|
409
|
+
width: `${((i === 0 ? item.width : item.width - (border ? 1 : 0)) || 50) - 8}px`,
|
|
410
|
+
color: item.color
|
|
411
|
+
}
|
|
412
|
+
return (
|
|
413
|
+
<div class="ks-table__multiple-cloumn-cell" style={itemStyle} onClick={e => onCellClick(e, item)}>
|
|
414
|
+
<span class="ks-table__multiple-cloumn-cell__text" style={itemTextStyle}>
|
|
415
|
+
{allFormatter[item.key] ? allFormatter[item.key](h, { row, column: item, index: `${index}-${i}` }) : row[item.key]}
|
|
416
|
+
</span>
|
|
417
|
+
</div>
|
|
418
|
+
)
|
|
419
|
+
})
|
|
420
|
+
let columnStyle = {
|
|
421
|
+
height: `${lineHeight - (border ? 1 : 0)}px`
|
|
422
|
+
}
|
|
423
|
+
return (
|
|
424
|
+
<div class="ks-table__multiple-cloumn" style={columnStyle}>
|
|
425
|
+
{list}
|
|
426
|
+
</div>
|
|
427
|
+
)
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
let loop = data => data.map((row, index) => ({ ...row, _checked: false, _index: index }))
|
|
431
|
+
|
|
432
|
+
export default {
|
|
433
|
+
name: 'ksTable',
|
|
434
|
+
components: {
|
|
435
|
+
draggable,
|
|
436
|
+
renderCell,
|
|
437
|
+
renderHeader
|
|
438
|
+
},
|
|
439
|
+
props: {
|
|
440
|
+
headerHeight: {
|
|
441
|
+
type: Number,
|
|
442
|
+
default: 28
|
|
443
|
+
},
|
|
444
|
+
lineHeight: {
|
|
445
|
+
type: Number,
|
|
446
|
+
default: 34
|
|
447
|
+
},
|
|
448
|
+
offsetTop: {
|
|
449
|
+
type: [Number, String],
|
|
450
|
+
default: getOffsetTop()
|
|
451
|
+
},
|
|
452
|
+
columns: {
|
|
453
|
+
type: Array,
|
|
454
|
+
default: () => []
|
|
455
|
+
},
|
|
456
|
+
data: {
|
|
457
|
+
type: Array,
|
|
458
|
+
default: () => []
|
|
459
|
+
},
|
|
460
|
+
pagination: {
|
|
461
|
+
type: Boolean,
|
|
462
|
+
default: true
|
|
463
|
+
},
|
|
464
|
+
page: {
|
|
465
|
+
type: Number,
|
|
466
|
+
default: 1
|
|
467
|
+
},
|
|
468
|
+
total: {
|
|
469
|
+
type: Number,
|
|
470
|
+
default: 0
|
|
471
|
+
},
|
|
472
|
+
pageSize: {
|
|
473
|
+
type: Number,
|
|
474
|
+
default: 10
|
|
475
|
+
},
|
|
476
|
+
index: {
|
|
477
|
+
type: Boolean,
|
|
478
|
+
default: true
|
|
479
|
+
},
|
|
480
|
+
selection: {
|
|
481
|
+
type: Boolean,
|
|
482
|
+
default: false
|
|
483
|
+
},
|
|
484
|
+
highlightRow: {
|
|
485
|
+
type: Function,
|
|
486
|
+
default: () => ''
|
|
487
|
+
},
|
|
488
|
+
storageKey: String,
|
|
489
|
+
headerFormatter: {
|
|
490
|
+
type: Object,
|
|
491
|
+
default: () => ({})
|
|
492
|
+
},
|
|
493
|
+
formatter: {
|
|
494
|
+
type: Object,
|
|
495
|
+
default: () => ({})
|
|
496
|
+
},
|
|
497
|
+
border: {
|
|
498
|
+
type: Boolean,
|
|
499
|
+
default: true
|
|
500
|
+
},
|
|
501
|
+
stripe: {
|
|
502
|
+
type: Boolean,
|
|
503
|
+
default: false
|
|
504
|
+
},
|
|
505
|
+
indexWidth: {
|
|
506
|
+
type: Number,
|
|
507
|
+
default: 40
|
|
508
|
+
},
|
|
509
|
+
headerTitle: {
|
|
510
|
+
type: String,
|
|
511
|
+
default: '横屏表格'
|
|
512
|
+
},
|
|
513
|
+
headerTitleHeight: {
|
|
514
|
+
type: Number,
|
|
515
|
+
default: 44
|
|
516
|
+
},
|
|
517
|
+
isStopDefualtScroll: {
|
|
518
|
+
type: Boolean,
|
|
519
|
+
default: true
|
|
520
|
+
},
|
|
521
|
+
isNewHeightCalculate: {
|
|
522
|
+
type: Boolean,
|
|
523
|
+
default: false
|
|
524
|
+
},
|
|
525
|
+
popoverOffset: {
|
|
526
|
+
type: Array,
|
|
527
|
+
default: () => [0, 0]
|
|
528
|
+
}
|
|
529
|
+
},
|
|
530
|
+
data() {
|
|
531
|
+
return {
|
|
532
|
+
isHorizontal: false,
|
|
533
|
+
showSettings: false,
|
|
534
|
+
currentSortKey: '',
|
|
535
|
+
currentSortType: '',
|
|
536
|
+
verticalTableHeight: this.lineHeight + 'px',
|
|
537
|
+
horizontalTableHeight: this.lineHeight + 'px',
|
|
538
|
+
clientWidth: 0,
|
|
539
|
+
horizontalTableMaxWidth: 0,
|
|
540
|
+
currentColumns: JSON.parse(JSON.stringify(this.columns)),
|
|
541
|
+
defaultHeaderFormatter,
|
|
542
|
+
defaultCellFormatter,
|
|
543
|
+
scrollX: 0,
|
|
544
|
+
scrollY: 0,
|
|
545
|
+
currentData: loop(this.data),
|
|
546
|
+
checkedAll: false,
|
|
547
|
+
indeterminate: false,
|
|
548
|
+
checkedRow: [],
|
|
549
|
+
stickyContainer: null,
|
|
550
|
+
ksStatusBarHeight: 0,
|
|
551
|
+
showPopover: false,
|
|
552
|
+
popoverStyle: {},
|
|
553
|
+
popoverContent: ''
|
|
554
|
+
}
|
|
555
|
+
},
|
|
556
|
+
computed: {
|
|
557
|
+
showColumns() {
|
|
558
|
+
let columns = JSON.parse(JSON.stringify(this.currentColumns))
|
|
559
|
+
const newColumns = columns
|
|
560
|
+
.map(item => {
|
|
561
|
+
if (item.children) {
|
|
562
|
+
item.children = item.children.filter(t => t.show)
|
|
563
|
+
item.width = item.children.reduce((total, item) => total + item.width, 0)
|
|
564
|
+
if (item.show && !item.children.length) {
|
|
565
|
+
item.show = false
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
return item
|
|
569
|
+
})
|
|
570
|
+
.filter(item => item.show)
|
|
571
|
+
return newColumns
|
|
572
|
+
},
|
|
573
|
+
tableWidth() {
|
|
574
|
+
return (
|
|
575
|
+
this.showColumns.reduce((total, item) => total + item.width + (this.border ? 1 : 0), 0) +
|
|
576
|
+
(this.index ? this.indexWidth + (this.border ? 1 : 0) : 0) +
|
|
577
|
+
(this.selection ? 40 + (this.border ? 1 : 0) : 0)
|
|
578
|
+
)
|
|
579
|
+
},
|
|
580
|
+
notFixedColumns() {
|
|
581
|
+
return this.showColumns.filter(item => !item.fixed)
|
|
582
|
+
},
|
|
583
|
+
fixedColumns() {
|
|
584
|
+
return this.showColumns.filter(item => item.fixed)
|
|
585
|
+
},
|
|
586
|
+
fixedTableWidth() {
|
|
587
|
+
return (
|
|
588
|
+
this.fixedColumns.reduce((total, item) => total + item.width + (this.border ? 1 : 0), 0) +
|
|
589
|
+
(this.index ? this.indexWidth + (this.border ? 1 : 0) : 0) +
|
|
590
|
+
(this.selection ? 40 + (this.border ? 1 : 0) : 0)
|
|
591
|
+
)
|
|
592
|
+
},
|
|
593
|
+
isFixed() {
|
|
594
|
+
return this.showColumns.some(item => item.fixed) || this.index || this.selection
|
|
595
|
+
},
|
|
596
|
+
checkboxClass() {
|
|
597
|
+
return this.indeterminate ? 'checkbox-column__header' : ''
|
|
598
|
+
}
|
|
599
|
+
},
|
|
600
|
+
mounted() {
|
|
601
|
+
this.isNewHeightCalculate ? this.newSetTableHeight() : this.setTableHeight()
|
|
602
|
+
this.$nextTick(() => {
|
|
603
|
+
this.getStoreSettings()
|
|
604
|
+
this.createScrollTable()
|
|
605
|
+
})
|
|
606
|
+
this.stickyContainer = this.$refs.root
|
|
607
|
+
},
|
|
608
|
+
beforeDestroy() {
|
|
609
|
+
this.clearScrollTable()
|
|
610
|
+
},
|
|
611
|
+
watch: {
|
|
612
|
+
$route() {
|
|
613
|
+
if (this.isHorizontal) {
|
|
614
|
+
this.closeHorizontal()
|
|
615
|
+
}
|
|
616
|
+
// 存在keep-alive保活路由切换回来head头的滚动位置丢失问题
|
|
617
|
+
const x = this.scroolTable && this.scroolTable.x || 0
|
|
618
|
+
if (this.$refs.head) {
|
|
619
|
+
this.$refs.head.scrollLeft = Math.abs(x)
|
|
620
|
+
}
|
|
621
|
+
},
|
|
622
|
+
columns: {
|
|
623
|
+
deep: true,
|
|
624
|
+
handler(val) {
|
|
625
|
+
this.currentColumns = JSON.parse(JSON.stringify(val))
|
|
626
|
+
this.clearScroll()
|
|
627
|
+
this.$nextTick(() => {
|
|
628
|
+
if (this.scroolTable) {
|
|
629
|
+
this.scroolTable.refresh()
|
|
630
|
+
this.scroolTable.scrollTo(0, 0)
|
|
631
|
+
}
|
|
632
|
+
})
|
|
633
|
+
}
|
|
634
|
+
},
|
|
635
|
+
// 滚动兜底处理
|
|
636
|
+
'scroolTable.x': {
|
|
637
|
+
deep: true,
|
|
638
|
+
handler(val) {
|
|
639
|
+
if (!this.isNumber(val)) {
|
|
640
|
+
this.scroolTable.x = 0
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
},
|
|
644
|
+
'scroolTable.y': {
|
|
645
|
+
deep: true,
|
|
646
|
+
handler(val) {
|
|
647
|
+
if (!this.isNumber(val)) {
|
|
648
|
+
this.scroolTable.y = 0
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
},
|
|
652
|
+
data: {
|
|
653
|
+
deep: true,
|
|
654
|
+
handler(val) {
|
|
655
|
+
this.currentData = loop(val)
|
|
656
|
+
if (this.scroolTable) {
|
|
657
|
+
// 数据变动高度发生变化,渲染后刷新iscroll重新计算可滚动高度
|
|
658
|
+
this.isNewHeightCalculate ? this.newSetTableHeight() : this.setTableHeight()
|
|
659
|
+
this.$nextTick(() => {
|
|
660
|
+
this.scroolTable.refresh()
|
|
661
|
+
this.scroolTable.scrollTo(this.scrollX, 0)
|
|
662
|
+
if (this.isFixed) {
|
|
663
|
+
this.$refs.fixedBody.scrollTop = 0
|
|
664
|
+
}
|
|
665
|
+
})
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
},
|
|
670
|
+
methods: {
|
|
671
|
+
isNumber(val) {
|
|
672
|
+
return val !== undefined && val !== null && !isNaN(val)
|
|
673
|
+
},
|
|
674
|
+
/**
|
|
675
|
+
* 创建iscroll实例
|
|
676
|
+
*/
|
|
677
|
+
createScrollTable(x = 0, y = 0) {
|
|
678
|
+
this.$refs.body.addEventListener('touchmove', this.stopDefualtScroll)
|
|
679
|
+
this.$refs.body.addEventListener('mousewheel', this.stopDefualtScroll)
|
|
680
|
+
this.scroolTable = new IScroll(this.$refs.body, {
|
|
681
|
+
scrollX: true,
|
|
682
|
+
scrollY: true,
|
|
683
|
+
probeType: 3,
|
|
684
|
+
mouseWheel: true,
|
|
685
|
+
bindToWrapper: true,
|
|
686
|
+
bounce: false,
|
|
687
|
+
disableTouch: false,
|
|
688
|
+
deceleration: 0.001,
|
|
689
|
+
preventDefault: false // 阻止默认行为
|
|
690
|
+
})
|
|
691
|
+
let handleScroll = () => {
|
|
692
|
+
// 记录滚动位置
|
|
693
|
+
this.scrollX = this.scroolTable.x
|
|
694
|
+
this.ScrollY = this.scroolTable.y
|
|
695
|
+
|
|
696
|
+
// 处理固定列跟随滚动
|
|
697
|
+
if (this.isFixed) {
|
|
698
|
+
window.requestAnimationFrame(() => {
|
|
699
|
+
this.$refs.fixedBody.scrollTop = Math.abs(this.scroolTable.y)
|
|
700
|
+
})
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
// 处理表头跟随滚动
|
|
704
|
+
window.requestAnimationFrame(() => {
|
|
705
|
+
this.$refs.head.scrollLeft = Math.abs(this.scroolTable.x)
|
|
706
|
+
})
|
|
707
|
+
}
|
|
708
|
+
// 监听滚动事件
|
|
709
|
+
this.scroolTable.on('scroll', handleScroll)
|
|
710
|
+
this.scroolTable.on('scrollEnd', handleScroll)
|
|
711
|
+
// 设置滚动位置
|
|
712
|
+
this.scroolTable.scrollTo(x, y)
|
|
713
|
+
},
|
|
714
|
+
/**
|
|
715
|
+
* 销毁事件绑定及iscroll实例
|
|
716
|
+
*/
|
|
717
|
+
clearScrollTable() {
|
|
718
|
+
this.$refs.body.removeEventListener('touchmove', this.stopDefualtScroll)
|
|
719
|
+
this.$refs.body.removeEventListener('mousewheel', this.stopDefualtScroll)
|
|
720
|
+
if (this.scroolTable) {
|
|
721
|
+
this.scroolTable.destroy()
|
|
722
|
+
this.scroolTable = null
|
|
723
|
+
}
|
|
724
|
+
},
|
|
725
|
+
setTableHeight(num) {
|
|
726
|
+
// 整个表格组件的高度,用户传入参数或者获取父容器高度
|
|
727
|
+
let height = num || window.getComputedStyle(this.$refs.root.parentNode).height
|
|
728
|
+
const footerHeight = 40 // 分页高度
|
|
729
|
+
// 横屏全屏时表格宽度,ipx兼容刘海屏,左右各设置26像素边距
|
|
730
|
+
this.horizontalTableMaxWidth = document.body.className.indexOf('ipx') === -1 ? window.screen.height : window.screen.height - 26 * 2
|
|
731
|
+
// 横屏全屏时屏幕高度,android减去状态栏高度22像素
|
|
732
|
+
// this.clientWidth = document.body.className.indexOf('android') === -1 ? window.screen.width : window.screen.width - 22
|
|
733
|
+
// ios和安卓在横屏状态下获取屏幕宽高不一致兼容,ios横竖屏获取不变,安卓会跟随改变
|
|
734
|
+
this.clientWidth = document.body.className.indexOf('android') === -1 ? window.screen.width : (this.isHorizontal ? window.screen.height - 22 : window.screen.width - 22)
|
|
735
|
+
// 获取横屏的头部高度
|
|
736
|
+
const headerTitle = this.headerTitleHeight
|
|
737
|
+
let heightInt = parseInt(height)
|
|
738
|
+
if (this.pagination) {
|
|
739
|
+
if (heightInt - this.headerHeight - footerHeight < this.lineHeight) {
|
|
740
|
+
// 表格高度小于行高则将表格高度设置为行高
|
|
741
|
+
this.verticalTableHeight = this.lineHeight + 'px'
|
|
742
|
+
this.horizontalTableHeight = this.lineHeight - headerTitle + 'px'
|
|
743
|
+
} else {
|
|
744
|
+
this.verticalTableHeight = heightInt - this.headerHeight - (this.border ? 2 : 0) - footerHeight + 'px'
|
|
745
|
+
this.horizontalTableHeight = this.clientWidth - this.headerHeight - (this.border ? 2 : 0) - footerHeight- headerTitle + 'px'
|
|
746
|
+
}
|
|
747
|
+
} else {
|
|
748
|
+
if (heightInt - this.headerHeight < this.lineHeight) {
|
|
749
|
+
// 表格高度小于行高则将表格高度设置为行高
|
|
750
|
+
this.verticalTableHeight = this.lineHeight + 'px'
|
|
751
|
+
this.horizontalTableHeight = this.lineHeight - headerTitle + 'px'
|
|
752
|
+
} else {
|
|
753
|
+
this.verticalTableHeight = heightInt - this.headerHeight - (this.border ? 2 : 0) + 'px'
|
|
754
|
+
this.horizontalTableHeight = this.clientWidth - this.headerHeight - (this.border ? 2 : 0) - headerTitle + 'px'
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
},
|
|
758
|
+
/**
|
|
759
|
+
* 新的高度计算法,解决鸿蒙手机高度计算问题
|
|
760
|
+
*/
|
|
761
|
+
newSetTableHeight(num) {
|
|
762
|
+
const screenHeight = window.innerHeight
|
|
763
|
+
const screenWidth = window.innerWidth
|
|
764
|
+
const footerHeight = 40 // 分页高度
|
|
765
|
+
// 整个表格组件的高度,用户传入参数或者获取父容器高度
|
|
766
|
+
let height = num || window.getComputedStyle(this.$refs.root.parentNode).height
|
|
767
|
+
// 横屏全屏时表格宽度,ipx兼容刘海屏,左右各设置26像素边距
|
|
768
|
+
this.horizontalTableMaxWidth = document.body.className.indexOf('ipx') === -1 ? screenHeight : screenHeight - 26 * 2
|
|
769
|
+
// 横屏全屏时屏幕高度,android减去状态栏高度22像素
|
|
770
|
+
// ios和安卓在横屏状态下获取屏幕宽高不一致兼容,ios横竖屏获取不变,安卓会跟随改变
|
|
771
|
+
this.clientWidth = this.isHorizontal ? screenHeight : screenWidth
|
|
772
|
+
// 获取横屏的头部高度
|
|
773
|
+
const headerTitle = this.headerTitleHeight
|
|
774
|
+
let heightInt = parseInt(height)
|
|
775
|
+
let verticalTableHeight = 0
|
|
776
|
+
let horizontalTableHeight = 0
|
|
777
|
+
if (this.pagination) {
|
|
778
|
+
// 在旋转横屏的时候this.$refs.root.parentNode高度变得异常
|
|
779
|
+
if (!this.isHorizontal && (heightInt - this.headerHeight - footerHeight < this.lineHeight)) {
|
|
780
|
+
// 表格高度小于行高则将表格高度设置为行高
|
|
781
|
+
verticalTableHeight = this.lineHeight
|
|
782
|
+
horizontalTableHeight = this.lineHeight - headerTitle
|
|
783
|
+
} else {
|
|
784
|
+
verticalTableHeight = heightInt - this.headerHeight - (this.border ? 2 : 0) - footerHeight
|
|
785
|
+
horizontalTableHeight = this.clientWidth - this.headerHeight - (this.border ? 2 : 0) - footerHeight- headerTitle
|
|
786
|
+
}
|
|
787
|
+
} else {
|
|
788
|
+
if (heightInt - this.headerHeight < this.lineHeight) {
|
|
789
|
+
// 表格高度小于行高则将表格高度设置为行高
|
|
790
|
+
verticalTableHeight = this.lineHeight
|
|
791
|
+
horizontalTableHeight = this.lineHeight - headerTitle
|
|
792
|
+
} else {
|
|
793
|
+
verticalTableHeight = heightInt - this.headerHeight - (this.border ? 2 : 0)
|
|
794
|
+
horizontalTableHeight = this.clientWidth - this.headerHeight - (this.border ? 2 : 0) - headerTitle
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
this.verticalTableHeight = Math.max(60, verticalTableHeight) + 'px'
|
|
798
|
+
this.horizontalTableHeight = Math.max(60, horizontalTableHeight) + 'px'
|
|
799
|
+
},
|
|
800
|
+
/**
|
|
801
|
+
* 使用本地用户个性设置作为列配置
|
|
802
|
+
*/
|
|
803
|
+
getStoreSettings() {
|
|
804
|
+
if (this.storageKey) {
|
|
805
|
+
let menuId = (window.ksui && window.ksui.menu && window.ksui.menu.id) || ''
|
|
806
|
+
let employeeNumber = (window.ksui && window.ksui.user && window.ksui.user.employeeNumber) || ''
|
|
807
|
+
let jsonStr = localStorage.getItem(`${menuId}-${this.storageKey}-${employeeNumber}`)
|
|
808
|
+
if (jsonStr) {
|
|
809
|
+
this.currentColumns = JSON.parse(jsonStr)
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
},
|
|
813
|
+
/**
|
|
814
|
+
* 排序事件
|
|
815
|
+
*/
|
|
816
|
+
handleSort(column) {
|
|
817
|
+
if (!column.children && column.sort) {
|
|
818
|
+
if (column.key === this.currentSortKey) {
|
|
819
|
+
this.currentSortType = this.currentSortType === 'asc' ? 'desc' : 'asc'
|
|
820
|
+
} else {
|
|
821
|
+
this.currentSortKey = column.key
|
|
822
|
+
this.currentSortType = 'asc'
|
|
823
|
+
}
|
|
824
|
+
this.initCheck()
|
|
825
|
+
this.$emit('sort', { key: column.key, sortType: this.currentSortType })
|
|
826
|
+
}
|
|
827
|
+
},
|
|
828
|
+
/**
|
|
829
|
+
* 设置排序字段(一般在需要设定默认排序字段时使用)
|
|
830
|
+
*/
|
|
831
|
+
setSort(key, sortType) {
|
|
832
|
+
this.currentSortKey = key
|
|
833
|
+
this.currentSortType = sortType
|
|
834
|
+
},
|
|
835
|
+
/**
|
|
836
|
+
* 分页事件
|
|
837
|
+
*/
|
|
838
|
+
handleChangePage(e) {
|
|
839
|
+
this.initCheck()
|
|
840
|
+
this.$emit('change-page', e)
|
|
841
|
+
},
|
|
842
|
+
/**
|
|
843
|
+
* 重置滚动位置
|
|
844
|
+
*/
|
|
845
|
+
clearScroll() {
|
|
846
|
+
this.scrollX = 0
|
|
847
|
+
this.scrollY = 0
|
|
848
|
+
this.$refs.body.scrollLeft = 0
|
|
849
|
+
this.$refs.head.scrollLeft = 0
|
|
850
|
+
this.$refs.body.scrollTop = 0
|
|
851
|
+
if (this.isFixed) {
|
|
852
|
+
this.$refs.fixedBody.scrollTop = 0
|
|
853
|
+
}
|
|
854
|
+
},
|
|
855
|
+
/**
|
|
856
|
+
* 启动横屏
|
|
857
|
+
*/
|
|
858
|
+
openHorizontal() {
|
|
859
|
+
if (window.ks && window.ks.setInterfaceOrientation) {
|
|
860
|
+
window.ks.setInterfaceOrientation({
|
|
861
|
+
orientation: 1
|
|
862
|
+
})
|
|
863
|
+
ks.setCloseButton({ isShow: false })
|
|
864
|
+
}
|
|
865
|
+
this.isHorizontal = true
|
|
866
|
+
this.$nextTick(() => {
|
|
867
|
+
this.$refs.horizontalTable.appendChild(this.$refs.verticalTable)
|
|
868
|
+
this.clearScroll()
|
|
869
|
+
this.scroolTable.scrollTo(0, 0)
|
|
870
|
+
this.scroolTable.refresh()
|
|
871
|
+
if (this.isNewHeightCalculate) {
|
|
872
|
+
// 延迟的目的是等原生能力旋转后拿到正确的window.innerHeight
|
|
873
|
+
setTimeout(() => {
|
|
874
|
+
this.newSetTableHeight()
|
|
875
|
+
}, 100)
|
|
876
|
+
}
|
|
877
|
+
})
|
|
878
|
+
},
|
|
879
|
+
/**
|
|
880
|
+
* 关闭横屏
|
|
881
|
+
*/
|
|
882
|
+
closeHorizontal() {
|
|
883
|
+
this.isHorizontal = false
|
|
884
|
+
this.$refs.verticalTableWrapper.appendChild(this.$refs.verticalTable)
|
|
885
|
+
if (window.ks && window.ks.setInterfaceOrientation) {
|
|
886
|
+
window.ks.setInterfaceOrientation({
|
|
887
|
+
orientation: 0
|
|
888
|
+
})
|
|
889
|
+
window.ks.setCloseButton({ isShow: true })
|
|
890
|
+
}
|
|
891
|
+
this.$nextTick(() => {
|
|
892
|
+
this.setHtmlFontSize()
|
|
893
|
+
this.clearScroll()
|
|
894
|
+
this.scroolTable.scrollTo(0, 0)
|
|
895
|
+
this.scroolTable.refresh()
|
|
896
|
+
// 延迟的目的是等原生能力旋转后拿到正确的window.innerHeight
|
|
897
|
+
setTimeout(() => {
|
|
898
|
+
this.newSetTableHeight()
|
|
899
|
+
}, 100)
|
|
900
|
+
})
|
|
901
|
+
this.$emit('close-horizontal')
|
|
902
|
+
},
|
|
903
|
+
// 设置HTML文档字体 rem据此设置生效
|
|
904
|
+
setHtmlFontSize() {
|
|
905
|
+
var clientWidth = document.documentElement.clientWidth
|
|
906
|
+
if (clientWidth) {
|
|
907
|
+
let px = clientWidth / 10
|
|
908
|
+
document.documentElement.style.fontSize = px + 'px'
|
|
909
|
+
}
|
|
910
|
+
},
|
|
911
|
+
/**
|
|
912
|
+
* 打开个性设置
|
|
913
|
+
*/
|
|
914
|
+
openSettings() {
|
|
915
|
+
if (!this.storageKey) {
|
|
916
|
+
return Toast('请设置storageKey属性')
|
|
917
|
+
}
|
|
918
|
+
this.showSettings = true
|
|
919
|
+
},
|
|
920
|
+
/**
|
|
921
|
+
* 保存个性设置到本地
|
|
922
|
+
*/
|
|
923
|
+
saveSettings() {
|
|
924
|
+
this.showSettings = false
|
|
925
|
+
let menuId = window.ksui.menu.id
|
|
926
|
+
let employeeNumber = window.ksui.user.employeeNumber
|
|
927
|
+
localStorage.setItem(`${menuId}-${this.storageKey}-${employeeNumber}`, JSON.stringify(this.currentColumns))
|
|
928
|
+
this.$nextTick(() => {
|
|
929
|
+
this.scroolTable.refresh()
|
|
930
|
+
})
|
|
931
|
+
},
|
|
932
|
+
/**
|
|
933
|
+
* 重置列配置
|
|
934
|
+
*/
|
|
935
|
+
resetSettings() {
|
|
936
|
+
this.showSettings = false
|
|
937
|
+
this.currentColumns = JSON.parse(JSON.stringify(this.columns))
|
|
938
|
+
let menuId = window.ksui.menu.id
|
|
939
|
+
let employeeNumber = window.ksui.user.employeeNumber
|
|
940
|
+
localStorage.removeItem(`${menuId}-${this.storageKey}-${employeeNumber}`)
|
|
941
|
+
this.$nextTick(() => {
|
|
942
|
+
this.scroolTable.refresh()
|
|
943
|
+
})
|
|
944
|
+
},
|
|
945
|
+
/**
|
|
946
|
+
* 阻止默认滚动事件
|
|
947
|
+
*/
|
|
948
|
+
stopDefualtScroll(e) {
|
|
949
|
+
const { scroolTable, isStopDefualtScroll } = this
|
|
950
|
+
if (isStopDefualtScroll) {
|
|
951
|
+
e.preventDefault();
|
|
952
|
+
return
|
|
953
|
+
}
|
|
954
|
+
const { y: scrollTop, maxScrollY } = scroolTable
|
|
955
|
+
const isBottom = maxScrollY === scrollTop
|
|
956
|
+
const isTop = scrollTop === 0
|
|
957
|
+
// 左右滑动
|
|
958
|
+
const lr = scroolTable.directionX !== 0
|
|
959
|
+
// 轻左右拖动问题
|
|
960
|
+
const lightMove = scroolTable.directionX === 0 && scroolTable.directionY === 0 && Math.abs(scroolTable.distY) < Math.abs(scroolTable.distX)
|
|
961
|
+
if (!isTop && !isBottom || lr || lightMove) {
|
|
962
|
+
e.preventDefault();
|
|
963
|
+
}
|
|
964
|
+
},
|
|
965
|
+
/**
|
|
966
|
+
* 单元格点击事件
|
|
967
|
+
*/
|
|
968
|
+
handleCellClick(row, column, index, event) {
|
|
969
|
+
this.handleShowPopover(row, column, event)
|
|
970
|
+
if (!column.children) {
|
|
971
|
+
this.$emit('cell-click', row, column, index)
|
|
972
|
+
}
|
|
973
|
+
},
|
|
974
|
+
findTdEl (el){
|
|
975
|
+
try {
|
|
976
|
+
if (el.tagName === 'TD' || el.className === 'ks-table__multiple-cloumn-cell') {
|
|
977
|
+
return el
|
|
978
|
+
} else {
|
|
979
|
+
return this.findTdEl(el.parentElement)
|
|
980
|
+
}
|
|
981
|
+
} catch {
|
|
982
|
+
return null
|
|
983
|
+
}
|
|
984
|
+
},
|
|
985
|
+
/**
|
|
986
|
+
* jsx单元格点击事件
|
|
987
|
+
*/
|
|
988
|
+
handleCellClick2(row, column, index, e) {
|
|
989
|
+
e.stopPropagation()
|
|
990
|
+
this.handleShowPopover(row, column, event)
|
|
991
|
+
this.$emit('cell-click', row, column, index)
|
|
992
|
+
},
|
|
993
|
+
handleShowPopover(row, column, event) {
|
|
994
|
+
if (column.showPopover) {
|
|
995
|
+
const target = this.findTdEl(event.target)
|
|
996
|
+
const targetStyle = target && target.getBoundingClientRect()
|
|
997
|
+
const { x, y } = targetStyle
|
|
998
|
+
this.popoverStyle = {
|
|
999
|
+
position: 'fixed',
|
|
1000
|
+
top: `${y - this.popoverOffset[1] + 4}px`,
|
|
1001
|
+
left: `${x + this.popoverOffset[0] + 20}px`
|
|
1002
|
+
}
|
|
1003
|
+
this.popoverContent = row[column.key]
|
|
1004
|
+
this.showPopover = true
|
|
1005
|
+
}
|
|
1006
|
+
},
|
|
1007
|
+
/**
|
|
1008
|
+
* 吸顶组件滚动事件
|
|
1009
|
+
*/
|
|
1010
|
+
stickyScroll(e) {
|
|
1011
|
+
this.$emit('sticky-scroll', e)
|
|
1012
|
+
},
|
|
1013
|
+
/**
|
|
1014
|
+
* 初始化复选框参数
|
|
1015
|
+
*/
|
|
1016
|
+
initCheck() {
|
|
1017
|
+
this.checkedAll = false
|
|
1018
|
+
this.indeterminate = false
|
|
1019
|
+
this.checkedRow = []
|
|
1020
|
+
},
|
|
1021
|
+
/**
|
|
1022
|
+
* 处理表格内容复选框勾选
|
|
1023
|
+
*/
|
|
1024
|
+
handleCheck(row) {
|
|
1025
|
+
let checked = !row._checked
|
|
1026
|
+
if (checked) {
|
|
1027
|
+
this.checkedRow.push({ ...row })
|
|
1028
|
+
} else {
|
|
1029
|
+
let index = this.checkedRow.findIndex(v => v._index === row._index)
|
|
1030
|
+
if (index > -1) {
|
|
1031
|
+
this.checkedRow.splice(index, 1)
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
this.$set(row, '_checked', checked)
|
|
1035
|
+
|
|
1036
|
+
// 处理全选/全不选状态
|
|
1037
|
+
let indeterminate = false
|
|
1038
|
+
let checkedAll = false
|
|
1039
|
+
if (this.checkedRow.length > 0) {
|
|
1040
|
+
if (this.checkedRow.length !== this.currentData.length) {
|
|
1041
|
+
indeterminate = true
|
|
1042
|
+
} else {
|
|
1043
|
+
checkedAll = true
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
this.checkedAll = checkedAll
|
|
1047
|
+
this.indeterminate = indeterminate
|
|
1048
|
+
this.emitChangeSelect()
|
|
1049
|
+
},
|
|
1050
|
+
/**
|
|
1051
|
+
* 处理表头复选框勾选
|
|
1052
|
+
*/
|
|
1053
|
+
handleCheckAll() {
|
|
1054
|
+
if (this.checkedRow.length !== this.currentData.length) {
|
|
1055
|
+
this.currentData = this.currentData.map(v => ({ ...v, _checked: true }))
|
|
1056
|
+
this.checkedRow = this.currentData.map(v => ({ ...v, _checked: true }))
|
|
1057
|
+
} else {
|
|
1058
|
+
this.currentData = this.currentData.map(v => ({ ...v, _checked: false }))
|
|
1059
|
+
this.checkedRow = []
|
|
1060
|
+
}
|
|
1061
|
+
this.checkedAll = !this.checkedAll
|
|
1062
|
+
this.indeterminate = false
|
|
1063
|
+
this.emitChangeSelect()
|
|
1064
|
+
},
|
|
1065
|
+
/**
|
|
1066
|
+
* 复选框点击事件
|
|
1067
|
+
*/
|
|
1068
|
+
emitChangeSelect() {
|
|
1069
|
+
this.$emit('selection-change', this.checkedRow, this.checkedRow.length === this.currentData.length)
|
|
1070
|
+
},
|
|
1071
|
+
getKsStatusBarHeight() {
|
|
1072
|
+
return new Promise(resolve => {
|
|
1073
|
+
try {
|
|
1074
|
+
const isIos = document.body.className.indexOf('android') === -1
|
|
1075
|
+
window.ks.callFunc({ method: "getKsStatusBarHeight", params: {} }).then(() => {
|
|
1076
|
+
this.ksStatusBarHeight = isIos ? 0 : 0
|
|
1077
|
+
}).finally(() => {
|
|
1078
|
+
resolve(true)
|
|
1079
|
+
})
|
|
1080
|
+
} catch (e) {
|
|
1081
|
+
resolve(true)
|
|
1082
|
+
}
|
|
1083
|
+
})
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
</script>
|
|
1088
|
+
|