ocpview-plus 1.3.14 → 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,1286 +1,1286 @@
1
- <script>
2
- import { deepCopy } from '../../utils/assist';
3
- import Base from './basegrid.vue';
4
- import elementResizeDetectorMaker from 'element-resize-detector';
5
- import {gzip} from 'pako';
6
- export default {
7
- name: 'viewgridbase',
8
- extends: Base,
9
- data () {
10
- return {
11
- myConfig:{
12
- resources:'',
13
- method:'',
14
- response:'',
15
- searchParam:null,
16
- readOnly:true,
17
- multiSelect:true,
18
- bindSearchParam:'ph_key',
19
- showAll:false,
20
- exportMethod:'exportExcel',
21
- separator:'::',
22
- exportType:'2',
23
- overrideData:'',
24
- headStyle:'padding-bottom: 10px;padding-top: 10px;',
25
- multiSelectGrid:false,
26
- multiGridCol:11,
27
- multiGridTitle:'已选择',
28
- gridTitle:'待选择',
29
- highLightRow:true,
30
- dynamicColumnFlag:false,
31
- dynameicColumnConfig: {
32
- groupColumns:[],
33
- dynameicColumnName:'',
34
- dynameicColumnValue:'',
35
- dynameicColumnValueTitle:'',
36
- dynameicColumnValuePro:{},
37
- dynameicColumnSumLable:'动态合计'
38
- }
39
- },
40
- multiGridCol:11,
41
- gridCol:11,
42
- editRowFlag:false,
43
- singleData:{},
44
- searchBeforeSearchParam:{},
45
- order_field:'',
46
- order_direction:'',
47
- rightActive:false,
48
- leftActive:false,
49
- multiSelectData:[],
50
- multiTableColumns:[],
51
- dynamicColumnItems:[],
52
- tempMultiSelectData:[],
53
- multiSoltTableColumns:[],
54
- showHelpBtn:false
55
- };
56
- },
57
- computed:{
58
- makeTableColumns() {
59
- if (this.myConfig.dynamicColumnFlag) {
60
- return [];
61
- } else {
62
- return this.initColumn();
63
- }
64
- }
65
- },
66
- methods: {
67
- customInit() {
68
- if (this.isPop) {
69
- if (!this.myConfig.showCheckBox) {
70
- if (this.myConfig.multiSelect) {
71
- this.myConfig.showCheckBox = true;
72
- }
73
- }
74
- if (this.myConfig.multiGridCol) {
75
- this.multiGridCol = Number(this.myConfig.multiGridCol);
76
- this.gridCol = 24 - 2 - this.multiGridCol;
77
- }
78
- this.myConfig.tableSize = 'small';
79
- this.myConfig.headStyle = '';
80
- this.myConfig.showBorder = false;
81
- this.myConfig.headStyle = '';
82
- this.myConfig.pageSize = 'small';
83
- if (this.myConfig.height === undefined) {
84
- this.myConfig.height = 360;
85
- }
86
- if (!this.myConfig.pageSizeNum) {
87
- this.myConfig.pageConfig.page_size = 50;
88
- }
89
- }
90
-
91
- if (this.myConfig.pageSizeNum) {
92
- this.myConfig.pageConfig.page_size = Number(this.myConfig.pageSizeNum);
93
- }
94
- this.myConfig.items.forEach(el => {
95
- if (el.resizable === undefined) {
96
- el.resizable = true;
97
- }
98
- if (!el.width && !el.minWidth) {
99
- el.minWidth = 60;
100
- }
101
- });
102
- if (this.myConfig.multiSelectGrid) {
103
- this.multiTableColumns = this.multiInitColumn();
104
- }
105
- if (this.myConfig.gridType === 'billGrid') {
106
- this.getModuleMethod();
107
- }
108
- if (this.myConfig.dynamicColumnFlag) {
109
- this.myConfig.showPage = false;
110
- }
111
- let self = this;
112
- this.curHelpUrl = this.OmdUrl.getCurHelpUrl(self);
113
- if (this.curHelpUrl) {
114
- this.showHelpBtn = true;
115
- } else {
116
- this.showHelpBtn = false;
117
- }
118
- },
119
- conditionAction(temp) {
120
- let data = [];
121
- switch (temp.action) {
122
- case 'condition_search' :
123
- if (temp.para) {
124
- this.conditionSearchParam = this.$Method.copy(temp.para);
125
- }
126
- this.refurbish();
127
- break;
128
- case 'condition_clear' :
129
- this.conditionSearchParam = {};
130
- break;
131
- case 'condition_ok' :
132
- if (this.myConfig.multiSelect) {
133
- data = this.getSelection();
134
- } else {
135
- if (this.singleData.currentRow) {
136
- data.push(this.singleData.currentRow);
137
- }
138
- }
139
- if (data.length === 0) {
140
- this.alert('请选择');
141
- } else {
142
- temp.rows = data;
143
- this.$emit('conditionAction',temp);
144
- }
145
- break;
146
- case 'condition_cancel' :
147
- this.$emit('conditionAction',temp);
148
- break;
149
- }
150
- },
151
- getSearchParam(obj, flag) {
152
- let searchParam =Object.assign({},this.myConfig.searchParam,this.searchBeforeSearchParam);
153
- if (!searchParam) {
154
- searchParam = {};
155
- }
156
- if (this.myConfig.response === 'report') {
157
- searchParam = Object.assign({},searchParam,this.conditionSearchParam);
158
- } else {
159
- let tempSearchParam = {};
160
- for (let el in searchParam) {
161
- if (this.conditionSearchParam[el]) {
162
- tempSearchParam[el]={'$and':[]};
163
- let temp = {};
164
- temp[el] = searchParam[el];
165
- tempSearchParam[el]['$and'].push(temp);
166
- let temp2 = {};
167
- temp2[el] = this.conditionSearchParam[el];
168
- tempSearchParam[el]['$and'].push(temp2);
169
- }
170
- }
171
- searchParam = Object.assign({},searchParam,this.conditionSearchParam);
172
- for (let el in tempSearchParam) {
173
- searchParam['$and'] = this.$Method.copy(tempSearchParam[el]['$and']);
174
- delete searchParam[el];
175
- }
176
- }
177
-
178
- if (this.myConfig.showPage) {
179
- if (!flag) {
180
- this.myConfig.pageConfig.page_no = 1;
181
- searchParam.page_no = 1;
182
- this.culPage = 1;
183
- } else {
184
- if (this.myConfig.pageConfig.page_no) {
185
- searchParam.page_no = this.myConfig.pageConfig.page_no;
186
- } else {
187
- searchParam.page_no = 1;
188
- }
189
- }
190
- searchParam.page_size = this.myConfig.pageConfig.page_size;
191
- }
192
- if (this.order_field) {
193
- searchParam.order_field = this.order_field;
194
- if (this.order_direction) {
195
- searchParam.order_direction = this.order_direction;
196
- }
197
- }
198
- if (obj) {
199
- searchParam =Object.assign({},searchParam,obj);
200
- }
201
- if (!this.myConfig.dynamicColumnFlag) {
202
- if (this.summaryColumn && this.summaryColumn.length > 0) {
203
- searchParam.summary_fld = this.summaryColumn.join(',');
204
- }
205
- }
206
- if (this.myConfig.showSumGroup) {
207
- searchParam.sumgroups = this.myConfig.sumgroups;
208
- }
209
- if (this.myConfig.overrideSearchParam) {
210
- return this.myConfig.overrideSearchParam(searchParam);
211
- } else {
212
- return searchParam;
213
- }
214
-
215
- },
216
- setWhereParam(obj) {
217
- this.conditionSearchParam = this.$Method.copy(obj);
218
- },
219
- refurbish(obj,flag) {
220
- this.loading = true;
221
- let self = this;
222
- this.singleData = {};
223
- self.data = [];
224
- self.asyncPost(self.myConfig.resources,self.myConfig.method,self.getSearchParam(obj,flag),function(data) {
225
- self.dynamicInitData = data;
226
- if (self.myConfig.dynamicColumnFlag) {
227
- self.makeDynamicColumn();
228
- } else {
229
- self.refurbishSucceedDefault();
230
- }
231
- self.loading = false;
232
- },function(e) {
233
- self.loading = false;
234
- self.$nextTick(() => {
235
- setTimeout(() => {
236
- self.alert(e, null, 2);
237
- }, 1000);
238
- });
239
- });
240
- },
241
- changePage (para) {
242
- let old = this.myConfig.pageConfig.page_no;
243
- if (this.myConfig.refurbishCheck) {
244
- this.myConfig.refurbishCheck(para,old,this.callBackChangePage);
245
- } else {
246
- this.myConfig.pageConfig.page_no = para;
247
- this.refurbish(null, true);
248
- }
249
-
250
- },
251
- refurbishSucceedDefault () {
252
- this.sumGroupNum = 0;
253
- if (this.dynamicInitData && this.dynamicInitData[this.myConfig.response]) {
254
- if (this.myConfig.showAll) {
255
- if (this.myConfig.rowAll) {
256
- this.dynamicInitData[this.myConfig.response].splice(0,0,this.myConfig.rowAll);
257
- }
258
- }
259
- let data = [];
260
- if (this.myConfig.overrideData) {
261
- data = this.myConfig.overrideData(this.dynamicInitData[this.myConfig.response]);
262
- } else {
263
- data = this.dynamicInitData[this.myConfig.response];
264
- }
265
- if (this.dynamicInitData.sumgroups) {
266
- data = this.doSumgroups(data, this.dynamicInitData.sumgroups);
267
- }
268
- this.data = data;
269
- this.tempData = this.$Method.copy(data);
270
- }
271
- if (this.dynamicInitData.total_results !== undefined) {
272
- this.myConfig.pageConfig.total_results= Number(this.dynamicInitData.total_results);
273
- }
274
- if (this.dynamicInitData.total_summary !== undefined) {
275
- this.total_summary = Object.assign({}, {}, this.dynamicInitData.total_summary);
276
- if (!this.myConfig.showSummary) {
277
- Object.assign(this.myConfig,{'showSummary':true});
278
- }
279
- } else {
280
- if (this.myConfig.showSummary) {
281
- Object.assign(this.myConfig,{'showSummary':false});
282
- }
283
- }
284
- },
285
- callBackChangePage(flag ,newvalue, oldvale) {
286
- if (!flag) {
287
- this.$nextTick(() => {
288
- this.myConfig.pageConfig.page_no = oldvale;
289
- this.myConfig.showPage = false;
290
- this.myConfig = Object.assign({},this.myConfig);
291
- this.$nextTick(() => {
292
- this.myConfig.showPage = true;
293
- this.myConfig = Object.assign({},this.myConfig);
294
- });
295
- });
296
- } else {
297
- this.myConfig.pageConfig.page_no = newvalue;
298
- this.refurbish(null,true);
299
- }
300
- },
301
- callBackChangePageSize(flag ,newvalue, oldvale) {
302
- if (!flag) {
303
- this.$nextTick(() => {
304
- this.myConfig.pageConfig.page_size = oldvale;
305
- this.myConfig.showPage = false;
306
- this.myConfig = Object.assign({},this.myConfig);
307
- this.$nextTick(() => {
308
- this.myConfig.showPage = true;
309
- this.myConfig = Object.assign({},this.myConfig);
310
- });
311
- });
312
- } else {
313
- this.myConfig.pageConfig.page_size = newvalue;
314
- this.refurbish(null,true);
315
- }
316
- },
317
- changePageSize (para) {
318
- let old = this.myConfig.pageConfig.page_size;
319
- if (this.myConfig.refurbishCheck) {
320
- this.myConfig.refurbishCheck(para,old,this.callBackChangePageSize);
321
- } else {
322
- this.myConfig.pageConfig.page_size = para;
323
- if (this.data && this.data.length > 0) {
324
- this.refurbish(null, true);
325
- }
326
- }
327
- },
328
- sortChagne (para) {
329
- this.order_field = '';
330
- this.order_direction = '';
331
- let tempField = [];
332
- let tempDirection = [];
333
- /*
334
- 沿用老版本,丢弃searchParam中的
335
- if (this.config.searchParam) {
336
- if (this.config.searchParam.order_field) {
337
- tempField = this.config.searchParam.order_field.split(',');
338
- if (this.config.searchParam.order_direction) {
339
- tempDirection = this.config.searchParam.order_direction.split(',');
340
- let tempDirectionNum = tempDirection.length;
341
- for (let i=tempDirectionNum;i<tempField.length;i++) {
342
- tempDirection.push('asc');
343
- }
344
- } else {
345
- for (let i=0;i<tempField.length;i++) {
346
- tempDirection.push('asc');
347
- }
348
- }
349
- }
350
- }*/
351
- if (para.order !== 'normal') {
352
- let index = tempField.findIndex(el => el === para.key);
353
- if (index > -1) {
354
- tempDirection.splice(index, 1, para.order);
355
- } else {
356
- tempField.push(para.key);
357
- tempDirection.push(para.order);
358
- }
359
- }
360
- if (tempField.length > 0) {
361
- this.order_field = tempField.join();
362
- this.order_direction = tempDirection.join();
363
- }
364
-
365
- if (this.data && this.data.length > 0) {
366
- this.refurbish();
367
- }
368
- },
369
- onCurrentChange(currentRow,oldCurrentRow) {
370
- this.singleData = {};
371
- this.singleData.currentRow= currentRow;
372
- this.singleData.oldCurrentRow= oldCurrentRow;
373
- if (this.myConfig.onSingleChange) {
374
- this.myConfig.onSingleChange();
375
- }
376
- if (this.myConfig.showCheckBox) {
377
- if (this.myConfig.onSetRowCheck) {
378
- this.myConfig.onSetRowCheck(currentRow._customIndex,true);
379
- } else {
380
- this.setRowCheck(currentRow._customIndex,true);
381
- }
382
- }
383
-
384
- },
385
- onSelect(rows,curRow) {
386
- if (this.myConfig.onSelect) {
387
- this.myConfig.onSelect(rows,curRow);
388
- }
389
- },
390
- onSelectCancel(rows,curRow) {
391
- if (this.myConfig.onSelectCancel) {
392
- this.myConfig.onSelectCancel(rows,curRow);
393
- }
394
- },
395
- OnSelectionChange(row) {
396
- this.$nextTick(() => {
397
- if (this.myConfig.onSelectionChange) {
398
- this.myConfig.onSelectionChange(row);
399
- }
400
- if (row && row.length > 0) {
401
- this.leftActive = true;
402
- } else {
403
- this.leftActive = false;
404
- }
405
- let data = this.$Method.copy(this.data);
406
- let flag = false;
407
- data.forEach((el,index) => {
408
- flag = false;
409
- row.forEach(el2 => {
410
- if (index === el2._customIndex) {
411
- flag = true;
412
- return true;
413
- }
414
- });
415
- el._checked = flag;
416
- })
417
- this.data = data;
418
- this.tempData = this.$Method.copy(data);
419
- /*if (this.data.length === row.length) {
420
- if (!this.isAll) {
421
- this.$refs.table.selectAll(true);
422
- this.isAll = true;
423
- } else {
424
- this.isAll = false;
425
- }
426
- }*/
427
- });
428
- },
429
- OnMultiSelectionChange (row) {
430
- this.$nextTick(() => {
431
- let data = this.$Method.copy(this.tempMultiSelectData);
432
- let flag = false;
433
- data.forEach((el,index) => {
434
- flag = false;
435
- row.forEach(el2 => {
436
- if (index === el2._customIndex) {
437
- flag = true;
438
- return true;
439
- }
440
- });
441
- el._checked = flag;
442
- })
443
- this.tempMultiSelectData = data;
444
- if (row && row.length > 0) {
445
- this.rightActive = true;
446
- } else {
447
- this.rightActive = false;
448
- }
449
- });
450
- },
451
- removeRow(index) {
452
- this.data.splice(index, 1);
453
- },
454
- doBatchAction(obj) {
455
- if (obj.name !== 'addData') {
456
- let data = this.getSelection();
457
- if (data.length === 0) {
458
- this.alert('请至少选择一行');
459
- return;
460
- }
461
- obj.data= data;
462
- }
463
- this.$emit('doAction', obj);
464
- },
465
- add() {
466
- let obj = {};
467
- obj.name ='addData';
468
- this.$emit('doAction', obj);
469
- },
470
- setSearchBeforeSearchParam(obj) {
471
- this.searchBeforeSearchParam = Object.assign({},{},obj);
472
- },
473
- clearSearchBeforeSearchParam() {
474
- this.searchBeforeSearchParam = {};
475
- },
476
- popValueChanged (para) {
477
- let reData = [];
478
- let self = this;
479
- let searchParam = Object.assign({},self.getSearchParam(),para);
480
- self.synchroPost(self.myConfig.resources,self.myConfig.method,searchParam,function(data) {
481
- if (data && data[self.myConfig.response]) {
482
- reData = data[self.myConfig.response];
483
- }
484
- },null);
485
- return reData;
486
- },
487
- getTotalCount() {
488
- let total_results = '';
489
- if (this.myConfig.pageConfig.total_results !== undefined) {
490
- total_results = this.myConfig.pageConfig.total_results;
491
- }
492
- return total_results;
493
- },
494
- export(asyncExport,afterFun) {
495
- if(this.data.length == 0){
496
- this.alert('请先查询数据');
497
- return;
498
- }
499
- let _param = this.getSearchParam();
500
- if (this.OmdUrl.maxRowNum) {
501
- _param.maxrownum = this.OmdUrl.maxRowNum;
502
- }
503
-
504
- if (this.OmdUrl.maxDataNum) {
505
- _param.maxdatanum = this.OmdUrl.maxDataNum;
506
- }
507
- let modulecode = this.getModulecode();
508
- if (modulecode) {
509
- _param.modulecode = modulecode;
510
- }
511
- let dict = {};
512
- dict.dictdata = {};
513
- _param.fields =this.$Method.getGridField(this.myConfig.items,this.myConfig.separator,this.dictData, dict.dictdata);
514
- if (!_param.fields) {
515
- _param.fields = '';
516
- }
517
- // 添加总数
518
- let totalCount = this.getTotalCount();
519
- if (totalCount) {
520
- _param.fields += ',totalCount'+ this.myConfig.separator + totalCount;
521
- }
522
- // 添加模块号
523
- if (modulecode) {
524
- _param.fields += ',modulecode'+ this.myConfig.separator + modulecode;
525
- }
526
- let exportMethod = this.myConfig.exportMethod;
527
- if (asyncExport) {
528
- exportMethod = 'asyncExport';
529
- }
530
- let _baseUrl = this.myConfig.resources.replace('rest', exportMethod);
531
- let _self = this;
532
- const encodedArray =this.zip(JSON.stringify(dict.dictdata));
533
- _param.dictdata = encodeURIComponent(encodedArray);
534
- if (asyncExport) {
535
- this.asyncExport(_baseUrl,this.myConfig.method,_param,afterFun);
536
- } else {
537
- this.doExportExcel(_baseUrl, this.myConfig.method, _param,this.myConfig.exportType, _self);
538
- }
539
- },
540
- zip (str) {
541
- let binaryString = gzip(str, { to: 'string' });
542
- return btoa(binaryString);
543
- },
544
- asyncExport(_baseUrl,method, _param,afterFun) {
545
- let self = this;
546
- self.synchroPost(_baseUrl,method,_param,function(data) {
547
- if (data.flag === '1') {
548
- if (afterFun) {
549
- afterFun();
550
- } else {
551
- this.alert('文件正在生成,请稍后');
552
- }
553
- }
554
- },null);
555
- },
556
- initAsynExportConfig(columns,headname,newColumns) {
557
- for (let i = 0; i < columns.length; i++) {
558
- let column = this.$Method.copy(columns[i]);
559
- if (column.visible !== false && column.isExport !== false) {
560
- if (column.name) {
561
- column.label = headname + column.label;
562
- newColumns.push(column);
563
- }
564
- if (column.children) {
565
- let culhead = headname + '(' + column.label + ')';
566
- this.initAsynExportConfig(column.children,culhead,newColumns);
567
- }
568
- }
569
- }
570
- },
571
- setRowHighlight(index , flag) {
572
- if (index > -1) {
573
- let newRow = Object.assign({},this.data[index],{});
574
- newRow._highlight = flag;
575
- this.$nextTick(() => {
576
- this.data.splice(index,1,newRow);
577
- this.tempData.splice(index,1,newRow);
578
- if (!this.myConfig.multiSelect) {
579
- this.singleData.currentRow = this.$Method.copy(this.data[index]);
580
- }
581
- });
582
- }
583
- },
584
- getSelection() {
585
- if (this.myConfig.multiSelect === false) {
586
- if (this.singleData.currentRow) {
587
- return [this.singleData.currentRow];
588
- } else {
589
- return [];
590
- }
591
- } else {
592
- if (this.myConfig.multiSelectGrid) {
593
- return this.$Method.copy(this.multiSelectData);
594
- } else {
595
- return this.$refs.table.getSelection();
596
- }
597
- }
598
- },
599
- setSelection(data) {
600
- if (this.myConfig.multiSelectGrid) {
601
- this.multiSelectData = [];
602
- this.$nextTick(() => {
603
- this.multiSelectData = data;
604
- this.tempMultiSelectData = this.$Method.copy(this.multiSelectData);
605
- });
606
- }
607
- },
608
- moveToLeft() {
609
- let data = this.$refs.multiSelectTable.getSelection();
610
- if (data && data.length > 0) {
611
- data.forEach(el => {
612
- let index = this.multiSelectData.findIndex(el2 => el2[this.myConfig.responseId] === el[this.myConfig.responseId]);
613
- if (index > -1) {
614
- this.multiSelectData.splice(index, 1);
615
- }
616
- });
617
- }
618
- this.tempMultiSelectData = this.$Method.copy(this.multiSelectData);
619
- this.rightActive = false;
620
- },
621
- moveToRight() {
622
- let data = this.$refs.table.getSelection();
623
- if (data && data.length > 0) {
624
- data.forEach(el => {
625
- if (this.myConfig.multiCheck) {
626
- if (this.myConfig.multiCheck(this.multiSelectData, el)) {
627
- delete el._customIndex;
628
- delete el._checked;
629
- this.multiSelectData.push(el);
630
- }
631
- } else {
632
- let index = this.multiSelectData.findIndex(el2 => el2[this.myConfig.responseId] === el[this.myConfig.responseId]);
633
- if (index === -1) {
634
- delete el._customIndex;
635
- delete el._checked;
636
- this.multiSelectData.push(el);
637
- }
638
- }
639
- });
640
- }
641
- this.tempMultiSelectData = this.$Method.copy(this.multiSelectData);
642
- },
643
- multiInitColumn () {
644
- let columns = [];
645
- let items = this.myConfig.items;
646
- if (this.myConfig.multiItems) {
647
- items = this.myConfig.multiItems;
648
- }
649
- if (!items || items.length === 0) {
650
- return columns;
651
- }
652
- this.initCheckColumn(columns);
653
- this.initMultiIndexColumn(columns);
654
- const length = items.length;
655
- for (let i = 0; i < length; i++) {
656
- if (items[i].visible !== false) {
657
- //this.setColumn(i);
658
- // 添加复杂列项的支持
659
- this.initCommonColumn(items[i],columns);
660
- }
661
- }
662
- this.initExpandColumn(columns);
663
- this.initOperColumn(columns);
664
- let multiSoltTableColumns = [];
665
- this.getSoltTableColumns(columns, multiSoltTableColumns);
666
- this.multiSoltTableColumns = multiSoltTableColumns;
667
- return columns;
668
- },
669
- customClearData() {
670
- this.multiSelectData = [];
671
- this.rightActive = false;
672
- this.leftActive = false;
673
- if (this.myConfig.dynamicColumnFlag) {
674
- this.tableColumns = [];
675
- this.soltTableColumns = [];
676
- this.newRow = {};
677
- this.total_summary = {};
678
- if (this.myConfig.showSummary) {
679
- Object.assign(this.myConfig,{'showSummary':false});
680
- }
681
- }
682
- },
683
- clearCondition() {
684
- if (this.$refs.condition && this.$refs.condition.clear) {
685
- this.$refs.condition.clear();
686
- }
687
- },
688
- clearCurrentRow() {
689
- if (this.$refs.table) {
690
- this.$refs.table.clearCurrentRow();
691
- }
692
- },
693
- delRow(index) {
694
- this.data.splice(index, 1);
695
- this.tempData = this.data;
696
- },
697
- updataRow(index,para) {
698
- let row = Object.assign({}, this.data[index], para);
699
- this.data.splice(index,1,row);
700
- this.tempData = this.data;
701
- },
702
- initMultiIndexColumn(columns) {
703
- let index = {};
704
- index.type = 'index';
705
- index.key = 'index';
706
- index.width = 45;
707
- index.title = '行号';
708
- index.align = 'center';
709
- columns.push(index);
710
- },
711
- makeDynamicColumn() {
712
- let initData = [];
713
- this.tableColumns = [];
714
- this.soltTableColumns = [];
715
- this.total_summary = {};
716
- if (this.dynamicInitData && this.dynamicInitData[this.myConfig.response]) {
717
- initData = this.$Method.copy(this.dynamicInitData[this.myConfig.response]);
718
- let groupColumns = [];
719
- groupColumns = this.$Method.copy(this.myConfig.dynameicColumnConfig.groupColumns);
720
-
721
- let dynameicColumnNames = [];
722
- if (this.myConfig.dynameicColumnConfig.dynameicColumnName) {
723
- dynameicColumnNames = this.myConfig.dynameicColumnConfig.dynameicColumnName.split(',');
724
- }
725
- let dynameicColumnValue = [];
726
- if (this.myConfig.dynameicColumnConfig.dynameicColumnValue) {
727
- dynameicColumnValue = this.myConfig.dynameicColumnConfig.dynameicColumnValue.split(',');
728
- }
729
- let dynameicColumnValueTitle = [];
730
- if (this.myConfig.dynameicColumnConfig.dynameicColumnValueTitle) {
731
- dynameicColumnValueTitle = this.myConfig.dynameicColumnConfig.dynameicColumnValueTitle.split(',');
732
- }
733
- let fatherTemp = [];
734
- dynameicColumnNames.forEach(el2 => {
735
- let tmp = {};
736
- tmp.name = el2;
737
- fatherTemp.push(tmp);
738
- });
739
- let obj = {};
740
- let endNodes = {};
741
- let num = 0;
742
- initData.forEach(el => {
743
- let groupId = '';
744
- groupColumns.forEach(el2 => {
745
- groupId = groupId + el[el2] + '-' ;
746
- });
747
- if (groupId) {
748
- groupId = groupId.substring(0,groupId.length - 1);
749
- }
750
- let dyId = '';
751
- let fatherId = '';
752
- dynameicColumnNames.forEach((el2,index) => {
753
- dyId = dyId + el[el2] + '-';
754
- if (!fatherTemp[index][el[el2]]) {
755
- fatherTemp[index][el[el2]] = {};
756
- fatherTemp[index][el[el2]].fatherId = fatherId;
757
- fatherTemp[index][el[el2]].label=el[el2];
758
- }
759
- fatherId = el[el2];
760
- if (index === dynameicColumnNames.length -1) {
761
- fatherTemp[index][el[el2]].id = dyId.substring(0,dyId.length - 1);
762
- }
763
- });
764
- if (dyId) {
765
- dyId = dyId.substring(0,dyId.length - 1);
766
- }
767
-
768
- if (!obj[groupId]) {
769
- obj[groupId] = {};
770
- obj[groupId].data = {};
771
- groupColumns.forEach(el2 => {
772
- obj[groupId].data[el2] = el[el2];
773
- });
774
- obj[groupId].columns = {};
775
- }
776
- if (!obj[groupId].columns[dyId]) {
777
- if (dynameicColumnValue.length > 1) {
778
- obj[groupId].columns[dyId] = {};
779
- dynameicColumnValue.forEach(elv => {
780
- obj[groupId].columns[dyId][elv] = el[elv];
781
- });
782
- } else {
783
- obj[groupId].columns[dyId] = el[this.myConfig.dynameicColumnConfig.dynameicColumnValue];
784
- }
785
- }
786
- if (!endNodes[dyId]) {
787
- endNodes[dyId] = {};
788
- endNodes[dyId].name = 'dy_col_' + num;
789
- if (dynameicColumnValue.length > 1) {
790
- endNodes[dyId].sum = {};
791
- dynameicColumnValue.forEach(elv => {
792
- endNodes[dyId].sum[elv] = el[elv];
793
- });
794
- } else {
795
- endNodes[dyId].sum = 0;
796
- }
797
- num++;
798
- }
799
- if (dynameicColumnValue.length > 1) {
800
- dynameicColumnValue.forEach(elv => {
801
- endNodes[dyId].sum[elv] = Number(endNodes[dyId].sum[elv]) + Number(el[elv]) ;
802
- });
803
- } else {
804
- endNodes[dyId].sum = Number(endNodes[dyId].sum)+ Number(el[this.myConfig.dynameicColumnConfig.dynameicColumnValue]);
805
- }
806
- });
807
- let data = [];
808
- for (let pro in obj) {
809
- let tempData = {};
810
- Object.assign(tempData, obj[pro].data);
811
- let dynamic_sum = 0;
812
- for (let pro2 in endNodes) {
813
- if (dynameicColumnValue.length > 1) {
814
- if (obj[pro].columns[pro2] !== undefined) {
815
- dynameicColumnValue.forEach(el => {
816
- let tmpname = endNodes[pro2].name + '_' +el;
817
- tempData[tmpname] = obj[pro].columns[pro2][el];
818
- dynamic_sum = dynamic_sum + Number(tempData[tmpname]);
819
- });
820
- } else {
821
- dynameicColumnValue.forEach(el => {
822
- let tmpname = endNodes[pro2].name + '_' +el;
823
- tempData[tmpname] = 0;
824
- dynamic_sum = dynamic_sum + Number(tempData[tmpname]);
825
- });
826
- }
827
- } else {
828
- if (obj[pro].columns[pro2] !== undefined) {
829
- tempData[endNodes[pro2].name] = obj[pro].columns[pro2];
830
- dynamic_sum = dynamic_sum + Number(tempData[endNodes[pro2].name]);
831
- } else {
832
- tempData[endNodes[pro2].name] = 0;
833
- dynamic_sum = dynamic_sum + Number(tempData[endNodes[pro2].name]);
834
- }
835
- }
836
- }
837
- tempData.dynamic_sum = dynamic_sum;
838
- data.push(tempData);
839
- }
840
-
841
- let columnsList = [];
842
- this.makeDynamicColumnConfig(fatherTemp, 0, '', columnsList, endNodes,dynameicColumnValue,dynameicColumnValueTitle);
843
-
844
- let temp = {};
845
- if (this.myConfig.dynameicColumnConfig.dynameicColumnSumLable) {
846
- temp.label = this.myConfig.dynameicColumnConfig.dynameicColumnSumLable;
847
- } else {
848
- temp.label = '动态合计';
849
- }
850
- temp.type='NumberBox';
851
- temp.contentAlign = 'right';
852
- temp.summary = true;
853
- temp.name = 'dynamic_sum';
854
- let width = this.$Method.getTextWidth(temp.label);
855
- temp.width = width;
856
- Object.assign(temp, this.myConfig.dynameicColumnConfig.dynameicColumnValuePro);
857
- columnsList.push(temp);
858
- let tableColumns = this.myConfig.items.concat(columnsList);
859
- this.dynamicColumnConfig = this.$Method.copy(tableColumns);
860
- this.initDynamicColumn(tableColumns);
861
- let total_summary = {};
862
- let dynamic_sum = 0;
863
- for (let pro in endNodes) {
864
- if (dynameicColumnValue.length > 1) {
865
- dynameicColumnValue.forEach(el => {
866
- let tmpName =endNodes[pro].name + '_' + el;
867
- total_summary[tmpName] = endNodes[pro].sum[el];
868
- dynamic_sum = dynamic_sum + Number(endNodes[pro].sum[el]);
869
- });
870
- } else {
871
- total_summary[endNodes[pro].name] = endNodes[pro].sum;
872
- dynamic_sum = dynamic_sum + Number(endNodes[pro].sum);
873
- }
874
- }
875
- total_summary.dynamic_sum = dynamic_sum;
876
-
877
- let summaryColumn = [];
878
- this.summaryColumn.forEach(el => {
879
- if (total_summary[el] === undefined) {
880
- summaryColumn.push(el);
881
- }
882
- });
883
- if (summaryColumn.length > 0) {
884
- data.forEach(el => {
885
- summaryColumn.forEach(el2 => {
886
- if (!total_summary[el2]) {
887
- total_summary[el2] = 0;
888
- }
889
- total_summary[el2] = total_summary[el2] + Number(el[el2]);
890
- });
891
- });
892
- }
893
- this.data = data;
894
- this.tempData = this.$Method.copy(data);
895
- this.total_summary = Object.assign({}, {}, total_summary);
896
- if (!this.myConfig.showSummary) {
897
- Object.assign(this.myConfig,{'showSummary':true});
898
- }
899
- } else {
900
- if (this.myConfig.showSummary) {
901
- Object.assign(this.myConfig,{'showSummary':false});
902
- }
903
- }
904
- },
905
- initDynamicColumn(tableColumns) {
906
- let newRow = {};
907
- let summaryColumn = [];
908
- let columns = [];
909
- this.initCheckColumn(columns);
910
- this.initOperColumn(columns);
911
- this.initIndexColumn(columns);
912
- const length = tableColumns.length;
913
- for (let i = 0; i < length; i++) {
914
- if (tableColumns[i].visible !== false) {
915
- //this.setColumn(i);
916
- // 添加复杂列项的支持
917
- this.initCommonColumn(tableColumns[i],columns,summaryColumn,newRow);
918
- } else {
919
- if (tableColumns[i].defaultValue !== undefined) {
920
- if (tableColumns[i].name) {
921
- newRow[tableColumns[i].name] = tableColumns[i].defaultValue;
922
- }
923
- if (tableColumns[i].sname) {
924
- newRow[tableColumns[i].sname] = tableColumns[i].defaultValue;
925
- }
926
- if (tableColumns[i].ename) {
927
- newRow[tableColumns[i].ename] = tableColumns[i].defaultValue;
928
- }
929
- }
930
- }
931
- }
932
- this.total_summary = {};
933
- this.newRow = deepCopy(newRow);
934
- summaryColumn.push('dynamic_sum');
935
- this.summaryColumn = deepCopy(summaryColumn);
936
- this.tableColumns = deepCopy(columns);
937
- let soltTableColumns = [];
938
- this.getSoltTableColumns(columns,soltTableColumns);
939
- this.soltTableColumns = soltTableColumns;
940
- this.dynamicColumnItems = tableColumns;
941
- },
942
- makeDynamicColumnConfig (fatherTemp, index, id, items, endNodes,dynameicColumnValue,dynameicColumnValueTitle) {
943
- let fahter = fatherTemp[index];
944
- if (index === fatherTemp.length -1) {
945
- for (let pro in fahter) {
946
- if (pro === 'name') {
947
- continue;
948
- }
949
- let temp = {};
950
- temp.label = fahter[pro].label;
951
- if (dynameicColumnValue.length > 1) {
952
- temp.align = 'center';
953
- temp.children = [];
954
- dynameicColumnValue.forEach((el,index) => {
955
- let temp2 = {};
956
- temp2.type='NumberBox';
957
- temp2.align = 'center';
958
- temp2.contentAlign = 'right';
959
- temp2.summary = true;
960
- Object.assign(temp2, this.myConfig.dynameicColumnConfig.dynameicColumnValuePro);
961
- temp2.label = dynameicColumnValueTitle[index];
962
- let width = this.$Method.getTextWidth(temp2.label);
963
- temp2.width = width;
964
- temp2.name = endNodes[fahter[pro].id].name + '_' + el;
965
- temp.children.push(temp2);
966
- });
967
- } else {
968
- temp.type='NumberBox';
969
- temp.align = 'center';
970
- temp.contentAlign = 'right';
971
- temp.summary = true;
972
- let width = this.$Method.getTextWidth(temp.label);
973
- temp.width = width;
974
- if (endNodes[fahter[pro].id]) {
975
- temp.name = endNodes[fahter[pro].id].name;
976
- }
977
- Object.assign(temp, this.myConfig.dynameicColumnConfig.dynameicColumnValuePro);
978
- }
979
-
980
- if (id) {
981
- if (fahter[pro].fatherId === id) {
982
- items.push(temp);
983
- items.sort((a, b) => {
984
- return a > b;
985
- });
986
- }
987
- } else {
988
- items.push(temp);
989
- items.sort((a, b) => {
990
- return a > b;
991
- });
992
- }
993
- }
994
-
995
- } else {
996
- for (let pro in fahter) {
997
- if (pro === 'name') {
998
- continue;
999
- }
1000
- let temp = {};
1001
- temp.label = fahter[pro].label;
1002
- temp.align = 'center';
1003
- if (id) {
1004
- if (fahter[pro].fatherId === id) {
1005
- temp.children = [];
1006
- this.makeDynamicColumnConfig(fatherTemp, index+1, pro, temp.children, endNodes,dynameicColumnValue,dynameicColumnValueTitle);
1007
- items.push(temp);
1008
- items.sort((a, b) => {
1009
- return a > b;
1010
- });
1011
- }
1012
- } else {
1013
- temp.children = [];
1014
- this.makeDynamicColumnConfig(fatherTemp, index+1, pro, temp.children, endNodes,dynameicColumnValue,dynameicColumnValueTitle);
1015
- items.push(temp);
1016
- items.sort((a, b) => {
1017
- return a > b;
1018
- });
1019
- }
1020
-
1021
- }
1022
-
1023
- }
1024
- },
1025
- handleSummary({ columns }) {
1026
- let sums = {};
1027
- for (let tmp in this.newRow) {
1028
- sums[tmp]={key:tmp,value:''};
1029
- }
1030
- let index = columns.findIndex(el => el.type === 'index');
1031
- if (index > -1) {
1032
- sums.index = {key:'index',value:''};
1033
- }
1034
- let index2 = columns.findIndex(el => el.type === 'selection');
1035
- if (index2 > -1) {
1036
- sums.selection = {key:'selection',value:''};
1037
- }
1038
- let items = [];
1039
- if (this.myConfig.dynamicColumnFlag) {
1040
- items = this.dynamicColumnItems;
1041
- } else {
1042
- items = this.config.items;
1043
- }
1044
- for (let pro in this.total_summary) {
1045
- let configItems = {};
1046
- this.findItemByName(items, pro, configItems);
1047
- if (configItems.name) {
1048
- let tmpValue = this.total_summary[pro];
1049
- if (configItems.format !== undefined) {
1050
- tmpValue = this.$Method.formatNumber(tmpValue,configItems.format,configItems.notzero);
1051
- }
1052
- sums[pro]={key:pro,value:tmpValue};
1053
- }
1054
- }
1055
- let firstkey = this.findFirst(columns);
1056
- sums[firstkey] = {key:firstkey,value:this.myConfig.sumText};
1057
- if (this.myConfig.customSummary){
1058
- return this.myConfig.customSummary(sums);
1059
- } else {
1060
- return sums;
1061
- }
1062
- },
1063
- findFirst(columns) {
1064
- let key = '';
1065
- columns.some(el => {
1066
- if (el.key !== 'selection' && el.key !== 'index' && el.key !== 'sumindex') {
1067
- key = el.name;
1068
- return true;
1069
- }
1070
- });
1071
- return key;
1072
- },
1073
- findItemByName(items, name, config) {
1074
- if (items instanceof Array) {
1075
- let flag = false;
1076
- items.some(el => {
1077
- if (el.children && el.children.length > 0) {
1078
- flag = this.findItemByName(el.children, name, config);
1079
- if (flag) {
1080
- return true;
1081
- }
1082
- } else {
1083
- if (el.name) {
1084
- if (el.name === name) {
1085
- Object.assign(config, el);
1086
- flag = true;
1087
- return true;
1088
- }
1089
- }
1090
- }
1091
- });
1092
- return flag;
1093
- } else {
1094
- if (items.name) {
1095
- if (items.name === name) {
1096
- Object.assign(config, items);
1097
- return true;
1098
- }
1099
- }
1100
- }
1101
- return false;
1102
- },
1103
- dynamicExportExcel() {
1104
- let dynameicColumnNames = [];
1105
- if (this.myConfig.dynameicColumnConfig.dynameicColumnName) {
1106
- dynameicColumnNames = this.myConfig.dynameicColumnConfig.dynameicColumnName.split(',');
1107
- }
1108
- let headNum = dynameicColumnNames.length;
1109
- let modulecode = this.$Method.getUrlParam('modulecode');
1110
- if (!modulecode) {
1111
- modulecode = this.$Method.getUrlParam('billmoduleid');
1112
- }
1113
- let fileName = this.$Method.formatDate(new Date(),'yyyyMMddhhmmss') +'(合计' + this.data.length+'条).xlsx';
1114
- if (modulecode) {
1115
- fileName = modulecode + '_' + fileName;
1116
- }
1117
- let tmpData = this.$Method.copy(this.data);
1118
- this.dynamicColumnConfig.forEach(el => {
1119
- if (el.type === 'ComboBox') {
1120
- let valueField = 'code';
1121
- let textField = 'name'
1122
- if (el.valueField) {
1123
- valueField = column.valueField;
1124
- }
1125
- if (el.textField) {
1126
- textField = column.textField;
1127
- }
1128
- tmpData.forEach(el2 => {
1129
- if (el2[el.name]) {
1130
- if (el.data) {
1131
- let index = el.data.findIndex(el3 => el3[valueField] === el2[el.name]);
1132
- if (index > -1) {
1133
- if (el.codeWithName === false) {
1134
- el2[el.name] = el.data[index][textField];
1135
- } else {
1136
- el2[el.name] = '[' + el.data[index][valueField] + ']' + el.data[index][textField];
1137
- }
1138
- }
1139
- }
1140
- }
1141
- });
1142
- }
1143
- });
1144
- let newConfig = [];
1145
- this.initAsynExportConfig(this.dynamicColumnConfig,'',newConfig);
1146
- this.$Method.exportExcelStyle(newConfig,tmpData,headNum,fileName);
1147
- },
1148
- formatValue(index, column) {
1149
- let value = '';
1150
- let row = this.$Method.copy(this.tempData[index]);
1151
- if (column.name) {
1152
- value = row[column.name];
1153
- }
1154
- let config = column;
1155
- let valueFormat = this.$Method.formatValue(value, row, config);
1156
- let obj = {};
1157
- obj.value = value;
1158
- obj.row = row;
1159
- obj.config = config;
1160
- obj.valueFormat = valueFormat;
1161
- if (column.formatValue) {
1162
- return column.formatValue(obj);
1163
- } else if (this.myConfig.formatValue) {
1164
- return this.myConfig.formatValue(obj);
1165
- } else {
1166
- return valueFormat;
1167
- }
1168
- },
1169
- formatMulValue(index, column) {
1170
- let value = '';
1171
- let row = this.$Method.copy(this.tempMultiSelectData[index]);
1172
- if (column.name) {
1173
- value = row[column.name];
1174
- }
1175
- let config = column;
1176
- return this.$Method.formatValue(value, row, config);
1177
- },
1178
- setCustomColumn(column) {
1179
- column.slot = column.key;
1180
- },
1181
- onLinkTo(obj) {
1182
- const column = this.findColumnConfig (obj.name,this.myConfig.items);
1183
- this.addRowInfo(obj, column);
1184
- return column.onLinkTo(obj);
1185
- },
1186
- addRowInfo(obj, column) {
1187
- let index = obj.rowIndex;
1188
- obj.rowinfo = {};
1189
- obj.rowinfo.column = column;
1190
- obj.rowinfo.index = index;
1191
- if (index > -1) {
1192
- obj.rowinfo.row = this.data[index];
1193
- }
1194
- let that = this;
1195
- obj.rowinfo.gridObject = that;
1196
- },
1197
- doSumgroups(data,Sumgroups) {
1198
- let tmp = [];
1199
- Sumgroups.forEach(el => {
1200
- if (el.data && el.data.length > 0) {
1201
- let groupstr = el.group.split(',');
1202
- let culkey='';
1203
- let key = '';
1204
- data.forEach((el2,index) => {
1205
- key = '';
1206
- groupstr.forEach(el3 => {
1207
- key = key + el2[el3];
1208
- });
1209
- if (!culkey) {
1210
- culkey = key;
1211
- }
1212
- if (culkey !== key) {
1213
- let sumdata = el.data.find(el4 => {
1214
- let key2 = '';
1215
- groupstr.forEach(el5 => {
1216
- key2 = key2 + el4[el5];
1217
- });
1218
- return key2 === culkey;
1219
- });
1220
- let tmpObj = {};
1221
- tmpObj.index = index;
1222
- tmpObj.sum = sumdata;
1223
- if (el.showgroup) {
1224
- let showgroup = el.showgroup.split(',');
1225
- tmpObj.showgroup = showgroup;
1226
- }
1227
- tmpObj.group = groupstr;
1228
- tmp.push(tmpObj);
1229
- culkey = key;
1230
- }
1231
- });
1232
- }
1233
- });
1234
- if (tmp.length > 0) {
1235
- let tmpData = [];
1236
- data.forEach((el,index) => {
1237
- let sumindex = index + 1;
1238
- if (this.myConfig.showPage) {
1239
- sumindex = sumindex + (this.myConfig.pageConfig.page_no - 1) * this.myConfig.pageConfig.page_size;
1240
- }
1241
- el.sumindex = sumindex + '';
1242
- let tmpObj = tmp.find(el2 => el2.index === index);
1243
- if (tmpObj) {
1244
- if (this.myConfig.customSummaryGroup){
1245
- tmpObj = this.myConfig.customSummaryGroup(tmpObj);
1246
- }
1247
- if (tmpObj.showgroup) {
1248
- tmpObj.group.forEach(el2 => {
1249
- let tmpIndex = tmpObj.showgroup.findIndex(el3 => el2 === el3);
1250
- if (tmpIndex === -1) {
1251
- tmpObj.sum[el2] = '';
1252
- }
1253
- });
1254
- }
1255
- tmpObj.sum.sumindex = '';
1256
- tmpData.push(tmpObj.sum);
1257
- tmpData.push(el);
1258
- } else {
1259
- tmpData.push(el);
1260
- }
1261
- });
1262
- return tmpData;
1263
- } else {
1264
- return data;
1265
- }
1266
- }
1267
- },
1268
- mounted () {
1269
- this.observer = elementResizeDetectorMaker();
1270
- if (this.$refs.head) {
1271
- this.observer.listenTo(this.$refs.head, this.setExtraHeight);
1272
- }
1273
- if (this.$refs.page) {
1274
- this.observer.listenTo(this.$refs.page, this.setExtraHeight);
1275
- }
1276
- },
1277
- beforeUnmount() {
1278
- if (this.$refs.head) {
1279
- this.observer.removeListener(this.$refs.head, this.setExtraHeight);
1280
- }
1281
- if (this.$refs.page) {
1282
- this.observer.removeListener(this.$refs.page, this.setExtraHeight);
1283
- }
1284
- }
1285
- };
1286
- </script>
1
+ <script>
2
+ import { deepCopy } from '../../utils/assist';
3
+ import Base from './basegrid.vue';
4
+ import elementResizeDetectorMaker from 'element-resize-detector';
5
+ import {gzip} from 'pako';
6
+ export default {
7
+ name: 'viewgridbase',
8
+ extends: Base,
9
+ data () {
10
+ return {
11
+ myConfig:{
12
+ resources:'',
13
+ method:'',
14
+ response:'',
15
+ searchParam:null,
16
+ readOnly:true,
17
+ multiSelect:true,
18
+ bindSearchParam:'ph_key',
19
+ showAll:false,
20
+ exportMethod:'exportExcel',
21
+ separator:'::',
22
+ exportType:'2',
23
+ overrideData:'',
24
+ headStyle:'padding-bottom: 10px;padding-top: 10px;',
25
+ multiSelectGrid:false,
26
+ multiGridCol:11,
27
+ multiGridTitle:'已选择',
28
+ gridTitle:'待选择',
29
+ highLightRow:true,
30
+ dynamicColumnFlag:false,
31
+ dynameicColumnConfig: {
32
+ groupColumns:[],
33
+ dynameicColumnName:'',
34
+ dynameicColumnValue:'',
35
+ dynameicColumnValueTitle:'',
36
+ dynameicColumnValuePro:{},
37
+ dynameicColumnSumLable:'动态合计'
38
+ }
39
+ },
40
+ multiGridCol:11,
41
+ gridCol:11,
42
+ editRowFlag:false,
43
+ singleData:{},
44
+ searchBeforeSearchParam:{},
45
+ order_field:'',
46
+ order_direction:'',
47
+ rightActive:false,
48
+ leftActive:false,
49
+ multiSelectData:[],
50
+ multiTableColumns:[],
51
+ dynamicColumnItems:[],
52
+ tempMultiSelectData:[],
53
+ multiSoltTableColumns:[],
54
+ showHelpBtn:false
55
+ };
56
+ },
57
+ computed:{
58
+ makeTableColumns() {
59
+ if (this.myConfig.dynamicColumnFlag) {
60
+ return [];
61
+ } else {
62
+ return this.initColumn();
63
+ }
64
+ }
65
+ },
66
+ methods: {
67
+ customInit() {
68
+ if (this.isPop) {
69
+ if (!this.myConfig.showCheckBox) {
70
+ if (this.myConfig.multiSelect) {
71
+ this.myConfig.showCheckBox = true;
72
+ }
73
+ }
74
+ if (this.myConfig.multiGridCol) {
75
+ this.multiGridCol = Number(this.myConfig.multiGridCol);
76
+ this.gridCol = 24 - 2 - this.multiGridCol;
77
+ }
78
+ this.myConfig.tableSize = 'small';
79
+ this.myConfig.headStyle = '';
80
+ this.myConfig.showBorder = false;
81
+ this.myConfig.headStyle = '';
82
+ this.myConfig.pageSize = 'small';
83
+ if (this.myConfig.height === undefined) {
84
+ this.myConfig.height = 360;
85
+ }
86
+ if (!this.myConfig.pageSizeNum) {
87
+ this.myConfig.pageConfig.page_size = 50;
88
+ }
89
+ }
90
+
91
+ if (this.myConfig.pageSizeNum) {
92
+ this.myConfig.pageConfig.page_size = Number(this.myConfig.pageSizeNum);
93
+ }
94
+ this.myConfig.items.forEach(el => {
95
+ if (el.resizable === undefined) {
96
+ el.resizable = true;
97
+ }
98
+ if (!el.width && !el.minWidth) {
99
+ el.minWidth = 60;
100
+ }
101
+ });
102
+ if (this.myConfig.multiSelectGrid) {
103
+ this.multiTableColumns = this.multiInitColumn();
104
+ }
105
+ if (this.myConfig.gridType === 'billGrid') {
106
+ this.getModuleMethod();
107
+ }
108
+ if (this.myConfig.dynamicColumnFlag) {
109
+ this.myConfig.showPage = false;
110
+ }
111
+ let self = this;
112
+ this.curHelpUrl = this.OmdUrl.getCurHelpUrl(self);
113
+ if (this.curHelpUrl) {
114
+ this.showHelpBtn = true;
115
+ } else {
116
+ this.showHelpBtn = false;
117
+ }
118
+ },
119
+ conditionAction(temp) {
120
+ let data = [];
121
+ switch (temp.action) {
122
+ case 'condition_search' :
123
+ if (temp.para) {
124
+ this.conditionSearchParam = this.$Method.copy(temp.para);
125
+ }
126
+ this.refurbish();
127
+ break;
128
+ case 'condition_clear' :
129
+ this.conditionSearchParam = {};
130
+ break;
131
+ case 'condition_ok' :
132
+ if (this.myConfig.multiSelect) {
133
+ data = this.getSelection();
134
+ } else {
135
+ if (this.singleData.currentRow) {
136
+ data.push(this.singleData.currentRow);
137
+ }
138
+ }
139
+ if (data.length === 0) {
140
+ this.alert('请选择');
141
+ } else {
142
+ temp.rows = data;
143
+ this.$emit('conditionAction',temp);
144
+ }
145
+ break;
146
+ case 'condition_cancel' :
147
+ this.$emit('conditionAction',temp);
148
+ break;
149
+ }
150
+ },
151
+ getSearchParam(obj, flag) {
152
+ let searchParam =Object.assign({},this.myConfig.searchParam,this.searchBeforeSearchParam);
153
+ if (!searchParam) {
154
+ searchParam = {};
155
+ }
156
+ if (this.myConfig.response === 'report') {
157
+ searchParam = Object.assign({},searchParam,this.conditionSearchParam);
158
+ } else {
159
+ let tempSearchParam = {};
160
+ for (let el in searchParam) {
161
+ if (this.conditionSearchParam[el]) {
162
+ tempSearchParam[el]={'$and':[]};
163
+ let temp = {};
164
+ temp[el] = searchParam[el];
165
+ tempSearchParam[el]['$and'].push(temp);
166
+ let temp2 = {};
167
+ temp2[el] = this.conditionSearchParam[el];
168
+ tempSearchParam[el]['$and'].push(temp2);
169
+ }
170
+ }
171
+ searchParam = Object.assign({},searchParam,this.conditionSearchParam);
172
+ for (let el in tempSearchParam) {
173
+ searchParam['$and'] = this.$Method.copy(tempSearchParam[el]['$and']);
174
+ delete searchParam[el];
175
+ }
176
+ }
177
+
178
+ if (this.myConfig.showPage) {
179
+ if (!flag) {
180
+ this.myConfig.pageConfig.page_no = 1;
181
+ searchParam.page_no = 1;
182
+ this.culPage = 1;
183
+ } else {
184
+ if (this.myConfig.pageConfig.page_no) {
185
+ searchParam.page_no = this.myConfig.pageConfig.page_no;
186
+ } else {
187
+ searchParam.page_no = 1;
188
+ }
189
+ }
190
+ searchParam.page_size = this.myConfig.pageConfig.page_size;
191
+ }
192
+ if (this.order_field) {
193
+ searchParam.order_field = this.order_field;
194
+ if (this.order_direction) {
195
+ searchParam.order_direction = this.order_direction;
196
+ }
197
+ }
198
+ if (obj) {
199
+ searchParam =Object.assign({},searchParam,obj);
200
+ }
201
+ if (!this.myConfig.dynamicColumnFlag) {
202
+ if (this.summaryColumn && this.summaryColumn.length > 0) {
203
+ searchParam.summary_fld = this.summaryColumn.join(',');
204
+ }
205
+ }
206
+ if (this.myConfig.showSumGroup) {
207
+ searchParam.sumgroups = this.myConfig.sumgroups;
208
+ }
209
+ if (this.myConfig.overrideSearchParam) {
210
+ return this.myConfig.overrideSearchParam(searchParam);
211
+ } else {
212
+ return searchParam;
213
+ }
214
+
215
+ },
216
+ setWhereParam(obj) {
217
+ this.conditionSearchParam = this.$Method.copy(obj);
218
+ },
219
+ refurbish(obj,flag) {
220
+ this.loading = true;
221
+ let self = this;
222
+ this.singleData = {};
223
+ self.data = [];
224
+ self.asyncPost(self.myConfig.resources,self.myConfig.method,self.getSearchParam(obj,flag),function(data) {
225
+ self.dynamicInitData = data;
226
+ if (self.myConfig.dynamicColumnFlag) {
227
+ self.makeDynamicColumn();
228
+ } else {
229
+ self.refurbishSucceedDefault();
230
+ }
231
+ self.loading = false;
232
+ },function(e) {
233
+ self.loading = false;
234
+ self.$nextTick(() => {
235
+ setTimeout(() => {
236
+ self.alert(e, null, 2);
237
+ }, 1000);
238
+ });
239
+ });
240
+ },
241
+ changePage (para) {
242
+ let old = this.myConfig.pageConfig.page_no;
243
+ if (this.myConfig.refurbishCheck) {
244
+ this.myConfig.refurbishCheck(para,old,this.callBackChangePage);
245
+ } else {
246
+ this.myConfig.pageConfig.page_no = para;
247
+ this.refurbish(null, true);
248
+ }
249
+
250
+ },
251
+ refurbishSucceedDefault () {
252
+ this.sumGroupNum = 0;
253
+ if (this.dynamicInitData && this.dynamicInitData[this.myConfig.response]) {
254
+ if (this.myConfig.showAll) {
255
+ if (this.myConfig.rowAll) {
256
+ this.dynamicInitData[this.myConfig.response].splice(0,0,this.myConfig.rowAll);
257
+ }
258
+ }
259
+ let data = [];
260
+ if (this.myConfig.overrideData) {
261
+ data = this.myConfig.overrideData(this.dynamicInitData[this.myConfig.response]);
262
+ } else {
263
+ data = this.dynamicInitData[this.myConfig.response];
264
+ }
265
+ if (this.dynamicInitData.sumgroups) {
266
+ data = this.doSumgroups(data, this.dynamicInitData.sumgroups);
267
+ }
268
+ this.data = data;
269
+ this.tempData = this.$Method.copy(data);
270
+ }
271
+ if (this.dynamicInitData.total_results !== undefined) {
272
+ this.myConfig.pageConfig.total_results= Number(this.dynamicInitData.total_results);
273
+ }
274
+ if (this.dynamicInitData.total_summary !== undefined) {
275
+ this.total_summary = Object.assign({}, {}, this.dynamicInitData.total_summary);
276
+ if (!this.myConfig.showSummary) {
277
+ Object.assign(this.myConfig,{'showSummary':true});
278
+ }
279
+ } else {
280
+ if (this.myConfig.showSummary) {
281
+ Object.assign(this.myConfig,{'showSummary':false});
282
+ }
283
+ }
284
+ },
285
+ callBackChangePage(flag ,newvalue, oldvale) {
286
+ if (!flag) {
287
+ this.$nextTick(() => {
288
+ this.myConfig.pageConfig.page_no = oldvale;
289
+ this.myConfig.showPage = false;
290
+ this.myConfig = Object.assign({},this.myConfig);
291
+ this.$nextTick(() => {
292
+ this.myConfig.showPage = true;
293
+ this.myConfig = Object.assign({},this.myConfig);
294
+ });
295
+ });
296
+ } else {
297
+ this.myConfig.pageConfig.page_no = newvalue;
298
+ this.refurbish(null,true);
299
+ }
300
+ },
301
+ callBackChangePageSize(flag ,newvalue, oldvale) {
302
+ if (!flag) {
303
+ this.$nextTick(() => {
304
+ this.myConfig.pageConfig.page_size = oldvale;
305
+ this.myConfig.showPage = false;
306
+ this.myConfig = Object.assign({},this.myConfig);
307
+ this.$nextTick(() => {
308
+ this.myConfig.showPage = true;
309
+ this.myConfig = Object.assign({},this.myConfig);
310
+ });
311
+ });
312
+ } else {
313
+ this.myConfig.pageConfig.page_size = newvalue;
314
+ this.refurbish(null,true);
315
+ }
316
+ },
317
+ changePageSize (para) {
318
+ let old = this.myConfig.pageConfig.page_size;
319
+ if (this.myConfig.refurbishCheck) {
320
+ this.myConfig.refurbishCheck(para,old,this.callBackChangePageSize);
321
+ } else {
322
+ this.myConfig.pageConfig.page_size = para;
323
+ if (this.data && this.data.length > 0) {
324
+ this.refurbish(null, true);
325
+ }
326
+ }
327
+ },
328
+ sortChagne (para) {
329
+ this.order_field = '';
330
+ this.order_direction = '';
331
+ let tempField = [];
332
+ let tempDirection = [];
333
+ /*
334
+ 沿用老版本,丢弃searchParam中的
335
+ if (this.config.searchParam) {
336
+ if (this.config.searchParam.order_field) {
337
+ tempField = this.config.searchParam.order_field.split(',');
338
+ if (this.config.searchParam.order_direction) {
339
+ tempDirection = this.config.searchParam.order_direction.split(',');
340
+ let tempDirectionNum = tempDirection.length;
341
+ for (let i=tempDirectionNum;i<tempField.length;i++) {
342
+ tempDirection.push('asc');
343
+ }
344
+ } else {
345
+ for (let i=0;i<tempField.length;i++) {
346
+ tempDirection.push('asc');
347
+ }
348
+ }
349
+ }
350
+ }*/
351
+ if (para.order !== 'normal') {
352
+ let index = tempField.findIndex(el => el === para.key);
353
+ if (index > -1) {
354
+ tempDirection.splice(index, 1, para.order);
355
+ } else {
356
+ tempField.push(para.key);
357
+ tempDirection.push(para.order);
358
+ }
359
+ }
360
+ if (tempField.length > 0) {
361
+ this.order_field = tempField.join();
362
+ this.order_direction = tempDirection.join();
363
+ }
364
+
365
+ if (this.data && this.data.length > 0) {
366
+ this.refurbish();
367
+ }
368
+ },
369
+ onCurrentChange(currentRow,oldCurrentRow) {
370
+ this.singleData = {};
371
+ this.singleData.currentRow= currentRow;
372
+ this.singleData.oldCurrentRow= oldCurrentRow;
373
+ if (this.myConfig.onSingleChange) {
374
+ this.myConfig.onSingleChange();
375
+ }
376
+ if (this.myConfig.showCheckBox) {
377
+ if (this.myConfig.onSetRowCheck) {
378
+ this.myConfig.onSetRowCheck(currentRow._customIndex,true);
379
+ } else {
380
+ this.setRowCheck(currentRow._customIndex,true);
381
+ }
382
+ }
383
+
384
+ },
385
+ onSelect(rows,curRow) {
386
+ if (this.myConfig.onSelect) {
387
+ this.myConfig.onSelect(rows,curRow);
388
+ }
389
+ },
390
+ onSelectCancel(rows,curRow) {
391
+ if (this.myConfig.onSelectCancel) {
392
+ this.myConfig.onSelectCancel(rows,curRow);
393
+ }
394
+ },
395
+ OnSelectionChange(row) {
396
+ this.$nextTick(() => {
397
+ if (this.myConfig.onSelectionChange) {
398
+ this.myConfig.onSelectionChange(row);
399
+ }
400
+ if (row && row.length > 0) {
401
+ this.leftActive = true;
402
+ } else {
403
+ this.leftActive = false;
404
+ }
405
+ let data = this.$Method.copy(this.data);
406
+ let flag = false;
407
+ data.forEach((el,index) => {
408
+ flag = false;
409
+ row.forEach(el2 => {
410
+ if (index === el2._customIndex) {
411
+ flag = true;
412
+ return true;
413
+ }
414
+ });
415
+ el._checked = flag;
416
+ })
417
+ this.data = data;
418
+ this.tempData = this.$Method.copy(data);
419
+ /*if (this.data.length === row.length) {
420
+ if (!this.isAll) {
421
+ this.$refs.table.selectAll(true);
422
+ this.isAll = true;
423
+ } else {
424
+ this.isAll = false;
425
+ }
426
+ }*/
427
+ });
428
+ },
429
+ OnMultiSelectionChange (row) {
430
+ this.$nextTick(() => {
431
+ let data = this.$Method.copy(this.tempMultiSelectData);
432
+ let flag = false;
433
+ data.forEach((el,index) => {
434
+ flag = false;
435
+ row.forEach(el2 => {
436
+ if (index === el2._customIndex) {
437
+ flag = true;
438
+ return true;
439
+ }
440
+ });
441
+ el._checked = flag;
442
+ })
443
+ this.tempMultiSelectData = data;
444
+ if (row && row.length > 0) {
445
+ this.rightActive = true;
446
+ } else {
447
+ this.rightActive = false;
448
+ }
449
+ });
450
+ },
451
+ removeRow(index) {
452
+ this.data.splice(index, 1);
453
+ },
454
+ doBatchAction(obj) {
455
+ if (obj.name !== 'addData') {
456
+ let data = this.getSelection();
457
+ if (data.length === 0) {
458
+ this.alert('请至少选择一行');
459
+ return;
460
+ }
461
+ obj.data= data;
462
+ }
463
+ this.$emit('doAction', obj);
464
+ },
465
+ add() {
466
+ let obj = {};
467
+ obj.name ='addData';
468
+ this.$emit('doAction', obj);
469
+ },
470
+ setSearchBeforeSearchParam(obj) {
471
+ this.searchBeforeSearchParam = Object.assign({},{},obj);
472
+ },
473
+ clearSearchBeforeSearchParam() {
474
+ this.searchBeforeSearchParam = {};
475
+ },
476
+ popValueChanged (para) {
477
+ let reData = [];
478
+ let self = this;
479
+ let searchParam = Object.assign({},self.getSearchParam(),para);
480
+ self.synchroPost(self.myConfig.resources,self.myConfig.method,searchParam,function(data) {
481
+ if (data && data[self.myConfig.response]) {
482
+ reData = data[self.myConfig.response];
483
+ }
484
+ },null);
485
+ return reData;
486
+ },
487
+ getTotalCount() {
488
+ let total_results = '';
489
+ if (this.myConfig.pageConfig.total_results !== undefined) {
490
+ total_results = this.myConfig.pageConfig.total_results;
491
+ }
492
+ return total_results;
493
+ },
494
+ export(asyncExport,afterFun) {
495
+ if(this.data.length == 0){
496
+ this.alert('请先查询数据');
497
+ return;
498
+ }
499
+ let _param = this.getSearchParam();
500
+ if (this.OmdUrl.maxRowNum) {
501
+ _param.maxrownum = this.OmdUrl.maxRowNum;
502
+ }
503
+
504
+ if (this.OmdUrl.maxDataNum) {
505
+ _param.maxdatanum = this.OmdUrl.maxDataNum;
506
+ }
507
+ let modulecode = this.getModulecode();
508
+ if (modulecode) {
509
+ _param.modulecode = modulecode;
510
+ }
511
+ let dict = {};
512
+ dict.dictdata = {};
513
+ _param.fields =this.$Method.getGridField(this.myConfig.items,this.myConfig.separator,this.dictData, dict.dictdata);
514
+ if (!_param.fields) {
515
+ _param.fields = '';
516
+ }
517
+ // 添加总数
518
+ let totalCount = this.getTotalCount();
519
+ if (totalCount) {
520
+ _param.fields += ',totalCount'+ this.myConfig.separator + totalCount;
521
+ }
522
+ // 添加模块号
523
+ if (modulecode) {
524
+ _param.fields += ',modulecode'+ this.myConfig.separator + modulecode;
525
+ }
526
+ let exportMethod = this.myConfig.exportMethod;
527
+ if (asyncExport) {
528
+ exportMethod = 'asyncExport';
529
+ }
530
+ let _baseUrl = this.myConfig.resources.replace('rest', exportMethod);
531
+ let _self = this;
532
+ const encodedArray =this.zip(JSON.stringify(dict.dictdata));
533
+ _param.dictdata = encodeURIComponent(encodedArray);
534
+ if (asyncExport) {
535
+ this.asyncExport(_baseUrl,this.myConfig.method,_param,afterFun);
536
+ } else {
537
+ this.doExportExcel(_baseUrl, this.myConfig.method, _param,this.myConfig.exportType, _self);
538
+ }
539
+ },
540
+ zip (str) {
541
+ let binaryString = gzip(str, { to: 'string' });
542
+ return btoa(binaryString);
543
+ },
544
+ asyncExport(_baseUrl,method, _param,afterFun) {
545
+ let self = this;
546
+ self.synchroPost(_baseUrl,method,_param,function(data) {
547
+ if (data.flag === '1') {
548
+ if (afterFun) {
549
+ afterFun();
550
+ } else {
551
+ this.alert('文件正在生成,请稍后');
552
+ }
553
+ }
554
+ },null);
555
+ },
556
+ initAsynExportConfig(columns,headname,newColumns) {
557
+ for (let i = 0; i < columns.length; i++) {
558
+ let column = this.$Method.copy(columns[i]);
559
+ if (column.visible !== false && column.isExport !== false) {
560
+ if (column.name) {
561
+ column.label = headname + column.label;
562
+ newColumns.push(column);
563
+ }
564
+ if (column.children) {
565
+ let culhead = headname + '(' + column.label + ')';
566
+ this.initAsynExportConfig(column.children,culhead,newColumns);
567
+ }
568
+ }
569
+ }
570
+ },
571
+ setRowHighlight(index , flag) {
572
+ if (index > -1) {
573
+ let newRow = Object.assign({},this.data[index],{});
574
+ newRow._highlight = flag;
575
+ this.$nextTick(() => {
576
+ this.data.splice(index,1,newRow);
577
+ this.tempData.splice(index,1,newRow);
578
+ if (!this.myConfig.multiSelect) {
579
+ this.singleData.currentRow = this.$Method.copy(this.data[index]);
580
+ }
581
+ });
582
+ }
583
+ },
584
+ getSelection() {
585
+ if (this.myConfig.multiSelect === false) {
586
+ if (this.singleData.currentRow) {
587
+ return [this.singleData.currentRow];
588
+ } else {
589
+ return [];
590
+ }
591
+ } else {
592
+ if (this.myConfig.multiSelectGrid) {
593
+ return this.$Method.copy(this.multiSelectData);
594
+ } else {
595
+ return this.$refs.table.getSelection();
596
+ }
597
+ }
598
+ },
599
+ setSelection(data) {
600
+ if (this.myConfig.multiSelectGrid) {
601
+ this.multiSelectData = [];
602
+ this.$nextTick(() => {
603
+ this.multiSelectData = data;
604
+ this.tempMultiSelectData = this.$Method.copy(this.multiSelectData);
605
+ });
606
+ }
607
+ },
608
+ moveToLeft() {
609
+ let data = this.$refs.multiSelectTable.getSelection();
610
+ if (data && data.length > 0) {
611
+ data.forEach(el => {
612
+ let index = this.multiSelectData.findIndex(el2 => el2[this.myConfig.responseId] === el[this.myConfig.responseId]);
613
+ if (index > -1) {
614
+ this.multiSelectData.splice(index, 1);
615
+ }
616
+ });
617
+ }
618
+ this.tempMultiSelectData = this.$Method.copy(this.multiSelectData);
619
+ this.rightActive = false;
620
+ },
621
+ moveToRight() {
622
+ let data = this.$refs.table.getSelection();
623
+ if (data && data.length > 0) {
624
+ data.forEach(el => {
625
+ if (this.myConfig.multiCheck) {
626
+ if (this.myConfig.multiCheck(this.multiSelectData, el)) {
627
+ delete el._customIndex;
628
+ delete el._checked;
629
+ this.multiSelectData.push(el);
630
+ }
631
+ } else {
632
+ let index = this.multiSelectData.findIndex(el2 => el2[this.myConfig.responseId] === el[this.myConfig.responseId]);
633
+ if (index === -1) {
634
+ delete el._customIndex;
635
+ delete el._checked;
636
+ this.multiSelectData.push(el);
637
+ }
638
+ }
639
+ });
640
+ }
641
+ this.tempMultiSelectData = this.$Method.copy(this.multiSelectData);
642
+ },
643
+ multiInitColumn () {
644
+ let columns = [];
645
+ let items = this.myConfig.items;
646
+ if (this.myConfig.multiItems) {
647
+ items = this.myConfig.multiItems;
648
+ }
649
+ if (!items || items.length === 0) {
650
+ return columns;
651
+ }
652
+ this.initCheckColumn(columns);
653
+ this.initMultiIndexColumn(columns);
654
+ const length = items.length;
655
+ for (let i = 0; i < length; i++) {
656
+ if (items[i].visible !== false) {
657
+ //this.setColumn(i);
658
+ // 添加复杂列项的支持
659
+ this.initCommonColumn(items[i],columns);
660
+ }
661
+ }
662
+ this.initExpandColumn(columns);
663
+ this.initOperColumn(columns);
664
+ let multiSoltTableColumns = [];
665
+ this.getSoltTableColumns(columns, multiSoltTableColumns);
666
+ this.multiSoltTableColumns = multiSoltTableColumns;
667
+ return columns;
668
+ },
669
+ customClearData() {
670
+ this.multiSelectData = [];
671
+ this.rightActive = false;
672
+ this.leftActive = false;
673
+ if (this.myConfig.dynamicColumnFlag) {
674
+ this.tableColumns = [];
675
+ this.soltTableColumns = [];
676
+ this.newRow = {};
677
+ this.total_summary = {};
678
+ if (this.myConfig.showSummary) {
679
+ Object.assign(this.myConfig,{'showSummary':false});
680
+ }
681
+ }
682
+ },
683
+ clearCondition() {
684
+ if (this.$refs.condition && this.$refs.condition.clear) {
685
+ this.$refs.condition.clear();
686
+ }
687
+ },
688
+ clearCurrentRow() {
689
+ if (this.$refs.table) {
690
+ this.$refs.table.clearCurrentRow();
691
+ }
692
+ },
693
+ delRow(index) {
694
+ this.data.splice(index, 1);
695
+ this.tempData = this.data;
696
+ },
697
+ updataRow(index,para) {
698
+ let row = Object.assign({}, this.data[index], para);
699
+ this.data.splice(index,1,row);
700
+ this.tempData = this.data;
701
+ },
702
+ initMultiIndexColumn(columns) {
703
+ let index = {};
704
+ index.type = 'index';
705
+ index.key = 'index';
706
+ index.width = 45;
707
+ index.title = '行号';
708
+ index.align = 'center';
709
+ columns.push(index);
710
+ },
711
+ makeDynamicColumn() {
712
+ let initData = [];
713
+ this.tableColumns = [];
714
+ this.soltTableColumns = [];
715
+ this.total_summary = {};
716
+ if (this.dynamicInitData && this.dynamicInitData[this.myConfig.response]) {
717
+ initData = this.$Method.copy(this.dynamicInitData[this.myConfig.response]);
718
+ let groupColumns = [];
719
+ groupColumns = this.$Method.copy(this.myConfig.dynameicColumnConfig.groupColumns);
720
+
721
+ let dynameicColumnNames = [];
722
+ if (this.myConfig.dynameicColumnConfig.dynameicColumnName) {
723
+ dynameicColumnNames = this.myConfig.dynameicColumnConfig.dynameicColumnName.split(',');
724
+ }
725
+ let dynameicColumnValue = [];
726
+ if (this.myConfig.dynameicColumnConfig.dynameicColumnValue) {
727
+ dynameicColumnValue = this.myConfig.dynameicColumnConfig.dynameicColumnValue.split(',');
728
+ }
729
+ let dynameicColumnValueTitle = [];
730
+ if (this.myConfig.dynameicColumnConfig.dynameicColumnValueTitle) {
731
+ dynameicColumnValueTitle = this.myConfig.dynameicColumnConfig.dynameicColumnValueTitle.split(',');
732
+ }
733
+ let fatherTemp = [];
734
+ dynameicColumnNames.forEach(el2 => {
735
+ let tmp = {};
736
+ tmp.name = el2;
737
+ fatherTemp.push(tmp);
738
+ });
739
+ let obj = {};
740
+ let endNodes = {};
741
+ let num = 0;
742
+ initData.forEach(el => {
743
+ let groupId = '';
744
+ groupColumns.forEach(el2 => {
745
+ groupId = groupId + el[el2] + '-' ;
746
+ });
747
+ if (groupId) {
748
+ groupId = groupId.substring(0,groupId.length - 1);
749
+ }
750
+ let dyId = '';
751
+ let fatherId = '';
752
+ dynameicColumnNames.forEach((el2,index) => {
753
+ dyId = dyId + el[el2] + '-';
754
+ if (!fatherTemp[index][el[el2]]) {
755
+ fatherTemp[index][el[el2]] = {};
756
+ fatherTemp[index][el[el2]].fatherId = fatherId;
757
+ fatherTemp[index][el[el2]].label=el[el2];
758
+ }
759
+ fatherId = el[el2];
760
+ if (index === dynameicColumnNames.length -1) {
761
+ fatherTemp[index][el[el2]].id = dyId.substring(0,dyId.length - 1);
762
+ }
763
+ });
764
+ if (dyId) {
765
+ dyId = dyId.substring(0,dyId.length - 1);
766
+ }
767
+
768
+ if (!obj[groupId]) {
769
+ obj[groupId] = {};
770
+ obj[groupId].data = {};
771
+ groupColumns.forEach(el2 => {
772
+ obj[groupId].data[el2] = el[el2];
773
+ });
774
+ obj[groupId].columns = {};
775
+ }
776
+ if (!obj[groupId].columns[dyId]) {
777
+ if (dynameicColumnValue.length > 1) {
778
+ obj[groupId].columns[dyId] = {};
779
+ dynameicColumnValue.forEach(elv => {
780
+ obj[groupId].columns[dyId][elv] = el[elv];
781
+ });
782
+ } else {
783
+ obj[groupId].columns[dyId] = el[this.myConfig.dynameicColumnConfig.dynameicColumnValue];
784
+ }
785
+ }
786
+ if (!endNodes[dyId]) {
787
+ endNodes[dyId] = {};
788
+ endNodes[dyId].name = 'dy_col_' + num;
789
+ if (dynameicColumnValue.length > 1) {
790
+ endNodes[dyId].sum = {};
791
+ dynameicColumnValue.forEach(elv => {
792
+ endNodes[dyId].sum[elv] = el[elv];
793
+ });
794
+ } else {
795
+ endNodes[dyId].sum = 0;
796
+ }
797
+ num++;
798
+ }
799
+ if (dynameicColumnValue.length > 1) {
800
+ dynameicColumnValue.forEach(elv => {
801
+ endNodes[dyId].sum[elv] = Number(endNodes[dyId].sum[elv]) + Number(el[elv]) ;
802
+ });
803
+ } else {
804
+ endNodes[dyId].sum = Number(endNodes[dyId].sum)+ Number(el[this.myConfig.dynameicColumnConfig.dynameicColumnValue]);
805
+ }
806
+ });
807
+ let data = [];
808
+ for (let pro in obj) {
809
+ let tempData = {};
810
+ Object.assign(tempData, obj[pro].data);
811
+ let dynamic_sum = 0;
812
+ for (let pro2 in endNodes) {
813
+ if (dynameicColumnValue.length > 1) {
814
+ if (obj[pro].columns[pro2] !== undefined) {
815
+ dynameicColumnValue.forEach(el => {
816
+ let tmpname = endNodes[pro2].name + '_' +el;
817
+ tempData[tmpname] = obj[pro].columns[pro2][el];
818
+ dynamic_sum = dynamic_sum + Number(tempData[tmpname]);
819
+ });
820
+ } else {
821
+ dynameicColumnValue.forEach(el => {
822
+ let tmpname = endNodes[pro2].name + '_' +el;
823
+ tempData[tmpname] = 0;
824
+ dynamic_sum = dynamic_sum + Number(tempData[tmpname]);
825
+ });
826
+ }
827
+ } else {
828
+ if (obj[pro].columns[pro2] !== undefined) {
829
+ tempData[endNodes[pro2].name] = obj[pro].columns[pro2];
830
+ dynamic_sum = dynamic_sum + Number(tempData[endNodes[pro2].name]);
831
+ } else {
832
+ tempData[endNodes[pro2].name] = 0;
833
+ dynamic_sum = dynamic_sum + Number(tempData[endNodes[pro2].name]);
834
+ }
835
+ }
836
+ }
837
+ tempData.dynamic_sum = dynamic_sum;
838
+ data.push(tempData);
839
+ }
840
+
841
+ let columnsList = [];
842
+ this.makeDynamicColumnConfig(fatherTemp, 0, '', columnsList, endNodes,dynameicColumnValue,dynameicColumnValueTitle);
843
+
844
+ let temp = {};
845
+ if (this.myConfig.dynameicColumnConfig.dynameicColumnSumLable) {
846
+ temp.label = this.myConfig.dynameicColumnConfig.dynameicColumnSumLable;
847
+ } else {
848
+ temp.label = '动态合计';
849
+ }
850
+ temp.type='NumberBox';
851
+ temp.contentAlign = 'right';
852
+ temp.summary = true;
853
+ temp.name = 'dynamic_sum';
854
+ let width = this.$Method.getTextWidth(temp.label);
855
+ temp.width = width;
856
+ Object.assign(temp, this.myConfig.dynameicColumnConfig.dynameicColumnValuePro);
857
+ columnsList.push(temp);
858
+ let tableColumns = this.myConfig.items.concat(columnsList);
859
+ this.dynamicColumnConfig = this.$Method.copy(tableColumns);
860
+ this.initDynamicColumn(tableColumns);
861
+ let total_summary = {};
862
+ let dynamic_sum = 0;
863
+ for (let pro in endNodes) {
864
+ if (dynameicColumnValue.length > 1) {
865
+ dynameicColumnValue.forEach(el => {
866
+ let tmpName =endNodes[pro].name + '_' + el;
867
+ total_summary[tmpName] = endNodes[pro].sum[el];
868
+ dynamic_sum = dynamic_sum + Number(endNodes[pro].sum[el]);
869
+ });
870
+ } else {
871
+ total_summary[endNodes[pro].name] = endNodes[pro].sum;
872
+ dynamic_sum = dynamic_sum + Number(endNodes[pro].sum);
873
+ }
874
+ }
875
+ total_summary.dynamic_sum = dynamic_sum;
876
+
877
+ let summaryColumn = [];
878
+ this.summaryColumn.forEach(el => {
879
+ if (total_summary[el] === undefined) {
880
+ summaryColumn.push(el);
881
+ }
882
+ });
883
+ if (summaryColumn.length > 0) {
884
+ data.forEach(el => {
885
+ summaryColumn.forEach(el2 => {
886
+ if (!total_summary[el2]) {
887
+ total_summary[el2] = 0;
888
+ }
889
+ total_summary[el2] = total_summary[el2] + Number(el[el2]);
890
+ });
891
+ });
892
+ }
893
+ this.data = data;
894
+ this.tempData = this.$Method.copy(data);
895
+ this.total_summary = Object.assign({}, {}, total_summary);
896
+ if (!this.myConfig.showSummary) {
897
+ Object.assign(this.myConfig,{'showSummary':true});
898
+ }
899
+ } else {
900
+ if (this.myConfig.showSummary) {
901
+ Object.assign(this.myConfig,{'showSummary':false});
902
+ }
903
+ }
904
+ },
905
+ initDynamicColumn(tableColumns) {
906
+ let newRow = {};
907
+ let summaryColumn = [];
908
+ let columns = [];
909
+ this.initCheckColumn(columns);
910
+ this.initOperColumn(columns);
911
+ this.initIndexColumn(columns);
912
+ const length = tableColumns.length;
913
+ for (let i = 0; i < length; i++) {
914
+ if (tableColumns[i].visible !== false) {
915
+ //this.setColumn(i);
916
+ // 添加复杂列项的支持
917
+ this.initCommonColumn(tableColumns[i],columns,summaryColumn,newRow);
918
+ } else {
919
+ if (tableColumns[i].defaultValue !== undefined) {
920
+ if (tableColumns[i].name) {
921
+ newRow[tableColumns[i].name] = tableColumns[i].defaultValue;
922
+ }
923
+ if (tableColumns[i].sname) {
924
+ newRow[tableColumns[i].sname] = tableColumns[i].defaultValue;
925
+ }
926
+ if (tableColumns[i].ename) {
927
+ newRow[tableColumns[i].ename] = tableColumns[i].defaultValue;
928
+ }
929
+ }
930
+ }
931
+ }
932
+ this.total_summary = {};
933
+ this.newRow = deepCopy(newRow);
934
+ summaryColumn.push('dynamic_sum');
935
+ this.summaryColumn = deepCopy(summaryColumn);
936
+ this.tableColumns = deepCopy(columns);
937
+ let soltTableColumns = [];
938
+ this.getSoltTableColumns(columns,soltTableColumns);
939
+ this.soltTableColumns = soltTableColumns;
940
+ this.dynamicColumnItems = tableColumns;
941
+ },
942
+ makeDynamicColumnConfig (fatherTemp, index, id, items, endNodes,dynameicColumnValue,dynameicColumnValueTitle) {
943
+ let fahter = fatherTemp[index];
944
+ if (index === fatherTemp.length -1) {
945
+ for (let pro in fahter) {
946
+ if (pro === 'name') {
947
+ continue;
948
+ }
949
+ let temp = {};
950
+ temp.label = fahter[pro].label;
951
+ if (dynameicColumnValue.length > 1) {
952
+ temp.align = 'center';
953
+ temp.children = [];
954
+ dynameicColumnValue.forEach((el,index) => {
955
+ let temp2 = {};
956
+ temp2.type='NumberBox';
957
+ temp2.align = 'center';
958
+ temp2.contentAlign = 'right';
959
+ temp2.summary = true;
960
+ Object.assign(temp2, this.myConfig.dynameicColumnConfig.dynameicColumnValuePro);
961
+ temp2.label = dynameicColumnValueTitle[index];
962
+ let width = this.$Method.getTextWidth(temp2.label);
963
+ temp2.width = width;
964
+ temp2.name = endNodes[fahter[pro].id].name + '_' + el;
965
+ temp.children.push(temp2);
966
+ });
967
+ } else {
968
+ temp.type='NumberBox';
969
+ temp.align = 'center';
970
+ temp.contentAlign = 'right';
971
+ temp.summary = true;
972
+ let width = this.$Method.getTextWidth(temp.label);
973
+ temp.width = width;
974
+ if (endNodes[fahter[pro].id]) {
975
+ temp.name = endNodes[fahter[pro].id].name;
976
+ }
977
+ Object.assign(temp, this.myConfig.dynameicColumnConfig.dynameicColumnValuePro);
978
+ }
979
+
980
+ if (id) {
981
+ if (fahter[pro].fatherId === id) {
982
+ items.push(temp);
983
+ items.sort((a, b) => {
984
+ return a > b;
985
+ });
986
+ }
987
+ } else {
988
+ items.push(temp);
989
+ items.sort((a, b) => {
990
+ return a > b;
991
+ });
992
+ }
993
+ }
994
+
995
+ } else {
996
+ for (let pro in fahter) {
997
+ if (pro === 'name') {
998
+ continue;
999
+ }
1000
+ let temp = {};
1001
+ temp.label = fahter[pro].label;
1002
+ temp.align = 'center';
1003
+ if (id) {
1004
+ if (fahter[pro].fatherId === id) {
1005
+ temp.children = [];
1006
+ this.makeDynamicColumnConfig(fatherTemp, index+1, pro, temp.children, endNodes,dynameicColumnValue,dynameicColumnValueTitle);
1007
+ items.push(temp);
1008
+ items.sort((a, b) => {
1009
+ return a > b;
1010
+ });
1011
+ }
1012
+ } else {
1013
+ temp.children = [];
1014
+ this.makeDynamicColumnConfig(fatherTemp, index+1, pro, temp.children, endNodes,dynameicColumnValue,dynameicColumnValueTitle);
1015
+ items.push(temp);
1016
+ items.sort((a, b) => {
1017
+ return a > b;
1018
+ });
1019
+ }
1020
+
1021
+ }
1022
+
1023
+ }
1024
+ },
1025
+ handleSummary({ columns }) {
1026
+ let sums = {};
1027
+ for (let tmp in this.newRow) {
1028
+ sums[tmp]={key:tmp,value:''};
1029
+ }
1030
+ let index = columns.findIndex(el => el.type === 'index');
1031
+ if (index > -1) {
1032
+ sums.index = {key:'index',value:''};
1033
+ }
1034
+ let index2 = columns.findIndex(el => el.type === 'selection');
1035
+ if (index2 > -1) {
1036
+ sums.selection = {key:'selection',value:''};
1037
+ }
1038
+ let items = [];
1039
+ if (this.myConfig.dynamicColumnFlag) {
1040
+ items = this.dynamicColumnItems;
1041
+ } else {
1042
+ items = this.config.items;
1043
+ }
1044
+ for (let pro in this.total_summary) {
1045
+ let configItems = {};
1046
+ this.findItemByName(items, pro, configItems);
1047
+ if (configItems.name) {
1048
+ let tmpValue = this.total_summary[pro];
1049
+ if (configItems.format !== undefined) {
1050
+ tmpValue = this.$Method.formatNumber(tmpValue,configItems.format,configItems.notzero);
1051
+ }
1052
+ sums[pro]={key:pro,value:tmpValue};
1053
+ }
1054
+ }
1055
+ let firstkey = this.findFirst(columns);
1056
+ sums[firstkey] = {key:firstkey,value:this.myConfig.sumText};
1057
+ if (this.myConfig.customSummary){
1058
+ return this.myConfig.customSummary(sums);
1059
+ } else {
1060
+ return sums;
1061
+ }
1062
+ },
1063
+ findFirst(columns) {
1064
+ let key = '';
1065
+ columns.some(el => {
1066
+ if (el.key !== 'selection' && el.key !== 'index' && el.key !== 'sumindex') {
1067
+ key = el.name;
1068
+ return true;
1069
+ }
1070
+ });
1071
+ return key;
1072
+ },
1073
+ findItemByName(items, name, config) {
1074
+ if (items instanceof Array) {
1075
+ let flag = false;
1076
+ items.some(el => {
1077
+ if (el.children && el.children.length > 0) {
1078
+ flag = this.findItemByName(el.children, name, config);
1079
+ if (flag) {
1080
+ return true;
1081
+ }
1082
+ } else {
1083
+ if (el.name) {
1084
+ if (el.name === name) {
1085
+ Object.assign(config, el);
1086
+ flag = true;
1087
+ return true;
1088
+ }
1089
+ }
1090
+ }
1091
+ });
1092
+ return flag;
1093
+ } else {
1094
+ if (items.name) {
1095
+ if (items.name === name) {
1096
+ Object.assign(config, items);
1097
+ return true;
1098
+ }
1099
+ }
1100
+ }
1101
+ return false;
1102
+ },
1103
+ dynamicExportExcel() {
1104
+ let dynameicColumnNames = [];
1105
+ if (this.myConfig.dynameicColumnConfig.dynameicColumnName) {
1106
+ dynameicColumnNames = this.myConfig.dynameicColumnConfig.dynameicColumnName.split(',');
1107
+ }
1108
+ let headNum = dynameicColumnNames.length;
1109
+ let modulecode = this.$Method.getUrlParam('modulecode');
1110
+ if (!modulecode) {
1111
+ modulecode = this.$Method.getUrlParam('billmoduleid');
1112
+ }
1113
+ let fileName = this.$Method.formatDate(new Date(),'yyyyMMddhhmmss') +'(合计' + this.data.length+'条).xlsx';
1114
+ if (modulecode) {
1115
+ fileName = modulecode + '_' + fileName;
1116
+ }
1117
+ let tmpData = this.$Method.copy(this.data);
1118
+ this.dynamicColumnConfig.forEach(el => {
1119
+ if (el.type === 'ComboBox') {
1120
+ let valueField = 'code';
1121
+ let textField = 'name'
1122
+ if (el.valueField) {
1123
+ valueField = column.valueField;
1124
+ }
1125
+ if (el.textField) {
1126
+ textField = column.textField;
1127
+ }
1128
+ tmpData.forEach(el2 => {
1129
+ if (el2[el.name]) {
1130
+ if (el.data) {
1131
+ let index = el.data.findIndex(el3 => el3[valueField] === el2[el.name]);
1132
+ if (index > -1) {
1133
+ if (el.codeWithName === false) {
1134
+ el2[el.name] = el.data[index][textField];
1135
+ } else {
1136
+ el2[el.name] = '[' + el.data[index][valueField] + ']' + el.data[index][textField];
1137
+ }
1138
+ }
1139
+ }
1140
+ }
1141
+ });
1142
+ }
1143
+ });
1144
+ let newConfig = [];
1145
+ this.initAsynExportConfig(this.dynamicColumnConfig,'',newConfig);
1146
+ this.$Method.exportExcelStyle(newConfig,tmpData,headNum,fileName);
1147
+ },
1148
+ formatValue(index, column) {
1149
+ let value = '';
1150
+ let row = this.$Method.copy(this.tempData[index]);
1151
+ if (column.name) {
1152
+ value = row[column.name];
1153
+ }
1154
+ let config = column;
1155
+ let valueFormat = this.$Method.formatValue(value, row, config);
1156
+ let obj = {};
1157
+ obj.value = value;
1158
+ obj.row = row;
1159
+ obj.config = config;
1160
+ obj.valueFormat = valueFormat;
1161
+ if (column.formatValue) {
1162
+ return column.formatValue(obj);
1163
+ } else if (this.myConfig.formatValue) {
1164
+ return this.myConfig.formatValue(obj);
1165
+ } else {
1166
+ return valueFormat;
1167
+ }
1168
+ },
1169
+ formatMulValue(index, column) {
1170
+ let value = '';
1171
+ let row = this.$Method.copy(this.tempMultiSelectData[index]);
1172
+ if (column.name) {
1173
+ value = row[column.name];
1174
+ }
1175
+ let config = column;
1176
+ return this.$Method.formatValue(value, row, config);
1177
+ },
1178
+ setCustomColumn(column) {
1179
+ column.slot = column.key;
1180
+ },
1181
+ onLinkTo(obj) {
1182
+ const column = this.findColumnConfig (obj.name,this.myConfig.items);
1183
+ this.addRowInfo(obj, column);
1184
+ return column.onLinkTo(obj);
1185
+ },
1186
+ addRowInfo(obj, column) {
1187
+ let index = obj.rowIndex;
1188
+ obj.rowinfo = {};
1189
+ obj.rowinfo.column = column;
1190
+ obj.rowinfo.index = index;
1191
+ if (index > -1) {
1192
+ obj.rowinfo.row = this.data[index];
1193
+ }
1194
+ let that = this;
1195
+ obj.rowinfo.gridObject = that;
1196
+ },
1197
+ doSumgroups(data,Sumgroups) {
1198
+ let tmp = [];
1199
+ Sumgroups.forEach(el => {
1200
+ if (el.data && el.data.length > 0) {
1201
+ let groupstr = el.group.split(',');
1202
+ let culkey='';
1203
+ let key = '';
1204
+ data.forEach((el2,index) => {
1205
+ key = '';
1206
+ groupstr.forEach(el3 => {
1207
+ key = key + el2[el3];
1208
+ });
1209
+ if (!culkey) {
1210
+ culkey = key;
1211
+ }
1212
+ if (culkey !== key) {
1213
+ let sumdata = el.data.find(el4 => {
1214
+ let key2 = '';
1215
+ groupstr.forEach(el5 => {
1216
+ key2 = key2 + el4[el5];
1217
+ });
1218
+ return key2 === culkey;
1219
+ });
1220
+ let tmpObj = {};
1221
+ tmpObj.index = index;
1222
+ tmpObj.sum = sumdata;
1223
+ if (el.showgroup) {
1224
+ let showgroup = el.showgroup.split(',');
1225
+ tmpObj.showgroup = showgroup;
1226
+ }
1227
+ tmpObj.group = groupstr;
1228
+ tmp.push(tmpObj);
1229
+ culkey = key;
1230
+ }
1231
+ });
1232
+ }
1233
+ });
1234
+ if (tmp.length > 0) {
1235
+ let tmpData = [];
1236
+ data.forEach((el,index) => {
1237
+ let sumindex = index + 1;
1238
+ if (this.myConfig.showPage) {
1239
+ sumindex = sumindex + (this.myConfig.pageConfig.page_no - 1) * this.myConfig.pageConfig.page_size;
1240
+ }
1241
+ el.sumindex = sumindex + '';
1242
+ let tmpObj = tmp.find(el2 => el2.index === index);
1243
+ if (tmpObj) {
1244
+ if (this.myConfig.customSummaryGroup){
1245
+ tmpObj = this.myConfig.customSummaryGroup(tmpObj);
1246
+ }
1247
+ if (tmpObj.showgroup) {
1248
+ tmpObj.group.forEach(el2 => {
1249
+ let tmpIndex = tmpObj.showgroup.findIndex(el3 => el2 === el3);
1250
+ if (tmpIndex === -1) {
1251
+ tmpObj.sum[el2] = '';
1252
+ }
1253
+ });
1254
+ }
1255
+ tmpObj.sum.sumindex = '';
1256
+ tmpData.push(tmpObj.sum);
1257
+ tmpData.push(el);
1258
+ } else {
1259
+ tmpData.push(el);
1260
+ }
1261
+ });
1262
+ return tmpData;
1263
+ } else {
1264
+ return data;
1265
+ }
1266
+ }
1267
+ },
1268
+ mounted () {
1269
+ this.observer = elementResizeDetectorMaker();
1270
+ if (this.$refs.head) {
1271
+ this.observer.listenTo(this.$refs.head, this.setExtraHeight);
1272
+ }
1273
+ if (this.$refs.page) {
1274
+ this.observer.listenTo(this.$refs.page, this.setExtraHeight);
1275
+ }
1276
+ },
1277
+ beforeUnmount() {
1278
+ if (this.$refs.head) {
1279
+ this.observer.removeListener(this.$refs.head, this.setExtraHeight);
1280
+ }
1281
+ if (this.$refs.page) {
1282
+ this.observer.removeListener(this.$refs.page, this.setExtraHeight);
1283
+ }
1284
+ }
1285
+ };
1286
+ </script>