main.js 12 KB

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