main.js 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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 { checkLock, onLock, unLock } from "@/api/lock/lock"
  32. import './util/directives.js'
  33. //客户选择组件
  34. import selectComponent from '@/components/selectComponent/customerSelect';
  35. // 仓库选择组件
  36. import warehouseSelect from '@/components/warehouseSelect/index';
  37. // 商品选择组件
  38. import goodsSelect from '@/components/goodsSelect/index';
  39. //费用选择组件
  40. import breakdownSelect from '@/components/costBreakdown/costBreakdown';
  41. //用户选择组件
  42. import userSelect from '@/components/selectComponent/userSelect';
  43. //重新封装了客户选择组件
  44. import cropSelect from "@/components/crop-select/main";
  45. // 发送消息㢟
  46. import messagePost from "@/components/messageSend/main"
  47. //枚举列设置名称管理
  48. import {
  49. getColumnName
  50. } from "@/enums/column-name"
  51. import {
  52. getColumnData,
  53. saveColumnData,
  54. delColumnData
  55. } from "@/util/columnSetting"
  56. import {
  57. inDetailsKey,
  58. leaveDetailsKey
  59. } from "@/util/keyData"
  60. // 导入弹窗放大样式
  61. import '@/assets/css/form.css'
  62. // 客户调出收发货地址
  63. import {corpAddr} from "@/components/function/corpAddrSelect"
  64. //获取浏览器指纹并生成ID
  65. import Fingerprint2 from 'fingerprintjs2'
  66. Vue.component('selectComponent', selectComponent);
  67. Vue.component('warehouseSelect', warehouseSelect);
  68. Vue.component('goodsSelect', goodsSelect);
  69. Vue.component('breakdownSelect', breakdownSelect);
  70. Vue.component('userSelect', userSelect);
  71. Vue.component('cropSelect', cropSelect);
  72. Vue.component('messagePost', messagePost);
  73. import portInfo from "@/components/port-info/index";
  74. Vue.component('portInfo', portInfo);
  75. // 注册全局crud驱动
  76. window.$crudCommon = crudCommon;
  77. // 加载Vue拓展
  78. Vue.use(router);
  79. Vue.use(VueAxios, axios);
  80. Vue.use(Element, {
  81. i18n: (key, value) => i18n.t(key, value)
  82. });
  83. Vue.use(window.AVUE, {
  84. size: 'small',
  85. tableSize: 'small',
  86. calcHeight: 65,
  87. i18n: (key, value) => i18n.t(key, value)
  88. });
  89. Vue.use(format); //v-format
  90. // 注册全局容器
  91. Vue.component('basicContainer', basicContainer);
  92. Vue.component('basicBlock', basicBlock);
  93. Vue.component('thirdRegister', thirdRegister);
  94. //此处有个问题,下面这句不能使用
  95. // Vue.component('avueUeditor', avueUeditor);
  96. Vue.use(avueUeditor);
  97. //自定义标题
  98. import containerTitle from './components/titleComponent/main.vue';
  99. Vue.component('containerTitle', containerTitle);
  100. //注册echarts图表
  101. import * as echarts from 'echarts';
  102. Vue.prototype.$echarts = echarts
  103. // 加载相关url地址
  104. Object.keys(urls).forEach(key => {
  105. Vue.prototype[key] = urls[key];
  106. });
  107. // 加载website
  108. Vue.prototype.website = website;
  109. // 业务字典
  110. Vue.prototype.getWorkDicts = getWorkDicts
  111. // 动态加载阿里云字体库
  112. iconfontVersion.forEach(ele => {
  113. loadStyle(iconfontUrl.replace('$key', ele));
  114. });
  115. //枚举列设置名称管理
  116. Vue.prototype.getColumnName = getColumnName
  117. Vue.prototype.getColumnData = getColumnData
  118. Vue.prototype.saveColumnData = saveColumnData
  119. Vue.prototype.delColumnData=delColumnData
  120. //进入详情页时,保存id和其他参数
  121. Vue.prototype.inDetailsKey=inDetailsKey
  122. //离开详情页时,清除对应key的id和其他参数
  123. Vue.prototype.leaveDetailsKey=leaveDetailsKey
  124. Vue.config.productionTip = false;
  125. Vue.prototype.corpAddr = corpAddr;
  126. // 业务锁
  127. Vue.prototype.checkLock = checkLock;
  128. Vue.prototype.onLock = onLock;
  129. Vue.prototype.unLock = unLock;
  130. new Vue({
  131. router,
  132. store,
  133. i18n,
  134. render: h => h(App)
  135. }).$mount('#app');
  136. Vue.directive("input-limit", {
  137. bind(el, binding) {
  138. var wins_0 = /[^\d]/g //整数判断
  139. var wins_1 = /[^\d^\.]/g //小数判断
  140. var flag = true;
  141. var points = 0;
  142. var lengths = 0
  143. var remainder = 0
  144. var no_int = 0
  145. const target = el instanceof HTMLInputElement ? el : el.querySelector("input");
  146. target.addEventListener("compositionstart", e => {
  147. flag = false;
  148. });
  149. target.addEventListener("compositionend", e => {
  150. flag = true;
  151. });
  152. target.addEventListener("input", e => {
  153. setTimeout(function() {
  154. if (flag) {
  155. if (binding.value == 0) {
  156. if (wins_0.test(e.target.value)) {
  157. e.target.value = e.target.value.replace(wins_0, "");
  158. e.target.dispatchEvent(new Event("input")) //手动更新v-model值
  159. }
  160. }
  161. if (binding.value == 1) {
  162. if (wins_0.test(e.target.value.toString().replace(/\d+\.(\d*)/, '$1'))) {
  163. remainder = true
  164. }
  165. if ((e.target.value.split('.')).length - 1 > 1) {
  166. points = true
  167. }
  168. if (e.target.value.toString().split(".")[1] != undefined) {
  169. if (e.target.value.toString().split(".")[1].length > 1) {
  170. lengths = true
  171. }
  172. }
  173. if (e.target.value.toString().indexOf(".") != -1) {
  174. no_int = false
  175. } else {
  176. no_int = true
  177. }
  178. if (wins_1.test(e.target.value) || lengths || points || remainder) {
  179. if (!no_int) {
  180. e.target.value = e.target.value.replace(wins_1, "").replace('.', '$#$').replace(/\./g, '').replace(
  181. '$#$', '.').replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3').substring(0, e.target.value.indexOf(
  182. ".") + 2)
  183. } else {
  184. e.target.value = e.target.value.replace(wins_0, "")
  185. }
  186. e.target.dispatchEvent(new Event("input"))
  187. }
  188. }
  189. if (binding.value == 2) {
  190. if (wins_0.test(e.target.value.toString().replace(/\d+\.(\d*)/, '$1'))) {
  191. remainder = true
  192. }
  193. if ((e.target.value.split('.')).length - 1 > 1) {
  194. points = true
  195. }
  196. if (e.target.value.toString().split(".")[1] != undefined) {
  197. if (e.target.value.toString().split(".")[1].length > 2) {
  198. lengths = true
  199. }
  200. }
  201. if (e.target.value.toString().indexOf(".") != -1) {
  202. no_int = false
  203. } else {
  204. no_int = true
  205. }
  206. if (wins_1.test(e.target.value) || lengths || points || remainder) {
  207. if (!no_int) {
  208. e.target.value = e.target.value.replace(wins_1, "").replace('.', '$#$').replace(/\./g, '').replace(
  209. '$#$', '.').replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3').substring(0, e.target.value.indexOf(
  210. ".") + 3)
  211. } else {
  212. e.target.value = e.target.value.replace(wins_0, "")
  213. }
  214. e.target.dispatchEvent(new Event("input"))
  215. }
  216. }
  217. if (binding.value == 4) {
  218. if (wins_0.test(e.target.value.toString().replace(/\d+\.(\d*)/, '$1'))) {
  219. remainder = true
  220. }
  221. if ((e.target.value.split('.')).length - 1 > 1) {
  222. points = true
  223. }
  224. if (e.target.value.toString().split(".")[1] != undefined) {
  225. if (e.target.value.toString().split(".")[1].length > 4) {
  226. lengths = true
  227. }
  228. }
  229. if (e.target.value.toString().indexOf(".") != -1) {
  230. no_int = false
  231. } else {
  232. no_int = true
  233. }
  234. if (wins_1.test(e.target.value) || lengths || points || remainder) {
  235. if (!no_int) {
  236. e.target.value = e.target.value.replace(wins_1, "").replace('.', '$#$').replace(/\./g, '').replace(
  237. '$#$', '.').substring(0, e.target.value.indexOf(
  238. ".") + 5)
  239. } else {
  240. e.target.value = e.target.value.replace(wins_0, "")
  241. }
  242. e.target.dispatchEvent(new Event("input"))
  243. }
  244. }
  245. }
  246. }, 0)
  247. })
  248. }
  249. })
  250. Fingerprint2.get(function(components) {
  251. const values = components.map(function(component,index) {
  252. if (index === 0) {
  253. return component.value.replace(/\bNetType\/\w+\b/, '')
  254. }
  255. return component.value
  256. })
  257. // 生成最终id murmur
  258. const murmur = Fingerprint2.x64hash128(values.join(''), 31)
  259. if(localStorage.getItem('browserID')!=murmur){
  260. localStorage.setItem('browserID',murmur)
  261. }
  262. })