@kyfe/ks-query-table 0.0.21 → 0.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (310) hide show
  1. package/.bitmap +38 -0
  2. package/.editorconfig +5 -0
  3. package/.env.dev +2 -0
  4. package/.env.gray +2 -0
  5. package/.env.prod +2 -0
  6. package/.env.stg +3 -0
  7. package/.env.uat +2 -0
  8. package/.eslintignore +1 -0
  9. package/.eslintrc.js +25 -0
  10. package/.gitmodules +4 -0
  11. package/.prettierrc +11 -0
  12. package/README.md +15 -0
  13. package/babel.config.js +10 -0
  14. package/build-apm.sh +9 -0
  15. package/build.sh +16 -0
  16. package/config/index.js +20 -0
  17. package/jsconfig.json +7 -0
  18. package/kuasheng-sdk/index.js +80 -0
  19. package/kuasheng-sdk/lib/assets.js +304 -0
  20. package/kuasheng-sdk/lib/context.js +199 -0
  21. package/kuasheng-sdk/lib/layout.js +346 -0
  22. package/kuasheng-sdk/lib/location.js +46 -0
  23. package/kuasheng-sdk/lib/media.js +342 -0
  24. package/kuasheng-sdk/lib/navigation.js +30 -0
  25. package/kuasheng-sdk/lib/request.js +76 -0
  26. package/kuasheng-sdk/lib/system.js +190 -0
  27. package/kuasheng-sdk/lib/userinfo.js +98 -0
  28. package/kuasheng-sdk/util/check.js +102 -0
  29. package/kuasheng-sdk/util/config.js +47 -0
  30. package/kuasheng-sdk/util/device.js +25 -0
  31. package/kuasheng-sdk/util/error.js +19 -0
  32. package/kuasheng-sdk/util/funtional.js +153 -0
  33. package/kuasheng-sdk/util/mixin.js +36 -0
  34. package/kuasheng-sdk/util/requestUtil.js +41 -0
  35. package/kuasheng-sdk/util/response.js +33 -0
  36. package/kuasheng-sdk/util/warn.js +35 -0
  37. package/kuasheng-ui/CHANGELOG.md +9 -0
  38. package/kuasheng-ui/components/card.vue +57 -0
  39. package/kuasheng-ui/components/ks-area-select/README.md +43 -0
  40. package/kuasheng-ui/components/ks-area-select/area-picker.vue +554 -0
  41. package/kuasheng-ui/components/ks-area-select/area-search.vue +363 -0
  42. package/kuasheng-ui/components/ks-area-select/areas-pop.vue +56 -0
  43. package/kuasheng-ui/components/ks-area-select/common.js +183 -0
  44. package/kuasheng-ui/components/ks-area-select/index.vue +355 -0
  45. package/kuasheng-ui/components/ks-area-select/mixins.js +216 -0
  46. package/kuasheng-ui/components/ks-area-single-select/README.md +50 -0
  47. package/kuasheng-ui/components/ks-area-single-select/hot-city.js +45 -0
  48. package/kuasheng-ui/components/ks-area-single-select/index.vue +324 -0
  49. package/kuasheng-ui/components/ks-calendar/index.vue +269 -0
  50. package/kuasheng-ui/components/ks-call-phone/call-tips.vue +70 -0
  51. package/kuasheng-ui/components/ks-call-phone/call.vue +178 -0
  52. package/kuasheng-ui/components/ks-call-phone/index.js +48 -0
  53. package/kuasheng-ui/components/ks-call-phone/index.vue +131 -0
  54. package/kuasheng-ui/components/ks-call-phone//345/221/274/345/217/253/347/273/204/344/273/266.md +0 -0
  55. package/kuasheng-ui/components/ks-date-picker/README.md +23 -0
  56. package/kuasheng-ui/components/ks-date-picker/date-picker-bottom.vue +123 -0
  57. package/kuasheng-ui/components/ks-date-picker/date-picker-dropdown.vue +80 -0
  58. package/kuasheng-ui/components/ks-date-picker/date-picker-right.vue +87 -0
  59. package/kuasheng-ui/components/ks-date-picker/date-picker-top.vue +88 -0
  60. package/kuasheng-ui/components/ks-date-picker/date-picker.js +15 -0
  61. package/kuasheng-ui/components/ks-date-picker/date-range-select.vue +92 -0
  62. package/kuasheng-ui/components/ks-date-picker/date-select.vue +65 -0
  63. package/kuasheng-ui/components/ks-date-picker/date-week-month.vue +131 -0
  64. package/kuasheng-ui/components/ks-date-picker/index.js +12 -0
  65. package/kuasheng-ui/components/ks-date-picker/mixin.js +92 -0
  66. package/kuasheng-ui/components/ks-date-picker/month-range-select.vue +129 -0
  67. package/kuasheng-ui/components/ks-date-picker/month-select.vue +85 -0
  68. package/kuasheng-ui/components/ks-date-picker/quarter-select.vue +94 -0
  69. package/kuasheng-ui/components/ks-date-picker/style.less +121 -0
  70. package/kuasheng-ui/components/ks-date-picker/utils.js +109 -0
  71. package/kuasheng-ui/components/ks-date-picker/week-select.vue +99 -0
  72. package/kuasheng-ui/components/ks-decrypt/index.vue +159 -0
  73. package/kuasheng-ui/components/ks-employee/README.md +78 -0
  74. package/kuasheng-ui/components/ks-employee/employee-input.vue +173 -0
  75. package/kuasheng-ui/components/ks-employee/employee-list.vue +662 -0
  76. package/kuasheng-ui/components/ks-employee/employee-popup.vue +197 -0
  77. package/kuasheng-ui/components/ks-employee/employee-search.vue +250 -0
  78. package/kuasheng-ui/components/ks-employee/employee-selected.vue +173 -0
  79. package/kuasheng-ui/components/ks-employee/index.js +17 -0
  80. package/kuasheng-ui/components/ks-employee/package-lock.json +5 -0
  81. package/kuasheng-ui/components/ks-employee/package.json +15 -0
  82. package/kuasheng-ui/components/ks-employee/yarn.lock +4 -0
  83. package/kuasheng-ui/components/ks-field-money/index.js +8 -0
  84. package/kuasheng-ui/components/ks-field-money/index.vue +212 -0
  85. package/kuasheng-ui/components/ks-field-money/package.json +11 -0
  86. package/kuasheng-ui/components/ks-field-money/utils.js +65 -0
  87. 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
  88. package/kuasheng-ui/components/ks-history-search/history-input.vue +131 -0
  89. package/kuasheng-ui/components/ks-history-search/history-list.vue +188 -0
  90. package/kuasheng-ui/components/ks-history-search/img/delete.png +0 -0
  91. package/kuasheng-ui/components/ks-history-search/index.js +9 -0
  92. package/kuasheng-ui/components/ks-history-search/index.vue +125 -0
  93. package/kuasheng-ui/components/ks-history-search/package-lock.json +5 -0
  94. package/kuasheng-ui/components/ks-history-search/package.json +15 -0
  95. package/kuasheng-ui/components/ks-history-search/utils.js +35 -0
  96. package/kuasheng-ui/components/ks-input-search/index.vue +106 -0
  97. package/kuasheng-ui/components/ks-list/index.vue +75 -0
  98. package/kuasheng-ui/components/ks-loading/index.js +16 -0
  99. package/kuasheng-ui/components/ks-month/index.vue +47 -0
  100. package/kuasheng-ui/components/ks-month/package.json +3 -0
  101. package/kuasheng-ui/components/ks-month/range.vue +172 -0
  102. package/kuasheng-ui/components/ks-month/single.vue +136 -0
  103. package/kuasheng-ui/components/ks-month/style.less +125 -0
  104. package/kuasheng-ui/components/ks-month/utils.js +35 -0
  105. package/kuasheng-ui/components/ks-nav/index.vue +264 -0
  106. package/kuasheng-ui/components/ks-nav-bar.js +35 -0
  107. package/kuasheng-ui/components/ks-org/ks-org-tree.vue +247 -0
  108. package/kuasheng-ui/components/ks-org/ks-popup-tree.vue +154 -0
  109. package/kuasheng-ui/components/ks-org/ks-tree-input.vue +240 -0
  110. package/kuasheng-ui/components/ks-org/ks-tree-node.vue +94 -0
  111. package/kuasheng-ui/components/ks-org/ks-tree.vue +229 -0
  112. package/kuasheng-ui/components/ks-org/utils.js +54 -0
  113. package/kuasheng-ui/components/ks-popover/index.vue +457 -0
  114. package/kuasheng-ui/components/ks-popover/mixin.js +28 -0
  115. package/kuasheng-ui/components/ks-popover/utils.js +60 -0
  116. package/kuasheng-ui/components/ks-pull-refresh/index.vue +43 -0
  117. package/kuasheng-ui/components/ks-quarter/index.vue +256 -0
  118. package/kuasheng-ui/components/ks-table/README.md +103 -0
  119. package/kuasheng-ui/components/ks-table/cell.vue +31 -0
  120. package/kuasheng-ui/components/ks-table/index.js +8 -0
  121. package/kuasheng-ui/components/ks-table/index.less +486 -0
  122. package/kuasheng-ui/components/ks-table/index.vue +1088 -0
  123. package/kuasheng-ui/components/ks-table/package.json +12 -0
  124. package/kuasheng-ui/components/ks-table/release.md +7 -0
  125. package/kuasheng-ui/components/ks-toast.js +35 -0
  126. package/kuasheng-ui/components/ks-upload/index.vue +174 -0
  127. package/kuasheng-ui/components/ks-user-access.vue +229 -0
  128. package/kuasheng-ui/components/no-data/README.md +45 -0
  129. package/kuasheng-ui/components/no-data/image.js +1 -0
  130. package/kuasheng-ui/components/no-data/index.vue +83 -0
  131. package/kuasheng-ui/components/notice-bar.vue +16 -0
  132. package/kuasheng-ui/components/steps.js +11 -0
  133. package/kuasheng-ui/components/tabs.vue +40 -0
  134. package/kuasheng-ui/index.js +239 -0
  135. package/kuasheng-ui/patch/datetime-picker/datetimePicker.md +0 -0
  136. package/kuasheng-ui/patch/datetime-picker/index.js +46 -0
  137. package/kuasheng-ui/patch/datetime-picker/utils.js +78 -0
  138. package/kuasheng-ui/patch/field/field.md +1 -0
  139. package/kuasheng-ui/patch/field/index.js +122 -0
  140. package/kuasheng-ui/patch/field/utils.js +36 -0
  141. package/kuasheng-ui/patch/form/form.md +7 -0
  142. package/kuasheng-ui/patch/form/index.js +106 -0
  143. package/kuasheng-ui/patch/index.js +12 -0
  144. package/kuasheng-ui/patch/pagination/index.js +78 -0
  145. package/kuasheng-ui/style/animation-ui.less +31 -0
  146. package/kuasheng-ui/style/font/number/font-number1.otf +0 -0
  147. package/kuasheng-ui/style/font/number/font-number2.ttf +0 -0
  148. package/kuasheng-ui/style/images/checked.svg +1 -0
  149. package/kuasheng-ui/style/images/success.svg +1 -0
  150. package/kuasheng-ui/style/index.less +6 -0
  151. package/kuasheng-ui/style/kuasheng-ui.less +207 -0
  152. package/kuasheng-ui/style/reset-vant.less +307 -0
  153. package/kuasheng-ui/style/vant-var.less +138 -0
  154. package/kuasheng-ui/utils/apis.js +17 -0
  155. package/kuasheng-ui/utils/axios-adapter.js +47 -0
  156. package/kuasheng-ui/utils/bem.js +39 -0
  157. package/kuasheng-ui/utils/bus.js +97 -0
  158. package/kuasheng-ui/utils/common.js +88 -0
  159. package/kuasheng-ui/utils/decrypt/config.js +12 -0
  160. package/kuasheng-ui/utils/decrypt/decrypt-api.js +139 -0
  161. package/kuasheng-ui/utils/decrypt/index.js +6 -0
  162. package/kuasheng-ui/utils/decrypt/mask.js +36 -0
  163. package/kuasheng-ui/utils/decrypt/virtual.js +44 -0
  164. package/kuasheng-ui/utils/directive.js +57 -0
  165. package/kuasheng-ui/utils/directive.md +23 -0
  166. package/kuasheng-ui/utils/drcheck-plugin.js +219 -0
  167. package/kuasheng-ui/utils/error-plugin.js +88 -0
  168. package/kuasheng-ui/utils/filter.js +149 -0
  169. package/kuasheng-ui/utils/http-interceptors.js +18 -0
  170. package/kuasheng-ui/utils/http.js +140 -0
  171. package/kuasheng-ui/utils/index.js +5 -0
  172. package/kuasheng-ui/utils/init-event.js +20 -0
  173. package/kuasheng-ui/utils/log.js +309 -0
  174. package/kuasheng-ui/utils/token.js +9 -0
  175. package/kuasheng-ui/utils/type.js +45 -0
  176. package/kuasheng-ui/utils/validate.js +20 -0
  177. package/kuasheng-ui/utils/watermark.js +67 -0
  178. package/kuasheng-ui/version.js +1 -0
  179. package/ky-apm/client.js +37 -0
  180. package/ky-apm/customHttp.js +38 -0
  181. package/ky-apm/index.js +68 -0
  182. package/ky-apm/plugins/performance.js +84 -0
  183. package/ky-apm/plugins/self-error.js +26 -0
  184. package/ky-apm/warn-log.js +3 -0
  185. package/package.json +81 -10
  186. package/plugin/ks-chii-webpack-html/index.js +53 -0
  187. package/plugin/ks-chii-webpack-html/package.json +16 -0
  188. package/postcss.config.js +15 -0
  189. package/public/capsule-positon.js +50 -0
  190. package/public/fonts/DingTalkJinBuTi.ttf +0 -0
  191. package/public/framework/axios@0.19.0.min.js +9 -0
  192. package/public/framework/fastclick@1.0.6.min.js +1 -0
  193. package/public/framework/iconfont/iconfont.css +91 -0
  194. package/public/framework/iconfont/iconfont.js +1 -0
  195. package/public/framework/iconfont/iconfont.json +142 -0
  196. package/public/framework/iconfont/iconfont.ttf +0 -0
  197. package/public/framework/iconfont/iconfont.woff +0 -0
  198. package/public/framework/iconfont/iconfont.woff2 +0 -0
  199. package/public/framework/vant@2.5.6.min.js +7 -0
  200. package/public/framework/vue-router@3.1.3.min.js +6 -0
  201. package/public/framework/vue@2.6.10.runtime.min.js +6 -0
  202. package/public/framework/vuex@3.1.1.min.js +6 -0
  203. package/public/index.html +260 -0
  204. package/public/ks@3.0.8.umd.min.js +1 -0
  205. package/public/ksui@4.0.27.umd.min.js +10 -0
  206. package/public/status-bar-preset.js +39 -0
  207. package/{index.js → qt-npm/index.js} +3 -3
  208. package/qt-npm/package.json +13 -0
  209. package/src/App.vue +204 -0
  210. package/src/README.md +15 -0
  211. package/src/common/README.md +94 -0
  212. package/src/common/http/axios-adapter.js +47 -0
  213. package/src/common/http/common.js +88 -0
  214. package/src/common/http/http-interceptors.js +18 -0
  215. package/src/common/http/http-lock.js +45 -0
  216. package/src/common/http/index.js +163 -0
  217. package/src/common/http/token.js +9 -0
  218. package/src/common/styles/font/AlibabaSans102Ver2-Md.ttf +0 -0
  219. package/src/common/styles/font.less +12 -0
  220. package/src/common/styles/variables.less +43 -0
  221. package/src/common/utils/index.js +1 -0
  222. package/src/common/utils/platform/README.md +1 -0
  223. package/src/common/utils/platform/android/.gitkeep +0 -0
  224. package/src/common/utils/platform/core/index.js +24 -0
  225. package/src/common/utils/platform/index.js +164 -0
  226. package/src/common/utils/platform/ios/.gitkeep +0 -0
  227. package/src/common/utils/platform/subscribe/helper.js +38 -0
  228. package/src/common/utils/platform/subscribe/index.js +204 -0
  229. package/src/common/utils/platform/subscribe/table-animation.js +75 -0
  230. package/src/config/index.js +31 -0
  231. package/src/config.js +1 -0
  232. package/src/main.js +73 -0
  233. package/src/router.js +52 -0
  234. package/src/view/home/config.js +101 -0
  235. package/src/view/home/demo1.vue +223 -0
  236. package/src/view/home/demo2.vue +124 -0
  237. package/src/view/home/demo3.vue +51 -0
  238. package/src/view/home/demo4.vue +140 -0
  239. package/src/view/home/index.vue +97 -0
  240. package/src/view/home/query-table/README.md +45 -0
  241. package/src/view/home/query-table/api/index.js +12 -0
  242. package/src/view/home/query-table/assets/horizontal-back.svg +1 -0
  243. package/src/view/home/query-table/components/pe-table/cell.js +181 -0
  244. package/src/view/home/query-table/components/pe-table/collapse.js +334 -0
  245. package/src/view/home/query-table/components/pe-table/empty.vue +48 -0
  246. package/src/view/home/query-table/components/pe-table/header.js +328 -0
  247. package/src/view/home/query-table/components/pe-table/images/abnormal.png +0 -0
  248. package/src/view/home/query-table/components/pe-table/images/empty.png +0 -0
  249. package/src/view/home/query-table/components/pe-table/images/fold.svg +1 -0
  250. package/src/view/home/query-table/components/pe-table/images/sort.svg +1 -0
  251. package/src/view/home/query-table/components/pe-table/images/sorting.svg +1 -0
  252. package/src/view/home/query-table/components/pe-table/images/unfold.svg +1 -0
  253. package/src/view/home/query-table/components/pe-table/index.vue +847 -0
  254. package/src/view/home/query-table/components/pe-table/load-more.js +46 -0
  255. package/src/view/home/query-table/components/pe-table/props/index.js +193 -0
  256. package/src/view/home/query-table/components/pe-table/row.vue +118 -0
  257. package/src/view/home/query-table/components/pe-table/scrollbar.js +424 -0
  258. package/src/view/home/query-table/components/pe-table/stretch-damping.js +112 -0
  259. package/src/view/home/query-table/components/pe-table/style/cell.less +89 -0
  260. package/src/view/home/query-table/components/pe-table/style/empty.less +48 -0
  261. package/src/view/home/query-table/components/pe-table/style/header.less +141 -0
  262. package/src/view/home/query-table/components/pe-table/style/index.less +88 -0
  263. package/src/view/home/query-table/components/pe-table/style/load-more.less +61 -0
  264. package/src/view/home/query-table/components/pe-table/style/row.less +6 -0
  265. package/src/view/home/query-table/components/pe-table/table-loading.vue +120 -0
  266. package/src/view/home/query-table/components/pe-table/table-total.vue +57 -0
  267. package/src/view/home/query-table/components/pe-table/utils/animate.js +80 -0
  268. package/src/view/home/query-table/components/pe-table/utils/columns.js +290 -0
  269. package/src/view/home/query-table/components/pe-table/utils/data.js +12 -0
  270. package/src/view/home/query-table/components/pe-table/utils/fixed.js +69 -0
  271. package/src/view/home/query-table/components/pe-table/utils/formatter.js +327 -0
  272. package/src/view/home/query-table/components/pe-table/utils/render-cells.js +424 -0
  273. package/src/view/home/query-table/components/pe-table/utils/slot.js +28 -0
  274. package/src/view/home/query-table/components/pe-table/utils/tools.js +84 -0
  275. package/src/view/home/query-table/components/pe-table/utils/touch-scroll.js +417 -0
  276. package/src/view/home/query-table/components/query-table/index.vue +497 -0
  277. package/src/view/home/query-table/components/query-table/mixins/column-mixin.js +102 -0
  278. package/src/view/home/query-table/components/query-table/mixins/column-setting.js +143 -0
  279. package/src/view/home/query-table/components/query-table/mixins/data-mixin.js +519 -0
  280. package/src/view/home/query-table/components/query-table/mixins/pagination-mixin.js +26 -0
  281. package/src/view/home/query-table/components/query-table/mixins/table-fixed.js +130 -0
  282. package/src/view/home/query-table/components/query-table/mixins/table-horizontal.js +119 -0
  283. package/src/view/home/query-table/components/table-horizontal.vue +99 -0
  284. package/src/view/home/query-table/components/table-pagination.vue +32 -0
  285. package/src/view/home/query-table/components/table-settings/assets/arrpw-up.svg +1 -0
  286. package/src/view/home/query-table/components/table-settings/assets/disabled-down.svg +1 -0
  287. package/src/view/home/query-table/components/table-settings/assets/disabled-up.svg +1 -0
  288. package/src/view/home/query-table/components/table-settings/assets/down.svg +1 -0
  289. package/src/view/home/query-table/components/table-settings/assets/up.svg +1 -0
  290. package/src/view/home/query-table/components/table-settings/index.less +294 -0
  291. package/src/view/home/query-table/components/table-settings/index.vue +260 -0
  292. package/src/view/home/query-table/components/table-settings/settings.vue +479 -0
  293. package/src/view/home/query-table/components/table-settings/test.js +626 -0
  294. package/src/view/home/query-table/components/table-settings//344/270/252/346/200/247/350/256/276/347/275/256.md +0 -0
  295. package/src/view/home/query-table/components/tooltip.js +124 -0
  296. package/src/view/home/query-table/hooks/use-cache-promise.js +27 -0
  297. package/src/view/home/query-table/hooks/use-column-config.js +190 -0
  298. package/src/view/home/query-table/hooks/use-encryption.js +0 -0
  299. package/src/view/home/query-table/hooks/use-generic-search.js +95 -0
  300. package/src/view/home/query-table/index.js +7 -0
  301. package/src/view/home/query-table/store/column-store.js +0 -0
  302. package/src/view/home/query-table/styles/table.less +24 -0
  303. package/src/view/home/query-table/utils/column.js +36 -0
  304. package/src/view/home/query-table/utils/config.js +12 -0
  305. package/src/view/home/query-table/utils/encryption.js +32 -0
  306. package/src/view/home/query-table/utils/http.js +1 -0
  307. package/src/view/home/query-table/utils/localStorage.js +35 -0
  308. package/src/view/home//351/246/226/351/241/265.md +0 -0
  309. package/src/web.js +99 -0
  310. package/vue.config.js +131 -0
