ocpview-plus 1.3.15 → 1.3.16

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 (213) hide show
  1. package/README.md +55 -43
  2. package/dist/ocpviewplus.min.esm.js +574 -482
  3. package/dist/ocpviewplus.min.js +9 -9
  4. package/dist/style.css +1 -1
  5. package/dist/styles/efviewplus.css +1 -1
  6. package/package.json +146 -146
  7. package/src/components/base/ContractPrintMixins.js +30 -30
  8. package/src/components/base/controlbase.vue +190 -190
  9. package/src/components/base/controlbox.vue +102 -102
  10. package/src/components/base/index.js +2 -2
  11. package/src/components/base/load.js +19 -19
  12. package/src/components/base/probase.js +220 -220
  13. package/src/components/base/size.js +78 -78
  14. package/src/components/billbox/billbox.vue +67 -67
  15. package/src/components/billbox/index.js +1 -1
  16. package/src/components/cascaderbox/cascaderbox.vue +184 -184
  17. package/src/components/cascaderbox/index.js +2 -2
  18. package/src/components/checkbox/checkbox.vue +75 -75
  19. package/src/components/checkbox/checkgroupbox.vue +103 -103
  20. package/src/components/checkbox/index.js +2 -2
  21. package/src/components/colorbox/colorbox.vue +43 -43
  22. package/src/components/colorbox/index.js +1 -1
  23. package/src/components/combobox/combobox.vue +219 -219
  24. package/src/components/combobox/index.js +1 -1
  25. package/src/components/conditionbox/conditionbase.vue +194 -194
  26. package/src/components/conditionbox/conditionbox.vue +62 -62
  27. package/src/components/conditionbox/conditionfilterbox.vue +479 -479
  28. package/src/components/conditionbox/conditionselectorbox.vue +237 -237
  29. package/src/components/conditionbox/index.js +4 -4
  30. package/src/components/conditionbox/queryconditionbox.vue +25 -25
  31. package/src/components/conditionbox/queryconditionboxbase.vue +123 -123
  32. package/src/components/conditionbox/searchconditionbox.vue +113 -113
  33. package/src/components/conditionbox/searchgrid.vue +391 -391
  34. package/src/components/datebox/DateBoxV1.vue +22 -22
  35. package/src/components/datebox/datebox.vue +129 -129
  36. package/src/components/datebox/daterangebox.vue +154 -154
  37. package/src/components/datebox/index.js +5 -5
  38. package/src/components/form/baseform.vue +676 -676
  39. package/src/components/form/detailsbox.vue +487 -487
  40. package/src/components/form/formbox.vue +28 -28
  41. package/src/components/form/formcardbox.vue +267 -267
  42. package/src/components/form/formcardbox2.vue +228 -228
  43. package/src/components/form/formcardgroupbox.vue +251 -251
  44. package/src/components/form/formcompro.js +18 -18
  45. package/src/components/form/formdetail.vue +128 -128
  46. package/src/components/form/formdetailtwo.vue +302 -302
  47. package/src/components/form/index.js +9 -9
  48. package/src/components/form/toolanchor.js +45 -45
  49. package/src/components/form/workform.vue +167 -167
  50. package/src/components/grid/basegrid.vue +1062 -1062
  51. package/src/components/grid/editgrid.vue +51 -51
  52. package/src/components/grid/editgridbase.vue +1062 -1062
  53. package/src/components/grid/editgridcard.vue +193 -193
  54. package/src/components/grid/expandrow.vue +137 -137
  55. package/src/components/grid/index.js +5 -5
  56. package/src/components/grid/viewgrid.vue +121 -121
  57. package/src/components/grid/viewgridbase.vue +1286 -1286
  58. package/src/components/icon/common-icon.vue +53 -53
  59. package/src/components/icon/eicon.vue +28 -28
  60. package/src/components/icon/icons.vue +42 -42
  61. package/src/components/icon/index.js +1 -1
  62. package/src/components/label/index.js +2 -2
  63. package/src/components/label/showtext.vue +94 -94
  64. package/src/components/load/loadcartoon.vue +227 -227
  65. package/src/components/map/index.js +1 -1
  66. package/src/components/map/mapbox.vue +348 -348
  67. package/src/components/masterplate/RewriteBillListDetails/BillInfoPanel.vue +184 -184
  68. package/src/components/masterplate/RewriteBillListDetails/BillInfoPanelEditTable.vue +838 -838
  69. package/src/components/masterplate/RewriteBillListDetails/BillInfoPanelEditTableControlbox.vue +126 -126
  70. package/src/components/masterplate/RewriteBillListDetails/BillInfoPanelEditTableControlboxNumberbox.vue +27 -27
  71. package/src/components/masterplate/RewriteBillListDetails/BillListPanel.vue +126 -126
  72. package/src/components/masterplate/RewriteBillListDetails/BillListPanelQueryBar.vue +280 -280
  73. package/src/components/masterplate/RewriteBillListDetails/BillListPanelTable.vue +346 -346
  74. package/src/components/masterplate/RewriteBillListDetails/index.vue +325 -325
  75. package/src/components/masterplate/RewriteBillListDetails/mixins/useVxeGridEditTypeKeydownEventHook.js +251 -251
  76. package/src/components/masterplate/RewriteListdetails/BillListPanelV2.vue +115 -115
  77. package/src/components/masterplate/RewriteListdetails/BillListPanelV2QueryBar.vue +24 -24
  78. package/src/components/masterplate/RewriteListdetails/BillListPanelV3.vue +121 -121
  79. package/src/components/masterplate/RewriteListdetails/BillListPanelV3QueryBar.vue +275 -275
  80. package/src/components/masterplate/RewriteListdetails/indexV2.vue +320 -320
  81. package/src/components/masterplate/RewriteListdetails/indexV3.vue +331 -331
  82. package/src/components/masterplate/appendix.vue +586 -586
  83. package/src/components/masterplate/approval.vue +863 -863
  84. package/src/components/masterplate/base.vue +1028 -1028
  85. package/src/components/masterplate/billasyncimport.vue +614 -614
  86. package/src/components/masterplate/billconditionbox.vue +223 -223
  87. package/src/components/masterplate/billconditionsbox.vue +427 -427
  88. package/src/components/masterplate/billdetailform.vue +1028 -1028
  89. package/src/components/masterplate/billimport.vue +301 -301
  90. package/src/components/masterplate/billquerygrid.vue +391 -391
  91. package/src/components/masterplate/billsinglegrid.vue +234 -234
  92. package/src/components/masterplate/birtreport.vue +185 -185
  93. package/src/components/masterplate/contractappendix.vue +688 -688
  94. package/src/components/masterplate/detailbtntoolbar.vue +311 -311
  95. package/src/components/masterplate/detailsbox.vue +386 -386
  96. package/src/components/masterplate/editgridcard.vue +292 -292
  97. package/src/components/masterplate/editgridcard2.vue +127 -127
  98. package/src/components/masterplate/formcard.vue +105 -105
  99. package/src/components/masterplate/formcardgroupbox.vue +167 -167
  100. package/src/components/masterplate/formdetailtwo.vue +366 -366
  101. package/src/components/masterplate/gridcolset.vue +226 -226
  102. package/src/components/masterplate/index.js +54 -54
  103. package/src/components/masterplate/layouttemplate.vue +51 -51
  104. package/src/components/masterplate/leftlistrightdetails.vue +581 -581
  105. package/src/components/masterplate/leftlistrightlist.vue +464 -464
  106. package/src/components/masterplate/lefttreerightdetails.vue +636 -636
  107. package/src/components/masterplate/levelreport.vue +510 -510
  108. package/src/components/masterplate/listbtntoolbar.vue +276 -276
  109. package/src/components/masterplate/listdetails.vue +768 -768
  110. package/src/components/masterplate/operlog.vue +272 -272
  111. package/src/components/masterplate/options.vue +110 -110
  112. package/src/components/masterplate/page.vue +102 -102
  113. package/src/components/masterplate/promptmessage.vue +73 -73
  114. package/src/components/masterplate/querybar.vue +490 -490
  115. package/src/components/masterplate/report.vue +357 -357
  116. package/src/components/masterplate/rowbtntoolbar.vue +126 -126
  117. package/src/components/masterplate/simpletree.vue +137 -137
  118. package/src/components/masterplate/simpleviewgrid.vue +144 -144
  119. package/src/components/mychart/bar/bar.vue +201 -201
  120. package/src/components/mychart/basechart.vue +190 -190
  121. package/src/components/mychart/complexmychart/barline.vue +153 -153
  122. package/src/components/mychart/gauge/gauge.vue +82 -82
  123. package/src/components/mychart/index.js +8 -8
  124. package/src/components/mychart/line/line.vue +201 -201
  125. package/src/components/mychart/liquidfill/liquidfill.vue +108 -108
  126. package/src/components/mychart/pie/pie.vue +95 -95
  127. package/src/components/mychart/radar/radar.vue +121 -121
  128. package/src/components/mychart/scatter/scatter.vue +75 -75
  129. package/src/components/numberbox/NumberBoxV1.vue +39 -39
  130. package/src/components/numberbox/append.js +11 -11
  131. package/src/components/numberbox/index.js +4 -4
  132. package/src/components/numberbox/numberbox.vue +302 -302
  133. package/src/components/numberbox/numberrangebox.vue +422 -422
  134. package/src/components/picturebox/filebox.vue +369 -369
  135. package/src/components/picturebox/index.js +2 -2
  136. package/src/components/picturebox/picturebox.vue +541 -541
  137. package/src/components/picturebox/uploadbox.vue +164 -164
  138. package/src/components/poptagbox/index.js +1 -1
  139. package/src/components/poptagbox/poptagbox.vue +388 -388
  140. package/src/components/poptextbox/index.js +1 -1
  141. package/src/components/poptextbox/poptextbox.vue +624 -624
  142. package/src/components/radiobox/index.js +1 -1
  143. package/src/components/radiobox/radiogroupbox.vue +75 -75
  144. package/src/components/richtextbox/editor.vue +150 -150
  145. package/src/components/richtextbox/index.js +1 -1
  146. package/src/components/richtextbox/richtextbox.vue +448 -448
  147. package/src/components/textbox/index.js +1 -1
  148. package/src/components/textbox/textbox.vue +97 -97
  149. package/src/components/timebox/index.js +1 -1
  150. package/src/components/timebox/timebox.vue +75 -75
  151. package/src/components/toolbar/ebutton.vue +169 -169
  152. package/src/components/toolbar/index.js +3 -3
  153. package/src/components/toolbar/toolbar.vue +445 -445
  154. package/src/components/tree/CompatTree.vue +297 -297
  155. package/src/components/tree/basetree.vue +1098 -1098
  156. package/src/components/tree/index.js +2 -2
  157. package/src/components/tree/treedata.vue +53 -53
  158. package/src/components/tree/treedatabase.vue +189 -189
  159. package/src/components/upload/billimport.vue +233 -233
  160. package/src/components/upload/index.js +1 -1
  161. package/src/components/videobox/index.js +1 -1
  162. package/src/components/videobox/uploadbox.vue +148 -148
  163. package/src/components/videobox/videobox.vue +503 -503
  164. package/src/components/wrichtextbox/editor.vue +219 -219
  165. package/src/components/wrichtextbox/index.js +1 -1
  166. package/src/components/wrichtextbox/wrichtextbox.vue +62 -62
  167. package/src/index.js +231 -231
  168. package/src/locale/format.js +51 -51
  169. package/src/locale/index.js +63 -63
  170. package/src/locale/lang/zh-CN.js +123 -123
  171. package/src/locale/lang/zh-TW.js +114 -114
  172. package/src/locale/lang/zh-UG.js +115 -115
  173. package/src/locale/lang.js +15 -15
  174. package/src/method/case/case.js +1274 -1274
  175. package/src/method/config/queryconfig.js +24 -24
  176. package/src/method/const/const.js +815 -815
  177. package/src/method/index.js +7 -7
  178. package/src/plugins/theme/theme-variable.css +114 -114
  179. package/src/plugins/vxeTable/index.js +241 -241
  180. package/src/plugins/vxeTable/renderer/components/TableFilterInput.vue +51 -51
  181. package/src/plugins/vxeTable/renderer/filter.js +32 -32
  182. package/src/static/excel/exportexcel.js +626 -626
  183. package/src/static/iview/coustom.js +462 -462
  184. package/src/store/index.js +18 -18
  185. package/src/store/modules/app.js +53 -53
  186. package/src/styles/README.md +3 -3
  187. package/src/styles/common.less +80 -80
  188. package/src/styles/components/anchor.less +74 -74
  189. package/src/styles/components/approval.less +135 -135
  190. package/src/styles/components/button.less +208 -208
  191. package/src/styles/components/card.less +51 -51
  192. package/src/styles/components/content.less +38 -38
  193. package/src/styles/components/font.less +313 -313
  194. package/src/styles/components/form.less +71 -71
  195. package/src/styles/components/iconfont/fonts/iconfont.less +1384 -1384
  196. package/src/styles/components/iconfont/fonts/iconfont.svg +703 -703
  197. package/src/styles/components/index.less +16 -16
  198. package/src/styles/components/input.less +290 -290
  199. package/src/styles/components/modal.less +203 -203
  200. package/src/styles/components/page.less +340 -340
  201. package/src/styles/components/select.less +361 -361
  202. package/src/styles/components/steps.less +367 -367
  203. package/src/styles/components/table.less +544 -544
  204. package/src/styles/components/tabs.less +249 -249
  205. package/src/styles/components/upload.less +82 -82
  206. package/src/styles/custom.less +67 -67
  207. package/src/styles/index.less +6 -6
  208. package/src/styles/pack.less +6 -6
  209. package/src/utils/EfuMessenger.js +155 -155
  210. package/src/utils/assist.js +353 -353
  211. package/src/utils/index.js +1 -1
  212. package/src/utils/random_str.js +10 -10
  213. package/src/components/masterplate/detailgridbox.vue +0 -386
