list.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <div>
  3. <use-table ref="tbl"></use-table>
  4. <div class="container padding_b_0">
  5. <!-- <div class="dflex_wrap">
  6. <div class="dflex_vertical_c margin_r_40 margin_b_20">
  7. <div class="search_name">关键字:</div>
  8. <el-input v-model="req.keyword" placeholder="请输入" @input="loadData" class="search_input"></el-input>
  9. </div>
  10. <el-button size="mini" class="search_btn margin_b_20 margin_r_40" @click="loadData">搜索</el-button>
  11. </div> -->
  12. </div>
  13. <div class="container use-table">
  14. <el-table :height="tblHeight" :data="tableDatas" highlight-current-row>
  15. <el-table-column property="userId" label="用户ID" align="center"></el-table-column>
  16. <el-table-column property="keyword" label="关键字" align="center"></el-table-column>
  17. <el-table-column property="searchCnt" label="搜索次数" align="center"></el-table-column>
  18. <el-table-column property="createTime" label="创建时间" align="center"></el-table-column>
  19. </el-table>
  20. <el-pagination
  21. :current-page="req.page"
  22. :page-sizes="[10, 20, 30, 50, 100]"
  23. :page-size="req.rows"
  24. layout="total, sizes, prev, pager, next, jumper"
  25. :total="tableTotal"
  26. @size-change="sizeChange"
  27. @current-change="currentChange"
  28. ></el-pagination>
  29. </div>
  30. </div>
  31. </template>
  32. <script>
  33. const __name = 'usemall-search-history';
  34. export default {
  35. data() {
  36. return {
  37. req: {
  38. page: 1,
  39. rows: 10,
  40. orderby: 'sort asc',
  41. keyword: ''
  42. },
  43. tblHeight: 0,
  44. tableDatas: [],
  45. tableTotal: 0
  46. };
  47. },
  48. methods: {
  49. loadData() {
  50. //历史搜索
  51. this.$axios.get("/usersearchhistory/list",
  52. {
  53. params:{
  54. 'curPage':this.req.page,
  55. 'pageSize':this.req.rows,
  56. },
  57. headers:{
  58. 'User-Token': uni.getStorageSync('tokenId')
  59. }
  60. }).then(response => {
  61. let res = response
  62. console.log(res)
  63. if (res.success) {
  64. res.data.list.forEach((row, idx) => {
  65. row.createTime = new Date(row.createTime).format();
  66. });
  67. this.tableDatas = res.data.list;
  68. this.tableTotal = res.data.totalCount;
  69. } else {
  70. }
  71. }).catch(res =>{
  72. });
  73. // this.$db[__name]
  74. // .whereif(this.req.keyword, { keyword: new RegExp(this.req.keyword) })
  75. // .totable(this.req)
  76. // .then(res => {
  77. // if (res.code == 200) {
  78. // res.datas.rows.forEach((row, idx) => {
  79. // row.create_time = new Date(row.create_time).format();
  80. // });
  81. // this.tableDatas = res.datas.rows;
  82. // this.tableTotal = res.datas.total;
  83. // }
  84. // });
  85. },
  86. sizeChange(size) {
  87. this.req.rows = size;
  88. this.loadData();
  89. },
  90. currentChange(current) {
  91. this.req.page = current;
  92. this.loadData();
  93. }
  94. },
  95. created() {
  96. this.loadData();
  97. },
  98. updated() {
  99. if (!this.tblHeight) {
  100. this.tblHeight = this.$refs.tbl.tblHeight;
  101. }
  102. }
  103. };
  104. </script>
  105. <style ></style>