sentandback.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. toDetail(e) {
  29. const {
  30. item
  31. } = e.currentTarget.dataset;
  32. wx.navigateTo({
  33. url: (item.type == "发货" ? "/packageA/dispatchBill/detail" : "/packageA/returnOne/detail") + '?id=' + item.id
  34. })
  35. },
  36. tabsChange(e) {
  37. this.data.content.where.type = e.detail.name == "0" ? "" : e.detail.name;
  38. this.getList(true)
  39. },
  40. /* 获取产品 */
  41. getList(init = false) {
  42. if (init.detail != undefined) init = init.detail;
  43. let content = this.data.content;
  44. if (init) content.pageNumber = 1;
  45. if (content.pageNumber > content.pageTotal) return;
  46. this.setListHeight();
  47. console.log(content)
  48. _Http.basic({
  49. "id": "20230626104003",
  50. "version": 1,
  51. content
  52. }).then(res => {
  53. console.log("发货列表", res)
  54. this.selectComponent('#ListBox').RefreshToComplete();
  55. content.pageNumber = res.pageNumber + 1
  56. content.pageTotal = res.pageTotal
  57. res.data.map(v => {
  58. v.amount = CNY(currency(v.price).multiply(v.qty));
  59. v.price = CNY(v.price);
  60. return v
  61. })
  62. this.setData({
  63. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  64. content
  65. })
  66. })
  67. },
  68. /* 修改查看日期 */
  69. changeDate(e) {
  70. this.data.content.where[e.currentTarget.dataset.name] = e.detail.value;
  71. this.getList(true)
  72. },
  73. initialize() {
  74. this.data.content.where.enddate = "";
  75. this.data.content.where.begindate = "";
  76. this.getList(true)
  77. },
  78. /* 搜索 */
  79. onSearch({
  80. detail
  81. }) {
  82. this.data.content.where.condition = detail;
  83. this.getList(true)
  84. },
  85. /* 设置页面高度 */
  86. setListHeight() {
  87. this.selectComponent("#ListBox").setHeight(".head", this);
  88. }
  89. })