sh-view 1.5.2

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 (209) hide show
  1. package/.eslintrc.js +21 -0
  2. package/README.en.md +36 -0
  3. package/README.md +39 -0
  4. package/package.json +64 -0
  5. package/packages/assets/css/animated.scss +33 -0
  6. package/packages/assets/css/loader.scss +193 -0
  7. package/packages/assets/css/main.scss +235 -0
  8. package/packages/assets/css/theme.scss +52 -0
  9. package/packages/assets/icons/demo.css +539 -0
  10. package/packages/assets/icons/iconfont.css +415 -0
  11. package/packages/assets/icons/iconfont.js +1 -0
  12. package/packages/assets/icons/iconfont.json +709 -0
  13. package/packages/assets/icons/iconfont.ttf +0 -0
  14. package/packages/assets/icons/iconfont.woff +0 -0
  15. package/packages/assets/icons/iconfont.woff2 +0 -0
  16. package/packages/assets/img/image-error.png +0 -0
  17. package/packages/assets/img/square-image.png +0 -0
  18. package/packages/components/global-components/sh-card/index.vue +122 -0
  19. package/packages/components/global-components/sh-code-editor/index.vue +237 -0
  20. package/packages/components/global-components/sh-corner/index.vue +236 -0
  21. package/packages/components/global-components/sh-count-to/index.vue +46 -0
  22. package/packages/components/global-components/sh-empty/index.vue +43 -0
  23. package/packages/components/global-components/sh-header/index.vue +269 -0
  24. package/packages/components/global-components/sh-icon/icons.vue +32 -0
  25. package/packages/components/global-components/sh-icon/index.vue +27 -0
  26. package/packages/components/global-components/sh-iv-form/components/iv-group-item.vue +57 -0
  27. package/packages/components/global-components/sh-iv-form/components/iv-single-item.vue +76 -0
  28. package/packages/components/global-components/sh-iv-form/index.vue +255 -0
  29. package/packages/components/global-components/sh-layout/index.vue +142 -0
  30. package/packages/components/global-components/sh-loading/index.vue +42 -0
  31. package/packages/components/global-components/sh-noticebar/index.vue +201 -0
  32. package/packages/components/global-components/sh-preview/index.vue +62 -0
  33. package/packages/components/global-components/sh-pull-refresh/index.vue +290 -0
  34. package/packages/components/global-components/sh-result/index.vue +88 -0
  35. package/packages/components/global-components/sh-sheet/index.vue +173 -0
  36. package/packages/components/global-components/sh-upload/components/u-img.vue +63 -0
  37. package/packages/components/global-components/sh-upload/components/u-list.vue +100 -0
  38. package/packages/components/global-components/sh-upload/index.vue +418 -0
  39. package/packages/components/global-components/sh-vxe-form/components/form-item.vue +25 -0
  40. package/packages/components/global-components/sh-vxe-form/css/index.scss +55 -0
  41. package/packages/components/global-components/sh-vxe-form/index.vue +115 -0
  42. package/packages/components/global-components/sh-vxe-form/js/methods.js +170 -0
  43. package/packages/components/global-components/sh-vxe-form/js/props.js +63 -0
  44. package/packages/components/global-components/sh-vxe-form/mixin/defaultData.js +33 -0
  45. package/packages/components/global-components/sh-vxe-list/index.vue +129 -0
  46. package/packages/components/global-components/sh-vxe-modal/index.vue +209 -0
  47. package/packages/components/global-components/sh-vxe-query/index.vue +286 -0
  48. package/packages/components/global-components/sh-vxe-table/components/importModal.vue +377 -0
  49. package/packages/components/global-components/sh-vxe-table/css/index.scss +94 -0
  50. package/packages/components/global-components/sh-vxe-table/index.vue +350 -0
  51. package/packages/components/global-components/sh-vxe-table/js/excel_to_json.js +313 -0
  52. package/packages/components/global-components/sh-vxe-table/js/methods.js +614 -0
  53. package/packages/components/global-components/sh-vxe-table/js/props.js +311 -0
  54. package/packages/components/global-components/sh-vxe-table/mixin/defaultData.js +116 -0
  55. package/packages/components/global-components/sh-vxe-toolbar/index.vue +172 -0
  56. package/packages/components/global-components/sh-vxe-tree/components/table-tree.vue +251 -0
  57. package/packages/components/global-components/sh-vxe-tree/css/index.scss +20 -0
  58. package/packages/components/global-components/sh-vxe-tree/index.vue +85 -0
  59. package/packages/components/global-components/sh-vxe-tree/js/props.js +120 -0
  60. package/packages/components/global-components/sh-vxe-tree/js/treeMethods.js +171 -0
  61. package/packages/components/global-components/sh-vxe-tree/mixin/defaultData.js +48 -0
  62. package/packages/components/global-components/sh-vxe-tree/vxe-direct-tree.vue +202 -0
  63. package/packages/components/global-components/sh-vxe-tree/vxe-select-tree.vue +291 -0
  64. package/packages/components/global-components/sh-water-fall/index.vue +87 -0
  65. package/packages/components/global-components/sh-word/index.vue +110 -0
  66. package/packages/components/index.js +64 -0
  67. package/packages/components/other-components/sh-cron-modal/components/cron-content.vue +287 -0
  68. package/packages/components/other-components/sh-cron-modal/css/index.scss +45 -0
  69. package/packages/components/other-components/sh-cron-modal/index.vue +67 -0
  70. package/packages/components/other-components/sh-cron-modal/mixin/cron-box.js +169 -0
  71. package/packages/components/other-components/sh-cron-modal/tabs/cron-day-box.vue +92 -0
  72. package/packages/components/other-components/sh-cron-modal/tabs/cron-hour-box.vue +56 -0
  73. package/packages/components/other-components/sh-cron-modal/tabs/cron-minute-box.vue +56 -0
  74. package/packages/components/other-components/sh-cron-modal/tabs/cron-month-box.vue +56 -0
  75. package/packages/components/other-components/sh-cron-modal/tabs/cron-second-box.vue +56 -0
  76. package/packages/components/other-components/sh-cron-modal/tabs/cron-week-box.vue +115 -0
  77. package/packages/components/other-components/sh-cron-modal/tabs/cron-year-box.vue +46 -0
  78. package/packages/components/other-components/sh-cron-modal/utils/index.js +52 -0
  79. package/packages/components/other-components/sh-markdown/index.vue +170 -0
  80. package/packages/components/other-components/sh-markdown/tinymce/langs/ar.js +7 -0
  81. package/packages/components/other-components/sh-markdown/tinymce/langs/az.js +7 -0
  82. package/packages/components/other-components/sh-markdown/tinymce/langs/bg_BG.js +7 -0
  83. package/packages/components/other-components/sh-markdown/tinymce/langs/bn_BD.js +7 -0
  84. package/packages/components/other-components/sh-markdown/tinymce/langs/ca.js +7 -0
  85. package/packages/components/other-components/sh-markdown/tinymce/langs/cs.js +7 -0
  86. package/packages/components/other-components/sh-markdown/tinymce/langs/cy.js +7 -0
  87. package/packages/components/other-components/sh-markdown/tinymce/langs/da.js +7 -0
  88. package/packages/components/other-components/sh-markdown/tinymce/langs/de.js +7 -0
  89. package/packages/components/other-components/sh-markdown/tinymce/langs/dv.js +7 -0
  90. package/packages/components/other-components/sh-markdown/tinymce/langs/el.js +7 -0
  91. package/packages/components/other-components/sh-markdown/tinymce/langs/eo.js +7 -0
  92. package/packages/components/other-components/sh-markdown/tinymce/langs/es.js +7 -0
  93. package/packages/components/other-components/sh-markdown/tinymce/langs/es_MX.js +7 -0
  94. package/packages/components/other-components/sh-markdown/tinymce/langs/et.js +7 -0
  95. package/packages/components/other-components/sh-markdown/tinymce/langs/eu.js +7 -0
  96. package/packages/components/other-components/sh-markdown/tinymce/langs/fa.js +7 -0
  97. package/packages/components/other-components/sh-markdown/tinymce/langs/fi.js +7 -0
  98. package/packages/components/other-components/sh-markdown/tinymce/langs/fr_FR.js +7 -0
  99. package/packages/components/other-components/sh-markdown/tinymce/langs/ga.js +7 -0
  100. package/packages/components/other-components/sh-markdown/tinymce/langs/gl.js +7 -0
  101. package/packages/components/other-components/sh-markdown/tinymce/langs/he_IL.js +7 -0
  102. package/packages/components/other-components/sh-markdown/tinymce/langs/hi.js +7 -0
  103. package/packages/components/other-components/sh-markdown/tinymce/langs/hr.js +7 -0
  104. package/packages/components/other-components/sh-markdown/tinymce/langs/hu_HU.js +7 -0
  105. package/packages/components/other-components/sh-markdown/tinymce/langs/hy.js +7 -0
  106. package/packages/components/other-components/sh-markdown/tinymce/langs/id.js +7 -0
  107. package/packages/components/other-components/sh-markdown/tinymce/langs/is_IS.js +7 -0
  108. package/packages/components/other-components/sh-markdown/tinymce/langs/it.js +7 -0
  109. package/packages/components/other-components/sh-markdown/tinymce/langs/ja.js +7 -0
  110. package/packages/components/other-components/sh-markdown/tinymce/langs/kab.js +7 -0
  111. package/packages/components/other-components/sh-markdown/tinymce/langs/kk.js +7 -0
  112. package/packages/components/other-components/sh-markdown/tinymce/langs/ko_KR.js +7 -0
  113. package/packages/components/other-components/sh-markdown/tinymce/langs/ku.js +7 -0
  114. package/packages/components/other-components/sh-markdown/tinymce/langs/lt.js +7 -0
  115. package/packages/components/other-components/sh-markdown/tinymce/langs/lv.js +7 -0
  116. package/packages/components/other-components/sh-markdown/tinymce/langs/nb_NO.js +7 -0
  117. package/packages/components/other-components/sh-markdown/tinymce/langs/ne.js +7 -0
  118. package/packages/components/other-components/sh-markdown/tinymce/langs/nl.js +7 -0
  119. package/packages/components/other-components/sh-markdown/tinymce/langs/nl_BE.js +7 -0
  120. package/packages/components/other-components/sh-markdown/tinymce/langs/oc.js +7 -0
  121. package/packages/components/other-components/sh-markdown/tinymce/langs/pl.js +7 -0
  122. package/packages/components/other-components/sh-markdown/tinymce/langs/pt_BR.js +7 -0
  123. package/packages/components/other-components/sh-markdown/tinymce/langs/ro.js +7 -0
  124. package/packages/components/other-components/sh-markdown/tinymce/langs/ru.js +7 -0
  125. package/packages/components/other-components/sh-markdown/tinymce/langs/sk.js +7 -0
  126. package/packages/components/other-components/sh-markdown/tinymce/langs/sl_SI.js +7 -0
  127. package/packages/components/other-components/sh-markdown/tinymce/langs/sq.js +7 -0
  128. package/packages/components/other-components/sh-markdown/tinymce/langs/sr.js +7 -0
  129. package/packages/components/other-components/sh-markdown/tinymce/langs/sv_SE.js +7 -0
  130. package/packages/components/other-components/sh-markdown/tinymce/langs/ta.js +7 -0
  131. package/packages/components/other-components/sh-markdown/tinymce/langs/tg.js +7 -0
  132. package/packages/components/other-components/sh-markdown/tinymce/langs/th_TH.js +7 -0
  133. package/packages/components/other-components/sh-markdown/tinymce/langs/tr.js +7 -0
  134. package/packages/components/other-components/sh-markdown/tinymce/langs/ug.js +7 -0
  135. package/packages/components/other-components/sh-markdown/tinymce/langs/uk.js +7 -0
  136. package/packages/components/other-components/sh-markdown/tinymce/langs/vi.js +7 -0
  137. package/packages/components/other-components/sh-markdown/tinymce/langs/zh-Hans.js +7 -0
  138. package/packages/components/other-components/sh-markdown/tinymce/skins/content/dark/content.css +72 -0
  139. package/packages/components/other-components/sh-markdown/tinymce/skins/content/dark/content.min.css +7 -0
  140. package/packages/components/other-components/sh-markdown/tinymce/skins/content/default/content.css +67 -0
  141. package/packages/components/other-components/sh-markdown/tinymce/skins/content/default/content.min.css +7 -0
  142. package/packages/components/other-components/sh-markdown/tinymce/skins/content/document/content.css +72 -0
  143. package/packages/components/other-components/sh-markdown/tinymce/skins/content/document/content.min.css +7 -0
  144. package/packages/components/other-components/sh-markdown/tinymce/skins/content/writer/content.css +68 -0
  145. package/packages/components/other-components/sh-markdown/tinymce/skins/content/writer/content.min.css +7 -0
  146. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide/content.css +732 -0
  147. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide/content.inline.css +726 -0
  148. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide/content.inline.min.css +7 -0
  149. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide/content.min.css +7 -0
  150. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide/content.mobile.css +29 -0
  151. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide/content.mobile.min.css +7 -0
  152. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide/fonts/tinymce-mobile.woff +0 -0
  153. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide/skin.css +3047 -0
  154. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide/skin.min.css +7 -0
  155. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide/skin.mobile.css +673 -0
  156. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide/skin.mobile.min.css +7 -0
  157. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide/skin.shadowdom.css +37 -0
  158. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide/skin.shadowdom.min.css +7 -0
  159. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/content.css +714 -0
  160. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/content.inline.css +726 -0
  161. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/content.inline.min.css +7 -0
  162. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/content.min.css +7 -0
  163. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/content.mobile.css +29 -0
  164. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/content.mobile.min.css +7 -0
  165. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/fonts/tinymce-mobile.woff +0 -0
  166. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/skin.css +3047 -0
  167. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/skin.min.css +7 -0
  168. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/skin.mobile.css +673 -0
  169. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/skin.mobile.min.css +7 -0
  170. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/skin.shadowdom.css +37 -0
  171. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/skin.shadowdom.min.css +7 -0
  172. package/packages/components/other-components/sh-menu-card/index.vue +224 -0
  173. package/packages/components/other-components/sh-menu-card/menu-box.vue +68 -0
  174. package/packages/components/other-components/sh-system-tip/index.vue +113 -0
  175. package/packages/css/index.js +6 -0
  176. package/packages/directive/directives.js +27 -0
  177. package/packages/directive/index.js +19 -0
  178. package/packages/directive/module/draggable.js +42 -0
  179. package/packages/index.js +40 -0
  180. package/packages/iview/css/index.scss +32 -0
  181. package/packages/iview/index.js +24 -0
  182. package/packages/mixin/index.js +87 -0
  183. package/packages/vxeTable/css/index.scss +454 -0
  184. package/packages/vxeTable/css/variable.scss +256 -0
  185. package/packages/vxeTable/index.js +178 -0
  186. package/packages/vxeTable/render/cell/vxe-render-checkbox.vue +19 -0
  187. package/packages/vxeTable/render/cell/vxe-render-checkgroup.vue +36 -0
  188. package/packages/vxeTable/render/cell/vxe-render-code.vue +19 -0
  189. package/packages/vxeTable/render/cell/vxe-render-goption.vue +93 -0
  190. package/packages/vxeTable/render/cell/vxe-render-href.vue +11 -0
  191. package/packages/vxeTable/render/cell/vxe-render-img.vue +28 -0
  192. package/packages/vxeTable/render/cell/vxe-render-input.vue +51 -0
  193. package/packages/vxeTable/render/cell/vxe-render-money.vue +25 -0
  194. package/packages/vxeTable/render/cell/vxe-render-progress.vue +19 -0
  195. package/packages/vxeTable/render/cell/vxe-render-radio.vue +19 -0
  196. package/packages/vxeTable/render/cell/vxe-render-radiogroup.vue +36 -0
  197. package/packages/vxeTable/render/cell/vxe-render-select.vue +36 -0
  198. package/packages/vxeTable/render/cell/vxe-render-switch.vue +19 -0
  199. package/packages/vxeTable/render/cell/vxe-render-table.vue +78 -0
  200. package/packages/vxeTable/render/cell/vxe-render-textarea.vue +19 -0
  201. package/packages/vxeTable/render/cell/vxe-render-time.vue +34 -0
  202. package/packages/vxeTable/render/cell/vxe-render-tree.vue +59 -0
  203. package/packages/vxeTable/render/cell/vxe-render-upload.vue +24 -0
  204. package/packages/vxeTable/render/filters/vxe-filter-input.vue +43 -0
  205. package/packages/vxeTable/render/footer/vxe-footer-input.vue +13 -0
  206. package/packages/vxeTable/render/footer/vxe-footer-money.vue +20 -0
  207. package/packages/vxeTable/render/globalRenders.js +491 -0
  208. package/packages/vxeTable/render/header/vxe-header-money.vue +21 -0
  209. package/packages/vxeTable/render/mixin/cell-mixin.js +195 -0
