impower.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. "content": {
  5. "sa_projectid": 1,
  6. "pageNumber": 1,
  7. "pageSize": 20,
  8. "where": {
  9. "condition": ""
  10. }
  11. }
  12. },
  13. onLoad(options) {
  14. this.data.content.sa_projectid = options.sa_projectid;
  15. this.getList()
  16. },
  17. /* 获取列表 */
  18. getList(init = false) {
  19. if (init.detail != undefined) init = init.detail;
  20. let content = this.data.content;
  21. if (init) content.pageNumber = 1;
  22. if (content.pageNumber > content.pageTotal) return;
  23. _Http.basic({
  24. "id": 20230816124004,
  25. content
  26. }).then(res => {
  27. console.log("授权列表", res)
  28. this.selectComponent('#ListBox').RefreshToComplete();
  29. if (res.msg != '成功') return wx.showToast({
  30. title: res.msg,
  31. icon: "none"
  32. })
  33. content.pageNumber = res.pageNumber + 1;
  34. content.pageTotal = res.pageTotal;
  35. content.total = res.total;
  36. this.setData({
  37. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  38. content
  39. })
  40. })
  41. },
  42. preview(e) {
  43. const {
  44. item
  45. } = e.currentTarget.dataset;
  46. if (this.compareDates(item.begdate_auth, item.enddate_auth)) return;
  47. _Http.basic({
  48. "id": 20221213094501,
  49. "content": {
  50. "sys_reportid": 104,
  51. "dataid": item.sa_projectid,
  52. sys_enterpriseid: item.enterpriseid_auth,
  53. }
  54. }).then(res => {
  55. console.log("查看授权书", res)
  56. if (res.msg != '成功') return wx.showToast({
  57. title: res.msg,
  58. icon: "none"
  59. })
  60. let url = `${_Http.baseUrl+res.data}&enterprisename=${item.enterprisename}&begdate=${item.begdate_auth}&enddate=${item.enddate_auth}`
  61. wx.navigateTo({
  62. url: `/packageA/project/impower/webview`,
  63. })
  64. this.setData({
  65. url
  66. })
  67. })
  68. },
  69. dispose(e) {
  70. const {
  71. item
  72. } = e.target.dataset,
  73. that = this;
  74. if (e.target.id == 1 && this.compareDates(item.begdate_auth, item.enddate_auth)) return;
  75. wx.showModal({
  76. title: '提示',
  77. content: `该项目授权申请确认${e.target.id==1?'通过':'不通过'}?`,
  78. complete: ({
  79. confirm
  80. }) => {
  81. if (confirm) _Http.basic({
  82. "id": "20230810161804",
  83. "content": {
  84. "sa_project_authorizationid": item.sa_project_authorizationid,
  85. "begdate": item.begdate_auth,
  86. "enddate": item.enddate_auth,
  87. "isPass": e.target.id
  88. }
  89. }).then(res => {
  90. console.log(e.target.id == 1 ? '通过' : '不通过', res)
  91. wx.showToast({
  92. title: res.msg == '成功' ? '操作成功' : res.msg,
  93. icon: "none"
  94. });
  95. if (res.msg == '成功') this.setData({
  96. list: that.data.list.filter(v => v.sa_project_authorizationid != item.sa_project_authorizationid)
  97. })
  98. })
  99. }
  100. })
  101. },
  102. onChangeDate(e) {
  103. const {
  104. index,
  105. item,
  106. name
  107. } = e.currentTarget.dataset;
  108. item[name] = e.detail.value;
  109. this.setData({
  110. [`list[${index}]`]: item
  111. })
  112. },
  113. compareDates(d1, d2) {
  114. let date1 = new Date(d1).getTime();
  115. let date2 = new Date(d2).getTime();
  116. if (date1 > date2) wx.showToast({
  117. title: '请检查授权书有效期,开始时间不能晚于结束时间',
  118. icon: "none"
  119. })
  120. return date1 > date2
  121. },
  122. onReady() {
  123. this.selectComponent("#ListBox").setHeight(".head", this);
  124. }
  125. })