agilebuilder-ui 1.0.90-tmp18 → 1.0.90-tmp1811

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.
package/src/utils/util.js CHANGED
@@ -3,24 +3,24 @@ import { executeExpression } from './calculator/calculator-util'
3
3
  import { getLangByShort } from './common-util'
4
4
 
5
5
  export function getI18n() {
6
- let myI18n = window.$i18n
7
- if(!myI18n){
8
- myI18n = i18n
9
- }
10
- if (!window.$locale) {
11
- i18n.locale = 'cn'
12
- } else {
13
- i18n.locale = window.$locale
14
- }
15
- return myI18n.global
6
+ let myI18n = window.$i18n
7
+ if (!myI18n) {
8
+ myI18n = i18n
9
+ }
10
+ if (!window.$locale) {
11
+ i18n.locale = 'cn'
12
+ } else {
13
+ i18n.locale = window.$locale
14
+ }
15
+ return myI18n.global
16
16
  }
17
17
 
18
18
  export function getLanguageWithLocale() {
19
- let currentLocale = window.$locale
20
- if (!currentLocale || currentLocale === 'zh') {
21
- currentLocale = 'cn'
22
- }
23
- return getLangByShort(currentLocale)
19
+ let currentLocale = window.$locale
20
+ if (!currentLocale || currentLocale === 'zh') {
21
+ currentLocale = 'cn'
22
+ }
23
+ return getLangByShort(currentLocale)
24
24
  }
25
25
 
26
26
  /**
@@ -31,51 +31,45 @@ export function getLanguageWithLocale() {
31
31
  * @returns
32
32
  */
