journal.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <!--
  2. * @Author: your name
  3. * @Date: 2021-11-25 10:42:02
  4. * @LastEditTime: 2021-11-25 17:19:06
  5. * @LastEditors: Please set LastEditors
  6. * @Description: 个人日志
  7. * @FilePath: \Foshan4A2.0\src\views\dashboard\components\journal.vue
  8. -->
  9. <template>
  10. <div class="dashboard-journal">
  11. <div class="journal-title flex">
  12. <div class="title">个人日志</div>
  13. <div class="search flex-wrap">
  14. <div class="j-date">
  15. <el-date-picker v-model="value1" size="small" @change="pickerChange" value-format="yyyy-MM-dd HH:mm:ss" class="j-date-input" type="datetimerange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
  16. </el-date-picker>
  17. </div>
  18. <Search @getSearchData="getSearchData" @clearSearchData="clearSearch" :isTitle="false" :isSlot="false" />
  19. </div>
  20. </div>
  21. <div class="journal-content">
  22. <el-table :data="tableData" :row-class-name="tableRowClassName" class="table scrollbar" height="450" style="width: 100%">
  23. <el-table-column label="用户名">
  24. <template slot-scope="scope">
  25. <div :class="scope.row.isSocket ? 'red' : ''">{{ scope.row.UserName ? scope.row.UserName : "暂无数据" }}</div>
  26. </template>
  27. </el-table-column>
  28. <el-table-column label="应用名称">
  29. <template slot-scope="scope">
  30. <div :class="scope.row.isSocket ? 'red' : ''">{{ scope.row.AppName ? scope.row.AppName : "暂无数据" }}</div>
  31. </template>
  32. </el-table-column>
  33. <el-table-column label="IP">
  34. <template slot-scope="scope">
  35. <div :class="scope.row.isSocket ? 'red' : ''">
  36. {{ scope.row.OperateIP ? scope.row.OperateIP : "暂无数据" }}
  37. </div>
  38. </template>
  39. </el-table-column>
  40. <el-table-column label="内容">
  41. <template slot-scope="scope">
  42. <div :class="scope.row.isSocket ? 'red' : ''">{{ scope.row.Msg ? scope.row.Msg : "暂无数据" }}</div>
  43. </template>
  44. </el-table-column>
  45. <el-table-column label="结果">
  46. <template slot-scope="scope">
  47. <div :class="scope.row.isSocket ? 'red' : ''">
  48. {{
  49. scope.row.OperateResult ? scope.row.OperateResult : "暂无数据"
  50. }}
  51. </div>
  52. </template>
  53. </el-table-column>
  54. <el-table-column label="日志时间">
  55. <template slot-scope="scope">
  56. <div :class="scope.row.isSocket ? 'red' : ''">
  57. {{ scope.row.BeginTime ? scope.row.BeginTime : "暂无数据" }}
  58. </div>
  59. </template>
  60. </el-table-column>
  61. </el-table>
  62. <div class="pager">
  63. <el-pagination class="pager_btns" layout="prev, pager, next" background :hide-on-single-page="true" :current-page="page" :page-size="size" :total="total" @current-change="fetchData" />
  64. </div>
  65. </div>
  66. </div>
  67. </template>
  68. <script>
  69. import Search from "@/layout/components/Search";
  70. import { GetLogList } from "@/api/apiLog";
  71. import { parseTime } from "@/utils/index";
  72. export default {
  73. name: "Journal",
  74. components: { Search },
  75. data () {
  76. return {
  77. tableData: [],
  78. tableCopy: [],
  79. value1: [
  80. parseTime(new Date(), "{y}-{m}-{d} 00:00:00"),
  81. parseTime(
  82. new Date().getTime() + 24 * 60 * 60 * 1000,
  83. "{y}-{m}-{d} 00:00:00"
  84. ),
  85. ],
  86. Msg: "",
  87. BeginTime: "",
  88. EndTime: "",
  89. page: 1,
  90. size: 10,
  91. total: null
  92. };
  93. },
  94. watch: {
  95. "$store.state.app.wsData": {
  96. handler (arr) {
  97. const datas = arr.concat(this.tableCopy);
  98. this.tableData = datas;
  99. },
  100. deep: true,
  101. },
  102. },
  103. created () {
  104. this.BeginTime = this.value1[0];
  105. this.EndTime = this.value1[1];
  106. this.getLogList({
  107. Msg: "",
  108. BeginTime: this.BeginTime,
  109. EndTime: this.EndTime,
  110. Page: this.page,
  111. PageSize: this.size
  112. });
  113. },
  114. methods: {
  115. tableRowClassName ({ row, rowIndex }) {
  116. if (rowIndex % 2 === 0) {
  117. return "warning-row";
  118. } else {
  119. return "success-row";
  120. }
  121. },
  122. async getLogList (params) {
  123. try {
  124. const res = await GetLogList(params);
  125. if (res.code == 0) {
  126. const datas = this.$store.state.app.wsData
  127. this.tableData = datas.concat(res.returnData.result);
  128. this.tableCopy = res.returnData.result;
  129. this.total = res.returnData.total;
  130. } else {
  131. this.tableData = [];
  132. this.$message.error(res.message);
  133. }
  134. } catch (error) {
  135. console.log(error);
  136. }
  137. },
  138. getSearchData (val) {
  139. const dates = this.value1;
  140. if (dates && dates.length) {
  141. this.BeginTime = dates[0];
  142. this.EndTime = dates[1];
  143. }
  144. this.Msg = val;
  145. this.getLogList({
  146. Msg: this.Msg,
  147. BeginTime: this.BeginTime,
  148. EndTime: this.EndTime,
  149. Page: this.page,
  150. PageSize: this.size
  151. });
  152. },
  153. clearSearch () {
  154. this.Msg = "";
  155. this.getLogList({
  156. Msg: this.Msg,
  157. BeginTime: this.BeginTime,
  158. EndTime: this.EndTime,
  159. Page: this.page,
  160. PageSize: this.size
  161. });
  162. },
  163. pickerChange (val) {
  164. if (val) {
  165. if (val && val.length) {
  166. this.BeginTime = val[0];
  167. this.EndTime = val[1];
  168. }
  169. } else {
  170. this.BeginTime = "";
  171. this.EndTime = "";
  172. this.getLogList({
  173. Msg: this.Msg,
  174. BeginTime: "",
  175. EndTime: "",
  176. Page: this.page,
  177. PageSize: this.size
  178. });
  179. }
  180. },
  181. fetchData (val) {
  182. this.page = val;
  183. this.getLogList({
  184. Msg: this.Msg,
  185. BeginTime: this.BeginTime,
  186. EndTime: this.EndTime,
  187. Page: this.page,
  188. PageSize: this.size
  189. });
  190. }
  191. },
  192. };
  193. </script>
  194. <style lang="scss" scoped>
  195. .dashboard-journal {
  196. min-height: calc(100vh - 395px);
  197. padding: 32px;
  198. background: #ffffff;
  199. box-shadow: 0px 6px 7px 0px rgba(0, 0, 0, 0.06);
  200. border-radius: 16px;
  201. .journal-title {
  202. line-height: 48px;
  203. .title {
  204. font-size: 24px;
  205. font-family: Microsoft YaHei;
  206. font-weight: bold;
  207. color: #303133;
  208. }
  209. .j-date {
  210. height: 48px;
  211. line-height: 48px;
  212. padding: 0 24px;
  213. background: #ffffff;
  214. -webkit-box-shadow: 0px 6px 7px 0px rgb(0 0 0 / 6%);
  215. box-shadow: 0px 6px 7px 0px rgb(0 0 0 / 6%);
  216. border-radius: 6px;
  217. margin-right: 20px;
  218. }
  219. }
  220. .journal-content {
  221. margin-top: 24px;
  222. ::v-deep .table {
  223. .el-table__header {
  224. .has-gutter {
  225. color: #ffffff;
  226. .is-leaf {
  227. height: 64px;
  228. background: #6e82a7;
  229. &:first-child {
  230. border-top-left-radius: 6px;
  231. }
  232. &:nth-child(6) {
  233. border-top-right-radius: 6px;
  234. }
  235. }
  236. }
  237. }
  238. td.el-table__cell,
  239. th.el-table__cell.is-leaf {
  240. border-bottom: none;
  241. }
  242. .el-table__cell {
  243. padding: 16px 0;
  244. // background: #f5f7fa;
  245. }
  246. .el-table__row--level-1 {
  247. td {
  248. background: #dfe4ec;
  249. }
  250. }
  251. &::before {
  252. width: 0;
  253. }
  254. tbody tr:hover > td {
  255. background-color: transparent;
  256. }
  257. .warning-row {
  258. background-color: #f5f7fa;
  259. }
  260. .success-row {
  261. background-color: #e3e6ef;
  262. }
  263. .el-table__body-wrapper {
  264. &::-webkit-scrollbar {
  265. width: 8px;
  266. }
  267. &::-webkit-scrollbar-thumb {
  268. background: #b6bac3;
  269. border-radius: 2px;
  270. }
  271. }
  272. .red {
  273. color: red;
  274. }
  275. }
  276. ::v-deep .pager {
  277. text-align: right;
  278. margin-top: 20px;
  279. &_btns {
  280. display: inline-block;
  281. .el-pager li.active {
  282. background: linear-gradient(0deg, #6983be, #777dba);
  283. }
  284. }
  285. }
  286. }
  287. }
  288. </style>