af-mobile-client-vue3 1.3.84 → 1.3.85

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "af-mobile-client-vue3",
3
3
  "type": "module",
4
- "version": "1.3.84",
4
+ "version": "1.3.85",
5
5
  "packageManager": "pnpm@10.13.1",
6
6
  "description": "Vue + Vite component lib",
7
7
  "engines": {
@@ -418,15 +418,50 @@ function splitArrayAt<T>(array: T[], index: number) {
418
418
 
419
419
  // 新增:动态获取按钮分组
420
420
  function getActionGroups(item: any, index: number) {
421
- // 先过滤出当前行可见的按钮
422
- const visibleActions = allActions.value.filter(action =>
423
- evaluateCustomFunction(action.customFunction, item, index),
424
- )
425
- // 前3个为主按钮,其余为更多按钮,保持逆序
426
- return {
427
- main: visibleActions.slice(0, 3).reverse(),
428
- more: visibleActions.slice(3).reverse(),
421
+ const main: any[] = []
422
+ const more: any[] = []
423
+ let mainCount = 0
424
+
425
+ // 遍历所有按钮,同时处理显示/隐藏和样式,避免多次遍历
426
+ for (const action of allActions.value) {
427
+ let visible = true
428
+ let buttonStyle = {}
429
+
430
+ // 处理有 customFunction 的按钮
431
+ if (action.customFunction) {
432
+ try {
433
+ const result = executeStrFunctionByContext(currInst, action.customFunction, [item, index])
434
+
435
+ if (typeof result === 'boolean') {
436
+ visible = result
437
+ }
438
+ else if (result && typeof result === 'object') {
439
+ visible = true
440
+ buttonStyle = result
441
+ }
442
+ }
443
+ catch (error) {
444
+ console.error('Error in getActionGroups customFunction:', error)
445
+ visible = false
446
+ }
447
+ }
448
+
449
+ // 只处理可见的按钮
450
+ if (visible) {
451
+ const processedAction = { ...action, buttonStyle }
452
+
453
+ // 直接分配到 main 或 more,避免后续的 slice 和 reverse 操作
454
+ if (mainCount < 3) {
455
+ main.unshift(processedAction) // 使用 unshift 实现逆序
456
+ mainCount++
457
+ }
458
+ else {
459
+ more.unshift(processedAction) // 使用 unshift 实现逆序
460
+ }
461
+ }
429
462
  }
463
+
464
+ return { main, more }
430
465
  }
431
466
 
432
467
  watch(() => searchValue.value, (newVal) => {
@@ -550,32 +585,6 @@ function handleButtonClick(btn, item) {
550
585
  emit(`${btn.btnIcon}`, item)
551
586
  }
552
587
 
553
- // 处理自定义函数
554
- function evaluateCustomFunction(funcString: string | undefined, record: any, index: number): boolean {
555
- try {
556
- // 如果 customFunction 不存在,返回 true 表示正常显示
557
- if (!funcString || funcString === '')
558
- return true
559
-
560
- // 匹配参数名、函数体
561
- const innerFuncRegex = /function\s*\((\w+)\s*,\s*(\w+)\)\s*\{([\s\S]*)\}/
562
- const matches = funcString.match(innerFuncRegex)
563
-
564
- if (!matches)
565
- return true
566
-
567
- const [, param1, param2, functionBody] = matches
568
-
569
- // eslint-disable-next-line no-new-func
570
- const func = new Function(param1, param2, functionBody)
571
- return func(record, index)
572
- }
573
- catch (error) {
574
- console.error('Error evaluating custom function:', error)
575
- return true
576
- }
577
- }
578
-
579
588
  /**
580
589
  * 函数描述: 传入自定义条件进行查询(传入字段必须在琉璃中配置生成查询项才会生效)
581
590
  * @param {string} params - 查询条件map 例: { os_id:1 }
@@ -988,7 +997,8 @@ function handleCheckboxChange(item: any, checked: boolean) {
988
997
  <VanButton
989
998
  v-for="button in getActionGroups(item, index).main"
990
999
  :key="button.func"
991
- type="primary"
1000
+ :type="button.buttonStyle?.type || 'primary'"
1001
+ :color="button.buttonStyle?.color"
992
1002
  size="normal"
993
1003
  class="action-btn"
994
1004
  :disabled="isMultiSelectMode"