plm前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

110 lines
3.9 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. import Vue from 'vue'
  2. import App from '@/App'
  3. import router from '@/router' // api: https://github.com/vuejs/vue-router
  4. import store from '@/store' // api: https://github.com/vuejs/vuex
  5. import VueCookie from 'vue-cookie' // api: https://github.com/alfhen/vue-cookie // 时间处理
  6. import dayjs from 'dayjs';
  7. import '@/element-ui' // api: https://github.com/ElemeFE/element
  8. import '@/icons' // api: http://www.iconfont.cn/
  9. import '@/element-ui-theme'
  10. import 'element-ui/lib/theme-chalk/icon.css';
  11. import '@/assets/scss/index.scss'
  12. import httpRequest from '@/utils/httpRequest' // api: https://github.com/axios/axios
  13. import { isAuth } from '@/utils'
  14. import { accessField } from '@/utils'
  15. import cloneDeep from 'lodash/cloneDeep'
  16. import JsonExcel from 'vue-json-excel'
  17. import i18n from '@/i18n/i18n'
  18. import './utils/directives'
  19. import decimalUtil from '@/utils/decimalUtil.js'
  20. import getLodop from '@/utils/LodopFuncs.js'
  21. import pdf from 'vue-pdf'
  22. import { debounce,throttle} from '@/utils/common.js'
  23. import selectDiv from '@/views/common/selectDiv.vue'
  24. import {resetForm} from "./utils/system";
  25. import echarts from "echarts";
  26. import highlightContainer from './utils/highlight';
  27. import field from './utils/field';
  28. import 'element-ui/lib/theme-chalk/divider.css'
  29. import 'element-ui/lib/theme-chalk/drawer.css'
  30. // import 'element-ui/lib/theme-chalk/dialog.css'
  31. import 'element-ui/lib/popover'
  32. Vue.prototype.$echarts = echarts;
  33. Vue.component('downloadExcel', JsonExcel)
  34. Vue.component('pdf', pdf)
  35. Vue.use(VueCookie)
  36. Vue.config.productionTip = false
  37. Vue.component('selectDiv', selectDiv);
  38. Vue.directive('highlight-container', highlightContainer);
  39. Vue.directive('field', field);
  40. // 非生产环境, 适配mockjs模拟数据 // api: https://github.com/nuysoft/Mock
  41. if (process.env.NODE_ENV !== 'production') {
  42. require('@/mock')
  43. }
  44. // 挂载全局
  45. Vue.prototype.resetForm = resetForm
  46. Vue.prototype.$http = httpRequest // ajax请求方法
  47. Vue.prototype.isAuth = isAuth // 权限方法
  48. Vue.prototype.accessField = accessField // 权限方法
  49. Vue.prototype.getLodop = getLodop // 打印
  50. Vue.prototype.decimalUtil = decimalUtil // 计算
  51. Vue.prototype.dayjs = dayjs //时间格式化插件 2021-11-02
  52. Vue.prototype.debounce = debounce // 防抖
  53. Vue.prototype.throttle = throttle // 限流
  54. // 保存整站vuex本地储存初始状态
  55. window.SITE_CONFIG['storeState'] = cloneDeep(store.state)
  56. /* eslint-disable no-new */
  57. new Vue({
  58. el: '#app',
  59. router,
  60. i18n,
  61. store,
  62. template: '<App/>',
  63. components: { App },
  64. mounted() {
  65. Vue.nextTick(() => {
  66. // 在这里调用自定义指令的绑定逻辑
  67. this.$el.querySelectorAll('[v-highlight-container]').forEach(el => {
  68. highlightContainer.bind.call({ el, bind: {} }, el);
  69. });
  70. });
  71. }
  72. })
  73. // 在Vue实例初始化之前添加全局事件监听器 type为number的输入库禁用上下箭头
  74. document.addEventListener('keydown', function(event) {
  75. // 获取触发事件的元素
  76. const targetElement = event.target;
  77. // 如果触发事件的元素是<input type="number">,并且按下的是上下箭头键
  78. if (targetElement.tagName === 'INPUT' && targetElement.type === 'number' && (event.key === 'ArrowUp' || event.key === 'ArrowDown')) {
  79. // 阻止默认行为,取消按上下箭头键改变值的行为
  80. event.preventDefault();
  81. }
  82. });
  83. Vue.prototype.$clearHighLight = function () {
  84. // 查找所有带有 highlight 类的元素
  85. const highlightedElements = this.$el.querySelectorAll('.highlight');
  86. // 移除 highlight 类
  87. highlightedElements.forEach(el => {
  88. el.classList.remove('highlight');
  89. });
  90. };
  91. Vue.prototype.$triggerInputEvent = function (inputRef) {
  92. const inputElement = inputRef.$el.querySelector('.el-input__inner');
  93. if (inputElement) {
  94. inputElement.dispatchEvent(new Event('input'));
  95. }
  96. };