main.js 9.4 KB

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