index.esm.js 73 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518
  1. /*!
  2. * FormCreate 低代码表单渲染器
  3. * @form-create/core v2.6.3
  4. * (c) 2018-2024 xaboy
  5. * Github https://github.com/xaboy/form-create
  6. * Site https://form-create.com/
  7. * Released under the MIT License.
  8. */
  9. var ze = Object.defineProperty, Ze = Object.defineProperties;
  10. var Ye = Object.getOwnPropertyDescriptors;
  11. var ge = Object.getOwnPropertySymbols;
  12. var xe = Object.prototype.hasOwnProperty, et = Object.prototype.propertyIsEnumerable;
  13. var $e = (t, e, r) => e in t ? ze(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, $ = (t, e) => {
  14. for (var r in e || (e = {}))
  15. xe.call(e, r) && $e(t, r, e[r]);
  16. if (ge)
  17. for (var r of ge(e))
  18. et.call(e, r) && $e(t, r, e[r]);
  19. return t;
  20. }, N = (t, e) => Ze(t, Ye(e));
  21. import w from "vue";
  22. function E(t, e, r) {
  23. w.set(t, e, r);
  24. }
  25. function k(t, e) {
  26. w.delete(t, e);
  27. }
  28. const tt = Object.assign || function(t) {
  29. for (let e, r = 1; r < arguments.length; r++)
  30. for (let n in e = arguments[r], e)
  31. Object.prototype.hasOwnProperty.call(e, n) && E(t, n, e[n]);
  32. return t;
  33. };
  34. function p() {
  35. return tt.apply(this, arguments);
  36. }
  37. function M(t) {
  38. return Array.isArray(t) ? t : [null, void 0, ""].indexOf(t) > -1 ? [] : [t];
  39. }
  40. const _e = "FormCreate", Y = (t, e) => {
  41. if (!(!t || t === e)) {
  42. if (t.formCreateInject)
  43. return t.formCreateInject;
  44. if (t.$parent)
  45. return Y(t.$parent, e);
  46. }
  47. };
  48. function rt(t, e, r) {
  49. return {
  50. name: _e,
  51. componentName: _e,
  52. model: {
  53. prop: "api"
  54. },
  55. components: e,
  56. directives: r,
  57. provide() {
  58. return {
  59. $pfc: this
  60. };
  61. },
  62. inject: { $pfc: { default: null } },
  63. props: {
  64. rule: {
  65. type: Array,
  66. required: !0
  67. },
  68. option: {
  69. type: Object,
  70. default: () => ({})
  71. },
  72. extendOption: Boolean,
  73. disabled: {
  74. type: Boolean,
  75. default: void 0
  76. },
  77. value: Object,
  78. api: Object,
  79. name: String,
  80. subForm: {
  81. type: Boolean,
  82. default: !0
  83. },
  84. inFor: Boolean
  85. },
  86. data() {
  87. return {
  88. formData: void 0,
  89. destroyed: !1,
  90. validate: {},
  91. $f: void 0,
  92. isShow: !0,
  93. unique: 1,
  94. renderRule: [...this.rule || []],
  95. ctxInject: {},
  96. updateValue: JSON.stringify(this.value || {}),
  97. isMore: !!this.inFor
  98. };
  99. },
  100. render() {
  101. return this.formCreate.render();
  102. },
  103. methods: {
  104. _refresh() {
  105. ++this.unique;
  106. },
  107. _renderRule() {
  108. this.renderRule = [...this.rule || []];
  109. },
  110. _updateValue(n) {
  111. this.destroyed || (this.updateValue = JSON.stringify(n), this.$emit("update:value", n));
  112. }
  113. },
  114. watch: {
  115. value: {
  116. handler(n) {
  117. JSON.stringify(n || {}) !== this.updateValue && (this.$f.config.forceCoverValue ? this.$f.coverValue(n || {}) : this.$f.setValue(n || {}));
  118. },
  119. deep: !0
  120. },
  121. option: {
  122. handler() {
  123. this.formCreate.initOptions(), this.$f.refresh();
  124. },
  125. deep: !0
  126. },
  127. rule(n, s) {
  128. n.length === this.renderRule.length && n.every((i) => this.renderRule.indexOf(i) > -1) || (this.formCreate.$handle.reloadRule(n), this._renderRule(), n !== s && this.formCreate.$handle.targetReload());
  129. },
  130. disabled() {
  131. this.$f.refresh();
  132. }
  133. },
  134. beforeCreate() {
  135. this.formCreate = new t(this), Object.keys(this.formCreate.prop).forEach((n) => {
  136. p(this.$options[n], this.formCreate.prop[n]);
  137. }), this.$emit("beforeCreate", this.formCreate.api());
  138. },
  139. created() {
  140. const n = this, s = this.formCreate.api(), i = () => {
  141. if (n.$pfc) {
  142. const a = Y(n, n.$pfc);
  143. if (a) {
  144. let l;
  145. n.isMore ? (l = M(a.getSubForm()), l.push(s)) : l = s, a.subForm(l);
  146. }
  147. }
  148. }, o = () => {
  149. const a = Y(n, n.$pfc);
  150. if (a)
  151. if (n.isMore) {
  152. const l = M(a.getSubForm()), u = l.indexOf(s);
  153. u > -1 && l.splice(u, 1);
  154. } else
  155. a.subForm();
  156. };
  157. n.$on("hook:beforeDestroy", () => {
  158. o();
  159. }), this.$watch(() => this.subForm, (a) => {
  160. a ? i() : o();
  161. }, { immediate: !0 });
  162. }
  163. };
  164. }
  165. const h = {
  166. type(t, e) {
  167. return Object.prototype.toString.call(t) === "[object " + e + "]";
  168. },
  169. Undef(t) {
  170. return t == null;
  171. },
  172. Element(t) {
  173. return typeof t == "object" && t !== null && t.nodeType === 1 && !h.Object(t);
  174. },
  175. trueArray(t) {
  176. return Array.isArray(t) && t.length > 0;
  177. },
  178. Function(t) {
  179. const e = this.getType(t);
  180. return e === "Function" || e === "AsyncFunction";
  181. },
  182. getType(t) {
  183. const e = Object.prototype.toString.call(t);
  184. return /^\[object (.*)\]$/.exec(e)[1];
  185. },
  186. empty(t) {
  187. return t == null || Array.isArray(t) && Array.isArray(t) && !t.length ? !0 : typeof t == "string" && !t;
  188. }
  189. };
  190. ["Date", "Object", "String", "Boolean", "Array", "Number"].forEach((t) => {
  191. h[t] = function(e) {
  192. return h.type(e, t);
  193. };
  194. });
  195. function F(t, e) {
  196. return {}.hasOwnProperty.call(t, e);
  197. }
  198. const we = ["attrs", "props", "domProps", "scopedSlots"], ke = ["class", "style", "directives"], Ve = ["on", "nativeOn"], q = (t, e = {}, r = {}) => {
  199. const n = [...we, ...r.normal || []], s = [...ke, ...r.array || []], i = [...Ve, ...r.functional || []], o = r.props || [];
  200. return t.reduce((a, l) => {
  201. for (const u in l)
  202. if (a[u])
  203. if (o.indexOf(u) > -1)
  204. a[u] = q([l[u]], a[u]);
  205. else if (n.indexOf(u) > -1)
  206. a[u] = $($({}, a[u]), l[u]);
  207. else if (s.indexOf(u) > -1) {
  208. const d = a[u] instanceof Array ? a[u] : [a[u]], m = l[u] instanceof Array ? l[u] : [l[u]];
  209. a[u] = [...d, ...m];
  210. } else if (i.indexOf(u) > -1)
  211. for (const d in l[u])
  212. if (a[u][d]) {
  213. const m = a[u][d] instanceof Array ? a[u][d] : [a[u][d]], _ = l[u][d] instanceof Array ? l[u][d] : [l[u][d]];
  214. a[u][d] = [...m, ..._];
  215. } else
  216. a[u][d] = l[u][d];
  217. else if (u === "hook")
  218. for (let d in l[u])
  219. a[u][d] ? a[u][d] = nt(a[u][d], l[u][d]) : a[u][d] = l[u][d];
  220. else
  221. a[u] = l[u];
  222. else
  223. n.indexOf(u) > -1 || i.indexOf(u) > -1 || o.indexOf(u) > -1 ? a[u] = $({}, l[u]) : s.indexOf(u) > -1 ? a[u] = l[u] instanceof Array ? [...l[u]] : typeof l[u] == "object" ? $({}, l[u]) : l[u] : a[u] = l[u];
  224. return a;
  225. }, e);
  226. }, nt = (t, e) => function() {
  227. t && t.apply(this, arguments), e && e.apply(this, arguments);
  228. }, Pe = ["type", "slot", "emitPrefix", "value", "name", "native", "hidden", "display", "inject", "options", "emit", "nativeEmit", "link", "prefix", "suffix", "update", "sync", "optionsTo", "key", "preview", "component", "cache"], ne = ["validate", "children", "control"], ie = ["effect", "deep"];
  229. function it() {
  230. return [...Pe, ...we, ...ke, ...Ve, ...ne, ...ie];
  231. }
  232. function se(t, e, r) {
  233. return `[form-create ${t}]: ${e}`;
  234. }
  235. function st(t, e) {
  236. console.warn(se("tip", t));
  237. }
  238. function oe(t, e) {
  239. console.error(se("err", t));
  240. }
  241. function ot(t) {
  242. oe(t.toString()), console.error(t);
  243. }
  244. function X(t, e = {}, r) {
  245. let n = !1;
  246. for (let s in e)
  247. if (Object.prototype.hasOwnProperty.call(e, s)) {
  248. let i = e[s];
  249. if ((n = Array.isArray(i)) || h.Object(i)) {
  250. let o = t[s] === void 0;
  251. if (n)
  252. n = !1, o && E(t, s, []);
  253. else if (i._clone && r !== void 0)
  254. if (r)
  255. i = i.getRule(), o && E(t, s, {});
  256. else {
  257. E(t, s, i._clone());
  258. continue;
  259. }
  260. else
  261. o && E(t, s, {});
  262. t[s] = X(t[s], i, r);
  263. } else
  264. E(t, s, i), h.Undef(i) || (h.Undef(i.__json) || (t[s].__json = i.__json), h.Undef(i.__origin) || (t[s].__origin = i.__origin));
  265. }
  266. return r !== void 0 && Array.isArray(t) ? t.filter((s) => !s || !s.__ctrl) : t;
  267. }
  268. function T(t) {
  269. return X({}, { value: t }).value;
  270. }
  271. const x = "[[FORM-CREATE-PREFIX-", ee = "-FORM-CREATE-SUFFIX]]";
  272. function De(t, e) {
  273. return JSON.stringify(X(Array.isArray(t) ? [] : {}, t, !0), function(r, n) {
  274. if (!(n && n._isVue === !0)) {
  275. if (typeof n != "function")
  276. return n;
  277. if (n.__json)
  278. return n.__json;
  279. if (n.__origin && (n = n.__origin), !n.__emit)
  280. return x + n + ee;
  281. }
  282. }, e);
  283. }
  284. function Q(t) {
  285. return new Function("return " + t)();
  286. }
  287. function P(t, e) {
  288. if (t && h.String(t) && t.length > 4) {
  289. let r = t.trim(), n = !1;
  290. try {
  291. if (r.indexOf(ee) > 0 && r.indexOf(x) === 0)
  292. r = r.replace(ee, "").replace(x, ""), n = !0;
  293. else if (r.indexOf("$FN:") === 0)
  294. r = r.substring(4), n = !0;
  295. else if (r.indexOf("$EXEC:") === 0)
  296. r = r.substring(6), n = !0;
  297. else if (r.indexOf("$GLOBAL:") === 0) {
  298. const i = r.substring(8);
  299. return r = function(...o) {
  300. const a = o[0].api.getGlobalEvent(i);
  301. if (a)
  302. return a.call(this, ...o);
  303. }, r.__json = t, r.__inject = !0, r;
  304. } else {
  305. if (r.indexOf("$FNX:") === 0)
  306. return r = Q("function($inject){" + r.substring(5) + "}"), r.__json = t, r.__inject = !0, r;
  307. (!e && r.indexOf("function ") === 0 && r !== "function " || !e && r.indexOf("function(") === 0 && r !== "function(") && (n = !0);
  308. }
  309. if (!n) return t;
  310. let s;
  311. try {
  312. s = Q(r);
  313. } catch (i) {
  314. s = Q("function " + r);
  315. }
  316. return s.__json = t, s;
  317. } catch (s) {
  318. oe(`解析失败:${r}
  319. err: ${s}`);
  320. return;
  321. }
  322. }
  323. return t;
  324. }
  325. function at(t, e) {
  326. return JSON.parse(t, function(r, n) {
  327. return h.Undef(n) || !n.indexOf ? n : P(n, e);
  328. });
  329. }
  330. function te(t, e) {
  331. return {
  332. value: t,
  333. enumerable: !1,
  334. configurable: !1,
  335. writable: !!e
  336. };
  337. }
  338. function ae(t) {
  339. return Te([t])[0];
  340. }
  341. function Te(t, e) {
  342. return X([], [...t], e || !1);
  343. }
  344. function D(t, e) {
  345. return q(Array.isArray(e) ? e : [e], t, { array: ne, normal: ie }), t;
  346. }
  347. function Ce(t) {
  348. const e = h.Function(t.getRule) ? t.getRule() : t;
  349. return e.type || (e.type = "input"), e;
  350. }
  351. function ut(t, e) {
  352. return t ? (Object.keys(e || {}).forEach((r) => {
  353. e[r] && (t[r] = D(t[r] || {}, e[r]));
  354. }), t) : e;
  355. }
  356. function Ie(t, e) {
  357. Object.defineProperties(t, Object.keys(e).reduce((r, n) => (r[n] = {
  358. get() {
  359. return e[n]();
  360. }
  361. }, r), {}));
  362. }
  363. function H(t) {
  364. return t.__fc__ || (t.__origin__ ? t.__origin__.__fc__ : null);
  365. }
  366. function R(t, e) {
  367. try {
  368. e = t();
  369. } catch (r) {
  370. ot(r);
  371. }
  372. return e;
  373. }
  374. const Oe = (t, e) => typeof t == "string" ? String(e) : typeof t == "number" ? Number(e) : e, L = {
  375. "==": (t, e) => JSON.stringify(t) === JSON.stringify(Oe(t, e)),
  376. "!=": (t, e) => !L["=="](t, e),
  377. ">": (t, e) => t > e,
  378. ">=": (t, e) => t >= e,
  379. "<": (t, e) => t < e,
  380. "<=": (t, e) => t <= e,
  381. on(t, e) {
  382. return t && t.indexOf && t.indexOf(Oe(t[0], e)) > -1;
  383. },
  384. notOn(t, e) {
  385. return !L.on(t, e);
  386. },
  387. in(t, e) {
  388. return e && e.indexOf && e.indexOf(t) > -1;
  389. },
  390. notIn(t, e) {
  391. return !L.in(t, e);
  392. },
  393. between(t, e) {
  394. return t > e[0] && t < e[1];
  395. },
  396. notBetween(t, e) {
  397. return t < e[0] || t > e[1];
  398. },
  399. empty(t) {
  400. return h.empty(t);
  401. },
  402. notEmpty(t) {
  403. return !h.empty(t);
  404. },
  405. pattern(t, e) {
  406. return new RegExp(e, "g").test(t);
  407. }
  408. };
  409. function Ne() {
  410. return {
  411. props: {},
  412. on: {},
  413. options: [],
  414. children: [],
  415. effect: {},
  416. hidden: !1,
  417. display: !0,
  418. value: void 0
  419. };
  420. }
  421. function ue(t, e) {
  422. return (r, n, s, i = {}) => {
  423. const o = new le(t, r, n, s, i);
  424. return e && (h.Function(e) ? e(o) : o.props(e)), o;
  425. };
  426. }
  427. function le(t, e, r, n, s) {
  428. this._data = p(Ne(), { type: t, title: e, field: r, value: n, props: s || {} }), this.event = this.on;
  429. }
  430. p(le.prototype, {
  431. getRule() {
  432. return this._data;
  433. },
  434. setProp(t, e) {
  435. return E(this._data, t, e), this;
  436. },
  437. _clone() {
  438. const t = new this.constructor();
  439. return t._data = ae(this._data), t;
  440. }
  441. });
  442. function Le(t) {
  443. t.forEach((e) => {
  444. le.prototype[e] = function(r) {
  445. return D(this._data, { [e]: arguments.length < 2 ? r : { [r]: arguments[1] } }), this;
  446. };
  447. });
  448. }
  449. Le(it());
  450. const Me = ue("");
  451. function lt(t, e, r) {
  452. let n = Me("", e);
  453. return n._data.type = t, n._data.title = r, n;
  454. }
  455. function be(t, e, r, n) {
  456. let s = Me("", r);
  457. return s._data.type = "template", s._data.template = t, s._data.title = n, s._data.vm = e, s;
  458. }
  459. function ft() {
  460. return {
  461. create: lt,
  462. createTmp: be,
  463. template: be,
  464. factory: ue
  465. };
  466. }
  467. function dt(t, e, r) {
  468. const n = `fail to ${t} ${r.status}'`, s = new Error(n);
  469. return s.status = r.status, s.url = t, s;
  470. }
  471. function Ee(t) {
  472. const e = t.responseText || t.response;
  473. if (!e)
  474. return e;
  475. try {
  476. return JSON.parse(e);
  477. } catch (r) {
  478. return e;
  479. }
  480. }
  481. function qe(t) {
  482. if (typeof XMLHttpRequest == "undefined")
  483. return;
  484. const e = new XMLHttpRequest(), r = t.action;
  485. e.onerror = function(o) {
  486. t.onError(o);
  487. }, e.onload = function() {
  488. if (e.status < 200 || e.status >= 300)
  489. return t.onError(dt(r, t, e), Ee(e));
  490. t.onSuccess(Ee(e));
  491. }, e.open(t.method || "get", r, !0);
  492. let n;
  493. t.data && ((t.dataType || "").toLowerCase() !== "json" ? (n = new FormData(), Object.keys(t.data).map((i) => {
  494. n.append(i, t.data[i]);
  495. })) : (n = JSON.stringify(t.data), e.setRequestHeader("content-type", "application/json"))), t.withCredentials && "withCredentials" in e && (e.withCredentials = !0);
  496. const s = t.headers || {};
  497. Object.keys(s).forEach((i) => {
  498. s[i] !== null && e.setRequestHeader(i, s[i]);
  499. }), e.send(n);
  500. }
  501. function ht(t) {
  502. return new Promise((e, r) => {
  503. qe(N($({}, t), {
  504. onSuccess(n) {
  505. let s = (o) => o;
  506. const i = P(t.parse);
  507. h.Function(i) ? s = i : i && h.String(i) && (s = (o) => (i.split(".").forEach((a) => {
  508. o && (o = o[a]);
  509. }), o)), e(s(n));
  510. },
  511. onError(n) {
  512. r(n);
  513. }
  514. }));
  515. });
  516. }
  517. function J(t) {
  518. return T(t);
  519. }
  520. function ct(t) {
  521. function e(i) {
  522. return h.Undef(i) ? i = t.fields() : Array.isArray(i) || (i = [i]), i;
  523. }
  524. function r(i, o, a) {
  525. e(i).forEach((l) => {
  526. t.getCtxs(l).forEach((u) => {
  527. E(u.rule, o, a), t.$render.clearCache(u);
  528. });
  529. });
  530. }
  531. function n() {
  532. const i = t.subForm;
  533. return Object.keys(i).reduce((o, a) => {
  534. const l = i[a];
  535. return l && (Array.isArray(l) ? o.push(...l) : o.push(l)), o;
  536. }, []);
  537. }
  538. const s = {
  539. get config() {
  540. return t.options;
  541. },
  542. get options() {
  543. return t.options;
  544. },
  545. get form() {
  546. return t.form;
  547. },
  548. get rule() {
  549. return t.rules;
  550. },
  551. get parent() {
  552. return t.vm.$pfc && t.vm.$pfc.$f;
  553. },
  554. get top() {
  555. return s.parent ? s.parent.top : s;
  556. },
  557. get children() {
  558. return n();
  559. },
  560. formData(i) {
  561. return e(i).reduce((o, a) => {
  562. const l = t.getFieldCtx(a);
  563. return l && (o[l.field] = J(l.rule.value)), o;
  564. }, t.options.appendValue !== !1 ? J(t.appendData) : {});
  565. },
  566. getValue(i) {
  567. const o = t.getFieldCtx(i);
  568. if (o)
  569. return J(o.rule.value);
  570. },
  571. coverValue(i) {
  572. const o = $({}, i || {});
  573. t.deferSyncValue(() => {
  574. s.fields().forEach((a) => {
  575. const l = t.fieldCtx[a];
  576. if (l) {
  577. const u = F(o, a);
  578. l.forEach((d) => {
  579. d.rule.value = u ? o[a] : void 0;
  580. }), delete o[a];
  581. }
  582. }), p(t.appendData, o);
  583. });
  584. },
  585. setValue(i) {
  586. let o = i;
  587. arguments.length >= 2 && (o = { [i]: arguments[1] }), t.deferSyncValue(() => {
  588. Object.keys(o).forEach((a) => {
  589. const l = t.fieldCtx[a];
  590. if (!l) return t.appendData[a] = o[a];
  591. l.forEach((u) => {
  592. u.rule.value = o[a];
  593. });
  594. });
  595. });
  596. },
  597. removeField(i) {
  598. const o = t.getCtx(i);
  599. return t.deferSyncValue(() => {
  600. t.getCtxs(i).forEach((a) => {
  601. a.rm();
  602. });
  603. }, !0), o ? o.origin : void 0;
  604. },
  605. removeRule(i) {
  606. const o = i && H(i);
  607. if (o)
  608. return o.rm(), o.origin;
  609. },
  610. destroy: () => {
  611. t.vm.$el.parentNode && t.vm.$el.parentNode.removeChild(t.vm.$el), t.vm.$destroy();
  612. },
  613. fields: () => t.fields(),
  614. append: (i, o, a) => {
  615. let l = t.sort.length - 1, u;
  616. const d = t.getCtx(o);
  617. d ? a ? (u = d.rule.children, l = d.rule.children.length - 1) : (l = d.root.indexOf(d.origin), u = d.root) : u = t.rules, u.splice(l + 1, 0, i);
  618. },
  619. prepend: (i, o, a) => {
  620. let l = 0, u;
  621. const d = t.getCtx(o);
  622. d ? a ? u = d.rule.children : (l = d.root.indexOf(d.origin), u = d.root) : u = t.rules, u.splice(l, 0, i);
  623. },
  624. hidden(i, o) {
  625. r(o, "hidden", !!i), t.refresh();
  626. },
  627. hiddenStatus(i) {
  628. const o = t.getCtx(i);
  629. if (o)
  630. return !!o.rule.hidden;
  631. },
  632. display(i, o) {
  633. r(o, "display", !!i), t.refresh();
  634. },
  635. displayStatus(i) {
  636. const o = t.getCtx(i);
  637. if (o)
  638. return !!o.rule.display;
  639. },
  640. disabled(i, o) {
  641. e(o).forEach((a) => {
  642. t.getCtxs(a).forEach((l) => {
  643. l.rule.props && E(l.rule.props, "disabled", !!i);
  644. });
  645. }), t.refresh();
  646. },
  647. all(i) {
  648. return Object.keys(t.ctxs).map((o) => {
  649. const a = t.ctxs[o];
  650. return i ? a.origin : a.rule;
  651. });
  652. },
  653. model(i) {
  654. return t.fields().reduce((o, a) => {
  655. const l = t.fieldCtx[a][0];
  656. return o[a] = i ? l.origin : l.rule, o;
  657. }, {});
  658. },
  659. component(i) {
  660. return Object.keys(t.nameCtx).reduce((o, a) => {
  661. const l = t.nameCtx[a].map((u) => i ? u.origin : u.rule);
  662. return o[a] = l.length === 1 ? l[0] : l, o;
  663. }, {});
  664. },
  665. bind() {
  666. return s.form;
  667. },
  668. reload: (i) => {
  669. t.reloadRule(i);
  670. },
  671. updateOptions(i) {
  672. t.fc.updateOptions(i), s.refresh();
  673. },
  674. onSubmit(i) {
  675. s.updateOptions({ onSubmit: i });
  676. },
  677. sync: (i) => {
  678. if (Array.isArray(i)) {
  679. i.forEach((a) => s.sync(a));
  680. return;
  681. }
  682. let o = h.Object(i) ? H(i) : t.getCtxs(i);
  683. o && (o = Array.isArray(o) ? o : [o], o.forEach((a) => {
  684. if (!a.deleted) {
  685. const l = t.subForm[a.id];
  686. l && (Array.isArray(l) ? l.forEach((u) => {
  687. u.refresh();
  688. }) : l && l.refresh()), t.$render.clearCache(a);
  689. }
  690. }), t.refresh());
  691. },
  692. refresh: () => {
  693. n().forEach((i) => {
  694. i.refresh();
  695. }), t.$render.clearCacheAll(), t.refresh();
  696. },
  697. refreshOptions() {
  698. t.$manager.updateOptions(t.options), s.refresh();
  699. },
  700. hideForm: (i) => {
  701. E(t.vm, "isShow", !i);
  702. },
  703. changeStatus: () => t.changeStatus,
  704. clearChangeStatus: () => {
  705. t.changeStatus = !1;
  706. },
  707. updateRule(i, o) {
  708. t.getCtxs(i).forEach((a) => {
  709. p(a.rule, o);
  710. });
  711. },
  712. updateRules(i) {
  713. Object.keys(i).forEach((o) => {
  714. s.updateRule(o, i[o]);
  715. });
  716. },
  717. mergeRule: (i, o) => {
  718. t.getCtxs(i).forEach((a) => {
  719. D(a.rule, o);
  720. });
  721. },
  722. mergeRules(i) {
  723. Object.keys(i).forEach((o) => {
  724. s.mergeRule(o, i[o]);
  725. });
  726. },
  727. getRule: (i, o) => {
  728. const a = t.getCtx(i);
  729. if (a)
  730. return o ? a.origin : a.rule;
  731. },
  732. getRenderRule: (i) => {
  733. const o = t.getCtx(i);
  734. if (o)
  735. return o.prop;
  736. },
  737. getRefRule: (i) => {
  738. const o = t.getCtxs(i);
  739. if (o && o.length) {
  740. const a = o.map((l) => l.rule);
  741. return a.length === 1 ? a[0] : a;
  742. }
  743. },
  744. setEffect(i, o, a) {
  745. const l = t.getCtx(i);
  746. l && o && (o[0] === "$" && (o = o.substr(1)), F(l.rule, "$" + o) && E(l.rule, "$" + o, a), F(l.rule, "effect") || E(l.rule, "effect", {}), E(l.rule.effect, o, a));
  747. },
  748. clearEffectData(i, o) {
  749. const a = t.getCtx(i);
  750. a && (o && o[0] === "$" && (o = o.substr(1)), a.clearEffectData(o), s.sync(i));
  751. },
  752. updateValidate(i, o, a) {
  753. a ? s.mergeRule(i, { validate: o }) : r(i, "validate", o);
  754. },
  755. updateValidates(i, o) {
  756. Object.keys(i).forEach((a) => {
  757. s.updateValidate(a, i[a], o);
  758. });
  759. },
  760. refreshValidate() {
  761. t.vm.validate = {}, s.refresh();
  762. },
  763. resetFields(i) {
  764. e(i).forEach((o) => {
  765. t.getCtxs(o).forEach((a) => {
  766. t.$render.clearCache(a), a.rule.value = J(a.defaultValue);
  767. });
  768. }), t.vm.$nextTick(() => {
  769. s.clearValidateState();
  770. }), i == null && (h.Function(t.options.onReset) && R(() => t.options.onReset(s)), t.vm.$emit("reset", s));
  771. },
  772. method(i, o) {
  773. const a = s.el(i);
  774. if (!a || !a[o])
  775. throw new Error(se("err", `${o}方法不存在`));
  776. return (...l) => a[o](...l);
  777. },
  778. exec(i, o, ...a) {
  779. return R(() => s.method(i, o)(...a));
  780. },
  781. toJson(i) {
  782. return De(s.rule, i);
  783. },
  784. trigger(i, o, ...a) {
  785. const l = s.el(i);
  786. l && l.$emit(o, ...a);
  787. },
  788. el(i) {
  789. const o = t.getCtx(i);
  790. if (o) return o.exportEl || o.el || t.vm.$refs[o.ref];
  791. },
  792. closeModal: (i) => {
  793. const o = s.el(i);
  794. o && o.$emit && o.$emit("close-modal");
  795. },
  796. getSubForm(i) {
  797. const o = t.getCtx(i);
  798. return o ? t.subForm[o.id] : void 0;
  799. },
  800. nextTick(i) {
  801. t.bus.$once("next-tick", i), t.refresh();
  802. },
  803. nextRefresh(i) {
  804. t.nextRefresh(), i && R(i);
  805. },
  806. emit(i, ...o) {
  807. t.vm.$emit(i, ...o);
  808. },
  809. deferSyncValue(i, o) {
  810. t.deferSyncValue(i, o);
  811. },
  812. fetch(i) {
  813. return new Promise((o, a) => {
  814. t.beforeFetch(i).then(() => ht(i).then(o).catch(a));
  815. });
  816. },
  817. getData(i, o) {
  818. return t.fc.getData(i, o);
  819. },
  820. setData(i, o) {
  821. return t.fc.setData(i, o);
  822. },
  823. helper: {
  824. tidyFields: e,
  825. props: r
  826. }
  827. };
  828. return ["on", "once", "off", "set", "emit"].forEach((i) => {
  829. s[i] = function(...o) {
  830. t.vm[`$${i}`](...o);
  831. };
  832. }), s.changeValue = s.changeField = s.setValue, s;
  833. }
  834. function pt(t) {
  835. p(t.prototype, {
  836. initCache() {
  837. this.clearCacheAll();
  838. },
  839. clearCache(e) {
  840. if (e.rule.cache)
  841. return;
  842. if (!this.cache[e.id]) {
  843. e.parent && this.clearCache(e.parent);
  844. return;
  845. }
  846. (this.cache[e.id].use === !0 || this.cache[e.id].parent) && this.$handle.refresh();
  847. const r = this.cache[e.id].parent;
  848. this.cache[e.id] = null, r && this.clearCache(r);
  849. },
  850. clearCacheAll() {
  851. this.cache = {};
  852. },
  853. setCache(e, r, n) {
  854. this.cache[e.id] = {
  855. vnode: r,
  856. use: !1,
  857. parent: n,
  858. slot: e.rule.slot
  859. };
  860. },
  861. getCache(e) {
  862. const r = this.cache[e.id];
  863. if (r)
  864. return r.use = !0, r.vnode;
  865. }
  866. });
  867. }
  868. function S(t) {
  869. const e = t.replace(/(-[a-z])/g, function(r) {
  870. return r.replace("-", "").toLocaleUpperCase();
  871. });
  872. return Ue(e);
  873. }
  874. function Ue(t) {
  875. return t.replace(t[0], t[0].toLowerCase());
  876. }
  877. function mt(t) {
  878. return t == null ? "" : typeof t == "object" ? JSON.stringify(t, null, 2) : String(t);
  879. }
  880. function K(t) {
  881. let e = t.replace(/([A-Z])/g, "-$1").toLocaleLowerCase();
  882. return e.indexOf("-") === 0 && (e = e.substr(1)), e;
  883. }
  884. let yt = 0;
  885. function G() {
  886. const t = 370 + ++yt;
  887. return "F" + Math.random().toString(36).substr(3, 3) + (+`${Date.now()}`).toString(36) + t.toString(36) + "c";
  888. }
  889. function W(t, e, r) {
  890. let n = t, s;
  891. return (e || "").split(".").forEach((i) => {
  892. s && ((!n[s] || typeof n[s] != "object") && (n[s] = {}), n = n[s]), s = i;
  893. }), n[s] = r, n;
  894. }
  895. function gt(t) {
  896. p(t.prototype, {
  897. initRender() {
  898. this.tempList = {}, this.clearOrgChildren();
  899. },
  900. initOrgChildren() {
  901. const e = this.$handle.ctxs;
  902. this.orgChildren = Object.keys(e).reduce((r, n) => {
  903. if (e[n].parser.loadChildren !== !1) {
  904. const s = e[n].rule.children;
  905. r[n] = h.trueArray(s) ? [...s] : [];
  906. }
  907. return r;
  908. }, {});
  909. },
  910. clearOrgChildren() {
  911. this.orgChildren = {};
  912. },
  913. getTypeSlot(e) {
  914. const r = (n) => {
  915. if (n) {
  916. let s;
  917. return e.rule.field && (s = n.$scopedSlots["field-" + K(e.rule.field)] || n.$scopedSlots["field-" + e.rule.field]), s || (s = n.$scopedSlots["type-" + K(e.type)] || n.$scopedSlots["type-" + e.type]), s || r(n.$pfc);
  918. }
  919. };
  920. return r(this.vm);
  921. },
  922. render() {
  923. if (!this.vm.isShow)
  924. return;
  925. this.$h = this.vm.$createElement, this.$manager.beforeRender();
  926. let e;
  927. const r = () => this.renderList();
  928. return r.renderSlot = (n) => this.renderList(n), r.renderName = (n) => this.renderId(n), r.renderField = (n) => this.renderId(n, "field"), this.vm.$scopedSlots.container ? e = [this.vm.$scopedSlots.container(r)] : e = r(), this.$manager.render(e);
  929. },
  930. renderList(e) {
  931. return this.sort.map((r) => e ? this.renderSlot(this.$handle.ctxs[r], e) : this.renderCtx(this.$handle.ctxs[r])).filter((r) => r !== void 0);
  932. },
  933. makeVm(e) {
  934. const r = e.vm;
  935. if (r) {
  936. if (h.Function(r))
  937. return R(() => e.vm(this.$handle.getInjectData(e)));
  938. if (!r._isVue)
  939. return new w(r);
  940. } else return new w();
  941. return r;
  942. },
  943. mergeGlobal(e) {
  944. const r = this.$handle.options.global;
  945. r && (e.cacheConfig || (e.cacheConfig = r[e.originType] || r[e.type] || r[e.trueType] || {}), e.prop = D({}, [r["*"], e.cacheConfig, e.prop]));
  946. },
  947. setOptions(e) {
  948. e.prop.optionsTo && e.prop.options && W(e.prop, e.prop.optionsTo, e.prop.options);
  949. },
  950. deepSet(e) {
  951. const r = e.rule.deep;
  952. r && Object.keys(r).sort((n, s) => n.length < s.length ? -1 : 1).forEach((n) => {
  953. W(e.prop, n, r[n]);
  954. });
  955. },
  956. setTempProps(e, r) {
  957. if (!e.$props) return;
  958. const { prop: n } = r, s = Object.keys(e.$props), i = this.injectProp(r), o = Object.keys(i);
  959. s.forEach((l) => {
  960. F(n.props, l) ? e.$props[l] = n.props[l] : o.indexOf(l) > -1 && (e.$props[l] = i[l]);
  961. });
  962. const a = e.$options.model && e.$options.model.prop || "value";
  963. s.indexOf(a) > -1 && (e.$props[a] = n.value);
  964. },
  965. renderTemp(e) {
  966. if (!w.compile)
  967. return st("当前使用的Vue构建版本不支持compile,无法使用template功能"), [];
  968. const r = e.prop, { id: n, key: s } = e;
  969. if (!this.tempList[n]) {
  970. e.el || (e.el = this.makeVm(r), this.vm.$nextTick(() => e.parser.mounted(e)));
  971. let l = e.el;
  972. e.input && l.$on(l.$options.model && l.$options.model.event || "input", (u) => {
  973. this.onInput(e, u);
  974. }), this.tempList[n] = {
  975. vm: l,
  976. template: w.compile(r.template)
  977. };
  978. }
  979. const { vm: i, template: o } = this.tempList[n];
  980. this.setTempProps(i, e);
  981. const a = o.render.call(i);
  982. return h.Undef(a.data) && (a.data = {}), a.key = s, a.data.ref = e.ref, a.data.key = s, a;
  983. },
  984. parseSide(e, r) {
  985. return h.Object(e) ? D({ props: { formCreateInject: r.prop.props.formCreateInject } }, e) : e;
  986. },
  987. renderSides(e, r, n) {
  988. const s = r[n ? "rule" : "prop"];
  989. return [this.renderRule(this.parseSide(s.prefix, r)), e, this.renderRule(this.parseSide(s.suffix, r))];
  990. },
  991. renderSlot(e, r) {
  992. return e.rule.slot === r ? this.renderCtx(e) : void 0;
  993. },
  994. renderId(e, r) {
  995. const n = this.$handle[r === "field" ? "fieldCtx" : "nameCtx"][e];
  996. return n ? n.map((s) => this.renderCtx(s, s.parent)) : void 0;
  997. },
  998. renderCtx(e, r) {
  999. if (e.type === "hidden") return;
  1000. const n = e.rule;
  1001. if (!this.cache[e.id] || this.cache[e.id].slot !== n.slot) {
  1002. let s, i = n.cache !== !1;
  1003. const o = e.trueType, a = !(h.Undef(n.display) || n.display);
  1004. if (o === "template" && !n.template)
  1005. s = this.renderSides(this.renderChildren(e), e, !0), a && this.display(s), s = this.item(e, s);
  1006. else if (o === "fcFragment")
  1007. s = this.renderChildren(e);
  1008. else {
  1009. e.initProp(), this.mergeGlobal(e), this.$manager.tidyRule(e), this.deepSet(e), this.setOptions(e), this.ctxProp(e);
  1010. let l = e.prop;
  1011. l.preview = !!(F(l, "preview") ? l.preview : this.options.preview), l.props.formCreateInject = this.injectProp(e);
  1012. const u = l.preview;
  1013. if (l.hidden) {
  1014. this.setCache(e, void 0, r);
  1015. return;
  1016. }
  1017. if (o === "template" && l.template)
  1018. s = this.renderTemp(e), i = !1;
  1019. else {
  1020. let d = [];
  1021. e.parser.renderChildren ? d = e.parser.renderChildren(e) : e.parser.loadChildren !== !1 && (d = this.renderChildren(e));
  1022. const m = this.getTypeSlot(e);
  1023. m ? s = m({
  1024. rule: n,
  1025. prop: l,
  1026. preview: u,
  1027. children: d,
  1028. api: this.$handle.api,
  1029. model: l.model || {}
  1030. }) : s = u ? e.parser.preview(d, e) : e.parser.render(d, e);
  1031. }
  1032. s = this.renderSides(s, e), !(!e.input && h.Undef(l.native)) && l.native !== !0 && (s = this.$manager.makeWrap(e, s)), a && (s = this.display(s)), s = this.item(e, s);
  1033. }
  1034. return i && this.setCache(e, s, r), s;
  1035. }
  1036. return this.getCache(e);
  1037. },
  1038. display(e) {
  1039. if (Array.isArray(e)) {
  1040. const r = [];
  1041. return e.forEach((n) => {
  1042. if (Array.isArray(n)) return this.display(n);
  1043. this.none(n) && r.push(n);
  1044. }), r;
  1045. } else
  1046. return this.none(e);
  1047. },
  1048. none(e) {
  1049. if (e && e.data)
  1050. return Array.isArray(e.data.style) ? e.data.style.push({ display: "none" }) : h.String(e.data.style) ? e.data.style += ";display:none;" : e.data.style = [e.data.style, { display: "none" }], e;
  1051. },
  1052. item(e, r) {
  1053. return this.$h("fcFragment", {
  1054. slot: e.rule.slot,
  1055. key: e.key
  1056. }, [r]);
  1057. },
  1058. injectProp(e) {
  1059. this.vm.ctxInject[e.id] || E(this.vm.ctxInject, e.id, {
  1060. api: this.$handle.api,
  1061. form: this.fc.create,
  1062. subForm: (n) => {
  1063. this.$handle.addSubForm(e, n);
  1064. },
  1065. getSubForm: () => this.$handle.subForm[e.id],
  1066. options: [],
  1067. children: [],
  1068. prop: {},
  1069. preview: !1,
  1070. id: e.id,
  1071. field: e.field,
  1072. rule: e.rule,
  1073. input: e.input
  1074. });
  1075. const r = this.vm.ctxInject[e.id];
  1076. return p(r, {
  1077. preview: e.prop.preview,
  1078. options: e.prop.options,
  1079. children: e.rule.children,
  1080. prop: function() {
  1081. const n = $({}, e.prop);
  1082. return n.on = n.on ? $({}, n.on) : {}, delete n.model, n;
  1083. }()
  1084. }), r;
  1085. },
  1086. ctxProp(e) {
  1087. const { ref: r, key: n, rule: s } = e;
  1088. this.$manager.mergeProp(e), e.parser.mergeProp(e);
  1089. const i = [
  1090. {
  1091. ref: r,
  1092. key: s.key || `${n}fc`,
  1093. slot: void 0,
  1094. on: {
  1095. "hook:mounted": () => {
  1096. this.onMounted(e);
  1097. },
  1098. "fc.sub-form": (o) => {
  1099. this.$handle.addSubForm(e, o);
  1100. },
  1101. "fc.el": (o) => {
  1102. e.exportEl = o, o && ((o.$el || o).__rule__ = e.rule);
  1103. }
  1104. }
  1105. }
  1106. ];
  1107. return e.input && (this.vm.$props.disabled === !0 && (e.prop.props.disabled = !0), e.prop.model = {
  1108. value: this.$handle.getFormData(e),
  1109. callback: (o) => {
  1110. this.onInput(e, o);
  1111. },
  1112. expression: `formData.${e.id}`
  1113. }), q(i, e.prop), e.prop;
  1114. },
  1115. onMounted(e) {
  1116. e.el = this.vm.$refs[e.ref], e.el && ((e.el.$el || e.el).__rule__ = e.rule), e.parser.mounted(e), this.$handle.effect(e, "mounted");
  1117. },
  1118. onInput(e, r) {
  1119. this.$handle.onInput(e, r);
  1120. },
  1121. renderChildren(e) {
  1122. const { children: r } = e.rule, n = this.orgChildren[e.id], s = (i) => !h.String(i) && i.__fc__ && !this.$handle.ctxs[i.__fc__.id];
  1123. return !h.trueArray(r) && n ? (this.$handle.deferSyncValue(() => {
  1124. n.forEach((i) => {
  1125. i && s(i) && this.$handle.rmCtx(i.__fc__);
  1126. });
  1127. }), this.orgChildren[e.id] = [], []) : (n && this.$handle.deferSyncValue(() => {
  1128. n.forEach((i) => {
  1129. i && r.indexOf(i) === -1 && s(i) && this.$handle.rmCtx(i.__fc__);
  1130. });
  1131. }), r.map((i) => {
  1132. if (i) {
  1133. if (h.String(i)) return i;
  1134. if (i.__fc__)
  1135. return this.renderCtx(i.__fc__, e);
  1136. i.type && this.vm.$nextTick(() => {
  1137. this.$handle.loadChildren(r, e), this.$handle.refresh();
  1138. });
  1139. }
  1140. }));
  1141. },
  1142. defaultRender(e, r) {
  1143. const n = e.prop;
  1144. return n.component ? this.vNode.makeComponent(n.component, n, r) : this.vNode[e.type] ? this.vNode[e.type](n, r) : this.vNode[e.originType] ? this.vNode[e.originType](n, r) : this.vNode.make(Ue(e.originType), n, r);
  1145. },
  1146. renderRule(e, r, n) {
  1147. if (!e) return;
  1148. if (h.String(e)) return e;
  1149. let s;
  1150. if (n)
  1151. s = e.type;
  1152. else if (s = e.is, e.type) {
  1153. s = S(e.type);
  1154. const o = this.vNode.aliasMap[s];
  1155. o && (s = S(o));
  1156. }
  1157. if (!s) return;
  1158. let i = [[r]];
  1159. return h.trueArray(e.children) && i.push(e.children.map((o) => this.renderRule(o))), this.$h(s, $({}, e), i);
  1160. }
  1161. });
  1162. }
  1163. function fe(t) {
  1164. p(this, {
  1165. $handle: t,
  1166. fc: t.fc,
  1167. vm: t.vm,
  1168. $manager: t.$manager,
  1169. vNode: new t.fc.CreateNode(t.vm)
  1170. }), Ie(this, {
  1171. options() {
  1172. return t.options;
  1173. },
  1174. sort() {
  1175. return t.sort;
  1176. }
  1177. }), this.initCache(), this.initRender();
  1178. }
  1179. pt(fe);
  1180. gt(fe);
  1181. function $t(t) {
  1182. p(t.prototype, {
  1183. parseInjectEvent(e, r) {
  1184. const n = e.inject || this.options.injectEvent;
  1185. return this.parseEventLst(e, r, n);
  1186. },
  1187. parseEventLst(e, r, n, s) {
  1188. return Object.keys(r).forEach((i) => {
  1189. const o = this.parseEvent(e, r[i], n, s);
  1190. o && (r[i] = o);
  1191. }), r;
  1192. },
  1193. parseEvent(e, r, n, s) {
  1194. if (h.Function(r) && (n !== !1 && !h.Undef(n) || r.__inject))
  1195. return this.inject(e, r, n);
  1196. if (!s && Array.isArray(r) && r[0] && (h.String(r[0]) || h.Function(r[0])))
  1197. return this.parseEventLst(e, r, n, !0);
  1198. if (h.String(r)) {
  1199. const i = P(r);
  1200. if (i && r !== i)
  1201. return i.__inject ? this.parseEvent(e, i, n, !0) : i;
  1202. }
  1203. },
  1204. parseEmit(e, r) {
  1205. let n = {}, s = e.rule, { emitPrefix: i, field: o, name: a, inject: l } = s, u = s[r ? "emit" : "nativeEmit"] || [];
  1206. return h.trueArray(u) && u.forEach((d) => {
  1207. if (!d) return;
  1208. let m, _ = i || o || a;
  1209. if (h.Object(d) && (m = d.inject, d = d.name, _ = d.prefix || _), _) {
  1210. r || (_ = `native-${_}`);
  1211. const O = K(`${_}-${d}`), y = (...b) => {
  1212. this.vm.$emit(O, ...b), this.vm.$emit("emit-event", O, ...b);
  1213. };
  1214. if (y.__emit = !0, !m && l === !1)
  1215. n[d] = y;
  1216. else {
  1217. let b = m || l || this.options.injectEvent;
  1218. n[d] = h.Undef(b) ? y : this.inject(s, y, b);
  1219. }
  1220. }
  1221. }), e.computed[r ? "on" : "nativeOn"] = n, n;
  1222. },
  1223. getInjectData(e, r) {
  1224. const { option: n, rule: s } = this.vm.$options.propsData;
  1225. return {
  1226. api: this.api,
  1227. $f: this.api,
  1228. rule: s,
  1229. self: e.__origin__,
  1230. option: n,
  1231. inject: r
  1232. };
  1233. },
  1234. inject(e, r, n) {
  1235. if (r.__origin) {
  1236. if (this.watching && !this.loading)
  1237. return r;
  1238. r = r.__origin;
  1239. }
  1240. const s = this, i = function(...o) {
  1241. const a = s.getInjectData(e, n);
  1242. return a.args = [...o], o.unshift(a), r.apply(this, o);
  1243. };
  1244. return i.__origin = r, i.__json = r.__json, i;
  1245. }
  1246. });
  1247. }
  1248. const ve = ["hook:updated", "hook:mounted"];
  1249. function _t(t) {
  1250. p(t.prototype, {
  1251. usePage() {
  1252. const e = this.options.page;
  1253. if (!e) return;
  1254. let r = 25, n = Ct(this.rules);
  1255. h.Object(e) && (e.first && (r = parseInt(e.first, 10) || r), e.limit && (n = parseInt(e.limit, 10) || n)), p(this, {
  1256. first: r,
  1257. limit: n,
  1258. pageEnd: this.rules.length <= r
  1259. }), this.bus.$on("page-end", () => this.vm.$emit("page-end", this.api)), this.pageLoad();
  1260. },
  1261. pageLoad() {
  1262. const e = () => {
  1263. this.pageEnd ? (this.vm.$off(ve, e), this.bus.$emit("page-end")) : (this.first += this.limit, this.pageEnd = this.rules.length <= this.first, this.loadRule(), this.refresh());
  1264. };
  1265. this.vm.$on(ve, e);
  1266. }
  1267. });
  1268. }
  1269. function Ct(t) {
  1270. return t.length < 31 ? 31 : Math.ceil(t.length / 3);
  1271. }
  1272. function Ot(t) {
  1273. p(t.prototype, {
  1274. clearNextTick() {
  1275. this.nextTick && clearTimeout(this.nextTick), this.nextTick = null;
  1276. },
  1277. bindNextTick(e) {
  1278. this.clearNextTick(), this.nextTick = setTimeout(() => {
  1279. e(), this.nextTick = null;
  1280. }, 10);
  1281. },
  1282. render() {
  1283. return ++this.loadedId, this.vm.unique > 0 ? this.$render.render() : (this.vm.unique = 1, []);
  1284. }
  1285. });
  1286. }
  1287. function bt(t) {
  1288. Object.defineProperties(t.origin, {
  1289. __fc__: te(t, !0)
  1290. }), t.rule !== t.origin && Object.defineProperties(t.rule, {
  1291. __fc__: te(t, !0)
  1292. });
  1293. }
  1294. function Be(t, e, r) {
  1295. const n = G();
  1296. p(this, {
  1297. id: n,
  1298. ref: n,
  1299. wrapRef: n + "fi",
  1300. rule: e,
  1301. origin: e.__origin__ || e,
  1302. name: e.name,
  1303. watch: [],
  1304. linkOn: [],
  1305. root: [],
  1306. ctrlRule: [],
  1307. parent: null,
  1308. cacheConfig: null,
  1309. prop: $({}, e),
  1310. computed: {},
  1311. payload: {},
  1312. input: !!e.field,
  1313. el: void 0,
  1314. exportEl: void 0,
  1315. defaultValue: e.field ? T(r) : void 0,
  1316. field: e.field || void 0
  1317. }), this.updateKey(), bt(this), this.update(t, !0);
  1318. }
  1319. p(Be.prototype, {
  1320. effectData(t) {
  1321. return this.payload[t] || (this.payload[t] = {}), this.payload[t];
  1322. },
  1323. clearEffectData(t) {
  1324. t === void 0 ? this.payload = {} : delete this.payload[t];
  1325. },
  1326. updateKey(t) {
  1327. this.key = G(), t && this.parent && this.parent.updateKey(t);
  1328. },
  1329. updateType() {
  1330. this.originType = this.rule.type, this.type = S(this.rule.type), this.trueType = this.$handle.getType(this.originType);
  1331. },
  1332. setParser(t) {
  1333. this.parser = t, t.init(this);
  1334. },
  1335. initProp() {
  1336. const t = $({}, this.rule);
  1337. delete t.children, this.prop = D({}, [t, ...Object.keys(this.payload).map((e) => this.payload[e]), this.computed]);
  1338. },
  1339. injectValidate() {
  1340. return M(this.prop.validate).map((t) => {
  1341. if (h.Function(t.validator)) {
  1342. const e = $({}, t), r = this;
  1343. return e.validator = function(...n) {
  1344. return t.validator.call({
  1345. that: this,
  1346. id: r.id,
  1347. field: r.field,
  1348. rule: r.rule,
  1349. api: r.$handle.api
  1350. }, ...n);
  1351. }, e;
  1352. }
  1353. return t;
  1354. });
  1355. },
  1356. check(t) {
  1357. return this.vm === t.vm;
  1358. },
  1359. unwatch() {
  1360. this.watch.forEach((t) => t()), this.watch = [];
  1361. },
  1362. unlink() {
  1363. this.linkOn.forEach((t) => t()), this.linkOn = [];
  1364. },
  1365. link() {
  1366. this.unlink(), this.$handle.appendLink(this);
  1367. },
  1368. watchTo() {
  1369. this.$handle.watchCtx(this);
  1370. },
  1371. delete() {
  1372. this.unwatch(), this.unlink(), this.rmCtrl(), p(this, {
  1373. deleted: !0,
  1374. prop: $({}, this.rule),
  1375. computed: {},
  1376. el: void 0,
  1377. $handle: void 0,
  1378. $render: void 0,
  1379. $api: void 0,
  1380. vm: void 0,
  1381. vNode: void 0,
  1382. parent: null,
  1383. cacheConfig: null
  1384. });
  1385. },
  1386. rmCtrl() {
  1387. this.ctrlRule.forEach((t) => t.__fc__ && t.__fc__.rm()), this.ctrlRule = [];
  1388. },
  1389. rm() {
  1390. const t = () => {
  1391. let e = this.root.indexOf(this.origin);
  1392. e > -1 && (this.root.splice(e, 1), this.$handle && this.$handle.refresh());
  1393. };
  1394. if (this.deleted) {
  1395. t();
  1396. return;
  1397. }
  1398. this.$handle.noWatch(() => {
  1399. this.$handle.deferSyncValue(() => {
  1400. this.rmCtrl(), t(), this.$handle.rmCtx(this), p(this, {
  1401. root: []
  1402. });
  1403. }, this.input);
  1404. });
  1405. },
  1406. update(t, e) {
  1407. p(this, {
  1408. deleted: !1,
  1409. $handle: t,
  1410. $render: t.$render,
  1411. $api: t.api,
  1412. vm: t.vm,
  1413. vNode: t.$render.vNode,
  1414. updated: !1,
  1415. cacheValue: this.rule.value
  1416. }), !e && this.unwatch(), this.watchTo(), this.link(), this.updateType();
  1417. }
  1418. });
  1419. function Et(t) {
  1420. p(t.prototype, {
  1421. nextRefresh(e) {
  1422. const r = this.loadedId;
  1423. this.vm.$nextTick(() => {
  1424. r === this.loadedId && (e ? e() : this.refresh());
  1425. });
  1426. },
  1427. parseRule(e) {
  1428. const r = Ce(e);
  1429. return Object.defineProperties(r, {
  1430. __origin__: te(e, !0)
  1431. }), vt(r), this.appendValue(r), r.options = Array.isArray(r.options) ? r.options : [], [r, r.prefix, r.suffix].forEach((n) => {
  1432. n && this.loadFn(n, r);
  1433. }), this.loadCtrl(r), r.update && (r.update = P(r.update)), r;
  1434. },
  1435. loadFn(e, r) {
  1436. ["on", "props", "nativeOn", "deep"].forEach((n) => {
  1437. e[n] && this.parseInjectEvent(r, e[n]);
  1438. });
  1439. },
  1440. loadCtrl(e) {
  1441. e.control && e.control.forEach((r) => {
  1442. r.handle && (r.handle = P(r.handle));
  1443. });
  1444. },
  1445. syncProp(e) {
  1446. const r = e.rule;
  1447. h.trueArray(r.sync) && q([{
  1448. on: r.sync.reduce((n, s) => (n[`update:${s}`] = (i) => {
  1449. r.props[s] = i, this.vm.$emit("sync", s, i, r, this.fapi);
  1450. }, n), {})
  1451. }], e.computed);
  1452. },
  1453. loadRule() {
  1454. this.cycleLoad = !1, this.loading = !0, this.pageEnd && this.bus.$emit("load-start"), this.deferSyncValue(() => {
  1455. if (this._loadRule(this.rules), this.loading = !1, this.cycleLoad && this.pageEnd)
  1456. return this.loadRule();
  1457. this.pageEnd && this.bus.$emit("load-end"), this.vm._renderRule(), this.$render.initOrgChildren(), this.syncForm();
  1458. });
  1459. },
  1460. loadChildren(e, r) {
  1461. if (this.cycleLoad = !1, this.loading = !0, this.bus.$emit("load-start"), this._loadRule(e, r), this.loading = !1, this.cycleLoad)
  1462. return this.loadRule();
  1463. this.bus.$emit("load-end"), this.syncForm(), this.$render.clearCache(r);
  1464. },
  1465. _loadRule(e, r) {
  1466. const n = (i) => {
  1467. let o = e[i - 1];
  1468. if (!o || !o.__fc__)
  1469. return i > 0 ? n(i - 1) : -1;
  1470. let a = this.sort.indexOf(o.__fc__.id);
  1471. return a > -1 ? a : n(i - 1);
  1472. }, s = (i, o) => {
  1473. h.trueArray(i) && this._loadRule(i, o);
  1474. };
  1475. e.map((i, o) => {
  1476. if (r && !h.Object(i) || !this.pageEnd && !r && o >= this.first) return;
  1477. if (i.__fc__ && i.__fc__.root === e && this.ctxs[i.__fc__.id])
  1478. return s(i.__fc__.rule.children, i.__fc__), i.__fc__;
  1479. let a = Ce(i);
  1480. const l = () => !!(a.field && this.fieldCtx[a.field] && this.fieldCtx[a.field][0] !== i.__fc__);
  1481. this.ruleEffect(a, "init", { repeat: l() }), l() && this.vm.$emit("repeat-field", i, this.api);
  1482. let u, d = !1, m = !!i.__fc__, _ = a.value;
  1483. if (m) {
  1484. u = i.__fc__, _ = u.defaultValue;
  1485. const y = !u.check(this);
  1486. if (u.deleted) {
  1487. if (y) {
  1488. if (Fe(u))
  1489. return;
  1490. u.update(this);
  1491. }
  1492. } else if (y) {
  1493. if (Fe(u))
  1494. return;
  1495. e[o] = i = i._clone ? i._clone() : ae(i), u = null, d = !0;
  1496. }
  1497. }
  1498. if (u)
  1499. u.originType !== u.rule.type && u.updateType(), this.bindParser(u), this.appendValue(u.rule);
  1500. else {
  1501. const y = this.parseRule(i);
  1502. u = new Be(this, y, _), this.bindParser(u);
  1503. }
  1504. if ([!1, !0].forEach((y) => this.parseEmit(u, y)), this.syncProp(u), u.parent = r || null, u.root = e, this.setCtx(u), !d && !m && this.effect(u, "load"), this.effect(u, "created"), u.parser.loadChildren === !1 || s(u.rule.children, u), !r) {
  1505. const y = n(o);
  1506. y > -1 || !o ? this.sort.splice(y + 1, 0, u.id) : this.sort.push(u.id);
  1507. }
  1508. const O = u.rule;
  1509. return u.updated || (u.updated = !0, h.Function(O.update) && this.bus.$once("load-end", () => {
  1510. this.refreshUpdate(u, O.value, "init");
  1511. }), this.effect(u, "loaded")), u.input && Object.defineProperty(O, "value", this.valueHandle(u)), this.refreshControl(u) && (this.cycleLoad = !0), u;
  1512. });
  1513. },
  1514. refreshControl(e) {
  1515. return e.input && e.rule.control && this.useCtrl(e);
  1516. },
  1517. useCtrl(e) {
  1518. const r = Ft(e), n = [], s = this.api;
  1519. if (!r.length) return !1;
  1520. for (let a = 0; a < r.length; a++) {
  1521. const l = r[a], u = l.handle || function(m) {
  1522. return (L[l.condition || "=="] || L["=="])(m, l.value);
  1523. };
  1524. if (!h.trueArray(l.rule)) continue;
  1525. const d = N($({}, l), {
  1526. valid: R(() => u(e.rule.value, s)),
  1527. ctrl: St(e, l.rule),
  1528. isHidden: h.String(l.rule[0])
  1529. });
  1530. d.valid && d.ctrl || !d.valid && !d.ctrl && !d.isHidden || n.push(d);
  1531. }
  1532. if (!n.length) return !1;
  1533. const i = [];
  1534. let o = !1;
  1535. return this.deferSyncValue(() => {
  1536. n.reverse().forEach(({ isHidden: a, valid: l, rule: u, prepend: d, append: m, child: _, ctrl: O, method: y }) => {
  1537. if (a) {
  1538. l ? e.ctrlRule.push({
  1539. __ctrl: !0,
  1540. children: u,
  1541. valid: l
  1542. }) : O && e.ctrlRule.splice(e.ctrlRule.indexOf(O) >>> 0, 1), i[l ? "push" : "unshift"](() => {
  1543. y === "disabled" || y === "enabled" ? this.api.disabled(!l, u) : y === "display" ? this.api.display(l, u) : y === "required" ? (u.forEach((b) => {
  1544. this.api.setEffect(b, "required", l);
  1545. }), l || this.api.clearValidateState(u)) : this.api.hidden(!l, u);
  1546. });
  1547. return;
  1548. }
  1549. if (l) {
  1550. o = !0;
  1551. const b = {
  1552. type: "fcFragment",
  1553. native: !0,
  1554. __ctrl: !0,
  1555. children: u
  1556. };
  1557. e.ctrlRule.push(b), this.bus.$once("load-start", () => {
  1558. d ? s.prepend(b, d, _) : m || _ ? s.append(b, m || e.id, _) : e.root.splice(e.root.indexOf(e.origin) + 1, 0, b);
  1559. });
  1560. } else {
  1561. e.ctrlRule.splice(e.ctrlRule.indexOf(O), 1);
  1562. const b = H(O);
  1563. b && b.rm();
  1564. }
  1565. });
  1566. }), i.length && this.vm.$nextTick(() => {
  1567. i.forEach((a) => a());
  1568. }), this.vm.$emit("control", e.origin, this.api), this.effect(e, "control"), o;
  1569. },
  1570. reloadRule(e) {
  1571. return this._reloadRule(e);
  1572. },
  1573. _reloadRule(e) {
  1574. e || (e = this.rules);
  1575. const r = $({}, this.ctxs);
  1576. this.clearNextTick(), this.$render.clearOrgChildren(), this.initData(e), this.fc.rules = e, this.deferSyncValue(() => {
  1577. this.bus.$once("load-end", () => {
  1578. Object.keys(r).filter((n) => this.ctxs[n] === void 0).forEach((n) => this.rmCtx(r[n])), this.$render.clearCacheAll();
  1579. }), this.reloading = !0, this.loadRule(), this.reloading = !1, this.refresh(), this.vm.$emit("reloading", this.api);
  1580. }), this.vm.$emit("update", this.api);
  1581. },
  1582. //todo 组件生成全部通过 alias
  1583. refresh() {
  1584. this.vm._refresh();
  1585. }
  1586. });
  1587. }
  1588. function vt(t) {
  1589. const e = Ne();
  1590. return Object.keys(e).forEach((r) => {
  1591. F(t, r) || E(t, r, e[r]);
  1592. }), t;
  1593. }
  1594. function Ft(t) {
  1595. const e = t.rule.control || [];
  1596. return h.Object(e) ? [e] : e;
  1597. }
  1598. function St(t, e) {
  1599. for (let r = 0; r < t.ctrlRule.length; r++) {
  1600. const n = t.ctrlRule[r];
  1601. if (n.children === e)
  1602. return n;
  1603. }
  1604. }
  1605. function Fe(t) {
  1606. return !!t.rule.__ctrl;
  1607. }
  1608. function Rt(t) {
  1609. p(t.prototype, {
  1610. getValue(e) {
  1611. return h.Undef(e.cacheValue) && (e.cacheValue = e.parser.toValue(this.getFormData(e), e)), e.cacheValue;
  1612. },
  1613. setValue(e, r, n, s) {
  1614. e.deleted || (e.cacheValue = r, this.changeStatus = !0, this.nextRefresh(), this.$render.clearCache(e), this.setFormData(e, n), this.syncValue(), this.valueChange(e, r), this.vm.$emit("change", e.field, r, e.origin, this.api, s || !1), this.effect(e, "value"), this.emitEvent("change", e.field, r, {
  1615. rule: e.origin,
  1616. api: this.api,
  1617. setFlag: s || !1
  1618. }));
  1619. },
  1620. onInput(e, r) {
  1621. let n;
  1622. e.input && (this.isQuote(e, n = e.parser.toValue(r, e)) || this.isChange(e, n)) && this.setValue(e, n, r);
  1623. },
  1624. setFormData(e, r) {
  1625. E(this.formData, e.id, r === null ? void 0 : r);
  1626. },
  1627. getFormData(e) {
  1628. return this.formData[e.id];
  1629. },
  1630. validate() {
  1631. return Re(this.vm.validate), this.fields().forEach((e) => {
  1632. this.fieldCtx[e].forEach((r) => {
  1633. this.vm.validate[r.id] = M(r.rule.validate);
  1634. });
  1635. }), this.vm.validate;
  1636. },
  1637. syncForm() {
  1638. Re(this.form), Object.defineProperties(this.form, this.fields().reduce((e, r) => {
  1639. const n = this.getFieldCtx(r), s = this.valueHandle(n);
  1640. return s.configurable = !0, e[r] = s, e;
  1641. }, this.options.appendValue !== !1 ? Object.keys(this.appendData).reduce((e, r) => (e[r] = {
  1642. enumerable: !0,
  1643. configurable: !0,
  1644. get: () => this.appendData[r],
  1645. set: (n) => {
  1646. this.appendData[r] = n;
  1647. }
  1648. }, e), {}) : {})), this.syncValue();
  1649. },
  1650. valueHandle(e) {
  1651. return {
  1652. enumerable: !0,
  1653. get: () => this.getValue(e),
  1654. set: (r) => {
  1655. this.isChange(e, r) && this.setValue(e, r, e.parser.toFormValue(r, e), !0);
  1656. }
  1657. };
  1658. },
  1659. appendValue(e) {
  1660. !e.field || !F(this.appendData, e.field) || (e.value = this.appendData[e.field], delete this.appendData[e.field]);
  1661. },
  1662. addSubForm(e, r) {
  1663. this.subForm[e.id] = r;
  1664. },
  1665. deferSyncValue(e, r) {
  1666. this.deferSyncFn || (this.deferSyncFn = e), this.deferSyncFn.sync || (this.deferSyncFn.sync = r), R(e), this.deferSyncFn === e && (this.deferSyncFn = null, e.sync && this.syncValue());
  1667. },
  1668. syncValue() {
  1669. if (this.deferSyncFn)
  1670. return this.deferSyncFn.sync = !0;
  1671. this.vm._updateValue($($({}, this.options.appendValue !== !1 ? this.appendData : {}), this.form));
  1672. },
  1673. isChange(e, r) {
  1674. return JSON.stringify(e.rule.value, Se) !== JSON.stringify(r === null ? void 0 : r, Se);
  1675. },
  1676. isQuote(e, r) {
  1677. return (h.Object(r) || Array.isArray(r)) && r === e.rule.value;
  1678. },
  1679. refreshUpdate(e, r, n, s) {
  1680. if (h.Function(e.rule.update)) {
  1681. const i = R(() => e.rule.update(r, e.origin, this.api, {
  1682. origin: n || "change",
  1683. linkField: s
  1684. }));
  1685. if (i === void 0) return;
  1686. e.rule.hidden = i === !0;
  1687. }
  1688. },
  1689. valueChange(e, r) {
  1690. this.refreshRule(e, r), this.bus.$emit("change-" + e.field, r);
  1691. },
  1692. refreshRule(e, r, n, s) {
  1693. this.refreshControl(e) && (this.$render.clearCacheAll(), this.loadRule(), this.vm.$emit("update", this.api), this.refresh()), this.refreshUpdate(e, r, n, s);
  1694. },
  1695. appendLink(e) {
  1696. const r = e.rule.link;
  1697. h.trueArray(r) && r.forEach((n) => {
  1698. const s = () => this.refreshRule(e, e.rule.value, "link", n);
  1699. this.bus.$on("change-" + n, s), e.linkOn.push(() => this.bus.$off("change-" + n, s));
  1700. });
  1701. },
  1702. fields() {
  1703. return Object.keys(this.fieldCtx);
  1704. }
  1705. });
  1706. }
  1707. function Se(t, e) {
  1708. return typeof e == "function" ? "" + e : e;
  1709. }
  1710. function Re(t) {
  1711. Object.keys(t).forEach((e) => delete t[e]);
  1712. }
  1713. const re = {
  1714. init(t) {
  1715. },
  1716. toFormValue(t, e) {
  1717. return t;
  1718. },
  1719. toValue(t, e) {
  1720. return t;
  1721. },
  1722. mounted(t) {
  1723. },
  1724. render(t, e) {
  1725. return e.$render.defaultRender(e, t);
  1726. },
  1727. preview(t, e) {
  1728. return this.render(t, e);
  1729. },
  1730. mergeProp(t) {
  1731. }
  1732. }, jt = ["field", "value", "vm", "template", "name", "config", "control", "inject", "sync", "payload", "optionsTo", "update", "component", "cache"];
  1733. function At(t) {
  1734. p(t.prototype, {
  1735. getCtx(e) {
  1736. return this.getFieldCtx(e) || this.getNameCtx(e)[0] || this.ctxs[e];
  1737. },
  1738. getCtxs(e) {
  1739. return this.fieldCtx[e] || this.nameCtx[e] || (this.ctxs[e] ? [this.ctxs[e]] : []);
  1740. },
  1741. setIdCtx(e, r, n) {
  1742. const s = `${n}Ctx`;
  1743. this[s][r] ? this[s][r].push(e) : this[s][r] = [e];
  1744. },
  1745. rmIdCtx(e, r, n) {
  1746. const s = `${n}Ctx`, i = this[s][r];
  1747. if (!i) return !1;
  1748. const o = i.splice(i.indexOf(e) >>> 0, 1).length > 0;
  1749. return i.length || delete this[s][r], o;
  1750. },
  1751. getFieldCtx(e) {
  1752. return (this.fieldCtx[e] || [])[0];
  1753. },
  1754. getNameCtx(e) {
  1755. return this.nameCtx[e] || [];
  1756. },
  1757. setCtx(e) {
  1758. let { id: r, field: n, name: s, rule: i } = e;
  1759. this.ctxs[r] = e, s && this.setIdCtx(e, s, "name"), e.input && (this.setIdCtx(e, n, "field"), this.setFormData(e, e.parser.toFormValue(i.value, e)), this.isMounted && !this.reloading && this.vm.$emit("change", e.field, i.value, e.origin, this.api));
  1760. },
  1761. getParser(e) {
  1762. const r = this.fc.parsers;
  1763. return r[e.originType] || r[S(e.type)] || r[e.trueType] || re;
  1764. },
  1765. bindParser(e) {
  1766. e.setParser(this.getParser(e));
  1767. },
  1768. getType(e) {
  1769. const r = this.fc.CreateNode.aliasMap, n = r[e] || r[S(e)] || e;
  1770. return S(n);
  1771. },
  1772. noWatch(e) {
  1773. this.noWatchFn || (this.noWatchFn = e), R(e), this.noWatchFn === e && (this.noWatchFn = null);
  1774. },
  1775. watchCtx(e) {
  1776. const r = this.vm;
  1777. Object.keys(e.rule).filter((n) => n[0] !== "_" && n[0] !== "$" && jt.indexOf(n) === -1).forEach((n) => {
  1778. const s = n === "children";
  1779. e.watch.push(r.$watch(() => e.rule[n], (i, o) => {
  1780. if (!(this.loading || this.noWatchFn || this.reloading)) {
  1781. if (s && e.parser.loadChildren === !1) {
  1782. this.$render.clearCache(e), this.nextRefresh();
  1783. return;
  1784. }
  1785. if (this.watching = !0, n === "link") {
  1786. e.link();
  1787. return;
  1788. } else if (["props", "on", "nativeOn", "deep"].indexOf(n) > -1)
  1789. this.parseInjectEvent(e.rule, i || {}), n === "props" && e.input && this.setFormData(e, e.parser.toFormValue(e.rule.value, e));
  1790. else if (["emit", "nativeEmit"].indexOf(n) > -1)
  1791. this.parseEmit(e, n === "emit");
  1792. else if (["prefix", "suffix"].indexOf(n) > -1)
  1793. i && this.loadFn(i, e.rule);
  1794. else if (n === "type")
  1795. e.updateType(), this.bindParser(e);
  1796. else if (n === "children") {
  1797. const a = h.trueArray(i);
  1798. this.deferSyncValue(() => {
  1799. i !== o && (this.rmSub(o, e), this.$render.initOrgChildren()), a && this.loadChildren(i, e), this.vm.$emit("update", this.api);
  1800. });
  1801. }
  1802. this.$render.clearCache(e), this.refresh(), this.watching = !1;
  1803. }
  1804. }, { deep: !s, sync: s }));
  1805. }), this.watchEffect(e);
  1806. },
  1807. rmSub(e, r) {
  1808. h.trueArray(e) && e.forEach((n) => {
  1809. n && n.__fc__ && n.__fc__.parent === r && this.rmCtx(n.__fc__);
  1810. });
  1811. },
  1812. rmCtx(e) {
  1813. if (e.deleted) return;
  1814. const { id: r, field: n, input: s, name: i } = e;
  1815. e.input && Object.defineProperty(e.rule, "value", {
  1816. value: e.rule.value,
  1817. writable: !0
  1818. }), k(this.ctxs, r), k(this.$render.tempList, r), k(this.$render.orgChildren, r), k(this.vm.ctxInject, r), k(this.formData, r), k(this.subForm, r), k(e, "cacheValue"), s && this.rmIdCtx(e, n, "field"), i && this.rmIdCtx(e, i, "name"), s && !F(this.fieldCtx, n) && k(this.form, n), this.deferSyncValue(() => {
  1819. this.reloading || (e.parser.loadChildren !== !1 && h.trueArray(e.rule.children) && e.rule.children.forEach((a) => a.__fc__ && this.rmCtx(a.__fc__)), e.root === this.rules && this.vm._renderRule());
  1820. }, s);
  1821. const o = this.sort.indexOf(r);
  1822. return o > -1 && this.sort.splice(o, 1), this.$render.clearCache(e), e.delete(), this.effect(e, "deleted"), s && !this.fieldCtx[n] && this.vm.$emit("removeField", n, e.rule, this.api), e.rule.__ctrl || this.vm.$emit("removeRule", e.rule, this.api), e;
  1823. }
  1824. });
  1825. }
  1826. function wt(t) {
  1827. p(t.prototype, {
  1828. mounted() {
  1829. const e = () => {
  1830. this.isMounted = !0, this.lifecycle("mounted");
  1831. };
  1832. this.pageEnd ? e() : this.bus.$once("page-end", e);
  1833. },
  1834. lifecycle(e) {
  1835. this.vm.$emit(e, this.api), this.emitEvent(e, this.api);
  1836. },
  1837. targetReload() {
  1838. this.bus.$off("next-tick", this.nextReload), this.bus.$once("next-tick", this.nextReload);
  1839. },
  1840. emitEvent(e, ...r) {
  1841. const n = this.options[e] || this.options[S("on-" + e)];
  1842. if (n) {
  1843. const s = P(n);
  1844. h.Function(s) && R(() => s(...r));
  1845. }
  1846. this.bus.$emit(e, ...r);
  1847. }
  1848. });
  1849. }
  1850. function kt(t) {
  1851. p(t.prototype, {
  1852. useProvider() {
  1853. const e = this.fc.providers;
  1854. Object.keys(e).forEach((r) => {
  1855. let n = e[r];
  1856. h.Function(n) && (n = n(this.fc)), n._c = Pt(n), this.onEffect(n), this.providers[r] = n;
  1857. });
  1858. },
  1859. onEffect(e) {
  1860. const r = [];
  1861. (e._c || ["*"]).forEach((n) => {
  1862. const s = n === "*" ? "*" : this.getType(n);
  1863. r.indexOf(s) > -1 || (r.push(s), this.bus.$on(`p:${e.name}:${s}:${e.input ? 1 : 0}`, (i, o) => {
  1864. e[i] && e[i](...o);
  1865. }));
  1866. }), e._used = r;
  1867. },
  1868. watchEffect(e) {
  1869. const r = this.vm;
  1870. let n = {
  1871. required: () => {
  1872. var s, i;
  1873. return (F(e.rule, "$required") ? e.rule.$required : (i = (s = e.rule) == null ? void 0 : s.effect) == null ? void 0 : i.required) || !1;
  1874. }
  1875. };
  1876. Object.keys(e.rule.effect || {}).forEach((s) => {
  1877. n[s] = () => e.rule.effect[s];
  1878. }), Object.keys(e.rule).forEach((s) => {
  1879. s[0] === "$" && (n[s.substr(1)] = () => e.rule[s]);
  1880. }), Object.keys(n || {}).forEach((s) => {
  1881. e.watch.push(r.$watch(n[s], (i) => {
  1882. this.effect(e, "watch", { [s]: i });
  1883. }, { deep: !0 }));
  1884. });
  1885. },
  1886. ruleEffect(e, r, n) {
  1887. this.emitEffect({
  1888. rule: e,
  1889. input: !!e.field,
  1890. type: this.getType(e.type)
  1891. }, r, n);
  1892. },
  1893. effect(e, r, n) {
  1894. this.emitEffect({
  1895. rule: e.rule,
  1896. input: e.input,
  1897. type: e.trueType,
  1898. ctx: e,
  1899. custom: n
  1900. }, r);
  1901. },
  1902. getEffect(e, r) {
  1903. if (F(e, "$" + r))
  1904. return e["$" + r];
  1905. if (F(e, "effect") && F(e.effect, r))
  1906. return e.effect[r];
  1907. },
  1908. emitEffect({ ctx: e, rule: r, input: n, type: s, custom: i }, o, a) {
  1909. if (!s || s === "fcFragment") return;
  1910. const l = i || Object.keys(r).reduce((u, d) => (d[0] === "$" && (u[d.substr(1)] = r[d]), u), $({}, r.effect || {}));
  1911. Object.keys(l).forEach((u) => {
  1912. const d = this.providers[u];
  1913. if (!d || d.input && !n) return;
  1914. let m;
  1915. if (!d._c)
  1916. m = "*";
  1917. else if (d._used.indexOf(s) > -1)
  1918. m = s;
  1919. else
  1920. return;
  1921. const _ = $({ value: l[u], getValue: () => this.getEffect(r, u) }, a || {});
  1922. e && (_.getProp = () => e.effectData(u), _.clearProp = () => e.clearEffectData(u), _.mergeProp = (O) => D(_.getProp(), [O]), _.id = e.id), this.bus.$emit(`p:${u}:${m}:${d.input ? 1 : 0}`, o, [_, r, this.api]);
  1923. });
  1924. }
  1925. });
  1926. }
  1927. function Vt(t) {
  1928. return t.filter(function(e, r, n) {
  1929. return n.indexOf(e, 0) === r;
  1930. });
  1931. }
  1932. function Pt(t) {
  1933. const e = t.components;
  1934. if (Array.isArray(e)) {
  1935. const r = Vt(e.filter((n) => n !== "*"));
  1936. return r.length ? r : !1;
  1937. } else return h.String(e) ? [e] : !1;
  1938. }
  1939. function A(t) {
  1940. p(this, {
  1941. fc: t,
  1942. vm: t.vm,
  1943. watching: !1,
  1944. loading: !1,
  1945. reloading: !1,
  1946. noWatchFn: null,
  1947. deferSyncFn: null,
  1948. isMounted: !1,
  1949. formData: {},
  1950. subForm: {},
  1951. form: {},
  1952. appendData: {},
  1953. providers: {},
  1954. cycleLoad: null,
  1955. loadedId: 1,
  1956. nextTick: null,
  1957. changeStatus: !1,
  1958. pageEnd: !0,
  1959. nextReload: () => {
  1960. this.lifecycle("reload");
  1961. }
  1962. }), Ie(this, {
  1963. options() {
  1964. return t.options;
  1965. },
  1966. bus() {
  1967. return t.bus;
  1968. }
  1969. }), this.initData(t.rules), this.$manager = new t.manager(this), this.$render = new fe(this), this.api = t.extendApi(ct(this), this);
  1970. }
  1971. p(A.prototype, {
  1972. initData(t) {
  1973. p(this, {
  1974. ctxs: {},
  1975. fieldCtx: {},
  1976. nameCtx: {},
  1977. sort: [],
  1978. rules: t
  1979. });
  1980. },
  1981. init() {
  1982. this.appendData = $($($({}, this.fc.options.formData || {}), this.vm.value || {}), this.appendData), this.useProvider(), this.usePage(), this.loadRule(), this.$manager.__init(), this.lifecycle("created"), this.vm.$set(this.vm, "formData", this.formData);
  1983. },
  1984. beforeFetch(t) {
  1985. return new Promise((e) => {
  1986. const r = this.options.beforeFetch && R(() => this.options.beforeFetch(t, { api: this.api }));
  1987. r && h.Function(r.then) ? r.then(e) : e();
  1988. });
  1989. }
  1990. });
  1991. $t(A);
  1992. _t(A);
  1993. Ot(A);
  1994. Et(A);
  1995. Rt(A);
  1996. At(A);
  1997. wt(A);
  1998. kt(A);
  1999. const Dt = "fcFragment", z = {
  2000. name: Dt,
  2001. functional: !0,
  2002. props: ["vnode"],
  2003. render(t, e) {
  2004. return e.props.vnode ? e.props.vnode : e.children;
  2005. }
  2006. };
  2007. function Tt(t) {
  2008. return h.String(t) ? { domProps: { innerHTML: t } } : t;
  2009. }
  2010. function It() {
  2011. const t = {};
  2012. function e(r) {
  2013. r && this.setVm(r);
  2014. }
  2015. return p(e.prototype, {
  2016. setVm(r) {
  2017. this.vm = r, this.$h = r.$createElement;
  2018. },
  2019. make(r, n, s) {
  2020. return w.config.isReservedTag(r) && n.nativeOn && delete n.nativeOn, this.makeComponent(r, n, s);
  2021. },
  2022. makeComponent(r, n, s) {
  2023. let i = this.$h(r, Tt(n), s || []);
  2024. return i.context = this.vm, i;
  2025. },
  2026. aliasMap: t
  2027. }), p(e, {
  2028. aliasMap: t,
  2029. alias(r, n) {
  2030. t[r] = n;
  2031. },
  2032. use(r) {
  2033. Object.keys(r).forEach((n) => {
  2034. const s = K(n), i = mt(n).toLocaleLowerCase(), o = r[n];
  2035. [n, s, i].forEach((a) => {
  2036. e.alias(n, o), e.prototype[a] = function(l, u) {
  2037. return this.make(o, l, u);
  2038. };
  2039. });
  2040. });
  2041. }
  2042. }), e;
  2043. }
  2044. function Nt(t) {
  2045. class e extends Je {
  2046. }
  2047. return Object.assign(e.prototype, t), e;
  2048. }
  2049. function Je(t) {
  2050. p(this, {
  2051. $handle: t,
  2052. vm: t.vm,
  2053. options: {},
  2054. ref: "fcForm",
  2055. mergeOptionsRule: {
  2056. normal: ["form", "row", "info", "submitBtn", "resetBtn"]
  2057. }
  2058. }), this.updateKey(), this.init();
  2059. }
  2060. p(Je.prototype, {
  2061. __init() {
  2062. this.$render = this.$handle.$render, this.$r = (...t) => this.$render.renderRule(...t);
  2063. },
  2064. updateKey() {
  2065. this.key = G();
  2066. },
  2067. //TODO interface
  2068. init() {
  2069. },
  2070. update() {
  2071. },
  2072. beforeRender() {
  2073. },
  2074. form() {
  2075. return this.vm.$refs[this.ref];
  2076. },
  2077. getSlot(t) {
  2078. const e = (r) => {
  2079. if (r) {
  2080. let n = r.$scopedSlots[t];
  2081. return n || e(r.$pfc);
  2082. }
  2083. };
  2084. return e(this.vm);
  2085. },
  2086. mergeOptions(t, e) {
  2087. return q(t.map((r) => this.tidyOptions(r)), e, this.mergeOptionsRule);
  2088. },
  2089. updateOptions(t) {
  2090. this.options = this.mergeOptions([t], this.getDefaultOptions()), this.update();
  2091. },
  2092. tidyOptions(t) {
  2093. return t;
  2094. },
  2095. tidyRule(t) {
  2096. },
  2097. mergeProp(t) {
  2098. },
  2099. getDefaultOptions() {
  2100. return {};
  2101. },
  2102. render(t) {
  2103. }
  2104. });
  2105. const Lt = function(t) {
  2106. const e = {
  2107. name: "loadData",
  2108. _fn: [],
  2109. created(r, n, s) {
  2110. this.deleted(r);
  2111. let i = M(r.getValue());
  2112. const o = [];
  2113. i.forEach((a) => {
  2114. if (a) {
  2115. const l = () => {
  2116. a.watch !== !1 && (t.bus.$off("p.loadData." + a.attr, l), t.bus.$once("p.loadData." + a.attr, l));
  2117. let u;
  2118. a.attr && (u = t.loadData[a.attr] || a.default, a.copy !== !1 && (u = T(u))), W(r.getProp(), a.to || "options", u), s.sync(n);
  2119. };
  2120. o.push(() => t.bus.$off("p.loadData." + a.attr, l)), l();
  2121. }
  2122. }), this._fn[r.id] = o;
  2123. },
  2124. deleted(r) {
  2125. this._fn[r.id] && (this._fn[r.id].forEach((n) => {
  2126. n();
  2127. }), delete this._fn[r.id]), r.clearProp();
  2128. }
  2129. };
  2130. return e.watch = e.created, e;
  2131. }, He = {
  2132. name: "componentValidate",
  2133. load(t, e, r) {
  2134. const n = t.getValue();
  2135. n ? t.getProp().validate = [{
  2136. validator(...s) {
  2137. const i = H(e);
  2138. if (i)
  2139. return r.exec(i.id, n === !0 ? "formCreateValidate" : n, ...s, {
  2140. attr: t,
  2141. rule: e,
  2142. api: r
  2143. });
  2144. }
  2145. }] : (t.clearProp(), r.clearValidateState([e.field]));
  2146. },
  2147. watch(...t) {
  2148. He.load(...t);
  2149. }
  2150. }, Mt = function(t) {
  2151. function e(n) {
  2152. return h.String(n) && (n = {
  2153. action: n,
  2154. to: "options"
  2155. }), n;
  2156. }
  2157. function r(n, s, i) {
  2158. let o = n.value;
  2159. const a = (m) => {
  2160. m === void 0 ? (n.clearProp(), i.sync(s)) : W(n.getProp(), o.to || "options", m);
  2161. };
  2162. if (h.Function(o) && (o = o(s, i)), o = e(o), !o || !o.action) {
  2163. a(void 0);
  2164. return;
  2165. }
  2166. o = T(o), o.to || (o.to = "options");
  2167. const l = o.onError, u = () => {
  2168. if (!n.getValue())
  2169. return n.clearProp(), i.sync(s), !0;
  2170. }, d = N($({
  2171. headers: {}
  2172. }, o), {
  2173. onSuccess(m, _) {
  2174. if (u()) return;
  2175. let O = (y) => _ ? y : F(y, "data") ? y.data : y;
  2176. h.Function(o.parse) ? O = o.parse : o.parse && h.String(o.parse) && (O = (y) => (o.parse.split(".").forEach((b) => {
  2177. y && (y = y[b]);
  2178. }), y)), a(O(m, s, i)), i.sync(s);
  2179. },
  2180. onError(m) {
  2181. a(void 0), !u() && (l || ((_) => oe(_.message || "fetch fail " + o.action)))(m, s, i);
  2182. }
  2183. });
  2184. t.$handle.beforeFetch(d, { rule: s, api: i }).then(() => {
  2185. if (h.Function(o.action)) {
  2186. o.action(s, i).then((m) => {
  2187. d.onSuccess(m, !0);
  2188. }).catch((m) => {
  2189. d.onError(m);
  2190. });
  2191. return;
  2192. }
  2193. R(() => t.create.fetch(d, { inject: n, rule: s, api: i }));
  2194. });
  2195. }
  2196. return {
  2197. name: "fetch",
  2198. loaded(...n) {
  2199. r(...n);
  2200. },
  2201. watch(...n) {
  2202. r(...n);
  2203. }
  2204. };
  2205. }, Ke = {
  2206. name: "required",
  2207. load(t, e, r) {
  2208. const n = qt(t.getValue());
  2209. if (n.required === !1)
  2210. t.clearProp(), r.clearValidateState([e.field]);
  2211. else {
  2212. const s = $({
  2213. required: !0,
  2214. validator(i, o, a) {
  2215. h.empty(o) ? a(s.message) : a();
  2216. }
  2217. }, n);
  2218. if (!s.message) {
  2219. let i = e.title || "";
  2220. s.message = ((typeof i == "object" ? i.title : i) || "") + "不能为空";
  2221. }
  2222. t.getProp().validate = [s];
  2223. }
  2224. r.sync(e);
  2225. },
  2226. watch(...t) {
  2227. Ke.load(...t);
  2228. }
  2229. };
  2230. function qt(t) {
  2231. return h.Boolean(t) ? { required: t } : h.String(t) ? { message: t } : h.Undef(t) ? { required: !1 } : h.Function(t) ? { validator: t } : h.Object(t) ? t : {};
  2232. }
  2233. const Ut = {
  2234. fetch: Mt,
  2235. loadData: Lt,
  2236. required: Ke,
  2237. componentValidate: He
  2238. }, Bt = "html", Jt = {
  2239. name: Bt,
  2240. loadChildren: !1,
  2241. render(t, e) {
  2242. return e.prop.domProps || (e.prop.domProps = {}), e.prop.domProps.innerHTML = t, e.vNode.make(e.prop.props.tag || "div", e.prop);
  2243. },
  2244. renderChildren(t) {
  2245. return Array.isArray(t.rule.children) ? t.rule.children.filter((e) => h.String(e)).join("") : "";
  2246. }
  2247. };
  2248. function Ht(t, e) {
  2249. let r;
  2250. return arguments.length === 2 ? (r = arguments[1], e = r[t]) : r = arguments[2], { id: e, prop: r };
  2251. }
  2252. function Z() {
  2253. return Ht("name", ...arguments);
  2254. }
  2255. function je(t) {
  2256. return !t || !t.el ? window.document.body : h.Element(t.el) ? t.el : document.querySelector(t.el);
  2257. }
  2258. function Ae(t, e) {
  2259. const r = new w({
  2260. data() {
  2261. return { rule: t, option: e || {} };
  2262. },
  2263. render(n) {
  2264. return n("FormCreate", { ref: "fc", props: this.$data });
  2265. }
  2266. });
  2267. return r.$mount(), r;
  2268. }
  2269. function Kt(t) {
  2270. const e = t.key || [], r = t.array || [], n = t.normal || [];
  2271. Pe.push(...e), ne.push(...r), ie.push(...n), Le([...e, ...r, ...n]);
  2272. }
  2273. let Wt = 1;
  2274. const v = {};
  2275. function Xt(t) {
  2276. const e = {
  2277. [z.name]: z
  2278. }, r = {}, n = {}, s = $({}, Ut), i = ft();
  2279. let o = { global: {} };
  2280. const a = {}, l = It(), u = {};
  2281. Kt(t.attrs || {});
  2282. function d(f) {
  2283. const c = v[f];
  2284. if (Array.isArray(c))
  2285. return c.map((g) => g.api());
  2286. if (c)
  2287. return c.api();
  2288. }
  2289. function m() {
  2290. const f = Z(...arguments);
  2291. f.id && f.prop && (n[f.id] = f.prop);
  2292. }
  2293. function _() {
  2294. const f = Z(...arguments);
  2295. f.id && f.prop && (s[f.id] = N($({}, f.prop), { name: f.id }));
  2296. }
  2297. function O(f) {
  2298. l.use(f);
  2299. }
  2300. function y() {
  2301. const f = Z(...arguments);
  2302. if (!f.id || !f.prop) return re;
  2303. const c = S(f.id), g = f.prop, C = g.merge === !0 ? r[c] : void 0;
  2304. r[c] = g, Object.setPrototypeOf(g, C || re), i[c] = ue(c), g.maker && p(i, g.maker);
  2305. }
  2306. function b(f, c) {
  2307. let g;
  2308. if (h.String(f)) {
  2309. if (g = S(f), ["form-create", "formcreate"].indexOf(g) > -1)
  2310. return U();
  2311. if (c === void 0)
  2312. return e[g];
  2313. } else
  2314. g = S(f.name), c = f;
  2315. if (!g || !c) return;
  2316. const C = S(g);
  2317. e[g] = c, e[C] = c, delete l.aliasMap[g], delete l.aliasMap[C], delete r[g], delete r[C], c.formCreateParser && y(g, c.formCreateParser);
  2318. }
  2319. function de(f) {
  2320. Object.keys(v).forEach((c) => {
  2321. (Array.isArray(v[c]) ? v[c] : [v[c]]).forEach((C) => {
  2322. C.bus.$emit("p.loadData." + f);
  2323. });
  2324. });
  2325. }
  2326. function he(f, c) {
  2327. a[f] = c, de(f);
  2328. }
  2329. function ce(f, c) {
  2330. return F(a, f) ? a[f] : c;
  2331. }
  2332. function We(f) {
  2333. delete a[f], de(f);
  2334. }
  2335. function U() {
  2336. return rt(me, e, n);
  2337. }
  2338. function pe() {
  2339. return z;
  2340. }
  2341. function Xe(f, c) {
  2342. return h.Function(f.install) ? f.install(V, c) : h.Function(f) && f(V, c), this;
  2343. }
  2344. function V(f, c, g) {
  2345. let C = Ae(f, c || {});
  2346. const j = C.$refs.fc.formCreate;
  2347. return j.$parent = g, je(j.options).appendChild(C.$el), j.api();
  2348. }
  2349. Object.setPrototypeOf(V, u);
  2350. function Ge(f) {
  2351. let c = $({}, t);
  2352. return f ? c.inherit = {
  2353. components: e,
  2354. parsers: r,
  2355. directives: n,
  2356. providers: s,
  2357. maker: i,
  2358. loadData: a
  2359. } : delete c.inherit, Xt(c);
  2360. }
  2361. function me(f) {
  2362. const c = f.$options.propsData.rule;
  2363. p(this, {
  2364. id: Wt++,
  2365. vm: f,
  2366. create: V,
  2367. manager: Nt(t.manager),
  2368. parsers: r,
  2369. providers: s,
  2370. rules: Array.isArray(c) ? c : [],
  2371. name: f.$options.propsData.name || G(),
  2372. inFor: f.$options.propsData.inFor,
  2373. prop: {
  2374. components: e,
  2375. directives: n
  2376. },
  2377. setData: he,
  2378. getData: ce,
  2379. loadData: a,
  2380. CreateNode: l,
  2381. bus: new w(),
  2382. unwatch: null,
  2383. options: {},
  2384. extendApi: t.extendApi || ((g) => g)
  2385. }), this.init(), this.initOptions(), this.name && (this.inFor ? (v[this.name] || (v[this.name] = []), v[this.name].push(this)) : v[this.name] = this);
  2386. }
  2387. p(me.prototype, {
  2388. init() {
  2389. const f = this.vm, c = new A(this);
  2390. this.$handle = c, f.$f = c.api, f.$emit("input", c.api), f.$on("hook:created", () => {
  2391. this.isSub() && (this.unwatch = f.$watch(() => f.$pfc.option, () => {
  2392. this.initOptions(), f.$f.refresh();
  2393. }, { deep: !0 }), this.initOptions()), this.created();
  2394. }), f.$on("hook:mounted", () => {
  2395. this.mounted();
  2396. }), f.$on("hook:beforeDestroy", () => {
  2397. if (f.destroyed = !0, this.unwatch && this.unwatch(), c.reloadRule([]), this.name)
  2398. if (this.inFor) {
  2399. const g = v[this.name].indexOf(this);
  2400. v[this.name].splice(g, 1), v[this.name].length || delete v[this.name];
  2401. } else
  2402. delete v[this.name];
  2403. }), f.$on("hook:updated", () => {
  2404. c.bindNextTick(() => this.bus.$emit("next-tick", c.api));
  2405. });
  2406. },
  2407. isSub() {
  2408. return this.vm.$pfc && this.vm.extendOption;
  2409. },
  2410. initOptions() {
  2411. this.options = {};
  2412. let f = $({ formData: {}, submitBtn: {}, resetBtn: {} }, T(o));
  2413. this.isSub() && this.mergeOptions(this.options, this.vm.$pfc.$f.config || {}, !0), f = this.mergeOptions(f, this.vm.$options.propsData.option), this.updateOptions(f);
  2414. },
  2415. mergeOptions(f, c, g) {
  2416. return c = T(c), g && ["page", "onSubmit", "onReset", "onCreated", "onChange", "onMounted", "mounted", "onReload", "reload", "formData", "el"].forEach((C) => {
  2417. delete c[C];
  2418. }), c.global && (f.global = ut(f.global, c.global), delete c.global), this.$handle.$manager.mergeOptions([c], f), f;
  2419. },
  2420. updateOptions(f) {
  2421. this.mergeOptions(this.options, f), this.$handle.$manager.updateOptions(this.options);
  2422. },
  2423. created() {
  2424. this.$handle.init(), this.vm.$emit("created", this.api());
  2425. },
  2426. api() {
  2427. return this.$handle.api;
  2428. },
  2429. render() {
  2430. return this.$handle.render();
  2431. },
  2432. mounted() {
  2433. this.$handle.mounted();
  2434. }
  2435. });
  2436. function ye(f) {
  2437. p(f, {
  2438. version: t.version,
  2439. ui: t.ui,
  2440. setData: he,
  2441. getData: ce,
  2442. removeData: We,
  2443. maker: i,
  2444. component: b,
  2445. directive: m,
  2446. register: _,
  2447. $vnode: pe,
  2448. parser: y,
  2449. use: Xe,
  2450. factory: Ge,
  2451. componentAlias: O,
  2452. copyRule: ae,
  2453. copyRules: Te,
  2454. fetch: qe,
  2455. $form: U,
  2456. parseFn: P,
  2457. parseJson: at,
  2458. toJson: De,
  2459. getApi: d,
  2460. init(c, g = {}) {
  2461. let C = Ae(c, g), j = C.$refs.fc.formCreate;
  2462. return {
  2463. mount(I) {
  2464. return I && h.Element(I) && (j.options.el = I), je(j.options).appendChild(C.$el), j.api();
  2465. },
  2466. remove() {
  2467. C.$el.parentNode && C.$el.parentNode.removeChild(C.$el);
  2468. },
  2469. destroy() {
  2470. this.remove(), C.$destroy();
  2471. },
  2472. $f: j.api()
  2473. };
  2474. }
  2475. });
  2476. }
  2477. function Qe(f) {
  2478. p(f, {
  2479. create: V,
  2480. install(c, g) {
  2481. if (o = $($({}, o), g || {}), c._installedFormCreate === !0) return;
  2482. c._installedFormCreate = !0;
  2483. const C = function(j, I = {}) {
  2484. return V(j, I, this);
  2485. };
  2486. ye(C), c.prototype.$formCreate = C, c.component("FormCreate", U()), c.component("FcFragment", pe());
  2487. }
  2488. });
  2489. }
  2490. if (ye(u), Qe(u), l.use({ fragment: "fcFragment" }), y(Jt), t.install && V.use(t), t.inherit) {
  2491. const f = t.inherit;
  2492. f.components && p(e, f.components), f.parsers && p(r, f.parsers), f.directives && p(n, f.directives), f.providers && p(s, f.providers), f.maker && p(i, f.maker), f.loadData && p(a, f.loadData);
  2493. }
  2494. const B = U();
  2495. return Object.setPrototypeOf(B, u), Object.defineProperties(B, {
  2496. fetch: {
  2497. get() {
  2498. return u.fetch;
  2499. },
  2500. set(f) {
  2501. u.fetch = f;
  2502. }
  2503. }
  2504. }), B.util = u, B;
  2505. }
  2506. export {
  2507. le as Creator,
  2508. Je as Manager,
  2509. ae as copyRule,
  2510. Te as copyRules,
  2511. ue as creatorFactory,
  2512. Xt as default,
  2513. z as fragment,
  2514. D as mergeRule,
  2515. at as parseJson,
  2516. De as toJson
  2517. };