meeting-inspection.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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. switchTab(e) {
  90. this.setData({ currentTab: e.currentTarget.dataset.no });
  91. },
  92. /**
  93. * 巡检结果正常
  94. * @param {*} e
  95. */
  96. normal: function (e) {
  97. let that = this;
  98. // 修改巡检结果为正常(10)
  99. that.data.inspectionProjectList[e.currentTarget.dataset.index].result = 10;
  100. that.data.inspectionProjectList[e.currentTarget.dataset.index].color = '#2EC3CD';
  101. that.data.inspectionProjectList[e.currentTarget.dataset.index].results = '正常';
  102. let list = that.data.inspectionResultList;
  103. list.push({
  104. inspectionProjectId: e.currentTarget.dataset.id,
  105. result: 10
  106. });
  107. that.setData({
  108. inspectionProjectList: that.data.inspectionProjectList,
  109. inspectionResultList: list
  110. });
  111. },
  112. /**
  113. * 巡检结果不正常
  114. * @param {*} e
  115. */
  116. abnormal: function (e) {
  117. this.setData({
  118. abnormalIndex: e.currentTarget.dataset.index
  119. });
  120. wx.navigateTo({
  121. url: '../meeting-inspection-abnormal/meeting-inspection-abnormal?inspectionProjectId=' + e.currentTarget.dataset.id,
  122. })
  123. },
  124. /**
  125. * 历史记录
  126. */
  127. history: function () {
  128. wx.navigateTo({
  129. url: '../meeting-inspection-history/meeting-inspection-history?inspectionType=20&meetingId=' + this.data.meetingId,
  130. });
  131. },
  132. /**
  133. * 提交巡检结果
  134. */
  135. submitInspection: function () {
  136. let that = this;
  137. let inspectionResultList = that.data.inspectionResultList;
  138. if (!inspectionResultList || inspectionResultList.length < 1) {
  139. util.toast('请选择巡检结果');
  140. return;
  141. }
  142. wx.showModal({
  143. cancelColor: 'cancelColor',
  144. title: '巡检工程师',
  145. showCancel: false,
  146. editable: true,
  147. placeholderText: '请输入姓名',
  148. success: (res) => {
  149. if (!res.content) {
  150. util.toast('请输入姓名');
  151. return;
  152. } else {
  153. util.post({
  154. url: '/api/inspection/record/addBean',
  155. data: {
  156. meetingId: that.data.meetingId,
  157. inspectionType: that.data.currentTab,
  158. inspectionResultList: inspectionResultList,
  159. inspectionPersonnel: res.content
  160. },
  161. success: (res) => {
  162. wx.hideLoading();
  163. if (res.data.code != 200) {
  164. util.toast(res.data.msg);
  165. } else {
  166. util.toast(res.data.msg);
  167. setTimeout(() => {
  168. wx.navigateBack({
  169. delta: -1,
  170. });
  171. }, 1000);
  172. }
  173. }
  174. });
  175. }
  176. }
  177. });
  178. }
  179. })