workDetail.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. // pages/workDetail/workDetail.js
  2. var app = getApp()
  3. Page({
  4. data: {
  5. iconShow: false, //是否显示图标弹窗
  6. commitShow: false, //上报组长
  7. inpShow: true, //显示输入框还是显示完成
  8. detail: [],
  9. one: false,
  10. two: false,
  11. three: false,
  12. four: false,
  13. id: '',
  14. value: '',
  15. screenHeight: '', //屏幕可视高度
  16. alarmShow: false, //是否显示警报弹窗【true 显示 false 不显示】
  17. topNum: 0, //返回顶部
  18. alarmState: 0, // 【0 限制警报类型 1 不限制报警类型】
  19. page: 1, //当前页面
  20. skipDetail: false,
  21. },
  22. onLoad: function (options) {
  23. var that = this;
  24. that.setData({
  25. screenHeight: app.globalData.screenHeight,
  26. })
  27. that.setData({
  28. id: options.id
  29. })
  30. that.status();
  31. },
  32. input: function (e) {
  33. this.setData({
  34. value: e.detail.value
  35. });
  36. },
  37. status: function () {
  38. wx.showLoading({
  39. title: '加载中...',
  40. })
  41. var that = this;
  42. app.request('work_order/workOrderDetail?work_order_id=' + that.data.id, '', 'GET').then(res => {
  43. console.log(res);
  44. wx.hideLoading();
  45. if (res.statusCode == 200) {
  46. that.setData({
  47. detail: res.data,
  48. skipDetail: true
  49. })
  50. if (res.data.planned == 4) {
  51. that.setData({
  52. one: true,
  53. two: true,
  54. three: true,
  55. four: true
  56. })
  57. } else if (res.data.planned == 3) {
  58. that.setData({
  59. one: true,
  60. two: true,
  61. three: true
  62. })
  63. } else if (res.data.planned == 2) {
  64. that.setData({
  65. one: true,
  66. two: true
  67. })
  68. } else if (res.data.planned == 1) {
  69. that.setData({
  70. one: true
  71. })
  72. }
  73. }
  74. })
  75. },
  76. /**
  77. * 查看警报
  78. */
  79. alarm() {
  80. this.setData({
  81. alarmShow: true
  82. });
  83. this.getAlarm();
  84. },
  85. getAlarm() {
  86. wx.showLoading({
  87. title: '加载中...',
  88. })
  89. app.request('work_order/getWarningByWorkOrderId?id=' + this.data.id + '&is_limit_type=' + this.data.alarmState, '', 'GET').then(res => {
  90. wx.hideLoading();
  91. if (res.statusCode == 200) {
  92. this.setData({
  93. alarmList: res.data
  94. })
  95. }
  96. console.log(res)
  97. })
  98. },
  99. closeAlarm() {
  100. this.setData({
  101. alarmShow: false
  102. })
  103. },
  104. alarmChoose(e) {
  105. let state = e.currentTarget.dataset.state;
  106. this.setData({
  107. alarmState: state,
  108. alarmList: []
  109. })
  110. this.getAlarm();
  111. this.goTop();
  112. },
  113. // moreAlarm() {
  114. // let that = this;
  115. // var page = that.data.page + 1;
  116. // app.request('work_order/getWarningByWorkOrderId?id=' + this.data.id + '&is_limit_type=' + this.data.alarmState + '&page='+page, '', 'GET').then(res => {
  117. // if (res.statusCode == 200) {
  118. // let alarm = res.data
  119. // this.setData({
  120. // alarmList: that.data.alarmList.concat(alarm)
  121. // })
  122. // }
  123. // })
  124. // },
  125. goTop: function (e) { // 一键回到顶部
  126. this.setData({
  127. topNum: 0
  128. });
  129. },
  130. goHome: function () {
  131. if (this.data.skipDetail) {
  132. wx.reLaunch({
  133. url: '/pages/logs/logs?bike_no=' + this.data.detail.bike_no,
  134. })
  135. }else{
  136. wx.showToast({
  137. title: '页面加载完后再试',
  138. icon:'none'
  139. })
  140. }
  141. },
  142. //打开图标弹窗
  143. openICon() {
  144. if (this.data.detail.planned == 4) {
  145. wx.showToast({
  146. title: '已完成',
  147. icon: 'none'
  148. })
  149. } else {
  150. this.setData({
  151. iconShow: true
  152. })
  153. }
  154. },
  155. //关闭图标弹窗
  156. closeIcon() {
  157. this.setData({
  158. iconShow: false,
  159. commitShow: false,
  160. inpShow: false
  161. })
  162. },
  163. //领取工单
  164. getWork() {
  165. wx.showLoading({
  166. title: '接单中..',
  167. })
  168. var that = this;
  169. app.request('work_order/receive?work_order_id=' + this.data.id, '', 'GET').then(res => {
  170. wx.hideLoading();
  171. that.status()
  172. wx.showToast({
  173. title: '接单成功',
  174. icon: 'none'
  175. })
  176. that.setData({
  177. iconShow: false
  178. })
  179. })
  180. },
  181. //上报组长
  182. reported() {
  183. this.setData({
  184. commitShow: true,
  185. iconShow: false,
  186. inpShow: true,
  187. })
  188. },
  189. //完成
  190. finish() {
  191. this.setData({
  192. iconShow: false,
  193. commitShow: true,
  194. inpShow: false,
  195. })
  196. },
  197. //取消按钮
  198. cancel() {
  199. this.setData({
  200. commitShow: false
  201. })
  202. },
  203. //确定按钮
  204. submit() {
  205. wx.showLoading({
  206. title: '加载中...',
  207. })
  208. var that = this;
  209. let condition = this.data.inpShow
  210. if (condition == true) {
  211. //调上报组长接口
  212. var data = {
  213. work_order_id: that.data.id,
  214. remark: that.data.value
  215. }
  216. app.request('work_order/upgrade', data, 'POST').then(res => {
  217. wx.hideLoading();
  218. console.log(res);
  219. if (res.statusCode == 200) {
  220. wx.showToast({
  221. title: '上报成功',
  222. icon: 'none'
  223. })
  224. that.setData({
  225. inpShow: false,
  226. iconShow: false,
  227. commitShow: false
  228. })
  229. that.status()
  230. }
  231. })
  232. } else {
  233. app.request('work_order/over?work_order_id=' + that.data.id, '', 'GET').then(res => {
  234. if (res.statusCode == 200) {
  235. wx.showToast({
  236. title: '处理完成',
  237. icon: 'none'
  238. })
  239. that.setData({
  240. inpShow: false,
  241. iconShow: false,
  242. commitShow: false
  243. })
  244. that.status()
  245. }
  246. })
  247. }
  248. },
  249. })