sku-rank.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // package5/pages/report/detail/detail.js
  2. const app = getApp()
  3. const Constants = require('../../../../utils/Constants.js');
  4. const mixins = require('@/mixins/index.js')
  5. Page({
  6. mixins: [mixins],
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. service: app.globalData['reportService'],
  12. // 查询条件
  13. searchContent: [{
  14. code: 'makeTime',
  15. title: mixins.$t('currentMonth'),
  16. defaultValue: 3,
  17. searchType: Constants.searchType.date
  18. },
  19. {
  20. code: 'orderBy',
  21. title: mixins.$t('sort'),
  22. searchType: Constants.searchType.radio,
  23. value: 1,
  24. options: [
  25. {
  26. "text": "利润升序",
  27. "value": "profitAsc"
  28. },
  29. {
  30. "text": "利润倒序",
  31. "value": "profitDesc"
  32. },
  33. {
  34. "text": "利率升序",
  35. "value": "rateAsc"
  36. },
  37. {
  38. "text": "利率倒序",
  39. "value": "rateDsc"
  40. },
  41. ],
  42. }
  43. ],
  44. tab1Columns: [
  45. {
  46. "name": "skuName",
  47. "title": "商品型号/名称",
  48. "width": "50%"
  49. },
  50. {
  51. "name": "profit",
  52. "title": "销售利润",
  53. "type": "amount",
  54. "width": "30%"
  55. },
  56. {
  57. "after": "%",
  58. "name": "profitRate",
  59. "title": "利润率",
  60. "width": "20%"
  61. }
  62. ],
  63. tab1TableData: [],
  64. tab1TopData: [
  65. {
  66. "title": "销售利润(总额)",
  67. "type": "amount",
  68. "value": "0.00"
  69. },
  70. {
  71. "title": "利润率",
  72. "type": "amount",
  73. "value": "0.00"
  74. }
  75. ],
  76. },
  77. /**
  78. * 生命周期函数--监听页面加载
  79. */
  80. onLoad(options) {
  81. this.getReportData()
  82. },
  83. /** 查询页面展示的所有 */
  84. getReportData() {
  85. this.excute(this.data.service, this.data.service.getSaleProfitGroupBySku, JSON.parse(this.data.searchForm)).then(res => {
  86. if (res.data.code == Constants.SUCESS_CODE) {
  87. this.setData({
  88. tab1TopData: [{ title: '销售利润(总额)', type: 'amount', value: res.data.data.profit ? res.data.data.profit.profit : 0 },
  89. { title: '利润率', type: '', value: (res.data.data.profit ? res.data.data.profit.profitRate : 0) + '%' }
  90. ],
  91. tab1TableData: res.data.data.skuProfit
  92. })
  93. }
  94. })
  95. },
  96. })