Summary.js 796 B

1234567891011121314151617181920212223242526
  1. import { computed, defineComponent, onBeforeUnmount, watchEffect } from 'vue';
  2. import { useInjectTable } from '../context/TableContext';
  3. let indexGuid = 0;
  4. const Summary = defineComponent({
  5. name: 'TableSummary',
  6. props: ['fixed'],
  7. setup(props, _ref) {
  8. let {
  9. slots
  10. } = _ref;
  11. const tableContext = useInjectTable();
  12. const uniKey = `table-summary-uni-key-${++indexGuid}`;
  13. const fixed = computed(() => props.fixed === '' || props.fixed);
  14. watchEffect(() => {
  15. tableContext.summaryCollect(uniKey, fixed.value);
  16. });
  17. onBeforeUnmount(() => {
  18. tableContext.summaryCollect(uniKey, false);
  19. });
  20. return () => {
  21. var _a;
  22. return (_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots);
  23. };
  24. }
  25. });
  26. export default Summary;