@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,143 @@
|
|
|
1
|
+
import { upDateLocalCache } from '../../../hooks/use-generic-search'
|
|
2
|
+
import TableSettings from '../../table-settings/index.vue'
|
|
3
|
+
import { setLocalStorageItem } from '../../../utils/localStorage'
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
data() {
|
|
8
|
+
return {
|
|
9
|
+
showSetting: false,
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
methods: {
|
|
13
|
+
createTableSetting() {
|
|
14
|
+
const $props = this.$props
|
|
15
|
+
if (!$props.showSettingDialog) {
|
|
16
|
+
return null
|
|
17
|
+
}
|
|
18
|
+
const slot = this.$slots.default ? this.$slots.default[0] : this.$scopedSlots
|
|
19
|
+
const tableSettingAttrs = {
|
|
20
|
+
props: {
|
|
21
|
+
value: this.showSetting,
|
|
22
|
+
tableColumns: this.onlineColumns,
|
|
23
|
+
innerTabVisible: this.$props.innerTabVisible,
|
|
24
|
+
disabledAutoHideClose: this.$props.disabledAutoHideClose,
|
|
25
|
+
isShowHorizontal: this.isShowHorizontal,
|
|
26
|
+
},
|
|
27
|
+
on: {
|
|
28
|
+
input: val => (this.showSetting = val),
|
|
29
|
+
confirm: this.settingsConfirm,
|
|
30
|
+
initColumns: this.initColumns,
|
|
31
|
+
cancel: this.settingsCancel,
|
|
32
|
+
back: this.settingsBack,
|
|
33
|
+
reset: this.settingsReset,
|
|
34
|
+
},
|
|
35
|
+
ref: 'tableSettings',
|
|
36
|
+
scopedSlots: {
|
|
37
|
+
top: slot['setting-top'],
|
|
38
|
+
},
|
|
39
|
+
}
|
|
40
|
+
return <TableSettings {...tableSettingAttrs}></TableSettings>
|
|
41
|
+
},
|
|
42
|
+
// 打开个性设置弹窗
|
|
43
|
+
openSetting() {
|
|
44
|
+
this.showSetting = true
|
|
45
|
+
},
|
|
46
|
+
// 个性设置弹窗关闭确认
|
|
47
|
+
settingsConfirm(val) {
|
|
48
|
+
// 关闭动画和设置列头同时执行,在低端机器下阻塞进程。
|
|
49
|
+
setTimeout(async () => {
|
|
50
|
+
this.setOnlineColumns(val)
|
|
51
|
+
this.setColsToStorage(val)
|
|
52
|
+
await this.saveConfigToHttp(this.onlineColumns)
|
|
53
|
+
this.$emit('settingsConfirm', this.onlineColumns)
|
|
54
|
+
}, 0)
|
|
55
|
+
},
|
|
56
|
+
setColsToStorage(clos) {
|
|
57
|
+
if (!this.needCache) return
|
|
58
|
+
setLocalStorageItem('pe_stocks_quotes_table_fields-' + this.searchCode || '', JSON.stringify(clos))
|
|
59
|
+
},
|
|
60
|
+
// 个性设置取消
|
|
61
|
+
settingsCancel() {
|
|
62
|
+
this.$emit('settingsCancel')
|
|
63
|
+
},
|
|
64
|
+
// 个性设置返回
|
|
65
|
+
settingsBack() {
|
|
66
|
+
this.$emit('settingsBack')
|
|
67
|
+
},
|
|
68
|
+
// 个性设置重置
|
|
69
|
+
async settingsReset() {
|
|
70
|
+
this.resizeColumnMap = this.clearResizeColumnMap()
|
|
71
|
+
let val = await this.resetToHttp()
|
|
72
|
+
this.setOnlineColumns(val)
|
|
73
|
+
this.setColsToStorage(val)
|
|
74
|
+
this.$emit('settingsReset', this.onlineColumns)
|
|
75
|
+
},
|
|
76
|
+
/**
|
|
77
|
+
* 用户变更列显示/隐藏后,保存状态
|
|
78
|
+
* @param {*} columns
|
|
79
|
+
* @returns
|
|
80
|
+
*/
|
|
81
|
+
async saveConfigToHttp(columns) {
|
|
82
|
+
if (this.columns.length && !this.forceSaveSettings) {
|
|
83
|
+
return
|
|
84
|
+
}
|
|
85
|
+
this.genericId = await this.getGenericId()
|
|
86
|
+
let fieldContent = this.formatFieldContent(columns)
|
|
87
|
+
let fieldSnapshot = this.formatFieldSnapshot(columns)
|
|
88
|
+
let params = {
|
|
89
|
+
genericId: this.genericId,
|
|
90
|
+
menuId: ksui.menu.id,
|
|
91
|
+
fieldContent: JSON.stringify(fieldContent),
|
|
92
|
+
fieldSnapshot: JSON.stringify(fieldSnapshot),
|
|
93
|
+
}
|
|
94
|
+
await this.$http('system.genericSearch.field.saveOrUpdate', 10124, params)
|
|
95
|
+
await upDateLocalCache(params, 'update')
|
|
96
|
+
},
|
|
97
|
+
/**
|
|
98
|
+
* 个性设置重置
|
|
99
|
+
* @returns
|
|
100
|
+
*/
|
|
101
|
+
async resetToHttp() {
|
|
102
|
+
this.genericId = await this.getGenericId()
|
|
103
|
+
let params = {
|
|
104
|
+
genericId: this.genericId,
|
|
105
|
+
menuId: ksui.menu.id
|
|
106
|
+
}
|
|
107
|
+
let res = await this.$http('system.genericSearch.field.reset', 10124, params)
|
|
108
|
+
window.vant.Toast('重置成功')
|
|
109
|
+
let resetCols = JSON.parse(res.genericSearch)
|
|
110
|
+
resetCols.forEach(v => this.mergeColumn(v))
|
|
111
|
+
// upDateCatch({ id: params.genericId })
|
|
112
|
+
await upDateLocalCache({ ...params, fieldContent: res.genericSearch }, 'reset')
|
|
113
|
+
return resetCols
|
|
114
|
+
},
|
|
115
|
+
// 获取show的列
|
|
116
|
+
formatFieldContent(columns) {
|
|
117
|
+
return columns.filter(v => v.show).map(v => {
|
|
118
|
+
if (v.children) {
|
|
119
|
+
return {
|
|
120
|
+
key: v.key,
|
|
121
|
+
child: (v.children || []).filter(c => c.show).map(c => c.key)
|
|
122
|
+
}
|
|
123
|
+
} else {
|
|
124
|
+
return v.key
|
|
125
|
+
}
|
|
126
|
+
})
|
|
127
|
+
},
|
|
128
|
+
// 获取快照
|
|
129
|
+
formatFieldSnapshot(columns) {
|
|
130
|
+
return columns.reduce((prev, cur) => {
|
|
131
|
+
let obj = { show: !!cur.show }
|
|
132
|
+
if (cur.children && cur.children.length) {
|
|
133
|
+
obj.children = cur.children.reduce((p, c) => {
|
|
134
|
+
p[c.key] = { show: !!c.show }
|
|
135
|
+
return p
|
|
136
|
+
}, {})
|
|
137
|
+
}
|
|
138
|
+
prev[cur.key] = obj
|
|
139
|
+
return prev
|
|
140
|
+
}, {})
|
|
141
|
+
},
|
|
142
|
+
}
|
|
143
|
+
}
|
|
@@ -0,0 +1,519 @@
|
|
|
1
|
+
import cloneDeep from 'lodash/cloneDeep'
|
|
2
|
+
import debounce from 'lodash/debounce'
|
|
3
|
+
// 无限滚动数据的更新时间,防止用户长时间停留,滑动后数据不更新
|
|
4
|
+
const UPDATE_INTERVAL = 5 * 60 * 1000
|
|
5
|
+
// 获取全量id的数量
|
|
6
|
+
const idsPageSize = 10000
|
|
7
|
+
// 每次更新数据的数量
|
|
8
|
+
const upLength = Math.ceil(window.screen.width / 44) + 2
|
|
9
|
+
// 无限滚动需要多加载的行数
|
|
10
|
+
const addRowLength = 500
|
|
11
|
+
|
|
12
|
+
export default {
|
|
13
|
+
props: {
|
|
14
|
+
// mounted后直接加载数据
|
|
15
|
+
autoLoadData: {
|
|
16
|
+
type: Boolean,
|
|
17
|
+
default: true
|
|
18
|
+
},
|
|
19
|
+
// 禁用loading
|
|
20
|
+
disabledLoading: {
|
|
21
|
+
type: Boolean,
|
|
22
|
+
default: false
|
|
23
|
+
},
|
|
24
|
+
// 禁用表格请求
|
|
25
|
+
disabledHttp: {
|
|
26
|
+
type: Boolean,
|
|
27
|
+
default: false
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
data() {
|
|
31
|
+
return {
|
|
32
|
+
// 本次滚动前的开始行
|
|
33
|
+
beforeStartRow: 0,
|
|
34
|
+
// 本次滚动前的结束行
|
|
35
|
+
beforeEndRow: 0,
|
|
36
|
+
// 全量的ids
|
|
37
|
+
tableScrollIds: [],
|
|
38
|
+
// 所有的数据映射map
|
|
39
|
+
tableMap: {},
|
|
40
|
+
lastReqTime: null, // TODO 需要保证code与数据一致,且是最后一次的请求
|
|
41
|
+
// 缓存的排序参数
|
|
42
|
+
orderByClauses: null,
|
|
43
|
+
// querytable 默认300
|
|
44
|
+
innterDelayLoading: 300,
|
|
45
|
+
dataFinish_timeStamp: null, // 数据返回时间
|
|
46
|
+
idsFinish_timeStamp: null, // ids最后返回时间
|
|
47
|
+
isLoadingMore: false // 加载更多加载中状态
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
computed: {
|
|
51
|
+
// 无限滚动用来加载视口数据的key
|
|
52
|
+
idsKey() {
|
|
53
|
+
// 非无限滚动也需要生成map映射
|
|
54
|
+
return this.config?.idsKey || this.config?.scrollLoad?.idsKey || 'code'
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
created() {
|
|
58
|
+
this.initDefaultData()
|
|
59
|
+
},
|
|
60
|
+
mounted() {
|
|
61
|
+
if (!this.autoLoadData) {
|
|
62
|
+
return
|
|
63
|
+
}
|
|
64
|
+
this.loadData()
|
|
65
|
+
},
|
|
66
|
+
methods: {
|
|
67
|
+
async loadMoreData() {
|
|
68
|
+
// 防止重复加载及无数据时触发
|
|
69
|
+
if (this.isLoadingMore || this.isLoading || !this.tableData || this.tableData.length === 0) return
|
|
70
|
+
this.isLoadingMore = true
|
|
71
|
+
this.loadData({ page: this.currentPage + 1, loadMore: true })
|
|
72
|
+
},
|
|
73
|
+
initDefaultData() {
|
|
74
|
+
// 不需要响应式
|
|
75
|
+
this.loadIdsMap = {}
|
|
76
|
+
// 需要更新进表格的数据
|
|
77
|
+
this.willUpdateDataArr = []
|
|
78
|
+
},
|
|
79
|
+
// 处理分页参数
|
|
80
|
+
formatPageParams(params, options) {
|
|
81
|
+
const { page } = options || {}
|
|
82
|
+
params.page = page ? page : 1
|
|
83
|
+
return params
|
|
84
|
+
},
|
|
85
|
+
// 处理当前页总数
|
|
86
|
+
formatRowTotal(res) {
|
|
87
|
+
const { scrollLoad } = this.config
|
|
88
|
+
if (!scrollLoad) {
|
|
89
|
+
// 非无限滚动,需要设置为出参表格行数
|
|
90
|
+
res.rowTotal = res.rows.length
|
|
91
|
+
}
|
|
92
|
+
return res
|
|
93
|
+
},
|
|
94
|
+
// 处理排序参数
|
|
95
|
+
formatSortParams(params, options) {
|
|
96
|
+
const { reqProp, order } = options || {}
|
|
97
|
+
if (!(reqProp || this.orderByClauses)) return params
|
|
98
|
+
if (reqProp) {
|
|
99
|
+
// 优先使用传入的排序参数,并保存
|
|
100
|
+
let _orderByClauses = [{ field: reqProp, orderByMode: order === 'ascending' ? 0 : 1 }]
|
|
101
|
+
params.orderByClauses = _orderByClauses
|
|
102
|
+
this.orderByClauses = _orderByClauses
|
|
103
|
+
} else if (this.orderByClauses) {
|
|
104
|
+
// 翻页或其他场景,使用缓存好的排序参数
|
|
105
|
+
params.orderByClauses = this.orderByClauses
|
|
106
|
+
}
|
|
107
|
+
return params
|
|
108
|
+
},
|
|
109
|
+
// 请求数据
|
|
110
|
+
async loadData(options) {
|
|
111
|
+
if (this.disabledHttp) return
|
|
112
|
+
return new Promise(async (resolve, reject) => {
|
|
113
|
+
try {
|
|
114
|
+
if (!this.disabledLoading && !(options && options.loadMore)) {
|
|
115
|
+
// 底部加载更多时无需表格全局loading
|
|
116
|
+
this.isLoading = true
|
|
117
|
+
}
|
|
118
|
+
const { url, appkey, beforeHttp, afterHttp, scrollLoad, afterSetData, firstScreenDataCompleted } = this.config
|
|
119
|
+
const now = new Date().valueOf()
|
|
120
|
+
this.lastReqTime = now
|
|
121
|
+
|
|
122
|
+
// 需要无限滚动,加载全量id
|
|
123
|
+
scrollLoad && this.loadTableScrollIds(now, options)
|
|
124
|
+
|
|
125
|
+
let params = {
|
|
126
|
+
// 默认页码200
|
|
127
|
+
pageSize: this.config.pageSize || 200
|
|
128
|
+
}
|
|
129
|
+
// 请求前,外部可处理入参
|
|
130
|
+
let beforeParams = { url, appkey, params }
|
|
131
|
+
// 合并外部return的参数
|
|
132
|
+
let $params = typeof beforeHttp === 'function' ? { ...beforeParams, ...await beforeHttp(beforeParams) } : beforeParams
|
|
133
|
+
|
|
134
|
+
let { url: _url, appkey: _appkey, params: _params } = $params
|
|
135
|
+
|
|
136
|
+
// 每次请求,记录时间戳
|
|
137
|
+
let serach_time_stamp = now
|
|
138
|
+
|
|
139
|
+
// 处理分页参数
|
|
140
|
+
_params = this.formatPageParams(_params, options)
|
|
141
|
+
// 处理排序参数
|
|
142
|
+
_params = this.formatSortParams(_params, options)
|
|
143
|
+
let res = await this.$http(_url, _appkey, _params)
|
|
144
|
+
// 非无限滚动,重复请求,不赋值
|
|
145
|
+
if (!scrollLoad && serach_time_stamp < this.lastReqTime) {
|
|
146
|
+
return
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// 只赋值最后一次的请求
|
|
150
|
+
if (serach_time_stamp && this.lastReqTime && serach_time_stamp < this.lastReqTime) return
|
|
151
|
+
|
|
152
|
+
// 请求后,外部可处理出参
|
|
153
|
+
res = typeof afterHttp === 'function' ? await afterHttp(res) : res
|
|
154
|
+
res = this.formatRowTotal(res)
|
|
155
|
+
|
|
156
|
+
const { rowTotal, rows } = res
|
|
157
|
+
|
|
158
|
+
this.setTableData({ rowTotal, rows }, now, options)
|
|
159
|
+
|
|
160
|
+
// TODO 首屏数据设置完成
|
|
161
|
+
typeof afterSetData === 'function' && afterSetData()
|
|
162
|
+
typeof firstScreenDataCompleted === 'function' && firstScreenDataCompleted({ rowTotal, rows })
|
|
163
|
+
// this.tableData = res.rows
|
|
164
|
+
// TODO 取出参配置有问题
|
|
165
|
+
!scrollLoad && this.setPage({ page: _params.page, pageTotal: res.pageTotal })
|
|
166
|
+
if (options && options.loadMore && _params.page >= res.pageTotal || !!scrollLoad) {
|
|
167
|
+
// 当前页码等于最大页码时 或者 无限滚动
|
|
168
|
+
this.loadMoreFinish = true
|
|
169
|
+
}
|
|
170
|
+
this.isLoading = false
|
|
171
|
+
resolve(res)
|
|
172
|
+
} catch (error) {
|
|
173
|
+
this.checkNetType(error)
|
|
174
|
+
// TODO 错误是否需要清空数据
|
|
175
|
+
console.error('[query-table-search-error]', error)
|
|
176
|
+
reject(error)
|
|
177
|
+
}
|
|
178
|
+
})
|
|
179
|
+
},
|
|
180
|
+
// TODO, 暂时处理单元格数据 key都不存在的情况。此方法影响性能,后续要去除
|
|
181
|
+
createBaseData() {
|
|
182
|
+
// return Object.keys(val).reduce((base, v) => {
|
|
183
|
+
// base[v] = '-'
|
|
184
|
+
// return base
|
|
185
|
+
// }, {})
|
|
186
|
+
return {}
|
|
187
|
+
},
|
|
188
|
+
// 获取无限滚动需要的全量id
|
|
189
|
+
async loadTableScrollIds(now, options) {
|
|
190
|
+
try {
|
|
191
|
+
const { scrollLoad, appkey } = this.config
|
|
192
|
+
if (!scrollLoad) return
|
|
193
|
+
|
|
194
|
+
const { getIdsUrl, idsBeforeHttp, idsAfterHttp } = scrollLoad
|
|
195
|
+
|
|
196
|
+
let params = {}
|
|
197
|
+
|
|
198
|
+
// 请求前,外部可处理入参
|
|
199
|
+
let idsBeforeParams = { url: getIdsUrl, appkey, params }
|
|
200
|
+
// 合并外部return的参数
|
|
201
|
+
let $params = typeof idsBeforeHttp === 'function' ? { ...idsBeforeParams, ...await idsBeforeHttp(idsBeforeParams) } : idsBeforeParams
|
|
202
|
+
|
|
203
|
+
let { url: _url, appkey: _appkey, params: _params } = $params
|
|
204
|
+
// 无限滚动,首页数据需要设置唯一时间戳,用于校验是否为最后一次请求,与首页数据时间戳一致
|
|
205
|
+
let serach_time_stamp = now
|
|
206
|
+
|
|
207
|
+
// 处理排序参数
|
|
208
|
+
_params = this.formatSortParams(_params, options)
|
|
209
|
+
// id写死最大请求数量
|
|
210
|
+
let res = await this.$http(_url, _appkey, { ..._params, pageSize: idsPageSize })
|
|
211
|
+
|
|
212
|
+
// 只赋值最后一次的请求
|
|
213
|
+
if (serach_time_stamp && this.lastReqTime && serach_time_stamp < this.lastReqTime) return
|
|
214
|
+
|
|
215
|
+
// 请求后,外部可处理出参
|
|
216
|
+
res = typeof idsAfterHttp === 'function' ? await idsAfterHttp(res) : res
|
|
217
|
+
|
|
218
|
+
// res 需要处理成字符串数组['id1', 'id2]
|
|
219
|
+
this.tableScrollIds = res
|
|
220
|
+
|
|
221
|
+
this.idsFinish_timeStamp = now
|
|
222
|
+
|
|
223
|
+
this.setTableScrollIds()
|
|
224
|
+
} catch (error) {
|
|
225
|
+
console.error('[query-table-search-ids]', error)
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
// 无限滚动过程中加载数据
|
|
229
|
+
async scrollLoadData(scrollOptions) {
|
|
230
|
+
try {
|
|
231
|
+
const { scrollLoad, appkey, url } = this.config
|
|
232
|
+
if (!scrollLoad) return
|
|
233
|
+
|
|
234
|
+
const { scrollBeforeHttp, scrollAfterHttp } = scrollLoad
|
|
235
|
+
let params = {}
|
|
236
|
+
|
|
237
|
+
// 请求前,外部可处理入参
|
|
238
|
+
let scrollBeforeParams = { url, appkey, params }
|
|
239
|
+
|
|
240
|
+
let $params = typeof scrollBeforeHttp === 'function' ? { ...scrollBeforeParams, ...await scrollBeforeHttp(scrollBeforeParams, scrollOptions) } : scrollBeforeParams
|
|
241
|
+
|
|
242
|
+
let { url: _url, appkey: _appkey, params: _params } = $params
|
|
243
|
+
|
|
244
|
+
let res = await this.$http(_url, _appkey, _params)
|
|
245
|
+
|
|
246
|
+
// 请求后,外部可处理出参
|
|
247
|
+
res = typeof scrollAfterHttp === 'function' ? await scrollAfterHttp(res) : res
|
|
248
|
+
|
|
249
|
+
this.updateTableData(res.rows, 'api')
|
|
250
|
+
} catch (error) {
|
|
251
|
+
console.error('[query-table-scrollLoadData]', error)
|
|
252
|
+
}
|
|
253
|
+
// 清空本次请求加载中的ids
|
|
254
|
+
this.clearLoadIds(scrollOptions.code)
|
|
255
|
+
},
|
|
256
|
+
// 清空加载中的ids
|
|
257
|
+
clearLoadIds(codes) {
|
|
258
|
+
for (let index = 0; index < codes.length; index++) {
|
|
259
|
+
delete this.loadIdsMap[codes[index]]
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
async setTableData(val, now, loadOptions) {
|
|
263
|
+
let { rowTotal, rows, options: scrollData } = val
|
|
264
|
+
const nowDateStr = +new Date()
|
|
265
|
+
if (!scrollData) {
|
|
266
|
+
|
|
267
|
+
let tableData = []
|
|
268
|
+
let item = null
|
|
269
|
+
// 设置第一页数据,全部双向绑定
|
|
270
|
+
for (let index = 0; index < rows.length; index++) {
|
|
271
|
+
item = rows[index]
|
|
272
|
+
tableData.push({ ...item, id: 'pe_' + Math.random().toString(), __updateTime: nowDateStr })
|
|
273
|
+
}
|
|
274
|
+
// 根据总条数设置空行,用于一次展示所有数据,后续滚动过程中请求后合并空数据
|
|
275
|
+
for (let index = rows.length; index < rowTotal; index++) {
|
|
276
|
+
tableData.push({ ...this.createBaseData(rows[0]), id: 'pe_' + Math.random().toString(), name: '-', selectedFlag: null })
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
if (loadOptions && loadOptions.loadMore) {
|
|
280
|
+
rows.forEach(v => this.tableData.push(v))
|
|
281
|
+
} else {
|
|
282
|
+
this.tableData = tableData
|
|
283
|
+
}
|
|
284
|
+
this.isLoadingMore = false
|
|
285
|
+
this.dataFinish_timeStamp = now
|
|
286
|
+
// 第一页数据,非滚动
|
|
287
|
+
this.total = Math.max(rowTotal, this.tableData.length)
|
|
288
|
+
this.setTableScrollIds()
|
|
289
|
+
|
|
290
|
+
// 第一页数据,让表格回到顶部
|
|
291
|
+
if (!(loadOptions && loadOptions.loadMore)) {
|
|
292
|
+
this.$refs.peTable && this.$refs.peTable.scrollToTop()
|
|
293
|
+
// 如果有数据,异步存入到map内
|
|
294
|
+
setTimeout(() => {
|
|
295
|
+
this.tableData.forEach(item => {
|
|
296
|
+
if (item.__updateTime) {
|
|
297
|
+
this.tableMap[item[this.idsKey]] = item
|
|
298
|
+
}
|
|
299
|
+
})
|
|
300
|
+
}, 0)
|
|
301
|
+
}
|
|
302
|
+
} else {
|
|
303
|
+
// 滚动加载的数据
|
|
304
|
+
this.updateTableData(rows, 'api')
|
|
305
|
+
}
|
|
306
|
+
},
|
|
307
|
+
// 表格滑动拉取数据
|
|
308
|
+
tableScrollPullData: debounce(async function (e) {
|
|
309
|
+
const { scrollLoad } = this.config
|
|
310
|
+
if (!scrollLoad) return
|
|
311
|
+
let { startRow, endRow, action, rowsPerViewport } = e
|
|
312
|
+
|
|
313
|
+
// code还没请求回来
|
|
314
|
+
if (!this.tableScrollIds.length) {
|
|
315
|
+
// 保存数据用于code取回来后立即执行
|
|
316
|
+
this.beforeStartRow = startRow
|
|
317
|
+
this.beforeEndRow = endRow
|
|
318
|
+
return
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
if (action === 'reload') {
|
|
322
|
+
// 立即请求
|
|
323
|
+
startRow = this.beforeStartRow
|
|
324
|
+
endRow = this.beforeEndRow
|
|
325
|
+
} else {
|
|
326
|
+
// 未产生行数变更时,不调用接口
|
|
327
|
+
if (this.beforeStartRow === startRow && this.beforeEndRow === endRow) {
|
|
328
|
+
return
|
|
329
|
+
} else {
|
|
330
|
+
this.beforeStartRow = startRow
|
|
331
|
+
this.beforeEndRow = endRow
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
// TODO ? 业务逻辑
|
|
337
|
+
// if (startRow !== undefined && endRow !== undefined && isPullKLine) {
|
|
338
|
+
// // 暂时隐藏,后续需要根据调用状态判断是否需要原生方法
|
|
339
|
+
// const curCodes = this.tableScrollIds.slice(startRow, endRow)
|
|
340
|
+
// try {
|
|
341
|
+
// window.ks.callFunc({ method: "preLoadStockKlineToFile", params: { ids: uniq(curCodes) } })
|
|
342
|
+
// } catch (error) {
|
|
343
|
+
// console.log(error)
|
|
344
|
+
// }
|
|
345
|
+
// }
|
|
346
|
+
|
|
347
|
+
// 优化处理,不重复请求已有数据
|
|
348
|
+
let codes = []
|
|
349
|
+
// 预加载多一屏数据
|
|
350
|
+
|
|
351
|
+
// 是否需要预加载
|
|
352
|
+
// 校验下一屏是否是空的
|
|
353
|
+
const checkNextViewData = () => {
|
|
354
|
+
const nowDateStr = +new Date()
|
|
355
|
+
let checkStartRow = startRow
|
|
356
|
+
let checkEndRow = endRow + rowsPerViewport
|
|
357
|
+
let id = null
|
|
358
|
+
let item = null
|
|
359
|
+
let load = false
|
|
360
|
+
while (checkStartRow <= checkEndRow) {
|
|
361
|
+
id = this.tableScrollIds[checkStartRow]
|
|
362
|
+
item = this.tableMap[id]
|
|
363
|
+
const noItem = id && !item
|
|
364
|
+
const oldItem = item && (!item.__updateTime || nowDateStr > UPDATE_INTERVAL + item.__updateTime)
|
|
365
|
+
if (id && (noItem || oldItem)) {
|
|
366
|
+
load = true
|
|
367
|
+
break
|
|
368
|
+
}
|
|
369
|
+
checkStartRow++
|
|
370
|
+
}
|
|
371
|
+
return load
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
if (!checkNextViewData()) {
|
|
375
|
+
return
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
let preloadEndRow = Math.min(endRow + addRowLength, this.tableScrollIds.length)
|
|
379
|
+
if (preloadEndRow > 0) {
|
|
380
|
+
let i = startRow
|
|
381
|
+
const nowDateStr = +new Date()
|
|
382
|
+
let id = null
|
|
383
|
+
let item = null
|
|
384
|
+
while (i <= preloadEndRow) {
|
|
385
|
+
// 如果已经有数据,不需要再请求获取
|
|
386
|
+
// 加入更新时间,如果超过指定时间需要重新获取
|
|
387
|
+
id = this.tableScrollIds[i] || ''
|
|
388
|
+
item = this.tableMap[id]
|
|
389
|
+
|
|
390
|
+
const noItem = id && !item
|
|
391
|
+
const oldItem = item && (!item.__updateTime || nowDateStr > UPDATE_INTERVAL + item.__updateTime)
|
|
392
|
+
const idLoad = this.loadIdsMap[id] // 加载中的数据
|
|
393
|
+
|
|
394
|
+
if (id && (noItem || oldItem) && !idLoad) {
|
|
395
|
+
codes.push(id)
|
|
396
|
+
this.loadIdsMap[id] = true
|
|
397
|
+
}
|
|
398
|
+
i++
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
if (!codes.length) return
|
|
403
|
+
|
|
404
|
+
let options = {
|
|
405
|
+
code: codes,
|
|
406
|
+
startRow,
|
|
407
|
+
endRow,
|
|
408
|
+
}
|
|
409
|
+
this.scrollLoadData(options)
|
|
410
|
+
|
|
411
|
+
}, 100),
|
|
412
|
+
/**
|
|
413
|
+
* 基于ID过滤并合并两个大型数组,保持原始顺序
|
|
414
|
+
* @param {Array} arr1 第一个数组(将被过滤)
|
|
415
|
+
* @param {Array} arr2 第二个数组(将完整保留)
|
|
416
|
+
* @returns {Array} 合并后的新数组
|
|
417
|
+
*/
|
|
418
|
+
filterAndMergeArrays(arr1, arr2) {
|
|
419
|
+
// 创建第二个数组的ID集合用于快速查找
|
|
420
|
+
const arr2IdSet = new Set()
|
|
421
|
+
for (const item of arr2) {
|
|
422
|
+
if (item[this.idsKey]) {
|
|
423
|
+
arr2IdSet.add(item[this.idsKey])
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
// 过滤第一个数组中存在于第二个数组的项
|
|
428
|
+
const filteredArr1 = []
|
|
429
|
+
for (const item of arr1) {
|
|
430
|
+
if (item[this.idsKey] && !arr2IdSet.has(item[this.idsKey])) {
|
|
431
|
+
filteredArr1.push(item)
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
// 合并数组(保持顺序)
|
|
436
|
+
return [...filteredArr1, ...arr2]
|
|
437
|
+
},
|
|
438
|
+
// 更新数据
|
|
439
|
+
updateTableData(arr, type, callback) {
|
|
440
|
+
// 去除已在队列中的的重复数据,以新的为准,减少更新操作,提升性能
|
|
441
|
+
this.willUpdateDataArr = this.filterAndMergeArrays([...this.willUpdateDataArr], arr)
|
|
442
|
+
const nowDateStr = +new Date()
|
|
443
|
+
const step = () => {
|
|
444
|
+
if (this.willUpdateDataArr.length === 0) return
|
|
445
|
+
// 每次只更新设置好的行数
|
|
446
|
+
let upList = this.willUpdateDataArr.splice(0, upLength)
|
|
447
|
+
for (let index = 0; index < upList.length; index++) {
|
|
448
|
+
const item = upList[index]
|
|
449
|
+
const id = item[this.idsKey]
|
|
450
|
+
// 后端返回的直接赋值,实时数据需要该行不为空
|
|
451
|
+
if (this.tableMap[id] && (type === 'api' || this.tableMap[id].__updateTime)) {
|
|
452
|
+
const oldItem = cloneDeep(this.tableMap[id])
|
|
453
|
+
Object.assign(this.tableMap[id], item, { __updateTime: nowDateStr })
|
|
454
|
+
callback && callback(this.tableMap[id], oldItem)
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
// 每次设置完数据,主动更新
|
|
458
|
+
this.$refs?.peTable?.renderViewportRows()
|
|
459
|
+
requestAnimationFrame(step)
|
|
460
|
+
}
|
|
461
|
+
requestAnimationFrame(step)
|
|
462
|
+
},
|
|
463
|
+
resetTableData(i) {
|
|
464
|
+
// 重置下总数
|
|
465
|
+
this.total = i
|
|
466
|
+
if (this.tableData.length !== i) {
|
|
467
|
+
this.tableData = this.tableData.slice(0, i)
|
|
468
|
+
}
|
|
469
|
+
},
|
|
470
|
+
checkSetIds() {
|
|
471
|
+
// 数据返回是最新的,并且ids返回是最新的
|
|
472
|
+
return this.dataFinish_timeStamp === this.lastReqTime && this.idsFinish_timeStamp === this.lastReqTime
|
|
473
|
+
},
|
|
474
|
+
// 给每一行数据设置数据需要的id
|
|
475
|
+
setTableScrollIds() {
|
|
476
|
+
if (!this.config.scrollLoad) return
|
|
477
|
+
// 需要首页search 和 ids 是同一轮
|
|
478
|
+
if (!this.checkSetIds()) return
|
|
479
|
+
let i = Math.min(this.tableData.length, this.tableScrollIds.length)
|
|
480
|
+
// 兜底,ids与rowTotal 长度不一致时,用短的
|
|
481
|
+
this.resetTableData(i)
|
|
482
|
+
let id = null
|
|
483
|
+
let item = null
|
|
484
|
+
while (i--) {
|
|
485
|
+
item = this.tableData[i]
|
|
486
|
+
if (item[this.idsKey] === '-' || !item[this.idsKey]) {
|
|
487
|
+
id = this.tableScrollIds[i]
|
|
488
|
+
item[this.idsKey] = id
|
|
489
|
+
this.tableMap[id] = item
|
|
490
|
+
this.tableMap[id].__index = i
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
const { scrollLoad } = this.config
|
|
494
|
+
const { setScrollIdsAfter } = scrollLoad
|
|
495
|
+
typeof setScrollIdsAfter === 'function' && setScrollIdsAfter()
|
|
496
|
+
},
|
|
497
|
+
// 校验网络状态
|
|
498
|
+
async checkNetType(e) {
|
|
499
|
+
this.isLoading = false
|
|
500
|
+
// 后端超时
|
|
501
|
+
if (e.data && [27057].includes(e.data.code)) {
|
|
502
|
+
this.tableData = []
|
|
503
|
+
this.tableIsAbnormal = true
|
|
504
|
+
return
|
|
505
|
+
}
|
|
506
|
+
// 前端取消
|
|
507
|
+
if (e.message === (window.networkTimeoutMessage || '请求超时,服务器未响应')) {
|
|
508
|
+
this.tableData = []
|
|
509
|
+
this.tableIsAbnormal = true
|
|
510
|
+
return
|
|
511
|
+
}
|
|
512
|
+
if (window.ks) {
|
|
513
|
+
const netStatus = await window.ks.callFunc({ method: 'getNetType', params: {} })
|
|
514
|
+
this.tableData = netStatus === 1 ? [] : this.tableData
|
|
515
|
+
this.tableIsAbnormal = netStatus === 1
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
|
|
2
|
+
export default {
|
|
3
|
+
props: {
|
|
4
|
+
showPage: Boolean
|
|
5
|
+
},
|
|
6
|
+
data() {
|
|
7
|
+
return {
|
|
8
|
+
currentPage: 1,
|
|
9
|
+
totalPages: 1
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
methods: {
|
|
13
|
+
setPage(res) {
|
|
14
|
+
// TODO 需要缓存页码
|
|
15
|
+
// if (!this.showPage ) {
|
|
16
|
+
// return
|
|
17
|
+
// }
|
|
18
|
+
this.currentPage = res.page
|
|
19
|
+
this.totalPages = res.pageTotal
|
|
20
|
+
},
|
|
21
|
+
onPageChanged(newPage) {
|
|
22
|
+
this.currentPage = newPage
|
|
23
|
+
this.loadData({ page: newPage })
|
|
24
|
+
},
|
|
25
|
+
}
|
|
26
|
+
}
|