imatrix-ui 0.2.3-up → 0.2.5-up

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/utils/util.js CHANGED
@@ -1,23 +1,24 @@
1
1
  import i18n from '../i18n/i18n'
2
- import * as Vue from 'vue'
3
- import { executeExpression } from './calculator/calculator-util'
4
- import { getLangByShort } from './common-util'
2
+ import {executeExpression} from './calculator/calculator-util'
3
+ import {getLangByShort} from './common-util'
4
+
5
5
  export function getI18n() {
6
- if (!window.$locale) {
7
- i18n.locale = 'cn'
8
- } else {
9
- i18n.locale = window.$locale
10
- }
11
- return i18n
6
+ if (!window.$locale) {
7
+ i18n.locale = 'cn'
8
+ } else {
9
+ i18n.locale = window.$locale
10
+ }
11
+ return i18n.global
12
12
  }
13
13
 
14
14
  export function getLanguageWithLocale() {
15
- let currentLocale = window.$locale
16
- if (!currentLocale || currentLocale === 'zh') {
17
- currentLocale = 'cn'
18
- }
19
- return getLangByShort(currentLocale)
15
+ let currentLocale = window.$locale
16
+ if (!currentLocale || currentLocale === 'zh') {
17
+ currentLocale = 'cn'
18
+ }
19
+ return getLangByShort(currentLocale)
20
20
  }
21
+
21
22
  /**
22
23
  * 根据动态数据源获得下拉选的选项集合
23
24
  * @param {*} dynamicSourceCode 动态数据源编码
@@ -26,49 +27,49 @@ export function getLanguageWithLocale() {
26
27
  * @returns
27
28
  */
28
29
  export function findOptionsByDynamicDataSource(
29
- dynamicSourceCode,
30
- searchText,
31
- entity,
32
- additionalParameterStr
30
+ dynamicSourceCode,
31
+ searchText,
32
+ entity,
33
+ additionalParameterStr
33
34
  ) {
34
- return new Promise((resolve, reject) => {
35
- findDynamicDataSourceByCode(
36
- dynamicSourceCode,
37
- searchText,
38
- entity,
39
- additionalParameterStr
40
- )
41
- .then((dynamicDataSourceDto) => {
42
- let options = []
43
- if (dynamicDataSourceDto && dynamicDataSourceDto.options) {
44
- const setOptions = dynamicDataSourceDto.options
45
- let valueAttribute
46
- if (dynamicDataSourceDto.valueAttribute) {
47
- valueAttribute = dynamicDataSourceDto.valueAttribute
48
- }
49
- if (!valueAttribute || valueAttribute === '[label]') {
50
- valueAttribute = '_label_'
51
- }
52
- setOptions.forEach((item) => {
53
- // 值
54
- const value = item[valueAttribute]
55
- // 显示的标签
56
- const label = item['_label_']
57
- options.push({
58
- label,
59
- value,
35
+ return new Promise((resolve, reject) => {
36
+ findDynamicDataSourceByCode(
37
+ dynamicSourceCode,
38
+ searchText,
39
+ entity,
40
+ additionalParameterStr
41
+ )
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)
60
68
  })
61
- })
62
- }
63
- if (!options) {
64
- options = []
65
- }
66
- resolve(options)
67
- })
68
- .catch((error) => {
69
- reject(error)
70
- })
71
- })
69
+ .catch((error) => {
70
+ reject(error)
71
+ })
72
+ })
72
73
  }
73
74
 
74
75
  /**
@@ -79,39 +80,39 @@ export function findOptionsByDynamicDataSource(
79
80
  * @returns
80
81
  */
81
82
  export function findDynamicDataSourceByCode(
82
- dynamicSourceCode,
83
- searchText,
84
- entity,
85
- additionalParameterStr
83
+ dynamicSourceCode,
84
+ searchText,
85
+ entity,
86
+ additionalParameterStr
86
87
  ) {
87
- return new Promise((resolve, reject) => {
88
- if (searchText === undefined || searchText === null) {
89
- searchText = ''
90
- }
91
- const params = {
92
- searchText,
93
- }
94
- // const additionalParameterStr = window.sessionStorage.getItem('additionalParamMap')
95
- if (additionalParameterStr) {
96
- params.additionalParamMap = JSON.parse(additionalParameterStr)
97
- }
98
- if (entity && entity !== null) {
99
- params.entity = entity
100
- }
101
- window.$vueApp.config.globalProperties.$http
102
- .post(
103
- window.$vueApp.config.globalProperties.baseURL +
104
- '/common/dynamic-data-source/' +
105
- dynamicSourceCode,
106
- params
107
- )
108
- .then((dynamicDataSourceDto) => {
109
- resolve(dynamicDataSourceDto)
110
- })
111
- .catch((error) => {
112
- reject(error)
113
- })
114
- })
88
+ return new Promise((resolve, reject) => {
89
+ if (searchText === undefined || searchText === null) {
90
+ searchText = ''
91
+ }
92
+ const params = {
93
+ searchText,
94
+ }
95
+ // const additionalParameterStr = window.sessionStorage.getItem('additionalParamMap')
96
+ if (additionalParameterStr) {
97
+ params.additionalParamMap = JSON.parse(additionalParameterStr)
98
+ }
99
+ if (entity && entity !== null) {
100
+ params.entity = entity
101
+ }
102
+ window.$vueApp.config.globalProperties.$http
103
+ .post(
104
+ window.$vueApp.config.globalProperties.baseURL +
105
+ '/common/dynamic-data-source/' +
106
+ dynamicSourceCode,
107
+ params
108
+ )
109
+ .then((dynamicDataSourceDto) => {
110
+ resolve(dynamicDataSourceDto)
111
+ })
112
+ .catch((error) => {
113
+ reject(error)
114
+ })
115
+ })
115
116
  }
