agilebuilder-ui 1.1.35-sit3 → 1.1.35

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,45 +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(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
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
61
+ })
62
+ })
63
+ }
64
+ if (!options) {
65
+ options = []
66
+ }
67
+ resolve(options)
61
68
  })
62
- })
63
- }
64
- if (!options) {
65
- options = []
66
- }
67
- resolve(options)
68
- })
69
- .catch((error) => {
70
- reject(error)
71
- })
72
- })
69
+ .catch((error) => {
70
+ reject(error)
71
+ })
72
+ })
73
73
  }
74
74
 
75
75
  /**
@@ -80,84 +80,84 @@ export function findOptionsByDynamicDataSource(
80
80
  * @returns
81
81
  */
82
82
  export function findDynamicDataSourceByCode(
83
- dynamicSourceCode,
84
- searchText,
85
- entity,
86
- additionalParameterStr,
87
- searchParam
88
- ) {
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 = {
83
+ dynamicSourceCode,
105
84
  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
130
-
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) => {
150
- reject(error)
151
- })
152
- } else {
153
- resolve(result)
154
- }
155
- })
156
- .catch((error) => {
157
- reject(error)
158
- })
85
+ entity,
86
+ additionalParameterStr,
87
+ searchParam
88
+ ) {
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
159
103
  }
160
- })
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
130
+
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) => {
150
+ reject(error)
151
+ })
152
+ } else {
153
+ resolve(result)
154
+ }
155
+ })
156
+ .catch((error) => {
157
+ reject(error)
158
+ })
159
+ }
160
+ })
161
161
  }
162
162
 
163
163
  /**
@@ -171,233 +171,233 @@ export function findDynamicDataSourceByCode(
171
171
  * @returns
172
172
  */
173
173
  export function analysisCondition(
174
- conditionListJson,
175
- entity,
176
- additionalParameter,
177
- contextParameter,
178
- isSql,
179
- tableName,
180
- parentFormData,
181
- pageContext
182
- ) {
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(
174
+ conditionListJson,
220
175
  entity,
221
- conditionList,
176
+ additionalParameter,
177
+ contextParameter,
222
178
  isSql,
223
179
  tableName,
224
- additionalParameterMap,
225
- contextParameterMap,
226
180
  parentFormData,
227
181
  pageContext
228
- )
182
+ ) {
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(
220
+ entity,
221
+ conditionList,
222
+ isSql,
223
+ tableName,
224
+ additionalParameterMap,
225
+ contextParameterMap,
226
+ parentFormData,
227
+ pageContext
228
+ )
229
229
  }
230
230
 
231
231
  function parseCondition(
232
- entity,
233
- conditionList,
234
- isSql,
235
- tableName,
236
- additionalParamMap,
237
- contextParameterMap,
238
- parentFormData,
239
- pageContext
232
+ entity,
233
+ conditionList,
234
+ isSql,
235
+ tableName,
236
+ additionalParamMap,
237
+ contextParameterMap,
238
+ parentFormData,
239
+ pageContext
240
240
  ) {
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)
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
271
254
  }
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
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)
271
+ }
272
+ }
316
273
  } else {
317
- conditionResult = false
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
+ }
318
285
  }
319
- }
320
- }
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', '||')
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)
335
297
  }
336
- conditions += joinSign + ' '
337
- }
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
- }
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
+ } else {
317
+ conditionResult = false
318
+ }
319
+ }
320
+ }
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
+ }
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
+ }
347
347
  }
348
348
 
349
349
  const REPLACE_DOT = '__'
350
350
 
351
351
  function getValue(entityData, fieldName, isSql) {
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)
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)
363
+ }
364
+ }
365
+ }
363
366
  }
364
- }
365
367
  }
366
- }
367
368
  }
368
- }
369
- return value
369
+ return value
370
370
  }
371
371
 
372
372
  export function getValueByField(entityData, fieldName) {
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
- }
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
+ }
383
+ }
384
+ return value
383
385
  }
384
- return value
385
- }
386
386
  }
387
387
 
388
388
  function getSubEntityValue(entityData, fieldName) {
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)
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)
398
+ }
398
399
  }
399
- }
400
- return value
400
+ return value
401
401
  }
402
402
 
