index.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <template>
  2. <div class="app-container">
  3. <el-button type="primary" size="mini" icon="el-icon-plus" style="margin-bottom: 10px;" @click="onAdd">新增模板</el-button>
  4. <el-table
  5. :data="tableData"
  6. border
  7. highlight-current-row
  8. >
  9. <el-table-column
  10. prop="groupName"
  11. label="组名称"
  12. width="200"
  13. />
  14. <el-table-column
  15. prop="name"
  16. label="模板名称"
  17. width="200"
  18. />
  19. <el-table-column
  20. prop="fileName"
  21. label="文件名称"
  22. />
  23. <el-table-column
  24. label="操作"
  25. width="150"
  26. >
  27. <template slot-scope="scope">
  28. <el-button type="text" size="mini" @click="onTableUpdate(scope.row)">修改</el-button>
  29. <el-button type="text" size="mini" @click="onTableDelete(scope.row)">删除</el-button>
  30. </template>
  31. </el-table-column>
  32. </el-table>
  33. </div>
  34. </template>
  35. <script>
  36. export default {
  37. data() {
  38. return {
  39. tableData: []
  40. }
  41. },
  42. created() {
  43. this.loadTable()
  44. },
  45. methods: {
  46. loadTable: function() {
  47. this.groupId = this.$route.query.groupId;
  48. if (typeof this.groupId === 'undefined') {
  49. this.groupId = '';
  50. }
  51. this.post(`/template/list?groupId=${this.groupId}`, {}, function(resp) {
  52. this.tableData = resp.data
  53. })
  54. },
  55. onTableUpdate: function(row) {
  56. this.goRoute(`edit/${row.id}`)
  57. },
  58. onTableDelete: function(row) {
  59. this.confirm(`确认要删除【${row.name}】吗?`, function(done) {
  60. this.post('/template/del', row, function() {
  61. done()
  62. this.tip('删除成功')
  63. this.loadTable()
  64. })
  65. })
  66. },
  67. onAdd: function() {
  68. this.goRoute('edit/0')
  69. }
  70. }
  71. }
  72. </script>