main.js 13 KB

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