@kyfe/ks-query-table 0.0.22 → 0.0.24
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/index.js +11 -0
- package/package.json +10 -81
- package/.bitmap +0 -38
- package/.editorconfig +0 -5
- package/.env.dev +0 -2
- package/.env.gray +0 -2
- package/.env.prod +0 -2
- package/.env.stg +0 -3
- package/.env.uat +0 -2
- package/.eslintignore +0 -1
- package/.eslintrc.js +0 -25
- package/.gitmodules +0 -4
- package/.prettierrc +0 -11
- package/README.md +0 -15
- package/babel.config.js +0 -10
- package/build-apm.sh +0 -9
- package/build.sh +0 -16
- package/config/index.js +0 -20
- package/jsconfig.json +0 -7
- package/kuasheng-sdk/index.js +0 -80
- package/kuasheng-sdk/lib/assets.js +0 -304
- package/kuasheng-sdk/lib/context.js +0 -199
- package/kuasheng-sdk/lib/layout.js +0 -346
- package/kuasheng-sdk/lib/location.js +0 -46
- package/kuasheng-sdk/lib/media.js +0 -342
- package/kuasheng-sdk/lib/navigation.js +0 -30
- package/kuasheng-sdk/lib/request.js +0 -76
- package/kuasheng-sdk/lib/system.js +0 -190
- package/kuasheng-sdk/lib/userinfo.js +0 -98
- package/kuasheng-sdk/util/check.js +0 -102
- package/kuasheng-sdk/util/config.js +0 -47
- package/kuasheng-sdk/util/device.js +0 -25
- package/kuasheng-sdk/util/error.js +0 -19
- package/kuasheng-sdk/util/funtional.js +0 -153
- package/kuasheng-sdk/util/mixin.js +0 -36
- package/kuasheng-sdk/util/requestUtil.js +0 -41
- package/kuasheng-sdk/util/response.js +0 -33
- package/kuasheng-sdk/util/warn.js +0 -35
- package/kuasheng-ui/CHANGELOG.md +0 -9
- package/kuasheng-ui/components/card.vue +0 -57
- package/kuasheng-ui/components/ks-area-select/README.md +0 -43
- package/kuasheng-ui/components/ks-area-select/area-picker.vue +0 -554
- package/kuasheng-ui/components/ks-area-select/area-search.vue +0 -363
- package/kuasheng-ui/components/ks-area-select/areas-pop.vue +0 -56
- package/kuasheng-ui/components/ks-area-select/common.js +0 -183
- package/kuasheng-ui/components/ks-area-select/index.vue +0 -355
- package/kuasheng-ui/components/ks-area-select/mixins.js +0 -216
- package/kuasheng-ui/components/ks-area-single-select/README.md +0 -50
- package/kuasheng-ui/components/ks-area-single-select/hot-city.js +0 -45
- package/kuasheng-ui/components/ks-area-single-select/index.vue +0 -324
- package/kuasheng-ui/components/ks-calendar/index.vue +0 -269
- package/kuasheng-ui/components/ks-call-phone/call-tips.vue +0 -70
- package/kuasheng-ui/components/ks-call-phone/call.vue +0 -178
- package/kuasheng-ui/components/ks-call-phone/index.js +0 -48
- package/kuasheng-ui/components/ks-call-phone/index.vue +0 -131
- 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 +0 -23
- package/kuasheng-ui/components/ks-date-picker/date-picker-bottom.vue +0 -123
- package/kuasheng-ui/components/ks-date-picker/date-picker-dropdown.vue +0 -80
- package/kuasheng-ui/components/ks-date-picker/date-picker-right.vue +0 -87
- package/kuasheng-ui/components/ks-date-picker/date-picker-top.vue +0 -88
- package/kuasheng-ui/components/ks-date-picker/date-picker.js +0 -15
- package/kuasheng-ui/components/ks-date-picker/date-range-select.vue +0 -92
- package/kuasheng-ui/components/ks-date-picker/date-select.vue +0 -65
- package/kuasheng-ui/components/ks-date-picker/date-week-month.vue +0 -131
- package/kuasheng-ui/components/ks-date-picker/index.js +0 -12
- package/kuasheng-ui/components/ks-date-picker/mixin.js +0 -92
- package/kuasheng-ui/components/ks-date-picker/month-range-select.vue +0 -129
- package/kuasheng-ui/components/ks-date-picker/month-select.vue +0 -85
- package/kuasheng-ui/components/ks-date-picker/quarter-select.vue +0 -94
- package/kuasheng-ui/components/ks-date-picker/style.less +0 -121
- package/kuasheng-ui/components/ks-date-picker/utils.js +0 -109
- package/kuasheng-ui/components/ks-date-picker/week-select.vue +0 -99
- package/kuasheng-ui/components/ks-decrypt/index.vue +0 -159
- package/kuasheng-ui/components/ks-employee/README.md +0 -78
- package/kuasheng-ui/components/ks-employee/employee-input.vue +0 -173
- package/kuasheng-ui/components/ks-employee/employee-list.vue +0 -662
- package/kuasheng-ui/components/ks-employee/employee-popup.vue +0 -197
- package/kuasheng-ui/components/ks-employee/employee-search.vue +0 -250
- package/kuasheng-ui/components/ks-employee/employee-selected.vue +0 -173
- package/kuasheng-ui/components/ks-employee/index.js +0 -17
- package/kuasheng-ui/components/ks-employee/package-lock.json +0 -5
- package/kuasheng-ui/components/ks-employee/package.json +0 -15
- package/kuasheng-ui/components/ks-employee/yarn.lock +0 -4
- package/kuasheng-ui/components/ks-field-money/index.js +0 -8
- package/kuasheng-ui/components/ks-field-money/index.vue +0 -212
- package/kuasheng-ui/components/ks-field-money/package.json +0 -11
- package/kuasheng-ui/components/ks-field-money/utils.js +0 -65
- 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 +0 -131
- package/kuasheng-ui/components/ks-history-search/history-list.vue +0 -188
- package/kuasheng-ui/components/ks-history-search/img/delete.png +0 -0
- package/kuasheng-ui/components/ks-history-search/index.js +0 -9
- package/kuasheng-ui/components/ks-history-search/index.vue +0 -125
- package/kuasheng-ui/components/ks-history-search/package-lock.json +0 -5
- package/kuasheng-ui/components/ks-history-search/package.json +0 -15
- package/kuasheng-ui/components/ks-history-search/utils.js +0 -35
- package/kuasheng-ui/components/ks-input-search/index.vue +0 -106
- package/kuasheng-ui/components/ks-list/index.vue +0 -75
- package/kuasheng-ui/components/ks-loading/index.js +0 -16
- package/kuasheng-ui/components/ks-month/index.vue +0 -47
- package/kuasheng-ui/components/ks-month/package.json +0 -3
- package/kuasheng-ui/components/ks-month/range.vue +0 -172
- package/kuasheng-ui/components/ks-month/single.vue +0 -136
- package/kuasheng-ui/components/ks-month/style.less +0 -125
- package/kuasheng-ui/components/ks-month/utils.js +0 -35
- package/kuasheng-ui/components/ks-nav/index.vue +0 -264
- package/kuasheng-ui/components/ks-nav-bar.js +0 -35
- package/kuasheng-ui/components/ks-org/ks-org-tree.vue +0 -247
- package/kuasheng-ui/components/ks-org/ks-popup-tree.vue +0 -154
- package/kuasheng-ui/components/ks-org/ks-tree-input.vue +0 -240
- package/kuasheng-ui/components/ks-org/ks-tree-node.vue +0 -94
- package/kuasheng-ui/components/ks-org/ks-tree.vue +0 -229
- package/kuasheng-ui/components/ks-org/utils.js +0 -54
- package/kuasheng-ui/components/ks-popover/index.vue +0 -457
- package/kuasheng-ui/components/ks-popover/mixin.js +0 -28
- package/kuasheng-ui/components/ks-popover/utils.js +0 -60
- package/kuasheng-ui/components/ks-pull-refresh/index.vue +0 -43
- package/kuasheng-ui/components/ks-quarter/index.vue +0 -256
- package/kuasheng-ui/components/ks-table/README.md +0 -103
- package/kuasheng-ui/components/ks-table/cell.vue +0 -31
- package/kuasheng-ui/components/ks-table/index.js +0 -8
- package/kuasheng-ui/components/ks-table/index.less +0 -486
- package/kuasheng-ui/components/ks-table/index.vue +0 -1088
- package/kuasheng-ui/components/ks-table/package.json +0 -12
- package/kuasheng-ui/components/ks-table/release.md +0 -7
- package/kuasheng-ui/components/ks-toast.js +0 -35
- package/kuasheng-ui/components/ks-upload/index.vue +0 -174
- package/kuasheng-ui/components/ks-user-access.vue +0 -229
- package/kuasheng-ui/components/no-data/README.md +0 -45
- package/kuasheng-ui/components/no-data/image.js +0 -1
- package/kuasheng-ui/components/no-data/index.vue +0 -83
- package/kuasheng-ui/components/notice-bar.vue +0 -16
- package/kuasheng-ui/components/steps.js +0 -11
- package/kuasheng-ui/components/tabs.vue +0 -40
- package/kuasheng-ui/index.js +0 -239
- package/kuasheng-ui/patch/datetime-picker/datetimePicker.md +0 -0
- package/kuasheng-ui/patch/datetime-picker/index.js +0 -46
- package/kuasheng-ui/patch/datetime-picker/utils.js +0 -78
- package/kuasheng-ui/patch/field/field.md +0 -1
- package/kuasheng-ui/patch/field/index.js +0 -122
- package/kuasheng-ui/patch/field/utils.js +0 -36
- package/kuasheng-ui/patch/form/form.md +0 -7
- package/kuasheng-ui/patch/form/index.js +0 -106
- package/kuasheng-ui/patch/index.js +0 -12
- package/kuasheng-ui/patch/pagination/index.js +0 -78
- package/kuasheng-ui/style/animation-ui.less +0 -31
- 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 +0 -1
- package/kuasheng-ui/style/images/success.svg +0 -1
- package/kuasheng-ui/style/index.less +0 -6
- package/kuasheng-ui/style/kuasheng-ui.less +0 -207
- package/kuasheng-ui/style/reset-vant.less +0 -307
- package/kuasheng-ui/style/vant-var.less +0 -138
- package/kuasheng-ui/utils/apis.js +0 -17
- package/kuasheng-ui/utils/axios-adapter.js +0 -47
- package/kuasheng-ui/utils/bem.js +0 -39
- package/kuasheng-ui/utils/bus.js +0 -97
- package/kuasheng-ui/utils/common.js +0 -88
- package/kuasheng-ui/utils/decrypt/config.js +0 -12
- package/kuasheng-ui/utils/decrypt/decrypt-api.js +0 -139
- package/kuasheng-ui/utils/decrypt/index.js +0 -6
- package/kuasheng-ui/utils/decrypt/mask.js +0 -36
- package/kuasheng-ui/utils/decrypt/virtual.js +0 -44
- package/kuasheng-ui/utils/directive.js +0 -57
- package/kuasheng-ui/utils/directive.md +0 -23
- package/kuasheng-ui/utils/drcheck-plugin.js +0 -219
- package/kuasheng-ui/utils/error-plugin.js +0 -88
- package/kuasheng-ui/utils/filter.js +0 -149
- package/kuasheng-ui/utils/http-interceptors.js +0 -18
- package/kuasheng-ui/utils/http.js +0 -140
- package/kuasheng-ui/utils/index.js +0 -5
- package/kuasheng-ui/utils/init-event.js +0 -20
- package/kuasheng-ui/utils/log.js +0 -309
- package/kuasheng-ui/utils/token.js +0 -9
- package/kuasheng-ui/utils/type.js +0 -45
- package/kuasheng-ui/utils/validate.js +0 -20
- package/kuasheng-ui/utils/watermark.js +0 -67
- package/kuasheng-ui/version.js +0 -1
- package/ky-apm/client.js +0 -37
- package/ky-apm/customHttp.js +0 -38
- package/ky-apm/index.js +0 -68
- package/ky-apm/plugins/performance.js +0 -84
- package/ky-apm/plugins/self-error.js +0 -26
- package/ky-apm/warn-log.js +0 -3
- package/plugin/ks-chii-webpack-html/index.js +0 -53
- package/plugin/ks-chii-webpack-html/package.json +0 -16
- package/postcss.config.js +0 -15
- package/public/capsule-positon.js +0 -50
- package/public/fonts/DingTalkJinBuTi.ttf +0 -0
- package/public/framework/axios@0.19.0.min.js +0 -9
- package/public/framework/fastclick@1.0.6.min.js +0 -1
- package/public/framework/iconfont/iconfont.css +0 -91
- package/public/framework/iconfont/iconfont.js +0 -1
- package/public/framework/iconfont/iconfont.json +0 -142
- 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 +0 -7
- package/public/framework/vue-router@3.1.3.min.js +0 -6
- package/public/framework/vue@2.6.10.runtime.min.js +0 -6
- package/public/framework/vuex@3.1.1.min.js +0 -6
- package/public/index.html +0 -260
- package/public/ks@3.0.8.umd.min.js +0 -1
- package/public/ksui@4.0.27.umd.min.js +0 -10
- package/public/status-bar-preset.js +0 -39
- package/qt-npm/index.js +0 -11
- package/qt-npm/package.json +0 -13
- package/src/App.vue +0 -204
- package/src/README.md +0 -15
- package/src/common/README.md +0 -94
- package/src/common/http/axios-adapter.js +0 -47
- package/src/common/http/common.js +0 -88
- package/src/common/http/http-interceptors.js +0 -18
- package/src/common/http/http-lock.js +0 -45
- package/src/common/http/index.js +0 -163
- package/src/common/http/token.js +0 -9
- package/src/common/styles/font/AlibabaSans102Ver2-Md.ttf +0 -0
- package/src/common/styles/font.less +0 -12
- package/src/common/styles/variables.less +0 -43
- package/src/common/utils/index.js +0 -1
- package/src/common/utils/platform/README.md +0 -1
- package/src/common/utils/platform/android/.gitkeep +0 -0
- package/src/common/utils/platform/core/index.js +0 -24
- package/src/common/utils/platform/index.js +0 -164
- package/src/common/utils/platform/ios/.gitkeep +0 -0
- package/src/common/utils/platform/subscribe/helper.js +0 -38
- package/src/common/utils/platform/subscribe/index.js +0 -204
- package/src/common/utils/platform/subscribe/table-animation.js +0 -75
- package/src/config/index.js +0 -31
- package/src/config.js +0 -1
- package/src/main.js +0 -73
- package/src/router.js +0 -52
- package/src/view/home/config.js +0 -101
- package/src/view/home/demo1.vue +0 -223
- package/src/view/home/demo2.vue +0 -124
- package/src/view/home/demo3.vue +0 -51
- package/src/view/home/demo4.vue +0 -140
- package/src/view/home/index.vue +0 -97
- package/src/view/home/query-table/README.md +0 -45
- package/src/view/home/query-table/api/index.js +0 -12
- package/src/view/home/query-table/assets/horizontal-back.svg +0 -1
- package/src/view/home/query-table/components/pe-table/cell.js +0 -181
- package/src/view/home/query-table/components/pe-table/collapse.js +0 -334
- package/src/view/home/query-table/components/pe-table/empty.vue +0 -48
- package/src/view/home/query-table/components/pe-table/header.js +0 -328
- 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 +0 -1
- package/src/view/home/query-table/components/pe-table/images/sort.svg +0 -1
- package/src/view/home/query-table/components/pe-table/images/sorting.svg +0 -1
- package/src/view/home/query-table/components/pe-table/images/unfold.svg +0 -1
- package/src/view/home/query-table/components/pe-table/index.vue +0 -847
- package/src/view/home/query-table/components/pe-table/load-more.js +0 -46
- package/src/view/home/query-table/components/pe-table/props/index.js +0 -193
- package/src/view/home/query-table/components/pe-table/row.vue +0 -118
- package/src/view/home/query-table/components/pe-table/scrollbar.js +0 -424
- package/src/view/home/query-table/components/pe-table/stretch-damping.js +0 -112
- package/src/view/home/query-table/components/pe-table/style/cell.less +0 -89
- package/src/view/home/query-table/components/pe-table/style/empty.less +0 -48
- package/src/view/home/query-table/components/pe-table/style/header.less +0 -141
- package/src/view/home/query-table/components/pe-table/style/index.less +0 -88
- package/src/view/home/query-table/components/pe-table/style/load-more.less +0 -61
- package/src/view/home/query-table/components/pe-table/style/row.less +0 -6
- package/src/view/home/query-table/components/pe-table/table-loading.vue +0 -120
- package/src/view/home/query-table/components/pe-table/table-total.vue +0 -57
- package/src/view/home/query-table/components/pe-table/utils/animate.js +0 -80
- package/src/view/home/query-table/components/pe-table/utils/columns.js +0 -290
- package/src/view/home/query-table/components/pe-table/utils/data.js +0 -12
- package/src/view/home/query-table/components/pe-table/utils/fixed.js +0 -69
- package/src/view/home/query-table/components/pe-table/utils/formatter.js +0 -327
- package/src/view/home/query-table/components/pe-table/utils/render-cells.js +0 -424
- package/src/view/home/query-table/components/pe-table/utils/slot.js +0 -28
- package/src/view/home/query-table/components/pe-table/utils/tools.js +0 -84
- package/src/view/home/query-table/components/pe-table/utils/touch-scroll.js +0 -417
- package/src/view/home/query-table/components/query-table/index.vue +0 -497
- package/src/view/home/query-table/components/query-table/mixins/column-mixin.js +0 -102
- package/src/view/home/query-table/components/query-table/mixins/column-setting.js +0 -143
- package/src/view/home/query-table/components/query-table/mixins/data-mixin.js +0 -519
- package/src/view/home/query-table/components/query-table/mixins/pagination-mixin.js +0 -26
- package/src/view/home/query-table/components/query-table/mixins/table-fixed.js +0 -130
- package/src/view/home/query-table/components/query-table/mixins/table-horizontal.js +0 -119
- package/src/view/home/query-table/components/table-horizontal.vue +0 -99
- package/src/view/home/query-table/components/table-pagination.vue +0 -32
- package/src/view/home/query-table/components/table-settings/assets/arrpw-up.svg +0 -1
- package/src/view/home/query-table/components/table-settings/assets/disabled-down.svg +0 -1
- package/src/view/home/query-table/components/table-settings/assets/disabled-up.svg +0 -1
- package/src/view/home/query-table/components/table-settings/assets/down.svg +0 -1
- package/src/view/home/query-table/components/table-settings/assets/up.svg +0 -1
- package/src/view/home/query-table/components/table-settings/index.less +0 -294
- package/src/view/home/query-table/components/table-settings/index.vue +0 -260
- package/src/view/home/query-table/components/table-settings/settings.vue +0 -479
- package/src/view/home/query-table/components/table-settings/test.js +0 -626
- 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 +0 -124
- package/src/view/home/query-table/hooks/use-cache-promise.js +0 -27
- package/src/view/home/query-table/hooks/use-column-config.js +0 -190
- package/src/view/home/query-table/hooks/use-encryption.js +0 -0
- package/src/view/home/query-table/hooks/use-generic-search.js +0 -95
- package/src/view/home/query-table/index.js +0 -7
- package/src/view/home/query-table/store/column-store.js +0 -0
- package/src/view/home/query-table/styles/table.less +0 -24
- package/src/view/home/query-table/utils/column.js +0 -36
- package/src/view/home/query-table/utils/config.js +0 -12
- package/src/view/home/query-table/utils/encryption.js +0 -32
- package/src/view/home/query-table/utils/http.js +0 -1
- package/src/view/home/query-table/utils/localStorage.js +0 -35
- package/src/view/home//351/246/226/351/241/265.md +0 -0
- package/src/web.js +0 -99
- package/vue.config.js +0 -131
|
@@ -1,290 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
|
|
3
|
-
import cloneDeep from 'lodash/cloneDeep'
|
|
4
|
-
import { createFixedColumnsOnLeft, updateColumnsIndexWidth } from './fixed'
|
|
5
|
-
const key = 'key'
|
|
6
|
-
|
|
7
|
-
function getAllChildKeys(children, acc) {
|
|
8
|
-
const keys = new Set()
|
|
9
|
-
|
|
10
|
-
for (const child of children) {
|
|
11
|
-
const childKey = child[key]
|
|
12
|
-
keys.add(childKey)
|
|
13
|
-
getAllChildKeys(child.children || [], [...acc, childKey]).forEach(
|
|
14
|
-
(subKey) => {
|
|
15
|
-
keys.add(subKey)
|
|
16
|
-
}
|
|
17
|
-
)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return Array.from(keys)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function createVisibleFlatColumns({
|
|
24
|
-
columns,
|
|
25
|
-
rowCellRender,
|
|
26
|
-
headerCellRender
|
|
27
|
-
}) {
|
|
28
|
-
const stack = cloneDeep(columns)
|
|
29
|
-
|
|
30
|
-
const visibleFlatColumns = []
|
|
31
|
-
const collapsedMap_ = new Map()
|
|
32
|
-
const colsMap = {}
|
|
33
|
-
while (stack.length) {
|
|
34
|
-
const current = stack.shift()
|
|
35
|
-
const currentKey = current[key]
|
|
36
|
-
const {
|
|
37
|
-
children = [],
|
|
38
|
-
fixed,
|
|
39
|
-
width,
|
|
40
|
-
parentNodeKeys = [],
|
|
41
|
-
childKeys = [],
|
|
42
|
-
// parentNodeKey,
|
|
43
|
-
resizable = true,
|
|
44
|
-
minWidth,
|
|
45
|
-
...reset
|
|
46
|
-
} = current
|
|
47
|
-
const { level = 1, collapsed = false, collapseKeys = [] } = reset
|
|
48
|
-
if (collapseKeys.length) {
|
|
49
|
-
for (const k of collapseKeys) {
|
|
50
|
-
collapsedMap_.set(k, collapsed)
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
const hasChildren = !!children.length
|
|
54
|
-
if (hasChildren) {
|
|
55
|
-
// 继承父级的fixed
|
|
56
|
-
const parentNodeKey = currentKey
|
|
57
|
-
stack.unshift(
|
|
58
|
-
...children.map((child) => ({
|
|
59
|
-
...child,
|
|
60
|
-
parentNodeKeys: [...parentNodeKeys, parentNodeKey],
|
|
61
|
-
fixed,
|
|
62
|
-
parentNodeKey,
|
|
63
|
-
level: level + 1,
|
|
64
|
-
}))
|
|
65
|
-
)
|
|
66
|
-
}
|
|
67
|
-
const item = {
|
|
68
|
-
...current,
|
|
69
|
-
width: minWidth || width,
|
|
70
|
-
minWidth,
|
|
71
|
-
parentNodeKeys,
|
|
72
|
-
children,
|
|
73
|
-
level,
|
|
74
|
-
resizable,
|
|
75
|
-
childKeys: getAllChildKeys(children, childKeys),
|
|
76
|
-
rowCellRender: current.rowCellRender || rowCellRender,
|
|
77
|
-
headerCellRender: current.headerCellRender || headerCellRender
|
|
78
|
-
}
|
|
79
|
-
if (item.width) {
|
|
80
|
-
item.width = parseInt(item.width)
|
|
81
|
-
}
|
|
82
|
-
visibleFlatColumns.push(item)
|
|
83
|
-
colsMap[currentKey] = item
|
|
84
|
-
}
|
|
85
|
-
// 子级的折叠状态跟随父级的状态
|
|
86
|
-
collapsedMap_.forEach((value, key) => {
|
|
87
|
-
const { childKeys = [] } = colsMap[key] || {}
|
|
88
|
-
if (childKeys.length) {
|
|
89
|
-
childKeys.forEach((childKey) => {
|
|
90
|
-
if (!collapsedMap_.has(childKey)) {
|
|
91
|
-
collapsedMap_.set(childKey, value)
|
|
92
|
-
}
|
|
93
|
-
})
|
|
94
|
-
}
|
|
95
|
-
})
|
|
96
|
-
const collapsedMap = Object.fromEntries(collapsedMap_.entries())
|
|
97
|
-
return { visibleFlatColumns, collapsedMap }
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export function logError(err, logConf = '') {
|
|
101
|
-
// eslint-disable-next-line
|
|
102
|
-
if (typeof console !== 'undefined') {
|
|
103
|
-
// eslint-disable-next-line
|
|
104
|
-
console.error('%c【KyeTable2】' + err, logConf)
|
|
105
|
-
} else {
|
|
106
|
-
throw err
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// 列配置的显示与否根据祖先节点的状态来决定
|
|
111
|
-
function validateColumnShow(acc, col) {
|
|
112
|
-
const { parentNodeKey } = col
|
|
113
|
-
const parentNode = acc[parentNodeKey]
|
|
114
|
-
return parentNode && parentNode.show === false ? false : col.show
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function computedColumnsWidthInChildKeys(col, columnsKeyMap, collapsedMap) {
|
|
118
|
-
const { width, children = [], childKeys = [] } = col || {}
|
|
119
|
-
if (!children.length && width) {
|
|
120
|
-
return width
|
|
121
|
-
}
|
|
122
|
-
return childKeys.reduce((acc, childKey) => {
|
|
123
|
-
const { children = [], width, show } = columnsKeyMap[childKey] || {}
|
|
124
|
-
// 仅计算未被折叠的宽度和
|
|
125
|
-
if (!children.length && !collapsedMap[childKey] && show) {
|
|
126
|
-
acc += width
|
|
127
|
-
}
|
|
128
|
-
return acc
|
|
129
|
-
}, 0)
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function createColumnsKeyMap(visibleFlatColumns = []) {
|
|
133
|
-
const columnKeyMap = visibleFlatColumns.reduce((acc, col) => {
|
|
134
|
-
const { key } = col
|
|
135
|
-
const show = validateColumnShow(acc, col)
|
|
136
|
-
acc[key] = {
|
|
137
|
-
...col,
|
|
138
|
-
show,
|
|
139
|
-
}
|
|
140
|
-
return acc
|
|
141
|
-
}, {})
|
|
142
|
-
return columnKeyMap
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export function createFlatColumns (params) {
|
|
146
|
-
const addFixedConfInColumns =
|
|
147
|
-
params.columns && params.columns.length > 0 ? createFixedColumnsOnLeft({ showIndex: params.showIndex }) : []
|
|
148
|
-
const { visibleFlatColumns, collapsedMap } = createVisibleFlatColumns({
|
|
149
|
-
...params,
|
|
150
|
-
columns: [...addFixedConfInColumns, ...params.columns],
|
|
151
|
-
})
|
|
152
|
-
return {
|
|
153
|
-
visibleFlatColumns,
|
|
154
|
-
collapsedMap
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// 根据筛选的列和 折叠选项生成 多表格列配置
|
|
159
|
-
export function createColumns({visibleFlatColumns, collapsedMap = {}, rowKey, headerRowHeight, curMaxIndexVal}) {
|
|
160
|
-
const columnsKeyMap = createColumnsKeyMap(visibleFlatColumns)
|
|
161
|
-
const columnVisibleConfIter = (key) =>
|
|
162
|
-
columnsKeyMap[key].show !== false && !collapsedMap[key]
|
|
163
|
-
const fixedColumnsOnLeft = visibleFlatColumns.filter(
|
|
164
|
-
(column) =>
|
|
165
|
-
(column.fixed === 'left' || column.fixed === true) &&
|
|
166
|
-
columnVisibleConfIter(column.key)
|
|
167
|
-
)
|
|
168
|
-
const normalColumns = visibleFlatColumns.filter(
|
|
169
|
-
(column) => !column.fixed && columnVisibleConfIter(column.key)
|
|
170
|
-
)
|
|
171
|
-
if (curMaxIndexVal >= 10000) {
|
|
172
|
-
updateColumnsIndexWidth(fixedColumnsOnLeft, curMaxIndexVal)
|
|
173
|
-
}
|
|
174
|
-
const mainColumns = [...fixedColumnsOnLeft, ...normalColumns]
|
|
175
|
-
const maxLevel = creatMaxlevel(mainColumns)
|
|
176
|
-
// const headerTotalHeight = maxLevel * headerRowHeight
|
|
177
|
-
|
|
178
|
-
const collapseKeysMap = {}
|
|
179
|
-
function calculateOffsetXAndWidth(arr = [], iter) {
|
|
180
|
-
let offsetX = 0
|
|
181
|
-
return arr.map((col, index) => {
|
|
182
|
-
const width = computedColumnsWidthInChildKeys(
|
|
183
|
-
col,
|
|
184
|
-
columnsKeyMap,
|
|
185
|
-
collapsedMap
|
|
186
|
-
)
|
|
187
|
-
col.width = width
|
|
188
|
-
if (col.collapseKeys && col.collapseKeys.length) {
|
|
189
|
-
if (!collapseKeysMap[col.key]) {
|
|
190
|
-
collapseKeysMap[col.key] = col.collapseKeys
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
if (index > 0) {
|
|
194
|
-
const { width: preWidth, key: preKey } = mainColumns[index - 1]
|
|
195
|
-
offsetX += preWidth
|
|
196
|
-
// 如果上一次是父级,则减去父级的宽度。从父级的起始点开始
|
|
197
|
-
if (col.parentNodeKey === preKey) {
|
|
198
|
-
offsetX -= preWidth
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
col.offsetX = offsetX
|
|
202
|
-
const otherResult = iter(col, index) || {}
|
|
203
|
-
const levelNum =
|
|
204
|
-
col.level !== maxLevel && !col.children.length
|
|
205
|
-
? Math.abs(col.level - maxLevel) + 1
|
|
206
|
-
: 1
|
|
207
|
-
const height = levelNum * headerRowHeight
|
|
208
|
-
const top = (col.level - 1) * headerRowHeight
|
|
209
|
-
return {
|
|
210
|
-
...col,
|
|
211
|
-
originIndex: index,
|
|
212
|
-
...otherResult,
|
|
213
|
-
height: height,
|
|
214
|
-
top,
|
|
215
|
-
[rowKey]: (col.fixed ? 'fixed_left_' : '') + col.key,
|
|
216
|
-
}
|
|
217
|
-
})
|
|
218
|
-
}
|
|
219
|
-
const _mainColumns = calculateOffsetXAndWidth(mainColumns, function (col) {
|
|
220
|
-
const { key } = col
|
|
221
|
-
const fixedLeftKeys = ['_index', '_selection'].indexOf(key) > -1
|
|
222
|
-
return {
|
|
223
|
-
headerCellRender: fixedLeftKeys ? null : col.headerCellRender,
|
|
224
|
-
rowCellRender: fixedLeftKeys ? null : col.rowCellRender,
|
|
225
|
-
}
|
|
226
|
-
})
|
|
227
|
-
// function setPlaceholderSign() {
|
|
228
|
-
// return {
|
|
229
|
-
// placeholderSign: false,
|
|
230
|
-
// }
|
|
231
|
-
// }
|
|
232
|
-
// const _fixedColumnsOnLeft = calculateOffsetXAndWidth(
|
|
233
|
-
// fixedColumnsOnLeft.length
|
|
234
|
-
// ? mainColumns.slice(0, fixedColumnsOnLeft.length)
|
|
235
|
-
// : [],
|
|
236
|
-
// setPlaceholderSign
|
|
237
|
-
// )
|
|
238
|
-
return {
|
|
239
|
-
columns: _mainColumns,
|
|
240
|
-
// fixedColumnsOnLeft: _fixedColumnsOnLeft,
|
|
241
|
-
maxLevel,
|
|
242
|
-
collapseKeysMap
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
export function creatMaxlevel(columns) {
|
|
247
|
-
const levelIter = (col) => col.level
|
|
248
|
-
const maxLevel = columns.length ? Math.max(...columns.map(levelIter)) : 1
|
|
249
|
-
return maxLevel
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
export function createRenderColumnOption({
|
|
253
|
-
mainColumns,
|
|
254
|
-
maxLevel,
|
|
255
|
-
headerRowHeight,
|
|
256
|
-
}) {
|
|
257
|
-
const {
|
|
258
|
-
tableWidth,
|
|
259
|
-
// renderRowColumns,
|
|
260
|
-
renderCellsColumns,
|
|
261
|
-
renderCellsColumnsWidths,
|
|
262
|
-
} = mainColumns.reduce(
|
|
263
|
-
(obj, col) => {
|
|
264
|
-
if (col.level === 1) {
|
|
265
|
-
obj.tableWidth += col.width
|
|
266
|
-
// obj.renderRowColumns.push(col)
|
|
267
|
-
}
|
|
268
|
-
if (!(col.children && col.children.length)) {
|
|
269
|
-
const levelNum =
|
|
270
|
-
col.level !== maxLevel ? Math.abs(col.level - maxLevel) + 1 : 1
|
|
271
|
-
col.headerRowHeight = levelNum * headerRowHeight
|
|
272
|
-
obj.renderCellsColumns.push(col)
|
|
273
|
-
obj.renderCellsColumnsWidths.push(col.width)
|
|
274
|
-
}
|
|
275
|
-
return obj
|
|
276
|
-
},
|
|
277
|
-
{
|
|
278
|
-
tableWidth: 0,
|
|
279
|
-
// renderRowColumns: [],
|
|
280
|
-
renderCellsColumns: [],
|
|
281
|
-
renderCellsColumnsWidths: [],
|
|
282
|
-
}
|
|
283
|
-
)
|
|
284
|
-
return {
|
|
285
|
-
tableWidth,
|
|
286
|
-
// renderRowColumns,
|
|
287
|
-
renderCellsColumns,
|
|
288
|
-
renderCellsColumnsWidths,
|
|
289
|
-
}
|
|
290
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export function createTableData({ data, columns, rowKey, pageForIndex, showPage }, indexFormat) {
|
|
2
|
-
return (data || []).reduce((acc, rowData, index) => {
|
|
3
|
-
const _rowData = columns.reduce((row, col) => {
|
|
4
|
-
row[col.key] = rowData[col.key]
|
|
5
|
-
return row
|
|
6
|
-
}, {})
|
|
7
|
-
_rowData[rowKey] = rowData[rowKey] || '_inner_id' + index
|
|
8
|
-
_rowData['$index'] = indexFormat ? indexFormat(index + 1, _rowData, rowData) : index + 1 + (showPage ? (pageForIndex - 1) * 200 : 0)
|
|
9
|
-
acc.push(_rowData)
|
|
10
|
-
return acc
|
|
11
|
-
}, [])
|
|
12
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
const COLUMNS_INDEX = {
|
|
2
|
-
label: '序号',
|
|
3
|
-
key: '$index',
|
|
4
|
-
sortable: false,
|
|
5
|
-
// resizable: true,
|
|
6
|
-
width: 40,
|
|
7
|
-
// isInternal: true,
|
|
8
|
-
align: 'left',
|
|
9
|
-
showPopover: false,
|
|
10
|
-
// _internal: true,
|
|
11
|
-
// headerCellRender: function (h, { column }) {
|
|
12
|
-
// // const classes = getCustomHeaderCellAlignClass(column)
|
|
13
|
-
// const classes = []
|
|
14
|
-
// return <div class={classes}>{column.label || '#'}</div>
|
|
15
|
-
// },
|
|
16
|
-
// rowCellRender: function (h, { rowData }) {
|
|
17
|
-
// const index = _index
|
|
18
|
-
// let i = typeof index === 'number' ? index : index
|
|
19
|
-
// if (isNaN(i)) {
|
|
20
|
-
// i = ''
|
|
21
|
-
// }
|
|
22
|
-
// // const classes = getCustomRowCellAlignClass(column)
|
|
23
|
-
// const classes = []
|
|
24
|
-
// return <div class={classes}>{i}</div>
|
|
25
|
-
// }
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// 生成索引和复选框的列配置
|
|
29
|
-
export function createFixedColumnsOnLeft({
|
|
30
|
-
showIndex, // 是否添加索引列
|
|
31
|
-
// showSelection,
|
|
32
|
-
// showRadio
|
|
33
|
-
}) {
|
|
34
|
-
const fixedColumnsOnLeft = []
|
|
35
|
-
const obj = {
|
|
36
|
-
level: 1,
|
|
37
|
-
show: true,
|
|
38
|
-
fixed: 'left',
|
|
39
|
-
// resizable: false
|
|
40
|
-
}
|
|
41
|
-
if (showIndex) {
|
|
42
|
-
fixedColumnsOnLeft.unshift({
|
|
43
|
-
...COLUMNS_INDEX,
|
|
44
|
-
...obj,
|
|
45
|
-
})
|
|
46
|
-
}
|
|
47
|
-
// if (showSelection) {
|
|
48
|
-
// fixedColumnsOnLeft.unshift({
|
|
49
|
-
// ...COLUMNS_SELECTION,
|
|
50
|
-
// ...obj
|
|
51
|
-
// })
|
|
52
|
-
// }
|
|
53
|
-
// if (showRadio) {
|
|
54
|
-
// fixedColumnsOnLeft.unshift({
|
|
55
|
-
// ...COLUMNS_RADIO,
|
|
56
|
-
// ...obj
|
|
57
|
-
// })
|
|
58
|
-
// }
|
|
59
|
-
return fixedColumnsOnLeft
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export function updateColumnsIndexWidth(fixedColumnsOnLeft = [], tableDataLength) {
|
|
63
|
-
const showIndexColumn = fixedColumnsOnLeft.find(item => item.key === COLUMNS_INDEX.key)
|
|
64
|
-
let indexCol = String(tableDataLength).length * 10
|
|
65
|
-
const width = indexCol < COLUMNS_INDEX.width ? COLUMNS_INDEX.width : indexCol
|
|
66
|
-
if (showIndexColumn && width > COLUMNS_INDEX.width && width !== showIndexColumn.width) {
|
|
67
|
-
showIndexColumn.width = width
|
|
68
|
-
}
|
|
69
|
-
}
|
|
@@ -1,327 +0,0 @@
|
|
|
1
|
-
import dayJs from 'dayjs'
|
|
2
|
-
export const isEmpty = val => val === '' || val === null || val === undefined
|
|
3
|
-
|
|
4
|
-
export const date = (date, fmt = 'YYYY-MM-DD') => {
|
|
5
|
-
let str = date || ''
|
|
6
|
-
if (typeof str === 'string' && str && (str.includes('**') || str.includes('✽✽'))) {
|
|
7
|
-
return str
|
|
8
|
-
}
|
|
9
|
-
return str ? dayJs(str).format(fmt) : str
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const time = (d, fmt = 'YYYY-MM-DD HH:mm:ss') => {
|
|
13
|
-
return date(d, fmt)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const minute = (d, fmt = 'YYYY-MM-DD HH:mm') => {
|
|
17
|
-
return date(d, fmt)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const second = (d, fmt = 'HH:mm:ss') => {
|
|
21
|
-
return date(d, fmt)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const month = (d, fmt = 'YYYY-MM') => {
|
|
25
|
-
return date(d, fmt)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export const money = (num, prev = '¥ ', fixed = 2) => {
|
|
29
|
-
if (typeof num !== 'number' && !num) {
|
|
30
|
-
return ''
|
|
31
|
-
}
|
|
32
|
-
if (typeof num === 'string' && (num.includes('**') || num.includes('✽✽'))) {
|
|
33
|
-
return num
|
|
34
|
-
}
|
|
35
|
-
prev = prev === null ? '¥ ' : prev
|
|
36
|
-
return `${prev}${(+num).toFixed(fixed).replace(/\B(?=(\d{3})+(?!\d))/g, ',')}`
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export const decimal = (num, precision = 2) => {
|
|
40
|
-
if (typeof num !== 'number' && !num) {
|
|
41
|
-
return ''
|
|
42
|
-
}
|
|
43
|
-
if (typeof num === 'string' && (num.includes('**') || num.includes('✽✽'))) {
|
|
44
|
-
return num
|
|
45
|
-
}
|
|
46
|
-
return `${(+num).toFixed(precision).replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,')}`
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export const thousands = num => {
|
|
50
|
-
if (typeof num !== 'number' && !num) {
|
|
51
|
-
return ''
|
|
52
|
-
}
|
|
53
|
-
if (typeof num === 'string' && (num.includes('**') || num.includes('✽✽'))) {
|
|
54
|
-
return num
|
|
55
|
-
}
|
|
56
|
-
return (+num).toLocaleString()
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// 后端时间导出自定义类型
|
|
60
|
-
export const customDateTime = (d, fmt = 'YYYY-MM-DD') => {
|
|
61
|
-
return date(d, fmt)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* 9级组织过滤器
|
|
66
|
-
* @param val 投资集团/快递事业部/京津冀大区/取派中心/北京分区/顺义区/顺义取派部/东城片区/顺义八里庄点部@顺义取派部@顺义八里庄点部
|
|
67
|
-
* @param dept Array:9级组织 | 1:部门 | 2:点部
|
|
68
|
-
* @param split 组织、部门、点部 的分隔符,默认为“@”
|
|
69
|
-
* @returns {string} 根据用户保存的点部配置,解析出对应的部门数据
|
|
70
|
-
*/
|
|
71
|
-
export const deptFilter = (val, dept, split = '@') => {
|
|
72
|
-
let index = val && val.indexOf(split)
|
|
73
|
-
if (!index || index === -1) {
|
|
74
|
-
return val
|
|
75
|
-
}
|
|
76
|
-
if (Array.isArray(dept)) {
|
|
77
|
-
let arr = val.substring(0, index).split('/')
|
|
78
|
-
let len = Math.min(arr.length, dept.length)
|
|
79
|
-
let str = ''
|
|
80
|
-
for (let i = 0; i < len; i++) {
|
|
81
|
-
let s = arr[dept[i] - 1]
|
|
82
|
-
if (s) {
|
|
83
|
-
str = `${str}/${s}`
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return str ? str.replace(/^\//, '') : val
|
|
87
|
-
} else if (dept === 1) {
|
|
88
|
-
return val.substring(index + 1, val.lastIndexOf(split))
|
|
89
|
-
} else if (dept === 2) {
|
|
90
|
-
return val.substring(val.lastIndexOf(split) + 1)
|
|
91
|
-
} else {
|
|
92
|
-
return val
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// 234333.22 => 23万 4333 234.22 => 234.22 支持金额切换
|
|
97
|
-
export const numberSplit = (val, globalMoneyFormat = true) => {
|
|
98
|
-
// 防止空字符返回为0
|
|
99
|
-
if (val === '') return val
|
|
100
|
-
if (globalMoneyFormat) {
|
|
101
|
-
return money(val)
|
|
102
|
-
}
|
|
103
|
-
let toNumberVal = Number(val)
|
|
104
|
-
if (isNaN(toNumberVal)) {
|
|
105
|
-
return val
|
|
106
|
-
}
|
|
107
|
-
let flag = ''
|
|
108
|
-
if (toNumberVal < 0) {
|
|
109
|
-
flag = '-'
|
|
110
|
-
toNumberVal = Math.abs(toNumberVal)
|
|
111
|
-
}
|
|
112
|
-
if (toNumberVal >= 10000) {
|
|
113
|
-
// 大于等于10000的数据要去掉小数位
|
|
114
|
-
const numStr = Math.floor(toNumberVal) + ''
|
|
115
|
-
const len = numStr.length
|
|
116
|
-
const numArr = []
|
|
117
|
-
// 每4位截取一次,截取小于10000部分的数据
|
|
118
|
-
let itemLast = Number(numStr.substring(len - 4, len))
|
|
119
|
-
// 只有个位数前面要加0 等于0则去掉,不加入数组拼接
|
|
120
|
-
if (itemLast < 10 && itemLast > 0) {
|
|
121
|
-
numArr.unshift('0' + itemLast)
|
|
122
|
-
} else if (itemLast >= 10) {
|
|
123
|
-
numArr.unshift(itemLast)
|
|
124
|
-
}
|
|
125
|
-
let itemCenter = 0
|
|
126
|
-
let itemFirst = 0
|
|
127
|
-
if (len <= 8) {
|
|
128
|
-
// 长度小于等于8, 没有亿位,这个时候万位可以从index = 0 开始截取
|
|
129
|
-
itemCenter = Number(numStr.substring(0, len - 4))
|
|
130
|
-
} else {
|
|
131
|
-
// 长度大于8才有亿, 万位不能再从index = 0开始截取
|
|
132
|
-
itemCenter = Number(numStr.substring(len - 8, len - 4))
|
|
133
|
-
itemFirst = Number(numStr.substring(0, len - 8))
|
|
134
|
-
}
|
|
135
|
-
// 万位和亿位如果大于0才加入数组拼接
|
|
136
|
-
if (itemCenter > 0) numArr.unshift(itemCenter + '万')
|
|
137
|
-
if (itemFirst > 0) numArr.unshift(itemFirst + '亿')
|
|
138
|
-
return flag + numArr.join('')
|
|
139
|
-
}
|
|
140
|
-
return flag + toNumberVal
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// 234333.22 => 23万4333 234.22 => 234.22 不支持金额切换
|
|
144
|
-
export const numberSplitInt = val => {
|
|
145
|
-
// 防止空字符返回为0
|
|
146
|
-
if (val === '') return val
|
|
147
|
-
let toNumberVal = Number(val)
|
|
148
|
-
if (isNaN(toNumberVal)) {
|
|
149
|
-
return val
|
|
150
|
-
}
|
|
151
|
-
let flag = ''
|
|
152
|
-
if (toNumberVal < 0) {
|
|
153
|
-
flag = '-'
|
|
154
|
-
toNumberVal = Math.abs(toNumberVal)
|
|
155
|
-
}
|
|
156
|
-
if (toNumberVal >= 10000) {
|
|
157
|
-
// 大于等于10000的数据要去掉小数位
|
|
158
|
-
const numStr = Math.floor(toNumberVal) + ''
|
|
159
|
-
const len = numStr.length
|
|
160
|
-
const numArr = []
|
|
161
|
-
// 每4位截取一次,截取小于10000部分的数据
|
|
162
|
-
let itemLast = Number(numStr.substring(len - 4, len))
|
|
163
|
-
// 只有个位数前面要加0 等于0则去掉,不加入数组拼接
|
|
164
|
-
if (itemLast < 10 && itemLast > 0) {
|
|
165
|
-
numArr.unshift('0' + itemLast)
|
|
166
|
-
} else if (itemLast >= 10) {
|
|
167
|
-
numArr.unshift(itemLast)
|
|
168
|
-
}
|
|
169
|
-
let itemCenter = 0
|
|
170
|
-
let itemFirst = 0
|
|
171
|
-
if (len <= 8) {
|
|
172
|
-
// 长度小于等于8, 没有亿位,这个时候万位可以从index = 0 开始截取
|
|
173
|
-
itemCenter = Number(numStr.substring(0, len - 4))
|
|
174
|
-
} else {
|
|
175
|
-
// 长度大于8才有亿, 万位不能再从index = 0开始截取
|
|
176
|
-
itemCenter = Number(numStr.substring(len - 8, len - 4))
|
|
177
|
-
itemFirst = Number(numStr.substring(0, len - 8))
|
|
178
|
-
}
|
|
179
|
-
// 万位和亿位如果大于0才加入数组拼接
|
|
180
|
-
if (itemCenter > 0) numArr.unshift(itemCenter + '万')
|
|
181
|
-
if (itemFirst > 0) numArr.unshift(itemFirst + '亿')
|
|
182
|
-
return flag + numArr.join('')
|
|
183
|
-
}
|
|
184
|
-
return flag + toNumberVal
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
// 234333.22 => 23万4333.22 234.22 => 234.22
|
|
188
|
-
export const numberSplitFloat = (val, decimal, globalMoneyFormat = false) => {
|
|
189
|
-
// 防止空字符返回为0
|
|
190
|
-
if (val === '') return val
|
|
191
|
-
if (globalMoneyFormat) {
|
|
192
|
-
return money(val)
|
|
193
|
-
}
|
|
194
|
-
return filterNumber(val, decimal)
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
const filterNumber = (val, decimal) => {
|
|
198
|
-
if (decimal < 0 || !Number.isInteger(decimal)) decimal = void 0
|
|
199
|
-
let toNumberVal = Number(val)
|
|
200
|
-
if (isNaN(toNumberVal)) {
|
|
201
|
-
return val
|
|
202
|
-
}
|
|
203
|
-
let flag = ''
|
|
204
|
-
if (toNumberVal < 0) {
|
|
205
|
-
flag = '-'
|
|
206
|
-
toNumberVal = Math.abs(toNumberVal)
|
|
207
|
-
}
|
|
208
|
-
const numStrArr = String(toNumberVal).split('.')
|
|
209
|
-
const numStr = numStrArr[0]
|
|
210
|
-
const _decimal = decimal == 0 ? '' : decimal || (numStrArr[1] && numStrArr[1].length) || ''
|
|
211
|
-
const decimalNum = numStrArr[1] && _decimal ? `.${numStrArr[1].substring(0, _decimal)}` : ''
|
|
212
|
-
if (toNumberVal >= 10000) {
|
|
213
|
-
const len = numStr.length
|
|
214
|
-
const numArr = []
|
|
215
|
-
// 每4位截取一次,截取小于10000部分的数据
|
|
216
|
-
let itemLast = Number(numStr.substring(len - 4, len))
|
|
217
|
-
// 只有个位数前面要加0 等于0则去掉,不加入数组拼接
|
|
218
|
-
if (itemLast < 10 && itemLast > 0) {
|
|
219
|
-
numArr.unshift('0' + itemLast)
|
|
220
|
-
} else if (itemLast >= 10) {
|
|
221
|
-
numArr.unshift(itemLast)
|
|
222
|
-
}
|
|
223
|
-
let itemCenter = 0
|
|
224
|
-
let itemFirst = 0
|
|
225
|
-
// let itemBillion = 0
|
|
226
|
-
// 处理万亿(兆)级别
|
|
227
|
-
if (len >= 13) {
|
|
228
|
-
const billion = 1e12 // 1万亿
|
|
229
|
-
let billionValue = String(numStr / billion)
|
|
230
|
-
const dotIndex = billionValue.indexOf('.')
|
|
231
|
-
if (dotIndex !== -1) {
|
|
232
|
-
billionValue = billionValue.slice(0, dotIndex + 5) // dotIndex + 5 保留四位小数
|
|
233
|
-
}
|
|
234
|
-
// 长度大于等于13 万亿(兆)级别
|
|
235
|
-
// itemBillion = Number(numStr.substring(0, len - 12)) // 万亿(兆)部分
|
|
236
|
-
// itemFirst = Number(numStr.substring(len - 12, len - 10)) // 亿部分
|
|
237
|
-
// itemCenter = Number(numStr.substring(len - 8, len - 4)) // 万部分
|
|
238
|
-
// return `${itemBillion}${itemFirst ? '.' + itemFirst : ''}万亿`
|
|
239
|
-
return `${billionValue}万亿`
|
|
240
|
-
} else if (len >= 9) {
|
|
241
|
-
// 长度大于8才有亿, 万位不能再从index = 0开始截取
|
|
242
|
-
itemCenter = Number(numStr.substring(len - 8, len - 4))
|
|
243
|
-
itemFirst = Number(numStr.substring(0, len - 8))
|
|
244
|
-
} else {
|
|
245
|
-
// 长度小于9,只有万以下的数值
|
|
246
|
-
itemCenter = Number(numStr.substring(0, len - 4)) // 万部分
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
if (itemCenter > 0) numArr.unshift(itemCenter + '万')
|
|
250
|
-
if (itemFirst > 0) numArr.unshift(itemFirst + '亿')
|
|
251
|
-
// if (itemBillion > 0) numArr.unshift(itemBillion + '万亿')
|
|
252
|
-
return flag + numArr.join('') + decimalNum
|
|
253
|
-
}
|
|
254
|
-
return flag + Math.floor(toNumberVal) + decimalNum
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
// 234333.22 => 23万4333.22 234.22 => 234.22 , null => '-'
|
|
258
|
-
export const formatMoneyByNumber = (val, decimal = 2) => {
|
|
259
|
-
// 金融板块 金额为空时 需要返回 返回‘-’, 且默认2为小数, 默认带前缀 ¥
|
|
260
|
-
if (isEmpty(val)) return '-'
|
|
261
|
-
const num = filterNumber(val, decimal)
|
|
262
|
-
return num.includes('*') || num.includes('✽') ? num : `¥ ${num}`
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
function getFormatter(col = {}, filter) {
|
|
267
|
-
if (!filter) {
|
|
268
|
-
return null
|
|
269
|
-
}
|
|
270
|
-
// 过滤器
|
|
271
|
-
if (col.filter) {
|
|
272
|
-
if (col.filter.type && col.filter.args) {
|
|
273
|
-
let func = filter[col.filter.type]
|
|
274
|
-
if (func) {
|
|
275
|
-
return (row, column, val) => func(val, ...col.filter.args)
|
|
276
|
-
}
|
|
277
|
-
} else {
|
|
278
|
-
// 不显示秒,minute 替换 time
|
|
279
|
-
// if (col.filter === 'time') {
|
|
280
|
-
// col.filter = 'minute'
|
|
281
|
-
// }
|
|
282
|
-
let func = filter[col.filter]
|
|
283
|
-
if (func) {
|
|
284
|
-
// 9级组织
|
|
285
|
-
if (col.filter === 'deptFilter') {
|
|
286
|
-
return (row, column, val) => func(val, column.dept)
|
|
287
|
-
} else {
|
|
288
|
-
return (row, column, val) => func(val)
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
return null
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
const filter = {
|
|
297
|
-
date,
|
|
298
|
-
time,
|
|
299
|
-
minute,
|
|
300
|
-
second,
|
|
301
|
-
month,
|
|
302
|
-
money,
|
|
303
|
-
decimal,
|
|
304
|
-
thousands,
|
|
305
|
-
customDateTime,
|
|
306
|
-
deptFilter,
|
|
307
|
-
numberSplit,
|
|
308
|
-
numberSplitInt,
|
|
309
|
-
numberSplitFloat,
|
|
310
|
-
formatMoneyByNumber,
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
export const tableCellFormatterResult = ({ column = {}, rowData, rowIndex, columnIndex, displayText }) => {
|
|
314
|
-
try {
|
|
315
|
-
const formatter = getFormatter(column, filter)
|
|
316
|
-
if (formatter) {
|
|
317
|
-
displayText = formatter(rowData, column, displayText)
|
|
318
|
-
}
|
|
319
|
-
if (column.formatter && typeof column.formatter === 'function') {
|
|
320
|
-
displayText = column.formatter(rowData, column, displayText, rowIndex, columnIndex)
|
|
321
|
-
}
|
|
322
|
-
return displayText
|
|
323
|
-
} catch (error) {
|
|
324
|
-
console.error(error)
|
|
325
|
-
return displayText
|
|
326
|
-
}
|
|
327
|
-
}
|