@wetspace/pro-components
Version:
::: tip 基本介绍
170 lines (169 loc) • 6.21 kB
JavaScript
import { defineComponent as P, shallowRef as x, ref as R, computed as y, h as E, openBlock as T, createElementBlock as U, createVNode as t, unref as l, withCtx as n, createElementVNode as s, normalizeClass as p, createTextVNode as m, toDisplayString as _ } from "vue";
import { useNamespace as b, ElPopover as $, ElInput as D, ElForm as j, ElFormItem as V, ElInputNumber as k, ElButton as C } from "element-plus";
import "../../../delete-button/index.mjs";
import "../../../count-down-button/index.mjs";
import { TextEllipsis as N } from "../../../ellipsis/index.mjs";
import "../../index.mjs";
import "../../../pro-form/index.mjs";
import "../../../pro-table/index.mjs";
import "../../../pro-descriptions/index.mjs";
import "../../../pro-list/index.mjs";
import "../../../layout/index.mjs";
import "../../../page/index.mjs";
import "../../../guide/index.mjs";
import "../../../notice-menu/index.mjs";
import "../../../state/index.mjs";
import { digitRangeProps as A } from "./types.mjs";
const G = { style: { "text-align": "right" } }, ae = /* @__PURE__ */ P({
__name: "index",
props: A,
emits: ["update:modelValue", "change"],
setup(z, { emit: h }) {
const g = h, u = b("digitrange"), I = b("input"), o = z, f = x(), v = x(), c = x(!1), r = R([]), B = y(() => typeof o.suffixIcon == "string" ? E("span", {}, {
default: () => o.suffixIcon
}) : o.suffixIcon), S = y(() => typeof o.prefixIcon == "string" ? E("span", {}, {
default: () => o.prefixIcon
}) : o.prefixIcon), q = {
0: [{
validator(a, e, i) {
var d;
r.value[1] !== void 0 && (e > r.value[1] && i(new Error("数值起点不能高于或等于数值终点")), (e === "" || e === void 0) && i(new Error("当前输入不能为空"))), e === "" && ((d = f.value) == null || d.clearValidate()), i();
}
}],
1: [{
validator(a, e, i) {
var d;
r.value[0] !== void 0 && (e <= r.value[0] && i(new Error("数值终点不能低于或等于数值起点")), (e === "" || e === void 0) && i(new Error("当前输入不能为空"))), e === "" && ((d = f.value) == null || d.clearValidate()), i();
}
}]
}, F = () => {
var e;
if (o.disabled) return;
c.value = !0;
const a = (e = v.value) == null ? void 0 : e.querySelector(`.${I.e("wrapper")}`);
a && a.classList.add("is-focus");
}, w = () => {
var e;
c.value = !1;
const a = (e = v.value) == null ? void 0 : e.querySelector(`.${I.e("wrapper")}`);
a && a.classList.remove("is-focus");
}, L = async () => {
var a;
await ((a = f.value) == null ? void 0 : a.validate()), g("update:modelValue", r.value), g("change", r.value), w();
};
return (a, e) => (T(), U("div", null, [
t(l($), {
visible: c.value,
width: 350
}, {
reference: n(() => [
s("div", {
ref_key: "inputdiv",
ref: v,
class: p([l(u).b(), l(u).is("disabled", o.disabled)]),
onClick: F
}, [
s("div", {
class: p([l(u).e("inner")])
}, [
s("div", {
class: p([l(u).e("inner-value"), "is-left"])
}, [
t(l(N), null, {
default: n(() => {
var i;
return [
m(_((i = o.modelValue) == null ? void 0 : i[0]), 1)
];
}),
_: 1
})
], 2),
e[2] || (e[2] = s("div", null, "-", -1)),
s("div", {
class: p([l(u).e("inner-value"), "is-right"])
}, [
t(l(N), null, {
default: n(() => {
var i;
return [
m(_((i = o.modelValue) == null ? void 0 : i[1]), 1)
];
}),
_: 1
})
], 2)
], 2),
t(l(D), {
disabled: o.disabled,
style: { width: "100%" },
placeholder: o.placeholder,
"model-value": o.modelValue && o.modelValue.length !== 0 ? " " : "",
"suffix-icon": B.value,
"prefix-icon": S.value,
size: o.size
}, null, 8, ["disabled", "placeholder", "model-value", "suffix-icon", "prefix-icon", "size"])
], 2)
]),
default: n(() => [
t(l(j), {
ref_key: "formIns",
ref: f,
model: r.value,
rules: q,
class: p([l(u).e("popover-panel")])
}, {
default: n(() => [
t(l(V), { prop: "0" }, {
default: n(() => [
t(l(k), {
modelValue: r.value[0],
"onUpdate:modelValue": e[0] || (e[0] = (i) => r.value[0] = i)
}, null, 8, ["modelValue"])
]),
_: 1
}),
t(l(V), null, {
default: n(() => e[3] || (e[3] = [
s("div", { style: { padding: "0 8px" } }, " - ", -1)
])),
_: 1
}),
t(l(V), { prop: "1" }, {
default: n(() => [
t(l(k), {
modelValue: r.value[1],
"onUpdate:modelValue": e[1] || (e[1] = (i) => r.value[1] = i)
}, null, 8, ["modelValue"])
]),
_: 1
})
]),
_: 1
}, 8, ["model", "class"]),
s("div", G, [
t(l(C), { onClick: w }, {
default: n(() => e[4] || (e[4] = [
m(" 取消 ")
])),
_: 1
}),
t(l(C), {
type: "primary",
onClick: L
}, {
default: n(() => e[5] || (e[5] = [
m(" 确认 ")
])),
_: 1
})
])
]),
_: 1
}, 8, ["visible"])
]));
}
});
export {
ae as default
};