Cell.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
  2. import { createVNode as _createVNode } from "vue";
  3. import { defineComponent } from 'vue';
  4. import Cell from '../Cell';
  5. import { useInjectSummary } from '../context/SummaryContext';
  6. import { useInjectTable } from '../context/TableContext';
  7. import { getCellFixedInfo } from '../utils/fixUtil';
  8. export default defineComponent({
  9. name: 'SummaryCell',
  10. props: ['index', 'colSpan', 'rowSpan', 'align'],
  11. setup: function setup(props, _ref) {
  12. var attrs = _ref.attrs,
  13. slots = _ref.slots;
  14. var tableContext = useInjectTable();
  15. var summaryContext = useInjectSummary();
  16. return function () {
  17. var index = props.index,
  18. _props$colSpan = props.colSpan,
  19. colSpan = _props$colSpan === void 0 ? 1 : _props$colSpan,
  20. rowSpan = props.rowSpan,
  21. align = props.align;
  22. var prefixCls = tableContext.prefixCls,
  23. direction = tableContext.direction;
  24. var scrollColumnIndex = summaryContext.scrollColumnIndex,
  25. stickyOffsets = summaryContext.stickyOffsets,
  26. flattenColumns = summaryContext.flattenColumns;
  27. var lastIndex = index + colSpan - 1;
  28. var mergedColSpan = lastIndex + 1 === scrollColumnIndex ? colSpan + 1 : colSpan;
  29. var fixedInfo = getCellFixedInfo(index, index + mergedColSpan - 1, flattenColumns, stickyOffsets, direction);
  30. return _createVNode(Cell, _objectSpread({
  31. "class": attrs.class,
  32. "index": index,
  33. "component": "td",
  34. "prefixCls": prefixCls,
  35. "record": null,
  36. "dataIndex": null,
  37. "align": align,
  38. "colSpan": mergedColSpan,
  39. "rowSpan": rowSpan,
  40. "customRender": function customRender() {
  41. var _slots$default;
  42. return (_slots$default = slots.default) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots);
  43. }
  44. }, fixedInfo), null);
  45. };
  46. }
  47. });