index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <script setup lang="ts">
  2. import { PageWrapper } from '/@/components/Page';
  3. import { useTable, BasicTable, TableAction } from '/@/components/Table';
  4. import { searchFormSchema, tableColumns } from './components/data.config';
  5. import FormEdit from './components/edit.vue';
  6. import ClassTree from './components/tree.vue';
  7. import FormImport from './components/import.vue';
  8. import FormDivision from './components/division.vue';
  9. import StudentImport from './components/import1.vue';
  10. import { useModal } from '/@/components/Modal';
  11. import { reactive } from 'vue';
  12. import { getBaseNewStudentPage } from '/@/services/apis/BaseNewStudentController';
  13. import { useMessage } from '/@/hooks/web/useMessage';
  14. const searchInfo = reactive<Recordable>({});
  15. const [registerModal, { openModal }] = useModal();
  16. const { createMessage } = useMessage();
  17. const [registerImportModal, { openModal: openImportModal }] = useModal();
  18. const [registerStudentImportModal, { openModal: openStudentImportModal }] = useModal();
  19. const [registerDivisionModal, { openModal: openDivisionModal }] = useModal();
  20. const [registerTable, { reload, getSelectRows }] = useTable({
  21. api: getBaseNewStudentPage,
  22. title: '新生列表',
  23. rowKey: 'id',
  24. columns: tableColumns,
  25. formConfig: {
  26. labelWidth: 120,
  27. schemas: searchFormSchema,
  28. },
  29. useSearchForm: true,
  30. showTableSetting: true,
  31. bordered: true,
  32. immediate: true,
  33. canResize: true,
  34. actionColumn: {
  35. width: 100,
  36. title: '操作',
  37. dataIndex: 'action',
  38. slots: { customRender: 'action' },
  39. fixed: 'right',
  40. },
  41. rowSelection: {
  42. type: 'checkbox',
  43. },
  44. });
  45. const handleEdit = (record: any, isUpdate: boolean) => {
  46. if (isUpdate === false) {
  47. if (searchInfo.enrollmentPlanId) {
  48. record.enrollmentPlanId = searchInfo.enrollmentPlanId;
  49. } else {
  50. createMessage.warning('请选择招生计划');
  51. return;
  52. }
  53. }
  54. openModal(true, {
  55. isUpdate: isUpdate,
  56. baseData: {
  57. ...record,
  58. },
  59. });
  60. };
  61. function handleSelect(id) {
  62. searchInfo.enrollmentPlanId = id;
  63. reload();
  64. }
  65. const handleSuccess = async () => {
  66. await reload();
  67. };
  68. const handelStudenImport = () => {
  69. if (searchInfo.enrollmentPlanId) {
  70. openStudentImportModal(true, { baseData: { enrollmentPlanId: searchInfo.enrollmentPlanId } });
  71. } else {
  72. createMessage.warning('请选择招生计划');
  73. }
  74. };
  75. const handelImport = () => {
  76. if (searchInfo.enrollmentPlanId) {
  77. openImportModal(true, { baseData: { enrollmentPlanId: searchInfo.enrollmentPlanId } });
  78. } else {
  79. createMessage.warning('请选择招生计划');
  80. }
  81. };
  82. const handleDivision = () => {
  83. const data = getSelectRows();
  84. if (data.length === 0) {
  85. createMessage.warning('请选择的学生');
  86. return;
  87. }
  88. openDivisionModal(true, { isUpdate: false, baseData: [...data] });
  89. };
  90. </script>
  91. <template>
  92. <PageWrapper dense contentFullHeight fixedHeight contentClass="flex">
  93. <ClassTree class="w-1/3 xl:w-1/4" @select="handleSelect" />
  94. <BasicTable class="w-2/3 xl:w-3/4" @register="registerTable" :searchInfo="searchInfo">
  95. <template #toolbar>
  96. <a-button type="primary" @click="handleEdit({}, false)">新增</a-button>
  97. <a-button type="primary" @click="handleDivision">手动分班</a-button>
  98. <a-button type="primary" @click="handelStudenImport">学生导入</a-button>
  99. <a-button type="primary" @click="handelImport">成绩导入</a-button>
  100. </template>
  101. <template #action="{ record }">
  102. <div style="display: flex; justify-content: center">
  103. <TableAction
  104. :actions="[
  105. {
  106. label: '编辑',
  107. onClick: handleEdit.bind(null, record, true),
  108. },
  109. ]"
  110. />
  111. </div>
  112. </template>
  113. </BasicTable>
  114. <FormEdit @register="registerModal" @success="handleSuccess" />
  115. <FormImport @register="registerImportModal" @success="handleSuccess" />
  116. <StudentImport @register="registerStudentImportModal" @success="handleSuccess" />
  117. <FormDivision @register="registerDivisionModal" @success="handleSuccess" />
  118. </PageWrapper>
  119. </template>
  120. <style scoped lang="less"></style>