operation_log.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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-select v-model="req.type" class="search_input" @change="loadData">
  9. <el-option v-for="(item, idx) in typeOptions" :key="idx" :label="item.label"
  10. :value="item.value"></el-option>
  11. </el-select>
  12. </div>
  13. <div class="dflex_vertical_c margin_r_40 margin_b_20" v-if="advancedSearch">
  14. <div class="search_name">状态:</div>
  15. <el-select v-model="req.state" class="search_input" @change="loadData">
  16. <el-option v-for="(item, idx) in stateOptions" :key="idx" :label="item.label"
  17. :value="item.value"></el-option>
  18. </el-select>
  19. </div>
  20. <el-button size="mini" class="search_btn margin_b_20 margin_r_40" @click="loadData">搜索</el-button>
  21. <div class="search_advanced margin_b_20" @click="advancedSearch = !advancedSearch"
  22. v-if="!advancedSearch">高级筛选</div>
  23. <div class="search_common margin_b_20" @click="advancedSearch = !advancedSearch" v-if="advancedSearch">
  24. 常用筛选</div>
  25. </div>
  26. </div>
  27. <div class="container use-table">
  28. <el-table :height="tblHeight" :data="tableDatas" highlight-current-row>
  29. <el-table-column property="user_id" label="设备ID" align="center"></el-table-column>
  30. <el-table-column label="类型" align="center">
  31. <template slot-scope="scope">
  32. <div>{{ scope.row.type == 'login' ? '登录' : '退出' }}</div>
  33. </template>
  34. </el-table-column>
  35. <el-table-column label="状态" align="center">
  36. <template slot-scope="scope">
  37. <div>{{ scope.row.state == '1' ? '成功' : '失败' }}</div>
  38. </template>
  39. </el-table-column>
  40. <el-table-column property="create_date" label="操作时间" align="center"></el-table-column>
  41. </el-table>
  42. <el-pagination :current-page="req.page" :page-sizes="[10, 20, 30, 50, 100]" :page-size="req.rows"
  43. layout="total, sizes, prev, pager, next, jumper" :total="tableTotal" @size-change="sizeChange"
  44. @current-change="currentChange"></el-pagination>
  45. </div>
  46. </div>
  47. </template>
  48. <script>
  49. const __name = 'uni-id-log';
  50. export default {
  51. data() {
  52. return {
  53. advancedSearch: false,
  54. typeOptions: [{
  55. value: '',
  56. label: '全部'
  57. },
  58. {
  59. value: 'login',
  60. label: '登录'
  61. },
  62. {
  63. value: 'logout',
  64. label: '登出'
  65. }
  66. ],
  67. stateOptions: [{
  68. value: '',
  69. label: '全部'
  70. },
  71. {
  72. value: '1',
  73. label: '成功'
  74. },
  75. {
  76. value: '0',
  77. label: '失败'
  78. }
  79. ],
  80. req: {
  81. page: 1,
  82. rows: 20,
  83. orderby: 'sort asc',
  84. name: '',
  85. state: ''
  86. },
  87. tblHeight: 0,
  88. tableDatas: [],
  89. tableTotal: 0,
  90. selectDatas: []
  91. };
  92. },
  93. methods: {
  94. async loadData() {
  95. await this.$db[__name]
  96. .whereif(this.req.type, {
  97. type: this.req.type
  98. })
  99. .whereif(this.req.state, {
  100. state: parseInt(this.req.state)
  101. })
  102. .totable(this.req)
  103. .then(res => {
  104. if (res.code == 200) {
  105. res.datas.rows.forEach((row, idx) => {
  106. row.create_date = new Date(row.create_date).format();
  107. });
  108. this.tableDatas = res.datas.rows;
  109. this.tableTotal = res.datas.total;
  110. }
  111. });
  112. },
  113. sizeChange(size) {
  114. this.req.rows = size;
  115. this.loadData();
  116. },
  117. currentChange(current) {
  118. this.req.page = current;
  119. this.loadData();
  120. }
  121. },
  122. created() {
  123. this.loadData();
  124. },
  125. updated() {
  126. if (!this.tblHeight) {
  127. this.tblHeight = this.$refs.tbl.tblHeight;
  128. }
  129. }
  130. };
  131. </script>
  132. <style></style>