index.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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. lifetimes: {
  21. attached: function () {
  22. getApp().globalData.Language.getLanguagePackage(this)
  23. }
  24. },
  25. data: {
  26. active: null, //现在阶段
  27. content: {
  28. total: null
  29. }
  30. },
  31. methods: {
  32. getList(change = false) {
  33. _Http.basic({
  34. "id": 20221024102402,
  35. "content": {
  36. "nacache": true,
  37. "sa_projectid": this.data.sa_projectid,
  38. "sa_projstagetempid": this.data.sa_projstagetempid
  39. }
  40. }).then(res => {
  41. console.log("工作阶段查询", res)
  42. if (res.msg != '成功') return wx.showToast({
  43. title: res.data,
  44. icon: "none"
  45. });
  46. const active = res.data.findIndex(v => v.active == 1);
  47. this.setData({
  48. list: res.data,
  49. active,
  50. "content.total": res.total
  51. });
  52. this.viewData(change);
  53. })
  54. },
  55. /* 切换阶段 */
  56. changeViewItem(e) {
  57. if (!this.data.disabled) return;
  58. const {
  59. index
  60. } = e.currentTarget.dataset;
  61. let {
  62. stagename,
  63. sa_projectid,
  64. sa_projstagetempid,
  65. sa_project_stageid
  66. } = this.data.list[index],
  67. that = this;
  68. if (index == this.data.active) return getApp().globalData.Language.showToast([{
  69. v: '当前已在',
  70. t: 1,
  71. r: " “"
  72. }, {
  73. v: stagename,
  74. r: "” "
  75. }, {
  76. v: '阶段',
  77. t: 1
  78. }])
  79. wx.showModal({
  80. title: getApp().globalData.Language.getMapText('提示'),
  81. content: getApp().globalData.Language.joint([{
  82. v: '是否进入',
  83. t: 1,
  84. r: " “"
  85. }, {
  86. v: stagename,
  87. r: "” "
  88. }, {
  89. v: '阶段',
  90. t: 1,
  91. r: "?"
  92. }]),
  93. cancelText: getApp().globalData.Language.getMapText('取消'),
  94. confirmText: getApp().globalData.Language.getMapText('确定'),
  95. complete: ({
  96. confirm
  97. }) => {
  98. if (confirm) _Http.basic({
  99. "id": 20221024160102,
  100. "content": {
  101. sa_projectid,
  102. sa_projstagetempid,
  103. sa_project_stageid
  104. }
  105. }).then(res => {
  106. wx.showToast({
  107. title: res.msg == '成功' ? getApp().globalData.Language.joint([{
  108. v: '已进入',
  109. t: 1,
  110. r: " “"
  111. }, {
  112. v: stagename,
  113. r: "” "
  114. }, {
  115. v: '阶段',
  116. t: 1,
  117. }]) : res.data,
  118. icon: "none"
  119. });
  120. if (res.msg == '成功') {
  121. that.setData({
  122. active: index
  123. })
  124. that.viewData(true);
  125. }
  126. })
  127. }
  128. })
  129. },
  130. viewData(change = false) {
  131. this.triggerEvent("changeCallBack", {
  132. list: this.data.list[this.data.active],
  133. change
  134. })
  135. },
  136. }
  137. })