index.js 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. const _Http = getApp().globalData.http;
  2. Component({
  3. options: {
  4. addGlobalClass: true
  5. },
  6. properties: {
  7. sa_projectid: String,
  8. sa_projstagetempid: String,
  9. changeCallBack: Function
  10. },
  11. data: {
  12. active: null, //现在阶段
  13. content: {
  14. total: null
  15. }
  16. },
  17. methods: {
  18. getList(change = false) {
  19. _Http.basic({
  20. "id": 20221024102402,
  21. "content": {
  22. "nacache": true,
  23. "sa_projectid": this.data.sa_projectid,
  24. "sa_projstagetempid": this.data.sa_projstagetempid
  25. }
  26. }).then(res => {
  27. console.log("工作阶段查询", res)
  28. if (res.msg != '成功') return wx.showToast({
  29. title: res.data,
  30. icon: "none"
  31. });
  32. const active = res.data.findIndex(v => v.active == 1);
  33. this.setData({
  34. list: res.data,
  35. active,
  36. "content.total": res.total
  37. });
  38. this.viewData(change);
  39. })
  40. },
  41. /* 切换阶段 */
  42. changeViewItem(e) {
  43. const {
  44. index
  45. } = e.currentTarget.dataset;
  46. console.log(index)
  47. let {
  48. stagename,
  49. sa_projectid,
  50. sa_projstagetempid,
  51. sa_project_stageid
  52. } = this.data.list[index],
  53. that = this;
  54. if (index == this.data.active) return wx.showToast({
  55. title: `当前已在${stagename}阶段`,
  56. icon: "none"
  57. })
  58. wx.showModal({
  59. title: '提示',
  60. content: `是否进入${stagename} 阶段?`,
  61. complete: ({
  62. confirm
  63. }) => {
  64. if (confirm) _Http.basic({
  65. "id": 20221024160102,
  66. "content": {
  67. sa_projectid,
  68. sa_projstagetempid,
  69. sa_project_stageid
  70. }
  71. }).then(res => {
  72. wx.showToast({
  73. title: res.msg == '成功' ? `已进入${stagename} 阶段` : res.data,
  74. icon: "none"
  75. });
  76. if (res.msg == '成功') {
  77. that.setData({
  78. active: index
  79. })
  80. that.viewData(true);
  81. }
  82. })
  83. }
  84. })
  85. },
  86. viewData(change = false) {
  87. this.triggerEvent("changeCallBack", {
  88. list: this.data.list[this.data.active],
  89. change
  90. })
  91. },
  92. }
  93. })