index.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <template>
  2. <div class="table-page">
  3. <GiTable
  4. row-key="id"
  5. title="奖励列表"
  6. :data="dataList"
  7. :columns="columns"
  8. :loading="loading"
  9. :scroll="{ x: '100%', y: '100%', minWidth: 1200 }"
  10. :pagination="pagination"
  11. :disabled-tools="['size']"
  12. :disabled-column-keys="['title']"
  13. @refresh="search"
  14. >
  15. <template #toolbar-left>
  16. <a-input-search v-model="queryForm.rewardsName" placeholder="名称" allow-clear @search="search" />
  17. <a-input-search v-model="queryForm.rewardsDescribe" placeholder="奖励说明" allow-clear @search="search" />
  18. <a-input-search v-model="queryForm.inviteNum" placeholder="邀请好友数量" allow-clear @search="search" />
  19. <a-input-search v-model="queryForm.goldCoinNum" placeholder="金币数量" allow-clear @search="search" />
  20. <a-button @click="reset">
  21. <template #icon><icon-refresh /></template>
  22. <template #default>重置</template>
  23. </a-button>
  24. </template>
  25. <template #toolbar-right>
  26. <a-button type="primary" @click="onAdd">
  27. <template #icon><icon-plus /></template>
  28. <template #default>新增</template>
  29. </a-button>
  30. </template>
  31. <template #action="{ record }">
  32. <a-space>
  33. <a-link title="修改" @click="onUpdate(record)">修改</a-link>
  34. <a-link status="danger" title="删除" @click="onDelete(record)"> 删除 </a-link>
  35. </a-space>
  36. </template>
  37. </GiTable>
  38. <JiangliAddModal ref="JiangliAddModalRef" @save-success="search"></JiangliAddModal>
  39. </div>
  40. </template>
  41. <script setup lang="ts">
  42. import JiangliAddModal from './jiangliAddModal.vue'
  43. import type { TableInstanceColumns } from '@/components/GiTable/type'
  44. import { useTable } from '@/hooks'
  45. import { isMobile } from '@/utils'
  46. import type { JiangliListResp, JiangliQuery } from '@/apis/user/type'
  47. import { jiangliDel, listJiangli } from '@/apis/user/userlist'
  48. defineOptions({ name: 'Jliangli' })
  49. const queryForm = reactive<JiangliQuery>({} as JiangliQuery)
  50. const {
  51. tableData: dataList,
  52. loading,
  53. pagination,
  54. search,
  55. handleDelete,
  56. } = useTable((page) => listJiangli({ ...queryForm, ...page }), { immediate: true })
  57. const columns: TableInstanceColumns[] = [
  58. {
  59. title: '序号',
  60. width: 66,
  61. align: 'center',
  62. render: ({ rowIndex }) => h('span', {}, rowIndex + 1 + (pagination.current - 1) * pagination.pageSize),
  63. },
  64. { title: '名称', dataIndex: 'rewardsName', slotName: 'rewardsName', align: 'center', width: 180 },
  65. { title: '奖励说明', dataIndex: 'rewardsDescribe', slotName: 'rewardsDescribe', align: 'center', width: 180 },
  66. { title: '邀请好友数量', dataIndex: 'inviteNum', slotName: 'inviteNum', align: 'center', width: 180 },
  67. { title: '金币数量', dataIndex: 'goldCoinNum', slotName: 'goldCoinNum', align: 'center', width: 180 },
  68. {
  69. title: '操作',
  70. dataIndex: 'action',
  71. slotName: 'action',
  72. width: 350,
  73. align: 'center',
  74. fixed: !isMobile() ? 'right' : undefined,
  75. show: true,
  76. },
  77. ]
  78. // 重置
  79. const reset = () => {
  80. queryForm.rewardsName = undefined
  81. queryForm.rewardsDescribe = undefined
  82. queryForm.inviteNum = undefined
  83. queryForm.goldCoinNum = undefined
  84. search()
  85. }
  86. // 新增
  87. const JiangliAddModalRef = ref<InstanceType<typeof JiangliAddModal>>()
  88. const onAdd = () => {
  89. JiangliAddModalRef.value?.onAdd()
  90. }
  91. const onUpdate = (record: JiangliListResp) => {
  92. JiangliAddModalRef.value?.onUpdate(record.id)
  93. }
  94. const onDelete = (record: JiangliListResp) => {
  95. return handleDelete(() => jiangliDel(record.id), {
  96. content: `是否确定删除奖励「${record.rewardsName}」?`,
  97. showModal: true,
  98. })
  99. }
  100. </script>
  101. <style scoped lang="scss"></style>