seeAico.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. import api from "../../utils/api";
  2. Page({
  3. data: {
  4. pageStatus: 2,
  5. notesInput: '',
  6. room_name: '--',
  7. hotel_name: '--',
  8. count: 0,
  9. normal: 0,
  10. abnormal: 0,
  11. abnormal_d_name: '--',
  12. room_id: 0,
  13. show1: false,
  14. show2: false,
  15. show2Text: '',
  16. roomInfo: {},
  17. logsInfo: {},
  18. deviceList: []
  19. },
  20. onLoad: function (options) {
  21. this.setData({
  22. room_id: options.room_id
  23. , room_name: options.room_name
  24. , hotel_name: options.hotel_name,
  25. pageStatus: 0
  26. })
  27. },
  28. bindNotesInput: function (e) {
  29. this.setData({
  30. notesInput: e.detail.value
  31. });
  32. console.log(this.data.notesInput)
  33. },
  34. onClose() {
  35. this.setData({
  36. show1: false, show2: false
  37. });
  38. },
  39. onShow() {
  40. this.setData({
  41. pageStatus: 0
  42. , notesInput: ''
  43. , deviceList: []
  44. , logsInfo: {}
  45. , roomInfo:{}
  46. });
  47. },
  48. onShow1() {
  49. this.setData({
  50. show1: true
  51. });
  52. },
  53. onShow2(text=null) {
  54. this.setData({
  55. show2: true,
  56. show2Text: text
  57. });
  58. },
  59. onStartInspection() {
  60. api.startCheck({
  61. params: {room_id: this.data.room_id},
  62. headers: {unionid: wx.getStorageSync("unionid")},
  63. })
  64. .then(data => {
  65. if (data.code === 1) {
  66. wx.showToast({
  67. icon: 'none',
  68. title: "开始巡检",
  69. });
  70. this.setData({
  71. deviceList:[],
  72. logsInfo: {},
  73. roomInfo:{}
  74. })
  75. this.getNucEquips()
  76. this.setData({pageStatus: 1});
  77. } else {
  78. this.onShow2(data.info|| "巡检异常请联系管理员")
  79. }
  80. })
  81. .catch(err => {
  82. this.onShow2("巡检异常请联系管理员")
  83. });
  84. }
  85. ,
  86. getNucEquips() {
  87. api.nucEquips({
  88. params: {room_id: this.data.room_id},
  89. headers: {unionid: wx.getStorageSync("unionid")}
  90. }).then(data => {
  91. if (data.code === 1) {
  92. var logs = data.data.logs|| {};
  93. this.setData({
  94. deviceList: logs.inspection || [],
  95. logsInfo:logs,
  96. roomInfo:data.data.room||{}
  97. })
  98. }else{
  99. this.onShow2(data.info|| "获取设备列表失败,请联系管理员!")
  100. }
  101. }).catch(err => {
  102. this.onShow2("获取设备列表失败,请联系管理员!")
  103. });
  104. },
  105. onConfirm() {
  106. api.confirm({
  107. body: {note: this.data.notesInput,id: this.data.logsInfo.id},
  108. headers: {unionid: wx.getStorageSync("unionid")}
  109. }).then(data => {
  110. if (data.code === 1) {
  111. this.setData({
  112. pageStatus: 0
  113. , notesInput: ''
  114. , deviceList: []
  115. , logsInfo: {}
  116. , roomInfo:{}
  117. });
  118. }else{
  119. this.onShow2(data.info|| "提交失败,请联系管理员!")
  120. }
  121. }).catch(err => {
  122. this.onShow2( "提交失败,请联系管理员!")
  123. });
  124. this.onClose()
  125. },
  126. onClosePage() {
  127. this.onConfirm()
  128. wx.navigateBack({
  129. delta: 1
  130. });
  131. },
  132. onSubmit() {
  133. api.inspect({
  134. body: {inspection: this.data.deviceList,id: this.data.logsInfo.id},
  135. headers: {unionid: wx.getStorageSync("unionid")}
  136. }).then(data => {
  137. if (data.code === 1) {
  138. let { count =0,normal=0,abnormal=0, inspection=[]} =data.data||{}
  139. wx.showToast({
  140. icon: 'none',
  141. title: data.info|| "提交成功!",
  142. });
  143. this.setData({
  144. pageStatus: 2,
  145. count,
  146. normal,
  147. abnormal,
  148. abnormal_d_name: inspection.map(item => item.entity_name).join(',') || '--'
  149. });
  150. }else{
  151. this.onShow2(data.info|| "提交失败,请联系管理员!")
  152. }
  153. }).catch(err => {
  154. this.onShow2("提交失败,请联系管理员!")
  155. });
  156. },
  157. setDeviceStats(e) {
  158. let {index, status} = e.currentTarget.dataset
  159. this.setData({
  160. [`deviceList[${index}].checked`]: status
  161. })
  162. }
  163. });