main.js 13 KB

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