imatrix-ui 0.2.6-up → 0.2.7-up

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 (206) hide show
  1. package/README.md +7 -7
  2. package/index.html +13 -13
  3. package/lib/super-ui.css +1 -1
  4. package/lib/super-ui.js +2724 -1932
  5. package/lib/super-ui.umd.cjs +24 -24
  6. package/package.json +1 -1
  7. package/packages/IntervalSelection/index.js +6 -6
  8. package/packages/IntervalSelection/src/quarterScope.vue +405 -405
  9. package/packages/IntervalSelection/src/sectionDate.vue +475 -475
  10. package/packages/breadcrumb/index.js +6 -6
  11. package/packages/breadcrumb/src/breadcrumb.vue +81 -81
  12. package/packages/department-tree/index.js +6 -6
  13. package/packages/department-tree/src/department-tree.vue +113 -113
  14. package/packages/department-tree-inline/index.js +6 -6
  15. package/packages/department-tree-inline/src/department-multi-tree-inline.vue +472 -472
  16. package/packages/department-tree-inline/src/department-single-tree-inline.vue +340 -340
  17. package/packages/department-tree-inline/src/department-tree-inline.vue +86 -86
  18. package/packages/department-tree-inline/src/department-tree-service.js +344 -344
  19. package/packages/department-tree-inline/src/search-result.vue +235 -235
  20. package/packages/department-user-tree/index.js +6 -6
  21. package/packages/department-user-tree/src/department-user-multiple-tree.vue +129 -129
  22. package/packages/department-user-tree/src/department-user-single-tree.vue +94 -94
  23. package/packages/department-user-tree/src/department-user-tree.vue +114 -114
  24. package/packages/department-user-tree-inline/index.js +9 -9
  25. package/packages/department-user-tree-inline/src/department-user-multiple-tree-inline.vue +731 -731
  26. package/packages/department-user-tree-inline/src/department-user-single-tree-inline.vue +334 -334
  27. package/packages/department-user-tree-inline/src/department-user-tree-inline.vue +87 -87
  28. package/packages/department-user-tree-inline/src/department-user-tree-multi-service.js +309 -309
  29. package/packages/department-user-tree-inline/src/department-user-tree-single-service.js +179 -179
  30. package/packages/department-user-tree-inline/src/search-result.vue +273 -273
  31. package/packages/directives/prevent-reclick.js +22 -22
  32. package/packages/dynamic-source-select/index.js +6 -6
  33. package/packages/dynamic-source-select/src/dynamic-source-select-service.js +106 -106
  34. package/packages/dynamic-source-select/src/dynamic-source-select.vue +675 -675
  35. package/packages/dynamic-source-select/src/events.js +78 -78
  36. package/packages/fs-preview/index.js +6 -6
  37. package/packages/fs-preview/src/fs-preview.vue +287 -287
  38. package/packages/fs-upload/index.js +6 -6
  39. package/packages/fs-upload/src/fs-upload-multi.vue +443 -443
  40. package/packages/fs-upload/src/fs-upload-single.vue +353 -353
  41. package/packages/fs-upload/src/fs-upload.vue +191 -191
  42. package/packages/fs-upload/src/see-big-picture.vue +67 -67
  43. package/packages/fs-upload-list/index.js +6 -6
  44. package/packages/fs-upload-list/src/fs-upload-list.vue +372 -372
  45. package/packages/hamburger/index.js +6 -6
  46. package/packages/hamburger/src/hamburger.vue +40 -40
  47. package/packages/index.js +123 -123
  48. package/packages/multipart-upload/index.js +6 -6
  49. package/packages/multipart-upload/src/index.vue +66 -66
  50. package/packages/multipart-upload/src/multipart-upload-form.vue +377 -377
  51. package/packages/multipart-upload/src/multipart-upload-list.vue +517 -517
  52. package/packages/organization-input/index.js +6 -6
  53. package/packages/organization-input/src/organization-input.vue +583 -583
  54. package/packages/plugins/export-data-new.js +623 -623
  55. package/packages/plugins/export-data.js +431 -431
  56. package/packages/plugins/index.js +15 -15
  57. package/packages/plugins/public-method.js +47 -47
  58. package/packages/remove-department/index.js +6 -6
  59. package/packages/remove-department/src/remove-department.vue +200 -200
  60. package/packages/remove-department/src/remove-dept-service.js +31 -31
  61. package/packages/remove-user/index.js +6 -6
  62. package/packages/remove-user/src/remove-user-service.js +31 -31
  63. package/packages/remove-user/src/remove-user.vue +226 -226
  64. package/packages/remove-workgroup/index.js +6 -6
  65. package/packages/remove-workgroup/src/remove-workgroup-service.js +31 -31
  66. package/packages/remove-workgroup/src/remove-workgroup.vue +183 -183
  67. package/packages/rich-editor/index.js +7 -7
  68. package/packages/rich-editor/index.vue +297 -297
  69. package/packages/rich-editor/langs/zh-Hans.js +438 -438
  70. package/packages/rich-editor/viewer.vue +105 -105
  71. package/packages/scan-code-input/index.js +6 -6
  72. package/packages/scan-code-input/src/events.js +34 -34
  73. package/packages/scan-code-input/src/scan-code-input-colse.vue +140 -140
  74. package/packages/scan-code-input/src/scan-code-input.vue +132 -132
  75. package/packages/secret-info/index.js +7 -7
  76. package/packages/secret-info/index.vue +100 -100
  77. package/packages/super-grid/index.js +7 -7
  78. package/packages/super-grid/src/apis.js +1092 -1092
  79. package/packages/super-grid/src/columns-config.vue +427 -427
  80. package/packages/super-grid/src/custom-formatter.js +394 -394
  81. package/packages/super-grid/src/eventBus.js +2 -2
  82. package/packages/super-grid/src/events.js +56 -56
  83. package/packages/super-grid/src/formValidatorUtil.js +300 -300
  84. package/packages/super-grid/src/formatter.js +196 -196
  85. package/packages/super-grid/src/group-column.vue +99 -99
  86. package/packages/super-grid/src/header-context-menu.vue +82 -82
  87. package/packages/super-grid/src/index-column.vue +69 -69
  88. package/packages/super-grid/src/public-methods.js +30 -30
  89. package/packages/super-grid/src/row-operation.vue +193 -193
  90. package/packages/super-grid/src/search-button.vue +74 -74
  91. package/packages/super-grid/src/search-condition-input.vue +73 -73
  92. package/packages/super-grid/src/search-condition-list.vue +68 -68
  93. package/packages/super-grid/src/search-form-advancedQuery.vue +819 -819
  94. package/packages/super-grid/src/search-form-dialog.vue +77 -77
  95. package/packages/super-grid/src/search-form-item.vue +495 -495
  96. package/packages/super-grid/src/search-form-number.vue +111 -111
  97. package/packages/super-grid/src/search-form-ordinarySearch.vue +239 -239
  98. package/packages/super-grid/src/search-form.vue +762 -762
  99. package/packages/super-grid/src/search-methods.js +592 -592
  100. package/packages/super-grid/src/selection-column.vue +46 -46
  101. package/packages/super-grid/src/store.js +3 -3
  102. package/packages/super-grid/src/super-grid-service.js +728 -728
  103. package/packages/super-grid/src/super-grid.vue +3011 -3011
  104. package/packages/super-grid/src/utils.js +880 -880
  105. package/packages/super-grid/src/view-image-dialog.vue +176 -176
  106. package/packages/super-nine-grid/index.js +7 -7
  107. package/packages/super-nine-grid/src/apis.js +108 -108
  108. package/packages/super-nine-grid/src/custom-formatter.js +73 -73
  109. package/packages/super-nine-grid/src/formatter.js +134 -134
  110. package/packages/super-nine-grid/src/search-form-number.vue +35 -35
  111. package/packages/super-nine-grid/src/search-form.vue +700 -700
  112. package/packages/super-nine-grid/src/search-methods.js +151 -151
  113. package/packages/super-nine-grid/src/store.js +3 -3
  114. package/packages/super-nine-grid/src/super-grid-service.js +107 -107
  115. package/packages/svg-icon/index.js +6 -6
  116. package/packages/svg-icon/src/svg-icon.vue +43 -43
  117. package/packages/utils/date-util.js +292 -292
  118. package/packages/utils/dom.js +227 -227
  119. package/packages/utils/gogocodeTransfer.js +59 -59
  120. package/packages/utils/memory-cache-utils.js +117 -117
  121. package/packages/utils/utils.js +180 -180
  122. package/packages/utils/value-set.js +97 -97
  123. package/packages/valid-code/index.js +7 -7
  124. package/packages/valid-code/src/valid-code.vue +104 -104
  125. package/packages/workflow-button/index.js +6 -6
  126. package/packages/workflow-button/src/workflow-button.vue +550 -550
  127. package/packages/workflow-history-list/index.js +6 -6
  128. package/packages/workflow-history-list/src/api.js +7 -7
  129. package/packages/workflow-history-list/src/workflow-history-list.vue +291 -291
  130. package/packages/workgroup-tree/index.js +6 -6
  131. package/packages/workgroup-tree/src/workgroup-tree.vue +86 -86
  132. package/packages/workgroup-tree-inline/index.js +6 -6
  133. package/packages/workgroup-tree-inline/src/search-result.vue +222 -222
  134. package/packages/workgroup-tree-inline/src/workgroup-tree-inline.vue +516 -516
  135. package/packages/workgroup-tree-inline/src/workgroup-tree-service.js +93 -93
  136. package/packages/workgroup-user-tree/index.js +6 -6
  137. package/packages/workgroup-user-tree/src/workgroup-user-tree.vue +103 -103
  138. package/packages/workgroup-user-tree-inline/index.js +9 -9
  139. package/packages/workgroup-user-tree-inline/src/search-result.vue +266 -266
  140. package/packages/workgroup-user-tree-inline/src/workgroup-tree-inline-service.js +239 -239
  141. package/packages/workgroup-user-tree-inline/src/workgroup-user-tree-inline.vue +657 -657
  142. package/packages/year-range-picker/index.js +6 -6
  143. package/packages/year-range-picker/src/year-range-picker.vue +53 -53
  144. package/src/api/sso-service.js +172 -172
  145. package/src/api/tab.js +36 -36
  146. package/src/api/user-service.js +11 -11
  147. package/src/directives/permission/index.js +13 -13
  148. package/src/directives/permission/permission.js +20 -20
  149. package/src/i18n/langs/cn.js +259 -259
  150. package/src/i18n/langs/en.js +269 -269
  151. package/src/index.js +93 -93
  152. package/src/plugins.js +18 -18
  153. package/src/router/index.js +8 -26
  154. package/src/store/getters.js +15 -15
  155. package/src/store/index.js +19 -19
  156. package/src/store/modules/app.js +54 -54
  157. package/src/store/modules/tab-content.js +36 -36
  158. package/src/store/modules/user.js +285 -285
  159. package/src/utils/auth.js +61 -61
  160. package/src/utils/calculator/calculator-factory-wf.js +558 -558
  161. package/src/utils/calculator/calculator-factory.js +145 -145
  162. package/src/utils/calculator/calculator-util.js +166 -166
  163. package/src/utils/eventBus.js +2 -2
  164. package/src/utils/iconUtils.js +28 -28
  165. package/src/utils/index.js +102 -102
  166. package/src/utils/jump-page-utils.js +824 -824
  167. package/src/utils/menu.js +19 -19
  168. package/src/utils/permission.js +31 -31
  169. package/src/utils/permissionAuth.js +96 -96
  170. package/src/utils/range-selector.js +188 -188
  171. package/src/utils/request.js +269 -269
  172. package/src/utils/restful-interface-utils.js +57 -57
  173. package/src/utils/util.js +703 -703
  174. package/src/utils/validate.js +34 -34
  175. package/src/utils/watermark.js +108 -108
  176. package/src/utils/workflow-util.js +93 -93
  177. package/src/views/404.vue +248 -248
  178. package/src/views/dsc-component/Sidebar/Item.vue +84 -84
  179. package/src/views/dsc-component/Sidebar/Link.vue +38 -38
  180. package/src/views/dsc-component/Sidebar/SidebarItem.vue +198 -198
  181. package/src/views/dsc-component/Sidebar/index.vue +229 -229
  182. package/src/views/dsc-component/tabs/tab-content.vue +203 -203
  183. package/src/views/error-page/401.vue +106 -106
  184. package/src/views/error-page/404.vue +248 -248
  185. package/src/views/layout/EmptyLayout.vue +3 -3
  186. package/src/views/layout/Layout.vue +81 -81
  187. package/src/views/layout/NewLayout.vue +18 -18
  188. package/src/views/layout/components/AppMain.vue +39 -39
  189. package/src/views/layout/components/Breadcrumb/index.vue +158 -158
  190. package/src/views/layout/components/Menubar/Item.vue +79 -79
  191. package/src/views/layout/components/Menubar/Link.vue +38 -38
  192. package/src/views/layout/components/Menubar/index.vue +210 -210
  193. package/src/views/layout/components/Sidebar/Item.vue +53 -53
  194. package/src/views/layout/components/Sidebar/Link.vue +38 -38
  195. package/src/views/layout/components/Sidebar/index.vue +141 -141
  196. package/src/views/layout/components/iframe-page.vue +38 -38
  197. package/src/views/layout/components/index.js +4 -4
  198. package/src/views/layout/components/tabs/tab-content.vue +207 -207
  199. package/src/views/layout/mixin/ResizeHandler.js +41 -41
  200. package/src/views/layout/tab-content-iframe-index.vue +38 -38
  201. package/src/views/layout/tab-content-index.vue +93 -93
  202. package/src/views/login/authredirect.vue +10 -10
  203. package/src/views/login/index.vue +296 -296
  204. package/src/views/login/update-password.vue +243 -243
  205. package/src/views/redirect/index.vue +14 -14
  206. package/src/views/wf-history/tache-subprocess-history.vue +45 -45
