log.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px">
  4. <el-form-item label="任务名称" prop="jobName">
  5. <el-input
  6. v-model="queryParams.jobName"
  7. placeholder="请输入任务名称"
  8. clearable
  9. size="small"
  10. style="width: 240px"
  11. @keyup.enter.native="handleQuery"
  12. />
  13. </el-form-item>
  14. <el-form-item label="任务组名" prop="jobGroup">
  15. <el-select
  16. v-model="queryParams.jobGroup"
  17. placeholder="请任务组名"
  18. clearable
  19. size="small"
  20. style="width: 240px"
  21. >
  22. <el-option
  23. v-for="dict in jobGroupOptions"
  24. :key="dict.dictValue"
  25. :label="dict.dictLabel"
  26. :value="dict.dictValue"
  27. />
  28. </el-select>
  29. </el-form-item>
  30. <el-form-item label="执行状态" prop="status">
  31. <el-select
  32. v-model="queryParams.status"
  33. placeholder="请选择执行状态"
  34. clearable
  35. size="small"
  36. style="width: 240px"
  37. >
  38. <el-option
  39. v-for="dict in statusOptions"
  40. :key="dict.dictValue"
  41. :label="dict.dictLabel"
  42. :value="dict.dictValue"
  43. />
  44. </el-select>
  45. </el-form-item>
  46. <el-form-item label="执行时间">
  47. <el-date-picker
  48. v-model="dateRange"
  49. size="small"
  50. style="width: 240px"
  51. value-format="yyyy-MM-dd"
  52. type="daterange"
  53. range-separator="-"
  54. start-placeholder="开始日期"
  55. end-placeholder="结束日期"
  56. ></el-date-picker>
  57. </el-form-item>
  58. <el-form-item>
  59. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  60. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  61. </el-form-item>
  62. </el-form>
  63. <el-row :gutter="10" class="mb8">
  64. <el-col :span="1.5">
  65. <el-button
  66. type="danger"
  67. icon="el-icon-delete"
  68. size="mini"
  69. :disabled="multiple"
  70. @click="handleDelete"
  71. v-hasPermi="['monitor:job:remove']"
  72. >删除</el-button>
  73. </el-col>
  74. <el-col :span="1.5">
  75. <el-button
  76. type="danger"
  77. icon="el-icon-delete"
  78. size="mini"
  79. @click="handleClean"
  80. v-hasPermi="['monitor:job:remove']"
  81. >清空</el-button>
  82. </el-col>
  83. <el-col :span="1.5">
  84. <el-button
  85. type="warning"
  86. icon="el-icon-download"
  87. size="mini"
  88. @click="handleExport"
  89. v-hasPermi="['monitor:job:export']"
  90. >导出</el-button>
  91. </el-col>
  92. </el-row>
  93. <el-table v-loading="loading" :data="jobLogList" @selection-change="handleSelectionChange">
  94. <el-table-column type="selection" width="55" align="center" />
  95. <el-table-column label="日志编号" width="80" align="center" prop="jobLogId" />
  96. <el-table-column label="任务名称" align="center" prop="jobName" :show-overflow-tooltip="true" />
  97. <el-table-column label="任务组名" align="center" prop="jobGroup" :formatter="jobGroupFormat" :show-overflow-tooltip="true" />
  98. <el-table-column label="调用目标字符串" align="center" prop="invokeTarget" :show-overflow-tooltip="true" />
  99. <el-table-column label="日志信息" align="center" prop="jobMessage" :show-overflow-tooltip="true" />
  100. <el-table-column label="执行状态" align="center" prop="status" :formatter="statusFormat" />
  101. <el-table-column label="执行时间" align="center" prop="createTime" width="180">
  102. <template slot-scope="scope">
  103. <span>{{ parseTime(scope.row.createTime) }}</span>
  104. </template>
  105. </el-table-column>
  106. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  107. <template slot-scope="scope">
  108. <el-button
  109. size="mini"
  110. type="text"
  111. icon="el-icon-view"
  112. @click="handleView(scope.row)"
  113. v-hasPermi="['monitor:job:query']"
  114. >详细</el-button>
  115. </template>
  116. </el-table-column>
  117. </el-table>
  118. <pagination
  119. v-show="total>0"
  120. :total="total"
  121. :page.sync="queryParams.pageNum"
  122. :limit.sync="queryParams.pageSize"
  123. @pagination="getList"
  124. />
  125. <!-- 调度日志详细 -->
  126. <el-dialog title="调度日志详细" :visible.sync="open" width="700px" append-to-body>
  127. <el-form ref="form" :model="form" label-width="100px" size="mini">
  128. <el-row>
  129. <el-col :span="12">
  130. <el-form-item label="日志序号:">{{ form.jobLogId }}</el-form-item>
  131. <el-form-item label="任务名称:">{{ form.jobName }}</el-form-item>
  132. </el-col>
  133. <el-col :span="12">
  134. <el-form-item label="任务分组:">{{ form.jobGroup }}</el-form-item>
  135. <el-form-item label="执行时间:">{{ form.createTime }}</el-form-item>
  136. </el-col>
  137. <el-col :span="24">
  138. <el-form-item label="调用方法:">{{ form.invokeTarget }}</el-form-item>
  139. </el-col>
  140. <el-col :span="24">
  141. <el-form-item label="日志信息:">{{ form.jobMessage }}</el-form-item>
  142. </el-col>
  143. <el-col :span="24">
  144. <el-form-item label="执行状态:">
  145. <div v-if="form.status == 0">正常</div>
  146. <div v-else-if="form.status == 1">失败</div>
  147. </el-form-item>
  148. </el-col>
  149. <el-col :span="24">
  150. <el-form-item label="异常信息:" v-if="form.status == 1">{{ form.exceptionInfo }}</el-form-item>
  151. </el-col>
  152. </el-row>
  153. </el-form>
  154. <div slot="footer" class="dialog-footer">
  155. <el-button @click="open = false">关 闭</el-button>
  156. </div>
  157. </el-dialog>
  158. </div>
  159. </template>
  160. <script>
  161. import { listJobLog, delJobLog, exportJobLog, cleanJobLog } from "@/api/monitor/jobLog";
  162. export default {
  163. name: "JobLog",
  164. data() {
  165. return {
  166. // 遮罩层
  167. loading: true,
  168. // 选中数组
  169. ids: [],
  170. // 非多个禁用
  171. multiple: true,
  172. // 总条数
  173. total: 0,
  174. // 调度日志表格数据
  175. jobLogList: [],
  176. // 是否显示弹出层
  177. open: false,
  178. // 日期范围
  179. dateRange: [],
  180. // 表单参数
  181. form: {},
  182. // 执行状态字典
  183. statusOptions: [],
  184. // 任务组名字典
  185. jobGroupOptions: [],
  186. // 查询参数
  187. queryParams: {
  188. pageNum: 1,
  189. pageSize: 10,
  190. jobName: undefined,
  191. jobGroup: undefined,
  192. status: undefined
  193. }
  194. };
  195. },
  196. created() {
  197. this.getList();
  198. this.getDicts("sys_job_status").then(response => {
  199. this.statusOptions = response.data;
  200. });
  201. this.getDicts("sys_job_group").then(response => {
  202. this.jobGroupOptions = response.data;
  203. });
  204. },
  205. methods: {
  206. /** 查询调度日志列表 */
  207. getList() {
  208. this.loading = true;
  209. listJobLog(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
  210. this.jobLogList = response.rows;
  211. this.total = response.total;
  212. this.loading = false;
  213. }
  214. );
  215. },
  216. // 执行状态字典翻译
  217. statusFormat(row, column) {
  218. return this.selectDictLabel(this.statusOptions, row.status);
  219. },
  220. // 任务组名字典翻译
  221. jobGroupFormat(row, column) {
  222. return this.selectDictLabel(this.jobGroupOptions, row.jobGroup);
  223. },
  224. /** 搜索按钮操作 */
  225. handleQuery() {
  226. this.queryParams.pageNum = 1;
  227. this.getList();
  228. },
  229. /** 重置按钮操作 */
  230. resetQuery() {
  231. this.dateRange = [];
  232. this.resetForm("queryForm");
  233. this.handleQuery();
  234. },
  235. // 多选框选中数据
  236. handleSelectionChange(selection) {
  237. this.ids = selection.map(item => item.jobLogId);
  238. this.multiple = !selection.length;
  239. },
  240. /** 详细按钮操作 */
  241. handleView(row) {
  242. this.open = true;
  243. this.form = row;
  244. },
  245. /** 删除按钮操作 */
  246. handleDelete(row) {
  247. const jobLogIds = this.ids;
  248. this.$confirm('是否确认删除调度日志编号为"' + jobLogIds + '"的数据项?', "警告", {
  249. confirmButtonText: "确定",
  250. cancelButtonText: "取消",
  251. type: "warning"
  252. }).then(function() {
  253. return delJobLog(jobLogIds);
  254. }).then(() => {
  255. this.getList();
  256. this.msgSuccess("删除成功");
  257. }).catch(function() {});
  258. },
  259. /** 清空按钮操作 */
  260. handleClean() {
  261. this.$confirm("是否确认清空所有调度日志数据项?", "警告", {
  262. confirmButtonText: "确定",
  263. cancelButtonText: "取消",
  264. type: "warning"
  265. }).then(function() {
  266. return cleanJobLog();
  267. }).then(() => {
  268. this.getList();
  269. this.msgSuccess("清空成功");
  270. }).catch(function() {});
  271. },
  272. /** 导出按钮操作 */
  273. handleExport() {
  274. const queryParams = this.queryParams;
  275. this.$confirm("是否确认导出所有调度日志数据项?", "警告", {
  276. confirmButtonText: "确定",
  277. cancelButtonText: "取消",
  278. type: "warning"
  279. }).then(function() {
  280. return exportJobLog(queryParams);
  281. }).then(response => {
  282. this.download(response.msg);
  283. }).catch(function() {});
  284. }
  285. }
  286. };
  287. </script>