import Vue from 'vue' import Cookies from 'js-cookie' import 'normalize.css/normalize.css' // a modern alternative to CSS resets import Element from 'element-ui' import './assets/styles/element-variables.scss' import '@/assets/styles/index.scss' // global css import '@/assets/styles/ruoyi.scss' // ruoyi css import App from './App' import store from './store' import router from './router' import permission from './directive/permission' import './assets/icons' // icon import './permission' // permission control import { getDicts } from "@/api/system/dict/data"; import { getConfigKey } from "@/api/system/config"; import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, download, handleTree } from "@/utils/ruoyi"; import Pagination from "@/components/Pagination"; //自定义表格工具扩展 import RightToolbar from "@/components/RightToolbar" import * as echarts from "echarts"; import '@/utils/dialog.js' import { toSuperFixed } from "./api/warehouseBusiness/restructure"; import Viewer from 'v-viewer' import 'viewerjs/dist/viewer.css' // 解决浮点数的问题 import _ from 'lodash'; import Print from '@/components/plugs/print' Vue.use(Print) // 注册 import PrintE from '../src/combination/plugs/print' Vue.use(PrintE) // 注册打印 import Blob from '@/excel/Blob.js' import Export2Excel from '@/excel/Export2Excel.js' // 全局方法挂载 Vue.prototype.$echarts = echarts; Vue.prototype.getDicts = getDicts Vue.prototype.getConfigKey = getConfigKey Vue.prototype.parseTime = parseTime Vue.prototype.resetForm = resetForm Vue.prototype.addDateRange = addDateRange Vue.prototype.selectDictLabel = selectDictLabel Vue.prototype.selectDictLabels = selectDictLabels Vue.prototype.download = download Vue.prototype.handleTree = handleTree Vue.prototype.msgSuccess = function (msg) { this.$message({ showClose: true, message: msg, type: "success" }); } Vue.prototype.msgError = function (msg) { this.$message({ showClose: true, message: msg, type: "error" }); } Vue.prototype.msgError2 = function (msg) { this.$message({ showClose: true, message: msg, type: "error", duration: 20 * 1000 }); } Vue.prototype.msgInfo = function (msg) { this.$message.info(msg); } // number原型链绑定四舍五入的方法 Number.prototype.toSuperFixed = toSuperFixed // 全局组件挂载 Vue.component('Pagination', Pagination) Vue.component('RightToolbar', RightToolbar) Vue.use(permission) /** * If you don't want to use mock-server * you want to use MockJs for mock api * you can execute: mockXHR() * * Currently MockJs will be used in the production environment, * please remove it before going online! ! ! */ Vue.use(Element, { size: Cookies.get('size') || 'medium' // set element-ui default size }) Vue.config.productionTip = false Vue.use(Viewer) Viewer.setDefaults({ Options: { 'inline': true, // 启用 inline 模式 'button': true, // 显示右上角关闭按钮 'navbar': true, // 显示缩略图导航 'title': true, // 显示当前图片的标题 'toolbar': true, // 显示工具栏 'tooltip': true, // 显示缩放百分比 'movable': true, // 图片是否可移动 'zoomable': true, // 图片是否可缩放 'rotatable': true, // 图片是否可旋转 'scalable': true, // 图片是否可翻转 'transition': true, // 使用 CSS3 过度 'fullscreen': true, // 播放时是否全屏 'keyboard': true, // 是否支持键盘 'url': 'data-source' // 设置大图片的 url } }) new Vue({ el: '#app', router, store, render: h => h(App) }) Vue.directive("dialogDrag", { bind(el, binding, vnode, oldVnode) { const dialogHeaderEl = el.querySelector(".el-dialog__header"); const dragDom = el.querySelector(".el-dialog"); const enlarge = el.querySelector(".enlarge"); dialogHeaderEl.style.cursor = "move"; // 获取原有属性 ie dom元素.currentStyle 火狐谷歌 window.getComputedStyle(dom元素, null); const sty = dragDom.currentStyle || window.getComputedStyle(dragDom, null); if (enlarge) { enlarge.onclick = (e) => { dragDom.style.top = "0px"; dragDom.style.left = "0px"; }; } dialogHeaderEl.onmousedown = (e) => { // 鼠标按下,计算当前元素距离可视区的距离 const disX = e.clientX - dialogHeaderEl.offsetLeft; const disY = e.clientY - dialogHeaderEl.offsetTop; // 获取到的值带px 正则匹配替换 let styL, styT; // 注意在ie中 第一次获取到的值为组件自带50% 移动之后赋值为px if (sty.left.includes("%")) { styL = +document.body.clientWidth * (+sty.left.replace(/\%/g, "") / 100); styT = +document.body.clientHeight * (+sty.top.replace(/\%/g, "") / 100); } else { styL = +sty.left.replace(/\px/g, ""); styT = +sty.top.replace(/\px/g, ""); } document.onmousemove = function (e) { // 通过事件委托,计算移动的距离 const l = e.clientX - disX; const t = e.clientY - disY; // 移动当前元素 if (t + styT >= 0) { dragDom.style.top = `${t + styT}px`; } dragDom.style.left = `${l + styL}px`; // 将此时的位置传出去 // binding.value({x:e.pageX,y:e.pageY}) }; document.onmouseup = function (e) { document.onmousemove = null; document.onmouseup = null; }; }; }, }); Vue.directive("input-limit", { bind(el, binding) { var wins_0 = /[^\d]/g //整数判断 var wins_1 = /[^\d^\.]/g //小数判断 var flag = true; var points = 0; var lengths = 0 var remainder = 0 var no_int = 0 const target = el instanceof HTMLInputElement ? el : el.querySelector("input"); target.addEventListener("compositionstart", e => { flag = false; }); target.addEventListener("compositionend", e => { flag = true; }); target.addEventListener("input", e => { setTimeout(function () { if (flag) { if (binding.value == 0) { if (wins_0.test(e.target.value)) { e.target.value = e.target.value.replace(wins_0, ""); e.target.dispatchEvent(new Event("input")) //手动更新v-model值 } } if (binding.value == 1) { if (wins_0.test(e.target.value.toString().replace(/\d+\.(\d*)/, '$1'))) { remainder = true } if ((e.target.value.split('.')).length - 1 > 1) { points = true } if (e.target.value.toString().split(".")[1] != undefined) { if (e.target.value.toString().split(".")[1].length > 1) { lengths = true } } if (e.target.value.toString().indexOf(".") != -1) { no_int = false } else { no_int = true } if (wins_1.test(e.target.value) || lengths || points || remainder) { if (!no_int) { e.target.value = e.target.value.replace(wins_1, "").replace('.', '$#$').replace(/\./g, '').replace( '$#$', '.').replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3').substring(0, e.target.value.indexOf( ".") + 2) } else { e.target.value = e.target.value.replace(wins_0, "") } e.target.dispatchEvent(new Event("input")) } } if (binding.value == 2) { if (wins_0.test(e.target.value.toString().replace(/\d+\.(\d*)/, '$1'))) { remainder = true } if ((e.target.value.split('.')).length - 1 > 1) { points = true } if (e.target.value.toString().split(".")[1] != undefined) { if (e.target.value.toString().split(".")[1].length > 2) { lengths = true } } if (e.target.value.toString().indexOf(".") != -1) { no_int = false } else { no_int = true } if (wins_1.test(e.target.value) || lengths || points || remainder) { if (!no_int) { e.target.value = e.target.value.replace(wins_1, "").replace('.', '$#$').replace(/\./g, '').replace( '$#$', '.').replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3').substring(0, e.target.value.indexOf( ".") + 3) } else { e.target.value = e.target.value.replace(wins_0, "") } e.target.dispatchEvent(new Event("input")) } } if (binding.value == 3) { if (wins_0.test(e.target.value.toString().replace(/\d+\.(\d*)/, '$1'))) { remainder = true } if ((e.target.value.split('.')).length - 1 > 1) { points = true } if (e.target.value.toString().split(".")[1] != undefined) { if (e.target.value.toString().split(".")[1].length > 3) { lengths = true } } if (e.target.value.toString().indexOf(".") != -1) { no_int = false } else { no_int = true } if (wins_1.test(e.target.value) || lengths || points || remainder) { if (!no_int) { e.target.value = e.target.value.replace(wins_1, "").replace('.', '$#$').replace(/\./g, '').replace( '$#$', '.').replace(/^(\-)*(\d+)\.(\d\d\d).*$/, '$1$2.$3').substring(0, e.target.value.indexOf( ".") + 4) } else { e.target.value = e.target.value.replace(wins_0, "") } e.target.dispatchEvent(new Event("input")) } } if (binding.value == 4) { if (wins_0.test(e.target.value.toString().replace(/\d+\.(\d*)/, '$1'))) { remainder = true } if ((e.target.value.split('.')).length - 1 > 1) { points = true } if (e.target.value.toString().split(".")[1] != undefined) { if (e.target.value.toString().split(".")[1].length > 4) { lengths = true } } if (e.target.value.toString().indexOf(".") != -1) { no_int = false } else { no_int = true } if (wins_1.test(e.target.value) || lengths || points || remainder) { if (!no_int) { e.target.value = e.target.value.replace(wins_1, "").replace('.', '$#$').replace(/\./g, '').replace( '$#$', '.').substring(0, e.target.value.indexOf( ".") + 5) } else { e.target.value = e.target.value.replace(wins_0, "") } e.target.dispatchEvent(new Event("input")) } } } }, 0) }) } }) Vue.directive('Alphabet', { inserted: function (el) { const input = el.querySelector('.el-input__inner'); input.onkeyup = function (e) { input.value = input.value.replace(/[^A-Za-z0-9]/g, '') } input.onblur = function (e) { input.value = input.value.replace(/[^A-Za-z0-9]/g, '') } } }); Vue.directive('Space', { inserted: function (el) { const input = el.querySelector('.el-input__inner'); input.onkeyup = function (e) { input.value = input.value.replace(/\s+/g, '') } input.onblur = function (e) { input.value = input.value.replace(/\s+/g, '') } } });