Skip to content

ReportPrintOption Component

A two-panel settings component for configuring report date ranges and print options. Internally uses the Tab component to switch between a Report settings tab and a Print settings tab. Provides date type presets, dual-calendar (AD/BS) date pickers, paper size/orientation selectors, and toggle switches for print visibility options.


Table of Contents


Import

ts
import { ReportPrintOption } from "dolphin-components";
import type { ReportPrintOptionProps } from "dolphin-components";

Basic Usage

vue
<template>
  <ReportPrintOption v-model="config" />
</template>

<script setup lang="ts">
import { ref } from "vue";
import { ReportPrintOption } from "dolphin-components";

const config = ref({
  startDate: "",
  endDate: "",
  dateType: "today",
  isBS: false,
  paperSize: "A4",
  paperOrientation: "Portrait",
  showHeader: true,
  showReport: true,
  showReportOverview: true,
  showPageCount: true,
  showPrintDate: true,
});
</script>

Props

PropTypeDefaultDescription
modelValueReportPrintOptionModelValueSee defaults belowThe configuration object containing all report and print settings. Supports v-model.

Default modelValue

typescript
{
  startDate: "",
  endDate: "",
  dateType: "today",
  isBS: false,
  paperSize: "A4",
  paperOrientation: "Portrait",
  showHeader: true,
  showReport: true,
  showReportOverview: true,
  showPageCount: true,
  showPrintDate: true,
}

Model Value Properties

PropertyTypeDefaultDescription
startDatestring""Start date in AD format (YYYY-MM-DD).
endDatestring""End date in AD format (YYYY-MM-DD).
dateTypestring"today"Active date type preset ID (see Date Type Presets).
isBSbooleanfalseWhether to display dates in Nepali calendar (Bikram Sambat).
paperSizestring"A4"Paper size for printing. Options: "A3", "A4", "A5", "Letter".
paperOrientationstring"Portrait"Page orientation. Options: "Portrait", "Landscape".
showHeaderbooleantrueShow header section when printing.
showReportbooleantrueShow report content when printing (legacy alias for showReportOverview).
showReportOverviewbooleantrueShow report overview table when printing.
showPageCountbooleantrueShow page count when printing.
showPrintDatebooleantrueShow print date when printing.

Events

EventPayloadDescription
update:modelValueReportPrintOptionModelValueEmitted whenever any setting changes. Supports v-model.
searchEmitted when a search/refresh action is triggered.

Slots

The component provides named slots at strategic insertion points to allow adding custom settings rows in either the Report or Print tab.

Report Tab Slots

Slot NameDescription
before-date-typeInsert content before the Date Type selector.
after-date-typeInsert content after the Date Type selector.
after-from-dateInsert content after the From Date picker.
after-to-dateInsert content after the To Date picker.
report-sectionInsert content at the end of the repport tab panel.
Slot NameDescription
before-paper-sizeInsert content before the Paper Size selector.
after-paper-sizeInsert content after the Paper Size selector.
after-page-orientationInsert content after the Page Orientation selector.
after-show-headerInsert content after the Show Header toggle.
after-show-report-overviewInsert content after the Show Report Overview toggle.
after-show-page-countInsert content after the Show Page Count toggle.
after-show-print-dateInsert content after the Show Print Date toggle.
print-sectionInsert content at the end of the print tab panel.

TypeScript Interfaces

typescript
interface ReportPrintOptionProps {
  modelValue?: {
    startDate: string;
    endDate: string;
    dateType: string;
    isBS: boolean;
    paperSize?: string;
    paperOrientation?: string;
    showHeader?: boolean;
    showReport?: boolean;
    showReportOverview?: boolean;
    showPageCount?: boolean;
    showPrintDate?: boolean;
  };
}

Date Type Presets

The Report tab includes a dropdown of predefined date ranges, all calculated using the Nepali fiscal year system:

