index.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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.code != '1') 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. t: 1,
  87. v: stagename,
  88. r: "” "
  89. }, {
  90. v: '阶段',
  91. t: 1,
  92. r: "?"
  93. }]),
  94. cancelText: getApp().globalData.Language.getMapText('取消'),
  95. confirmText: getApp().globalData.Language.getMapText('确定'),
  96. complete: ({
  97. confirm
  98. }) => {
  99. if (confirm) _Http.basic({
  100. "id": 20221024160102,
  101. "content": {
  102. sa_projectid,
  103. sa_projstagetempid,
  104. sa_project_stageid
  105. }
  106. }).then(res => {
  107. wx.showToast({
  108. title: res.code == '1' ? getApp().globalData.Language.joint([{
  109. v: '已进入',
  110. t: 1,
  111. r: " “"
  112. }, {
  113. v: stagename,
  114. r: "” "
  115. }, {
  116. v: '阶段',
  117. t: 1,
  118. }]) : res.data,
  119. icon: "none"
  120. });
  121. if (res.code == '1') {
  122. that.setData({
  123. active: index
  124. })
  125. that.viewData(true);
  126. }
  127. })
  128. }
  129. })
  130. },
  131. viewData(change = false) {
  132. this.triggerEvent("changeCallBack", {
  133. list: this.data.list[this.data.active],
  134. change
  135. })
  136. },
  137. }
  138. })