main.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. import Vue from 'vue';
  2. import axios from './router/axios';
  3. import VueAxios from 'vue-axios';
  4. import App from './App';
  5. import router from './router/router';
  6. import './permission'; // 权限
  7. import './error'; // 日志
  8. import './cache'; //页面缓存
  9. import store from './store';
  10. import {
  11. loadStyle
  12. } from './util/util'
  13. import * as urls from '@/config/env';
  14. import Element from 'element-ui';
  15. import {
  16. iconfontUrl,
  17. iconfontVersion
  18. } from '@/config/env';
  19. import i18n from './lang'; // Internationalization
  20. import './styles/common.scss';
  21. import basicBlock from './components/basic-block/main';
  22. import basicContainer from './components/basic-container/main';
  23. import thirdRegister from './components/third-register/main';
  24. import avueUeditor from 'avue-plugin-ueditor';
  25. import website from '@/config/website';
  26. import crudCommon from '@/mixins/crud';
  27. import format from 'vue-text-format'; //v-format
  28. import {
  29. getWorkDicts
  30. } from '@/api/system/dictbiz'
  31. import './util/directives.js'
  32. //客户选择组件
  33. import selectComponent from '@/components/selectComponent/customerSelect';
  34. // 仓库选择组件
  35. import warehouseSelect from '@/components/warehouseSelect/index';
  36. // 商品选择组件
  37. import goodsSelect from '@/components/goodsSelect/index';
  38. //枚举列设置名称管理
  39. import {
  40. getColumnName
  41. } from "@/enums/column-name"
  42. import {
  43. getColumnData,
  44. saveColumnData
  45. } from "@/util/columnSetting"
  46. // 导入弹窗放大样式
  47. import '@/assets/css/form.css'
  48. Vue.component('selectComponent', selectComponent);
  49. Vue.component('warehouseSelect', warehouseSelect);
  50. Vue.component('goodsSelect', goodsSelect);
  51. import portInfo from "@/components/port-info/index";
  52. Vue.component('portInfo', portInfo);
  53. // 注册全局crud驱动
  54. window.$crudCommon = crudCommon;
  55. // 加载Vue拓展
  56. Vue.use(router);
  57. Vue.use(VueAxios, axios);
  58. Vue.use(Element, {
  59. i18n: (key, value) => i18n.t(key, value)
  60. });
  61. Vue.use(window.AVUE, {
  62. size: 'small',
  63. tableSize: 'small',
  64. calcHeight: 65,
  65. i18n: (key, value) => i18n.t(key, value)
  66. });
  67. Vue.use(format); //v-format
  68. // 注册全局容器
  69. Vue.component('basicContainer', basicContainer);
  70. Vue.component('basicBlock', basicBlock);
  71. Vue.component('thirdRegister', thirdRegister);
  72. //此处有个问题,下面这句不能使用
  73. // Vue.component('avueUeditor', avueUeditor);
  74. Vue.use(avueUeditor);
  75. //自定义标题
  76. import containerTitle from './components/titleComponent/main.vue';
  77. Vue.component('containerTitle', containerTitle);
  78. // 加载相关url地址
  79. Object.keys(urls).forEach(key => {
  80. Vue.prototype[key] = urls[key];
  81. });
  82. // 加载website
  83. Vue.prototype.website = website;
  84. // 业务字典
  85. Vue.prototype.getWorkDicts = getWorkDicts
  86. // 动态加载阿里云字体库
  87. iconfontVersion.forEach(ele => {
  88. loadStyle(iconfontUrl.replace('$key', ele));
  89. });
  90. //枚举列设置名称管理
  91. Vue.prototype.getColumnName = getColumnName
  92. Vue.prototype.getColumnData = getColumnData
  93. Vue.prototype.saveColumnData = saveColumnData
  94. Vue.config.productionTip = false;
  95. new Vue({
  96. router,
  97. store,
  98. i18n,
  99. render: h => h(App)
  100. }).$mount('#app');
  101. Vue.directive("input-limit", {
  102. bind(el, binding) {
  103. var wins_0 = /[^\d]/g //整数判断
  104. var wins_1 = /[^\d^\.]/g //小数判断
  105. var flag = true;
  106. var points = 0;
  107. var lengths = 0
  108. var remainder = 0
  109. var no_int = 0
  110. const target = el instanceof HTMLInputElement ? el : el.querySelector("input");
  111. target.addEventListener("compositionstart", e => {
  112. flag = false;
  113. });
  114. target.addEventListener("compositionend", e => {
  115. flag = true;
  116. });
  117. target.addEventListener("input", e => {
  118. setTimeout(function() {
  119. if (flag) {
  120. if (binding.value == 0) {
  121. if (wins_0.test(e.target.value)) {
  122. e.target.value = e.target.value.replace(wins_0, "");
  123. e.target.dispatchEvent(new Event("input")) //手动更新v-model值
  124. }
  125. }
  126. if (binding.value == 1) {
  127. if (wins_0.test(e.target.value.toString().replace(/\d+\.(\d*)/, '$1'))) {
  128. remainder = true
  129. }
  130. if ((e.target.value.split('.')).length - 1 > 1) {
  131. points = true
  132. }
  133. if (e.target.value.toString().split(".")[1] != undefined) {
  134. if (e.target.value.toString().split(".")[1].length > 1) {
  135. lengths = true
  136. }
  137. }
  138. if (e.target.value.toString().indexOf(".") != -1) {
  139. no_int = false
  140. } else {
  141. no_int = true
  142. }
  143. if (wins_1.test(e.target.value) || lengths || points || remainder) {
  144. if (!no_int) {
  145. e.target.value = e.target.value.replace(wins_1, "").replace('.', '$#$').replace(/\./g, '').replace(
  146. '$#$', '.').replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3').substring(0, e.target.value.indexOf(
  147. ".") + 2)
  148. } else {
  149. e.target.value = e.target.value.replace(wins_0, "")
  150. }
  151. e.target.dispatchEvent(new Event("input"))
  152. }
  153. }
  154. if (binding.value == 2) {
  155. if (wins_0.test(e.target.value.toString().replace(/\d+\.(\d*)/, '$1'))) {
  156. remainder = true
  157. }
  158. if ((e.target.value.split('.')).length - 1 > 1) {
  159. points = true
  160. }
  161. if (e.target.value.toString().split(".")[1] != undefined) {
  162. if (e.target.value.toString().split(".")[1].length > 2) {
  163. lengths = true
  164. }
  165. }
  166. if (e.target.value.toString().indexOf(".") != -1) {
  167. no_int = false
  168. } else {
  169. no_int = true
  170. }
  171. if (wins_1.test(e.target.value) || lengths || points || remainder) {
  172. if (!no_int) {
  173. e.target.value = e.target.value.replace(wins_1, "").replace('.', '$#$').replace(/\./g, '').replace(
  174. '$#$', '.').replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3').substring(0, e.target.value.indexOf(
  175. ".") + 3)
  176. } else {
  177. e.target.value = e.target.value.replace(wins_0, "")
  178. }
  179. e.target.dispatchEvent(new Event("input"))
  180. }
  181. }
  182. if (binding.value == 4) {
  183. if (wins_0.test(e.target.value.toString().replace(/\d+\.(\d*)/, '$1'))) {
  184. remainder = true
  185. }
  186. if ((e.target.value.split('.')).length - 1 > 1) {
  187. points = true
  188. }
  189. if (e.target.value.toString().split(".")[1] != undefined) {
  190. if (e.target.value.toString().split(".")[1].length > 4) {
  191. lengths = true
  192. }
  193. }
  194. if (e.target.value.toString().indexOf(".") != -1) {
  195. no_int = false
  196. } else {
  197. no_int = true
  198. }
  199. if (wins_1.test(e.target.value) || lengths || points || remainder) {
  200. if (!no_int) {
  201. e.target.value = e.target.value.replace(wins_1, "").replace('.', '$#$').replace(/\./g, '').replace(
  202. '$#$', '.').substring(0, e.target.value.indexOf(
  203. ".") + 5)
  204. } else {
  205. e.target.value = e.target.value.replace(wins_0, "")
  206. }
  207. e.target.dispatchEvent(new Event("input"))
  208. }
  209. }
  210. }
  211. }, 0)
  212. })
  213. }
  214. })