address.vue 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <div class="app-container">
  3. <!-- 查询和其他操作 -->
  4. <div class="filter-container">
  5. <el-input v-model="listQuery.userId" clearable class="filter-item" style="width: 200px;" placeholder="请输入用户ID"/>
  6. <el-input v-model="listQuery.name" clearable class="filter-item" style="width: 200px;" placeholder="请输入收货人名称"/>
  7. <el-button class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">查找</el-button>
  8. <el-button :loading="downloadLoading" class="filter-item" type="primary" icon="el-icon-download" @click="handleDownload">导出</el-button>
  9. </div>
  10. <!-- 查询结果 -->
  11. <el-table v-loading="listLoading" :data="list" size="small" element-loading-text="正在查询中。。。" border fit highlight-current-row>
  12. <el-table-column align="center" width="100px" label="地址ID" prop="id" sortable/>
  13. <el-table-column align="center" min-width="100px" label="用户ID" prop="userId"/>
  14. <el-table-column align="center" min-width="100px" label="收货人名称" prop="name"/>
  15. <el-table-column align="center" min-width="100px" label="手机号码" prop="mobile"/>
  16. <el-table-column align="center" min-width="300px" label="地址" prop="address">
  17. <template slot-scope="scope">
  18. {{ scope.row.province + scope.row.city + scope.row.area + scope.row.address }}
  19. </template>
  20. </el-table-column>
  21. <el-table-column align="center" min-width="80px" label="默认" prop="isDefault">
  22. <template slot-scope="scope">
  23. {{ scope.row.isDefault ? '是' : '否' }}
  24. </template>
  25. </el-table-column>
  26. </el-table>
  27. <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList" />
  28. </div>
  29. </template>
  30. <script>
  31. import { listAddress } from '@/api/user'
  32. import Pagination from '@/components/Pagination' // Secondary package based on el-pagination
  33. export default {
  34. name: 'UserAddress',
  35. components: { Pagination },
  36. data() {
  37. return {
  38. list: null,
  39. total: 0,
  40. listLoading: true,
  41. listQuery: {
  42. page: 1,
  43. limit: 20,
  44. name: undefined,
  45. userId: undefined,
  46. sort: 'add_time',
  47. order: 'desc'
  48. },
  49. downloadLoading: false
  50. }
  51. },
  52. created() {
  53. this.getList()
  54. },
  55. methods: {
  56. getList() {
  57. this.listLoading = true
  58. listAddress(this.listQuery).then(response => {
  59. this.list = response.data.data.items
  60. this.total = response.data.data.total
  61. this.listLoading = false
  62. }).catch(() => {
  63. this.list = []
  64. this.total = 0
  65. this.listLoading = false
  66. })
  67. },
  68. handleFilter() {
  69. this.listQuery.page = 1
  70. this.getList()
  71. },
  72. handleDownload() {
  73. this.downloadLoading = true
  74. import('@/vendor/Export2Excel').then(excel => {
  75. const tHeader = ['地址ID', '用户ID', '收获人', '手机号', '省', '市', '区', '地址', '是否默认']
  76. const filterVal = ['id', 'userId', 'name', 'mobile', 'province', 'city', 'area', 'address', 'isDefault']
  77. excel.export_json_to_excel2(tHeader, this.list, filterVal, '用户地址信息')
  78. this.downloadLoading = false
  79. })
  80. }
  81. }
  82. }
  83. </script>