main.js 7.8 KB

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