agilebuilder-ui 1.1.40 → 1.1.41-rc1

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.
@@ -1,601 +1,513 @@
1
1
  const searchMethods = {
2
- packageSearchParam() {
3
- if (
4
- this.searchType === 'normal' ||
5
- !this.searchType ||
6
- this.searchType === null ||
7
- this.searchType === undefined ||
8
- this.searchType === ''
9
- ) {
10
- const searchParams = []
11
- this.searchableColumns.forEach((column) => {
12
- const param = {leftBracket: '', rightBracket: '', joinSign: 'and'}
13
- // 布尔型字段时prop中去掉了is字符,查询时返回带有is的属性字段,
14
- // 否则会导致查询布尔型报500错误
15
- let orgProp = column.orgProp
16
- // sql查询时,会把点“.”改为两个下划线"__"
17
- const replaceDot = '__'
18
- if (orgProp && orgProp.indexOf(replaceDot) > 0) {
19
- // 表示包括点“.”,需要把两个下划线"__"重新改为点“.”,否则会导致查询报500错误
20
- orgProp = orgProp.replace(replaceDot, '.')
21
- }
22
- param.propName = orgProp
23
- param.enumName = column.enumName
24
- param.operator = this.getOperator(column)
25
- param.dataType = column.dataType
26
- param.matchingType = column.queryMatching
27
- param.formatter = column.formatter
28
- ? JSON.parse(JSON.stringify(column.formatter))
29
- : column.formatter
30
- param.isEmptyValue= column._emptyValue && column._emptyValue === '#blank#'?true:false
31
- const values = this.getFormItemValue(column.prop)
32
- if (column.dataType === 'DATE' || column.dataType === 'TIME') {
33
- // 日期 或 时间类型
34
- // console.log('values==', values, column.prop)
35
- if (
36
- values&&
37
- values.length === 2 &&
38
- values[0] !== null &&
39
- values[1] !== null
40
- ) {
41
- const format = this.getDateTimeSearchFormatter(
42
- column,
43
- column.dataType,
44
- column.formatter
45
- )
46
- if (format) {
47
- if (!param.formatter) {
48
- param.formatter = {}
49
- param.formatter.options = {}
50
- } else if (!param.formatter.options) {
51
- param.formatter.options = {}
52
- }
53
- param.formatter.options.format = format
54
- }
55
- param.startValue = this.getDateTimeMillsByDateStr(values[0], format)
56
- param.endValue = this.getDateTimeMillsByDateStr(values[1], format)
57
- searchParams.push(param)
58
- }
59
- } else if (
60
- (column.dataType === 'INTEGER' ||
61
- column.dataType === 'LONG' ||
62
- column.dataType === 'DOUBLE') &&
63
- Array.isArray(values)
64
- ) {
65
- // 日期 或 时间类型
66
- // const values1 = this.getFormItemValue(column.prop)
67
- if (values) {
68
- if (column.componentType === 'yearRange') {
69
- if (values[0] || values[1]) {
70
- param.startValue = values[0]
71
- param.endValue = values[1]
72
- if (values[0] && !values[1]) {
73
- param.startValue = values[0]
74
- param.endValue = 9999
75
- } else if (!values[0] && values[1]) {
76
- param.startValue = 0
77
- param.endValue = values[1]
78
- }
79
- searchParams.push(param)
80
- }
81
- } else {
82
- if (
83
- !Array.isArray(values) ||
84
- values.length < 2 ||
85
- (values[0] === null && values[1] === null)
86
- ) {
87
- // 填写了一个有效值
88
- if (!Array.isArray(values)) {
89
- param.propValue = values
90
- searchParams.push(param)
91
- } else if (values.length < 2) {
92
- param.propValue = values[0]
93
- searchParams.push(param)
94
- } else if (values[0] === null) {
95
- param.propValue = values[1]
96
- searchParams.push(param)
97
- } else if (values[1] === null) {
98
- param.propValue = values[0]
99
- searchParams.push(param)
100
- }
101
- } else {
102
- // 填写了两个有效值
103
-
104
- param.startValue = values[0]
105
- param.endValue = values[1]
106
- searchParams.push(param)
107
- }
108
- }
109
- }
110
- } else if (
111
- column.componentType &&
112
- column.componentType.indexOf('Tree') !== -1 &&
113
- column.componentType.indexOf('single') === -1
114
- ) {
115
- // 说明是多选组织树
116
- // 是否是人员树
117
- const isUser = this.isUserTree(column.componentType)
118
- const values = this.getFormItemValue(column.prop)
119
- if (values && values !== '') {
120
- const newValue = []
121
- let valueArr = values
122
- if (Array.isArray(values)) {
123
- // 表示是数组
124
- valueArr = values
125
- } else {
126
- // 表示是字符串
127
- valueArr = values.split(',')
128
- }
129
- if (Array.isArray(valueArr) && valueArr && valueArr.length > 0) {
130
- valueArr.forEach((val) => {
131
- // 截取用户名中的英文名信息
132
- const userName = this.getUserName(isUser, val)
133
- if (userName !== undefined && userName !== null) {
134
- newValue.push(userName)
135
- }
136
- })
137
- }
138
- this.packageValueWithArray(newValue, searchParams, param)
139
- }
140
- } else if (
141
- column.componentType &&
142
- column.componentType.indexOf('Tree') !== -1
143
- ) {
144
- // 说明是单选组织树
145
- // 是否是人员树
146
- const isUser = this.isUserTree(column.componentType)
147
- let propValue = this.getFormItemValue(column.prop)
148
- // 截取用户名中的英文名信息
149
- propValue = this.getUserName(isUser, propValue)
150
- this.packageValueWithArray(propValue, searchParams, param)
151
- } else {
152
- if (column.componentType === 'multiselect') {
153
- // 表示是多选下拉框选择器选择的值
154
- const values = this.getFormItemValue(column.prop)
155
- // console.log('values==', values, column.prop)
156
- this.packageValueWithArray(values, searchParams, param)
157
- } else {
158
- const propValue = this.getFormItemValue(column.prop)
159
- this.packageValueWithArray(propValue, searchParams, param)
160
- }
161
- }
162
- })
163
- return searchParams
164
- } else {
165
- const newSearchFormList = []
166
- this.searchFormList.forEach((param) => {
167
- let newParam = {}
168
- newParam = param
169
- // const param = { leftBracket: '', rightBracket: '', joinSign: 'and' }
170
- // 布尔型字段时prop中去掉了is字符,查询时返回带有is的属性字段,
171
- // 否则会导致查询布尔型报500错误
172
- let orgProp = newParam.orgProp
173
- // sql查询时,会把点“.”改为两个下划线"__"
174
- const replaceDot = '__'
175
- if (orgProp && orgProp.indexOf(replaceDot) > 0) {
176
- // 表示包括点“.”,需要把两个下划线"__"重新改为点“.”,否则会导致查询报500错误
177
- orgProp = orgProp.replace(replaceDot, '.')
178
- }
179
- newParam.propName = orgProp
180
- newParam.operator = this.getOperator(param)
181
- newParam.matchingType = param.queryMatching
182
- if (newParam.dataType === 'DATE' || newParam.dataType === 'TIME') {
183
- // 日期 或 时间类型
184
- const values = newParam.value
185
- // console.log('values==', values, column.prop)
186
- if (
187
- values !== null &&
188
- values.length === 2 &&
189
- values[0] !== null &&
190
- values[1] !== null
191
- ) {
192
- newParam.startValue = values[0]
193
- newParam.endValue = values[1]
194
- }
195
- } else if (
196
- newParam.dataType === 'INTEGER' ||
197
- newParam.dataType === 'LONG'
198
- ) {
199
- const values1 = newParam.value
200
- if (values1) {
201
- if (
202
- !Array.isArray(values1) ||
203
- values1.length < 2 ||
204
- (values1[0] === null && values1[1] === null)
205
- ) {
206
- // 填写了一个有效值
207
- if (!Array.isArray(values1)) {
208
- newParam.propValue = values1
209
- } else if (values1.length < 2) {
210
- newParam.propValue = values1[0]
211
- } else if (values1[0] === null) {
212
- newParam.propValue = values1[1]
213
- } else if (values1[1] === null) {
214
- newParam.propValue = values1[0]
215
- }
216
- } else {
217
- // 填写了两个有效值
218
- newParam.startValue = values1[0]
219
- newParam.endValue = values1[1]
220
- }
221
- }
222
- } else if (
223
- newParam.componentType &&
224
- newParam.componentType.indexOf('Tree') !== -1 &&
225
- newParam.componentType.indexOf('single') === -1
226
- ) {
227
- // 树多选,先手动分割数组,在生成多条
228
- // 是否是人员树
229
- const isUser = this.isUserTree(newParam.componentType)
230
- const values = newParam.value
231
- if (values && values !== '') {
232
- const newValue = []
233
- let valueArr = values
234
- if (Array.isArray(values)) {
235
- valueArr = values
236
- } else {
237
- valueArr = values.split(',')
238
- }
239
- if (Array.isArray(valueArr) && valueArr && valueArr.length > 0) {
240
- valueArr.forEach((val) => {
241
- // 截取用户名中的英文名信息
242
- const userName = this.getUserName(isUser, val)
243
- if (userName !== undefined && userName !== null) {
244
- newValue.push(userName)
245
- }
246
- })
247
- }
248
- this.packageValueWithArray(newValue, newSearchFormList, param)
249
- }
250
- } else if (
251
- newParam.componentType &&
252
- newParam.componentType.indexOf('Tree') !== -1
253
- ) {
254
- // 说明是单选组织树
255
- // 是否是人员树
256
- const isUser = this.isUserTree(newParam.componentType)
257
- let propValue = newParam.value
258
- // 截取用户名中的英文名信息
259
- propValue = this.getUserName(isUser, propValue)
260
- this.packageValueWithArray(propValue, newSearchFormList, param)
261
- } else {
262
- if (newParam.componentType === 'multiselect') {
263
- // 表示是多选下拉框选择器选择的值
264
- const values = newParam.value
265
- // console.log('values==', values, column.prop)
266
- this.packageValueWithArray(values, newSearchFormList, param)
267
- } else {
268
- const values = newParam.value
269
- this.packageValueWithArray(values, newSearchFormList, param)
270
- }
271
- }
272
- })
273
- return newSearchFormList
274
- }
275
- },
276
- // 获得日期、时间查询格式配置,影响后台查询结果
277
- getDateTimeSearchFormatter(column, dataType, formatter) {
278
- const dateTimeFormat = 'yyyy-MM-dd HH:mm:ss'
279
- const dateFormat = 'yyyy-m-d'
280
- let format
281
- if (column.componentType === 'dateSection') {
282
- // 日期区间
283
- format = dateFormat
284
- } else if (column.componentType === 'dateTimePicker') {
285
- // 日期时间选择器
286
- format = dateTimeFormat
287
- } else if (column.dataType === 'DATE' || column.componentType === 'date') {
288
- // 日期选择器
289
- format = dateFormat
290
- }
291
- if (!format) {
292
- if (formatter) {
293
- const formatOptions = formatter.options
294
- if (formatOptions && formatOptions != null) {
295
- format = formatOptions.format
296
- }
297
- }
298
- }
299
-
300
- if (!format) {
301
- if (dataType === 'DATE') {
302
- format = 'yyyy-m-d'
303
- } else if (dataType === 'TIME') {
304
- format = 'yyyy-m-d hh:mm:ss'
305
- }
2
+ packageSearchParam() {
3
+ if (
4
+ this.searchType === 'normal' ||
5
+ !this.searchType ||
6
+ this.searchType === null ||
7
+ this.searchType === undefined ||
8
+ this.searchType === ''
9
+ ) {
10
+ const searchParams = []
11
+ this.searchableColumns.forEach((column) => {
12
+ const param = { leftBracket: '', rightBracket: '', joinSign: 'and' }
13
+ // 布尔型字段时prop中去掉了is字符,查询时返回带有is的属性字段,
14
+ // 否则会导致查询布尔型报500错误
15
+ let orgProp = column.orgProp
16
+ // sql查询时,会把点“.”改为两个下划线"__"
17
+ const replaceDot = '__'
18
+ if (orgProp && orgProp.indexOf(replaceDot) > 0) {
19
+ // 表示包括点“.”,需要把两个下划线"__"重新改为点“.”,否则会导致查询报500错误
20
+ orgProp = orgProp.replace(replaceDot, '.')
306
21
  }
307
- return format
308
- },
309
- // 根据日期字符串获得日期毫秒值
310
- getDateTimeMillsByDateStr(dateStr, format) {
311
- if (typeof dateStr === 'string' && format) {
312
- if (dateStr.indexOf('T') !== -1) {
313
- return new Date(dateStr).getTime()
22
+ param.propName = orgProp
23
+ param.enumName = column.enumName
24
+ param.operator = this.getOperator(column)
25
+ param.dataType = column.dataType
26
+ param.matchingType = column.queryMatching
27
+ param.formatter = column.formatter ? JSON.parse(JSON.stringify(column.formatter)) : column.formatter
28
+ param.isEmptyValue = column._emptyValue && column._emptyValue === '#blank#' ? true : false
29
+ const values = this.getFormItemValue(column.prop)
30
+ if (column.dataType === 'DATE' || column.dataType === 'TIME') {
31
+ // 日期 或 时间类型
32
+ // console.log('values==', values, column.prop)
33
+ if (values && values.length === 2 && values[0] !== null && values[1] !== null) {
34
+ const format = this.getDateTimeSearchFormatter(column, column.dataType, column.formatter)
35
+ if (format) {
36
+ if (!param.formatter) {
37
+ param.formatter = {}
38
+ param.formatter.options = {}
39
+ } else if (!param.formatter.options) {
40
+ param.formatter.options = {}
41
+ }
42
+ param.formatter.options.format = format
314
43
  }
315
- // 表示是格式化后的值,转成date毫秒值传给后台,解决时区问题
316
- format = format.toLowerCase()
317
- if (
318
- format.indexOf('h') > 0 &&
319
- format.indexOf('m') > 0 &&
320
- format.indexOf('s') > 0
321
- ) {
322
- // 表示有时分秒
323
- dateStr = new Date(dateStr).getTime()
324
- } else {
325
- // 表示精确到日
326
- dateStr = new Date(dateStr + ' 00:00:00').getTime()
327
- }
328
- }
329
- return dateStr
330
- },
331
- // 是否是人员树
332
- isUserTree(componentType) {
333
- if (
334
- componentType.indexOf('DeptManTree') > 0 ||
335
- componentType.indexOf('WgManTree') > 0
336
- ) {
337
- return true
338
- }
339
- return false
340
- },
341
- // 获得用户名
342
- getUserName(isUser, val) {
343
- if (
344
- isUser &&
345
- val !== undefined &&
346
- val !== null &&
347
- val.indexOf('(') > 0 &&
348
- val.indexOf(')') > 0
349
- ) {
350
- // 说明是人员树,如果是值中包括英文名,把英文名截取掉,因为有些字段保存的有英文名,有些没有英文名,为了便于查询,所以统一将英文名去掉。
351
- // 例如:张三(Andy),处理后是:张三
352
- val = val.substring(0, val.indexOf('('))
353
- }
354
- return val
355
- },
356
- getOperator(column) {
357
- if (
358
- (column.dataType === 'TEXT' || column.dataType === 'CLOB') &&
359
- column.fuzzy &&
360
- (!column.componentType ||
361
- (column.componentType &&
362
- ((column.componentType !== 'select' &&
363
- column.componentType !== 'multiselect') ||
364
- (column.componentType === 'multiselect' &&
365
- column.ifMultiData !== undefined &&
366
- column.ifMultiData === true))))
44
+ param.startValue = this.getDateTimeMillsByDateStr(values[0], format)
45
+ param.endValue = this.getDateTimeMillsByDateStr(values[1], format)
46
+ searchParams.push(param)
47
+ }
48
+ } else if (
49
+ (column.dataType === 'INTEGER' || column.dataType === 'LONG' || column.dataType === 'DOUBLE') &&
50
+ Array.isArray(values)
367
51
  ) {
368
- // 是否是文本类型的字段,且启用了模糊查询,则表示操作符为contains模糊查询
369
- return 'CONTAIN'
370
- } else if (Array.isArray(this.getFormItemValue(column.prop))) {
371
- if (
372
- column.dataType === 'INTEGER' ||
373
- column.dataType === 'LONG' ||
374
- column.dataType === 'DOUBLE'
375
- ) {
376
- return 'BETWEEN'
52
+ // 日期 或 时间类型
53
+ // const values1 = this.getFormItemValue(column.prop)
54
+ if (values) {
55
+ if (column.componentType === 'yearRange') {
56
+ if (values[0] || values[1]) {
57
+ param.startValue = values[0]
58
+ param.endValue = values[1]
59
+ if (values[0] && !values[1]) {
60
+ param.startValue = values[0]
61
+ param.endValue = 9999
62
+ } else if (!values[0] && values[1]) {
63
+ param.startValue = 0
64
+ param.endValue = values[1]
65
+ }
66
+ searchParams.push(param)
67
+ }
377
68
  } else {
378
- return 'EQ'
69
+ if (!Array.isArray(values) || values.length < 2 || (values[0] === null && values[1] === null)) {
70
+ // 填写了一个有效值
71
+ if (!Array.isArray(values)) {
72
+ param.propValue = values
73
+ searchParams.push(param)
74
+ } else if (values.length < 2) {
75
+ param.propValue = values[0]
76
+ searchParams.push(param)
77
+ } else if (values[0] === null) {
78
+ param.propValue = values[1]
79
+ searchParams.push(param)
80
+ } else if (values[1] === null) {
81
+ param.propValue = values[0]
82
+ searchParams.push(param)
83
+ }
84
+ } else {
85
+ // 填写了两个有效值
86
+
87
+ param.startValue = values[0]
88
+ param.endValue = values[1]
89
+ searchParams.push(param)
90
+ }
379
91
  }
380
- } else {
381
- // 否则就是等于
382
- return 'EQ'
383
- }
384
- },
385
- getFormItemValue(prop, index) {
386
- if (prop.indexOf('.') > 0) {
387
- const parentOjbect = this.getParentObject(prop)
388
- if (index != null && index !== undefined) {
389
- return parentOjbect[prop.substring(prop.lastIndexOf('.') + 1)][index]
92
+ }
93
+ } else if (
94
+ column.componentType &&
95
+ column.componentType.indexOf('Tree') !== -1 &&
96
+ column.componentType.indexOf('single') === -1
97
+ ) {
98
+ // 说明是多选组织树
99
+ // 是否是人员树
100
+ const isUser = this.isUserTree(column.componentType)
101
+ const values = this.getFormItemValue(column.prop)
102
+ if (values && values !== '') {
103
+ const newValue = []
104
+ let valueArr = values
105
+ if (Array.isArray(values)) {
106
+ // 表示是数组
107
+ valueArr = values
390
108
  } else {
391
- return parentOjbect[prop.substring(prop.lastIndexOf('.') + 1)]
109
+ // 表示是字符串
110
+ valueArr = values.split(',')
392
111
  }
393
- } else {
394
- if (index != null && index !== undefined) {
395
- return this.searchForm[prop][index]
396
- } else {
397
- return this.searchForm[prop]
112
+ if (Array.isArray(valueArr) && valueArr && valueArr.length > 0) {
113
+ valueArr.forEach((val) => {
114
+ // 截取用户名中的英文名信息
115
+ const userName = this.getUserName(isUser, val)
116
+ if (userName !== undefined && userName !== null) {
117
+ newValue.push(userName)
118
+ }
119
+ })
398
120
  }
399
- }
400
- },
401
- getParentObject(prop) {
402
- const nestedProp = prop.split('.')
403
- // 属性只有一个时父对象就是searchForm
404
- if (nestedProp.length === 1) {
405
- return this.searchForm
121
+ this.packageValueWithArray(newValue, searchParams, param)
122
+ }
123
+ } else if (column.componentType && column.componentType.indexOf('Tree') !== -1) {
124
+ // 说明是单选组织树
125
+ // 是否是人员树
126
+ const isUser = this.isUserTree(column.componentType)
127
+ let propValue = this.getFormItemValue(column.prop)
128
+ // 截取用户名中的英文名信息
129
+ propValue = this.getUserName(isUser, propValue)
130
+ this.packageValueWithArray(propValue, searchParams, param)
406
131
  } else {
407
- let parentObject
408
- // 属性超过2个时先找到最后一层属性的父对象
409
- for (let i = 0; i < nestedProp.length - 1; i++) {
410
- parentObject = this.searchForm[nestedProp[i]]
411
- }
412
- return parentObject
132
+ if (column.componentType === 'multiselect') {
133
+ // 表示是多选下拉框选择器选择的值
134
+ const values = this.getFormItemValue(column.prop)
135
+ // console.log('values==', values, column.prop)
136
+ this.packageValueWithArray(values, searchParams, param)
137
+ } else {
138
+ const propValue = this.getFormItemValue(column.prop)
139
+ this.packageValueWithArray(propValue, searchParams, param)
140
+ }
413
141
  }
414
- },
415
- // 处理多选下拉框时获得的值
416
- // 处理非多选下拉框的值
417
- packageValueWithArray(value, searchParams, param) {
418
- if (value && Array.isArray(value)) {
419
- const selectValues = value
420
- // if (!Array.isArray(values)) {
421
- // selectValues = values.split(',')
422
- // }
423
- let num = 0
424
- selectValues.forEach((val) => {
425
- const selectParam = Object.assign({}, param)
426
- selectParam.joinSign = 'or' // 将条件连接符修改为or,否则无法查询到值
427
- if (num === 0) {
428
- selectParam.leftBracket = '1' // 左边有1个括号
429
- }
430
- if (num === selectValues.length - 1) {
431
- // 说明是最后一个条件
432
- selectParam.rightBracket = '1' // 右边有1个括号
433
- selectParam.joinSign = 'and' // 最后一个条件的连接符需要修改为and
434
- }
435
- selectParam.propValue = val
436
- // 注释该代码,是因为多选下拉框数据库中以逗号分隔存储时,使用EQ无法查询出结果,需要使用getOpertator计算出的结果
437
- // selectParam.operator = 'EQ'
438
- if (val !== undefined && val !== null) {
439
- searchParams.push(selectParam)
440
- }
441
- num++
442
- })
443
- } else if (
444
- param.isEmptyValue || (
445
- typeof value !== 'undefined' &&
446
- value !== '' &&
447
- value !== null &&
448
- !Array.isArray(value))
449
- ) {
450
- // 不是数组
451
- param.propValue = value
452
- searchParams.push(param)
142
+ })
143
+ return searchParams
144
+ } else {
145
+ const newSearchFormList = []
146
+ this.searchFormList.forEach((param) => {
147
+ let newParam = {}
148
+ newParam = param
149
+ // const param = { leftBracket: '', rightBracket: '', joinSign: 'and' }
150
+ // 布尔型字段时prop中去掉了is字符,查询时返回带有is的属性字段,
151
+ // 否则会导致查询布尔型报500错误
152
+ let orgProp = newParam.orgProp
153
+ // sql查询时,会把点“.”改为两个下划线"__"
154
+ const replaceDot = '__'
155
+ if (orgProp && orgProp.indexOf(replaceDot) > 0) {
156
+ // 表示包括点“.”,需要把两个下划线"__"重新改为点“.”,否则会导致查询报500错误
157
+ orgProp = orgProp.replace(replaceDot, '.')
453
158
  }
454
- },
455
- // 保存查询条件
456
- saveSearchCondition(condition) {
457
- return this.$http.post(
458
- window.$vueApp.config.globalProperties.baseAPI +
459
- '/component/super-grids/search-conditions',
460
- condition
461
- )
462
- },
463
- // 显示查询条件列表
464
- listSearchCondition(listCode) {
465
- return new Promise((resolve,reject)=>{
466
- if(!listCode){
467
- resolve([])
159
+ newParam.propName = orgProp
160
+ newParam.operator = this.getOperator(param)
161
+ newParam.matchingType = param.queryMatching
162
+ if (newParam.dataType === 'DATE' || newParam.dataType === 'TIME') {
163
+ // 日期 或 时间类型
164
+ const values = newParam.value
165
+ // console.log('values==', values, column.prop)
166
+ if (values !== null && values.length === 2 && values[0] !== null && values[1] !== null) {
167
+ newParam.startValue = values[0]
168
+ newParam.endValue = values[1]
169
+ }
170
+ } else if (newParam.dataType === 'INTEGER' || newParam.dataType === 'LONG') {
171
+ const values1 = newParam.value
172
+ if (values1) {
173
+ if (!Array.isArray(values1) || values1.length < 2 || (values1[0] === null && values1[1] === null)) {
174
+ // 填写了一个有效值
175
+ if (!Array.isArray(values1)) {
176
+ newParam.propValue = values1
177
+ } else if (values1.length < 2) {
178
+ newParam.propValue = values1[0]
179
+ } else if (values1[0] === null) {
180
+ newParam.propValue = values1[1]
181
+ } else if (values1[1] === null) {
182
+ newParam.propValue = values1[0]
183
+ }
468
184
  } else {
469
- this.$http.get(
470
- window.$vueApp.config.globalProperties.baseAPI +
471
- '/component/super-grids/search-condition-list/' +
472
- listCode
473
- ).then(data=>{
474
- resolve(data)
475
- })
185
+ // 填写了两个有效值
186
+ newParam.startValue = values1[0]
187
+ newParam.endValue = values1[1]
476
188
  }
477
- })
478
- },
479
- // 删除查询条件
480
- removeSearchCondition(conditionId) {
481
- return this.$http.delete(
482
- window.$vueApp.config.globalProperties.baseAPI +
483
- '/component/super-grids/search-conditions/' +
484
- conditionId
485
- )
486
- },
487
- // 查询条件
488
- getSearchCondition(conditionId) {
489
- return this.$http.get(
490
- window.$vueApp.config.globalProperties.baseAPI +
491
- '/component/super-grids/search-conditions/' +
492
- conditionId
493
- )
494
- },
495
- // 设置默认查询值
496
- setDefaultQueryValue(column, searchForm) {
497
- if (
498
- column.componentType === 'date' ||
499
- column.componentType === 'dateSection' ||
500
- column.componentType === 'timePicker' ||
501
- column.componentType === 'dateTimePicker'
189
+ }
190
+ } else if (
191
+ newParam.componentType &&
192
+ newParam.componentType.indexOf('Tree') !== -1 &&
193
+ newParam.componentType.indexOf('single') === -1
502
194
  ) {
503
- const formatList = {
504
- date: 'YYYYMMDD',
505
- dateSection: 'YYYYMMDDHHMMSS',
506
- timePicker: 'YYYYMMDD',
507
- dateTimePicker: 'YYYYMMDDHHMMSS',
508
- }
509
- const valueTypeList = {
510
- date: 'String',
511
- dateSection: 'Date',
512
- timePicker: 'String',
513
- dateTimePicker: 'String',
195
+ // 树多选,先手动分割数组,在生成多条
196
+ // 是否是人员树
197
+ const isUser = this.isUserTree(newParam.componentType)
198
+ const values = newParam.value
199
+ if (values && values !== '') {
200
+ const newValue = []
201
+ let valueArr = values
202
+ if (Array.isArray(values)) {
203
+ valueArr = values
204
+ } else {
205
+ valueArr = values.split(',')
514
206
  }
515
- const rowControlConfig = column['controlConfig']
516
- if (
517
- rowControlConfig !== null &&
518
- rowControlConfig !== undefined &&
519
- rowControlConfig !== ''
520
- ) {
521
- const controlConfig = JSON.parse(rowControlConfig)
522
- if (controlConfig.timeDefaultQueryRange) {
523
- const format = formatList[column.componentType]
524
- const valueType = valueTypeList[column.componentType]
525
- if (format && valueType) {
526
- const queryRange = this.getDateQueryRange(
527
- column.componentType,
528
- format,
529
- controlConfig.timeDefaultQueryRange,
530
- valueType
531
- )
532
- searchForm[column.prop] = queryRange
533
- }
207
+ if (Array.isArray(valueArr) && valueArr && valueArr.length > 0) {
208
+ valueArr.forEach((val) => {
209
+ // 截取用户名中的英文名信息
210
+ const userName = this.getUserName(isUser, val)
211
+ if (userName !== undefined && userName !== null) {
212
+ newValue.push(userName)
534
213
  }
214
+ })
535
215
  }
216
+ this.packageValueWithArray(newValue, newSearchFormList, param)
217
+ }
218
+ } else if (newParam.componentType && newParam.componentType.indexOf('Tree') !== -1) {
219
+ // 说明是单选组织树
220
+ // 是否是人员树
221
+ const isUser = this.isUserTree(newParam.componentType)
222
+ let propValue = newParam.value
223
+ // 截取用户名中的英文名信息
224
+ propValue = this.getUserName(isUser, propValue)
225
+ this.packageValueWithArray(propValue, newSearchFormList, param)
226
+ } else {
227
+ if (newParam.componentType === 'multiselect') {
228
+ // 表示是多选下拉框选择器选择的值
229
+ const values = newParam.value
230
+ // console.log('values==', values, column.prop)
231
+ this.packageValueWithArray(values, newSearchFormList, param)
232
+ } else {
233
+ const values = newParam.value
234
+ this.packageValueWithArray(values, newSearchFormList, param)
235
+ }
536
236
  }
537
- },
538
- // 获取近一周,近两周,近一个月的时间范围
539
- // componentType组件类型 date time
540
- // format 格式 年月日/年月日时分秒
541
- // queryRangeType 查询范围类型 近一周nearlyWeek/近两周nearlyTwoWeeks/近一个月nearlyMonth
542
- // valueType 返回对象类型 String Date
543
- getDateQueryRange(componentType, format, timeDefaultQueryRange, valueType) {
544
- const queryRange = []
545
- const nowDate = new Date() // 当前时间
546
- let startDate // 开始时间
547
- const endDate = new Date() // 结束时间
548
- if (timeDefaultQueryRange !== null && timeDefaultQueryRange > 0) {
549
- startDate = new Date(
550
- nowDate.setDate(nowDate.getDate() - parseInt(timeDefaultQueryRange))
551
- )
237
+ })
238
+ return newSearchFormList
239
+ }
240
+ },
241
+ // 获得日期、时间查询格式配置,影响后台查询结果
242
+ getDateTimeSearchFormatter(column, dataType, formatter) {
243
+ const dateTimeFormat = 'yyyy-MM-dd HH:mm:ss'
244
+ const dateFormat = 'yyyy-m-d'
245
+ let format
246
+ if (column.componentType === 'dateSection') {
247
+ // 日期区间
248
+ format = dateFormat
249
+ } else if (column.componentType === 'dateTimePicker') {
250
+ // 日期时间选择器
251
+ format = dateTimeFormat
252
+ } else if (column.dataType === 'DATE' || column.componentType === 'date') {
253
+ // 日期选择器
254
+ format = dateFormat
255
+ }
256
+ if (!format) {
257
+ if (formatter) {
258
+ const formatOptions = formatter.options
259
+ if (formatOptions && formatOptions != null) {
260
+ format = formatOptions.format
552
261
  }
553
- if (format === 'YYYYMMDD') {
554
- queryRange[0] =
555
- startDate.getFullYear() +
556
- '-' +
557
- (startDate.getMonth() + 1) +
558
- '-' +
559
- startDate.getDate()
560
- queryRange[1] =
561
- endDate.getFullYear() +
562
- '-' +
563
- (endDate.getMonth() + 1) +
564
- '-' +
565
- endDate.getDate()
566
- } else {
567
- queryRange[0] =
568
- startDate.getFullYear() +
569
- '-' +
570
- (startDate.getMonth() + 1) +
571
- '-' +
572
- startDate.getDate() +
573
- ' 00:00:00'
574
- queryRange[1] =
575
- endDate.getFullYear() +
576
- '-' +
577
- (endDate.getMonth() + 1) +
578
- '-' +
579
- endDate.getDate() +
580
- ' 23:59:59'
262
+ }
263
+ }
264
+
265
+ if (!format) {
266
+ if (dataType === 'DATE') {
267
+ format = 'yyyy-m-d'
268
+ } else if (dataType === 'TIME') {
269
+ format = 'yyyy-m-d hh:mm:ss'
270
+ }
271
+ }
272
+ return format
273
+ },
274
+ // 根据日期字符串获得日期毫秒值
275
+ getDateTimeMillsByDateStr(dateStr, format) {
276
+ if (typeof dateStr === 'string' && format) {
277
+ if (dateStr.indexOf('T') !== -1) {
278
+ return new Date(dateStr).getTime()
279
+ }
280
+ // 表示是格式化后的值,转成date毫秒值传给后台,解决时区问题
281
+ format = format.toLowerCase()
282
+ if (format.indexOf('h') > 0 && format.indexOf('m') > 0 && format.indexOf('s') > 0) {
283
+ // 表示有时分秒
284
+ dateStr = new Date(dateStr).getTime()
285
+ } else {
286
+ // 表示精确到日
287
+ dateStr = new Date(dateStr + ' 00:00:00').getTime()
288
+ }
289
+ }
290
+ return dateStr
291
+ },
292
+ // 是否是人员树
293
+ isUserTree(componentType) {
294
+ if (componentType.indexOf('DeptManTree') > 0 || componentType.indexOf('WgManTree') > 0) {
295
+ return true
296
+ }
297
+ return false
298
+ },
299
+ // 获得用户名
300
+ getUserName(isUser, val) {
301
+ if (isUser && val !== undefined && val !== null && val.indexOf('(') > 0 && val.indexOf(')') > 0) {
302
+ // 说明是人员树,如果是值中包括英文名,把英文名截取掉,因为有些字段保存的有英文名,有些没有英文名,为了便于查询,所以统一将英文名去掉。
303
+ // 例如:张三(Andy),处理后是:张三
304
+ val = val.substring(0, val.indexOf('('))
305
+ }
306
+ return val
307
+ },
308
+ getOperator(column) {
309
+ if (
310
+ (column.dataType === 'TEXT' || column.dataType === 'CLOB') &&
311
+ column.fuzzy &&
312
+ (!column.componentType ||
313
+ (column.componentType &&
314
+ ((column.componentType !== 'select' && column.componentType !== 'multiselect') ||
315
+ (column.componentType === 'multiselect' &&
316
+ column.ifMultiData !== undefined &&
317
+ column.ifMultiData === true))))
318
+ ) {
319
+ // 是否是文本类型的字段,且启用了模糊查询,则表示操作符为contains模糊查询
320
+ return 'CONTAIN'
321
+ } else if (Array.isArray(this.getFormItemValue(column.prop))) {
322
+ if (column.dataType === 'INTEGER' || column.dataType === 'LONG' || column.dataType === 'DOUBLE') {
323
+ return 'BETWEEN'
324
+ } else {
325
+ return 'EQ'
326
+ }
327
+ } else {
328
+ // 否则就是等于
329
+ return 'EQ'
330
+ }
331
+ },
332
+ getFormItemValue(prop, index) {
333
+ if (prop.indexOf('.') > 0) {
334
+ const parentOjbect = this.getParentObject(prop)
335
+ if (index != null && index !== undefined) {
336
+ return parentOjbect[prop.substring(prop.lastIndexOf('.') + 1)][index]
337
+ } else {
338
+ return parentOjbect[prop.substring(prop.lastIndexOf('.') + 1)]
339
+ }
340
+ } else {
341
+ if (index != null && index !== undefined) {
342
+ return this.searchForm[prop][index]
343
+ } else {
344
+ return this.searchForm[prop]
345
+ }
346
+ }
347
+ },
348
+ getParentObject(prop) {
349
+ const nestedProp = prop.split('.')
350
+ // 属性只有一个时父对象就是searchForm
351
+ if (nestedProp.length === 1) {
352
+ return this.searchForm
353
+ } else {
354
+ let parentObject
355
+ // 属性超过2个时先找到最后一层属性的父对象
356
+ for (let i = 0; i < nestedProp.length - 1; i++) {
357
+ parentObject = this.searchForm[nestedProp[i]]
358
+ }
359
+ return parentObject
360
+ }
361
+ },
362
+ // 处理多选下拉框时获得的值
363
+ // 处理非多选下拉框的值
364
+ packageValueWithArray(value, searchParams, param) {
365
+ if (value && Array.isArray(value)) {
366
+ const selectValues = value
367
+ // if (!Array.isArray(values)) {
368
+ // selectValues = values.split(',')
369
+ // }
370
+ let num = 0
371
+ selectValues.forEach((val) => {
372
+ const selectParam = Object.assign({}, param)
373
+ selectParam.joinSign = 'or' // 将条件连接符修改为or,否则无法查询到值
374
+ if (num === 0) {
375
+ selectParam.leftBracket = '1' // 左边有1个括号
376
+ }
377
+ if (num === selectValues.length - 1) {
378
+ // 说明是最后一个条件
379
+ selectParam.rightBracket = '1' // 右边有1个括号
380
+ selectParam.joinSign = 'and' // 最后一个条件的连接符需要修改为and
581
381
  }
582
- if (valueType === 'Date') {
583
- const queryRangeFormat = []
584
- queryRange.forEach((date) => {
585
- var tempStrs = date.split(' ')
586
- var dateStrs = tempStrs[0].split('-')
587
- var year = parseInt(dateStrs[0], 10)
588
- var month = parseInt(dateStrs[1], 10) - 1
589
- var day = parseInt(dateStrs[2], 10)
590
- var timeStrs = tempStrs[1].split(':')
591
- var hour = parseInt(timeStrs[0], 10)
592
- var minute = parseInt(timeStrs[1], 10)
593
- var second = parseInt(timeStrs[2], 10)
594
- queryRangeFormat.push(new Date(year, month, day, hour, minute, second))
595
- })
596
- return queryRangeFormat
382
+ selectParam.propValue = val
383
+ // 注释该代码,是因为多选下拉框数据库中以逗号分隔存储时,使用EQ无法查询出结果,需要使用getOpertator计算出的结果
384
+ // selectParam.operator = 'EQ'
385
+ if (val !== undefined && val !== null) {
386
+ searchParams.push(selectParam)
387
+ }
388
+ num++
389
+ })
390
+ } else if (
391
+ param.isEmptyValue ||
392
+ (typeof value !== 'undefined' && value !== '' && value !== null && !Array.isArray(value))
393
+ ) {
394
+ // 不是数组
395
+ param.propValue = value
396
+ searchParams.push(param)
397
+ }
398
+ },
399
+ // 保存查询条件
400
+ saveSearchCondition(condition) {
401
+ return this.$http.post(
402
+ window.$vueApp.config.globalProperties.baseAPI + '/component/super-grids/search-conditions',
403
+ condition
404
+ )
405
+ },
406
+ // 显示查询条件列表
407
+ listSearchCondition(listCode) {
408
+ return new Promise((resolve, reject) => {
409
+ if (!listCode) {
410
+ resolve([])
411
+ } else {
412
+ this.$http
413
+ .get(
414
+ window.$vueApp.config.globalProperties.baseAPI + '/component/super-grids/search-condition-list/' + listCode
415
+ )
416
+ .then((data) => {
417
+ resolve(data)
418
+ })
419
+ }
420
+ })
421
+ },
422
+ // 删除查询条件
423
+ removeSearchCondition(conditionId) {
424
+ return this.$http.delete(
425
+ window.$vueApp.config.globalProperties.baseAPI + '/component/super-grids/search-conditions/' + conditionId
426
+ )
427
+ },
428
+ // 查询条件
429
+ getSearchCondition(conditionId) {
430
+ return this.$http.get(
431
+ window.$vueApp.config.globalProperties.baseAPI + '/component/super-grids/search-conditions/' + conditionId
432
+ )
433
+ },
434
+ // 设置默认查询值
435
+ setDefaultQueryValue(column, searchForm) {
436
+ if (
437
+ column.componentType === 'date' ||
438
+ column.componentType === 'dateSection' ||
439
+ column.componentType === 'timePicker' ||
440
+ column.componentType === 'dateTimePicker'
441
+ ) {
442
+ const formatList = {
443
+ date: 'YYYYMMDD',
444
+ dateSection: 'YYYYMMDDHHMMSS',
445
+ timePicker: 'YYYYMMDD',
446
+ dateTimePicker: 'YYYYMMDDHHMMSS'
447
+ }
448
+ const valueTypeList = {
449
+ date: 'String',
450
+ dateSection: 'Date',
451
+ timePicker: 'String',
452
+ dateTimePicker: 'String'
453
+ }
454
+ const rowControlConfig = column['controlConfig']
455
+ if (rowControlConfig !== null && rowControlConfig !== undefined && rowControlConfig !== '') {
456
+ const controlConfig = JSON.parse(rowControlConfig)
457
+ if (controlConfig.timeDefaultQueryRange) {
458
+ const format = formatList[column.componentType]
459
+ const valueType = valueTypeList[column.componentType]
460
+ if (format && valueType) {
461
+ const queryRange = this.getDateQueryRange(
462
+ column.componentType,
463
+ format,
464
+ controlConfig.timeDefaultQueryRange,
465
+ valueType
466
+ )
467
+ searchForm[column.prop] = queryRange
468
+ }
597
469
  }
598
- return queryRange
599
- },
470
+ }
471
+ }
472
+ },
473
+ // 获取近一周,近两周,近一个月的时间范围
474
+ // componentType组件类型 date time
475
+ // format 格式 年月日/年月日时分秒
476
+ // queryRangeType 查询范围类型 近一周nearlyWeek/近两周nearlyTwoWeeks/近一个月nearlyMonth
477
+ // valueType 返回对象类型 String Date
478
+ getDateQueryRange(componentType, format, timeDefaultQueryRange, valueType) {
479
+ const queryRange = []
480
+ const nowDate = new Date() // 当前时间
481
+ let startDate // 开始时间
482
+ const endDate = new Date() // 结束时间
483
+ if (timeDefaultQueryRange !== null && timeDefaultQueryRange > 0) {
484
+ startDate = new Date(nowDate.setDate(nowDate.getDate() - parseInt(timeDefaultQueryRange)))
485
+ }
486
+ if (format === 'YYYYMMDD') {
487
+ queryRange[0] = startDate.getFullYear() + '-' + (startDate.getMonth() + 1) + '-' + startDate.getDate()
488
+ queryRange[1] = endDate.getFullYear() + '-' + (endDate.getMonth() + 1) + '-' + endDate.getDate()
489
+ } else {
490
+ queryRange[0] =
491
+ startDate.getFullYear() + '-' + (startDate.getMonth() + 1) + '-' + startDate.getDate() + ' 00:00:00'
492
+ queryRange[1] = endDate.getFullYear() + '-' + (endDate.getMonth() + 1) + '-' + endDate.getDate() + ' 23:59:59'
493
+ }
494
+ if (valueType === 'Date') {
495
+ const queryRangeFormat = []
496
+ queryRange.forEach((date) => {
497
+ var tempStrs = date.split(' ')
498
+ var dateStrs = tempStrs[0].split('-')
499
+ var year = parseInt(dateStrs[0], 10)
500
+ var month = parseInt(dateStrs[1], 10) - 1
501
+ var day = parseInt(dateStrs[2], 10)
502
+ var timeStrs = tempStrs[1].split(':')
503
+ var hour = parseInt(timeStrs[0], 10)
504
+ var minute = parseInt(timeStrs[1], 10)
505
+ var second = parseInt(timeStrs[2], 10)
506
+ queryRangeFormat.push(new Date(year, month, day, hour, minute, second))
507
+ })
508
+ return queryRangeFormat
509
+ }
510
+ return queryRange
511
+ }
600
512
  }
601
513
  export default searchMethods