workDetail.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. },
  16. onLoad: function(options) {
  17. var that = this;
  18. that.setData({id:options.id})
  19. that.status()
  20. },
  21. input:function(e){
  22. console.log(e)
  23. this.setData({value:e.detail.value})
  24. },
  25. status:function(){
  26. var that = this;
  27. app.request('work_order/workOrderDetail?work_order_id=' + that.data.id, '', 'GET').then(res => {
  28. console.log(res)
  29. that.setData({ detail: res.data })
  30. if (res.data.planned == 4) {
  31. that.setData({ one: true, two: true, three: true, four: true })
  32. } else if (res.data.planned == 3) {
  33. that.setData({ one: true, two: true, three: true })
  34. } else if (res.data.planned == 2) {
  35. that.setData({ one: true, two: true })
  36. } else if (res.data.planned == 1) {
  37. that.setData({ one: true })
  38. }
  39. })
  40. },
  41. goHome:function(){
  42. wx.reLaunch({
  43. url: '/pages/logs/logs?bike_no=' + this.data.detail.bike_no,
  44. })
  45. },
  46. //打开图标弹窗
  47. openICon() {
  48. if(this.data.detail.planned==4){
  49. wx.showToast({
  50. title: '已完成',
  51. icon:'none'
  52. })
  53. }else{
  54. this.setData({
  55. iconShow: true
  56. })
  57. }
  58. },
  59. //关闭图标弹窗
  60. closeIcon() {
  61. this.setData({
  62. iconShow: false,
  63. commitShow:false,
  64. inpShow:false
  65. })
  66. },
  67. //领取工单
  68. getWork(){
  69. var that = this;
  70. app.request('work_order/receive?work_order_id='+this.data.id,'','GET').then(res=>{
  71. console.log(res);
  72. that.status()
  73. wx.showToast({
  74. title: '接单成功',
  75. icon:'none'
  76. })
  77. that.setData({ iconShow:false})
  78. })
  79. },
  80. //上报组长
  81. reported(){
  82. this.setData({
  83. commitShow:true,
  84. iconShow: false,
  85. inpShow: true,
  86. })
  87. },
  88. //完成
  89. finish(){
  90. this.setData({
  91. iconShow:false,
  92. commitShow: true,
  93. inpShow:false,
  94. })
  95. },
  96. //取消按钮
  97. cancel(){
  98. this.setData({
  99. commitShow:false
  100. })
  101. },
  102. //确定按钮
  103. submit(){
  104. console.log(this.data.inpShow)
  105. var that = this;
  106. let condition = this.data.inpShow
  107. if (condition == true){
  108. //调上报组长接口
  109. var data = {
  110. work_order_id:that.data.id,
  111. remark:that.data.value
  112. }
  113. app.request('work_order/upgrade',data,'POST').then(res=>{
  114. console.log(res);
  115. if(res.statusCode==200){
  116. wx.showToast({
  117. title: '上报成功',
  118. icon:'none'
  119. })
  120. that.setData({inpShow: false, iconShow: false,commitShow: false})
  121. that.status()
  122. }
  123. })
  124. }else{
  125. app.request('work_order/over?work_order_id='+that.data.id, '', 'GET').then(res => {
  126. console.log(res);
  127. if (res.statusCode == 200) {
  128. wx.showToast({
  129. title: '处理完成',
  130. icon: 'none'
  131. })
  132. that.setData({ inpShow: false, iconShow: false, commitShow: false })
  133. that.status()
  134. }
  135. })
  136. }
  137. },
  138. onReady: function() {
  139. },
  140. onShow: function() {
  141. },
  142. onHide: function() {
  143. },
  144. onUnload: function() {
  145. },
  146. onPullDownRefresh: function() {
  147. },
  148. onReachBottom: function() {
  149. },
  150. onShareAppMessage: function() {
  151. }
  152. })