index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <script setup lang="ts">
  2. import { PageWrapper } from '/@/components/Page';
  3. import { useTable } from '/@/components/Table';
  4. import BasicTable from '/@/components/Table/src/BasicTable.vue';
  5. import { searchForm, tableColumns } from './components/data.config';
  6. import edit from './components/edit.vue';
  7. import { useModal } from '/@/components/Modal';
  8. import maintenance from './components/maintenance.vue';
  9. import copyPlan from './components/copyPlan.vue';
  10. import {
  11. deleteStudentEnrollmentPlan,
  12. getEnrollmentPlanPage,
  13. putStudentEnrollmentPlan,
  14. } from '/@/services/apis/EnrollmentPlanController';
  15. import TableAction from '/@/components/Table/src/components/TableAction.vue';
  16. import { useMessage } from '/@/hooks/web/useMessage';
  17. const [modelReg, { openModal }] = useModal();
  18. const [maintenanceReg, { openModal: openMaintenanceReg }] = useModal();
  19. const [copyPlanReg, { openModal: openCopyPlanModal }] = useModal();
  20. const [tableReg, { reload }] = useTable({
  21. title: '招生计划列表',
  22. columns: tableColumns,
  23. api: getEnrollmentPlanPage,
  24. rowKey: 'id',
  25. formConfig: {
  26. labelWidth: 120,
  27. schemas: searchForm,
  28. },
  29. useSearchForm: true,
  30. showTableSetting: true,
  31. bordered: true,
  32. immediate: true,
  33. canResize: true,
  34. actionColumn: {
  35. width: 120,
  36. title: '操作',
  37. dataIndex: 'action',
  38. slots: { customRender: 'action' },
  39. fixed: 'right',
  40. },
  41. });
  42. const { createMessage } = useMessage();
  43. const handleEdit = (record: any, isUpdate: boolean) => {
  44. openModal(true, {
  45. isUpdate: isUpdate,
  46. baseData: {
  47. ...record,
  48. },
  49. });
  50. };
  51. const handleMaintenance = (record) => {
  52. openMaintenanceReg(true, { ...record });
  53. };
  54. const handleCopy = () => {
  55. openCopyPlanModal(true, {});
  56. };
  57. const handleDelete = async (record: any) => {
  58. try {
  59. await deleteStudentEnrollmentPlan([record.id]);
  60. createMessage.success('删除成功');
  61. await reload();
  62. } catch (e) {
  63. createMessage.error('删除失败');
  64. }
  65. };
  66. const changeStatus = async (record: any) => {
  67. try {
  68. await putStudentEnrollmentPlan({
  69. id: record.id,
  70. status: record.status === 0 ? 1 : 0,
  71. });
  72. createMessage.success('发布成功');
  73. await reload();
  74. } catch (e) {
  75. createMessage.error('发布失败');
  76. }
  77. };
  78. </script>
  79. <template>
  80. <PageWrapper dense contentFullHeight fixedHeight contentClass="flex">
  81. <BasicTable @register="tableReg">
  82. <template #toolbar>
  83. <a-button type="primary" @click="handleEdit(null, false)">新增</a-button>
  84. </template>
  85. <template #action="{ record }">
  86. <TableAction
  87. :actions="[
  88. {
  89. label: '编辑',
  90. onClick: handleEdit.bind(null, record, true),
  91. },
  92. {
  93. label: '删除',
  94. color: 'error',
  95. onClick: handleDelete.bind(null, record),
  96. },
  97. ]"
  98. />
  99. </template>
  100. </BasicTable>
  101. <edit @register="modelReg" @success="reload()" />
  102. <maintenance @register="maintenanceReg" />
  103. <copyPlan @register="copyPlanReg" @success="reload" />
  104. </PageWrapper>
  105. </template>
  106. <style scoped lang="less"></style>