main.js 9.3 KB

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