@opengis/admin 0.2.131 → 0.2.132

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