meeting-inspection.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. // pages/meeting-inspection/meeting-inspection.js
  2. const util = require('../../utils/util.js');
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. inspectionProjectList: [],
  9. currentTab: 20,//20:会前 30:会中 40:会后
  10. meetingId: '',
  11. inspectionResultList: [],
  12. abnormalIndex: null,
  13. },
  14. /**
  15. * 生命周期函数--监听页面加载
  16. */
  17. onLoad: function (options) {
  18. let that = this;
  19. let templetId = options.templetId;
  20. let meetingId = options.meetingId;
  21. util.get({
  22. url: '/api/inspection/template/getProjectByTemplateId',
  23. header: {
  24. 'Content-Type': 'application/x-www-form-urlencoded'
  25. },
  26. data: {
  27. templateId: templetId
  28. },
  29. success: (res) => {
  30. wx.hideLoading();
  31. if (res.data.code != 200) {
  32. util.toast(res.data.msg);
  33. } else {
  34. that.setData({
  35. inspectionProjectList: res.data.data,
  36. meetingId: meetingId
  37. });
  38. }
  39. }
  40. });
  41. },
  42. /**
  43. * 生命周期函数--监听页面初次渲染完成
  44. */
  45. onReady: function () {
  46. },
  47. /**
  48. * 生命周期函数--监听页面显示
  49. */
  50. onShow: function () {
  51. let that = this;
  52. let item = wx.getStorageSync('inspectionResultItem');
  53. if (item) {
  54. let obj = JSON.parse(item);
  55. let index = that.data.abnormalIndex;
  56. that.data.inspectionProjectList[index].result = 20;
  57. that.data.inspectionProjectList[index].color = '#E95543';
  58. that.data.inspectionProjectList[index].results = '不正常';
  59. let list = that.data.inspectionResultList;
  60. list.push(obj);
  61. that.setData({
  62. inspectionProjectList: that.data.inspectionProjectList,
  63. inspectionResultList: list,
  64. abnormalIndex: null
  65. });
  66. wx.removeStorageSync('inspectionResultItem');
  67. }
  68. },
  69. /**
  70. * 生命周期函数--监听页面隐藏
  71. */
  72. onHide: function () {
  73. },
  74. /**
  75. * 生命周期函数--监听页面卸载
  76. */
  77. onUnload: function () {
  78. },
  79. /**
  80. * 页面相关事件处理函数--监听用户下拉动作
  81. */
  82. onPullDownRefresh: function () {
  83. },
  84. /**
  85. * 页面上拉触底事件的处理函数
  86. */
  87. onReachBottom: function () {
  88. },
  89. /**
  90. * 用户点击右上角分享
  91. */
  92. onShareAppMessage: function () {
  93. },
  94. switchTab(e) {
  95. this.setData({ currentTab: e.currentTarget.dataset.no });
  96. },
  97. /**
  98. * 巡检结果正常
  99. * @param {*} e
  100. */
  101. normal: function (e) {
  102. let that = this;
  103. // 修改巡检结果为正常(10)
  104. that.data.inspectionProjectList[e.currentTarget.dataset.index].result = 10;
  105. that.data.inspectionProjectList[e.currentTarget.dataset.index].color = '#2EC3CD';
  106. that.data.inspectionProjectList[e.currentTarget.dataset.index].results = '正常';
  107. let list = that.data.inspectionResultList;
  108. list.push({
  109. inspectionProjectId: e.currentTarget.dataset.id,
  110. result: 10
  111. });
  112. that.setData({
  113. inspectionProjectList: that.data.inspectionProjectList,
  114. inspectionResultList: list
  115. });
  116. },
  117. /**
  118. * 巡检结果不正常
  119. * @param {*} e
  120. */
  121. abnormal: function (e) {
  122. this.setData({
  123. abnormalIndex: e.currentTarget.dataset.index
  124. });
  125. wx.navigateTo({
  126. url: '../meeting-inspection-abnormal/meeting-inspection-abnormal?inspectionProjectId=' + e.currentTarget.dataset.id,
  127. })
  128. },
  129. /**
  130. * 历史记录
  131. * @param {*} e
  132. */
  133. history: function (e) {
  134. wx.navigateTo({
  135. url: '../meeting-inspection-history/meeting-inspection-history',
  136. });
  137. },
  138. /**
  139. * 提交巡检结果
  140. */
  141. submitInspection: function () {
  142. let that = this;
  143. let inspectionResultList = that.data.inspectionResultList;
  144. if (!inspectionResultList || inspectionResultList.length < 1) {
  145. util.toast('请选择巡检结果');
  146. return;
  147. }
  148. wx.showModal({
  149. cancelColor: 'cancelColor',
  150. title: '巡检工程师',
  151. showCancel: false,
  152. editable: true,
  153. placeholderText: '请输入姓名',
  154. success: (res) => {
  155. if (!res.content) {
  156. util.toast('请输入姓名');
  157. return;
  158. } else {
  159. util.post({
  160. url: '/api/inspection/record/addBean',
  161. data: {
  162. meetingId: that.data.meetingId,
  163. inspectionType: that.data.currentTab,
  164. inspectionResultList: inspectionResultList,
  165. inspectionPersonnel: res.content
  166. },
  167. success: (res) => {
  168. wx.hideLoading();
  169. if (res.data.code != 200) {
  170. util.toast(res.data.msg);
  171. } else {
  172. util.toast(res.data.msg);
  173. setTimeout(() => {
  174. wx.navigateBack({
  175. delta: -1,
  176. });
  177. }, 1000);
  178. }
  179. }
  180. });
  181. }
  182. }
  183. });
  184. }
  185. })