index.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. viewIndex: 0, //查看阶段
  14. range: [],
  15. content: {
  16. total: null
  17. }
  18. },
  19. methods: {
  20. getList(change = false) {
  21. _Http.basic({
  22. "id": 20221024102402,
  23. "content": {
  24. "nacache": true,
  25. "sa_projectid": this.data.sa_projectid,
  26. "sa_projstagetempid": this.data.sa_projstagetempid
  27. }
  28. }).then(res => {
  29. if (res.msg != '成功') return wx.showToast({
  30. title: res.data,
  31. icon: "none"
  32. });
  33. const active = res.data.findIndex(v => v.active == 1);
  34. this.setData({
  35. list: res.data,
  36. active,
  37. viewIndex: active,
  38. range: res.data.map(v => v.stagename),
  39. "content.total": res.total
  40. });
  41. this.viewData(change);
  42. })
  43. },
  44. /* 设置阶段 */
  45. bindPickerChange(e) {
  46. let {
  47. value
  48. } = e.detail, {
  49. stagename,
  50. sa_projectid,
  51. sa_projstagetempid,
  52. sa_project_stageid
  53. } = this.data.list[value],
  54. that = this;
  55. if (value == this.data.active) return wx.showToast({
  56. title: `当前已在${stagename}阶段`,
  57. icon: "none"
  58. })
  59. wx.showModal({
  60. title: '提示',
  61. content: `是否进入${stagename} 阶段?`,
  62. complete: ({
  63. confirm
  64. }) => {
  65. if (confirm) _Http.basic({
  66. "id": 20221024160102,
  67. "content": {
  68. sa_projectid,
  69. sa_projstagetempid,
  70. sa_project_stageid
  71. }
  72. }).then(res => {
  73. if (res.msg == '成功') that.getList(true);
  74. wx.showToast({
  75. title: res.msg == '成功' ? `已进入${stagename} 阶段` : res.data,
  76. icon: "none"
  77. });
  78. })
  79. }
  80. })
  81. },
  82. /* 切换查看 */
  83. changeViewItem(e) {
  84. const {
  85. index
  86. } = e.currentTarget.dataset;
  87. // if (this.data.viewIndex == index) return;
  88. this.setData({
  89. viewIndex: index
  90. });
  91. this.viewData(true);
  92. },
  93. viewData(change = false) {
  94. this.triggerEvent("changeCallBack", {
  95. list: this.data.list[this.data.viewIndex].work,
  96. isFollow: this.data.viewIndex === this.data.active,
  97. change
  98. })
  99. },
  100. }
  101. })