main.js 13 KB

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