epic-designer-gold 0.0.48 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/{attributeView-DvYRuXDB.js → attributeView-BhPj8bSe.js} +1 -1
  2. package/dist/{attributeView-CMbZBZIS.cjs → attributeView-C9gY9X-c.cjs} +1 -1
  3. package/dist/{index-WBW2xl-M.js → index-3ndHV3fl.js} +1 -1
  4. package/dist/index-B45xlt7e.js +4 -0
  5. package/dist/{index-BIfS14i1.cjs → index-BA5cmAC5.cjs} +1 -1
  6. package/dist/{index-2_PG24En.cjs → index-BmqAqj29.cjs} +1 -1
  7. package/dist/{index-CtK_8YxJ.cjs → index-C2HMY2I2.cjs} +2 -2
  8. package/dist/{index-C8eSqkwT.cjs → index-CE9DjYAW.cjs} +1 -1
  9. package/dist/{index-Bjj1uygU.js → index-CshPxldv.js} +1 -1
  10. package/dist/{index-FUj4O0Wm.cjs → index-CvF1WVts.cjs} +1 -1
  11. package/dist/{index-D0xByXxW.js → index-Cw3VVR9A.js} +1 -1
  12. package/dist/{index-SmoMBzHL.js → index-DMDLjlCJ.js} +1 -1
  13. package/dist/{index-Dy65ngnp.js → index-DNuLy9hB.js} +6 -6
  14. package/dist/{index-BsyFZeFI.cjs → index-DpitV6qp.cjs} +1 -1
  15. package/dist/{index-ijn3b5rF.js → index-DtWX93JN.js} +1 -1
  16. package/dist/{index-3oFTJubt.cjs → index-F6atymcD.cjs} +1 -1
  17. package/dist/index-G-yqaciQ.cjs +1 -0
  18. package/dist/{index-BizWKLWZ.js → index-N_JBxsiO.js} +1 -1
  19. package/dist/index-efmvTLGJ.js +194 -0
  20. package/dist/{index-zyeRTxj7.cjs → index-iQ5ZEvrv.cjs} +1 -1
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.js +1 -1
  23. package/dist/sign-BJBURbHk.js +218 -0
  24. package/dist/sign-Cn6LXVcp.cjs +1 -0
  25. package/dist/style.css +1 -1
  26. package/dist/{styleView-CF34Ddn9.cjs → styleView-Dew56dxa.cjs} +1 -1
  27. package/dist/{styleView-BbQxI-Nr.js → styleView-SPW99MRS.js} +1 -1
  28. package/dist/ui/elementPlus/index.cjs +1 -1
  29. package/dist/ui/elementPlus/index.js +42 -44
  30. package/package.json +1 -1
  31. package/dist/index-CqirvAEP.js +0 -4
  32. package/dist/index-DiYy4kUz.js +0 -228
  33. package/dist/index-YV7i1gyI.cjs +0 -1
  34. package/dist/sign-BRchUdJt.js +0 -156
  35. package/dist/sign-CnQtsTLr.cjs +0 -1
