bri-components 1.0.0

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 (215) hide show
  1. package/README.md +30 -0
  2. package/lib/.DS_Store +0 -0
  3. package/lib/0.bri-components.min.js +2 -0
  4. package/lib/0.bri-components.min.js.map +1 -0
  5. package/lib/1.bri-components.min.js +2 -0
  6. package/lib/1.bri-components.min.js.map +1 -0
  7. package/lib/2.bri-components.min.js +2 -0
  8. package/lib/2.bri-components.min.js.map +1 -0
  9. package/lib/3.bri-components.min.js +2 -0
  10. package/lib/3.bri-components.min.js.gz +0 -0
  11. package/lib/3.bri-components.min.js.map +1 -0
  12. package/lib/4.bri-components.min.js +2 -0
  13. package/lib/4.bri-components.min.js.gz +0 -0
  14. package/lib/4.bri-components.min.js.map +1 -0
  15. package/lib/5.bri-components.min.js +2 -0
  16. package/lib/5.bri-components.min.js.map +1 -0
  17. package/lib/6.bri-components.min.js +2 -0
  18. package/lib/6.bri-components.min.js.map +1 -0
  19. package/lib/bri-components.min.js +21 -0
  20. package/lib/bri-components.min.js.gz +0 -0
  21. package/lib/bri-components.min.js.map +1 -0
  22. package/lib/styles/bri-components.css +1 -0
  23. package/lib/styles/bundle.css +14 -0
  24. package/lib/styles/font/fontello.eot +0 -0
  25. package/lib/styles/font/fontello.svg +32 -0
  26. package/lib/styles/font/fontello.ttf +0 -0
  27. package/lib/styles/font/fontello.woff +0 -0
  28. package/lib/styles/font/fontello.woff2 +0 -0
  29. package/package.json +121 -0
  30. package/src/.DS_Store +0 -0
  31. package/src/components/controls/base/DshBack.vue +36 -0
  32. package/src/components/controls/base/DshCascader.vue +366 -0
  33. package/src/components/controls/base/DshCascaderMultiple.vue +158 -0
  34. package/src/components/controls/base/DshCheckbox.vue +199 -0
  35. package/src/components/controls/base/DshCoordinates.vue +497 -0
  36. package/src/components/controls/base/DshDate.vue +148 -0
  37. package/src/components/controls/base/DshDaterange.vue +335 -0
  38. package/src/components/controls/base/DshDivider.vue +59 -0
  39. package/src/components/controls/base/DshEditor.vue +166 -0
  40. package/src/components/controls/base/DshInput.vue +139 -0
  41. package/src/components/controls/base/DshLabels.vue +302 -0
  42. package/src/components/controls/base/DshNumber/BriInputNumber/BriInputNumber.vue +425 -0
  43. package/src/components/controls/base/DshNumber/BriInputNumber/mixins/emitter.js +34 -0
  44. package/src/components/controls/base/DshNumber/BriInputNumber/mixins/form.js +14 -0
  45. package/src/components/controls/base/DshNumber/BriInputNumber/utils/assist.js +322 -0
  46. package/src/components/controls/base/DshNumber/DshNumber.vue +148 -0
  47. package/src/components/controls/base/DshNumberange.vue +137 -0
  48. package/src/components/controls/base/DshPackage.vue +72 -0
  49. package/src/components/controls/base/DshSelect.vue +231 -0
  50. package/src/components/controls/base/DshSwitch.vue +112 -0
  51. package/src/components/controls/base/DshUndeveloped.vue +39 -0
  52. package/src/components/controls/base/YSerialNumber.vue +37 -0
  53. package/src/components/controls/base/ZUpload/YUploadImage.vue +228 -0
  54. package/src/components/controls/base/ZUpload/index.vue +356 -0
  55. package/src/components/controls/base/ZUpload/upload-list.vue +277 -0
  56. package/src/components/controls/base/ZUpload/upload-listItem.vue +0 -0
  57. package/src/components/controls/base/ZUpload/uploadMixin.js +397 -0
  58. package/src/components/controls/base/selectMixin.js +110 -0
  59. package/src/components/controls/base/textMultiple/DshTextMultiple.vue +94 -0
  60. package/src/components/controls/base/textMultiple/MultipleInput.vue +106 -0
  61. package/src/components/controls/controlMap.js +94 -0
  62. package/src/components/controls/controlMixin.js +84 -0
  63. package/src/components/form/DshAdvSearchForm.vue +341 -0
  64. package/src/components/form/DshDefaultSearch.vue +203 -0
  65. package/src/components/form/DshForm.vue +364 -0
  66. package/src/components/form/searchMixin.js +205 -0
  67. package/src/components/list/DshBox/DshBox.vue +168 -0
  68. package/src/components/list/DshBox/DshCard.vue +219 -0
  69. package/src/components/list/DshBox/DshCrossTable.vue +624 -0
  70. package/src/components/list/DshBox/DshList.vue +442 -0
  71. package/src/components/list/DshBox/DshPanel.vue +407 -0
  72. package/src/components/list/DshBox/DshSingleData.vue +82 -0
  73. package/src/components/list/DshBox/DshTable.vue +273 -0
  74. package/src/components/list/DshCascaderTable.vue +817 -0
  75. package/src/components/list/DshFlatTable.vue +622 -0
  76. package/src/components/list/ZTree.vue +527 -0
  77. package/src/components/list/easyTable/index.js +23 -0
  78. package/src/components/list/easyTable/src/directives/clickoutside.js +32 -0
  79. package/src/components/list/easyTable/src/mixins/layerAdjustment.js +62 -0
  80. package/src/components/list/easyTable/src/settings/settings.js +11 -0
  81. package/src/components/list/easyTable/src/utils/deepClone.js +256 -0
  82. package/src/components/list/easyTable/src/utils/dom.js +41 -0
  83. package/src/components/list/easyTable/src/utils/utils.js +190 -0
  84. package/src/components/list/easyTable/v-checkbox/index.js +7 -0
  85. package/src/components/list/easyTable/v-checkbox/src/checkbox.vue +127 -0
  86. package/src/components/list/easyTable/v-checkbox-group/index.js +7 -0
  87. package/src/components/list/easyTable/v-checkbox-group/src/checkbox-group.vue +68 -0
  88. package/src/components/list/easyTable/v-dropdown/index.js +7 -0
  89. package/src/components/list/easyTable/v-dropdown/src/dropdown.vue +337 -0
  90. package/src/components/list/easyTable/v-table/index.js +7 -0
  91. package/src/components/list/easyTable/v-table/src/body-cell-merge-mixin.js +141 -0
  92. package/src/components/list/easyTable/v-table/src/cell-edit-mixin.js +102 -0
  93. package/src/components/list/easyTable/v-table/src/checkbox-selection-mixin.js +189 -0
  94. package/src/components/list/easyTable/v-table/src/classes-mixin.js +56 -0
  95. package/src/components/list/easyTable/v-table/src/drag-width-mixin.js +202 -0
  96. package/src/components/list/easyTable/v-table/src/export-csv.js +74 -0
  97. package/src/components/list/easyTable/v-table/src/frozen-columns-mixin.js +134 -0
  98. package/src/components/list/easyTable/v-table/src/loading.vue +49 -0
  99. package/src/components/list/easyTable/v-table/src/scroll-bar-control-mixin.js +21 -0
  100. package/src/components/list/easyTable/v-table/src/scroll-control-mixin.js +92 -0
  101. package/src/components/list/easyTable/v-table/src/sort-control-mixin.js +108 -0
  102. package/src/components/list/easyTable/v-table/src/table-empty-mixin.js +73 -0
  103. package/src/components/list/easyTable/v-table/src/table-empty.vue +66 -0
  104. package/src/components/list/easyTable/v-table/src/table-filters-mixin.js +126 -0
  105. package/src/components/list/easyTable/v-table/src/table-footer-mixin.js +122 -0
  106. package/src/components/list/easyTable/v-table/src/table-resize-mixin.js +279 -0
  107. package/src/components/list/easyTable/v-table/src/table-row-mouse-events-mixin.js +123 -0
  108. package/src/components/list/easyTable/v-table/src/table.vue +1565 -0
  109. package/src/components/list/easyTable/v-table/src/title-cell-merge-mixin.js +115 -0
  110. package/src/components/list/evTable/EvTable.vue +323 -0
  111. package/src/components/list/evTable/EvTableMixin.js +26 -0
  112. package/src/components/other/DshAvatar.vue +149 -0
  113. package/src/components/other/DshBtnModal.vue +64 -0
  114. package/src/components/other/DshColorPanel.vue +128 -0
  115. package/src/components/other/DshEditPanel.vue +130 -0
  116. package/src/components/other/InfoCascader.vue +258 -0
  117. package/src/components/other/YNoPermission.vue +45 -0
  118. package/src/components/other/ZCode.vue +125 -0
  119. package/src/components/other/ZCollapseTree.vue +84 -0
  120. package/src/components/other/ZGantt.vue +669 -0
  121. package/src/components/other/ZIframe.vue +105 -0
  122. package/src/components/other/ZLoading.vue +59 -0
  123. package/src/components/other/menu/DshMenu.vue +133 -0
  124. package/src/components/other/menu/DshMenuNav.vue +104 -0
  125. package/src/components/pages/Error/Error403.vue +34 -0
  126. package/src/components/pages/Error/Error404.vue +34 -0
  127. package/src/components/pages/Error/Error500.vue +34 -0
  128. package/src/components/pages/Error/error.less +163 -0
  129. package/src/components/pages/Error/errorBack.vue +38 -0
  130. package/src/components/small/Ctooltip.vue +90 -0
  131. package/src/components/small/DshButtons.vue +195 -0
  132. package/src/components/small/DshControlDefine.vue +110 -0
  133. package/src/components/small/DshCrumbs.vue +61 -0
  134. package/src/components/small/DshCrumbsItem.vue +107 -0
  135. package/src/components/small/DshDropdown.vue +159 -0
  136. package/src/components/small/DshFileShow.vue +212 -0
  137. package/src/components/small/DshIcons.vue +63 -0
  138. package/src/components/small/DshModal.vue +255 -0
  139. package/src/components/small/DshPage.vue +98 -0
  140. package/src/components/small/DshSteps.vue +68 -0
  141. package/src/components/small/DshTabs.vue +227 -0
  142. package/src/components/small/DshTags.vue +58 -0
  143. package/src/components/small/DshTdRender.js +21 -0
  144. package/src/components/small/DshTitle.vue +36 -0
  145. package/src/components/small/render.js +20 -0
  146. package/src/components/unit/DshFormItem.vue +157 -0
  147. package/src/components/unit/DshUnit.vue +72 -0
  148. package/src/components/unit/unitMixin.js +43 -0
  149. package/src/datas/.DS_Store +0 -0
  150. package/src/datas/common/region.json +1 -0
  151. package/src/datas/common/resourceData.json +20 -0
  152. package/src/datas/index.js +11 -0
  153. package/src/index.js +243 -0
  154. package/src/styles/animate.less +16 -0
  155. package/src/styles/bundle.css +14 -0
  156. package/src/styles/common/box.less +157 -0
  157. package/src/styles/common/common.less +31 -0
  158. package/src/styles/common/flex.less +282 -0
  159. package/src/styles/common/index.less +4 -0
  160. package/src/styles/common/text.less +43 -0
  161. package/src/styles/components/controls/DshCascader.less +75 -0
  162. package/src/styles/components/controls/DshCheckbox.less +156 -0
  163. package/src/styles/components/controls/DshCoordinates.less +72 -0
  164. package/src/styles/components/controls/DshDaterange.less +49 -0
  165. package/src/styles/components/controls/DshDivider.less +115 -0
  166. package/src/styles/components/controls/DshEditor.less +52 -0
  167. package/src/styles/components/controls/DshInput.less +40 -0
  168. package/src/styles/components/controls/DshLabels.less +187 -0
  169. package/src/styles/components/controls/DshNumberange.less +24 -0
  170. package/src/styles/components/controls/DshPackage.less +25 -0
  171. package/src/styles/components/controls/DshSelect.less +172 -0
  172. package/src/styles/components/controls/MultipleInput.less +55 -0
  173. package/src/styles/components/controls/ZUpload.less +446 -0
  174. package/src/styles/components/form/DshAdvSearchForm.less +159 -0
  175. package/src/styles/components/form/DshDefaultSearch.less +71 -0
  176. package/src/styles/components/index.less +49 -0
  177. package/src/styles/components/list/DshCascaderTable.less +113 -0
  178. package/src/styles/components/list/DshCrossTable.less +175 -0
  179. package/src/styles/components/list/DshFlatTable.less +98 -0
  180. package/src/styles/components/list/DshSingleData.less +30 -0
  181. package/src/styles/components/list/evTable.less +79 -0
  182. package/src/styles/components/list/evtable/animation.less +141 -0
  183. package/src/styles/components/list/evtable/font/fontello.eot +0 -0
  184. package/src/styles/components/list/evtable/font/fontello.svg +32 -0
  185. package/src/styles/components/list/evtable/font/fontello.ttf +0 -0
  186. package/src/styles/components/list/evtable/font/fontello.woff +0 -0
  187. package/src/styles/components/list/evtable/font/fontello.woff2 +0 -0
  188. package/src/styles/components/list/evtable/fontello.less +68 -0
  189. package/src/styles/components/list/evtable/index.less +5 -0
  190. package/src/styles/components/list/evtable/v-checkbox.less +167 -0
  191. package/src/styles/components/list/evtable/v-dropdown.less +235 -0
  192. package/src/styles/components/list/evtable/v-table.less +334 -0
  193. package/src/styles/components/list/ivu_reset.less +49 -0
  194. package/src/styles/components/other/DshEditPanel.less +70 -0
  195. package/src/styles/components/other/DshMenu.less +37 -0
  196. package/src/styles/components/other/DshMenuNav.less +82 -0
  197. package/src/styles/components/other/InfoCascader.less +55 -0
  198. package/src/styles/components/other/ZCode.less +1 -0
  199. package/src/styles/components/other/ZCollapseTree.less +62 -0
  200. package/src/styles/components/other/ZGantt.less +278 -0
  201. package/src/styles/components/other/ZLoading.less +36 -0
  202. package/src/styles/components/small/Ctooltip.less +5 -0
  203. package/src/styles/components/small/DshButtons.less +40 -0
  204. package/src/styles/components/small/DshControlDefine.less +64 -0
  205. package/src/styles/components/small/DshDropdown.less +61 -0
  206. package/src/styles/components/small/DshPage.less +94 -0
  207. package/src/styles/components/small/DshSteps.less +58 -0
  208. package/src/styles/components/small/DshTabs.less +82 -0
  209. package/src/styles/components/small/DshTitle.less +18 -0
  210. package/src/styles/components/unit/DshFormItem.less +124 -0
  211. package/src/styles/define.less +374 -0
  212. package/src/styles/index.less +10 -0
  213. package/src/styles/reset.less +83 -0
  214. package/src/styles/variables.less +98 -0
  215. package/src/styles/view_reset.less +446 -0
