UNPKG

sohelp-ele

Version:

SohelpEle Library

181 lines (180 loc) 4.89 kB
(function() { "use strict"; try { if (typeof document != "undefined") { var elementStyle = document.createElement("style"); elementStyle.appendChild(document.createTextNode("")); document.head.appendChild(elementStyle); } } catch (e) { console.error("vite-plugin-css-injected-by-js", e); } })(); "use strict"; var core = require("../utils/core"); var render = function() { var _vm = this; var _h = _vm.$createElement; var _c = _vm._self._c || _h; return _c("ele-tree-select", _vm._g(_vm._b({ attrs: { "clearable": "", "data": _vm.treeData, "init-value": _vm.initValue }, on: { "input": _vm.updateValue } }, "ele-tree-select", _vm.$attrs, false), _vm.$listeners)); }; var staticRenderFns = []; var index_vue_vue_type_style_index_0_scoped_true_lang = ""; function normalizeComponent(scriptExports, render2, staticRenderFns2, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) { var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports; if (render2) { options.render = render2; options.staticRenderFns = staticRenderFns2; options._compiled = true; } if (functionalTemplate) { options.functional = true; } if (scopeId) { options._scopeId = "data-v-" + scopeId; } var hook; if (moduleIdentifier) { hook = function(context) { context = context || this.$vnode && this.$vnode.ssrContext || this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext; if (!context && typeof __VUE_SSR_CONTEXT__ !== "undefined") { context = __VUE_SSR_CONTEXT__; } if (injectStyles) { injectStyles.call(this, context); } if (context && context._registeredComponents) { context._registeredComponents.add(moduleIdentifier); } }; options._ssrRegister = hook; } else if (injectStyles) { hook = shadowMode ? function() { injectStyles.call( this, (options.functional ? this.parent : this).$root.$options.shadowRoot ); } : injectStyles; } if (hook) { if (options.functional) { options._injectStyles = hook; var originalRender = options.render; options.render = function renderWithStyleInjection(h, context) { hook.call(context); return originalRender(h, context); }; } else { var existing = options.beforeCreate; options.beforeCreate = existing ? [].concat(existing, hook) : [hook]; } } return { exports: scriptExports, options }; } const __vue2_script = { name: "SohelpTreeSelect", props: { namespace: "", url: { type: String, default: "/engine/service/crud/page" }, params: { type: Object }, mappingFields: { type: Object, default: function() { return { key: "id", value: "value", label: "label", parent_id: "parent_id" }; } } }, data() { return { initValue: {}, treeData: [], baseParams: {}, done: false }; }, created() { this.load({}); }, mounted() { }, methods: { async load() { if (this.$attrs.data) { this.treeData = this.$attrs.data; return false; } let _initValue = { value: this.$attrs["value"] }; this.done = false; let _params = this.params || {}; _params.namespace = this.namespace; let res = await SohelpHttp.get(this.url, _params); if (res.meta.success) { let _res = res.data; _res == null ? void 0 : _res.forEach((d) => { d.key = d[this.mappingFields.key]; d.value = d[this.mappingFields.value]; d.label = d[this.mappingFields.label]; if (_initValue.value === d.value) { _initValue["label"] = d.label; } }); let _data = core.toTreeData({ data: _res, idField: this.mappingFields.key, parentIdField: this.mappingFields.parent_id }); this.initValue = Object.assign({}, _initValue); this.treeData = _data; this.done = true; } else { this.done = true; this.$message.error(res.meta.message); } }, updateValue(value) { this.$emit("input", value); }, reload(_params) { Object.assign(this.baseParams, _params); this.load(this.baseParams); }, refresh() { this.reload({}); } } }; const __cssModules = {}; var __component__ = /* @__PURE__ */ normalizeComponent( __vue2_script, render, staticRenderFns, false, __vue2_injectStyles, "5ab470f3", null, null ); function __vue2_injectStyles(context) { for (let o in __cssModules) { this[o] = __cssModules[o]; } } var index = /* @__PURE__ */ function() { return __component__.exports; }(); module.exports = index;