satisfy.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <script setup lang="ts">
  2. import { useModalInner, BasicModal } from '/@/components/Modal';
  3. import { PageWrapper } from '/@/components/Page';
  4. import { useTable, BasicTable, TableAction } from '/@/components/Table';
  5. import { reactive, ref } from 'vue';
  6. import { Recordable } from 'vite-plugin-mock';
  7. import {
  8. getBandingTaskClassSatisfyStudent,
  9. postBandingTaskClassRemoveStudent,
  10. } from '/@/services/apis/BandingTaskClassController';
  11. import { tableSatisfyColumns } from '../data.config';
  12. const modelRef = ref<Recordable>({});
  13. const emit = defineEmits(['success', 'register']);
  14. const searchInfo = reactive<Recordable>({});
  15. const [registerTable, { reload }] = useTable({
  16. api: getBandingTaskClassSatisfyStudent,
  17. title: '满足学生列表',
  18. rowKey: 'id',
  19. columns: tableSatisfyColumns,
  20. useSearchForm: false,
  21. showTableSetting: true,
  22. bordered: true,
  23. immediate: false,
  24. canResize: true,
  25. actionColumn: {
  26. width: 100,
  27. title: '操作',
  28. dataIndex: 'action',
  29. slots: { customRender: 'action' },
  30. fixed: 'right',
  31. },
  32. });
  33. const [registerModal, { setModalProps }] = useModalInner((data) => {
  34. setModalProps({ confirmLoading: false });
  35. modelRef.value = { ...data.baseData };
  36. searchInfo.bandingTaskClassId = data.baseData.id;
  37. reload();
  38. });
  39. const handleDelete = async (record: Recordable) => {
  40. await postBandingTaskClassRemoveStudent({
  41. bandingTaskClassId: modelRef.value.id,
  42. newStudentIds: [record.id],
  43. });
  44. reload();
  45. };
  46. const handleCancel = () => {
  47. emit('success');
  48. };
  49. </script>
  50. <template>
  51. <BasicModal
  52. :destroyOnClose="true"
  53. :maskClosable="false"
  54. v-bind="$attrs"
  55. @register="registerModal"
  56. :width="1002"
  57. title="满足学生"
  58. :footer="null"
  59. @cancel="handleCancel"
  60. >
  61. <PageWrapper dense contentFullHeight fixedHeight contentClass="flex">
  62. <BasicTable @register="registerTable" :searchInfo="searchInfo">
  63. <template #action="{ record }">
  64. <TableAction
  65. :actions="[
  66. {
  67. label: '移出',
  68. onClick: handleDelete.bind(null, record),
  69. },
  70. ]"
  71. />
  72. </template>
  73. </BasicTable>
  74. </PageWrapper>
  75. </BasicModal>
  76. </template>
  77. <style scoped lang="less"></style>