index.vue 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <!-- 搜索工作栏 -->
  3. <ContentWrap>
  4. <Search :schema="allSchemas.searchSchema" @reset="setSearchParams" @search="setSearchParams">
  5. <!-- 新增等操作按钮 -->
  6. <template #actionMore>
  7. <el-button
  8. v-hasPermi="['promotion:seckill-activity:create']"
  9. plain
  10. type="primary"
  11. @click="openForm('create')"
  12. >
  13. <Icon class="mr-5px" icon="ep:plus" />
  14. 新增
  15. </el-button>
  16. </template>
  17. </Search>
  18. </ContentWrap>
  19. <!-- 列表 -->
  20. <ContentWrap>
  21. <Table
  22. v-model:currentPage="tableObject.currentPage"
  23. v-model:pageSize="tableObject.pageSize"
  24. :columns="allSchemas.tableColumns"
  25. :data="tableObject.tableList"
  26. :loading="tableObject.loading"
  27. :pagination="{
  28. total: tableObject.total
  29. }"
  30. >
  31. <template #action="{ row }">
  32. <el-button
  33. v-hasPermi="['promotion:seckill-activity:update']"
  34. link
  35. type="primary"
  36. @click="openForm('update', row.id)"
  37. >
  38. 编辑
  39. </el-button>
  40. <el-button
  41. v-hasPermi="['promotion:seckill-activity:delete']"
  42. link
  43. type="danger"
  44. @click="handleDelete(row.id)"
  45. >
  46. 删除
  47. </el-button>
  48. </template>
  49. </Table>
  50. </ContentWrap>
  51. <!-- 表单弹窗:添加/修改 -->
  52. <SeckillActivityForm ref="formRef" @success="getList" />
  53. </template>
  54. <script lang="ts" name="PromotionSeckillActivity" setup>
  55. import { allSchemas } from './seckillActivity.data'
  56. import * as SeckillActivityApi from '@/api/mall/promotion/seckill/seckillActivity'
  57. import SeckillActivityForm from './SeckillActivityForm.vue'
  58. // tableObject:表格的属性对象,可获得分页大小、条数等属性
  59. // tableMethods:表格的操作对象,可进行获得分页、删除记录等操作
  60. // 详细可见:https://doc.iocoder.cn/vue3/crud-schema/
  61. const { tableObject, tableMethods } = useTable({
  62. getListApi: SeckillActivityApi.getSeckillActivityPage, // 分页接口
  63. delListApi: SeckillActivityApi.deleteSeckillActivity // 删除接口
  64. })
  65. // 获得表格的各种操作
  66. const { getList, setSearchParams } = tableMethods
  67. /** 添加/修改操作 */
  68. const formRef = ref()
  69. const openForm = (type: string, id?: number) => {
  70. formRef.value.open(type, id)
  71. }
  72. /** 删除按钮操作 */
  73. const handleDelete = (id: number) => {
  74. tableMethods.delList(id, false)
  75. }
  76. /** 初始化 **/
  77. onMounted(() => {
  78. getList()
  79. })
  80. </script>