ocpview-plus 0.0.1

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