LogList.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <template>
  2. <a-card :bordered="false">
  3. <!--导航区域-->
  4. <div>
  5. <a-tabs defaultActiveKey="1" @change="callback">
  6. <a-tab-pane tab="登录日志" key="1"></a-tab-pane>
  7. <a-tab-pane tab="操作日志" key="2"></a-tab-pane>
  8. </a-tabs>
  9. </div>
  10. <!-- 查询区域 -->
  11. <div class="table-page-search-wrapper">
  12. <a-form layout="inline" @keyup.enter.native="searchQuery">
  13. <a-row :gutter="24">
  14. <a-col :md="6" :sm="8">
  15. <a-form-item label="搜索日志">
  16. <a-input placeholder="请输入搜索关键词" v-model="queryParam.keyWord"></a-input>
  17. </a-form-item>
  18. </a-col>
  19. <a-col :md="6" :sm="10">
  20. <a-form-item label="创建时间" :labelCol="labelCol" :wrapperCol="wrapperCol">
  21. <a-range-picker
  22. style="width: 210px"
  23. v-model="queryParam.createTimeRange"
  24. format="YYYY-MM-DD"
  25. :placeholder="['开始时间', '结束时间']"
  26. @change="onDateChange"
  27. @ok="onDateOk"
  28. />
  29. </a-form-item>
  30. </a-col>
  31. <a-col :md="5" :sm="8" v-if="tabKey === '2'">
  32. <a-form-item label="操作类型" style="left: 10px">
  33. <j-dict-select-tag v-model="queryParam.operateType" placeholder="请选择操作类型" dictCode="operate_type"/>
  34. </a-form-item>
  35. </a-col>
  36. <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
  37. <a-col :md="6" :sm="24" >
  38. <a-button type="primary" style="left: 10px" @click="searchQuery" icon="search">查询</a-button>
  39. <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px;left: 10px">重置</a-button>
  40. </a-col>
  41. </span>
  42. </a-row>
  43. </a-form>
  44. </div>
  45. <!-- table区域-begin -->
  46. <a-table
  47. ref="table"
  48. size="middle"
  49. rowKey="id"
  50. :columns="columns"
  51. :dataSource="dataSource"
  52. :pagination="ipagination"
  53. :loading="loading"
  54. @change="handleTableChange">
  55. <div v-show="queryParam.logType==2" slot="expandedRowRender" slot-scope="record" style="margin: 0">
  56. <div style="margin-bottom: 5px"><a-badge status="success" style="vertical-align: middle;"/><span style="vertical-align: middle;">请求方法:{{ record.method }}</span></div>
  57. <div><a-badge status="processing" style="vertical-align: middle;"/><span style="vertical-align: middle;">请求参数:{{ record.requestParam }}</span></div>
  58. </div>
  59. <!-- 字符串超长截取省略号显示-->
  60. <span slot="logContent" slot-scope="text, record">
  61. <j-ellipsis :value="text" :length="40"/>
  62. </span>
  63. </a-table>
  64. <!-- table区域-end -->
  65. </a-card>
  66. </template>
  67. <script>
  68. import { filterObj } from '@/utils/util';
  69. import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  70. import JEllipsis from '@/components/jeecg/JEllipsis'
  71. export default {
  72. name: "LogList",
  73. mixins:[JeecgListMixin],
  74. components: {
  75. JEllipsis
  76. },
  77. data () {
  78. return {
  79. description: '这是日志管理页面',
  80. // 查询条件
  81. queryParam: {
  82. ipInfo:'',
  83. createTimeRange:[],
  84. logType:'1',
  85. keyWord:'',
  86. },
  87. tabKey: "1",
  88. // 表头
  89. columns: [
  90. {
  91. title: '#',
  92. dataIndex: '',
  93. key:'rowIndex',
  94. align:"center",
  95. customRender:function (t,r,index) {
  96. return parseInt(index)+1;
  97. }
  98. },
  99. {
  100. title: '日志内容',
  101. align:"left",
  102. dataIndex: 'logContent',
  103. scopedSlots: { customRender: 'logContent' },
  104. sorter: true
  105. },
  106. {
  107. title: '操作人ID',
  108. dataIndex: 'userid',
  109. align:"center",
  110. sorter: true
  111. },
  112. {
  113. title: '操作人名称',
  114. dataIndex: 'username',
  115. align:"center",
  116. sorter: true
  117. },
  118. {
  119. title: 'IP',
  120. dataIndex: 'ip',
  121. align:"center",
  122. sorter: true
  123. },
  124. {
  125. title: '耗时(毫秒)',
  126. dataIndex: 'costTime',
  127. align:"center",
  128. sorter: true
  129. },
  130. {
  131. title: '日志类型',
  132. dataIndex: 'logType_dictText',
  133. /*customRender:function (text) {
  134. if(text==1){
  135. return "登录日志";
  136. }else if(text==2){
  137. return "操作日志";
  138. }else{
  139. return text;
  140. }
  141. },*/
  142. align:"center",
  143. },
  144. {
  145. title: '创建时间',
  146. dataIndex: 'createTime',
  147. align:"center",
  148. sorter: true
  149. }
  150. ],
  151. operateColumn:
  152. {
  153. title: '操作类型',
  154. dataIndex: 'operateType_dictText',
  155. align:"center",
  156. },
  157. labelCol: {
  158. xs: { span: 1 },
  159. sm: { span: 2 },
  160. },
  161. wrapperCol: {
  162. xs: { span: 10 },
  163. sm: { span: 16 },
  164. },
  165. url: {
  166. list: "/sys/log/list",
  167. },
  168. }
  169. },
  170. methods: {
  171. getQueryParams(){
  172. var param = Object.assign({}, this.queryParam,this.isorter);
  173. param.field = this.getQueryField();
  174. param.pageNo = this.ipagination.current;
  175. param.pageSize = this.ipagination.pageSize;
  176. delete param.createTimeRange; // 时间参数不传递后台
  177. if (this.superQueryParams) {
  178. param['superQueryParams'] = encodeURI(this.superQueryParams)
  179. param['superQueryMatchType'] = this.superQueryMatchType
  180. }
  181. return filterObj(param);
  182. },
  183. // 重置
  184. searchReset(){
  185. var that = this;
  186. var logType = that.queryParam.logType;
  187. that.queryParam = {}; //清空查询区域参数
  188. that.queryParam.logType = logType;
  189. that.loadData(this.ipagination.current);
  190. },
  191. // 日志类型
  192. callback(key){
  193. // 动态添加操作类型列
  194. if (key == 2) {
  195. this.tabKey = '2';
  196. this.columns.splice(7, 0, this.operateColumn);
  197. }else if(this.columns.length == 9)
  198. {
  199. this.tabKey = '1';
  200. this.columns.splice(7,1);
  201. }
  202. let that=this;
  203. that.queryParam.logType=key;
  204. that.loadData();
  205. },
  206. onDateChange: function (value, dateString) {
  207. console.log(dateString[0],dateString[1]);
  208. this.queryParam.createTime_begin=dateString[0];
  209. this.queryParam.createTime_end=dateString[1];
  210. },
  211. onDateOk(value) {
  212. console.log(value);
  213. },
  214. }
  215. }
  216. </script>
  217. <style scoped>
  218. @import '~@assets/less/common.less'
  219. </style>