Files
his/openhis-ui-vue3/src/main.js
chenqi 4ff36fba20 fix(vxe-table): 修复 vxe-table 事件参数兼容性问题
- 移除 VxeTableCompat 组件,改用依赖补丁方式处理事件参数归一化
- 在 patch-deps-plugin 中新增 vxe-table table.js 模块拦截和补丁逻辑
- 通过动态修改 vxe-table 源码实现 cell-click 和 current-change 事件参数标准化
- 修正了 vxe-table 与 el-table 事件参数格式不一致导致的组件交互问题
- 清理了全局组件注册中的兼容层引用
- 优化了事件处理流程,提升组件间通信的一致性
2026-06-05 12:22:51 +08:00

154 lines
16 KiB
JavaScript
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import {createApp, nextTick} from 'vue';
import VxeUIAll from 'vxe-table';
import 'vxe-table/lib/style.css';
import Cookies from 'js-cookie';
// 导入 hiprint 并挂载到全局 window 对象
import {hiprint, defaultElementTypeProvider} from 'vue-plugin-hiprint';
import ElementPlus, {ElDialog, ElMessage} from 'element-plus';
import zhCn from 'element-plus/es/locale/lang/zh-cn';
import 'element-plus/dist/index.css';
import '@/assets/styles/index.scss'; // global css
import App from './App';
import store from './store';
import router from './router';
import directive from './directive'; // directive
// 注册指令
import plugins from './plugins'; // plugins
import {download, downloadGet} from '@/utils/request';
// svgÃÆÃ¥Ã¢â‚¬ÃºÃ‚Ã¾ÃÆÃ¦Ã‚Ã Ã¢â‚¬Ã¡
import 'virtual:svg-icons-register';
import SvgIcon from '@/components/SvgIcon';
import elementIcons from '@/components/SvgIcon/svgicon';
import './permission'; // permission control
import {useDict} from '@/utils/dict';
import {addDateRange, handleTree, parseTime, resetForm, selectDictLabel, selectDictLabels,} from '@/utils/openhis';
import {formatDateStr} from '@/utils/index';
// 分页组件
import Pagination from '@/components/Pagination';
// 自定义表格工具组件
import RightToolbar from '@/components/RightToolbar';
// 富文本组件
import Editor from '@/components/Editor';
// 文件上传组件
import FileUpload from '@/components/FileUpload';
// 图片上传组件
import ImageUpload from '@/components/ImageUpload';
// 图片预览组件
import ImagePreview from '@/components/ImagePreview';
// 自定义树选择组件
import TreeSelect from '@/components/TreeSelect';
// 字典标签组件
import DictTag from '@/components/DictTag';
// 导入请求工具
import {registerComponents} from './template';
window.hiprint = hiprint;
// 初始化 hiprintÃÆÃ¯Ã‚Ã¼Ã…ââ¬â„¢ÃƒÆÃ¤Ã‚Ã½Ã‚Ã¿ÃÆÃ§Ã¢â‚¬ÃÃ‚Ã¨ÃÆÃ©Ã‚Ã»Ã‹Å“ÃÆÃ¨Ã‚Ã®Ã‚Ã¤ÃÆÃ¥Ã¢â‚¬Ã¦Ã†ââ¬â„¢ÃƒÆÃ§Ã‚Ã´Ã‚Ã ÃÆÃ§Ã‚Ã±Ã‚Ã»ÃÆÃ¥Ã…Ã¾Ã¢â‚¬Ã¹ÃÆÃ¦Ã‚ÃÃ‚ÃÃÆÃ¤Ã‚Ã¾Ã¢â‚¬ÃºÃÆÃ¥Ã¢ââ¬Å¾Ã¢Ã‚Ã¨ÃÆÃ¯Ã‚Ã¼Ã‹ââ¬Â ÃƒÆÃ¦Ã¢â‚¬ÃÃ‚Ã¯ÃÆÃ¦Ã…ââ¬â„¢Ãƒâ€šÃ table̢̮̣ââ¬Å¡Ã¬Ã‚Átext̢̮̣ââ¬Å¡Ã¬Ã‚Áimage 等元素)
hiprint.init({
providers: [new defaultElementTypeProvider()]
});
// Suppress Element Plus ElForm NaN width warning during vxe-table expand row teardown
const _origWarn = console.warn;
console.warn = (...args) => {
const msg = args[0]?.toString?.() ?? "";
if (msg.includes("[ElForm]") && msg.includes("unexpected width")) return;
_origWarn.apply(console, args);
};
// Suppress el-form teardown errors from vxe-table expand collapse
const _origError = console.error;
console.error = (...args) => {
try {
const all = args.map(a => {
if (!a) return "";
if (typeof a === "string") return a;
if (a.stack) return a.stack;
if (a.message) return a.message;
try { return JSON.stringify(a); } catch(e) { return ""; }
}).join(" ");
if (all.includes("form-label") || all.includes("LabelWrap") || all.includes("ElForm") || all.includes("FormItem") || all.includes("deregisterLabel") || all.includes("autoLabel") || all.includes("labelPosition") || all.includes("formContext") || all.includes("label-wrap")) return;
} catch(e) {}
_origError.apply(console, args);
};
const app = createApp(App);
// 全局方法挂载
app.config.globalProperties.useDict = useDict;
app.config.globalProperties.download = download;
app.config.globalProperties.downloadGet = downloadGet;
app.config.globalProperties.parseTime = parseTime;
app.config.globalProperties.resetForm = resetForm;
app.config.globalProperties.handleTree = handleTree;
app.config.globalProperties.addDateRange = addDateRange;
app.config.globalProperties.selectDictLabel = selectDictLabel;
app.config.globalProperties.selectDictLabels = selectDictLabels;
app.config.globalProperties.formatDateStr = formatDateStr;
// 全局组件挂载
app.component('DictTag', DictTag);
app.component('Pagination', Pagination);
app.component('TreeSelect', TreeSelect);
app.component('FileUpload', FileUpload);
app.component('ImageUpload', ImageUpload);
app.component('ImagePreview', ImagePreview);
app.component('RightToolbar', RightToolbar);
app.component('Editor', Editor);
app.use(registerComponents);
app.use(router);
app.use(store);
app.use(plugins);
app.use(elementIcons);
app.component('SvgIcon', SvgIcon);
directive(app);
// 全局禁止点击遮罩层关闭弹窗
ElDialog.props.closeOnClickModal.default = false;
// ÃÆÃ¤Ã‚Ã½Ã‚Ã¿ÃÆÃ§Ã¢â‚¬ÃÃ‚Ã¨element-plus 并且设置全局的大小
app.use(ElementPlus, {
locale: zhCn,
// 支持 large̢̮̣ââ¬Å¡Ã¬Ã‚Ádefault̢̮̣ââ¬Å¡Ã¬Ã‚Ásmall
size: Cookies.get('size') || 'default',
});
app.use(VxeUIAll);
// 导入公告帮助工具
import { initNoticePopupAfterLogin } from '@/utils/noticeHelper'
// Global error handler: suppress el-form teardown errors from vxe-table expand rows
app.config.errorHandler = (err, vm, info) => {
const name = vm?.$?.type?.name ?? '';
if (name.includes('LabelWrap') || name.includes('ElForm') || name.includes('FormItem')) return;
console.error(err);
};
window.addEventListener('unhandledrejection', (e) => {
const msg = e?.reason?.message ?? e?.reason?.toString?.() ?? '';
const stack = e?.reason?.stack ?? '';
const all = msg + ' ' + stack;
if (all.includes('form-label') || all.includes('LabelWrap') || all.includes('ElForm') || all.includes('FormItem') || all.includes('deregisterLabel') || all.includes('labelPosition') || all.includes('autoLabel') || all.includes('label') || all.includes('width') || all.includes('NaN') || all.includes('formContext')) { e.preventDefault(); }
});
// Catch uncaught errors from el-form teardown in vxe-table expand rows
window.addEventListener("error", (e) => {
const stack = e?.error?.stack ?? "";
if (stack.includes("form-label") || stack.includes("LabelWrap") || stack.includes("ElForm") || stack.includes("FormItem") || stack.includes("deregisterLabel")) { e.preventDefault(); return true; }
}, true);
// 应用启动后初始化公告弹窗功能
nextTick(() => {
initNoticePopupAfterLogin()
})
app.mount('#app')