@@ -0,0 +1,194 @@
1
+ import { defineComponent as $, inject as w, resolveComponent as M, openBlock as m, createBlock as E, unref as n, isRef as k, withCtx as B, createElementVNode as c, normalizeClass as D, createVNode as s, createCommentVNode as I, createElementBlock as _, ref as z, reactive as N, onMounted as A, watch as L, provide as R, Fragment as T, renderList as j, toDisplayString as F, withDirectives as q, vShow as G, createTextVNode as H } from "vue";
2
+ import { d as J } from "./vuedraggable.umd-D2S7Eo7p.js";
3
+ import { p as v, E as S } from "./js.cookie-oHpRFPCO.js";
4
+ import { _ as y } from "./icon.vue_vue_type_script_setup_true_lang-D3QdcReY.js";
5
+ import { n as C } from "./index-DNuLy9hB.js";
6
+ import "element-plus";
7
+ import { _ as K } from "./_plugin-vue_export-helper-CHgC5LLL.js";
8
+ const P = {
9
+ key: 0,
10
+ class: "pl-4"
11
+ }, Q = /* @__PURE__ */ $({
12
+ name: "EOptionItem",
13
+ __name: "optionItem",
14
+ props: {
15
+ modelValue: {}
16
+ },
17
+ emits: ["update:modelValue"],
18
+ setup(x, { emit: g }) {
19
+ const b = x, f = v.getComponent("input"), r = w("tree", !1), i = C(b, "modelValue", g);
20
+ function h(t) {
21
+ const u = {
22
+ label: "",
23
+ value: ""
24
+ };
25
+ t.children ? t.children.push(u) : t.children = [u];
26
+ }
27
+ function o(t) {
28
+ i.value = i.value.filter((u, V) => V !== t);
29
+ }
30
+ return (t, u) => {
31
+ const V = M("EOptionItem");
32
+ return m(), E(n(J), {
33
+ modelValue: n(i),
34
+ "onUpdate:modelValue": u[0] || (u[0] = (l) => k(i) ? i.value = l : null),
35
+ "item-key": "id",
36
+ "component-data": {
37
+ type: "transition-group"
38
+ },
39
+ group: "option-list",
40
+ handle: ".handle",
41
+ animation: 200
42
+ }, {
43
+ item: B(({ element: l, index: a }) => [
44
+ c("div", null, [
45
+ c("div", {
46
+ class: D([n(r) ? "grid-cols-[16px_auto_auto_16px_16px]" : "grid-cols-[16px_auto_auto_16px]", "option-item text-16px grid text-$epic-text-secondary gap-2 items-center mb-2"])
47
+ }, [
48
+ s(n(y), {
49
+ class: "mr-2 cursor-move handle",
50
+ name: "icon--epic--drag"
51
+ }),
52
+ s(n(f), {
53
+ modelValue: l.label,
54
+ "onUpdate:modelValue": (e) => l.label = e,
55
+ value: l.label,
56
+ "onUpdate:value": (e) => l.label = e,
57
+ placeholder: "label"
58
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "value", "onUpdate:value"]),
59
+ s(n(f), {
60
+ modelValue: l.value,
61
+ "onUpdate:modelValue": (e) => l.value = e,
62
+ value: l.value,
63
+ "onUpdate:value": (e) => l.value = e,
64
+ placeholder: "value"
65
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "value", "onUpdate:value"]),
66
+ n(r) ? (m(), E(n(y), {
67
+ key: 0,
68
+ class: "cursor-pointer text-lg!",
69
+ name: "icon--epic--add-rounded",
70
+ onClick: (e) => h(l)
71
+ }, null, 8, ["onClick"])) : I("", !0),
72
+ s(n(y), {
73
+ class: "hover:text-red cursor-pointer",
74
+ name: "icon--epic--delete-outline-rounded",
75
+ onClick: (e) => o(a)
76
+ }, null, 8, ["onClick"])
77
+ ], 2),
78
+ l.children ? (m(), _("div", P, [
79
+ s(V, {
80
+ modelValue: l.children,
81
+ "onUpdate:modelValue": (e) => l.children = e
82
+ }, null, 8, ["modelValue", "onUpdate:modelValue"])
83
+ ])) : I("", !0)
84
+ ])
85
+ ]),
86
+ _: 1
87
+ }, 8, ["modelValue"]);
88
+ };
89
+ }
90
+ }), W = { class: "" }, X = { class: "epic-tabs-box" }, Y = ["title", "onClick"], Z = { key: 0 }, ee = { class: "py-4 my-2 text-center text-gray-400 bg-white" }, le = { key: 1 }, te = /* @__PURE__ */ $({
91
+ __name: "index",
92
+ props: {
93
+ tree: { type: Boolean },
94
+ modelValue: {},
95
+ dynamicId: {},
96
+ type: {}
97
+ },
98
+ emits: ["update:modelValue", "update:EOptionsEditor"],
99
+ setup(x, { emit: g }) {
100
+ const b = v.getComponent("button"), f = v.getComponent("select"), r = z([]), p = N({
101
+ title: "静态"
102
+ }), i = x, h = g;
103
+ S.on("deleteSourceData", (a) => {
104
+ t.value === a && (t.value = "", o.value = []);
105
+ }), S.on("updateSource", (a) => {
106
+ r.value = v.sourceData.map((e) => ({
107
+ ...e,
108
+ label: e.apiName,
109
+ value: e.id
110
+ }));
111
+ }), A(() => {
112
+ r.value = v.sourceData.map((a) => ({
113
+ ...a,
114
+ label: a.apiName,
115
+ value: a.id
116
+ }));
117
+ });
118
+ const o = C(i, "modelValue", h), t = C(i, "dynamicId", h);
119
+ L(
120
+ () => t.value,
121
+ async () => {
122
+ t.value ? p.title = "动态" : p.title = "静态";
123
+ },
124
+ {
125
+ immediate: !0
126
+ }
127
+ );
128
+ const u = [
129
+ {
130
+ title: "静态"
131
+ },
132
+ {
133
+ title: "动态"
134
+ }
135
+ ];
136
+ async function V(a) {
137
+ p.title = a.title, a.title === "静态" ? (o.value = [], t.value = "") : (o.value = [], r.value = v.sourceData.map((e) => ({
138
+ ...e,
139
+ label: e.apiName,
140
+ value: e.id
141
+ })));
142
+ }
143
+ i.modelValue, R("tree", i.tree);
144
+ function l() {
145
+ const a = N({
146
+ label: "",
147
+ value: ""
148
+ });
149
+ o.value.length ? o.value = [...o.value, a] : o.value = [a];
150
+ }
151
+ return (a, e) => {
152
+ var U;
153
+ return m(), _("div", W, [
154
+ c("div", null, [
155
+ c("div", X, [
156
+ (m(), _(T, null, j(u, (d, O) => c("div", {
157
+ class: D(["epic-tab cursor-pointer truncate", { checked: p.title === d.title }]),
158
+ key: O,
159
+ title: d.title,
160
+ onClick: (ae) => V(d)
161
+ }, F(d.title), 11, Y)), 64))
162
+ ]),
163
+ p.title === "静态" ? (m(), _("div", Z, [
164
+ q(c("div", ee, "暂无选项", 512), [
165
+ [G, !((U = n(o)) != null && U.length)]
166
+ ]),
167
+ s(Q, {
168
+ modelValue: n(o),
169
+ "onUpdate:modelValue": e[0] || (e[0] = (d) => k(o) ? o.value = d : null)
170
+ }, null, 8, ["modelValue"]),
171
+ s(n(b), { onClick: l }, {
172
+ default: B(() => e[2] || (e[2] = [
173
+ H("添加选项")
174
+ ])),
175
+ _: 1
176
+ })
177
+ ])) : (m(), _("div", le, [
178
+ e[3] || (e[3] = c("span", { style: { "font-size": "12px", "margin-bottom": "8px", display: "inline-block" } }, "数据源", -1)),
179
+ s(n(f), {
180
+ modelValue: n(t),
181
+ "onUpdate:modelValue": e[1] || (e[1] = (d) => k(t) ? t.value = d : null),
182
+ placeholder: "请选择数据源",
183
+ clearable: "",
184
+ options: r.value
185
+ }, null, 8, ["modelValue", "options"])
186
+ ]))
187
+ ])
188
+ ]);
189
+ };
190
+ }
191
+ }), ce = /* @__PURE__ */ K(te, [["__scopeId", "data-v-21fb2159"]]);
192
+ export {
193
+ ce as default
194
+ };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),F=require("./js.cookie-BH1G_HRi.cjs"),C=require("./index-CtK_8YxJ.cjs"),J=require("./icon.vue_vue_type_script_setup_true_lang-DJbUD5AQ.cjs"),G=require("./vuedraggable.umd-BqhSJIAi.cjs"),ee={class:"epic-widget-action-item whitespace-nowrap"},te={key:0,class:"flex items-center"},ne=e.defineComponent({__name:"previewWidgets",setup(A,{expose:R}){const u=e.inject("pageManager",{}),_=e.inject("pageSchema"),r=e.inject("designer"),h=e.inject("designerProps"),c=e.inject("revoke"),f=e.ref(null),w=e.ref(null),g=e.ref(null),M=e.ref(!1),l=e.ref(!1),a=e.ref(!0),i=e.ref("top"),{canvasScale:s,disabledZoom:k}=C.useStore();let n=null;const L=e.computed(()=>{const t=r.state.checkedNode;return!(!(t!=null&&t.id)||h.value.lockDefaultSchemaEdit&&u.defaultComponentIds.value.includes(t==null?void 0:t.id))}),T=e.computed(()=>{var S,N,V,m,O,H;const t=u.componentInstances.value,d=(S=r.state.checkedNode)==null?void 0:S.id;if((V=(N=r.state.checkedNode)==null?void 0:N.componentProps)!=null&&V.hidden)return null;const y=F.pluginManager.getComponentConfingByType((m=r.state.checkedNode)==null?void 0:m.type)??null;if(!d||!(t!=null&&t[d]))return null;if(y!=null&&y.defaultSchema.input&&((O=r.state.checkedNode)==null?void 0:O.noFormItem)!==!0)return(H=t[d+"formItem"])==null?void 0:H.$el;const o=t[d];return!(o!=null&&o.$el)||(o==null?void 0:o.$el.nodeName)==="#text"||!(o!=null&&o.$el.getBoundingClientRect)?null:o==null?void 0:o.$el}),B=e.computed(()=>{var S,N,V,m;const t=u.componentInstances.value,d=(S=r.state.hoverNode)==null?void 0:S.id,y=F.pluginManager.getComponentConfingByType((N=r.state.hoverNode)==null?void 0:N.type)??null;if(!d||!(t!=null&&t[d]))return null;if(y!=null&&y.defaultSchema.input&&((V=r.state.hoverNode)==null?void 0:V.noFormItem)!==!0)return(m=t[d+"formItem"])==null?void 0:m.$el;const o=t[d];return(o==null?void 0:o.$el.nodeName)==="#text"?null:o==null?void 0:o.$el}),{mutationObserver:p,observerConfig:x}=Z(j),{startTimedQuery:v,stopTimedQuery:z}=C.useTimedQuery(j);e.watch(()=>T.value,t=>{if(t){M.value=!0,p.observe(t,x);const d=t.parentNode;d&&(d.ondragstart=()=>{a.value=!1,v()},d.ondragend=()=>{a.value=!0,z()}),j()}else M.value=!1});const{mutationObserver:P,observerConfig:E}=Z(q);e.watch(()=>B.value,t=>{t&&(P.observe(t,E),q())});let b=0;e.watch(()=>{var t;return(t=r.state.hoverNode)==null?void 0:t.id},t=>{if(t){l.value=!0,clearTimeout(b);return}b=setTimeout(()=>{l.value=!1},300)});let $=0,D=0;function j(){const t=T.value;if(!t||!n)return;const{top:d,left:y}=n==null?void 0:n.getBoundingClientRect(),{top:o,left:S,width:N,height:V}=t.getBoundingClientRect(),m=k.value?1:s.value,O=o-d+((n==null?void 0:n.scrollTop)??0)*m,H=S-y+((n==null?void 0:n.scrollLeft)??0)*m,W=V/m;f.value&&(f.value.style.width=`${N/m}px`,f.value.style.height=`${W}px`,f.value.style.top=`${O/m}px`,f.value.style.left=`${H/m}px`,I(O,H)),g.value&&(O<45&&W<100?(g.value.style.top="",g.value.style.bottom="-30px",g.value.style["border-radius"]="0px 0px 4px 4px",i.value="bottom"):O<45?(g.value.style.top="0px",g.value.style["border-radius"]="0px 0px 4px 0",i.value="center"):(g.value.style.top="-30px",g.value.style["border-radius"]="4px 4px 0px 0px",i.value="top"))}function I(t,d){const y=T.value;if(!n||!y)return;const o=n.getBoundingClientRect(),{width:S}=y.getBoundingClientRect(),N=k.value?1:s.value,V=t/N-o.top;let m=d/N-o.left+S/N;m<o.width&&(m=0);const O=n.scrollTop-o.height/3+60,H=n.scrollTop+o.height/3*2,W=n.scrollLeft-o.width+200,U=n.scrollLeft+o.width-200;Math.abs(V-$)<10&&Math.abs(m-D)<10||($=V,D=m,!(V>O&&V<H&&m>W&&m<U)&&(n.scrollTop=V,n.scrollLeft=m))}function q(){var W,U;const t=B.value;if(!t)return;const{top:d,left:y}=(n==null?void 0:n.getBoundingClientRect())??{top:0,left:0},{top:o,left:S,width:N,height:V}=((W=t.getBoundingClientRect)==null?void 0:W.call(t))??((U=t.nextElementSibling)==null?void 0:U.getBoundingClientRect()),m=k.value?1:s.value,O=o-d+((n==null?void 0:n.scrollTop)??0)*m,H=S-y+((n==null?void 0:n.scrollLeft)??0)*m;w.value&&(w.value.style.width=`${N/m}px`,w.value.style.height=`${V/m}px`,w.value.style.top=`${O/m}px`,w.value.style.left=`${H/m}px`)}function Z(t){const d=window.MutationObserver,y={childList:!0,attributes:!0,subtree:!0};return{mutationObserver:new d(t),observerConfig:y}}function K(){var N;const t=C.findSchemaInfoById(_.schemas,((N=r.state.checkedNode)==null?void 0:N.id)??"root");if(!t)return!1;const{list:d,schema:y,index:o}=t,S=C.generateNewSchema(y);d.splice(o+1,0,S),r.setCheckedNode(S),c.push(_.schemas,"复制组件")}function X(){var S;const t=C.findSchemaInfoById(_.schemas,((S=r.state.checkedNode)==null?void 0:S.id)??"root");if(!t)return!1;let{list:d,schema:y,index:o}=t;d.splice(o,1),o===d.length&&o--,r.setCheckedNode(d[o]),c.push(_.schemas,"删除组件")}function Y(t){n=t,n==null||n.addEventListener("scroll",()=>{j()}),C.useResizeObserver(T,j),C.useResizeObserver(B,q)}return R({handleInit:Y}),(t,d)=>{var y,o,S,N,V;return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.withDirectives(e.createElementVNode("div",{ref_key:"selectorRef",ref:f,class:e.normalizeClass(["epic-checked-widget absolute pointer-events-none z-20",i.value+" "+(a.value?"transition-all":"")])},[e.createElementVNode("div",{class:"epic-widget-action-box",ref_key:"actionBoxRef",ref:g},[e.createElementVNode("div",ee,e.toDisplayString((o=e.unref(F.pluginManager).getComponentConfingByType(((y=e.unref(r).state.checkedNode)==null?void 0:y.type)??""))==null?void 0:o.defaultSchema.label),1),L.value?(e.openBlock(),e.createElementBlock("div",te,[e.createElementVNode("div",{title:"复制",class:"epic-widget-action-item pointer-events-auto",onClick:K},[e.createVNode(e.unref(J._sfc_main),{name:"icon--epic--copy-all-outline-rounded"})]),e.createElementVNode("div",{title:"删除",class:"epic-widget-action-item pointer-events-auto",onClick:X},[e.createVNode(e.unref(J._sfc_main),{name:"icon--epic--delete-outline-rounded"})])])):e.createCommentVNode("",!0)],512)],2),[[e.vShow,M.value&&((S=e.unref(r).state.checkedNode)==null?void 0:S.id)!=="root"]]),e.withDirectives(e.createElementVNode("div",{ref_key:"hoverWidgetRef",ref:w,class:"epic-hover-widget absolute transition-all pointer-events-none z-998"},null,512),[[e.vShow,l.value&&((N=e.unref(r).state.checkedNode)==null?void 0:N.id)!==((V=e.unref(r).state.hoverNode)==null?void 0:V.id)]])],64)}}}),oe=e.defineComponent({name:"EditNodeItem",__name:"editNodeItem",props:{schemas:{}},emits:["update:schemas"],setup(A,{emit:R}){const u=e.inject("designer"),_=e.inject("pageSchema"),r=e.inject("revoke"),h=A,c=R,f=e.computed({get(){return h.schemas},set(a){c("update:schemas",a)}});function w(a){u.setCheckedNode(f.value[a]),u.setDisableHover(!0)}function g(){u.setDisableHover(),r.push(_.schemas,"拖拽组件")}function M(){r.push(_.schemas,"插入组件")}function l(a){var i,s,k;return a.id===((i=_.schemas[0])==null?void 0:i.id)||(k=(s=F.pluginManager.getComponentConfingByType(a.type))==null?void 0:s.editConstraints)!=null&&k.immovable?"unmover-item":"draggable-item"}return(a,i)=>(e.openBlock(),e.createBlock(e.unref(G.draggable),e.mergeProps({modelValue:f.value,"onUpdate:modelValue":i[0]||(i[0]=s=>f.value=s),"item-key":"id","component-data":{type:"transition-group"},class:"epic-draggable-range"},{animation:200,group:"edit-draggable",handle:".draggable-item",ghostClass:"moveing"},{onStart:i[1]||(i[1]=s=>w(s.oldIndex)),onEnd:i[2]||(i[2]=s=>g()),onAdd:i[3]||(i[3]=s=>{w(s.newIndex),M()})}),{item:e.withCtx(({element:s,index:k})=>[(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["widget-box",l(s)]),key:k},[e.createVNode(Q,{schema:s},null,8,["schema"])],2))]),_:1},16,["modelValue"]))}}),Q=e.defineComponent({name:"ENodeItem",__name:"nodeItem",props:{schema:{},name:{}},setup(A){const R=e.useAttrs(),u=e.inject("designer"),_=e.inject("pageManager",{}),r=e.inject("pageSchema",{}),h=e.ref(null);e.provide("nodeAttrs",R);const c=A,f=e.computed(()=>{var k,n,L,T,B;const l=_.componentInstances.value,a=(k=c.schema)==null?void 0:k.id,i=F.pluginManager.getComponentConfingByType((n=c.schema)==null?void 0:n.type)??null;if(!a||!(l!=null&&l[a]))return null;if(i!=null&&i.defaultSchema.input&&((L=c.schema)==null?void 0:L.noFormItem)!==!0)return(T=l[a+"formItem"])==null?void 0:T.$el;const s=l[a];return((B=s==null?void 0:s.$el)==null?void 0:B.nodeName)==="#text"?null:s==null?void 0:s.$el});e.watch(()=>f.value,l=>{l==null||l.addEventListener("click",w,!1),l==null||l.addEventListener("mouseover",g,!1),l==null||l.addEventListener("mouseout",M,!1)}),e.onUnmounted(()=>{var l,a,i;(l=f.value)==null||l.removeEventListener("click",w,!1),(a=f.value)==null||a.removeEventListener("mouseover",g,!1),(i=f.value)==null||i.removeEventListener("mouseout",M,!1)});function w(l){l.stopPropagation(),u.setCheckedNode(c.schema)}function g(l){var a;c.schema.id!==((a=r.schemas[0])==null?void 0:a.id)&&(l.stopPropagation(),u.setHoverNode(c.schema))}function M(l){l.stopPropagation(),u.setHoverNode(null)}return(l,a)=>{var s,k;const i=e.resolveComponent("ENodeItem");return e.openBlock(),e.createBlock(e.unref(C._sfc_main),{ref_key:"nodeRef",ref:h,componentSchema:c.schema},e.createSlots({_:2},[(k=(s=e.unref(F.pluginManager).getComponentConfingByType(c.schema.type))==null?void 0:s.editConstraints)!=null&&k.childImmovable?{name:"edit-node",fn:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.schema.children,n=>(e.openBlock(),e.createBlock(i,{key:n.id,schema:n},null,8,["schema"]))),128))]),key:"0"}:{name:"edit-node",fn:e.withCtx(()=>[c.schema.children?(e.openBlock(),e.createBlock(oe,{key:0,schemas:c.schema.children,"onUpdate:schemas":a[0]||(a[0]=n=>c.schema.children=n)},null,8,["schemas"])):e.createCommentVNode("",!0)]),key:"1"}]),1032,["componentSchema"])}}}),le={class:"min-w-750px rounded h-full"},ae=e.defineComponent({__name:"previewJson",setup(A,{expose:R}){const u=F.pluginManager.getComponent("modal"),_=F.pluginManager.getComponent("monacoEditor"),r={theme:"vs-light",selectOnLineNumbers:!0,minimap:{enabled:!1},readOnly:!0},h=e.ref(null),c=e.ref(!1),f=e.inject("pageSchema");function w(){c.value=!1}function g(){c.value=!0,h.value?h.value.setValue(JSON.stringify(f,null,2)):setTimeout(()=>{g()},300)}function M(l="epic-data.json"){const a=JSON.stringify(f,null,2);var i=`data:text/json;charset=utf-8,${encodeURIComponent(a)}`,s=document.createElement("a");s.setAttribute("href",i),s.setAttribute("download",l),s.click()}return R({handleOpen:g}),(l,a)=>(e.openBlock(),e.createBlock(e.unref(u),{modelValue:c.value,"onUpdate:modelValue":a[0]||(a[0]=i=>c.value=i),title:"查看数据",class:"w-900px",width:"900px",onClose:w,onOk:M,okText:"导出数据"},{default:e.withCtx(()=>[e.createElementVNode("div",le,[e.createVNode(e.unref(_),{ref_key:"monacoEditorRef",ref:h,class:"editor h-full",autoToggleTheme:"",readOnly:"",config:r,language:"json"},null,512)])]),_:1},8,["modelValue"]))}}),se={class:"epic-edit-toolbar flex items-center justify-between px-2"},re={class:"flex-1 h-full flex items-center"},ie={key:0,class:"epic-divider"},ce=["title","onClick"],de={class:"flex-1 h-full flex items-center justify-end"},ue={key:0,class:"flex items-center ml-12px"},fe={class:"pr-8px w-82px cursor-pointer"},me={class:"epic-device h-28px items-center gap-1 rounded-md border p-2px flex"},ve=["title","onClick"],pe=e.defineComponent({__name:"toolbar",setup(A){const R=F.pluginManager.getComponent("select"),{canvasScale:u,disabledZoom:_}=C.useStore(),r=e.ref("pc"),h=e.inject("pageSchema"),c=e.inject("designer"),f=e.inject("revoke"),w=e.ref(null),g=[{icon:"icon--epic--computer-outline-rounded",title:"pc",key:"pc"}],M=e.computed(()=>[{icon:"icon--epic--trash",title:"清空",on:n},{icon:"icon--epic--undo",title:"撤销",on:s,disabled:!f.recordList.value.length,divider:!0},{icon:"icon--epic--redo",title:"重做",on:k,disabled:!f.undoList.value.length}]),l=e.ref(null),a=e.computed({get(){return`${(u.value*100).toFixed(0)}%`},set(p){const x=parseFloat(p);u.value=x/100}}),i=[{label:"60%",value:"60%"},{label:"80%",value:"80%"},{label:"100%",value:"100%"},{label:"120%",value:"120%"},{label:"140%",value:"140%"}];function s(){const p=f.undo();p&&(C.deepCompareAndModify(h.schemas,p),c.setCheckedNode(h.schemas[0]))}function k(){const p=f.redo();p&&(C.deepCompareAndModify(h.schemas,p),c.setCheckedNode(h.schemas[0]))}function n(){c.reset()}function L(p){var z;const x=(z=p.target.files)==null?void 0:z[0];if(!x)return;p.target.value=null;const v=new FileReader;v.readAsText(x),v.onload=P=>{var E;T((E=P.target)==null?void 0:E.result)}}function T(p){try{let x=JSON.parse(p??"");x.schemas||(x=C.convertKFormData(x)),C.deepCompareAndModify(h,x)}catch(x){console.error(x)}}function B(p){c.handleToggleDeviceMode(p),r.value=p;const x={pc:{},pad:{width:"780px",mode:p},mobile:{width:"390px",mode:p}};h.canvas=x[p]}return(p,x)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",se,[e.createElementVNode("div",re,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(M.value,(v,z)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:z},[v.divider?(e.openBlock(),e.createElementBlock("div",ie)):e.createCommentVNode("",!0),e.createElementVNode("div",{title:v.title,class:e.normalizeClass(["epic-action-item text-base h-90% px-10px flex items-center cursor-pointer",{disabled:v.disabled}]),onClick:v.on},[e.createVNode(e.unref(J._sfc_main),{name:v.icon},null,8,["name"])],10,ce)],64))),128))]),e.withDirectives(e.createElementVNode("input",{type:"file",ref_key:"fileRef",ref:l,accept:".json,.txt",onChange:L},null,544),[[e.vShow,!1]]),e.createElementVNode("div",de,[e.unref(_)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",ue,[e.createElementVNode("div",fe,[e.createVNode(e.unref(R),{value:a.value,"onUpdate:value":x[0]||(x[0]=v=>a.value=v),modelValue:a.value,"onUpdate:modelValue":x[1]||(x[1]=v=>a.value=v),options:i,size:"small"},null,8,["value","modelValue"])])])),e.createElementVNode("div",me,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(g,v=>e.createElementVNode("div",{key:v.key,title:v.title,class:e.normalizeClass(["epic-device-item h-full px-1 flex items-center cursor-pointer text-base transition-colors rounded-sm",{checked:v.key===r.value}]),onClick:z=>B(v.key)},[e.createVNode(e.unref(J._sfc_main),{name:v.icon},null,8,["name"])],10,ve)),64))])])]),e.createVNode(ae,{ref_key:"previewJson",ref:w},null,512)],64))}}),he={class:"h-full flex flex-col relative"},ge=["draggable"],xe=e.defineComponent({__name:"editScreenContainer",setup(A){const R=e.inject("pageSchema"),u=e.ref(null),_=e.ref(null),r=e.ref(null),{pressSpace:h,disabledZoom:c}=C.useStore(),{handleElementDragStart:f,handleElementDrag:w,handleElementDragEnd:g}=C.useElementDrag(u),{width:M,height:l}=C.useElementSize(u),{canvasScale:a,handleZoom:i}=C.useElementZoom(_);let s=0,k=0;const n=e.ref({}),L=e.ref({}),T=e.ref({}),B=e.shallowRef({width:0,height:0});e.watchEffect(x),e.watch(T,()=>{e.nextTick(p)});function p(){r.value&&(B.value={width:r.value.clientWidth,height:r.value.clientHeight})}function x(){var E,b;T.value={width:((E=R.canvas)==null?void 0:E.width)??"0",height:((b=R.canvas)==null?void 0:b.height)??"0"}}C.watchOnce(M,v),e.watch(B,v);function v(){let E=B.value.width||s,b=B.value.height||k;n.value={width:M.value+E+"px",height:l.value+b+"px"},L.value={width:E+"px",height:b+"px"},z()}function z(){e.nextTick(()=>{var j;let E=B.value.width||s;const $=(B.value.height||k)/2,D=E/2;(j=u.value)==null||j.scrollTo(D,$)})}C.useResizeObserver(u,P),C.useResizeObserver(_,P);function P(){var b;if(!u.value)return;const E=u.value.getBoundingClientRect();if(s=E.width-60,k=E.height-80,!c.value)if(B.value.width===0)a.value=1;else{const $=(s-20)/B.value.width,D=k/(B.value.height||((b=_.value)==null?void 0:b.clientHeight)||1),j=Math.abs($-1)<Math.abs(D-1);let I=1;j?I=$:I=D,($<1||D<1)&&(I=Math.min($,D)),I<1.4&&I>.5&&(a.value=I)}C.debounce(v,50)()}return(E,b)=>(e.openBlock(),e.createElementBlock("div",he,[e.createVNode(pe),e.createElementVNode("div",{ref_key:"editScreenContainerRef",ref:u,class:e.normalizeClass(["flex-1 overflow-auto overflow-y-hidden epic-edit-screen-container",{"cursor-grab":e.unref(h)}]),draggable:e.unref(h),onWheel:b[0]||(b[0]=(...$)=>e.unref(i)&&e.unref(i)(...$)),onDragstart:b[1]||(b[1]=(...$)=>e.unref(f)&&e.unref(f)(...$)),onDragend:b[2]||(b[2]=(...$)=>e.unref(g)&&e.unref(g)(...$)),onDrag:b[3]||(b[3]=(...$)=>e.unref(w)&&e.unref(w)(...$))},[e.createElementVNode("div",{id:"canvasContainer",class:"flex items-center justify-center",style:e.normalizeStyle(n.value)},[e.createElementVNode("div",{ref_key:"draggableElRef",ref:_,class:"transition-all"},[e.createElementVNode("div",{class:e.normalizeClass({"pointer-events-none":e.unref(h)}),style:e.normalizeStyle(L.value)},[e.renderSlot(E.$slots,"default")],6)],512)],4)],42,ge),e.createElementVNode("div",{ref_key:"sizeBoxRef",ref:r,class:"absolute top-0 pointer-events-none",style:e.normalizeStyle(T.value)},null,4)]))}}),ye={class:"epic-edit-canvas"},_e=e.defineComponent({__name:"index",setup(A){const R=e.ref(null),u=e.ref(null),_=e.inject("pageSchema"),r=e.computed(()=>_.schemas[0]),h=e.computed(()=>({width:"100%",height:"100%"}));return e.onMounted(()=>{var c;(c=u.value)==null||c.handleInit(R.value)}),(c,f)=>(e.openBlock(),e.createElementBlock("section",ye,[e.createVNode(xe,null,{default:e.withCtx(()=>[e.createElementVNode("div",{ref_key:"epicEditRangeRef",ref:R,class:"epic-edit-range rounded-md overflow-auto relative",style:e.normalizeStyle(h.value)},[e.createVNode(Q,{schema:r.value},null,8,["schema"]),e.createVNode(ne,{ref_key:"ePreviewWidgetsRef",ref:u},null,512)],4)]),_:1})]))}});exports.default=_e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),F=require("./js.cookie-BH1G_HRi.cjs"),C=require("./index-C2HMY2I2.cjs"),J=require("./icon.vue_vue_type_script_setup_true_lang-DJbUD5AQ.cjs"),G=require("./vuedraggable.umd-BqhSJIAi.cjs"),ee={class:"epic-widget-action-item whitespace-nowrap"},te={key:0,class:"flex items-center"},ne=e.defineComponent({__name:"previewWidgets",setup(A,{expose:R}){const u=e.inject("pageManager",{}),_=e.inject("pageSchema"),r=e.inject("designer"),h=e.inject("designerProps"),c=e.inject("revoke"),f=e.ref(null),w=e.ref(null),g=e.ref(null),M=e.ref(!1),l=e.ref(!1),a=e.ref(!0),i=e.ref("top"),{canvasScale:s,disabledZoom:k}=C.useStore();let n=null;const L=e.computed(()=>{const t=r.state.checkedNode;return!(!(t!=null&&t.id)||h.value.lockDefaultSchemaEdit&&u.defaultComponentIds.value.includes(t==null?void 0:t.id))}),T=e.computed(()=>{var S,N,V,m,O,H;const t=u.componentInstances.value,d=(S=r.state.checkedNode)==null?void 0:S.id;if((V=(N=r.state.checkedNode)==null?void 0:N.componentProps)!=null&&V.hidden)return null;const y=F.pluginManager.getComponentConfingByType((m=r.state.checkedNode)==null?void 0:m.type)??null;if(!d||!(t!=null&&t[d]))return null;if(y!=null&&y.defaultSchema.input&&((O=r.state.checkedNode)==null?void 0:O.noFormItem)!==!0)return(H=t[d+"formItem"])==null?void 0:H.$el;const o=t[d];return!(o!=null&&o.$el)||(o==null?void 0:o.$el.nodeName)==="#text"||!(o!=null&&o.$el.getBoundingClientRect)?null:o==null?void 0:o.$el}),B=e.computed(()=>{var S,N,V,m;const t=u.componentInstances.value,d=(S=r.state.hoverNode)==null?void 0:S.id,y=F.pluginManager.getComponentConfingByType((N=r.state.hoverNode)==null?void 0:N.type)??null;if(!d||!(t!=null&&t[d]))return null;if(y!=null&&y.defaultSchema.input&&((V=r.state.hoverNode)==null?void 0:V.noFormItem)!==!0)return(m=t[d+"formItem"])==null?void 0:m.$el;const o=t[d];return(o==null?void 0:o.$el.nodeName)==="#text"?null:o==null?void 0:o.$el}),{mutationObserver:p,observerConfig:x}=Z(j),{startTimedQuery:v,stopTimedQuery:z}=C.useTimedQuery(j);e.watch(()=>T.value,t=>{if(t){M.value=!0,p.observe(t,x);const d=t.parentNode;d&&(d.ondragstart=()=>{a.value=!1,v()},d.ondragend=()=>{a.value=!0,z()}),j()}else M.value=!1});const{mutationObserver:P,observerConfig:E}=Z(q);e.watch(()=>B.value,t=>{t&&(P.observe(t,E),q())});let b=0;e.watch(()=>{var t;return(t=r.state.hoverNode)==null?void 0:t.id},t=>{if(t){l.value=!0,clearTimeout(b);return}b=setTimeout(()=>{l.value=!1},300)});let $=0,D=0;function j(){const t=T.value;if(!t||!n)return;const{top:d,left:y}=n==null?void 0:n.getBoundingClientRect(),{top:o,left:S,width:N,height:V}=t.getBoundingClientRect(),m=k.value?1:s.value,O=o-d+((n==null?void 0:n.scrollTop)??0)*m,H=S-y+((n==null?void 0:n.scrollLeft)??0)*m,W=V/m;f.value&&(f.value.style.width=`${N/m}px`,f.value.style.height=`${W}px`,f.value.style.top=`${O/m}px`,f.value.style.left=`${H/m}px`,I(O,H)),g.value&&(O<45&&W<100?(g.value.style.top="",g.value.style.bottom="-30px",g.value.style["border-radius"]="0px 0px 4px 4px",i.value="bottom"):O<45?(g.value.style.top="0px",g.value.style["border-radius"]="0px 0px 4px 0",i.value="center"):(g.value.style.top="-30px",g.value.style["border-radius"]="4px 4px 0px 0px",i.value="top"))}function I(t,d){const y=T.value;if(!n||!y)return;const o=n.getBoundingClientRect(),{width:S}=y.getBoundingClientRect(),N=k.value?1:s.value,V=t/N-o.top;let m=d/N-o.left+S/N;m<o.width&&(m=0);const O=n.scrollTop-o.height/3+60,H=n.scrollTop+o.height/3*2,W=n.scrollLeft-o.width+200,U=n.scrollLeft+o.width-200;Math.abs(V-$)<10&&Math.abs(m-D)<10||($=V,D=m,!(V>O&&V<H&&m>W&&m<U)&&(n.scrollTop=V,n.scrollLeft=m))}function q(){var W,U;const t=B.value;if(!t)return;const{top:d,left:y}=(n==null?void 0:n.getBoundingClientRect())??{top:0,left:0},{top:o,left:S,width:N,height:V}=((W=t.getBoundingClientRect)==null?void 0:W.call(t))??((U=t.nextElementSibling)==null?void 0:U.getBoundingClientRect()),m=k.value?1:s.value,O=o-d+((n==null?void 0:n.scrollTop)??0)*m,H=S-y+((n==null?void 0:n.scrollLeft)??0)*m;w.value&&(w.value.style.width=`${N/m}px`,w.value.style.height=`${V/m}px`,w.value.style.top=`${O/m}px`,w.value.style.left=`${H/m}px`)}function Z(t){const d=window.MutationObserver,y={childList:!0,attributes:!0,subtree:!0};return{mutationObserver:new d(t),observerConfig:y}}function K(){var N;const t=C.findSchemaInfoById(_.schemas,((N=r.state.checkedNode)==null?void 0:N.id)??"root");if(!t)return!1;const{list:d,schema:y,index:o}=t,S=C.generateNewSchema(y);d.splice(o+1,0,S),r.setCheckedNode(S),c.push(_.schemas,"复制组件")}function X(){var S;const t=C.findSchemaInfoById(_.schemas,((S=r.state.checkedNode)==null?void 0:S.id)??"root");if(!t)return!1;let{list:d,schema:y,index:o}=t;d.splice(o,1),o===d.length&&o--,r.setCheckedNode(d[o]),c.push(_.schemas,"删除组件")}function Y(t){n=t,n==null||n.addEventListener("scroll",()=>{j()}),C.useResizeObserver(T,j),C.useResizeObserver(B,q)}return R({handleInit:Y}),(t,d)=>{var y,o,S,N,V;return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.withDirectives(e.createElementVNode("div",{ref_key:"selectorRef",ref:f,class:e.normalizeClass(["epic-checked-widget absolute pointer-events-none z-20",i.value+" "+(a.value?"transition-all":"")])},[e.createElementVNode("div",{class:"epic-widget-action-box",ref_key:"actionBoxRef",ref:g},[e.createElementVNode("div",ee,e.toDisplayString((o=e.unref(F.pluginManager).getComponentConfingByType(((y=e.unref(r).state.checkedNode)==null?void 0:y.type)??""))==null?void 0:o.defaultSchema.label),1),L.value?(e.openBlock(),e.createElementBlock("div",te,[e.createElementVNode("div",{title:"复制",class:"epic-widget-action-item pointer-events-auto",onClick:K},[e.createVNode(e.unref(J._sfc_main),{name:"icon--epic--copy-all-outline-rounded"})]),e.createElementVNode("div",{title:"删除",class:"epic-widget-action-item pointer-events-auto",onClick:X},[e.createVNode(e.unref(J._sfc_main),{name:"icon--epic--delete-outline-rounded"})])])):e.createCommentVNode("",!0)],512)],2),[[e.vShow,M.value&&((S=e.unref(r).state.checkedNode)==null?void 0:S.id)!=="root"]]),e.withDirectives(e.createElementVNode("div",{ref_key:"hoverWidgetRef",ref:w,class:"epic-hover-widget absolute transition-all pointer-events-none z-998"},null,512),[[e.vShow,l.value&&((N=e.unref(r).state.checkedNode)==null?void 0:N.id)!==((V=e.unref(r).state.hoverNode)==null?void 0:V.id)]])],64)}}}),oe=e.defineComponent({name:"EditNodeItem",__name:"editNodeItem",props:{schemas:{}},emits:["update:schemas"],setup(A,{emit:R}){const u=e.inject("designer"),_=e.inject("pageSchema"),r=e.inject("revoke"),h=A,c=R,f=e.computed({get(){return h.schemas},set(a){c("update:schemas",a)}});function w(a){u.setCheckedNode(f.value[a]),u.setDisableHover(!0)}function g(){u.setDisableHover(),r.push(_.schemas,"拖拽组件")}function M(){r.push(_.schemas,"插入组件")}function l(a){var i,s,k;return a.id===((i=_.schemas[0])==null?void 0:i.id)||(k=(s=F.pluginManager.getComponentConfingByType(a.type))==null?void 0:s.editConstraints)!=null&&k.immovable?"unmover-item":"draggable-item"}return(a,i)=>(e.openBlock(),e.createBlock(e.unref(G.draggable),e.mergeProps({modelValue:f.value,"onUpdate:modelValue":i[0]||(i[0]=s=>f.value=s),"item-key":"id","component-data":{type:"transition-group"},class:"epic-draggable-range"},{animation:200,group:"edit-draggable",handle:".draggable-item",ghostClass:"moveing"},{onStart:i[1]||(i[1]=s=>w(s.oldIndex)),onEnd:i[2]||(i[2]=s=>g()),onAdd:i[3]||(i[3]=s=>{w(s.newIndex),M()})}),{item:e.withCtx(({element:s,index:k})=>[(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["widget-box",l(s)]),key:k},[e.createVNode(Q,{schema:s},null,8,["schema"])],2))]),_:1},16,["modelValue"]))}}),Q=e.defineComponent({name:"ENodeItem",__name:"nodeItem",props:{schema:{},name:{}},setup(A){const R=e.useAttrs(),u=e.inject("designer"),_=e.inject("pageManager",{}),r=e.inject("pageSchema",{}),h=e.ref(null);e.provide("nodeAttrs",R);const c=A,f=e.computed(()=>{var k,n,L,T,B;const l=_.componentInstances.value,a=(k=c.schema)==null?void 0:k.id,i=F.pluginManager.getComponentConfingByType((n=c.schema)==null?void 0:n.type)??null;if(!a||!(l!=null&&l[a]))return null;if(i!=null&&i.defaultSchema.input&&((L=c.schema)==null?void 0:L.noFormItem)!==!0)return(T=l[a+"formItem"])==null?void 0:T.$el;const s=l[a];return((B=s==null?void 0:s.$el)==null?void 0:B.nodeName)==="#text"?null:s==null?void 0:s.$el});e.watch(()=>f.value,l=>{l==null||l.addEventListener("click",w,!1),l==null||l.addEventListener("mouseover",g,!1),l==null||l.addEventListener("mouseout",M,!1)}),e.onUnmounted(()=>{var l,a,i;(l=f.value)==null||l.removeEventListener("click",w,!1),(a=f.value)==null||a.removeEventListener("mouseover",g,!1),(i=f.value)==null||i.removeEventListener("mouseout",M,!1)});function w(l){l.stopPropagation(),u.setCheckedNode(c.schema)}function g(l){var a;c.schema.id!==((a=r.schemas[0])==null?void 0:a.id)&&(l.stopPropagation(),u.setHoverNode(c.schema))}function M(l){l.stopPropagation(),u.setHoverNode(null)}return(l,a)=>{var s,k;const i=e.resolveComponent("ENodeItem");return e.openBlock(),e.createBlock(e.unref(C._sfc_main),{ref_key:"nodeRef",ref:h,componentSchema:c.schema},e.createSlots({_:2},[(k=(s=e.unref(F.pluginManager).getComponentConfingByType(c.schema.type))==null?void 0:s.editConstraints)!=null&&k.childImmovable?{name:"edit-node",fn:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.schema.children,n=>(e.openBlock(),e.createBlock(i,{key:n.id,schema:n},null,8,["schema"]))),128))]),key:"0"}:{name:"edit-node",fn:e.withCtx(()=>[c.schema.children?(e.openBlock(),e.createBlock(oe,{key:0,schemas:c.schema.children,"onUpdate:schemas":a[0]||(a[0]=n=>c.schema.children=n)},null,8,["schemas"])):e.createCommentVNode("",!0)]),key:"1"}]),1032,["componentSchema"])}}}),le={class:"min-w-750px rounded h-full"},ae=e.defineComponent({__name:"previewJson",setup(A,{expose:R}){const u=F.pluginManager.getComponent("modal"),_=F.pluginManager.getComponent("monacoEditor"),r={theme:"vs-light",selectOnLineNumbers:!0,minimap:{enabled:!1},readOnly:!0},h=e.ref(null),c=e.ref(!1),f=e.inject("pageSchema");function w(){c.value=!1}function g(){c.value=!0,h.value?h.value.setValue(JSON.stringify(f,null,2)):setTimeout(()=>{g()},300)}function M(l="epic-data.json"){const a=JSON.stringify(f,null,2);var i=`data:text/json;charset=utf-8,${encodeURIComponent(a)}`,s=document.createElement("a");s.setAttribute("href",i),s.setAttribute("download",l),s.click()}return R({handleOpen:g}),(l,a)=>(e.openBlock(),e.createBlock(e.unref(u),{modelValue:c.value,"onUpdate:modelValue":a[0]||(a[0]=i=>c.value=i),title:"查看数据",class:"w-900px",width:"900px",onClose:w,onOk:M,okText:"导出数据"},{default:e.withCtx(()=>[e.createElementVNode("div",le,[e.createVNode(e.unref(_),{ref_key:"monacoEditorRef",ref:h,class:"editor h-full",autoToggleTheme:"",readOnly:"",config:r,language:"json"},null,512)])]),_:1},8,["modelValue"]))}}),se={class:"epic-edit-toolbar flex items-center justify-between px-2"},re={class:"flex-1 h-full flex items-center"},ie={key:0,class:"epic-divider"},ce=["title","onClick"],de={class:"flex-1 h-full flex items-center justify-end"},ue={key:0,class:"flex items-center ml-12px"},fe={class:"pr-8px w-82px cursor-pointer"},me={class:"epic-device h-28px items-center gap-1 rounded-md border p-2px flex"},ve=["title","onClick"],pe=e.defineComponent({__name:"toolbar",setup(A){const R=F.pluginManager.getComponent("select"),{canvasScale:u,disabledZoom:_}=C.useStore(),r=e.ref("pc"),h=e.inject("pageSchema"),c=e.inject("designer"),f=e.inject("revoke"),w=e.ref(null),g=[{icon:"icon--epic--computer-outline-rounded",title:"pc",key:"pc"}],M=e.computed(()=>[{icon:"icon--epic--trash",title:"清空",on:n},{icon:"icon--epic--undo",title:"撤销",on:s,disabled:!f.recordList.value.length,divider:!0},{icon:"icon--epic--redo",title:"重做",on:k,disabled:!f.undoList.value.length}]),l=e.ref(null),a=e.computed({get(){return`${(u.value*100).toFixed(0)}%`},set(p){const x=parseFloat(p);u.value=x/100}}),i=[{label:"60%",value:"60%"},{label:"80%",value:"80%"},{label:"100%",value:"100%"},{label:"120%",value:"120%"},{label:"140%",value:"140%"}];function s(){const p=f.undo();p&&(C.deepCompareAndModify(h.schemas,p),c.setCheckedNode(h.schemas[0]))}function k(){const p=f.redo();p&&(C.deepCompareAndModify(h.schemas,p),c.setCheckedNode(h.schemas[0]))}function n(){c.reset()}function L(p){var z;const x=(z=p.target.files)==null?void 0:z[0];if(!x)return;p.target.value=null;const v=new FileReader;v.readAsText(x),v.onload=P=>{var E;T((E=P.target)==null?void 0:E.result)}}function T(p){try{let x=JSON.parse(p??"");x.schemas||(x=C.convertKFormData(x)),C.deepCompareAndModify(h,x)}catch(x){console.error(x)}}function B(p){c.handleToggleDeviceMode(p),r.value=p;const x={pc:{},pad:{width:"780px",mode:p},mobile:{width:"390px",mode:p}};h.canvas=x[p]}return(p,x)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",se,[e.createElementVNode("div",re,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(M.value,(v,z)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:z},[v.divider?(e.openBlock(),e.createElementBlock("div",ie)):e.createCommentVNode("",!0),e.createElementVNode("div",{title:v.title,class:e.normalizeClass(["epic-action-item text-base h-90% px-10px flex items-center cursor-pointer",{disabled:v.disabled}]),onClick:v.on},[e.createVNode(e.unref(J._sfc_main),{name:v.icon},null,8,["name"])],10,ce)],64))),128))]),e.withDirectives(e.createElementVNode("input",{type:"file",ref_key:"fileRef",ref:l,accept:".json,.txt",onChange:L},null,544),[[e.vShow,!1]]),e.createElementVNode("div",de,[e.unref(_)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",ue,[e.createElementVNode("div",fe,[e.createVNode(e.unref(R),{value:a.value,"onUpdate:value":x[0]||(x[0]=v=>a.value=v),modelValue:a.value,"onUpdate:modelValue":x[1]||(x[1]=v=>a.value=v),options:i,size:"small"},null,8,["value","modelValue"])])])),e.createElementVNode("div",me,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(g,v=>e.createElementVNode("div",{key:v.key,title:v.title,class:e.normalizeClass(["epic-device-item h-full px-1 flex items-center cursor-pointer text-base transition-colors rounded-sm",{checked:v.key===r.value}]),onClick:z=>B(v.key)},[e.createVNode(e.unref(J._sfc_main),{name:v.icon},null,8,["name"])],10,ve)),64))])])]),e.createVNode(ae,{ref_key:"previewJson",ref:w},null,512)],64))}}),he={class:"h-full flex flex-col relative"},ge=["draggable"],xe=e.defineComponent({__name:"editScreenContainer",setup(A){const R=e.inject("pageSchema"),u=e.ref(null),_=e.ref(null),r=e.ref(null),{pressSpace:h,disabledZoom:c}=C.useStore(),{handleElementDragStart:f,handleElementDrag:w,handleElementDragEnd:g}=C.useElementDrag(u),{width:M,height:l}=C.useElementSize(u),{canvasScale:a,handleZoom:i}=C.useElementZoom(_);let s=0,k=0;const n=e.ref({}),L=e.ref({}),T=e.ref({}),B=e.shallowRef({width:0,height:0});e.watchEffect(x),e.watch(T,()=>{e.nextTick(p)});function p(){r.value&&(B.value={width:r.value.clientWidth,height:r.value.clientHeight})}function x(){var E,b;T.value={width:((E=R.canvas)==null?void 0:E.width)??"0",height:((b=R.canvas)==null?void 0:b.height)??"0"}}C.watchOnce(M,v),e.watch(B,v);function v(){let E=B.value.width||s,b=B.value.height||k;n.value={width:M.value+E+"px",height:l.value+b+"px"},L.value={width:E+"px",height:b+"px"},z()}function z(){e.nextTick(()=>{var j;let E=B.value.width||s;const $=(B.value.height||k)/2,D=E/2;(j=u.value)==null||j.scrollTo(D,$)})}C.useResizeObserver(u,P),C.useResizeObserver(_,P);function P(){var b;if(!u.value)return;const E=u.value.getBoundingClientRect();if(s=E.width-60,k=E.height-80,!c.value)if(B.value.width===0)a.value=1;else{const $=(s-20)/B.value.width,D=k/(B.value.height||((b=_.value)==null?void 0:b.clientHeight)||1),j=Math.abs($-1)<Math.abs(D-1);let I=1;j?I=$:I=D,($<1||D<1)&&(I=Math.min($,D)),I<1.4&&I>.5&&(a.value=I)}C.debounce(v,50)()}return(E,b)=>(e.openBlock(),e.createElementBlock("div",he,[e.createVNode(pe),e.createElementVNode("div",{ref_key:"editScreenContainerRef",ref:u,class:e.normalizeClass(["flex-1 overflow-auto overflow-y-hidden epic-edit-screen-container",{"cursor-grab":e.unref(h)}]),draggable:e.unref(h),onWheel:b[0]||(b[0]=(...$)=>e.unref(i)&&e.unref(i)(...$)),onDragstart:b[1]||(b[1]=(...$)=>e.unref(f)&&e.unref(f)(...$)),onDragend:b[2]||(b[2]=(...$)=>e.unref(g)&&e.unref(g)(...$)),onDrag:b[3]||(b[3]=(...$)=>e.unref(w)&&e.unref(w)(...$))},[e.createElementVNode("div",{id:"canvasContainer",class:"flex items-center justify-center",style:e.normalizeStyle(n.value)},[e.createElementVNode("div",{ref_key:"draggableElRef",ref:_,class:"transition-all"},[e.createElementVNode("div",{class:e.normalizeClass({"pointer-events-none":e.unref(h)}),style:e.normalizeStyle(L.value)},[e.renderSlot(E.$slots,"default")],6)],512)],4)],42,ge),e.createElementVNode("div",{ref_key:"sizeBoxRef",ref:r,class:"absolute top-0 pointer-events-none",style:e.normalizeStyle(T.value)},null,4)]))}}),ye={class:"epic-edit-canvas"},_e=e.defineComponent({__name:"index",setup(A){const R=e.ref(null),u=e.ref(null),_=e.inject("pageSchema"),r=e.computed(()=>_.schemas[0]),h=e.computed(()=>({width:"100%",height:"100%"}));return e.onMounted(()=>{var c;(c=u.value)==null||c.handleInit(R.value)}),(c,f)=>(e.openBlock(),e.createElementBlock("section",ye,[e.createVNode(xe,null,{default:e.withCtx(()=>[e.createElementVNode("div",{ref_key:"epicEditRangeRef",ref:R,class:"epic-edit-range rounded-md overflow-auto relative",style:e.normalizeStyle(h.value)},[e.createVNode(Q,{schema:r.value},null,8,["schema"]),e.createVNode(ne,{ref_key:"ePreviewWidgetsRef",ref:u},null,512)],4)]),_:1})]))}});exports.default=_e;
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-CtK_8YxJ.cjs"),a=require("./js.cookie-BH1G_HRi.cjs");exports.EBuilder=e._sfc_main$1;exports.EDesigner=e._sfc_main$2;exports.ENode=e._sfc_main;exports.capitalizeFirstLetter=e.capitalizeFirstLetter;exports.convertKFormData=e.convertKFormData;exports.debounce=e.debounce;exports.deepClone=e.deepClone;exports.deepCompareAndModify=e.deepCompareAndModify;exports.deepEqual=e.deepEqual;exports.findSchemaById=e.findSchemaById;exports.findSchemaInfoById=e.findSchemaInfoById;exports.findSchemas=e.findSchemas;exports.generateNewSchema=e.generateNewSchema;exports.getDarkState=e.getDarkState;exports.getFormFields=e.getFormFields;exports.getFormSchemas=e.getFormSchemas;exports.getMatchedById=e.getMatchedById;exports.getUUID=e.getUUID;exports.getValueByPath=e.getValueByPath;exports.initStore=e.initStore;exports.mapSchemas=e.mapSchemas;exports.recursionConvertedNode=e.recursionConvertedNode;exports.setValueByPath=e.setValueByPath;exports.useDark=e.useDark;exports.useElementDrag=e.useElementDrag;exports.useElementZoom=e.useElementZoom;exports.useKeyPress=e.useKeyPress;exports.usePageManager=e.usePageManager;exports.useRevoke=e.useRevoke;exports.useStore=e.useStore;exports.useTheme=e.useTheme;exports.useTimedQuery=e.useTimedQuery;exports.EventBus=a.EventBus;exports.PluginManager=a.PluginManager;exports.loadAsyncComponent=a.loadAsyncComponent;exports.pluginManager=a.pluginManager;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-C2HMY2I2.cjs"),a=require("./js.cookie-BH1G_HRi.cjs");exports.EBuilder=e._sfc_main$1;exports.EDesigner=e._sfc_main$2;exports.ENode=e._sfc_main;exports.capitalizeFirstLetter=e.capitalizeFirstLetter;exports.convertKFormData=e.convertKFormData;exports.debounce=e.debounce;exports.deepClone=e.deepClone;exports.deepCompareAndModify=e.deepCompareAndModify;exports.deepEqual=e.deepEqual;exports.findSchemaById=e.findSchemaById;exports.findSchemaInfoById=e.findSchemaInfoById;exports.findSchemas=e.findSchemas;exports.generateNewSchema=e.generateNewSchema;exports.getDarkState=e.getDarkState;exports.getFormFields=e.getFormFields;exports.getFormSchemas=e.getFormSchemas;exports.getMatchedById=e.getMatchedById;exports.getUUID=e.getUUID;exports.getValueByPath=e.getValueByPath;exports.initStore=e.initStore;exports.mapSchemas=e.mapSchemas;exports.recursionConvertedNode=e.recursionConvertedNode;exports.setValueByPath=e.setValueByPath;exports.useDark=e.useDark;exports.useElementDrag=e.useElementDrag;exports.useElementZoom=e.useElementZoom;exports.useKeyPress=e.useKeyPress;exports.usePageManager=e.usePageManager;exports.useRevoke=e.useRevoke;exports.useStore=e.useStore;exports.useTheme=e.useTheme;exports.useTimedQuery=e.useTimedQuery;exports.EventBus=a.EventBus;exports.PluginManager=a.PluginManager;exports.loadAsyncComponent=a.loadAsyncComponent;exports.pluginManager=a.pluginManager;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { q as s, r as t, _ as r, E as o, c as n, j as d, m, d as u, x as i, l as g, f as l, B as c, g as p, H as h, z as y, A as E, y as S, k as f, o as B, I as D, C as F, D as I, s as P, G as v, e as C, i as M, F as k, t as x, v as A, u as N, p as q, a as z } from "./index-Dy65ngnp.js";
1
+ import { q as s, r as t, _ as r, E as o, c as n, j as d, m, d as u, x as i, l as g, f as l, B as c, g as p, H as h, z as y, A as E, y as S, k as f, o as B, I as D, C as F, D as I, s as P, G as v, e as C, i as M, F as k, t as x, v as A, u as N, p as q, a as z } from "./index-DNuLy9hB.js";
2
2
  import { E as T, P as U, l as V, p as b } from "./js.cookie-oHpRFPCO.js";
