index.vue.vm 2.5 KB

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