mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
synced 2026-09-21 04:12:03 +08:00
升级Vue3,iView替换ElementPlus
- 删除babel配置、更新依赖与入口初始化 - 全量替换UI组件、样式适配,新增迁移文档与标签/过滤器自动化替换脚本
This commit is contained in:
74
seller/src/utils/message.js
Normal file
74
seller/src/utils/message.js
Normal file
@@ -0,0 +1,74 @@
|
||||
import { ElMessage, ElMessageBox } from "element-plus";
|
||||
|
||||
/**
|
||||
* 兼容原 view-design Message API,便于业务页渐进迁移
|
||||
*/
|
||||
export const Message = {
|
||||
success(content) {
|
||||
return ElMessage.success(normalize(content));
|
||||
},
|
||||
error(content) {
|
||||
return ElMessage.error(normalize(content));
|
||||
},
|
||||
warning(content) {
|
||||
return ElMessage.warning(normalize(content));
|
||||
},
|
||||
info(content) {
|
||||
return ElMessage.info(normalize(content));
|
||||
},
|
||||
};
|
||||
|
||||
export const Notice = {
|
||||
open(options = {}) {
|
||||
const fn = Message[options.type] || Message.info;
|
||||
return fn(options.desc || options.title || "");
|
||||
},
|
||||
info(options) {
|
||||
return Message.info(options?.desc || options?.title || "");
|
||||
},
|
||||
success(options) {
|
||||
return Message.success(options?.desc || options?.title || "");
|
||||
},
|
||||
warning(options) {
|
||||
return Message.warning(options?.desc || options?.title || "");
|
||||
},
|
||||
error(options) {
|
||||
return Message.error(options?.desc || options?.title || "");
|
||||
},
|
||||
};
|
||||
|
||||
export const Modal = {
|
||||
confirm(options = {}) {
|
||||
const content = options.content || options.title || "确认操作?";
|
||||
return ElMessageBox.confirm(content, options.title || "提示", {
|
||||
confirmButtonText: options.okText || "确定",
|
||||
cancelButtonText: options.cancelText || "取消",
|
||||
type: options.type || "warning",
|
||||
})
|
||||
.then(() => {
|
||||
if (typeof options.onOk === "function") {
|
||||
return options.onOk();
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
if (typeof options.onCancel === "function") {
|
||||
options.onCancel();
|
||||
}
|
||||
});
|
||||
},
|
||||
remove() {
|
||||
ElMessageBox.close();
|
||||
},
|
||||
};
|
||||
|
||||
function normalize(content) {
|
||||
if (typeof content === "string") return content;
|
||||
if (content && content.content) return content.content;
|
||||
return String(content ?? "");
|
||||
}
|
||||
|
||||
export function setupLegacyMessage(app) {
|
||||
app.config.globalProperties.$Message = Message;
|
||||
app.config.globalProperties.$Modal = Modal;
|
||||
app.config.globalProperties.$Notice = Notice;
|
||||
}
|
||||
26
seller/src/utils/print.js
Normal file
26
seller/src/utils/print.js
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* 打印指定 DOM 区域(替代 vue-print-nb)
|
||||
*/
|
||||
export function printElement(elementId, title = "打印") {
|
||||
const el = document.getElementById(elementId);
|
||||
if (!el) {
|
||||
console.warn(`[print] element #${elementId} not found`);
|
||||
return;
|
||||
}
|
||||
const iframe = document.createElement("iframe");
|
||||
iframe.style.cssText = "position:fixed;right:0;bottom:0;width:0;height:0;border:0";
|
||||
document.body.appendChild(iframe);
|
||||
const doc = iframe.contentWindow.document;
|
||||
doc.open();
|
||||
doc.write(
|
||||
`<!DOCTYPE html><html><head><title>${title}</title><style>
|
||||
body{font-family:Arial,sans-serif;padding:12px;color:#333}
|
||||
table{width:100%;border-collapse:collapse}
|
||||
td,th{border:1px solid #ddd;padding:6px}
|
||||
</style></head><body>${el.innerHTML}</body></html>`
|
||||
);
|
||||
doc.close();
|
||||
iframe.contentWindow.focus();
|
||||
iframe.contentWindow.print();
|
||||
setTimeout(() => document.body.removeChild(iframe), 1000);
|
||||
}
|
||||
Reference in New Issue
Block a user