moonCakeReport.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <div class="moonCakeReport">
  3. <el-table
  4. :data="tableData"
  5. v-loading="loading"
  6. border
  7. :max-height="maxHeight"
  8. :size="'mini'"
  9. :span-method="objectSpanMethod"
  10. style="width: 100%"
  11. >
  12. <el-table-column prop="itemName" label="部门" fixed="left" width="60"/>
  13. <el-table-column show-overflow-tooltip label="价格(元)" min-width="120">
  14. <template slot-scope="scope">
  15. <span>{{ scope.row.sale_price | toThousandFilter }}</span>
  16. </template>
  17. </el-table-column>
  18. <el-table-column show-overflow-tooltip label="累计销售数量" min-width="120">
  19. <template slot-scope="scope">
  20. <span>{{ scope.row.num | toThousandFilter }}</span>
  21. </template>
  22. </el-table-column>
  23. <el-table-column show-overflow-tooltip label="金额(万元)" min-width="120">
  24. <template slot-scope="scope">
  25. <span>{{ scope.row.total_fee | toThousandFilter }}</span>
  26. </template>
  27. </el-table-column>
  28. <el-table-column show-overflow-tooltip prop="good_code" label="成本商品编号" min-width="160"/>
  29. </el-table>
  30. </div>
  31. </template>
  32. <script>
  33. import asyncRequest from "@/api/index";
  34. import setHeight from "@/mixins/index";
  35. export default {
  36. name: "moonCakeReport",
  37. mixins: [setHeight],
  38. watch: {
  39. date: function (val) {
  40. this.dataTime = val;
  41. if (val) {
  42. this.searchList();
  43. }
  44. },
  45. },
  46. data() {
  47. return {
  48. dataTime: this.date,
  49. loading: false,
  50. maxHeight: "0",
  51. tableData: [],
  52. };
  53. },
  54. async created() {
  55. window.onresize = () => {
  56. this.getHeight();
  57. };
  58. },
  59. mounted() {
  60. this.$nextTick(() => {
  61. this.getHeight();
  62. });
  63. this.searchList();
  64. },
  65. methods: {
  66. objectSpanMethod({ row, column, rowIndex, columnIndex }) {
  67. const { index, span_total } = row;
  68. // console.log(column);
  69. console.log(rowIndex);
  70. console.log(columnIndex);
  71. if (columnIndex === 0) {
  72. if (index === 0) {
  73. return {
  74. rowspan: span_total,
  75. colspan: 1,
  76. };
  77. } else {
  78. return {
  79. rowspan: 0,
  80. colspan: 0,
  81. };
  82. }
  83. }
  84. },
  85. async searchList() {
  86. this.loading = true;
  87. this.tableData = [];
  88. const { code, data } = await asyncRequest.salereport({});
  89. if (code === 0) {
  90. data.forEach((a, ai) => {
  91. a.child.forEach((b, bi) => {
  92. let model = {
  93. index: bi,
  94. good_code: b.good_code,
  95. itemName: a.itemName,
  96. itemid: b.itemid,
  97. num: b.num,
  98. sale_price: b.sale_price,
  99. total_fee: b.total_fee,
  100. span_total: a.child.length,
  101. };
  102. this.tableData.push(model);
  103. });
  104. });
  105. console.log(this.tableData);
  106. } else {
  107. this.tableData = [];
  108. }
  109. this.getHeight();
  110. this.loading = false;
  111. },
  112. },
  113. };
  114. </script>
  115. <style lang="scss" scoped>
  116. .moonCakeReport {
  117. }
  118. </style>