index.js 3.4 KB

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