main.js 10 KB

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