@@ -0,0 +1,57 @@
1
+ // 键盘顶出的高度
2
+ const getScrollTop = () => {
3
+ return window.pageYOffset ||
4
+ document.documentElement.scrollTop ||
5
+ document.body.scrollTop ||
6
+ 0
7
+ }
8
+
9
+ const onFocusin = (el) => {
10
+ // 等待键盘弹起延迟200毫秒
11
+ setTimeout(() => {
12
+ let scrollTop = getScrollTop()
13
+ if (scrollTop) {
14
+ if (el) {
15
+ el.style.transform = `translateY(${scrollTop}px)`
16
+ }
17
+ } else {
18
+ // 滚动高度0,重试一次
19
+ setTimeout(() => {
20
+ if (el) {
21
+ el.style.transform = `translateY(${getScrollTop()}px)`
22
+ }
23
+ }, 100)
24
+ }
25
+ }, 200)
26
+ }
27
+
28
+ const onFocusout = (el) => {
29
+ if (el) {
30
+ el.style.transform = 'translateY(0)'
31
+ }
32
+ }
33
+
34
+ let timer
35
+ const onScroll = (el) => {
36
+ el.style.opacity = 0
37
+ clearTimeout(timer)
38
+ timer = setTimeout(() => {
39
+ el.style.transform = `translateY(${getScrollTop()}px)`
40
+ el.style.opacity = 1
41
+ }, 100)
42
+ }
43
+
44
+ export const sticky = {
45
+ bind (el) {
46
+ if (navigator.userAgent.includes('iPhone')) {
47
+ document.body.addEventListener('focusin', onFocusin.bind(this, el))
48
+ document.body.addEventListener('focusout', onFocusout.bind(this, el))
49
+ window.addEventListener('scroll', onScroll.bind(this, el))
50
+ }
51
+ },
52
+ unbind () {
53
+ document.body.removeEventListener('focusin', onFocusin)
54
+ document.body.removeEventListener('focusout', onFocusout)
55
+ window.removeEventListener('scroll', onScroll)
56
+ }
57
+ }
@@ -0,0 +1,23 @@
1
+ ## 指令
2
+
3
+ ### v-sticky
4
+ - 该指令用于解决ios平台键盘弹出时导航被顶出可视区的问题
5
+
6
+ #### 用法:
7
+ - 该指令已在ksui中全局注入
8
+
9
+ ``` javascript
10
+ <header v-sticky class="ksui-header">
11
+ <div class="ksui-nav">
12
+ <ks-nav-bar
13
+ :title="title"
14
+ :left-arrow="showArrow"
15
+ @click-left="goBack"
16
+ />
17
+ </div>
18
+ </header>
19
+ ```
20
+
21
+ #### 注意:
22
+ - 自定义导航请参考demo项目的布局结构和定位方式使用该指令
23
+ - 该指令使用transform样式来修正导航的位置,使用该指令的容器要避免使用transform样式
@@ -0,0 +1,219 @@
1
+
2
+ let rules = []
3
+ let stopUpload = false
4
+ const vmSet = new Set()
5
+ const maxLength = 10
6
+ const wait = 2000 // ms
7
+ const poll = 3000 // ms
8
+ let pollInterval = null
9
+ let http = null
10
+ let lastCheckTime = +new Date()
11
+
12
+ const headers = {
13
+ 'X-menu-id': '2820215716730110',
14
+ $config: {
15
+ _tips: true,
16
+ _log: false
17
+ }
18
+ }
19
+
20
+ export function installDRCheck(Vue) {
21
+ if (isProd()) return
22
+ if (!Vue) {
23
+ createEvent()
24
+ mixVue(window.Vue)
25
+ }
26
+ createPoll()
27
+ }
28
+
29
+ function createEvent() {
30
+ window.addEventListener('__ks_ready__', function (e) {
31
+ delayInit(e.detail)
32
+ })
33
+ }
34
+
35
+ async function delayInit(option) {
36
+ http = option.http
37
+ try {
38
+ let data = await getRulesByHttp()
39
+ rules = data[0] && data[0].childrenLookupValues || []
40
+ if (!rules.length) failedToGetRules()
41
+ } catch (e) {
42
+ failedToGetRules()
43
+ console.log('[drCheck-plugin] ', e)
44
+ }
45
+ }
46
+
47
+ function failedToGetRules() {
48
+ rules = []
49
+ stopUpload = true
50
+ clearInterval(pollInterval)
51
+ }
52
+
53
+ function getRulesByHttp() {
54
+ return http('system.lookupValue.BatchByCode', 10124, ['sys_frontend_drcheck_h5'], { headers })
55
+ }
56
+
57
+ function isProd() {
58
+ return window.location.origin.indexOf('www.kye-erp.com') >= 0 || window.navigator.userAgent.indexOf('prod') > 0
59
+ }
60
+
61
+ function getModuleId() {
62
+ let erp = (window.__ERPMODULE__ && window.__ERPMODULE__.id) || ''
63
+ let h5 = (window.ksui && window.ksui.menu && window.ksui.menu.id) || ''
64
+ return erp || h5
65
+ }
66
+
67
+ function mixVue(Vue) {
68
+ Vue.mixin({
69
+ mounted() {
70
+ let env = {
71
+ url: window.location.href,
72
+ menuId: getModuleId()
73
+ }
74
+ this.__drcheck_env__ = env
75
+ addVm(this)
76
+ // console.log('collect: ', vmSet)
77
+ },
78
+ // destroyed () {
79
+ // remove(this)
80
+ // console.log('collect: ', vmSet)
81
+ // }
82
+ })
83
+ }
84
+
85
+ function addVm(vm) {
86
+ if (stopUpload) return
87
+ try {
88
+ vmSet.add(vm)
89
+ setTimeout(checkForUpload, 0)
90
+ resetPoll()
91
+ } catch (e) {
92
+ console.log('[drCheck-plugin] ', e)
93
+ }
94
+ }
95
+
96
+ function createPoll() {
97
+ pollInterval = window.setInterval(checkForUpload, poll)
98
+ }
99
+
100
+ function resetPoll() {
101
+ clearInterval(pollInterval)
102
+ createPoll()
103
+ }
104
+
105
+ // function remove (vm) {
106
+ // vmSet.delete(vm)
107
+ // }
108
+
109
+ function checkForUpload() {
110
+ if (vmSet.size === 0) return
111
+ if (!rules.length) return
112
+ let isTimeout = +new Date() - lastCheckTime > wait
113
+ if (vmSet.size > maxLength || isTimeout) {
114
+ lastCheckTime = +new Date()
115
+ const willUpload = []
116
+ vmSet.forEach(vm => {
117
+ let props = extractDataAndProps(vm)
118
+ let el = vm.$el
119
+ let currentRule = null
120
+ let canUpload = rules.some(rule => {
121
+ try {
122
+ let option = {
123
+ props,
124
+ el,
125
+ vm
126
+ }
127
+ if (createFunction(rule.func || rule.lookupValue)(option)) {
128
+ currentRule = rule
129
+ return true
130
+ }
131
+ } catch (_) {
132
+ return false
133
+ }
134
+ })
135
+ if (canUpload) {
136
+ willUpload.push(extractForUpload(vm, currentRule))
137
+ }
138
+ vmSet.delete(vm)
139
+ })
140
+ upload(willUpload)
141
+ }
142
+ }
143
+
144
+ function upload(list) {
145
+ if (list.length === 0) return
146
+ console.warn('[drCheck-plugin] will-upload: ', list)
147
+ try {
148
+ // http('cts.framework.uploadWebActionLog', 50159, list, {headers})
149
+ } catch (e) {
150
+ console.log('[drCheck-plugin] dcCheck http: ', e)
151
+ }
152
+ }
153
+
154
+ function createFunction(body) {
155
+ // eslint-disable-next-line
156
+ return new Function('option', body)
157
+ }
158
+
159
+ function extractForUpload(vm, rule) {
160
+ let detail = ''
161
+ try {
162
+ detail = JSON.stringify(extractPrimitive(extractDataAndProps(vm)))
163
+ } catch (e) {
164
+ console.log(e)
165
+ detail = '[drCheck-plugin] extract error'
166
+ }
167
+ return {
168
+ menuId: vm.__drcheck_env__.menuId,
169
+ url: vm.__drcheck_env__.url,
170
+ ruleId: rule.lookupCode,
171
+ tag: vm.$vnode && vm.$vnode.tag,
172
+ detail,
173
+ navigator: window.navigator.userAgent,
174
+ ext1: `xpath: ${getPathTo(vm.$el)}, version: ${document.lastModified}`
175
+ }
176
+ }
177
+
178
+ function extractDataAndProps(vm) {
179
+ return {
180
+ ...vm._props,
181
+ ...vm._data
182
+ }
183
+ }
184
+
185
+ function extractPrimitive(obj) {
186
+ let result = Object.create(null)
187
+ Object.keys(obj).forEach(k => {
188
+ if (isObject(obj[k])) {
189
+ result[k] = `_ignore_`
190
+ } else {
191
+ result[k] = obj[k]
192
+ }
193
+ })
194
+ return result
195
+ }
196
+
197
+ function isObject(obj) {
198
+ return obj !== null && typeof obj === 'object'
199
+ }
200
+
201
+ function getPathTo(element) {
202
+ if (!element) {
203
+ return 'Error Dom'
204
+ }
205
+ try {
206
+ if (element.id !== '') { return 'id("' + element.id + '")' }
207
+ if (element === document.body) { return element.tagName }
208
+
209
+ let ix = 0
210
+ let siblings = element.parentNode.childNodes
211
+ for (let i = 0; i < siblings.length; i++) {
212
+ let sibling = siblings[i]
213
+ if (sibling === element) { return getPathTo(element.parentNode) + '/' + element.tagName + '[' + (ix + 1) + ']' }
214
+ if (sibling.nodeType === 1 && sibling.tagName === element.tagName) { ix++ }
215
+ }
216
+ } catch (_) {
217
+ return element.tagName || 'Error Dom'
218
+ }
219
+ }
@@ -0,0 +1,88 @@
1
+ /**
2
+ * 前端错误日志上报
3
+ */
4
+ class ErrorPlugin {
5
+ /**
6
+ * @param {*} option 参数包含user、menu、type字段
7
+ */
8
+ constructor(option = {}) {
9
+ this.user = option.user
10
+ this.menu = option.menu
11
+ this.type = option.type || 'H5'
12
+ this.platform = 'H5'
13
+ this.addEvent()
14
+ }
15
+
16
+ addEvent() {
17
+ window.addEventListener('error', this.windowErrorHandler.bind(this), false)
18
+ }
19
+
20
+ /**
21
+ * 处理window error报错
22
+ */
23
+ windowErrorHandler(e) {
24
+ this.handleError(e.error, {
25
+ info: e.filename,
26
+ colno: e.colno,
27
+ lineno: e.lineno
28
+ })
29
+ }
30
+
31
+ /**
32
+ * 处理vue报错
33
+ */
34
+ vueErrorHandler(Vue) {
35
+ Vue.config.errorHandler = (error, vm, info) => {
36
+ if (vm) {
37
+ this.handleError(error, {
38
+ info,
39
+ component: vm._original && vm._original.$vnode ? vm._original.$vnode.tag : vm.$vnode.tag
40
+ })
41
+ }
42
+ }
43
+ }
44
+
45
+ /**
46
+ * 处理react报错
47
+ */
48
+ reactErrorHandler(error, info) {
49
+ this.handleError(error, {
50
+ info: info.componentStack,
51
+ })
52
+ }
53
+
54
+ handleError(error, option) {
55
+ if (!error) {
56
+ return
57
+ }
58
+ let user = this.user || (window.ksui && window.ksui.user) || {}
59
+ let menu = this.menu || (window.ksui && window.ksui.menu) || {}
60
+ let data = {
61
+ userId: user.id || '',
62
+ userName: user.name || '',
63
+ menuId: menu.id || '',
64
+ menuName: `${this.type}-${menu.title || ''}`,
65
+ platform: this.platform,
66
+ error: error && error.stack || '',
67
+ option: {
68
+ veriosn: document.lastModified,
69
+ url: decodeURIComponent(location.href),
70
+ ua: window.navigator.userAgent,
71
+ ...option
72
+ }
73
+ }
74
+ this.report(data)
75
+ }
76
+
77
+ report(data) {
78
+ data.option = JSON.stringify(data.option)
79
+ let headers = {
80
+ timestamp: Date.now(),
81
+ appkey: '10135'
82
+ }
83
+ // console.log('[error-log]', data)
84
+ // window.ks.request('syslog.frontendOperationLog.save', data, headers)
85
+ }
86
+ }
87
+
88
+ export default ErrorPlugin
@@ -0,0 +1,149 @@
1
+ /**
2
+ *
3
+ * @param {date} date
4
+ * @param {string} fmt
5
+ */
6
+ export const date = (date, fmt = 'YYYY-MM-DD HH:mm:ss') => {
7
+ var o = {
8
+ 'M+': date.getMonth() + 1,
9
+ 'D+': date.getDate(),
10
+ 'h+': date.getHours() % 12 === 0 ? 12 : date.getHours() % 12,
11
+ 'H+': date.getHours(),
12
+ 'm+': date.getMinutes(),
13
+ 's+': date.getSeconds(),
14
+ 'q+': Math.floor((date.getMonth() + 3) / 3),
15
+ 'S': date.getMilliseconds()
16
+ }
17
+ var week = {
18
+ '0': '\u65e5',
19
+ '1': '\u4e00',
20
+ '2': '\u4e8c',
21
+ '3': '\u4e09',
22
+ '4': '\u56db',
23
+ '5': '\u4e94',
24
+ '6': '\u516d'
25
+ }
26
+ if (/(Y+)/.test(fmt)) {
27
+ fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
28
+ }
29
+ if (/(E+)/.test(fmt)) {
30
+ fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? '\u661f\u671f' : '\u5468') : '') + week[date.getDay() + ''])
31
+ }
32
+ for (var k in o) {
33
+ if (new RegExp('(' + k + ')').test(fmt)) {
34
+ fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
35
+ }
36
+ }
37
+ return fmt
38
+ }
39
+
40
+ // 102000 -> 10万2千
41
+ export const numberSplit = val => {
42
+ if (!val) return val
43
+ let toNumberVal = Number(val)
44
+ if (isNaN(toNumberVal)) {
45
+ return val
46
+ }
47
+ let flag = ''
48
+ if (toNumberVal < 0) {
49
+ flag = '-'
50
+ toNumberVal = Math.abs(toNumberVal)
51
+ }
52
+ if (toNumberVal >= 10000) {
53
+ // 大于等于10000的数据要去掉小数位
54
+ const numStr = Math.floor(toNumberVal) + ''
55
+ const len = numStr.length
56
+ const numArr = []
57
+ // 每4位截取一次,截取小于10000部分的数据
58
+ let itemLast = Number(numStr.substring(len - 4, len))
59
+ // 只有个位数前面要加0 等于0则去掉,不加入数组拼接
60
+ if (itemLast < 10 && itemLast > 0) {
61
+ numArr.unshift('0' + itemLast)
62
+ } else if (itemLast >= 10) {
63
+ numArr.unshift(itemLast)
64
+ }
65
+ let itemCenter = 0
66
+ let itemFirst = 0
67
+ if (len <= 8) {
68
+ // 长度小于等于8, 没有亿位,这个时候万位可以从index = 0 开始截取
69
+ itemCenter = Number(numStr.substring(0, len - 4))
70
+ } else {
71
+ // 长度大于8才有亿, 万位不能再从index = 0开始截取
72
+ itemCenter = Number(numStr.substring(len - 8, len - 4))
73
+ itemFirst = Number(numStr.substring(0, len - 8))
74
+ }
75
+ // 万位和亿位如果大于0才加入数组拼接
76
+ if (itemCenter > 0) numArr.unshift(itemCenter + '万')
77
+ if (itemFirst > 0) numArr.unshift(itemFirst + '亿')
78
+ return flag + numArr.join('')
79
+ }
80
+ return flag + toNumberVal
81
+ }
82
+
83
+ export const numberSplitFloat = (val, decimal = 2) => {
84
+ // 防止空字符返回为0
85
+ if (val === '') return val
86
+ let toNumberVal = Number(val)
87
+ if (isNaN(toNumberVal)) {
88
+ return val
89
+ }
90
+ let flag = ''
91
+ if (toNumberVal < 0) {
92
+ flag = '-'
93
+ toNumberVal = Math.abs(toNumberVal)
94
+ }
95
+ const numStrArr = String(toNumberVal).split('.')
96
+ const numStr = numStrArr[0]
97
+ const _decimal = decimal !== undefined ? decimal : (numStrArr[1] && numStrArr[1].length) || ''
98
+ const decimalNum = numStrArr[1] && decimal >= 1 ? `.${numStrArr[1].substring(0, _decimal)}` : ''
99
+ if (toNumberVal >= 10000) {
100
+ const len = numStr.length
101
+ const numArr = []
102
+ // 每4位截取一次,截取小于10000部分的数据
103
+ let itemLast = Number(numStr.substring(len - 4, len))
104
+ // 只有个位数前面要加0 等于0则去掉,不加入数组拼接
105
+ if (itemLast < 10 && itemLast > 0) {
106
+ numArr.unshift('0' + itemLast)
107
+ } else if (itemLast >= 10) {
108
+ numArr.unshift(itemLast)
109
+ }
110
+ let itemCenter = 0
111
+ let itemFirst = 0
112
+ if (len <= 8) {
113
+ // 长度小于等于8, 没有亿位,这个时候万位可以从index = 0 开始截取
114
+ itemCenter = Number(numStr.substring(0, len - 4))
115
+ } else {
116
+ // 长度大于8才有亿, 万位不能再从index = 0开始截取
117
+ itemCenter = Number(numStr.substring(len - 8, len - 4))
118
+ itemFirst = Number(numStr.substring(0, len - 8))
119
+ }
120
+ // 万位和亿位如果大于0才加入数组拼接
121
+ if (itemCenter > 0) numArr.unshift(itemCenter + '万')
122
+ if (itemFirst > 0) numArr.unshift(itemFirst + '亿')
123
+ return flag + numArr.join('') + decimalNum
124
+ }
125
+ return flag + Math.floor(toNumberVal) + decimalNum
126
+ }
127
+
128
+ export function formatMoneySeparators(number, decimal = 2) {
129
+ if (number === '') return number
130
+ number = Number(number)
131
+ if (typeof number !== 'number') {
132
+ throw new Error('Input must be a number')
133
+ }
134
+ const parts = truncateDecimals(number, decimal).toString().split('.')
135
+ parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',')
136
+ return parts.join('.')
137
+ }
138
+
139
+ function hasDecimal(number) {
140
+ return Number.isFinite(number) && number % 1 !== 0
141
+ }
142
+
143
+ function truncateDecimals(number, decimal) {
144
+ if (!hasDecimal(number)) return number
145
+ const factor = Math.pow(10, decimal)
146
+ return Math.floor(number * factor) / factor
147
+ }
148
+
149
+
@@ -0,0 +1,18 @@
1
+ const Toast = window.vant && window.vant.Toast
2
+ /**
3
+ * 响应拦截-针对接口响应添加了灰度标识,判断路由meta标识是否需要弹窗提示接口正在灰度
4
+ */
5
+ export function handleResponseGrayTips (response) {
6
+ const data = typeof response.data === 'object' ? response.data : {}
7
+ const method = response.config.headers.method || response.config.url
8
+ if (data.code === 0) {
9
+ // 判断该接口是否存在灰度标识
10
+ if (response.headers['x-framework-isgray'] && response.headers['x-framework-isgray'] === '1') {
11
+ // 灰度标识接口且判断当前路由meta是否配置弹窗
12
+ if (window.isCheckApiGray) {
13
+ Toast(`${method}接口正在灰度`)
14
+ }
15
+ }
16
+ }
17
+ return response
18
+ }
@@ -0,0 +1,140 @@
1
+ import { getToken } from './token'
2
+ import { md5Http, random, getXWebTraceId, isKSClient, getKsEnvUrl } from './common'
3
+ import { handleResponseGrayTips } from './http-interceptors'
4
+ import adapter from './axios-adapter.js'
5
+ import bus from './bus'
6
+
7
+ const axios = window.axios
8
+ const Toast = window.vant && window.vant.Toast
9
+
10
+ let TIMEOUT = 20000
11
+
12
+ let getErrors = function () {
13
+ return {
14
+ 'Network Error': '网络错误,请检查网络',
15
+ [`timeout of ${TIMEOUT}ms exceeded`]: window.networkTimeoutMessage || '请求超时,服务器未响应',
16
+ 'Internal Server Error': '请求服务器错误',
17
+ 'Request failed with status code 502': '请求服务器错误',
18
+ api: '接口错误'
19
+ }
20
+ }
21
+
22
+ let baseUrl = '/router/rest'
23
+
24
+ const isKsClient = isKSClient()
25
+
26
+ // 判断请求是不是ajax 类型
27
+ const isKsHttpByAJAX = window.__KSUICONFIGHTTP === 'ajax'
28
+
29
+ // 在容器且为 ajax 请求时需要手动设置 baseUrl
30
+ if (isKsClient && isKsHttpByAJAX) {
31
+ baseUrl = getKsEnvUrl() + '/router/rest'
32
+ }
33
+
34
+ let options = {
35
+ baseURL: baseUrl,
36
+ timeout: TIMEOUT,
37
+ headers: { 'format': 'JSON' }
38
+ }
39
+
40
+ if (!isKsHttpByAJAX) {
41
+ options = isKsClient ? { ...options, adapter } : options
42
+ } else {
43
+ // 走 ajax 请求需要关闭自定义上报 http 至 APM
44
+ window.__APMCUSTOMHTTP = true
45
+ }
46
+
47
+ const httpClient = axios.create(options)
48
+
49
+ httpClient.interceptors.request.use(config => {
50
+ // headers对象中设置_tips属性,合并到config中并从headers中删除
51
+ let $config = config.headers.$config
52
+ if ($config) {
53
+ config.$config = { ...$config }
54
+ delete config.headers.$config
55
+ }
56
+ bus.$emit('httpStart', config)
57
+ return config
58
+ })
59
+
60
+ httpClient.interceptors.response.use(handleResponseGrayTips)
61
+
62
+ httpClient.interceptors.response.use(res => {
63
+ bus.$emit('httpEnd', res)
64
+ if (String(res.data.code) === '0') {
65
+ return res.data.data
66
+ }
67
+ // options参数中有_tips属性不提示错误
68
+ if (res.config.$config === undefined || res.config.$config._tips === undefined) {
69
+ Toast(res.data.msg)
70
+ }
71
+ return Promise.reject(res)
72
+ }, error => {
73
+ const msg = error.message || error.msg
74
+ const config = error._config || {}
75
+ if (msg && (config.$config === undefined || config.$config._tips === undefined)) {
76
+ const ERRORS = getErrors()
77
+ error.message = ERRORS[msg] || msg || ERRORS.api
78
+ Toast(error.message)
79
+ }
80
+ return Promise.reject(error)
81
+ })
82
+
83
+
84
+
85
+ /**
86
+ *
87
+ * @param {string} method 开放平台的apiCode
88
+ * @param {number | string} appkey 开放平台的appkey
89
+ * @param {object} data
90
+ * @param {object} options 其他配置
91
+ */
92
+ const http = async (method, appkey, data, options) => {
93
+
94
+ if (options && options.timeout) {
95
+ TIMEOUT = options.timeout
96
+ }
97
+
98
+ let token = getToken()
99
+ let menu = window.ksui.menu || { id: '156439900739872047', title: '股票' }
100
+
101
+ // 先从window上获取user,没有再调sdk获取
102
+ let user = window.ksui && window.ksui.user
103
+ if (!(user && user.id)) {
104
+ user = { id: '' }
105
+ }
106
+
107
+ let now = Date.now()
108
+ let headers = {
109
+ method,
110
+ appkey,
111
+ token,
112
+ timestamp: now,
113
+ sign: md5Http(token, now, data),
114
+ 'X-menu-id': menu.id,
115
+ webTraceId: `${user.id}-${now}-${random(4)}-${menu.id || 'xxxx'}`,
116
+ 'x-webtrace-id': getXWebTraceId(user.id, menu.id, now)
117
+ }
118
+ if (options && options.headers) {
119
+ headers = { ...headers, ...options.headers }
120
+ }
121
+ let config = {
122
+ url: `?${method}`,
123
+ method: 'POST',
124
+ data,
125
+ ...options,
126
+ headers,
127
+ }
128
+ return httpClient(config)
129
+ }
130
+
131
+ // 换token
132
+ const token = (data) => {
133
+ let headers = {
134
+ method: 'cas.oauth.ticketValidate',
135
+ appkey: 10184
136
+ }
137
+ return httpClient({ method: 'POST', data, headers })
138
+ }
139
+
140
+ export { http, token }
@@ -0,0 +1,5 @@
1
+ import { decryptApi } from './decrypt'
2
+
3
+ export const $utils = {
4
+ decryptApi,
5
+ }