class-statistic-table.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <template>
  2. <Table :data="classList" :columns="columns" selection-mode="multiple" row-key="classId"
  3. :selected-rows="selectedClasses" @selection-change="handleSelectionChange"/>
  4. </template>
  5. <script setup name="ClassStatisticTable">
  6. import {useInjectPaperClassStatisticCondition} from "@/views/dz/papers/hooks/usePaperClassStatisticCondition.js";
  7. import Table from '@/components/Table/index.vue';
  8. import consts from "@/utils/consts.js";
  9. const props = defineProps({
  10. exactMode: Boolean
  11. })
  12. const {classList, selectedClasses} = useInjectPaperClassStatisticCondition()
  13. const ids = ref([]);
  14. const single = ref(true);
  15. const multiple = ref(true);
  16. const columns = props.exactMode ? [
  17. {label: '班级名称', prop: 'className'},
  18. {label: '总人数', prop: 'total'},
  19. ...consts.config.exactColumns
  20. ] : [
  21. {label: '班级名称', prop: 'className'},
  22. {label: '总人数', prop: 'total'},
  23. ...consts.config.fullColumns
  24. ]
  25. function handleSelectionChange(selection) {
  26. ids.value = selection.map((item) => item.classId);
  27. single.value = selection.length != 1;
  28. multiple.value = !selection.length;
  29. selectedClasses.value = selection
  30. }
  31. </script>
  32. <style scoped>
  33. </style>