403
403
  /**
@@ -408,18 +408,18 @@ function getSubEntityValue(entityData, fieldName) {
408
408
  * @return
409
409
  */
410
410
  function getSubEntityFieldValue(subEntityData, fieldName) {
411
- if (subEntityData === undefined || subEntityData === null) {
412
- return null
413
- }
414
- return subEntityData[fieldName]
411
+ if (subEntityData === undefined || subEntityData === null) {
412
+ return null
413
+ }
414
+ return subEntityData[fieldName]
415
415
  }
416
416
 
417
417
  function getContextValue(contextParameterMap, propValue) {
418
- let value = getLastNDate(propValue)
419
- if (contextParameterMap) {
420
- value = contextParameterMap[propValue]
421
- }
422
- return value
418
+ let value = getLastNDate(propValue)
419
+ if (contextParameterMap) {
420
+ value = contextParameterMap[propValue]
421
+ }
422
+ return value
423
423
  }
424
424
  /**
425
425
  * 获得最近n天的开始日期和结束日期集合
@@ -427,33 +427,33 @@ function getContextValue(contextParameterMap, propValue) {
427
427
  * @returns [startDate,endDate],例如:[2024/2/26 00:00:00,2023/3/3 23:59:59]
428
428
  */
429
429
  export function getLastNDate(propValue) {
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
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
457
457
  }
458
458
  /**
459
459
  * 获得当前周的周一和周日的的日期
@@ -461,17 +461,17 @@ export function getLastNDate(propValue) {
461
461
  * @returns
462
462
  */
463
463
  function getCurrentWeek() {
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]
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]
475
475
  }
476
476
  /**
477
477
  * 获得当前月第1天和最后1天的日期
@@ -479,33 +479,33 @@ function getCurrentWeek() {
479
479
  * @returns [xxx,xxx]
480
480
  */
481
481
  function getCurrentMonth() {
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]
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]
509
509
  }
510
510
  /**
511
511
  * 获得当前季度第1天和最后一天的日期
@@ -513,26 +513,26 @@ function getCurrentMonth() {
513
513
  * @returns
514
514
  */
515
515
  function getCurrentQuarter() {
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
- }
524
-
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]
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
+ }
524
+
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]
536
536
  }
537
537
  /**
538
538
  * 获得本年的第1天和最后一天的日期
@@ -540,21 +540,21 @@ function getCurrentQuarter() {
540
540
  * @returns
541
541
  */
542
542
  function getCurrentYear() {
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]
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]
558
558
  }
559
559
  /**
560
560
  * 获得最近n天的日期[n天前,当前日期]。
@@ -562,163 +562,157 @@ function getCurrentYear() {
562
562
  * @param {} n
563
563
  */
564
564
  function getLastNDay(n) {
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)]
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)]
586
586
  }
587
587
  export function getPropValue(
588
- propValue,
589
- entity,
590
- additionalParamMap,
591
- contextParameterMap,
592
- parentEntity,
593
- subEntity,
594
- task
588
+ propValue,
589
+ entity,
590
+ additionalParamMap,
591
+ contextParameterMap,
592
+ parentEntity,
593
+ subEntity,
594
+ task
595
595
  ) {
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)
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)
607
607
  }
608
608
 