@@ -1,1062 +1,1062 @@
1
- <script>
2
- import Base from './basegrid.vue';
3
- export default {
4
- name: 'editgridbase',
5
- extends: Base,
6
- data() {
7
- return {
8
- myConfig: {
9
- resources: '',
10
- method: '',
11
- response: '',
12
- searchParam: null,
13
- readOnly: false,
14
- showIndex: true,
15
- showCheckBox: true,
16
- multiSelect: true,
17
- addRowBefore: '',
18
- name: '',
19
- editItemMaxNum: 8,
20
- lineNum: 4,
21
- labelWidth: 100,
22
- showAddBtn: true,
23
- showDelBatchBtn: true,
24
- showZoom:false,
25
- delBatchBtnName: '删除',
26
- addBtnName: '新增',
27
- editBtnName: '编辑',
28
- cancelBtnName: '放弃',
29
- showPage: false
30
- },
31
- showAddBtn: true,
32
- showDelBatchBtn: true,
33
- showDelBtn: true,
34
- showZoom:false,
35
- delBatchBtnName: '删除',
36
- addBtnName: '新增',
37
- showEditRowForm: false,
38
- defaultRow: {},
39
- editItemNum: 0,
40
- rowAction: [{
41
- iconcls: 'row',
42
- name: 'editRowForm',
43
- text: '编辑',
44
- }, ],
45
- openChange: false,
46
- focusIndex: null,
47
- focusKey: null,
48
- };
49
- },
50
- computed: {
51
- colKeys() {
52
- return this.soltTableColumns.map(c => c.key);
53
- }
54
- },
55
- /*beforeUnmount() {
56
- document.removeEventListener('keydown', this.handleKeydown);
57
- },*/
58
- methods: {
59
- customInit() {
60
- if (this.myConfig.items && this.myConfig.items.length > 0) {
61
- this.myConfig.items.forEach(el => {
62
- if (el.visible !== false) {
63
- this.editItemNum++;
64
- }
65
- });
66
- }
67
- if (this.editItemNum > Number(this.myConfig.editItemMaxNum)) {
68
- //启动行表单编辑模式
69
- this.showRowAction = true;
70
- this.myToolConfig.items = this.$Method.copy(this.rowAction);
71
- this.editRowFlag = false;
72
- } else {
73
- this.toolConfig.items = [];
74
- this.showRowAction = false;
75
- this.editRowFlag = true;
76
- }
77
-
78
- if (this.showDelRow) {
79
- if (!this.myToolConfig.items) {
80
- this.myToolConfig.items = [];
81
- }
82
- this.myToolConfig.items = this.myToolConfig.items.concat(this.delRowAction);
83
- }
84
- if (this.myConfig.showAddBtn !== undefined) {
85
- this.showAddBtn = this.myConfig.showAddBtn;
86
- }
87
- if (this.myConfig.showAddBtn !== undefined) {
88
- this.showAddBtn = this.myConfig.showAddBtn;
89
- }
90
- if (this.myConfig.addBtnName !== undefined) {
91
- this.addBtnName = this.myConfig.addBtnName;
92
- }
93
- if (this.myConfig.showDelBatchBtn !== undefined) {
94
- this.showDelBatchBtn = this.myConfig.showDelBatchBtn;
95
- }
96
- if (this.myConfig.showZoom !== undefined) {
97
- this.showZoom = this.myConfig.showZoom;
98
- }
99
-
100
- if (this.myConfig.showPage) {
101
- this.myConfig.indexMethod = this.customIndexMethod;
102
- if (this.myConfig.pageSizeNum) {
103
- this.myConfig.pageConfig.page_size = Number(this.myConfig.pageSizeNum);
104
- } else {
105
- this.myConfig.pageConfig.page_size = 20;
106
- }
107
- }
108
- if (this.customInit2) {
109
- this.customInit2();
110
- }
111
- this.myConfig.getGridObject = this.getGridObject;
112
- //监听键盘事件
113
- /* document.addEventListener('keydown', (e) => {
114
- this.handleKeydown(e);
115
- })*/
116
- },
117
- getGridObject() {
118
- let that = this;
119
- return that;
120
- },
121
- conditionAction(temp) {
122
- let data = [];
123
- switch (temp.action) {
124
- case 'condition_search':
125
- if (temp.para) {
126
- this.conditionSearchParam = this.$Method.copy(temp.para);
127
- }
128
- this.refurbish();
129
- break;
130
- case 'condition_clear':
131
- this.conditionSearchParam = {};
132
- break;
133
- case 'condition_ok':
134
- if (this.myConfig.multiSelect) {
135
- data = this.getSelection();
136
- } else {
137
- if (this.singleData.currentRow) {
138
- data.push(this.singleData.currentRow);
139
- }
140
- }
141
- if (data.length === 0) {
142
- this.alert('请选择');
143
- } else {
144
- temp.action = 'viewgrid_ok';
145
- temp.rows = data;
146
- this.$emit('viewGridAction', temp);
147
- }
148
- break;
149
- case 'condition_cancel':
150
- temp.action = 'viewgrid_cancel';
151
- this.$emit('viewGridAction', temp);
152
- break;
153
- }
154
- },
155
- /*getSelection() {
156
- return this.$refs.table.getSelection();
157
- },*/
158
- addRow(obj) {
159
- if (this.checkIsEdit) {
160
- if (!this.checkIsEdit()) {
161
- return;
162
- }
163
- }
164
- if (this.myConfig.readOnly) {
165
- this.setReadOnly(false);
166
- }
167
- let row = null;
168
- if (this.myConfig.addRowBefore) {
169
- let temp = {};
170
- temp.name = this.myConfig.name;
171
- temp.grid = this.$refs.table;
172
- row = this.myConfig.addRowBefore(temp);
173
- if (row === false) {
174
- return;
175
- }
176
- }
177
- if (!row || row === true) {
178
- row = {};
179
- }
180
- if (obj) {
181
- row = Object.assign({}, row, obj);
182
- }
183
- this.initScrollLeft();
184
- this.cancelCellEditing();
185
- this.$nextTick(() => {
186
- row.flag = 'I';
187
- let newRow = Object.assign({}, this.newRow, row);
188
- this.data.push(newRow);
189
- let tempObj = {};
190
- tempObj.name = 'editGrid';
191
- tempObj.gridname = this.myConfig.name;
192
- this.$emit('doAction', tempObj);
193
- });
194
- },
195
- setPro(obj) {
196
- if (obj) {
197
- this.myConfig = Object.assign({}, this.myConfig, obj);
198
- }
199
- },
200
- setReadOnly(value) {
201
- let obj = {};
202
- obj.readOnly = value;
203
- if (this.config.showCheckBox !== false) {
204
- if (obj.readOnly) {
205
- obj.showCheckBox = false;
206
- } else {
207
- obj.showCheckBox = true;
208
- }
209
- }
210
- this.cancelCellEditing();
211
- this.setPro(obj);
212
- },
213
- delBatchRow() {
214
- this.delCommonRow(null);
215
- },
216
- delRow(index) {
217
- this.delCommonRow(index);
218
- },
219
- delCommonRow(index) {
220
- let row = null;
221
- let self = this;
222
- if (this.myConfig.delRowBefore) {
223
- let obj = {};
224
- obj.name = this.myConfig.name;
225
- obj.grid = this.$refs.table;
226
- obj.index = index;
227
- row = this.myConfig.delRowBefore(obj);
228
- if (row === false) {
229
- return;
230
- }
231
- }
232
- this.cancelCellEditing();
233
- if (index || index === 0) {
234
- this.remove(index);
235
- } else {
236
- let selectionRows = this.getSelection();
237
- const length = selectionRows.length;
238
- for (let i = 0; i < length; i++) {
239
- this.remove(selectionRows[i]._customIndex, true);
240
- }
241
- }
242
- if (this.myConfig.delRowAfter) {
243
- let obj = {};
244
- obj.name = this.myConfig.name;
245
- obj.grid = self;
246
- this.$nextTick(() => {
247
- this.myConfig.delRowAfter(obj);
248
- });
249
- }
250
- },
251
- updataRow(index, obj) {
252
- let data = this.getData();
253
- if (this.myConfig.showPage) {
254
- let start = (this.myConfig.pageConfig.page_no - 1) * this.myConfig.pageConfig.page_size,
255
- end = start + this.myConfig.pageConfig.page_size;
256
- let row = data[index];
257
- let flag = true;
258
- if (index >= start && index < end) {
259
- flag = false;
260
- }
261
- if (row.flag === undefined) {
262
- obj.flag = 'U';
263
- }
264
- obj = Object.assign({}, row, obj);
265
- if (!flag) {
266
- let curlIndex = index - start;
267
- this.data.splice(curlIndex, 1, obj);
268
- } else {
269
- if (row.flag === 'I') {
270
- let addIndex = this.getAddIndex(index);
271
- if (addIndex > -1) {
272
- this.data.splice(this.getAddCurlIndex(addIndex), 1, obj);
273
- }
274
- } else {
275
- this.initData.splice(index, 1, obj);
276
- }
277
- }
278
- } else {
279
- if (data[index].flag === undefined) {
280
- obj.flag = 'U';
281
- }
282
- obj = Object.assign({}, data[index], obj);
283
- this.data.splice(index, 1, obj);
284
- }
285
- if (this.showEditRowForm) {
286
- if (this.$refs.rowForm) {
287
- if (index === this.$refs.rowForm.getEditIndex()) {
288
- this.$refs.rowForm.setData(obj);
289
- }
290
- }
291
- }
292
- },
293
- updateRow(index, obj) {
294
- this.updataRow(index, obj);
295
- },
296
- initRowForm(obj) {
297
- if (obj.rowinfo.row.flag === 'D') {
298
- return;
299
- }
300
- this.showEditRowForm = true;
301
- this.$refs.rowForm.setEditIndex(obj.rowinfo.index);
302
- this.$refs.rowForm.setData(obj.rowinfo.row);
303
- },
304
- OnSelectionChange(row) {
305
- if (this.myConfig.onSelectionChange) {
306
- this.myConfig.onSelectionChange(row);
307
- }
308
- let data = this.$Method.copy(this.data);
309
- let flag = false;
310
- data.forEach((el, index) => {
311
- flag = false;
312
- row.forEach(el2 => {
313
- if (index === el2._customIndex) {
314
- flag = true;
315
- return true;
316
- }
317
- });
318
- el._checked = flag;
319
- })
320
- this.data = data;
321
- },
322
- customInitOperColumn(action, columns) {
323
- if (this.myConfig.readOnly !== true) {
324
- if (this.showDelRow === false) {
325
- let index = this.myToolConfig.items.findIndex(el => el.name === 'delRow');
326
- if (index > -1) {
327
- this.myToolConfig.items.splice(index, 1);
328
- }
329
- if (this.myToolConfig.items.length > 0) {
330
- columns.push(action);
331
- }
332
- } else {
333
- columns.push(action);
334
- }
335
- }
336
- },
337
- editRow() {
338
- let row = this.$refs.rowForm.getData();
339
- this.$refs.rowForm.cancelCellEditing();
340
- this.updateRow(this.$refs.rowForm.getEditIndex(), row);
341
- },
342
- getChangeData() {
343
- let changeData = [];
344
- let data = this.getData();
345
- if (data.length > 0) {
346
- data.forEach(el => {
347
- if (el.flag !== undefined) {
348
- changeData.push(el);
349
- }
350
- });
351
- }
352
- if (this.myConfig.showPage) {
353
- return changeData;
354
- } else {
355
- return this.delData.concat(changeData);
356
- }
357
- },
358
- isChange() {
359
- let data = this.getChangeData();
360
- if (data.length > 0) {
361
- return true;
362
- }
363
- return false;
364
- },
365
- setShowAddBtn(flag) {
366
- this.showAddBtn = flag;
367
- },
368
- setShowDelBatchBtn(flag) {
369
- this.showDelBatchBtn = flag;
370
- },
371
- setCustomColumn(column) {
372
- //column.render= this.commonRendel;
373
- column.slot = column.key;
374
- },
375
- addRowInfo(obj, column) {
376
- let index = this.editIndex;
377
- obj.rowinfo = {};
378
- obj.rowinfo.column = column;
379
- if (index === -1) {
380
- index = this.oldEditIndex;
381
- }
382
- obj.rowinfo.index = index;
383
- if (index > -1) {
384
- obj.rowinfo.row = this.$Method.copy(this.data[index]);
385
- }
386
- let that = this;
387
- obj.rowinfo.gridObject = that;
388
- },
389
- valueChanged(obj) {
390
- const column = this.findColumnConfig(obj.name, this.myConfig.items);
391
- this.addRowInfo(obj, column);
392
- return column.valueChanged(obj);
393
- },
394
- onLinkTo(obj) {
395
- if (this.myConfig.readOnly) {
396
- const column = this.findColumnConfig(obj.name, this.myConfig.items);
397
- this.addRowInfo(obj, column);
398
- obj.rowinfo.index = obj.rowIndex;
399
- if (obj.rowIndex > -1) {
400
- obj.rowinfo.row = this.$Method.copy(this.data[obj.rowIndex]);
401
- }
402
- return column.onLinkTo(obj);
403
- } else {
404
- return;
405
- }
406
- },
407
- searchBefore(that) {
408
- const column = this.findColumnConfig(that.myConfig.name, this.myConfig.items);
409
- this.addRowInfo(that, column);
410
- return column.searchBefore(that);
411
- },
412
- setDataBefore(obj, that) {
413
- const column = this.findColumnConfig(that.myConfig.name, this.myConfig.items);
414
- let temp = {};
415
- temp.data = obj;
416
- temp.tabname = this.myConfig.name;
417
- this.addRowInfo(temp, column);
418
- return column.setDataBefore(temp, that);
419
- },
420
- cancelCellEditing() {
421
- let name = 'cell_' + this.editIndex + '_' + this.editKey;
422
- if (this.$refs[name] && this.$refs[name].setFocus) {
423
- this.$refs[name].setFocus(false);
424
- }
425
- let self = this;
426
- this.$nextTick(() => {
427
- self.editKey = '';
428
- self.oldEditIndex = this.editIndex;
429
- self.editIndex = -1;
430
- });
431
- },
432
- IsCellError(index, config) {
433
- let error = '';
434
- let row = this.$Method.copy(this.data[index]);
435
- if (row.flag === 'D') {
436
- error = 'efutre-del-row';
437
- } else {
438
- if (config.required === true) {
439
- if (!row[config.name] && row[config.name] !== 0) {
440
- let checkIndex = index;
441
- if (this.myConfig.showPage) {
442
- if (row.flag === 'I') {
443
- checkIndex = this.getAddIndex(index, true);
444
- if (this.checkAddInfo.length > checkIndex && this.checkAddInfo[checkIndex][config.key]) {
445
- error = 'efuture-grid-cell-error';
446
- }
447
- } else {
448
- checkIndex = checkIndex + (this.myConfig.pageConfig.page_no - 1) * this.myConfig.pageConfig.page_size;
449
- if (this.checkInfo.length > checkIndex && this.checkInfo[checkIndex][config.key]) {
450
- error = 'efuture-grid-cell-error';
451
- }
452
- }
453
- } else {
454
- if (this.checkInfo.length > checkIndex && this.checkInfo[checkIndex][config.key]) {
455
- error = 'efuture-grid-cell-error';
456
- }
457
- }
458
- }
459
- }
460
- }
461
- if (!error) {
462
- error = 'efuture-grid-cell';
463
- }
464
- return error;
465
- },
466
- EditCell(index, config) {
467
- //this.setEditGridFocus(index, config.key);
468
- if (this.myConfig.readOnly) {
469
- this.cancelCellEditing();
470
- return;
471
- }
472
- if (config.readOnly) {
473
- this.cancelCellEditing();
474
- return;
475
- }
476
- let row = this.getCurRow(index);
477
- if (this.myConfig.showPage) {
478
- if (row.flag === 'D') {
479
- return;
480
- }
481
- }
482
- if (this.editIndex === index && this.editKey === config.key) {
483
- return;
484
- }
485
- if (this.myConfig.cellbeginedit) {
486
- let rowinfo = {};
487
- rowinfo.index = index;
488
- rowinfo.column = config;
489
- rowinfo.tabname = this.myConfig.name;
490
- rowinfo.row = row;
491
- if (!this.myConfig.cellbeginedit(rowinfo)) {
492
- this.cancelCellEditing();
493
- return;
494
- } else {
495
- this.editIndex = index;
496
- this.editKey = config.key;
497
- }
498
- this.setcheckInfo(index, config.key);
499
- } else {
500
- this.editIndex = index;
501
- this.editKey = config.key;
502
- this.setcheckInfo(index, config.key);
503
- }
504
- },
505
- // 设置焦点位置
506
- setEditGridFocus(rowIdx, colKey) {
507
- this.focusIndex = rowIdx;
508
- this.focusKey = colKey;
509
- this.editIndex = rowIdx;
510
- this.editKey = colKey;
511
- this.focusCell(rowIdx, colKey);
512
- },
513
- // 设置键盘选中单元格样式
514
- focusCell(rowIdx, colKey) {
515
- this.$nextTick(() => {
516
- const tableEl = this.$refs.table.$el;
517
- const selector = `div[cell-row="${rowIdx}"][cell-col="${colKey}"]`;
518
- let curElement = tableEl.querySelector(selector);
519
- if(curElement) {
520
- const arr = tableEl.querySelectorAll('.ivu-table-column-selected');
521
- if(arr.length != 0) {
522
- arr.forEach(el => {
523
- el.classList.remove('ivu-table-column-selected');
524
- })
525
- }
526
-
527
- const cellDiv = curElement.closest('td');
528
- if (cellDiv) {
529
- cellDiv.classList.add('ivu-table-column-selected');
530
- cellDiv.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
531
- }
532
- }
533
- });
534
- },
535
- // 键盘导航事件
536
- handleKeydown(event) {
537
- if (this.focusIndex === null || this.focusKey === null) return;
538
- const colIdx = this.colKeys.findIndex(it => { return it == this.focusKey});
539
-
540
- this.focusKey = this.colKeys[colIdx];
541
- let newRow = this.focusIndex;
542
- let newCol = colIdx;
543
-
544
- let name = 'cell_' + this.editIndex + '_' + this.editKey;
545
- const { key } = event;
546
-
547
- if(key == 'ArrowUp') {
548
- if (this.focusIndex > 0) newRow--;
549
- this.extEditStatus();
550
- }
551
- if(key == 'ArrowDown') {
552
- if (this.focusIndex < this.data.length - 1) newRow++;
553
- this.extEditStatus();
554
- }
555
- if(key == 'ArrowLeft') {
556
- if (colIdx > 1) newCol--;
557
- this.extEditStatus();
558
- }
559
- if(key == 'ArrowRight') {
560
- if (colIdx < this.colKeys.length - 1) newCol++;
561
- this.extEditStatus();
562
- }
563
-
564
- if(key == 'Enter') {
565
- if (colIdx < this.colKeys.length - 1) newCol++;
566
- }
567
-
568
- this.setEditGridFocus(newRow, this.colKeys[newCol]);
569
- if(!this.myConfig.readOnly) {
570
- // 解决键盘按下input框的值不修改问题
571
- if (this.$refs[name] && this.$refs[name].autofocus) {
572
- return true;
573
- }
574
- } else {
575
- this.handleOut();
576
- }
577
- event.preventDefault();
578
- },
579
- extEditStatus() {
580
- if(!this.myConfig.readOnly) {
581
- //this.handleOut();
582
- let name = 'cell_' + this.editIndex + '_' + this.editKey;
583
- if (this.$refs[name] && this.$refs[name].setFocus) {
584
- this.$refs[name].setFocus(false);
585
- }
586
- let self = this;
587
- this.$nextTick(() => {
588
- self.editKey = '';
589
- self.oldEditIndex = this.editIndex;
590
- //self.editIndex = -1;
591
- });
592
- }
593
- },
594
- setcheckInfo(index, key) {
595
- let checkIndex = index;
596
- let row = this.getCurRow(index);
597
- if (this.myConfig.showPage) {
598
- checkIndex = checkIndex + (this.myConfig.pageConfig.page_no - 1) * this.myConfig.pageConfig.page_size;
599
- if (row.flag === 'I') {
600
- this.setCheckCommonInfo(this.checkAddInfo, this.getAddIndex(index, true), key);
601
- } else {
602
- this.setCheckCommonInfo(this.checkInfo, checkIndex, key);
603
- }
604
- } else {
605
- this.setCheckCommonInfo(this.checkInfo, checkIndex, key);
606
- }
607
- },
608
- setCheckCommonInfo(data, index, key) {
609
- if (data.length > index) {
610
- this.checkInfo[index][key] = true;
611
- } else {
612
- let curNum = data.length;
613
- for (let i = 0; i < index - curNum + 1; i++) {
614
- data.push({});
615
- }
616
- }
617
- data[index][key] = true;
618
- },
619
- formatValue(index, column) {
620
- let value = '';
621
- let row = this.$Method.copy(this.data[index]);
622
- if (column.name) {
623
- value = row[column.name];
624
- }
625
- let config = column;
626
- if (column.updateCellConfig) {
627
- let rowinfo = {};
628
- rowinfo.index = index;
629
- rowinfo.column = column;
630
- rowinfo.row = this.$Method.copy(this.data[index]);
631
- config = column.updateCellConfig(rowinfo);
632
- }
633
- let valueFormat = this.$Method.formatValue(value, row, config);
634
- let obj = {};
635
- obj.value = value;
636
- obj.row = row;
637
- obj.config = config;
638
- obj.valueFormat = valueFormat;
639
- if (column.formatValue) {
640
- return column.formatValue(obj);
641
- } else if (this.myConfig.formatValue) {
642
- return this.myConfig.formatValue(obj);
643
- } else {
644
- return valueFormat;
645
- }
646
- },
647
- getCellConfig(index, config) {
648
- const column = this.findColumnConfig(config.name, this.myConfig.items);
649
- if (column.updateCellConfig) {
650
- let rowinfo = {};
651
- rowinfo.index = index;
652
- rowinfo.column = config;
653
- rowinfo.row = this.$Method.copy(this.data[index]);
654
- let newConfig = column.updateCellConfig(rowinfo);
655
- newConfig.onOpenChange = this.onOpenChange;
656
- newConfig.place = 'grid';
657
- return newConfig;
658
- } else {
659
- config.onOpenChange = this.onOpenChange;
660
- config.place = 'grid';
661
- return config;
662
- }
663
- },
664
- onOpenChange(value) {
665
- this.openChange = value;
666
- },
667
- getCurRow(index) {
668
- return this.$Method.copy(this.data[index]);
669
- },
670
- handleOut() {
671
- if (this.editKey) {
672
- if (!this.openChange) {
673
- // 去除编辑状态
674
- this.cancelCellEditing();
675
- }
676
- }
677
- },
678
- checkValidate() {
679
- // check 去除编辑状态
680
- this.cancelCellEditing();
681
- let flag = false;
682
- let data = this.getData();
683
- if (data.length > 0) {
684
- let keys = [];
685
- this.soltTableColumns.some(el => {
686
- if (el.name || el.sname) {
687
- if (el.visible !== false && el.required === true) {
688
- if (el.name) {
689
- keys.push(el.name);
690
- }
691
- if (el.sname) {
692
- keys.push(el.sname);
693
- }
694
- if (el.ename) {
695
- keys.push(el.ename);
696
- }
697
- }
698
- }
699
- });
700
- let addIndex = -1;
701
- data.forEach((el, index) => {
702
- if (el.flag === 'I') {
703
- addIndex++;
704
- }
705
- if (el.flag !== 'D') {
706
- keys.forEach(key => {
707
- if (!el[key] && el[key] !== 0) {
708
- if (!flag) flag = true;
709
- if (this.myConfig.showPage) {
710
- if (el.flag === 'I') {
711
- this.setCheckCommonInfo(this.checkAddInfo, addIndex, key);
712
- } else {
713
- this.setCheckCommonInfo(this.checkInfo, index, key);
714
- }
715
- } else {
716
- this.setCheckCommonInfo(this.checkInfo, index, key);
717
- }
718
-
719
- }
720
- });
721
- }
722
- });
723
- }
724
- return flag;
725
- },
726
- setShowBtn(value) {
727
- this.showBtn = value;
728
- },
729
- doAction(obj) {
730
- if (this[obj.name]) {
731
- this[obj.name](obj);
732
- }
733
- },
734
- enterKeyDown() {
735
- let nextKey = this.findNextItems(this.editIndex, this.editKey);
736
- if (nextKey) {
737
- this.editIndex = nextKey.editIndex;
738
- this.editKey = nextKey.editKey;
739
- this.setcheckInfo(nextKey.editIndex, nextKey.editKey);
740
- //this.setEditGridFocus(this.editIndex, this.editKey);
741
- }
742
- },
743
- findNextItems(editIndex, editName) {
744
- let index = this.soltTableColumns.findIndex(el => {
745
- return el.name === editName || el.sname === editName;
746
- });
747
- let nextIndex = index + 1;
748
- if (index > -1) {
749
- if (nextIndex >= this.soltTableColumns.length) {
750
- if (editIndex + 1 >= this.data.length) {
751
- editIndex = this.findNextRow(0);
752
- nextIndex = 0;
753
- if (this.soltTableColumns[0].type === 'selection' || this.soltTableColumns[0].type === 'index') {
754
- nextIndex++;
755
- }
756
- if (this.soltTableColumns[1].type === 'index') {
757
- nextIndex++;
758
- }
759
- } else {
760
- let temp = editIndex + 1;
761
- editIndex = this.findNextRow(temp);
762
- nextIndex = 0;
763
- if (this.soltTableColumns[0].type === 'selection' || this.soltTableColumns[0].type === 'index') {
764
- nextIndex++;
765
- }
766
- if (this.soltTableColumns[1].type === 'index') {
767
- nextIndex++;
768
- }
769
- }
770
- }
771
- } else {
772
- return null;
773
- }
774
- let column = this.soltTableColumns[nextIndex];
775
- let config = this.getCellConfig(editIndex, column);
776
- let name = config.name;
777
- if (config.sname) {
778
- name = config.sname;
779
- }
780
- if (config.readOnly === true || config.visible === false || config.type === 'PictureBox' || config.type === 'VideoBox' || config.type === 'RichTextBox' || config.type === 'wRichTextBox'|| config.type === 'selection' || config.type === 'index') {
781
- return this.findNextItems(editIndex, name);
782
- } else {
783
- if (this.myConfig.cellbeginedit) {
784
- let rowinfo = {};
785
- rowinfo.index = editIndex;
786
- rowinfo.column = config;
787
- rowinfo.tabname = this.myConfig.name;
788
- rowinfo.row = this.$Method.copy(this.data[editIndex]);
789
- if (!this.myConfig.cellbeginedit(rowinfo)) {
790
- return this.findNextItems(editIndex, name);
791
- } else {
792
- let nextKey = {};
793
- nextKey.editIndex = editIndex;
794
- nextKey.editKey = name;
795
- return nextKey;
796
- }
797
- } else {
798
- let nextKey = {};
799
- nextKey.editIndex = editIndex;
800
- nextKey.editKey = name;
801
- return nextKey;
802
- }
803
- }
804
- },
805
- customIndexMethod(row, index) {
806
- if (row.flag === 'I') {
807
- return '+';
808
- } else {
809
- return index;
810
- }
811
- },
812
- findNextRow(editIndex) {
813
- let resultIndex = editIndex;
814
- if (this.myConfig.showPage) {
815
- this.data.some((el, index) => {
816
- if (index >= editIndex) {
817
- if (el.flag !== 'D') {
818
- resultIndex = index;
819
- return true;
820
- }
821
- }
822
- });
823
- }
824
- return resultIndex;
825
- },
826
- rowClassName(row) {
827
- if (row.flag === 'D') {
828
- return 'efutre-del-row';
829
- }
830
- return '';
831
- },
832
- getCellClass(index) {
833
- let row = this.getCurRow(index);
834
- if (row && row.flag === 'D') {
835
- return 'efutre-del-row';
836
- } else {
837
- return '';
838
- }
839
- },
840
- changePageSize(pageSize) {
841
- this.saveCurlData(this.myConfig.pageConfig.page_no, this.initData);
842
- this.myConfig.pageConfig.page_no = 1;
843
- this.data = this.fillData(this.myConfig.pageConfig.page_no, pageSize);
844
- this.myConfig.pageConfig.page_size = pageSize;
845
- this.cancelCellEditing();
846
- },
847
- changePage(page) {
848
- this.saveCurlData(this.myConfig.pageConfig.page_no, this.initData);
849
- this.data = this.fillData(page, this.myConfig.pageConfig.page_size);
850
- this.myConfig.pageConfig.page_no = page;
851
- this.cancelCellEditing();
852
- },
853
- customClearData() {
854
- this.initScrollLeft();
855
- },
856
- saveCurlData(pageIndex, data) {
857
- let addData = [];
858
- this.data.forEach((el, index) => {
859
- let curlIndex = (pageIndex - 1) * this.myConfig.pageConfig.page_size + index;
860
- if (el.flag === 'U' || el.flag === 'D') {
861
- data.splice(curlIndex, 1, el);
862
- } else {
863
- if (el.flag === 'I') {
864
- addData.push(el);
865
- }
866
- }
867
- });
868
- this.addData = addData;
869
- },
870
- setData(data) {
871
- if (!data) {
872
- data = [];
873
- }
874
- if (this.myConfig.showPage) {
875
- this.initData = this.$Method.copy(data);
876
- this.myConfig.pageConfig.page_no = 1;
877
- this.myConfig.pageConfig.total_results = data.length;
878
- this.data = this.fillData(this.myConfig.pageConfig.page_no, this.myConfig.pageConfig.page_size);
879
- } else {
880
- this.data = data;
881
- this.initData = this.$Method.copy(this.data);
882
- }
883
- this.addData = [];
884
- this.delData = [];
885
- this.checkInfo = [];
886
- this.initScrollLeft();
887
- this.cancelCellEditing();
888
- },
889
- fillData(pageIndex, pageSize) {
890
- let arr = [];
891
- let start = (pageIndex - 1) * pageSize,
892
- end = start + pageSize;
893
- if (end > this.myConfig.pageConfig.total_results) {
894
- end = this.myConfig.pageConfig.total_results;
895
- }
896
- for (var i = start, l = end; i < l; i++) {
897
- var record = this.initData[i];
898
- if (!record)
899
- continue;
900
- arr.push(record);
901
- }
902
- this.addData.forEach(el => {
903
- arr.push(el);
904
- });
905
- return arr;
906
- },
907
- getData() {
908
- if (this.myConfig.showPage) {
909
- let initData = this.$Method.copy(this.initData);
910
- this.saveCurlData(this.myConfig.pageConfig.page_no, initData);
911
- this.addData.forEach(el => {
912
- initData.push(el);
913
- });
914
- return initData;
915
- } else {
916
- return this.$Method.copy(this.data);
917
- }
918
- },
919
- remove(index, flag) {
920
- let _index = index;
921
- if (flag) {
922
- let tempIndex = this.data.findIndex(item => item._customIndex === index);
923
- if (tempIndex > -1) {
924
- _index = tempIndex;
925
- }
926
- }
927
- let data = this.getData();
928
- if (_index > -1) {
929
- if (data[_index].flag === undefined || data[_index].flag === 'U') {
930
- let row = this.$Method.copy(data[_index]);
931
- row.flag = 'D';
932
- if (this.myConfig.showPage) {
933
- let start = (this.myConfig.pageConfig.page_no - 1) * this.myConfig.pageConfig.page_size,
934
- end = start + this.myConfig.pageConfig.page_size;
935
- let curlIndex = _index;
936
- if (index >= start && index < end) {
937
- curlIndex = index - start;
938
- this.data.splice(curlIndex, 1, row);
939
- } else {
940
- this.initData.splice(curlIndex, 1, row);
941
- }
942
- } else {
943
- this.delData.push(row);
944
- this.data.splice(_index, 1);
945
- }
946
- } else {
947
- if (data[_index].flag === 'I') {
948
- if (this.myConfig.showPage) {
949
- let addIndex = this.getAddIndex(_index);
950
- if (addIndex > -1) {
951
- this.checkAddInfo.splice(addIndex, 1);
952
- this.data.splice(this.getAddCurlIndex(addIndex), 1);
953
- }
954
- } else {
955
- this.data.splice(_index, 1);
956
- this.checkInfo.splice(_index, 1);
957
- }
958
- }
959
- }
960
- }
961
- this.initScrollLeft();
962
- },
963
- getAddIndex(index, flag) {
964
- let addIndex = -1;
965
- let data = [];
966
- if (flag) {
967
- data = this.data;
968
- } else {
969
- data = this.getData();
970
- }
971
- data.some((el, culIndex) => {
972
- if (el.flag === 'I') {
973
- addIndex++;
974
- }
975
- if (culIndex === index) {
976
- return true;
977
- }
978
- });
979
- return addIndex;
980
- },
981
- getAddCurlIndex(index) {
982
- let addIndex = -1;
983
- let result = -1;
984
- this.data.some((el, culIndex) => {
985
- if (el.flag === 'I') {
986
- addIndex++;
987
- }
988
- if (addIndex === index) {
989
- result = culIndex;
990
- return true;
991
- }
992
- });
993
- return result;
994
- },
995
- setSummary(config,data,sums) {
996
- if (config.children) {
997
- config.children.forEach(el => {
998
- this.setSummary(el,data.sums);
999
- });
1000
- } else {
1001
- const key = config.key;
1002
- if(config.summary) {
1003
- const values = data.map(item => Number(item[key]));
1004
- if (!values.every(value => isNaN(value))) {
1005
- const v = values.reduce((prev, curr) => {
1006
- const value = Number(curr);
1007
- if (!isNaN(value)) {
1008
- return prev + curr;
1009
- } else {
1010
- return prev;
1011
- }
1012
- }, 0);
1013
- sums[key] = {
1014
- key,
1015
- value: this.$Method.formatNumber(v, config.format, config.notzero),
1016
- countValue:v
1017
- };
1018
- } else {
1019
- sums[key] = {
1020
- key,
1021
- value: 'N/A'
1022
- };
1023
- }
1024
- } else {
1025
- sums[key] = {
1026
- key,
1027
- value: ''
1028
- };
1029
- }
1030
- }
1031
- },
1032
- handleSummary({ columns ,data}) {
1033
- const sums = {};
1034
- columns.forEach(column => {
1035
- this.setSummary(column,data,sums);
1036
- });
1037
- let firstkey = this.findFirst(columns);
1038
- sums[firstkey] = {key:firstkey,value:this.myConfig.sumText};
1039
- if (this.myConfig.customSummary){
1040
- return this.myConfig.customSummary(sums);
1041
- } else {
1042
- return sums;
1043
- }
1044
- },
1045
- findFirst(columns) {
1046
- let key = '';
1047
- columns.some(el => {
1048
- if (el.key !== 'selection' && el.key !== 'index') {
1049
- key = el.name;
1050
- return true;
1051
- }
1052
- });
1053
- return key;
1054
- },
1055
- },
1056
- };
1057
- </script>
1058
- <style lang="less">
1059
- .ivu-table-column-selected, .active-cell{
1060
- box-shadow: inset 0 0 0 2px #AF292E;
1061
- }
1062
- </style>
1
+ <script>
2
+ import Base from './basegrid.vue';
3
+ export default {
4
+ name: 'editgridbase',
5
+ extends: Base,
6
+ data() {
7
+ return {
8
+ myConfig: {
9
+ resources: '',
10
+ method: '',
11
+ response: '',
12
+ searchParam: null,
13
+ readOnly: false,
14
+ showIndex: true,
15
+ showCheckBox: true,
16
+ multiSelect: true,
17
+ addRowBefore: '',
18
+ name: '',
19
+ editItemMaxNum: 8,
20
+ lineNum: 4,
21
+ labelWidth: 100,
22
+ showAddBtn: true,
23
+ showDelBatchBtn: true,
24
+ showZoom:false,
25
+ delBatchBtnName: '删除',
26
+ addBtnName: '新增',
27
+ editBtnName: '编辑',
28
+ cancelBtnName: '放弃',
29
+ showPage: false
30
+ },
31
+ showAddBtn: true,
32
+ showDelBatchBtn: true,
33
+ showDelBtn: true,
34
+ showZoom:false,
35
+ delBatchBtnName: '删除',
36
+ addBtnName: '新增',
37
+ showEditRowForm: false,
38
+ defaultRow: {},
39
+ editItemNum: 0,
40
+ rowAction: [{
41
+ iconcls: 'row',
42
+ name: 'editRowForm',
43
+ text: '编辑',
44
+ }, ],
45
+ openChange: false,
46
+ focusIndex: null,
47
+ focusKey: null,
48
+ };
49
+ },
50
+ computed: {
51
+ colKeys() {
52
+ return this.soltTableColumns.map(c => c.key);
53
+ }
54
+ },
55
+ /*beforeUnmount() {
56
+ document.removeEventListener('keydown', this.handleKeydown);
57
+ },*/
58
+ methods: {
59
+ customInit() {
60
+ if (this.myConfig.items && this.myConfig.items.length > 0) {
61
+ this.myConfig.items.forEach(el => {
62
+ if (el.visible !== false) {
63
+ this.editItemNum++;
64
+ }
65
+ });
66
+ }
67
+ if (this.editItemNum > Number(this.myConfig.editItemMaxNum)) {
68
+ //启动行表单编辑模式
69
+ this.showRowAction = true;
70
+ this.myToolConfig.items = this.$Method.copy(this.rowAction);
71
+ this.editRowFlag = false;
72
+ } else {
73
+ this.toolConfig.items = [];
74
+ this.showRowAction = false;
75
+ this.editRowFlag = true;
76
+ }
77
+
78
+ if (this.showDelRow) {
79
+ if (!this.myToolConfig.items) {
80
+ this.myToolConfig.items = [];
81
+ }
82
+ this.myToolConfig.items = this.myToolConfig.items.concat(this.delRowAction);
83
+ }
84
+ if (this.myConfig.showAddBtn !== undefined) {
85
+ this.showAddBtn = this.myConfig.showAddBtn;
86
+ }
87
+ if (this.myConfig.showAddBtn !== undefined) {
88
+ this.showAddBtn = this.myConfig.showAddBtn;
89
+ }
90
+ if (this.myConfig.addBtnName !== undefined) {
91
+ this.addBtnName = this.myConfig.addBtnName;
92
+ }
93
+ if (this.myConfig.showDelBatchBtn !== undefined) {
94
+ this.showDelBatchBtn = this.myConfig.showDelBatchBtn;
95
+ }
96
+ if (this.myConfig.showZoom !== undefined) {
97
+ this.showZoom = this.myConfig.showZoom;
98
+ }
99
+
100
+ if (this.myConfig.showPage) {
101
+ this.myConfig.indexMethod = this.customIndexMethod;
102
+ if (this.myConfig.pageSizeNum) {
103
+ this.myConfig.pageConfig.page_size = Number(this.myConfig.pageSizeNum);
104
+ } else {
105
+ this.myConfig.pageConfig.page_size = 20;
106
+ }
107
+ }
108
+ if (this.customInit2) {
109
+ this.customInit2();
110
+ }
111
+ this.myConfig.getGridObject = this.getGridObject;
112
+ //监听键盘事件
113
+ /* document.addEventListener('keydown', (e) => {
114
+ this.handleKeydown(e);
115
+ })*/
116
+ },
117
+ getGridObject() {
118
+ let that = this;
119
+ return that;
120
+ },
121
+ conditionAction(temp) {
122
+ let data = [];
123
+ switch (temp.action) {
124
+ case 'condition_search':
125
+ if (temp.para) {
126
+ this.conditionSearchParam = this.$Method.copy(temp.para);
127
+ }
128
+ this.refurbish();
129
+ break;
130
+ case 'condition_clear':
131
+ this.conditionSearchParam = {};
132
+ break;
133
+ case 'condition_ok':
134
+ if (this.myConfig.multiSelect) {
135
+ data = this.getSelection();
136
+ } else {
137
+ if (this.singleData.currentRow) {
138
+ data.push(this.singleData.currentRow);
139
+ }
140
+ }
141
+ if (data.length === 0) {
142
+ this.alert('请选择');
143
+ } else {
144
+ temp.action = 'viewgrid_ok';
145
+ temp.rows = data;
146
+ this.$emit('viewGridAction', temp);
147
+ }
148
+ break;
149
+ case 'condition_cancel':
150
+ temp.action = 'viewgrid_cancel';
151
+ this.$emit('viewGridAction', temp);
152
+ break;
153
+ }
154
+ },
155
+ /*getSelection() {
156
+ return this.$refs.table.getSelection();
157
+ },*/
158
+ addRow(obj) {
159
+ if (this.checkIsEdit) {
160
+ if (!this.checkIsEdit()) {
161
+ return;
162
+ }
163
+ }
164
+ if (this.myConfig.readOnly) {
165
+ this.setReadOnly(false);
166
+ }
167
+ let row = null;
168
+ if (this.myConfig.addRowBefore) {
169
+ let temp = {};
170
+ temp.name = this.myConfig.name;
171
+ temp.grid = this.$refs.table;
172
+ row = this.myConfig.addRowBefore(temp);
173
+ if (row === false) {
174
+ return;
175
+ }
176
+ }
177
+ if (!row || row === true) {
178
+ row = {};
179
+ }
180
+ if (obj) {
181
+ row = Object.assign({}, row, obj);
182
+ }
183
+ this.initScrollLeft();
184
+ this.cancelCellEditing();
185
+ this.$nextTick(() => {
186
+ row.flag = 'I';
187
+ let newRow = Object.assign({}, this.newRow, row);
188
+ this.data.push(newRow);
189
+ let tempObj = {};
190
+ tempObj.name = 'editGrid';
191
+ tempObj.gridname = this.myConfig.name;
192
+ this.$emit('doAction', tempObj);
193
+ });
194
+ },
195
+ setPro(obj) {
196
+ if (obj) {
197
+ this.myConfig = Object.assign({}, this.myConfig, obj);
198
+ }
199
+ },
200
+ setReadOnly(value) {
201
+ let obj = {};
202
+ obj.readOnly = value;
203
+ if (this.config.showCheckBox !== false) {
204
+ if (obj.readOnly) {
205
+ obj.showCheckBox = false;
206
+ } else {
207
+ obj.showCheckBox = true;
208
+ }
209
+ }
210
+ this.cancelCellEditing();
211
+ this.setPro(obj);
212
+ },
213
+ delBatchRow() {
214
+ this.delCommonRow(null);
215
+ },
216
+ delRow(index) {
217
+ this.delCommonRow(index);
218
+ },
219
+ delCommonRow(index) {
220
+ let row = null;
221
+ let self = this;
222
+ if (this.myConfig.delRowBefore) {
223
+ let obj = {};
224
+ obj.name = this.myConfig.name;
225
+ obj.grid = this.$refs.table;
226
+ obj.index = index;
227
+ row = this.myConfig.delRowBefore(obj);
228
+ if (row === false) {
229
+ return;
230
+ }
231
+ }
232
+ this.cancelCellEditing();
233
+ if (index || index === 0) {
234
+ this.remove(index);
235
+ } else {
236
+ let selectionRows = this.getSelection();
237
+ const length = selectionRows.length;
238
+ for (let i = 0; i < length; i++) {
239
+ this.remove(selectionRows[i]._customIndex, true);
240
+ }
241
+ }
242
+ if (this.myConfig.delRowAfter) {
243
+ let obj = {};
244
+ obj.name = this.myConfig.name;
245
+ obj.grid = self;
246
+ this.$nextTick(() => {
247
+ this.myConfig.delRowAfter(obj);
248
+ });
249
+ }
250
+ },
251
+ updataRow(index, obj) {
252
+ let data = this.getData();
253
+ if (this.myConfig.showPage) {
254
+ let start = (this.myConfig.pageConfig.page_no - 1) * this.myConfig.pageConfig.page_size,
255
+ end = start + this.myConfig.pageConfig.page_size;
256
+ let row = data[index];
257
+ let flag = true;
258
+ if (index >= start && index < end) {
259
+ flag = false;
260
+ }
261
+ if (row.flag === undefined) {
262
+ obj.flag = 'U';
263
+ }
264
+ obj = Object.assign({}, row, obj);
265
+ if (!flag) {
266
+ let curlIndex = index - start;
267
+ this.data.splice(curlIndex, 1, obj);
268
+ } else {
269
+ if (row.flag === 'I') {
270
+ let addIndex = this.getAddIndex(index);
271
+ if (addIndex > -1) {
272
+ this.data.splice(this.getAddCurlIndex(addIndex), 1, obj);
273
+ }
274
+ } else {
275
+ this.initData.splice(index, 1, obj);
276
+ }
277
+ }
278
+ } else {
279
+ if (data[index].flag === undefined) {
280
+ obj.flag = 'U';
281
+ }
282
+ obj = Object.assign({}, data[index], obj);
283
+ this.data.splice(index, 1, obj);
284
+ }
285
+ if (this.showEditRowForm) {
286
+ if (this.$refs.rowForm) {
287
+ if (index === this.$refs.rowForm.getEditIndex()) {
288
+ this.$refs.rowForm.setData(obj);
289
+ }
290
+ }
291
+ }
292
+ },
293
+ updateRow(index, obj) {
294
+ this.updataRow(index, obj);
295
+ },
296
+ initRowForm(obj) {
297
+ if (obj.rowinfo.row.flag === 'D') {
298
+ return;
299
+ }
300
+ this.showEditRowForm = true;
301
+ this.$refs.rowForm.setEditIndex(obj.rowinfo.index);
302
+ this.$refs.rowForm.setData(obj.rowinfo.row);
303
+ },
304
+ OnSelectionChange(row) {
305
+ if (this.myConfig.onSelectionChange) {
306
+ this.myConfig.onSelectionChange(row);
307
+ }
308
+ let data = this.$Method.copy(this.data);
309
+ let flag = false;
310
+ data.forEach((el, index) => {
311
+ flag = false;
312
+ row.forEach(el2 => {
313
+ if (index === el2._customIndex) {
314
+ flag = true;
315
+ return true;
316
+ }
317
+ });
318
+ el._checked = flag;
319
+ })
320
+ this.data = data;
321
+ },
322
+ customInitOperColumn(action, columns) {
323
+ if (this.myConfig.readOnly !== true) {
324
+ if (this.showDelRow === false) {
325
+ let index = this.myToolConfig.items.findIndex(el => el.name === 'delRow');
326
+ if (index > -1) {
327
+ this.myToolConfig.items.splice(index, 1);
328
+ }
329
+ if (this.myToolConfig.items.length > 0) {
330
+ columns.push(action);
331
+ }
332
+ } else {
333
+ columns.push(action);
334
+ }
335
+ }
336
+ },
337
+ editRow() {
338
+ let row = this.$refs.rowForm.getData();
339
+ this.$refs.rowForm.cancelCellEditing();
340
+ this.updateRow(this.$refs.rowForm.getEditIndex(), row);
341
+ },
342
+ getChangeData() {
343
+ let changeData = [];
344
+ let data = this.getData();
345
+ if (data.length > 0) {
346
+ data.forEach(el => {
347
+ if (el.flag !== undefined) {
348
+ changeData.push(el);
349
+ }
350
+ });
351
+ }
352
+ if (this.myConfig.showPage) {
353
+ return changeData;
354
+ } else {
355
+ return this.delData.concat(changeData);
356
+ }
357
+ },
358
+ isChange() {
359
+ let data = this.getChangeData();
360
+ if (data.length > 0) {
361
+ return true;
362
+ }
363
+ return false;
364
+ },
365
+ setShowAddBtn(flag) {
366
+ this.showAddBtn = flag;
367
+ },
368
+ setShowDelBatchBtn(flag) {
369
+ this.showDelBatchBtn = flag;
370
+ },
371
+ setCustomColumn(column) {
372
+ //column.render= this.commonRendel;
373
+ column.slot = column.key;
374
+ },
375
+ addRowInfo(obj, column) {
376
+ let index = this.editIndex;
377
+ obj.rowinfo = {};
378
+ obj.rowinfo.column = column;
379
+ if (index === -1) {
380
+ index = this.oldEditIndex;
381
+ }
382
+ obj.rowinfo.index = index;
383
+ if (index > -1) {
384
+ obj.rowinfo.row = this.$Method.copy(this.data[index]);
385
+ }
386
+ let that = this;
387
+ obj.rowinfo.gridObject = that;
388
+ },
389
+ valueChanged(obj) {
390
+ const column = this.findColumnConfig(obj.name, this.myConfig.items);
391
+ this.addRowInfo(obj, column);
392
+ return column.valueChanged(obj);
393
+ },
394
+ onLinkTo(obj) {
395
+ if (this.myConfig.readOnly) {
396
+ const column = this.findColumnConfig(obj.name, this.myConfig.items);
397
+ this.addRowInfo(obj, column);
398
+ obj.rowinfo.index = obj.rowIndex;
399
+ if (obj.rowIndex > -1) {
400
+ obj.rowinfo.row = this.$Method.copy(this.data[obj.rowIndex]);
401
+ }
402
+ return column.onLinkTo(obj);
403
+ } else {
404
+ return;
405
+ }
406
+ },
407
+ searchBefore(that) {
408
+ const column = this.findColumnConfig(that.myConfig.name, this.myConfig.items);
409
+ this.addRowInfo(that, column);
410
+ return column.searchBefore(that);
411
+ },
412
+ setDataBefore(obj, that) {
413
+ const column = this.findColumnConfig(that.myConfig.name, this.myConfig.items);
414
+ let temp = {};
415
+ temp.data = obj;
416
+ temp.tabname = this.myConfig.name;
417
+ this.addRowInfo(temp, column);
418
+ return column.setDataBefore(temp, that);
419
+ },
420
+ cancelCellEditing() {
421
+ let name = 'cell_' + this.editIndex + '_' + this.editKey;
422
+ if (this.$refs[name] && this.$refs[name].setFocus) {
423
+ this.$refs[name].setFocus(false);
424
+ }
425
+ let self = this;
426
+ this.$nextTick(() => {
427
+ self.editKey = '';
428
+ self.oldEditIndex = this.editIndex;
429
+ self.editIndex = -1;
430
+ });
431
+ },
432
+ IsCellError(index, config) {
433
+ let error = '';
434
+ let row = this.$Method.copy(this.data[index]);
435
+ if (row.flag === 'D') {
436
+ error = 'efutre-del-row';
437
+ } else {
438
+ if (config.required === true) {
439
+ if (!row[config.name] && row[config.name] !== 0) {
440
+ let checkIndex = index;
441
+ if (this.myConfig.showPage) {
442
+ if (row.flag === 'I') {
443
+ checkIndex = this.getAddIndex(index, true);
444
+ if (this.checkAddInfo.length > checkIndex && this.checkAddInfo[checkIndex][config.key]) {
445
+ error = 'efuture-grid-cell-error';
446
+ }
447
+ } else {
448
+ checkIndex = checkIndex + (this.myConfig.pageConfig.page_no - 1) * this.myConfig.pageConfig.page_size;
449
+ if (this.checkInfo.length > checkIndex && this.checkInfo[checkIndex][config.key]) {
450
+ error = 'efuture-grid-cell-error';
451
+ }
452
+ }
453
+ } else {
454
+ if (this.checkInfo.length > checkIndex && this.checkInfo[checkIndex][config.key]) {
455
+ error = 'efuture-grid-cell-error';
456
+ }
457
+ }
458
+ }
459
+ }
460
+ }
461
+ if (!error) {
462
+ error = 'efuture-grid-cell';
463
+ }
464
+ return error;
465
+ },
466
+ EditCell(index, config) {
467
+ //this.setEditGridFocus(index, config.key);
468
+ if (this.myConfig.readOnly) {
469
+ this.cancelCellEditing();
470
+ return;
471
+ }
472
+ if (config.readOnly) {
473
+ this.cancelCellEditing();
474
+ return;
475
+ }
476
+ let row = this.getCurRow(index);
477
+ if (this.myConfig.showPage) {
478
+ if (row.flag === 'D') {
479
+ return;
480
+ }
481
+ }
482
+ if (this.editIndex === index && this.editKey === config.key) {
483
+ return;
484
+ }
485
+ if (this.myConfig.cellbeginedit) {
486
+ let rowinfo = {};
487
+ rowinfo.index = index;
488
+ rowinfo.column = config;
489
+ rowinfo.tabname = this.myConfig.name;
490
+ rowinfo.row = row;
491
+ if (!this.myConfig.cellbeginedit(rowinfo)) {
492
+ this.cancelCellEditing();
493
+ return;
494
+ } else {
495
+ this.editIndex = index;
496
+ this.editKey = config.key;
497
+ }
498
+ this.setcheckInfo(index, config.key);
499
+ } else {
500
+ this.editIndex = index;
501
+ this.editKey = config.key;
502
+ this.setcheckInfo(index, config.key);
503
+ }
504
+ },
505
+ // 设置焦点位置
506
+ setEditGridFocus(rowIdx, colKey) {
507
+ this.focusIndex = rowIdx;
508
+ this.focusKey = colKey;
509
+ this.editIndex = rowIdx;
510
+ this.editKey = colKey;
511
+ this.focusCell(rowIdx, colKey);
512
+ },
513
+ // 设置键盘选中单元格样式
514
+ focusCell(rowIdx, colKey) {
515
+ this.$nextTick(() => {
516
+ const tableEl = this.$refs.table.$el;
517
+ const selector = `div[cell-row="${rowIdx}"][cell-col="${colKey}"]`;
518
+ let curElement = tableEl.querySelector(selector);
519
+ if(curElement) {
520
+ const arr = tableEl.querySelectorAll('.ivu-table-column-selected');
521
+ if(arr.length != 0) {
522
+ arr.forEach(el => {
523
+ el.classList.remove('ivu-table-column-selected');
524
+ })
525
+ }
526
+
527
+ const cellDiv = curElement.closest('td');
528
+ if (cellDiv) {
529
+ cellDiv.classList.add('ivu-table-column-selected');
530
+ cellDiv.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
531
+ }
532
+ }
533
+ });
534
+ },
535
+ // 键盘导航事件
536
+ handleKeydown(event) {
537
+ if (this.focusIndex === null || this.focusKey === null) return;
538
+ const colIdx = this.colKeys.findIndex(it => { return it == this.focusKey});
539
+
540
+ this.focusKey = this.colKeys[colIdx];
541
+ let newRow = this.focusIndex;
542
+ let newCol = colIdx;
543
+
544
+ let name = 'cell_' + this.editIndex + '_' + this.editKey;
545
+ const { key } = event;
546
+
547
+ if(key == 'ArrowUp') {
548
+ if (this.focusIndex > 0) newRow--;
549
+ this.extEditStatus();
550
+ }
551
+ if(key == 'ArrowDown') {
552
+ if (this.focusIndex < this.data.length - 1) newRow++;
553
+ this.extEditStatus();
554
+ }
555
+ if(key == 'ArrowLeft') {
556
+ if (colIdx > 1) newCol--;
557
+ this.extEditStatus();
558
+ }
559
+ if(key == 'ArrowRight') {
560
+ if (colIdx < this.colKeys.length - 1) newCol++;
561
+ this.extEditStatus();
562
+ }
563
+
564
+ if(key == 'Enter') {
565
+ if (colIdx < this.colKeys.length - 1) newCol++;
566
+ }
567
+
568
+ this.setEditGridFocus(newRow, this.colKeys[newCol]);
569
+ if(!this.myConfig.readOnly) {
570
+ // 解决键盘按下input框的值不修改问题
571
+ if (this.$refs[name] && this.$refs[name].autofocus) {
572
+ return true;
573
+ }
574
+ } else {
575
+ this.handleOut();
576
+ }
577
+ event.preventDefault();
578
+ },
579
+ extEditStatus() {
580
+ if(!this.myConfig.readOnly) {
581
+ //this.handleOut();
582
+ let name = 'cell_' + this.editIndex + '_' + this.editKey;
583
+ if (this.$refs[name] && this.$refs[name].setFocus) {
584
+ this.$refs[name].setFocus(false);
585
+ }
586
+ let self = this;
587
+ this.$nextTick(() => {
588
+ self.editKey = '';
589
+ self.oldEditIndex = this.editIndex;
590
+ //self.editIndex = -1;
591
+ });
592
+ }
593
+ },
594
+ setcheckInfo(index, key) {
595
+ let checkIndex = index;
596
+ let row = this.getCurRow(index);
597
+ if (this.myConfig.showPage) {
598
+ checkIndex = checkIndex + (this.myConfig.pageConfig.page_no - 1) * this.myConfig.pageConfig.page_size;
599
+ if (row.flag === 'I') {
600
+ this.setCheckCommonInfo(this.checkAddInfo, this.getAddIndex(index, true), key);
601
+ } else {
602
+ this.setCheckCommonInfo(this.checkInfo, checkIndex, key);
603
+ }
604
+ } else {
605
+ this.setCheckCommonInfo(this.checkInfo, checkIndex, key);
606
+ }
607
+ },
608
+ setCheckCommonInfo(data, index, key) {
609
+ if (data.length > index) {
610
+ this.checkInfo[index][key] = true;
611
+ } else {
612
+ let curNum = data.length;
613
+ for (let i = 0; i < index - curNum + 1; i++) {
614
+ data.push({});
615
+ }
616
+ }
617
+ data[index][key] = true;
618
+ },
619
+ formatValue(index, column) {
620
+ let value = '';
621
+ let row = this.$Method.copy(this.data[index]);
622
+ if (column.name) {
623
+ value = row[column.name];
624
+ }
625
+ let config = column;
626
+ if (column.updateCellConfig) {
627
+ let rowinfo = {};
628
+ rowinfo.index = index;
629
+ rowinfo.column = column;
630
+ rowinfo.row = this.$Method.copy(this.data[index]);
631
+ config = column.updateCellConfig(rowinfo);
632
+ }
633
+ let valueFormat = this.$Method.formatValue(value, row, config);
634
+ let obj = {};
635
+ obj.value = value;
636
+ obj.row = row;
637
+ obj.config = config;
638
+ obj.valueFormat = valueFormat;
639
+ if (column.formatValue) {
640
+ return column.formatValue(obj);
641
+ } else if (this.myConfig.formatValue) {
642
+ return this.myConfig.formatValue(obj);
643
+ } else {
644
+ return valueFormat;
645
+ }
646
+ },
647
+ getCellConfig(index, config) {
648
+ const column = this.findColumnConfig(config.name, this.myConfig.items);
649
+ if (column.updateCellConfig) {
650
+ let rowinfo = {};
651
+ rowinfo.index = index;
652
+ rowinfo.column = config;
653
+ rowinfo.row = this.$Method.copy(this.data[index]);
654
+ let newConfig = column.updateCellConfig(rowinfo);
655
+ newConfig.onOpenChange = this.onOpenChange;
656
+ newConfig.place = 'grid';
657
+ return newConfig;
658
+ } else {
659
+ config.onOpenChange = this.onOpenChange;
660
+ config.place = 'grid';
661
+ return config;
662
+ }
663
+ },
664
+ onOpenChange(value) {
665
+ this.openChange = value;
666
+ },
667
+ getCurRow(index) {
668
+ return this.$Method.copy(this.data[index]);
669
+ },
670
+ handleOut() {
671
+ if (this.editKey) {
672
+ if (!this.openChange) {
673
+ // 去除编辑状态
674
+ this.cancelCellEditing();
675
+ }
676
+ }
677
+ },
678
+ checkValidate() {
679
+ // check 去除编辑状态
680
+ this.cancelCellEditing();
681
+ let flag = false;
682
+ let data = this.getData();
683
+ if (data.length > 0) {
684
+ let keys = [];
685
+ this.soltTableColumns.some(el => {
686
+ if (el.name || el.sname) {
687
+ if (el.visible !== false && el.required === true) {
688
+ if (el.name) {
689
+ keys.push(el.name);
690
+ }
691
+ if (el.sname) {
692
+ keys.push(el.sname);
693
+ }
694
+ if (el.ename) {
695
+ keys.push(el.ename);
696
+ }
697
+ }
698
+ }
699
+ });
700
+ let addIndex = -1;
701
+ data.forEach((el, index) => {
702
+ if (el.flag === 'I') {
703
+ addIndex++;
704
+ }
705
+ if (el.flag !== 'D') {
706
+ keys.forEach(key => {
707
+ if (!el[key] && el[key] !== 0) {
708
+ if (!flag) flag = true;
709
+ if (this.myConfig.showPage) {
710
+ if (el.flag === 'I') {
711
+ this.setCheckCommonInfo(this.checkAddInfo, addIndex, key);
712
+ } else {
713
+ this.setCheckCommonInfo(this.checkInfo, index, key);
714
+ }
715
+ } else {
716
+ this.setCheckCommonInfo(this.checkInfo, index, key);
717
+ }
718
+
719
+ }
720
+ });
721
+ }
722
+ });
723
+ }
724
+ return flag;
725
+ },
726
+ setShowBtn(value) {
727
+ this.showBtn = value;
728
+ },
729
+ doAction(obj) {
730
+ if (this[obj.name]) {
731
+ this[obj.name](obj);
732
+ }
733
+ },
734
+ enterKeyDown() {
735
+ let nextKey = this.findNextItems(this.editIndex, this.editKey);
736
+ if (nextKey) {
737
+ this.editIndex = nextKey.editIndex;
738
+ this.editKey = nextKey.editKey;
739
+ this.setcheckInfo(nextKey.editIndex, nextKey.editKey);
740
+ //this.setEditGridFocus(this.editIndex, this.editKey);
741
+ }
742
+ },
743
+ findNextItems(editIndex, editName) {
744
+ let index = this.soltTableColumns.findIndex(el => {
745
+ return el.name === editName || el.sname === editName;
746
+ });
747
+ let nextIndex = index + 1;
748
+ if (index > -1) {
749
+ if (nextIndex >= this.soltTableColumns.length) {
750
+ if (editIndex + 1 >= this.data.length) {
751
+ editIndex = this.findNextRow(0);
752
+ nextIndex = 0;
753
+ if (this.soltTableColumns[0].type === 'selection' || this.soltTableColumns[0].type === 'index') {
754
+ nextIndex++;
755
+ }
756
+ if (this.soltTableColumns[1].type === 'index') {
757
+ nextIndex++;
758
+ }
759
+ } else {
760
+ let temp = editIndex + 1;
761
+ editIndex = this.findNextRow(temp);
762
+ nextIndex = 0;
763
+ if (this.soltTableColumns[0].type === 'selection' || this.soltTableColumns[0].type === 'index') {
764
+ nextIndex++;
765
+ }
766
+ if (this.soltTableColumns[1].type === 'index') {
767
+ nextIndex++;
768
+ }
769
+ }
770
+ }
771
+ } else {
772
+ return null;
773
+ }
774
+ let column = this.soltTableColumns[nextIndex];
775
+ let config = this.getCellConfig(editIndex, column);
776
+ let name = config.name;
777
+ if (config.sname) {
778
+ name = config.sname;
779
+ }
780
+ if (config.readOnly === true || config.visible === false || config.type === 'PictureBox' || config.type === 'VideoBox' || config.type === 'RichTextBox' || config.type === 'wRichTextBox'|| config.type === 'selection' || config.type === 'index') {
781
+ return this.findNextItems(editIndex, name);
782
+ } else {
783
+ if (this.myConfig.cellbeginedit) {
784
+ let rowinfo = {};
785
+ rowinfo.index = editIndex;
786
+ rowinfo.column = config;
787
+ rowinfo.tabname = this.myConfig.name;
788
+ rowinfo.row = this.$Method.copy(this.data[editIndex]);
789
+ if (!this.myConfig.cellbeginedit(rowinfo)) {
790
+ return this.findNextItems(editIndex, name);
791
+ } else {
792
+ let nextKey = {};
793
+ nextKey.editIndex = editIndex;
794
+ nextKey.editKey = name;
795
+ return nextKey;
796
+ }
797
+ } else {
798
+ let nextKey = {};
799
+ nextKey.editIndex = editIndex;
800
+ nextKey.editKey = name;
801
+ return nextKey;
802
+ }
803
+ }
804
+ },
805
+ customIndexMethod(row, index) {
806
+ if (row.flag === 'I') {
807
+ return '+';
808
+ } else {
809
+ return index;
810
+ }
811
+ },
812
+ findNextRow(editIndex) {
813
+ let resultIndex = editIndex;
814
+ if (this.myConfig.showPage) {
815
+ this.data.some((el, index) => {
816
+ if (index >= editIndex) {
817
+ if (el.flag !== 'D') {
818
+ resultIndex = index;
819
+ return true;
820
+ }
821
+ }
822
+ });
823
+ }
824
+ return resultIndex;
825
+ },
826
+ rowClassName(row) {
827
+ if (row.flag === 'D') {
828
+ return 'efutre-del-row';
829
+ }
830
+ return '';
831
+ },
832
+ getCellClass(index) {
833
+ let row = this.getCurRow(index);
834
+ if (row && row.flag === 'D') {
835
+ return 'efutre-del-row';
836
+ } else {
837
+ return '';
838
+ }
839
+ },
840
+ changePageSize(pageSize) {
841
+ this.saveCurlData(this.myConfig.pageConfig.page_no, this.initData);
842
+ this.myConfig.pageConfig.page_no = 1;
843
+ this.data = this.fillData(this.myConfig.pageConfig.page_no, pageSize);
844
+ this.myConfig.pageConfig.page_size = pageSize;
845
+ this.cancelCellEditing();
846
+ },
847
+ changePage(page) {
848
+ this.saveCurlData(this.myConfig.pageConfig.page_no, this.initData);
849
+ this.data = this.fillData(page, this.myConfig.pageConfig.page_size);
850
+ this.myConfig.pageConfig.page_no = page;
851
+ this.cancelCellEditing();
852
+ },
853
+ customClearData() {
854
+ this.initScrollLeft();
855
+ },
856
+ saveCurlData(pageIndex, data) {
857
+ let addData = [];
858
+ this.data.forEach((el, index) => {
859
+ let curlIndex = (pageIndex - 1) * this.myConfig.pageConfig.page_size + index;
860
+ if (el.flag === 'U' || el.flag === 'D') {
861
+ data.splice(curlIndex, 1, el);
862
+ } else {
863
+ if (el.flag === 'I') {
864
+ addData.push(el);
865
+ }
866
+ }
867
+ });
868
+ this.addData = addData;
869
+ },
870
+ setData(data) {
871
+ if (!data) {
872
+ data = [];
873
+ }
874
+ if (this.myConfig.showPage) {
875
+ this.initData = this.$Method.copy(data);
876
+ this.myConfig.pageConfig.page_no = 1;
877
+ this.myConfig.pageConfig.total_results = data.length;
878
+ this.data = this.fillData(this.myConfig.pageConfig.page_no, this.myConfig.pageConfig.page_size);
879
+ } else {
880
+ this.data = data;
881
+ this.initData = this.$Method.copy(this.data);
882
+ }
883
+ this.addData = [];
884
+ this.delData = [];
885
+ this.checkInfo = [];
886
+ this.initScrollLeft();
887
+ this.cancelCellEditing();
888
+ },
889
+ fillData(pageIndex, pageSize) {
890
+ let arr = [];
891
+ let start = (pageIndex - 1) * pageSize,
892
+ end = start + pageSize;
893
+ if (end > this.myConfig.pageConfig.total_results) {
894
+ end = this.myConfig.pageConfig.total_results;
895
+ }
896
+ for (var i = start, l = end; i < l; i++) {
897
+ var record = this.initData[i];
898
+ if (!record)
899
+ continue;
900
+ arr.push(record);
901
+ }
902
+ this.addData.forEach(el => {
903
+ arr.push(el);
904
+ });
905
+ return arr;
906
+ },
907
+ getData() {
908
+ if (this.myConfig.showPage) {
909
+ let initData = this.$Method.copy(this.initData);
910
+ this.saveCurlData(this.myConfig.pageConfig.page_no, initData);
911
+ this.addData.forEach(el => {
912
+ initData.push(el);
913
+ });
914
+ return initData;
915
+ } else {
916
+ return this.$Method.copy(this.data);
917
+ }
918
+ },
919
+ remove(index, flag) {
920
+ let _index = index;
921
+ if (flag) {
922
+ let tempIndex = this.data.findIndex(item => item._customIndex === index);
923
+ if (tempIndex > -1) {
924
+ _index = tempIndex;
925
+ }
926
+ }
927
+ let data = this.getData();
928
+ if (_index > -1) {
929
+ if (data[_index].flag === undefined || data[_index].flag === 'U') {
930
+ let row = this.$Method.copy(data[_index]);
931
+ row.flag = 'D';
932
+ if (this.myConfig.showPage) {
933
+ let start = (this.myConfig.pageConfig.page_no - 1) * this.myConfig.pageConfig.page_size,
934
+ end = start + this.myConfig.pageConfig.page_size;
935
+ let curlIndex = _index;
936
+ if (index >= start && index < end) {
937
+ curlIndex = index - start;
938
+ this.data.splice(curlIndex, 1, row);
939
+ } else {
940
+ this.initData.splice(curlIndex, 1, row);
941
+ }
942
+ } else {
943
+ this.delData.push(row);
944
+ this.data.splice(_index, 1);
945
+ }
946
+ } else {
947
+ if (data[_index].flag === 'I') {
948
+ if (this.myConfig.showPage) {
949
+ let addIndex = this.getAddIndex(_index);
950
+ if (addIndex > -1) {
951
+ this.checkAddInfo.splice(addIndex, 1);
952
+ this.data.splice(this.getAddCurlIndex(addIndex), 1);
953
+ }
954
+ } else {
955
+ this.data.splice(_index, 1);
956
+ this.checkInfo.splice(_index, 1);
957
+ }
958
+ }
959
+ }
960
+ }
961
+ this.initScrollLeft();
962
+ },
963
+ getAddIndex(index, flag) {
964
+ let addIndex = -1;
965
+ let data = [];
966
+ if (flag) {
967
+ data = this.data;
968
+ } else {
969
+ data = this.getData();
970
+ }
971
+ data.some((el, culIndex) => {
972
+ if (el.flag === 'I') {
973
+ addIndex++;
974
+ }
975
+ if (culIndex === index) {
976
+ return true;
977
+ }
978
+ });
979
+ return addIndex;
980
+ },
981
+ getAddCurlIndex(index) {
982
+ let addIndex = -1;
983
+ let result = -1;
984
+ this.data.some((el, culIndex) => {
985
+ if (el.flag === 'I') {
986
+ addIndex++;
987
+ }
988
+ if (addIndex === index) {
989
+ result = culIndex;
990
+ return true;
991
+ }
992
+ });
993
+ return result;
994
+ },
995
+ setSummary(config,data,sums) {
996
+ if (config.children) {
997
+ config.children.forEach(el => {
998
+ this.setSummary(el,data.sums);
999
+ });
1000
+ } else {
1001
+ const key = config.key;
1002
+ if(config.summary) {
1003
+ const values = data.map(item => Number(item[key]));
1004
+ if (!values.every(value => isNaN(value))) {
1005
+ const v = values.reduce((prev, curr) => {
1006
+ const value = Number(curr);
1007
+ if (!isNaN(value)) {
1008
+ return prev + curr;
1009
+ } else {
1010
+ return prev;
1011
+ }
1012
+ }, 0);
1013
+ sums[key] = {
1014
+ key,
1015
+ value: this.$Method.formatNumber(v, config.format, config.notzero),
1016
+ countValue:v
1017
+ };
1018
+ } else {
1019
+ sums[key] = {
1020
+ key,
1021
+ value: 'N/A'
1022
+ };
1023
+ }
1024
+ } else {
1025
+ sums[key] = {
1026
+ key,
1027
+ value: ''
1028
+ };
1029
+ }
1030
+ }
1031
+ },
1032
+ handleSummary({ columns ,data}) {
1033
+ const sums = {};
1034
+ columns.forEach(column => {
1035
+ this.setSummary(column,data,sums);
1036
+ });
1037
+ let firstkey = this.findFirst(columns);
1038
+ sums[firstkey] = {key:firstkey,value:this.myConfig.sumText};
1039
+ if (this.myConfig.customSummary){
1040
+ return this.myConfig.customSummary(sums);
1041
+ } else {
1042
+ return sums;
1043
+ }
1044
+ },
1045
+ findFirst(columns) {
1046
+ let key = '';
1047
+ columns.some(el => {
1048
+ if (el.key !== 'selection' && el.key !== 'index') {
1049
+ key = el.name;
1050
+ return true;
1051
+ }
1052
+ });
1053
+ return key;
1054
+ },
1055
+ },
1056
+ };
1057
+ </script>
1058
+ <style lang="less">
1059
+ .ivu-table-column-selected, .active-cell{
1060
+ box-shadow: inset 0 0 0 2px #AF292E;
1061
+ }
1062
+ </style>