workDetail.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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. that.setData({
  46. detail: res.data,
  47. skipDetail: true
  48. })
  49. if (res.data.planned == 4) {
  50. that.setData({
  51. one: true,
  52. two: true,
  53. three: true,
  54. four: true
  55. })
  56. } else if (res.data.planned == 3) {
  57. that.setData({
  58. one: true,
  59. two: true,
  60. three: true
  61. })
  62. } else if (res.data.planned == 2) {
  63. that.setData({
  64. one: true,
  65. two: true
  66. })
  67. } else if (res.data.planned == 1) {
  68. that.setData({
  69. one: true
  70. })
  71. }
  72. })
  73. },
  74. /**
  75. * 查看警报
  76. */
  77. alarm() {
  78. this.setData({
  79. alarmShow: true
  80. });
  81. this.getAlarm();
  82. },
  83. getAlarm() {
  84. wx.showLoading({
  85. title: '加载中...',
  86. })
  87. app.request('work_order/getWarningByWorkOrderId?id=' + this.data.id + '&is_limit_type=' + this.data.alarmState, '', 'GET').then(res => {
  88. wx.hideLoading();
  89. this.setData({
  90. alarmList: res.data
  91. })
  92. console.log(res)
  93. })
  94. },
  95. closeAlarm() {
  96. this.setData({
  97. alarmShow: false
  98. })
  99. },
  100. alarmChoose(e) {
  101. let state = e.currentTarget.dataset.state;
  102. this.setData({
  103. alarmState: state,
  104. alarmList: []
  105. })
  106. this.getAlarm();
  107. this.goTop();
  108. },
  109. // moreAlarm() {
  110. // let that = this;
  111. // var page = that.data.page + 1;
  112. // app.request('work_order/getWarningByWorkOrderId?id=' + this.data.id + '&is_limit_type=' + this.data.alarmState + '&page='+page, '', 'GET').then(res => {
  113. // let alarm = res.data
  114. // this.setData({
  115. // alarmList: that.data.alarmList.concat(alarm)
  116. // })
  117. // })
  118. // },
  119. goTop: function (e) { // 一键回到顶部
  120. this.setData({
  121. topNum: 0
  122. });
  123. },
  124. goHome: function () {
  125. if (this.data.skipDetail) {
  126. wx.reLaunch({
  127. url: '/pages/logs/logs?bike_no=' + this.data.detail.bike_no,
  128. })
  129. }else{
  130. wx.showToast({
  131. title: '页面加载完后再试',
  132. icon:'none'
  133. })
  134. }
  135. },
  136. //打开图标弹窗
  137. openICon() {
  138. if (this.data.detail.planned == 4) {
  139. wx.showToast({
  140. title: '已完成',
  141. icon: 'none'
  142. })
  143. } else {
  144. this.setData({
  145. iconShow: true
  146. })
  147. }
  148. },
  149. //关闭图标弹窗
  150. closeIcon() {
  151. this.setData({
  152. iconShow: false,
  153. commitShow: false,
  154. inpShow: false
  155. })
  156. },
  157. //领取工单
  158. getWork() {
  159. wx.showLoading({
  160. title: '接单中..',
  161. })
  162. var that = this;
  163. app.request('work_order/receive?work_order_id=' + this.data.id, '', 'GET').then(res => {
  164. wx.hideLoading();
  165. that.status()
  166. wx.showToast({
  167. title: '接单成功',
  168. icon: 'none'
  169. })
  170. that.setData({
  171. iconShow: false
  172. })
  173. })
  174. },
  175. //上报组长
  176. reported() {
  177. this.setData({
  178. commitShow: true,
  179. iconShow: false,
  180. inpShow: true,
  181. })
  182. },
  183. //完成
  184. finish() {
  185. this.setData({
  186. iconShow: false,
  187. commitShow: true,
  188. inpShow: false,
  189. })
  190. },
  191. //取消按钮
  192. cancel() {
  193. this.setData({
  194. commitShow: false
  195. })
  196. },
  197. //确定按钮
  198. submit() {
  199. wx.showLoading({
  200. title: '加载中...',
  201. })
  202. var that = this;
  203. let condition = this.data.inpShow
  204. if (condition == true) {
  205. //调上报组长接口
  206. var data = {
  207. work_order_id: that.data.id,
  208. remark: that.data.value
  209. }
  210. app.request('work_order/upgrade', data, 'POST').then(res => {
  211. wx.hideLoading();
  212. console.log(res);
  213. wx.showToast({
  214. title: '上报成功',
  215. icon: 'none'
  216. })
  217. that.setData({
  218. inpShow: false,
  219. iconShow: false,
  220. commitShow: false
  221. })
  222. that.status()
  223. })
  224. } else {
  225. app.request('work_order/over?work_order_id=' + that.data.id, '', 'GET').then(res => {
  226. wx.showToast({
  227. title: '处理完成',
  228. icon: 'none'
  229. })
  230. that.setData({
  231. inpShow: false,
  232. iconShow: false,
  233. commitShow: false
  234. })
  235. that.status()
  236. })
  237. }
  238. },
  239. })