33
33
  export function findOptionsByDynamicDataSource(
34
- dynamicSourceCode,
35
- searchText,
36
- entity,
37
- additionalParameterStr,
38
- searchParam
34
+ dynamicSourceCode,
35
+ searchText,
36
+ entity,
37
+ additionalParameterStr,
38
+ searchParam
39
39
  ) {
40
- return new Promise((resolve, reject) => {
41
- findDynamicDataSourceByCode(
42
- dynamicSourceCode,
43
- searchText,
44
- entity,
45
- additionalParameterStr,
46
- searchParam
47
- )
48
- .then((dynamicDataSourceDto) => {
49
- let options = []
50
- if (dynamicDataSourceDto && dynamicDataSourceDto.options) {
51
- const setOptions = dynamicDataSourceDto.options
52
- let valueAttribute
53
- if (dynamicDataSourceDto.valueAttribute) {
54
- valueAttribute = dynamicDataSourceDto.valueAttribute
55
- }
56
- if (!valueAttribute || valueAttribute === '[label]') {
57
- valueAttribute = '_label_'
58
- }
59
- setOptions.forEach((item) => {
60
- // 值
61
- const value = item[valueAttribute]
62
- // 显示的标签
63
- const label = item['_label_']
64
- options.push({
65
- label,
66
- value,
67
- })
68
- })
69
- }
70
- if (!options) {
71
- options = []
72
- }
73
- resolve(options)
74
- })
75
- .catch((error) => {
76
- reject(error)
40
+ return new Promise((resolve, reject) => {
41
+ findDynamicDataSourceByCode(dynamicSourceCode, searchText, entity, additionalParameterStr, searchParam)
42
+ .then((dynamicDataSourceDto) => {
43
+ let options = []
44
+ if (dynamicDataSourceDto && dynamicDataSourceDto.options) {
45
+ const setOptions = dynamicDataSourceDto.options
46
+ let valueAttribute
47
+ if (dynamicDataSourceDto.valueAttribute) {
48
+ valueAttribute = dynamicDataSourceDto.valueAttribute
49
+ }
50
+ if (!valueAttribute || valueAttribute === '[label]') {
51
+ valueAttribute = '_label_'
52
+ }
53
+ setOptions.forEach((item) => {
54
+ //
55
+ const value = item[valueAttribute]
56
+ // 显示的标签
57
+ const label = item['_label_']
58
+ options.push({
59
+ label,
60
+ value
77
61
  })
78
- })
62
+ })
63
+ }
64
+ if (!options) {
65
+ options = []
66
+ }
67
+ resolve(options)
68
+ })
69
+ .catch((error) => {
70
+ reject(error)
71
+ })
72
+ })
79
73
  }
80
74
 
81
75
  /**
@@ -86,76 +80,84 @@ export function findOptionsByDynamicDataSource(
86
80
  * @returns
87
81
  */
88
82
  export function findDynamicDataSourceByCode(
89
- dynamicSourceCode,
90
- searchText,
91
- entity,
92
- additionalParameterStr,
93
- searchParam
83
+ dynamicSourceCode,
84
+ searchText,
85
+ entity,
86
+ additionalParameterStr,
87
+ searchParam
94
88
  ) {
95
- let watchAttrValue
96
- let parentEntity
97
- let listCode
98
- let formCode
99
- let tableName
100
- if (searchParam) {
101
- watchAttrValue = searchParam.watchAttrValue
102
- if (watchAttrValue === undefined || watchAttrValue === null) {
103
- watchAttrValue = ''
104
- }
105
- parentEntity = searchParam.parent
106
- listCode = searchParam._listCode
107
- formCode = searchParam._formCode
108
- tableName = searchParam._tableName
109
- }
110
- const params = {
111
- searchText,
112
- watchAttrValue,
113
- parent: parentEntity
114
-
115
- }
116
- if (additionalParameterStr && typeof (additionalParameterStr) === 'object') {
117
- params.additionalParamMap = additionalParameterStr
118
- } else if (additionalParameterStr && typeof (additionalParameterStr) === 'string') {
119
- params.additionalParamMap = JSON.parse(additionalParameterStr)
120
- }
121
- if (params.additionalParamMap === undefined) {
122
- params.additionalParamMap = {}
123
- }
124
- if (listCode) {
125
- params.additionalParamMap._listCode = listCode
126
- }
127
- if (formCode) {
128
- params.additionalParamMap._formCode = formCode
129
- }
130
- if (tableName) {
131
- params.additionalParamMap._tableName = tableName
132
- }
133
- if (entity && entity !== null) {
134
- params.entity = entity
135
- }
136
- const backendUrl = window.$vueApp.config.globalProperties.baseURL
89
+ let watchAttrValue
90
+ let parentEntity
91
+ let listCode
92
+ let formCode
93
+ let tableName
94
+ if (searchParam) {
95
+ watchAttrValue = searchParam.watchAttrValue
96
+ if (watchAttrValue === undefined || watchAttrValue === null) {
97
+ watchAttrValue = ''
98
+ }
99
+ parentEntity = searchParam.parent
100
+ listCode = searchParam._listCode
101
+ formCode = searchParam._formCode
102
+ tableName = searchParam._tableName
103
+ }
104
+ const params = {
105
+ searchText,
106
+ watchAttrValue,
107
+ parent: parentEntity
108
+ }
109
+ if (additionalParameterStr && typeof additionalParameterStr === 'object') {
110
+ params.additionalParamMap = additionalParameterStr
111
+ } else if (additionalParameterStr && typeof additionalParameterStr === 'string') {
112
+ params.additionalParamMap = JSON.parse(additionalParameterStr)
113
+ }
114
+ if (params.additionalParamMap === undefined) {
115
+ params.additionalParamMap = {}
116
+ }
117
+ if (listCode) {
118
+ params.additionalParamMap._listCode = listCode
119
+ }
120
+ if (formCode) {
121
+ params.additionalParamMap._formCode = formCode
122
+ }
123
+ if (tableName) {
124
+ params.additionalParamMap._tableName = tableName
125
+ }
126
+ if (entity && entity !== null) {
127
+ params.entity = entity
128
+ }
129
+ const backendUrl = window.$vueApp.config.globalProperties.baseURL
137
130
 
138
- return new Promise((resolve, reject) => {
139
- // 页面设计不请求动态数据源
140
- if (window.$vueApp.config.globalProperties.systemCode !== undefined && window.$vueApp.config.globalProperties.systemCode === 'agilebuilder') {
141
- resolve()
142
- } else {
143
- window.$vueApp.config.globalProperties.$http.post(backendUrl + '/common/dynamic-data-source/' + dynamicSourceCode, params).then(result => {
144
- if (result.backendUrl) {
145
- // result.backendUrl表示需要使用动态数据源所属的系统路径重新获得一次数据
146
- window.$vueApp.config.globalProperties.$http.post(result.backendUrl + '/common/dynamic-data-source/' + dynamicSourceCode, params).then(finallyResult => {
147
- resolve(finallyResult)
148
- }).catch(error => {
149
- reject(error)
150
- })
151
- } else {
152
- resolve(result)
153
- }
154
- }).catch(error => {
131
+ return new Promise((resolve, reject) => {
132
+ // 页面设计不请求动态数据源
133
+ if (
134
+ window.$vueApp.config.globalProperties.systemCode !== undefined &&
135
+ window.$vueApp.config.globalProperties.systemCode === 'agilebuilder'
136
+ ) {
137
+ resolve()
138
+ } else {
139
+ window.$vueApp.config.globalProperties.$http
140
+ .post(backendUrl + '/common/dynamic-data-source/' + dynamicSourceCode, params)
141
+ .then((result) => {
142
+ if (result.backendUrl) {
143
+ // result.backendUrl表示需要使用动态数据源所属的系统路径重新获得一次数据
144
+ window.$vueApp.config.globalProperties.$http
145
+ .post(result.backendUrl + '/common/dynamic-data-source/' + dynamicSourceCode, params)
146
+ .then((finallyResult) => {
147
+ resolve(finallyResult)
148
+ })
149
+ .catch((error) => {
155
150
  reject(error)
156
- })
157
- }
158
- })
151
+ })
152
+ } else {
153
+ resolve(result)
154
+ }
155
+ })
156
+ .catch((error) => {
157
+ reject(error)
158
+ })
159
+ }
160
+ })
159
161
  }
160
162
 
161
163
  /**
@@ -169,266 +171,233 @@ export function findDynamicDataSourceByCode(
169
171
  * @returns
170
172
  */
171
173
  export function analysisCondition(
172
- conditionListJson,
173
- entity,
174
- additionalParameter,
175
- contextParameter,
176
- isSql,
177
- tableName,
178
- parentFormData,
179
- pageContext
174
+ conditionListJson,
175
+ entity,
176
+ additionalParameter,
177
+ contextParameter,
178
+ isSql,
179
+ tableName,
180
+ parentFormData,
181
+ pageContext
180
182
  ) {
181
- // console.log('analysisCondition判断条件conditionListJson', conditionListJson)
182
- // console.log('analysisCondition判断条件entity', entity)
183
- // console.log('analysisCondition判断条件additionalParameter', additionalParameter)
184
- // console.log('analysisCondition判断条件contextParameter', contextParameter)
185
- // console.log('analysisCondition判断条件isSql', isSql)
186
- // console.log('analysisCondition判断条件tableName', tableName)
187
- // console.log('analysisCondition判断条件parentFormData', parentFormData)
188
- if (
189
- conditionListJson === undefined ||
190
- conditionListJson === '' ||
191
- conditionListJson === null
192
- ) {
193
- // 如果条件不存在,则默认返回true
194
- return true
195
- }
196
- if (typeof isSql === 'undefined' || isSql === null) {
197
- // 默认是定制开发时
198
- isSql = false
199
- }
200
- // 页面附加参数
201
- let additionalParameterMap = {}
202
- if (
203
- additionalParameter &&
204
- typeof additionalParameter === 'string' &&
205
- additionalParameter !== ''
206
- ) {
207
- additionalParameterMap = JSON.parse(additionalParameter)
208
- } else if (additionalParameter && typeof additionalParameter === 'object') {
209
- additionalParameterMap = additionalParameter
210
- }
211
- // 环境变量,例如:当前用户id、当前用户登录名等
212
- let contextParameterMap = {}
213
- if (
214
- contextParameter &&
215
- typeof contextParameter === 'string' &&
216
- contextParameter !== ''
217
- ) {
218
- contextParameterMap = JSON.parse(contextParameter)
219
- } else if (contextParameter && typeof contextParameter === 'object') {
220
- contextParameterMap = contextParameter
221
- }
222
- let conditionList = []
223
- if (
224
- conditionListJson &&
225
- typeof conditionListJson === 'string' &&
226
- conditionListJson !== ''
227
- ) {
228
- // conditionList = eval('('+conditionListJson+')')
229
- conditionList = JSON.parse(conditionListJson)
230
- } else if (conditionListJson && Array.isArray(conditionListJson)) {
231
- conditionList = conditionListJson
232
- }
233
- return parseCondition(
234
- entity,
235
- conditionList,
236
- isSql,
237
- tableName,
238
- additionalParameterMap,
239
- contextParameterMap,
240
- parentFormData,
241
- pageContext
242
- )
243
- }
244
-
245
- function parseCondition(
183
+ // console.log('analysisCondition判断条件conditionListJson', conditionListJson)
184
+ // console.log('analysisCondition判断条件entity', entity)
185
+ // console.log('analysisCondition判断条件additionalParameter', additionalParameter)
186
+ // console.log('analysisCondition判断条件contextParameter', contextParameter)
187
+ // console.log('analysisCondition判断条件isSql', isSql)
188
+ // console.log('analysisCondition判断条件tableName', tableName)
189
+ // console.log('analysisCondition判断条件parentFormData', parentFormData)
190
+ if (conditionListJson === undefined || conditionListJson === '' || conditionListJson === null) {
191
+ // 如果条件不存在,则默认返回true
192
+ return true
193
+ }
194
+ if (typeof isSql === 'undefined' || isSql === null) {
195
+ // 默认是定制开发时
196
+ isSql = false
197
+ }
198
+ // 页面附加参数
199
+ let additionalParameterMap = {}
200
+ if (additionalParameter && typeof additionalParameter === 'string' && additionalParameter !== '') {
201
+ additionalParameterMap = JSON.parse(additionalParameter)
202
+ } else if (additionalParameter && typeof additionalParameter === 'object') {
203
+ additionalParameterMap = additionalParameter
204
+ }
205
+ // 环境变量,例如:当前用户id、当前用户登录名等
206
+ let contextParameterMap = {}
207
+ if (contextParameter && typeof contextParameter === 'string' && contextParameter !== '') {
208
+ contextParameterMap = JSON.parse(contextParameter)
209
+ } else if (contextParameter && typeof contextParameter === 'object') {
210
+ contextParameterMap = contextParameter
211
+ }
212
+ let conditionList = []
213
+ if (conditionListJson && typeof conditionListJson === 'string' && conditionListJson !== '') {
214
+ // conditionList = eval('('+conditionListJson+')')
215
+ conditionList = JSON.parse(conditionListJson)
216
+ } else if (conditionListJson && Array.isArray(conditionListJson)) {
217
+ conditionList = conditionListJson
218
+ }
219
+ return parseCondition(
246
220
  entity,
247
221
  conditionList,
248
222
  isSql,
249
223
  tableName,
250
- additionalParamMap,
224
+ additionalParameterMap,
251
225
  contextParameterMap,
252
226
  parentFormData,
253
227
  pageContext
228
+ )
229
+ }
230
+
231
+ function parseCondition(
232
+ entity,
233
+ conditionList,
234
+ isSql,
235
+ tableName,
236
+ additionalParamMap,
237
+ contextParameterMap,
238
+ parentFormData,
239
+ pageContext
254
240
  ) {
255
- if (
256
- conditionList === undefined ||
257
- conditionList === null ||
258
- conditionList.length === 0
259
- ) {
260
- // 表示没有设置条件,默认是true
261
- return true
262
- }
263
- // 条件封装的表达式
264
- let conditions = ''
265
- for (let i = 0; i < conditionList.length; i++) {
266
- const condition = conditionList[i]
267
- let propName = condition.propName
268
- let propDbName = condition.propDbName
269
- if ((!propName || propName === '') && (!propDbName || propDbName === '')) {
270
- // 没有属性和字段名表示是无效的条件
271
- continue
272
- }
273
- let leftValue
274
- if (isSql && propDbName) {
275
- if (propDbName.indexOf('parent_+_') !== -1) {
276
- propDbName = propDbName.replace('parent_+_', '')
277
- // 再获取属于那张表
278
- const propDbNameArr = propDbName.split('_+_')
279
- propDbName = propDbNameArr[1]
280
- leftValue = getValue(parentFormData, propDbName, isSql)
281
- } else {
282
- leftValue = getValue(entity, propDbName, isSql)
283
- }
284
- if (leftValue === undefined || leftValue === null) {
285
- if (
286
- tableName &&
287
- propDbName.toLowerCase().startsWith(tableName.toLowerCase() + '.')
288
- ) {
289
- // 表示是当前表的字段
290
- const myProp = propDbName.substring(propDbName.indexOf('.'))
291
- leftValue = getValue(entity, myProp, isSql)
292
- }
293
- }
294
- } else {
295
- if (propName.indexOf('parent_+_') !== -1) {
296
- propName = propName.replace('parent_+_', '')
297
- const propNameArr = propName.split('_+_')
298
- propName = propNameArr[1]
299
- leftValue = getValue(parentFormData, propName, isSql)
300
- } else {
301
- leftValue = getValue(entity, propName, isSql)
302
- }
303
- if (propDbName && (leftValue === undefined || leftValue === null)) {
304
- leftValue = getValue(entity, propDbName, isSql)
305
- }
241
+ if (conditionList === undefined || conditionList === null || conditionList.length === 0) {
242
+ // 表示没有设置条件,默认是true
243
+ return true
244
+ }
245
+ // 条件封装的表达式
246
+ let conditions = ''
247
+ for (let i = 0; i < conditionList.length; i++) {
248
+ const condition = conditionList[i]
249
+ let propName = condition.propName
250
+ let propDbName = condition.propDbName
251
+ if ((!propName || propName === '') && (!propDbName || propDbName === '')) {
252
+ // 没有属性和字段名表示是无效的条件
253
+ continue
254
+ }
255
+ let leftValue
256
+ if (isSql && propDbName) {
257
+ if (propDbName.indexOf('parent_+_') !== -1) {
258
+ propDbName = propDbName.replace('parent_+_', '')
259
+ // 再获取属于那张表
260
+ const propDbNameArr = propDbName.split('_+_')
261
+ propDbName = propDbNameArr[1]
262
+ leftValue = getValue(parentFormData, propDbName, isSql)
263
+ } else {
264
+ leftValue = getValue(entity, propDbName, isSql)
265
+ }
266
+ if (leftValue === undefined || leftValue === null) {
267
+ if (tableName && propDbName.toLowerCase().startsWith(tableName.toLowerCase() + '.')) {
268
+ // 表示是当前表的字段
269
+ const myProp = propDbName.substring(propDbName.indexOf('.'))
270
+ leftValue = getValue(entity, myProp, isSql)
306
271
  }
307
- const operator = condition.operator
308
- const propValue = condition.propValue
309
- const dataType = condition.dataType
310
- const variableIsNullStr = condition.variableIsNull
311
- // 解析单个条件的值
312
- // 判断value类型
313
- let value
314
- if(pageContext){
315
- value = getPropValueNew(propValue, pageContext)
272
+ }
273
+ } else {
274
+ if (propName.indexOf('parent_+_') !== -1) {
275
+ propName = propName.replace('parent_+_', '')
276
+ const propNameArr = propName.split('_+_')
277
+ propName = propNameArr[1]
278
+ leftValue = getValue(parentFormData, propName, isSql)
279
+ } else {
280
+ leftValue = getValue(entity, propName, isSql)
281
+ }
282
+ if (propDbName && (leftValue === undefined || leftValue === null)) {
283
+ leftValue = getValue(entity, propDbName, isSql)
284
+ }
285
+ }
286
+ const operator = condition.operator
287
+ const propValue = condition.propValue
288
+ const dataType = condition.dataType
289
+ const variableIsNullStr = condition.variableIsNull
290
+ // 解析单个条件的值
291
+ // 判断value类型
292
+ let value
293
+ if (pageContext) {
294
+ value = getPropValueNew(propValue, pageContext)
295
+ } else {
296
+ value = getPropValue(propValue, entity, additionalParamMap, contextParameterMap)
297
+ }
298
+ if (variableIsNullStr && variableIsNullStr === 'null') {
299
+ if (value === undefined || value === '') {
300
+ value = null
301
+ }
302
+ }
303
+ let conditionResult = executeExpression(leftValue, operator, value, dataType)
304
+ const leftBracket = condition.leftBracket
305
+ const rightBracket = condition.rightBracket
306
+ let joinSign = condition.joinSign
307
+ if (leftBracket && leftBracket !== null && leftBracket !== '') {
308
+ conditions = conditions + leftBracket
309
+ conditions = conditions + ' '
310
+ // conditions.append(leftBracket).append(' ')
311
+ }
312
+ if (variableIsNullStr && variableIsNullStr !== 'null') {
313
+ if (value === undefined || value === null || value + '' === '') {
314
+ if (variableIsNullStr === '1=1') {
315
+ conditionResult = true
316
316
  } else {
317
- value = getPropValue(
318
- propValue,
319
- entity,
320
- additionalParamMap,
321
- contextParameterMap
322
- )
323
- }
324
- if (variableIsNullStr && variableIsNullStr === 'null') {
325
- if (value === undefined || value === '') {
326
- value = null
327
- }
328
- }
329
- let conditionResult = executeExpression(
330
- leftValue,
331
- operator,
332
- value,
333
- dataType
334
- )
335
- const leftBracket = condition.leftBracket
336
- const rightBracket = condition.rightBracket
337
- let joinSign = condition.joinSign
338
- if (leftBracket && leftBracket !== null && leftBracket !== '') {
339
- conditions = conditions + leftBracket
340
- conditions = conditions + ' '
341
- // conditions.append(leftBracket).append(' ')
342
- }
343
- if (variableIsNullStr && variableIsNullStr !== 'null') {
344
- if (value === undefined || value === null || value + '' === '') {
345
- if (variableIsNullStr === '1=1') {
346
- conditionResult = true
347
- } else {
348
- conditionResult = false
349
- }
350
- }
351
- }
352
- conditions += conditionResult + ' '
353
- if (rightBracket && rightBracket !== null && rightBracket !== '') {
354
- conditions = conditions + rightBracket
355
- conditions = conditions + ' '
356
- // conditions.append(rightBracket).append(' ')
357
- }
358
- if (i < conditionList.length - 1) {
359
- // 最后一个不拼接“连接符”
360
- if (joinSign && joinSign !== null && joinSign !== '') {
361
- const joinSignIgnoreCase = joinSign.toLowerCase()
362
- if (joinSignIgnoreCase === 'and') {
363
- joinSign = joinSignIgnoreCase.replace('and', '&&')
364
- } else if (joinSignIgnoreCase === 'or') {
365
- joinSign = joinSignIgnoreCase.replace('or', '||')
366
- }
367
- conditions += joinSign + ' '
368
- }
317
+ conditionResult = false
369
318
  }
319
+ }
370
320
  }
371
- console.log('parseCondition----conditions=', conditions)
372
- if (conditions) {
373
- // eslint-disable-next-line no-eval
374
- return eval('(' + conditions + ')')
375
- } else {
376
- return true
321
+ conditions += conditionResult + ' '
322
+ if (rightBracket && rightBracket !== null && rightBracket !== '') {
323
+ conditions = conditions + rightBracket
324
+ conditions = conditions + ' '
325
+ // conditions.append(rightBracket).append(' ')
326
+ }
327
+ if (i < conditionList.length - 1) {
328
+ // 最后一个不拼接“连接符”
329
+ if (joinSign && joinSign !== null && joinSign !== '') {
330
+ const joinSignIgnoreCase = joinSign.toLowerCase()
331
+ if (joinSignIgnoreCase === 'and') {
332
+ joinSign = joinSignIgnoreCase.replace('and', '&&')
333
+ } else if (joinSignIgnoreCase === 'or') {
334
+ joinSign = joinSignIgnoreCase.replace('or', '||')
335
+ }
336
+ conditions += joinSign + ' '
337
+ }
377
338
  }
339
+ }
340
+ console.log('parseCondition----conditions=', conditions)
341
+ if (conditions) {
342
+ // eslint-disable-next-line no-eval
343
+ return eval('(' + conditions + ')')
344
+ } else {
345
+ return true
346
+ }
378
347
  }
379
348
 
380
349
  const REPLACE_DOT = '__'
381
350
 
382
351
  function getValue(entityData, fieldName, isSql) {
383
- let value = null
384
- if (entityData && entityData !== null) {
385
- if (fieldName && fieldName !== null) {
386
- value = getValueByField(entityData, fieldName)
387
- if (value === undefined || value === null) {
388
- if (isSql) {
389
- if (value === undefined || value == null) {
390
- if (fieldName.indexOf('.') > 0) {
391
- // 将“.”替换为'__',列表组件中的entity中如果是'.',传过来的实体信息中的字段属性会是“__”
392
- fieldName = fieldName.replace('.', REPLACE_DOT)
393
- value = getValueByField(entityData, fieldName)
394
- }
395
- }
396
- }
352
+ let value = null
353
+ if (entityData && entityData !== null) {
354
+ if (fieldName && fieldName !== null) {
355
+ value = getValueByField(entityData, fieldName)
356
+ if (value === undefined || value === null) {
357
+ if (isSql) {
358
+ if (value === undefined || value == null) {
359
+ if (fieldName.indexOf('.') > 0) {
360
+ // 将“.”替换为'__',列表组件中的entity中如果是'.',传过来的实体信息中的字段属性会是“__”
361
+ fieldName = fieldName.replace('.', REPLACE_DOT)
362
+ value = getValueByField(entityData, fieldName)
397
363
  }
364
+ }
398
365
  }
366
+ }
399
367
  }
400
- return value
368
+ }
369
+ return value
401
370
  }
402
371
 
403
372
  export function getValueByField(entityData, fieldName) {
404
- if (entityData && entityData !== null) {
405
- let value
406
- if (fieldName.indexOf('.') > 0) {
407
- // 表示是子表字段
408
- value = getSubEntityValue(entityData, fieldName)
409
- } else {
410
- value = entityData[fieldName.toUpperCase()]
411
- if (value === undefined) {
412
- value = entityData[fieldName.toLowerCase()]
413
- }
414
- }
415
- return value
373
+ if (entityData && entityData !== null) {
374
+ let value
375
+ if (fieldName.indexOf('.') > 0) {
376
+ // 表示是子表字段
377
+ value = getSubEntityValue(entityData, fieldName)
378
+ } else {
379
+ value = entityData[fieldName.toUpperCase()]
380
+ if (value === undefined) {
381
+ value = entityData[fieldName.toLowerCase()]
382
+ }
416
383
  }
384
+ return value
385
+ }
417
386
  }
418
387
 
419
388
  function getSubEntityValue(entityData, fieldName) {
420
- let value = null
421
- let subEntityData = entityData
422
- const fieldNames = fieldName.split('\\.')
423
- for (let i = 0; i < fieldNames.length; i++) {
424
- const field = fieldNames[i]
425
- if (i === fieldNames.length) {
426
- value = getSubEntityFieldValue(subEntityData, field)
427
- } else {
428
- subEntityData = getSubEntityFieldValue(subEntityData, field)
429
- }
389
+ let value = null
390
+ let subEntityData = entityData
391
+ const fieldNames = fieldName.split('\\.')
392
+ for (let i = 0; i < fieldNames.length; i++) {
393
+ const field = fieldNames[i]
394
+ if (i === fieldNames.length) {
395
+ value = getSubEntityFieldValue(subEntityData, field)
396
+ } else {
397
+ subEntityData = getSubEntityFieldValue(subEntityData, field)
430
398
  }
431
- return value
399
+ }
400
+ return value
432
401
  }
433
402
 
434
403
  /**
@@ -439,18 +408,18 @@ function getSubEntityValue(entityData, fieldName) {
439
408
  * @return
440
409
  */
441
410
  function getSubEntityFieldValue(subEntityData, fieldName) {
442
- if (subEntityData === undefined || subEntityData === null) {
443
- return null
444
- }
445
- return subEntityData[fieldName]
411
+ if (subEntityData === undefined || subEntityData === null) {
412
+ return null
413
+ }
414
+ return subEntityData[fieldName]
446
415
  }
447
416
 
448
417
  function getContextValue(contextParameterMap, propValue) {
449
- let value = getLastNDate(propValue)
450
- if (contextParameterMap) {
451
- value = contextParameterMap[propValue]
452
- }
453
- return value
418
+ let value = getLastNDate(propValue)
419
+ if (contextParameterMap) {
420
+ value = contextParameterMap[propValue]
421
+ }
422
+ return value
454
423
  }
455
424
  /**
456
425
  * 获得最近n天的开始日期和结束日期集合
@@ -458,57 +427,51 @@ function getContextValue(contextParameterMap, propValue) {
458
427
  * @returns [startDate,endDate],例如:[2024/2/26 00:00:00,2023/3/3 23:59:59]
459
428
  */
460
429
  export function getLastNDate(propValue) {
461
- let value
462
- if (propValue &&
463
- propValue === 'currentTime') {
464
- // 当前时间
465
- value = new Date()
466
- }
467
- if (propValue &&
468
- propValue === 'currentWeek') {
469
- // 本周
470
- value = getCurrentWeek()
471
- }
472
- if (propValue &&
473
- propValue === 'currentMonth') {
474
- // 本月
475
- value = getCurrentMonth()
476
- }
477
- if (propValue &&
478
- propValue === 'currentQuarter') {
479
- // 本季度
480
- value = getCurrentQuarter()
481
- }
482
- if (propValue &&
483
- propValue === 'currentYear') {
484
- // 本年
485
- value = getCurrentYear()
486
- }
487
- if (propValue &&
488
- propValue.indexOf('lastNDay') >= 0) {
489
- // 最近n天 lastNDay:n,例如:lastNDay:5,表示最近5天
490
- const n = propValue.substring(propValue.indexOf(':') + 1)
491
- value = getLastNDay(parseInt(n))
492
- }
493
- return value
430
+ let value
431
+ if (propValue && propValue === 'currentTime') {
432
+ // 当前时间
433
+ value = new Date()
434
+ }
435
+ if (propValue && propValue === 'currentWeek') {
436
+ // 本周
437
+ value = getCurrentWeek()
438
+ }
439
+ if (propValue && propValue === 'currentMonth') {
440
+ // 本月
441
+ value = getCurrentMonth()
442
+ }
443
+ if (propValue && propValue === 'currentQuarter') {
444
+ // 本季度
445
+ value = getCurrentQuarter()
446
+ }
447
+ if (propValue && propValue === 'currentYear') {
448
+ // 本年
449
+ value = getCurrentYear()
450
+ }
451
+ if (propValue && propValue.indexOf('lastNDay') >= 0) {
452
+ // 最近n天 lastNDay:n,例如:lastNDay:5,表示最近5天
453
+ const n = propValue.substring(propValue.indexOf(':') + 1)
454
+ value = getLastNDay(parseInt(n))
455
+ }
456
+ return value
494
457
  }
495
458
  /**
496
459
  * 获得当前周的周一和周日的的日期
497
460
  * 例如:[2024/2/26 00:00:00,2023/3/3 23:59:59]
498
- * @returns
461
+ * @returns
499
462
  */
500
463
  function getCurrentWeek() {
501
- const new_Date = new Date() //获取本周一周日期
502
- const timesStamp = new_Date.getTime();
503
- const currenDay = new_Date.getDay();
504
- // 周一
505
- const monday = new Date(timesStamp + 24 * 60 * 60 * 1000 * (0 - (currenDay + 6) % 7))
506
- // 周日
507
- const sunday = new Date(timesStamp + 24 * 60 * 60 * 1000 * (6 - (currenDay + 6) % 7))
508
- const startDate = monday.toLocaleDateString() + " " + monday.toLocaleTimeString()
509
- const endDate = sunday.toLocaleDateString() + " " + sunday.toLocaleTimeString()
510
- console.log(`getCurrentMonth从 ${startDate} 开始,到 ${endDate} 结束`);
511
- return [monday, sunday]
464
+ const new_Date = new Date() //获取本周一周日期
465
+ const timesStamp = new_Date.getTime()
466
+ const currenDay = new_Date.getDay()
467
+ // 周一
468
+ const monday = new Date(timesStamp + 24 * 60 * 60 * 1000 * (0 - ((currenDay + 6) % 7)))
469
+ // 周日
470
+ const sunday = new Date(timesStamp + 24 * 60 * 60 * 1000 * (6 - ((currenDay + 6) % 7)))
471
+ const startDate = monday.toLocaleDateString() + ' ' + monday.toLocaleTimeString()
472
+ const endDate = sunday.toLocaleDateString() + ' ' + sunday.toLocaleTimeString()
473
+ console.log(`getCurrentMonth从 ${startDate} 开始,到 ${endDate} 结束`)
474
+ return [monday, sunday]
512
475
  }
513
476
  /**
514
477
  * 获得当前月第1天和最后1天的日期
@@ -516,230 +479,240 @@ function getCurrentWeek() {
516
479
  * @returns [xxx,xxx]
517
480
  */
518
481
  function getCurrentMonth() {
519
- // 创建一个新的Date对象,表示当前时间
520
- const currentDate = new Date();
521
-
522
- // 获取当前年份和月份
523
- const year = currentDate.getFullYear(); // 获取完整的四位年份
524
- const month = currentDate.getMonth() + 1; // getMonth返回值范围为0-11,因此加上1得到真正的月份
525
-
526
- // 设置起始日期为本月第一天
527
- currentDate.setDate(1);
528
-
529
- // 将起始日期格式化成字符串形式(YYYY-MM-DD)
530
- const startDateStr = `${year}/${month < 10 ? '0' : ''}${month}/01`;
531
-
532
- // 设置结束日期为下个月第一天的前一天
533
- currentDate.setMonth(currentDate.getMonth() + 2);
534
- currentDate.setDate(0);
535
-
536
- // 将结束日期格式化成字符串形式(YYYY-MM-DD)
537
- const endDateStr = `${currentDate.getFullYear()}/${currentDate.getMonth() < 9 ? '0' : ''}${(currentDate.getMonth() + 1)}/01`;
538
- const startDate11 = new Date(Date.parse(startDateStr))
539
- const endDate11 = new Date(new Date(Date.parse(endDateStr)).getTime() - 1000)
540
- const startDate = startDate11.toLocaleDateString() + " " + startDate11.toLocaleTimeString()
541
- const endDate = endDate11.toLocaleDateString() + " " + endDate11.toLocaleTimeString()
542
- console.log(`getCurrentMonth从 ${startDate} 开始,到 ${endDate} 结束`);
543
- return [startDate11, endDate11]
482
+ // 创建一个新的Date对象,表示当前时间
483
+ const currentDate = new Date()
484
+
485
+ // 获取当前年份和月份
486
+ const year = currentDate.getFullYear() // 获取完整的四位年份
487
+ const month = currentDate.getMonth() + 1 // getMonth返回值范围为0-11,因此加上1得到真正的月份
488
+
489
+ // 设置起始日期为本月第一天
490
+ currentDate.setDate(1)
491
+
492
+ // 将起始日期格式化成字符串形式(YYYY-MM-DD)
493
+ const startDateStr = `${year}/${month < 10 ? '0' : ''}${month}/01`
494
+
495
+ // 设置结束日期为下个月第一天的前一天
496
+ currentDate.setMonth(currentDate.getMonth() + 2)
497
+ currentDate.setDate(0)
498
+
499
+ // 将结束日期格式化成字符串形式(YYYY-MM-DD)
500
+ const endDateStr = `${currentDate.getFullYear()}/${currentDate.getMonth() < 9 ? '0' : ''}${
501
+ currentDate.getMonth() + 1
502
+ }/01`
503
+ const startDate11 = new Date(Date.parse(startDateStr))
504
+ const endDate11 = new Date(new Date(Date.parse(endDateStr)).getTime() - 1000)
505
+ const startDate = startDate11.toLocaleDateString() + ' ' + startDate11.toLocaleTimeString()
506
+ const endDate = endDate11.toLocaleDateString() + ' ' + endDate11.toLocaleTimeString()
507
+ console.log(`getCurrentMonth从 ${startDate} 开始,到 ${endDate} 结束`)
508
+ return [startDate11, endDate11]
544
509
  }
545
510
  /**
546
511
  * 获得当前季度第1天和最后一天的日期
547
512
  * 例如:[2023/1/1 00:00:00,2023/3/31 23:59:59]
548
- * @returns
513
+ * @returns
549
514
  */
550
515
  function getCurrentQuarter() {
551
- const currentDate = new Date();
552
- const quarterStartIndex = (currentDate.getMonth() + 3) % 12;
553
- let firstDayOfQuarter; // 存放第一天的Date对象
554
- if (currentDate.getMonth() < quarterStartIndex + 2) {
555
- firstDayOfQuarter = new Date(currentDate.getFullYear(), quarterStartIndex, 1);
556
- } else {
557
- firstDayOfQuarter = new Date(currentDate.getFullYear() + 1, quarterStartIndex, 1);
558
- }
516
+ const currentDate = new Date()
517
+ const quarterStartIndex = (currentDate.getMonth() + 3) % 12
518
+ let firstDayOfQuarter // 存放第一天的Date对象
519
+ if (currentDate.getMonth() < quarterStartIndex + 2) {
520
+ firstDayOfQuarter = new Date(currentDate.getFullYear(), quarterStartIndex, 1)
521
+ } else {
522
+ firstDayOfQuarter = new Date(currentDate.getFullYear() + 1, quarterStartIndex, 1)
523
+ }
559
524
 
560
- let lastDayOfQuarter; // 存放最后一天的Date对象
561
- if (firstDayOfQuarter.getMonth() === 11) {
562
- lastDayOfQuarter = new Date(firstDayOfQuarter.getFullYear() + 1, 0, 0);
563
- } else {
564
- lastDayOfQuarter = new Date(firstDayOfQuarter.getFullYear(), firstDayOfQuarter.getMonth() + 3, 0);
565
- }
566
- lastDayOfQuarter = new Date(lastDayOfQuarter.getTime() + (24 * 60 * 60 * 1000) - 1000)
567
- const startDate = firstDayOfQuarter.toLocaleDateString() + " " + firstDayOfQuarter.toLocaleTimeString()
568
- const endDate = lastDayOfQuarter.toLocaleDateString() + " " + lastDayOfQuarter.toLocaleTimeString()
569
- console.log(`getCurrentQuarter从 ${startDate} 开始,到 ${endDate} 结束`);
570
- return [firstDayOfQuarter, lastDayOfQuarter]
525
+ let lastDayOfQuarter // 存放最后一天的Date对象
526
+ if (firstDayOfQuarter.getMonth() === 11) {
527
+ lastDayOfQuarter = new Date(firstDayOfQuarter.getFullYear() + 1, 0, 0)
528
+ } else {
529
+ lastDayOfQuarter = new Date(firstDayOfQuarter.getFullYear(), firstDayOfQuarter.getMonth() + 3, 0)
530
+ }
531
+ lastDayOfQuarter = new Date(lastDayOfQuarter.getTime() + 24 * 60 * 60 * 1000 - 1000)
532
+ const startDate = firstDayOfQuarter.toLocaleDateString() + ' ' + firstDayOfQuarter.toLocaleTimeString()
533
+ const endDate = lastDayOfQuarter.toLocaleDateString() + ' ' + lastDayOfQuarter.toLocaleTimeString()
534
+ console.log(`getCurrentQuarter从 ${startDate} 开始,到 ${endDate} 结束`)
535
+ return [firstDayOfQuarter, lastDayOfQuarter]
571
536
  }
572
537
  /**
573
538
  * 获得本年的第1天和最后一天的日期
574
539
  * 例如:[2023/1/1 00:00:00,2023/12/31 23:59:59]
575
- * @returns
540
+ * @returns
576
541
  */
577
542
  function getCurrentYear() {
578
- // 创建一个新的日期对象
579
- const currentYear = new Date().getFullYear(); // 获取当前年份
580
-
581
- // 设置为当前年的1月1号(第一天)
582
- let firstDayOfCurrentYear = new Date(currentYear, 0);
583
- firstDayOfCurrentYear.setMonth(0, 1); // 将月份设置为0表示1月
584
-
585
- // 设置为下一年的12月31号(最后一天)
586
- let lastDayOfCurrentYear = new Date(currentYear + 1, 0);
587
- lastDayOfCurrentYear = lastDayOfCurrentYear.getTime() - 1000
588
- lastDayOfCurrentYear = new Date(lastDayOfCurrentYear)
589
- const startDate = firstDayOfCurrentYear.toLocaleDateString() + " " + firstDayOfCurrentYear.toLocaleTimeString()
590
- const endDate = lastDayOfCurrentYear.toLocaleDateString() + " " + lastDayOfCurrentYear.toLocaleTimeString()
591
- console.log(`getCurrentYear从 ${startDate} 开始,到 ${endDate} 结束`);
592
- return [firstDayOfCurrentYear, lastDayOfCurrentYear]
543
+ // 创建一个新的日期对象
544
+ const currentYear = new Date().getFullYear() // 获取当前年份
545
+
546
+ // 设置为当前年的1月1号(第一天)
547
+ let firstDayOfCurrentYear = new Date(currentYear, 0)
548
+ firstDayOfCurrentYear.setMonth(0, 1) // 将月份设置为0表示1月
549
+
550
+ // 设置为下一年的12月31号(最后一天)
551
+ let lastDayOfCurrentYear = new Date(currentYear + 1, 0)
552
+ lastDayOfCurrentYear = lastDayOfCurrentYear.getTime() - 1000
553
+ lastDayOfCurrentYear = new Date(lastDayOfCurrentYear)
554
+ const startDate = firstDayOfCurrentYear.toLocaleDateString() + ' ' + firstDayOfCurrentYear.toLocaleTimeString()
555
+ const endDate = lastDayOfCurrentYear.toLocaleDateString() + ' ' + lastDayOfCurrentYear.toLocaleTimeString()
556
+ console.log(`getCurrentYear从 ${startDate} 开始,到 ${endDate} 结束`)
557
+ return [firstDayOfCurrentYear, lastDayOfCurrentYear]
593
558
  }
594
559
  /**
595
560
  * 获得最近n天的日期[n天前,当前日期]。
596
561
  * 例如:[2024/2/25 00:00:00,2024/2/29 23:59:59]
597
- * @param {} n
562
+ * @param {} n
598
563
  */
599
564
  function getLastNDay(n) {
600
- let currentDate = new Date(); // 创建一个表示今天的Date对象
601
- let year = currentDate.getFullYear(); // 获取完整的四位年份
602
- let month = currentDate.getMonth() + 1; // getMonth返回值范围为0-11,因此加上1得到真正的月份
603
- let date = currentDate.getDate(); // getMonth返回值范围为0-11,因此加上1得到真正的月份
604
- let startDateStr = `${year}/${month < 10 ? '0' : ''}${month}/${date}`;
605
- currentDate = new Date(Date.parse(startDateStr))
606
- currentDate.setDate(currentDate.getDate() + 1)
607
- currentDate = new Date(currentDate.getTime() - 1000)
608
-
609
- let lastNDay = new Date(); // 创建一个表示今天的Date对象
610
- lastNDay.setDate(lastNDay.getDate() - (n - 1));
611
- const lastNYear = lastNDay.getFullYear(); // 获取完整的四位年份
612
- const lastNMonth = lastNDay.getMonth() + 1; // getMonth返回值范围为0-11,因此加上1得到真正的月份
613
- const lastNDate = lastNDay.getDate(); // getMonth返回值范围为0-11,因此加上1得到真正的月份
614
- const endtDateStr = `${lastNYear}/${lastNMonth < 10 ? '0' : ''}${lastNMonth}/${lastNDate}`;
615
- lastNDay = new Date(Date.parse(endtDateStr))
616
-
617
- const startDate = lastNDay.toLocaleDateString() + " " + lastNDay.toLocaleTimeString()
618
- const endDate = currentDate.toLocaleDateString() + " " + currentDate.toLocaleTimeString()
619
- console.log(`getLastNDay从 ${startDate} 开始,到 ${endDate} 结束`);
620
- retur[lastNDay, currentDate]
565
+ let currentDate = new Date() // 创建一个表示今天的Date对象
566
+ let year = currentDate.getFullYear() // 获取完整的四位年份
567
+ let month = currentDate.getMonth() + 1 // getMonth返回值范围为0-11,因此加上1得到真正的月份
568
+ let date = currentDate.getDate() // getMonth返回值范围为0-11,因此加上1得到真正的月份
569
+ let startDateStr = `${year}/${month < 10 ? '0' : ''}${month}/${date}`
570
+ currentDate = new Date(Date.parse(startDateStr))
571
+ currentDate.setDate(currentDate.getDate() + 1)
572
+ currentDate = new Date(currentDate.getTime() - 1000)
573
+
574
+ let lastNDay = new Date() // 创建一个表示今天的Date对象
575
+ lastNDay.setDate(lastNDay.getDate() - (n - 1))
576
+ const lastNYear = lastNDay.getFullYear() // 获取完整的四位年份
577
+ const lastNMonth = lastNDay.getMonth() + 1 // getMonth返回值范围为0-11,因此加上1得到真正的月份
578
+ const lastNDate = lastNDay.getDate() // getMonth返回值范围为0-11,因此加上1得到真正的月份
579
+ const endtDateStr = `${lastNYear}/${lastNMonth < 10 ? '0' : ''}${lastNMonth}/${lastNDate}`
580
+ lastNDay = new Date(Date.parse(endtDateStr))
581
+
582
+ const startDate = lastNDay.toLocaleDateString() + ' ' + lastNDay.toLocaleTimeString()
583
+ const endDate = currentDate.toLocaleDateString() + ' ' + currentDate.toLocaleTimeString()
584
+ console.log(`getLastNDay从 ${startDate} 开始,到 ${endDate} 结束`)
585
+ retur[(lastNDay, currentDate)]
621
586
  }
622
587
  export function getPropValue(
623
- propValue,
624
- entity,
625
- additionalParamMap,
626
- contextParameterMap,
627
- parentEntity,
628
- subEntity,
629
- task
588
+ propValue,
589
+ entity,
590
+ additionalParamMap,
591
+ contextParameterMap,
592
+ parentEntity,
593
+ subEntity,
594
+ task
630
595
  ) {
631
- const pageContext = {entity:{data: entity, context: contextParameterMap, request: additionalParamMap, parent: parentEntity, row: subEntity, task: task}}
632
- return getPropValueNew(propValue,pageContext)
596
+ const pageContext = {
597
+ entity: {
598
+ data: entity,
599
+ context: contextParameterMap,
600
+ request: additionalParamMap,
601
+ parent: parentEntity,
602
+ row: subEntity,
603
+ task: task
604
+ }
605
+ }
606
+ return getPropValueNew(propValue, pageContext)
633
607
  }
634
608
 
635
- function getAdditionalParamMap(pageContext){
636
- if(pageContext && pageContext.entity){
637
- let additionalParamMap = pageContext.entity.page
638
- if(!additionalParamMap){
639
- additionalParamMap = {}
640
- }
641
- const requestMap = pageContext.entity.request
642
- if (requestMap) {
643
- Object.assign(additionalParamMap, requestMap)
644
- }
645
- return additionalParamMap
609
+ function getAdditionalParamMap(pageContext) {
610
+ if (pageContext && pageContext.entity) {
611
+ let additionalParamMap = pageContext.entity.page
612
+ if (!additionalParamMap) {
613
+ additionalParamMap = {}
646
614
  }
615
+ const requestMap = pageContext.entity.request
616
+ if (requestMap) {
617
+ Object.assign(additionalParamMap, requestMap)
618
+ }
619
+ return additionalParamMap
647
620
  }
621
+ }
648
622
 
649
- export function getPropValueNew(
650
- propValue,
651
- pageContext
652
- ) {
653
- let value = null
654
- if (propValue && propValue !== null && propValue !== '') {
655
- const entity = pageContext && pageContext.entity?pageContext.entity.data:null
656
- const additionalParamMap = getAdditionalParamMap(pageContext)
657
- const contextParameterMap = pageContext && pageContext.entity?pageContext.entity.context: null
658
- const parentEntity = pageContext && pageContext.entity?(pageContext.entity.parent?pageContext.entity.parent:pageContext.entity.data): null
659
- const subEntity = pageContext && pageContext.entity?pageContext.entity.row: null
660
- const task = pageContext && pageContext.entity?pageContext.entity.task: null
661
- const system = pageContext && pageContext.entity?pageContext.entity.system: null
662
- if (propValue === 'null') {
663
- value = null
664
- } else if (
665
- propValue.includes('${context.') ||
666
- propValue.includes('${request.') ||
667
- propValue.includes('${obj.')||
668
- propValue.includes('${data.')
623
+ export function getPropValueNew(propValue, pageContext) {
624
+ let value = null
625
+ if (propValue && propValue !== null && propValue !== '') {
626
+ const entity = pageContext && pageContext.entity ? pageContext.entity.data : null
627
+ const additionalParamMap = getAdditionalParamMap(pageContext)
628
+ const contextParameterMap = pageContext && pageContext.entity ? pageContext.entity.context : null
629
+ const parentEntity =
630
+ pageContext && pageContext.entity
631
+ ? pageContext.entity.parent
632
+ ? pageContext.entity.parent
633
+ : pageContext.entity.data
634
+ : null
635
+ const subEntity = pageContext && pageContext.entity ? pageContext.entity.row : null
636
+ const task = pageContext && pageContext.entity ? pageContext.entity.task : null
637
+ const system = pageContext && pageContext.entity ? pageContext.entity.system : null
638
+ if (propValue === 'null') {
639
+ value = null
640
+ } else if (
641
+ propValue.includes('${context.') ||
642
+ propValue.includes('${request.') ||
643
+ propValue.includes('${obj.') ||
644
+ propValue.includes('${data.')
645
+ ) {
646
+ // 填写的固定值
647
+ if (propValue.includes('${context.')) {
648
+ propValue = propValue.replace('${context.', '').replace('}', '')
649
+ value = getContextValue(contextParameterMap, propValue)
650
+ } else if (propValue.includes('${request.') && propValue !== '${request.term}') {
651
+ // ${request.term}表示页面中手动输入的值
652
+ propValue = propValue.replace('${request.', '').replace('}', '')
653
+ if (
654
+ additionalParamMap &&
655
+ additionalParamMap != null &&
656
+ Object.keys(additionalParamMap).indexOf(propValue) >= 0 &&
657
+ additionalParamMap[propValue] &&
658
+ additionalParamMap[propValue] !== null
669
659
  ) {
670
- // 填写的固定值
671
- if (propValue.includes('${context.')) {
672
- propValue = propValue.replace('${context.', '').replace('}', '')
673
- value = getContextValue(contextParameterMap, propValue)
674
- } else if (
675
- propValue.includes('${request.') &&
676
- propValue !== '${request.term}'
677
- ) {
678
- // ${request.term}表示页面中手动输入的值
679
- propValue = propValue.replace('${request.', '').replace('}', '')
680
- if (
681
- additionalParamMap &&
682
- additionalParamMap != null &&
683
- Object.keys(additionalParamMap).indexOf(propValue) >= 0 &&
684
- additionalParamMap[propValue] &&
685
- additionalParamMap[propValue] !== null
686
- ) {
687
- value = additionalParamMap[propValue]
688
- } else {
689
- value = null
690
- }
691
- } else if (propValue.includes('${obj.')) {
692
- if (entity === undefined || entity == null) {
693
- value = null
694
- } else {
695
- const propName = propValue.replace('${obj.', '').replace('}', '')
696
- value = getEntityFieldValue(entity, propName)
697
- }
698
- } else if (propValue.includes('${data.')) {
699
- if (entity === undefined || entity == null) {
700
- value = null
701
- } else {
702
- const propName = propValue.replace('${data.', '').replace('}', '')
703
- value = getEntityFieldValue(entity, propName)
704
- }
705
- }
706
- } else if (propValue.includes('${parent.')) {
707
- if (parentEntity === undefined || parentEntity == null) {
708
- value = null
709
- } else {
710
- const propName = propValue.replace('${parent.', '').replace('}', '')
711
- value = getEntityFieldValue(parentEntity, propName)
712
- }
713
- }else if (propValue.includes('${system.')) {
714
- if (system === undefined || system == null) {
715
- value = null
716
- } else {
717
- const propName = propValue.replace('${system.', '').replace('}', '')
718
- value = getEntityFieldValue(system, propName)
719
- }
720
- } else if (propValue.includes('${task.')) {
721
- if (task === undefined || task == null) {
722
- value = null
723
- } else {
724
- const propName = propValue.replace('${task.', '').replace('}', '')
725
- value = getEntityFieldValue(task, propName)
726
- }
727
- } else if (propValue.includes('${subObj.')) {
728
- if (subEntity === undefined || subEntity == null) {
729
- value = null
730
- } else {
731
- const propName = propValue.replace('${subObj.', '').replace('}', '')
732
- value = getEntityFieldValue(subEntity, propName)
733
- }
734
- }else if (propValue.includes('${input.') ) {
735
- value = propValue.replace('${input.', '').replace('}', '')
736
- } else if (propValue.includes('${fixed.')) {
737
- value = propValue.replace('${fixed.', '').replace('}', '')
660
+ value = additionalParamMap[propValue]
661
+ } else {
662
+ value = null
663
+ }
664
+ } else if (propValue.includes('${obj.')) {
665
+ if (entity === undefined || entity == null) {
666
+ value = null
667
+ } else {
668
+ const propName = propValue.replace('${obj.', '').replace('}', '')
669
+ value = getEntityFieldValue(entity, propName)
670
+ }
671
+ } else if (propValue.includes('${data.')) {
672
+ if (entity === undefined || entity == null) {
673
+ value = null
738
674
  } else {
739
- value = propValue
675
+ const propName = propValue.replace('${data.', '').replace('}', '')
676
+ value = getEntityFieldValue(entity, propName)
740
677
  }
678
+ }
679
+ } else if (propValue.includes('${parent.')) {
680
+ if (parentEntity === undefined || parentEntity == null) {
681
+ value = null
682
+ } else {
683
+ const propName = propValue.replace('${parent.', '').replace('}', '')
684
+ value = getEntityFieldValue(parentEntity, propName)
685
+ }
686
+ } else if (propValue.includes('${system.')) {
687
+ if (system === undefined || system == null) {
688
+ value = null
689
+ } else {
690
+ const propName = propValue.replace('${system.', '').replace('}', '')
691
+ value = getEntityFieldValue(system, propName)
692
+ }
693
+ } else if (propValue.includes('${task.')) {
694
+ if (task === undefined || task == null) {
695
+ value = null
696
+ } else {
697
+ const propName = propValue.replace('${task.', '').replace('}', '')
698
+ value = getEntityFieldValue(task, propName)
699
+ }
700
+ } else if (propValue.includes('${subObj.')) {
701
+ if (subEntity === undefined || subEntity == null) {
702
+ value = null
703
+ } else {
704
+ const propName = propValue.replace('${subObj.', '').replace('}', '')
705
+ value = getEntityFieldValue(subEntity, propName)
706
+ }
707
+ } else if (propValue.includes('${input.')) {
708
+ value = propValue.replace('${input.', '').replace('}', '')
709
+ } else if (propValue.includes('${fixed.')) {
710
+ value = propValue.replace('${fixed.', '').replace('}', '')
711
+ } else {
712
+ value = propValue
741
713
  }
742
- return value
714
+ }
715
+ return value
743
716
  }
744
717
 
745
718
  /**
@@ -750,41 +723,27 @@ function getAdditionalParamMap(pageContext){
750
723
  * @param {*} contextParameter
751
724
  * @returns
752
725
  */
753
- export function analysisValue(
754
- conditionValue,
755
- entity,
756
- additionalParameter,
757
- contextParameter,
758
- pageContext
759
- ) {
760
- if (!conditionValue) {
761
- return
762
- }
763
- let label = ''
764
- const split = conditionValue.split('-#-#')
765
- if (split != null && split.length > 0) {
766
- split.forEach((item) => {
767
- let value
768
- if(pageContext){
769
- value = getPropValueNew(
770
- item,
771
- pageContext
772
- )
773
- } else {
774
- value = getPropValue(
775
- item,
776
- entity,
777
- additionalParameter,
778
- contextParameter
779
- )
780
- }
781
- if (!value || value === null) {
782
- value = ''
783
- }
784
- label += value
785
- })
786
- }
787
- return label
726
+ export function analysisValue(conditionValue, entity, additionalParameter, contextParameter, pageContext) {
727
+ if (!conditionValue) {
728
+ return
729
+ }
730
+ let label = ''
731
+ const split = conditionValue.split('-#-#')
732
+ if (split != null && split.length > 0) {
733
+ split.forEach((item) => {
734
+ let value
735
+ if (pageContext) {
736
+ value = getPropValueNew(item, pageContext)
737
+ } else {
738
+ value = getPropValue(item, entity, additionalParameter, contextParameter)
739
+ }
740
+ if (!value || value === null) {
741
+ value = ''
742
+ }
743
+ label += value
744
+ })
745
+ }
746
+ return label
788
747
  }
789
748
 
790
749
  /**
@@ -794,29 +753,29 @@ export function analysisValue(
794
753
  * @param {*} value
795
754
  */
796
755
  export function setEntityFieldValue(entity, prop, value) {
797
- if (prop && entity) {
798
- if (prop && prop.indexOf('.') > 0) {
799
- const parentObj = getParentObjectUtil(prop, entity)
800
- if (parentObj) {
801
- const subProp = prop.substring(prop.lastIndexOf('.') + 1)
802
- if (parentObj[subProp] === undefined) {
803
- // 动态对象属性赋值,防止属性不存在,导致属性无法赋值问题
804
- parentObj[prop.substring(prop.lastIndexOf('.') + 1)] = value
805
- } else {
806
- // 静态对象属性赋值,提高性能
807
- parentObj[subProp] = value
808
- }
809
- }
756
+ if (prop && entity) {
757
+ if (prop && prop.indexOf('.') > 0) {
758
+ const parentObj = getParentObjectUtil(prop, entity)
759
+ if (parentObj) {
760
+ const subProp = prop.substring(prop.lastIndexOf('.') + 1)
761
+ if (parentObj[subProp] === undefined) {
762
+ // 动态对象属性赋值,防止属性不存在,导致属性无法赋值问题
763
+ parentObj[prop.substring(prop.lastIndexOf('.') + 1)] = value
810
764
  } else {
811
- if (entity[prop] === undefined || entity[prop] === null) {
812
- // 动态对象属性赋值,防止属性不存在,导致属性无法赋值问题
813
- entity[prop] = value
814
- } else {
815
- // 静态对象属性赋值,提高性能
816
- entity[prop] = value
817
- }
765
+ // 静态对象属性赋值,提高性能
766
+ parentObj[subProp] = value
818
767
  }
768
+ }
769
+ } else {
770
+ if (entity[prop] === undefined || entity[prop] === null) {
771
+ // 动态对象属性赋值,防止属性不存在,导致属性无法赋值问题
772
+ entity[prop] = value
773
+ } else {
774
+ // 静态对象属性赋值,提高性能
775
+ entity[prop] = value
776
+ }
819
777
  }
778
+ }
820
779
  }
821
780
 
822
781
  /**
@@ -826,13 +785,13 @@ export function setEntityFieldValue(entity, prop, value) {
826
785
  * @returns
827
786
  */
828
787
  export function getEntityFieldValueWithOutCase(entity, prop) {
829
- if (prop && prop.indexOf('.') > 0) {
830
- const parentOjbect = getParentObjectUtil(prop, entity)
831
- const modelName = prop.substring(prop.lastIndexOf('.') + 1)
832
- return parentOjbect[modelName]
833
- } else {
834
- return entity[prop]
835
- }
788
+ if (prop && prop.indexOf('.') > 0) {
789
+ const parentOjbect = getParentObjectUtil(prop, entity)
790
+ const modelName = prop.substring(prop.lastIndexOf('.') + 1)
791
+ return parentOjbect[modelName]
792
+ } else {
793
+ return entity[prop]
794
+ }
836
795
  }
837
796
 
838
797
  /**
@@ -842,68 +801,71 @@ export function getEntityFieldValueWithOutCase(entity, prop) {
842
801
  * @returns
843
802
  */
844
803
  export function getEntityFieldValue(entity, prop, isLowerCase) {
845
- let value = getEntityFieldValueWithCase(entity, prop)
846
- if (value === undefined || value === null) {
847
- // 兼容mysql数据库
848
- value = getEntityFieldValueWithCase(entity, prop.toLowerCase())
849
- }
850
- if (value === undefined || (value === null && isLowerCase === undefined)) {
851
- // 兼容oracle数据库
852
- value = getEntityFieldValueWithCase(entity, prop.toUpperCase())
853
- }
854
- return value
804
+ if (!prop) {
805
+ return null
806
+ }
807
+ let value = getEntityFieldValueWithCase(entity, prop)
808
+ if (value === undefined || value === null) {
809
+ // 兼容mysql数据库
810
+ value = getEntityFieldValueWithCase(entity, prop.toLowerCase())
811
+ }
812
+ if (value === undefined || (value === null && isLowerCase === undefined)) {
813
+ // 兼容oracle数据库
814
+ value = getEntityFieldValueWithCase(entity, prop.toUpperCase())
815
+ }
816
+ return value
855
817
  }
856
818
 
857
819
  function getEntityFieldValueWithCase(entity, prop) {
858
- if (prop && prop.indexOf('.') > 0) {
859
- const parentOjbect = getParentObjectUtil(prop, entity)
860
- const modelName = prop.substring(prop.lastIndexOf('.') + 1)
861
- return parentOjbect[modelName]
862
- } else {
863
- return entity[prop]
864
- }
820
+ if (prop && prop.indexOf('.') > 0) {
821
+ const parentOjbect = getParentObjectUtil(prop, entity)
822
+ const modelName = prop.substring(prop.lastIndexOf('.') + 1)
823
+ return parentOjbect[modelName]
824
+ } else {
825
+ return entity[prop]
826
+ }
865
827
  }
866
828
 
867
829
  export function getParentObjectUtil(prop, entity) {
868
- const nestedProp = prop.split('.')
869
- // 属性只有一个时父对象就是models
870
- if (nestedProp.length === 1) {
871
- return entity
872
- } else {
873
- let parentObject
874
- // 属性超过2个时先找到最后一层属性的父对象
875
- for (let i = 0; i < nestedProp.length - 1; i++) {
876
- if (i === 0) {
877
- parentObject = getParentModelProp(nestedProp[i], entity)
878
- } else {
879
- parentObject = getParentModelProp(nestedProp[i], parentObject)
880
- }
881
- }
882
- return parentObject
830
+ const nestedProp = prop.split('.')
831
+ // 属性只有一个时父对象就是models
832
+ if (nestedProp.length === 1) {
833
+ return entity
834
+ } else {
835
+ let parentObject
836
+ // 属性超过2个时先找到最后一层属性的父对象
837
+ for (let i = 0; i < nestedProp.length - 1; i++) {
838
+ if (i === 0) {
839
+ parentObject = getParentModelProp(nestedProp[i], entity)
840
+ } else {
841
+ parentObject = getParentModelProp(nestedProp[i], parentObject)
842
+ }
883
843
  }
844
+ return parentObject
845
+ }
884
846
  }
885
847
 
886
848
  function getParentModelProp(prop, parentObj) {
887
- let myPparentObject = getParentModelPropWithCase(prop, parentObj)
888
- if (myPparentObject === undefined) {
889
- // 兼容mysql数据库
890
- myPparentObject = getParentModelPropWithCase(prop.toLowerCase(), parentObj)
891
- }
892
- if (myPparentObject === undefined) {
893
- // 兼容oracle数据库
894
- myPparentObject = getParentModelPropWithCase(prop.toUpperCase(), parentObj)
895
- }
896
- return myPparentObject
849
+ let myPparentObject = getParentModelPropWithCase(prop, parentObj)
850
+ if (myPparentObject === undefined) {
851
+ // 兼容mysql数据库
852
+ myPparentObject = getParentModelPropWithCase(prop.toLowerCase(), parentObj)
853
+ }
854
+ if (myPparentObject === undefined) {
855
+ // 兼容oracle数据库
856
+ myPparentObject = getParentModelPropWithCase(prop.toUpperCase(), parentObj)
857
+ }
858
+ return myPparentObject
897
859
  }
898
860
 
899
861
  function getParentModelPropWithCase(prop, parentObj) {
900
- if (!parentObj) {
901
- parentObj = {}
902
- }
903
- if (!parentObj[prop] && !parentObj[prop.toUpperCase()]) {
904
- parentObj[prop] = {}
905
- }
906
- return parentObj[prop]
862
+ if (!parentObj) {
863
+ parentObj = {}
864
+ }
865
+ if (!parentObj[prop] && !parentObj[prop.toUpperCase()]) {
866
+ parentObj[prop] = {}
867
+ }
868
+ return parentObj[prop]
907
869
  }
908
870
 
909
871
  /**
@@ -912,66 +874,53 @@ function getParentModelPropWithCase(prop, parentObj) {
912
874
  * @returns
913
875
  */
914
876
  export function findSystemInfoByCode(systemCode) {
915
- return new Promise((resolve, reject) => {
916
- if (!systemCode) {
917
- systemCode = window.$vueApp.config.globalProperties.systemCode
877
+ return new Promise((resolve, reject) => {
878
+ if (!systemCode) {
879
+ systemCode = window.$vueApp.config.globalProperties.systemCode
880
+ }
881
+
882
+ window.$vueApp.config.globalProperties.$http
883
+ .get(window.$vueApp.config.globalProperties.baseAPI + '/component/business-systems/' + systemCode)
884
+ .then((system) => {
885
+ if (system) {
886
+ resolve({
887
+ zh_CN: system.name,
888
+ en_US: system.enName,
889
+ frontendUrl: system.frontendUrl
890
+ })
891
+ } else {
892
+ resolve('系统:' + systemCode + '不存在')
918
893
  }
919
-
920
- window.$vueApp.config.globalProperties.$http
921
- .get(
922
- window.$vueApp.config.globalProperties.baseAPI +
923
- '/component/business-systems/' +
924
- systemCode
925
- )
926
- .then((system) => {
927
- if (system) {
928
- resolve({
929
- zh_CN: system.name,
930
- en_US: system.enName,
931
- frontendUrl: system.frontendUrl,
932
- })
933
- } else {
934
- resolve('系统:' + systemCode + '不存在')
935
- }
936
- })
937
- .catch((error) => {
938
- reject(error)
939
- })
940
- })
894
+ })
895
+ .catch((error) => {
896
+ reject(error)
897
+ })
898
+ })
941
899
  }
942
900
 
943
901
  export function getPropNameWhenJoinTable(prop, isJoinTable, tableName) {
944
- if (prop && isJoinTable !== undefined && isJoinTable === true) {
945
- // 关联表时将点改成下划线,如果没点,则表示是主表字段,拼接主表tableName,因为列表组件中是这样处理的
946
- const replaceDot = '__'
947
- if (prop.indexOf('.') > 0) {
948
- prop = prop.replace('.', replaceDot)
949
- } else {
950
- if (
951
- tableName &&
952
- tableName !== null &&
953
- tableName !== '' &&
954
- prop.indexOf(tableName + replaceDot) < 0
955
- ) {
956
- // 如果属性名没有拼接表名才需要拼接
957
- prop = tableName + replaceDot + prop
958
- }
959
- }
902
+ if (prop && isJoinTable !== undefined && isJoinTable === true) {
903
+ // 关联表时将点改成下划线,如果没点,则表示是主表字段,拼接主表tableName,因为列表组件中是这样处理的
904
+ const replaceDot = '__'
905
+ if (prop.indexOf('.') > 0) {
906
+ prop = prop.replace('.', replaceDot)
907
+ } else {
908
+ if (tableName && tableName !== null && tableName !== '' && prop.indexOf(tableName + replaceDot) < 0) {
909
+ // 如果属性名没有拼接表名才需要拼接
910
+ prop = tableName + replaceDot + prop
911
+ }
960
912
  }
961
- return prop
913
+ }
914
+ return prop
962
915
  }
963
916
 
964
917
  export function isImage(fileName) {
965
- // const fileType = fileName.substring(fileName.lastIndexOf('.'), fileName.length).toLowerCase()
966
- // const imageTypes = ['.jpg', '.JPG', '.png', '.bmp', '.BMP', '.jpeg', '.gif', '.psd', '.tif', '.tga', '.svg', '.eps']
967
- // const index = imageTypes.indexOf(fileType)
968
- if (fileName &&
969
- /\.(jpg|JPG|jpeg|JPEG|png|PNG|gif|GIF|bmp|BMP|psd|PSD|tif|TIF)$/.test(
970
- fileName
971
- )
972
- ) {
973
- return true
974
- } else {
975
- return false
976
- }
918
+ // const fileType = fileName.substring(fileName.lastIndexOf('.'), fileName.length).toLowerCase()
919
+ // const imageTypes = ['.jpg', '.JPG', '.png', '.bmp', '.BMP', '.jpeg', '.gif', '.psd', '.tif', '.tga', '.svg', '.eps']
920
+ // const index = imageTypes.indexOf(fileType)
921
+ if (fileName && /\.(jpg|JPG|jpeg|JPEG|png|PNG|gif|GIF|bmp|BMP|psd|PSD|tif|TIF)$/.test(fileName)) {
922
+ return true
923
+ } else {
924
+ return false
925
+ }
977
926
  }