3
3
  export {
4
4
  s as EBuilder,
@@ -0,0 +1,218 @@
1
+ import { inject as G, watch as J, nextTick as D, ref as l, onMounted as K, onUnmounted as Q, openBlock as x, createElementBlock as w, createVNode as S, unref as P, withCtx as _, createElementVNode as m, createTextVNode as M } from "vue";
2
+ import { p as A, a as Z, b as ee } from "./js.cookie-oHpRFPCO.js";
3
+ import { ElMessageBox as R, ElMessage as k } from "element-plus";
4
+ import { _ as te } from "./_plugin-vue_export-helper-CHgC5LLL.js";
5
+ const oe = { class: "sign-main" }, ae = ["src"], ne = {
6
+ class: "sign",
7
+ style: {
8
+ height: "100%",
9
+ width: "100%"
10
+ }
11
+ }, le = ["id"], se = { class: "btn" }, ue = { class: "btns" }, ie = {
12
+ __name: "sign",
13
+ props: {
14
+ componentSchema: {
15
+ type: Object,
16
+ require: !0,
17
+ default: () => ({})
18
+ },
19
+ modelValue: {
20
+ type: String,
21
+ default: ""
22
+ }
23
+ },
24
+ emits: ["update:modelValue"],
25
+ setup(W, { expose: j, emit: E }) {
26
+ const T = A.getComponent("button"), U = A.getComponent("Dialog"), X = E, a = W, p = G("disabled", { value: !1 });
27
+ J(
28
+ () => a.componentSchema,
29
+ () => {
30
+ D(() => {
31
+ f.value = a.modelValue;
32
+ });
33
+ },
34
+ { deep: !0, immediate: !0 }
35
+ );
36
+ const n = l(null), i = l(null), o = l(), Y = l("");
37
+ function I() {
38
+ var t, e, u, h;
39
+ if (i.value && ((t = i.value) != null && t.clientHeight) && ((e = i.value) != null && e.clientWidth)) {
40
+ if (n.value = document.getElementById(`canvas${a.componentSchema.field}`), n.value.height = ((u = i.value) == null ? void 0 : u.clientHeight) || 600, n.value.width = (h = i.value) == null ? void 0 : h.clientWidth, o.value = n.value.getContext("2d"), a.modelValue) {
41
+ let r = new Image();
42
+ r.src = a.modelValue, r.setAttribute("crossOrigin", "anonymous"), r.onload = () => {
43
+ o.value.fillStyle = o.value.createPattern(r, "repeat"), o.value.fillRect(0, 0, 1e3, 550);
44
+ };
45
+ }
46
+ o.value.lineWidth = a.componentSchema.componentProps.lineWidth || 4, a.componentSchema && a.componentSchema.componentProps && a.componentSchema.componentProps.style && a.componentSchema.componentProps.style.color && (o.value.strokeStyle = a.componentSchema.componentProps.style.color), Y.value = n.value.getBoundingClientRect();
47
+ }
48
+ }
49
+ const d = l(""), v = l(""), z = l(""), N = l(""), s = l([]), y = l(!1);
50
+ function F(t) {
51
+ if (p.value || a.componentSchema.componentProps.readonly || a.componentSchema.componentProps.disabled)
52
+ return;
53
+ t = t || event, t.preventDefault();
54
+ let e = {
55
+ x: t.offsetX,
56
+ y: t.offsetY
57
+ };
58
+ d.value = e.x, v.value = e.y, o.value.beginPath(), o.value.moveTo(e.x, e.y), o.value.lineTo(e.x, e.y), o.value.stroke(), o.value.closePath(), s.value.push(e), y.value = !0;
59
+ }
60
+ function H(t) {
61
+ if (!(p.value || a.componentSchema.componentProps.readonly || a.componentSchema.componentProps.disabled) && (t = t || event, t.preventDefault(), y.value)) {
62
+ let e = {
63
+ x: t.offsetX,
64
+ y: t.offsetY
65
+ };
66
+ z.value = e.x, N.value = e.y, o.value.beginPath(), o.value.moveTo(d.value, v.value), o.value.lineTo(e.x, e.y), o.value.stroke(), o.value.closePath(), d.value = e.x, v.value = e.y, s.value.push(e);
67
+ }
68
+ }
69
+ function O(t) {
70
+ if (p.value || a.componentSchema.componentProps.readonly || a.componentSchema.componentProps.disabled)
71
+ return;
72
+ t = t || event, t.preventDefault();
73
+ let e = {
74
+ x: t.offsetX,
75
+ y: t.offsetY
76
+ };
77
+ o.value.beginPath(), o.value.moveTo(d.value, v.value), o.value.lineTo(e.x, e.y), o.value.stroke(), o.value.closePath(), s.value.push(e), s.value.push({ x: -1, y: -1 }), y.value = !1;
78
+ }
79
+ function B() {
80
+ R.confirm("重写将清空画布,请确定是否重写?", "警告", {
81
+ confirmButtonText: "确定",
82
+ cancelButtonText: "取消",
83
+ type: "warning"
84
+ }).then(() => {
85
+ o.value.clearRect(0, 0, n.value.width, n.value.height), s.value = [], k({
86
+ type: "info",
87
+ message: "清空成功"
88
+ });
89
+ }).catch(() => {
90
+ });
91
+ }
92
+ const f = l("");
93
+ async function b() {
94
+ let t = await $(n.value.toDataURL("image/png"));
95
+ f.value = t, X("update:modelValue", t);
96
+ }
97
+ async function $(t) {
98
+ try {
99
+ let e = atob(t.split(",")[1]), u = new ArrayBuffer(e.length), h = new Uint8Array(u);
100
+ for (let g = 0; g < e.length; g++)
101
+ h[g] = e.charCodeAt(g);
102
+ let r = new Blob([u], { type: "image/png" }), C = new FormData();
103
+ C.append("file", r, Date.now() + "png");
104
+ let L = await Z({
105
+ method: "post",
106
+ url: "https://ess-ds.com/prod-api/center-file/file/upload",
107
+ data: C,
108
+ headers: {
109
+ "Content-Type": "multipart/form-data",
110
+ Authorization: "Bearer " + ee.get("Admin-Token")
111
+ }
112
+ });
113
+ return k({
114
+ type: "success",
115
+ message: "上传成功"
116
+ }), L.data.data.url;
117
+ } catch {
118
+ k({
119
+ type: "warning",
120
+ message: "上传失败"
121
+ }), c.value = !1;
122
+ } finally {
123
+ c.value = !1;
124
+ }
125
+ }
126
+ const c = l(!1);
127
+ function q() {
128
+ R.confirm("是否放弃本次签字?", "警告", {
129
+ confirmButtonText: "确定",
130
+ cancelButtonText: "取消",
131
+ type: "warning"
132
+ }).then(() => {
133
+ o.value.clearRect(0, 0, n.value.width, n.value.height), s.value = [], c.value = !1;
134
+ }).catch(() => !1);
135
+ }
136
+ function V() {
137
+ p.value || a.componentSchema.componentProps.readonly || a.componentSchema.componentProps.disabled || (c.value = !0, o.value && (o.value.clearRect(0, 0, n.value.width, n.value.height), s.value = []), D(() => {
138
+ I();
139
+ }));
140
+ }
141
+ return K(() => {
142
+ }), Q(() => {
143
+ }), j({
144
+ surewrite: b
145
+ }), (t, e) => (x(), w("div", oe, [
146
+ f.value ? (x(), w("img", {
147
+ key: 1,
148
+ class: "sign-board",
149
+ src: f.value,
150
+ alt: "",
151
+ onClick: V
152
+ }, null, 8, ae)) : (x(), w("div", {
153
+ key: 0,
154
+ class: "sign-board",
155
+ onClick: V
156
+ }, "签字板")),
157
+ S(P(U), {
158
+ modelValue: c.value,
159
+ "onUpdate:modelValue": e[0] || (e[0] = (u) => c.value = u),
160
+ title: "签字板",
161
+ class: "w-860px",
162
+ width: "860px",
163
+ style: { height: "600px" },
164
+ "before-close": q,
165
+ draggable: !1,
166
+ modal: ""
167
+ }, {
168
+ default: _(() => [
169
+ m("div", ne, [
170
+ m("div", {
171
+ class: "canvas",
172
+ ref_key: "canvasWrap",
173
+ ref: i
174
+ }, [
175
+ m("canvas", {
176
+ id: `canvas${a.componentSchema.field}`,
177
+ onMousedown: F,
178
+ onMousemove: H,
179
+ onMouseup: O
180
+ }, null, 40, le)
181
+ ], 512),
182
+ m("div", se, [
183
+ e[3] || (e[3] = m("div", { class: "remark" }, null, -1)),
184
+ m("div", ue, [
185
+ S(P(T), {
186
+ type: "info",
187
+ size: "mini",
188
+ onClick: B,
189
+ onTouch: B
190
+ }, {
191
+ default: _(() => e[1] || (e[1] = [
192
+ M("重写")
193
+ ])),
194
+ _: 1
195
+ }),
196
+ S(P(T), {
197
+ type: "primary",
198
+ size: "mini",
199
+ onClick: b,
200
+ onTouch: b
201
+ }, {
202
+ default: _(() => e[2] || (e[2] = [
203
+ M("确定")
204
+ ])),
205
+ _: 1
206
+ })
207
+ ])
208
+ ])
209
+ ])
210
+ ]),
211
+ _: 1
212
+ }, 8, ["modelValue"])
213
+ ]));
214
+ }
215
+ }, de = /* @__PURE__ */ te(ie, [["__scopeId", "data-v-017ab137"]]);
216
+ export {
217
+ de as default
218
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),y=require("./js.cookie-BH1G_HRi.cjs"),m=require("element-plus"),X=require("./_plugin-vue_export-helper-BHFhmbuH.cjs"),Y={class:"sign-main"},I=["src"],z={class:"sign",style:{height:"100%",width:"100%"}},H=["id"],O={class:"btn"},F={class:"btns"},$={__name:"sign",props:{componentSchema:{type:Object,require:!0,default:()=>({})},modelValue:{type:String,default:""}},emits:["update:modelValue"],setup(V,{expose:_,emit:T}){const w=y.pluginManager.getComponent("button"),B=y.pluginManager.getComponent("Dialog"),E=T,a=V,p=e.inject("disabled",{value:!1});e.watch(()=>a.componentSchema,()=>{e.nextTick(()=>{f.value=a.modelValue})},{deep:!0,immediate:!0});const l=e.ref(null),c=e.ref(null),n=e.ref(),C=e.ref("");function M(){var o,t,u,h;if(c.value&&((o=c.value)!=null&&o.clientHeight)&&((t=c.value)!=null&&t.clientWidth)){if(l.value=document.getElementById(`canvas${a.componentSchema.field}`),l.value.height=((u=c.value)==null?void 0:u.clientHeight)||600,l.value.width=(h=c.value)==null?void 0:h.clientWidth,n.value=l.value.getContext("2d"),a.modelValue){let r=new Image;r.src=a.modelValue,r.setAttribute("crossOrigin","anonymous"),r.onload=()=>{n.value.fillStyle=n.value.createPattern(r,"repeat"),n.value.fillRect(0,0,1e3,550)}}n.value.lineWidth=a.componentSchema.componentProps.lineWidth||4,a.componentSchema&&a.componentSchema.componentProps&&a.componentSchema.componentProps.style&&a.componentSchema.componentProps.style.color&&(n.value.strokeStyle=a.componentSchema.componentProps.style.color),C.value=l.value.getBoundingClientRect()}}const d=e.ref(""),v=e.ref(""),D=e.ref(""),N=e.ref(""),s=e.ref([]),x=e.ref(!1);function j(o){if(p.value||a.componentSchema.componentProps.readonly||a.componentSchema.componentProps.disabled)return;o=o||event,o.preventDefault();let t={x:o.offsetX,y:o.offsetY};d.value=t.x,v.value=t.y,n.value.beginPath(),n.value.moveTo(t.x,t.y),n.value.lineTo(t.x,t.y),n.value.stroke(),n.value.closePath(),s.value.push(t),x.value=!0}function A(o){if(!(p.value||a.componentSchema.componentProps.readonly||a.componentSchema.componentProps.disabled)&&(o=o||event,o.preventDefault(),x.value)){let t={x:o.offsetX,y:o.offsetY};D.value=t.x,N.value=t.y,n.value.beginPath(),n.value.moveTo(d.value,v.value),n.value.lineTo(t.x,t.y),n.value.stroke(),n.value.closePath(),d.value=t.x,v.value=t.y,s.value.push(t)}}function R(o){if(p.value||a.componentSchema.componentProps.readonly||a.componentSchema.componentProps.disabled)return;o=o||event,o.preventDefault();let t={x:o.offsetX,y:o.offsetY};n.value.beginPath(),n.value.moveTo(d.value,v.value),n.value.lineTo(t.x,t.y),n.value.stroke(),n.value.closePath(),s.value.push(t),s.value.push({x:-1,y:-1}),x.value=!1}function S(){m.ElMessageBox.confirm("重写将清空画布,请确定是否重写?","警告",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then(()=>{n.value.clearRect(0,0,l.value.width,l.value.height),s.value=[],m.ElMessage({type:"info",message:"清空成功"})}).catch(()=>{})}const f=e.ref("");async function b(){let o=await W(l.value.toDataURL("image/png"));f.value=o,E("update:modelValue",o)}async function W(o){try{let t=atob(o.split(",")[1]),u=new ArrayBuffer(t.length),h=new Uint8Array(u);for(let g=0;g<t.length;g++)h[g]=t.charCodeAt(g);let r=new Blob([u],{type:"image/png"}),P=new FormData;P.append("file",r,Date.now()+"png");let U=await y.axios({method:"post",url:"https://ess-ds.com/prod-api/center-file/file/upload",data:P,headers:{"Content-Type":"multipart/form-data",Authorization:"Bearer "+y.api.get("Admin-Token")}});return m.ElMessage({type:"success",message:"上传成功"}),U.data.data.url}catch{m.ElMessage({type:"warning",message:"上传失败"}),i.value=!1}finally{i.value=!1}}const i=e.ref(!1);function q(){m.ElMessageBox.confirm("是否放弃本次签字?","警告",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then(()=>{n.value.clearRect(0,0,l.value.width,l.value.height),s.value=[],i.value=!1}).catch(()=>!1)}function k(){p.value||a.componentSchema.componentProps.readonly||a.componentSchema.componentProps.disabled||(i.value=!0,n.value&&(n.value.clearRect(0,0,l.value.width,l.value.height),s.value=[]),e.nextTick(()=>{M()}))}return e.onMounted(()=>{}),e.onUnmounted(()=>{}),_({surewrite:b}),(o,t)=>(e.openBlock(),e.createElementBlock("div",Y,[f.value?(e.openBlock(),e.createElementBlock("img",{key:1,class:"sign-board",src:f.value,alt:"",onClick:k},null,8,I)):(e.openBlock(),e.createElementBlock("div",{key:0,class:"sign-board",onClick:k},"签字板")),e.createVNode(e.unref(B),{modelValue:i.value,"onUpdate:modelValue":t[0]||(t[0]=u=>i.value=u),title:"签字板",class:"w-860px",width:"860px",style:{height:"600px"},"before-close":q,draggable:!1,modal:""},{default:e.withCtx(()=>[e.createElementVNode("div",z,[e.createElementVNode("div",{class:"canvas",ref_key:"canvasWrap",ref:c},[e.createElementVNode("canvas",{id:`canvas${a.componentSchema.field}`,onMousedown:j,onMousemove:A,onMouseup:R},null,40,H)],512),e.createElementVNode("div",O,[t[3]||(t[3]=e.createElementVNode("div",{class:"remark"},null,-1)),e.createElementVNode("div",F,[e.createVNode(e.unref(w),{type:"info",size:"mini",onClick:S,onTouch:S},{default:e.withCtx(()=>t[1]||(t[1]=[e.createTextVNode("重写")])),_:1}),e.createVNode(e.unref(w),{type:"primary",size:"mini",onClick:b,onTouch:b},{default:e.withCtx(()=>t[2]||(t[2]=[e.createTextVNode("确定")])),_:1})])])])]),_:1},8,["modelValue"])]))}},L=X._export_sfc($,[["__scopeId","data-v-017ab137"]]);exports.default=L;