运维小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. const api = require('../../api/index.js');
  2. Page({
  3. data: {
  4. visible:false,
  5. tabsindex:"1,2",
  6. workorderName:'',
  7. datestart:'',
  8. dateend:'',
  9. array:['日常','故障','其他'],
  10. priority:'',
  11. index:'',
  12. reviewdata:[],
  13. examineType:0,
  14. partnerPosition:{},
  15. objectArray: [],
  16. },
  17. onLoad() {
  18. this.setData({
  19. partnerPosition:wx.getStorageSync('partnerPosition')
  20. })
  21. },
  22. // 查询电站
  23. getpowestation() {
  24. api.request(`/syspowerstation/selectpowestation`, 'POST', {})
  25. .then((res) => {
  26. if (res.code == 200) {
  27. // this.setData({
  28. // objectArray: res.data
  29. // })
  30. }
  31. })
  32. .catch((err) => {
  33. console.error('请求失败:', err);
  34. // 在这里处理请求失败的情况
  35. });
  36. },
  37. // 选项卡
  38. onTabsChange(e){
  39. console.log(e.detail.value);
  40. this.setData({
  41. tabsindex:e.detail.value
  42. })
  43. this.gitreview()
  44. },
  45. // 输入工单名称
  46. onPeakprice(e){
  47. console.log(e.detail.value);
  48. this.setData({
  49. workorderName:e.detail.value
  50. })
  51. },
  52. // 事件
  53. bindeventChange(e){
  54. console.log(e.detail.value);
  55. this.setData({
  56. index:e.detail.value
  57. })
  58. },
  59. // 开始事件
  60. bindstartChange: function(e) {
  61. console.log('picker发送选择改变,携带值为', e.detail.value)
  62. this.setData({
  63. datestart: e.detail.value
  64. })
  65. },
  66. // 结束时间
  67. bindendChange: function(e) {
  68. console.log('picker发送选择改变,携带值为', e.detail.value)
  69. this.setData({
  70. dateend: e.detail.value
  71. })
  72. },
  73. // 工单优先级
  74. onradio(e){
  75. console.log(e.detail.value);
  76. this.setData({
  77. priority:e.detail.value
  78. })
  79. },
  80. // 工单审核状态
  81. onexamineType(e){
  82. console.log(e.detail.value);
  83. this.setData({
  84. examineType:e.detail.value
  85. })
  86. },
  87. onworkorder(){
  88. this.setData({
  89. visible:false
  90. })
  91. this.gitreview()
  92. },
  93. onreset(){
  94. this.setData({
  95. workorderName:'',
  96. tabsindex:"1,2",
  97. datestart:'',
  98. dateend:'',
  99. index:'',
  100. priority:'',
  101. examineType:0
  102. })
  103. this.gitreview()
  104. },
  105. gitreview(){
  106. let data = {
  107. workorderName:this.data.workorderName,
  108. workorderType:this.data.tabsindex==0?'':this.data.tabsindex,
  109. workorderAddress:'',
  110. starttime:this.data.datestart,
  111. endtime:this.data.dateend,
  112. type:this.data.index==''?'':this.data.index*1+1,
  113. examineType:this.data.examineType==0?'':this.data.examineType
  114. }
  115. api.request(`/workoder/selectworkoder`, 'POST',data)
  116. .then((res) => {
  117. if (res.data) {
  118. this.setData({
  119. reviewdata:res.data
  120. })
  121. }else{
  122. this.setData({
  123. reviewdata:[]
  124. })
  125. }
  126. })
  127. .catch((err) => {
  128. console.error('请求失败:', err);
  129. // 在这里处理请求失败的情况
  130. });
  131. },
  132. onfilter(){
  133. this.setData({
  134. visible:true
  135. })
  136. },
  137. onVisibleChange(){
  138. this.setData({
  139. visible:false
  140. })
  141. },
  142. ondetails(e){
  143. console.log(e.currentTarget.dataset);
  144. wx.navigateTo({
  145. url: `/pages/workorderdetails/index?id=${e.currentTarget.dataset.id}&workorderId=${e.currentTarget.dataset.workorderid}`,
  146. })
  147. },
  148. onUndo(e){
  149. let _this = this
  150. console.log(e.currentTarget.dataset.id);
  151. wx.showModal({
  152. title: '提示',
  153. content: '是否撤消,删除工单?',
  154. success (res) {
  155. if (res.confirm) {
  156. let data ={
  157. workorderId:e.currentTarget.dataset.id
  158. }
  159. api.request(`/workoder/deleteworkorder`, 'POST',data)
  160. .then((res) => {
  161. wx.showToast({
  162. title: '撤消成功',
  163. icon: 'none'
  164. });
  165. _this.gitreview()
  166. })
  167. .catch((err) => {
  168. console.error('请求失败:', err);
  169. // 在这里处理请求失败的情况
  170. });
  171. } else if (res.cancel) {
  172. console.log('用户点击取消');
  173. }
  174. }
  175. })
  176. },
  177. onShow() {
  178. // this.setData({
  179. // workorderName:'',
  180. // tabsindex:"1,2",
  181. // datestart:'',
  182. // dateend:'',
  183. // index:''
  184. // })
  185. this.gitreview()
  186. },
  187. /**
  188. * 页面相关事件处理函数--监听用户下拉动作
  189. */
  190. async onPullDownRefresh() {
  191. await this.gitreview()
  192. await wx.stopPullDownRefresh();
  193. }
  194. });