helper.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. export default {
  64. detailData,
  65. selectContractNo,
  66. now,
  67. isArray,
  68. erpWarehouse,
  69. getListByUserId,
  70. setAudit
  71. }