k5web/assets/index.dc85229e.js
2024-06-09 09:26:55 +08:00

38 lines
16 KiB
JavaScript

import{u as re,b as qe,c as h,d as We,i as Ie,_ as Me}from"./useConfig.e2f085de.js";import{d as Ee,c as y,aI as C,i as He,f as P,t as Oe,r as Te,o as Ke,b as Ue,w as ke,p as we,n as ze}from"./arco.768e32d2.js";import{G as Ge,A as je,z as Ne,B as Fe,H as Je,J as Ce,K as Xe,M as ie,F as Ze}from"./index.ca5b2f7e.js";import{u as Qe,i as _e}from"./index.ae3329ec.js";import{u as Re,F as Be,i as Pe,V as q,_ as R,a as Ye,C as er,r as b,s as $e,v as rr}from"./form-model.ea91f0ac.js";import{g as de,r as tr}from"./index.abff64e0.js";import{a as ar,C as nr,E as lr}from"./dialog.89c5077d.js";/**
* tdesign v1.9.4
* (c) 2024 tdesign
* @license MIT
*/var ur={content:{type:[String,Function]},default:{type:[String,Function]},disabled:{type:Boolean,default:void 0},download:{type:[String,Boolean]},hover:{type:String,default:"underline",validator:function(e){return e?["color","underline"].includes(e):!0}},href:{type:String,default:""},prefixIcon:{type:Function},size:{type:String,default:"medium",validator:function(e){return e?["small","medium","large"].includes(e):!0}},suffixIcon:{type:Function},target:{type:String,default:""},theme:{type:String,default:"default",validator:function(e){return e?["default","primary","danger","warning","success"].includes(e):!0}},underline:Boolean,onClick:Function};/**
* tdesign v1.9.4
* (c) 2024 tdesign
* @license MIT
*/function Le(l,e){var o=Object.keys(l);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(l);e&&(s=s.filter(function(S){return Object.getOwnPropertyDescriptor(l,S).enumerable})),o.push.apply(o,s)}return o}function ir(l){for(var e=1;e<arguments.length;e++){var o=arguments[e]!=null?arguments[e]:{};e%2?Le(Object(o),!0).forEach(function(s){h(l,s,o[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(l,Object.getOwnPropertyDescriptors(o)):Le(Object(o)).forEach(function(s){Object.defineProperty(l,s,Object.getOwnPropertyDescriptor(o,s))})}return l}var sr=Ee({name:"TLink",props:ir({},ur),emits:["click"],setup:function(e,o){var s=o.emit,S=Ge(),p=je(),V=re("link"),$=qe(),I=$.STATUS,_=$.SIZE,te=Ne("classPrefix"),ae=te.classPrefix,r=Qe(),U=y(function(){return["".concat(V.value),"".concat(V.value,"--theme-").concat(e.theme),h(h(h(h({},_.value[e.size],e.size!=="medium"),I.value.disabled,r.value),"".concat(ae.value,"-is-underline"),e.underline),"".concat(V.value,"--hover-").concat(e.hover),!r.value)]}),z=function(A){r.value||s("click",A)};return function(){var G=S("default","content"),A=p("prefixIcon"),J=p("suffixIcon");return C("a",{class:We(U.value),href:r.value||!e.href?void 0:e.href,target:e.target?e.target:void 0,download:e.download?e.download:void 0,onClick:z},[A?C("span",{class:"".concat(V.value,"__prefix-icon")},[A]):null,G,J?C("span",{class:"".concat(V.value,"__suffix-icon")},[J]):null])}}});/**
* tdesign v1.9.4
* (c) 2024 tdesign
* @license MIT
*/var Cr=Fe(sr);/**
* tdesign v1.9.4
* (c) 2024 tdesign
* @license MIT
*/var or={for:{type:String,default:""},help:{type:[String,Function]},label:{type:[String,Function],default:""},labelAlign:{type:String,validator:function(e){return e?["left","right","top"].includes(e):!0}},labelWidth:{type:[String,Number]},name:{type:String,default:""},requiredMark:{type:Boolean,default:void 0},rules:{type:Array},showErrorMessage:{type:Boolean,default:void 0},status:{type:String,default:""},statusIcon:{type:[Boolean,Function],default:void 0},successBorder:Boolean,tips:{type:[String,Function]}};/**
* tdesign v1.9.4
* (c) 2024 tdesign
* @license MIT
*/function cr(l,e){return l.replace(/\${(.*?)}/g,function(o,s){return e[s.trim()]||""})}/**
* tdesign v1.9.4
* (c) 2024 tdesign
* @license MIT
*/function Ve(l,e){var o=Object.keys(l);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(l);e&&(s=s.filter(function(S){return Object.getOwnPropertyDescriptor(l,S).enumerable})),o.push.apply(o,s)}return o}function Se(l){for(var e=1;e<arguments.length;e++){var o=arguments[e]!=null?arguments[e]:{};e%2?Ve(Object(o),!0).forEach(function(s){h(l,s,o[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(l,Object.getOwnPropertyDescriptors(o)):Ve(Object(o)).forEach(function(s){Object.defineProperty(l,s,Object.getOwnPropertyDescriptor(o,s))})}return l}function De(l,e){return e?"".concat(l,"__").concat(e).replace(/(\[|\]\.)/g,"_"):""}var vr=Ee({name:"TFormItem",props:Se({},or),setup:function(e,o){var s=o.slots,S=je(),p=Re(),V=Ne("form"),$=V.globalConfig,I=ar({CheckCircleFilledIcon:nr,CloseCircleFilledIcon:er,ErrorCircleFilledIcon:lr}),_=I.CheckCircleFilledIcon,te=I.CloseCircleFilledIcon,ae=I.ErrorCircleFilledIcon,r=He(Be,void 0),U=re(),z=re("form-item"),G=y(function(){var a,n,t=(a=(n=e.requiredMark)!==null&&n!==void 0?n:r==null?void 0:r.requiredMark)!==null&&a!==void 0?a:$.value.requiredMark,d=g.value.filter(function(f){return f.required}).length>0;return t!=null?t:d}),A=y(function(){return s.label||e.label}),J=y(function(){return!!(r!=null&&r.colon&&A.value)}),W=re("form__label"),H=y(function(){return Pe(e.labelAlign)?r==null?void 0:r.labelAlign:e.labelAlign}),E=y(function(){return Pe(e.labelWidth)?r==null?void 0:r.labelWidth:e.labelWidth}),me=y(function(){return[p.value.label,h(h(h(h(h({},"".concat(W.value,"--required"),G.value),"".concat(W.value,"--colon"),J.value),"".concat(W.value,"--top"),A.value&&(H.value==="top"||!E.value)),"".concat(W.value,"--left"),H.value==="left"&&E.value),"".concat(W.value,"--right"),H.value==="right"&&E.value)]}),ge=function(){if(Number(E.value)!==0){var n={};return E.value&&H.value!=="top"&&(Ie(E.value)?n={width:"".concat(E.value,"px")}:n={width:E.value}),C("div",{class:me.value,style:n},[C("label",{for:e.for||null},[S("label")])])}},ne=function(){var n=function(O){return C("span",{class:p.value.status},[C(O,null,null)])},t=L.value;if(D.value===q.SUCCESS)return n(_);if(t!=null&&t[0]){var d=t[0].type||"error",f={error:te,warning:ae}[d]||_;return n(f)}return null},pe=function(){var n=e.statusIcon;if(n!==!1){var t=S("statusIcon",{defaultNode:ne()});if(t)return C("span",{class:p.value.status},[t]);if(t!==!1&&(t=r==null?void 0:r.renderContent("statusIcon",{defaultNode:ne(),params:e}),t))return t}},X=y(function(){if(!k.value)return"";if(D.value===q.SUCCESS)return e.successBorder?[p.value.success,p.value.successBorder].join(" "):p.value.success;if(!!L.value.length){var a=L.value[0].type||"error";return a==="error"?p.value.error:p.value.warning}}),se=y(function(){return[p.value.controls,X.value]}),oe=y(function(){var a={};return E.value&&H.value!=="top"&&(Ie(E.value)?a={marginLeft:"".concat(E.value,"px")}:a={marginLeft:E.value}),a}),L=P([]),B=P([]),D=P(q.TO_BE_VALIDATED),le=P(!1),x=P(!1),ue=function(){x.value=!1,L.value=[],B.value=[],D.value=q.TO_BE_VALIDATED},ye=function(){var n=Object.prototype.toString.call(de(r==null?void 0:r.data,e.name)),t;return n==="[object String]"&&(t=""),n==="[object Array]"&&(t=[]),n==="[object Object]"&&(t={}),t},be=function(){var a=R(b.mark(function n(){var t,d=arguments;return b.wrap(function(j){for(;;)switch(j.prev=j.next){case 0:if(t=d.length>0&&d[0]!==void 0?d[0]:r==null?void 0:r.resetType,e.name){j.next=3;break}return j.abrupt("return");case 3:return t==="empty"?$e(r==null?void 0:r.data,e.name,ye()):t==="initial"&&$e(r==null?void 0:r.data,e.name,M.value),j.next=6,ze();case 6:le.value?x.value=!0:ue();case 7:case"end":return j.stop()}},n)}));return function(){return a.apply(this,arguments)}}(),ce=y(function(){var a;return(a=r==null?void 0:r.errorMessage)!==null&&a!==void 0?a:$.value.errorMessage}),g=y(function(){var a;if((a=e.rules)!==null&&a!==void 0&&a.length)return e.rules;if(!e.name)return[];var n="".concat(e.name).lastIndexOf(".")||-1,t="".concat(e.name).slice(n+1);return de(r==null?void 0:r.rules,e.name)||de(r==null?void 0:r.rules,t)||[]}),u=function(){var a=R(b.mark(function n(t){var d,f;return b.wrap(function(O){for(;;)switch(O.prev=O.next){case 0:if(f={successList:[],errorList:[],rules:[],resultList:[],allowSetValue:!1},f.rules=t==="all"?g.value:g.value.filter(function(m){return(m.trigger||"change")===t}),!(g.value.length&&!((d=f.rules)!==null&&d!==void 0&&d.length))){O.next=4;break}return O.abrupt("return",f);case 4:return f.allowSetValue=!0,O.next=7,rr(w.value,f.rules);case 7:return f.resultList=O.sent,f.errorList=f.resultList.filter(function(m){return m.result!==!0}).map(function(m){return Object.keys(m).forEach(function(Y){if(!m.message&&ce.value[Y]){var fe=Xe(e.label)?e.label:e.name;m.message=cr(ce.value[Y],{name:fe,validate:m[Y]})}}),m}),f.successList=f.resultList.filter(function(m){return m.result===!0&&m.message&&m.type==="success"}),O.abrupt("return",f);case 11:case"end":return O.stop()}},n)}));return function(t){return a.apply(this,arguments)}}(),i=function(){var a=R(b.mark(function n(t,d){var f,j,O,m,Y,fe;return b.wrap(function(ee){for(;;)switch(ee.prev=ee.next){case 0:return le.value=!0,F.value=d,ee.next=4,u(t);case 4:return f=ee.sent,j=f.successList,O=f.errorList,m=f.rules,Y=f.resultList,fe=f.allowSetValue,fe&&(B.value=j,L.value=O),m.length&&(D.value=O.length?q.FAIL:q.SUCCESS),x.value&&ue(),le.value=!1,ee.abrupt("return",h({},e.name,O.length===0?!0:Y));case 15:case"end":return ee.stop()}},n)}));return function(t,d){return a.apply(this,arguments)}}(),v=function(){var a=R(b.mark(function n(t){var d,f,j;return b.wrap(function(m){for(;;)switch(m.prev=m.next){case 0:return m.next=2,u(t);case 2:return d=m.sent,f=d.errorList,j=d.resultList,m.abrupt("return",h({},e.name,f.length===0?!0:j));case 6:case"end":return m.stop()}},n)}));return function(t){return a.apply(this,arguments)}}(),c=function(n){!n&&!Ce(n)||(n.length===0&&(L.value=[],D.value=q.SUCCESS),L.value=n.map(function(t){return Se(Se({},t),{},{result:!1})}),D.value=q.FAIL)},w=y(function(){return(r==null?void 0:r.data)&&de(r==null?void 0:r.data,e.name)}),M=P(void 0),T=Oe(e),K=T.name,Z=Te({name:K,resetHandler:ue,resetField:be,validate:i,validateOnly:v,setValidateMessage:c});Ke(function(){M.value=Je(w.value),r==null||r.children.push(Z)}),Ue(function(){r&&(r.children=r==null?void 0:r.children.filter(function(a){return a!==Z}))}),ke(w,R(b.mark(function a(){return b.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,i("change");case 2:case"end":return t.stop()}},a)})),{deep:!0}),ke(function(){return[e.name,JSON.stringify(e.rules)].join(",")},function(){i("change")});var F=P(void 0),k=y(function(){return _e(F.value)?F.value:_e(e.showErrorMessage)?e.showErrorMessage:r==null?void 0:r.showErrorMessage}),ve=y(function(){return[p.value.formItem,De(z.value,e.name),h(h({},p.value.formItemWithHelp,he.value),p.value.formItemWithExtra,N.value)]}),he=y(function(){var a=S("help");return a?C("div",{class:p.value.help},[a]):null}),N=y(function(){var a,n=function(f){return C("div",{class:p.value.extra,title:f},[f])},t=L.value;return k.value&&t!==null&&t!==void 0&&(a=t[0])!==null&&a!==void 0&&a.message?n(t[0].message):B.value.length?n(B.value[0].message):null}),Q=y(function(){var a=S("tips");if(!a)return null;var n=["".concat(z.value,"-tips"),"".concat(U.value,"-tips"),"".concat(U.value,"-is-").concat(e.status||"default")];return C("div",{class:n},[a])}),xe=function(){var a=R(b.mark(function n(){return b.wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return d.next=2,i("blur");case 2:case"end":return d.stop()}},n)}));return function(){return a.apply(this,arguments)}}();return we(Ye,{handleBlur:xe}),function(){return C("div",{class:ve.value},[ge(),C("div",{class:se.value,style:oe.value},[C("div",{class:p.value.controlsContent},[S("default"),pe()]),he.value,Q.value,N.value])])}}});/**
* tdesign v1.9.4
* (c) 2024 tdesign
* @license MIT
*/var fr={colon:Boolean,data:{type:Object,default:function(){return{}}},disabled:{type:Boolean,default:void 0},errorMessage:{type:Object},formControlledComponents:{type:Array},labelAlign:{type:String,default:"right",validator:function(e){return e?["left","right","top"].includes(e):!0}},labelWidth:{type:[String,Number],default:"100px"},layout:{type:String,default:"vertical",validator:function(e){return e?["vertical","inline"].includes(e):!0}},preventSubmitDefault:{type:Boolean,default:!0},requiredMark:{type:Boolean,default:void 0},resetType:{type:String,default:"empty",validator:function(e){return e?["empty","initial"].includes(e):!0}},rules:{type:Object},scrollToFirstError:{type:String,validator:function(e){return e?["","smooth","auto"].includes(e):!0}},showErrorMessage:{type:Boolean,default:!0},statusIcon:{type:[Boolean,Function],default:void 0},submitWithWarningMessage:Boolean,onReset:Function,onSubmit:Function,onValidate:Function};/**
* tdesign v1.9.4
* (c) 2024 tdesign
* @license MIT
*/function Ae(l,e){var o=Object.keys(l);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(l);e&&(s=s.filter(function(S){return Object.getOwnPropertyDescriptor(l,S).enumerable})),o.push.apply(o,s)}return o}function dr(l){for(var e=1;e<arguments.length;e++){var o=arguments[e]!=null?arguments[e]:{};e%2?Ae(Object(o),!0).forEach(function(s){h(l,s,o[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(l,Object.getOwnPropertyDescriptors(o)):Ae(Object(o)).forEach(function(s){Object.defineProperty(l,s,Object.getOwnPropertyDescriptor(o,s))})}return l}var mr=Ee({name:"TForm",props:dr({},fr),setup:function(e,o){var s=o.expose,S=je(),p=Oe(e),V=p.disabled;we("formDisabled",{disabled:V});var $=P(null),I=P([]),_=Oe(e),te=_.showErrorMessage,ae=_.labelWidth,r=_.labelAlign,U=_.data,z=_.colon,G=_.requiredMark,A=_.rules,J=_.errorMessage,W=_.resetType;we(Be,Te({showErrorMessage:te,labelWidth:ae,labelAlign:r,data:U,colon:z,requiredMark:G,rules:A,errorMessage:J,resetType:W,children:I,renderContent:S}));var H=re("form"),E=Re(),me=y(function(){return[E.value.form,h({},"".concat(H.value,"-inline"),e.layout==="inline")]}),ge=re("form-item"),ne=function(u){if(_e(u))return"";var i=Object.keys(u),v=Me(i,1),c=v[0];if(e.scrollToFirstError){var w=De(ge.value,c);pe(w)}var M=u[c];return Ce(M)?M.filter(function(T){return!T.result})[0].message:""},pe=function(u){var i=$.value.getElementsByClassName(u),v=Me(i,1),c=v[0],w=e.scrollToFirstError;w&&c&&c.scrollIntoView({behavior:w})},X=function(u,i){return!i||!Ce(i)?!0:i.indexOf("".concat(u))!==-1},se=function(u){var i=u.reduce(function(v,c){return Object.assign(v||{},c)},{});return Object.keys(i).forEach(function(v){i[v]===!0&&delete i[v]}),Ze(i)?!0:i},oe=function(){var g=R(b.mark(function u(i){var v,c,w,M,T,K,Z,F,k,ve;return b.wrap(function(N){for(;;)switch(N.prev=N.next){case 0:return c=i||{},w=c.fields,M=c.trigger,T=M===void 0?"all":M,K=c.showErrorMessage,Z=I.value.filter(function(Q){return ie(Q.validate)&&X(String(Q.name),w)}).map(function(Q){return Q.validate(T,K)}),N.next=4,Promise.all(Z);case 4:return F=N.sent,k=se(F),ve=ne(k),(v=e.onValidate)===null||v===void 0||v.call(e,{validateResult:k,firstError:ve}),N.abrupt("return",k);case 9:case"end":return N.stop()}},u)}));return function(i){return g.apply(this,arguments)}}(),L=function(){var g=R(b.mark(function u(i){var v,c,w,M,T,K;return b.wrap(function(F){for(;;)switch(F.prev=F.next){case 0:return v=i||{},c=v.fields,w=v.trigger,M=w===void 0?"all":w,T=I.value.filter(function(k){return ie(k.validateOnly)&&X(String(k.name),c)}).map(function(k){return k.validateOnly(M)}),F.next=4,Promise.all(T);case 4:return K=F.sent,F.abrupt("return",se(K));case 6:case"end":return F.stop()}},u)}));return function(i){return g.apply(this,arguments)}}(),B=P(),D=function(u){e.preventSubmitDefault&&u&&(u.preventDefault(),u.stopPropagation()),oe(B.value).then(function(i){var v;(v=e.onSubmit)===null||v===void 0||v.call(e,{validateResult:i,firstError:ne(i),e:u})}),B.value=void 0},le=function(){var g=R(b.mark(function u(i){return b.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:B.value=i,tr($.value);case 2:case"end":return c.stop()}},u)}));return function(i){return g.apply(this,arguments)}}(),x=P(),ue=function(u){var i;e.preventSubmitDefault&&u&&(u.preventDefault(),u.stopPropagation()),I.value.filter(function(v){var c;return ie(v.resetField)&&X(String(v.name),(c=x.value)===null||c===void 0?void 0:c.fields)}).forEach(function(v){var c;return v.resetField((c=x.value)===null||c===void 0?void 0:c.type)}),x.value=void 0,(i=e.onReset)===null||i===void 0||i.call(e,{e:u})},ye=function(u){x.value=u,$.value.reset()},be=function(u){I.value.forEach(function(i){ie(i.resetHandler)&&X(String(i.name),u)&&i.resetHandler()})},ce=function(u){var i=Object.keys(u);if(!!i.length){var v=I.value.filter(function(c){return ie(c.setValidateMessage)&&i.includes("".concat(c.name))}).map(function(c){return c.setValidateMessage(u[c.name])});Promise.all(v)}};return s({validate:oe,submit:le,reset:ye,clearValidate:be,setValidateMessage:ce,validateOnly:L}),function(){return C("form",{ref:$,class:me.value,onSubmit:function(u){return D(u)},onReset:function(u){return ue(u)}},[S("default")])}}});/**
* tdesign v1.9.4
* (c) 2024 tdesign
* @license MIT
*/var _r=Fe(mr),Er=Fe(vr);export{Er as F,Cr as L,_r as a};