main.js 7.6 KB

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