import Vue from 'vue'; import axios from './router/axios'; import VueAxios from 'vue-axios'; import App from './App'; import router from './router/router'; import './permission'; // 权限 import './error'; // 日志 import './cache'; //页面缓存 import store from './store'; import { loadStyle } from './util/util' import * as urls from '@/config/env'; import Element from 'element-ui'; import { iconfontUrl, iconfontVersion } from '@/config/env'; import i18n from './lang'; // Internationalization import './styles/common.scss'; import basicBlock from './components/basic-block/main'; import basicContainer from './components/basic-container/main'; import thirdRegister from './components/third-register/main'; import avueUeditor from 'avue-plugin-ueditor'; import website from '@/config/website'; import crudCommon from '@/mixins/crud'; import format from 'vue-text-format'; //v-format import { getWorkDicts } from '@/api/system/dictbiz' import './util/directives.js' //客户选择组件 import selectComponent from '@/components/selectComponent/customerSelect'; // 仓库选择组件 import warehouseSelect from '@/components/warehouseSelect/index'; // 商品选择组件 import goodsSelect from '@/components/goodsSelect/index'; //枚举列设置名称管理 import { getColumnName } from "@/enums/column-name" import { getColumnData, saveColumnData } from "@/util/columnSetting" // 导入弹窗放大样式 import '@/assets/css/form.css' Vue.component('selectComponent', selectComponent); Vue.component('warehouseSelect', warehouseSelect); Vue.component('goodsSelect', goodsSelect); import portInfo from "@/components/port-info/index"; Vue.component('portInfo', portInfo); // 注册全局crud驱动 window.$crudCommon = crudCommon; // 加载Vue拓展 Vue.use(router); Vue.use(VueAxios, axios); Vue.use(Element, { i18n: (key, value) => i18n.t(key, value) }); Vue.use(window.AVUE, { size: 'small', tableSize: 'small', calcHeight: 65, i18n: (key, value) => i18n.t(key, value) }); Vue.use(format); //v-format // 注册全局容器 Vue.component('basicContainer', basicContainer); Vue.component('basicBlock', basicBlock); Vue.component('thirdRegister', thirdRegister); //此处有个问题,下面这句不能使用 // Vue.component('avueUeditor', avueUeditor); Vue.use(avueUeditor); //自定义标题 import containerTitle from './components/titleComponent/main.vue'; Vue.component('containerTitle', containerTitle); // 加载相关url地址 Object.keys(urls).forEach(key => { Vue.prototype[key] = urls[key]; }); // 加载website Vue.prototype.website = website; // 业务字典 Vue.prototype.getWorkDicts = getWorkDicts // 动态加载阿里云字体库 iconfontVersion.forEach(ele => { loadStyle(iconfontUrl.replace('$key', ele)); }); //枚举列设置名称管理 Vue.prototype.getColumnName = getColumnName Vue.prototype.getColumnData = getColumnData Vue.prototype.saveColumnData = saveColumnData Vue.config.productionTip = false; new Vue({ router, store, i18n, render: h => h(App) }).$mount('#app'); 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 == 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) }) } })