@opengis/admin 0.1.99 → 0.1.100

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,92 @@
1
+ import { _ as m, u as b, a as c } from "./import-file-DgJqxKyF.js";
2
+ import { resolveComponent as h, openBlock as i, createElementBlock as d, createElementVNode as a, createBlock as p, createCommentVNode as f } from "vue";
3
+ const g = {
4
+ data() {
5
+ return {
6
+ formValues: {},
7
+ scheme: null,
8
+ table: ""
9
+ };
10
+ },
11
+ mounted() {
12
+ this.getFormScheme();
13
+ },
14
+ methods: {
15
+ flattenMenu(t) {
16
+ const e = [];
17
+ return t.forEach((o) => {
18
+ o.menu ? e.push(...this.flattenMenu(o.menu)) : e.push(o);
19
+ }), e;
20
+ },
21
+ async getFormScheme() {
22
+ const t = this.flattenMenu(b.value);
23
+ t != null && t.length || this.$router.replace("/404");
24
+ const e = t == null ? void 0 : t.find((s) => {
25
+ var r, l;
26
+ return (s == null ? void 0 : s.path) == ((l = (r = this.$route) == null ? void 0 : r.query) == null ? void 0 : l.table);
27
+ });
28
+ e || this.$router.replace("/404");
29
+ const o = e == null ? void 0 : e.table;
30
+ this.table = o;
31
+ try {
32
+ const {
33
+ data: { form: s }
34
+ } = await c.get(`/api/template/table/${o}`), { data: r } = await c.get(`/api/template/form/${s}`);
35
+ this.scheme = (r == null ? void 0 : r.schema) || r;
36
+ } catch {
37
+ }
38
+ },
39
+ async createObject() {
40
+ try {
41
+ await this.$refs.form.doValidation(), await c.post(`/api/table/${this.table}`, this.formValues), await this.$router.back(), await this.$notify({
42
+ title: "Успішно!",
43
+ message: "Об'єкт успішно створено",
44
+ type: "success"
45
+ });
46
+ } catch {
47
+ this.$notify({
48
+ title: "Помилка!",
49
+ message: "Сталася помилка",
50
+ type: "error"
51
+ });
52
+ }
53
+ }
54
+ }
55
+ }, x = { style: { width: "calc(100vw - 260px)" } }, w = { class: "h-[76px] bg-gray-50 flex items-center justify-between px-[30px]" }, y = { class: "flex items-center gap-[6px]" }, k = {
56
+ style: { height: "calc(100vh - 150px)", width: "calc(100vw - 260px)" },
57
+ class: "bg-gray-50 p-[20px] flex"
58
+ }, v = { class: "bg-white w-full rounded-xl border p-[20px] overflow-auto [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar:horizontal]:h-[8px] [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500" };
59
+ function V(t, e, o, s, r, l) {
60
+ const u = h("VsForm");
61
+ return i(), d("div", x, [
62
+ a("div", w, [
63
+ e[3] || (e[3] = a("h2", { class: "text-xl font-medium" }, "Створити", -1)),
64
+ a("div", y, [
65
+ a("button", {
66
+ onClick: e[0] || (e[0] = (n) => t.$router.back()),
67
+ class: "py-2 px-3 flex items-center gap-x-2 text-sm font-medium rounded-lg border bg-white border-gray-100 text-gray-800 shadow focus:outline-none hover:bg-gray-50 hover:border-gray-100 duration-300"
68
+ }, " Скасувати "),
69
+ a("button", {
70
+ onClick: e[1] || (e[1] = (...n) => l.createObject && l.createObject(...n)),
71
+ class: "py-2 px-3 inline-flex items-center gap-x-2 text-sm font-medium rounded-lg border border-transparent bg-blue-600 text-white hover:bg-blue-700 hover:text-white duration-300"
72
+ }, " Зберегти ")
73
+ ])
74
+ ]),
75
+ a("div", k, [
76
+ a("div", v, [
77
+ r.scheme ? (i(), p(u, {
78
+ key: 0,
79
+ ref: "form",
80
+ scheme: r.scheme,
81
+ modelValue: r.formValues,
82
+ "onUpdate:modelValue": e[2] || (e[2] = (n) => r.formValues = n),
83
+ class: "p-0 mt-[20px]"
84
+ }, null, 8, ["scheme", "modelValue"])) : f("", !0)
85
+ ])
86
+ ])
87
+ ]);
88
+ }
89
+ const j = /* @__PURE__ */ m(g, [["render", V]]);
90
+ export {
91
+ j as default
92
+ };