index.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. import { mapActions, mapGetters } from 'vuex'
  2. import currency from 'currency.js'
  3. import { Calc, Format } from '@fujica/utils'
  4. export default {
  5. data() {
  6. return {
  7. // 全局格式化方法类
  8. Format,
  9. // 全局计算
  10. Calc,
  11. public_msgType: [
  12. {
  13. id: '0',
  14. name: '立即返回'
  15. },
  16. {
  17. id: '1',
  18. name: '业务返回'
  19. }
  20. ],
  21. public_projectType: [
  22. {
  23. id: '0',
  24. name: '车场项目'
  25. },
  26. {
  27. id: '1',
  28. name: '人行项目'
  29. }
  30. ],
  31. // public_cartype: [ // 车辆类型,待定
  32. // {
  33. // id: 1,
  34. // name: '蓝牌车'
  35. // },
  36. // {
  37. // id: 2,
  38. // name: '绿牌车'
  39. // },
  40. // {
  41. // id: 3,
  42. // name: '黄牌车'
  43. // },
  44. // {
  45. // id: 4,
  46. // name: '白牌车'
  47. // },
  48. // {
  49. // id: 5,
  50. // name: '黑牌车'
  51. // },
  52. // {
  53. // id: 6,
  54. // name: '其他'
  55. // }
  56. // ],
  57. public_cartype_obj: {
  58. 1: '蓝牌车',
  59. 2: '绿牌车',
  60. 3: '黄牌车',
  61. 4: '白牌车',
  62. 5: '黑牌车',
  63. 6: '其他'
  64. },
  65. public_cartype1: [ // 车辆类型,待定
  66. {
  67. id: 1,
  68. name: '小型车'
  69. },
  70. {
  71. id: 2,
  72. name: '小型车'
  73. },
  74. {
  75. id: 3,
  76. name: '大型车'
  77. },
  78. {
  79. id: 4,
  80. name: '小型车'
  81. },
  82. {
  83. id: 5,
  84. name: '小型车'
  85. },
  86. {
  87. id: 6,
  88. name: '其他车'
  89. }
  90. ],
  91. public_cartype_obj1: {
  92. 1: '小型车',
  93. 2: '小型车',
  94. 3: '大型车',
  95. 4: '小型车',
  96. 5: '小型车',
  97. 6: '其他车'
  98. },
  99. public_carcolor: [ // 车辆类型,待定
  100. {
  101. id: 1,
  102. name: '蓝牌'
  103. },
  104. {
  105. id: 2,
  106. name: '绿牌'
  107. },
  108. {
  109. id: 3,
  110. name: '黄牌'
  111. },
  112. {
  113. id: 4,
  114. name: '白牌'
  115. },
  116. {
  117. id: 5,
  118. name: '黑牌'
  119. },
  120. {
  121. id: 6,
  122. name: '其他'
  123. }
  124. ],
  125. public_carcolor_obj: {
  126. 1: '蓝牌',
  127. 2: '绿牌',
  128. 3: '黄牌',
  129. 4: '白牌',
  130. 5: '黑牌',
  131. 6: '其他'
  132. },
  133. public_state: [ // 启用禁用状态
  134. {
  135. id: 0,
  136. name: '禁用'
  137. },
  138. {
  139. id: 1,
  140. name: '启用'
  141. }
  142. ],
  143. public_couponsource: [ // 优惠券种类
  144. {
  145. id: 1,
  146. name: '电子优惠券'
  147. },
  148. {
  149. id: 2,
  150. name: '纸质优惠券'
  151. },
  152. {
  153. id: 3,
  154. name: '活动优惠券'
  155. },
  156. {
  157. id: 4,
  158. name: '时段优惠券'
  159. },
  160. {
  161. id: 10,
  162. name: '电子优惠券'
  163. }
  164. ],
  165. public_coupontype: [ // 优惠券类型
  166. {
  167. id: 1,
  168. name: '全免'
  169. },
  170. {
  171. id: 2,
  172. name: '当天全免'
  173. },
  174. {
  175. id: 3,
  176. name: '金额减免'
  177. },
  178. {
  179. id: 4,
  180. name: '小时减免'
  181. },
  182. {
  183. id: 10,
  184. name: '平台时长优惠'
  185. }
  186. ],
  187. public_chargetype: [ // 计费类型
  188. {
  189. id: 1,
  190. name: '长租车'
  191. },
  192. {
  193. id: 2,
  194. name: '临停车'
  195. }
  196. ],
  197. public_chargetype_obj: {
  198. 1: '长租车',
  199. 2: '临停车'
  200. },
  201. public_inout: [ // 进出类型
  202. {
  203. id: 1,
  204. name: '入场'
  205. },
  206. {
  207. id: 2,
  208. name: '出场'
  209. }
  210. ],
  211. public_inout_obj: {
  212. 1: '入场',
  213. 2: '出场'
  214. },
  215. public_eventsource: [ // 事件来源
  216. {
  217. id: 4,
  218. name: '车主呼叫'
  219. },
  220. {
  221. id: 2,
  222. name: '超时转化'
  223. },
  224. {
  225. id: 3,
  226. name: '视频转化'
  227. },
  228. {
  229. id: 1,
  230. name: '实时触发'
  231. }
  232. ],
  233. public_eventsource_obj: {
  234. 1: '实时触发',
  235. 2: '超时转化',
  236. 3: '视频转化',
  237. 4: '车主呼叫'
  238. },
  239. public_changeway: [ // 转化方式
  240. {
  241. id: 0,
  242. name: '未转化'
  243. },
  244. {
  245. id: 1,
  246. name: '自动转化'
  247. },
  248. {
  249. id: 2,
  250. name: '手动转化'
  251. },
  252. {
  253. id: 3,
  254. name: '现场恢复'
  255. }
  256. ],
  257. public_changeway_obj: {
  258. 0: '未转化',
  259. 1: '自动转化',
  260. 2: '手动转化',
  261. 3: '现场恢复'
  262. },
  263. public_open_model: { // 开闸模式
  264. 1: '自动开闸',
  265. 2: '确认开闸',
  266. 3: '禁止入场/出场'
  267. },
  268. public_time_type: {
  269. // 1: {
  270. // zh: '日',
  271. // en: 'day'
  272. // },
  273. 2: {
  274. zh: '月',
  275. en: 'month'
  276. },
  277. 3: {
  278. zh: '年',
  279. en: 'year'
  280. }
  281. },
  282. public_free_time_list: [
  283. {
  284. id: 1,
  285. num: 1,
  286. type: 2
  287. },
  288. {
  289. id: 2,
  290. num: 2,
  291. type: 2
  292. },
  293. {
  294. id: 3,
  295. num: 3,
  296. type: 2
  297. },
  298. {
  299. id: 4,
  300. num: 6,
  301. type: 2
  302. },
  303. {
  304. id: 5,
  305. num: 1,
  306. type: 3
  307. }
  308. ],
  309. DICT_CODE: {
  310. devicename_type: '201', // 报警处理设备类别
  311. alarm_type: '188', // 报警事件类型
  312. public_cartype: '216', // 车牌颜色
  313. cardvoucher_type: '237', // 卡凭证类型
  314. device_state: '182', // 人行梯控设备状态
  315. device_type: '201', // 人行梯控设备类型
  316. message_type: '242', // 消息类型
  317. platform_type: '226', // 开票平台类型
  318. handle_method: '244', // 处理方式
  319. event_status: '245', // 事件状态
  320. convert_method: '246', // 转化方式
  321. menusystem_type: '183', // 菜单管理-系统类型
  322. lane_type: '274', // 通道类别
  323. pay_way: '284', // 支付方式
  324. pay_type: '284', // 支付方式
  325. pay_type1: '211', // 支付类型
  326. pay_type_db: '249', // 上海地标支付类型
  327. pay_channel: '280', // 支付渠道
  328. pay_source: '281' // 支付来源
  329. },
  330. // 缺省图
  331. default_graph_small: require('@/assets/default_graph/graph_car_small.png'),
  332. default_graph_big: require('@/assets/default_graph/graph_car_big.png')
  333. }
  334. },
  335. computed: {
  336. ...mapGetters(['public_dict', 'globalProject', 'globalUserInfo', 'globalFilter', 'globalCompany']),
  337. public_cartype() {
  338. const arr = this.public_dict[this.DICT_CODE.public_cartype] || []
  339. arr.forEach(item => {
  340. item.id = parseInt(item.mycode)
  341. item.name = item.myname
  342. })
  343. return arr
  344. },
  345. globalProjectNo() { // 全局项目ID
  346. return this.globalProject.projectNo
  347. },
  348. globalCompanyId() { // 全局企业ID【当前项目所属企业】
  349. return this.isFujicaAdmin ? (this.$store.state.user.company?.id || 0) : this.globalUserInfo.companyId
  350. },
  351. isFujicaAdmin() { // 超管用户
  352. return this.globalUserInfo.companyId === 0
  353. },
  354. isCompanyAdmin() { // 企业超管
  355. }
  356. },
  357. methods: {
  358. ...mapActions('dict', {
  359. 'storeDictByCode': 'dict'
  360. }),
  361. // 公共获取文本方法
  362. publicGetTxt(id, data, nulltxt) {
  363. const txt = id || id == 0 ? data.filter(item => item.id.toString() === id.toString())[0] : ''
  364. return txt ? txt.name || txt.myname : (nulltxt || '--')
  365. },
  366. /*
  367. * 获取集合字段显示
  368. * params: Array list
  369. * params: String filedName
  370. * */
  371. getMultipleFiled(list, filedName) {
  372. if (!list?.length) return '--'
  373. return list.map(item => item[filedName] || '--').join(',')
  374. },
  375. // 金额计算方法
  376. floatNumCalc() {
  377. let sum = 0
  378. for (var i = 0; i < arguments.length; i++) {
  379. const val = arguments[i] || 0
  380. sum = currency(sum).add(val).value // .value 不显示.00
  381. }
  382. return sum
  383. },
  384. // 获取数字字典key值 增加单独处理 spe
  385. findValue(code, val, spe = false) {
  386. if (!val && val != 0) return '--'
  387. const obj = this.public_dict?.[code] ? this.public_dict[code].find(item => spe ? item.mycode.indexOf(val) > -1 : item.mycode == val) : {}
  388. return obj?.myname || '--'
  389. },
  390. filterButton(str) {
  391. return this.$store.getters.operations.includes(str)
  392. },
  393. /* 用于弹窗嵌套*/
  394. _openLoading() {
  395. this._loadingInstance = this.$loading({
  396. lock: true,
  397. text: '等待中...',
  398. spinner: 'el-icon-loading',
  399. background: 'rgba(0, 0, 0, 0.7)'
  400. })
  401. },
  402. _closeLoading() {
  403. this._loadingInstance && this._loadingInstance.close()
  404. },
  405. downloadExcel(res, name) {
  406. var blob, url, a
  407. if (res.success) {
  408. url = res.data
  409. a = document.createElement('a')
  410. a.href = url
  411. a.click()
  412. }
  413. if (!res.code) {
  414. blob = new Blob([res.data], {
  415. type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
  416. })
  417. url = window.URL.createObjectURL(blob)
  418. a = document.createElement('a')
  419. if (res.headers['content-disposition']) {
  420. const fileName = res.headers['content-disposition'].split('=')[1]
  421. if (fileName) {
  422. const formatString = escape(fileName)
  423. const fname = decodeURI(formatString)
  424. a.download = fname
  425. }
  426. }
  427. // var timestamp = Date.parse(new Date())
  428. // a.download = name + timestamp + '.xlsx'
  429. a.href = url
  430. a.click()
  431. window.URL.revokeObjectURL(url)
  432. }
  433. },
  434. ruleTxt(type, rule) { // 优惠券规则文本拼接
  435. var txt = ''
  436. switch (parseInt(type)) {
  437. case 1: {
  438. txt = '停车费全免'
  439. break
  440. }
  441. case 2: {
  442. txt = '入场当天停车费全免'
  443. break
  444. }
  445. case 3: {
  446. txt = '减免金额' + rule + '元'
  447. break
  448. }
  449. case 4: {
  450. txt = '减免时长' + rule + '小时'
  451. break
  452. }
  453. case 10: {
  454. txt = rule
  455. break
  456. }
  457. default: {
  458. txt = '--'
  459. }
  460. }
  461. return txt
  462. },
  463. getDictTxt(list, code) {
  464. const obj = list.find(item => item.mycode == code)
  465. return obj ? obj.myname : '--'
  466. },
  467. /*
  468. *@description: 根据秒转化为时分秒
  469. *@params: time:传入的秒 require
  470. *@params: type: HH-MM-SS(00时00分00秒) HH-MM(00时00分) hh-mm-ss(0时0分0秒) hh-mm(0时0分)
  471. * */
  472. formateTime(time, type = 'hhmmss') {
  473. if (!time) return
  474. time = parseInt(time)
  475. const h = Math.floor(time / 3600)
  476. const m = Math.floor((time / 60 % 60))
  477. const s = Math.floor((time % 60))
  478. const hh = h < 10 ? '0' + h : h
  479. const mm = m < 10 ? '0' + m : m
  480. const ss = s < 10 ? '0' + s : s
  481. const hhmmss = `${h > 0 ? h + '时' : ''}${m > 0 ? m + '分' : ''}${s > 0 ? s + '秒' : ''}`
  482. const HHMMSS = `${h > 0 ? hh + '时' : ''}${m > 0 ? mm + '分' : ''}${s > 0 ? ss + '秒' : ''}`
  483. const hhmm = `${h > 0 ? h + '时' : ''}${m > 0 ? m + '分' : ''}`
  484. const HHMM = `${h > 0 ? hh + '时' : ''}${m > 0 ? mm + '分' : ''}`
  485. return {
  486. hhmmss,
  487. HHMMSS,
  488. hhmm,
  489. HHMM
  490. }[type]
  491. },
  492. exportnotify(val,res) {
  493. const _this = this
  494. if (val) {
  495. this.$notify({
  496. title: '数据导入/出成功',
  497. dangerouslyUseHTMLString: true,
  498. message: `请前往【<span><a underline="false" type="primary" style="color: #2d72ff" >数据中心/导入导出结果</a></span>】查看结果`,
  499. onClick: function() {
  500. _this.$router.push({
  501. path: '/exportlist/exportlist'
  502. })
  503. }
  504. })
  505. } else {
  506. if(res.code == '1000000'){
  507. this.$notify({
  508. title: '存在错误数据',
  509. dangerouslyUseHTMLString: true,
  510. message: `请前往【<span><a underline="false" type="primary" style="color: #2d72ff" >数据/导入导出报表中心</a></span>】查看结果`,
  511. onClick: function() {
  512. _this.$router.push({
  513. path: '/exportlist/exportlist'
  514. })
  515. }
  516. })
  517. }else{
  518. this.$message.error(res.msg || '操作失败')
  519. }
  520. }
  521. }
  522. }
  523. }