index.js 3.1 KB

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