index.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. <AccumulatePointsApplyEdit ref="accumulatePointsApplyEditRefs"></AccumulatePointsApplyEdit>
  22. </div>
  23. </template>
  24. <script>
  25. import {
  26. getAccumulatePointList,
  27. deleteAccumulatePoint
  28. } from '@/api/accumulatePoint'
  29. import AccumulatePointsApplyEdit from './accumulatePointsApplyEdit.vue'
  30. export default {
  31. name: 'accumulatePointsEntering',
  32. components: {
  33. AccumulatePointsApplyEdit
  34. },
  35. data () {
  36. return {
  37. searchItems: [
  38. {
  39. label: '名称',
  40. prop: 'name',
  41. type: 'input',
  42. options: {
  43. placeholder: '请输入名称'
  44. }
  45. }
  46. ],
  47. searchValues: {
  48. name: null
  49. },
  50. headers: [
  51. { label: '名称', prop: 'name' },
  52. { label: '状态', prop: 'status' },
  53. { label: '操作', prop: 'actions', fixed: 'right', width: 300 }
  54. ],
  55. items: [],
  56. total: 0,
  57. pageInfo: {
  58. current: 1,
  59. size: 10
  60. },
  61. loading: false
  62. }
  63. },
  64. created () {
  65. this.onInit()
  66. },
  67. methods: {
  68. async onInit () {
  69. this.loading = true
  70. try {
  71. const { data } = await getAccumulatePointList({
  72. ...this.searchValues,
  73. ...this.pageInfo
  74. })
  75. this.items = data.records
  76. this.total = data.total
  77. } catch (error) {
  78. this.$message.error(error)
  79. } finally {
  80. this.loading = false
  81. }
  82. },
  83. onAdd () {
  84. this.$refs.accumulatePointsApplyEditRefs.open()
  85. },
  86. onEdit (item) {
  87. this.$refs.accumulatePointsApplyEditRefs.open(item)
  88. },
  89. onDelete (row) {
  90. this.$confirm('确定删除吗?', '提示')
  91. .then(async () => {
  92. try {
  93. await deleteAccumulatePoint({ id: row.id })
  94. this.$message.success('删除成功')
  95. this.onInit()
  96. } catch (error) {
  97. this.$message.error(error)
  98. }
  99. })
  100. .catch(_ => {})
  101. },
  102. onSearch () {
  103. this.pageInfo.current = 1
  104. this.onInit()
  105. },
  106. onPageChange (index) {
  107. this.pageInfo.current = index
  108. this.onInit()
  109. }
  110. }
  111. }
  112. </script>
  113. <style lang="scss" scoped>
  114. /* 自定义样式 */
  115. </style>