birdpaper-ui
Version:
一个通用的 vue3 UI组件库。A common vue3 UI component library.
42 lines (41 loc) • 1.35 kB
JavaScript
;
const vue = require("vue");
const types = require("../types.js");
const dayjs = require("dayjs");
const core = require("../core.js");
const birdpaperIcon = require("birdpaper-icon");
const _sfc_main = vue.defineComponent({
name: "YearTable",
components: { IconArrowLeftDoubleFill: birdpaperIcon.IconArrowLeftDoubleFill, IconArrowRightDoubleFill: birdpaperIcon.IconArrowRightDoubleFill },
emits: ["change-picker"],
setup(props, { emit }) {
const name = "bp-year-table";
let ctx = null;
ctx = vue.inject(types.dateInjectionKey);
const { toDay, current, firstYear, yearCell, setYearCell } = core.useDayJs(ctx.langs, ctx.modelValue.value);
const currentVal = vue.ref(current.value && current.value.format(ctx.valueFormat));
setYearCell(ctx.valueFormat);
const handleChange = (type, step = 12) => {
let val = firstYear.value;
firstYear.value = type === "next" ? val + step : val - step;
setYearCell(ctx.valueFormat);
};
const handleSelect = (date) => {
currentVal.value = date.value;
ctx.onSelect(currentVal.value, {}, false);
emit("change-picker", "month");
};
return {
name,
ctx,
toDay,
handleChange,
currentVal,
yearCell,
firstYear,
handleSelect,
dayjs
};
}
});
module.exports = _sfc_main;