yanzhen-design-vue
Version:
78 lines (77 loc) • 3.3 kB
JavaScript
;
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const vue = require("vue");
const antDesignVue = require("ant-design-vue");
const lodashEs = require("lodash-es");
require("./InnerTreeSelect.vue.cjs");
const InnerCascader = require("./InnerCascader.vue.cjs");
const InnerTreeSelect_vue_vue_type_script_setup_true_lang = require("./InnerTreeSelect.vue2.cjs");
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
__name: "HydrateCascade",
props: /* @__PURE__ */ vue.mergeModels({
mode: {},
isReadonly: { type: Boolean },
isHidden: { type: Boolean },
placeholder: {},
tooltips: {},
options: { default: () => [] },
filterOptions: { default: () => [] },
leafOnly: { type: Boolean },
showAllLevels: { type: Boolean },
selectMaxLimit: {},
selectMaxLimitMsg: {}
}, {
"modelValue": { default: [] },
"modelModifiers": {}
}),
emits: ["update:modelValue"],
setup(__props) {
const attrs = vue.useAttrs();
const targetKey = vue.computed(() => {
const fieldNames = attrs == null ? void 0 : attrs["field-names"];
return (fieldNames == null ? void 0 : fieldNames.value) || "id";
});
const props = __props;
const currentValue = vue.useModel(__props, "modelValue");
const { filterOptions, options } = vue.toRefs(props);
const treeData = vue.computed(() => {
const cloneTreeData = lodashEs.cloneDeep(vue.toValue(options));
const cleanUp = (nodes) => {
const restNodes = nodes.filter(
(node) => !vue.toValue(filterOptions).includes(node[vue.toValue(targetKey)])
);
return restNodes.map((node) => {
if (node.children) {
node.children = cleanUp(node.children);
}
return node;
});
};
return cleanUp(cloneTreeData);
});
return (_ctx, _cache) => {
return _ctx.mode === "tree" ? (vue.openBlock(), vue.createBlock(InnerTreeSelect_vue_vue_type_script_setup_true_lang.default, {
key: 0,
modelValue: currentValue.value,
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => currentValue.value = $event),
"tree-data": treeData.value,
"max-tag-count": "responsive",
"tree-checkable": "",
"allow-clear": "",
placeholder: "请选择",
"tree-check-strictly": !props.leafOnly ? true : false,
"show-checked-strategy": !props.leafOnly ? vue.unref(antDesignVue.TreeSelect).SHOW_ALL : vue.unref(antDesignVue.TreeSelect).SHOW_CHILD,
"tree-node-filter-prop": "label"
}, null, 8, ["modelValue", "tree-data", "tree-check-strictly", "show-checked-strategy"])) : (vue.openBlock(), vue.createBlock(InnerCascader.default, {
key: 1,
modelValue: currentValue.value,
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => currentValue.value = $event),
options: treeData.value,
"check-strictly": !props.leafOnly,
"field-names": { label: "name", value: "id", children: "children" },
"display-render": props.showAllLevels ? (labels) => labels.join("/") : null
}, null, 8, ["modelValue", "options", "check-strictly", "display-render"]));
};
}
});
exports.default = _sfc_main;