index.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. disabled: Boolean
  11. },
  12. data: {
  13. active: null, //现在阶段
  14. content: {
  15. total: null
  16. }
  17. },
  18. methods: {
  19. getList(change = false) {
  20. _Http.basic({
  21. "id": 20221024102402,
  22. "content": {
  23. "nacache": true,
  24. "sa_projectid": this.data.sa_projectid,
  25. "sa_projstagetempid": this.data.sa_projstagetempid
  26. }
  27. }).then(res => {
  28. console.log("工作阶段查询", 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. "content.total": res.total
  38. });
  39. this.viewData(change);
  40. })
  41. },
  42. /* 切换阶段 */
  43. changeViewItem(e) {
  44. if (!this.data.disabled) return wx.showToast({
  45. title: '暂无权限更改阶段',
  46. icon: "none"
  47. })
  48. const {
  49. index
  50. } = e.currentTarget.dataset;
  51. let {
  52. stagename,
  53. sa_projectid,
  54. sa_projstagetempid,
  55. sa_project_stageid
  56. } = this.data.list[index],
  57. that = this;
  58. if (index == this.data.active) return wx.showToast({
  59. title: `当前已在${stagename}阶段`,
  60. icon: "none"
  61. })
  62. wx.showModal({
  63. title: '提示',
  64. content: `是否进入${stagename} 阶段?`,
  65. complete: ({
  66. confirm
  67. }) => {
  68. if (confirm) _Http.basic({
  69. "id": 20221024160102,
  70. "content": {
  71. sa_projectid,
  72. sa_projstagetempid,
  73. sa_project_stageid
  74. }
  75. }).then(res => {
  76. wx.showToast({
  77. title: res.msg == '成功' ? `已进入${stagename} 阶段` : res.data,
  78. icon: "none"
  79. });
  80. if (res.msg == '成功') {
  81. that.setData({
  82. active: index
  83. })
  84. that.viewData(true);
  85. }
  86. })
  87. }
  88. })
  89. },
  90. viewData(change = false) {
  91. this.triggerEvent("changeCallBack", {
  92. list: this.data.list[this.data.active],
  93. change
  94. })
  95. },
  96. }
  97. })