eoss-ui 0.6.51 → 0.6.52

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 (218) hide show
  1. package/lib/eoss-ui.common.js +546 -523
  2. package/lib/flow-list.js +110 -87
  3. package/lib/flow.js +280 -280
  4. package/lib/index.js +1 -1
  5. package/lib/main.js +132 -132
  6. package/lib/qr-code.js +13 -13
  7. package/lib/upload.js +6 -6
  8. package/package.json +159 -159
  9. package/packages/button/index.js +5 -5
  10. package/packages/button/src/main.vue +418 -418
  11. package/packages/button-group/index.js +5 -5
  12. package/packages/button-group/src/main.vue +298 -298
  13. package/packages/calendar/index.js +5 -5
  14. package/packages/card/index.js +5 -5
  15. package/packages/card/src/main.vue +156 -156
  16. package/packages/cascader/index.js +5 -5
  17. package/packages/cascader/src/main.vue +168 -168
  18. package/packages/checkbox-group/index.js +5 -5
  19. package/packages/checkbox-group/src/main.vue +333 -333
  20. package/packages/clients/index.js +5 -5
  21. package/packages/clients/src/main.vue +144 -144
  22. package/packages/data-table/index.js +5 -5
  23. package/packages/data-table/src/children.vue +39 -39
  24. package/packages/data-table/src/column.vue +989 -989
  25. package/packages/data-table/src/main.vue +1822 -1822
  26. package/packages/data-table/src/sizer.vue +195 -195
  27. package/packages/data-table-form/index.js +5 -5
  28. package/packages/data-table-form/src/checkbox.vue +101 -101
  29. package/packages/data-table-form/src/colgroup.vue +17 -17
  30. package/packages/data-table-form/src/main.vue +181 -181
  31. package/packages/data-table-form/src/radio.vue +65 -65
  32. package/packages/data-table-form/src/table.vue +233 -233
  33. package/packages/data-table-form/src/tbody.vue +336 -336
  34. package/packages/data-table-form/src/thead.vue +68 -68
  35. package/packages/date-picker/index.js +5 -5
  36. package/packages/date-picker/src/main.vue +236 -236
  37. package/packages/dialog/index.js +5 -5
  38. package/packages/enable-drag/index.js +5 -5
  39. package/packages/enterprise/index.js +5 -5
  40. package/packages/enterprise/src/main.vue +66 -66
  41. package/packages/error-page/index.js +5 -5
  42. package/packages/error-page/src/main.vue +44 -44
  43. package/packages/flow/index.js +5 -5
  44. package/packages/flow/src/component/CommonOpinions.vue +345 -345
  45. package/packages/flow/src/component/CustomPreset.vue +322 -322
  46. package/packages/flow/src/component/FileList.vue +99 -99
  47. package/packages/flow/src/component/Preset.vue +255 -255
  48. package/packages/flow/src/component/SendMsg.vue +229 -229
  49. package/packages/flow/src/component/TimeLimit.vue +190 -190
  50. package/packages/flow/src/component/taskUnionExamine.vue +611 -611
  51. package/packages/flow/src/form.vue +121 -121
  52. package/packages/flow/src/freeStartFlow.vue +2843 -2843
  53. package/packages/flow/src/main.vue +3131 -3131
  54. package/packages/flow/src/processForm.vue +1031 -1031
  55. package/packages/flow/src/processReject.vue +293 -293
  56. package/packages/flow/src/reset.vue +902 -902
  57. package/packages/flow/src/startTaskRead.vue +597 -597
  58. package/packages/flow/src/supervise.vue +138 -138
  59. package/packages/flow/src/table.vue +58 -58
  60. package/packages/flow-group/index.js +5 -5
  61. package/packages/flow-group/src/main.vue +688 -688
  62. package/packages/flow-list/index.js +5 -5
  63. package/packages/flow-list/src/main.vue +1434 -1411
  64. package/packages/form/index.js +5 -5
  65. package/packages/form/src/main.vue +3583 -3583
  66. package/packages/form/src/table.vue +1426 -1426
  67. package/packages/handle-user/index.js +5 -5
  68. package/packages/handle-user/src/main.vue +138 -138
  69. package/packages/handler/index.js +5 -5
  70. package/packages/handler/src/main.vue +493 -493
  71. package/packages/icon/index.js +5 -5
  72. package/packages/icon/src/main.vue +101 -101
  73. package/packages/icons/index.js +5 -5
  74. package/packages/icons/src/main.vue +81 -81
  75. package/packages/input/index.js +5 -5
  76. package/packages/input/src/main.vue +356 -356
  77. package/packages/input-number/index.js +5 -5
  78. package/packages/input-number/src/main.vue +106 -106
  79. package/packages/label/index.js +5 -5
  80. package/packages/label/src/main.vue +457 -457
  81. package/packages/layout/index.js +5 -5
  82. package/packages/layout/src/item.vue +152 -152
  83. package/packages/layout/src/main.vue +31 -31
  84. package/packages/login/index.js +5 -5
  85. package/packages/login/src/main.vue +1935 -1935
  86. package/packages/login/src/resetPassword.vue +562 -562
  87. package/packages/main/index.js +5 -5
  88. package/packages/main/src/default/message.vue +249 -249
  89. package/packages/main/src/default/notice.vue +157 -157
  90. package/packages/main/src/default/userinfo.vue +503 -503
  91. package/packages/main/src/public/online.vue +89 -89
  92. package/packages/main/src/public/search.vue +461 -461
  93. package/packages/main/src/public/settings.vue +221 -221
  94. package/packages/main/src/simplicity/apps.vue +388 -388
  95. package/packages/main/src/simplicity/avatar.vue +82 -82
  96. package/packages/main/src/simplicity/handler.vue +259 -259
  97. package/packages/main/src/simplicity/index.vue +2064 -2064
  98. package/packages/main/src/simplicity/lists.vue +84 -84
  99. package/packages/main/src/simplicity/menu-list.vue +128 -128
  100. package/packages/main/src/simplicity/message.vue +259 -259
  101. package/packages/main/src/simplicity/notice.vue +190 -190
  102. package/packages/main/src/simplicity/router-page.vue +45 -45
  103. package/packages/main/src/simplicity/sub-menu.vue +241 -241
  104. package/packages/main/src/simplicity/user.vue +257 -257
  105. package/packages/main/src/simplicity/userinfo.vue +312 -312
  106. package/packages/menu/index.js +5 -5
  107. package/packages/menu/src/main.vue +536 -536
  108. package/packages/nav/index.js +5 -5
  109. package/packages/nav/src/main.vue +351 -351
  110. package/packages/notify/index.js +5 -5
  111. package/packages/notify/src/main.vue +538 -538
  112. package/packages/page/index.js +5 -5
  113. package/packages/page/src/main.vue +167 -167
  114. package/packages/pagination/index.js +5 -5
  115. package/packages/pagination/src/main.vue +96 -96
  116. package/packages/player/index.js +5 -5
  117. package/packages/player/src/main.vue +194 -194
  118. package/packages/qr-code/index.js +5 -5
  119. package/packages/qr-code/src/main.vue +170 -170
  120. package/packages/radio-group/index.js +6 -6
  121. package/packages/radio-group/src/main.vue +319 -319
  122. package/packages/retrial-auth/index.js +5 -5
  123. package/packages/retrial-auth/src/main.vue +280 -280
  124. package/packages/select/index.js +5 -5
  125. package/packages/select/src/main.vue +775 -775
  126. package/packages/select-ganged/index.js +5 -5
  127. package/packages/select-ganged/src/main.vue +724 -724
  128. package/packages/selector/index.js +5 -5
  129. package/packages/selector/src/main.vue +687 -687
  130. package/packages/selector-panel/index.js +5 -5
  131. package/packages/selector-panel/src/main.vue +1027 -1027
  132. package/packages/selector-panel/src/selection.vue +177 -177
  133. package/packages/selector-panel/src/tree.vue +129 -129
  134. package/packages/sizer/index.js +5 -5
  135. package/packages/sizer/src/main.vue +254 -254
  136. package/packages/steps/index.js +5 -5
  137. package/packages/steps/src/main.vue +181 -181
  138. package/packages/switch/index.js +5 -5
  139. package/packages/switch/src/main.vue +154 -154
  140. package/packages/table-form/index.js +5 -5
  141. package/packages/tabs/index.js +5 -5
  142. package/packages/tabs/src/main.vue +788 -788
  143. package/packages/tabs-panel/index.js +5 -5
  144. package/packages/tabs-panel/src/main.vue +29 -29
  145. package/packages/theme-chalk/src/base.scss +260 -260
  146. package/packages/theme-chalk/src/button-group.scss +175 -175
  147. package/packages/theme-chalk/src/button.scss +24 -24
  148. package/packages/theme-chalk/src/calendar.scss +113 -113
  149. package/packages/theme-chalk/src/card.scss +99 -99
  150. package/packages/theme-chalk/src/checkbox-group.scss +8 -8
  151. package/packages/theme-chalk/src/clients.scss +87 -87
  152. package/packages/theme-chalk/src/data-table-form.scss +67 -67
  153. package/packages/theme-chalk/src/data-table.scss +293 -293
  154. package/packages/theme-chalk/src/date-picker.scss +7 -7
  155. package/packages/theme-chalk/src/dialog.scss +77 -77
  156. package/packages/theme-chalk/src/enable-drag.scss +181 -181
  157. package/packages/theme-chalk/src/enterprise.scss +5 -5
  158. package/packages/theme-chalk/src/error-page.scss +18 -18
  159. package/packages/theme-chalk/src/flow-group.scss +110 -110
  160. package/packages/theme-chalk/src/flow-list.scss +36 -36
  161. package/packages/theme-chalk/src/flow.scss +335 -335
  162. package/packages/theme-chalk/src/form.scss +496 -496
  163. package/packages/theme-chalk/src/handle-user.scss +40 -40
  164. package/packages/theme-chalk/src/handler.scss +143 -143
  165. package/packages/theme-chalk/src/icon.scss +1789 -1789
  166. package/packages/theme-chalk/src/icons.scss +99 -99
  167. package/packages/theme-chalk/src/input.scss +9 -9
  168. package/packages/theme-chalk/src/label.scss +24 -24
  169. package/packages/theme-chalk/src/layout.scss +46 -46
  170. package/packages/theme-chalk/src/login.scss +969 -969
  171. package/packages/theme-chalk/src/main.scss +663 -663
  172. package/packages/theme-chalk/src/menu.scss +222 -222
  173. package/packages/theme-chalk/src/mixins/color.scss +117 -117
  174. package/packages/theme-chalk/src/nav.scss +111 -111
  175. package/packages/theme-chalk/src/page.scss +3 -3
  176. package/packages/theme-chalk/src/pagination.scss +29 -29
  177. package/packages/theme-chalk/src/player.scss +9 -9
  178. package/packages/theme-chalk/src/qr-code.scss +17 -17
  179. package/packages/theme-chalk/src/radio-group.scss +9 -9
  180. package/packages/theme-chalk/src/retrial-auth.scss +38 -38
  181. package/packages/theme-chalk/src/select-ganged.scss +8 -8
  182. package/packages/theme-chalk/src/select.scss +8 -8
  183. package/packages/theme-chalk/src/selector-panel.scss +204 -204
  184. package/packages/theme-chalk/src/selector.scss +91 -91
  185. package/packages/theme-chalk/src/simplicity.scss +1265 -1265
  186. package/packages/theme-chalk/src/sizer.scss +36 -36
  187. package/packages/theme-chalk/src/steps.scss +88 -88
  188. package/packages/theme-chalk/src/switch.scss +3 -3
  189. package/packages/theme-chalk/src/table-form.scss +1 -1
  190. package/packages/theme-chalk/src/tabs.scss +87 -87
  191. package/packages/theme-chalk/src/tips.scss +7 -7
  192. package/packages/theme-chalk/src/toolbar.scss +179 -179
  193. package/packages/theme-chalk/src/tree-group.scss +72 -72
  194. package/packages/theme-chalk/src/tree.scss +165 -165
  195. package/packages/theme-chalk/src/upload.scss +167 -167
  196. package/packages/theme-chalk/src/wxlogin.scss +3 -3
  197. package/packages/tips/index.js +5 -5
  198. package/packages/tips/src/main.vue +141 -141
  199. package/packages/toolbar/index.js +5 -5
  200. package/packages/toolbar/src/main.vue +430 -430
  201. package/packages/tree/index.js +5 -5
  202. package/packages/tree-group/index.js +5 -5
  203. package/packages/upload/index.js +5 -5
  204. package/packages/upload/src/main.vue +1339 -1335
  205. package/packages/upload/src/picture.js +15 -15
  206. package/packages/wujie/index.js +5 -5
  207. package/packages/wujie/src/main.vue +145 -145
  208. package/packages/wxlogin/index.js +5 -5
  209. package/packages/wxlogin/src/main.vue +128 -128
  210. package/src/config/api.js +281 -281
  211. package/src/config/image.js +2 -2
  212. package/src/index.js +1 -1
  213. package/src/utils/bus.js +3 -3
  214. package/src/utils/date-util.js +312 -312
  215. package/src/utils/http.js +50 -50
  216. package/src/utils/rules.js +18 -18
  217. package/src/utils/store.js +21 -21
  218. package/src/utils/webSocket.js +107 -107