@@ -0,0 +1,614 @@
1
+ const vxeEvents = {
2
+ // -------- 表格
3
+ // 当前行变化
4
+ onCurrentChange(params) {
5
+ this.tableCurrentRowData = params
6
+ this.$emit('current-change', params)
7
+ },
8
+ // 单选框变化
9
+ onRadioChange(params) {
10
+ const that = this
11
+ var { row } = params
12
+ that.selectionRows = [row]
13
+ that.$emit('radio-change', that.selectionRows, params)
14
+ },
15
+ // 复选框变化
16
+ onSelectionChange(params) {
17
+ let { records } = params
18
+ this.isAllChecked = this.tableRef().isAllCheckboxChecked()
19
+ this.isIndeterminate = this.tableRef().isAllCheckboxIndeterminate()
20
+ if (this.tableTreeConfig && this.tableTreeConfig?.transform) {
21
+ let keyField = this.rowConfig.keyField || '_XID'
22
+ let childRowsKeys = []
23
+ this.$vUtils.eachTree(records, row => {
24
+ if (row._X_ROW_CHILD && row._X_ROW_CHILD.length > 0) {
25
+ row._X_ROW_CHILD.forEach(child => {
26
+ childRowsKeys.push(child[keyField])
27
+ })
28
+ }
29
+ })
30
+ records = records.filter(row => !childRowsKeys.includes(row[keyField]))
31
+ }
32
+ this.selectionRows = records
33
+ this.$emit('selection-change', this.selectionRows, params)
34
+ },
35
+ // 单元格点击事件
36
+ onCellClick(params) {
37
+ this.$emit('cell-click', params)
38
+ },
39
+ // 单元格双击事件
40
+ onCellDblClick(params) {
41
+ this.$emit('cell-dblclick', params)
42
+ },
43
+ // 单元格双击事件
44
+ onHeaderCellClick(params) {
45
+ this.$emit('header-cell-click', params)
46
+ },
47
+ // 排序变化事件
48
+ onSortChange(params) {
49
+ this.$emit('sort-change', params)
50
+ },
51
+ // 过滤变化事件
52
+ onFilterChange(params) {
53
+ this.$emit('filter-change', params)
54
+ },
55
+ // 当行展开或收起时会触发该事件
56
+ onToggleRowExpand(params) {
57
+ this.$emit('toggle-row-expand', params)
58
+ },
59
+ // 当树节点展开或收起时会触发该事件
60
+ onToggleTreeExpand(params) {
61
+ this.$emit('toggle-tree-expand', params)
62
+ },
63
+ // 只对 edit-config 配置时有效,单元格编辑状态下被关闭时会触发该事件
64
+ async onEditClosed(params) {
65
+ const that = this
66
+ let { row, column } = params
67
+ let { property, model, rname, rprops } = column
68
+ if ((model.update || model.change) && rname) {
69
+ let { rvalue, rtext } = that.$vUtils.formatRender(model.value, property, row, rname, rprops, that)
70
+ that.$vUtils.set(row, column.property, rvalue)
71
+ model.change = false
72
+ }
73
+ that.$emit('edit-closed', params)
74
+ },
75
+ // 只对 edit-config 配置时有效,单元格被激活编辑时会触发该事件
76
+ async onEditActived(params) {
77
+ this.$emit('edit-actived', params)
78
+ },
79
+ // 滚动事件
80
+ onScroll(params) {
81
+ this.$emit('scroll', params)
82
+ },
83
+ // 如果与工具栏关联,在自定义列按钮被手动点击后会触发该事件
84
+ onCustom(params) {
85
+ this.$emit('custom', params)
86
+ },
87
+ // 分页变化触发
88
+ onPageChange(params) {
89
+ let { currentPage, pageSize } = params
90
+ this.selectionRows = []
91
+ this.tablePagerConfig.currentPage = currentPage
92
+ this.tablePagerConfig.pageSize = pageSize
93
+ this.$emit('page-change', params)
94
+ },
95
+
96
+ // -------- 工具栏
97
+ // 只对 toolbar.buttons 配置时有效,当左侧按钮被点击时会后触发该事件
98
+ onToolbarButtonClick(params) {
99
+ this.$emit('toolbar-button-click', params)
100
+ },
101
+ // 只对 toolbar.tools 配置时有效,当右侧工具被点击时会后触发该事件
102
+ onToolbarToolClick(params) {
103
+ this.$emit('toolbar-tool-click', params)
104
+ }
105
+ }
106
+
107
+ const vxeFormEvents = {
108
+ // 表单展开全部/收起切换事件
109
+ onFormCollapsed(value) {
110
+ const that = this
111
+ if (that.tableVitualScroll) {
112
+ setTimeout(() => {
113
+ that.tableRef().recalculate(true)
114
+ }, 200)
115
+ }
116
+ },
117
+ // -------- 搜索
118
+ onFormSubmit() {
119
+ this.$emit('form-submit', this.queryData)
120
+ },
121
+ // 表单重置
122
+ onFormReset(params) {
123
+ this.$emit('form-reset', params)
124
+ },
125
+ // 表单项编辑回调
126
+ onFormEditClosed(obj, renderbox, $form) {
127
+ this.$emit('form-edit-closed', obj, renderbox, $form)
128
+ },
129
+ // 表单校验不通过
130
+ onFormSubmitInvalid(obj) {
131
+ this.$emit('form-submit-invalid', obj)
132
+ }
133
+ }
134
+
135
+ const vxeMethods = {
136
+ // // vxe组件方法可通过 this.tableRef() 调用
137
+ // 表格全选
138
+ setSelectionAll() {
139
+ const that = this
140
+ that.isAllChecked = !that.isAllChecked
141
+ that.tableRef().setAllCheckboxRow(that.isAllChecked)
142
+ that.selectionRows = that.tableRef().getCheckboxRecords()
143
+ },
144
+ // 表格打印、导出统一过滤列
145
+ columnDefaultFilterMethod({ column, $columnIndex }) {
146
+ let field = column.field
147
+ let renderObj = column.cellRender || column.editRender
148
+ let renderName = renderObj && renderObj.name
149
+ let returnValue = true
150
+ if (!field || ['seq', 'checkbox', 'radio'].includes(column.type)) {
151
+ returnValue = false
152
+ } else if (renderName === '$vGlobalOption') {
153
+ returnValue = false
154
+ }
155
+ return returnValue
156
+ },
157
+ // 表格打印、导出统一导出前渲染数据
158
+ getExportPrintDataByOption(obj = {}, type) {
159
+ let { options, content } = obj
160
+ let { data, columns, mode } = options
161
+ if (!data) {
162
+ if (mode === 'selected') {
163
+ data = this.getSelectionData()
164
+ } else {
165
+ data = this.$vUtils.clone(this.tableRef().getTableData().fullData, true)
166
+ columns.forEach(col => {
167
+ let { property, rname, rprops } = col
168
+ if (rname) {
169
+ data.forEach(row => {
170
+ if (!this.$vUtils.isNone(row[property])) {
171
+ row[property] = this.$vUtils.formatRender(row[property], property, row, rname, rprops, this)
172
+ }
173
+ })
174
+ }
175
+ })
176
+ }
177
+ options.data = data
178
+ }
179
+ if (type === 'print') {
180
+ return content
181
+ }
182
+ return obj
183
+ },
184
+ // 表格导出-自定义工作簿
185
+ exportSheetMethod({ options, workbook, worksheet }) {},
186
+ // 表格导入方法
187
+ setImportData(params) {
188
+ this.$emit('import-confirm', params)
189
+ },
190
+ // 默认求底部绑定方法vxe
191
+ tableFooterMethod({ columns, data }) {
192
+ let that = this
193
+ let footerData = []
194
+ let footerCalculateList = that.footerCalculate.calculate || []
195
+ footerCalculateList.forEach(key => {
196
+ footerData.push(that.tableFooterCompute(columns, data, key, that.footerCalculate[key]))
197
+ })
198
+ return footerData
199
+ },
200
+ // 默认求底部计算方法(已改用footer渲染器,其他需要自行计算)
201
+ tableFooterCompute(columns, data, computeType, typeObj = {}) {
202
+ let emptyString = ''
203
+ let computeName = typeObj.name || ''
204
+ let computeData = typeObj.data || {}
205
+ let textIndex = 0
206
+ if (!computeName) {
207
+ switch (computeType) {
208
+ case 'subTotal':
209
+ computeName = '合计'
210
+ break
211
+ case 'allTotal':
212
+ computeName = '总计'
213
+ break
214
+ case 'mean':
215
+ computeName = '平均'
216
+ break
217
+ default:
218
+ }
219
+ }
220
+ return columns.map((column, columnIndex) => {
221
+ let result = null
222
+ if (column.type === 'seq' || column.type === 'total') {
223
+ result = computeName
224
+ textIndex = columnIndex
225
+ } else {
226
+ result = computeData[column.property] || emptyString
227
+ this.$vUtils.set(column, `rfooter.index`, textIndex)
228
+ this.$vUtils.set(column, `rfooter.${computeName}`, { computeType, result, typeObj })
229
+ }
230
+ return result
231
+ })
232
+ },
233
+ tableFooterSpanMethod({ $rowIndex, column, $columnIndex, data }) {
234
+ let that = this
235
+ let defaultColumns = that.columnsConfigDefault.filter(item => that.tableGlobalConfig[item.type])
236
+ let colspan = defaultColumns.length || 1
237
+ if (column.type === 'seq') {
238
+ return { rowspan: 1, colspan: colspan }
239
+ } else if (column.type === 'checkbox' || column.type === 'radio') {
240
+ return { rowspan: 1, colspan: 0 }
241
+ } else {
242
+ return { rowspan: 1, colspan: 1 }
243
+ }
244
+ }
245
+ }
246
+
247
+ const shMethods = {
248
+ // 初始化
249
+ initCreated() {},
250
+ // 初始化分页配置
251
+ initPagerConfig() {
252
+ if (this.pagerConfig === false || this.reverse) {
253
+ this.tablePagerConfig = { enabled: false }
254
+ } else {
255
+ this.tablePagerConfig = Object.assign({}, this.pagerConfigDefault, this.pagerConfig)
256
+ }
257
+ },
258
+ // 初始化生成新表头数据
259
+ initTableColumns(columns = []) {
260
+ let that = this
261
+ let { columnsArr, columnsFlatArr, formItemsArr, rules } = that.getTransfarColumn(columns)
262
+ that.tableColumnsFlat = columnsFlatArr
263
+ that.tableFormItems = formItemsArr
264
+ that.initEditRules(rules)
265
+ if (!that.tableReverse) {
266
+ that.tableColumnsFixed = that.$vUtils.clone(columnsArr, true)
267
+ } else {
268
+ that.tableColumnsFixed = that.getReverseColumn(that.columns)
269
+ }
270
+ },
271
+ // 初始化验证规则
272
+ initEditRules(rules) {
273
+ const that = this
274
+ if (rules && that.$vUtils.isPlainObject(rules)) {
275
+ Object.keys(rules).forEach(key => {
276
+ if (that.tableEditRules[key]) {
277
+ that.tableEditRules[key] = Array.from(new Set(that.tableEditRules[key].concat(rules[key])))
278
+ } else {
279
+ that.tableEditRules[key] = rules[key]
280
+ }
281
+ })
282
+ }
283
+ },
284
+ // 初始化表头配置默认值
285
+ initColsDefaultValue() {
286
+ const that = this
287
+ let colsDefaultValue = {}
288
+ that.$vUtils.eachTree(that.tableColumnsFlat, item => {
289
+ let renderObj = item.editRender || item.cellRender || {}
290
+ let noRenderArr = ['$vGlobalOption']
291
+ if (!noRenderArr.includes(renderObj.name) && !that.$vUtils.isNone(renderObj.props?.defaultValue)) {
292
+ that.$vUtils.set(colsDefaultValue, item.field, renderObj.props?.defaultValue)
293
+ }
294
+ })
295
+ that.tableRowDefaultData = colsDefaultValue
296
+ if (Array.isArray(that.dataSourse) && Object.keys(colsDefaultValue).length > 0) {
297
+ that.dataSourse.forEach(row => {
298
+ Object.keys(colsDefaultValue).forEach(field => {
299
+ if (that.$vUtils.isNone(that.$vUtils.get(row, field))) {
300
+ that.$vUtils.set(row, field, that.$vUtils.get(colsDefaultValue, field))
301
+ }
302
+ })
303
+ })
304
+ }
305
+ },
306
+ // 反转表格-反转表头及数据
307
+ getReverseColumn(oriColumns) {
308
+ const that = this
309
+ let columns = []
310
+ let columnsNum = that.reverseConfig.num
311
+ let keyPrefix = that.reverseConfig.keyPrefix || 'reversePre'
312
+ let titPrefix = that.reverseConfig.titPrefix || ''
313
+ let valueRenderObj = that.disabled ? { cellRender: { name: '$vRowCell' } } : { editRender: { name: '$vRowCell' } }
314
+ if (columnsNum) {
315
+ for (let i = 1; i <= columnsNum; i++) {
316
+ columns.push(
317
+ Object.assign({ field: `${keyPrefix}title${i}`, title: `名称${i}` }, that.columnObjDefault),
318
+ Object.assign({ field: `${keyPrefix}value${i}`, title: `数值${i}` }, that.columnObjDefault, valueRenderObj)
319
+ )
320
+ }
321
+ } else {
322
+ columns.push(Object.assign({ field: `${keyPrefix}title`, title: '名称', fixed: 'left' }, that.columnObjDefault))
323
+ that.dataSourse.forEach((item, index) => {
324
+ columns.push(Object.assign({ field: `${keyPrefix}value${index + 1}`, title: `${titPrefix}${index + 1}` }, that.columnObjDefault, valueRenderObj))
325
+ })
326
+ }
327
+ return columns
328
+ },
329
+ // 反转表格-反转配置生成数据
330
+ getReverseData(oriData = []) {
331
+ const that = this
332
+ let data = []
333
+ let columnsNum = that.reverseConfig.num
334
+ let keyPrefix = that.reverseConfig.keyPrefix || 'reversePre'
335
+ if (columnsNum) {
336
+ // 将表头平均分组
337
+ let chunkColumns = that.$vUtils.chunk(that.columns, columnsNum)
338
+ chunkColumns.forEach((colGroup, colGroupIndex) => {
339
+ let item = {}
340
+ colGroup.forEach((column, columnIndex) => {
341
+ item[`${keyPrefix}title${columnIndex + 1}`] = column.title
342
+ item[`${keyPrefix}value${columnIndex + 1}`] = oriData[colGroupIndex][column.field] || ''
343
+ item[`${keyPrefix}value${columnIndex + 1}field`] = column.field || ''
344
+ column.field ? (item[`${column.field}RenderName`] = column.renderName || '') : ''
345
+ })
346
+ data.push(item)
347
+ })
348
+ } else {
349
+ data = that.columns.map(column => {
350
+ const item = { [`${keyPrefix}title`]: column.title }
351
+ oriData.forEach((row, index) => {
352
+ item[`${keyPrefix}value${index + 1}`] = row[column.field] || ''
353
+ item[`${keyPrefix}value${index + 1}field`] = column.field || ''
354
+ column.field ? (item[`${column.field}RenderName`] = column.renderName || '') : ''
355
+ })
356
+ return item
357
+ })
358
+ }
359
+ return data
360
+ },
361
+ // 转换生成新表头数据
362
+ getTransfarColumn(oriArr = []) {
363
+ let that = this
364
+ let columnsFlatArr = []
365
+ let formItemsArr = []
366
+ let rules = {}
367
+ let columnsArr = that.$vUtils.mapTree(oriArr, ori => {
368
+ let tar = Object.assign({}, that.columnObjDefault, that.columnObj, ori)
369
+ if (ori.children && ori.children.length > 0) {
370
+ tar.sortable = false
371
+ tar.filter = false
372
+ } else {
373
+ let renderConfig = {
374
+ name: ori.renderName || '$vInput',
375
+ props: Object.assign({}, ori.renderProps || {})
376
+ }
377
+ // 首先提取校验配置
378
+ if (that.isTrue(tar['renderRequire'])) {
379
+ // 若配置了校验参数则走校验参数,没配置则给默认校验条件
380
+ if (tar['requireProps'] && Array.isArray(tar['requireProps']) && tar['requireProps'].length > 0) {
381
+ rules[tar['field']] = tar['requireProps']
382
+ } else {
383
+ let dataType = 'string'
384
+ let arrayType = ['$vCheckgroup', '$vUpload', '$vTable']
385
+ if (arrayType.includes(ori['renderName']) || ((ori['renderName'] === '$vSelect' || ori['renderName'] === '$vTree') && that.isTrue(renderConfig.props.multiple))) {
386
+ dataType = 'array'
387
+ }
388
+ rules[tar['field']] = [{ required: true, message: that.getDefaultMessage(tar['renderName'], tar['title']), type: dataType }]
389
+ }
390
+ }
391
+ // 个性化设置
392
+ if (tar.renderName === '$vGlobalOption' || ['$vImg', '$vHref', '$vUpload'].includes(tar.renderName)) {
393
+ tar.filter = false
394
+ tar.sortable = false
395
+ }
396
+ if (tar.renderName === '$vGlobalOption') {
397
+ tar.resizable = false
398
+ }
399
+ if (tar.renderName === '$vMoney' || ['number', 'float', 'integer'].includes(renderConfig.props.type)) {
400
+ tar.cellType = 'number'
401
+ }
402
+ if (tar.renderName === '$vMoney' && renderConfig.props.bill) {
403
+ tar.filter = false
404
+ tar.headerClassName = tar.headerClassName ? `${tar.headerClassName} header-bill-cell` : 'header-bill-cell'
405
+ }
406
+ // 初始化排序条件
407
+ if (Number(tar.sortable) === 0 || tar.sortable === 'false') {
408
+ tar.sortable = false
409
+ }
410
+ // 判断单元格是否可编辑
411
+ if (ori.readonly || ori.slots?.default || (!ori.renderName && !(tar.editRender && tar.editRender.name))) {
412
+ tar.cellRender = Object.assign({}, renderConfig, tar.cellRender || {})
413
+ } else {
414
+ tar.editRender = Object.assign({}, renderConfig, tar.editRender || {})
415
+ }
416
+ // 初始化表单查询配置
417
+ if (that.tableGlobalConfig.search) {
418
+ let editFixedNames = ['$vImg', '$vHref', '$vUpload']
419
+ let formItem = Object.assign({}, tar)
420
+ formItem.itemRender = Object.assign({}, renderConfig, tar.editRender || {}, tar.itemRender || {})
421
+ delete formItem.cellRender
422
+ delete formItem.editRender
423
+ formItem.itemRender.name = formItem.itemRender.name || '$vInput'
424
+ // 此处修正, 对其不进行默认渲染
425
+ if (formItem.search && formItem.search !== '0' && !editFixedNames.includes(formItem.itemRender.name)) {
426
+ formItemsArr.push(formItem)
427
+ }
428
+ }
429
+ // 初始化过滤条件
430
+ if (tar.filter === true || Number(tar.filter) === 1) {
431
+ that.turnColumnItemFilters(tar, renderConfig.props)
432
+ }
433
+ }
434
+ columnsFlatArr.push(tar)
435
+ return tar
436
+ })
437
+ return { columnsArr, columnsFlatArr, formItemsArr, rules }
438
+ },
439
+ // 转化表头过滤配置
440
+ turnColumnItemFilters(column, props) {
441
+ let columnRender = column.cellRender || column.editRender || column.contentRender
442
+ let columnProps = Object.assign({}, props)
443
+ columnProps.colRenderName = columnRender.name
444
+ if (!column.filters) {
445
+ switch (columnRender.name) {
446
+ case '$select':
447
+ case '$vSelect':
448
+ case '$vCheckgroup':
449
+ case '$vRadiogroup':
450
+ case '$vSwitch':
451
+ column.filters = Array.isArray(columnRender.props && columnRender.props.options) ? columnRender.props.options : false
452
+ column.filterMultiple = true
453
+ break
454
+ case '$vInput':
455
+ column.filters = [{ value: '', data: '' }]
456
+ column.filterRender = { name: '$vFilterInput', props: columnProps }
457
+ break
458
+ default:
459
+ column.filters = [{ value: '', data: '' }]
460
+ column.filterRender = { name: '$vFilterInput', props: columnProps }
461
+ break
462
+ }
463
+ }
464
+ },
465
+ // 获取默认验证信息
466
+ getDefaultMessage(renderType, title) {
467
+ let message = ''
468
+ const selectRenders = ['$vSelect', '$vTree', '$vTime', '$vSwitch', '$vCheckbox', '$vCheckgroup', '$vRadio', '$vRadiogroup', '$vUpload']
469
+ if (selectRenders.includes(renderType)) {
470
+ message = '请选择' + title
471
+ } else {
472
+ message = '请输入' + title
473
+ }
474
+ return message
475
+ },
476
+ // 判断为true
477
+ isTrue(value) {
478
+ return String(value) === '1' || String(value).toLowerCase() === 'true'
479
+ },
480
+ // 全局搜索输入框事件
481
+ handleTableFilter(obj) {
482
+ const that = this
483
+ let filterText = that.tableFilterText
484
+ let filterData = null
485
+ if (filterText) {
486
+ let searchFields = []
487
+ let tableColumnsAll = that.tableRef().getColumns()
488
+ tableColumnsAll.forEach(col => {
489
+ let renderObj = col.cellRender || col.editRender || col.itemRender
490
+ let noSearchArr = ['$vGlobalOption', '$vImg', '$vCheckbox', '$vRadio', '$vUpload', '$vCode', 'seq', 'checkbox', 'radio']
491
+ if (col.property && renderObj && renderObj.name && !noSearchArr.includes(renderObj.name) && !noSearchArr.includes(col.type)) {
492
+ searchFields.push({ rkey: col.property, rname: renderObj.name, rprops: Object.assign({}, renderObj.props, col.rprops) })
493
+ }
494
+ })
495
+ filterData = that.$vUtils.searchTree(that.dataSourse, row => {
496
+ return searchFields.some(item => {
497
+ let cellValue = that.$vUtils.get(row, item.rkey)
498
+ if (that.$vxePluginNames.expendRenders && that.$vxePluginNames.expendRenders.includes(item.rname)) {
499
+ let { rtext } = that.$vUtils.formatRender(cellValue, item.rkey, row, item.rname, item.rprops, that)
500
+ return String(rtext).toLowerCase().indexOf(filterText) > -1
501
+ }
502
+ return that.$vUtils.trim(cellValue).toLowerCase().indexOf(filterText) > -1
503
+ })
504
+ })
505
+ }
506
+ if (that.tableFilterData === null && !filterText) {
507
+ return
508
+ }
509
+ that.tableFilterData = filterData
510
+ },
511
+ // 获取选中数据
512
+ getSelectionData() {
513
+ return this.selectionRows || []
514
+ },
515
+ // 表格验证方法
516
+ validate(rows = true) {
517
+ return this.tableRef().validate(rows)
518
+ },
519
+ // 刷新表格视图
520
+ refreshRender() {
521
+ this.renderKey++
522
+ },
523
+ // 表格导出按钮
524
+ handleTableExportBtn(options) {
525
+ if (typeof this.onExportMethod === 'function') {
526
+ return this.onExportMethod(options, this)
527
+ }
528
+ return this.tableRef().openExport(options)
529
+ },
530
+ // 表格导入按钮
531
+ handleTableImportBtn() {
532
+ this.importModal = true
533
+ },
534
+ // 表格打印按鈕
535
+ handleTablePrintBtn(options) {
536
+ if (typeof this.onPrintMethod === 'function') {
537
+ return this.onPrintMethod(options, this)
538
+ }
539
+ return this.tableRef().openPrint(options)
540
+ },
541
+ // 表格切换全屏缩放按钮
542
+ handleTableZoomBtn(val) {
543
+ this.tableIsFullscreen = val
544
+ if (val) {
545
+ this.tableRef().zoom()
546
+ } else {
547
+ this.tableRef().revert()
548
+ }
549
+ },
550
+ // 自定义操作列点击事件
551
+ handleGoptionClick(btnObj, dataObj) {
552
+ const that = this
553
+ if (btnObj.code === 'delete' || btnObj.idConfirm) {
554
+ that.msgconfirm({
555
+ content: btnObj.ConfirmContent || `确定${btnObj.content}吗?`
556
+ }).then(() => {
557
+ that.$emit('globaloption', btnObj, dataObj)
558
+ })
559
+ } else {
560
+ that.$emit('globaloption', btnObj, dataObj)
561
+ }
562
+ },
563
+ // 新增行按钮
564
+ async handleTableAddRow(rows, index = -1, isTool = false) {
565
+ const that = this
566
+ let tableRowDefaultData = Object.assign({}, that.tableRowDefaultData)
567
+ let addRows = rows ? that.$vUtils.clone(rows, true) : tableRowDefaultData
568
+ if (!isTool && typeof that.onToolbarBtnAddBefore === 'function') {
569
+ addRows = await that.onToolbarBtnAddBefore(addRows)
570
+ }
571
+ // 删除主键,以防排序冲突
572
+ let mainKeyField = that.rowConfig?.keyField || '_XID'
573
+ if (Array.isArray(addRows)) {
574
+ addRows.forEach(item => {
575
+ delete item[mainKeyField]
576
+ })
577
+ } else {
578
+ delete addRows[mainKeyField]
579
+ }
580
+ let { row: newRow } = await that.tableRef().insertAt(addRows, index)
581
+ await that.tableRef().setActiveRow(newRow)
582
+ if (!isTool) that.$emit('toolbaroption', 'add', newRow, that.tableRef())
583
+ },
584
+ // 删除行按钮
585
+ async handleTableDeleteRow(rows, isTool = false) {
586
+ const that = this
587
+ let deleteRows = rows
588
+ if (isTool) {
589
+ let selectedRows = that.getSelectionData()
590
+ if (selectedRows.length < 1) {
591
+ that.msgwarning('请选择要删除的行!')
592
+ return
593
+ }
594
+ deleteRows = selectedRows
595
+ await that.msgconfirm({ content: `确定删除吗?` })
596
+ } else if (typeof that.onToolbarBtnDeleteBefore === 'function') {
597
+ let result = await that.onToolbarBtnDeleteBefore(deleteRows)
598
+ if (!result) return
599
+ }
600
+ await that.tableRef().remove(deleteRows)
601
+ if (that.selectionRows && that.selectionRows.length > 0) {
602
+ let keyField = that.rowConfig.keyField || that.$vTableSetup.table.rowConfig.keyField
603
+ that.selectionRows = that.selectionRows.filter(sr => !deleteRows.find(dr => dr[keyField] === sr[keyField]))
604
+ }
605
+ if (!isTool) that.$emit('toolbaroption', 'delete', deleteRows, that.tableRef())
606
+ }
607
+ }
608
+
609
+ export default {
610
+ ...vxeEvents,
611
+ ...vxeFormEvents,
612
+ ...vxeMethods,
613
+ ...shMethods
614
+ }