sentandback.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. hidePrice: wx.getStorageSync('hidePrice'),
  10. content: {
  11. pageNumber: 1,
  12. pageTotal: 1,
  13. pageSize: 20,
  14. where: {
  15. condition: "",
  16. type: "",
  17. begindate: "",
  18. enddate: ""
  19. }
  20. }
  21. },
  22. onLoad(options) {
  23. this.getList()
  24. this.setData({
  25. userrole: wx.getStorageSync('userrole')
  26. })
  27. },
  28. //sa_dispatchid
  29. toDetail(e) {
  30. const {
  31. item
  32. } = e.currentTarget.dataset;
  33. console.log(item.id)
  34. wx.navigateTo({
  35. url: (item.type == "发货" ? "/packageA/dispatchBill/detail" : "/packageA/returnOne/detail") + '?id=' + item.id
  36. })
  37. },
  38. tabsChange(e) {
  39. this.data.content.where.type = e.detail.name == "0" ? "" : e.detail.name;
  40. this.getList(true)
  41. },
  42. /* 获取产品 */
  43. getList(init = false) {
  44. if (init.detail != undefined) init = init.detail;
  45. let content = this.data.content;
  46. if (init) content.pageNumber = 1;
  47. if (content.pageNumber > content.pageTotal) return;
  48. this.setListHeight();
  49. _Http.basic({
  50. "id": "20230626104003",
  51. "version": 1,
  52. content
  53. }).then(res => {
  54. this.selectComponent('#ListBox').RefreshToComplete();
  55. content.pageNumber = res.pageNumber + 1
  56. content.pageTotal = res.pageTotal
  57. let list = [];
  58. res.data.forEach(v => {
  59. let index = list.findIndex(item => item.billno == v.billno);
  60. v.amount = CNY(currency(v.price).multiply(v.qty));
  61. v.price = CNY(v.price);
  62. if (index != -1) {
  63. list[index].productList.push(v)
  64. } else {
  65. v.productList = []
  66. list[list.length] = v;
  67. }
  68. })
  69. this.setData({
  70. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  71. content
  72. })
  73. })
  74. },
  75. /* 修改查看日期 */
  76. changeDate(e) {
  77. this.data.content.where[e.currentTarget.dataset.name] = e.detail.value;
  78. this.getList(true)
  79. },
  80. initialize() {
  81. this.data.content.where.enddate = "";
  82. this.data.content.where.begindate = "";
  83. this.getList(true)
  84. },
  85. /* 搜索 */
  86. onSearch({
  87. detail
  88. }) {
  89. this.data.content.where.condition = detail;
  90. this.getList(true)
  91. },
  92. /* 设置页面高度 */
  93. setListHeight() {
  94. this.selectComponent("#ListBox").setHeight(".head", this);
  95. }
  96. })