UNPKG

sohelp-ele

Version:

SohelpEle Library

258 lines (257 loc) 8.11 kB
(function() { "use strict"; try { if (typeof document != "undefined") { var elementStyle = document.createElement("style"); elementStyle.appendChild(document.createTextNode(".el-dialog__headerbtn[data-v-40257bb6] {\n position: absolute;\n top: 20px;\n right: 20px;\n}\n.setting-icon[data-v-40257bb6] {\n right: 66px !important;\n}\n.el-dialog__footer[data-v-40257bb6] {\n padding-top: 20px;\n}")); document.head.appendChild(elementStyle); } } catch (e) { console.error("vite-plugin-css-injected-by-js", e); } })(); import SohelpModal from "../sohelp-modal"; import SohelpVform from "../sohelp-vform"; var render = function() { var _vm = this; var _h = _vm.$createElement; var _c = _vm._self._c || _h; return _c("sohelp-modal", _vm._g(_vm._b({ attrs: { "before-close": _vm.close, "close-on-click-modal": false, "destroy-on-close": false, "visible": _vm.visible }, on: { "update:visible": function($event) { _vm.visible = $event; } } }, "sohelp-modal", _vm.$attrs, false), _vm.$listeners), [_c("template", { slot: "title" }, [_vm._v(" " + _vm._s(_vm.$attrs.title) + " "), _c("span", { staticClass: "el-dialog__headerbtn setting-icon", on: { "click": _vm.openVformDesigner } }, [_c("i", { staticClass: "el-icon-setting" })])]), _c("sohelp-vform", { ref: "sohelpVformRef", scopedSlots: _vm._u([_vm._l(Object.keys(_vm.$scopedSlots), function(slot) { return { key: slot, fn: function(scope) { return [_vm._t(slot, null, null, scope)]; } }; })], null, true) }), _c("template", { slot: "footer" }, _vm._l(_vm.buttons, function(item) { return _c("el-button", { key: item.title, attrs: { "disabled": item.disabled === "true", "icon": item.icon, "loading": item.loading === "true", "plain": item.plain === "true", "round": item.round === "true", "size": item.size, "type": item.type }, on: { "click": function($event) { return _vm.buttonClick(item.click); } } }, [_vm._v(_vm._s(item.title) + " ")]); }), 1)], 2); }; 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: "SohelpVformModal", inheritAttrs: false, props: { refid: { type: String, value: false, require: false }, visible: { type: Boolean, default: false } }, inject: ["$this"], components: { SohelpModal, SohelpVform }, data() { return { buttons: [], done: false, params: {}, baseParams: {} }; }, async created() { if (this.refid) ; }, mounted() { }, watch: { visible: { handler(newValue, oldValue) { if (this.refid) { this.load(this.refid); } }, immediate: true } }, methods: { setReadMode(readMode) { this.$refs.sohelpVformRef.setReadMode(readMode); }, getFormData(needValidation = true) { return this.$refs.sohelpVformRef.getFormData(needValidation); }, enableForm() { this.$refs.sohelpVformRef.enableForm(); }, disableForm() { this.$refs.sohelpVformRef.disableForm(); }, async isDone() { let promise = new Promise((resolve, reject) => { if (this.done) { resolve(); } else { let timer = setInterval(() => { if (this.done) { clearInterval(timer); resolve(); } }, 17); } }); return promise; }, async load(refid) { var _a, _b; this.done = false; const res = await SohelpHttp.get("/engine/web/ele/designer/read", { refid }); if (res.meta.success && ((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.code)) { try { let formJson = JSON.parse(res.data.code); this.buttons = ((_b = res.data) == null ? void 0 : _b.btnStr) ? JSON.parse(res.data.btnStr) : []; this.$nextTick(() => { var _a2; (_a2 = this.$refs.sohelpVformRef) == null ? void 0 : _a2.setFormJson(formJson); this.done = true; }); } catch (e) { this.done = true; this.$message.error("\u8BFB\u53D6\u754C\u9762\u914D\u7F6E\u9519\u8BEF:" + this.refid + ":" + e); } } else { this.done = true; this.$message.error(res.meta.message); } }, show(config) { this.baseParams = Object.assign({}, this.baseParams, (config == null ? void 0 : config.baseParams) || {}); this.params = Object.assign({}, this.params, (config == null ? void 0 : config.params) || {}); this.$emit("update:visible", true); this.isDone().then(() => { this.reset(); }); }, hide() { this.$emit("update:visible", false); }, close() { this.$emit("update:visible", false); }, getVformRef() { return this.$refs.sohelpVformRef.getVformRef(); }, setValue(refName, value) { this.$refs.sohelpVformRef.setValue(refName, value); }, getValue(refName) { this.$refs.sohelpVformRef.getValue(refName); }, getRef(refName) { return this.$refs.sohelpVformRef.getRef(refName); }, setValues(values) { this.$refs.sohelpVformRef.setFormData(values); }, getValues() { return this.$refs.sohelpVformRef.getValues(); }, reset() { return this.$refs.sohelpVformRef.reset(); }, getRecordUpdater() { return this.$refs.sohelpVformRef.getRecordUpdater(); }, getWidgetRef(ref) { return this.$refs.sohelpVformRef.getWidgetRef(ref); }, buttonClick(click) { const buttonHandlerCode = click; try { let func = new Function(buttonHandlerCode); func.call(this); } catch (err) { this.$message.error(err); } }, openVformDesigner() { const url = `${SOHELP_API_URL}/dev/index.html#/design?refid=${this.refid}`; window.open(url); } } }; const __cssModules = {}; var __component__ = /* @__PURE__ */ normalizeComponent( __vue2_script, render, staticRenderFns, false, __vue2_injectStyles, "40257bb6", null, null ); function __vue2_injectStyles(context) { for (let o in __cssModules) { this[o] = __cssModules[o]; } } var index = /* @__PURE__ */ function() { return __component__.exports; }(); export { index as default };