joblog.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. <template>
  2. <basic-container>
  3. <avue-crud :option="option"
  4. :table-loading="loading"
  5. :data="data"
  6. :page.sync="page"
  7. :permission="permissionList"
  8. :before-open="beforeOpen"
  9. v-model="form"
  10. v-model:search="search"
  11. ref="crud"
  12. @row-update="rowUpdate"
  13. @row-save="rowSave"
  14. @row-del="rowDel"
  15. @search-change="searchChange"
  16. @search-reset="searchReset"
  17. @selection-change="selectionChange"
  18. @current-change="currentChange"
  19. @size-change="sizeChange"
  20. @refresh-change="refreshChange"
  21. @on-load="onLoad">
  22. <template slot="menuLeft">
  23. <el-button type="danger"
  24. size="small"
  25. icon="el-icon-delete"
  26. plain
  27. @click="handleDelete">删 除
  28. </el-button>
  29. <el-button
  30. type="danger"
  31. plain
  32. icon="el-icon-delete"
  33. size="small"
  34. @click="handleClean"
  35. >清空</el-button>
  36. </template>
  37. </avue-crud>
  38. </basic-container>
  39. </template>
  40. <script>
  41. import {getList, getDetail, add, update, remove, cleanJobLog} from "@/api/quartz/joblog";
  42. import {mapGetters} from "vuex";
  43. export default {
  44. data() {
  45. return {
  46. search: {
  47. jobName: "sss",
  48. jobGroup: ""
  49. },
  50. form: {},
  51. query: {},
  52. loading: true,
  53. page: {
  54. pageSize: 10,
  55. currentPage: 1,
  56. total: 0
  57. },
  58. selectionList: [],
  59. option: {
  60. height:'auto',
  61. calcHeight: 30,
  62. tip: false,
  63. searchShow: true,
  64. searchMenuSpan: 6,
  65. border: true,
  66. index: true,
  67. viewBtn: true,
  68. selection: true,
  69. dialogClickModal: false,
  70. column: [
  71. {
  72. label: "任务名称",
  73. prop: "jobName",
  74. search: true,
  75. rules: [{
  76. required: true,
  77. message: "请输入任务名称",
  78. trigger: "blur"
  79. }]
  80. },
  81. {
  82. label: "任务组名",
  83. prop: "jobGroup",
  84. type: "select",
  85. search: true,
  86. dicUrl: "/api/blade-system/dict-biz/dictionary?code=task_group_name",
  87. props: {
  88. label: "dictValue",
  89. value: "dictKey"
  90. },
  91. },
  92. {
  93. label: "调用方法",
  94. prop: "invokeTarget",
  95. rules: [{
  96. required: true,
  97. message: "请输入调用目标字符串",
  98. trigger: "blur"
  99. }]
  100. },
  101. {
  102. label: "日志信息",
  103. prop: "jobMessage",
  104. rules: [{
  105. required: true,
  106. message: "请输入日志信息",
  107. trigger: "blur"
  108. }]
  109. },
  110. {
  111. label: "执行状态",
  112. prop: "status",
  113. type: "select",
  114. search: true,
  115. dicUrl: "/api/blade-system/dict-biz/dictionary?code=task_process_state",
  116. props: {
  117. label: "dictValue",
  118. value: "dictKey"
  119. },
  120. dataType: "number",
  121. },
  122. {
  123. label: "执行时间",
  124. prop: "createTime",
  125. },
  126. {
  127. label: "异常信息",
  128. prop: "exceptionInfo",
  129. type: "textarea",
  130. hide: true,
  131. span: 24
  132. },
  133. ]
  134. },
  135. data: []
  136. };
  137. },
  138. computed: {
  139. ...mapGetters(["permission"]),
  140. permissionList() {
  141. return {
  142. addBtn: this.vaildData(this.permission.joblog_add, false),
  143. viewBtn: this.vaildData(this.permission.joblog_view, false),
  144. delBtn: this.vaildData(this.permission.joblog_delete, false),
  145. editBtn: this.vaildData(this.permission.joblog_edit, false)
  146. };
  147. },
  148. ids() {
  149. let ids = [];
  150. this.selectionList.forEach(ele => {
  151. ids.push(ele.id);
  152. });
  153. return ids.join(",");
  154. }
  155. },
  156. created() {
  157. const queryParam = this.$route.query;
  158. console.log("queryParam -> ", queryParam);
  159. const jobId = queryParam.jobId;
  160. if (jobId !== undefined && jobId != 0) {
  161. this.search.jobName = queryParam.jobName;
  162. this.search.jobGroup = queryParam.jobGroup;
  163. }
  164. },
  165. methods: {
  166. rowSave(row, done, loading) {
  167. add(row).then(() => {
  168. this.onLoad(this.page);
  169. this.$message({
  170. type: "success",
  171. message: "操作成功!"
  172. });
  173. done();
  174. }, error => {
  175. loading();
  176. window.console.log(error);
  177. });
  178. },
  179. rowUpdate(row, index, done, loading) {
  180. update(row).then(() => {
  181. this.onLoad(this.page);
  182. this.$message({
  183. type: "success",
  184. message: "操作成功!"
  185. });
  186. done();
  187. }, error => {
  188. loading();
  189. console.log(error);
  190. });
  191. },
  192. rowDel(row) {
  193. this.$confirm("确定将选择数据删除?", {
  194. confirmButtonText: "确定",
  195. cancelButtonText: "取消",
  196. type: "warning"
  197. })
  198. .then(() => {
  199. return remove(row.id);
  200. })
  201. .then(() => {
  202. this.onLoad(this.page);
  203. this.$message({
  204. type: "success",
  205. message: "操作成功!"
  206. });
  207. });
  208. },
  209. handleDelete() {
  210. if (this.selectionList.length === 0) {
  211. this.$message.warning("请选择至少一条数据");
  212. return;
  213. }
  214. this.$confirm("确定将选择数据删除?", {
  215. confirmButtonText: "确定",
  216. cancelButtonText: "取消",
  217. type: "warning"
  218. })
  219. .then(() => {
  220. return remove(this.ids);
  221. })
  222. .then(() => {
  223. this.onLoad(this.page);
  224. this.$message({
  225. type: "success",
  226. message: "操作成功!"
  227. });
  228. this.$refs.crud.toggleSelection();
  229. });
  230. },
  231. beforeOpen(done, type) {
  232. if (["edit", "view"].includes(type)) {
  233. getDetail(this.form.id).then(res => {
  234. this.form = res.data.data;
  235. });
  236. }
  237. done();
  238. },
  239. searchReset() {
  240. this.query = {};
  241. this.onLoad(this.page);
  242. },
  243. searchChange(params, done) {
  244. this.query = params;
  245. this.page.currentPage = 1;
  246. this.onLoad(this.page, params);
  247. done();
  248. },
  249. selectionChange(list) {
  250. this.selectionList = list;
  251. },
  252. selectionClear() {
  253. this.selectionList = [];
  254. this.$refs.crud.toggleSelection();
  255. },
  256. currentChange(currentPage){
  257. this.page.currentPage = currentPage;
  258. },
  259. sizeChange(pageSize){
  260. this.page.pageSize = pageSize;
  261. },
  262. refreshChange() {
  263. this.onLoad(this.page, this.query);
  264. },
  265. onLoad(page, params = {}) {
  266. this.loading = true;
  267. console.log("query -> ", this.query);
  268. getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
  269. const data = res.data.data;
  270. this.page.total = data.total;
  271. this.data = data.records;
  272. this.loading = false;
  273. this.selectionClear();
  274. });
  275. },
  276. /** 清空按钮操作 */
  277. handleClean() {
  278. this.$confirm('是否确认清空所有调度日志数据项?').then(function() {
  279. return cleanJobLog();
  280. }).then(() => {
  281. this.onLoad(this.page, this.query);
  282. this.$message({
  283. type: "success",
  284. message: "清空成功!"
  285. });
  286. }).catch(() => {});
  287. },
  288. }
  289. };
  290. </script>
  291. <style>
  292. </style>