- 移除 VxeTableCompat 组件,改用依赖补丁方式处理事件参数归一化 - 在 patch-deps-plugin 中新增 vxe-table table.js 模块拦截和补丁逻辑 - 通过动态修改 vxe-table 源码实现 cell-click 和 current-change 事件参数标准化 - 修正了 vxe-table 与 el-table 事件参数格式不一致导致的组件交互问题 - 清理了全局组件注册中的兼容层引用 - 优化了事件处理流程,提升组件间通信的一致性
154 lines
16 KiB
JavaScript
Executable File
154 lines
16 KiB
JavaScript
Executable File
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')
|