@wetspace/pro-components
Version:
::: tip 基本介绍
61 lines (60 loc) • 1.62 kB
JavaScript
import { shallowRef as v, ref as S, computed as f } from "vue";
const m = v(!1), w = (a, u) => {
const l = S({}), t = v(), s = f(() => {
if (a.search) {
const r = {
span: 6,
labelWidth: 70,
collapsed: !0,
collapseShowNum: -1
};
return typeof a.search == "boolean" ? r : {
...r,
...a.search
};
} else
return !1;
}), h = async () => {
var o;
const r = await ((o = t.value) == null ? void 0 : o.submit());
l.value = r;
}, d = () => {
var o;
const r = (o = t.value) == null ? void 0 : o.reset();
l.value = r;
}, I = f(() => {
let r = [];
if (u.value && s.value) {
const o = u.value.filter((e) => e.search), P = s.value.collapseShowNum === -1 ? 24 / s.value.span : s.value.collapseShowNum + 1;
r = o.map((e, y) => {
var n, p, c;
return {
valueType: e.valueType,
valueEnum: e.valueEnum,
...e.formItemProps,
// fixedWidth:true,
label: e.title || ((n = e.formItemProps) == null ? void 0 : n.label),
property: e.dataIndex || e.formItemProps.property || ((p = e.formItemProps) == null ? void 0 : p.prop),
hideInForm: !m.value && y + 1 >= P,
formInputProps: {
...e.fieldProps,
...(c = e.formItemProps) == null ? void 0 : c.formInputProps
}
};
});
}
return r;
});
return {
formState: l,
formPorps: s,
formIns: t,
getSearchValue: h,
resetForm: d,
properties: I,
collapsed: m
};
};
export {
w as default
};