index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <div class="app-container">
  3. <div class="mymain-container">
  4. <div class="btn-group clearfix">
  5. <div class="fl">
  6. <el-button type="primary" icon="el-icon-plus" size="small" @click="addOrEdit('add')">添加模块</el-button>
  7. <el-button type="primary" size="small" @click="editCommonModule">编辑公共模块</el-button>
  8. </div>
  9. </div>
  10. <div class="table">
  11. <el-table v-loading="listLoading" :data="dataList" element-loading-text="Loading" border fit highlight-current-row stripe>
  12. <el-table-column align="center" label="模块名称" prop="name"></el-table-column>
  13. <el-table-column align="center" label="创建时间" prop="createTime"></el-table-column>
  14. <el-table-column align="center" label="修改时间" prop="updateTime"></el-table-column>
  15. <el-table-column align="center" label="商户" prop="companyName"></el-table-column>
  16. <el-table-column align="center" label="操作" width="140">
  17. <template slot-scope="scope">
  18. <el-button type="primary" size="mini" @click="addOrEdit('edit', scope.row.commonTemplateId)">编辑</el-button>
  19. <el-popconfirm style="margin-left: 10px;" title="确定删除吗?" @onConfirm="delItem(scope.row.commonTemplateId)" >
  20. <el-button slot="reference" size="mini">删除</el-button>
  21. </el-popconfirm>
  22. </template>
  23. </el-table-column>
  24. </el-table>
  25. </div>
  26. <div class="pagination clearfix">
  27. <div class="fr">
  28. <el-pagination
  29. @size-change="handleSizeChange"
  30. @current-change="handleCurrentChange"
  31. :current-page="currentPage"
  32. :page-sizes="[10, 20, 30, 50]"
  33. :page-size="10"
  34. layout="total, sizes, prev, pager, next, jumper"
  35. :total="listTotal">
  36. </el-pagination>
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. </template>
  42. <script>
  43. import { getModuleList, deleteModule } from '@/api/goods'
  44. export default {
  45. data() {
  46. return {
  47. dataList: null, // 列表数据
  48. listLoading: true, // 列表加载loading
  49. currentPage: 1, // 当前页码
  50. pageSize: 10, // 每页数量
  51. listTotal: 0, // 列表总数
  52. }
  53. },
  54. created() {
  55. this.getList();
  56. },
  57. methods: {
  58. getList() {
  59. this.listLoading = true;
  60. let params = {
  61. pageNum: this.currentPage,
  62. pageSize: this.pageSize
  63. };
  64. getModuleList(params).then(res => {
  65. this.dataList = res.data.records;
  66. this.listTotal = res.data.total;
  67. this.listLoading = false;
  68. })
  69. },
  70. // 编辑公共模块
  71. editCommonModule() {
  72. this.$router.push({
  73. name:"explain_common",
  74. query: {}
  75. })
  76. },
  77. // 添加模块
  78. addOrEdit(type, id) {
  79. if(type == 'add') {
  80. this.$router.push({
  81. name:"explain_add",
  82. query: {}
  83. })
  84. }else {
  85. this.$router.push({
  86. name:"explain_add",
  87. query: {
  88. id
  89. }
  90. })
  91. }
  92. },
  93. // 删除模块
  94. delItem(commonTemplateId) {
  95. deleteModule({
  96. commonTemplateId
  97. }).then(res => {
  98. this.getList();
  99. this.$successMsg();
  100. })
  101. },
  102. // 更改每页数量
  103. handleSizeChange(val) {
  104. this.pageSize = val;
  105. this.currentPage = 1;
  106. this.getList();
  107. },
  108. // 更改当前页
  109. handleCurrentChange(val) {
  110. this.currentPage = val;
  111. this.getList();
  112. },
  113. }
  114. }
  115. </script>
  116. <style scoped>
  117. </style>