ocpview-plus 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (195) hide show
  1. package/LICENSE +0 -0
  2. package/README.md +0 -0
  3. package/dist/efviewplus.min.esm.js +99954 -0
  4. package/dist/efviewplus.min.js +142 -0
  5. package/dist/locale/lang.js +1 -0
  6. package/dist/locale/zh-CN.js +1 -0
  7. package/dist/locale/zh-TW.js +1 -0
  8. package/dist/locale/zh-UG.js +1 -0
  9. package/dist/style.css +9 -0
  10. package/dist/styles/efviewplus.css +1 -0
  11. package/package.json +144 -0
  12. package/src/components/base/controlbase.vue +191 -0
  13. package/src/components/base/controlbox.vue +102 -0
  14. package/src/components/base/index.js +3 -0
  15. package/src/components/base/load.js +20 -0
  16. package/src/components/base/probase.js +220 -0
  17. package/src/components/base/size.js +78 -0
  18. package/src/components/billbox/billbox.vue +68 -0
  19. package/src/components/billbox/index.js +2 -0
  20. package/src/components/cascaderbox/cascaderbox.vue +184 -0
  21. package/src/components/cascaderbox/index.js +2 -0
  22. package/src/components/checkbox/checkbox.vue +76 -0
  23. package/src/components/checkbox/checkgroupbox.vue +104 -0
  24. package/src/components/checkbox/index.js +3 -0
  25. package/src/components/colorbox/colorbox.vue +44 -0
  26. package/src/components/colorbox/index.js +2 -0
  27. package/src/components/combobox/combobox.vue +220 -0
  28. package/src/components/combobox/index.js +2 -0
  29. package/src/components/conditionbox/conditionbase.vue +195 -0
  30. package/src/components/conditionbox/conditionbox.vue +63 -0
  31. package/src/components/conditionbox/conditionfilterbox.vue +477 -0
  32. package/src/components/conditionbox/conditionselectorbox.vue +237 -0
  33. package/src/components/conditionbox/index.js +5 -0
  34. package/src/components/conditionbox/queryconditionbox.vue +26 -0
  35. package/src/components/conditionbox/queryconditionboxbase.vue +124 -0
  36. package/src/components/conditionbox/searchconditionbox.vue +114 -0
  37. package/src/components/conditionbox/searchgrid.vue +391 -0
  38. package/src/components/datebox/datebox.vue +129 -0
  39. package/src/components/datebox/daterangebox.vue +155 -0
  40. package/src/components/datebox/index.js +3 -0
  41. package/src/components/form/baseform.vue +677 -0
  42. package/src/components/form/detailsbox.vue +487 -0
  43. package/src/components/form/formbox.vue +29 -0
  44. package/src/components/form/formcardbox.vue +268 -0
  45. package/src/components/form/formcardgroupbox.vue +252 -0
  46. package/src/components/form/formcompro.js +19 -0
  47. package/src/components/form/formdetail.vue +129 -0
  48. package/src/components/form/formdetailtwo.vue +302 -0
  49. package/src/components/form/index.js +8 -0
  50. package/src/components/form/toolanchor.js +46 -0
  51. package/src/components/form/workform.vue +168 -0
  52. package/src/components/grid/basegrid.vue +1061 -0
  53. package/src/components/grid/editgrid.vue +51 -0
  54. package/src/components/grid/editgridbase.vue +947 -0
  55. package/src/components/grid/editgridcard.vue +193 -0
  56. package/src/components/grid/expandrow.vue +137 -0
  57. package/src/components/grid/index.js +6 -0
  58. package/src/components/grid/viewgrid.vue +122 -0
  59. package/src/components/grid/viewgridbase.vue +1284 -0
  60. package/src/components/icon/common-icon.vue +53 -0
  61. package/src/components/icon/eicon.vue +29 -0
  62. package/src/components/icon/icons.vue +42 -0
  63. package/src/components/icon/index.js +2 -0
  64. package/src/components/label/index.js +3 -0
  65. package/src/components/label/showtext.vue +95 -0
  66. package/src/components/load/loadcartoon.vue +228 -0
  67. package/src/components/map/index.js +2 -0
  68. package/src/components/map/mapbox.vue +348 -0
  69. package/src/components/masterplate/appendix.vue +586 -0
  70. package/src/components/masterplate/approval.vue +803 -0
  71. package/src/components/masterplate/base.vue +985 -0
  72. package/src/components/masterplate/billasyncimport.vue +614 -0
  73. package/src/components/masterplate/billconditionbox.vue +224 -0
  74. package/src/components/masterplate/billconditionsbox.vue +427 -0
  75. package/src/components/masterplate/billdetailform.vue +990 -0
  76. package/src/components/masterplate/billimport.vue +263 -0
  77. package/src/components/masterplate/billquerygrid.vue +316 -0
  78. package/src/components/masterplate/billsinglegrid.vue +234 -0
  79. package/src/components/masterplate/birtreport.vue +185 -0
  80. package/src/components/masterplate/detailbtntoolbar.vue +311 -0
  81. package/src/components/masterplate/detailsbox.vue +386 -0
  82. package/src/components/masterplate/editgridcard.vue +222 -0
  83. package/src/components/masterplate/editgridcard2.vue +109 -0
  84. package/src/components/masterplate/formcard.vue +106 -0
  85. package/src/components/masterplate/formcardgroupbox.vue +168 -0
  86. package/src/components/masterplate/formdetailtwo.vue +356 -0
  87. package/src/components/masterplate/gridcolset.vue +227 -0
  88. package/src/components/masterplate/index.js +23 -0
  89. package/src/components/masterplate/layouttemplate.vue +33 -0
  90. package/src/components/masterplate/leftlistrightdetails.vue +474 -0
  91. package/src/components/masterplate/leftlistrightlist.vue +465 -0
  92. package/src/components/masterplate/lefttreerightdetails.vue +619 -0
  93. package/src/components/masterplate/levelreport.vue +510 -0
  94. package/src/components/masterplate/listbtntoolbar.vue +257 -0
  95. package/src/components/masterplate/listdetails.vue +769 -0
  96. package/src/components/masterplate/operlog.vue +272 -0
  97. package/src/components/masterplate/options.vue +110 -0
  98. package/src/components/masterplate/page.vue +102 -0
  99. package/src/components/masterplate/promptmessage.vue +74 -0
  100. package/src/components/masterplate/querybar.vue +490 -0
  101. package/src/components/masterplate/report.vue +357 -0
  102. package/src/components/masterplate/rowbtntoolbar.vue +126 -0
  103. package/src/components/masterplate/simpletree.vue +129 -0
  104. package/src/components/masterplate/simpleviewgrid.vue +144 -0
  105. package/src/components/mychart/bar/bar.vue +202 -0
  106. package/src/components/mychart/basechart.vue +190 -0
  107. package/src/components/mychart/complexmychart/barline.vue +154 -0
  108. package/src/components/mychart/gauge/gauge.vue +83 -0
  109. package/src/components/mychart/index.js +9 -0
  110. package/src/components/mychart/line/line.vue +202 -0
  111. package/src/components/mychart/liquidfill/liquidfill.vue +109 -0
  112. package/src/components/mychart/pie/pie.vue +96 -0
  113. package/src/components/mychart/radar/radar.vue +122 -0
  114. package/src/components/mychart/scatter/scatter.vue +76 -0
  115. package/src/components/numberbox/append.js +11 -0
  116. package/src/components/numberbox/index.js +3 -0
  117. package/src/components/numberbox/numberbox.vue +303 -0
  118. package/src/components/numberbox/numberrangebox.vue +423 -0
  119. package/src/components/picturebox/filebox.vue +365 -0
  120. package/src/components/picturebox/index.js +3 -0
  121. package/src/components/picturebox/picturebox.vue +541 -0
  122. package/src/components/picturebox/uploadbox.vue +164 -0
  123. package/src/components/poptagbox/index.js +2 -0
  124. package/src/components/poptagbox/poptagbox.vue +389 -0
  125. package/src/components/poptextbox/index.js +2 -0
  126. package/src/components/poptextbox/poptextbox.vue +601 -0
  127. package/src/components/radiobox/index.js +2 -0
  128. package/src/components/radiobox/radiogroupbox.vue +76 -0
  129. package/src/components/richtextbox/editor.vue +150 -0
  130. package/src/components/richtextbox/index.js +2 -0
  131. package/src/components/richtextbox/richtextbox.vue +448 -0
  132. package/src/components/textbox/index.js +2 -0
  133. package/src/components/textbox/textbox.vue +98 -0
  134. package/src/components/timebox/index.js +2 -0
  135. package/src/components/timebox/timebox.vue +76 -0
  136. package/src/components/toolbar/ebutton.vue +169 -0
  137. package/src/components/toolbar/index.js +3 -0
  138. package/src/components/toolbar/toolbar.vue +446 -0
  139. package/src/components/tree/basetree.vue +725 -0
  140. package/src/components/tree/index.js +3 -0
  141. package/src/components/tree/treedata.vue +51 -0
  142. package/src/components/tree/treedatabase.vue +189 -0
  143. package/src/components/upload/billimport.vue +233 -0
  144. package/src/components/upload/index.js +2 -0
  145. package/src/components/videobox/index.js +2 -0
  146. package/src/components/videobox/uploadbox.vue +148 -0
  147. package/src/components/videobox/videobox.vue +503 -0
  148. package/src/components/wrichtextbox/editor.vue +219 -0
  149. package/src/components/wrichtextbox/index.js +2 -0
  150. package/src/components/wrichtextbox/wrichtextbox.vue +63 -0
  151. package/src/index.js +215 -0
  152. package/src/locale/format.js +51 -0
  153. package/src/locale/index.js +63 -0
  154. package/src/locale/lang/zh-CN.js +123 -0
  155. package/src/locale/lang/zh-TW.js +114 -0
  156. package/src/locale/lang/zh-UG.js +115 -0
  157. package/src/locale/lang.js +15 -0
  158. package/src/method/case/case.js +1180 -0
  159. package/src/method/config/queryconfig.js +24 -0
  160. package/src/method/const/const.js +815 -0
  161. package/src/method/index.js +8 -0
  162. package/src/static/excel/exportexcel.js +627 -0
  163. package/src/static/iview/coustom.js +463 -0
  164. package/src/store/index.js +19 -0
  165. package/src/store/modules/app.js +53 -0
  166. package/src/styles/README.md +3 -0
  167. package/src/styles/common.less +75 -0
  168. package/src/styles/components/anchor.less +74 -0
  169. package/src/styles/components/approval.less +136 -0
  170. package/src/styles/components/button.less +208 -0
  171. package/src/styles/components/card.less +51 -0
  172. package/src/styles/components/content.less +38 -0
  173. package/src/styles/components/font.less +314 -0
  174. package/src/styles/components/form.less +72 -0
  175. package/src/styles/components/iconfont/fonts/iconfont.less +1376 -0
  176. package/src/styles/components/iconfont/fonts/iconfont.svg +699 -0
  177. package/src/styles/components/iconfont/fonts/iconfont.ttf +0 -0
  178. package/src/styles/components/iconfont/fonts/iconfont.woff +0 -0
  179. package/src/styles/components/iconfont/fonts/iconfont.woff2 +0 -0
  180. package/src/styles/components/index.less +16 -0
  181. package/src/styles/components/input.less +290 -0
  182. package/src/styles/components/modal.less +203 -0
  183. package/src/styles/components/page.less +340 -0
  184. package/src/styles/components/select.less +361 -0
  185. package/src/styles/components/steps.less +367 -0
  186. package/src/styles/components/table.less +544 -0
  187. package/src/styles/components/tabs.less +249 -0
  188. package/src/styles/components/upload.less +83 -0
  189. package/src/styles/custom.less +67 -0
  190. package/src/styles/index.less +6 -0
  191. package/src/styles/pack.less +6 -0
  192. package/src/utils/EfuMessenger.js +155 -0
  193. package/src/utils/assist.js +353 -0
  194. package/src/utils/index.js +1 -0
  195. package/src/utils/random_str.js +10 -0