@@ -1,775 +1,775 @@
1
- <script>
2
- import { findSysCode, getDictList } from 'eoss-ui/src/config/api.js';
3
- import { debounce } from 'throttle-debounce';
4
- import store from 'eoss-ui/src/utils/store';
5
- import util from 'eoss-ui/src/utils/util';
6
- export default {
7
- name: 'EsSelect',
8
- componentName: 'EsSelect',
9
- inheritAttrs: false,
10
- provide() {
11
- return {
12
- esSelect: this
13
- };
14
- },
15
- inject: {
16
- esForm: {
17
- default: ''
18
- }
19
- },
20
- props: {
21
- service: String,
22
- value: [String, Array, Object, Number],
23
- method: {
24
- type: String,
25
- default: 'get'
26
- },
27
- param: {
28
- type: Object,
29
- default() {
30
- return {};
31
- }
32
- },
33
- // 显示隐藏组件
34
- display: {
35
- type: Boolean,
36
- default: true
37
- },
38
- // 是否不渲染组件
39
- hide: {
40
- type: Boolean,
41
- default: false
42
- },
43
- valueType: {
44
- type: String,
45
- default: 'string',
46
- validator: function (value) {
47
- return ['string', 'object'].includes(value);
48
- }
49
- },
50
- // 选择项的值字段
51
- valueKey: {
52
- type: String,
53
- default: 'value'
54
- },
55
- // 指定选择项显示值的键名,data元素是对象类型时必填
56
- labelKey: {
57
- type: String,
58
- default: 'name'
59
- },
60
- data: {
61
- type: Array,
62
- default() {
63
- return [];
64
- }
65
- },
66
- // 远程搜索
67
- remote: Boolean,
68
- remoteKey: {
69
- type: String,
70
- default: 'searchKey'
71
- },
72
- remoteMethod: Function,
73
- // 选择项远程地址
74
- url: String,
75
- // 选择项获取代码表数据(优先级大于url)
76
- sysCode: String,
77
- filtrate: [String, Object, Array],
78
- filtrateKey: {
79
- type: String,
80
- default: 'pid'
81
- },
82
- readonly: Boolean,
83
- separator: {
84
- type: String,
85
- default: '-'
86
- },
87
- symbol: {
88
- type: String,
89
- default: ','
90
- },
91
- plain: Boolean,
92
- where: Object,
93
- parseData: Function,
94
- disabled: Boolean,
95
- // 是否下拉树选择
96
- tree: {
97
- type: [Boolean, Object],
98
- default: false
99
- },
100
- // 父级是否可选
101
- parentCheck: {
102
- type: Boolean,
103
- default: true
104
- },
105
- // 父级可选时父级是否作为单独的值
106
- parentAsValue: {
107
- type: Boolean,
108
- default: true
109
- },
110
- group: Boolean,
111
- multiple: Boolean,
112
- defaultValue: Boolean,
113
- onExpand: Function,
114
- onLoadsub: Function,
115
- subParamKey: Object,
116
- lazy: Boolean,
117
- //是否请求代码表
118
- ajax: {
119
- type: Boolean,
120
- default: true
121
- },
122
- isNoParamRequest: {
123
- type: Boolean,
124
- default: true
125
- },
126
- dataKey: String
127
- },
128
- data() {
129
- return {
130
- loading: false,
131
- options: '',
132
- valKey: this.valueKey,
133
- label: this.labelKey,
134
- hidden: false,
135
- canceled: false
136
- };
137
- },
138
- computed: {
139
- isObject() {
140
- if (this.valueType === 'object') {
141
- return true;
142
- }
143
- if (
144
- util.isObject(this.value) ||
145
- (this.value && this.value[0] && util.isObject(this.value[0]))
146
- ) {
147
- return true;
148
- }
149
- return false;
150
- },
151
- isRemote() {
152
- return new Boolean(this.remote);
153
- },
154
- results() {
155
- if (this.options.length) {
156
- return this.options;
157
- }
158
- if (this.filtrate) {
159
- if (Array.isArray(this.filtrate) && this.filtrate.length) {
160
- let ary = [];
161
- this.filtrate.forEach((items) => {
162
- let val = typeof items === 'string' ? items : items[this.valKey];
163
- ary = ary.concat(
164
- this.data.filter((item) => {
165
- return item[this.filtrateKey] == val;
166
- })
167
- );
168
- });
169
- return ary;
170
- } else {
171
- let val =
172
- typeof this.filtrate === 'string'
173
- ? this.filtrate
174
- : this.filtrate[this.valKey];
175
- return this.data.filter((item) => {
176
- return item[this.filtrateKey] == val;
177
- });
178
- }
179
- }
180
- return this.data;
181
- },
182
- models: {
183
- get() {
184
- return this.value;
185
- },
186
- set(val) {
187
- return val;
188
- }
189
- },
190
- findCode() {
191
- if (this.service) {
192
- return `/${this.service}${getDictList}`;
193
- }
194
- return findSysCode;
195
- }
196
- },
197
- watch: {
198
- sysCode: {
199
- immediate: true,
200
- handler(val, old) {
201
- if (val && val !== old) {
202
- this.label = this.service ? 'label' : 'shortName';
203
- this.valKey = this.service ? 'value' : 'cciValue';
204
- const options = store.get(val);
205
- if (options) {
206
- this.options = JSON.parse(JSON.stringify(options));
207
- } else {
208
- this.getData(val);
209
- }
210
- }
211
- }
212
- },
213
- url: {
214
- immediate: true,
215
- handler(val, old) {
216
- if (val && old !== val && !this.sysCode) {
217
- this.getData(this.sysCode);
218
- }
219
- }
220
- },
221
- param: {
222
- deep: true,
223
- handler(val, old) {
224
- if (this.url && JSON.stringify(val) !== JSON.stringify(old)) {
225
- this.options = [];
226
- this.getData(this.sysCode);
227
- }
228
- }
229
- }
230
- },
231
- beforeCreate() {
232
- this.getData = debounce(500, (sysCode, param, reload) => {
233
- this.getDatas(sysCode, param, reload);
234
- });
235
- },
236
- created() {
237
- this.bindEventBus();
238
- },
239
- mounted() {},
240
- methods: {
241
- createOption({ filtrate, data, readonly = false, h }) {
242
- let filte =
243
- filtrate && util.isObject(filtrate) ? filtrate[this.valKey] : filtrate;
244
- let eles = [];
245
- data.forEach((item) => {
246
- if (this.models === undefined && item.selected) {
247
- this.$emit(
248
- 'input',
249
- this.valueType === 'object' ? item : item[this.valKey]
250
- );
251
- }
252
- if (
253
- (Object.prototype.hasOwnProperty.call(item, 'children') ||
254
- Object.prototype.hasOwnProperty.call(item, 'options')) &&
255
- (item.children || item.options)
256
- ) {
257
- const children = item.children || item.options;
258
- if (readonly) {
259
- eles.push(
260
- this.createOption({ filtrate, data: children, readonly, h })
261
- );
262
- } else {
263
- eles.push(
264
- h(
265
- 'el-option-group',
266
- { attrs: { label: item[this.label] || item.label } },
267
- this.createOption({ filtrate, data: children, readonly, h })
268
- )
269
- );
270
- }
271
- } else {
272
- if (readonly) {
273
- if (item[this.valKey] === filte) {
274
- eles.push(item[this.label] || item.label);
275
- }
276
- } else {
277
- if (
278
- filte === null ||
279
- filte === undefined ||
280
- filte === '' ||
281
- filte === item[this.filtrateKey]
282
- ) {
283
- if (typeof item === 'string') {
284
- eles.push(
285
- h('el-option', {
286
- attrs: {
287
- label: item,
288
- value: item
289
- }
290
- })
291
- );
292
- } else {
293
- let content = [];
294
- const labelContent = item[this.label] || item.label;
295
- //判断它是否是html字符串
296
- if (
297
- typeof labelContent === 'string' &&
298
- /<[^>]+>/.test(labelContent)
299
- ) {
300
- // 如果是 HTML 字符串,创建对应的 VNode
301
- content = [
302
- h('div', { domProps: { innerHTML: labelContent } })
303
- ];
304
- } else {
305
- content = [labelContent];
306
- }
307
- if (item.render) {
308
- content = [item.render(h, item)];
309
- }
310
- if (item.tips) {
311
- let attrs =
312
- typeof item.tips == 'string'
313
- ? { content: item.tips }
314
- : item.tips;
315
- content.push(
316
- h('es-tips', {
317
- attrs: attrs
318
- })
319
- );
320
- }
321
-
322
- eles.push(
323
- h(
324
- 'el-option',
325
- {
326
- attrs: {
327
- label: item[this.label] || item.label,
328
- value: this.isObject ? item : item[this.valKey],
329
- disabled: item.disabled
330
- }
331
- },
332
- content
333
- )
334
- );
335
- }
336
- }
337
- }
338
- }
339
- });
340
- return eles;
341
- },
342
- getDatas(sysCode, param, reload) {
343
- if (
344
- !reload &&
345
- (!this.ajax ||
346
- (!this.isNoParamRequest && Object.keys(this.param).length == 0))
347
- ) {
348
- return false;
349
- }
350
- let params = {};
351
- if (this.results.length === 0 || reload) {
352
- params = util.extend(
353
- {},
354
- this.param,
355
- sysCode ? { sysAppCode: sysCode, code: sysCode } : {},
356
- param ? param : {}
357
- );
358
- } else {
359
- return false;
360
- }
361
- if (!sysCode && !this.url) {
362
- return false;
363
- }
364
- this.loading = true;
365
- util
366
- .ajax({
367
- url: sysCode ? this.findCode : this.url,
368
- method: this.method,
369
- params: params,
370
- data: params
371
- })
372
- .then((res) => {
373
- this.loading = false;
374
- this.canceled = false;
375
- if (res.rCode === 0) {
376
- if (this.parseData) {
377
- this.options = this.parseData(
378
- JSON.parse(JSON.stringify(res.results))
379
- );
380
- } else {
381
- this.options = JSON.parse(JSON.stringify(res.results));
382
- }
383
- if (sysCode || this.dataKey) {
384
- const bus = this.bus || this.$root.Bus;
385
- bus &&
386
- bus.$emit(
387
- sysCode || this.dataKey,
388
- JSON.parse(JSON.stringify(this.options))
389
- );
390
- store.set(sysCode, JSON.parse(JSON.stringify(this.options)));
391
- }
392
- } else {
393
- this.$message.error(res.msg);
394
- }
395
- })
396
- .catch((err) => {
397
- this.loading = false;
398
- if (err.message) {
399
- if (err.message !== 'canceled') {
400
- this.$message.error(err.message);
401
- }
402
- if (err.message === 'canceled' && sysCode) {
403
- this.canceled = true;
404
- }
405
- }
406
- });
407
- },
408
- search(query) {
409
- if (query && query !== '') {
410
- if (this.url && this.url !== '') {
411
- this.loading = true;
412
- let params = {};
413
- params[this.remoteKey] = query;
414
- params = util.extend({}, this.param, params);
415
- util
416
- .ajax({
417
- url: this.url,
418
- method: this.method,
419
- params: params,
420
- data: params
421
- })
422
- .then((res) => {
423
- this.loading = false;
424
- if (res.rCode === 0) {
425
- this.options = JSON.parse(JSON.stringify(res.results));
426
- }
427
- })
428
- .catch((err) => {
429
- this.loading = false;
430
- if (err.message && err.message !== 'canceled') {
431
- this.$message.error(err.message);
432
- }
433
- });
434
- } else {
435
- this.options = [];
436
- }
437
- } else {
438
- this.options = this.data;
439
- }
440
- },
441
- renderd(doms, h, type) {
442
- if (typeof this.$attrs[type] === 'boolean') {
443
- if (this.$attrs.render) {
444
- if (typeof this.$attrs.render == 'string') {
445
- try {
446
- doms.push(
447
- h(
448
- 'template',
449
- { slot: type },
450
- util.toFunction(this.$attrs.render)(h, this)
451
- )
452
- );
453
- } catch (error) {
454
- throw error;
455
- }
456
- } else {
457
- doms.push(
458
- h('template', { slot: type }, this.$attrs.render(h, this))
459
- );
460
- }
461
- }
462
- } else if (typeof this.$attrs[type] === 'object') {
463
- doms.push(
464
- h(
465
- 'es-button',
466
- {
467
- slot: type,
468
- class: ['el-primeval', this.$attrs[type].class],
469
- props: {
470
- ...this.$attrs[type].props,
471
- size: this.$attrs[type].size
472
- ? this.$attrs[type].size
473
- : type === 'prefix' || type === 'suffix'
474
- ? 'small'
475
- : '',
476
- type: 'primary'
477
- },
478
- domProps: this.$attrs[type].icon
479
- ? { innerHTML: this.$attrs[type].icon }
480
- : {},
481
- on: {
482
- click: (e) => {
483
- this.$attrs[type].click &&
484
- this.$attrs[type].click(this, this.model);
485
- this.$attrs[type].event &&
486
- this.$attrs[type].event(this, this.model);
487
- }
488
- },
489
- ref: 'selectBtn'
490
- },
491
- [this.$attrs[type].text]
492
- )
493
- );
494
- } else {
495
- doms.push(h('template', { slot: type }, [this.$attrs[type]]));
496
- }
497
- },
498
- getLabel(value, data) {
499
- if ((value || value === 0) && data) {
500
- if (util.isObject(data)) {
501
- if (value === data[this.valKey]) {
502
- return data[this.label];
503
- } else if (value === data[this.label]) {
504
- return value;
505
- } else if (
506
- Object.prototype.hasOwnProperty.call(data, 'children') &&
507
- data.children &&
508
- data.children.length
509
- ) {
510
- let val = this.getLabel(value, data.children);
511
- if (val) {
512
- return val;
513
- }
514
- }
515
- } else {
516
- if (
517
- typeof data === 'string' ||
518
- (!data.length && !this.sysCode && !this.url)
519
- ) {
520
- return value;
521
- }
522
- if (Array.isArray(data) && data.length) {
523
- for (let i = 0; i < data.length; i++) {
524
- let val = this.getLabel(value, data[i]);
525
- if (val) {
526
- return val;
527
- }
528
- }
529
- }
530
- }
531
- }
532
- return '';
533
- },
534
- reload() {
535
- this.getData(...arguments);
536
- },
537
- handleExpand(data, node) {
538
- if (this.onExpand) {
539
- this.onExpand(data, node);
540
- } else {
541
- if (this.lazy) {
542
- this.loadsub(data, node);
543
- }
544
- this.$emit('node-expand', data, node);
545
- }
546
- },
547
- //请求子节点数据
548
- loadsub(data, node) {
549
- if (data.state !== '' && (!data.children || data.children.length === 0)) {
550
- let param = {};
551
- if (this.subParamKey) {
552
- for (let i in this.subParamKey) {
553
- param[i] = data[this.subParamKey[i]];
554
- }
555
- } else {
556
- param[this.valKey] = data[this.valKey];
557
- }
558
- let params = util.extend({}, this.param, this.where, param);
559
- if (this.parseParams) {
560
- params = this.parseParams({ data, params, node });
561
- }
562
- if (this.onLoadsub) {
563
- this.onLoadsub({ data, params, node })
564
- .then((res) => {
565
- this.loading = false;
566
- this.$set(data, 'children', JSON.parse(JSON.stringify(res)));
567
- if (this.dataKey && this.esForm) {
568
- this.esForm.setSysCodes(
569
- this.dataKey,
570
- JSON.parse(JSON.stringify(this.options))
571
- );
572
- }
573
- })
574
- .catch((e) => {
575
- this.loading = false;
576
- });
577
- } else {
578
- util
579
- .ajax({
580
- method: this.method,
581
- url: this.url,
582
- data: params,
583
- params: params
584
- })
585
- .then((res) => {
586
- if (res.rCode === 0) {
587
- this.loading = false;
588
- let results = JSON.parse(JSON.stringify(res.results));
589
- if (Array.isArray(results)) {
590
- if (data.id === results[0].id) {
591
- this.$set(data, 'children', results[0].children);
592
- } else {
593
- this.$set(data, 'children', results);
594
- }
595
- } else if (data.id === results.id) {
596
- this.$set(data, 'children', results.children);
597
- } else {
598
- console.error('tree数据格式错误');
599
- }
600
- if (this.dataKey && this.esForm) {
601
- this.esForm.setSysCodes(
602
- this.dataKey,
603
- JSON.parse(JSON.stringify(this.options))
604
- );
605
- }
606
- }
607
- })
608
- .catch((err) => {
609
- this.loading = false;
610
- if (err.message && err.message !== 'canceled') {
611
- this.$message.error(err.message);
612
- }
613
- });
614
- }
615
- }
616
- },
617
- toggleMenu() {
618
- this.$refs.elSelect.toggleMenu();
619
- },
620
- setOptions(val) {
621
- this.options = val;
622
- },
623
- bindEventBus() {
624
- const bus = this.bus || this.$root.Bus;
625
- bus && bus.$on(this.sysCode || this.dataKey, this.setOptions);
626
- },
627
- unbindEventBus() {
628
- const bus = this.bus || this.$root.Bus;
629
- bus && bus.$off(this.sysCode || this.dataKey, this.setOptions);
630
- }
631
- },
632
- beforeDestroy() {
633
- this.unbindEventBus();
634
- },
635
- render(h) {
636
- if (!this.hide) {
637
- if (this.readonly) {
638
- let dom = [];
639
- if (Array.isArray(this.models)) {
640
- dom = this.models.map((item) => {
641
- if (util.isObject(item)) {
642
- if (!item[this.label] && !item.label) {
643
- return this.getLabel(value[this.valKey], data);
644
- }
645
- return item[this.label] || item.label;
646
- }
647
- return this.getLabel(item, this.results);
648
- });
649
- } else if (util.isObject(this.models)) {
650
- if (!this.models[this.label] && !this.models.label) {
651
- dom = [this.getLabel(this.models[this.valKey], this.results)];
652
- } else {
653
- dom = [this.models[this.label] || this.models.label];
654
- }
655
- } else {
656
- dom = [this.getLabel(this.models, this.results)];
657
- }
658
- return h(
659
- 'div',
660
- {
661
- class: [
662
- {
663
- 'es-plain': this.plain,
664
- 'es-textarea__inner el-textarea__inner': this.multiple,
665
- 'el-input__inner es-input__inner': !this.multiple
666
- }
667
- ]
668
- },
669
- [dom.join(this.symbol)]
670
- );
671
- }
672
- let doms = [];
673
- let cls = [];
674
- if (this.results.length && !this.tree) {
675
- if (this.filtrate && Array.isArray(this.filtrate)) {
676
- doms = this.filtrate.map((item) => {
677
- return h(
678
- 'el-option-group',
679
- {
680
- attrs: {
681
- label: item[this.label] || item.label,
682
- key: item[this.valKey]
683
- }
684
- },
685
- this.createOption({ filtrate: item, data: this.results, h })
686
- );
687
- });
688
- } else {
689
- doms = this.createOption({
690
- filtrate: this.filtrate,
691
- data: this.results,
692
- h
693
- });
694
- }
695
- }
696
- let { prefix, suffix, prepend, append, ...attrs } = this.$attrs;
697
- if (this.$slots.prefix) {
698
- doms.push(h('template', { slot: 'prefix' }, this.$slots.prefix));
699
- } else if (prefix) {
700
- this.renderd(doms, h, 'prefix');
701
- cls.push('es-select-button-prefix');
702
- }
703
- if (this.$slots.suffix) {
704
- doms.push(h('template', { slot: 'suffix' }, this.$slots.suffix));
705
- } else if (suffix) {
706
- this.renderd(doms, h, 'suffix');
707
- cls.push('es-select-button-suffix');
708
- }
709
- if (this.$slots.prepend) {
710
- doms.push(h('template', { slot: 'prepend' }, this.$slots.prepend));
711
- } else if (prepend) {
712
- this.renderd(doms, h, 'prepend');
713
- }
714
- if (this.$slots.append) {
715
- doms.push(h('template', { slot: 'append' }, this.$slots.append));
716
- } else if (append) {
717
- this.renderd(doms, h, 'append');
718
- }
719
- if (!this.models && this.results.length && this.defaultValue) {
720
- if (this.valueType === 'object') {
721
- this.models = this.results[0];
722
- //this.$emit('input', this.results[0]);
723
- } else {
724
- this.models = this.results[0][this.valKey];
725
- //this.$emit('input', this.results[0][this.valKey]);
726
- }
727
- this.$emit('change', this.results[0], 0);
728
- }
729
- return h(
730
- 'el-select',
731
- {
732
- class: cls,
733
- ref: 'elSelect',
734
- directives: [
735
- {
736
- name: 'show',
737
- value: this.display
738
- }
739
- ],
740
- props: {
741
- ...attrs,
742
- multiple: this.multiple,
743
- valueType: this.valueType,
744
- valueKey: this.valKey,
745
- labelKey: this.label,
746
- loading: this.loading,
747
- disabled: this.disabled,
748
- tree:
749
- typeof this.tree === 'boolean'
750
- ? this.tree
751
- : { ...this.tree, lazy: this.label },
752
- data: this.results,
753
- // 父级是否可选
754
- parentCheck: this.parentCheck,
755
- // 父级可选时父级是否作为单独的值
756
- parentAsValue: this.parentAsValue,
757
- value: this.models
758
- },
759
- attrs: {
760
- remoteMethod: !this.remoteMethod ? this.search : this.remoteMethod,
761
- remote: this.remote
762
- },
763
- on: {
764
- ...this.$listeners,
765
- 'node-expand': this.handleExpand
766
- }
767
- },
768
- this.$slots.default ? this.$slots.default : doms
769
- );
770
- } else {
771
- return '';
772
- }
773
- }
774
- };
775
- </script>
1
+ <script>
2
+ import { findSysCode, getDictList } from 'eoss-ui/src/config/api.js';
3
+ import { debounce } from 'throttle-debounce';
4
+ import store from 'eoss-ui/src/utils/store';
5
+ import util from 'eoss-ui/src/utils/util';
6
+ export default {
7
+ name: 'EsSelect',
8
+ componentName: 'EsSelect',
9
+ inheritAttrs: false,
10
+ provide() {
11
+ return {
12
+ esSelect: this
13
+ };
14
+ },
15
+ inject: {
16
+ esForm: {
17
+ default: ''
18
+ }
19
+ },
20
+ props: {
21
+ service: String,
22
+ value: [String, Array, Object, Number],
23
+ method: {
24
+ type: String,
25
+ default: 'get'
26
+ },
27
+ param: {
28
+ type: Object,
29
+ default() {
30
+ return {};
31
+ }
32
+ },
33
+ // 显示隐藏组件
34
+ display: {
35
+ type: Boolean,
36
+ default: true
37
+ },
38
+ // 是否不渲染组件
39
+ hide: {
40
+ type: Boolean,
41
+ default: false
42
+ },
43
+ valueType: {
44
+ type: String,
45
+ default: 'string',
46
+ validator: function (value) {
47
+ return ['string', 'object'].includes(value);
48
+ }
49
+ },
50
+ // 选择项的值字段
51
+ valueKey: {
52
+ type: String,
53
+ default: 'value'
54
+ },
55
+ // 指定选择项显示值的键名,data元素是对象类型时必填
56
+ labelKey: {
57
+ type: String,
58
+ default: 'name'
59
+ },
60
+ data: {
61
+ type: Array,
62
+ default() {
63
+ return [];
64
+ }
65
+ },
66
+ // 远程搜索
67
+ remote: Boolean,
68
+ remoteKey: {
69
+ type: String,
70
+ default: 'searchKey'
71
+ },
72
+ remoteMethod: Function,
73
+ // 选择项远程地址
74
+ url: String,
75
+ // 选择项获取代码表数据(优先级大于url)
76
+ sysCode: String,
77
+ filtrate: [String, Object, Array],
78
+ filtrateKey: {
79
+ type: String,
80
+ default: 'pid'
81
+ },
82
+ readonly: Boolean,
83
+ separator: {
84
+ type: String,
85
+ default: '-'
86
+ },
87
+ symbol: {
88
+ type: String,
89
+ default: ','
90
+ },
91
+ plain: Boolean,
92
+ where: Object,
93
+ parseData: Function,
94
+ disabled: Boolean,
95
+ // 是否下拉树选择
96
+ tree: {
97
+ type: [Boolean, Object],
98
+ default: false
99
+ },
100
+ // 父级是否可选
101
+ parentCheck: {
102
+ type: Boolean,
103
+ default: true
104
+ },
105
+ // 父级可选时父级是否作为单独的值
106
+ parentAsValue: {
107
+ type: Boolean,
108
+ default: true
109
+ },
110
+ group: Boolean,
111
+ multiple: Boolean,
112
+ defaultValue: Boolean,
113
+ onExpand: Function,
114
+ onLoadsub: Function,
115
+ subParamKey: Object,
116
+ lazy: Boolean,
117
+ //是否请求代码表
118
+ ajax: {
119
+ type: Boolean,
120
+ default: true
121
+ },
122
+ isNoParamRequest: {
123
+ type: Boolean,
124
+ default: true
125
+ },
126
+ dataKey: String
127
+ },
128
+ data() {
129
+ return {
130
+ loading: false,
131
+ options: '',
132
+ valKey: this.valueKey,
133
+ label: this.labelKey,
134
+ hidden: false,
135
+ canceled: false
136
+ };
137
+ },
138
+ computed: {
139
+ isObject() {
140
+ if (this.valueType === 'object') {
141
+ return true;
142
+ }
143
+ if (
144
+ util.isObject(this.value) ||
145
+ (this.value && this.value[0] && util.isObject(this.value[0]))
146
+ ) {
147
+ return true;
148
+ }
149
+ return false;
150
+ },
151
+ isRemote() {
152
+ return new Boolean(this.remote);
153
+ },
154
+ results() {
155
+ if (this.options.length) {
156
+ return this.options;
157
+ }
158
+ if (this.filtrate) {
159
+ if (Array.isArray(this.filtrate) && this.filtrate.length) {
160
+ let ary = [];
161
+ this.filtrate.forEach((items) => {
162
+ let val = typeof items === 'string' ? items : items[this.valKey];
163
+ ary = ary.concat(
164
+ this.data.filter((item) => {
165
+ return item[this.filtrateKey] == val;
166
+ })
167
+ );
168
+ });
169
+ return ary;
170
+ } else {
171
+ let val =
172
+ typeof this.filtrate === 'string'
173
+ ? this.filtrate
174
+ : this.filtrate[this.valKey];
175
+ return this.data.filter((item) => {
176
+ return item[this.filtrateKey] == val;
177
+ });
178
+ }
179
+ }
180
+ return this.data;
181
+ },
182
+ models: {
183
+ get() {
184
+ return this.value;
185
+ },
186
+ set(val) {
187
+ return val;
188
+ }
189
+ },
190
+ findCode() {
191
+ if (this.service) {
192
+ return `/${this.service}${getDictList}`;
193
+ }
194
+ return findSysCode;
195
+ }
196
+ },
197
+ watch: {
198
+ sysCode: {
199
+ immediate: true,
200
+ handler(val, old) {
201
+ if (val && val !== old) {
202
+ this.label = this.service ? 'label' : 'shortName';
203
+ this.valKey = this.service ? 'value' : 'cciValue';
204
+ const options = store.get(val);
205
+ if (options) {
206
+ this.options = JSON.parse(JSON.stringify(options));
207
+ } else {
208
+ this.getData(val);
209
+ }
210
+ }
211
+ }
212
+ },
213
+ url: {
214
+ immediate: true,
215
+ handler(val, old) {
216
+ if (val && old !== val && !this.sysCode) {
217
+ this.getData(this.sysCode);
218
+ }
219
+ }
220
+ },
221
+ param: {
222
+ deep: true,
223
+ handler(val, old) {
224
+ if (this.url && JSON.stringify(val) !== JSON.stringify(old)) {
225
+ this.options = [];
226
+ this.getData(this.sysCode);
227
+ }
228
+ }
229
+ }
230
+ },
231
+ beforeCreate() {
232
+ this.getData = debounce(500, (sysCode, param, reload) => {
233
+ this.getDatas(sysCode, param, reload);
234
+ });
235
+ },
236
+ created() {
237
+ this.bindEventBus();
238
+ },
239
+ mounted() {},
240
+ methods: {
241
+ createOption({ filtrate, data, readonly = false, h }) {
242
+ let filte =
243
+ filtrate && util.isObject(filtrate) ? filtrate[this.valKey] : filtrate;
244
+ let eles = [];
245
+ data.forEach((item) => {
246
+ if (this.models === undefined && item.selected) {
247
+ this.$emit(
248
+ 'input',
249
+ this.valueType === 'object' ? item : item[this.valKey]
250
+ );
251
+ }
252
+ if (
253
+ (Object.prototype.hasOwnProperty.call(item, 'children') ||
254
+ Object.prototype.hasOwnProperty.call(item, 'options')) &&
255
+ (item.children || item.options)
256
+ ) {
257
+ const children = item.children || item.options;
258
+ if (readonly) {
259
+ eles.push(
260
+ this.createOption({ filtrate, data: children, readonly, h })
261
+ );
262
+ } else {
263
+ eles.push(
264
+ h(
265
+ 'el-option-group',
266
+ { attrs: { label: item[this.label] || item.label } },
267
+ this.createOption({ filtrate, data: children, readonly, h })
268
+ )
269
+ );
270
+ }
271
+ } else {
272
+ if (readonly) {
273
+ if (item[this.valKey] === filte) {
274
+ eles.push(item[this.label] || item.label);
275
+ }
276
+ } else {
277
+ if (
278
+ filte === null ||
279
+ filte === undefined ||
280
+ filte === '' ||
281
+ filte === item[this.filtrateKey]
282
+ ) {
283
+ if (typeof item === 'string') {
284
+ eles.push(
285
+ h('el-option', {
286
+ attrs: {
287
+ label: item,
288
+ value: item
289
+ }
290
+ })
291
+ );
292
+ } else {
293
+ let content = [];
294
+ const labelContent = item[this.label] || item.label;
295
+ //判断它是否是html字符串
296
+ if (
297
+ typeof labelContent === 'string' &&
298
+ /<[^>]+>/.test(labelContent)
299
+ ) {
300
+ // 如果是 HTML 字符串,创建对应的 VNode
301
+ content = [
302
+ h('div', { domProps: { innerHTML: labelContent } })
303
+ ];
304
+ } else {
305
+ content = [labelContent];
306
+ }
307
+ if (item.render) {
308
+ content = [item.render(h, item)];
309
+ }
310
+ if (item.tips) {
311
+ let attrs =
312
+ typeof item.tips == 'string'
313
+ ? { content: item.tips }
314
+ : item.tips;
315
+ content.push(
316
+ h('es-tips', {
317
+ attrs: attrs
318
+ })
319
+ );
320
+ }
321
+
322
+ eles.push(
323
+ h(
324
+ 'el-option',
325
+ {
326
+ attrs: {
327
+ label: item[this.label] || item.label,
328
+ value: this.isObject ? item : item[this.valKey],
329
+ disabled: item.disabled
330
+ }
331
+ },
332
+ content
333
+ )
334
+ );
335
+ }
336
+ }
337
+ }
338
+ }
339
+ });
340
+ return eles;
341
+ },
342
+ getDatas(sysCode, param, reload) {
343
+ if (
344
+ !reload &&
345
+ (!this.ajax ||
346
+ (!this.isNoParamRequest && Object.keys(this.param).length == 0))
347
+ ) {
348
+ return false;
349
+ }
350
+ let params = {};
351
+ if (this.results.length === 0 || reload) {
352
+ params = util.extend(
353
+ {},
354
+ this.param,
355
+ sysCode ? { sysAppCode: sysCode, code: sysCode } : {},
356
+ param ? param : {}
357
+ );
358
+ } else {
359
+ return false;
360
+ }
361
+ if (!sysCode && !this.url) {
362
+ return false;
363
+ }
364
+ this.loading = true;
365
+ util
366
+ .ajax({
367
+ url: sysCode ? this.findCode : this.url,
368
+ method: this.method,
369
+ params: params,
370
+ data: params
371
+ })
372
+ .then((res) => {
373
+ this.loading = false;
374
+ this.canceled = false;
375
+ if (res.rCode === 0) {
376
+ if (this.parseData) {
377
+ this.options = this.parseData(
378
+ JSON.parse(JSON.stringify(res.results))
379
+ );
380
+ } else {
381
+ this.options = JSON.parse(JSON.stringify(res.results));
382
+ }
383
+ if (sysCode || this.dataKey) {
384
+ const bus = this.bus || this.$root.Bus;
385
+ bus &&
386
+ bus.$emit(
387
+ sysCode || this.dataKey,
388
+ JSON.parse(JSON.stringify(this.options))
389
+ );
390
+ store.set(sysCode, JSON.parse(JSON.stringify(this.options)));
391
+ }
392
+ } else {
393
+ this.$message.error(res.msg);
394
+ }
395
+ })
396
+ .catch((err) => {
397
+ this.loading = false;
398
+ if (err.message) {
399
+ if (err.message !== 'canceled') {
400
+ this.$message.error(err.message);
401
+ }
402
+ if (err.message === 'canceled' && sysCode) {
403
+ this.canceled = true;
404
+ }
405
+ }
406
+ });
407
+ },
408
+ search(query) {
409
+ if (query && query !== '') {
410
+ if (this.url && this.url !== '') {
411
+ this.loading = true;
412
+ let params = {};
413
+ params[this.remoteKey] = query;
414
+ params = util.extend({}, this.param, params);
415
+ util
416
+ .ajax({
417
+ url: this.url,
418
+ method: this.method,
419
+ params: params,
420
+ data: params
421
+ })
422
+ .then((res) => {
423
+ this.loading = false;
424
+ if (res.rCode === 0) {
425
+ this.options = JSON.parse(JSON.stringify(res.results));
426
+ }
427
+ })
428
+ .catch((err) => {
429
+ this.loading = false;
430
+ if (err.message && err.message !== 'canceled') {
431
+ this.$message.error(err.message);
432
+ }
433
+ });
434
+ } else {
435
+ this.options = [];
436
+ }
437
+ } else {
438
+ this.options = this.data;
439
+ }
440
+ },
441
+ renderd(doms, h, type) {
442
+ if (typeof this.$attrs[type] === 'boolean') {
443
+ if (this.$attrs.render) {
444
+ if (typeof this.$attrs.render == 'string') {
445
+ try {
446
+ doms.push(
447
+ h(
448
+ 'template',
449
+ { slot: type },
450
+ util.toFunction(this.$attrs.render)(h, this)
451
+ )
452
+ );
453
+ } catch (error) {
454
+ throw error;
455
+ }
456
+ } else {
457
+ doms.push(
458
+ h('template', { slot: type }, this.$attrs.render(h, this))
459
+ );
460
+ }
461
+ }
462
+ } else if (typeof this.$attrs[type] === 'object') {
463
+ doms.push(
464
+ h(
465
+ 'es-button',
466
+ {
467
+ slot: type,
468
+ class: ['el-primeval', this.$attrs[type].class],
469
+ props: {
470
+ ...this.$attrs[type].props,
471
+ size: this.$attrs[type].size
472
+ ? this.$attrs[type].size
473
+ : type === 'prefix' || type === 'suffix'
474
+ ? 'small'
475
+ : '',
476
+ type: 'primary'
477
+ },
478
+ domProps: this.$attrs[type].icon
479
+ ? { innerHTML: this.$attrs[type].icon }
480
+ : {},
481
+ on: {
482
+ click: (e) => {
483
+ this.$attrs[type].click &&
484
+ this.$attrs[type].click(this, this.model);
485
+ this.$attrs[type].event &&
486
+ this.$attrs[type].event(this, this.model);
487
+ }
488
+ },
489
+ ref: 'selectBtn'
490
+ },
491
+ [this.$attrs[type].text]
492
+ )
493
+ );
494
+ } else {
495
+ doms.push(h('template', { slot: type }, [this.$attrs[type]]));
496
+ }
497
+ },
498
+ getLabel(value, data) {
499
+ if ((value || value === 0) && data) {
500
+ if (util.isObject(data)) {
501
+ if (value === data[this.valKey]) {
502
+ return data[this.label];
503
+ } else if (value === data[this.label]) {
504
+ return value;
505
+ } else if (
506
+ Object.prototype.hasOwnProperty.call(data, 'children') &&
507
+ data.children &&
508
+ data.children.length
509
+ ) {
510
+ let val = this.getLabel(value, data.children);
511
+ if (val) {
512
+ return val;
513
+ }
514
+ }
515
+ } else {
516
+ if (
517
+ typeof data === 'string' ||
518
+ (!data.length && !this.sysCode && !this.url)
519
+ ) {
520
+ return value;
521
+ }
522
+ if (Array.isArray(data) && data.length) {
523
+ for (let i = 0; i < data.length; i++) {
524
+ let val = this.getLabel(value, data[i]);
525
+ if (val) {
526
+ return val;
527
+ }
528
+ }
529
+ }
530
+ }
531
+ }
532
+ return '';
533
+ },
534
+ reload() {
535
+ this.getData(...arguments);
536
+ },
537
+ handleExpand(data, node) {
538
+ if (this.onExpand) {
539
+ this.onExpand(data, node);
540
+ } else {
541
+ if (this.lazy) {
542
+ this.loadsub(data, node);
543
+ }
544
+ this.$emit('node-expand', data, node);
545
+ }
546
+ },
547
+ //请求子节点数据
548
+ loadsub(data, node) {
549
+ if (data.state !== '' && (!data.children || data.children.length === 0)) {
550
+ let param = {};
551
+ if (this.subParamKey) {
552
+ for (let i in this.subParamKey) {
553
+ param[i] = data[this.subParamKey[i]];
554
+ }
555
+ } else {
556
+ param[this.valKey] = data[this.valKey];
557
+ }
558
+ let params = util.extend({}, this.param, this.where, param);
559
+ if (this.parseParams) {
560
+ params = this.parseParams({ data, params, node });
561
+ }
562
+ if (this.onLoadsub) {
563
+ this.onLoadsub({ data, params, node })
564
+ .then((res) => {
565
+ this.loading = false;
566
+ this.$set(data, 'children', JSON.parse(JSON.stringify(res)));
567
+ if (this.dataKey && this.esForm) {
568
+ this.esForm.setSysCodes(
569
+ this.dataKey,
570
+ JSON.parse(JSON.stringify(this.options))
571
+ );
572
+ }
573
+ })
574
+ .catch((e) => {
575
+ this.loading = false;
576
+ });
577
+ } else {
578
+ util
579
+ .ajax({
580
+ method: this.method,
581
+ url: this.url,
582
+ data: params,
583
+ params: params
584
+ })
585
+ .then((res) => {
586
+ if (res.rCode === 0) {
587
+ this.loading = false;
588
+ let results = JSON.parse(JSON.stringify(res.results));
589
+ if (Array.isArray(results)) {
590
+ if (data.id === results[0].id) {
591
+ this.$set(data, 'children', results[0].children);
592
+ } else {
593
+ this.$set(data, 'children', results);
594
+ }
595
+ } else if (data.id === results.id) {
596
+ this.$set(data, 'children', results.children);
597
+ } else {
598
+ console.error('tree数据格式错误');
599
+ }
600
+ if (this.dataKey && this.esForm) {
601
+ this.esForm.setSysCodes(
602
+ this.dataKey,
603
+ JSON.parse(JSON.stringify(this.options))
604
+ );
605
+ }
606
+ }
607
+ })
608
+ .catch((err) => {
609
+ this.loading = false;
610
+ if (err.message && err.message !== 'canceled') {
611
+ this.$message.error(err.message);
612
+ }
613
+ });
614
+ }
615
+ }
616
+ },
617
+ toggleMenu() {
618
+ this.$refs.elSelect.toggleMenu();
619
+ },
620
+ setOptions(val) {
621
+ this.options = val;
622
+ },
623
+ bindEventBus() {
624
+ const bus = this.bus || this.$root.Bus;
625
+ bus && bus.$on(this.sysCode || this.dataKey, this.setOptions);
626
+ },
627
+ unbindEventBus() {
628
+ const bus = this.bus || this.$root.Bus;
629
+ bus && bus.$off(this.sysCode || this.dataKey, this.setOptions);
630
+ }
631
+ },
632
+ beforeDestroy() {
633
+ this.unbindEventBus();
634
+ },
635
+ render(h) {
636
+ if (!this.hide) {
637
+ if (this.readonly) {
638
+ let dom = [];
639
+ if (Array.isArray(this.models)) {
640
+ dom = this.models.map((item) => {
641
+ if (util.isObject(item)) {
642
+ if (!item[this.label] && !item.label) {
643
+ return this.getLabel(value[this.valKey], data);
644
+ }
645
+ return item[this.label] || item.label;
646
+ }
647
+ return this.getLabel(item, this.results);
648
+ });
649
+ } else if (util.isObject(this.models)) {
650
+ if (!this.models[this.label] && !this.models.label) {
651
+ dom = [this.getLabel(this.models[this.valKey], this.results)];
652
+ } else {
653
+ dom = [this.models[this.label] || this.models.label];
654
+ }
655
+ } else {
656
+ dom = [this.getLabel(this.models, this.results)];
657
+ }
658
+ return h(
659
+ 'div',
660
+ {
661
+ class: [
662
+ {
663
+ 'es-plain': this.plain,
664
+ 'es-textarea__inner el-textarea__inner': this.multiple,
665
+ 'el-input__inner es-input__inner': !this.multiple
666
+ }
667
+ ]
668
+ },
669
+ [dom.join(this.symbol)]
670
+ );
671
+ }
672
+ let doms = [];
673
+ let cls = [];
674
+ if (this.results.length && !this.tree) {
675
+ if (this.filtrate && Array.isArray(this.filtrate)) {
676
+ doms = this.filtrate.map((item) => {
677
+ return h(
678
+ 'el-option-group',
679
+ {
680
+ attrs: {
681
+ label: item[this.label] || item.label,
682
+ key: item[this.valKey]
683
+ }
684
+ },
685
+ this.createOption({ filtrate: item, data: this.results, h })
686
+ );
687
+ });
688
+ } else {
689
+ doms = this.createOption({
690
+ filtrate: this.filtrate,
691
+ data: this.results,
692
+ h
693
+ });
694
+ }
695
+ }
696
+ let { prefix, suffix, prepend, append, ...attrs } = this.$attrs;
697
+ if (this.$slots.prefix) {
698
+ doms.push(h('template', { slot: 'prefix' }, this.$slots.prefix));
699
+ } else if (prefix) {
700
+ this.renderd(doms, h, 'prefix');
701
+ cls.push('es-select-button-prefix');
702
+ }
703
+ if (this.$slots.suffix) {
704
+ doms.push(h('template', { slot: 'suffix' }, this.$slots.suffix));
705
+ } else if (suffix) {
706
+ this.renderd(doms, h, 'suffix');
707
+ cls.push('es-select-button-suffix');
708
+ }
709
+ if (this.$slots.prepend) {
710
+ doms.push(h('template', { slot: 'prepend' }, this.$slots.prepend));
711
+ } else if (prepend) {
712
+ this.renderd(doms, h, 'prepend');
713
+ }
714
+ if (this.$slots.append) {
715
+ doms.push(h('template', { slot: 'append' }, this.$slots.append));
716
+ } else if (append) {
717
+ this.renderd(doms, h, 'append');
718
+ }
719
+ if (!this.models && this.results.length && this.defaultValue) {
720
+ if (this.valueType === 'object') {
721
+ this.models = this.results[0];
722
+ //this.$emit('input', this.results[0]);
723
+ } else {
724
+ this.models = this.results[0][this.valKey];
725
+ //this.$emit('input', this.results[0][this.valKey]);
726
+ }
727
+ this.$emit('change', this.results[0], 0);
728
+ }
729
+ return h(
730
+ 'el-select',
731
+ {
732
+ class: cls,
733
+ ref: 'elSelect',
734
+ directives: [
735
+ {
736
+ name: 'show',
737
+ value: this.display
738
+ }
739
+ ],
740
+ props: {
741
+ ...attrs,
742
+ multiple: this.multiple,
743
+ valueType: this.valueType,
744
+ valueKey: this.valKey,
745
+ labelKey: this.label,
746
+ loading: this.loading,
747
+ disabled: this.disabled,
748
+ tree:
749
+ typeof this.tree === 'boolean'
750
+ ? this.tree
751
+ : { ...this.tree, lazy: this.label },
752
+ data: this.results,
753
+ // 父级是否可选
754
+ parentCheck: this.parentCheck,
755
+ // 父级可选时父级是否作为单独的值
756
+ parentAsValue: this.parentAsValue,
757
+ value: this.models
758
+ },
759
+ attrs: {
760
+ remoteMethod: !this.remoteMethod ? this.search : this.remoteMethod,
761
+ remote: this.remote
762
+ },
763
+ on: {
764
+ ...this.$listeners,
765
+ 'node-expand': this.handleExpand
766
+ }
767
+ },
768
+ this.$slots.default ? this.$slots.default : doms
769
+ );
770
+ } else {
771
+ return '';
772
+ }
773
+ }
774
+ };
775
+ </script>