imatrix-ui 0.2.5-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 +2732 -1940
  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 -350
  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 -228
  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 -156
  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,762 +1,762 @@
1
- <template>
2
- <div>
3
- <search-condition-list
4
- v-if="searchConditions.length > 0"
5
- ref="searchConditionList"
6
- :search-type="searchType"
7
- :search-conditions="searchConditions"
8
- @remove-condition="removeCondition"
9
- @select-condition="selectCondition"
10
- />
11
- <search-form-ordinarySearch
12
- v-if="searchType === 'normal'"
13
- ref="searchFormOrdinarySearch"
14
- :searchable-columns="searchableColumns"
15
- :search-form="searchForm"
16
- :field-num="fieldNum"
17
- :label-width="labelWidth"
18
- :query="query"
19
- :code="code"
20
- :row-num="rowNum"
21
- :span-num="spanNum"
22
- :rules="rules"
23
- :is-sql="isSql"
24
- :load-complete-query="loadCompleteQuery"
25
- @submit-form="submitForm('searchForm')"
26
- @reset-form="resetForm('searchForm')"
27
- @save-condition="saveCondition()"
28
- @open-fold="openFold"
29
- />
30
- <search-form-advancedQuery
31
- v-if="searchType === 'advanced'"
32
- ref="searchFormAdvancedQuery"
33
- style="padding-bottom: 10px"
34
- :code="code"
35
- :searchable-columns="advancedQueryColumns"
36
- :search-form-list="searchFormList"
37
- :prop-map="propMap"
38
- :is-sql="isSql"
39
- @resetForm="resetSearchFormList"
40
- />
41
- <div
42
- v-if="searchType === 'advanced'"
43
- style="padding-top: 10px; padding-bottom: 10px; text-align: center"
44
- >
45
- <el-button
46
- :loading="loading"
47
- type="primary"
48
- size="mini"
49
- @click="submitForm('searchForm')"
50
- >
51
- {{ $t('imatrixUIPublicModel.sure') }}
52
- </el-button>
53
- <el-button
54
- :loading="loading"
55
- size="mini"
56
- @click="resetForm('searchForm')"
57
- >
58
- {{ $t('imatrixUIPublicModel.reset') }}
59
- </el-button>
60
- <el-button size="mini" @click="saveCondition">
61
- {{ $t('superGrid.saveCondition') }}
62
- </el-button>
63
- <span
64
- v-if="
65
- advancedQuery !== null &&
66
- advancedQuery !== undefined &&
67
- advancedQuery === true &&
68
- normalQuery !== null &&
69
- normalQuery !== undefined &&
70
- normalQuery === true
71
- "
72
- style="margin-left: 10px"
73
- >
74
- <el-button
75
- v-if="searchType === 'advanced'"
76
- size="mini"
77
- @click="searchType = 'normal'"
78
- >
79
- {{ $t('imatrixUIPublicModel.switchToNormalQuery') }}
80
- </el-button>
81
- <el-button
82
- v-if="searchType === 'normal'"
83
- size="mini"
84
- @click="searchType = 'advanced'"
85
- >
86
- {{ $t('imatrixUIPublicModel.switchToAdvancedQuery') }}
87
- </el-button>
88
- </span>
89
- </div>
90
- <search-condition-input
91
- v-if="isShowSearchCondition"
92
- @close="saveConditionValue"
93
- />
94
- </div>
95
- </template>
96
-
97
- <script>
98
- import { $on, $off, $once, $emit } from '../../utils/gogocodeTransfer'
99
- import searchMethods from './search-methods'
100
- // import searchFormNumber from './search-form-number.vue'
101
- import searchFormOrdinarySearch from './search-form-ordinarySearch.vue'
102
- // import searchFormAdvancedQuery from './search-form-advancedQuery'
103
- import store from './store'
104
- // import { isOptionFunction, getSearchObject } from './utils'
105
- import { addDynamicProp, addDynamicPropDateSection } from './utils'
106
- import * as Vue from 'vue'
107
- import SearchConditionInput from './search-condition-input.vue'
108
- import SearchConditionList from './search-condition-list.vue'
109
- export default {
110
- name: 'SearchForm',
111
- components: {
112
- // searchFormNumber,
113
- SearchConditionInput,
114
- SearchConditionList,
115
- searchFormOrdinarySearch,
116
- // searchFormAdvancedQuery
117
- },
118
- provide() {
119
- return {
120
- getListToolbarFormData: () => ({
121
- listToolbarFormData: this.listToolbarFormData,
122
- }),
123
- }
124
- },
125
- props: {
126
- columns: {
127
- type: Array,
128
- default: null,
129
- },
130
- code: {
131
- type: String,
132
- default: null,
133
- },
134
- url: {
135
- type: String,
136
- default: null,
137
- },
138
- pagination: {
139
- type: Object,
140
- default: null,
141
- },
142
- query: {
143
- type: Object,
144
- default: null,
145
- },
146
- searchParam: {
147
- type: Object,
148
- default: null,
149
- },
150
- initSearchProps: {
151
- type: Array,
152
- default: null,
153
- },
154
- isSql: {
155
- type: Boolean,
156
- default: false,
157
- },
158
- searchFormInfo: {
159
- type: Object,
160
- default: () => {
161
- return {}
162
- },
163
- },
164
- loadCompleteQuery: {
165
- type: Boolean,
166
- default: false,
167
- },
168
- listToolbarFormData: {
169
- type: Object,
170
- default: null,
171
- },
172
- },
173
- data() {
174
- const customComponentNames = new Set()
175
- const gridParams = store.get(this.code)
176
- const propMap = {}
177
- let searchForm = {}
178
- if (this.searchParam !== null) {
179
- searchForm = JSON.parse(JSON.stringify(this.searchParam))
180
- }
181
- const searchColumns = this.getSearchableColumns(null, null, propMap)
182
- if (this.initSearchProps === undefined || this.initSearchProps === null) {
183
- this.initSearchProps = []
184
- }
185
- console.log('searchForm=', searchColumns)
186
- searchColumns.forEach((column) => {
187
- // propMap[column.prop] = column
188
- if (this.initSearchProps.indexOf(column.prop) < 0) {
189
- // 表示没有默认初始查询字段
190
- if (column.prop && column.prop.indexOf('.') > 0) {
191
- if (column.componentType === 'dateSection') {
192
- addDynamicPropDateSection(searchForm, column.prop)
193
- } else {
194
- // 动态给searchForm添加属性,包括多级嵌套属性,属性的初始值都为 null
195
- addDynamicProp(searchForm, column.prop)
196
- }
197
- } else {
198
- if (column.componentType === 'dateSection') {
199
- searchForm[column.prop] = [new Date(), new Date()]
200
- } else if (column.componentType === 'yearRange') {
201
- searchForm[column.prop] = ['', '']
202
- } else {
203
- searchForm[column.prop] = null
204
- }
205
- this.setDefaultQueryValue(column, searchForm)
206
- }
207
- }
208
- })
209
- const spanNum = this.getSpanNum()
210
- const fieldNum = this.getFieldNumPerRow()
211
- const rowNum = Math.ceil(searchColumns.length / fieldNum)
212
- console.log('rowNumrowNumrowNumrowNum', rowNum)
213
- console.log(searchColumns)
214
- console.log(fieldNum)
215
- const advancedQuery = this.query.advancedQuery
216
- const normalQuery = this.query.normalQuery
217
- // console.log('searchColumns.length=' + searchColumns.length + ',fieldNum=' + fieldNum + ',rowNum=' + rowNum)
218
- // // -2是把
219
- // const dateSpanNum = (spanNum - 2) / 2
220
-
221
- return {
222
- searchForm,
223
- rules: {},
224
- searchParams: [],
225
- labelWidth:
226
- gridParams.options.search && gridParams.options.search.labelWidth
227
- ? gridParams.options.search.labelWidth
228
- : '80px',
229
- customComponentNames: customComponentNames,
230
- componentName: '',
231
- spanNum: spanNum,
232
- fieldNum: fieldNum, // 每行放的字段个数
233
- rowNum: rowNum, // 一共有几行
234
- loading: false, // 是否正在查询,默认时否
235
- isShowSearchCondition: false,
236
- searchConditions: [],
237
- propMap,
238
- advancedQuery,
239
- normalQuery,
240
- searchFormList: [],
241
- searchType: null,
242
- }
243
- },
244
- computed: {
245
- searchableColumns() {
246
- return this.getSearchableColumns()
247
- },
248
- advancedQueryColumns() {
249
- return this.getAdvancedQueryColumns()
250
- },
251
- },
252
- watch: {
253
- searchForm: {
254
- deep: true,
255
- handler(val) {
256
- this.searchFormInfo['data'] = val
257
- },
258
- },
259
- },
260
- created() {
261
- this.listSearchConditions()
262
- if (this.normalQuery) {
263
- this.searchType = 'normal'
264
- } else if (this.advancedQuery) {
265
- this.searchType = 'advanced'
266
- }
267
- },
268
- methods: {
269
- ...searchMethods,
270
- // 每行放的字段个数
271
- getFieldNumPerRow() {
272
- const gridParams = store.get(this.code)
273
- return gridParams.options.search && gridParams.options.search.fieldNum
274
- ? gridParams.options.search.fieldNum
275
- : 3
276
- },
277
- // 根据每行显示的字段个数,确定栅栏个数,默认是4个字段。最多就只能放6个字段
278
- getSpanNum() {
279
- const fieldNum = this.getFieldNumPerRow()
280
- if (fieldNum === 1) {
281
- return 22
282
- } else if (fieldNum === 2) {
283
- return 10
284
- } else if (fieldNum === 3) {
285
- return 8
286
- } else if (fieldNum === 4) {
287
- return 6
288
- } else {
289
- // 6个字段
290
- return 4
291
- }
292
- },
293
- setValueToModelProp(prop, value, componentName, index) {
294
- if (prop && prop.indexOf('.') > 0) {
295
- const parentOjbect = this.getParentObject(prop)
296
- // 嵌套属性中的最后一个属性是属于这个中间父对象的,所有要通过中间父对象来赋值
297
- if (index != null && index !== undefined) {
298
- // parentOjbect[prop.substring(prop.lastIndexOf('.') + 1)][index] = value
299
- parentOjbect[prop.substring(prop.lastIndexOf('.') + 1)][index] = value
300
- } else {
301
- parentOjbect[prop.substring(prop.lastIndexOf('.') + 1)] = value
302
- }
303
- } else {
304
- if (index != null && index !== undefined) {
305
- this.searchForm[prop][index] = value
306
- } else {
307
- this.searchForm[prop] = value
308
- }
309
- }
310
- },
311
- getAdvancedQueryColumns(columns, searchColumns, propMap) {
312
- if (!this.customComponentNames) {
313
- this.customComponentNames = new Set()
314
- }
315
- if (!searchColumns) {
316
- searchColumns = []
317
- }
318
- if (!columns) {
319
- columns = this.columns
320
- }
321
- for (let i = 0; i < columns.length; i++) {
322
- const column = columns[i]
323
- if (propMap) {
324
- propMap[column.prop] = column
325
- }
326
- if (
327
- column.prop === '$index' ||
328
- column.prop === '$selection' ||
329
- column.dynamic
330
- ) {
331
- // 序号和复选框列、动态列 不属于该组件的查询字段
332
- continue
333
- }
334
- if (column.groupHeader) {
335
- // 组合表头中子表头的字段查询
336
- this.getSearchableColumns(column.children, searchColumns, propMap)
337
- } else {
338
- if (
339
- column.queryType === 'advanced' &&
340
- !column.custom &&
341
- column.prop !== ''
342
- ) {
343
- // 表示是普通查询,且不是占位符列,是查询字段
344
- if (
345
- typeof column.componentType === 'undefined' ||
346
- column.componentType === ''
347
- ) {
348
- column.componentType = 'input'
349
- }
350
- if (column.querySetting && column.querySetting !== '') {
351
- const querySetting = JSON.parse(column.querySetting)
352
- if (querySetting.width) {
353
- column.searchControlWidth = 'width:' + querySetting.width + 'px'
354
- }
355
- if (querySetting.labelWidth) {
356
- column.searchLabelWidth = querySetting.labelWidth + 'px'
357
- }
358
- if (querySetting.label) {
359
- column.searchLabel = querySetting.label
360
- }
361
- }
362
- // 行编辑时自定义编辑组件
363
- if (
364
- column.componentType &&
365
- column.componentType.indexOf('custom:') >= 0
366
- ) {
367
- column.componentName = column.componentType.substring(
368
- column.componentType.indexOf(':') + 1
369
- )
370
- this.customComponentNames.add(column.componentName)
371
- } else {
372
- column.componentName = ''
373
- }
374
- // this.$set(this.propMap, column.prop, column)
375
- // this.propMap[column.prop] = column
376
- searchColumns.push(column)
377
- }
378
- }
379
- }
380
- return searchColumns
381
- },
382
- getSearchableColumns(columns, searchColumns, propMap) {
383
- if (!this.customComponentNames) {
384
- this.customComponentNames = new Set()
385
- }
386
- if (!searchColumns) {
387
- searchColumns = []
388
- }
389
- if (!columns) {
390
- columns = this.columns
391
- }
392
- for (let i = 0; i < columns.length; i++) {
393
- const column = columns[i]
394
- if (propMap) {
395
- propMap[column.prop] = column
396
- }
397
- if (
398
- column.prop === '$index' ||
399
- column.prop === '$selection' ||
400
- column.dynamic
401
- ) {
402
- // 序号和复选框列、动态列 不属于该组件的查询字段
403
- continue
404
- }
405
- if (column.groupHeader) {
406
- // 组合表头中子表头的字段查询
407
- this.getSearchableColumns(column.children, searchColumns, propMap)
408
- } else {
409
- if (
410
- column.queryType === 'normal' &&
411
- !column.custom &&
412
- column.prop !== ''
413
- ) {
414
- // 表示是普通查询,且不是占位符列,是查询字段
415
- if (
416
- typeof column.componentType === 'undefined' ||
417
- column.componentType === ''
418
- ) {
419
- column.componentType = 'input'
420
- }
421
- if (column.querySetting && column.querySetting !== '') {
422
- const querySetting = JSON.parse(column.querySetting)
423
- if (querySetting.width) {
424
- column.searchControlWidth = 'width:' + querySetting.width + 'px'
425
- }
426
- if (querySetting.labelWidth) {
427
- column.searchLabelWidth = querySetting.labelWidth + 'px'
428
- }
429
- if (querySetting.label) {
430
- column.searchLabel = querySetting.label
431
- }
432
- }
433
- // 行编辑时自定义编辑组件
434
- if (
435
- column.componentType &&
436
- column.componentType.indexOf('custom:') >= 0
437
- ) {
438
- column.componentName = column.componentType.substring(
439
- column.componentType.indexOf(':') + 1
440
- )
441
- this.customComponentNames.add(column.componentName)
442
- } else {
443
- column.componentName = ''
444
- }
445
- // this.$set(this.propMap, column.prop, column)
446
- // this.propMap[column.prop] = column
447
- searchColumns.push(column)
448
- }
449
- }
450
- }
451
- return searchColumns
452
- },
453
- customComponent(column) {
454
- const gridParams = store.get(this.code)
455
- if (column.componentName && column.componentName !== '') {
456
- this.customComponentNames.add(column.componentName)
457
- return true
458
- }
459
- if (
460
- (!column.componentName || column.componentName === '') &&
461
- gridParams.options &&
462
- gridParams.options.search &&
463
- gridParams.options.search.customSearchElements
464
- ) {
465
- // 定义了自定义查询组件
466
- const propSearchEle =
467
- gridParams.options.search.customSearchElements[column.prop]
468
- // console.log('customComponent-customSearchElements-propSearchEle-', column.prop)
469
- if (propSearchEle) {
470
- column.componentName = 'custom-' + column.prop
471
- const component = propSearchEle.call(this, column)
472
- // console.log('customComponent-customSearchElements-')
473
- if (component) {
474
- this.customComponentNames.add(column.componentName)
475
- window.$vueApp.component(column.componentName, component)
476
- return true
477
- }
478
- }
479
- }
480
- return false
481
- },
482
- submitForm() {
483
- if (this.searchType === 'normal') {
484
- this.$refs.searchFormOrdinarySearch.validateForm().then((valid) => {
485
- if (valid) {
486
- // this.loading = true
487
- this.searchParams = this.packageSearchParam()
488
- $emit(this, 'search', this.searchParams)
489
- } else {
490
- return false
491
- }
492
- })
493
- } else if (this.searchType === 'advanced') {
494
- this.$refs.searchFormAdvancedQuery.validateForm().then((valid) => {
495
- if (valid) {
496
- this.loading = true
497
- this.searchParams = this.packageSearchParam()
498
- $emit(this, 'search', this.searchParams)
499
- } else {
500
- return false
501
- }
502
- })
503
- }
504
- },
505
- resetForm() {
506
- if (this.$refs.searchConditionList) {
507
- this.$refs.searchConditionList.editConditionId = null
508
- }
509
- if (this.searchType === 'normal') {
510
- this.$refs.searchFormOrdinarySearch.resetForm()
511
- } else if (this.searchType === 'advanced') {
512
- this.$refs.searchFormAdvancedQuery.resetForm()
513
- $emit(this, 'reset')
514
- }
515
- // 子组件重置完成后调用reset方法 同步执行
516
- // this.$emit('reset')
517
- },
518
- setNumberValue(value, r, n) {
519
- let itemValue = this.getFormItemValue(
520
- this.searchableColumns[this.fieldNum * (r - 1) + (n - 1)].prop
521
- )
522
- itemValue = value
523
- this.setValueToModelProp(
524
- this.searchableColumns[this.fieldNum * (r - 1) + (n - 1)].prop,
525
- itemValue
526
- )
527
- },
528
- listSearchConditions() {
529
- return new Promise((resolve, reject) => {
530
- this.listSearchCondition(this.code)
531
- .then((conditions) => {
532
- this.searchConditions = conditions
533
- resolve(conditions)
534
- })
535
- .catch((error) => {
536
- reject(error)
537
- })
538
- })
539
- },
540
- saveCondition() {
541
- const searchParams = this.packageSearchParam()
542
- if (!searchParams || searchParams.length === 0) {
543
- this.$message({
544
- type: 'warning',
545
- message: this.$t('imatrixUIMessage.pleaseInputSearchCondition'),
546
- showClose: true,
547
- })
548
- return
549
- }
550
- this.isShowSearchCondition = true
551
- },
552
- saveConditionValue(conditionName) {
553
- if (conditionName) {
554
- let searchParams
555
- if (
556
- this.searchType === 'normal' ||
557
- this.searchType === '' ||
558
- this.searchType === null ||
559
- this.searchType === undefined
560
- ) {
561
- searchParams = this.packageSearchParam()
562
- } else {
563
- searchParams = this.searchFormList
564
- }
565
- const condition = {
566
- listCode: this.code,
567
- queryType:
568
- this.searchType === 'normal' ||
569
- this.searchType === '' ||
570
- this.searchType === null ||
571
- this.searchType === undefined
572
- ? 'FIXED'
573
- : 'CUSTOM',
574
- name: conditionName,
575
- queryCondition: JSON.stringify(searchParams),
576
- }
577
- this.saveSearchCondition(condition).then((condition) => {
578
- this.$message({
579
- type: 'success',
580
- message: this.$t('imatrixUIMessage.saveSuccessfully'),
581
- showClose: true,
582
- })
583
- this.isShowSearchCondition = false
584
- this.listSearchConditions().then(() => {
585
- if (this.$refs.searchConditionList) {
586
- // 选中刚刚保存的条件
587
- this.$refs.searchConditionList.editConditionId = condition.id + ''
588
- }
589
- // 查询条件对应的数据
590
- this.selectCondition(condition.id)
591
- })
592
- })
593
- }
594
- this.isShowSearchCondition = false
595
- },
596
- removeCondition(conditionId) {
597
- if (conditionId) {
598
- this.$confirm(
599
- this.$t('imatrixUIMessage.whetherToConfirmDeletion'),
600
- this.$t('imatrixUIMessage.tips'),
601
- {
602
- confirmButtonText: this.$t('imatrixUIPublicModel.sure'),
603
- cancelButtonText: this.$t('imatrixUIPublicModel.cancel'),
604
- type: 'warning',
605
- }
606
- ).then(() => {
607
- this.removeSearchCondition(conditionId).then(() => {
608
- this.$message({
609
- type: 'success',
610
- message: this.$t('superGrid.deleteSuccessful'),
611
- showClose: true,
612
- })
613
- this.listSearchConditions()
614
- })
615
- })
616
- }
617
- },
618
- selectCondition(conditionId) {
619
- if (conditionId) {
620
- this.getSearchCondition(conditionId).then((searchCondition) => {
621
- if (searchCondition) {
622
- const queryCondition = searchCondition.queryCondition
623
- if (queryCondition) {
624
- if (
625
- this.searchType === 'normal' ||
626
- this.searchType === '' ||
627
- this.searchType === null ||
628
- this.searchType === undefined
629
- ) {
630
- const searchParams = JSON.parse(queryCondition)
631
- const searchForm = this.packageSearchForm(searchParams)
632
- if (searchForm) {
633
- this.searchForm = searchForm
634
- }
635
- // 查询数据
636
- this.loading = true
637
- $emit(this, 'search', searchParams)
638
- } else {
639
- this.searchFormList = JSON.parse(queryCondition)
640
- // 查询数据
641
- this.loading = true
642
- $emit(this, 'search', this.packageSearchParam())
643
- }
644
- }
645
- }
646
- })
647
- }
648
- },
649
- // 封装searchForm
650
- packageSearchForm(searchFormArr) {
651
- if (searchFormArr && searchFormArr.length > 0) {
652
- const searchForm = {}
653
- const initSearchProps = []
654
- searchFormArr.forEach((item) => {
655
- // 获得的是"isDeleted"
656
- let prop = item.propName
657
- // 获得的是“deleted”
658
- const columnProp = item.columnProp
659
- const dataType = item.dataType
660
- if (dataType && dataType === 'BOOLEAN' && columnProp) {
661
- prop = columnProp
662
- }
663
- if (initSearchProps.indexOf(prop) === -1) {
664
- initSearchProps.push(prop)
665
- }
666
- const propValue = item.propValue
667
- if (prop && prop.indexOf('.') > 0) {
668
- // 动态给searchForm添加属性,包括多级嵌套属性,属性的初始值都为 null
669
- addDynamicProp(searchForm, prop, propValue)
670
- } else {
671
- let isRangeQueryValue = false
672
- if (dataType && (dataType === 'DATE' || dataType === 'TIME')) {
673
- if (item.startValue && item.endValue) {
674
- isRangeQueryValue = true
675
- }
676
- }
677
- if (isRangeQueryValue) {
678
- searchForm[prop] = [
679
- new Date(item.startValue),
680
- new Date(item.endValue),
681
- ]
682
- } else {
683
- if (searchForm[prop]) {
684
- if (searchForm[prop] instanceof Array) {
685
- searchForm[prop].push(propValue)
686
- } else {
687
- searchForm[prop] = [searchForm[prop], propValue]
688
- }
689
- } else {
690
- searchForm[prop] = propValue
691
- }
692
- }
693
- }
694
- })
695
-
696
- this.searchableColumns.forEach((column) => {
697
- if (initSearchProps) {
698
- if (initSearchProps.indexOf(column.prop) < 0) {
699
- // 表示没有默认初始查询字段
700
- if (column.prop && column.prop.indexOf('.') > 0) {
701
- if (column.componentType === 'dateSection') {
702
- addDynamicPropDateSection(searchForm, column.prop)
703
- } else {
704
- // 动态给searchForm添加属性,包括多级嵌套属性,属性的初始值都为 null
705
- addDynamicProp(searchForm, column.prop)
706
- }
707
- } else {
708
- if (column.componentType === 'dateSection') {
709
- searchForm[column.prop] = [new Date(), new Date()]
710
- } else {
711
- searchForm[column.prop] = null
712
- }
713
- }
714
- } else {
715
- if (
716
- column.componentType === 'multiselect' &&
717
- searchForm[column.prop]
718
- ) {
719
- if (!(searchForm[column.prop] instanceof Array)) {
720
- searchForm[column.prop] = [searchForm[column.prop]]
721
- }
722
- }
723
- }
724
- }
725
- })
726
-
727
- return searchForm
728
- }
729
- },
730
- resetSearchFormList() {
731
- this.searchFormList = null
732
- },
733
- openFold(isOpen) {
734
- $emit(this, 'open-fold', isOpen)
735
- },
736
- // 查询完毕
737
- searchComplete() {
738
- if (this.$refs.searchFormOrdinarySearch) {
739
- this.$refs.searchFormOrdinarySearch.searchComplete()
740
- }
741
- },
742
- },
743
- emits: ['search', 'open-fold', 'reset'],
744
- }
745
- </script>
746
-
747
- <style scoped>
748
- .grid-search-form {
749
- overflow: auto;
750
- }
751
- .grid-search-form :deep(.el-form-item) {
752
- margin-bottom: 0px;
753
- }
754
- .grid-search-form :deep(.search-btn) {
755
- margin-bottom: 5px;
756
- text-align: center;
757
- }
758
- .grid-search-form :deep(.el-select),
759
- .grid-search-form :deep(.customComponent) {
760
- width: 100%;
761
- }
762
- </style>
1
+ <template>
2
+ <div>
3
+ <search-condition-list
4
+ v-if="searchConditions.length > 0"
5
+ ref="searchConditionList"
6
+ :search-type="searchType"
7
+ :search-conditions="searchConditions"
8
+ @remove-condition="removeCondition"
9
+ @select-condition="selectCondition"
10
+ />
11
+ <search-form-ordinary-search
12
+ v-if="searchType === 'normal'"
13
+ ref="searchFormOrdinarySearch"
14
+ :searchable-columns="searchableColumns"
15
+ :search-form="searchForm"
16
+ :field-num="fieldNum"
17
+ :label-width="labelWidth"
18
+ :query="query"
19
+ :code="code"
20
+ :row-num="rowNum"
21
+ :span-num="spanNum"
22
+ :rules="rules"
23
+ :is-sql="isSql"
24
+ :load-complete-query="loadCompleteQuery"
25
+ @submit-form="submitForm('searchForm')"
26
+ @reset-form="resetForm('searchForm')"
27
+ @save-condition="saveCondition()"
28
+ @open-fold="openFold"
29
+ />
30
+ <search-form-advanced-query
31
+ v-if="searchType === 'advanced'"
32
+ ref="searchFormAdvancedQuery"
33
+ style="padding-bottom: 10px"
34
+ :code="code"
35
+ :searchable-columns="advancedQueryColumns"
36
+ :search-form-list="searchFormList"
37
+ :prop-map="propMap"
38
+ :is-sql="isSql"
39
+ @resetForm="resetSearchFormList"
40
+ />
41
+ <div
42
+ v-if="searchType === 'advanced'"
43
+ style="padding-top: 10px; padding-bottom: 10px; text-align: center"
44
+ >
45
+ <el-button
46
+ :loading="loading"
47
+ type="primary"
48
+ size="mini"
49
+ @click="submitForm('searchForm')"
50
+ >
51
+ {{ $t('imatrixUIPublicModel.sure') }}
52
+ </el-button>
53
+ <el-button
54
+ :loading="loading"
55
+ size="mini"
56
+ @click="resetForm('searchForm')"
57
+ >
58
+ {{ $t('imatrixUIPublicModel.reset') }}
59
+ </el-button>
60
+ <el-button size="mini" @click="saveCondition">
61
+ {{ $t('superGrid.saveCondition') }}
62
+ </el-button>
63
+ <span
64
+ v-if="
65
+ advancedQuery !== null &&
66
+ advancedQuery !== undefined &&
67
+ advancedQuery === true &&
68
+ normalQuery !== null &&
69
+ normalQuery !== undefined &&
70
+ normalQuery === true
71
+ "
72
+ style="margin-left: 10px"
73
+ >
74
+ <el-button
75
+ v-if="searchType === 'advanced'"
76
+ size="mini"
77
+ @click="searchType = 'normal'"
78
+ >
79
+ {{ $t('imatrixUIPublicModel.switchToNormalQuery') }}
80
+ </el-button>
81
+ <el-button
82
+ v-if="searchType === 'normal'"
83
+ size="mini"
84
+ @click="searchType = 'advanced'"
85
+ >
86
+ {{ $t('imatrixUIPublicModel.switchToAdvancedQuery') }}
87
+ </el-button>
88
+ </span>
89
+ </div>
90
+ <search-condition-input
91
+ v-if="isShowSearchCondition"
92
+ @close="saveConditionValue"
93
+ />
94
+ </div>
95
+ </template>
96
+
97
+ <script>
98
+ import { $on, $off, $once, $emit } from '../../utils/gogocodeTransfer'
99
+ import searchMethods from './search-methods'
100
+ // import searchFormNumber from './search-form-number.vue'
101
+ import searchFormOrdinarySearch from './search-form-ordinarySearch.vue'
102
+ import searchFormAdvancedQuery from './search-form-advancedQuery'
103
+ import store from './store'
104
+ // import { isOptionFunction, getSearchObject } from './utils'
105
+ import { addDynamicProp, addDynamicPropDateSection } from './utils'
106
+ import * as Vue from 'vue'
107
+ import SearchConditionInput from './search-condition-input.vue'
108
+ import SearchConditionList from './search-condition-list.vue'
109
+ export default {
110
+ name: 'SearchForm',
111
+ components: {
112
+ // searchFormNumber,
113
+ SearchConditionInput,
114
+ SearchConditionList,
115
+ searchFormOrdinarySearch,
116
+ searchFormAdvancedQuery
117
+ },
118
+ provide() {
119
+ return {
120
+ getListToolbarFormData: () => ({
121
+ listToolbarFormData: this.listToolbarFormData,
122
+ }),
123
+ }
124
+ },
125
+ props: {
126
+ columns: {
127
+ type: Array,
128
+ default: null,
129
+ },
130
+ code: {
131
+ type: String,
132
+ default: null,
133
+ },
134
+ url: {
135
+ type: String,
136
+ default: null,
137
+ },
138
+ pagination: {
139
+ type: Object,
140
+ default: null,
141
+ },
142
+ query: {
143
+ type: Object,
144
+ default: null,
145
+ },
146
+ searchParam: {
147
+ type: Object,
148
+ default: null,
149
+ },
150
+ initSearchProps: {
151
+ type: Array,
152
+ default: null,
153
+ },
154
+ isSql: {
155
+ type: Boolean,
156
+ default: false,
157
+ },
158
+ searchFormInfo: {
159
+ type: Object,
160
+ default: () => {
161
+ return {}
162
+ },
163
+ },
164
+ loadCompleteQuery: {
165
+ type: Boolean,
166
+ default: false,
167
+ },
168
+ listToolbarFormData: {
169
+ type: Object,
170
+ default: null,
171
+ },
172
+ },
173
+ data() {
174
+ const customComponentNames = new Set()
175
+ const gridParams = store.get(this.code)
176
+ const propMap = {}
177
+ let searchForm = {}
178
+ if (this.searchParam !== null) {
179
+ searchForm = JSON.parse(JSON.stringify(this.searchParam))
180
+ }
181
+ const searchColumns = this.getSearchableColumns(null, null, propMap)
182
+ if (this.initSearchProps === undefined || this.initSearchProps === null) {
183
+ this.initSearchProps = []
184
+ }
185
+ console.log('searchForm=', searchColumns)
186
+ searchColumns.forEach((column) => {
187
+ // propMap[column.prop] = column
188
+ if (this.initSearchProps.indexOf(column.prop) < 0) {
189
+ // 表示没有默认初始查询字段
190
+ if (column.prop && column.prop.indexOf('.') > 0) {
191
+ if (column.componentType === 'dateSection') {
192
+ addDynamicPropDateSection(searchForm, column.prop)
193
+ } else {
194
+ // 动态给searchForm添加属性,包括多级嵌套属性,属性的初始值都为 null
195
+ addDynamicProp(searchForm, column.prop)
196
+ }
197
+ } else {
198
+ if (column.componentType === 'dateSection') {
199
+ searchForm[column.prop] = [new Date(), new Date()]
200
+ } else if (column.componentType === 'yearRange') {
201
+ searchForm[column.prop] = ['', '']
202
+ } else {
203
+ searchForm[column.prop] = null
204
+ }
205
+ this.setDefaultQueryValue(column, searchForm)
206
+ }
207
+ }
208
+ })
209
+ const spanNum = this.getSpanNum()
210
+ const fieldNum = this.getFieldNumPerRow()
211
+ const rowNum = Math.ceil(searchColumns.length / fieldNum)
212
+ console.log('rowNumrowNumrowNumrowNum', rowNum)
213
+ console.log(searchColumns)
214
+ console.log(fieldNum)
215
+ const advancedQuery = this.query.advancedQuery
216
+ const normalQuery = this.query.normalQuery
217
+ // console.log('searchColumns.length=' + searchColumns.length + ',fieldNum=' + fieldNum + ',rowNum=' + rowNum)
218
+ // // -2是把
219
+ // const dateSpanNum = (spanNum - 2) / 2
220
+
221
+ return {
222
+ searchForm,
223
+ rules: {},
224
+ searchParams: [],
225
+ labelWidth:
226
+ gridParams.options.search && gridParams.options.search.labelWidth
227
+ ? gridParams.options.search.labelWidth
228
+ : '80px',
229
+ customComponentNames: customComponentNames,
230
+ componentName: '',
231
+ spanNum: spanNum,
232
+ fieldNum: fieldNum, // 每行放的字段个数
233
+ rowNum: rowNum, // 一共有几行
234
+ loading: false, // 是否正在查询,默认时否
235
+ isShowSearchCondition: false,
236
+ searchConditions: [],
237
+ propMap,
238
+ advancedQuery,
239
+ normalQuery,
240
+ searchFormList: [],
241
+ searchType: null,
242
+ }
243
+ },
244
+ computed: {
245
+ searchableColumns() {
246
+ return this.getSearchableColumns()
247
+ },
248
+ advancedQueryColumns() {
249
+ return this.getAdvancedQueryColumns()
250
+ },
251
+ },
252
+ watch: {
253
+ searchForm: {
254
+ deep: true,
255
+ handler(val) {
256
+ this.searchFormInfo['data'] = val
257
+ },
258
+ },
259
+ },
260
+ created() {
261
+ this.listSearchConditions()
262
+ if (this.normalQuery) {
263
+ this.searchType = 'normal'
264
+ } else if (this.advancedQuery) {
265
+ this.searchType = 'advanced'
266
+ }
267
+ },
268
+ methods: {
269
+ ...searchMethods,
270
+ // 每行放的字段个数
271
+ getFieldNumPerRow() {
272
+ const gridParams = store.get(this.code)
273
+ return gridParams.options.search && gridParams.options.search.fieldNum
274
+ ? gridParams.options.search.fieldNum
275
+ : 3
276
+ },
277
+ // 根据每行显示的字段个数,确定栅栏个数,默认是4个字段。最多就只能放6个字段
278
+ getSpanNum() {
279
+ const fieldNum = this.getFieldNumPerRow()
280
+ if (fieldNum === 1) {
281
+ return 22
282
+ } else if (fieldNum === 2) {
283
+ return 10
284
+ } else if (fieldNum === 3) {
285
+ return 8
286
+ } else if (fieldNum === 4) {
287
+ return 6
288
+ } else {
289
+ // 6个字段
290
+ return 4
291
+ }
292
+ },
293
+ setValueToModelProp(prop, value, componentName, index) {
294
+ if (prop && prop.indexOf('.') > 0) {
295
+ const parentOjbect = this.getParentObject(prop)
296
+ // 嵌套属性中的最后一个属性是属于这个中间父对象的,所有要通过中间父对象来赋值
297
+ if (index != null && index !== undefined) {
298
+ // parentOjbect[prop.substring(prop.lastIndexOf('.') + 1)][index] = value
299
+ parentOjbect[prop.substring(prop.lastIndexOf('.') + 1)][index] = value
300
+ } else {
301
+ parentOjbect[prop.substring(prop.lastIndexOf('.') + 1)] = value
302
+ }
303
+ } else {
304
+ if (index != null && index !== undefined) {
305
+ this.searchForm[prop][index] = value
306
+ } else {
307
+ this.searchForm[prop] = value
308
+ }
309
+ }
310
+ },
311
+ getAdvancedQueryColumns(columns, searchColumns, propMap) {
312
+ if (!this.customComponentNames) {
313
+ this.customComponentNames = new Set()
314
+ }
315
+ if (!searchColumns) {
316
+ searchColumns = []
317
+ }
318
+ if (!columns) {
319
+ columns = this.columns
320
+ }
321
+ for (let i = 0; i < columns.length; i++) {
322
+ const column = columns[i]
323
+ if (propMap) {
324
+ propMap[column.prop] = column
325
+ }
326
+ if (
327
+ column.prop === '$index' ||
328
+ column.prop === '$selection' ||
329
+ column.dynamic
330
+ ) {
331
+ // 序号和复选框列、动态列 不属于该组件的查询字段
332
+ continue
333
+ }
334
+ if (column.groupHeader) {
335
+ // 组合表头中子表头的字段查询
336
+ this.getSearchableColumns(column.children, searchColumns, propMap)
337
+ } else {
338
+ if (
339
+ column.queryType === 'advanced' &&
340
+ !column.custom &&
341
+ column.prop !== ''
342
+ ) {
343
+ // 表示是普通查询,且不是占位符列,是查询字段
344
+ if (
345
+ typeof column.componentType === 'undefined' ||
346
+ column.componentType === ''
347
+ ) {
348
+ column.componentType = 'input'
349
+ }
350
+ if (column.querySetting && column.querySetting !== '') {
351
+ const querySetting = JSON.parse(column.querySetting)
352
+ if (querySetting.width) {
353
+ column.searchControlWidth = 'width:' + querySetting.width + 'px'
354
+ }
355
+ if (querySetting.labelWidth) {
356
+ column.searchLabelWidth = querySetting.labelWidth + 'px'
357
+ }
358
+ if (querySetting.label) {
359
+ column.searchLabel = querySetting.label
360
+ }
361
+ }
362
+ // 行编辑时自定义编辑组件
363
+ if (
364
+ column.componentType &&
365
+ column.componentType.indexOf('custom:') >= 0
366
+ ) {
367
+ column.componentName = column.componentType.substring(
368
+ column.componentType.indexOf(':') + 1
369
+ )
370
+ this.customComponentNames.add(column.componentName)
371
+ } else {
372
+ column.componentName = ''
373
+ }
374
+ // this.$set(this.propMap, column.prop, column)
375
+ // this.propMap[column.prop] = column
376
+ searchColumns.push(column)
377
+ }
378
+ }
379
+ }
380
+ return searchColumns
381
+ },
382
+ getSearchableColumns(columns, searchColumns, propMap) {
383
+ if (!this.customComponentNames) {
384
+ this.customComponentNames = new Set()
385
+ }
386
+ if (!searchColumns) {
387
+ searchColumns = []
388
+ }
389
+ if (!columns) {
390
+ columns = this.columns
391
+ }
392
+ for (let i = 0; i < columns.length; i++) {
393
+ const column = columns[i]
394
+ if (propMap) {
395
+ propMap[column.prop] = column
396
+ }
397
+ if (
398
+ column.prop === '$index' ||
399
+ column.prop === '$selection' ||
400
+ column.dynamic
401
+ ) {
402
+ // 序号和复选框列、动态列 不属于该组件的查询字段
403
+ continue
404
+ }
405
+ if (column.groupHeader) {
406
+ // 组合表头中子表头的字段查询
407
+ this.getSearchableColumns(column.children, searchColumns, propMap)
408
+ } else {
409
+ if (
410
+ column.queryType === 'normal' &&
411
+ !column.custom &&
412
+ column.prop !== ''
413
+ ) {
414
+ // 表示是普通查询,且不是占位符列,是查询字段
415
+ if (
416
+ typeof column.componentType === 'undefined' ||
417
+ column.componentType === ''
418
+ ) {
419
+ column.componentType = 'input'
420
+ }
421
+ if (column.querySetting && column.querySetting !== '') {
422
+ const querySetting = JSON.parse(column.querySetting)
423
+ if (querySetting.width) {
424
+ column.searchControlWidth = 'width:' + querySetting.width + 'px'
425
+ }
426
+ if (querySetting.labelWidth) {
427
+ column.searchLabelWidth = querySetting.labelWidth + 'px'
428
+ }
429
+ if (querySetting.label) {
430
+ column.searchLabel = querySetting.label
431
+ }
432
+ }
433
+ // 行编辑时自定义编辑组件
434
+ if (
435
+ column.componentType &&
436
+ column.componentType.indexOf('custom:') >= 0
437
+ ) {
438
+ column.componentName = column.componentType.substring(
439
+ column.componentType.indexOf(':') + 1
440
+ )
441
+ this.customComponentNames.add(column.componentName)
442
+ } else {
443
+ column.componentName = ''
444
+ }
445
+ // this.$set(this.propMap, column.prop, column)
446
+ // this.propMap[column.prop] = column
447
+ searchColumns.push(column)
448
+ }
449
+ }
450
+ }
451
+ return searchColumns
452
+ },
453
+ customComponent(column) {
454
+ const gridParams = store.get(this.code)
455
+ if (column.componentName && column.componentName !== '') {
456
+ this.customComponentNames.add(column.componentName)
457
+ return true
458
+ }
459
+ if (
460
+ (!column.componentName || column.componentName === '') &&
461
+ gridParams.options &&
462
+ gridParams.options.search &&
463
+ gridParams.options.search.customSearchElements
464
+ ) {
465
+ // 定义了自定义查询组件
466
+ const propSearchEle =
467
+ gridParams.options.search.customSearchElements[column.prop]
468
+ // console.log('customComponent-customSearchElements-propSearchEle-', column.prop)
469
+ if (propSearchEle) {
470
+ column.componentName = 'custom-' + column.prop
471
+ const component = propSearchEle.call(this, column)
472
+ // console.log('customComponent-customSearchElements-')
473
+ if (component) {
474
+ this.customComponentNames.add(column.componentName)
475
+ window.$vueApp.component(column.componentName, component)
476
+ return true
477
+ }
478
+ }
479
+ }
480
+ return false
481
+ },
482
+ submitForm() {
483
+ if (this.searchType === 'normal') {
484
+ this.$refs.searchFormOrdinarySearch.validateForm().then((valid) => {
485
+ if (valid) {
486
+ // this.loading = true
487
+ this.searchParams = this.packageSearchParam()
488
+ $emit(this, 'search', this.searchParams)
489
+ } else {
490
+ return false
491
+ }
492
+ })
493
+ } else if (this.searchType === 'advanced') {
494
+ this.$refs.searchFormAdvancedQuery.validateForm().then((valid) => {
495
+ if (valid) {
496
+ this.loading = true
497
+ this.searchParams = this.packageSearchParam()
498
+ $emit(this, 'search', this.searchParams)
499
+ } else {
500
+ return false
501
+ }
502
+ })
503
+ }
504
+ },
505
+ resetForm() {
506
+ if (this.$refs.searchConditionList) {
507
+ this.$refs.searchConditionList.editConditionId = null
508
+ }
509
+ if (this.searchType === 'normal') {
510
+ this.$refs.searchFormOrdinarySearch.resetForm()
511
+ } else if (this.searchType === 'advanced') {
512
+ this.$refs.searchFormAdvancedQuery.resetForm()
513
+ $emit(this, 'reset')
514
+ }
515
+ // 子组件重置完成后调用reset方法 同步执行
516
+ // this.$emit('reset')
517
+ },
518
+ setNumberValue(value, r, n) {
519
+ let itemValue = this.getFormItemValue(
520
+ this.searchableColumns[this.fieldNum * (r - 1) + (n - 1)].prop
521
+ )
522
+ itemValue = value
523
+ this.setValueToModelProp(
524
+ this.searchableColumns[this.fieldNum * (r - 1) + (n - 1)].prop,
525
+ itemValue
526
+ )
527
+ },
528
+ listSearchConditions() {
529
+ return new Promise((resolve, reject) => {
530
+ this.listSearchCondition(this.code)
531
+ .then((conditions) => {
532
+ this.searchConditions = conditions
533
+ resolve(conditions)
534
+ })
535
+ .catch((error) => {
536
+ reject(error)
537
+ })
538
+ })
539
+ },
540
+ saveCondition() {
541
+ const searchParams = this.packageSearchParam()
542
+ if (!searchParams || searchParams.length === 0) {
543
+ this.$message({
544
+ type: 'warning',
545
+ message: this.$t('imatrixUIMessage.pleaseInputSearchCondition'),
546
+ showClose: true,
547
+ })
548
+ return
549
+ }
550
+ this.isShowSearchCondition = true
551
+ },
552
+ saveConditionValue(conditionName) {
553
+ if (conditionName) {
554
+ let searchParams
555
+ if (
556
+ this.searchType === 'normal' ||
557
+ this.searchType === '' ||
558
+ this.searchType === null ||
559
+ this.searchType === undefined
560
+ ) {
561
+ searchParams = this.packageSearchParam()
562
+ } else {
563
+ searchParams = this.searchFormList
564
+ }
565
+ const condition = {
566
+ listCode: this.code,
567
+ queryType:
568
+ this.searchType === 'normal' ||
569
+ this.searchType === '' ||
570
+ this.searchType === null ||
571
+ this.searchType === undefined
572
+ ? 'FIXED'
573
+ : 'CUSTOM',
574
+ name: conditionName,
575
+ queryCondition: JSON.stringify(searchParams),
576
+ }
577
+ this.saveSearchCondition(condition).then((condition) => {
578
+ this.$message({
579
+ type: 'success',
580
+ message: this.$t('imatrixUIMessage.saveSuccessfully'),
581
+ showClose: true,
582
+ })
583
+ this.isShowSearchCondition = false
584
+ this.listSearchConditions().then(() => {
585
+ if (this.$refs.searchConditionList) {
586
+ // 选中刚刚保存的条件
587
+ this.$refs.searchConditionList.editConditionId = condition.id + ''
588
+ }
589
+ // 查询条件对应的数据
590
+ this.selectCondition(condition.id)
591
+ })
592
+ })
593
+ }
594
+ this.isShowSearchCondition = false
595
+ },
596
+ removeCondition(conditionId) {
597
+ if (conditionId) {
598
+ this.$confirm(
599
+ this.$t('imatrixUIMessage.whetherToConfirmDeletion'),
600
+ this.$t('imatrixUIMessage.tips'),
601
+ {
602
+ confirmButtonText: this.$t('imatrixUIPublicModel.sure'),
603
+ cancelButtonText: this.$t('imatrixUIPublicModel.cancel'),
604
+ type: 'warning',
605
+ }
606
+ ).then(() => {
607
+ this.removeSearchCondition(conditionId).then(() => {
608
+ this.$message({
609
+ type: 'success',
610
+ message: this.$t('superGrid.deleteSuccessful'),
611
+ showClose: true,
612
+ })
613
+ this.listSearchConditions()
614
+ })
615
+ })
616
+ }
617
+ },
618
+ selectCondition(conditionId) {
619
+ if (conditionId) {
620
+ this.getSearchCondition(conditionId).then((searchCondition) => {
621
+ if (searchCondition) {
622
+ const queryCondition = searchCondition.queryCondition
623
+ if (queryCondition) {
624
+ if (
625
+ this.searchType === 'normal' ||
626
+ this.searchType === '' ||
627
+ this.searchType === null ||
628
+ this.searchType === undefined
629
+ ) {
630
+ const searchParams = JSON.parse(queryCondition)
631
+ const searchForm = this.packageSearchForm(searchParams)
632
+ if (searchForm) {
633
+ this.searchForm = searchForm
634
+ }
635
+ // 查询数据
636
+ this.loading = true
637
+ $emit(this, 'search', searchParams)
638
+ } else {
639
+ this.searchFormList = JSON.parse(queryCondition)
640
+ // 查询数据
641
+ this.loading = true
642
+ $emit(this, 'search', this.packageSearchParam())
643
+ }
644
+ }
645
+ }
646
+ })
647
+ }
648
+ },
649
+ // 封装searchForm
650
+ packageSearchForm(searchFormArr) {
651
+ if (searchFormArr && searchFormArr.length > 0) {
652
+ const searchForm = {}
653
+ const initSearchProps = []
654
+ searchFormArr.forEach((item) => {
655
+ // 获得的是"isDeleted"
656
+ let prop = item.propName
657
+ // 获得的是“deleted”
658
+ const columnProp = item.columnProp
659
+ const dataType = item.dataType
660
+ if (dataType && dataType === 'BOOLEAN' && columnProp) {
661
+ prop = columnProp
662
+ }
663
+ if (initSearchProps.indexOf(prop) === -1) {
664
+ initSearchProps.push(prop)
665
+ }
666
+ const propValue = item.propValue
667
+ if (prop && prop.indexOf('.') > 0) {
668
+ // 动态给searchForm添加属性,包括多级嵌套属性,属性的初始值都为 null
669
+ addDynamicProp(searchForm, prop, propValue)
670
+ } else {
671
+ let isRangeQueryValue = false
672
+ if (dataType && (dataType === 'DATE' || dataType === 'TIME')) {
673
+ if (item.startValue && item.endValue) {
674
+ isRangeQueryValue = true
675
+ }
676
+ }
677
+ if (isRangeQueryValue) {
678
+ searchForm[prop] = [
679
+ new Date(item.startValue),
680
+ new Date(item.endValue),
681
+ ]
682
+ } else {
683
+ if (searchForm[prop]) {
684
+ if (searchForm[prop] instanceof Array) {
685
+ searchForm[prop].push(propValue)
686
+ } else {
687
+ searchForm[prop] = [searchForm[prop], propValue]
688
+ }
689
+ } else {
690
+ searchForm[prop] = propValue
691
+ }
692
+ }
693
+ }
694
+ })
695
+
696
+ this.searchableColumns.forEach((column) => {
697
+ if (initSearchProps) {
698
+ if (initSearchProps.indexOf(column.prop) < 0) {
699
+ // 表示没有默认初始查询字段
700
+ if (column.prop && column.prop.indexOf('.') > 0) {
701
+ if (column.componentType === 'dateSection') {
702
+ addDynamicPropDateSection(searchForm, column.prop)
703
+ } else {
704
+ // 动态给searchForm添加属性,包括多级嵌套属性,属性的初始值都为 null
705
+ addDynamicProp(searchForm, column.prop)
706
+ }
707
+ } else {
708
+ if (column.componentType === 'dateSection') {
709
+ searchForm[column.prop] = [new Date(), new Date()]
710
+ } else {
711
+ searchForm[column.prop] = null
712
+ }
713
+ }
714
+ } else {
715
+ if (
716
+ column.componentType === 'multiselect' &&
717
+ searchForm[column.prop]
718
+ ) {
719
+ if (!(searchForm[column.prop] instanceof Array)) {
720
+ searchForm[column.prop] = [searchForm[column.prop]]
721
+ }
722
+ }
723
+ }
724
+ }
725
+ })
726
+
727
+ return searchForm
728
+ }
729
+ },
730
+ resetSearchFormList() {
731
+ this.searchFormList = null
732
+ },
733
+ openFold(isOpen) {
734
+ $emit(this, 'open-fold', isOpen)
735
+ },
736
+ // 查询完毕
737
+ searchComplete() {
738
+ if (this.$refs.searchFormOrdinarySearch) {
739
+ this.$refs.searchFormOrdinarySearch.searchComplete()
740
+ }
741
+ },
742
+ },
743
+ emits: ['search', 'open-fold', 'reset'],
744
+ }
745
+ </script>
746
+
747
+ <style scoped>
748
+ .grid-search-form {
749
+ overflow: auto;
750
+ }
751
+ .grid-search-form :deep(.el-form-item) {
752
+ margin-bottom: 0px;
753
+ }
754
+ .grid-search-form :deep(.search-btn) {
755
+ margin-bottom: 5px;
756
+ text-align: center;
757
+ }
758
+ .grid-search-form :deep(.el-select),
759
+ .grid-search-form :deep(.customComponent) {
760
+ width: 100%;
761
+ }
762
+ </style>