116
117
 
117
118
  /**
@@ -125,256 +126,258 @@ export function findDynamicDataSourceByCode(
125
126
  * @returns
126
127
  */
127
128
  export function analysisCondition(
128
- conditionListJson,
129
- entity,
130
- additionalParameter,
131
- contextParameter,
132
- isSql,
133
- tableName,
134
- parentFormData
135
- ) {
136
- // console.log('analysisCondition判断条件conditionListJson', conditionListJson)
137
- // console.log('analysisCondition判断条件entity', entity)
138
- // console.log('analysisCondition判断条件additionalParameter', additionalParameter)
139
- // console.log('analysisCondition判断条件contextParameter', contextParameter)
140
- // console.log('analysisCondition判断条件isSql', isSql)
141
- // console.log('analysisCondition判断条件tableName', tableName)
142
- // console.log('analysisCondition判断条件parentFormData', parentFormData)
143
- if (
144
- conditionListJson === undefined ||
145
- conditionListJson === '' ||
146
- conditionListJson === null
147
- ) {
148
- // 如果条件不存在,则默认返回true
149
- return true
150
- }
151
- if (typeof isSql === 'undefined' || isSql === null) {
152
- // 默认是定制开发时
153
- isSql = false
154
- }
155
- // 页面附加参数
156
- let additionalParameterMap = {}
157
- if (
158
- additionalParameter &&
159
- typeof additionalParameter === 'string' &&
160
- additionalParameter !== ''
161
- ) {
162
- additionalParameterMap = JSON.parse(additionalParameter)
163
- } else if (additionalParameter && typeof additionalParameter === 'object') {
164
- additionalParameterMap = additionalParameter
165
- }
166
- // 环境变量,例如:当前用户id、当前用户登录名等
167
- let contextParameterMap = {}
168
- if (
169
- contextParameter &&
170
- typeof contextParameter === 'string' &&
171
- contextParameter !== ''
172
- ) {
173
- contextParameterMap = JSON.parse(contextParameter)
174
- } else if (contextParameter && typeof contextParameter === 'object') {
175
- contextParameterMap = contextParameter
176
- }
177
- let conditionList = []
178
- if (
179
- conditionListJson &&
180
- typeof conditionListJson === 'string' &&
181
- conditionListJson !== ''
182
- ) {
183
- // conditionList = eval('('+conditionListJson+')')
184
- conditionList = JSON.parse(conditionListJson)
185
- } else if (conditionListJson && Array.isArray(conditionListJson)) {
186
- conditionList = conditionListJson
187
- }
188
- return parseCondition(
129
+ conditionListJson,
189
130
  entity,
190
- conditionList,
131
+ additionalParameter,
132
+ contextParameter,
191
133
  isSql,
192
134
  tableName,
193
- additionalParameterMap,
194
- contextParameterMap,
195
135
  parentFormData
196
- )
197
- }
198
-
199
- function parseCondition(
200
- entity,
201
- conditionList,
202
- isSql,
203
- tableName,
204
- additionalParamMap,
205
- contextParameterMap,
206
- parentFormData
207
136
  ) {
208
- if (
209
- conditionList === undefined ||
210
- conditionList === null ||
211
- conditionList.length === 0
212
- ) {
213
- // 表示没有设置条件,默认是true
214
- return true
215
- }
216
- // 条件封装的表达式
217
- let conditions = ''
218
- for (let i = 0; i < conditionList.length; i++) {
219
- const condition = conditionList[i]
220
- let propName = condition.propName
221
- let propDbName = condition.propDbName
222
- if ((!propName || propName === '') && (!propDbName || propDbName === '')) {
223
- // 没有属性和字段名表示是无效的条件
224
- continue
137
+ // console.log('analysisCondition判断条件conditionListJson', conditionListJson)
138
+ // console.log('analysisCondition判断条件entity', entity)
139
+ // console.log('analysisCondition判断条件additionalParameter', additionalParameter)
140
+ // console.log('analysisCondition判断条件contextParameter', contextParameter)
141
+ // console.log('analysisCondition判断条件isSql', isSql)
142
+ // console.log('analysisCondition判断条件tableName', tableName)
143
+ // console.log('analysisCondition判断条件parentFormData', parentFormData)
144
+ if (
145
+ conditionListJson === undefined ||
146
+ conditionListJson === '' ||
147
+ conditionListJson === null
148
+ ) {
149
+ // 如果条件不存在,则默认返回true
150
+ return true
225
151
  }
226
- let leftValue
227
- if (isSql && propDbName) {
228
- if (propDbName.indexOf('parent_+_') !== -1) {
229
- propDbName = propDbName.replace('parent_+_', '')
230
- // 再获取属于那张表
231
- const propDbNameArr = propDbName.split('_+_')
232
- propDbName = propDbNameArr[1]
233
- leftValue = getValue(parentFormData, propDbName, isSql)
234
- } else {
235
- leftValue = getValue(entity, propDbName, isSql)
236
- }
237
- if (leftValue === undefined || leftValue === null) {
238
- if (
239
- tableName &&
240
- propDbName.toLowerCase().startsWith(tableName.toLowerCase() + '.')
241
- ) {
242
- // 表示是当前表的字段
243
- const myProp = propDbName.substring(propDbName.indexOf('.'))
244
- leftValue = getValue(entity, myProp, isSql)
245
- }
246
- }
247
- } else {
248
- if (propName.indexOf('parent_+_') !== -1) {
249
- propName = propName.replace('parent_+_', '')
250
- const propNameArr = propName.split('_+_')
251
- propName = propNameArr[1]
252
- leftValue = getValue(parentFormData, propName, isSql)
253
- } else {
254
- leftValue = getValue(entity, propName, isSql)
255
- }
256
- if (propDbName && (leftValue === undefined || leftValue === null)) {
257
- leftValue = getValue(entity, propDbName, isSql)
258
- }
152
+ if (typeof isSql === 'undefined' || isSql === null) {
153
+ // 默认是定制开发时
154
+ isSql = false
259
155
  }
260
- const operator = condition.operator
261
- const propValue = condition.propValue
262
- const dataType = condition.dataType
263
- const variableIsNullStr = condition.variableIsNull
264
- // 解析单个条件的值
265
- // 判断value类型
266
- let value = getPropValue(
267
- propValue,
268
- entity,
269
- additionalParamMap,
270
- contextParameterMap
271
- )
272
- if (variableIsNullStr && variableIsNullStr === 'null') {
273
- if (value === undefined || value === '') {
274
- value = null
275
- }
156
+ // 页面附加参数
157
+ let additionalParameterMap = {}
158
+ if (
159
+ additionalParameter &&
160
+ typeof additionalParameter === 'string' &&
161
+ additionalParameter !== ''
162
+ ) {
163
+ additionalParameterMap = JSON.parse(additionalParameter)
164
+ } else if (additionalParameter && typeof additionalParameter === 'object') {
165
+ additionalParameterMap = additionalParameter
166
+ }
167
+ // 环境变量,例如:当前用户id、当前用户登录名等
168
+ let contextParameterMap = {}
169
+ if (
170
+ contextParameter &&
171
+ typeof contextParameter === 'string' &&
172
+ contextParameter !== ''
173
+ ) {
174
+ contextParameterMap = JSON.parse(contextParameter)
175
+ } else if (contextParameter && typeof contextParameter === 'object') {
176
+ contextParameterMap = contextParameter
177
+ }
178
+ let conditionList = []
179
+ if (
180
+ conditionListJson &&
181
+ typeof conditionListJson === 'string' &&
182
+ conditionListJson !== ''
183
+ ) {
184
+ // conditionList = eval('('+conditionListJson+')')
185
+ conditionList = JSON.parse(conditionListJson)
186
+ } else if (conditionListJson && Array.isArray(conditionListJson)) {
187
+ conditionList = conditionListJson
276
188
  }
277
- let conditionResult = executeExpression(
278
- leftValue,
279
- operator,
280
- value,
281
- dataType
189
+ return parseCondition(
190
+ entity,
191
+ conditionList,
192
+ isSql,
193
+ tableName,
194
+ additionalParameterMap,
195
+ contextParameterMap,
196
+ parentFormData
282
197
  )
283
- const leftBracket = condition.leftBracket
284
- const rightBracket = condition.rightBracket
285
- let joinSign = condition.joinSign
286
- if (leftBracket && leftBracket !== null && leftBracket !== '') {
287
- conditions = conditions + leftBracket
288
- conditions = conditions + ' '
289
- // conditions.append(leftBracket).append(' ')
198
+ }
199
+
200
+ function parseCondition(
201
+ entity,
202
+ conditionList,
203
+ isSql,
204
+ tableName,
205
+ additionalParamMap,
206
+ contextParameterMap,
207
+ parentFormData
208
+ ) {
209
+ if (
210
+ conditionList === undefined ||
211
+ conditionList === null ||
212
+ conditionList.length === 0
213
+ ) {
214
+ // 表示没有设置条件,默认是true
215
+ return true
290
216
  }
291
- if (variableIsNullStr && variableIsNullStr !== 'null') {
292
- if (value === undefined || value === null || value + '' === '') {
293
- if (variableIsNullStr === '1=1') {
294
- conditionResult = true
217
+ // 条件封装的表达式
218
+ let conditions = ''
219
+ for (let i = 0; i < conditionList.length; i++) {
220
+ const condition = conditionList[i]
221
+ let propName = condition.propName
222
+ let propDbName = condition.propDbName
223
+ if ((!propName || propName === '') && (!propDbName || propDbName === '')) {
224
+ // 没有属性和字段名表示是无效的条件
225
+ continue
226
+ }
227
+ let leftValue
228
+ if (isSql && propDbName) {
229
+ if (propDbName.indexOf('parent_+_') !== -1) {
230
+ propDbName = propDbName.replace('parent_+_', '')
231
+ // 再获取属于那张表
232
+ const propDbNameArr = propDbName.split('_+_')
233
+ propDbName = propDbNameArr[1]
234
+ leftValue = getValue(parentFormData, propDbName, isSql)
235
+ } else {
236
+ leftValue = getValue(entity, propDbName, isSql)
237
+ }
238
+ if (leftValue === undefined || leftValue === null) {
239
+ if (
240
+ tableName &&
241
+ propDbName.toLowerCase().startsWith(tableName.toLowerCase() + '.')
242
+ ) {
243
+ // 表示是当前表的字段
244
+ const myProp = propDbName.substring(propDbName.indexOf('.'))
245
+ leftValue = getValue(entity, myProp, isSql)
246
+ }
247
+ }
295
248
  } else {
296
- conditionResult = false
249
+ if (propName.indexOf('parent_+_') !== -1) {
250
+ propName = propName.replace('parent_+_', '')
251
+ const propNameArr = propName.split('_+_')
252
+ propName = propNameArr[1]
253
+ leftValue = getValue(parentFormData, propName, isSql)
254
+ } else {
255
+ leftValue = getValue(entity, propName, isSql)
256
+ }
257
+ if (propDbName && (leftValue === undefined || leftValue === null)) {
258
+ leftValue = getValue(entity, propDbName, isSql)
259
+ }
297
260
  }
298
- }
299
- }
300
- conditions += conditionResult + ' '
301
- if (rightBracket && rightBracket !== null && rightBracket !== '') {
302
- conditions = conditions + rightBracket
303
- conditions = conditions + ' '
304
- // conditions.append(rightBracket).append(' ')
305
- }
306
- if (i < conditionList.length - 1) {
307
- // 最后一个不拼接“连接符”
308
- if (joinSign && joinSign !== null && joinSign !== '') {
309
- const joinSignIgnoreCase = joinSign.toLowerCase()
310
- if (joinSignIgnoreCase === 'and') {
311
- joinSign = joinSignIgnoreCase.replace('and', '&&')
312
- } else if (joinSignIgnoreCase === 'or') {
313
- joinSign = joinSignIgnoreCase.replace('or', '||')
261
+ const operator = condition.operator
262
+ const propValue = condition.propValue
263
+ const dataType = condition.dataType
264
+ const variableIsNullStr = condition.variableIsNull
265
+ // 解析单个条件的值
266
+ // 判断value类型
267
+ let value = getPropValue(
268
+ propValue,
269
+ entity,
270
+ additionalParamMap,
271
+ contextParameterMap
272
+ )
273
+ if (variableIsNullStr && variableIsNullStr === 'null') {
274
+ if (value === undefined || value === '') {
275
+ value = null
276
+ }
314
277
  }
315
- conditions += joinSign + ' '
316
- }
278
+ let conditionResult = executeExpression(
279
+ leftValue,
280
+ operator,
281
+ value,
282
+ dataType
283
+ )
284
+ const leftBracket = condition.leftBracket
285
+ const rightBracket = condition.rightBracket
286
+ let joinSign = condition.joinSign
287
+ if (leftBracket && leftBracket !== null && leftBracket !== '') {
288
+ conditions = conditions + leftBracket
289
+ conditions = conditions + ' '
290
+ // conditions.append(leftBracket).append(' ')
291
+ }
292
+ if (variableIsNullStr && variableIsNullStr !== 'null') {
293
+ if (value === undefined || value === null || value + '' === '') {
294
+ if (variableIsNullStr === '1=1') {
295
+ conditionResult = true
296
+ } else {
297
+ conditionResult = false
298
+ }
299
+ }
300
+ }
301
+ conditions += conditionResult + ' '
302
+ if (rightBracket && rightBracket !== null && rightBracket !== '') {
303
+ conditions = conditions + rightBracket
304
+ conditions = conditions + ' '
305
+ // conditions.append(rightBracket).append(' ')
306
+ }
307
+ if (i < conditionList.length - 1) {
308
+ // 最后一个不拼接“连接符”
309
+ if (joinSign && joinSign !== null && joinSign !== '') {
310
+ const joinSignIgnoreCase = joinSign.toLowerCase()
311
+ if (joinSignIgnoreCase === 'and') {
312
+ joinSign = joinSignIgnoreCase.replace('and', '&&')
313
+ } else if (joinSignIgnoreCase === 'or') {
314
+ joinSign = joinSignIgnoreCase.replace('or', '||')
315
+ }
316
+ conditions += joinSign + ' '
317
+ }
318
+ }
319
+ }
320
+ console.log('parseCondition----conditions=', conditions)
321
+ if (conditions) {
322
+ // eslint-disable-next-line no-eval
323
+ return eval('(' + conditions + ')')
324
+ } else {
325
+ return true
317
326
  }
318
- }
319
- console.log('parseCondition----conditions=', conditions)
320
- if (conditions) {
321
- // eslint-disable-next-line no-eval
322
- return eval('(' + conditions + ')')
323
- } else {
324
- return true
325
- }
326
327
  }
328
+
327
329
  const REPLACE_DOT = '__'
328
330
 
329
331
  function getValue(entityData, fieldName, isSql) {
330
- let value = null
331
- if (entityData && entityData !== null) {
332
- if (fieldName && fieldName !== null) {
333
- value = getValueByField(entityData, fieldName)
334
- if (value === undefined || value === null) {
335
- if (isSql) {
336
- if (value === undefined || value == null) {
337
- if (fieldName.indexOf('.') > 0) {
338
- // 将“.”替换为'__',列表组件中的entity中如果是'.',传过来的实体信息中的字段属性会是“__”
339
- fieldName = fieldName.replace('.', REPLACE_DOT)
340
- value = getValueByField(entityData, fieldName)
332
+ let value = null
333
+ if (entityData && entityData !== null) {
334
+ if (fieldName && fieldName !== null) {
335
+ value = getValueByField(entityData, fieldName)
336
+ if (value === undefined || value === null) {
337
+ if (isSql) {
338
+ if (value === undefined || value == null) {
339
+ if (fieldName.indexOf('.') > 0) {
340
+ // 将“.”替换为'__',列表组件中的entity中如果是'.',传过来的实体信息中的字段属性会是“__”
341
+ fieldName = fieldName.replace('.', REPLACE_DOT)
342
+ value = getValueByField(entityData, fieldName)
343
+ }
344
+ }
345
+ }
341
346
  }
342
- }
343
347
  }
344
- }
345
348
  }
346
- }
347
- return value
349
+ return value
348
350
  }
349
351
 
350
352
  function getValueByField(entityData, fieldName) {
351
- if (entityData && entityData !== null) {
352
- let value
353
- if (fieldName.indexOf('.') > 0) {
354
- // 表示是子表字段
355
- value = getSubEntityValue(entityData, fieldName)
356
- } else {
357
- value = entityData[fieldName.toUpperCase()]
358
- if (value === undefined) {
359
- value = entityData[fieldName.toLowerCase()]
360
- }
353
+ if (entityData && entityData !== null) {
354
+ let value
355
+ if (fieldName.indexOf('.') > 0) {
356
+ // 表示是子表字段
357
+ value = getSubEntityValue(entityData, fieldName)
358
+ } else {
359
+ value = entityData[fieldName.toUpperCase()]
360
+ if (value === undefined) {
361
+ value = entityData[fieldName.toLowerCase()]
362
+ }
363
+ }
364
+ return value
361
365
  }
362
- return value
363
- }
364
366
  }
367
+
365
368
  function getSubEntityValue(entityData, fieldName) {
366
- let value = null
367
- let subEntityData = entityData
368
- const fieldNames = fieldName.split('\\.')
369
- for (let i = 0; i < fieldNames.length; i++) {
370
- const field = fieldNames[i]
371
- if (i === fieldNames.length) {
372
- value = getSubEntityFieldValue(subEntityData, field)
373
- } else {
374
- subEntityData = getSubEntityFieldValue(subEntityData, field)
369
+ let value = null
370
+ let subEntityData = entityData
371
+ const fieldNames = fieldName.split('\\.')
372
+ for (let i = 0; i < fieldNames.length; i++) {
373
+ const field = fieldNames[i]
374
+ if (i === fieldNames.length) {
375
+ value = getSubEntityFieldValue(subEntityData, field)
376
+ } else {
377
+ subEntityData = getSubEntityFieldValue(subEntityData, field)
378
+ }
375
379
  }
376
- }
377
- return value
380
+ return value
378
381
  }
379
382
 
380
383
  /**
@@ -385,94 +388,95 @@ function getSubEntityValue(entityData, fieldName) {
385
388
  * @return
386
389
  */
387
390
  function getSubEntityFieldValue(subEntityData, fieldName) {
388
- if (subEntityData === undefined || subEntityData === null) {
389
- return null
390
- }
391
- return subEntityData[fieldName]
391
+ if (subEntityData === undefined || subEntityData === null) {
392
+ return null
393
+ }
394
+ return subEntityData[fieldName]
392
395
  }
393
396
 
394
397
  function getContextValue(contextParameterMap, propValue) {
395
- if (contextParameterMap) {
396
- return contextParameterMap[propValue]
397
- }
398
+ if (contextParameterMap) {
399
+ return contextParameterMap[propValue]
400
+ }
398
401
  }
399
402
 
400
403
  export function getPropValue(
401
- propValue,
402
- entity,
403
- additionalParamMap,
404
- contextParameterMap,
405
- parentEntity,
406
- subEntity,
407
- task
404
+ propValue,
405
+ entity,
406
+ additionalParamMap,
407
+ contextParameterMap,
408
+ parentEntity,
409
+ subEntity,
410
+ task
408
411
  ) {
409
- let value = null
410
- if (propValue && propValue !== null && propValue !== '') {
411
- if (propValue === 'null') {
412
- value = null
413
- } else if (
414
- propValue.includes('${context.') ||
415
- propValue.includes('${request.') ||
416
- propValue.includes('${obj.')
417
- ) {
418
- // 填写的固定值
419
- if (propValue.includes('${context.')) {
420
- propValue = propValue.replace('${context.', '').replace('}', '')
421
- value = getContextValue(contextParameterMap, propValue)
422
- } else if (
423
- propValue.includes('${request.') &&
424
- propValue !== '${request.term}'
425
- ) {
426
- // ${request.term}表示页面中手动输入的值
427
- propValue = propValue.replace('${request.', '').replace('}', '')
428
- if (
429
- additionalParamMap &&
430
- additionalParamMap != null &&
431
- Object.keys(additionalParamMap).indexOf(propValue) >= 0 &&
432
- additionalParamMap[propValue] &&
433
- additionalParamMap[propValue] !== null
412
+ let value = null
413
+ if (propValue && propValue !== null && propValue !== '') {
414
+ if (propValue === 'null') {
415
+ value = null
416
+ } else if (
417
+ propValue.includes('${context.') ||
418
+ propValue.includes('${request.') ||
419
+ propValue.includes('${obj.')
434
420
  ) {
435
- value = additionalParamMap[propValue]
436
- } else {
437
- value = null
438
- }
439
- } else if (propValue.includes('${obj.')) {
440
- if (entity === undefined || entity == null) {
441
- value = null
421
+ // 填写的固定值
422
+ if (propValue.includes('${context.')) {
423
+ propValue = propValue.replace('${context.', '').replace('}', '')
424
+ value = getContextValue(contextParameterMap, propValue)
425
+ } else if (
426
+ propValue.includes('${request.') &&
427
+ propValue !== '${request.term}'
428
+ ) {
429
+ // ${request.term}表示页面中手动输入的值
430
+ propValue = propValue.replace('${request.', '').replace('}', '')
431
+ if (
432
+ additionalParamMap &&
433
+ additionalParamMap != null &&
434
+ Object.keys(additionalParamMap).indexOf(propValue) >= 0 &&
435
+ additionalParamMap[propValue] &&
436
+ additionalParamMap[propValue] !== null
437
+ ) {
438
+ value = additionalParamMap[propValue]
439
+ } else {
440
+ value = null
441
+ }
442
+ } else if (propValue.includes('${obj.')) {
443
+ if (entity === undefined || entity == null) {
444
+ value = null
445
+ } else {
446
+ const propName = propValue.replace('${obj.', '').replace('}', '')
447
+ value = getEntityFieldValue(entity, propName)
448
+ }
449
+ }
450
+ } else if (propValue.includes('${parent.')) {
451
+ if (parentEntity === undefined || parentEntity == null) {
452
+ value = null
453
+ } else {
454
+ const propName = propValue.replace('${parent.', '').replace('}', '')
455
+ value = getEntityFieldValue(parentEntity, propName)
456
+ }
457
+ } else if (propValue.includes('${task.')) {
458
+ if (task === undefined || task == null) {
459
+ value = null
460
+ } else {
461
+ const propName = propValue.replace('${task.', '').replace('}', '')
462
+ value = getEntityFieldValue(task, propName)
463
+ }
464
+ } else if (propValue.includes('${subObj.')) {
465
+ if (subEntity === undefined || subEntity == null) {
466
+ value = null
467
+ } else {
468
+ const propName = propValue.replace('${subObj.', '').replace('}', '')
469
+ value = getEntityFieldValue(subEntity, propName)
470
+ }
471
+ } else if (propValue.includes('${input.')) {
472
+ value = propValue.replace('${input.', '').replace('}', '')
442
473
  } else {
443
- const propName = propValue.replace('${obj.', '').replace('}', '')
444
- value = getEntityFieldValue(entity, propName)
474
+ value = propValue
445
475
  }
446
- }
447
- } else if (propValue.includes('${parent.')) {
448
- if (parentEntity === undefined || parentEntity == null) {
449
- value = null
450
- } else {
451
- const propName = propValue.replace('${parent.', '').replace('}', '')
452
- value = getEntityFieldValue(parentEntity, propName)
453
- }
454
- } else if (propValue.includes('${task.')) {
455
- if (task === undefined || task == null) {
456
- value = null
457
- } else {
458
- const propName = propValue.replace('${task.', '').replace('}', '')
459
- value = getEntityFieldValue(task, propName)
460
- }
461
- } else if (propValue.includes('${subObj.')) {
462
- if (subEntity === undefined || subEntity == null) {
463
- value = null
464
- } else {
465
- const propName = propValue.replace('${subObj.', '').replace('}', '')
466
- value = getEntityFieldValue(subEntity, propName)
467
- }
468
- } else if (propValue.includes('${input.')) {
469
- value = propValue.replace('${input.', '').replace('}', '')
470
- } else {
471
- value = propValue
472
476
  }
473
- }
474
- return value
477
+ return value
475
478
  }
479
+
476
480
  /**
477
481
  * 解析条件,例如:${obj.menu_code}-#-#${input.---}-#-#${context.currentTransactor}
478
482
  * @param {*} conditionValue
@@ -482,31 +486,31 @@ export function getPropValue(
482
486
  * @returns
483
487
  */
484
488
  export function analysisValue(
485
- conditionValue,
486
- entity,
487
- additionalParameter,
488
- contextParameter
489
+ conditionValue,
490
+ entity,
491
+ additionalParameter,
492
+ contextParameter
489
493
  ) {
490
- if (!conditionValue) {
491
- return
492
- }
493
- let label = ''
494
- const split = conditionValue.split('-#-#')
495
- if (split != null && split.length > 0) {
496
- split.forEach((item) => {
497
- let value = getPropValue(
498
- item,
499
- entity,
500
- additionalParameter,
501
- contextParameter
502
- )
503
- if (!value || value === null) {
504
- value = ''
505
- }
506
- label += value
507
- })
508
- }
509
- return label
494
+ if (!conditionValue) {
495
+ return
496
+ }
497
+ let label = ''
498
+ const split = conditionValue.split('-#-#')
499
+ if (split != null && split.length > 0) {
500
+ split.forEach((item) => {
501
+ let value = getPropValue(
502
+ item,
503
+ entity,
504
+ additionalParameter,
505
+ contextParameter
506
+ )
507
+ if (!value || value === null) {
508
+ value = ''
509
+ }
510
+ label += value
511
+ })
512
+ }
513
+ return label
510
514
  }
511
515
 
512
516
  /**
@@ -516,29 +520,29 @@ export function analysisValue(
516
520
  * @param {*} value
517
521
  */
518
522
  export function setEntityFieldValue(entity, prop, value) {
519
- if (prop && entity) {
520
- if (prop && prop.indexOf('.') > 0) {
521
- const parentObj = getParentObjectUtil(prop, entity)
522
- if (parentObj) {
523
- const subProp = prop.substring(prop.lastIndexOf('.') + 1)
524
- if (parentObj[subProp] === undefined) {
525
- // 动态对象属性赋值,防止属性不存在,导致属性无法赋值问题
526
- parentObj[prop.substring(prop.lastIndexOf('.') + 1)] = value
523
+ if (prop && entity) {
524
+ if (prop && prop.indexOf('.') > 0) {
525
+ const parentObj = getParentObjectUtil(prop, entity)
526
+ if (parentObj) {
527
+ const subProp = prop.substring(prop.lastIndexOf('.') + 1)
528
+ if (parentObj[subProp] === undefined) {
529
+ // 动态对象属性赋值,防止属性不存在,导致属性无法赋值问题
530
+ parentObj[prop.substring(prop.lastIndexOf('.') + 1)] = value
531
+ } else {
532
+ // 静态对象属性赋值,提高性能
533
+ parentObj[subProp] = value
534
+ }
535
+ }
527
536
  } else {
528
- // 静态对象属性赋值,提高性能
529
- parentObj[subProp] = value
537
+ if (entity[prop] === undefined) {
538
+ // 动态对象属性赋值,防止属性不存在,导致属性无法赋值问题
539
+ entity[prop] = value
540
+ } else {
541
+ // 静态对象属性赋值,提高性能
542
+ entity[prop] = value
543
+ }
530
544
  }
531
- }
532
- } else {
533
- if (entity[prop] === undefined) {
534
- // 动态对象属性赋值,防止属性不存在,导致属性无法赋值问题
535
- entity[prop] = value
536
- } else {
537
- // 静态对象属性赋值,提高性能
538
- entity[prop] = value
539
- }
540
545
  }
541
- }
542
546
  }
543
547
 
544
548
  /**
@@ -548,13 +552,13 @@ export function setEntityFieldValue(entity, prop, value) {
548
552
  * @returns
549
553
  */
550
554
  export function getEntityFieldValueWithOutCase(entity, prop) {
551
- if (prop && prop.indexOf('.') > 0) {
552
- const parentOjbect = getParentObjectUtil(prop, entity)
553
- const modelName = prop.substring(prop.lastIndexOf('.') + 1)
554
- return parentOjbect[modelName]
555
- } else {
556
- return entity[prop]
557
- }
555
+ if (prop && prop.indexOf('.') > 0) {
556
+ const parentOjbect = getParentObjectUtil(prop, entity)
557
+ const modelName = prop.substring(prop.lastIndexOf('.') + 1)
558
+ return parentOjbect[modelName]
559
+ } else {
560
+ return entity[prop]
561
+ }
558
562
  }
559
563
 
560
564
  /**
@@ -564,135 +568,136 @@ export function getEntityFieldValueWithOutCase(entity, prop) {
564
568
  * @returns
565
569
  */
566
570
  export function getEntityFieldValue(entity, prop, isLowerCase) {
567
- let value = getEntityFieldValueWithCase(entity, prop)
568
- if (value === undefined || value === null) {
569
- // 兼容mysql数据库
570
- value = getEntityFieldValueWithCase(entity, prop.toLowerCase())
571
- }
572
- if (value === undefined || (value === null && isLowerCase === undefined)) {
573
- // 兼容oracle数据库
574
- value = getEntityFieldValueWithCase(entity, prop.toUpperCase())
575
- }
576
- return value
571
+ let value = getEntityFieldValueWithCase(entity, prop)
572
+ if (value === undefined || value === null) {
573
+ // 兼容mysql数据库
574
+ value = getEntityFieldValueWithCase(entity, prop.toLowerCase())
575
+ }
576
+ if (value === undefined || (value === null && isLowerCase === undefined)) {
577
+ // 兼容oracle数据库
578
+ value = getEntityFieldValueWithCase(entity, prop.toUpperCase())
579
+ }
580
+ return value
577
581
  }
578
582
 
579
583
  function getEntityFieldValueWithCase(entity, prop) {
580
- if (prop && prop.indexOf('.') > 0) {
581
- const parentOjbect = getParentObjectUtil(prop, entity)
582
- const modelName = prop.substring(prop.lastIndexOf('.') + 1)
583
- return parentOjbect[modelName]
584
- } else {
585
- return entity[prop]
586
- }
584
+ if (prop && prop.indexOf('.') > 0) {
585
+ const parentOjbect = getParentObjectUtil(prop, entity)
586
+ const modelName = prop.substring(prop.lastIndexOf('.') + 1)
587
+ return parentOjbect[modelName]
588
+ } else {
589
+ return entity[prop]
590
+ }
587
591
  }
588
592
 
589
593
  export function getParentObjectUtil(prop, entity) {
590
- const nestedProp = prop.split('.')
591
- // 属性只有一个时父对象就是models
592
- if (nestedProp.length === 1) {
593
- return entity
594
- } else {
595
- let parentObject
596
- // 属性超过2个时先找到最后一层属性的父对象
597
- for (let i = 0; i < nestedProp.length - 1; i++) {
598
- if (i === 0) {
599
- parentObject = getParentModelProp(nestedProp[i], entity)
600
- } else {
601
- parentObject = getParentModelProp(nestedProp[i], parentObject)
602
- }
594
+ const nestedProp = prop.split('.')
595
+ // 属性只有一个时父对象就是models
596
+ if (nestedProp.length === 1) {
597
+ return entity
598
+ } else {
599
+ let parentObject
600
+ // 属性超过2个时先找到最后一层属性的父对象
601
+ for (let i = 0; i < nestedProp.length - 1; i++) {
602
+ if (i === 0) {
603
+ parentObject = getParentModelProp(nestedProp[i], entity)
604
+ } else {
605
+ parentObject = getParentModelProp(nestedProp[i], parentObject)
606
+ }
607
+ }
608
+ return parentObject
603
609
  }
604
- return parentObject
605
- }
606
610
  }
607
611
 
608
612
  function getParentModelProp(prop, parentObj) {
609
- let myPparentObject = getParentModelPropWithCase(prop, parentObj)
610
- if (myPparentObject === undefined) {
611
- // 兼容mysql数据库
612
- myPparentObject = getParentModelPropWithCase(prop.toLowerCase(), parentObj)
613
- }
614
- if (myPparentObject === undefined) {
615
- // 兼容oracle数据库
616
- myPparentObject = getParentModelPropWithCase(prop.toUpperCase(), parentObj)
617
- }
618
- return myPparentObject
613
+ let myPparentObject = getParentModelPropWithCase(prop, parentObj)
614
+ if (myPparentObject === undefined) {
615
+ // 兼容mysql数据库
616
+ myPparentObject = getParentModelPropWithCase(prop.toLowerCase(), parentObj)
617
+ }
618
+ if (myPparentObject === undefined) {
619
+ // 兼容oracle数据库
620
+ myPparentObject = getParentModelPropWithCase(prop.toUpperCase(), parentObj)
621
+ }
622
+ return myPparentObject
619
623
  }
620
624
 
621
625
  function getParentModelPropWithCase(prop, parentObj) {
622
- if (!parentObj) {
623
- parentObj = {}
624
- }
625
- if (!parentObj[prop] && !parentObj[prop.toUpperCase()]) {
626
- parentObj[prop] = {}
627
- }
628
- return parentObj[prop]
626
+ if (!parentObj) {
627
+ parentObj = {}
628
+ }
629
+ if (!parentObj[prop] && !parentObj[prop.toUpperCase()]) {
630
+ parentObj[prop] = {}
631
+ }
632
+ return parentObj[prop]
629
633
  }
634
+
630
635
  /**
631
636
  * 获得系统信息
632
637
  * @param {*}} systemCode
633
638
  * @returns
634
639
  */
635
640
  export function findSystemInfoByCode(systemCode) {
636
- return new Promise((resolve, reject) => {
637
- if (!systemCode) {
638
- systemCode = window.$vueApp.config.globalProperties.systemCode
639
- }
640
-
641
- window.$vueApp.config.globalProperties.$http
642
- .get(
643
- window.$vueApp.config.globalProperties.baseAPI +
644
- '/component/business-systems/' +
645
- systemCode
646
- )
647
- .then((system) => {
648
- if (system) {
649
- resolve({
650
- zh_CN: system.name,
651
- en_US: system.enName,
652
- frontendUrl: system.frontendUrl,
653
- })
654
- } else {
655
- resolve('系统:' + systemCode + '不存在')
641
+ return new Promise((resolve, reject) => {
642
+ if (!systemCode) {
643
+ systemCode = window.$vueApp.config.globalProperties.systemCode
656
644
  }
657
- })
658
- .catch((error) => {
659
- reject(error)
660
- })
661
- })
645
+
646
+ window.$vueApp.config.globalProperties.$http
647
+ .get(
648
+ window.$vueApp.config.globalProperties.baseAPI +
649
+ '/component/business-systems/' +
650
+ systemCode
651
+ )
652
+ .then((system) => {
653
+ if (system) {
654
+ resolve({
655
+ zh_CN: system.name,
656
+ en_US: system.enName,
657
+ frontendUrl: system.frontendUrl,
658
+ })
659
+ } else {
660
+ resolve('系统:' + systemCode + '不存在')
661
+ }
662
+ })
663
+ .catch((error) => {
664
+ reject(error)
665
+ })
666
+ })
662
667
  }
663
668
 
664
669
  export function getPropNameWhenJoinTable(prop, isJoinTable, tableName) {
665
- if (prop && isJoinTable !== undefined && isJoinTable === true) {
666
- // 关联表时将点改成下划线,如果没点,则表示是主表字段,拼接主表tableName,因为列表组件中是这样处理的
667
- const replaceDot = '__'
668
- if (prop.indexOf('.') > 0) {
669
- prop = prop.replace('.', replaceDot)
670
- } else {
671
- if (
672
- tableName &&
673
- tableName !== null &&
674
- tableName !== '' &&
675
- prop.indexOf(tableName + replaceDot) < 0
676
- ) {
677
- // 如果属性名没有拼接表名才需要拼接
678
- prop = tableName + replaceDot + prop
679
- }
670
+ if (prop && isJoinTable !== undefined && isJoinTable === true) {
671
+ // 关联表时将点改成下划线,如果没点,则表示是主表字段,拼接主表tableName,因为列表组件中是这样处理的
672
+ const replaceDot = '__'
673
+ if (prop.indexOf('.') > 0) {
674
+ prop = prop.replace('.', replaceDot)
675
+ } else {
676
+ if (
677
+ tableName &&
678
+ tableName !== null &&
679
+ tableName !== '' &&
680
+ prop.indexOf(tableName + replaceDot) < 0
681
+ ) {
682
+ // 如果属性名没有拼接表名才需要拼接
683
+ prop = tableName + replaceDot + prop
684
+ }
685
+ }
680
686
  }
681
- }
682
- return prop
687
+ return prop
683
688
  }
684
689
 
685
690
  export function isImage(fileName) {
686
- // const fileType = fileName.substring(fileName.lastIndexOf('.'), fileName.length).toLowerCase()
687
- // const imageTypes = ['.jpg', '.JPG', '.png', '.bmp', '.BMP', '.jpeg', '.gif', '.psd', '.tif', '.tga', '.svg', '.eps']
688
- // const index = imageTypes.indexOf(fileType)
689
- if (
690
- /\.(jpg|JPG|jpeg|JPEG|png|PNG|gif|GIF|bmp|BMP|psd|PSD|tif|TIF)$/.test(
691
- fileName
692
- )
693
- ) {
694
- return true
695
- } else {
696
- return false
697
- }
691
+ // const fileType = fileName.substring(fileName.lastIndexOf('.'), fileName.length).toLowerCase()
692
+ // const imageTypes = ['.jpg', '.JPG', '.png', '.bmp', '.BMP', '.jpeg', '.gif', '.psd', '.tif', '.tga', '.svg', '.eps']
693
+ // const index = imageTypes.indexOf(fileType)
694
+ if (
695
+ /\.(jpg|JPG|jpeg|JPEG|png|PNG|gif|GIF|bmp|BMP|psd|PSD|tif|TIF)$/.test(
696
+ fileName
697
+ )
698
+ ) {
699
+ return true
700
+ } else {
701
+ return false
702
+ }
698
703
  }