609
609
  function getAdditionalParamMap(pageContext) {
610
- if (pageContext && pageContext.entity) {
611
- let additionalParamMap = pageContext.entity.page
612
- if (!additionalParamMap) {
613
- additionalParamMap = {}
614
- }
615
- const requestMap = pageContext.entity.request
616
- if (requestMap) {
617
- Object.assign(additionalParamMap, requestMap)
610
+ if (pageContext && pageContext.entity) {
611
+ let additionalParamMap = pageContext.entity.page
612
+ if (!additionalParamMap) {
613
+ additionalParamMap = {}
614
+ }
615
+ const requestMap = pageContext.entity.request
616
+ if (requestMap) {
617
+ Object.assign(additionalParamMap, requestMap)
618
+ }
619
+ return additionalParamMap
618
620
  }
619
- return additionalParamMap
620
- }
621
621
  }
622
622
 
623
- export function getPropValueNew(propValue, pageContext, row) {
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 (propValue.startsWith('${row.')) {
641
- // 处理表格行数据 ${row.fieldName}
642
- if (row) {
643
- const propName = propValue.replace('${row.', '').replace('}', '')
644
- value = getEntityFieldValue(row, propName)
645
- }
646
- } else if (
647
- propValue.includes('${context.') ||
648
- propValue.includes('${request.') ||
649
- propValue.includes('${obj.') ||
650
- propValue.includes('${data.')
651
- ) {
652
- // 填写的固定值
653
- if (propValue.includes('${context.')) {
654
- propValue = propValue.replace('${context.', '').replace('}', '')
655
- value = getContextValue(contextParameterMap, propValue)
656
- } else if (propValue.includes('${request.') && propValue !== '${request.term}') {
657
- // ${request.term}表示页面中手动输入的值
658
- propValue = propValue.replace('${request.', '').replace('}', '')
659
- if (
660
- additionalParamMap &&
661
- additionalParamMap != null &&
662
- Object.keys(additionalParamMap).indexOf(propValue) >= 0 &&
663
- additionalParamMap[propValue] &&
664
- additionalParamMap[propValue] !== null
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.')
665
645
  ) {
666
- value = additionalParamMap[propValue]
667
- } else {
668
- value = null
669
- }
670
- } else if (propValue.includes('${obj.')) {
671
- if (entity === undefined || entity == null) {
672
- value = null
673
- } else {
674
- const propName = propValue.replace('${obj.', '').replace('}', '')
675
- value = getEntityFieldValue(entity, propName)
676
- }
677
- } else if (propValue.includes('${data.')) {
678
- if (entity === undefined || entity == null) {
679
- value = null
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
659
+ ) {
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
674
+ } else {
675
+ const propName = propValue.replace('${data.', '').replace('}', '')
676
+ value = getEntityFieldValue(entity, propName)
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('}', '')
680
711
  } else {
681
- const propName = propValue.replace('${data.', '').replace('}', '')
682
- value = getEntityFieldValue(entity, propName)
712
+ value = propValue
683
713
  }
684
- }
685
- } else if (propValue.includes('${parent.')) {
686
- if (parentEntity === undefined || parentEntity == null) {
687
- value = null
688
- } else {
689
- const propName = propValue.replace('${parent.', '').replace('}', '')
690
- value = getEntityFieldValue(parentEntity, propName)
691
- }
692
- } else if (propValue.includes('${system.')) {
693
- if (system === undefined || system == null) {
694
- value = null
695
- } else {
696
- const propName = propValue.replace('${system.', '').replace('}', '')
697
- value = getEntityFieldValue(system, propName)
698
- }
699
- } else if (propValue.includes('${task.')) {
700
- if (task === undefined || task == null) {
701
- value = null
702
- } else {
703
- const propName = propValue.replace('${task.', '').replace('}', '')
704
- value = getEntityFieldValue(task, propName)
705
- }
706
- } else if (propValue.includes('${subObj.')) {
707
- if (subEntity === undefined || subEntity == null) {
708
- value = null
709
- } else {
710
- const propName = propValue.replace('${subObj.', '').replace('}', '')
711
- value = getEntityFieldValue(subEntity, propName)
712
- }
713
- } else if (propValue.includes('${input.')) {
714
- value = propValue.replace('${input.', '').replace('}', '')
715
- } else if (propValue.includes('${fixed.')) {
716
- value = propValue.replace('${fixed.', '').replace('}', '')
717
- } else {
718
- value = propValue
719
714
  }
720
- }
721
- return value
715
+ return value
722
716
  }
723
717
 
724
718
  /**
@@ -730,26 +724,26 @@ export function getPropValueNew(propValue, pageContext, row) {
730
724
  * @returns
731
725
  */
732
726
  export function analysisValue(conditionValue, entity, additionalParameter, contextParameter, pageContext) {
733
- if (!conditionValue) {
734
- return
735
- }
736
- let label = ''
737
- const split = conditionValue.split('-#-#')
738
- if (split != null && split.length > 0) {
739
- split.forEach((item) => {
740
- let value
741
- if (pageContext) {
742
- value = getPropValueNew(item, pageContext, entity)
743
- } else {
744
- value = getPropValue(item, entity, additionalParameter, contextParameter)
745
- }
746
- if (!value || value === null) {
747
- value = ''
748
- }
749
- label += value
750
- })
751
- }
752
- return label
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
753
747
  }
