agilebuilder-ui 1.0.92 → 1.0.93-temp2

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
@@ -4,7 +4,7 @@ import { getLangByShort } from './common-util'
4
4
 
5
5
  export function getI18n() {
6
6
  let myI18n = window.$i18n
7
- if(!myI18n){
7
+ if (!myI18n) {
8
8
  myI18n = i18n
9
9
  }
10
10
  if (!window.$locale) {
@@ -38,13 +38,7 @@ export function findOptionsByDynamicDataSource(
38
38
  searchParam
39
39
  ) {
40
40
  return new Promise((resolve, reject) => {
41
- findDynamicDataSourceByCode(
42
- dynamicSourceCode,
43
- searchText,
44
- entity,
45
- additionalParameterStr,
46
- searchParam
47
- )
41
+ findDynamicDataSourceByCode(dynamicSourceCode, searchText, entity, additionalParameterStr, searchParam)
48
42
  .then((dynamicDataSourceDto) => {
49
43
  let options = []
50
44
  if (dynamicDataSourceDto && dynamicDataSourceDto.options) {
@@ -63,7 +57,7 @@ export function findOptionsByDynamicDataSource(
63
57
  const label = item['_label_']
64
58
  options.push({
65
59
  label,
66
- value,
60
+ value
67
61
  })
68
62
  })
69
63
  }
@@ -111,11 +105,10 @@ export function findDynamicDataSourceByCode(
111
105
  searchText,
112
106
  watchAttrValue,
113
107
  parent: parentEntity
114
-
115
108
  }
116
- if (additionalParameterStr && typeof (additionalParameterStr) === 'object') {
109
+ if (additionalParameterStr && typeof additionalParameterStr === 'object') {
117
110
  params.additionalParamMap = additionalParameterStr
118
- } else if (additionalParameterStr && typeof (additionalParameterStr) === 'string') {
111
+ } else if (additionalParameterStr && typeof additionalParameterStr === 'string') {
119
112
  params.additionalParamMap = JSON.parse(additionalParameterStr)
120
113
  }
121
114
  if (params.additionalParamMap === undefined) {
@@ -137,23 +130,32 @@ export function findDynamicDataSourceByCode(
137
130
 
138
131
  return new Promise((resolve, reject) => {
139
132
  // 页面设计不请求动态数据源
140
- if (window.$vueApp.config.globalProperties.systemCode !== undefined && window.$vueApp.config.globalProperties.systemCode === 'agilebuilder') {
133
+ if (
134
+ window.$vueApp.config.globalProperties.systemCode !== undefined &&
135
+ window.$vueApp.config.globalProperties.systemCode === 'agilebuilder'
136
+ ) {
141
137
  resolve()
142
138
  } else {
143
- window.$vueApp.config.globalProperties.$http.post(backendUrl + '/common/dynamic-data-source/' + dynamicSourceCode, params).then(result => {
144
- if (result.backendUrl) {
145
- // result.backendUrl表示需要使用动态数据源所属的系统路径重新获得一次数据
146
- window.$vueApp.config.globalProperties.$http.post(result.backendUrl + '/common/dynamic-data-source/' + dynamicSourceCode, params).then(finallyResult => {
147
- resolve(finallyResult)
148
- }).catch(error => {
149
- reject(error)
150
- })
151
- } else {
152
- resolve(result)
153
- }
154
- }).catch(error => {
155
- reject(error)
156
- })
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
+ })
157
159
  }
158
160
  })
159
161
  }
@@ -185,11 +187,7 @@ export function analysisCondition(
185
187
  // console.log('analysisCondition判断条件isSql', isSql)
186
188
  // console.log('analysisCondition判断条件tableName', tableName)
187
189
  // console.log('analysisCondition判断条件parentFormData', parentFormData)
188
- if (
189
- conditionListJson === undefined ||
190
- conditionListJson === '' ||
191
- conditionListJson === null
192
- ) {
190
+ if (conditionListJson === undefined || conditionListJson === '' || conditionListJson === null) {
193
191
  // 如果条件不存在,则默认返回true
194
192
  return true
195
193
  }
@@ -199,32 +197,20 @@ export function analysisCondition(
199
197
  }
200
198
  // 页面附加参数
201
199
  let additionalParameterMap = {}
202
- if (
203
- additionalParameter &&
204
- typeof additionalParameter === 'string' &&
205
- additionalParameter !== ''
206
- ) {
200
+ if (additionalParameter && typeof additionalParameter === 'string' && additionalParameter !== '') {
207
201
  additionalParameterMap = JSON.parse(additionalParameter)
208
202
  } else if (additionalParameter && typeof additionalParameter === 'object') {
209
203
  additionalParameterMap = additionalParameter
210
204
  }
211
205
  // 环境变量,例如:当前用户id、当前用户登录名等
212
206
  let contextParameterMap = {}
213
- if (
214
- contextParameter &&
215
- typeof contextParameter === 'string' &&
216
- contextParameter !== ''
217
- ) {
207
+ if (contextParameter && typeof contextParameter === 'string' && contextParameter !== '') {
218
208
  contextParameterMap = JSON.parse(contextParameter)
219
209
  } else if (contextParameter && typeof contextParameter === 'object') {
220
210
  contextParameterMap = contextParameter
221
211
  }
222
212
  let conditionList = []
223
- if (
224
- conditionListJson &&
225
- typeof conditionListJson === 'string' &&
226
- conditionListJson !== ''
227
- ) {
213
+ if (conditionListJson && typeof conditionListJson === 'string' && conditionListJson !== '') {
228
214
  // conditionList = eval('('+conditionListJson+')')
229
215
  conditionList = JSON.parse(conditionListJson)
230
216
  } else if (conditionListJson && Array.isArray(conditionListJson)) {
@@ -252,11 +238,7 @@ function parseCondition(
252
238
  parentFormData,
253
239
  pageContext
254
240
  ) {
255
- if (
256
- conditionList === undefined ||
257
- conditionList === null ||
258
- conditionList.length === 0
259
- ) {
241
+ if (conditionList === undefined || conditionList === null || conditionList.length === 0) {
260
242
  // 表示没有设置条件,默认是true
261
243
  return true
262
244
  }
@@ -282,10 +264,7 @@ function parseCondition(
282
264
  leftValue = getValue(entity, propDbName, isSql)
283
265
  }
284
266
  if (leftValue === undefined || leftValue === null) {
285
- if (
286
- tableName &&
287
- propDbName.toLowerCase().startsWith(tableName.toLowerCase() + '.')
288
- ) {
267
+ if (tableName && propDbName.toLowerCase().startsWith(tableName.toLowerCase() + '.')) {
289
268
  // 表示是当前表的字段
290
269
  const myProp = propDbName.substring(propDbName.indexOf('.'))
291
270
  leftValue = getValue(entity, myProp, isSql)
@@ -311,27 +290,17 @@ function parseCondition(
311
290
  // 解析单个条件的值
312
291
  // 判断value类型
313
292
  let value
314
- if(pageContext){
293
+ if (pageContext) {
315
294
  value = getPropValueNew(propValue, pageContext)
316
295
  } else {
317
- value = getPropValue(
318
- propValue,
319
- entity,
320
- additionalParamMap,
321
- contextParameterMap
322
- )
296
+ value = getPropValue(propValue, entity, additionalParamMap, contextParameterMap)
323
297
  }
324
298
  if (variableIsNullStr && variableIsNullStr === 'null') {
325
299
  if (value === undefined || value === '') {
326
300
  value = null
327
301
  }
328
302
  }
329
- let conditionResult = executeExpression(
330
- leftValue,
331
- operator,
332
- value,
333
- dataType
334
- )
303
+ let conditionResult = executeExpression(leftValue, operator, value, dataType)
335
304
  const leftBracket = condition.leftBracket
336
305
  const rightBracket = condition.rightBracket
337
306
  let joinSign = condition.joinSign
@@ -459,33 +428,27 @@ function getContextValue(contextParameterMap, propValue) {
459
428
  */
460
429
  export function getLastNDate(propValue) {
461
430
  let value
462
- if (propValue &&
463
- propValue === 'currentTime') {
431
+ if (propValue && propValue === 'currentTime') {
464
432
  // 当前时间
465
433
  value = new Date()
466
434
  }
467
- if (propValue &&
468
- propValue === 'currentWeek') {
435
+ if (propValue && propValue === 'currentWeek') {
469
436
  // 本周
470
437
  value = getCurrentWeek()
471
438
  }
472
- if (propValue &&
473
- propValue === 'currentMonth') {
439
+ if (propValue && propValue === 'currentMonth') {
474
440
  // 本月
475
441
  value = getCurrentMonth()
476
442
  }
477
- if (propValue &&
478
- propValue === 'currentQuarter') {
443
+ if (propValue && propValue === 'currentQuarter') {
479
444
  // 本季度
480
445
  value = getCurrentQuarter()
481
446
  }
482
- if (propValue &&
483
- propValue === 'currentYear') {
447
+ if (propValue && propValue === 'currentYear') {
484
448
  // 本年
485
449
  value = getCurrentYear()
486
450
  }
487
- if (propValue &&
488
- propValue.indexOf('lastNDay') >= 0) {
451
+ if (propValue && propValue.indexOf('lastNDay') >= 0) {
489
452
  // 最近n天 lastNDay:n,例如:lastNDay:5,表示最近5天
490
453
  const n = propValue.substring(propValue.indexOf(':') + 1)
491
454
  value = getLastNDay(parseInt(n))
@@ -495,19 +458,19 @@ export function getLastNDate(propValue) {
495
458
  /**
496
459
  * 获得当前周的周一和周日的的日期
497
460
  * 例如:[2024/2/26 00:00:00,2023/3/3 23:59:59]
498
- * @returns
461
+ * @returns
499
462
  */
500
463
  function getCurrentWeek() {
501
464
  const new_Date = new Date() //获取本周一周日期
502
- const timesStamp = new_Date.getTime();
503
- const currenDay = new_Date.getDay();
465
+ const timesStamp = new_Date.getTime()
466
+ const currenDay = new_Date.getDay()
504
467
  // 周一
505
- const monday = new Date(timesStamp + 24 * 60 * 60 * 1000 * (0 - (currenDay + 6) % 7))
468
+ const monday = new Date(timesStamp + 24 * 60 * 60 * 1000 * (0 - ((currenDay + 6) % 7)))
506
469
  // 周日
507
- const sunday = new Date(timesStamp + 24 * 60 * 60 * 1000 * (6 - (currenDay + 6) % 7))
508
- const startDate = monday.toLocaleDateString() + " " + monday.toLocaleTimeString()
509
- const endDate = sunday.toLocaleDateString() + " " + sunday.toLocaleTimeString()
510
- console.log(`getCurrentMonth从 ${startDate} 开始,到 ${endDate} 结束`);
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} 结束`)
511
474
  return [monday, sunday]
512
475
  }
513
476
  /**
@@ -517,107 +480,109 @@ function getCurrentWeek() {
517
480
  */
518
481
  function getCurrentMonth() {
519
482
  // 创建一个新的Date对象,表示当前时间
520
- const currentDate = new Date();
483
+ const currentDate = new Date()
521
484
 
522
485
  // 获取当前年份和月份
523
- const year = currentDate.getFullYear(); // 获取完整的四位年份
524
- const month = currentDate.getMonth() + 1; // getMonth返回值范围为0-11,因此加上1得到真正的月份
486
+ const year = currentDate.getFullYear() // 获取完整的四位年份
487
+ const month = currentDate.getMonth() + 1 // getMonth返回值范围为0-11,因此加上1得到真正的月份
525
488
 
526
489
  // 设置起始日期为本月第一天
527
- currentDate.setDate(1);
490
+ currentDate.setDate(1)
528
491
 
529
492
  // 将起始日期格式化成字符串形式(YYYY-MM-DD)
530
- const startDateStr = `${year}/${month < 10 ? '0' : ''}${month}/01`;
493
+ const startDateStr = `${year}/${month < 10 ? '0' : ''}${month}/01`
531
494
 
532
495
  // 设置结束日期为下个月第一天的前一天
533
- currentDate.setMonth(currentDate.getMonth() + 2);
534
- currentDate.setDate(0);
496
+ currentDate.setMonth(currentDate.getMonth() + 2)
497
+ currentDate.setDate(0)
535
498
 
536
499
  // 将结束日期格式化成字符串形式(YYYY-MM-DD)
537
- const endDateStr = `${currentDate.getFullYear()}/${currentDate.getMonth() < 9 ? '0' : ''}${(currentDate.getMonth() + 1)}/01`;
500
+ const endDateStr = `${currentDate.getFullYear()}/${currentDate.getMonth() < 9 ? '0' : ''}${
501
+ currentDate.getMonth() + 1
502
+ }/01`
538
503
  const startDate11 = new Date(Date.parse(startDateStr))
539
504
  const endDate11 = new Date(new Date(Date.parse(endDateStr)).getTime() - 1000)
540
- const startDate = startDate11.toLocaleDateString() + " " + startDate11.toLocaleTimeString()
541
- const endDate = endDate11.toLocaleDateString() + " " + endDate11.toLocaleTimeString()
542
- console.log(`getCurrentMonth从 ${startDate} 开始,到 ${endDate} 结束`);
505
+ const startDate = startDate11.toLocaleDateString() + ' ' + startDate11.toLocaleTimeString()
506
+ const endDate = endDate11.toLocaleDateString() + ' ' + endDate11.toLocaleTimeString()
507
+ console.log(`getCurrentMonth从 ${startDate} 开始,到 ${endDate} 结束`)
543
508
  return [startDate11, endDate11]
544
509
  }
545
510
  /**
546
511
  * 获得当前季度第1天和最后一天的日期
547
512
  * 例如:[2023/1/1 00:00:00,2023/3/31 23:59:59]
548
- * @returns
513
+ * @returns
549
514
  */
550
515
  function getCurrentQuarter() {
551
- const currentDate = new Date();
552
- const quarterStartIndex = (currentDate.getMonth() + 3) % 12;
553
- let firstDayOfQuarter; // 存放第一天的Date对象
516
+ const currentDate = new Date()
517
+ const quarterStartIndex = (currentDate.getMonth() + 3) % 12
518
+ let firstDayOfQuarter // 存放第一天的Date对象
554
519
  if (currentDate.getMonth() < quarterStartIndex + 2) {
555
- firstDayOfQuarter = new Date(currentDate.getFullYear(), quarterStartIndex, 1);
520
+ firstDayOfQuarter = new Date(currentDate.getFullYear(), quarterStartIndex, 1)
556
521
  } else {
557
- firstDayOfQuarter = new Date(currentDate.getFullYear() + 1, quarterStartIndex, 1);
522
+ firstDayOfQuarter = new Date(currentDate.getFullYear() + 1, quarterStartIndex, 1)
558
523
  }
559
524
 
560
- let lastDayOfQuarter; // 存放最后一天的Date对象
525
+ let lastDayOfQuarter // 存放最后一天的Date对象
561
526
  if (firstDayOfQuarter.getMonth() === 11) {
562
- lastDayOfQuarter = new Date(firstDayOfQuarter.getFullYear() + 1, 0, 0);
527
+ lastDayOfQuarter = new Date(firstDayOfQuarter.getFullYear() + 1, 0, 0)
563
528
  } else {
564
- lastDayOfQuarter = new Date(firstDayOfQuarter.getFullYear(), firstDayOfQuarter.getMonth() + 3, 0);
529
+ lastDayOfQuarter = new Date(firstDayOfQuarter.getFullYear(), firstDayOfQuarter.getMonth() + 3, 0)
565
530
  }
566
- lastDayOfQuarter = new Date(lastDayOfQuarter.getTime() + (24 * 60 * 60 * 1000) - 1000)
567
- const startDate = firstDayOfQuarter.toLocaleDateString() + " " + firstDayOfQuarter.toLocaleTimeString()
568
- const endDate = lastDayOfQuarter.toLocaleDateString() + " " + lastDayOfQuarter.toLocaleTimeString()
569
- console.log(`getCurrentQuarter从 ${startDate} 开始,到 ${endDate} 结束`);
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} 结束`)
570
535
  return [firstDayOfQuarter, lastDayOfQuarter]
571
536
  }
572
537
  /**
573
538
  * 获得本年的第1天和最后一天的日期
574
539
  * 例如:[2023/1/1 00:00:00,2023/12/31 23:59:59]
575
- * @returns
540
+ * @returns
576
541
  */
577
542
  function getCurrentYear() {
578
543
  // 创建一个新的日期对象
579
- const currentYear = new Date().getFullYear(); // 获取当前年份
544
+ const currentYear = new Date().getFullYear() // 获取当前年份
580
545
 
581
546
  // 设置为当前年的1月1号(第一天)
582
- let firstDayOfCurrentYear = new Date(currentYear, 0);
583
- firstDayOfCurrentYear.setMonth(0, 1); // 将月份设置为0表示1月
547
+ let firstDayOfCurrentYear = new Date(currentYear, 0)
548
+ firstDayOfCurrentYear.setMonth(0, 1) // 将月份设置为0表示1月
584
549
 
585
550
  // 设置为下一年的12月31号(最后一天)
586
- let lastDayOfCurrentYear = new Date(currentYear + 1, 0);
551
+ let lastDayOfCurrentYear = new Date(currentYear + 1, 0)
587
552
  lastDayOfCurrentYear = lastDayOfCurrentYear.getTime() - 1000
588
553
  lastDayOfCurrentYear = new Date(lastDayOfCurrentYear)
589
- const startDate = firstDayOfCurrentYear.toLocaleDateString() + " " + firstDayOfCurrentYear.toLocaleTimeString()
590
- const endDate = lastDayOfCurrentYear.toLocaleDateString() + " " + lastDayOfCurrentYear.toLocaleTimeString()
591
- console.log(`getCurrentYear从 ${startDate} 开始,到 ${endDate} 结束`);
554
+ const startDate = firstDayOfCurrentYear.toLocaleDateString() + ' ' + firstDayOfCurrentYear.toLocaleTimeString()
555
+ const endDate = lastDayOfCurrentYear.toLocaleDateString() + ' ' + lastDayOfCurrentYear.toLocaleTimeString()
556
+ console.log(`getCurrentYear从 ${startDate} 开始,到 ${endDate} 结束`)
592
557
  return [firstDayOfCurrentYear, lastDayOfCurrentYear]
593
558
  }
594
559
  /**
595
560
  * 获得最近n天的日期[n天前,当前日期]。
596
561
  * 例如:[2024/2/25 00:00:00,2024/2/29 23:59:59]
597
- * @param {} n
562
+ * @param {} n
598
563
  */
599
564
  function getLastNDay(n) {
600
- let currentDate = new Date(); // 创建一个表示今天的Date对象
601
- let year = currentDate.getFullYear(); // 获取完整的四位年份
602
- let month = currentDate.getMonth() + 1; // getMonth返回值范围为0-11,因此加上1得到真正的月份
603
- let date = currentDate.getDate(); // getMonth返回值范围为0-11,因此加上1得到真正的月份
604
- let startDateStr = `${year}/${month < 10 ? '0' : ''}${month}/${date}`;
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}`
605
570
  currentDate = new Date(Date.parse(startDateStr))
606
571
  currentDate.setDate(currentDate.getDate() + 1)
607
572
  currentDate = new Date(currentDate.getTime() - 1000)
608
573
 
609
- let lastNDay = new Date(); // 创建一个表示今天的Date对象
610
- lastNDay.setDate(lastNDay.getDate() - (n - 1));
611
- const lastNYear = lastNDay.getFullYear(); // 获取完整的四位年份
612
- const lastNMonth = lastNDay.getMonth() + 1; // getMonth返回值范围为0-11,因此加上1得到真正的月份
613
- const lastNDate = lastNDay.getDate(); // getMonth返回值范围为0-11,因此加上1得到真正的月份
614
- const endtDateStr = `${lastNYear}/${lastNMonth < 10 ? '0' : ''}${lastNMonth}/${lastNDate}`;
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}`
615
580
  lastNDay = new Date(Date.parse(endtDateStr))
616
581
 
617
- const startDate = lastNDay.toLocaleDateString() + " " + lastNDay.toLocaleTimeString()
618
- const endDate = currentDate.toLocaleDateString() + " " + currentDate.toLocaleTimeString()
619
- console.log(`getLastNDay从 ${startDate} 开始,到 ${endDate} 结束`);
620
- retur[lastNDay, currentDate]
582
+ const startDate = lastNDay.toLocaleDateString() + ' ' + lastNDay.toLocaleTimeString()
583
+ const endDate = currentDate.toLocaleDateString() + ' ' + currentDate.toLocaleTimeString()
584
+ console.log(`getLastNDay从 ${startDate} 开始,到 ${endDate} 结束`)
585
+ retur[(lastNDay, currentDate)]
621
586
  }
622
587
  export function getPropValue(
623
588
  propValue,
@@ -628,53 +593,61 @@ export function getPropValue(
628
593
  subEntity,
629
594
  task
630
595
  ) {
631
- const pageContext = {entity:{data: entity, context: contextParameterMap, request: additionalParamMap, parent: parentEntity, row: subEntity, task: task}}
632
- return getPropValueNew(propValue,pageContext)
596
+ const pageContext = {
597
+ entity: {
598
+ data: entity,
599
+ context: contextParameterMap,
600
+ request: additionalParamMap,
601
+ parent: parentEntity,
602
+ row: subEntity,
603
+ task: task
604
+ }
605
+ }
606
+ return getPropValueNew(propValue, pageContext)
633
607
  }
634
608
 
635
- function getAdditionalParamMap(pageContext){
636
- if(pageContext && pageContext.entity){
637
- let additionalParamMap = pageContext.entity.page
638
- if(!additionalParamMap){
639
- additionalParamMap = {}
640
- }
641
- const requestMap = pageContext.entity.request
642
- if (requestMap) {
643
- Object.assign(additionalParamMap, requestMap)
644
- }
645
- return additionalParamMap
646
- }
647
- }
648
-
649
- export function getPropValueNew(
650
- propValue,
651
- pageContext
652
- ) {
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)
618
+ }
619
+ return additionalParamMap
620
+ }
621
+ }
622
+
623
+ export function getPropValueNew(propValue, pageContext) {
653
624
  let value = null
654
625
  if (propValue && propValue !== null && propValue !== '') {
655
- const entity = pageContext && pageContext.entity?pageContext.entity.data:null
626
+ const entity = pageContext && pageContext.entity ? pageContext.entity.data : null
656
627
  const additionalParamMap = getAdditionalParamMap(pageContext)
657
- const contextParameterMap = pageContext && pageContext.entity?pageContext.entity.context: null
658
- const parentEntity = pageContext && pageContext.entity?(pageContext.entity.parent?pageContext.entity.parent:pageContext.entity.data): null
659
- const subEntity = pageContext && pageContext.entity?pageContext.entity.row: null
660
- const task = pageContext && pageContext.entity?pageContext.entity.task: null
661
- const system = pageContext && pageContext.entity?pageContext.entity.system: null
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
662
638
  if (propValue === 'null') {
663
639
  value = null
664
640
  } else if (
665
641
  propValue.includes('${context.') ||
666
642
  propValue.includes('${request.') ||
667
- propValue.includes('${obj.')||
643
+ propValue.includes('${obj.') ||
668
644
  propValue.includes('${data.')
669
645
  ) {
670
646
  // 填写的固定值
671
647
  if (propValue.includes('${context.')) {
672
648
  propValue = propValue.replace('${context.', '').replace('}', '')
673
649
  value = getContextValue(contextParameterMap, propValue)
674
- } else if (
675
- propValue.includes('${request.') &&
676
- propValue !== '${request.term}'
677
- ) {
650
+ } else if (propValue.includes('${request.') && propValue !== '${request.term}') {
678
651
  // ${request.term}表示页面中手动输入的值
679
652
  propValue = propValue.replace('${request.', '').replace('}', '')
680
653
  if (
@@ -710,7 +683,7 @@ function getAdditionalParamMap(pageContext){
710
683
  const propName = propValue.replace('${parent.', '').replace('}', '')
711
684
  value = getEntityFieldValue(parentEntity, propName)
712
685
  }
713
- }else if (propValue.includes('${system.')) {
686
+ } else if (propValue.includes('${system.')) {
714
687
  if (system === undefined || system == null) {
715
688
  value = null
716
689
  } else {
@@ -731,7 +704,7 @@ function getAdditionalParamMap(pageContext){
731
704
  const propName = propValue.replace('${subObj.', '').replace('}', '')
732
705
  value = getEntityFieldValue(subEntity, propName)
733
706
  }
734
- }else if (propValue.includes('${input.') ) {
707
+ } else if (propValue.includes('${input.')) {
735
708
  value = propValue.replace('${input.', '').replace('}', '')
736
709
  } else if (propValue.includes('${fixed.')) {
737
710
  value = propValue.replace('${fixed.', '').replace('}', '')
@@ -750,13 +723,7 @@ function getAdditionalParamMap(pageContext){
750
723
  * @param {*} contextParameter
751
724
  * @returns
752
725
  */
753
- export function analysisValue(
754
- conditionValue,
755
- entity,
756
- additionalParameter,
757
- contextParameter,
758
- pageContext
759
- ) {
726
+ export function analysisValue(conditionValue, entity, additionalParameter, contextParameter, pageContext) {
760
727
  if (!conditionValue) {
761
728
  return
762
729
  }
@@ -765,18 +732,10 @@ export function analysisValue(
765
732
  if (split != null && split.length > 0) {
766
733
  split.forEach((item) => {
767
734
  let value
768
- if(pageContext){
769
- value = getPropValueNew(
770
- item,
771
- pageContext
772
- )
735
+ if (pageContext) {
736
+ value = getPropValueNew(item, pageContext)
773
737
  } else {
774
- value = getPropValue(
775
- item,
776
- entity,
777
- additionalParameter,
778
- contextParameter
779
- )
738
+ value = getPropValue(item, entity, additionalParameter, contextParameter)
780
739
  }
781
740
  if (!value || value === null) {
782
741
  value = ''
@@ -842,6 +801,9 @@ export function getEntityFieldValueWithOutCase(entity, prop) {
842
801
  * @returns
843
802
  */
844
803
  export function getEntityFieldValue(entity, prop, isLowerCase) {
804
+ if (!prop) {
805
+ return null
806
+ }
845
807
  let value = getEntityFieldValueWithCase(entity, prop)
846
808
  if (value === undefined || value === null) {
847
809
  // 兼容mysql数据库
@@ -918,17 +880,13 @@ export function findSystemInfoByCode(systemCode) {
918
880
  }
919
881
 
920
882
  window.$vueApp.config.globalProperties.$http
921
- .get(
922
- window.$vueApp.config.globalProperties.baseAPI +
923
- '/component/business-systems/' +
924
- systemCode
925
- )
883
+ .get(window.$vueApp.config.globalProperties.baseAPI + '/component/business-systems/' + systemCode)
926
884
  .then((system) => {
927
885
  if (system) {
928
886
  resolve({
929
887
  zh_CN: system.name,
930
888
  en_US: system.enName,
931
- frontendUrl: system.frontendUrl,
889
+ frontendUrl: system.frontendUrl
932
890
  })
933
891
  } else {
934
892
  resolve('系统:' + systemCode + '不存在')
@@ -947,12 +905,7 @@ export function getPropNameWhenJoinTable(prop, isJoinTable, tableName) {
947
905
  if (prop.indexOf('.') > 0) {
948
906
  prop = prop.replace('.', replaceDot)
949
907
  } else {
950
- if (
951
- tableName &&
952
- tableName !== null &&
953
- tableName !== '' &&
954
- prop.indexOf(tableName + replaceDot) < 0
955
- ) {
908
+ if (tableName && tableName !== null && tableName !== '' && prop.indexOf(tableName + replaceDot) < 0) {
956
909
  // 如果属性名没有拼接表名才需要拼接
957
910
  prop = tableName + replaceDot + prop
958
911
  }
@@ -965,11 +918,7 @@ export function isImage(fileName) {
965
918
  // const fileType = fileName.substring(fileName.lastIndexOf('.'), fileName.length).toLowerCase()
966
919
  // const imageTypes = ['.jpg', '.JPG', '.png', '.bmp', '.BMP', '.jpeg', '.gif', '.psd', '.tif', '.tga', '.svg', '.eps']
967
920
  // const index = imageTypes.indexOf(fileType)
968
- if (fileName &&
969
- /\.(jpg|JPG|jpeg|JPEG|png|PNG|gif|GIF|bmp|BMP|psd|PSD|tif|TIF)$/.test(
970
- fileName
971
- )
972
- ) {
921
+ if (fileName && /\.(jpg|JPG|jpeg|JPEG|png|PNG|gif|GIF|bmp|BMP|psd|PSD|tif|TIF)$/.test(fileName)) {
973
922
  return true
974
923
  } else {
975
924
  return false