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.

141 lines
3.9 KiB

3 years ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 months ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. import Vue from "vue";
  2. import App from "./App.vue";
  3. import router from "./router";
  4. import store from "./store";
  5. import ElementUI from "element-ui";
  6. import axios from "axios";
  7. import JsonExcel from "vue-json-excel"; //vue全局导入导出excel
  8. import Print from "vue-print-nb";
  9. import Meta from 'vue-meta'
  10. import Contextmenu from 'vue-contextmenujs' //'vue-contextmenu'
  11. import "./assets/css/global_font.css";
  12. import 'umy-ui/lib/theme-chalk/index.css'; // 引入样式
  13. import "element-ui/lib/theme-chalk/index.css";
  14. Vue.use(Contextmenu);
  15. Vue.use(Meta);
  16. Vue.use(ElementUI);
  17. Vue.prototype.$axios = axios
  18. Vue.prototype.Window = {
  19. peisAPI:{
  20. receive: function (args) {
  21. // 函数逻辑
  22. //console.log('这是全局函数', args);
  23. }
  24. }
  25. }
  26. //全局注册外壳的 peisAPI 对象
  27. try {
  28. Vue.prototype.$peisAPI = window.peisAPI;
  29. } catch (error) {
  30. Vue.prototype.$peisAPI = null;
  31. }
  32. Vue.use(Print);
  33. Vue.component("downloadExcel", JsonExcel);
  34. Vue.config.productionTip = false;
  35. // Vue.filter('format', function (date) {
  36. // var json_date = new Date(date).toJSON()
  37. // return new Date(new Date(json_date) + 8 * 3600 * 1000).toISOString().replace(/t/g, '').replace(/\.[\d]{3}Z/, '')
  38. // })
  39. Vue.directive('focus', {
  40. // 当被绑定的元素插入到 DOM 中时
  41. inserted: function(el) {
  42. // 聚焦元素
  43. el.focus()
  44. },
  45. update: function(el) {
  46. // 聚焦元素
  47. el.focus()
  48. }
  49. })
  50. Vue.filter("dateFormat", (dataStr) => {
  51. if (!dataStr) {
  52. return
  53. }
  54. var time = new Date(dataStr);
  55. function timeAdd0(str) {
  56. if (str < 10) {
  57. str = "0" + str;
  58. }
  59. return str;
  60. }
  61. var y = time.getFullYear();
  62. var m = time.getMonth() + 1;
  63. var d = time.getDate();
  64. var h = time.getHours();
  65. var mm = time.getMinutes();
  66. var s = time.getSeconds();
  67. return (
  68. y +
  69. "-" +
  70. timeAdd0(m) +
  71. "-" +
  72. timeAdd0(d) +
  73. " " +
  74. timeAdd0(h) +
  75. ":" +
  76. timeAdd0(mm) +
  77. ":" +
  78. timeAdd0(s)
  79. );
  80. });
  81. new Vue({
  82. router,
  83. store,
  84. metaInfo() {
  85. return {
  86. title: '神豚体检管理系统',
  87. meta: [{
  88. name: "http-equiv",
  89. content: "Content-Security-Policy", //http-equiv="Content-Security-Policy" content="default-src 'self' 'unsafe-inline';">
  90. }, {
  91. name: "content",
  92. content: "default-src 'self' 'unsafe-inline';", //指向data的数据
  93. }]
  94. }
  95. },
  96. render: (h) => h(App),
  97. }).$mount("#app");
  98. //监听页面大小改变
  99. window.addEventListener('resize', onResize);
  100. function onResize() {
  101. //console.log(document.body.clientHeight,'-document.body.clientHeight-',window.innerHeight)
  102. store.commit('setData', { key: 'window.pageHeight', value: window.innerHeight })
  103. store.commit('setData', { key: 'window.pageWidth', value: window.innerWidth })
  104. }
  105. onResize();
  106. // 监听keydown:获取键盘按住事件,code返回按住的键信息 (为了省事放在全局,后续优化应考虑放至具体用到界面上)
  107. window.addEventListener('keydown', code => {
  108. // console.log('keydown', code)
  109. if (code.key == "Shift" && code.shiftKey) {
  110. store.commit('setData', { key: 'window.shift', value: true }); // 标记按住了shift键
  111. }
  112. if (code.key == "Control" && code.ctrlKey) {
  113. store.commit('setData', { key: 'window.ctrl', value: true }); // 标记按住了ctrl键
  114. }
  115. });
  116. // // 监听keyup:获取键盘松开事件,code返回按住的键信息
  117. window.addEventListener('keyup', code => {
  118. // console.log('keyup', code)
  119. if (code.key == "Shift") {
  120. store.commit('setData', { key: 'window.shift', value: false }); // 标记松开了shift键
  121. }
  122. if (code.key == "Control") {
  123. store.commit('setData', { key: 'window.ctrl', value: false }); // 标记松开了ctrl键
  124. }
  125. });