You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

193 lines
5.1 KiB

3 years ago
3 years ago
  1. <template>
  2. <el-dialog
  3. title="日志列表"
  4. :close-on-click-modal="false"
  5. :visible.sync="visible"
  6. width="75%">
  7. <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
  8. <el-form-item>
  9. <el-input v-model="dataForm.id" clearable></el-input>
  10. </el-form-item>
  11. <el-form-item>
  12. <el-button type="primary" @click="getDataList()">{{ buttons.search || '查询' }}</el-button>
  13. </el-form-item>
  14. </el-form>
  15. <el-table
  16. :data="dataList"
  17. border
  18. v-loading="dataListLoading"
  19. height="460"
  20. style="width: 100%;">
  21. <el-table-column
  22. prop="logId"
  23. header-align="center"
  24. align="center"
  25. width="80"
  26. :label="buttons.logId || '日志ID'">
  27. </el-table-column>
  28. <el-table-column
  29. prop="jobId"
  30. header-align="center"
  31. align="center"
  32. width="80"
  33. :label="buttons.jobId ||'任务ID'">
  34. </el-table-column>
  35. <el-table-column
  36. prop="beanName"
  37. header-align="center"
  38. align="center"
  39. :label="buttons.beanName ||'bean名称'">
  40. </el-table-column>
  41. <el-table-column
  42. prop="params"
  43. header-align="center"
  44. align="center"
  45. :label="buttons.params ||'参数'">
  46. </el-table-column>
  47. <el-table-column
  48. prop="status"
  49. header-align="center"
  50. align="center"
  51. :label="buttons.status ||'状态'">
  52. <template slot-scope="scope">
  53. <el-tag v-if="scope.row.status === 0" size="small">{{ buttons.success || '成功' }}</el-tag>
  54. <el-tag v-else @click.native="showErrorInfo(scope.row.logId)" size="small" type="danger"
  55. style="cursor: pointer;"> {{ buttons.fail || '失败' }}
  56. </el-tag>
  57. </template>
  58. </el-table-column>
  59. <el-table-column
  60. prop="times"
  61. header-align="center"
  62. align="center"
  63. :label="buttons.times ||'耗时(单位: 毫秒)'">
  64. </el-table-column>
  65. <el-table-column
  66. prop="createTime"
  67. header-align="center"
  68. align="center"
  69. width="180"
  70. :label="buttons.createTime ||'执行时间'">
  71. </el-table-column>
  72. <el-table-column
  73. prop="errorMsg"
  74. header-align="center"
  75. align="center"
  76. width="180"
  77. :label="buttons.errorMsg ||'执行结果'">
  78. </el-table-column>
  79. </el-table>
  80. <el-pagination
  81. @size-change="sizeChangeHandle"
  82. @current-change="currentChangeHandle"
  83. :current-page="pageIndex"
  84. :page-sizes="[20, 50, 100, 200,500]"
  85. :page-size="pageSize"
  86. :total="totalPage"
  87. layout="total, sizes, prev, pager, next, jumper">
  88. </el-pagination>
  89. </el-dialog>
  90. </template>
  91. <script>
  92. import {
  93. searchFunctionButtonList,
  94. } from "@/api/sysLanguage.js"
  95. export default {
  96. data() {
  97. return {
  98. visible: false,
  99. dataForm: {
  100. id: ''
  101. },
  102. dataList: [],
  103. pageIndex: 1,
  104. pageSize: 20,
  105. totalPage: 0,
  106. dataListLoading: false,
  107. buttons: {
  108. search: '查询',
  109. logId: '日志ID',
  110. jobId: '任务ID',
  111. beanName: 'bean名称',
  112. params: '参数',
  113. success: '成功',
  114. fail: '失败',
  115. times: '耗时(单位: 毫秒)',
  116. createTime: '执行时间',
  117. errorMsg: '执行结果',
  118. },
  119. }
  120. },
  121. methods: {
  122. // 获取button的词典
  123. getFunctionButtonList() {
  124. let queryButton = {
  125. functionId: this.$route.meta.menuId,
  126. tableId: '*',
  127. languageCode: this.$i18n.locale,
  128. objectType: 'button'
  129. }
  130. searchFunctionButtonList(queryButton).then(({data}) => {
  131. if (data.code == 0 && data.data) {
  132. this.buttons = data.data
  133. }
  134. })
  135. },
  136. init() {
  137. this.visible = true
  138. this.getDataList()
  139. },
  140. // 获取数据列表
  141. getDataList() {
  142. this.dataListLoading = true
  143. this.$http({
  144. url: this.$http.adornUrl('/sys/scheduleLog/list'),
  145. method: 'get',
  146. params: this.$http.adornParams({
  147. 'page': this.pageIndex,
  148. 'limit': this.pageSize,
  149. 'jobId': this.dataForm.id
  150. })
  151. }).then(({data}) => {
  152. if (data && data.code === 0) {
  153. this.dataList = data.page.list
  154. this.totalPage = data.page.totalCount
  155. } else {
  156. this.dataList = []
  157. this.totalPage = 0
  158. }
  159. this.dataListLoading = false
  160. })
  161. },
  162. // 每页数
  163. sizeChangeHandle(val) {
  164. this.pageSize = val
  165. this.pageIndex = 1
  166. this.getDataList()
  167. },
  168. // 当前页
  169. currentChangeHandle(val) {
  170. this.pageIndex = val
  171. this.getDataList()
  172. },
  173. // 失败信息
  174. showErrorInfo(id) {
  175. this.$http({
  176. url: this.$http.adornUrl(`/sys/scheduleLog/info/${id}`),
  177. method: 'get',
  178. params: this.$http.adornParams()
  179. }).then(({data}) => {
  180. if (data && data.code === 0) {
  181. this.$alert(data.log.error)
  182. } else {
  183. this.$message.error(data.msg)
  184. }
  185. })
  186. }
  187. },
  188. created() {
  189. this.getFunctionButtonList()
  190. }
  191. }
  192. </script>