IDDisplay NameDescription
year_to_dateYear to dateFrom fiscal year start to today
quarter_to_dateQuarter to dateFrom current fiscal quarter start to today
month_to_dateMonth to dateFrom current month start to today
week_to_dateWeek to dateFrom current week start to today
todayTodayCurrent day only
last_30_daysLast 30 days30 days ago to today
last_90_daysLast 90 days90 days ago to today
first_quarterFirst quarter (Q1)Complete first fiscal quarter
second_quarterSecond quarter (Q2)Complete second fiscal quarter
third_quarterThird quarter (Q3)Complete third fiscal quarter
fourth_quarterFourth quarter (Q4)Complete fourth fiscal quarter
customCustomAutomatically set when dates are manually picked

The Print tab provides the following configurable options:

SettingControlOptions / Default
Paper SizeMultiselectA3, A4, A5, Letter
Page OrientationMultiselectLandscape, Portrait
Show HeaderSwitchOn / Off
Show Report OverviewSwitchOn / Off
Show Page CountSwitchOn / Off
Show Print DateSwitchOn / Off

Usage Examples

With Custom Report Slot

Add a custom field between the built-in date settings:

vue
<template>
  <ReportPrintOption v-model="config">
    <template #after-to-date>
      <ReportPrintOptionLayout
        header="Department"
        description="Filter data by department."
      >
        <Multiselect
          v-model="selectedDepartment"
          :options="departments"
          label="name"
          trackBy="id"
          placeholder="Select Department"
          class="remove-height w-50 max-w-50"
        />
      </ReportPrintOptionLayout>
    </template>
  </ReportPrintOption>
</template>

<script setup lang="ts">
import { ref } from "vue";
import {
  ReportPrintOption,
  ReportPrintOptionLayout,
  Multiselect,
} from "dolphin-components";

const config = ref({
  startDate: "",
  endDate: "",
  dateType: "month_to_date",
  isBS: false,
});

const selectedDepartment = ref(null);
const departments = [
  { id: 1, name: "Engineering" },
  { id: 2, name: "Finance" },
  { id: 3, name: "HR" },
];
</script>

Watching for Configuration Changes

vue
<template>
  <ReportPrintOption v-model="reportConfig" />

  <div class="mt-4 text-sm text-gray-500">
    Period: {{ reportConfig.startDate }} to {{ reportConfig.endDate }} | Paper:
    {{ reportConfig.paperSize }} {{ reportConfig.paperOrientation }}
  </div>
</template>

<script setup lang="ts">
import { ref, watch } from "vue";
import { ReportPrintOption } from "dolphin-components";

const reportConfig = ref({
  startDate: "",
  endDate: "",
  dateType: "quarter_to_date",
  isBS: true,
  paperSize: "A4",
  paperOrientation: "Portrait",
  showHeader: true,
  showReport: true,
  showReportOverview: true,
  showPageCount: true,
  showPrintDate: true,
});

watch(
  reportConfig,
  (newConfig) => {
    console.log("Config updated:", newConfig);
  },
  { deep: true },
);
</script>

Best Practices

  1. Always use v-model — The component communicates all changes through update:modelValue. Use v-model for seamless two-way binding.
  2. Dates are always in AD format — Regardless of the BS/AD toggle display, startDate and endDate are always emitted in Gregorian YYYY-MM-DD format.
  3. Use named slots for custom fields — Insert domain-specific controls (department filters, branch selectors, etc.) using the available named slots rather than wrapping the component.
  4. Pair with ReportPrintOptionLayout — When adding custom rows via slots, wrap them in ReportPrintOptionLayout for visual consistency with the built-in settings.

Troubleshooting

Dates not updating

  • Ensure you are binding with v-model and your ref is reactive.
  • Verify the dateType value is one of the valid preset IDs. Invalid values default to "today".
  • Both showReport and showReportOverview are synced together for backward compatibility. Setting either one updates the other.

BS/AD toggle not working

  • The toggle switches the display format only. The model values (startDate, endDate) always remain in AD format.

Dependencies

  • Tab — Internal tab navigation between Report and Print panels
  • Toggle — BS/AD calendar system toggle
  • Switch — Print visibility toggles
  • Multiselect — Date type, paper size, and orientation selectors
  • nepali-datepicker-vue — Nepali calendar date picker
  • vue-datepicker-next — Gregorian calendar date picker
  • nepali-date-library — Date conversion utilities