main.js 12 KB

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