@@ -0,0 +1,725 @@
1
+ <script>
2
+ import size from '@/components/base/size';
3
+ import { resolveComponent } from 'vue';
4
+ export default {
5
+ mixins: [size],
6
+ name:'baseTree',
7
+ data () {
8
+ return {
9
+ globalConfig: {
10
+ emptyText: '暂无数据',
11
+ multiSelect: false,
12
+ resources: '',
13
+ method: '',
14
+ response: '',
15
+ selectkey: '',
16
+ idField:'',
17
+ parentField:'',
18
+ idClass:'',
19
+ searchParam: null,
20
+ readOnly: false,
21
+ showIcon:false,
22
+ keepExpand:false,
23
+ expandData:[],
24
+ showIconList:[],
25
+ showCheckBox: false,
26
+ showRootNode:false,
27
+ showTitle:true,
28
+ expand:true,
29
+ rootNode:{},
30
+ setNodeDisabled:'',
31
+ bordered:true,
32
+ disHover:false,
33
+ selectedRoot:false,
34
+ className:'efutre-tree-node'
35
+ },
36
+ myConfig: {
37
+
38
+ },
39
+ gridConfig:{
40
+
41
+ },
42
+ showCondition:true,
43
+ data:[],
44
+ oldData:[],
45
+ selectedData:[],
46
+ conditionSearchParam:{},
47
+ searchBeforeSearchParam:{},
48
+ rootNode:{},
49
+ showTree:true,
50
+ showGrid:false,
51
+ extraHeight:0,
52
+ outsideHeight:0,
53
+ treeData:[],
54
+ asyncLoad:false
55
+
56
+ };
57
+ },
58
+ created () {
59
+ this.init();
60
+ },
61
+ props:{
62
+ config: {
63
+ type: Object,
64
+ default: () => {
65
+ return {};
66
+ }
67
+ },
68
+ dictData: {
69
+ type: Object,
70
+ default:null
71
+ }
72
+ },
73
+ methods:{
74
+ init() {
75
+ //获取初期默认值
76
+ this.myConfig = Object.assign({}, this.globalConfig, this.myConfig);
77
+
78
+ //获取配置
79
+ if (this.config) {
80
+ this.myConfig = Object.assign({}, this.myConfig, this.config);
81
+ }
82
+
83
+ let rootCode = '0';
84
+ let rootName = '根节点';
85
+ if (this.myConfig.showRootNode) {
86
+ if (this.myConfig.rootNode !== undefined && this.myConfig.rootNode.code !== undefined) {
87
+ rootCode = this.myConfig.rootNode.code;
88
+ }
89
+ if (this.myConfig.rootNode !== undefined && this.myConfig.rootNode.name !== undefined) {
90
+ rootName = this.myConfig.rootNode.name;
91
+ }
92
+ }
93
+ if (this.myConfig.responseId === undefined) {
94
+ this.myConfig.responseId = this.myConfig.responseCode;
95
+ }
96
+ this.rootNode[this.myConfig.idField] = rootCode + '';
97
+ this.rootNode[this.myConfig.responseId] = rootCode + '';
98
+ this.rootNode[this.myConfig.responseCode] = rootCode + '';
99
+ this.rootNode[this.myConfig.responseName] = rootName;
100
+ if (this.myConfig.idClass !== undefined) {
101
+ this.rootNode[this.myConfig.idClass] = 0;
102
+ }
103
+ //多选 才允许出现复选框
104
+ if (this.myConfig.multiSelect !== true) {
105
+ this.myConfig.showCheckBox = false;
106
+ }
107
+ this.setSizeConfig(this.myConfig);
108
+
109
+ if (this.myConfig.asyncLoad) {
110
+ this.asyncLoad = true;
111
+ }
112
+ //特定化处理
113
+ if (this.customInit) {
114
+ this.customInit();
115
+ }
116
+
117
+ },
118
+ setIcon(data) {
119
+ let nodeClass = data[this.myConfig.idClass];
120
+ if (!nodeClass) {
121
+ nodeClass = 0;
122
+ } else {
123
+ nodeClass = Number(nodeClass);
124
+ }
125
+ if (!this.myConfig.showRootNode) {
126
+ if (nodeClass && nodeClass !== 0) {
127
+ nodeClass = nodeClass - 1;
128
+ }
129
+ }
130
+ if (nodeClass >= this.myConfig.showIconList.length) {
131
+ nodeClass = this.myConfig.showIconList.length - 1;
132
+ }
133
+
134
+ const icon = this.myConfig.showIconList[nodeClass];
135
+ data.icon = icon.type;
136
+ if (icon.size) {
137
+ data.iconSize = icon.size;
138
+ }
139
+ if (icon.color) {
140
+ data.iconColor = icon.color;
141
+ }
142
+ return data;
143
+ },
144
+ iconRender(h,params) {
145
+ let icon = params.data.icon;
146
+ let size = params.data.iconSize;
147
+ let color = params.data.iconColor;
148
+ if (!icon) {
149
+ if (params.node && params.node.children && params.node.children.length > 0) {
150
+ if (params.data.expand) {
151
+ icon = '_base_mulu';
152
+ } else {
153
+ icon = '_base_close_mulu';
154
+ }
155
+
156
+ } else {
157
+ icon = '_base_wenjian';
158
+ }
159
+ }
160
+ if (!size) {
161
+ size = 14;
162
+ }
163
+ let para = {
164
+ type:icon,
165
+ size:size,
166
+ color:color
167
+ }
168
+ if (this.myConfig.setTreeNodeIcon) {
169
+ para = this.myConfig.setTreeNodeIcon(params,para);
170
+ } else if (this.setTreeNodeIcon) {
171
+ para = this.setTreeNodeIcon(params,para);
172
+ }
173
+ if (para.type.indexOf('_') === 0) {
174
+ let resulIcon = para.type.substring(1,para.type.length);
175
+ resulIcon = 'iconfont icon-' + resulIcon;
176
+ para.custom = resulIcon;
177
+ delete para.type;
178
+ }
179
+ let nodeClass = 'efuture-treenode';
180
+ if (this.myConfig.setNodeClass) {
181
+ nodeClass =this.myConfig.setNodeClass(params)
182
+ }
183
+ let classstyle = {};
184
+ classstyle[nodeClass] = true;
185
+ return h(
186
+ 'div',
187
+ {
188
+ style: {
189
+ display: 'flex',
190
+ userSelect: 'none'
191
+ },
192
+ class:classstyle,
193
+ onDblclick:() => {
194
+ this.$nextTick(() => {
195
+ this.setExpend(params.data);
196
+ });
197
+ this.$emit('dbclick', params.data);
198
+ }
199
+ },
200
+ [
201
+ h(
202
+ 'div',
203
+ {
204
+ style: {
205
+ 'padding-left':'5px'
206
+ }
207
+ },
208
+ [
209
+ h(resolveComponent('Icon'), para)
210
+ ]
211
+ ),
212
+ h(resolveComponent('ShowText'), {
213
+ label:params.data.title,
214
+ contentAlign:'left'
215
+ })
216
+ ]);
217
+ },
218
+ toTreeData () {
219
+ let pos = {};
220
+ let tree = [];
221
+ let i = 0;
222
+ let data = this.$Method.copy(this.data);
223
+ data.forEach(el => {
224
+ this.setSelected(el);
225
+ });
226
+ let tempData = this.$Method.copy(data);
227
+ while (data.length !== 0) {
228
+ // 解决找不到节点,而导致的死循环
229
+ const index = tempData.findIndex(item => item[this.myConfig.idField] === data[i][this.myConfig.parentField]);
230
+
231
+ if (data[i][this.myConfig.parentField] === this.rootNode[this.myConfig.idField] || index < 0) {
232
+ tree.push(data[i]);
233
+ pos[data[i][this.myConfig.idField]] = [tree.length - 1];
234
+ data.splice(i, 1);
235
+ i--;
236
+ } else {
237
+ let posArr = pos[data[i][this.myConfig.parentField]];
238
+ if (posArr) {
239
+ let obj = tree[posArr[0]];
240
+ for (var j = 1; j < posArr.length; j++) {
241
+ obj = obj.children[posArr[j]];
242
+ }
243
+ obj.children.push(data[i]);
244
+ pos[data[i][this.myConfig.idField]] = posArr.concat([obj.children.length - 1]);
245
+ data.splice(i, 1);
246
+ i--;
247
+ }
248
+ }
249
+ i++;
250
+ if (i > data.length - 1) {
251
+ i = 0;
252
+ }
253
+ }
254
+ if (this.myConfig.showRootNode) {
255
+ let root = {
256
+ title: ' ' + this.myConfig.rootNode.name,
257
+ expand: true,
258
+ disabled :this.myConfig.readOnly,
259
+ children: tree,
260
+ selected:false
261
+ };
262
+ if (this.myConfig.rootNode.disabled !== undefined) {
263
+ root.disabled = this.myConfig.rootNode.disabled;
264
+ }
265
+ Object.assign(root, this.rootNode);
266
+
267
+ if (this.myConfig.showIcon) {
268
+ if (this.myConfig.idClass && this.myConfig.showIconList && this.myConfig.showIconList.length > 0) {
269
+ root[this.myConfig.idClass] = 0;
270
+ root = this.setIcon(root);
271
+ }
272
+ }
273
+ if (this.myConfig.nodeRender) {
274
+ root.render = this.myConfig.nodeRender;
275
+ } else{
276
+ root.render = this.iconRender;
277
+ }
278
+ return [root];
279
+ } else {
280
+ return tree;
281
+ }
282
+
283
+ },
284
+ setSelected (reTemp) {
285
+ if (this.myConfig.expand) {
286
+ reTemp.expand = this.myConfig.expand;
287
+ }
288
+ if (this.asyncLoad) {
289
+ if (Number(reTemp[this.myConfig.idClass]) !== Number(this.myConfig.maxClass)) {
290
+ reTemp.loading = false;
291
+ }
292
+ }
293
+ /*if (this.myConfig.keepExpand) {
294
+ let index = this.myConfig.expandData.findIndex(el => el === reTemp[this.myConfig.responseId]);
295
+ if (index > -1) {
296
+ reTemp.expand = true;
297
+ }
298
+ }*/
299
+ if (this.myConfig.showCodeWithName) {
300
+ reTemp.title = ' [' + reTemp[this.myConfig.responseCode] + '] ' + reTemp[this.myConfig.responseName];
301
+ } else {
302
+ reTemp.title = ' ' + reTemp[this.myConfig.responseName];
303
+ }
304
+ if (this.myConfig.readOnly) {
305
+ reTemp.disabled = true;
306
+ } else {
307
+ reTemp.disabled = false;
308
+ }
309
+ if (this.myConfig.setNodeDisabled) {
310
+ reTemp.disabled = this.myConfig.setNodeDisabled(reTemp);
311
+ }
312
+ if (this.myConfig.showIcon) {
313
+ if (this.myConfig.idClass && this.myConfig.showIconList && this.myConfig.showIconList.length > 0) {
314
+ reTemp = this.setIcon(reTemp);
315
+ }
316
+ }
317
+
318
+ if (this.myConfig.nodeRender) {
319
+ reTemp.render = this.myConfig.nodeRender;
320
+ } else{
321
+ reTemp.render = this.iconRender;
322
+ }
323
+ if (reTemp.children === undefined) {
324
+ reTemp.children= [];
325
+ } else {
326
+ let children = [];
327
+ reTemp.children.forEach(el => {
328
+ children.push(this.setSelected(el));
329
+ });
330
+ reTemp.children = children;
331
+ }
332
+ return reTemp;
333
+ },
334
+ refurbish(para) {
335
+ if(!para) {
336
+ para = {};
337
+ }
338
+ if (this.asyncLoad) {
339
+ para[this.myConfig.idClass] = 1;
340
+ }
341
+ let self = this;
342
+ self.synchroPost(self.myConfig.resources, self.myConfig.method, self.getSearchParam(para), function(data) {
343
+ let root = [];
344
+ if (data && data[self.myConfig.response]) {
345
+ if (self.checkData(data[self.myConfig.response])) {
346
+ root = data[self.myConfig.response];
347
+ } else {
348
+ return false;
349
+ }
350
+ }
351
+ if (self.myConfig.customData && self.myConfig.customData.length > 0) {
352
+ root = self.myConfig.customData.concat(root);
353
+ }
354
+ self.data = root;
355
+ self.treeData = self.toTreeData();
356
+ if (self.myConfig.selectedRoot) {
357
+ if (self.selectedData && self.selectedData.length === 0) {
358
+ self.selectedData.push(self.rootNode);
359
+ }
360
+ }
361
+ },null);
362
+ },
363
+ getAsyncNode(para){
364
+ let self = this;
365
+ let asyncData = [];
366
+ self.synchroPost(self.myConfig.resources, self.myConfig.method, self.getSearchParam(para), function(data) {
367
+ if (data && data[self.myConfig.response]) {
368
+ if (self.checkData(data[self.myConfig.response])) {
369
+ asyncData = data[self.myConfig.response];
370
+ }
371
+ }
372
+ },null);
373
+ return asyncData;
374
+ },
375
+ checkData(data) {
376
+ let index = data.findIndex(el => el[this.myConfig.idField] === el[this.myConfig.parentField]);
377
+ if (index > -1) {
378
+ this.alert('存在' + this.myConfig.idField +'与' + this.myConfig.parentField+'都为[' + data[index][this.myConfig.idField]+']的数据,请检查',null,2);
379
+ return false;
380
+ }
381
+ return true;
382
+ },
383
+ setReadOnly(flag) {
384
+ this.myConfig = Object.assign({},this.myConfig,{readOnly:flag});
385
+ },
386
+ getRootNode () {
387
+ return this.$Method.copy(this.rootNode);
388
+ },
389
+ getData() {
390
+ let data = null;
391
+ if (this.$refs.tree) {
392
+ if (this.myConfig.showCheckBox) {
393
+ data = this.$refs.tree.getCheckedNodes();
394
+ } else {
395
+ data = this.$refs.tree.getSelectedNodes();
396
+ }
397
+ }
398
+ return data;
399
+ },
400
+ setData(data) {
401
+ this.selectedData = this.$Method.copy(data);
402
+ this.oldData = this.$Method.copy(data);
403
+ },
404
+ setDisplayData(data) {
405
+ if (this.checkData(data)) {
406
+ this.data = this.$Method.copy(data);
407
+ this.treeData = this.toTreeData();
408
+ }
409
+ },
410
+ clearExpand() {
411
+ this.myConfig.expandData = [];
412
+ },
413
+ setPro(data) {
414
+ if (data) {
415
+ this.myConfig = Object.assign({},this.myConfig,data);
416
+ }
417
+ },
418
+ getPro(name) {
419
+ return this.myConfig[name];
420
+ },
421
+ onSelectChange: function(res,node) { //点击树节点时触发返回当前已选中的节点数组
422
+ this.$emit('onSelectChange', res, node);
423
+ },
424
+ onCheckChange: function(res,node) { //勾选树节点时触发返回当前已勾选的节点数组
425
+ if (this.myConfig.showCheckBox) {
426
+ let obj = [];
427
+ res.forEach(el => {
428
+ let temp = {};
429
+ temp[this.myConfig.responseId] = el[this.myConfig.responseId];
430
+ obj.push(temp);
431
+ });
432
+ this.selectedData = this.$Method.copy(obj);
433
+ }
434
+ this.$emit('onCheckChange', res,node);
435
+ },
436
+ onToggleExpand: function(res) { //展开和收起子列表时触发返回当前节点的数据
437
+ /*if (res.expand) {
438
+ // 去重
439
+ let index = this.myConfig.expandData.findIndex(el => el === res[this.myConfig.responseId]);
440
+ if (index === -1) {
441
+ this.myConfig.expandData.push(res[this.myConfig.responseId])
442
+ }
443
+ } else {
444
+ let children = [];
445
+ this.getChildren(res,children);
446
+ // 收起当前节点
447
+ children.push(res[this.myConfig.responseId]);
448
+ children.forEach(el => {
449
+ let index2 = this.myConfig.expandData.findIndex(el2 => el === el2);
450
+ if (index2 > -1) {
451
+ this.myConfig.expandData.splice(index2, 1);
452
+ }
453
+ });
454
+ }*/
455
+ this.$emit('onToggleExpand', res);
456
+ },
457
+ getChildren(res,childrens) {
458
+ this.data.forEach(el => {
459
+ if (el[this.myConfig.parentField] === res[this.myConfig.idField]) {
460
+ childrens.push(el[this.myConfig.responseId]);
461
+ this.getChildren(el, childrens);
462
+ }
463
+ });
464
+ },
465
+ popValueChanged (para) {
466
+ let reData = [];
467
+ let self = this;
468
+ let searchParam = Object.assign({},self.getSearchParam(),para);
469
+ self.synchroPost(self.myConfig.resources,self.myConfig.method,searchParam,function(data) {
470
+ if (data && data[self.myConfig.response]) {
471
+ reData = data[self.myConfig.response];
472
+ }
473
+ },null);
474
+ return reData;
475
+ },
476
+ clearData() {
477
+ this.data = [];
478
+ this.oldData = [];
479
+ this.selectedData =[];
480
+ this.treeData = [];
481
+ this.conditionSearchParam = {};
482
+ this.myConfig.expandData = [];
483
+ },
484
+ getSelectedNodes() {
485
+ return this.$refs.tree.getSelectedNodes();
486
+ },
487
+ getCheckedNodes() {
488
+ return this.$refs.tree.getCheckedNodes();
489
+ },
490
+ getCheckedAndIndeterminateNodes() {
491
+ return this.$refs.tree.getCheckedAndIndeterminateNodes();
492
+ },
493
+ isChange() {
494
+ // 初期值为空时,结果是否有值
495
+ let data = this.getData();
496
+ if (this.oldData.length === 0) {
497
+ if (data.length > 0) {
498
+ return true;
499
+ } else {
500
+ return false;
501
+ }
502
+ }
503
+ // 判断初期值是否在结果中
504
+ let resultFlag = false;
505
+ let tempflag = false;
506
+ this.oldData.forEach(el => {
507
+ tempflag = false;
508
+ data.forEach(el2 => {
509
+ if (el[this.myConfig.idField] === el2[this.myConfig.idField]) {
510
+ tempflag = true;
511
+ return;
512
+ }
513
+ });
514
+ if (!tempflag) {
515
+ resultFlag = true;
516
+ return;
517
+ }
518
+ });
519
+ if (resultFlag) {
520
+ return true;
521
+ }
522
+ // 初期值全部在结果中,是否多了新值
523
+ let num = 0;
524
+ data.forEach(el => {
525
+ if (el.children === undefined || (el.children && el.children.length === 0)) {
526
+ num++;
527
+ }
528
+ });
529
+ if (this.oldData.length !== num) {
530
+ return true;
531
+ } else {
532
+ return false;
533
+ }
534
+ },
535
+ setSearchBeforeSearchParam(obj) {
536
+ this.searchBeforeSearchParam = Object.assign({},{},obj);
537
+ },
538
+ clearSearchBeforeSearchParam() {
539
+ this.searchBeforeSearchParam = {};
540
+ },
541
+ getFatherNode(node) {
542
+ if (!node || !node[this.myConfig.parentField]) {
543
+ return {};
544
+ }
545
+ if (this.data && this.data.length > 0) {
546
+ const index = this.data.findIndex(el => el[this.myConfig.idField] === node[this.myConfig.parentField]);
547
+ if (index > -1) {
548
+ return this.$Method.copy(this.data[index]);
549
+ } else {
550
+ return {};
551
+ }
552
+ }
553
+ },
554
+ isChildren (node) {
555
+ let flag = false;
556
+ if (this.data && this.data.length > 0) {
557
+ const index = this.data.findIndex(el => el[this.myConfig.parentField] === node[this.myConfig.idField]);
558
+ if (index > -1) {
559
+ flag = true;
560
+ }
561
+ }
562
+ return flag;
563
+ },
564
+ setExtraHeight () {
565
+ let height = 0;
566
+ if (this.$refs.condition) {
567
+ height = this.$refs.condition.offsetHeight;
568
+ }
569
+ this.extraHeight = height;
570
+ },
571
+ setOutsideHeight(value) {
572
+ this.outsideHeight = value;
573
+ },
574
+ setAllNode(name, value) {
575
+ let tempName = name;
576
+ if (name === 'readOnly') {
577
+ tempName = 'disabled';
578
+ } else if (name === 'selected') {
579
+ if (this.myConfig.multiSelect && this.myConfig.showCheckBox) {
580
+ tempName ='checked';
581
+ } else {
582
+ tempName = 'selected';
583
+ }
584
+ }
585
+ if (this.$refs.tree && this.$refs.tree.flatState) {
586
+ this.$refs.tree.flatState.forEach(el => {
587
+ if (el.node[tempName] !== value) {
588
+ let obj ={};
589
+ obj[tempName] = value;
590
+ Object.assign(el.node,obj);
591
+ }
592
+ });
593
+ }
594
+ },
595
+ setNodes(data, name, value) {
596
+ let tempName = name;
597
+ if (name === 'readOnly') {
598
+ tempName = 'disabled';
599
+ } else if (name === 'selected') {
600
+ if (this.myConfig.multiSelect && this.myConfig.showCheckBox) {
601
+ tempName ='checked';
602
+ } else {
603
+ tempName = 'selected';
604
+ }
605
+ }
606
+ let responseId = this.myConfig.responseId;
607
+ this.$refs.tree.flatState.forEach(el => {
608
+ let index = data.findIndex(
609
+ el2 => el.node[responseId] === el2[responseId]
610
+ );
611
+ if (index > -1) {
612
+ if (el.node[tempName] !== value) {
613
+ let obj ={};
614
+ obj[tempName] = value;
615
+ Object.assign(el.node,obj);
616
+ }
617
+ } else {
618
+ if (el.node[tempName] !== !value) {
619
+ let obj ={};
620
+ obj[tempName] = !value;
621
+ Object.assign(el.node,obj);
622
+ }
623
+ }
624
+ });
625
+ },
626
+ updateNode(data,flag) {
627
+ let tmp = data;
628
+ if(flag !== 'D') {
629
+ tmp = this.setSelected(data);
630
+ }
631
+ tmp.selected = true;
632
+ if (this.$refs.tree && this.$refs.tree.flatState) {
633
+ let index = -1;
634
+ if (flag === 'U') {
635
+ index = this.$refs.tree.flatState.findIndex(el => el.node[this.myConfig.idField] === tmp[this.myConfig.idField]);
636
+ if (index > -1) {
637
+ if (this.$refs.tree.flatState[index].node.children && this.$refs.tree.flatState[index].node.children.length > 0) {
638
+ delete tmp.children;
639
+ }
640
+ Object.assign(this.$refs.tree.flatState[index].node,tmp);
641
+ } else {
642
+ index = this.$refs.tree.flatState.findIndex(el => el.node[this.myConfig.idField] === tmp[this.myConfig.parentField]);
643
+ if (index > -1) {
644
+ if (!this.$refs.tree.flatState[index].node.children){
645
+ this.$refs.tree.flatState[index].node.children = [];
646
+ }
647
+ this.$refs.tree.flatState[index].node.children.forEach(el2 => {
648
+ let tmpIndex = this.$refs.tree.flatState.findIndex(el => el.node[this.myConfig.idField] === el2[this.myConfig.idField] && el.node.selected);
649
+ if (tmpIndex > -1) {
650
+ Object.assign(this.$refs.tree.flatState[tmpIndex].node,{selected:false});
651
+ }
652
+ });
653
+ Object.assign(this.$refs.tree.flatState[index].node,{selected:false, expand:true});
654
+ this.$refs.tree.flatState[index].node.children.push(tmp)
655
+ }
656
+ }
657
+ }
658
+ if (flag === 'D') {
659
+ index = this.$refs.tree.flatState.findIndex(el => el.node[this.myConfig.idField] === tmp[this.myConfig.parentField]);
660
+ if (index > -1) {
661
+ let tmpIndex = this.$refs.tree.flatState[index].node.children.findIndex(el => el[this.myConfig.idField] === tmp[this.myConfig.idField]);
662
+ if (tmpIndex > -1) {
663
+ this.$refs.tree.flatState[index].node.children.splice(tmpIndex, 1);
664
+ if (this.$refs.tree.flatState[index].node.children.length === 0) {
665
+ Object.assign(this.$refs.tree.flatState[index].node,{expand:false});
666
+ }
667
+ }
668
+ }
669
+ }
670
+ }
671
+ },
672
+ setExpend(data) {
673
+ let index = this.$refs.tree.flatState.findIndex(el => el.node[this.myConfig.idField] === data[this.myConfig.idField]);
674
+ if (index > -1) {
675
+ let tmp = {expand:!this.$refs.tree.flatState[index].node.expand};
676
+ if (tmp.expand && this.asyncLoad) {
677
+ if (!this.$refs.tree.flatState[index].node.loading && this.$refs.tree.flatState[index].node.children.length === 0) {
678
+ tmp.loading = true;
679
+ };
680
+ let callback = (data) => {
681
+ data.forEach(el => {
682
+ el.selected = false;
683
+ this.$refs.tree.flatState[index].node.children.push(el);
684
+ })
685
+ Object.assign(this.$refs.tree.flatState[index].node,{loading:false});
686
+ }
687
+ if (this.$refs.tree.flatState[index].node.children.length === 0){
688
+ this.loadData(data,callback);
689
+ }
690
+
691
+ }
692
+ Object.assign(this.$refs.tree.flatState[index].node,tmp);
693
+ }
694
+ },
695
+ loadData (item, callback) {
696
+ let para = {};
697
+ para[this.myConfig.parentField] = item[this.myConfig.idField];
698
+ let data = this.getAsyncNode(para);
699
+ setTimeout(() => {
700
+ data.forEach(el => {
701
+ this.setSelected(el);
702
+ });
703
+ callback(data);
704
+ }, 200);
705
+ }
706
+ },
707
+ mounted () {
708
+ //this._setCustomHeight(this.clientHeight);
709
+ },
710
+ watch: {
711
+ 'myConfig.readOnly':function(val){
712
+ this.setAllNode('readOnly', val);
713
+ },
714
+ selectedData:function (val) {
715
+ this.setNodes(val,'selected', true);
716
+ }
717
+ }
718
+ };
719
+ </script>
720
+ <style>
721
+ .efutre-tree-node .ivu-tree-title{
722
+ width: 95%;
723
+ padding-left: 2px;
724
+ }
725
+ </style>