list.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <script lang="ts" setup>
  2. import type {
  3. OnActionClickParams,
  4. VxeTableGridOptions,
  5. } from '#/adapter/vxe-table';
  6. import type { PatientEvaluationModel } from '#/api';
  7. import { Page, useVbenModal } from '@vben/common-ui';
  8. import { Button, message } from 'ant-design-vue';
  9. import { useVbenVxeGrid } from '#/adapter/vxe-table';
  10. import {
  11. exportEfficacyEvaluationsMethod,
  12. listEfficacyEvaluationsMethod,
  13. } from '#/api';
  14. import {
  15. useEfficacySearchFormSchema,
  16. useEfficacyTableColumns,
  17. } from './data';
  18. import Detail from './modules/detail.vue';
  19. const [DetailModal, detailModalApi] = useVbenModal({
  20. connectedComponent: Detail,
  21. destroyOnClose: true,
  22. });
  23. const [Grid, gridApi] = useVbenVxeGrid({
  24. formOptions: {
  25. schema: useEfficacySearchFormSchema(),
  26. submitOnChange: false,
  27. wrapperClass: 'efficacy-search-form',
  28. },
  29. gridOptions: {
  30. columns: useEfficacyTableColumns(onActionClick),
  31. height: 'auto',
  32. keepSource: true,
  33. pagerConfig: {
  34. pageSize: 5,
  35. layouts: ['PrevPage', 'Jump', 'NextPage'],
  36. },
  37. proxyConfig: {
  38. ajax: {
  39. query({ page }, formValues) {
  40. return listEfficacyEvaluationsMethod(
  41. page.currentPage,
  42. page.pageSize,
  43. formValues,
  44. );
  45. },
  46. },
  47. },
  48. rowConfig: {
  49. keyField: 'id',
  50. },
  51. stripe: true,
  52. } as VxeTableGridOptions<PatientEvaluationModel.EfficacyEvaluation>,
  53. });
  54. function onActionClick(
  55. e: OnActionClickParams<PatientEvaluationModel.EfficacyEvaluation>,
  56. ) {
  57. switch (e.code) {
  58. case 'view': {
  59. onViewHandle(e.row);
  60. break;
  61. }
  62. }
  63. }
  64. function onViewHandle(row: PatientEvaluationModel.EfficacyEvaluation) {
  65. detailModalApi.setData(row).open();
  66. }
  67. async function onExport() {
  68. const formValues = await gridApi.formApi.getValues();
  69. try {
  70. await exportEfficacyEvaluationsMethod(formValues);
  71. message.success('导出成功');
  72. } catch (error: any) {
  73. message.error(error.message || '导出失败');
  74. }
  75. }
  76. </script>
  77. <template>
  78. <Page auto-content-height class="efficacy-page">
  79. <DetailModal />
  80. <Grid>
  81. <template #toolbar-tools>
  82. <Button type="link" @click="onExport">导出</Button>
  83. </template>
  84. </Grid>
  85. </Page>
  86. </template>
  87. <style scoped>
  88. .efficacy-page :deep(.efficacy-search-form) {
  89. margin-bottom: 0;
  90. }
  91. </style>