main.js 13 KB

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