main.js 7.5 KB

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