snowy-designer
Version:
基于Epic-Designer-Pro版本的设计器,可视化开发页面表单
161 lines (160 loc) • 4.41 kB
JavaScript
import { defineComponent as S, ref as i, reactive as w, createBlock as d, openBlock as l, unref as n, withCtx as u, createElementVNode as p, createCommentVNode as O, createElementBlock as U, Fragment as D, renderList as E, createVNode as J, toRaw as M } from "vue";
/* empty css */
import "radix-vue";
import "clsx";
import "tailwind-merge";
import "lucide-vue-next";
import "../../../../base-ui/src/shadch-ui/button/index.js";
import "@vueuse/core";
import "../../../../base-ui/src/shadch-ui/toast/index.js";
import P from "../../../../base-ui/src/components/node/node.vue.js";
import { deepCompareAndModify as s, deepClone as B } from "../../../../../utils/src/common/data.js";
import { getUUID as T } from "../../../../../utils/src/common/string.js";
import "../../../../../hooks/src/store/index.js";
import "lodash";
import { pluginManager as c } from "../../../../../utils/src/manager/pluginManager.js";
import "monaco-editor";
import { request as q } from "../../../../../utils/src/request/index.js";
import "vuedraggable";
const I = { class: "min-w-750px epic-api-modal-content rounded p-4" }, ne = /* @__PURE__ */ S({
__name: "apiEditModal",
emits: ["add"],
setup(K, { expose: f, emit: v }) {
const b = v, h = c.getComponent("modal"), y = c.getComponent("form"), o = i(!1), _ = i([]), g = {
componentProps: { labelLayout: "fixed", labelWidth: "90px" }
}, e = w({
dataFormat: "JSON",
id: "",
method: "get",
params: {},
url: ""
}), C = [
{
field: "id",
label: "名称",
type: "input"
},
{
field: "url",
label: "请求地址",
type: "input"
},
{
componentProps: {
options: [
{
label: "get",
value: "get"
},
{
label: "post",
value: "post"
},
{
label: "put",
value: "put"
},
{
label: "delete",
value: "delete"
}
]
},
field: "method",
label: "请求方式",
type: "select"
},
{
componentProps: {
defaultValue: "JSON",
options: [
{
label: "JSON",
value: "JSON"
},
{
label: "FormData",
value: "FormData"
},
{
label: "Form",
value: "Form"
}
],
optionType: "button"
},
field: "dataFormat",
label: "数据格式",
type: "radio"
},
{
componentProps: {
dataType: "object",
placeholder: ""
},
field: "data",
label: "参数",
type: "EInputKv"
}
];
function V(t) {
t ? s(e, t) : s(e, {
id: `data_${T()}`,
method: "get",
paramsType: "params",
url: ""
}), o.value = !0;
}
function x() {
b("add", B(M(e))), m();
}
function m() {
o.value = !1, _.value = [];
}
async function F() {
const t = await q(e);
console.log(t);
}
return f({
handleOpen: V
}), (t, r) => (l(), d(n(h), {
modelValue: o.value,
"onUpdate:modelValue": r[0] || (r[0] = (a) => o.value = a),
title: "配置请求",
width: "850px",
footer: null,
"wrap-class-name": "epic-api-modal",
onClose: m,
onOk: x
}, {
default: u(() => [
p("div", I, [
o.value ? (l(), d(n(y), {
key: 0,
"component-schema": g
}, {
default: u(() => [
(l(), U(D, null, E(C, (a, k) => J(n(P), {
key: k,
modelValue: e[a.field],
"onUpdate:modelValue": (N) => e[a.field] = N,
"component-schema": { ...a }
}, null, 8, ["modelValue", "onUpdate:modelValue", "component-schema"])), 64))
]),
_: 1
})) : O("", !0),
p("div", null, [
p("div", {
class: "epic-api-modal-footer",
onClick: F
}, "请求测试")
])
])
]),
_: 1
}, 8, ["modelValue"]));
}
});
export {
ne as default
};