index.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <template>
  2. <div class="pa-3 white">
  3. <m-search class="mb-3" :items="searchItems" v-model="searchValues" @search="onSearch"></m-search>
  4. <m-table
  5. v-loading="loading"
  6. :items="items"
  7. :headers="headers"
  8. :page-size="pageInfo.size"
  9. :page-current="pageInfo.current"
  10. :total="total"
  11. @page-change="onPageChange"
  12. >
  13. <template #card-tools>
  14. <m-button type="orange" icon="el-icon-plus" @click="onAdd">新增</m-button>
  15. </template>
  16. <template #actions="{ row }">
  17. <m-button type="primary" text @click="onEdit(row)">编辑</m-button>
  18. <m-button type="danger" text @click="onDelete(row)">删除</m-button>
  19. </template>
  20. </m-table>
  21. </div>
  22. </template>
  23. <script>
  24. import {
  25. // getAccumulatePointList,
  26. deleteAccumulatePoint
  27. } from '@/api/accumulatePoint'
  28. export default {
  29. name: 'AccumulatePointRules',
  30. data () {
  31. return {
  32. searchItems: [
  33. {
  34. label: '名称',
  35. prop: 'name',
  36. type: 'input',
  37. options: {
  38. placeholder: '请输入名称'
  39. }
  40. }
  41. ],
  42. searchValues: {
  43. name: null
  44. },
  45. headers: [
  46. { label: '名称', prop: 'name' },
  47. { label: '状态', prop: 'status' },
  48. { label: '操作', prop: 'actions', fixed: 'right', width: 300 }
  49. ],
  50. items: [],
  51. total: 0,
  52. pageInfo: {
  53. current: 1,
  54. size: 10
  55. },
  56. loading: false
  57. }
  58. },
  59. created () {
  60. this.onInit()
  61. },
  62. methods: {
  63. async onInit () {
  64. this.loading = true
  65. try {
  66. // const { data } = await getAccumulatePointList()
  67. // this.items = data.records
  68. // this.total = data.total
  69. } catch (error) {
  70. this.$message.error(error)
  71. } finally {
  72. this.loading = false
  73. }
  74. },
  75. onAdd () {
  76. this.$refs.accumulatePointRefs.open()
  77. },
  78. onEdit (item) {
  79. this.$refs.accumulatePointRefs.open(item)
  80. },
  81. onDelete (row) {
  82. this.$confirm('确定删除吗?', '提示')
  83. .then(async () => {
  84. try {
  85. await deleteAccumulatePoint({ id: row.id })
  86. this.$message.success('删除成功')
  87. this.onInit()
  88. } catch (error) {
  89. this.$message.error(error)
  90. }
  91. })
  92. .catch(_ => {})
  93. },
  94. onSearch () {
  95. this.pageInfo.current = 1
  96. this.onInit()
  97. },
  98. onPageChange (index) {
  99. this.pageInfo.current = index
  100. this.onInit()
  101. }
  102. }
  103. }
  104. </script>
  105. <style lang="scss" scoped>
  106. /* 自定义样式 */
  107. </style>