faultItem.ts 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // component/faultItem/faultItem.ts
  2. import { httpUtil } from '../../utils/restful';
  3. import { TimeUtil } from '../../utils/TimeUtil'
  4. Component({
  5. /**
  6. * 组件的属性列表
  7. */
  8. properties: {
  9. //0=待维修 1=维修中 2=已完成
  10. itemData: null
  11. },
  12. /**
  13. * 组件的初始数据
  14. */
  15. data: {
  16. status: 0,
  17. statusText: "",
  18. faultTime: '',
  19. myItemData: null,
  20. },
  21. lifetimes: {
  22. attached: function () {
  23. // 在组件实例被从页面节点树添加时执行
  24. let text = "";
  25. switch (Number(this.properties.itemData.processType)) {
  26. case 0:
  27. text = "待维修";
  28. break;
  29. case 1:
  30. text = "维修中";
  31. break;
  32. case 2:
  33. text = "已完成";
  34. break;
  35. }
  36. this.setData({
  37. status: this.properties.itemData.processType,
  38. statusText: text,
  39. faultTime: TimeUtil.dateFormat(parseInt(this.properties.itemData.reportTime), "yyyy-MM-dd HH:mm"),
  40. myItemData: this.properties.itemData
  41. })
  42. },
  43. detached: function () {
  44. // 在组件实例被从页面节点树移除时执行
  45. },
  46. },
  47. /**
  48. * 组件的方法列表
  49. */
  50. methods: {
  51. toFaultInfoPage: function () {
  52. console.log("去故障详情界面")
  53. httpUtil.wxGet(httpUtil.interfaces.getFaultInfoByDevId + this.data.itemData.id, null).then((res: any) => {
  54. console.log("获取故障详情成功:", res)
  55. let item = JSON.stringify(res.data.data)
  56. wx.navigateTo({
  57. url: '../../faultInfo/faultInfo?item=' + item
  58. })
  59. }).catch((res: any) => {
  60. console.log("获取故障详情失败:", res)
  61. })
  62. }
  63. }
  64. })