helper.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import * as config from '../config'
  2. const selectContractNo = {}
  3. const detailData = {}
  4. const erpWarehouse = {}
  5. const rolesList = []
  6. const now = Date.now || function() {
  7. return new Date().getTime();
  8. };
  9. const isArray = Array.isArray || function(obj) {
  10. return obj instanceof Array;
  11. };
  12. const getListByUserId = function() {
  13. let baseUrlNew = config.def().baseUrlNew
  14. var userInfo = uni.getStorageSync("userInfo")
  15. console.log("------", userInfo)
  16. if (userInfo) {
  17. uni.request({
  18. url: baseUrlNew + '/roleMenu/query/getListByUserId',
  19. data: {
  20. userId: userInfo.id ? userInfo.id : userInfo.data.id
  21. },
  22. method: 'GET',
  23. success: (res) => {
  24. if (res.statusCode === 200) {
  25. uni.setStorageSync("jurisdiction", res.data.data)
  26. let list = getUserAllRoles(res.data.data);
  27. uni.setStorageSync("rolesList", list)
  28. }
  29. }
  30. })
  31. }
  32. }
  33. const getUserAllRoles = (item) => {
  34. console.log(item)
  35. for (let i = 0; i < item.length; i++) {
  36. rolesList.push(item[i].name)
  37. // console.log('用户权限',rolesList)
  38. if (item[i].children && item[i].children.length > 0) {
  39. getUserAllRoles(item[i].children)
  40. }
  41. }
  42. return rolesList;
  43. }
  44. const setAudit = (item) => {
  45. let _list = uni.getStorageSync("copyTaskInfo")
  46. let _isShowbtn = true
  47. if (_list.length == 0) {
  48. _isShowbtn = false
  49. }
  50. for (let i = 0; i < _list.length; i++) {
  51. if (_list[i].businessId == item.id) {
  52. _list.splice(i, 1)
  53. uni.setStorageSync("copyTaskInfo", _list)
  54. }
  55. }
  56. if (_list.length > 0) {
  57. uni.navigateTo({
  58. url: _list[0].itemUrl + '&isShowbtn=' + _isShowbtn,
  59. })
  60. }
  61. console.log(item)
  62. }
  63. //获取当天日期
  64. const getNowFormatDate = () => {
  65. var date = new Date();
  66. var seperator1 = "-";
  67. var year = date.getFullYear();
  68. var month = date.getMonth() + 1;
  69. var strDate = date.getDate();
  70. if (month >= 1 && month <= 9) {
  71. month = "0" + month;
  72. }
  73. if (strDate >= 0 && strDate <= 9) {
  74. strDate = "0" + strDate;
  75. }
  76. var currentdate = year + seperator1 + month + seperator1 + strDate;
  77. return currentdate;
  78. }
  79. export default {
  80. detailData,
  81. selectContractNo,
  82. now,
  83. isArray,
  84. erpWarehouse,
  85. getListByUserId,
  86. setAudit,
  87. getNowFormatDate
  88. }