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.

130 lines
3.7 KiB

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