hu-element-components
Version:
66 lines (65 loc) • 2.16 kB
JavaScript
import { defineComponent as y, ref as s, watch as p, resolveComponent as V, createElementBlock as C, openBlock as P, createElementVNode as m, createVNode as c, mergeProps as f, unref as n, isRef as h } from "vue";
const T = { style: { display: "flex" } }, k = { style: { "margin-right": "20px" } }, x = /* @__PURE__ */ y({
__name: "index",
props: {
startPlaceholder: {
type: String,
default: "请选择开始日期"
},
endPlaceholder: {
type: String,
default: "请选择结束日期"
},
disableToday: {
type: Boolean,
default: !0
}
},
emits: ["startChange", "endChange"],
setup(a, { emit: g }) {
let v = a, i = g, t = s(null), l = s(null), r = s(!0), b = (e) => {
if (v.disableToday) return e.getTime() < Date.now() - 1e3 * 60 * 60 * 24;
}, D = (e) => {
if (t.value)
return e.getTime() < t.value.getTime() + 1e3 * 60 * 60 * 24;
};
return p(() => t.value, (e) => {
e ? (i("startChange", e), r.value = !1) : (l.value = null, r.value = !0);
}), p(() => l.value, (e) => {
e && i("endChange", {
startDate: t.value,
endDate: l.value
});
}), (e, o) => {
const u = V("el-date-picker");
return P(), C("div", T, [
m("div", k, [
c(u, f({
modelValue: n(t),
"onUpdate:modelValue": o[0] || (o[0] = (d) => h(t) ? t.value = d : t = d),
type: "date",
placeholder: a.startPlaceholder,
"disabled-date": n(b)
}, e.$attrs.startOptions), null, 16, ["modelValue", "placeholder", "disabled-date"])
]),
m("div", null, [
c(u, f({
modelValue: n(l),
"onUpdate:modelValue": o[1] || (o[1] = (d) => h(l) ? l.value = d : l = d),
type: "date",
placeholder: a.endPlaceholder,
disabled: n(r),
"disabled-date": n(D)
}, e.$attrs.endOptions), null, 16, ["modelValue", "placeholder", "disabled", "disabled-date"])
])
]);
};
}
}), B = {
install(a) {
a.component("m-choose-date", x);
}
};
export {
B as default
};