index.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. const _Http = getApp().globalData.http;
  2. Component({
  3. properties: {
  4. idname: {
  5. type: [String, Number]
  6. }
  7. },
  8. options: {
  9. addGlobalClass: true
  10. },
  11. lifetimes: {
  12. attached: function () {
  13. getApp().globalData.Language.getLanguagePackage(this)
  14. }
  15. },
  16. data: {
  17. sa_workorderid: 0,
  18. content: {
  19. nocache: true,
  20. pageNumber: 1,
  21. pageSize: 10,
  22. pageTotal: 1,
  23. total: null,
  24. where: {
  25. condition: ""
  26. }
  27. },
  28. list: [],
  29. showSearch: false,
  30. focus: false,
  31. condition: "",
  32. tabColorS: {
  33. 有效: {
  34. bgColor: "#E1EAFE",
  35. color: "#3874F6"
  36. },
  37. 无效: {
  38. bgColor: "#FDE4E3",
  39. color: "#ED4949"
  40. },
  41. },
  42. },
  43. methods: {
  44. getList(id, init = false) {
  45. console.log("getList", id)
  46. let content = {
  47. ...this.data.content,
  48. sa_workorderid: id || this.data.sa_workorderid,
  49. sa_serviceorderid: id || this.data.sa_workorderid,
  50. };
  51. content.where.sa_workorderid = content.sa_workorderid
  52. if (init) {
  53. content.pageNumber = 1
  54. content.pageTotal = 1
  55. }
  56. _Http.basic({
  57. "id": this.data.idname,
  58. content
  59. }).then(res => {
  60. console.log("服务确认单", res)
  61. if (res.code != '1') return wx.showToast({
  62. title: res.data,
  63. icon: "none"
  64. });
  65. this.setData({
  66. "content.pageNumber": res.pageNumber + 1,
  67. "content.pageTotal": res.pageTotal,
  68. "content.total": res.total,
  69. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  70. sa_workorderid: content.sa_workorderid
  71. })
  72. })
  73. },
  74. toSearch() {
  75. if (this.data.showSearch && this.data.content.where.condition) {
  76. this.data.content.where.condition = '';
  77. this.getList("", true);
  78. } else if (this.data.condition) {
  79. this.data.content.where.condition = this.data.condition;
  80. this.setData({
  81. condition: this.data.condition
  82. })
  83. this.getList("", true);
  84. }
  85. this.setData({
  86. showSearch: !this.data.showSearch
  87. })
  88. setTimeout(() => {
  89. this.setData({
  90. focus: this.data.showSearch
  91. })
  92. }, 300)
  93. },
  94. onChange({
  95. detail
  96. }) {
  97. this.data.condition = detail;
  98. },
  99. onSearch({
  100. detail
  101. }) {
  102. this.data.content.where.condition = detail;
  103. this.getList("", true)
  104. },
  105. }
  106. })