UNPKG

tian-yan-yan

Version:

一套不算好用的组件

59 lines (47 loc) 1.16 kB
/* * 弹出框 * @author: 张文 * @date 2022-07-28 * */ import {Language} from "./Language"; // 处理传入的数据 function format(obj){ if (obj.msgList && obj.msgList.length) { obj.allowHtml = true const msg = obj.msgList.map(item => { return ` <div style="text-align: left" class="ty-global-row"> <span class="ty-global-title" >${item.key}</span> <span class="ty-global-value-bold" >${item.value}</span> </div> ` }) obj.message = ` <div class="ty-global-value">${obj.message}</div> ${msg.join('')} ` } if (!obj.confirmButtonText){ obj.confirmButtonText = Language.get('utils.dialog.confirm','确认') } if (!obj.cancelButtonText){ obj.cancelButtonText = Language.get('utils.dialog.cancel','取消') } return obj } export function tyDialog(){ const that = this return { confirm(obj){ return that.$dialog.confirm(format(obj)) }, // 提示框 alert(obj){ return that.$dialog.alert(format(obj)) }, } }