index.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <!--
  2. - Copyright (c) 2018-2025, lengleng All rights reserved.
  3. -
  4. - Redistribution and use in source and binary forms, with or without
  5. - modification, are permitted provided that the following conditions are met:
  6. -
  7. - Redistributions of source code must retain the above copyright notice,
  8. - this list of conditions and the following disclaimer.
  9. - Redistributions in binary form must reproduce the above copyright
  10. - notice, this list of conditions and the following disclaimer in the
  11. - documentation and/or other materials provided with the distribution.
  12. - Neither the name of the pig4cloud.com developer nor the names of its
  13. - contributors may be used to endorse or promote products derived from
  14. - this software without specific prior written permission.
  15. - Author: lengleng (wangiegie@gmail.com)
  16. -->
  17. <template>
  18. <div class="execution">
  19. <basic-container>
  20. <avue-crud ref="crud"
  21. :page="page"
  22. :data="tableData"
  23. :table-loading="tableLoading"
  24. :option="tableOption"
  25. @on-load="getList"
  26. @refresh-change="refreshChange"
  27. @row-update="handleUpdate"
  28. @row-save="handleSave"
  29. @row-del="rowDel">
  30. <template slot-scope="scope"
  31. slot="menu">
  32. <el-button type="text"
  33. v-if="permissions.daemon_execution_log_del"
  34. icon="el-icon-delete"
  35. size="small"
  36. plain
  37. @click="handleDel(scope.row,scope.index)">删除</el-button>
  38. </template>
  39. </avue-crud>
  40. </basic-container>
  41. </div>
  42. </template>
  43. <script>
  44. import { fetchList, getObj, addObj, putObj, delObj } from '@/api/daemon/execution-log'
  45. import { tableOption } from '@/const/crud/daemon/execution-log'
  46. import { mapGetters } from 'vuex'
  47. export default {
  48. name: 'execution-log',
  49. data() {
  50. return {
  51. tableData: [],
  52. page: {
  53. total: 0, // 总页数
  54. currentPage: 1, // 当前页数
  55. pageSize: 20 // 每页显示多少条
  56. },
  57. tableLoading: false,
  58. tableOption: tableOption
  59. }
  60. },
  61. created() {
  62. this.page.pageSize=20;
  63. },
  64. mounted: function() { },
  65. computed: {
  66. ...mapGetters(['permissions'])
  67. },
  68. methods: {
  69. getList(page, params={}) {
  70. this.tableLoading = true
  71. fetchList(Object.assign({
  72. current: page.currentPage,
  73. size: page.pageSize,
  74. descs: 'start_time'
  75. }, params)).then(response => {
  76. this.tableData = response.data.data.records
  77. this.page.total = response.data.data.total
  78. this.tableLoading = false
  79. })
  80. },
  81. /**
  82. * @title 打开新增窗口
  83. * @detail 调用crud的handleadd方法即可
  84. *
  85. **/
  86. handleAdd: function() {
  87. this.$refs.crud.rowAdd()
  88. },
  89. handleEdit(row, index) {
  90. this.$refs.crud.rowEdit(row, index)
  91. },
  92. handleDel(row, index) {
  93. this.$refs.crud.rowDel(row, index)
  94. },
  95. rowDel: function(row, index) {
  96. var _this = this
  97. this.$confirm('是否确认删除ID为' + row.id, '提示', {
  98. confirmButtonText: '确定',
  99. cancelButtonText: '取消',
  100. type: 'warning'
  101. })
  102. .then(function() {
  103. return delObj(row.id)
  104. })
  105. .then(data => {
  106. _this.tableData.splice(index, 1)
  107. _this.$message({
  108. showClose: true,
  109. message: '删除成功',
  110. type: 'success'
  111. })
  112. this.getList(this.page)
  113. })
  114. .catch(function(err) { })
  115. },
  116. /**
  117. * @title 数据更新
  118. * @param row 为当前的数据
  119. * @param index 为当前更新数据的行数
  120. * @param done 为表单关闭函数
  121. *
  122. **/
  123. handleUpdate: function(row, index, done) {
  124. putObj(row).then(data => {
  125. this.tableData.splice(index, 1, Object.assign({}, row))
  126. this.$message({
  127. showClose: true,
  128. message: '修改成功',
  129. type: 'success'
  130. })
  131. done()
  132. this.getList(this.page)
  133. })
  134. },
  135. /**
  136. * @title 数据添加
  137. * @param row 为当前的数据
  138. * @param done 为表单关闭函数
  139. *
  140. **/
  141. handleSave: function(row, done) {
  142. addObj(row).then(data => {
  143. this.tableData.push(Object.assign({}, row))
  144. this.$message({
  145. showClose: true,
  146. message: '添加成功',
  147. type: 'success'
  148. })
  149. done()
  150. this.getList(this.page)
  151. })
  152. },
  153. /**
  154. * 刷新回调
  155. */
  156. refreshChange() {
  157. this.getList(this.page)
  158. }
  159. }
  160. }
  161. </script>
  162. <style lang="scss" scoped>
  163. </style>