754
748
 
755
749
  /**
@@ -759,29 +753,29 @@ export function analysisValue(conditionValue, entity, additionalParameter, conte
759
753
  * @param {*} value
760
754
  */
761
755
  export function setEntityFieldValue(entity, prop, value) {
762
- if (prop && entity) {
763
- if (prop && prop.indexOf('.') > 0) {
764
- const parentObj = getParentObjectUtil(prop, entity)
765
- if (parentObj) {
766
- const subProp = prop.substring(prop.lastIndexOf('.') + 1)
767
- if (parentObj[subProp] === undefined) {
768
- // 动态对象属性赋值,防止属性不存在,导致属性无法赋值问题
769
- parentObj[prop.substring(prop.lastIndexOf('.') + 1)] = value
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
764
+ } else {
765
+ // 静态对象属性赋值,提高性能
766
+ parentObj[subProp] = value
767
+ }
768
+ }
770
769
  } else {
771
- // 静态对象属性赋值,提高性能
772
- parentObj[subProp] = value
770
+ if (entity[prop] === undefined || entity[prop] === null) {
771
+ // 动态对象属性赋值,防止属性不存在,导致属性无法赋值问题
772
+ entity[prop] = value
773
+ } else {
774
+ // 静态对象属性赋值,提高性能
775
+ entity[prop] = value
776
+ }
773
777
  }
774
- }
775
- } else {
776
- if (entity[prop] === undefined || entity[prop] === null) {
777
- // 动态对象属性赋值,防止属性不存在,导致属性无法赋值问题
778
- entity[prop] = value
779
- } else {
780
- // 静态对象属性赋值,提高性能
781
- entity[prop] = value
782
- }
783
- }
784
- }
778
+ }
785
779
  }
786
780
 
787
781
  /**
@@ -791,13 +785,13 @@ export function setEntityFieldValue(entity, prop, value) {
791
785
  * @returns
792
786
  */
793
787
  export function getEntityFieldValueWithOutCase(entity, prop) {
794
- if (prop && prop.indexOf('.') > 0) {
795
- const parentOjbect = getParentObjectUtil(prop, entity)
796
- const modelName = prop.substring(prop.lastIndexOf('.') + 1)
797
- return parentOjbect[modelName]
798
- } else {
799
- return entity[prop]
800
- }
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
+ }
801
795
  }
802
796
 
803
797
  /**
@@ -807,71 +801,71 @@ export function getEntityFieldValueWithOutCase(entity, prop) {
807
801
  * @returns
808
802
  */
809
803
  export function getEntityFieldValue(entity, prop, isLowerCase) {
810
- if (!prop) {
811
- return null
812
- }
813
- let value = getEntityFieldValueWithCase(entity, prop)
814
- if (value === undefined || value === null) {
815
- // 兼容mysql数据库
816
- value = getEntityFieldValueWithCase(entity, prop.toLowerCase())
817
- }
818
- if (value === undefined || (value === null && isLowerCase === undefined)) {
819
- // 兼容oracle数据库
820
- value = getEntityFieldValueWithCase(entity, prop.toUpperCase())
821
- }
822
- 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
823
817
  }
824
818
 
825
819
  function getEntityFieldValueWithCase(entity, prop) {
826
- if (prop && prop.indexOf('.') > 0) {
827
- const parentOjbect = getParentObjectUtil(prop, entity)
828
- const modelName = prop.substring(prop.lastIndexOf('.') + 1)
829
- return parentOjbect[modelName]
830
- } else {
831
- return entity[prop]
832
- }
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
+ }
833
827
  }
834
828
 
835
829
  export function getParentObjectUtil(prop, entity) {
836
- const nestedProp = prop.split('.')
837
- // 属性只有一个时父对象就是models
838
- if (nestedProp.length === 1) {
839
- return entity
840
- } else {
841
- let parentObject
842
- // 属性超过2个时先找到最后一层属性的父对象
843
- for (let i = 0; i < nestedProp.length - 1; i++) {
844
- if (i === 0) {
845
- parentObject = getParentModelProp(nestedProp[i], entity)
846
- } else {
847
- parentObject = getParentModelProp(nestedProp[i], parentObject)
848
- }
849
- }
850
- return parentObject
851
- }
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
+ }
843
+ }
844
+ return parentObject
845
+ }
852
846
  }
