sentandback.js 2.7 KB

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