@@ -1,675 +1,675 @@
1
- <template>
2
- <span class="select-top-span">
3
- <el-select
4
- ref="dynamicDataSourceRef"
5
- :allow-create="allowCreate"
6
- :clearable="clearable"
7
- :filterable="remote"
8
- :loading="loading"
9
- :model-value="value"
10
- :placeholder="placeholder"
11
- :remote="remote"
12
- :remote-method="remoteMethod"
13
- :reserve-keyword="true"
14
- :size="size"
15
- :style="fullWidth ? { width: '100%', height: '100%' } : {}"
16
- :title="getClassOptionTitle(value)"
17
- :value-key="valueAttribute"
18
- default-first-option
19
- v-bind="myProps"
20
- @blur="blur"
21
- @change="change"
22
- @clear="clear"
23
- @focus="focus"
24
- @input="inputValue"
25
- @visible-change="visibleChange"
26
- @remove-tag="removeTag(remote, $event)"
27
- >
28
- <template v-if="descriptionAttribute">
29
- <div v-if="optionWidth > 0" :style="{ width: optionWidth + 'px' }">
30
- <el-option
31
- v-for="item in optionItems"
32
- :key="item.value"
33
- :label="item._label_"
34
- :title="item._label_ + item._description_"
35
- :value="item[valueAttribute]"
36
- >
37
- <div style="display: flex">
38
- <span>{{ item._label_ }}</span>
39
- <span
40
- style="color: #8492a6; font-size: 13px; margin-left: 30px"
41
- >{{ item._description_ }}</span
42
- >
43
- </div>
44
- </el-option>
45
- </div>
46
- <el-option
47
- v-for="item in optionItems"
48
- v-else
49
- :label="item._label_"
50
- :title="item._label_ + item._description_"
51
- :value="item[valueAttribute]"
52
- >
53
- <span style="float: left">{{ item._label_ }}</span>
54
- <span
55
- style="
56
- float: right;
57
- color: #8492a6;
58
- font-size: 13px;
59
- margin-left: 30px;
60
- "
61
- >{{ item._description_ }}</span
62
- >
63
- </el-option>
64
- </template>
65
- <template v-else>
66
- <div
67
- v-if="optionWidth > 0"
68
- :style="{ width: optionWidth + 'px', position: 'relative' }"
69
- >
70
- <el-option
71
- v-for="item in optionItems"
72
- :key="item.value"
73
- :label="item._label_"
74
- :value="item[valueAttribute]"
75
- />
76
- </div>
77
- <el-option
78
- v-for="item in optionItems"
79
- v-else
80
- :label="item._label_"
81
- :value="item[valueAttribute]"
82
- />
83
- </template>
84
- </el-select>
85
- </span>
86
- </template>
87
-
88
- <script>
89
- import {$emit, $on} from '../../utils/gogocodeTransfer'
90
- import dynamicSourceSelectService from './dynamic-source-select-service'
91
- import events from './events'
92
- import eventBus from '../../../src/utils/eventBus'
93
- import {getPropNameWhenJoinTable, setEntityFieldValue,} from '../../../src/utils/util'
94
-
95
- export default {
96
- name: 'DynamicSourceSelect',
97
- components: {},
98
- model: {
99
- prop: 'value',
100
- event: 'input',
101
- },
102
- props: {
103
- // 字段配置 只有列表行编辑时候才用
104
- column: {
105
- type: Object,
106
- default: null,
107
- },
108
- value: {
109
- type: [String, Boolean, Number, Array],
110
- default: null,
111
- },
112
- baseProps: {
113
- type: Object,
114
- default: null,
115
- },
116
- entity: {
117
- type: Object,
118
- default: null,
119
- },
120
- // dynamicDataSourceCode、valueSetOptions、isSql(默认是false,在配置系统中使用时需要是true)、additionalParameter( json字符串)
121
- options: {
122
- type: Object,
123
- default: null,
124
- },
125
- // 列表组件行编辑使用,sql查询时数据表名称,用于自定义系统中列表组件中字段多表查询带有别名时,将点"."改成两个下划线"__"时使用
126
- tableName: {
127
- type: String,
128
- default: null,
129
- },
130
- // 列表组件行编辑使用,是否是关联表,用于确定属性名是否需要拼接tableName
131
- isJoinTable: {
132
- type: Boolean,
133
- default: false,
134
- },
135
- // 子表行编辑时,父表单数据
136
- parent: {
137
- type: Object,
138
- default: null,
139
- },
140
- // 所在的列表编码
141
- listCode: {
142
- type: String,
143
- default: null,
144
- },
145
- // 所在的表单编码
146
- formCode: {
147
- type: String,
148
- default: null,
149
- },
150
- listToolbarFormData: {
151
- type: Object,
152
- default: () => {
153
- return {}
154
- },
155
- },
156
- fullWidth: {
157
- type: Boolean,
158
- default: true,
159
- },
160
- clearable: {
161
- type: Boolean,
162
- default: true,
163
- },
164
- size: {
165
- type: String,
166
- default: 'medium',
167
- },
168
- allowCreate: {
169
- type: Boolean,
170
- default: false,
171
- },
172
- analysisArea: {
173
- type: Number,
174
- default: null,
175
- // 1 为工具栏解析
176
- },
177
- placeholder: {
178
- type: String,
179
- default: null,
180
- },
181
- // 下拉框配置宽度
182
- optionWidth: {
183
- default: 0,
184
- },
185
- },
186
- // 是否是页面预览, 从页面管理传递
187
- inject: {
188
- isPageInfo: {value: 'isPageInfo', default: false},
189
- },
190
- data() {
191
- const myProps = Object.assign({}, this.baseProps)
192
- let markValue
193
- if (this.entity) {
194
- markValue = JSON.stringify(this.entity)
195
- }
196
- return {
197
- /**
198
- * 用于回显动态数据源选择的默认值,因为初始进入编辑状态时,没有获取映射关系,
199
- * 如果当前字段是保存的label值则无法确定当前选项组的值对应哪一个,导致row中的对应字段变成了空值,所以备份一份
200
- * 然后在获取动态数据源选项组后,给上默认值
201
- */
202
- markValue,
203
- optionItems: [],
204
- myProps,
205
- valueSetOptions: [], // 字段映射集合配置
206
- dynamicDataSourceCode: '', // 动态数据源编码
207
- loading: false, // 是否在加载
208
- valueAttribute: null, // 选项值字段,即控制下拉框组件的value-key属性的
209
- remote: false, // 是否是远程搜索
210
- additionalParameterStr: this.options.additionalParameter, // 附加参数json字符串
211
- isLoaded: false, // 动态数据源是否直接显示静态页面
212
- watchAttr: null, // 监控的entity属性名,多个属性名逗号分隔。即当该属性修改时,需要走后台重新获得当前下拉选的选项集合
213
- backendUrl: null, // 后台访问路径
214
- descriptionAttribute: null,
215
- queryParam: {}, // 请求参数
216
- }
217
- },
218
- watch: {
219
- baseProps: {
220
- deep: true,
221
- handler(newModels) {
222
- this.myProps = Object.assign({}, newModels)
223
- },
224
- },
225
- },
226
- created() {
227
- if (this.options && this.options.dynamicDataSourceCode) {
228
- this.dynamicDataSourceCode = this.options.dynamicDataSourceCode.trim()
229
- const param = {
230
- _listCode: this.listCode,
231
- _formCode: this.formCode,
232
- _tableName: this.tableName,
233
- }
234
- if (this.parent) {
235
- param.parent = this.parent
236
- }
237
- if (!this.isPageInfo) {
238
- this.packageDynamicDataSourceInfo(this.dynamicDataSourceCode, param)
239
- .then((dynamicDataSourceDto) => {
240
- // console.log('UI获取的数据', dynamicDataSourceDto)
241
- if (dynamicDataSourceDto.backendUrl) {
242
- this.backendUrl = dynamicDataSourceDto.backendUrl
243
- }
244
- if (
245
- dynamicDataSourceDto.fuzzyQuery !== undefined &&
246
- dynamicDataSourceDto.fuzzyQuery === true
247
- ) {
248
- // 是否启用远程搜索
249
- this.remote = true
250
- }
251
- if (this.options && this.options.valueSetOptions) {
252
- this.valueSetOptions = this.options.valueSetOptions
253
- }
254
- if (
255
- this.options &&
256
- this.options.isSql !== undefined &&
257
- this.options.isSql !== null
258
- ) {
259
- this.isSql = this.options.isSql
260
- }
261
- if (this.watchAttr) {
262
- let initWatchValue
263
- const watchAttrs = this.watchAttr.split(',')
264
- watchAttrs.forEach((attr) => {
265
- // 初始化下拉选内容
266
- if (this.entity) {
267
- initWatchValue = this.entity[attr]
268
- }
269
- this.$watch('entity.' + attr, function (newValue, oldValue) {
270
- this.watchAttrValueChange(newValue)
271
- // this.inputValue('')
272
- const items = this.optionItems.filter(
273
- (item) => item[this.valueAttribute] === newValue
274
- )
275
- if (!items) {
276
- this.inputValue('')
277
- }
278
- })
279
- })
280
- this.watchAttrValueChange(initWatchValue)
281
- }
282
- this.isLoaded = true
283
- // 默认选中处理
284
- if (dynamicDataSourceDto.defaultSelect) {
285
- // 多选处理
286
- if (this.baseProps.multiple) {
287
- $emit(this, 'set-default-value', [
288
- this.optionItems[0][this.valueAttribute],
289
- ])
290
- } else {
291
- // 单选处理
292
- if (this.optionItems.length > 0) {
293
- $emit(
294
- this,
295
- 'set-default-value',
296
- this.optionItems[0][this.valueAttribute]
297
- )
298
- }
299
- }
300
- }
301
- // console.log('判断参数',this.analysisArea);
302
- // console.log('判断参数',this.remote);
303
- if (this.analysisArea !== 1 && this.remote) {
304
- // 传递初始化查询供重置用
305
- const that = this
306
- $on(eventBus, 'remoteMethod', () => {
307
- that.remoteMethod('')
308
- })
309
- // console.log('传递了参数');
310
- }
311
- $emit(this, 'load-completed', dynamicDataSourceDto)
312
- })
313
- .catch((error) => {
314
- console.log(error)
315
- $emit(this, 'load-completed', {
316
- code: this.dynamicDataSourceCode,
317
- error: error,
318
- })
319
- this.isLoaded = true
320
- })
321
- }
322
- } else {
323
- this.isLoaded = true
324
- }
325
- console.log(
326
- '%c描述-095027',
327
- 'color:#2E3435;background:#F8BB07;padding:3px;border-radius:2px',
328
- this.optionWidth
329
- )
330
- },
331
- methods: {
332
- ...dynamicSourceSelectService,
333
- ...events,
334
- /**
335
- * @description: 获取提示标题
336
- * @Date: 2023-08-04 10:04:42
337
- * @param {*}
338
- * @return {*}
339
- */
340
- getClassOptionTitle(val) {
341
- if (val !== null && val !== undefined && val !== '' && val.length > 0) {
342
- let selectTittle = ''
343
- if (typeof val === 'string') {
344
- // 单选
345
- if (this.descriptionAttribute) {
346
- this.optionItems.forEach((item) => {
347
- if (item[this.valueAttribute] === val) {
348
- selectTittle = item._label_ + item._description_
349
- }
350
- })
351
- } else {
352
- this.optionItems.forEach((Ttem) => {
353
- if (Ttem[this.valueAttribute] === val) {
354
- selectTittle = Ttem._label_
355
- }
356
- })
357
- }
358
- } else {
359
- // 多选
360
- if (this.descriptionAttribute) {
361
- this.optionItems.forEach((item) => {
362
- val.forEach((Vtem) => {
363
- if (item[this.valueAttribute] === Vtem) {
364
- selectTittle = selectTittle + item._label_ + ','
365
- }
366
- })
367
- })
368
- selectTittle = selectTittle.slice(0, selectTittle.length - 1)
369
- } else {
370
- this.optionItems.forEach((Ttem) => {
371
- val.forEach((Vtem) => {
372
- if (Ttem[this.valueAttribute] === Vtem) {
373
- selectTittle = selectTittle + Ttem._label_ + ','
374
- }
375
- })
376
- })
377
- selectTittle = selectTittle.slice(0, selectTittle.length - 1)
378
- }
379
- }
380
- return selectTittle
381
- }
382
- },
383
- // 必须有该方法,否则无法给字段赋值
384
- inputValue(newValue) {
385
- $emit(this, 'update:value', newValue)
386
- if (newValue === null || newValue === undefined || newValue === '') {
387
- this.remoteQueryMethod(newValue)
388
- }
389
- this.setValues(newValue)
390
- },
391
- packageDynamicDataSourceInfo(dynamicDataSourceCode, param) {
392
- return new Promise((resolve, reject) => {
393
- this.findDynamicDataSourceByCode(
394
- dynamicDataSourceCode,
395
- this.entity,
396
- param,
397
- this.additionalParameterStr,
398
- this.backendUrl
399
- )
400
- .then((dynamicDataSourceDto) => {
401
- if (dynamicDataSourceDto) {
402
- if (dynamicDataSourceDto.options) {
403
- this.optionItems = dynamicDataSourceDto.options
404
- if (this.watchAttr) {
405
- // 解决当监控值变化时,数据源重新加载后select输入框中显示的值和下拉中的值不一致问题
406
- if (
407
- this.baseProps.multiple !== undefined &&
408
- this.baseProps.multiple === true
409
- ) {
410
- this.$nextTick(() => {
411
- this.$refs['dynamicDataSourceRef'].setSelected()
412
- })
413
- }
414
- }
415
- //
416
- if (this.column) {
417
- // 只有行编辑时处理
418
- // 设置选项组数据、 选项组值字段、 映射关系
419
- if (
420
- this.column.prop !== dynamicDataSourceDto.valueAttribute
421
- ) {
422
- this.column['_dynamic-source-data-' + this.column.prop] = {
423
- valueSetOptions: this.options.valueSetOptions,
424
- optionItems: this.optionItems,
425
- valueAttribute: dynamicDataSourceDto.valueAttribute,
426
- }
427
- }
428
- for (
429
- let i = 0;
430
- i < this.options.valueSetOptions.length;
431
- i++
432
- ) {
433
- const valueSetOption = this.options.valueSetOptions[i]
434
- if (
435
- dynamicDataSourceDto.valueAttribute ===
436
- valueSetOption.columnName
437
- ) {
438
- if (this.markValue) {
439
- const muMarkValue = JSON.parse(this.markValue)
440
- if (
441
- muMarkValue &&
442
- muMarkValue[valueSetOption.valueColumn.dbColumnName]
443
- ) {
444
- let targeValue = (
445
- muMarkValue[
446
- valueSetOption.valueColumn.dbColumnName
447
- ] + ''
448
- ).split(',')
449
- if (this.column.componentType === 'select') {
450
- // 如果是单选
451
- targeValue = targeValue[0]
452
- }
453
- // 不需要再赋值了 如果当前字段不上动态数据源的值字段,那就表示不需要回显
454
- // if (valueSetOption.valueColumn.dbColumnName === this.column.prop) {
455
- // this.$emit('set-value', {
456
- // value: targeValue,
457
- // targetColumnName: this.column.prop
458
- // })
459
- // }
460
- }
461
- }
462
- break
463
- }
464
- }
465
- }
466
- } else {
467
- this.optionItems = []
468
- }
469
- if (dynamicDataSourceDto.valueAttribute) {
470
- this.valueAttribute = dynamicDataSourceDto.valueAttribute
471
- }
472
- if (dynamicDataSourceDto.descriptionAttribute) {
473
- this.descriptionAttribute =
474
- dynamicDataSourceDto.descriptionAttribute
475
- }
476
- this.valueAttribute = this.getValueAttribute()
477
- this.watchAttr = dynamicDataSourceDto.watchAttr
478
- $emit(this, 'load-completed', dynamicDataSourceDto)
479
- resolve(dynamicDataSourceDto)
480
- } else {
481
- resolve()
482
- }
483
- })
484
- .catch((error) => {
485
- reject(error)
486
- })
487
- })
488
- },
489
- // 远程搜索方法
490
- remoteQuery(searchText, watchAttrValue) {
491
- if (
492
- (searchText !== null && searchText !== undefined) ||
493
- (watchAttrValue !== null && watchAttrValue !== undefined)
494
- ) {
495
- const param = {
496
- _listCode: this.listCode,
497
- _formCode: this.formCode,
498
- _tableName: this.tableName,
499
- }
500
- if (searchText !== null && searchText !== undefined) {
501
- param.searchText = searchText
502
- }
503
- if (watchAttrValue !== null && watchAttrValue !== undefined) {
504
- // 监控的属性值改变了远程搜索方法
505
- if (
506
- Object.prototype.toString.apply(watchAttrValue) === '[object Array]'
507
- ) {
508
- param.watchAttrValue = watchAttrValue.join(',')
509
- } else {
510
- param.watchAttrValue = watchAttrValue + ''
511
- }
512
- } else if (this.entity) {
513
- // 搜索时下拉选项的集合
514
- const watchValue = this.entity[this.watchAttr]
515
- if (watchValue !== null && watchValue !== undefined) {
516
- if (
517
- Object.prototype.toString.apply(watchValue) === '[object Array]'
518
- ) {
519
- param.watchAttrValue = watchValue.join(',')
520
- } else {
521
- param.watchAttrValue = watchValue + ''
522
- }
523
- }
524
- }
525
- if (this.parent) {
526
- param.parent = this.parent
527
- }
528
- this.loading = true
529
- this.packageDynamicDataSourceInfo(this.dynamicDataSourceCode, param)
530
- .then((dynamicDataSourceDto) => {
531
- this.loading = false
532
- })
533
- .catch((error) => {
534
- console.log(error)
535
- this.loading = false
536
- })
537
- }
538
- },
539
- // 远程搜索方法
540
- remoteQueryMethod(searchText) {
541
- if (Array.isArray(this.value)) {
542
- if (this.value.length === 0) {
543
- this.remoteQuery(searchText, null)
544
- }
545
- } else {
546
- this.remoteQuery(searchText, null)
547
- }
548
- },
549
- /**
550
- * 输入框输入查询值时搜索方法,
551
- * 不使用remoteQueryMethod, 解决输入框第一次输入时可查询,第二次输入时没有触发查询方法问题
552
- * @param {*} searchText
553
- */
554
- remoteMethod(searchText) {
555
- this.remoteQuery(searchText, null)
556
- },
557
- // 监控的属性值改变了远程搜索方法
558
- watchAttrValueChange(watchAttrValues) {
559
- this.remoteQuery(null, watchAttrValues)
560
- },
561
- getValueAttribute() {
562
- return !this.valueAttribute || this.valueAttribute === '[label]'
563
- ? '_label_'
564
- : this.valueAttribute
565
- },
566
- setValues(newValue) {
567
- if (this.valueSetOptions && this.valueSetOptions.length > 0) {
568
- this.valueSetOptions.forEach((columnInfo) => {
569
- const sourceColumnName = columnInfo.columnName
570
- let value
571
- if (this.optionItems && sourceColumnName) {
572
- value = this.getTargetColumnValue(newValue, sourceColumnName)
573
- }
574
- let targetColumnName = null
575
- const targetColumnInfo = columnInfo.valueColumn
576
- if (targetColumnInfo) {
577
- targetColumnName = targetColumnInfo.name
578
- if (this.isSql === true) {
579
- targetColumnName = targetColumnInfo.dbColumnName
580
- targetColumnName = getPropNameWhenJoinTable(
581
- targetColumnName,
582
- this.isJoinTable,
583
- this.tableName
584
- )
585
- }
586
- }
587
- if (
588
- this.entity &&
589
- targetColumnName &&
590
- targetColumnName !== null &&
591
- targetColumnName !== ''
592
- ) {
593
- setEntityFieldValue(this.entity, targetColumnName, value)
594
- }
595
- const item = this.getSelectedOptionItem(newValue)
596
- $emit(this, 'set-value', {
597
- value: value,
598
- sourceColumnName: sourceColumnName,
599
- targetColumnName: targetColumnName,
600
- options: this.optionItems,
601
- selectedItem: item,
602
- })
603
- })
604
- }
605
- },
606
- // 获得目的字段的值
607
- getTargetColumnValue(newValue, sourceColumnName) {
608
- if (newValue) {
609
- let value = ''
610
- if (
611
- this.baseProps.multiple !== undefined &&
612
- this.baseProps.multiple === true &&
613
- Array.isArray(newValue)
614
- ) {
615
- // 多选值处理,数组信息,使用逗号分开的格式设置其它字段的值
616
- let i = 0
617
- newValue.forEach((itemValue) => {
618
- const items = this.optionItems.filter(
619
- (item) => item[this.valueAttribute] === itemValue
620
- )
621
- if (items && items.length > 0) {
622
- value += items[0][sourceColumnName]
623
- if (i < newValue.length - 1) {
624
- // 最后一个元素不加逗号
625
- value += ','
626
- }
627
- i++
628
- }
629
- })
630
- } else {
631
- // 单选
632
- const items = this.optionItems.filter(
633
- (item) => item[this.valueAttribute] === newValue
634
- )
635
- if (items && items.length > 0) {
636
- value = items[0][sourceColumnName]
637
- }
638
- }
639
- return value
640
- }
641
- },
642
- // 移除所有tag和clear时候清除markValue的值解决清除选项时关联字段清空了但是当前动态数据源控件仍然有值问题
643
- clearMarkValue() {
644
- if (this.markValue && this.entity) {
645
- const muMarkValue = JSON.parse(this.markValue)
646
- for (let i = 0; i < this.options.valueSetOptions.length; i++) {
647
- const valueSetOption = this.options.valueSetOptions[i]
648
- muMarkValue[valueSetOption.valueColumn.dbColumnName] = null
649
- }
650
- this.markValue = JSON.stringify(muMarkValue)
651
- }
652
- },
653
- },
654
- emits: [
655
- 'set-default-value',
656
- 'load-completed',
657
- 'update:value',
658
- 'set-value',
659
- ,
660
- 'update:value',
661
- ],
662
- }
663
- </script>
664
-
665
- <style>
666
- .select-top-span {
667
- width: 100%;
668
- }
669
- </style>
670
-
671
- <style lang="scss" scoped>
672
- :deep(.el-select-dropdown__item) {
673
- display: inline-block;
674
- }
675
- </style>
1
+ <template>
2
+ <span class="select-top-span">
3
+ <el-select
4
+ ref="dynamicDataSourceRef"
5
+ :allow-create="allowCreate"
6
+ :clearable="clearable"
7
+ :filterable="remote"
8
+ :loading="loading"
9
+ :model-value="value"
10
+ :placeholder="placeholder"
11
+ :remote="remote"
12
+ :remote-method="remoteMethod"
13
+ :reserve-keyword="true"
14
+ :size="size"
15
+ :style="fullWidth ? { width: '100%', height: '100%' } : {}"
16
+ :title="getClassOptionTitle(value)"
17
+ :value-key="valueAttribute"
18
+ default-first-option
19
+ v-bind="myProps"
20
+ @blur="blur"
21
+ @change="change"
22
+ @clear="clear"
23
+ @focus="focus"
24
+ @input="inputValue"
25
+ @visible-change="visibleChange"
26
+ @remove-tag="removeTag(remote, $event)"
27
+ >
28
+ <template v-if="descriptionAttribute">
29
+ <div v-if="optionWidth > 0" :style="{ width: optionWidth + 'px' }">
30
+ <el-option
31
+ v-for="item in optionItems"
32
+ :key="item.value"
33
+ :label="item._label_"
34
+ :title="item._label_ + item._description_"
35
+ :value="item[valueAttribute]"
36
+ >
37
+ <div style="display: flex">
38
+ <span>{{ item._label_ }}</span>
39
+ <span
40
+ style="color: #8492a6; font-size: 13px; margin-left: 30px"
41
+ >{{ item._description_ }}</span
42
+ >
43
+ </div>
44
+ </el-option>
45
+ </div>
46
+ <el-option
47
+ v-for="item in optionItems"
48
+ v-else
49
+ :label="item._label_"
50
+ :title="item._label_ + item._description_"
51
+ :value="item[valueAttribute]"
52
+ >
53
+ <span style="float: left">{{ item._label_ }}</span>
54
+ <span
55
+ style="
56
+ float: right;
57
+ color: #8492a6;
58
+ font-size: 13px;
59
+ margin-left: 30px;
60
+ "
61
+ >{{ item._description_ }}</span
62
+ >
63
+ </el-option>
64
+ </template>
65
+ <template v-else>
66
+ <div
67
+ v-if="optionWidth > 0"
68
+ :style="{ width: optionWidth + 'px', position: 'relative' }"
69
+ >
70
+ <el-option
71
+ v-for="item in optionItems"
72
+ :key="item.value"
73
+ :label="item._label_"
74
+ :value="item[valueAttribute]"
75
+ />
76
+ </div>
77
+ <el-option
78
+ v-for="item in optionItems"
79
+ v-else
80
+ :label="item._label_"
81
+ :value="item[valueAttribute]"
82
+ />
83
+ </template>
84
+ </el-select>
85
+ </span>
86
+ </template>
87
+
88
+ <script>
89
+ import {$emit, $on} from '../../utils/gogocodeTransfer'
90
+ import dynamicSourceSelectService from './dynamic-source-select-service'
91
+ import events from './events'
92
+ import eventBus from '../../../src/utils/eventBus'
93
+ import {getPropNameWhenJoinTable, setEntityFieldValue,} from '../../../src/utils/util'
94
+
95
+ export default {
96
+ name: 'DynamicSourceSelect',
97
+ components: {},
98
+ model: {
99
+ prop: 'value',
100
+ event: 'input',
101
+ },
102
+ props: {
103
+ // 字段配置 只有列表行编辑时候才用
104
+ column: {
105
+ type: Object,
106
+ default: null,
107
+ },
108
+ value: {
109
+ type: [String, Boolean, Number, Array],
110
+ default: null,
111
+ },
112
+ baseProps: {
113
+ type: Object,
114
+ default: null,
115
+ },
116
+ entity: {
117
+ type: Object,
118
+ default: null,
119
+ },
120
+ // dynamicDataSourceCode、valueSetOptions、isSql(默认是false,在配置系统中使用时需要是true)、additionalParameter( json字符串)
121
+ options: {
122
+ type: Object,
123
+ default: null,
124
+ },
125
+ // 列表组件行编辑使用,sql查询时数据表名称,用于自定义系统中列表组件中字段多表查询带有别名时,将点"."改成两个下划线"__"时使用
126
+ tableName: {
127
+ type: String,
128
+ default: null,
129
+ },
130
+ // 列表组件行编辑使用,是否是关联表,用于确定属性名是否需要拼接tableName
131
+ isJoinTable: {
132
+ type: Boolean,
133
+ default: false,
134
+ },
135
+ // 子表行编辑时,父表单数据
136
+ parent: {
137
+ type: Object,
138
+ default: null,
139
+ },
140
+ // 所在的列表编码
141
+ listCode: {
142
+ type: String,
143
+ default: null,
144
+ },
145
+ // 所在的表单编码
146
+ formCode: {
147
+ type: String,
148
+ default: null,
149
+ },
150
+ listToolbarFormData: {
151
+ type: Object,
152
+ default: () => {
153
+ return {}
154
+ },
155
+ },
156
+ fullWidth: {
157
+ type: Boolean,
158
+ default: true,
159
+ },
160
+ clearable: {
161
+ type: Boolean,
162
+ default: true,
163
+ },
164
+ size: {
165
+ type: String,
166
+ default: 'medium',
167
+ },
168
+ allowCreate: {
169
+ type: Boolean,
170
+ default: false,
171
+ },
172
+ analysisArea: {
173
+ type: Number,
174
+ default: null,
175
+ // 1 为工具栏解析
176
+ },
177
+ placeholder: {
178
+ type: String,
179
+ default: null,
180
+ },
181
+ // 下拉框配置宽度
182
+ optionWidth: {
183
+ default: 0,
184
+ },
185
+ },
186
+ // 是否是页面预览, 从页面管理传递
187
+ inject: {
188
+ isPageInfo: {value: 'isPageInfo', default: false},
189
+ },
190
+ data() {
191
+ const myProps = Object.assign({}, this.baseProps)
192
+ let markValue
193
+ if (this.entity) {
194
+ markValue = JSON.stringify(this.entity)
195
+ }
196
+ return {
197
+ /**
198
+ * 用于回显动态数据源选择的默认值,因为初始进入编辑状态时,没有获取映射关系,
199
+ * 如果当前字段是保存的label值则无法确定当前选项组的值对应哪一个,导致row中的对应字段变成了空值,所以备份一份
200
+ * 然后在获取动态数据源选项组后,给上默认值
201
+ */
202
+ markValue,
203
+ optionItems: [],
204
+ myProps,
205
+ valueSetOptions: [], // 字段映射集合配置
206
+ dynamicDataSourceCode: '', // 动态数据源编码
207
+ loading: false, // 是否在加载
208
+ valueAttribute: null, // 选项值字段,即控制下拉框组件的value-key属性的
209
+ remote: false, // 是否是远程搜索
210
+ additionalParameterStr: this.options.additionalParameter, // 附加参数json字符串
211
+ isLoaded: false, // 动态数据源是否直接显示静态页面
212
+ watchAttr: null, // 监控的entity属性名,多个属性名逗号分隔。即当该属性修改时,需要走后台重新获得当前下拉选的选项集合
213
+ backendUrl: null, // 后台访问路径
214
+ descriptionAttribute: null,
215
+ queryParam: {}, // 请求参数
216
+ }
217
+ },
218
+ watch: {
219
+ baseProps: {
220
+ deep: true,
221
+ handler(newModels) {
222
+ this.myProps = Object.assign({}, newModels)
223
+ },
224
+ },
225
+ },
226
+ created() {
227
+ if (this.options && this.options.dynamicDataSourceCode) {
228
+ this.dynamicDataSourceCode = this.options.dynamicDataSourceCode.trim()
229
+ const param = {
230
+ _listCode: this.listCode,
231
+ _formCode: this.formCode,
232
+ _tableName: this.tableName,
233
+ }
234
+ if (this.parent) {
235
+ param.parent = this.parent
236
+ }
237
+ if (!this.isPageInfo) {
238
+ this.packageDynamicDataSourceInfo(this.dynamicDataSourceCode, param)
239
+ .then((dynamicDataSourceDto) => {
240
+ // console.log('UI获取的数据', dynamicDataSourceDto)
241
+ if (dynamicDataSourceDto.backendUrl) {
242
+ this.backendUrl = dynamicDataSourceDto.backendUrl
243
+ }
244
+ if (
245
+ dynamicDataSourceDto.fuzzyQuery !== undefined &&
246
+ dynamicDataSourceDto.fuzzyQuery === true
247
+ ) {
248
+ // 是否启用远程搜索
249
+ this.remote = true
250
+ }
251
+ if (this.options && this.options.valueSetOptions) {
252
+ this.valueSetOptions = this.options.valueSetOptions
253
+ }
254
+ if (
255
+ this.options &&
256
+ this.options.isSql !== undefined &&
257
+ this.options.isSql !== null
258
+ ) {
259
+ this.isSql = this.options.isSql
260
+ }
261
+ if (this.watchAttr) {
262
+ let initWatchValue
263
+ const watchAttrs = this.watchAttr.split(',')
264
+ watchAttrs.forEach((attr) => {
265
+ // 初始化下拉选内容
266
+ if (this.entity) {
267
+ initWatchValue = this.entity[attr]
268
+ }
269
+ this.$watch('entity.' + attr, function (newValue, oldValue) {
270
+ this.watchAttrValueChange(newValue)
271
+ // this.inputValue('')
272
+ const items = this.optionItems.filter(
273
+ (item) => item[this.valueAttribute] === newValue
274
+ )
275
+ if (!items) {
276
+ this.inputValue('')
277
+ }
278
+ })
279
+ })
280
+ this.watchAttrValueChange(initWatchValue)
281
+ }
282
+ this.isLoaded = true
283
+ // 默认选中处理
284
+ if (dynamicDataSourceDto.defaultSelect) {
285
+ // 多选处理
286
+ if (this.baseProps.multiple) {
287
+ $emit(this, 'set-default-value', [
288
+ this.optionItems[0][this.valueAttribute],
289
+ ])
290
+ } else {
291
+ // 单选处理
292
+ if (this.optionItems.length > 0) {
293
+ $emit(
294
+ this,
295
+ 'set-default-value',
296
+ this.optionItems[0][this.valueAttribute]
297
+ )
298
+ }
299
+ }
300
+ }
301
+ // console.log('判断参数',this.analysisArea);
302
+ // console.log('判断参数',this.remote);
303
+ if (this.analysisArea !== 1 && this.remote) {
304
+ // 传递初始化查询供重置用
305
+ const that = this
306
+ $on(eventBus, 'remoteMethod', () => {
307
+ that.remoteMethod('')
308
+ })
309
+ // console.log('传递了参数');
310
+ }
311
+ $emit(this, 'load-completed', dynamicDataSourceDto)
312
+ })
313
+ .catch((error) => {
314
+ console.log(error)
315
+ $emit(this, 'load-completed', {
316
+ code: this.dynamicDataSourceCode,
317
+ error: error,
318
+ })
319
+ this.isLoaded = true
320
+ })
321
+ }
322
+ } else {
323
+ this.isLoaded = true
324
+ }
325
+ console.log(
326
+ '%c描述-095027',
327
+ 'color:#2E3435;background:#F8BB07;padding:3px;border-radius:2px',
328
+ this.optionWidth
329
+ )
330
+ },
331
+ methods: {
332
+ ...dynamicSourceSelectService,
333
+ ...events,
334
+ /**
335
+ * @description: 获取提示标题
336
+ * @Date: 2023-08-04 10:04:42
337
+ * @param {*}
338
+ * @return {*}
339
+ */
340
+ getClassOptionTitle(val) {
341
+ if (val !== null && val !== undefined && val !== '' && val.length > 0) {
342
+ let selectTittle = ''
343
+ if (typeof val === 'string') {
344
+ // 单选
345
+ if (this.descriptionAttribute) {
346
+ this.optionItems.forEach((item) => {
347
+ if (item[this.valueAttribute] === val) {
348
+ selectTittle = item._label_ + item._description_
349
+ }
350
+ })
351
+ } else {
352
+ this.optionItems.forEach((Ttem) => {
353
+ if (Ttem[this.valueAttribute] === val) {
354
+ selectTittle = Ttem._label_
355
+ }
356
+ })
357
+ }
358
+ } else {
359
+ // 多选
360
+ if (this.descriptionAttribute) {
361
+ this.optionItems.forEach((item) => {
362
+ val.forEach((Vtem) => {
363
+ if (item[this.valueAttribute] === Vtem) {
364
+ selectTittle = selectTittle + item._label_ + ','
365
+ }
366
+ })
367
+ })
368
+ selectTittle = selectTittle.slice(0, selectTittle.length - 1)
369
+ } else {
370
+ this.optionItems.forEach((Ttem) => {
371
+ val.forEach((Vtem) => {
372
+ if (Ttem[this.valueAttribute] === Vtem) {
373
+ selectTittle = selectTittle + Ttem._label_ + ','
374
+ }
375
+ })
376
+ })
377
+ selectTittle = selectTittle.slice(0, selectTittle.length - 1)
378
+ }
379
+ }
380
+ return selectTittle
381
+ }
382
+ },
383
+ // 必须有该方法,否则无法给字段赋值
384
+ inputValue(newValue) {
385
+ $emit(this, 'update:value', newValue)
386
+ if (newValue === null || newValue === undefined || newValue === '') {
387
+ this.remoteQueryMethod(newValue)
388
+ }
389
+ this.setValues(newValue)
390
+ },
391
+ packageDynamicDataSourceInfo(dynamicDataSourceCode, param) {
392
+ return new Promise((resolve, reject) => {
393
+ this.findDynamicDataSourceByCode(
394
+ dynamicDataSourceCode,
395
+ this.entity,
396
+ param,
397
+ this.additionalParameterStr,
398
+ this.backendUrl
399
+ )
400
+ .then((dynamicDataSourceDto) => {
401
+ if (dynamicDataSourceDto) {
402
+ if (dynamicDataSourceDto.options) {
403
+ this.optionItems = dynamicDataSourceDto.options
404
+ if (this.watchAttr) {
405
+ // 解决当监控值变化时,数据源重新加载后select输入框中显示的值和下拉中的值不一致问题
406
+ if (
407
+ this.baseProps.multiple !== undefined &&
408
+ this.baseProps.multiple === true
409
+ ) {
410
+ this.$nextTick(() => {
411
+ this.$refs['dynamicDataSourceRef'].setSelected()
412
+ })
413
+ }
414
+ }
415
+ //
416
+ if (this.column) {
417
+ // 只有行编辑时处理
418
+ // 设置选项组数据、 选项组值字段、 映射关系
419
+ if (
420
+ this.column.prop !== dynamicDataSourceDto.valueAttribute
421
+ ) {
422
+ this.column['_dynamic-source-data-' + this.column.prop] = {
423
+ valueSetOptions: this.options.valueSetOptions,
424
+ optionItems: this.optionItems,
425
+ valueAttribute: dynamicDataSourceDto.valueAttribute,
426
+ }
427
+ }
428
+ for (
429
+ let i = 0;
430
+ i < this.options.valueSetOptions.length;
431
+ i++
432
+ ) {
433
+ const valueSetOption = this.options.valueSetOptions[i]
434
+ if (
435
+ dynamicDataSourceDto.valueAttribute ===
436
+ valueSetOption.columnName
437
+ ) {
438
+ if (this.markValue) {
439
+ const muMarkValue = JSON.parse(this.markValue)
440
+ if (
441
+ muMarkValue &&
442
+ muMarkValue[valueSetOption.valueColumn.dbColumnName]
443
+ ) {
444
+ let targeValue = (
445
+ muMarkValue[
446
+ valueSetOption.valueColumn.dbColumnName
447
+ ] + ''
448
+ ).split(',')
449
+ if (this.column.componentType === 'select') {
450
+ // 如果是单选
451
+ targeValue = targeValue[0]
452
+ }
453
+ // 不需要再赋值了 如果当前字段不上动态数据源的值字段,那就表示不需要回显
454
+ // if (valueSetOption.valueColumn.dbColumnName === this.column.prop) {
455
+ // this.$emit('set-value', {
456
+ // value: targeValue,
457
+ // targetColumnName: this.column.prop
458
+ // })
459
+ // }
460
+ }
461
+ }
462
+ break
463
+ }
464
+ }
465
+ }
466
+ } else {
467
+ this.optionItems = []
468
+ }
469
+ if (dynamicDataSourceDto.valueAttribute) {
470
+ this.valueAttribute = dynamicDataSourceDto.valueAttribute
471
+ }
472
+ if (dynamicDataSourceDto.descriptionAttribute) {
473
+ this.descriptionAttribute =
474
+ dynamicDataSourceDto.descriptionAttribute
475
+ }
476
+ this.valueAttribute = this.getValueAttribute()
477
+ this.watchAttr = dynamicDataSourceDto.watchAttr
478
+ $emit(this, 'load-completed', dynamicDataSourceDto)
479
+ resolve(dynamicDataSourceDto)
480
+ } else {
481
+ resolve()
482
+ }
483
+ })
484
+ .catch((error) => {
485
+ reject(error)
486
+ })
487
+ })
488
+ },
489
+ // 远程搜索方法
490
+ remoteQuery(searchText, watchAttrValue) {
491
+ if (
492
+ (searchText !== null && searchText !== undefined) ||
493
+ (watchAttrValue !== null && watchAttrValue !== undefined)
494
+ ) {
495
+ const param = {
496
+ _listCode: this.listCode,
497
+ _formCode: this.formCode,
498
+ _tableName: this.tableName,
499
+ }
500
+ if (searchText !== null && searchText !== undefined) {
501
+ param.searchText = searchText
502
+ }
503
+ if (watchAttrValue !== null && watchAttrValue !== undefined) {
504
+ // 监控的属性值改变了远程搜索方法
505
+ if (
506
+ Object.prototype.toString.apply(watchAttrValue) === '[object Array]'
507
+ ) {
508
+ param.watchAttrValue = watchAttrValue.join(',')
509
+ } else {
510
+ param.watchAttrValue = watchAttrValue + ''
511
+ }
512
+ } else if (this.entity) {
513
+ // 搜索时下拉选项的集合
514
+ const watchValue = this.entity[this.watchAttr]
515
+ if (watchValue !== null && watchValue !== undefined) {
516
+ if (
517
+ Object.prototype.toString.apply(watchValue) === '[object Array]'
518
+ ) {
519
+ param.watchAttrValue = watchValue.join(',')
520
+ } else {
521
+ param.watchAttrValue = watchValue + ''
522
+ }
523
+ }
524
+ }
525
+ if (this.parent) {
526
+ param.parent = this.parent
527
+ }
528
+ this.loading = true
529
+ this.packageDynamicDataSourceInfo(this.dynamicDataSourceCode, param)
530
+ .then((dynamicDataSourceDto) => {
531
+ this.loading = false
532
+ })
533
+ .catch((error) => {
534
+ console.log(error)
535
+ this.loading = false
536
+ })
537
+ }
538
+ },
539
+ // 远程搜索方法
540
+ remoteQueryMethod(searchText) {
541
+ if (Array.isArray(this.value)) {
542
+ if (this.value.length === 0) {
543
+ this.remoteQuery(searchText, null)
544
+ }
545
+ } else {
546
+ this.remoteQuery(searchText, null)
547
+ }
548
+ },
549
+ /**
550
+ * 输入框输入查询值时搜索方法,
551
+ * 不使用remoteQueryMethod, 解决输入框第一次输入时可查询,第二次输入时没有触发查询方法问题
552
+ * @param {*} searchText
553
+ */
554
+ remoteMethod(searchText) {
555
+ this.remoteQuery(searchText, null)
556
+ },
557
+ // 监控的属性值改变了远程搜索方法
558
+ watchAttrValueChange(watchAttrValues) {
559
+ this.remoteQuery(null, watchAttrValues)
560
+ },
561
+ getValueAttribute() {
562
+ return !this.valueAttribute || this.valueAttribute === '[label]'
563
+ ? '_label_'
564
+ : this.valueAttribute
565
+ },
566
+ setValues(newValue) {
567
+ if (this.valueSetOptions && this.valueSetOptions.length > 0) {
568
+ this.valueSetOptions.forEach((columnInfo) => {
569
+ const sourceColumnName = columnInfo.columnName
570
+ let value
571
+ if (this.optionItems && sourceColumnName) {
572
+ value = this.getTargetColumnValue(newValue, sourceColumnName)
573
+ }
574
+ let targetColumnName = null
575
+ const targetColumnInfo = columnInfo.valueColumn
576
+ if (targetColumnInfo) {
577
+ targetColumnName = targetColumnInfo.name
578
+ if (this.isSql === true) {
579
+ targetColumnName = targetColumnInfo.dbColumnName
580
+ targetColumnName = getPropNameWhenJoinTable(
581
+ targetColumnName,
582
+ this.isJoinTable,
583
+ this.tableName
584
+ )
585
+ }
586
+ }
587
+ if (
588
+ this.entity &&
589
+ targetColumnName &&
590
+ targetColumnName !== null &&
591
+ targetColumnName !== ''
592
+ ) {
593
+ setEntityFieldValue(this.entity, targetColumnName, value)
594
+ }
595
+ const item = this.getSelectedOptionItem(newValue)
596
+ $emit(this, 'set-value', {
597
+ value: value,
598
+ sourceColumnName: sourceColumnName,
599
+ targetColumnName: targetColumnName,
600
+ options: this.optionItems,
601
+ selectedItem: item,
602
+ })
603
+ })
604
+ }
605
+ },
606
+ // 获得目的字段的值
607
+ getTargetColumnValue(newValue, sourceColumnName) {
608
+ if (newValue) {
609
+ let value = ''
610
+ if (
611
+ this.baseProps.multiple !== undefined &&
612
+ this.baseProps.multiple === true &&
613
+ Array.isArray(newValue)
614
+ ) {
615
+ // 多选值处理,数组信息,使用逗号分开的格式设置其它字段的值
616
+ let i = 0
617
+ newValue.forEach((itemValue) => {
618
+ const items = this.optionItems.filter(
619
+ (item) => item[this.valueAttribute] === itemValue
620
+ )
621
+ if (items && items.length > 0) {
622
+ value += items[0][sourceColumnName]
623
+ if (i < newValue.length - 1) {
624
+ // 最后一个元素不加逗号
625
+ value += ','
626
+ }
627
+ i++
628
+ }
629
+ })
630
+ } else {
631
+ // 单选
632
+ const items = this.optionItems.filter(
633
+ (item) => item[this.valueAttribute] === newValue
634
+ )
635
+ if (items && items.length > 0) {
636
+ value = items[0][sourceColumnName]
637
+ }
638
+ }
639
+ return value
640
+ }
641
+ },
642
+ // 移除所有tag和clear时候清除markValue的值解决清除选项时关联字段清空了但是当前动态数据源控件仍然有值问题
643
+ clearMarkValue() {
644
+ if (this.markValue && this.entity) {
645
+ const muMarkValue = JSON.parse(this.markValue)
646
+ for (let i = 0; i < this.options.valueSetOptions.length; i++) {
647
+ const valueSetOption = this.options.valueSetOptions[i]
648
+ muMarkValue[valueSetOption.valueColumn.dbColumnName] = null
649
+ }
650
+ this.markValue = JSON.stringify(muMarkValue)
651
+ }
652
+ },
653
+ },
654
+ emits: [
655
+ 'set-default-value',
656
+ 'load-completed',
657
+ 'update:value',
658
+ 'set-value',
659
+ ,
660
+ 'update:value',
661
+ ],
662
+ }
663
+ </script>
664
+
665
+ <style>
666
+ .select-top-span {
667
+ width: 100%;
668
+ }
669
+ </style>
670
+
671
+ <style lang="scss" scoped>
672
+ :deep(.el-select-dropdown__item) {
673
+ display: inline-block;
674
+ }
675
+ </style>