2024-07-04 15:00:51 +08:00

8 lines
1.5 KiB
JavaScript

/*!
* @form-create/component-elm-tree v3.2.0
* (c) 2018-2024 xaboy
* Github https://github.com/xaboy/form-create with tree
* Released under the MIT License.
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).FcTree={},e.Vue)}(this,(function(e,t){"use strict";var r=t.defineComponent({name:"fcTree",inheritAttrs:!1,formCreateParser:{mergeProp:function(e){var t=e.prop.props;t.nodeKey||(t.nodeKey="id"),t.props||(t.props={label:"title"})}},props:{type:String,modelValue:{type:[Array,String,Number],default:function(){return[]}}},emits:["update:modelValue","fc.el"],watch:{modelValue:function(){this.setValue()}},methods:{updateValue:function(){var e;this.$refs.tree&&(e="selected"===this.type?this.$refs.tree.getCurrentKey():this.$refs.tree.getCheckedKeys(),this.$emit("update:modelValue",e))},setValue:function(){var e;this.$refs.tree&&("selected"===this.type?this.$refs.tree.setCurrentKey(this.modelValue):this.$refs.tree.setCheckedKeys((e=this.modelValue,Array.isArray(e)?e:[null,void 0,""].indexOf(e)>-1?[]:[e])))}},render:function(){return t.createVNode(t.resolveComponent("ElTree"),t.mergeProps(this.$attrs,{ref:"tree",onCheck:this.updateValue,"onNode-click":this.updateValue}),this.$slots)},mounted:function(){this.setValue(),this.$emit("fc.el",this.$refs.tree)}});e.default=r,Object.defineProperty(e,"__esModule",{value:!0})}));