rows.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. const _Http = getApp().globalData.http;
  2. import currency from "../../utils/currency";
  3. const CNY = value => currency(value, {
  4. symbol: "¥",
  5. precision: 2
  6. }).format();
  7. Page({
  8. data: {
  9. privacyFieldC: [],
  10. content: {
  11. pageNumber: 1,
  12. pageTotal: 1,
  13. pageSize: 20,
  14. where: {
  15. condition: "",
  16. convenient: "",
  17. begindate: "",
  18. enddate: ""
  19. }
  20. }
  21. },
  22. onLoad(options) {
  23. this.getList()
  24. this.setData({
  25. userrole: wx.getStorageSync('userrole')
  26. })
  27. try {
  28. let privacyFieldC = wx.getStorageSync('auth').worderdetails.forms.list.formcols.map(v => v.title);
  29. this.setData({
  30. privacyFieldC
  31. })
  32. console.log("privacyFieldC", privacyFieldC)
  33. } catch (error) {
  34. console.error(error)
  35. }
  36. },
  37. tabsChange({
  38. detail
  39. }) {
  40. this.data.content.where.convenient = detail.name
  41. this.getList(true)
  42. },
  43. /* 获取产品 */
  44. getList(init = false) {
  45. if (init.detail != undefined) init = init.detail;
  46. let content = this.data.content;
  47. if (init) content.pageNumber = 1;
  48. if (content.pageNumber > content.pageTotal) return;
  49. this.setListHeight();
  50. _Http.basic({
  51. "id": 20230508111703,
  52. content
  53. }).then(res => {
  54. console.log("订单列表", res)
  55. if (res.msg != '成功') return wx.showToast({
  56. title: res.msg,
  57. icon: "none"
  58. })
  59. this.selectComponent('#ListBox').RefreshToComplete();
  60. content.pageNumber = res.pageNumber + 1
  61. content.pageTotal = res.pageTotal
  62. let list = [];
  63. res.data.forEach(v => {
  64. let index = list.findIndex(item => item.sonum == v.sonum);
  65. v.amount = CNY(currency(v.price).multiply(v.qty));
  66. v.price = CNY(v.price);
  67. if (index != -1) {
  68. list[index].productList.push(v)
  69. } else {
  70. v.productList = []
  71. list[list.length] = v;
  72. }
  73. })
  74. this.setData({
  75. list: res.pageNumber == 1 ? list : this.data.list.concat(list),
  76. content
  77. })
  78. })
  79. },
  80. /* 修改查看日期 */
  81. changeDate(e) {
  82. this.data.content.where[e.currentTarget.dataset.name] = e.detail.value;
  83. this.getList(true)
  84. },
  85. initialize() {
  86. this.data.content.where.enddate = "";
  87. this.data.content.where.begindate = "";
  88. this.getList(true)
  89. },
  90. /* 搜索 */
  91. onSearch({
  92. detail
  93. }) {
  94. this.data.content.where.condition = detail;
  95. this.getList(true)
  96. },
  97. /* 设置页面高度 */
  98. setListHeight() {
  99. this.selectComponent("#ListBox").setHeight(".top", this);
  100. }
  101. })