Эх сурвалжийг харах

feat: 常用功能支持同菜单一致的自定义弹窗配置

zhangyuhan 2 жил өмнө
parent
commit
5722b0b596

+ 48 - 1
src/views/workspace/components/CommonUse.vue

@@ -103,7 +103,54 @@ export default {
           }
         })
       } else {
-        this.showNoPowerMessageTip()
+        // 判断是否需要自定义弹窗文案
+        const hasTipInfo = Object.keys(item?.tipInfo || {}).length > 0
+        if (hasTipInfo) {
+          // 自定义弹窗文案
+          const menu = item
+          // 格式化弹窗配置信息
+          const dialogParams = {
+            type: 'tip',
+            title: menu.tipInfo?.title,
+            message: menu.tipInfo?.content,
+            options: Object.assign({
+              dangerouslyUseHTMLString: true,
+              customClass: 'custom-message-box',
+              confirmButtonText: '我知道了',
+              confirmButtonClass: 'custom-confirm-btn',
+              showClose: false,
+              showCancelButton: false,
+              closeOnClickModal: false,
+              center: true
+            }, {
+              showCancelButton: menu.tipInfo?.isShowCancel,
+              confirmButtonText: menu.tipInfo?.confirmText
+            }, menu.tipInfo?.options || {})
+          }
+          this.$confirm(dialogParams.message, dialogParams.title, dialogParams.options).then(() => {
+            // 确认按钮自定义跳转
+            if (menu.tipInfo?.confirmUrl) {
+              // 调用工作桌面函数跳转
+              tryCallHooks({
+                fn: () => {
+                  this.$BRACE.methods.open({
+                    route: {
+                      link: menu.tipInfo?.confirmUrl,
+                      appType: menu.tipInfo?.appType,
+                      openType: menu.tipInfo?.openType
+                    }
+                  })
+                },
+                spareFn: () => {
+                  window.open(menu.tipInfo?.confirmUrl)
+                }
+              })
+            }
+          }).catch(e => e)
+        } else {
+          // 默认文案
+          this.showNoPowerMessageTip()
+        }
       }
     },
     confirmSaveFn () {