main.js 7.9 KB

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