ba-dec-order-list.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <div v-loading="loading">
  3. <div class="white-box">
  4. <el-table class="withdraw-table" :data="tableData" :max-height="maxHeight" style="width: 100%;" :span-method="objectSpanMethod">
  5. <el-table-column width="120" label="Product code" prop="SKU_CODE"></el-table-column><!--商品编号-->
  6. <el-table-column width="120" label="Product Name" prop="GOODS_TITLE"></el-table-column><!--商品名称-->
  7. <el-table-column width="120" label="Product Price" prop="REAL_PRICE"></el-table-column><!--报单金额-->
  8. <el-table-column width="120" label="Product BV" prop="REAL_PV"></el-table-column><!--报单BV-->
  9. <el-table-column width="120" label="Qty" prop="BUY_NUMS"></el-table-column><!--数量-->
  10. <el-table-column width="120" label="Tax rate" prop="TAX_RATE"></el-table-column><!--税率-->
  11. <el-table-column width="120" label="Tax" prop="TAX_AMOUNT"></el-table-column><!--税额-->
  12. <el-table-column width="120" label="Total Price" prop="TOTAL_AMOUNT"></el-table-column><!--总计金额-->
  13. <el-table-column width="120" label="Code" prop="DEC_SN"></el-table-column><!--报单编号-->
  14. <el-table-column width="120" label="Order code" prop="ORDER_SN"></el-table-column><!--订单编号-->
  15. <el-table-column width="120" label="Member code" prop="USER_NAME"></el-table-column><!--会员编号-->
  16. <el-table-column width="120" label="Member name" prop="REAL_NAME"></el-table-column><!--会员姓名-->
  17. <el-table-column width="150" label="Shipping Address" prop="ADDRESS"></el-table-column><!--收货地址-->
  18. <el-table-column width="120" label="Sponsor code" prop="CON_USER_NAME"></el-table-column><!--接点人编号-->
  19. <el-table-column width="120" label="Status" prop="STATUS"></el-table-column><!--状态-->
  20. <el-table-column width="150" label="Created time" prop="CREATED_AT"></el-table-column >
  21. <el-table-column width="120" label="Action"><!--操作-->
  22. <template slot-scope="scope">
  23. <el-button type="primary" size="small" @click.native="handleOrderExportPDF(scope.row.ORDER_SN)">Export PDF</el-button><!--导出PDF-->
  24. </template>
  25. </el-table-column>
  26. </el-table>
  27. <div class="white-box-footer">
  28. <pagination :total="totalCount" :page_size="pageSize" @size-change="handleSizeChange" @current-change="handleCurrentChange"></pagination>
  29. </div>
  30. </div>
  31. </div>
  32. </template>
  33. <script>
  34. import network from '@/utils/network'
  35. import tool from '@/utils/tool'
  36. import Pagination from '@/components/Pagination'
  37. import {SERVER_API_HTTP_TYPE, SERVER_API_DOMAIN,SERVER_API_PORT} from '@/utils/config'
  38. export default {
  39. name: 'dec-order-list',
  40. components: {Pagination},
  41. mounted () {
  42. this.getData()
  43. },
  44. data () {
  45. return {
  46. loading: false,
  47. form: {},
  48. tableData: null,
  49. list: null,
  50. currentPage: 1,
  51. totalPages: 1,
  52. totalCount: 1,
  53. pageSize: 20,
  54. tool: tool,
  55. // 订单号判断
  56. spanArr: [], // 用于存放需要合并的行的个数
  57. pos: 0, // 记录spanArr数组的下标
  58. maxHeight: tool.getTableHeight()
  59. }
  60. },
  61. methods: {
  62. objectSpanMethod (obj) {
  63. if (obj.columnIndex >= 7) {
  64. // ⼆维数组存储的数据取出
  65. let _row = this.spanArr[obj.rowIndex]
  66. let _col = _row > 0 ? 1 : 0
  67. return {
  68. rowspan: _row,
  69. colspan: _col
  70. }
  71. } else {
  72. return false
  73. }
  74. },
  75. getSpanArr (orderList) { // 传⼊你的列表数据
  76. this.pos = 0
  77. orderList.forEach((item, index) => {
  78. // 判断是否是第⼀项
  79. if (index === 0) {
  80. this.spanArr.push(1)
  81. this.pos = 0
  82. } else {
  83. // 不是第⼀项时,就根据标识去存储
  84. if ( // orderSn,createdAt...是你的第⼀个数据、第⼆个数据...
  85. orderList[index].DEC_SN === orderList[index - 1].DEC_SN &&
  86. orderList[index].ORDER_SN === orderList[index - 1].ORDER_SN &&
  87. orderList[index].USER_NAME === orderList[index - 1].USER_NAME &&
  88. orderList[index].REAL_NAME === orderList[index - 1].REAL_NAME &&
  89. orderList[index].CON_USER_NAME === orderList[index - 1].CON_USER_NAME &&
  90. orderList[index].P_CALC_MONTH === orderList[index - 1].P_CALC_MONTH
  91. ) {
  92. // 查找到符合条件的数据时每次要把之前存储的数据+1
  93. this.spanArr[this.pos] += 1
  94. this.spanArr.push(0)
  95. } else {
  96. // 没有符合的数据时,要记住当前的index
  97. this.spanArr.push(1)
  98. this.pos = index
  99. }
  100. }
  101. })
  102. },
  103. handleCurrentChange (page) {
  104. this.getData(page, this.pageSize)
  105. },
  106. handleSizeChange (pageSize) {
  107. this.getData(this.currentPage, pageSize)
  108. },
  109. getData (page, pageSize) {
  110. this.spanArr = []
  111. this.pos = 0
  112. let _this = this
  113. network.getPageData(_this, 'shop/ba-dec-order-list', page, pageSize, {type: this.type}, function (response) {
  114. _this.loading = false
  115. _this.list = response.list
  116. let settingObj = _this.list
  117. _this.tableData = Object.keys(settingObj).map(key => {
  118. return settingObj[key] // 把每个对象返回出去生成一个新的数组中相当于0:{id:1}
  119. })
  120. _this.getSpanArr(_this.tableData)
  121. })
  122. },
  123. // 导出PDF订单
  124. handleOrderExportPDF (orderSn) {
  125. network.getData(`shop/ba-dec-order-export/${orderSn}`).then(response => {
  126. let { fileUrl, targetName } = response
  127. let downloadElement = document.createElement('a')
  128. downloadElement.target = '_blank'
  129. downloadElement.href = SERVER_API_HTTP_TYPE + SERVER_API_DOMAIN + SERVER_API_PORT + '/' + fileUrl
  130. // 下载后文件名
  131. downloadElement.download = targetName
  132. // 点击下载
  133. downloadElement.click()
  134. })
  135. }
  136. }
  137. }
  138. </script>
  139. <style scoped>
  140. </style>