@kyfe/ks-query-table 0.0.22 → 0.0.23

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.
Files changed (311) hide show
  1. package/index.js +11 -0
  2. package/package.json +10 -81
  3. package/.bitmap +0 -38
  4. package/.editorconfig +0 -5
  5. package/.env.dev +0 -2
  6. package/.env.gray +0 -2
  7. package/.env.prod +0 -2
  8. package/.env.stg +0 -3
  9. package/.env.uat +0 -2
  10. package/.eslintignore +0 -1
  11. package/.eslintrc.js +0 -25
  12. package/.gitmodules +0 -4
  13. package/.prettierrc +0 -11
  14. package/README.md +0 -15
  15. package/babel.config.js +0 -10
  16. package/build-apm.sh +0 -9
  17. package/build.sh +0 -16
  18. package/config/index.js +0 -20
  19. package/jsconfig.json +0 -7
  20. package/kuasheng-sdk/index.js +0 -80
  21. package/kuasheng-sdk/lib/assets.js +0 -304
  22. package/kuasheng-sdk/lib/context.js +0 -199
  23. package/kuasheng-sdk/lib/layout.js +0 -346
  24. package/kuasheng-sdk/lib/location.js +0 -46
  25. package/kuasheng-sdk/lib/media.js +0 -342
  26. package/kuasheng-sdk/lib/navigation.js +0 -30
  27. package/kuasheng-sdk/lib/request.js +0 -76
  28. package/kuasheng-sdk/lib/system.js +0 -190
  29. package/kuasheng-sdk/lib/userinfo.js +0 -98
  30. package/kuasheng-sdk/util/check.js +0 -102
  31. package/kuasheng-sdk/util/config.js +0 -47
  32. package/kuasheng-sdk/util/device.js +0 -25
  33. package/kuasheng-sdk/util/error.js +0 -19
  34. package/kuasheng-sdk/util/funtional.js +0 -153
  35. package/kuasheng-sdk/util/mixin.js +0 -36
  36. package/kuasheng-sdk/util/requestUtil.js +0 -41
  37. package/kuasheng-sdk/util/response.js +0 -33
  38. package/kuasheng-sdk/util/warn.js +0 -35
  39. package/kuasheng-ui/CHANGELOG.md +0 -9
  40. package/kuasheng-ui/components/card.vue +0 -57
  41. package/kuasheng-ui/components/ks-area-select/README.md +0 -43
  42. package/kuasheng-ui/components/ks-area-select/area-picker.vue +0 -554
  43. package/kuasheng-ui/components/ks-area-select/area-search.vue +0 -363
  44. package/kuasheng-ui/components/ks-area-select/areas-pop.vue +0 -56
  45. package/kuasheng-ui/components/ks-area-select/common.js +0 -183
  46. package/kuasheng-ui/components/ks-area-select/index.vue +0 -355
  47. package/kuasheng-ui/components/ks-area-select/mixins.js +0 -216
  48. package/kuasheng-ui/components/ks-area-single-select/README.md +0 -50
  49. package/kuasheng-ui/components/ks-area-single-select/hot-city.js +0 -45
  50. package/kuasheng-ui/components/ks-area-single-select/index.vue +0 -324
  51. package/kuasheng-ui/components/ks-calendar/index.vue +0 -269
  52. package/kuasheng-ui/components/ks-call-phone/call-tips.vue +0 -70
  53. package/kuasheng-ui/components/ks-call-phone/call.vue +0 -178
  54. package/kuasheng-ui/components/ks-call-phone/index.js +0 -48
  55. package/kuasheng-ui/components/ks-call-phone/index.vue +0 -131
  56. package/kuasheng-ui/components/ks-call-phone//345/221/274/345/217/253/347/273/204/344/273/266.md +0 -0
  57. package/kuasheng-ui/components/ks-date-picker/README.md +0 -23
  58. package/kuasheng-ui/components/ks-date-picker/date-picker-bottom.vue +0 -123
  59. package/kuasheng-ui/components/ks-date-picker/date-picker-dropdown.vue +0 -80
  60. package/kuasheng-ui/components/ks-date-picker/date-picker-right.vue +0 -87
  61. package/kuasheng-ui/components/ks-date-picker/date-picker-top.vue +0 -88
  62. package/kuasheng-ui/components/ks-date-picker/date-picker.js +0 -15
  63. package/kuasheng-ui/components/ks-date-picker/date-range-select.vue +0 -92
  64. package/kuasheng-ui/components/ks-date-picker/date-select.vue +0 -65
  65. package/kuasheng-ui/components/ks-date-picker/date-week-month.vue +0 -131
  66. package/kuasheng-ui/components/ks-date-picker/index.js +0 -12
  67. package/kuasheng-ui/components/ks-date-picker/mixin.js +0 -92
  68. package/kuasheng-ui/components/ks-date-picker/month-range-select.vue +0 -129
  69. package/kuasheng-ui/components/ks-date-picker/month-select.vue +0 -85
  70. package/kuasheng-ui/components/ks-date-picker/quarter-select.vue +0 -94
  71. package/kuasheng-ui/components/ks-date-picker/style.less +0 -121
  72. package/kuasheng-ui/components/ks-date-picker/utils.js +0 -109
  73. package/kuasheng-ui/components/ks-date-picker/week-select.vue +0 -99
  74. package/kuasheng-ui/components/ks-decrypt/index.vue +0 -159
  75. package/kuasheng-ui/components/ks-employee/README.md +0 -78
  76. package/kuasheng-ui/components/ks-employee/employee-input.vue +0 -173
  77. package/kuasheng-ui/components/ks-employee/employee-list.vue +0 -662
  78. package/kuasheng-ui/components/ks-employee/employee-popup.vue +0 -197
  79. package/kuasheng-ui/components/ks-employee/employee-search.vue +0 -250
  80. package/kuasheng-ui/components/ks-employee/employee-selected.vue +0 -173
  81. package/kuasheng-ui/components/ks-employee/index.js +0 -17
  82. package/kuasheng-ui/components/ks-employee/package-lock.json +0 -5
  83. package/kuasheng-ui/components/ks-employee/package.json +0 -15
  84. package/kuasheng-ui/components/ks-employee/yarn.lock +0 -4
  85. package/kuasheng-ui/components/ks-field-money/index.js +0 -8
  86. package/kuasheng-ui/components/ks-field-money/index.vue +0 -212
  87. package/kuasheng-ui/components/ks-field-money/package.json +0 -11
  88. package/kuasheng-ui/components/ks-field-money/utils.js +0 -65
  89. 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
  90. package/kuasheng-ui/components/ks-history-search/history-input.vue +0 -131
  91. package/kuasheng-ui/components/ks-history-search/history-list.vue +0 -188
  92. package/kuasheng-ui/components/ks-history-search/img/delete.png +0 -0
  93. package/kuasheng-ui/components/ks-history-search/index.js +0 -9
  94. package/kuasheng-ui/components/ks-history-search/index.vue +0 -125
  95. package/kuasheng-ui/components/ks-history-search/package-lock.json +0 -5
  96. package/kuasheng-ui/components/ks-history-search/package.json +0 -15
  97. package/kuasheng-ui/components/ks-history-search/utils.js +0 -35
  98. package/kuasheng-ui/components/ks-input-search/index.vue +0 -106
  99. package/kuasheng-ui/components/ks-list/index.vue +0 -75
  100. package/kuasheng-ui/components/ks-loading/index.js +0 -16
  101. package/kuasheng-ui/components/ks-month/index.vue +0 -47
  102. package/kuasheng-ui/components/ks-month/package.json +0 -3
  103. package/kuasheng-ui/components/ks-month/range.vue +0 -172
  104. package/kuasheng-ui/components/ks-month/single.vue +0 -136
  105. package/kuasheng-ui/components/ks-month/style.less +0 -125
  106. package/kuasheng-ui/components/ks-month/utils.js +0 -35
  107. package/kuasheng-ui/components/ks-nav/index.vue +0 -264
  108. package/kuasheng-ui/components/ks-nav-bar.js +0 -35
  109. package/kuasheng-ui/components/ks-org/ks-org-tree.vue +0 -247
  110. package/kuasheng-ui/components/ks-org/ks-popup-tree.vue +0 -154
  111. package/kuasheng-ui/components/ks-org/ks-tree-input.vue +0 -240
  112. package/kuasheng-ui/components/ks-org/ks-tree-node.vue +0 -94
  113. package/kuasheng-ui/components/ks-org/ks-tree.vue +0 -229
  114. package/kuasheng-ui/components/ks-org/utils.js +0 -54
  115. package/kuasheng-ui/components/ks-popover/index.vue +0 -457
  116. package/kuasheng-ui/components/ks-popover/mixin.js +0 -28
  117. package/kuasheng-ui/components/ks-popover/utils.js +0 -60
  118. package/kuasheng-ui/components/ks-pull-refresh/index.vue +0 -43
  119. package/kuasheng-ui/components/ks-quarter/index.vue +0 -256
  120. package/kuasheng-ui/components/ks-table/README.md +0 -103
  121. package/kuasheng-ui/components/ks-table/cell.vue +0 -31
  122. package/kuasheng-ui/components/ks-table/index.js +0 -8
  123. package/kuasheng-ui/components/ks-table/index.less +0 -486
  124. package/kuasheng-ui/components/ks-table/index.vue +0 -1088
  125. package/kuasheng-ui/components/ks-table/package.json +0 -12
  126. package/kuasheng-ui/components/ks-table/release.md +0 -7
  127. package/kuasheng-ui/components/ks-toast.js +0 -35
  128. package/kuasheng-ui/components/ks-upload/index.vue +0 -174
  129. package/kuasheng-ui/components/ks-user-access.vue +0 -229
  130. package/kuasheng-ui/components/no-data/README.md +0 -45
  131. package/kuasheng-ui/components/no-data/image.js +0 -1
  132. package/kuasheng-ui/components/no-data/index.vue +0 -83
  133. package/kuasheng-ui/components/notice-bar.vue +0 -16
  134. package/kuasheng-ui/components/steps.js +0 -11
  135. package/kuasheng-ui/components/tabs.vue +0 -40
  136. package/kuasheng-ui/index.js +0 -239
  137. package/kuasheng-ui/patch/datetime-picker/datetimePicker.md +0 -0
  138. package/kuasheng-ui/patch/datetime-picker/index.js +0 -46
  139. package/kuasheng-ui/patch/datetime-picker/utils.js +0 -78
  140. package/kuasheng-ui/patch/field/field.md +0 -1
  141. package/kuasheng-ui/patch/field/index.js +0 -122
  142. package/kuasheng-ui/patch/field/utils.js +0 -36
  143. package/kuasheng-ui/patch/form/form.md +0 -7
  144. package/kuasheng-ui/patch/form/index.js +0 -106
  145. package/kuasheng-ui/patch/index.js +0 -12
  146. package/kuasheng-ui/patch/pagination/index.js +0 -78
  147. package/kuasheng-ui/style/animation-ui.less +0 -31
  148. package/kuasheng-ui/style/font/number/font-number1.otf +0 -0
  149. package/kuasheng-ui/style/font/number/font-number2.ttf +0 -0
  150. package/kuasheng-ui/style/images/checked.svg +0 -1
  151. package/kuasheng-ui/style/images/success.svg +0 -1
  152. package/kuasheng-ui/style/index.less +0 -6
  153. package/kuasheng-ui/style/kuasheng-ui.less +0 -207
  154. package/kuasheng-ui/style/reset-vant.less +0 -307
  155. package/kuasheng-ui/style/vant-var.less +0 -138
  156. package/kuasheng-ui/utils/apis.js +0 -17
  157. package/kuasheng-ui/utils/axios-adapter.js +0 -47
  158. package/kuasheng-ui/utils/bem.js +0 -39
  159. package/kuasheng-ui/utils/bus.js +0 -97
  160. package/kuasheng-ui/utils/common.js +0 -88
  161. package/kuasheng-ui/utils/decrypt/config.js +0 -12
  162. package/kuasheng-ui/utils/decrypt/decrypt-api.js +0 -139
  163. package/kuasheng-ui/utils/decrypt/index.js +0 -6
  164. package/kuasheng-ui/utils/decrypt/mask.js +0 -36
  165. package/kuasheng-ui/utils/decrypt/virtual.js +0 -44
  166. package/kuasheng-ui/utils/directive.js +0 -57
  167. package/kuasheng-ui/utils/directive.md +0 -23
  168. package/kuasheng-ui/utils/drcheck-plugin.js +0 -219
  169. package/kuasheng-ui/utils/error-plugin.js +0 -88
  170. package/kuasheng-ui/utils/filter.js +0 -149
  171. package/kuasheng-ui/utils/http-interceptors.js +0 -18
  172. package/kuasheng-ui/utils/http.js +0 -140
  173. package/kuasheng-ui/utils/index.js +0 -5
  174. package/kuasheng-ui/utils/init-event.js +0 -20
  175. package/kuasheng-ui/utils/log.js +0 -309
  176. package/kuasheng-ui/utils/token.js +0 -9
  177. package/kuasheng-ui/utils/type.js +0 -45
  178. package/kuasheng-ui/utils/validate.js +0 -20
  179. package/kuasheng-ui/utils/watermark.js +0 -67
  180. package/kuasheng-ui/version.js +0 -1
  181. package/ky-apm/client.js +0 -37
  182. package/ky-apm/customHttp.js +0 -38
  183. package/ky-apm/index.js +0 -68
  184. package/ky-apm/plugins/performance.js +0 -84
  185. package/ky-apm/plugins/self-error.js +0 -26
  186. package/ky-apm/warn-log.js +0 -3
  187. package/plugin/ks-chii-webpack-html/index.js +0 -53
  188. package/plugin/ks-chii-webpack-html/package.json +0 -16
  189. package/postcss.config.js +0 -15
  190. package/public/capsule-positon.js +0 -50
  191. package/public/fonts/DingTalkJinBuTi.ttf +0 -0
  192. package/public/framework/axios@0.19.0.min.js +0 -9
  193. package/public/framework/fastclick@1.0.6.min.js +0 -1
  194. package/public/framework/iconfont/iconfont.css +0 -91
  195. package/public/framework/iconfont/iconfont.js +0 -1
  196. package/public/framework/iconfont/iconfont.json +0 -142
  197. package/public/framework/iconfont/iconfont.ttf +0 -0
  198. package/public/framework/iconfont/iconfont.woff +0 -0
  199. package/public/framework/iconfont/iconfont.woff2 +0 -0
  200. package/public/framework/vant@2.5.6.min.js +0 -7
  201. package/public/framework/vue-router@3.1.3.min.js +0 -6
  202. package/public/framework/vue@2.6.10.runtime.min.js +0 -6
  203. package/public/framework/vuex@3.1.1.min.js +0 -6
  204. package/public/index.html +0 -260
  205. package/public/ks@3.0.8.umd.min.js +0 -1
  206. package/public/ksui@4.0.27.umd.min.js +0 -10
  207. package/public/status-bar-preset.js +0 -39
  208. package/qt-npm/index.js +0 -11
  209. package/qt-npm/package.json +0 -13
  210. package/src/App.vue +0 -204
  211. package/src/README.md +0 -15
  212. package/src/common/README.md +0 -94
  213. package/src/common/http/axios-adapter.js +0 -47
  214. package/src/common/http/common.js +0 -88
  215. package/src/common/http/http-interceptors.js +0 -18
  216. package/src/common/http/http-lock.js +0 -45
  217. package/src/common/http/index.js +0 -163
  218. package/src/common/http/token.js +0 -9
  219. package/src/common/styles/font/AlibabaSans102Ver2-Md.ttf +0 -0
  220. package/src/common/styles/font.less +0 -12
  221. package/src/common/styles/variables.less +0 -43
  222. package/src/common/utils/index.js +0 -1
  223. package/src/common/utils/platform/README.md +0 -1
  224. package/src/common/utils/platform/android/.gitkeep +0 -0
  225. package/src/common/utils/platform/core/index.js +0 -24
  226. package/src/common/utils/platform/index.js +0 -164
  227. package/src/common/utils/platform/ios/.gitkeep +0 -0
  228. package/src/common/utils/platform/subscribe/helper.js +0 -38
  229. package/src/common/utils/platform/subscribe/index.js +0 -204
  230. package/src/common/utils/platform/subscribe/table-animation.js +0 -75
  231. package/src/config/index.js +0 -31
  232. package/src/config.js +0 -1
  233. package/src/main.js +0 -73
  234. package/src/router.js +0 -52
  235. package/src/view/home/config.js +0 -101
  236. package/src/view/home/demo1.vue +0 -223
  237. package/src/view/home/demo2.vue +0 -124
  238. package/src/view/home/demo3.vue +0 -51
  239. package/src/view/home/demo4.vue +0 -140
  240. package/src/view/home/index.vue +0 -97
  241. package/src/view/home/query-table/README.md +0 -45
  242. package/src/view/home/query-table/api/index.js +0 -12
  243. package/src/view/home/query-table/assets/horizontal-back.svg +0 -1
  244. package/src/view/home/query-table/components/pe-table/cell.js +0 -181
  245. package/src/view/home/query-table/components/pe-table/collapse.js +0 -334
  246. package/src/view/home/query-table/components/pe-table/empty.vue +0 -48
  247. package/src/view/home/query-table/components/pe-table/header.js +0 -328
  248. package/src/view/home/query-table/components/pe-table/images/abnormal.png +0 -0
  249. package/src/view/home/query-table/components/pe-table/images/empty.png +0 -0
  250. package/src/view/home/query-table/components/pe-table/images/fold.svg +0 -1
  251. package/src/view/home/query-table/components/pe-table/images/sort.svg +0 -1
  252. package/src/view/home/query-table/components/pe-table/images/sorting.svg +0 -1
  253. package/src/view/home/query-table/components/pe-table/images/unfold.svg +0 -1
  254. package/src/view/home/query-table/components/pe-table/index.vue +0 -847
  255. package/src/view/home/query-table/components/pe-table/load-more.js +0 -46
  256. package/src/view/home/query-table/components/pe-table/props/index.js +0 -193
  257. package/src/view/home/query-table/components/pe-table/row.vue +0 -118
  258. package/src/view/home/query-table/components/pe-table/scrollbar.js +0 -424
  259. package/src/view/home/query-table/components/pe-table/stretch-damping.js +0 -112
  260. package/src/view/home/query-table/components/pe-table/style/cell.less +0 -89
  261. package/src/view/home/query-table/components/pe-table/style/empty.less +0 -48
  262. package/src/view/home/query-table/components/pe-table/style/header.less +0 -141
  263. package/src/view/home/query-table/components/pe-table/style/index.less +0 -88
  264. package/src/view/home/query-table/components/pe-table/style/load-more.less +0 -61
  265. package/src/view/home/query-table/components/pe-table/style/row.less +0 -6
  266. package/src/view/home/query-table/components/pe-table/table-loading.vue +0 -120
  267. package/src/view/home/query-table/components/pe-table/table-total.vue +0 -57
  268. package/src/view/home/query-table/components/pe-table/utils/animate.js +0 -80
  269. package/src/view/home/query-table/components/pe-table/utils/columns.js +0 -290
  270. package/src/view/home/query-table/components/pe-table/utils/data.js +0 -12
  271. package/src/view/home/query-table/components/pe-table/utils/fixed.js +0 -69
  272. package/src/view/home/query-table/components/pe-table/utils/formatter.js +0 -327
  273. package/src/view/home/query-table/components/pe-table/utils/render-cells.js +0 -424
  274. package/src/view/home/query-table/components/pe-table/utils/slot.js +0 -28
  275. package/src/view/home/query-table/components/pe-table/utils/tools.js +0 -84
  276. package/src/view/home/query-table/components/pe-table/utils/touch-scroll.js +0 -417
  277. package/src/view/home/query-table/components/query-table/index.vue +0 -497
  278. package/src/view/home/query-table/components/query-table/mixins/column-mixin.js +0 -102
  279. package/src/view/home/query-table/components/query-table/mixins/column-setting.js +0 -143
  280. package/src/view/home/query-table/components/query-table/mixins/data-mixin.js +0 -519
  281. package/src/view/home/query-table/components/query-table/mixins/pagination-mixin.js +0 -26
  282. package/src/view/home/query-table/components/query-table/mixins/table-fixed.js +0 -130
  283. package/src/view/home/query-table/components/query-table/mixins/table-horizontal.js +0 -119
  284. package/src/view/home/query-table/components/table-horizontal.vue +0 -99
  285. package/src/view/home/query-table/components/table-pagination.vue +0 -32
  286. package/src/view/home/query-table/components/table-settings/assets/arrpw-up.svg +0 -1
  287. package/src/view/home/query-table/components/table-settings/assets/disabled-down.svg +0 -1
  288. package/src/view/home/query-table/components/table-settings/assets/disabled-up.svg +0 -1
  289. package/src/view/home/query-table/components/table-settings/assets/down.svg +0 -1
  290. package/src/view/home/query-table/components/table-settings/assets/up.svg +0 -1
  291. package/src/view/home/query-table/components/table-settings/index.less +0 -294
  292. package/src/view/home/query-table/components/table-settings/index.vue +0 -260
  293. package/src/view/home/query-table/components/table-settings/settings.vue +0 -479
  294. package/src/view/home/query-table/components/table-settings/test.js +0 -626
  295. package/src/view/home/query-table/components/table-settings//344/270/252/346/200/247/350/256/276/347/275/256.md +0 -0
  296. package/src/view/home/query-table/components/tooltip.js +0 -124
  297. package/src/view/home/query-table/hooks/use-cache-promise.js +0 -27
  298. package/src/view/home/query-table/hooks/use-column-config.js +0 -190
  299. package/src/view/home/query-table/hooks/use-encryption.js +0 -0
  300. package/src/view/home/query-table/hooks/use-generic-search.js +0 -95
  301. package/src/view/home/query-table/index.js +0 -7
  302. package/src/view/home/query-table/store/column-store.js +0 -0
  303. package/src/view/home/query-table/styles/table.less +0 -24
  304. package/src/view/home/query-table/utils/column.js +0 -36
  305. package/src/view/home/query-table/utils/config.js +0 -12
  306. package/src/view/home/query-table/utils/encryption.js +0 -32
  307. package/src/view/home/query-table/utils/http.js +0 -1
  308. package/src/view/home/query-table/utils/localStorage.js +0 -35
  309. package/src/view/home//351/246/226/351/241/265.md +0 -0
  310. package/src/web.js +0 -99
  311. package/vue.config.js +0 -131
@@ -1,1088 +0,0 @@
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
-