index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <template>
  2. <div class="app-container">
  3. <!-- 查询和其他操作 -->
  4. <div class="filter-container">
  5. <el-button
  6. size="mini" class="filter-item" type="primary" icon="el-icon-search"
  7. style="margin-left:10px;"
  8. @click="handleSearch"
  9. >
  10. 查找
  11. </el-button>
  12. <br />
  13. <el-button
  14. size="mini" type="primary" icon="el-icon-plus"
  15. @click="$refs.EditModal && $refs.EditModal.handleOpen({ signConfigId: '' })"
  16. >
  17. 添加
  18. </el-button>
  19. </div>
  20. <!-- 查询结果 -->
  21. <div v-tableHeight>
  22. <el-table
  23. v-loading="listLoading" height="100%" element-loading-text="正在查询中。。。" :data="list"
  24. v-bind="{ stripe: true, size: 'small', border: true, fit: true, highlightCurrentRow: true }"
  25. >
  26. <el-table-column align="center" width="100" label="ID" prop="signConfigId" fixed="left" />
  27. <el-table-column align="center" width="150" label="每日签到金额" prop="signPrice" fixed="left" show-overflow-tooltip />
  28. <el-table-column align="center" width="150" label="连续签到天数设置" prop="signDay" show-overflow-tooltip />
  29. <el-table-column align="center" width="150" label="创建时间" prop="createTime" />
  30. <el-table-column align="center" label="操作" width="300" fixed="right" class-name="small-padding fixed-width">
  31. <template slot-scope="{ row }">
  32. <el-button size="mini" @click="handleDetail(row)">
  33. 查看
  34. </el-button>
  35. <el-button size="mini" @click="handleEdit(row)">
  36. 编辑
  37. </el-button>
  38. <el-button type="danger" size="mini" @click="handleDelete(row)">
  39. 删除
  40. </el-button>
  41. </template>
  42. </el-table-column>
  43. </el-table>
  44. </div>
  45. <div>
  46. <el-pagination
  47. :current-page="listQuery.page" :page-sizes="[10, 20, 50, 100]" :page-size="listQuery.pageSize"
  48. layout="total, sizes, prev, pager, next, jumper" :total="total"
  49. @size-change="(val) => ((listQuery.pageSize = val) && getList())"
  50. @current-change="(val) => ((listQuery.page = val) && getList())"
  51. />
  52. </div>
  53. <!-- 新增编辑 -->
  54. <EditModal ref="EditModal" @success="getList" />
  55. <!-- 查看详情 -->
  56. <DetailModal ref="DetailModal" />
  57. </div>
  58. </template>
  59. <script>
  60. import EditModal from './components/EditModal'
  61. import DetailModal from './components/DetailModal'
  62. import { getAllVoucherSignConfig, deleteByIdVoucherSignConfig } from '@/api/signInManagement/voucherSignIn'
  63. export default {
  64. name: 'VoucherSignIn',
  65. components: {
  66. EditModal,
  67. DetailModal
  68. },
  69. data() {
  70. return {
  71. list: [],
  72. total: 0,
  73. listLoading: true,
  74. listQuery: {
  75. page: 1,
  76. pageSize: 20
  77. }
  78. }
  79. },
  80. created() {
  81. this.getList()
  82. },
  83. methods: {
  84. async getList() {
  85. this.listLoading = true
  86. try {
  87. const res = await getAllVoucherSignConfig(this.listQuery)
  88. this.list = res.data.items
  89. this.total = res.data.total
  90. } finally {
  91. this.listLoading = false
  92. }
  93. },
  94. handleSearch() {
  95. this.listQuery.page = 1
  96. this.getList()
  97. },
  98. handleDetail(row) {
  99. this.$refs.DetailModal && this.$refs.DetailModal.handleOpen(row)
  100. },
  101. handleEdit(row) {
  102. this.$refs.EditModal && this.$refs.EditModal.handleOpen(row)
  103. },
  104. handleDelete(row) {
  105. this.$confirm('确定删除此项?')
  106. .then(async () => {
  107. await deleteByIdVoucherSignConfig({ id: row.signConfigId })
  108. this.$message({ message: '删除成功!', type: 'success' })
  109. this.handleSearch()
  110. })
  111. .catch(() => {})
  112. }
  113. }
  114. }
  115. </script>
  116. <style lang="less" scoped>
  117. .app-container {
  118. padding: 20px;
  119. display: flex;
  120. flex-direction: column;
  121. .filter-container {
  122. .filter-item {
  123. display: inline-block;
  124. vertical-align: middle;
  125. margin-bottom: 10px;
  126. }
  127. }
  128. .small-padding {
  129. .cell {
  130. padding-left: 5px;
  131. padding-right: 5px;
  132. }
  133. }
  134. .fixed-width {
  135. .el-button--mini {
  136. padding: 7px 10px;
  137. }
  138. }
  139. }
  140. </style>