@@ -0,0 +1,279 @@
1
+ /*
2
+ * 列自适应
3
+ * */
4
+ import utils from "../../src/utils/utils.js";
5
+
6
+ export default {
7
+
8
+ data () {
9
+ return {
10
+ resizeColumns: [], // 所有需要自适应的列集合
11
+ initTotalColumnsWidth: 0, // 所有列初始化时的总宽度
12
+ hasContainerWidth: false, // 容器是否有宽度(display:none 时没有)
13
+ containerWidthCheckTimer: null
14
+ };
15
+ },
16
+
17
+ methods: {
18
+ // 获取所有自适应列的集合
19
+ getResizeColumns () {
20
+
21
+ let result = [];
22
+
23
+ this.internalColumns.forEach(item => {
24
+
25
+ if (item.isResize) {
26
+ result.push({width: item.width, field: item.field});
27
+ }
28
+
29
+ });
30
+
31
+ this.resizeColumns = result;
32
+ },
33
+
34
+ // 初始化
35
+ initResizeColumns () {
36
+
37
+ this.initTotalColumnsWidth = this.totalColumnsWidth;
38
+ this.getResizeColumns();
39
+ },
40
+
41
+ // 如果初始化时document上包含滚动条,渲染完document滚动条消失会造成表格宽度计算有误的问题
42
+ containerWidthCheck () {
43
+
44
+ this.containerWidthCheckTimer = setTimeout(x => {
45
+
46
+ let tableContainerWidth = this.$el.clientWidth;
47
+
48
+ // 3为容错值
49
+ if (tableContainerWidth - this.internalWidth > 3) {
50
+
51
+ this.tableResize();
52
+ }
53
+ });
54
+ },
55
+
56
+ // 目前适用于有横向自适应功能的表格
57
+ adjustHeight (hasScrollBar) {
58
+
59
+ if (!this.$el || this.isVerticalResize) {
60
+ return false;
61
+ }
62
+
63
+ let totalColumnsHeight = this.getTotalColumnsHeight();
64
+ let scrollbarWidth = this.scrollbarWidth;
65
+
66
+ // 有footer 功能
67
+ if (this.hasTableFooter) {
68
+
69
+ if (hasScrollBar) {
70
+
71
+ if (this.footerTotalHeight === this.getFooterTotalRowHeight) {
72
+
73
+ this.footerTotalHeight += scrollbarWidth;
74
+
75
+ if (!(this.height && this.height > 0) || this.height > totalColumnsHeight) {
76
+ this.internalHeight += scrollbarWidth;
77
+ }
78
+ }
79
+ } else if (!hasScrollBar) {
80
+
81
+ if (this.footerTotalHeight > this.getFooterTotalRowHeight) {
82
+
83
+ this.footerTotalHeight -= scrollbarWidth;
84
+
85
+ if (!(this.height && this.height > 0) || this.height > totalColumnsHeight) {
86
+
87
+ this.internalHeight -= scrollbarWidth;
88
+ }
89
+ }
90
+ }
91
+ }
92
+ // 当没有设置高度时计算总高度 || 设置的高度大于所有列高度之和时
93
+ else if (!(this.height && this.height > 0) || this.height > totalColumnsHeight) {
94
+
95
+ if (hasScrollBar && this.internalHeight + 2 < totalColumnsHeight + scrollbarWidth) {
96
+
97
+ this.internalHeight += scrollbarWidth;
98
+
99
+ } else if (!hasScrollBar) {
100
+
101
+ this.internalHeight = this.getTotalColumnsHeight();
102
+ }
103
+ }
104
+ },
105
+
106
+ // 随着窗口改变表格自适应
107
+ tableResize () {
108
+ if (!this.isHorizontalResize && !this.isVerticalResize) {
109
+ return false;
110
+ }
111
+
112
+ let totalColumnsHeight = this.getTotalColumnsHeight();
113
+ let maxWidth = this.maxWidth;
114
+ let maxHeight = (this.height && this.height > 0) ? this.height : totalColumnsHeight;
115
+ let minWidth = this.minWidth;
116
+ let minHeight = this.minHeight > totalColumnsHeight ? totalColumnsHeight : this.minHeight;
117
+ let view = this.$el;
118
+ let viewOffset = utils.getViewportOffset(view);
119
+ let currentWidth = view.getBoundingClientRect !== "undefined" ? view.getBoundingClientRect().width : view.clientWidth;
120
+ let currentHeight = view.getBoundingClientRect !== "undefined" ? view.getBoundingClientRect().height : view.clientHeight;
121
+ // let right = window.document.documentElement.clientWidth - currentWidth - viewOffset.left;
122
+ let bottom = window.document.documentElement.clientHeight - currentHeight - viewOffset.top - 2;
123
+ let bottom2 = viewOffset.bottom2;
124
+ let scrollbarWidth = this.scrollbarWidth;
125
+
126
+ if (this.isHorizontalResize && this.internalWidth && this.internalWidth > 0 && currentWidth > 0) {
127
+
128
+ currentWidth = currentWidth > maxWidth ? maxWidth : currentWidth;
129
+ currentWidth = currentWidth < minWidth ? minWidth : currentWidth;
130
+
131
+ this.internalWidth = currentWidth;
132
+ }
133
+
134
+ if (this.isVerticalResize && currentHeight > 0) {
135
+
136
+ bottom -= this.verticalResizeOffset;
137
+
138
+ currentHeight = currentHeight + bottom;// - this.VerticalResizeOffset;
139
+ currentHeight = currentHeight > maxHeight ? maxHeight : currentHeight;
140
+ currentHeight = currentHeight < minHeight ? minHeight : currentHeight;
141
+
142
+ // 有横向滚动条
143
+ if (currentWidth <= this.initTotalColumnsWidth && !this.isTableEmpty) {
144
+
145
+ bottom2 -= this.verticalResizeOffset;
146
+
147
+ let differ = bottom2 - totalColumnsHeight;
148
+
149
+ // 高度足够(table 顶部到文档底部的高度 > 表格高度+滚动条高度)
150
+ if (bottom2 > totalColumnsHeight + scrollbarWidth) {
151
+
152
+ currentHeight += scrollbarWidth;
153
+
154
+ }
155
+ else if (differ > 0 && differ < scrollbarWidth) {
156
+
157
+ currentHeight += differ;
158
+ }
159
+ }
160
+
161
+ this.internalHeight = currentHeight;
162
+ }
163
+
164
+ this.changeColumnsWidth(currentWidth);
165
+ },
166
+
167
+ // 改变所有需要自适应列的宽度
168
+ changeColumnsWidth (currentWidth) {
169
+
170
+ let differ = currentWidth - this.totalColumnsWidth;
171
+ let initResizeWidths = this.initTotalColumnsWidth;
172
+ let rightViewBody = this.$el.querySelector(".v-table-body");
173
+ let rightViewFooter = this.$el.querySelector(".v-table-rightview .v-table-footer");
174
+
175
+ if (currentWidth <= initResizeWidths && !this.isTableEmpty) { // 排除表格无数据的影响
176
+
177
+ if (this.hasTableFooter) {
178
+
179
+ rightViewFooter.style.overflowX = "scroll";
180
+
181
+ } else {
182
+
183
+ rightViewBody.style.overflowX = "scroll";
184
+ }
185
+
186
+ this.adjustHeight(true);
187
+
188
+ } else {
189
+ // 防止最后一列右距中时内容显示不全
190
+ if (this.getTotalColumnsHeight() > this.internalHeight) {
191
+
192
+ differ -= this.scrollbarWidth;
193
+ }
194
+
195
+ if (this.hasTableFooter) {
196
+
197
+ rightViewFooter.style.overflowX = "hidden";
198
+ } else {
199
+
200
+ rightViewBody && rightViewBody.style && (rightViewBody.style.overflowX = "hidden");
201
+ }
202
+
203
+ this.adjustHeight(false);
204
+ }
205
+
206
+ if (this.hasFrozenColumn) {
207
+
208
+ differ -= 1;
209
+ }
210
+
211
+ if (currentWidth >= initResizeWidths || differ > 0) {
212
+
213
+ this.setColumnsWidth(differ);
214
+
215
+ } else { // 最小化有滚动条时
216
+
217
+ this.columns.forEach((col, index) => {
218
+
219
+ if (col.isResize) {
220
+
221
+ this.internalColumns[index].width = col.width;
222
+ }
223
+ });
224
+ }
225
+
226
+ this.containerWidthCheck();
227
+ },
228
+
229
+ /*
230
+ * 自适应时给列设置宽度
231
+ * 备注:浏览器 px 必须精确多整数
232
+ * */
233
+ setColumnsWidth (differ) {
234
+
235
+ let resizeColumnsLen = this.resizeColumns.length;
236
+ let average = Math.floor(differ / resizeColumnsLen);
237
+ let totalAverage = average * resizeColumnsLen;
238
+ let leftAverage = differ - totalAverage;
239
+ let leftAverageFloor = Math.floor(leftAverage);
240
+ let averageColumnsWidthArr = (new Array(resizeColumnsLen)).fill(average);
241
+ let index = 0;
242
+
243
+ // 剩余的宽度以整数的形式平均到每个列
244
+ for (let i = 0; i < leftAverageFloor; i++) {
245
+
246
+ averageColumnsWidthArr[i] += 1;
247
+ }
248
+
249
+ // 剩余的小数给最后一列
250
+ averageColumnsWidthArr[resizeColumnsLen - 1] += (leftAverage - leftAverageFloor);
251
+
252
+ this.internalColumns.map(item => {
253
+
254
+ if (item.isResize) {
255
+
256
+ item.width += averageColumnsWidthArr[index++];
257
+ }
258
+
259
+ return item;
260
+ });
261
+ },
262
+ timerFn () {
263
+ setTimeout(() => {
264
+ this.tableResize();
265
+ }, 500);
266
+ }
267
+ },
268
+
269
+ mounted () {
270
+
271
+ utils.bind(window, "resize", this.timerFn);
272
+ },
273
+ beforeDestroy () {
274
+
275
+ utils.unbind(window, "resize", this.tableResize);
276
+ clearTimeout(this.containerWidthCheckTimer);
277
+ }
278
+
279
+ };
@@ -0,0 +1,123 @@
1
+ export default {
2
+ data () {
3
+ return {
4
+ hoverRowIndex: -1,
5
+ clickRowIndex: -1
6
+ };
7
+ },
8
+
9
+ methods: {
10
+
11
+ handleMouseEnter (rowIndex) {
12
+ if (this.rowHoverColor && this.rowHoverColor.length > 0) {
13
+ this.hoverRowIndex = rowIndex;
14
+ }
15
+ this.rowMouseEnter && this.rowMouseEnter(rowIndex);
16
+ },
17
+
18
+ handleMouseOut (rowIndex) {
19
+ if (this.rowHoverColor && this.rowHoverColor.length > 0) {
20
+ this.hoverRowIndex = -1;
21
+ }
22
+ this.rowMouseLeave && this.rowMouseLeave(rowIndex);
23
+ },
24
+
25
+ /*
26
+ * 表头单元格单击事件
27
+ * 注意:如果为复杂表头,field 为数组
28
+ * */
29
+ titleCellClick (field, title) {
30
+ this.titleClick && this.titleClick(title, field);
31
+ },
32
+
33
+ /*
34
+ * 表头单元格双击事件
35
+ * 注意:如果为复杂表头,field 为数组
36
+ * */
37
+ titleCellDblClick (field, title) {
38
+ this.titleDblclick && this.titleDblclick(title, field);
39
+ },
40
+
41
+ // 行单击事件
42
+ rowCellClick (rowIndex, rowData, column) {
43
+ if (this.rowClickColor && this.rowClickColor.length > 0) {
44
+ this.clickRowIndex = rowIndex;
45
+ }
46
+ this.rowClick && this.rowClick(rowIndex, rowData, column);
47
+ },
48
+
49
+ // 行双击事件
50
+ rowCellDbClick (rowIndex, rowData, column) {
51
+ this.rowDblclick && this.rowDblclick(rowIndex, rowData, column);
52
+ },
53
+
54
+ /*
55
+ * @method getHighPriorityBgColor 获取高优先级的行背景色 优先级 click color > hover color > 奇偶color > table bg color
56
+ * */
57
+ getHighPriorityBgColor (rowIndex) {
58
+ let result = "";
59
+ if (this.clickRowIndex === rowIndex) {
60
+ result = this.rowClickColor;
61
+ } else if (this.hoverRowIndex === rowIndex) {
62
+ result = this.rowHoverColor;
63
+ }
64
+ if (result.length <= 0) {
65
+ if ((this.evenBgColor && this.evenBgColor.length > 0) || (this.oddBgColor && this.oddBgColor.length > 0)) {
66
+ result = (rowIndex + 1) % 2 === 0 ? this.evenBgColor : this.oddBgColor;
67
+ }
68
+ }
69
+ if (result.length <= 0) {
70
+ result = this.tableBgColor;
71
+ }
72
+ return result;
73
+ },
74
+
75
+ setRowBgColor (newVal, oldVal, color) {
76
+ let el = this.$el;
77
+ if (!el) {
78
+ return false;
79
+ }
80
+
81
+ let rowsCollection = [];
82
+ let oldRow;
83
+ let newRow;
84
+
85
+ if (this.hasFrozenColumn) {
86
+ rowsCollection.push(el.querySelectorAll(".v-table-leftview .v-table-row"));
87
+ }
88
+ if (this.hasFrozenRightColumn) {
89
+ rowsCollection.push(el.querySelectorAll(".v-table-rightview .v-table-row"));
90
+ }
91
+
92
+ rowsCollection.push(el.querySelectorAll(".v-table-centerview .v-table-row"));
93
+
94
+ rowsCollection.forEach(rows => {
95
+ oldRow = rows[oldVal];
96
+ newRow = rows[newVal];
97
+
98
+ if (oldRow) {
99
+ oldRow.style.backgroundColor = this.getHighPriorityBgColor(oldVal);
100
+ }
101
+ if (newRow) {
102
+ newRow.style.backgroundColor = color;
103
+ }
104
+ });
105
+ },
106
+ // 取消当前选中的行
107
+ clearCurrentRow () {
108
+ this.clickRowIndex = -1;
109
+ }
110
+
111
+ },
112
+
113
+ watch: {
114
+
115
+ "hoverRowIndex": function (newVal, oldVal) {
116
+ this.setRowBgColor(newVal, oldVal, this.rowHoverColor);
117
+ },
118
+
119
+ "clickRowIndex": function (newVal, oldVal) {
120
+ this.setRowBgColor(newVal, oldVal, this.rowClickColor);
121
+ }
122
+ }
123
+ };