TableBox.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <template>
  2. <div>
  3. <div class="btn-box">
  4. <el-button type="primary" icon="el-icon-plus" @click="onCreate">新增</el-button>
  5. </div>
  6. <el-table
  7. v-loading="loading"
  8. :data="data"
  9. border
  10. style="width: 100%"
  11. >
  12. <el-table-column
  13. type="index"
  14. label="序号"
  15. width="100"
  16. align="center"
  17. />
  18. <el-table-column
  19. prop="app_name"
  20. label="应用名称"
  21. width="240"
  22. show-overflow-tooltip
  23. />
  24. <el-table-column
  25. prop="content"
  26. label="任务描述"
  27. show-overflow-tooltip
  28. />
  29. <el-table-column
  30. prop=""
  31. label="操作"
  32. width="160"
  33. >
  34. <template slot-scope="scope">
  35. <el-link :underline="false" type="primary" @click="onEdit(scope.row)">编辑</el-link>
  36. <el-divider direction="vertical" />
  37. <el-link :underline="false" type="danger" @click="onDel(scope.row)">删除</el-link>
  38. </template>
  39. </el-table-column>
  40. </el-table>
  41. </div>
  42. </template>
  43. <script>
  44. import { deleteHelper } from '@/api/helper'
  45. export default {
  46. props: {
  47. data: {
  48. type: Array,
  49. default() {
  50. return []
  51. }
  52. },
  53. loading: {
  54. type: Boolean,
  55. default() {
  56. return false
  57. }
  58. }
  59. },
  60. methods: {
  61. onCreate() {
  62. localStorage.removeItem('helper')
  63. this.$router.push({ path: '/helper/config' })
  64. },
  65. onEdit(row) {
  66. localStorage.setItem('helper', JSON.stringify(row))
  67. this.$router.push({ path: '/helper/config' })
  68. },
  69. onDel(row) {
  70. this.$confirm('是否确认删除该数据?', '提示', {
  71. confirmButtonText: '确定',
  72. cancelButtonText: '取消',
  73. type: 'warning'
  74. }).then(() => {
  75. deleteHelper({ id: row.id }).then((res) => {
  76. this.$message.success(res.m || '操作成功')
  77. this.$emit('refresh')
  78. })
  79. })
  80. },
  81. handleRefresh() {
  82. this.$emit('refresh')
  83. }
  84. }
  85. }
  86. </script>
  87. <style lang="scss" scoped>
  88. .btn-box {
  89. text-align: right;
  90. margin-bottom: 15px;
  91. }
  92. </style>