index.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. const _Http = getApp().globalData.http,
  2. currency = require("../../../../utils/currency"),
  3. CNY = value => currency(value, {
  4. symbol: "¥",
  5. precision: 2
  6. }).format();
  7. Component({
  8. options: {
  9. addGlobalClass: true
  10. },
  11. properties: {
  12. ownertable: {
  13. type: String
  14. },
  15. ownerid: {
  16. type: String
  17. },
  18. disabled: {
  19. type: Boolean,
  20. value: true
  21. }
  22. },
  23. lifetimes: {
  24. attached: function () {
  25. getApp().globalData.Language.getLanguagePackage(this)
  26. }
  27. },
  28. data: {
  29. content: {
  30. nocache: true,
  31. pageNumber: 1,
  32. pageSize: 20,
  33. pageTotal: 1,
  34. total: null,
  35. where: {
  36. condition: ""
  37. }
  38. },
  39. list: [],
  40. showSearch: false,
  41. focus: false,
  42. condition: ""
  43. },
  44. methods: {
  45. toSearch() {
  46. if (this.data.showSearch && this.data.content.where.condition) {
  47. this.data.content.where.condition = '';
  48. this.getList("", true);
  49. } else if (this.data.condition) {
  50. this.data.content.where.condition = this.data.condition;
  51. this.setData({
  52. condition: this.data.condition
  53. })
  54. this.getList("", true);
  55. }
  56. this.setData({
  57. showSearch: !this.data.showSearch
  58. })
  59. setTimeout(() => {
  60. this.setData({
  61. focus: this.data.showSearch
  62. })
  63. }, 300)
  64. },
  65. onChange({
  66. detail
  67. }) {
  68. this.data.condition = detail;
  69. },
  70. onSearch({
  71. detail
  72. }) {
  73. this.data.content.where.condition = detail;
  74. this.getList("", true)
  75. },
  76. getList(id, init = false) {
  77. let content = this.data.content
  78. if (id) content.sa_contractid = id;
  79. if (init) {
  80. content.pageNumber = 1
  81. content.pageTotal = 1
  82. }
  83. _Http.basic({
  84. "id": 2025022115343002,
  85. content
  86. }).then(res => {
  87. console.log("关联订单", res)
  88. if (res.code != '1') return wx.showToast({
  89. title: res.data,
  90. icon: "none"
  91. });
  92. let list = res.data.map(v => {
  93. v.amount = CNY(v.amount)
  94. return v
  95. })
  96. this.setData({
  97. "content.pageNumber": res.pageNumber + 1,
  98. "content.pageTotal": res.pageTotal,
  99. "content.total": res.total,
  100. list: res.pageNumber == 1 ? list : this.data.list.concat(list)
  101. })
  102. })
  103. },
  104. }
  105. })