853
847
 
854
848
  function getParentModelProp(prop, parentObj) {
855
- let myPparentObject = getParentModelPropWithCase(prop, parentObj)
856
- if (myPparentObject === undefined) {
857
- // 兼容mysql数据库
858
- myPparentObject = getParentModelPropWithCase(prop.toLowerCase(), parentObj)
859
- }
860
- if (myPparentObject === undefined) {
861
- // 兼容oracle数据库
862
- myPparentObject = getParentModelPropWithCase(prop.toUpperCase(), parentObj)
863
- }
864
- 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
865
859
  }
866
860
 
867
861
  function getParentModelPropWithCase(prop, parentObj) {
868
- if (!parentObj) {
869
- parentObj = {}
870
- }
871
- if (!parentObj[prop] && !parentObj[prop.toUpperCase()]) {
872
- parentObj[prop] = {}
873
- }
874
- return parentObj[prop]
862
+ if (!parentObj) {
863
+ parentObj = {}
864
+ }
865
+ if (!parentObj[prop] && !parentObj[prop.toUpperCase()]) {
866
+ parentObj[prop] = {}
867
+ }
868
+ return parentObj[prop]
875
869
  }
876
870
 
877
871
  /**
@@ -880,53 +874,53 @@ function getParentModelPropWithCase(prop, parentObj) {
880
874
  * @returns
881
875
  */
882
876
  export function findSystemInfoByCode(systemCode) {
883
- return new Promise((resolve, reject) => {
884
- if (!systemCode) {
885
- systemCode = window.$vueApp.config.globalProperties.systemCode
886
- }
887
-
888
- window.$vueApp.config.globalProperties.$http
889
- .get(window.$vueApp.config.globalProperties.baseAPI + '/component/business-systems/' + systemCode)
890
- .then((system) => {
891
- if (system) {
892
- resolve({
893
- zh_CN: system.name,
894
- en_US: system.enName,
895
- frontendUrl: system.frontendUrl
896
- })
897
- } else {
898
- resolve('系统:' + systemCode + '不存在')
877
+ return new Promise((resolve, reject) => {
878
+ if (!systemCode) {
879
+ systemCode = window.$vueApp.config.globalProperties.systemCode
899
880
  }
900
- })
901
- .catch((error) => {
902
- reject(error)
903
- })
904
- })
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 + '不存在')
893
+ }
894
+ })
895
+ .catch((error) => {
896
+ reject(error)
897
+ })
898
+ })
905
899
  }
906
900
 
907
901
  export function getPropNameWhenJoinTable(prop, isJoinTable, tableName) {
908
- if (prop && isJoinTable !== undefined && isJoinTable === true) {
909
- // 关联表时将点改成下划线,如果没点,则表示是主表字段,拼接主表tableName,因为列表组件中是这样处理的
910
- const replaceDot = '__'
911
- if (prop.indexOf('.') > 0) {
912
- prop = prop.replace('.', replaceDot)
913
- } else {
914
- if (tableName && tableName !== null && tableName !== '' && prop.indexOf(tableName + replaceDot) < 0) {
915
- // 如果属性名没有拼接表名才需要拼接
916
- prop = tableName + replaceDot + prop
917
- }
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
+ }
912
+ }
918
913
  }
919
- }
920
- return prop
914
+ return prop
921
915
  }
922
916
 
923
917
  export function isImage(fileName) {
924
- // const fileType = fileName.substring(fileName.lastIndexOf('.'), fileName.length).toLowerCase()
925
- // const imageTypes = ['.jpg', '.JPG', '.png', '.bmp', '.BMP', '.jpeg', '.gif', '.psd', '.tif', '.tga', '.svg', '.eps']
926
- // const index = imageTypes.indexOf(fileType)
927
- if (fileName && /\.(jpg|JPG|jpeg|JPEG|png|PNG|gif|GIF|bmp|BMP|psd|PSD|tif|TIF)$/.test(fileName)) {
928
- return true
929
- } else {
930
- return false
931
- }
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
+ }
932
926
  }