operationLog.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. <template>
  2. <!-- 操作日志 -->
  3. <div class="operationLog_main">
  4. <div class="main_top_bg">
  5. </div>
  6. <div class="wrap">
  7. <div class="main_top">
  8. <div class="search_box">
  9. <el-input placeholder="- Enter keywords to search" v-model="keyword" class="search" @change = "search">
  10. <template slot="prepend" @click="search()">Search</template>
  11. </el-input>
  12. </div>
  13. <div class="button_box">
  14. <el-select v-model="reportType" placeholder="" @change="reportTypeFun">
  15. <el-option
  16. v-for="item in reportListEN"
  17. :key="item.value"
  18. :label="item.label"
  19. :value="item.value">
  20. </el-option>
  21. </el-select>
  22. <el-button round @click="exportExcel()" v-loading="loading.exportExcel">{{'Export Excel'}}</el-button>
  23. <el-button round @click="printing()" v-loading="loading.printing">{{'Print'}}</el-button>
  24. </div>
  25. </div>
  26. <div class="information_box">
  27. <el-table
  28. :data="tableData"
  29. ref="elTable"
  30. border
  31. width="100%"
  32. :height="showOverflowTooltip?'calc(100% - 92px)':''">
  33. <!-- <el-table-column
  34. type="selection"
  35. width="48">
  36. </el-table-column> -->
  37. <el-table-column
  38. label="Index"
  39. prop="GL_index"
  40. align="center"
  41. width="80">
  42. </el-table-column>
  43. <el-table-column
  44. align="center"
  45. :show-overflow-tooltip="showOverflowTooltip"
  46. :prop="item.prop"
  47. :label="item.label"
  48. :key="item.id"
  49. :width="item.width"
  50. :min-width="item.minWidth"
  51. v-for="(item) in tableListEN">
  52. </el-table-column>
  53. <!-- <el-table-column align="left" header-align="center" :show-overflow-tooltip="showOverflowTooltip" :prop="item.prop" :label="item.label" :key="item.id" :min-width="(item.label.length+1)*9+20" v-for="(item,index) in tableListEN" v-if="index == 4">
  54. </el-table-column> -->
  55. </el-table>
  56. <div class="paging_box">
  57. <el-pagination
  58. @size-change="handleSizeChange"
  59. @current-change="handleCurrentChange"
  60. :current-page.sync="currentPage"
  61. :page-size="pageSize"
  62. :page-sizes="[20, 40, 60, 100]"
  63. layout="sizes, prev, pager, next, jumper"
  64. :total="total">
  65. </el-pagination>
  66. </div>
  67. </div>
  68. </div>
  69. <button type="button" id="btn2" style="display: none"></button>
  70. </div>
  71. </template>
  72. <script type="text/javascript">
  73. import {mapGetters} from 'vuex'
  74. import baseApi from '../../api/base.js'
  75. import allUrl from '../../api/allUel.js'
  76. export default{
  77. data(){
  78. return{
  79. keyword:'',
  80. reportType:'login',
  81. reportList:[{label:'登录/登出日志',value:'login'},{label:'添加日志',value:'insert'},{label:'修改日志',value:'update'},{label:'指令日志',value:'cmd'},{label:'删除日志',value:'delete'},{label:'其他日志',value:'other'},],
  82. reportListEN:[{label:'Sign In/Sign out',value:'login'},{label:'Add',value:'insert'},{label:'Modify',value:'update'},{label:'Commands',value:'cmd'},{label:'Delete',value:'delete'},{label:'Others',value:'other'},],
  83. /*表格*/
  84. // tableList:[{prop:'time',label:'操作时间'},{prop:'type',label:'操作类型'},{prop:'username',label:'操作用户ID'},{prop:'realname',label:'操作用户名'},{prop:'content',label:'操作内容'}],
  85. tableListEN:[{prop:'time',label:'Operation time'},{prop:'type',label:'Operation type'},{prop:'username',label:'User ID'},{prop:'realname',label:'Username'},{prop:'content',label:'Behavior'}],
  86. tableData: [],
  87. currentPage:1,
  88. pageSize:20,
  89. total:0,
  90. loading:{
  91. exportExcel:false,
  92. table:false,
  93. printing:false,
  94. },
  95. showOverflowTooltip:true,
  96. }
  97. },
  98. computed:{
  99. ...mapGetters({
  100. token:'token',
  101. username:'username',
  102. client_key:'client_key',
  103. projectsId:'projectsId',
  104. version:'version',
  105. role:'role',
  106. remRatio:'remRatio',
  107. })
  108. },
  109. mounted(){
  110. this.getList(1,0);
  111. this.tableListEN = [
  112. {prop:'time',label:'Operation time',width:12*this.remRatio},
  113. {prop:'type',label:'Operation type',width:10*this.remRatio},
  114. {prop:'username',label:'User ID',width:8*this.remRatio},
  115. {prop:'realname',label:'Username',width:8*this.remRatio},
  116. {prop:'content',label:'Behavior',}
  117. ];
  118. },
  119. methods:{
  120. search(val){
  121. console.log(val)
  122. this.getList(1,0)
  123. },
  124. printing(){
  125. this.loading.printing = true;
  126. baseApi.ajax_post(
  127. allUrl.syslog.getList,
  128. {
  129. username:this.username,
  130. client_key:this.client_key,
  131. token:this.token,
  132. keyword:this.keyword,
  133. type:this.reportType,
  134. page:(this.currentPage - 1)*this.pageSize,
  135. count:200,
  136. download:0,
  137. print:1,
  138. },
  139. {},
  140. data =>{
  141. this.loading.printing = false;
  142. this.loading.table = false;
  143. // this.total = data.data.total*16;
  144. this.tableData = data.data.list;
  145. let i = (this.currentPage - 1)*this.pageSize+1;
  146. for(let d of this.tableData){
  147. d.GL_index = i;
  148. i++;
  149. for(let key in d){
  150. if(d[key] == null || d[key] == ''){
  151. d[key] = ' ';
  152. }
  153. }
  154. }
  155. this.showOverflowTooltip = false;
  156. $(".el-table").css({width:'1050px',borderBottom:'1px solid #ebeef5'});
  157. this.$refs.elTable.doLayout();
  158. let this_ = this;
  159. this.$nextTick(function(){
  160. $(".el-table").print({
  161. globalStyles : true,
  162. mediaPrint : false,
  163. iframe : true,
  164. deferred: $.Deferred().done(function() {
  165. $(".el-table").css({width:'100%',borderBottom:''});
  166. this_.showOverflowTooltip = true;
  167. this_.$refs.elTable.doLayout();
  168. this_.getList(this_.currentPage,0);
  169. })
  170. });
  171. })
  172. },
  173. this)
  174. },
  175. exportExcel(){
  176. this.getList(this.currentPage,1)
  177. },
  178. reportTypeFun(val){
  179. console.log(val)
  180. this.getList(1,0)
  181. },
  182. getList(value,type){
  183. if(type == 0){
  184. this.loading.table = true;
  185. }else{
  186. this.loading.exportExcel = true;
  187. }
  188. baseApi.ajax_post(
  189. allUrl.syslog.getList,
  190. {
  191. username:this.username,
  192. client_key:this.client_key,
  193. token:this.token,
  194. keyword:this.keyword,
  195. type:this.reportType,
  196. page:value,
  197. count:this.pageSize,
  198. download:type,
  199. },
  200. {},
  201. data =>{
  202. if(type == 0){
  203. this.loading.table = false;
  204. this.currentPage = value;
  205. this.total = data.data.total*this.pageSize;
  206. this.tableData = data.data.list;
  207. let i = (this.currentPage - 1)*this.pageSize+1;
  208. for(let d of this.tableData){
  209. d.GL_index = i;
  210. i++;
  211. for(let key in d){
  212. if(d[key] == null || d[key] == ''){
  213. d[key] = ' ';
  214. }
  215. }
  216. }
  217. // console.log(data,'日志列表')
  218. }else if(type == 1){
  219. this.loading.exportExcel = false;
  220. // var $eleBtn2 = $("#btn2");
  221. var $eleForm = $("<form method='get'></form>");
  222. $eleForm.attr("action",data.data.path);
  223. $(document.body).append($eleForm);
  224. //提交表单,实现下载
  225. $eleForm.submit();
  226. }
  227. },
  228. this)
  229. },
  230. /*表格*/
  231. /*分页*/
  232. handleSizeChange(val) {
  233. this.pageSize = val;
  234. this.getList(this.currentPage,0);
  235. },
  236. handleCurrentChange(val) {
  237. // console.log(`当前页: ${val}`);
  238. this.getList(val,0)
  239. },
  240. }
  241. }
  242. </script>
  243. <style type="text/css" lang="less">
  244. .operationLog_main{
  245. position: relative;
  246. min-width: 1260px;
  247. max-width: 1920px;
  248. height: 100%;
  249. min-height: 610px;
  250. max-height: 920px;
  251. >.wrap{
  252. padding: 0px 50px;
  253. height: 100%;
  254. }
  255. >.main_top_bg{
  256. // width:1920px;
  257. width: 100%;
  258. height:246px;
  259. position: absolute;
  260. z-index: -1;
  261. background:rgba(234,234,234,1);
  262. }
  263. .main_top{
  264. width: 100%;
  265. // height: 110px;
  266. margin-bottom: 29px;
  267. padding-top: 32px;
  268. position: relative;
  269. display: flex;
  270. justify-content: space-between;
  271. .search_box{
  272. width:344px;
  273. height:50px;line-height: 50px;
  274. background:rgba(255,255,255,1);
  275. box-shadow: -5px 0px 0px 0px rgba(252,132,64,1);
  276. .search{
  277. font-size:18px;
  278. font-family:PingFangSC-Regular;
  279. color:rgba(178,186,198,1);
  280. .el-input-group__prepend{
  281. cursor: pointer;
  282. }
  283. }
  284. .el-input__inner{
  285. height:50px;line-height: 50px;
  286. border: 0px;
  287. }
  288. .el-input-group__prepend{
  289. background: #ffffff;
  290. border: 0px;
  291. font-size: 18px;
  292. font-family:PingFangSC-Medium;
  293. color:rgba(26,26,26,1);
  294. }
  295. }
  296. .button_box{
  297. .el-select .el-input__inner{
  298. background: linear-gradient(#3682fb, #38a1f6);
  299. border-radius: 20px;
  300. color: #fff;
  301. text-align: center;
  302. border: 0;
  303. }
  304. .el-button{
  305. background: linear-gradient(140.3deg,rgba(252,132,64,1),rgba(254,113,33,1));
  306. color: #fff;
  307. margin-left: 18px;
  308. }
  309. }
  310. }
  311. .information_box{
  312. height: calc(100% - 113px);
  313. width:100%;
  314. border-top: 1px solid #DDE4ED;
  315. .el-table{
  316. th,td{
  317. padding: 0;
  318. >.cell{
  319. padding: 0 0.5rem;
  320. line-height: inherit;
  321. }
  322. }
  323. th{
  324. height: 3.33rem;line-height: 3.33rem;
  325. background:rgba(246,248,250,1);
  326. font-size:1rem;
  327. font-family:PingFang-SC-Medium,PingFang-SC;
  328. font-weight:500;
  329. color:rgba(102,102,102,1);
  330. }
  331. td{
  332. height: 3rem;line-height: 3rem;
  333. font-size:1rem;
  334. font-family:PingFangSC-Medium,PingFang SC;
  335. font-weight:500;
  336. color:rgba(51,51,51,1);
  337. }
  338. }
  339. .paging_box{
  340. text-align: center;
  341. padding: 30px 0;
  342. >.report_bottton{
  343. background: linear-gradient(#fc8440, #fe7121);
  344. border: 0px;
  345. color: #ffffff;
  346. }
  347. .el-pager li.active {
  348. color: #fff;
  349. background: #fc8440;
  350. border-radius: 20px;
  351. }
  352. .el-select .el-input.is-focus .el-input__inner{
  353. border-color: #fc8440;
  354. }
  355. .el-input.is-active .el-input__inner, .el-input__inner:focus{
  356. border-color: #fc8440;
  357. }
  358. }
  359. }
  360. }
  361. </style>