urit-qf-ui 0.2.5 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- (function(y,V){typeof exports=="object"&&typeof module<"u"?V(exports,require("element-plus"),require("element-plus/dist/index.css"),require("element-plus/es"),require("element-plus/es/components/base/style/css"),require("element-plus/es/components/input/style/css"),require("vue"),require("element-plus/es/components/input-number/style/css"),require("element-plus/es/components/select/style/css"),require("element-plus/es/components/option/style/css"),require("axios"),require("element-plus/es/components/switch/style/css"),require("element-plus/es/components/date-picker/style/css"),require("element-plus/es/components/button/style/css"),require("element-plus/es/components/menu/style/css"),require("element-plus/es/components/sub-menu/style/css"),require("element-plus/es/components/menu-item/style/css"),require("element-plus/es/components/icon/style/css"),require("element-plus/es/components/form/style/css"),require("element-plus/es/components/dialog/style/css"),require("@element-plus/icons-vue"),require("element-plus/es/components/drawer/style/css"),require("element-plus/es/components/table/style/css"),require("element-plus/es/components/table-column/style/css"),require("element-plus/es/components/pagination/style/css"),require("mitt"),require("mqtt")):typeof define=="function"&&define.amd?define(["exports","element-plus","element-plus/dist/index.css","element-plus/es","element-plus/es/components/base/style/css","element-plus/es/components/input/style/css","vue","element-plus/es/components/input-number/style/css","element-plus/es/components/select/style/css","element-plus/es/components/option/style/css","axios","element-plus/es/components/switch/style/css","element-plus/es/components/date-picker/style/css","element-plus/es/components/button/style/css","element-plus/es/components/menu/style/css","element-plus/es/components/sub-menu/style/css","element-plus/es/components/menu-item/style/css","element-plus/es/components/icon/style/css","element-plus/es/components/form/style/css","element-plus/es/components/dialog/style/css","@element-plus/icons-vue","element-plus/es/components/drawer/style/css","element-plus/es/components/table/style/css","element-plus/es/components/table-column/style/css","element-plus/es/components/pagination/style/css","mitt","mqtt"],V):(y=typeof globalThis<"u"?globalThis:y||self,V(y.UritQfUI={},y.ElementPlus,y.ElementPlus,y.ElementPlus,y.ElementPlus,y.ElementPlus,y.Vue,y.ElementPlus,y.ElementPlus,y.ElementPlus,y.axios,y.ElementPlus,y.ElementPlus,y.ElementPlus,y.ElementPlus,y.ElementPlus,y.ElementPlus,y.ElementPlus,y.ElementPlus,y.ElementPlus,y.ElementPlusIconsVue,y.ElementPlus,y.ElementPlus,y.ElementPlus,y.ElementPlus,y.mitt,y.mqtt))})(this,function(y,V,M,C,Rt,It,e,At,Mt,Ut,v,zt,Ft,Lt,qt,Wt,jt,Ot,Yt,Qt,ee,Kt,Gt,Ht,Jt,re,ce){"use strict";var $t=Object.defineProperty;var Nt=(y,V,M)=>V in y?$t(y,V,{enumerable:!0,configurable:!0,writable:!0,value:M}):y[V]=M;var w=(y,V,M)=>Nt(y,typeof V!="symbol"?V+"":V,M);const de=e.defineComponent({__name:"UInput",props:{fieldLabel:{},labelPosition:{default:"top"},labelWidth:{},labelAlign:{},required:{type:Boolean},modelValue:{},outlined:{type:Boolean},dense:{type:Boolean},filled:{type:Boolean},borderless:{type:Boolean},label:{},hint:{},error:{type:Boolean},errorMessage:{},type:{},placeholder:{},disable:{type:Boolean},readonly:{type:Boolean},prefix:{},suffix:{},mask:{},maxlength:{}},emits:["update:modelValue"],setup(n,{emit:a}){const t=n,l=a,d=e.computed(()=>{const r={};return t.labelPosition==="left"&&t.labelWidth&&(r.width=typeof t.labelWidth=="number"?`${t.labelWidth}px`:t.labelWidth),t.labelAlign&&(r.textAlign=t.labelAlign),r}),c=e.computed(()=>({"u-input-label-left":t.labelPosition==="left","u-input-label-top":t.labelPosition==="top"})),m={onInput(r){l("update:modelValue",r)}};return(r,o)=>{const s=C.ElInput;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["u-input",c.value])},[n.fieldLabel?(e.openBlock(),e.createElementBlock("div",{key:0,class:"u-input-label",style:e.normalizeStyle(d.value)},[e.createTextVNode(e.toDisplayString(n.fieldLabel)+" ",1),e.createElementVNode("span",{class:e.normalizeClass(["required-star",{"required-star--visible":n.required}])},"*",2)],4)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["u-input-field",{"u-input-field--top":n.labelPosition==="top"}])},[e.createVNode(s,{"model-value":n.modelValue,placeholder:n.placeholder,type:n.type,disabled:n.disable,readonly:n.readonly,maxlength:n.maxlength,"onUpdate:modelValue":m.onInput},null,8,["model-value","placeholder","type","disabled","readonly","maxlength","onUpdate:modelValue"])],2)],2)}}}),k=(n,a)=>{const t=n.__vccOpts||n;for(const[l,d]of a)t[l]=d;return t},$=k(de,[["__scopeId","data-v-ecf5177c"]]),me={class:"u-input-number-field"},Q=k(e.defineComponent({__name:"UInputNumber",props:{fieldLabel:{},labelPosition:{default:"top"},labelWidth:{},labelAlign:{},required:{type:Boolean},modelValue:{},outlined:{type:Boolean},dense:{type:Boolean},filled:{type:Boolean},borderless:{type:Boolean},label:{},hint:{},error:{type:Boolean},errorMessage:{},type:{},placeholder:{},disable:{type:Boolean},readonly:{type:Boolean},min:{},max:{},step:{},precision:{}},emits:["update:modelValue"],setup(n,{emit:a}){const t=n,l=a,d=e.computed(()=>{const r={};return t.labelPosition==="left"&&t.labelWidth&&(r.width=typeof t.labelWidth=="number"?`${t.labelWidth}px`:t.labelWidth),t.labelAlign&&(r.textAlign=t.labelAlign),r}),c=e.computed(()=>({"u-input-number-label-left":t.labelPosition==="left","u-input-number-label-top":t.labelPosition==="top"})),m={onUpdate(r){l("update:modelValue",r===void 0?0:r)}};return(r,o)=>{const s=C.ElInputNumber;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["u-input-number",c.value])},[n.fieldLabel?(e.openBlock(),e.createElementBlock("div",{key:0,class:"u-input-number-label",style:e.normalizeStyle(d.value)},[e.createTextVNode(e.toDisplayString(n.fieldLabel)+" ",1),e.createElementVNode("span",{class:e.normalizeClass(["required-star",{"required-star--visible":n.required}])},"*",2)],4)):e.createCommentVNode("",!0),e.createElementVNode("div",me,[e.createVNode(s,{"model-value":n.modelValue,placeholder:n.placeholder||"请输入数值",disabled:n.disable,min:n.min,max:n.max,step:n.step,precision:n.precision,controls:!0,"controls-position":"right",style:{width:"100%"},onChange:m.onUpdate},null,8,["model-value","placeholder","disabled","min","max","step","precision","onChange"])])],2)}}}),[["__scopeId","data-v-cb70bd5b"]]),U=v.create({timeout:3e4,headers:{"Content-Type":"application/json"}});U.interceptors.request.use(n=>{const a=localStorage.getItem("token");return a&&(n.headers.Authorization=`Bearer ${a}`),n},n=>Promise.reject(n)),U.interceptors.response.use(n=>{const a=n.data;if(a&&typeof a=="object"&&!Array.isArray(a)){if(a.status===void 0&&a.code!==void 0){const t=a.code,l=t===0||t===200||Number(t)===0||Number(t)===200;a.status=l?200:Number(t)}if(a.status!==void 0&&a.status!==200){const t=a.message||"请求失败";return console.error("[HTTP Error]",t),Promise.reject(new Error(t))}}return n},n=>{var t,l;const a=((l=(t=n.response)==null?void 0:t.data)==null?void 0:l.message)||n.message||"请求失败";return console.error("[HTTP Error]",a),Promise.reject(n)});const S={get(n,a){return U.get(n,a).then(t=>t.data)},post(n,a,t){return U.post(n,a,t).then(l=>l.data)},instance:U},D={formCfgApi(n,a="forms"){return`/api/form?type=${a}&id=${n}`},dictApi(n){return`/api/dict/full-list?dict_type=${n}`},cascaderApi(n,a=!0){return`/api/dict/tree-list?dict_type=${n}&children=${a}`}},T={},F={};function L(n){const{children:a,...t}=n;return{label:n.label??n.dict_value??String(n.value??""),value:n.value??n.dict_code,...t}}function q(n){return Array.isArray(n)?n.map(a=>{if(!a||typeof a!="object")return a;const t=L(a),l=a.children;return Array.isArray(l)&&l.length>0&&(t.children=q(l)),t}):[]}function W(n){return Array.isArray(n)?n.filter(a=>a&&typeof a=="object").map(a=>L(a)):[]}function ue(n){if(!Array.isArray(n))return[];const a=[],t=l=>{for(const d of l){if(!d||typeof d!="object")continue;const c=d.children;a.push(L(d)),Array.isArray(c)&&c.length>0&&t(c)}};return t(n),a}async function N(n){if(!n)return[];if(T[n])return T[n];if(n in F)return await F[n];const a=(async()=>{try{const t=await S.get(D.dictApi(n));if(t.status===200){const l=W(t.data);return T[n]=l,l}return[]}catch(t){return console.error(`[dict] 加载字典 ${n} 失败:`,t),[]}finally{delete F[n]}})();return F[n]=a,a}async function te(n,a,t=""){if(a==null||a==="")return t;const l=T[n];if(l&&l.length>0)return K(l,a);const d=await N(n);return d&&d.length>0?K(d,a):t||String(a)}function K(n,a){const t=n.find(l=>l.value===a||String(l.value)===String(a));return t?t.label:String(a)}function pe(n,a,t=""){if(a==null||a==="")return t;const l=T[n];return l&&l.length>0?K(l,a):t||String(a)}async function fe(n){await Promise.all(n.map(a=>N(a)))}function he(n){n?delete T[n]:Object.keys(T).forEach(a=>{delete T[a]})}function ge(n,a){T[n]=a}const ye={class:"u-dict-field"},R=k(e.defineComponent({__name:"UDict",props:{fieldLabel:{},labelPosition:{default:"top"},labelWidth:{},labelAlign:{},required:{type:Boolean},modelValue:{},outlined:{type:Boolean},dense:{type:Boolean},filled:{type:Boolean},borderless:{type:Boolean},label:{},hint:{},error:{type:Boolean},errorMessage:{},type:{},placeholder:{},disable:{type:Boolean},readonly:{type:Boolean},dictType:{}},emits:["update:modelValue"],setup(n,{emit:a}){const t=n,l=a,d=e.reactive({excluded:["fieldLabel","labelPosition","labelWidth","labelAlign","required","modelValue","dictType"],options:[],loading:!1}),c=async()=>{if(t.dictType){d.loading=!0;try{const s=await S.get(D.dictApi(t.dictType));s.status===200?d.options=W(s.data):(console.error("[UDict] 请求失败:",s.message),d.options=[])}catch(s){console.error("[UDict] 加载字典失败:",s),d.options=[]}finally{d.loading=!1}}};e.watch(()=>t.dictType,()=>{c()},{immediate:!0});const m=e.computed(()=>{const s={};return t.labelPosition==="left"&&t.labelWidth&&(s.width=typeof t.labelWidth=="number"?`${t.labelWidth}px`:t.labelWidth),t.labelAlign&&(s.textAlign=t.labelAlign),s}),r=e.computed(()=>({"u-dict-label-left":t.labelPosition==="left","u-dict-label-top":t.labelPosition==="top"})),o={onUpdate(s){l("update:modelValue",s)}};return(s,i)=>{const p=C.ElOption,f=C.ElSelect;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["u-dict",r.value])},[n.fieldLabel?(e.openBlock(),e.createElementBlock("div",{key:0,class:"u-dict-label",style:e.normalizeStyle(m.value)},[e.createTextVNode(e.toDisplayString(n.fieldLabel)+" ",1),e.createElementVNode("span",{class:e.normalizeClass(["required-star",{"required-star--visible":n.required}])},"*",2)],4)):e.createCommentVNode("",!0),e.createElementVNode("div",ye,[e.createVNode(f,{"model-value":n.modelValue,placeholder:n.placeholder||"请选择",loading:d.loading,disabled:n.disable,style:{width:"100%"},onChange:o.onUpdate},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.options,u=>(e.openBlock(),e.createBlock(p,{key:u.value,label:u.label,value:u.value},null,8,["label","value"]))),128))]),_:1},8,["model-value","placeholder","loading","disabled","onChange"])])],2)}}}),[["__scopeId","data-v-8bfd4dcf"]]),be={class:"u-toggle-field"},G=k(e.defineComponent({__name:"UToggle",props:{fieldLabel:{},labelPosition:{default:"left"},labelWidth:{},labelAlign:{},required:{type:Boolean},modelValue:{},dense:{type:Boolean,default:!0},color:{},trueValue:{default:!0},falseValue:{default:!1},label:{},hint:{},disable:{type:Boolean},readonly:{type:Boolean},activeText:{},inactiveText:{},activeColor:{},inactiveColor:{}},emits:["update:modelValue"],setup(n,{emit:a}){const t=n,l=a,d=e.reactive({excluded:["fieldLabel","labelPosition","labelWidth","labelAlign","required","modelValue","trueValue","falseValue","activeText","inactiveText","activeColor","inactiveColor"]}),c=()=>{const o={};return t.labelPosition==="left"&&t.labelWidth&&(o.width=typeof t.labelWidth=="number"?`${t.labelWidth}px`:t.labelWidth),t.labelAlign&&(o.textAlign=t.labelAlign),o},m=e.computed({get:()=>t.modelValue===t.trueValue,set:o=>{l("update:modelValue",o?t.trueValue:t.falseValue)}}),r=e.computed(()=>{const o={};for(const s in t)!d.excluded.includes(s)&&s!=="modelValue"&&(o[s]=t[s]);return o});return(o,s)=>{const i=C.ElSwitch;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["u-toggle",{"u-toggle-label-left":n.labelPosition==="left"}])},[n.fieldLabel?(e.openBlock(),e.createElementBlock("div",{key:0,class:"u-toggle-label",style:e.normalizeStyle(c())},[e.createTextVNode(e.toDisplayString(n.fieldLabel)+" ",1),e.createElementVNode("span",{class:e.normalizeClass(["required-star",{"required-star--visible":n.required}])},"*",2)],4)):e.createCommentVNode("",!0),e.createElementVNode("div",be,[e.createVNode(i,e.mergeProps({modelValue:m.value,"onUpdate:modelValue":s[0]||(s[0]=p=>m.value=p)},r.value,{"active-text":n.activeText,"inactive-text":n.inactiveText,"active-color":n.activeColor,"inactive-color":n.inactiveColor}),null,16,["modelValue","active-text","inactive-text","active-color","inactive-color"])])],2)}}}),[["__scopeId","data-v-94c1fd38"]]),we={class:"u-cascader-levels"},H=k(e.defineComponent({__name:"UCascader",props:{fieldLabel:{},labelPosition:{default:"top"},labelWidth:{},labelAlign:{},required:{type:Boolean},modelValue:{},options:{},depth:{default:1}},emits:["update:modelValue"],setup(n,{emit:a}){const t=n,l=a,d=()=>{const o={};return t.labelPosition==="left"&&t.labelWidth&&(o.width=typeof t.labelWidth=="number"?`${t.labelWidth}px`:t.labelWidth),t.labelAlign&&(o.textAlign=t.labelAlign),o},c=e.ref([]),m=e.computed(()=>{const o=[];let s=t.options||[];for(let i=0;i<t.depth;i++)if(o.push(s),c.value[i]!==void 0){const p=s.find(f=>f.value===c.value[i]);p&&p.children?s=p.children:s=[]}else s=[];return o});e.watch(()=>t.modelValue,o=>{o!=null?c.value=Array.isArray(o)?o:[o]:c.value=[]},{immediate:!0});const r=(o,s)=>{c.value[o]=s;for(let p=o+1;p<t.depth;p++)c.value[p]=void 0;const i=c.value.filter(p=>p!==void 0);l("update:modelValue",i)};return(o,s)=>{const i=C.ElOption,p=C.ElSelect;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["u-cascader",{"u-cascader-label-left":n.labelPosition==="left"}])},[n.fieldLabel?(e.openBlock(),e.createElementBlock("div",{key:0,class:"u-cascader-label",style:e.normalizeStyle(d())},[e.createTextVNode(e.toDisplayString(n.fieldLabel)+" ",1),e.createElementVNode("span",{class:e.normalizeClass(["required-star",{"required-star--visible":n.required}])},"*",2)],4)):e.createCommentVNode("",!0),e.createElementVNode("div",we,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.depth,f=>(e.openBlock(),e.createElementBlock("div",{key:f-1,class:"u-cascader-level"},[e.createVNode(p,{"model-value":c.value[f-1],options:m.value[f-1]||[],disabled:f>1&&c.value[f-2]===void 0,placeholder:`请选择${f}级`,style:{width:"100%"},onChange:u=>r(f-1,u)},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.value[f-1]||[],u=>(e.openBlock(),e.createBlock(i,{key:u.value,label:u.label,value:u.value},null,8,["label","value"]))),128))]),_:2},1032,["model-value","options","disabled","placeholder","onChange"])]))),128))])],2)}}}),[["__scopeId","data-v-d66c339c"]]),Ce={class:"u-date-field"},z=k(e.defineComponent({__name:"UDate",props:{fieldLabel:{},labelPosition:{default:"top"},labelWidth:{},labelAlign:{},required:{type:Boolean},modelValue:{},mode:{default:"single"},locale:{default:"zh-CN"},mask:{default:"YYYY-MM-DD"},min:{},max:{}},emits:["update:modelValue"],setup(n,{emit:a}){const t=n,l=a,d=()=>{const o={};return t.labelPosition==="left"&&t.labelWidth&&(o.width=typeof t.labelWidth=="number"?`${t.labelWidth}px`:t.labelWidth),t.labelAlign&&(o.textAlign=t.labelAlign),o},c=e.ref("");e.watch(()=>t.modelValue,o=>{t.mode==="single"?c.value=o||"":t.mode==="multiple"?c.value=Array.isArray(o)?o:o?[o]:[]:t.mode==="range"&&(o&&typeof o=="object"&&o.from&&o.to?c.value=[o.from,o.to]:c.value=[])},{immediate:!0});const m=o=>{o&&(t.mode==="single"||t.mode==="multiple"?l("update:modelValue",o):t.mode==="range"&&o&&o.length===2&&l("update:modelValue",{from:o[0],to:o[1]}))},r=e.computed(()=>t.mode==="range"?"daterange":t.mode==="multiple"?"dates":"date");return(o,s)=>{const i=C.ElDatePicker;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["u-date",{"u-date-label-left":n.labelPosition==="left"}])},[n.fieldLabel?(e.openBlock(),e.createElementBlock("div",{key:0,class:"u-date-label",style:e.normalizeStyle(d())},[e.createTextVNode(e.toDisplayString(n.fieldLabel)+" ",1),e.createElementVNode("span",{class:e.normalizeClass(["required-star",{"required-star--visible":n.required}])},"*",2)],4)):e.createCommentVNode("",!0),e.createElementVNode("div",Ce,[e.createVNode(i,{modelValue:c.value,"onUpdate:modelValue":s[0]||(s[0]=p=>c.value=p),type:r.value,placeholder:n.locale==="en-US"?"Select date":"选择日期","range-separator":n.locale==="en-US"?"to":"至","start-placeholder":n.locale==="en-US"?"Start date":"开始日期","end-placeholder":n.locale==="en-US"?"End date":"结束日期",format:n.mask.replace("YYYY","YYYY").replace("MM","MM").replace("DD","DD"),"value-format":n.mask.replace("YYYY","YYYY").replace("MM","MM").replace("DD","DD"),onChange:m},null,8,["modelValue","type","placeholder","range-separator","start-placeholder","end-placeholder","format","value-format"])])],2)}}}),[["__scopeId","data-v-9cd05064"]]);function I(n,a="info"){V.ElMessage({message:n,type:a,duration:1e3,showClose:!1})}function _(n){V.ElMessage({message:n,type:"error",duration:2e3,showClose:!1})}function ke(n){I(n,"success")}function xe(n){I(n,"error")}function Be(n){I(n,"warning")}function Ve(n){I(n,"info")}const E={notify:I,success:ke,error:xe,warning:Be,info:Ve,alertError:_},Se={key:0,class:"u-menu-brand"},_e=["src"],Ee={class:"u-menu-brand-text"},De={key:1,class:"u-menu-logout"},ae=k(e.defineComponent({__name:"UMenu",props:{menuId:{default:"menu"},config:{},mode:{},projectName:{},activePath:{},width:{}},emits:["menu-click","logout"],setup(n,{expose:a,emit:t}){const l=n,d=t,c=e.reactive({config:null,menus:[],activePath:"",iconMap:{},iconsLoaded:!1}),m=e.computed(()=>{var o,s,i,p,f,u,g,h;return{projectName:l.projectName??((o=c.config)==null?void 0:o.projectName)??"",logo:((s=c.config)==null?void 0:s.logo)||"",mode:l.mode??((i=c.config)==null?void 0:i.mode)??"sidebar",isHorizontal:(l.mode??((p=c.config)==null?void 0:p.mode)??"sidebar")==="horizontal",elMode:(l.mode??((f=c.config)==null?void 0:f.mode)??"sidebar")==="horizontal"?"horizontal":"vertical",width:l.width??((u=c.config)==null?void 0:u.width)??220,menus:c.menus,activeIndex:r.getIndexByPath(c.activePath),showLogout:((g=c.config)==null?void 0:g.showLogout)!==!1,logoutText:((h=c.config)==null?void 0:h.logoutText)||"退出登录",iconMap:c.iconMap}}),r={async init(){await r.ensureIcons(),l.config?(c.config=l.config,c.menus=r.normalizeMenus(l.config.menus)):await r.loadConfig(l.menuId),c.activePath=l.activePath||c.activePath},async loadConfig(o){if(o)try{const s=await S.get(D.formCfgApi(o,"menus"));if(s.status!==200){_(s.message||"获取菜单配置失败");return}const i=s.data||{};c.config=i,i.dictType?await r.loadDictMenus(i.dictType):c.menus=r.normalizeMenus(i.menus)}catch(s){_((s==null?void 0:s.message)||"获取菜单配置失败"),c.menus=[]}},async loadDictMenus(o){try{const s=await S.get(D.cascaderApi(o));if(s.status!==200){_(s.message||"获取菜单字典失败");return}c.menus=r.normalizeMenus(q(s.data))}catch(s){_((s==null?void 0:s.message)||"获取菜单字典失败"),c.menus=[]}},normalizeMenus(o){return Array.isArray(o)?o.map(s=>r.normalizeMenuNode(s)).filter(Boolean):[]},normalizeMenuNode(o){if(!o||typeof o!="object")return null;const s=r.parseInfo(o.info),i=o.label??o.dict_value??o.name;if(!i)return null;const p=s.path??o.path??o.dict_code??o.value??"",f=s.type??o.type??"route",u={...o,label:String(i),type:f,path:String(p??""),icon:s.icon??o.icon??""},g=s.id??o.id;g!=null&&g!==""&&(u.id=String(g));const h=s.open??o.open;(h==="new"||h==="self")&&(u.open=h),delete u.children;const b=o.children;return Array.isArray(b)&&b.length>0&&(u.children=b.map(x=>r.normalizeMenuNode(x)).filter(Boolean)),u},parseInfo(o){if(!o)return{};if(typeof o=="object")return o;if(typeof o=="string")try{const s=JSON.parse(o);return s&&typeof s=="object"?s:{}}catch{return{path:o}}return{}},itemIndex(o,s){return o.path||`menu-${s}`},childIndex(o,s,i,p){return i.path?i.path:`${r.itemIndex(o,s)}-${p}`},hasChildren(o){return Array.isArray(o.children)&&o.children.length>0},getIndexByPath(o){if(!o)return"";for(let s=0;s<c.menus.length;s++){const i=c.menus[s];if(i.path===o)return r.itemIndex(i,s);const p=i.children||[];for(let f=0;f<p.length;f++)if(p[f].path===o)return r.childIndex(i,s,p[f],f)}return""},findItemByIndex(o,s){for(let i=0;i<c.menus.length;i++){const p=c.menus[i],f=r.itemIndex(p,i);if(f===o)return{item:p,level:1,indexPath:s||[f],index:o};const u=p.children||[];for(let g=0;g<u.length;g++){const h=u[g],b=r.childIndex(p,i,h,g);if(b===o)return{item:h,level:2,indexPath:s||[f,b],index:o}}}return null},resolveTarget(o){const s=o.type||"route",i=o.path||"";return s==="url"?{type:s,path:i,url:i,open:o.open||"new"}:s==="form"||s==="table"||s==="menu"?{type:s,path:i,id:o.id||i}:{type:"route",path:i,route:i}},handleSelect(o,s){const i=r.findItemByIndex(o,s);if(!i||r.hasChildren(i.item))return;const p=r.resolveTarget(i.item);c.activePath=i.item.path||o;const f={...p,item:i.item,level:i.level,indexPath:i.indexPath,index:o};d("menu-click",f)},handleLogout(){d("logout")},setActivePath(o){c.activePath=o},async ensureIcons(){if(!c.iconsLoaded){c.iconsLoaded=!0;try{const o=await import("@element-plus/icons-vue"),s=o!=null&&o.default?{...o.default,...o}:{...o},i={};for(const[p,f]of Object.entries(s))i[p]=e.markRaw(f);c.iconMap=i}catch(o){console.warn("[UMenu] @element-plus/icons-vue 不可用,菜单图标将被忽略",o)}}},getIcon(o){return o&&c.iconMap[o]||null}};return e.watch(()=>l.menuId,o=>{l.config||r.loadConfig(o)}),e.watch(()=>l.activePath,o=>{c.activePath=o||""}),e.watch(()=>l.config,o=>{o&&(c.config=o,c.menus=r.normalizeMenus(o.menus))}),e.onMounted(()=>{r.init()}),a({loadConfig:r.loadConfig,setActivePath:r.setActivePath}),(o,s)=>{const i=C.ElIcon,p=C.ElMenuItem,f=C.ElSubMenu,u=C.ElMenu,g=C.ElButton;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["u-menu",[`u-menu--${m.value.mode}`,{"u-menu--no-brand":!m.value.projectName}]]),style:e.normalizeStyle(m.value.isHorizontal?{}:{width:m.value.width+"px"})},[m.value.projectName?(e.openBlock(),e.createElementBlock("div",Se,[e.renderSlot(o.$slots,"brand",{projectName:m.value.projectName,mode:m.value.mode},()=>[m.value.logo?(e.openBlock(),e.createElementBlock("img",{key:0,class:"u-menu-logo",src:m.value.logo,alt:"logo"},null,8,_e)):e.createCommentVNode("",!0),e.createElementVNode("span",Ee,e.toDisplayString(m.value.projectName),1)],!0)])):e.createCommentVNode("",!0),e.createVNode(u,{class:"u-menu-list",mode:m.value.elMode,"default-active":m.value.activeIndex,"unique-opened":!m.value.isHorizontal,onSelect:r.handleSelect},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.value.menus,(h,b)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:r.itemIndex(h,b)},[r.hasChildren(h)?(e.openBlock(),e.createBlock(f,{key:0,index:r.itemIndex(h,b)},{title:e.withCtx(()=>[e.renderSlot(o.$slots,"menu-title",{item:h,level:1,index:b},()=>[r.getIcon(h.icon)?(e.openBlock(),e.createBlock(i,{key:0,class:"u-menu-icon"},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(r.getIcon(h.icon))))]),_:2},1024)):e.createCommentVNode("",!0),e.createElementVNode("span",null,e.toDisplayString(h.label),1)],!0)]),default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.children,(x,A)=>(e.openBlock(),e.createBlock(p,{key:r.childIndex(h,b,x,A),index:r.childIndex(h,b,x,A)},{default:e.withCtx(()=>[e.renderSlot(o.$slots,"menu-item",{item:x,level:2,index:A,parent:h},()=>[r.getIcon(x.icon)?(e.openBlock(),e.createBlock(i,{key:0,class:"u-menu-icon"},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(r.getIcon(x.icon))))]),_:2},1024)):e.createCommentVNode("",!0),e.createElementVNode("span",null,e.toDisplayString(x.label),1)],!0)]),_:2},1032,["index"]))),128))]),_:2},1032,["index"])):(e.openBlock(),e.createBlock(p,{key:1,index:r.itemIndex(h,b)},{default:e.withCtx(()=>[e.renderSlot(o.$slots,"menu-item",{item:h,level:1,index:b,parent:null},()=>[r.getIcon(h.icon)?(e.openBlock(),e.createBlock(i,{key:0,class:"u-menu-icon"},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(r.getIcon(h.icon))))]),_:2},1024)):e.createCommentVNode("",!0),e.createElementVNode("span",null,e.toDisplayString(h.label),1)],!0)]),_:2},1032,["index"]))],64))),128))]),_:3},8,["mode","default-active","unique-opened","onSelect"]),m.value.showLogout?(e.openBlock(),e.createElementBlock("div",De,[e.renderSlot(o.$slots,"logout",{mode:m.value.mode},()=>[e.createVNode(g,{class:"u-menu-logout-btn",text:"",onClick:r.handleLogout},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(m.value.logoutText),1)]),_:1},8,["onClick"])],!0)])):e.createCommentVNode("",!0)],6)}}}),[["__scopeId","data-v-fe63251c"]]),Te={class:"form-content"},Pe={key:1,class:"form-layout"},$e={key:0,class:"form-header"},Ne={class:"title"},Re={class:"form-body"},Ie={key:1,class:"form-footer"},Ae=k(e.defineComponent({__name:"FormContainer",props:{visible:{type:Boolean},layout:{},title:{},loading:{type:Boolean,default:!1}},emits:["update:visible","close","closed"],setup(n,{emit:a}){const t=n,l=a,{visible:d}=e.toRefs(t),c=e.computed(()=>t.layout.open==="normal"),m=e.computed(()=>t.layout.width||400),r={handleClose(){l("update:visible",!1),l("close")},handleClosed(){l("closed")},updateVisible(o){l("update:visible",o)}};return(o,s)=>{const i=C.ElIcon,p=C.ElDialog;return c.value?e.unref(d)?(e.openBlock(),e.createElementBlock("div",Pe,[n.title?(e.openBlock(),e.createElementBlock("div",$e,[e.createElementVNode("div",Ne,e.toDisplayString(n.title),1)])):e.createCommentVNode("",!0),e.createElementVNode("div",Re,[n.loading?(e.openBlock(),e.createBlock(i,{key:0,class:"is-loading",size:40},{default:e.withCtx(()=>[e.createVNode(e.unref(ee.Loading))]),_:1})):e.renderSlot(o.$slots,"default",{},void 0,!0,1)]),o.$slots.actions?(e.openBlock(),e.createElementBlock("div",Ie,[e.renderSlot(o.$slots,"actions",{},void 0,!0)])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(p,{key:0,"model-value":e.unref(d),title:n.title,width:m.value,"close-on-click-modal":!1,"onUpdate:modelValue":r.updateVisible,onClose:r.handleClose,onClosed:r.handleClosed},{footer:e.withCtx(()=>[e.renderSlot(o.$slots,"actions",{},void 0,!0)]),default:e.withCtx(()=>[e.createElementVNode("div",Te,[n.loading?(e.openBlock(),e.createBlock(i,{key:0,class:"is-loading",size:40},{default:e.withCtx(()=>[e.createVNode(e.unref(ee.Loading))]),_:1})):e.renderSlot(o.$slots,"default",{},void 0,!0,1)])]),_:3},8,["model-value","title","width","onUpdate:modelValue","onClose","onClosed"]))}}}),[["__scopeId","data-v-83362259"]]),Me=k(e.defineComponent({__name:"FormGrid",props:{fields:{},layout:{}},setup(n){const a=n,t=e.reactive({columns:e.computed(()=>a.layout.columns||1)}),l={getColSpan(d){const c=d.colSpan||1;return Math.min(c,t.columns)}};return(d,c)=>(e.openBlock(),e.createElementBlock("div",{class:"form-grid",style:e.normalizeStyle({"--grid-columns":t.columns})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.fields,m=>(e.openBlock(),e.createElementBlock("div",{key:m.field,class:"form-grid-item",style:e.normalizeStyle({gridColumn:`span ${l.getColSpan(m)}`})},[e.renderSlot(d.$slots,"default",{field:m},void 0,!0)],4))),128))],4))}}),[["__scopeId","data-v-90ed35a4"]]),Ue={class:"form-field"},ze=k(e.defineComponent({__name:"FormField",props:{field:{},modelValue:{},layout:{},disabled:{type:Boolean,default:!1},error:{}},emits:["update:modelValue"],setup(n,{emit:a}){const t=n,l=a,d=e.reactive({componentMap:e.markRaw({input:$,"input-number":Q,dict:R,switch:G,cascader:H,date:z}),cascaderOptions:[]}),c=()=>{t.field.cascaderKey&&S.get(D.cascaderApi(t.field.cascaderKey)).then(i=>{i.status===200&&(d.cascaderOptions=q(i.data))})};e.watch(()=>t.field.cascaderKey,c,{immediate:!0});const m=e.computed(()=>d.componentMap[t.field.type]||$),r=e.computed(()=>{if((t.layout.labelPosition||"top")==="left"){const p=t.layout.labelWidth||0,f=typeof p=="number"?p+4:p;return{marginLeft:typeof f=="number"?`${f}px`:f}}return{}}),o=e.computed(()=>{const{field:i,modelValue:p,layout:f,disabled:u}=t;let g=p;i.type==="switch"&&p==null&&(g=!1);const h={fieldLabel:i.label,modelValue:g,labelPosition:f.labelPosition||"top",disable:u,name:i.field,required:i.required};if(f.labelWidth&&(h.labelWidth=f.labelWidth),f.labelAlign&&(h.labelAlign=f.labelAlign),i.maxlength&&(h.maxlength=i.maxlength),i.placeholder&&(h.placeholder=i.placeholder),i.readonly&&(h.readonly=i.readonly),i.lineCount&&i.lineCount>=2?(h.type="textarea",h.rows=i.lineCount):i.inputType&&(h.type=i.inputType),i.type==="switch"&&(i.activeText&&(h.activeText=i.activeText),i.inactiveText&&(h.inactiveText=i.inactiveText),i.activeColor&&(h.activeColor=i.activeColor),i.inactiveColor&&(h.inactiveColor=i.inactiveColor),i.trueValue!==void 0&&(h.trueValue=i.trueValue),i.falseValue!==void 0&&(h.falseValue=i.falseValue)),i.dictType&&(h.dictType=i.dictType),i.cascaderKey&&(h.options=d.cascaderOptions,h.depth=i.cascaderDepth||2),i.type==="date"){i.mode&&(h.mode=i.mode),i.locale&&(h.locale=i.locale),i.format?h.mask=i.format:i.mask&&(h.mask=i.mask);const b=i.dateMin??i.min,x=i.dateMax??i.max;b!=null&&(h.min=b),x!=null&&(h.max=x)}return i.type==="input-number"&&(i.min!==void 0&&(h.min=i.min),i.max!==void 0&&(h.max=i.max),i.step&&(h.step=i.step),i.precision!==void 0&&(h.precision=i.precision)),h}),s={handleUpdate(i){l("update:modelValue",i)}};return(i,p)=>(e.openBlock(),e.createElementBlock("div",Ue,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(m.value),e.mergeProps(o.value,{"onUpdate:modelValue":s.handleUpdate}),null,16,["onUpdate:modelValue"])),e.createElementVNode("div",{class:e.normalizeClass(["field-error",{"field-error--visible":n.error}]),style:e.normalizeStyle(r.value)},e.toDisplayString(n.error||""),7)]))}}),[["__scopeId","data-v-10299c8d"]]);class Fe{constructor(){w(this,"formConfig",null);w(this,"formData",{});w(this,"loading",!1);w(this,"submitting",!1);w(this,"visible",!1);w(this,"isEditMode",!1);w(this,"errors",[]);w(this,"currentQuery",{})}}let Le=class{constructor(){w(this,"data",e.reactive(new Fe))}parseQuery(a){if(!a)return{};const t={},l=a.split("&");for(const d of l){const[c,m]=d.split("=");c&&(t[c]=m||"")}return t}async fetchFormConfig(a){const t=await S.get(D.formCfgApi(a,"forms"));if(t.status!==200)throw new Error(t.message||"获取表单配置失败");return t.data}async fetchFormData(a,t){const l=t?`${a}?${t}`:a,d=await S.get(l);if(d.status!==200)throw new Error(d.message||"获取表单数据失败");return d.data}async submitForm(a,t){return await S.post(a,t)}buildInitialData(a){const t={};for(const l of a)l.default!==void 0?t[l.field]=l.default:t[l.field]=null;return t}checkIsEditMode(a){return!!a&&a.trim().length>0}validate(){var t;this.data.errors=[];const a=((t=this.data.formConfig)==null?void 0:t.fields)||[];for(const l of a){const d=this.data.formData[l.field];if(l.required&&(d==null||d==="")){this.data.errors.push({field:l.field,message:`${l.label}为必填项`});continue}if(l.rules&&l.rules.length>0&&d){for(const c of l.rules)if(c.pattern&&!new RegExp(c.pattern).test(d)){this.data.errors.push({field:l.field,message:c.message||`${l.label}格式不正确`});break}}}return this.data.errors.length===0}getFieldError(a){const t=this.data.errors.find(l=>l.field===a);return t?t.message:null}clearErrors(){this.data&&(this.data.errors=[])}async openForm(a,t){this.data.loading=!0,this.data.visible=!0,this.clearErrors(),this.data.currentQuery=this.parseQuery(t||"");try{const l=await this.fetchFormConfig(a);if(this.data.formConfig=l,this.data.isEditMode=this.checkIsEditMode(t||""),this.data.formData=this.buildInitialData(l.fields),this.data.isEditMode&&l.api.get&&t){const d=await this.fetchFormData(l.api.get,t),c=this.nestedToFlat(d);this.data.formData={...this.data.formData,...c}}}catch(l){throw console.error("[FormRender] 打开表单失败:",l),this.data.visible=!1,l}finally{this.data.loading=!1}}async doSubmit(){if(!this.data.formConfig)return;if(!this.validate())throw new Error("请完善表单信息");const{api:a}=this.data.formConfig;let t=this.data.isEditMode?a.edit:a.add;if(!t)throw new Error("提交地址未配置");let l={...this.data.formData};l=this.flattenToNested(l),this.data.isEditMode&&this.data.currentQuery.id&&(l.id=Number(this.data.currentQuery.id)),this.data.submitting=!0;try{const d=await this.submitForm(t,l);if(d.status===200)return d.data;throw new Error(d.message||"提交失败")}finally{this.data.submitting=!1}}closeForm(){this&&(this.data.visible=!1)}resetForm(){this.data.formConfig=null,this.data.formData={},this.data.isEditMode=!1,this.data.currentQuery={},this.clearErrors()}flattenToNested(a){const t={};for(const l in a){const d=a[l];if(l.includes(".")){const c=l.split(".");let m=t;for(let r=0;r<c.length-1;r++){const o=c[r];m[o]||(m[o]={}),m=m[o]}m[c[c.length-1]]=d}else t[l]=d}return t}nestedToFlat(a,t=""){const l={};for(const d in a){const c=a[d],m=t?`${t}.${d}`:d;c&&typeof c=="object"&&!Array.isArray(c)?Object.keys(c).length===2&&"from"in c&&"to"in c?l[m]=c:Object.assign(l,this.nestedToFlat(c,m)):l[m]=c}return l}};const J=k(e.defineComponent({__name:"FormRender",setup(n,{expose:a}){const t=new Le,l=e.ref(null),d=e.reactive({currentQuery:{},submitResolve:null}),c=e.computed(()=>{var u;const f={};if(!t.data.isEditMode||!d.currentQuery)return f;for(const g of((u=t.data.formConfig)==null?void 0:u.fields)||[])d.currentQuery[g.field]!==void 0&&(f[g.field]=!0);return f}),m=e.computed(()=>{var f;return((f=t.data.formConfig)==null?void 0:f.layout)||{open:"dialog",columns:1,labelPosition:"top",buttonAlign:"right"}}),r=e.computed(()=>{var f;return((f=t.data.formConfig)==null?void 0:f.fields)||[]}),o=e.computed(()=>{var f,u;return((u=(f=t.data.formConfig)==null?void 0:f.meta)==null?void 0:u.title)||"表单"}),s=e.computed(()=>m.value.buttonAlign||"right"),i=e.computed(()=>m.value.open==="normal"),p={async showForm(f,u){d.currentQuery=t.parseQuery(u||"");try{await t.openForm(f,u)}catch(g){return _((g==null?void 0:g.message)||"打开表单失败"),null}return new Promise(g=>{d.submitResolve=g})},async handleSubmit(){var f,u;try{const g=await t.doSubmit(),h=((u=(f=t.data.formConfig)==null?void 0:f.meta)==null?void 0:u.title)+"保存成功";return E.success(h),d.submitResolve&&(d.submitResolve(g),d.submitResolve=null),i.value||t.closeForm(),g}catch(g){return d.submitResolve&&(d.submitResolve(null),d.submitResolve=null),g!=null&&g.message&&g.message!=="请完善表单信息"&&_(g.message),null}},resolvePending(){d.submitResolve&&(d.submitResolve(null),d.submitResolve=null)},handleCancel(){i.value||(p.resolvePending(),t.closeForm())},getFieldError(f){return t.getFieldError(f)},handleClose(){p.resolvePending(),t.closeForm()},handleClosed(){t.data.visible||t.resetForm()}};return a({showForm:p.showForm}),(f,u)=>{const g=C.ElForm,h=C.ElButton;return e.openBlock(),e.createBlock(Ae,{visible:e.unref(t).data.visible,"onUpdate:visible":u[0]||(u[0]=b=>e.unref(t).data.visible=b),layout:m.value,title:o.value,loading:e.unref(t).data.loading,onClose:p.handleClose,onClosed:p.handleClosed},{actions:e.withCtx(()=>[e.createElementVNode("div",{class:e.normalizeClass(["form-actions",s.value==="right"?"justify-end":"justify-start"])},[e.createVNode(h,{onClick:p.handleCancel},{default:e.withCtx(()=>[...u[1]||(u[1]=[e.createTextVNode("取消",-1)])]),_:1},8,["onClick"]),e.createVNode(h,{type:"primary",loading:e.unref(t).data.submitting,onClick:p.handleSubmit},{default:e.withCtx(()=>[...u[2]||(u[2]=[e.createTextVNode("提交",-1)])]),_:1},8,["loading","onClick"])],2)]),default:e.withCtx(()=>[e.createVNode(g,{ref_key:"formRef",ref:l,class:"form-render","label-position":"top"},{default:e.withCtx(()=>[e.createVNode(Me,{fields:r.value,layout:m.value},{default:e.withCtx(({field:b})=>[e.createVNode(ze,{modelValue:e.unref(t).data.formData[b.field],"onUpdate:modelValue":x=>e.unref(t).data.formData[b.field]=x,field:b,layout:m.value,disabled:c.value[b.field],error:p.getFieldError(b.field)},null,8,["modelValue","onUpdate:modelValue","field","layout","disabled","error"])]),_:1},8,["fields","layout"])]),_:1},512)]),_:1},8,["visible","layout","title","loading","onClose","onClosed"])}}}),[["__scopeId","data-v-b3267c00"]]);class qe{constructor(a){this.config=a}async fetchList(a,t){const l={page:t.page,pageSize:t.pageSize,...a},d={};for(const o in l){const s=l[o];s!==""&&s!==null&&s!==void 0&&(d[o]=s)}const c=new URLSearchParams;for(const o in d)c.append(o,String(d[o]));const m=`${this.config.api.list}${c.toString()?"?"+c.toString():""}`,r=await S.get(m);if(r.status===200){const o=r.data;return Array.isArray(o)?{rows:o,total:o.length}:o||{rows:[],total:0}}throw new Error(r.message||"获取列表数据失败")}async deleteRow(a){if(!this.config.api.delete)throw new Error("未配置删除API");const t=this.config.key||"id",l=a[t],d=`${this.config.api.delete}?${encodeURIComponent(t)}=${encodeURIComponent(String(l??""))}`,c=await S.post(d);if(c.status!==200)throw new Error(c.message||"删除失败")}async batchDelete(a){if(!this.config.api.delete)throw new Error("未配置删除API");const t=await S.post(this.config.api.delete,a);if(t.status!==200)throw new Error(t.message||"批量删除失败")}async exportData(a){if(!this.config.api.export)throw new Error("未配置导出API");const l=(await S.post(this.config.api.export,a,{responseType:"blob"})).data,d=window.URL.createObjectURL(l),c=document.createElement("a");c.href=d,c.download=`export_${Date.now()}.xlsx`,c.click(),window.URL.revokeObjectURL(d)}async downloadTemplate(){if(!this.config.api.import)throw new Error("未配置导入API");const t=(await S.get(`${this.config.api.import}/template`,{responseType:"blob"})).data,l=window.URL.createObjectURL(t),d=document.createElement("a");d.href=l,d.download=`template_${Date.now()}.xlsx`,d.click(),window.URL.revokeObjectURL(l)}async importData(a){if(!this.config.api.import)throw new Error("未配置导入API");const t=new FormData;t.append("file",a);const l=await S.post(this.config.api.import,t,{headers:{"Content-Type":"multipart/form-data"}});if(l.status!==200)throw new Error(l.message||"导入失败");return l.data}}class We{constructor(){w(this,"tableConfig",null);w(this,"rows",[]);w(this,"total",0);w(this,"loading",!1);w(this,"searchParams",{});w(this,"pagination",{page:1,pageSize:20});w(this,"currentRow",null);w(this,"detailVisible",!1);w(this,"detailData",null);w(this,"detailLoading",!1);w(this,"previewVisible",!1);w(this,"previewMounted",!1);w(this,"previewRow",null)}}let je=class{constructor(){w(this,"data",e.reactive(new We));w(this,"dataService",null)}async loadConfig(a){var d;const t=D.formCfgApi(a,"tables");console.log("load config url =",t);const l=await S.get(t);if(console.log("---"),l.status!==200)throw new Error(l.message||"获取表格配置失败");this.data.tableConfig=l.data,this.dataService=new qe(l.data),this.data.currentRow=null,this.data.detailVisible=!1,this.data.detailData=null,this.data.previewVisible=!1,this.data.previewMounted=!1,this.data.previewRow=null,typeof console<"u"&&console.log("[TableRender] loadConfig:",{tableId:a,hasDetail:this.hasDetail(),detail:(d=this.data.tableConfig)==null?void 0:d.detail}),this.initSearchParams()}initSearchParams(){var l;const a={},t=((l=this.data.tableConfig)==null?void 0:l.search)||[];for(const d of t)a[d.field]="";this.data.searchParams=a}async loadData(){if(!this.dataService)throw new Error("表格配置未加载");this.data.loading=!0;try{const a=await this.dataService.fetchList(this.data.searchParams,this.data.pagination);this.data.rows=a.rows||[],this.data.total=a.total||0,this.syncRowRefs()}finally{this.data.loading=!1}}syncRowRefs(){const{currentRow:a,detailData:t}=this.data;if(!a&&!t)return;const l=this.getKeyField(),d=c=>c&&this.data.rows.find(m=>m[l]===c[l])||null;this.data.currentRow=d(a),this.data.detailData&&(this.data.detailData=d(this.data.detailData),this.data.detailData||(this.data.detailVisible=!1))}async search(){this.data.pagination.page=1,await this.loadData()}async reset(){this.initSearchParams(),this.data.pagination.page=1,await this.loadData()}updateSearchParam(a,t){this.data.searchParams[a]=t}async deleteRow(a){if(!this.dataService)throw new Error("表格配置未加载");await this.dataService.deleteRow(a),await this.loadData(),this.isSameRow(a,this.data.currentRow)&&(this.data.currentRow=null),this.isSameRow(a,this.data.detailData)&&this.closeDetail(),this.isSameRow(a,this.data.previewRow)&&this.closePreview()}isSameRow(a,t){return!a||!t?!1:a[this.getKeyField()]===t[this.getKeyField()]}async changePage(a){this.data.pagination.page=a,await this.loadData()}async changePageSize(a){this.data.pagination.pageSize=a,this.data.pagination.page=1,await this.loadData()}setCurrentRow(a){this.data.currentRow=a,this.hasDetail()&&this.openDetail(a)}getCurrentRow(){return this.data.currentRow}getCurrentKey(){var a;return(a=this.data.currentRow)==null?void 0:a[this.getKeyField()]}async exportData(){if(!this.dataService)throw new Error("表格配置未加载");await this.dataService.exportData(this.data.searchParams)}async downloadTemplate(){if(!this.dataService)throw new Error("表格配置未加载");await this.dataService.downloadTemplate()}async importData(a){if(!this.dataService)throw new Error("表格配置未加载");const t=await this.dataService.importData(a);return await this.loadData(),t}getKeyField(){var a;return((a=this.data.tableConfig)==null?void 0:a.key)||"id"}getFormId(){var a;return(a=this.data.tableConfig)==null?void 0:a.form}getDetailFormId(){var a,t;return(t=(a=this.data.tableConfig)==null?void 0:a.detail)==null?void 0:t.formId}hasDetail(){var t;const a=(t=this.data.tableConfig)==null?void 0:t.detail;return!a||typeof a!="object"||a.enable===!1?!1:a.enable===!0||a.enable!==void 0&&a.enable!==null&&a.enable!==""?!0:!!(a.formId||a.position)}isDetailInline(){var a,t;return((t=(a=this.data.tableConfig)==null?void 0:a.detail)==null?void 0:t.enable)===!0}getDetailMode(){return this.isDetailInline()?"inline":"drawer"}getDetailPosition(){var a,t;return((t=(a=this.data.tableConfig)==null?void 0:a.detail)==null?void 0:t.position)||"right"}getDetailWidth(){var t,l;const a=(l=(t=this.data.tableConfig)==null?void 0:t.detail)==null?void 0:l.width;return typeof a=="number"&&a>0?`${a}px`:typeof a=="string"&&a?a:"400px"}getDetailDirection(){return{left:"ltr",right:"rtl",top:"ttb"}[this.getDetailPosition()]||"rtl"}isDetailOpen(){return this.isDetailInline()||this.data.detailVisible}openDetail(a){this.data.detailData=a,this.data.detailVisible=!0}closeDetail(){this.data.detailVisible=!1,this.isDetailInline()&&(this.data.detailData=null)}resetDetail(){this.data.detailVisible||(this.data.detailData=null)}openPreview(a){this.data.previewRow=a,this.data.previewVisible=!0,this.data.previewMounted=!0}closePreview(){this.data.previewVisible=!1}resetPreview(){this.data.previewVisible||(this.data.previewRow=null,this.data.previewMounted=!1)}getSearchFields(){var a;return((a=this.data.tableConfig)==null?void 0:a.search)||[]}getColumns(){var a;return((a=this.data.tableConfig)==null?void 0:a.columns)||[]}hasSearch(){return this.getSearchFields().length>0}getToolbar(){var t;const a=(t=this.data.tableConfig)==null?void 0:t.toolbar;return Array.isArray(a)?a:[]}hasToolbar(){return this.getToolbar().length>0}getActions(){var t;const a=(t=this.data.tableConfig)==null?void 0:t.actions;return Array.isArray(a)?a:[]}hasActions(){return this.getActions().length>0}getButtonFormId(a){var t;return(a==null?void 0:a.form)||((t=this.data.tableConfig)==null?void 0:t.form)}getPaginationType(){var a;return((a=this.data.tableConfig)==null?void 0:a.pagination)||"page"}};const Oe={class:"table-search"},Ye={class:"search-fields"},Qe={class:"search-actions"},Ke=k(e.defineComponent({__name:"TableSearch",props:{fields:{},modelValue:{}},emits:["update:modelValue","search","reset"],setup(n,{emit:a}){const t=n,l=a,d={input:$,dict:R,dept:R,role:R,date:z,daterange:z},c={getComponent(m){return d[m]||$},updateValue(m,r){const o={...t.modelValue,[m]:r};l("update:modelValue",o)},handleSearch(){const m={};for(const r in t.modelValue){const o=t.modelValue[r];m[r]=typeof o=="string"?o.trim():o}l("update:modelValue",m),l("search")},handleReset(){l("reset")}};return(m,r)=>{const o=C.ElButton;return e.openBlock(),e.createElementBlock("div",Oe,[e.createElementVNode("div",Ye,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.fields,s=>(e.openBlock(),e.createElementBlock("div",{key:s.field,class:"search-field"},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(c.getComponent(s.type)),{"model-value":t.modelValue[s.field],"field-label":s.label,"dict-type":s.dictType,mode:s.type==="daterange"?"range":void 0,"label-position":"left","onUpdate:modelValue":i=>c.updateValue(s.field,i)},null,8,["model-value","field-label","dict-type","mode","onUpdate:modelValue"]))]))),128)),e.renderSlot(m.$slots,"search-extra",{params:t.modelValue,update:c.updateValue},void 0,!0)]),e.createElementVNode("div",Qe,[e.createVNode(o,{type:"primary",onClick:c.handleSearch},{default:e.withCtx(()=>[...r[0]||(r[0]=[e.createTextVNode("查询",-1)])]),_:1},8,["onClick"]),e.createVNode(o,{onClick:c.handleReset},{default:e.withCtx(()=>[...r[1]||(r[1]=[e.createTextVNode("重置",-1)])]),_:1},8,["onClick"]),e.renderSlot(m.$slots,"search-actions",{params:t.modelValue,search:c.handleSearch,reset:c.handleReset},void 0,!0)])])}}}),[["__scopeId","data-v-09e61a77"]]),Ge={class:"table-toolbar"},He={class:"toolbar-items"},Je={key:1},Xe=k(e.defineComponent({__name:"TableToolbar",props:{items:{},currentRow:{}},emits:["action"],setup(n,{emit:a}){const t=n,l=a,d=e.reactive({iconMap:{}}),c=e.computed(()=>({hasCurrentRow:!!t.currentRow})),m={needRow(r){return r==="edit"||r==="delete"||r==="preview"},getText(r){return r.text?r.text:{add:"新增",edit:"编辑",delete:"删除",preview:"预览",back:"返回"}[r.action]||""},getButtonType(r){return r.style?r.style==="default"?"":r.style:{add:"primary",edit:"primary",delete:"danger",preview:"primary",back:"primary"}[r.action]||""},isDisabled(r){return r.disabled?!0:m.needRow(r.action)&&!c.value.hasCurrentRow},getIcon(r){return r.icon?d.iconMap[r.icon]:null},handleClick(r){l("action",{action:r.action,item:r,row:t.currentRow})},async ensureIcons(){const r=[...new Set(t.items.map(i=>i.icon).filter(Boolean))];if(r.length===0)return;const o=await import("@element-plus/icons-vue"),s={...d.iconMap};for(const i of r)o[i]&&(s[i]=e.markRaw(o[i]));d.iconMap=e.markRaw(s)}};return e.onMounted(()=>{m.ensureIcons()}),e.watch(()=>t.items,()=>{m.ensureIcons()}),(r,o)=>{const s=C.ElIcon,i=C.ElButton;return e.openBlock(),e.createElementBlock("div",Ge,[e.renderSlot(r.$slots,"toolbar-left",{currentRow:t.currentRow},void 0,!0),e.createElementVNode("div",He,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.items,(p,f)=>(e.openBlock(),e.createBlock(i,{key:f,type:m.getButtonType(p),disabled:m.isDisabled(p),onClick:u=>m.handleClick(p)},{default:e.withCtx(()=>[m.getIcon(p)?(e.openBlock(),e.createBlock(s,{key:0},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(m.getIcon(p))))]),_:2},1024)):e.createCommentVNode("",!0),m.getText(p)?(e.openBlock(),e.createElementBlock("span",Je,e.toDisplayString(m.getText(p)),1)):e.createCommentVNode("",!0)]),_:2},1032,["type","disabled","onClick"]))),128))]),e.renderSlot(r.$slots,"toolbar-extra",{currentRow:t.currentRow},void 0,!0)])}}}),[["__scopeId","data-v-8f722515"]]),Ze=k(e.defineComponent({__name:"UInputShow",props:{modelValue:{},multiline:{type:Boolean,default:!1},maxLines:{default:0}},setup(n){const a=n,t=e.computed(()=>a.modelValue===null||a.modelValue===void 0?"":String(a.modelValue)),l=e.computed(()=>a.multiline||t.value.includes(`
2
- `)),d=e.computed(()=>a.maxLines>0&&l.value?{display:"-webkit-box",WebkitLineClamp:a.maxLines,WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis"}:{});return(c,m)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["u-input-show",{"u-input-multiline":l.value}]),style:e.normalizeStyle(d.value)},e.toDisplayString(t.value),7))}}),[["__scopeId","data-v-c78b151e"]]),ve=k(e.defineComponent({__name:"UDictShow",props:{modelValue:{},dictType:{},defaultText:{default:""}},setup(n){const a=n,t=e.ref(""),l=e.ref(!1),d=async()=>{if(a.modelValue===null||a.modelValue===void 0||a.modelValue===""){t.value=a.defaultText;return}if(!a.dictType){t.value=String(a.modelValue);return}l.value=!0;try{const c=await te(a.dictType,a.modelValue,a.defaultText);t.value=c}catch(c){console.error("[UDictShow] 翻译失败:",c),t.value=String(a.modelValue)}finally{l.value=!1}};return e.watch(()=>a.modelValue,d,{immediate:!0}),e.watch(()=>a.dictType,()=>{a.dictType&&N(a.dictType).then(()=>d())}),e.onMounted(()=>{a.dictType?N(a.dictType).then(()=>d()):d()}),(c,m)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["u-dict-show",{"u-dict-loading":l.value}])},e.toDisplayString(t.value),3))}}),[["__scopeId","data-v-908045c4"]]),et=k(e.defineComponent({__name:"UToggleShow",props:{modelValue:{},trueText:{default:"开启"},falseText:{default:"关闭"},useYesNo:{type:Boolean,default:!1}},setup(n){const a=n,t=e.computed(()=>a.useYesNo?"是":a.trueText),l=e.computed(()=>a.useYesNo?"否":a.falseText),d=e.computed(()=>a.modelValue===!0||a.modelValue==="true"?t.value:a.modelValue===!1||a.modelValue==="false"?l.value:String(a.modelValue??"")),c=e.computed(()=>a.modelValue===!0||a.modelValue==="true"?"toggle-true":a.modelValue===!1||a.modelValue==="false"?"toggle-false":"toggle-default");return(m,r)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["u-toggle-show",c.value])},e.toDisplayString(d.value),3))}}),[["__scopeId","data-v-bac05efc"]]),tt=k(e.defineComponent({__name:"UCascaderShow",props:{modelValue:{},cascaderKey:{},separator:{default:" / "},showRawValue:{type:Boolean,default:!0}},setup(n){const a=n,t=e.ref(""),l=e.ref(!1),d=async()=>{if(!a.modelValue||!Array.isArray(a.modelValue)){t.value="";return}const c=a.modelValue;if(a.cascaderKey){l.value=!0;try{const m=await N(a.cascaderKey),o=c.map(s=>{const i=m.find(p=>p.value===s||String(p.value)===String(s));return i?i.label:a.showRawValue?String(s):""}).filter(s=>s!=="");t.value=o.join(a.separator)}catch(m){console.error("[UCascaderShow] 翻译失败:",m),t.value=a.showRawValue?c.join(a.separator):""}finally{l.value=!1}}else t.value=c.join(a.separator)};return e.watch(()=>a.modelValue,d,{immediate:!0}),e.onMounted(()=>{d()}),(c,m)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["u-cascader-show",{"u-cascader-loading":l.value}])},e.toDisplayString(t.value),3))}}),[["__scopeId","data-v-5d84df67"]]),at=k(e.defineComponent({__name:"UDateShow",props:{modelValue:{},mode:{default:"single"},locale:{default:"zh-CN"},format:{},separator:{default:", "},rangeSeparator:{default:" ~ "}},setup(n){const a=n,t=e.computed(()=>a.locale==="en-US"?a.mode==="range"?" - ":", ":a.mode==="range"?a.rangeSeparator:a.separator),l=e.computed(()=>{const m=a.modelValue;return a.mode==="single"?m?d(m,a.format):"":a.mode==="multiple"?m?Array.isArray(m)?m.map(r=>d(r,a.format)).join(t.value):String(m):"":a.mode==="range"?m?typeof m=="object"&&m.from&&m.to?`${d(m.from,a.format)}${t.value}${d(m.to,a.format)}`:Array.isArray(m)&&m.length>=2?`${d(m[0],a.format)}${t.value}${d(m[1],a.format)}`:String(m):"":String(m??"")});function d(m,r){return m||""}const c=e.computed(()=>!l.value);return(m,r)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["u-date-show",{"u-date-empty":c.value}])},e.toDisplayString(l.value||(n.locale==="en-US"?"Empty":"暂无")),3))}}),[["__scopeId","data-v-930657df"]]),j=k(e.defineComponent({__name:"UFieldView",props:{type:{default:"text"},modelValue:{},dictType:{},mode:{},locale:{default:"zh-CN"},format:{},text:{},trueText:{default:"开启"},falseText:{default:"关闭"},useYesNo:{type:Boolean,default:!1},cascaderKey:{},multiline:{type:Boolean},defaultText:{default:""}},setup(n){const a=n,t=e.computed(()=>{if(!a.text)return null;const m=a.text.split("/");return m.length>=2?{trueText:m[0].trim(),falseText:m[1].trim()}:null}),l=e.computed(()=>{var m;return a.trueText||((m=t.value)==null?void 0:m.trueText)||"开启"}),d=e.computed(()=>{var m;return a.falseText||((m=t.value)==null?void 0:m.falseText)||"关闭"}),c=e.computed(()=>{switch(a.type){case"dict":return"UDictShow";case"switch":return"UToggleShow";case"cascader":return"UCascaderShow";case"date":return"UDateShow";case"input":case"text":default:return"UInputShow"}});return(m,r)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(c.value==="UDictShow"?ve:c.value==="UToggleShow"?et:c.value==="UCascaderShow"?tt:c.value==="UDateShow"?at:Ze),{"model-value":n.modelValue,"dict-type":n.type==="dict"?n.dictType:void 0,"cascader-key":n.type==="cascader"?n.cascaderKey:void 0,mode:n.type==="date"?n.mode:void 0,locale:n.type==="date"?n.locale:void 0,format:n.type==="date"?n.format:void 0,"true-text":n.type==="switch"?l.value:void 0,"false-text":n.type==="switch"?d.value:void 0,"use-yes-no":n.type==="switch"?n.useYesNo:void 0,multiline:n.type==="input"||n.type==="text"?n.multiline:void 0,"default-text":n.type==="dict"?n.defaultText:void 0},null,8,["model-value","dict-type","cascader-key","mode","locale","format","true-text","false-text","use-yes-no","multiline","default-text"]))}}),[["__scopeId","data-v-fedb54d7"]]),ot={class:"table-grid"},nt=k(e.defineComponent({inheritAttrs:!1,__name:"TableGrid",props:{rows:{},columns:{},loading:{type:Boolean},actions:{},keyField:{},selection:{type:[String,Boolean]},dictData:{},activeKey:{}},emits:["rowAction","rowClick","selectionChange"],setup(n,{emit:a}){const t=n,l=e.useSlots(),d=a,c=e.computed(()=>({actionList:t.actions||[],actionColumnWidth:r.getActionColumnWidth(),hasUserEmpty:!!l.empty,forwardSlots:Object.keys(l).filter(o=>o!=="default")})),m=e.computed(()=>{const o=t.columns.map(s=>{const i={prop:s.field,label:s.label};return typeof s.width=="number"&&(i.width=s.width),i});return c.value.actionList.length>0&&o.push({prop:"actions",label:"操作",width:c.value.actionColumnWidth,fixed:"right"}),o}),r={actionText(o){return o.text?o.text:{add:"新增",edit:"编辑",delete:"删除",preview:"预览",back:"返回"}[o.action]||""},actionType(o){return o.style?o.style==="default"?"":o.style:{add:"primary",edit:"primary",delete:"danger",preview:"primary",back:"primary"}[o.action]||"primary"},getActionColumnWidth(){const s=(t.actions||[]).reduce((i,p)=>i+Math.max(52,r.actionText(p).length*16+12),0);return Math.max(80,Math.ceil(s)+16)},maskPhone(o){return!o||o.length<7?o:o.replace(/(\d{3})\d{4}(\d{4})/,"$1****$2")},maskIdCard(o){return!o||o.length<8?o:o.replace(/(\d{3})\d{11}(\d{4})/,"$1***********$2")},formatMoney(o){const s=Number(o);return isNaN(s)?String(o):s.toLocaleString("zh-CN",{minimumFractionDigits:2,maximumFractionDigits:2})},formatByType(o,s){if(!o)return"";switch(s){case"phone":return r.maskPhone(o);case"idcard":return r.maskIdCard(o);case"money":return r.formatMoney(o);case"percent":return String(o*100)+"%";default:return s&&s.includes("{}")?s.replace("{}",String(o)):String(o)}},getNestedValue(o,s){if(!s.includes("."))return o[s];const i=s.split(".");let p=o;for(const f of i)if(p&&typeof p=="object"&&f in p)p=p[f];else return;return p},useFieldView(o){return o.type?["dict","switch","cascader","date","input","text"].includes(o.type):!1},rowClassName({row:o}){if(!o||t.activeKey===void 0||t.activeKey===null)return"";const s=t.keyField||"id";return o[s]===t.activeKey?"table-grid-active-row":""},onSelectionChange(o){d("selectionChange",o)},onRowClick(o){d("rowClick",o)},onRowAction(o,s){d("rowAction",{action:o.action,item:o,row:s})}};return(o,s)=>{const i=C.ElTableColumn,p=C.ElButton,f=C.ElTable;return e.openBlock(),e.createElementBlock("div",ot,[e.createVNode(f,e.mergeProps({stripe:!0,border:!0,...o.$attrs},{data:t.rows.length?t.rows:[{}],loading:t.loading,"row-key":t.keyField||"id","row-class-name":r.rowClassName,onSelectionChange:r.onSelectionChange,onRowClick:s[0]||(s[0]=u=>r.onRowClick(u))}),e.createSlots({default:e.withCtx(()=>[t.selection?(e.openBlock(),e.createBlock(i,{key:0,type:"selection",width:"55"})):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.value,u=>(e.openBlock(),e.createBlock(i,{key:u.prop,prop:u.prop,label:u.label,width:u.width,fixed:u.fixed},{default:e.withCtx(({row:g})=>[u.prop==="actions"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[Object.keys(g).length>0?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(c.value.actionList,(h,b)=>(e.openBlock(),e.createBlock(p,{key:b,link:"",type:r.actionType(h),disabled:h.disabled===!0,size:"small",onClick:e.withModifiers(x=>r.onRowAction(h,g),["stop"])},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(r.actionText(h)),1)]),_:2},1032,["type","disabled","onClick"]))),128)):e.createCommentVNode("",!0)],64)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[Object.keys(g).length>0?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(t.columns,h=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:h.field},[h.field===u.prop&&r.useFieldView(h)?(e.openBlock(),e.createBlock(j,{key:0,type:h.type,"model-value":r.getNestedValue(g,h.field),"dict-type":h.dictType,mode:h.mode,locale:h.locale,format:h.format,text:h.text,"true-text":h.trueText,"false-text":h.falseText,"use-yes-no":h.useYesNo,"cascader-key":h.cascaderKey,multiline:h.multiline,"default-text":h.defaultText},null,8,["type","model-value","dict-type","mode","locale","format","text","true-text","false-text","use-yes-no","cascader-key","multiline","default-text"])):h.field===u.prop?(e.openBlock(),e.createElementBlock("span",{key:1,class:e.normalizeClass({"table-grid-format":h.format})},e.toDisplayString(r.formatByType(r.getNestedValue(g,h.field),h.format||"")),3)):e.createCommentVNode("",!0)],64))),128)):e.createCommentVNode("",!0)],64))]),_:2},1032,["prop","label","width","fixed"]))),128)),e.renderSlot(o.$slots,"default",{},void 0,!0)]),_:2},[e.renderList(c.value.forwardSlots,u=>({name:u,fn:e.withCtx(g=>[e.renderSlot(o.$slots,u,e.normalizeProps(e.guardReactiveProps(g||{})),void 0,!0)])})),c.value.hasUserEmpty?void 0:{name:"empty",fn:e.withCtx(()=>[s[1]||(s[1]=e.createElementVNode("div",{class:"no-data"},"暂无数据",-1))]),key:"0"}]),1040,["data","loading","row-key","row-class-name","onSelectionChange"])])}}}),[["__scopeId","data-v-ca606e7b"]]),lt={class:"table-pagination"},it={class:"page-size-select"},st={class:"total-text"},rt={key:1,class:"load-more"},ct={key:2,class:"total-text"},dt=k(e.defineComponent({__name:"TablePagination",props:{page:{},pageSize:{},total:{},type:{}},emits:["update:page","update:pageSize"],setup(n,{emit:a}){const t=n,l=a,d=e.computed(()=>({totalPages:Math.ceil(t.total/t.pageSize),showPagination:t.type==="page"&&t.total>0})),c={onPageChange:m=>{l("update:page",m)},onPageSizeChange:m=>{l("update:pageSize",m)}};return(m,r)=>{const o=C.ElPagination,s=C.ElOption,i=C.ElSelect,p=C.ElButton;return e.openBlock(),e.createElementBlock("div",lt,[d.value.showPagination?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createVNode(o,{"current-page":t.page,"page-count":d.value.totalPages,"page-sizes":[10,20,50,100],"page-size":t.pageSize,layout:"total, prev, pager, next, jumper",onCurrentChange:c.onPageChange,onSizeChange:c.onPageSizeChange},null,8,["current-page","page-count","page-size","onCurrentChange","onSizeChange"]),e.createElementVNode("div",it,[e.createVNode(i,{"model-value":t.pageSize,style:{width:"100px"},onChange:c.onPageSizeChange},{default:e.withCtx(()=>[e.createVNode(s,{value:10,label:"10条/页"}),e.createVNode(s,{value:20,label:"20条/页"}),e.createVNode(s,{value:50,label:"50条/页"}),e.createVNode(s,{value:100,label:"100条/页"})]),_:1},8,["model-value","onChange"]),e.createElementVNode("span",st,"共 "+e.toDisplayString(t.total)+" 条",1)])],64)):t.type==="auto"?(e.openBlock(),e.createElementBlock("div",rt,[e.createVNode(p,{disabled:t.page*t.pageSize>=t.total},{default:e.withCtx(()=>[...r[0]||(r[0]=[e.createTextVNode("加载更多",-1)])]),_:1},8,["disabled"])])):t.type==="all"?(e.openBlock(),e.createElementBlock("div",ct,"共 "+e.toDisplayString(t.total)+" 条",1)):e.createCommentVNode("",!0)])}}}),[["__scopeId","data-v-53e593aa"]]),mt={class:"table-detail"},ut={key:0,class:"detail-header"},pt={class:"detail-title"},ft={class:"detail-body"},ht={key:0,class:"detail-status"},gt={key:1,class:"detail-content"},yt={class:"detail-label"},bt={class:"detail-value"},wt={key:2,class:"detail-status"},X=k(e.defineComponent({__name:"TableDetail",props:{showHeader:{type:Boolean},title:{},loading:{type:Boolean},rowData:{},columns:{},emptyText:{},extraMode:{}},setup(n){const a=n,t=e.useSlots(),l=e.computed(()=>!!t["detail-extra"]),d=e.computed(()=>l.value),c=e.computed(()=>!l.value||a.extraMode==="append"),m=e.computed(()=>({showHeader:a.showHeader!==!1,title:a.title||"详情",emptyText:a.emptyText||"暂无数据",hasRow:!!a.rowData})),r={getNestedValue(o,s){if(!o||!s)return"";if(!s.includes("."))return o[s];const i=s.split(".");let p=o;for(const f of i)if(p&&typeof p=="object"&&f in p)p=p[f];else return"";return p}};return(o,s)=>(e.openBlock(),e.createElementBlock("div",mt,[m.value.showHeader?(e.openBlock(),e.createElementBlock("div",ut,[e.createElementVNode("div",pt,e.toDisplayString(m.value.title),1)])):e.createCommentVNode("",!0),e.createElementVNode("div",ft,[c.value?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[a.loading?(e.openBlock(),e.createElementBlock("div",ht,"加载中...")):m.value.hasRow?(e.openBlock(),e.createElementBlock("div",gt,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.columns,i=>(e.openBlock(),e.createElementBlock("div",{key:i.field,class:"detail-item"},[e.createElementVNode("div",yt,e.toDisplayString(i.label),1),e.createElementVNode("div",bt,[e.createVNode(j,{type:i.type,"model-value":r.getNestedValue(a.rowData,i.field),"dict-type":i.dictType,mode:i.mode,locale:i.locale,format:i.format,text:i.text,"true-text":i.trueText,"false-text":i.falseText,"use-yes-no":i.useYesNo,"cascader-key":i.cascaderKey,multiline:i.multiline,"default-text":i.defaultText},null,8,["type","model-value","dict-type","mode","locale","format","text","true-text","false-text","use-yes-no","cascader-key","multiline","default-text"])])]))),128))])):(e.openBlock(),e.createElementBlock("div",wt,e.toDisplayString(m.value.emptyText),1))],64)):e.createCommentVNode("",!0),d.value?e.renderSlot(o.$slots,"detail-extra",{rowData:a.rowData,columns:a.columns},void 0,!0,1):e.createCommentVNode("",!0)])]))}}),[["__scopeId","data-v-3314a22f"]]),Ct={class:"table-body"},kt={class:"table-container"},oe=k(e.defineComponent({inheritAttrs:!1,__name:"TableRender",props:{formId:{},detailExtraMode:{}},emits:["back","toolbar-action","row-action"],setup(n,{expose:a,emit:t}){const l=["search-extra","search-actions","toolbar-left","toolbar-extra","detail-extra"],d=n,c=e.useAttrs(),m=e.useSlots(),r=t,o=new je,s=e.ref(null),i=e.reactive({searchParams:{},loaded:!1,dictData:{}});e.onMounted(async()=>{d.formId&&await f.loadConfig(d.formId)});const p=e.computed(()=>({tableConfig:o.data.tableConfig,rows:o.data.rows,total:o.data.total,loading:o.data.loading,pagination:o.data.pagination,searchFields:o.getSearchFields(),hasSearch:o.hasSearch(),columns:o.getColumns(),toolbar:o.getToolbar(),hasToolbar:o.hasToolbar(),actions:o.getActions(),currentRow:o.data.currentRow,currentKey:o.getCurrentKey(),showDetail:o.hasDetail(),detailMode:o.getDetailMode(),detailSide:o.getDetailPosition()==="left"?"left":"right",detailWidth:o.getDetailWidth(),detailDirection:o.getDetailDirection(),detailVisible:o.data.detailVisible,detailData:o.data.detailData,detailLoading:o.data.detailLoading,previewMounted:o.data.previewMounted,previewVisible:o.data.previewVisible,previewRow:o.data.previewRow,dictData:i.dictData})),f={getTableAttrs(){const{class:u,style:g,...h}=c;return h},getTableSlots(){const u={};for(const g of Object.keys(m))l.includes(g)||(u[g]=!0);return u},getDetailSlots(){return m["detail-extra"]?["detail-extra"]:[]},getDetailExtraMode(){return d.detailExtraMode==="append"?"append":"replace"},async loadConfig(u){try{await o.loadConfig(u)}catch(g){_((g==null?void 0:g.message)||"获取表格配置失败");return}i.searchParams={...o.data.searchParams},i.loaded=!0,await f.loadDictData(),await f.handleLoadData()},async handleLoadData(){try{await o.loadData()}catch(u){_((u==null?void 0:u.message)||"加载数据失败")}},async loadDictData(){const u=o.getColumns(),g=new Set;for(const h of u)h.type==="dict"&&h.dictType&&g.add(h.dictType);for(const h of g)try{const b=await S.get(D.dictApi(h));b.status===200&&(i.dictData[h]=W(b.data))}catch(b){console.error(`[TableRender] 加载字典 ${h} 失败:`,b)}},async handleSearch(){o.data.searchParams={...i.searchParams};try{await o.search()}catch(u){_((u==null?void 0:u.message)||"查询失败")}},async handleReset(){i.searchParams={};try{await o.reset()}catch(u){_((u==null?void 0:u.message)||"重置失败")}},updateSearchParam(u,g){i.searchParams[u]=g},async handlePageChange(u){try{await o.changePage(u)}catch(g){_((g==null?void 0:g.message)||"加载数据失败")}},async handlePageSizeChange(u){try{await o.changePageSize(u)}catch(g){_((g==null?void 0:g.message)||"加载数据失败")}},handleRowClick(u){o.setCurrentRow(u)},handleDetailClose(){o.closeDetail()},handleDetailClosed(){o.resetDetail()},handlePreviewClose(){o.closePreview()},handlePreviewClosed(){o.resetPreview()},handlePreview(u){if(!u){E.warning("请先点击表格中的一行数据");return}o.openPreview(u)},handleToolbarAction(u){r("toolbar-action",u),f.dispatchAction(u)},handleRowAction(u){r("row-action",u),f.dispatchAction(u)},async dispatchAction(u){switch(u.action){case"add":await f.handleAdd(u.item);break;case"edit":await f.handleEdit(u.row,u.item);break;case"delete":await f.handleDelete(u.row,u.item);break;case"preview":f.handlePreview(u.row);break;case"back":r("back",u);break;case"export":await f.handleExport();break;default:await f.handleCustomAction(u)}},async handleAdd(u){const g=u?o.getButtonFormId(u):o.getFormId();if(!g){E.warning("未配置表单,无法新增");return}if(!s.value)return;await s.value.showForm(g)!=null&&await f.handleLoadData()},async handleEdit(u,g){if(!u){E.warning("请先点击表格中的一行数据");return}const h=g?o.getButtonFormId(g):o.getFormId();if(!h){E.warning("未配置表单,无法编辑");return}if(!s.value)return;const b=o.getKeyField();await s.value.showForm(h,`${b}=${u[b]}`)!=null&&await f.handleLoadData()},async handleDelete(u,g){if(!u){E.warning("请先点击表格中的一行数据");return}try{await V.ElMessageBox.confirm((g==null?void 0:g.confirm)||"确定要删除这条数据吗?","确认删除",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"})}catch{return}try{await o.deleteRow(u),E.success("删除成功")}catch(h){_((h==null?void 0:h.message)||"删除失败")}},async handleExport(){try{await o.exportData(),E.success("导出成功")}catch(u){_((u==null?void 0:u.message)||"导出失败")}},async handleCustomAction(u){const{item:g,row:h}=u;if(!(g!=null&&g.url)){E.warning(`未识别的按钮动作:${u.action}`);return}try{await V.ElMessageBox.confirm(g.confirm||"确定执行该操作吗?","确认",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"})}catch{return}try{const b=await S.post(g.url,h||{});if(b.status!==200)throw new Error(b.message||"操作失败");E.success(b.message||"操作成功"),await f.handleLoadData()}catch(b){_((b==null?void 0:b.message)||"操作失败")}}};return a({loadConfig:f.loadConfig}),(u,g)=>{var b,x,A,le,ie,se;const h=C.ElDrawer;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["table-render",u.$attrs.class]),style:e.normalizeStyle(u.$attrs.style)},[p.value.hasSearch?(e.openBlock(),e.createBlock(Ke,{key:0,fields:p.value.searchFields,modelValue:i.searchParams,"onUpdate:modelValue":g[0]||(g[0]=B=>i.searchParams=B),onSearch:f.handleSearch,onReset:f.handleReset},{"search-extra":e.withCtx(B=>[e.renderSlot(u.$slots,"search-extra",e.normalizeProps(e.guardReactiveProps(B||{})),void 0,!0)]),"search-actions":e.withCtx(B=>[e.renderSlot(u.$slots,"search-actions",e.normalizeProps(e.guardReactiveProps(B||{})),void 0,!0)]),_:3},8,["fields","modelValue","onSearch","onReset"])):e.createCommentVNode("",!0),e.createElementVNode("div",Ct,[e.createElementVNode("div",kt,[e.createVNode(nt,e.mergeProps(f.getTableAttrs(),{rows:p.value.rows,columns:p.value.columns,loading:p.value.loading,actions:p.value.actions,"key-field":(b=p.value.tableConfig)==null?void 0:b.key,"dict-data":p.value.dictData,"active-key":p.value.currentKey,onRowAction:f.handleRowAction,onRowClick:f.handleRowClick}),e.createSlots({_:2},[e.renderList(f.getTableSlots(),(B,P)=>({name:P,fn:e.withCtx(Pt=>[e.renderSlot(u.$slots,P,e.normalizeProps(e.guardReactiveProps(Pt||{})),void 0,!0)])}))]),1040,["rows","columns","loading","actions","key-field","dict-data","active-key","onRowAction","onRowClick"]),e.createVNode(dt,{class:"table-pagination",page:p.value.pagination.page,"page-size":p.value.pagination.pageSize,total:p.value.total,type:(x=p.value.tableConfig)==null?void 0:x.pagination,"onUpdate:page":f.handlePageChange,"onUpdate:pageSize":f.handlePageSizeChange},null,8,["page","page-size","total","type","onUpdate:page","onUpdate:pageSize"])]),p.value.showDetail&&p.value.detailMode==="inline"?(e.openBlock(),e.createBlock(X,{key:0,class:e.normalizeClass(["table-detail-inline",`table-detail-inline-${p.value.detailSide}`]),style:e.normalizeStyle({width:p.value.detailWidth}),title:(le=(A=p.value.tableConfig)==null?void 0:A.meta)==null?void 0:le.title,loading:p.value.detailLoading,"row-data":p.value.detailData,columns:p.value.columns,"empty-text":p.value.detailSide==="left"?"请点击右侧表格行查看详情":"请点击左侧表格行查看详情","extra-mode":f.getDetailExtraMode()},e.createSlots({_:2},[e.renderList(f.getDetailSlots(),B=>({name:B,fn:e.withCtx(P=>[e.renderSlot(u.$slots,B,e.normalizeProps(e.guardReactiveProps(P||{})),void 0,!0)])}))]),1032,["class","style","title","loading","row-data","columns","empty-text","extra-mode"])):e.createCommentVNode("",!0)]),p.value.showDetail&&p.value.detailMode==="drawer"?(e.openBlock(),e.createBlock(h,{key:1,"model-value":p.value.detailVisible,direction:p.value.detailDirection,size:p.value.detailWidth,title:((se=(ie=p.value.tableConfig)==null?void 0:ie.meta)==null?void 0:se.title)||"详情",onClose:f.handleDetailClose,onClosed:f.handleDetailClosed},{default:e.withCtx(()=>[e.createVNode(X,{"show-header":!1,loading:p.value.detailLoading,"row-data":p.value.detailData,columns:p.value.columns,"extra-mode":f.getDetailExtraMode()},e.createSlots({_:2},[e.renderList(f.getDetailSlots(),B=>({name:B,fn:e.withCtx(P=>[e.renderSlot(u.$slots,B,e.normalizeProps(e.guardReactiveProps(P||{})),void 0,!0)])}))]),1032,["loading","row-data","columns","extra-mode"])]),_:3},8,["model-value","direction","size","title","onClose","onClosed"])):e.createCommentVNode("",!0),p.value.previewMounted?(e.openBlock(),e.createBlock(h,{key:2,"model-value":p.value.previewVisible,direction:p.value.detailDirection,size:p.value.detailWidth,title:"详情",onClose:f.handlePreviewClose,onClosed:f.handlePreviewClosed},{default:e.withCtx(()=>[e.createVNode(X,{"show-header":!1,"row-data":p.value.previewRow,columns:p.value.columns,"extra-mode":f.getDetailExtraMode()},e.createSlots({_:2},[e.renderList(f.getDetailSlots(),B=>({name:B,fn:e.withCtx(P=>[e.renderSlot(u.$slots,B,e.normalizeProps(e.guardReactiveProps(P||{})),void 0,!0)])}))]),1032,["row-data","columns","extra-mode"])]),_:3},8,["model-value","direction","size","onClose","onClosed"])):e.createCommentVNode("",!0),p.value.hasToolbar?(e.openBlock(),e.createBlock(Xe,{key:3,class:"table-toolbar-bottom",items:p.value.toolbar,"current-row":p.value.currentRow,onAction:f.handleToolbarAction},{"toolbar-left":e.withCtx(B=>[e.renderSlot(u.$slots,"toolbar-left",e.normalizeProps(e.guardReactiveProps(B||{})),void 0,!0)]),"toolbar-extra":e.withCtx(B=>[e.renderSlot(u.$slots,"toolbar-extra",e.normalizeProps(e.guardReactiveProps(B||{})),void 0,!0)]),_:3},8,["items","current-row","onAction"])):e.createCommentVNode("",!0),e.createVNode(J,{ref_key:"formRef",ref:s},null,512)],6)}}}),[["__scopeId","data-v-00444d8c"]]);function ne(){var n,a;try{if(typeof document<"u"&&document.baseURI){const t=new URL(document.baseURI).origin;if(t&&t!=="null")return t}}catch{}try{const t=(a=(n=window==null?void 0:window.$wujie)==null?void 0:n.location)==null?void 0:a.origin;if(typeof t=="string"&&t)return t}catch{}return typeof window<"u"?window.location.origin:""}class xt{constructor(a){w(this,"axiosInstance");w(this,"baseUrl","");this.axiosInstance=v.create({timeout:1e4,baseURL:""}),this.axiosInstance.defaults.headers["Content-Type"]="application/json;charset=utf-8",this.axiosInstance.interceptors.request.use(t=>(t.headers.token=localStorage.getItem("token"),a.baseUrl?t.baseURL=a.baseUrl:(this.baseUrl||(this.baseUrl=ne()),t.baseURL=this.baseUrl),t),t=>Promise.reject(t)),this.axiosInstance.interceptors.response.use(t=>t.config.responseType==="blob"?t:t.data,t=>Promise.reject(t))}Post(a,t){return this.axiosInstance.post(a,t)}Get(a,t){return this.axiosInstance.get(a,{params:t})}Delete(a,t){return this.axiosInstance.delete(a,{params:t})}Put(a,t){return this.axiosInstance.put(a,t)}Download(a,t){return this.axiosInstance.get(a,{params:t,responseType:"blob"})}}class Bt{constructor(){w(this,"emitter");this.emitter=re()}On(a,t){this.emitter.on(a,t)}Emit(a,t){this.emitter.emit(a,t)}Off(a,t){this.emitter.off(a,t)}}class Vt{constructor(a,t){w(this,"mqttClient",null);w(this,"eventBus");this.eventBus=a,this.connect(t).then()}async connect(a){const t={username:a.userName,password:a.password,clientId:`${a.module}_${this.randomStr(10)}`,clean:!0,keepalive:50,connectTimeout:5e3,reconnectPeriod:5e3};let l=a.mqttUrl||"ws://127.0.0.1:5002/ws";if(console.log("connect to mqtt..."),this.mqttClient=ce.connect(l,t),!this.mqttClient){console.log("connect mqtt failed");return}this.mqttClient.on("connect",()=>{console.log("=====> mqtt connect success!"),this.mqttClient.subscribe(Z,{qos:0},d=>{console.log(d?`mqtt subscribe [${Z}] failed`:`mqtt subscribe [${Z}] success`)})}),this.mqttClient.on("message",(d,c)=>{const m=c.toString();if(!m){console.error("Received empty message",d);return}let r=null;try{r=JSON.parse(m)}catch(o){console.error("Failed to parse message JSON",d,m,o);return}if(!r||r.Content===void 0||r.Content===null||!r.PType){console.log("parse notice failed!",m);return}r.PType==St&&this.eventBus.Emit(r.Route,r.Content)}),this.mqttClient.on(O.OffLine,()=>{console.log("mqtt offline...")}),this.mqttClient.on(O.Reconnect,()=>{console.log("mqtt reconnecting...")}),this.mqttClient.on(O.Close,()=>{console.log("mqtt close")}),this.mqttClient.on(O.Error,d=>{console.log("mqtt error")})}randomStr(a){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let l="";for(let d=0;d<a;d++)l+=t.charAt(Math.floor(Math.random()*t.length));return l}}const Z="Notice",St="NOTICE",O={OffLine:"offline",Close:"close",Reconnect:"reconnect",Error:"error"};let Y;const _t=n=>{if(!n)throw new Error("QfOptions is undefined");if(!Y&&n&&(Y=new Et(n)),!Y)throw new Error("Qf not initialized, please call GetQf(options) first");return Y};class Et{constructor(a){w(this,"EventBus");w(this,"WebApi");w(this,"Mqtt");w(this,"options");this.initQf(a)}initQf(a){if(!a)throw new Error(`StartQf failed! options is ${a}`);this.options=a,console.log("StartQf(), qfOptions=",a),this.EventBus=new Bt,this.WebApi=new xt(a),this.options.useMqtt&&(this.Mqtt=new Vt(this.EventBus,a))}On(a,t){this.EventBus.On(a,t)}Emit(a,t){this.EventBus.Emit(a,t)}Off(a,t){this.EventBus.Off(a,t)}Post(a,t){return this.WebApi.Post(a,t)}Get(a,t){return this.WebApi.Get(a,t)}Delete(a,t){return this.WebApi.Delete(a,t)}Put(a,t){return this.WebApi.Put(a,t)}Download(a,t){return this.WebApi.Download(a,t)}RegNotice(a,t){this.EventBus.On(a,t)}}const Dt={UInput:$,UInputNumber:Q,UDict:R,UToggle:G,UCascader:H,UDate:z,UMenu:ae,FormRender:J,TableRender:oe,UFieldView:j},Tt={install(n){n.use(V);for(const[a,t]of Object.entries(Dt))n.component(a,t)}};y.FormRender=J,y.GetQf=_t,y.TableRender=oe,y.UCascader=H,y.UDate=z,y.UDict=R,y.UFieldView=j,y.UInput=$,y.UInputNumber=Q,y.UMenu=ae,y.UToggle=G,y.apis=D,y.clearDictCache=he,y.default=Tt,y.flattenDictTree=ue,y.getDict=N,y.mapDictTree=q,y.normalizeDictNode=L,y.notify=E,y.notifyUtil=I,y.preloadDicts=fe,y.resolveBaseUrl=ne,y.setDictCache=ge,y.toDictOptions=W,y.translateDict=te,y.translateDictSync=pe,Object.defineProperties(y,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(b,V){typeof exports=="object"&&typeof module<"u"?V(exports,require("element-plus"),require("element-plus/dist/index.css"),require("element-plus/es"),require("element-plus/es/components/base/style/css"),require("element-plus/es/components/input/style/css"),require("vue"),require("element-plus/es/components/input-number/style/css"),require("element-plus/es/components/select/style/css"),require("element-plus/es/components/option/style/css"),require("axios"),require("mitt"),require("mqtt"),require("element-plus/es/components/switch/style/css"),require("element-plus/es/components/date-picker/style/css"),require("element-plus/es/components/button/style/css"),require("element-plus/es/components/menu/style/css"),require("element-plus/es/components/sub-menu/style/css"),require("element-plus/es/components/menu-item/style/css"),require("element-plus/es/components/icon/style/css"),require("@element-plus/icons-vue"),require("element-plus/es/components/form/style/css"),require("element-plus/es/components/dialog/style/css"),require("element-plus/es/components/drawer/style/css"),require("element-plus/es/components/table/style/css"),require("element-plus/es/components/table-column/style/css"),require("element-plus/es/components/pagination/style/css")):typeof define=="function"&&define.amd?define(["exports","element-plus","element-plus/dist/index.css","element-plus/es","element-plus/es/components/base/style/css","element-plus/es/components/input/style/css","vue","element-plus/es/components/input-number/style/css","element-plus/es/components/select/style/css","element-plus/es/components/option/style/css","axios","mitt","mqtt","element-plus/es/components/switch/style/css","element-plus/es/components/date-picker/style/css","element-plus/es/components/button/style/css","element-plus/es/components/menu/style/css","element-plus/es/components/sub-menu/style/css","element-plus/es/components/menu-item/style/css","element-plus/es/components/icon/style/css","@element-plus/icons-vue","element-plus/es/components/form/style/css","element-plus/es/components/dialog/style/css","element-plus/es/components/drawer/style/css","element-plus/es/components/table/style/css","element-plus/es/components/table-column/style/css","element-plus/es/components/pagination/style/css"],V):(b=typeof globalThis<"u"?globalThis:b||self,V(b.UritQfUI={},b.ElementPlus,b.ElementPlus,b.ElementPlus,b.ElementPlus,b.ElementPlus,b.Vue,b.ElementPlus,b.ElementPlus,b.ElementPlus,b.axios,b.mitt,b.mqtt,b.ElementPlus,b.ElementPlus,b.ElementPlus,b.ElementPlus,b.ElementPlus,b.ElementPlus,b.ElementPlus,b.ElementPlusIconsVue))})(this,function(b,V,U,C,Ft,Lt,e,qt,Wt,Ot,me,ue,pe,jt,Yt,Qt,Gt,Kt,Ht,Jt,Y){"use strict";var Ut=Object.defineProperty;var zt=(b,V,U)=>V in b?Ut(b,V,{enumerable:!0,configurable:!0,writable:!0,value:U}):b[V]=U;var w=(b,V,U)=>zt(b,typeof V!="symbol"?V+"":V,U);function fe(l){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const t in l)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(l,t);Object.defineProperty(a,t,s.get?s:{enumerable:!0,get:()=>l[t]})}}return a.default=l,Object.freeze(a)}const te=fe(Y),he=e.defineComponent({__name:"UInput",props:{fieldLabel:{},labelPosition:{default:"top"},labelWidth:{},labelAlign:{},required:{type:Boolean},modelValue:{},outlined:{type:Boolean},dense:{type:Boolean},filled:{type:Boolean},borderless:{type:Boolean},label:{},hint:{},error:{type:Boolean},errorMessage:{},type:{},placeholder:{},disable:{type:Boolean},readonly:{type:Boolean},prefix:{},suffix:{},mask:{},maxlength:{}},emits:["update:modelValue"],setup(l,{emit:a}){const t=l,s=a,r=e.computed(()=>{const m={};return t.labelPosition==="left"&&t.labelWidth&&(m.width=typeof t.labelWidth=="number"?`${t.labelWidth}px`:t.labelWidth),t.labelAlign&&(m.textAlign=t.labelAlign),m}),c=e.computed(()=>({"u-input-label-left":t.labelPosition==="left","u-input-label-top":t.labelPosition==="top"})),d={onInput(m){s("update:modelValue",m)}};return(m,o)=>{const n=C.ElInput;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["u-input",c.value])},[l.fieldLabel?(e.openBlock(),e.createElementBlock("div",{key:0,class:"u-input-label",style:e.normalizeStyle(r.value)},[e.createTextVNode(e.toDisplayString(l.fieldLabel)+" ",1),e.createElementVNode("span",{class:e.normalizeClass(["required-star",{"required-star--visible":l.required}])},"*",2)],4)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["u-input-field",{"u-input-field--top":l.labelPosition==="top"}])},[e.createVNode(n,{"model-value":l.modelValue,placeholder:l.placeholder,type:l.type,disabled:l.disable,readonly:l.readonly,maxlength:l.maxlength,"onUpdate:modelValue":d.onInput},null,8,["model-value","placeholder","type","disabled","readonly","maxlength","onUpdate:modelValue"])],2)],2)}}}),k=(l,a)=>{const t=l.__vccOpts||l;for(const[s,r]of a)t[s]=r;return t},R=k(he,[["__scopeId","data-v-ecf5177c"]]),ge={class:"u-input-number-field"},Q=k(e.defineComponent({__name:"UInputNumber",props:{fieldLabel:{},labelPosition:{default:"top"},labelWidth:{},labelAlign:{},required:{type:Boolean},modelValue:{},outlined:{type:Boolean},dense:{type:Boolean},filled:{type:Boolean},borderless:{type:Boolean},label:{},hint:{},error:{type:Boolean},errorMessage:{},type:{},placeholder:{},disable:{type:Boolean},readonly:{type:Boolean},min:{},max:{},step:{},precision:{}},emits:["update:modelValue"],setup(l,{emit:a}){const t=l,s=a,r=e.computed(()=>{const m={};return t.labelPosition==="left"&&t.labelWidth&&(m.width=typeof t.labelWidth=="number"?`${t.labelWidth}px`:t.labelWidth),t.labelAlign&&(m.textAlign=t.labelAlign),m}),c=e.computed(()=>({"u-input-number-label-left":t.labelPosition==="left","u-input-number-label-top":t.labelPosition==="top"})),d={onUpdate(m){s("update:modelValue",m===void 0?0:m)}};return(m,o)=>{const n=C.ElInputNumber;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["u-input-number",c.value])},[l.fieldLabel?(e.openBlock(),e.createElementBlock("div",{key:0,class:"u-input-number-label",style:e.normalizeStyle(r.value)},[e.createTextVNode(e.toDisplayString(l.fieldLabel)+" ",1),e.createElementVNode("span",{class:e.normalizeClass(["required-star",{"required-star--visible":l.required}])},"*",2)],4)):e.createCommentVNode("",!0),e.createElementVNode("div",ge,[e.createVNode(n,{"model-value":l.modelValue,placeholder:l.placeholder||"请输入数值",disabled:l.disable,min:l.min,max:l.max,step:l.step,precision:l.precision,controls:!0,"controls-position":"right",style:{width:"100%"},onChange:d.onUpdate},null,8,["model-value","placeholder","disabled","min","max","step","precision","onChange"])])],2)}}}),[["__scopeId","data-v-cb70bd5b"]]);function ae(){var l,a;try{if(typeof document<"u"&&document.baseURI){const t=new URL(document.baseURI);if(t.origin&&t.origin!=="null"){let s=t.pathname;return s.slice(s.lastIndexOf("/")+1).includes(".")&&(s=s.slice(0,s.lastIndexOf("/")+1)),s=s.replace(/\/+$/,""),t.origin+s}}}catch{}try{const t=(a=(l=window==null?void 0:window.$wujie)==null?void 0:l.location)==null?void 0:a.origin;if(typeof t=="string"&&t)return t}catch{}return typeof window<"u"?window.location.origin:""}function ye(l,a){const t=(l??"").trim();return t!==""&&t!=="."&&t!=="./"?t:(a.value===void 0&&(a.value=ae()),a.value)}class be{constructor(a){w(this,"axiosInstance");w(this,"baseCache",{});this.axiosInstance=me.create({timeout:1e4,baseURL:""}),this.axiosInstance.defaults.headers["Content-Type"]="application/json;charset=utf-8",this.axiosInstance.interceptors.request.use(t=>(t.headers.token=localStorage.getItem("token"),t.baseURL=ye(a.baseUrl,this.baseCache),t),t=>Promise.reject(t)),this.axiosInstance.interceptors.response.use(t=>{if(t.config.responseType==="blob")return t;const s=t.data;if(s&&typeof s=="object"&&!Array.isArray(s)&&s.status===void 0&&s.code!==void 0){const r=s.code,c=r===0||r===200||Number(r)===0||Number(r)===200;s.status=c?200:Number(r)}return s},t=>Promise.reject(t))}Get(a,t){return this.axiosInstance.get(a,{params:t})}Post(a,t){return this.axiosInstance.post(a,t)}Delete(a,t){return this.axiosInstance.delete(a,{params:t})}Put(a,t){return this.axiosInstance.put(a,t)}Download(a,t){return this.axiosInstance.get(a,{params:t,responseType:"blob"})}PostDownload(a,t){return this.axiosInstance.post(a,t,{responseType:"blob"})}}class we{constructor(){w(this,"emitter");this.emitter=ue()}On(a,t){this.emitter.on(a,t)}Emit(a,t){this.emitter.emit(a,t)}Off(a,t){this.emitter.off(a,t)}}class Ce{constructor(a,t){w(this,"mqttClient",null);w(this,"eventBus");this.eventBus=a,this.connect(t).then()}async connect(a){const t={username:a.userName,password:a.password,clientId:`${a.module}_${this.randomStr(10)}`,clean:!0,keepalive:50,connectTimeout:5e3,reconnectPeriod:5e3};let s=a.mqttUrl||"ws://127.0.0.1:5002/ws";if(console.log(`connect to mqtt... url=${s}`),this.mqttClient=pe.connect(s,t),!this.mqttClient){console.log("connect mqtt failed");return}this.mqttClient.on("connect",()=>{console.log("=====> mqtt connect success!"),this.mqttClient.subscribe(G,{qos:0},r=>{console.log(r?`mqtt subscribe [${G}] failed`:`mqtt subscribe [${G}] success`)})}),this.mqttClient.on("message",(r,c)=>{const d=c.toString();if(!d){console.error("Received empty message",r);return}let m=null;try{m=JSON.parse(d)}catch(o){console.error("Failed to parse message JSON",r,d,o);return}if(!m||m.Content===void 0||m.Content===null||!m.PType){console.log("parse notice failed!",d);return}m.PType==ke&&this.eventBus.Emit(m.Route,m.Content)}),this.mqttClient.on(F.OffLine,()=>{console.log("mqtt offline...")}),this.mqttClient.on(F.Reconnect,()=>{console.log("mqtt reconnecting...")}),this.mqttClient.on(F.Close,()=>{console.log("mqtt close")}),this.mqttClient.on(F.Error,r=>{console.log("mqtt error")})}randomStr(a){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let s="";for(let r=0;r<a;r++)s+=t.charAt(Math.floor(Math.random()*t.length));return s}}const G="Notice",ke="NOTICE",F={OffLine:"offline",Close:"close",Reconnect:"reconnect",Error:"error"};let $,K=!1;const xe=l=>{if(!l)throw new Error("QfOptions is undefined");if((!$||K)&&($=new oe(l),K=!1),!$)throw new Error("Qf not initialized, please call GetQf(options) first");return $},B=()=>($||($=new oe({module:"",useMqtt:!1,baseUrl:"",mqttUrl:"",userName:"",password:""}),K=!0),$);class oe{constructor(a){w(this,"EventBus");w(this,"WebApi");w(this,"Mqtt");w(this,"options");this.initQf(a)}initQf(a){if(!a)throw new Error(`StartQf failed! options is ${a}`);this.options=a,console.log("StartQf(), qfOptions=",a),this.EventBus=new we,this.WebApi=new be(a),this.options.useMqtt&&(this.Mqtt=new Ce(this.EventBus,a))}On(a,t){this.EventBus.On(a,t)}Emit(a,t){this.EventBus.Emit(a,t)}Off(a,t){this.EventBus.Off(a,t)}Post(a,t){return this.WebApi.Post(a,t)}Get(a,t){return this.WebApi.Get(a,t)}Delete(a,t){return this.WebApi.Delete(a,t)}Put(a,t){return this.WebApi.Put(a,t)}Download(a,t){return this.WebApi.Download(a,t)}PostDownload(a,t){return this.WebApi.PostDownload(a,t)}RegNotice(a,t){this.EventBus.On(a,t)}}const E={formCfgApi(l,a="forms"){return`/api/form?type=${a}&id=${l}`},dictApi(l){return`/api/dict/full-list?dict_type=${l}`},cascaderApi(l,a=!0){return`/api/dict/tree-list?dict_type=${l}&children=${a}`}},T={},L={};function q(l){const{children:a,...t}=l;return{label:l.label??l.dict_value??String(l.value??""),value:l.value??l.dict_code,...t}}function W(l){return Array.isArray(l)?l.map(a=>{if(!a||typeof a!="object")return a;const t=q(a),s=a.children;return Array.isArray(s)&&s.length>0&&(t.children=W(s)),t}):[]}function O(l){return Array.isArray(l)?l.filter(a=>a&&typeof a=="object").map(a=>q(a)):[]}function Se(l){if(!Array.isArray(l))return[];const a=[],t=s=>{for(const r of s){if(!r||typeof r!="object")continue;const c=r.children;a.push(q(r)),Array.isArray(c)&&c.length>0&&t(c)}};return t(l),a}async function A(l){if(!l)return[];if(T[l])return T[l];if(l in L)return await L[l];const a=(async()=>{try{const t=await B().Get(E.dictApi(l));if(t.status===200){const s=O(t.data);return T[l]=s,s}return[]}catch(t){return console.error(`[dict] 加载字典 ${l} 失败:`,t),[]}finally{delete L[l]}})();return L[l]=a,a}async function le(l,a,t=""){if(a==null||a==="")return t;const s=T[l];if(s&&s.length>0)return H(s,a);const r=await A(l);return r&&r.length>0?H(r,a):t||String(a)}function H(l,a){const t=l.find(s=>s.value===a||String(s.value)===String(a));return t?t.label:String(a)}function Be(l,a,t=""){if(a==null||a==="")return t;const s=T[l];return s&&s.length>0?H(s,a):t||String(a)}async function Ve(l){await Promise.all(l.map(a=>A(a)))}function _e(l){l?delete T[l]:Object.keys(T).forEach(a=>{delete T[a]})}function De(l,a){T[l]=a}const Ee={class:"u-dict-field"},I=k(e.defineComponent({__name:"UDict",props:{fieldLabel:{},labelPosition:{default:"top"},labelWidth:{},labelAlign:{},required:{type:Boolean},modelValue:{},outlined:{type:Boolean},dense:{type:Boolean},filled:{type:Boolean},borderless:{type:Boolean},label:{},hint:{},error:{type:Boolean},errorMessage:{},type:{},placeholder:{},disable:{type:Boolean},readonly:{type:Boolean},dictType:{}},emits:["update:modelValue"],setup(l,{emit:a}){const t=l,s=a,r=e.reactive({excluded:["fieldLabel","labelPosition","labelWidth","labelAlign","required","modelValue","dictType"],options:[],loading:!1}),c=async()=>{if(t.dictType){r.loading=!0;try{const n=await B().Get(E.dictApi(t.dictType));n.status===200?r.options=O(n.data):(console.error("[UDict] 请求失败:",n.message),r.options=[])}catch(n){console.error("[UDict] 加载字典失败:",n),r.options=[]}finally{r.loading=!1}}};e.watch(()=>t.dictType,()=>{c()},{immediate:!0});const d=e.computed(()=>{const n={};return t.labelPosition==="left"&&t.labelWidth&&(n.width=typeof t.labelWidth=="number"?`${t.labelWidth}px`:t.labelWidth),t.labelAlign&&(n.textAlign=t.labelAlign),n}),m=e.computed(()=>({"u-dict-label-left":t.labelPosition==="left","u-dict-label-top":t.labelPosition==="top"})),o={onUpdate(n){s("update:modelValue",n)}};return(n,i)=>{const u=C.ElOption,f=C.ElSelect;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["u-dict",m.value])},[l.fieldLabel?(e.openBlock(),e.createElementBlock("div",{key:0,class:"u-dict-label",style:e.normalizeStyle(d.value)},[e.createTextVNode(e.toDisplayString(l.fieldLabel)+" ",1),e.createElementVNode("span",{class:e.normalizeClass(["required-star",{"required-star--visible":l.required}])},"*",2)],4)):e.createCommentVNode("",!0),e.createElementVNode("div",Ee,[e.createVNode(f,{"model-value":l.modelValue,placeholder:l.placeholder||"请选择",loading:r.loading,disabled:l.disable,style:{width:"100%"},onChange:o.onUpdate},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.options,p=>(e.openBlock(),e.createBlock(u,{key:p.value,label:p.label,value:p.value},null,8,["label","value"]))),128))]),_:1},8,["model-value","placeholder","loading","disabled","onChange"])])],2)}}}),[["__scopeId","data-v-d0ae00fe"]]),Te={class:"u-toggle-field"},J=k(e.defineComponent({__name:"UToggle",props:{fieldLabel:{},labelPosition:{default:"left"},labelWidth:{},labelAlign:{},required:{type:Boolean},modelValue:{},dense:{type:Boolean,default:!0},color:{},trueValue:{default:!0},falseValue:{default:!1},label:{},hint:{},disable:{type:Boolean},readonly:{type:Boolean},activeText:{},inactiveText:{},activeColor:{},inactiveColor:{}},emits:["update:modelValue"],setup(l,{emit:a}){const t=l,s=a,r=e.reactive({excluded:["fieldLabel","labelPosition","labelWidth","labelAlign","required","modelValue","trueValue","falseValue","activeText","inactiveText","activeColor","inactiveColor"]}),c=()=>{const o={};return t.labelPosition==="left"&&t.labelWidth&&(o.width=typeof t.labelWidth=="number"?`${t.labelWidth}px`:t.labelWidth),t.labelAlign&&(o.textAlign=t.labelAlign),o},d=e.computed({get:()=>t.modelValue===t.trueValue,set:o=>{s("update:modelValue",o?t.trueValue:t.falseValue)}}),m=e.computed(()=>{const o={};for(const n in t)!r.excluded.includes(n)&&n!=="modelValue"&&(o[n]=t[n]);return o});return(o,n)=>{const i=C.ElSwitch;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["u-toggle",{"u-toggle-label-left":l.labelPosition==="left"}])},[l.fieldLabel?(e.openBlock(),e.createElementBlock("div",{key:0,class:"u-toggle-label",style:e.normalizeStyle(c())},[e.createTextVNode(e.toDisplayString(l.fieldLabel)+" ",1),e.createElementVNode("span",{class:e.normalizeClass(["required-star",{"required-star--visible":l.required}])},"*",2)],4)):e.createCommentVNode("",!0),e.createElementVNode("div",Te,[e.createVNode(i,e.mergeProps({modelValue:d.value,"onUpdate:modelValue":n[0]||(n[0]=u=>d.value=u)},m.value,{"active-text":l.activeText,"inactive-text":l.inactiveText,"active-color":l.activeColor,"inactive-color":l.inactiveColor}),null,16,["modelValue","active-text","inactive-text","active-color","inactive-color"])])],2)}}}),[["__scopeId","data-v-94c1fd38"]]),Pe={class:"u-cascader-levels"},X=k(e.defineComponent({__name:"UCascader",props:{fieldLabel:{},labelPosition:{default:"top"},labelWidth:{},labelAlign:{},required:{type:Boolean},modelValue:{},options:{},depth:{default:1}},emits:["update:modelValue"],setup(l,{emit:a}){const t=l,s=a,r=()=>{const o={};return t.labelPosition==="left"&&t.labelWidth&&(o.width=typeof t.labelWidth=="number"?`${t.labelWidth}px`:t.labelWidth),t.labelAlign&&(o.textAlign=t.labelAlign),o},c=e.ref([]),d=e.computed(()=>{const o=[];let n=t.options||[];for(let i=0;i<t.depth;i++)if(o.push(n),c.value[i]!==void 0){const u=n.find(f=>f.value===c.value[i]);u&&u.children?n=u.children:n=[]}else n=[];return o});e.watch(()=>t.modelValue,o=>{o!=null?c.value=Array.isArray(o)?o:[o]:c.value=[]},{immediate:!0});const m=(o,n)=>{c.value[o]=n;for(let u=o+1;u<t.depth;u++)c.value[u]=void 0;const i=c.value.filter(u=>u!==void 0);s("update:modelValue",i)};return(o,n)=>{const i=C.ElOption,u=C.ElSelect;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["u-cascader",{"u-cascader-label-left":l.labelPosition==="left"}])},[l.fieldLabel?(e.openBlock(),e.createElementBlock("div",{key:0,class:"u-cascader-label",style:e.normalizeStyle(r())},[e.createTextVNode(e.toDisplayString(l.fieldLabel)+" ",1),e.createElementVNode("span",{class:e.normalizeClass(["required-star",{"required-star--visible":l.required}])},"*",2)],4)):e.createCommentVNode("",!0),e.createElementVNode("div",Pe,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.depth,f=>(e.openBlock(),e.createElementBlock("div",{key:f-1,class:"u-cascader-level"},[e.createVNode(u,{"model-value":c.value[f-1],options:d.value[f-1]||[],disabled:f>1&&c.value[f-2]===void 0,placeholder:`请选择${f}级`,style:{width:"100%"},onChange:p=>m(f-1,p)},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value[f-1]||[],p=>(e.openBlock(),e.createBlock(i,{key:p.value,label:p.label,value:p.value},null,8,["label","value"]))),128))]),_:2},1032,["model-value","options","disabled","placeholder","onChange"])]))),128))])],2)}}}),[["__scopeId","data-v-d66c339c"]]),$e={class:"u-date-field"},z=k(e.defineComponent({__name:"UDate",props:{fieldLabel:{},labelPosition:{default:"top"},labelWidth:{},labelAlign:{},required:{type:Boolean},modelValue:{},mode:{default:"single"},locale:{default:"zh-CN"},mask:{default:"YYYY-MM-DD"},min:{},max:{}},emits:["update:modelValue"],setup(l,{emit:a}){const t=l,s=a,r=()=>{const o={};return t.labelPosition==="left"&&t.labelWidth&&(o.width=typeof t.labelWidth=="number"?`${t.labelWidth}px`:t.labelWidth),t.labelAlign&&(o.textAlign=t.labelAlign),o},c=e.ref("");e.watch(()=>t.modelValue,o=>{t.mode==="single"?c.value=o||"":t.mode==="multiple"?c.value=Array.isArray(o)?o:o?[o]:[]:t.mode==="range"&&(o&&typeof o=="object"&&o.from&&o.to?c.value=[o.from,o.to]:c.value=[])},{immediate:!0});const d=o=>{o&&(t.mode==="single"||t.mode==="multiple"?s("update:modelValue",o):t.mode==="range"&&o&&o.length===2&&s("update:modelValue",{from:o[0],to:o[1]}))},m=e.computed(()=>t.mode==="range"?"daterange":t.mode==="multiple"?"dates":"date");return(o,n)=>{const i=C.ElDatePicker;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["u-date",{"u-date-label-left":l.labelPosition==="left"}])},[l.fieldLabel?(e.openBlock(),e.createElementBlock("div",{key:0,class:"u-date-label",style:e.normalizeStyle(r())},[e.createTextVNode(e.toDisplayString(l.fieldLabel)+" ",1),e.createElementVNode("span",{class:e.normalizeClass(["required-star",{"required-star--visible":l.required}])},"*",2)],4)):e.createCommentVNode("",!0),e.createElementVNode("div",$e,[e.createVNode(i,{modelValue:c.value,"onUpdate:modelValue":n[0]||(n[0]=u=>c.value=u),type:m.value,placeholder:l.locale==="en-US"?"Select date":"选择日期","range-separator":l.locale==="en-US"?"to":"至","start-placeholder":l.locale==="en-US"?"Start date":"开始日期","end-placeholder":l.locale==="en-US"?"End date":"结束日期",format:l.mask.replace("YYYY","YYYY").replace("MM","MM").replace("DD","DD"),"value-format":l.mask.replace("YYYY","YYYY").replace("MM","MM").replace("DD","DD"),onChange:d},null,8,["modelValue","type","placeholder","range-separator","start-placeholder","end-placeholder","format","value-format"])])],2)}}}),[["__scopeId","data-v-9cd05064"]]);function M(l,a="info"){V.ElMessage({message:l,type:a,duration:1e3,showClose:!1})}function _(l){V.ElMessage({message:l,type:"error",duration:2e3,showClose:!1})}function Ne(l){M(l,"success")}function Re(l){M(l,"error")}function Ae(l){M(l,"warning")}function Ie(l){M(l,"info")}const D={notify:M,success:Ne,error:Re,warning:Ae,info:Ie,alertError:_},Me={key:0,class:"u-menu-brand"},Ue=["src"],ze={class:"u-menu-brand-text"},Fe={key:1,class:"u-menu-logout"},ne=k(e.defineComponent({__name:"UMenu",props:{menuId:{default:"menu"},config:{},mode:{},projectName:{},activePath:{},width:{}},emits:["menu-click","logout"],setup(l,{expose:a,emit:t}){const s=l,r=t,c=e.reactive({config:null,menus:[],activePath:"",iconMap:{},iconsLoaded:!1}),d=e.computed(()=>{var o,n,i,u,f,p,h,g;return{projectName:s.projectName??((o=c.config)==null?void 0:o.projectName)??"",logo:((n=c.config)==null?void 0:n.logo)||"",mode:s.mode??((i=c.config)==null?void 0:i.mode)??"sidebar",isHorizontal:(s.mode??((u=c.config)==null?void 0:u.mode)??"sidebar")==="horizontal",elMode:(s.mode??((f=c.config)==null?void 0:f.mode)??"sidebar")==="horizontal"?"horizontal":"vertical",width:s.width??((p=c.config)==null?void 0:p.width)??220,menus:c.menus,activeIndex:m.getIndexByPath(c.activePath),showLogout:((h=c.config)==null?void 0:h.showLogout)!==!1,logoutText:((g=c.config)==null?void 0:g.logoutText)||"退出登录",iconMap:c.iconMap}}),m={async init(){await m.ensureIcons(),s.config?(c.config=s.config,c.menus=m.normalizeMenus(s.config.menus)):await m.loadConfig(s.menuId),c.activePath=s.activePath||c.activePath},async loadConfig(o){if(o)try{const n=await B().Get(E.formCfgApi(o,"menus"));if(n.status!==200){_(n.message||"获取菜单配置失败");return}const i=n.data||{};c.config=i,i.dictType?await m.loadDictMenus(i.dictType):c.menus=m.normalizeMenus(i.menus)}catch(n){_((n==null?void 0:n.message)||"获取菜单配置失败"),c.menus=[]}},async loadDictMenus(o){try{const n=await B().Get(E.cascaderApi(o));if(n.status!==200){_(n.message||"获取菜单字典失败");return}c.menus=m.normalizeMenus(W(n.data))}catch(n){_((n==null?void 0:n.message)||"获取菜单字典失败"),c.menus=[]}},normalizeMenus(o){return Array.isArray(o)?o.map(n=>m.normalizeMenuNode(n)).filter(Boolean):[]},normalizeMenuNode(o){if(!o||typeof o!="object")return null;const n=m.parseInfo(o.info),i=o.label??o.dict_value??o.name;if(!i)return null;const u=n.path??o.path??o.dict_code??o.value??"",f=n.type??o.type??"route",p={...o,label:String(i),type:f,path:String(u??""),icon:n.icon??o.icon??""},h=n.id??o.id;h!=null&&h!==""&&(p.id=String(h));const g=n.open??o.open;(g==="new"||g==="self")&&(p.open=g),delete p.children;const y=o.children;return Array.isArray(y)&&y.length>0&&(p.children=y.map(x=>m.normalizeMenuNode(x)).filter(Boolean)),p},parseInfo(o){if(!o)return{};if(typeof o=="object")return o;if(typeof o=="string")try{const n=JSON.parse(o);return n&&typeof n=="object"?n:{}}catch{return{path:o}}return{}},itemIndex(o,n){return o.path||`menu-${n}`},childIndex(o,n,i,u){return i.path?i.path:`${m.itemIndex(o,n)}-${u}`},hasChildren(o){return Array.isArray(o.children)&&o.children.length>0},getIndexByPath(o){if(!o)return"";for(let n=0;n<c.menus.length;n++){const i=c.menus[n];if(i.path===o)return m.itemIndex(i,n);const u=i.children||[];for(let f=0;f<u.length;f++)if(u[f].path===o)return m.childIndex(i,n,u[f],f)}return""},findItemByIndex(o,n){for(let i=0;i<c.menus.length;i++){const u=c.menus[i],f=m.itemIndex(u,i);if(f===o)return{item:u,level:1,indexPath:n||[f],index:o};const p=u.children||[];for(let h=0;h<p.length;h++){const g=p[h],y=m.childIndex(u,i,g,h);if(y===o)return{item:g,level:2,indexPath:n||[f,y],index:o}}}return null},resolveTarget(o){const n=o.type||"route",i=o.path||"";return n==="url"?{type:n,path:i,url:i,open:o.open||"new"}:n==="form"||n==="table"||n==="menu"?{type:n,path:i,id:o.id||i}:{type:"route",path:i,route:i}},handleSelect(o,n){const i=m.findItemByIndex(o,n);if(!i||m.hasChildren(i.item))return;const u=m.resolveTarget(i.item);c.activePath=i.item.path||o;const f={...u,item:i.item,level:i.level,indexPath:i.indexPath,index:o};r("menu-click",f)},handleLogout(){r("logout")},setActivePath(o){c.activePath=o},async ensureIcons(){if(!c.iconsLoaded){c.iconsLoaded=!0;try{const o=te,n=o!=null&&o.default?{...o.default,...o}:{...o},i={};for(const[u,f]of Object.entries(n))i[u]=e.markRaw(f);c.iconMap=i}catch(o){console.warn("[UMenu] @element-plus/icons-vue 不可用,菜单图标将被忽略",o)}}},getIcon(o){return o&&c.iconMap[o]||null}};return e.watch(()=>s.menuId,o=>{s.config||m.loadConfig(o)}),e.watch(()=>s.activePath,o=>{c.activePath=o||""}),e.watch(()=>s.config,o=>{o&&(c.config=o,c.menus=m.normalizeMenus(o.menus))}),e.onMounted(()=>{m.init()}),a({loadConfig:m.loadConfig,setActivePath:m.setActivePath}),(o,n)=>{const i=C.ElIcon,u=C.ElMenuItem,f=C.ElSubMenu,p=C.ElMenu,h=C.ElButton;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["u-menu",[`u-menu--${d.value.mode}`,{"u-menu--no-brand":!d.value.projectName}]]),style:e.normalizeStyle(d.value.isHorizontal?{}:{width:d.value.width+"px"})},[d.value.projectName?(e.openBlock(),e.createElementBlock("div",Me,[e.renderSlot(o.$slots,"brand",{projectName:d.value.projectName,mode:d.value.mode},()=>[d.value.logo?(e.openBlock(),e.createElementBlock("img",{key:0,class:"u-menu-logo",src:d.value.logo,alt:"logo"},null,8,Ue)):e.createCommentVNode("",!0),e.createElementVNode("span",ze,e.toDisplayString(d.value.projectName),1)],!0)])):e.createCommentVNode("",!0),e.createVNode(p,{class:"u-menu-list",mode:d.value.elMode,"default-active":d.value.activeIndex,"unique-opened":!d.value.isHorizontal,onSelect:m.handleSelect},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value.menus,(g,y)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:m.itemIndex(g,y)},[m.hasChildren(g)?(e.openBlock(),e.createBlock(f,{key:0,index:m.itemIndex(g,y)},{title:e.withCtx(()=>[e.renderSlot(o.$slots,"menu-title",{item:g,level:1,index:y},()=>[m.getIcon(g.icon)?(e.openBlock(),e.createBlock(i,{key:0,class:"u-menu-icon"},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(m.getIcon(g.icon))))]),_:2},1024)):e.createCommentVNode("",!0),e.createElementVNode("span",null,e.toDisplayString(g.label),1)],!0)]),default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.children,(x,N)=>(e.openBlock(),e.createBlock(u,{key:m.childIndex(g,y,x,N),index:m.childIndex(g,y,x,N)},{default:e.withCtx(()=>[e.renderSlot(o.$slots,"menu-item",{item:x,level:2,index:N,parent:g},()=>[m.getIcon(x.icon)?(e.openBlock(),e.createBlock(i,{key:0,class:"u-menu-icon"},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(m.getIcon(x.icon))))]),_:2},1024)):e.createCommentVNode("",!0),e.createElementVNode("span",null,e.toDisplayString(x.label),1)],!0)]),_:2},1032,["index"]))),128))]),_:2},1032,["index"])):(e.openBlock(),e.createBlock(u,{key:1,index:m.itemIndex(g,y)},{default:e.withCtx(()=>[e.renderSlot(o.$slots,"menu-item",{item:g,level:1,index:y,parent:null},()=>[m.getIcon(g.icon)?(e.openBlock(),e.createBlock(i,{key:0,class:"u-menu-icon"},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(m.getIcon(g.icon))))]),_:2},1024)):e.createCommentVNode("",!0),e.createElementVNode("span",null,e.toDisplayString(g.label),1)],!0)]),_:2},1032,["index"]))],64))),128))]),_:3},8,["mode","default-active","unique-opened","onSelect"]),d.value.showLogout?(e.openBlock(),e.createElementBlock("div",Fe,[e.renderSlot(o.$slots,"logout",{mode:d.value.mode},()=>[e.createVNode(h,{class:"u-menu-logout-btn",text:"",onClick:m.handleLogout},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(d.value.logoutText),1)]),_:1},8,["onClick"])],!0)])):e.createCommentVNode("",!0)],6)}}}),[["__scopeId","data-v-41cadcd8"]]),Le={class:"form-content"},qe={key:1,class:"form-layout"},We={key:0,class:"form-header"},Oe={class:"title"},je={class:"form-body"},Ye={key:1,class:"form-footer"},Qe=k(e.defineComponent({__name:"FormContainer",props:{visible:{type:Boolean},layout:{},title:{},loading:{type:Boolean,default:!1}},emits:["update:visible","close","closed"],setup(l,{emit:a}){const t=l,s=a,{visible:r}=e.toRefs(t),c=e.computed(()=>t.layout.open==="normal"),d=e.computed(()=>t.layout.width||400),m={handleClose(){s("update:visible",!1),s("close")},handleClosed(){s("closed")},updateVisible(o){s("update:visible",o)}};return(o,n)=>{const i=C.ElIcon,u=C.ElDialog;return c.value?e.unref(r)?(e.openBlock(),e.createElementBlock("div",qe,[l.title?(e.openBlock(),e.createElementBlock("div",We,[e.createElementVNode("div",Oe,e.toDisplayString(l.title),1)])):e.createCommentVNode("",!0),e.createElementVNode("div",je,[l.loading?(e.openBlock(),e.createBlock(i,{key:0,class:"is-loading",size:40},{default:e.withCtx(()=>[e.createVNode(e.unref(Y.Loading))]),_:1})):e.renderSlot(o.$slots,"default",{},void 0,!0,1)]),o.$slots.actions?(e.openBlock(),e.createElementBlock("div",Ye,[e.renderSlot(o.$slots,"actions",{},void 0,!0)])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(u,{key:0,"model-value":e.unref(r),title:l.title,width:d.value,"close-on-click-modal":!1,"onUpdate:modelValue":m.updateVisible,onClose:m.handleClose,onClosed:m.handleClosed},{footer:e.withCtx(()=>[e.renderSlot(o.$slots,"actions",{},void 0,!0)]),default:e.withCtx(()=>[e.createElementVNode("div",Le,[l.loading?(e.openBlock(),e.createBlock(i,{key:0,class:"is-loading",size:40},{default:e.withCtx(()=>[e.createVNode(e.unref(Y.Loading))]),_:1})):e.renderSlot(o.$slots,"default",{},void 0,!0,1)])]),_:3},8,["model-value","title","width","onUpdate:modelValue","onClose","onClosed"]))}}}),[["__scopeId","data-v-83362259"]]),Ge=k(e.defineComponent({__name:"FormGrid",props:{fields:{},layout:{}},setup(l){const a=l,t=e.reactive({columns:e.computed(()=>a.layout.columns||1)}),s={getColSpan(r){const c=r.colSpan||1;return Math.min(c,t.columns)}};return(r,c)=>(e.openBlock(),e.createElementBlock("div",{class:"form-grid",style:e.normalizeStyle({"--grid-columns":t.columns})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.fields,d=>(e.openBlock(),e.createElementBlock("div",{key:d.field,class:"form-grid-item",style:e.normalizeStyle({gridColumn:`span ${s.getColSpan(d)}`})},[e.renderSlot(r.$slots,"default",{field:d},void 0,!0)],4))),128))],4))}}),[["__scopeId","data-v-90ed35a4"]]),Ke={class:"form-field"},He=k(e.defineComponent({__name:"FormField",props:{field:{},modelValue:{},layout:{},disabled:{type:Boolean,default:!1},error:{}},emits:["update:modelValue"],setup(l,{emit:a}){const t=l,s=a,r=e.reactive({componentMap:e.markRaw({input:R,"input-number":Q,dict:I,switch:J,cascader:X,date:z}),cascaderOptions:[]}),c=()=>{t.field.cascaderKey&&B().Get(E.cascaderApi(t.field.cascaderKey)).then(i=>{i.status===200&&(r.cascaderOptions=W(i.data))})};e.watch(()=>t.field.cascaderKey,c,{immediate:!0});const d=e.computed(()=>r.componentMap[t.field.type]||R),m=e.computed(()=>{if((t.layout.labelPosition||"top")==="left"){const u=t.layout.labelWidth||0,f=typeof u=="number"?u+4:u;return{marginLeft:typeof f=="number"?`${f}px`:f}}return{}}),o=e.computed(()=>{const{field:i,modelValue:u,layout:f,disabled:p}=t;let h=u;i.type==="switch"&&u==null&&(h=!1);const g={fieldLabel:i.label,modelValue:h,labelPosition:f.labelPosition||"top",disable:p,name:i.field,required:i.required};if(f.labelWidth&&(g.labelWidth=f.labelWidth),f.labelAlign&&(g.labelAlign=f.labelAlign),i.maxlength&&(g.maxlength=i.maxlength),i.placeholder&&(g.placeholder=i.placeholder),i.readonly&&(g.readonly=i.readonly),i.lineCount&&i.lineCount>=2?(g.type="textarea",g.rows=i.lineCount):i.inputType&&(g.type=i.inputType),i.type==="switch"&&(i.activeText&&(g.activeText=i.activeText),i.inactiveText&&(g.inactiveText=i.inactiveText),i.activeColor&&(g.activeColor=i.activeColor),i.inactiveColor&&(g.inactiveColor=i.inactiveColor),i.trueValue!==void 0&&(g.trueValue=i.trueValue),i.falseValue!==void 0&&(g.falseValue=i.falseValue)),i.dictType&&(g.dictType=i.dictType),i.cascaderKey&&(g.options=r.cascaderOptions,g.depth=i.cascaderDepth||2),i.type==="date"){i.mode&&(g.mode=i.mode),i.locale&&(g.locale=i.locale),i.format?g.mask=i.format:i.mask&&(g.mask=i.mask);const y=i.dateMin??i.min,x=i.dateMax??i.max;y!=null&&(g.min=y),x!=null&&(g.max=x)}return i.type==="input-number"&&(i.min!==void 0&&(g.min=i.min),i.max!==void 0&&(g.max=i.max),i.step&&(g.step=i.step),i.precision!==void 0&&(g.precision=i.precision)),g}),n={handleUpdate(i){s("update:modelValue",i)}};return(i,u)=>(e.openBlock(),e.createElementBlock("div",Ke,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(d.value),e.mergeProps(o.value,{"onUpdate:modelValue":n.handleUpdate}),null,16,["onUpdate:modelValue"])),e.createElementVNode("div",{class:e.normalizeClass(["field-error",{"field-error--visible":l.error}]),style:e.normalizeStyle(m.value)},e.toDisplayString(l.error||""),7)]))}}),[["__scopeId","data-v-96994a9a"]]);class Je{constructor(){w(this,"formConfig",null);w(this,"formData",{});w(this,"loading",!1);w(this,"submitting",!1);w(this,"visible",!1);w(this,"isEditMode",!1);w(this,"errors",[]);w(this,"currentQuery",{})}}let Xe=class{constructor(){w(this,"data",e.reactive(new Je))}parseQuery(a){if(!a)return{};const t={},s=a.split("&");for(const r of s){const[c,d]=r.split("=");c&&(t[c]=d||"")}return t}async fetchFormConfig(a){const t=await B().Get(E.formCfgApi(a,"forms"));if(t.status!==200)throw new Error(t.message||"获取表单配置失败");return t.data}async fetchFormData(a,t){const s=t?`${a}?${t}`:a,r=await B().Get(s);if(r.status!==200)throw new Error(r.message||"获取表单数据失败");return r.data}async submitForm(a,t){return await B().Post(a,t)}buildInitialData(a){const t={};for(const s of a)s.default!==void 0?t[s.field]=s.default:t[s.field]=null;return t}checkIsEditMode(a){return!!a&&a.trim().length>0}validate(){var t;this.data.errors=[];const a=((t=this.data.formConfig)==null?void 0:t.fields)||[];for(const s of a){const r=this.data.formData[s.field];if(s.required&&(r==null||r==="")){this.data.errors.push({field:s.field,message:`${s.label}为必填项`});continue}if(s.rules&&s.rules.length>0&&r){for(const c of s.rules)if(c.pattern&&!new RegExp(c.pattern).test(r)){this.data.errors.push({field:s.field,message:c.message||`${s.label}格式不正确`});break}}}return this.data.errors.length===0}getFieldError(a){const t=this.data.errors.find(s=>s.field===a);return t?t.message:null}clearErrors(){this.data&&(this.data.errors=[])}async openForm(a,t){this.data.loading=!0,this.data.visible=!0,this.clearErrors(),this.data.currentQuery=this.parseQuery(t||"");try{const s=await this.fetchFormConfig(a);if(this.data.formConfig=s,this.data.isEditMode=this.checkIsEditMode(t||""),this.data.formData=this.buildInitialData(s.fields),this.data.isEditMode&&s.api.get&&t){const r=await this.fetchFormData(s.api.get,t),c=this.nestedToFlat(r);this.data.formData={...this.data.formData,...c}}}catch(s){throw console.error("[FormRender] 打开表单失败:",s),this.data.visible=!1,s}finally{this.data.loading=!1}}async doSubmit(){if(!this.data.formConfig)return;if(!this.validate())throw new Error("请完善表单信息");const{api:a}=this.data.formConfig;let t=this.data.isEditMode?a.edit:a.add;if(!t)throw new Error("提交地址未配置");let s={...this.data.formData};s=this.flattenToNested(s),this.data.isEditMode&&this.data.currentQuery.id&&(s.id=Number(this.data.currentQuery.id)),this.data.submitting=!0;try{const r=await this.submitForm(t,s);if(r.status===200)return r.data;throw new Error(r.message||"提交失败")}finally{this.data.submitting=!1}}closeForm(){this&&(this.data.visible=!1)}resetForm(){this.data.formConfig=null,this.data.formData={},this.data.isEditMode=!1,this.data.currentQuery={},this.clearErrors()}flattenToNested(a){const t={};for(const s in a){const r=a[s];if(s.includes(".")){const c=s.split(".");let d=t;for(let m=0;m<c.length-1;m++){const o=c[m];d[o]||(d[o]={}),d=d[o]}d[c[c.length-1]]=r}else t[s]=r}return t}nestedToFlat(a,t=""){const s={};for(const r in a){const c=a[r],d=t?`${t}.${r}`:r;c&&typeof c=="object"&&!Array.isArray(c)?Object.keys(c).length===2&&"from"in c&&"to"in c?s[d]=c:Object.assign(s,this.nestedToFlat(c,d)):s[d]=c}return s}};const Z=k(e.defineComponent({__name:"FormRender",setup(l,{expose:a}){const t=new Xe,s=e.ref(null),r=e.reactive({currentQuery:{},submitResolve:null}),c=e.computed(()=>{var p;const f={};if(!t.data.isEditMode||!r.currentQuery)return f;for(const h of((p=t.data.formConfig)==null?void 0:p.fields)||[])r.currentQuery[h.field]!==void 0&&(f[h.field]=!0);return f}),d=e.computed(()=>{var f;return((f=t.data.formConfig)==null?void 0:f.layout)||{open:"dialog",columns:1,labelPosition:"top",buttonAlign:"right"}}),m=e.computed(()=>{var f;return((f=t.data.formConfig)==null?void 0:f.fields)||[]}),o=e.computed(()=>{var f,p;return((p=(f=t.data.formConfig)==null?void 0:f.meta)==null?void 0:p.title)||"表单"}),n=e.computed(()=>d.value.buttonAlign||"right"),i=e.computed(()=>d.value.open==="normal"),u={async showForm(f,p){r.currentQuery=t.parseQuery(p||"");try{await t.openForm(f,p)}catch(h){return _((h==null?void 0:h.message)||"打开表单失败"),null}return new Promise(h=>{r.submitResolve=h})},async handleSubmit(){var f,p;try{const h=await t.doSubmit(),g=((p=(f=t.data.formConfig)==null?void 0:f.meta)==null?void 0:p.title)+"保存成功";return D.success(g),r.submitResolve&&(r.submitResolve(h),r.submitResolve=null),i.value||t.closeForm(),h}catch(h){return r.submitResolve&&(r.submitResolve(null),r.submitResolve=null),h!=null&&h.message&&h.message!=="请完善表单信息"&&_(h.message),null}},resolvePending(){r.submitResolve&&(r.submitResolve(null),r.submitResolve=null)},handleCancel(){i.value||(u.resolvePending(),t.closeForm())},getFieldError(f){return t.getFieldError(f)},handleClose(){u.resolvePending(),t.closeForm()},handleClosed(){t.data.visible||t.resetForm()}};return a({showForm:u.showForm}),(f,p)=>{const h=C.ElForm,g=C.ElButton;return e.openBlock(),e.createBlock(Qe,{visible:e.unref(t).data.visible,"onUpdate:visible":p[0]||(p[0]=y=>e.unref(t).data.visible=y),layout:d.value,title:o.value,loading:e.unref(t).data.loading,onClose:u.handleClose,onClosed:u.handleClosed},{actions:e.withCtx(()=>[e.createElementVNode("div",{class:e.normalizeClass(["form-actions",n.value==="right"?"justify-end":"justify-start"])},[e.createVNode(g,{onClick:u.handleCancel},{default:e.withCtx(()=>[...p[1]||(p[1]=[e.createTextVNode("取消",-1)])]),_:1},8,["onClick"]),e.createVNode(g,{type:"primary",loading:e.unref(t).data.submitting,onClick:u.handleSubmit},{default:e.withCtx(()=>[...p[2]||(p[2]=[e.createTextVNode("提交",-1)])]),_:1},8,["loading","onClick"])],2)]),default:e.withCtx(()=>[e.createVNode(h,{ref_key:"formRef",ref:s,class:"form-render","label-position":"top"},{default:e.withCtx(()=>[e.createVNode(Ge,{fields:m.value,layout:d.value},{default:e.withCtx(({field:y})=>[e.createVNode(He,{modelValue:e.unref(t).data.formData[y.field],"onUpdate:modelValue":x=>e.unref(t).data.formData[y.field]=x,field:y,layout:d.value,disabled:c.value[y.field],error:u.getFieldError(y.field)},null,8,["modelValue","onUpdate:modelValue","field","layout","disabled","error"])]),_:1},8,["fields","layout"])]),_:1},512)]),_:1},8,["visible","layout","title","loading","onClose","onClosed"])}}}),[["__scopeId","data-v-b3267c00"]]);class Ze{constructor(a){this.config=a}async fetchList(a,t){const s={page:t.page,pageSize:t.pageSize,...a},r={};for(const o in s){const n=s[o];n!==""&&n!==null&&n!==void 0&&(r[o]=n)}const c=new URLSearchParams;for(const o in r)c.append(o,String(r[o]));const d=`${this.config.api.list}${c.toString()?"?"+c.toString():""}`,m=await B().Get(d);if(m.status===200){const o=m.data;return Array.isArray(o)?{rows:o,total:o.length}:o||{rows:[],total:0}}throw new Error(m.message||"获取列表数据失败")}async deleteRow(a){if(!this.config.api.delete)throw new Error("未配置删除API");const t=this.config.key||"id",s=a[t],r=`${this.config.api.delete}?${encodeURIComponent(t)}=${encodeURIComponent(String(s??""))}`,c=await B().Post(r);if(c.status!==200)throw new Error(c.message||"删除失败")}async batchDelete(a){if(!this.config.api.delete)throw new Error("未配置删除API");const t=await B().Post(this.config.api.delete,a);if(t.status!==200)throw new Error(t.message||"批量删除失败")}async exportData(a){if(!this.config.api.export)throw new Error("未配置导出API");const s=(await B().PostDownload(this.config.api.export,a)).data,r=window.URL.createObjectURL(s),c=document.createElement("a");c.href=r,c.download=`export_${Date.now()}.xlsx`,c.click(),window.URL.revokeObjectURL(r)}async downloadTemplate(){if(!this.config.api.import)throw new Error("未配置导入API");const t=(await B().Download(`${this.config.api.import}/template`)).data,s=window.URL.createObjectURL(t),r=document.createElement("a");r.href=s,r.download=`template_${Date.now()}.xlsx`,r.click(),window.URL.revokeObjectURL(s)}async importData(a){if(!this.config.api.import)throw new Error("未配置导入API");const t=new FormData;t.append("file",a);const s=await B().Post(this.config.api.import,t);if(s.status!==200)throw new Error(s.message||"导入失败");return s.data}}class ve{constructor(){w(this,"tableConfig",null);w(this,"rows",[]);w(this,"total",0);w(this,"loading",!1);w(this,"searchParams",{});w(this,"pagination",{page:1,pageSize:20});w(this,"currentRow",null);w(this,"detailVisible",!1);w(this,"detailData",null);w(this,"detailLoading",!1);w(this,"previewVisible",!1);w(this,"previewMounted",!1);w(this,"previewRow",null)}}let et=class{constructor(){w(this,"data",e.reactive(new ve));w(this,"dataService",null)}async loadConfig(a){var r;const t=E.formCfgApi(a,"tables");console.log("load config url =",t);const s=await B().Get(t);if(console.log("---"),s.status!==200)throw new Error(s.message||"获取表格配置失败");this.data.tableConfig=s.data,this.dataService=new Ze(s.data),this.data.currentRow=null,this.data.detailVisible=!1,this.data.detailData=null,this.data.previewVisible=!1,this.data.previewMounted=!1,this.data.previewRow=null,typeof console<"u"&&console.log("[TableRender] loadConfig:",{tableId:a,hasDetail:this.hasDetail(),detail:(r=this.data.tableConfig)==null?void 0:r.detail}),this.initSearchParams()}initSearchParams(){var s;const a={},t=((s=this.data.tableConfig)==null?void 0:s.search)||[];for(const r of t)a[r.field]="";this.data.searchParams=a}async loadData(){if(!this.dataService)throw new Error("表格配置未加载");this.data.loading=!0;try{const a=await this.dataService.fetchList(this.data.searchParams,this.data.pagination);this.data.rows=a.rows||[],this.data.total=a.total||0,this.syncRowRefs()}finally{this.data.loading=!1}}syncRowRefs(){const{currentRow:a,detailData:t}=this.data;if(!a&&!t)return;const s=this.getKeyField(),r=c=>c&&this.data.rows.find(d=>d[s]===c[s])||null;this.data.currentRow=r(a),this.data.detailData&&(this.data.detailData=r(this.data.detailData),this.data.detailData||(this.data.detailVisible=!1))}async search(){this.data.pagination.page=1,await this.loadData()}async reset(){this.initSearchParams(),this.data.pagination.page=1,await this.loadData()}updateSearchParam(a,t){this.data.searchParams[a]=t}async deleteRow(a){if(!this.dataService)throw new Error("表格配置未加载");await this.dataService.deleteRow(a),await this.loadData(),this.isSameRow(a,this.data.currentRow)&&(this.data.currentRow=null),this.isSameRow(a,this.data.detailData)&&this.closeDetail(),this.isSameRow(a,this.data.previewRow)&&this.closePreview()}isSameRow(a,t){return!a||!t?!1:a[this.getKeyField()]===t[this.getKeyField()]}async changePage(a){this.data.pagination.page=a,await this.loadData()}async changePageSize(a){this.data.pagination.pageSize=a,this.data.pagination.page=1,await this.loadData()}setCurrentRow(a){this.data.currentRow=a,this.hasDetail()&&this.openDetail(a)}getCurrentRow(){return this.data.currentRow}getCurrentKey(){var a;return(a=this.data.currentRow)==null?void 0:a[this.getKeyField()]}async exportData(){if(!this.dataService)throw new Error("表格配置未加载");await this.dataService.exportData(this.data.searchParams)}async downloadTemplate(){if(!this.dataService)throw new Error("表格配置未加载");await this.dataService.downloadTemplate()}async importData(a){if(!this.dataService)throw new Error("表格配置未加载");const t=await this.dataService.importData(a);return await this.loadData(),t}getKeyField(){var a;return((a=this.data.tableConfig)==null?void 0:a.key)||"id"}getFormId(){var a;return(a=this.data.tableConfig)==null?void 0:a.form}getDetailFormId(){var a,t;return(t=(a=this.data.tableConfig)==null?void 0:a.detail)==null?void 0:t.formId}hasDetail(){var t;const a=(t=this.data.tableConfig)==null?void 0:t.detail;return!a||typeof a!="object"||a.enable===!1?!1:a.enable===!0||a.enable!==void 0&&a.enable!==null&&a.enable!==""?!0:!!(a.formId||a.position)}isDetailInline(){var a,t;return((t=(a=this.data.tableConfig)==null?void 0:a.detail)==null?void 0:t.enable)===!0}getDetailMode(){return this.isDetailInline()?"inline":"drawer"}getDetailPosition(){var a,t;return((t=(a=this.data.tableConfig)==null?void 0:a.detail)==null?void 0:t.position)||"right"}getDetailWidth(){var t,s;const a=(s=(t=this.data.tableConfig)==null?void 0:t.detail)==null?void 0:s.width;return typeof a=="number"&&a>0?`${a}px`:typeof a=="string"&&a?a:"400px"}getDetailDirection(){return{left:"ltr",right:"rtl",top:"ttb"}[this.getDetailPosition()]||"rtl"}isDetailOpen(){return this.isDetailInline()||this.data.detailVisible}openDetail(a){this.data.detailData=a,this.data.detailVisible=!0}closeDetail(){this.data.detailVisible=!1,this.isDetailInline()&&(this.data.detailData=null)}resetDetail(){this.data.detailVisible||(this.data.detailData=null)}openPreview(a){this.data.previewRow=a,this.data.previewVisible=!0,this.data.previewMounted=!0}closePreview(){this.data.previewVisible=!1}resetPreview(){this.data.previewVisible||(this.data.previewRow=null,this.data.previewMounted=!1)}getSearchFields(){var a;return((a=this.data.tableConfig)==null?void 0:a.search)||[]}getColumns(){var a;return((a=this.data.tableConfig)==null?void 0:a.columns)||[]}hasSearch(){return this.getSearchFields().length>0}getToolbar(){var t;const a=(t=this.data.tableConfig)==null?void 0:t.toolbar;return Array.isArray(a)?a:[]}hasToolbar(){return this.getToolbar().length>0}getActions(){var t;const a=(t=this.data.tableConfig)==null?void 0:t.actions;return Array.isArray(a)?a:[]}hasActions(){return this.getActions().length>0}getButtonFormId(a){var t;return(a==null?void 0:a.form)||((t=this.data.tableConfig)==null?void 0:t.form)}getPaginationType(){var a;return((a=this.data.tableConfig)==null?void 0:a.pagination)||"page"}};const tt={class:"table-search"},at={class:"search-fields"},ot={class:"search-actions"},lt=k(e.defineComponent({__name:"TableSearch",props:{fields:{},modelValue:{}},emits:["update:modelValue","search","reset"],setup(l,{emit:a}){const t=l,s=a,r={input:R,dict:I,dept:I,role:I,date:z,daterange:z},c={getComponent(d){return r[d]||R},updateValue(d,m){const o={...t.modelValue,[d]:m};s("update:modelValue",o)},handleSearch(){const d={};for(const m in t.modelValue){const o=t.modelValue[m];d[m]=typeof o=="string"?o.trim():o}s("update:modelValue",d),s("search")},handleReset(){s("reset")}};return(d,m)=>{const o=C.ElButton;return e.openBlock(),e.createElementBlock("div",tt,[e.createElementVNode("div",at,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.fields,n=>(e.openBlock(),e.createElementBlock("div",{key:n.field,class:"search-field"},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(c.getComponent(n.type)),{"model-value":t.modelValue[n.field],"field-label":n.label,"dict-type":n.dictType,mode:n.type==="daterange"?"range":void 0,"label-position":"left","onUpdate:modelValue":i=>c.updateValue(n.field,i)},null,8,["model-value","field-label","dict-type","mode","onUpdate:modelValue"]))]))),128)),e.renderSlot(d.$slots,"search-extra",{params:t.modelValue,update:c.updateValue},void 0,!0)]),e.createElementVNode("div",ot,[e.createVNode(o,{type:"primary",onClick:c.handleSearch},{default:e.withCtx(()=>[...m[0]||(m[0]=[e.createTextVNode("查询",-1)])]),_:1},8,["onClick"]),e.createVNode(o,{onClick:c.handleReset},{default:e.withCtx(()=>[...m[1]||(m[1]=[e.createTextVNode("重置",-1)])]),_:1},8,["onClick"]),e.renderSlot(d.$slots,"search-actions",{params:t.modelValue,search:c.handleSearch,reset:c.handleReset},void 0,!0)])])}}}),[["__scopeId","data-v-0281d2ce"]]),nt={class:"table-toolbar"},it={class:"toolbar-items"},st={key:1},rt=k(e.defineComponent({__name:"TableToolbar",props:{items:{},currentRow:{}},emits:["action"],setup(l,{emit:a}){const t=l,s=a,r=e.reactive({iconMap:{}}),c=e.computed(()=>({hasCurrentRow:!!t.currentRow})),d={needRow(m){return m==="edit"||m==="delete"||m==="preview"},getText(m){return m.text?m.text:{add:"新增",edit:"编辑",delete:"删除",preview:"预览",back:"返回"}[m.action]||""},getButtonType(m){return m.style?m.style==="default"?"":m.style:{add:"primary",edit:"primary",delete:"danger",preview:"primary",back:"primary"}[m.action]||""},isDisabled(m){return m.disabled?!0:d.needRow(m.action)&&!c.value.hasCurrentRow},getIcon(m){return m.icon?r.iconMap[m.icon]:null},handleClick(m){s("action",{action:m.action,item:m,row:t.currentRow})},async ensureIcons(){const m=[...new Set(t.items.map(i=>i.icon).filter(Boolean))];if(m.length===0)return;const o=te,n={...r.iconMap};for(const i of m)o[i]&&(n[i]=e.markRaw(o[i]));r.iconMap=e.markRaw(n)}};return e.onMounted(()=>{d.ensureIcons()}),e.watch(()=>t.items,()=>{d.ensureIcons()}),(m,o)=>{const n=C.ElIcon,i=C.ElButton;return e.openBlock(),e.createElementBlock("div",nt,[e.renderSlot(m.$slots,"toolbar-left",{currentRow:t.currentRow},void 0,!0),e.createElementVNode("div",it,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.items,(u,f)=>(e.openBlock(),e.createBlock(i,{key:f,type:d.getButtonType(u),disabled:d.isDisabled(u),onClick:p=>d.handleClick(u)},{default:e.withCtx(()=>[d.getIcon(u)?(e.openBlock(),e.createBlock(n,{key:0},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(d.getIcon(u))))]),_:2},1024)):e.createCommentVNode("",!0),d.getText(u)?(e.openBlock(),e.createElementBlock("span",st,e.toDisplayString(d.getText(u)),1)):e.createCommentVNode("",!0)]),_:2},1032,["type","disabled","onClick"]))),128))]),e.renderSlot(m.$slots,"toolbar-extra",{currentRow:t.currentRow},void 0,!0)])}}}),[["__scopeId","data-v-2a87e101"]]),ct=k(e.defineComponent({__name:"UInputShow",props:{modelValue:{},multiline:{type:Boolean,default:!1},maxLines:{default:0}},setup(l){const a=l,t=e.computed(()=>a.modelValue===null||a.modelValue===void 0?"":String(a.modelValue)),s=e.computed(()=>a.multiline||t.value.includes(`
2
+ `)),r=e.computed(()=>a.maxLines>0&&s.value?{display:"-webkit-box",WebkitLineClamp:a.maxLines,WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis"}:{});return(c,d)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["u-input-show",{"u-input-multiline":s.value}]),style:e.normalizeStyle(r.value)},e.toDisplayString(t.value),7))}}),[["__scopeId","data-v-c78b151e"]]),dt=k(e.defineComponent({__name:"UDictShow",props:{modelValue:{},dictType:{},defaultText:{default:""}},setup(l){const a=l,t=e.ref(""),s=e.ref(!1),r=async()=>{if(a.modelValue===null||a.modelValue===void 0||a.modelValue===""){t.value=a.defaultText;return}if(!a.dictType){t.value=String(a.modelValue);return}s.value=!0;try{const c=await le(a.dictType,a.modelValue,a.defaultText);t.value=c}catch(c){console.error("[UDictShow] 翻译失败:",c),t.value=String(a.modelValue)}finally{s.value=!1}};return e.watch(()=>a.modelValue,r,{immediate:!0}),e.watch(()=>a.dictType,()=>{a.dictType&&A(a.dictType).then(()=>r())}),e.onMounted(()=>{a.dictType?A(a.dictType).then(()=>r()):r()}),(c,d)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["u-dict-show",{"u-dict-loading":s.value}])},e.toDisplayString(t.value),3))}}),[["__scopeId","data-v-908045c4"]]),mt=k(e.defineComponent({__name:"UToggleShow",props:{modelValue:{},trueText:{default:"开启"},falseText:{default:"关闭"},useYesNo:{type:Boolean,default:!1}},setup(l){const a=l,t=e.computed(()=>a.useYesNo?"是":a.trueText),s=e.computed(()=>a.useYesNo?"否":a.falseText),r=e.computed(()=>a.modelValue===!0||a.modelValue==="true"?t.value:a.modelValue===!1||a.modelValue==="false"?s.value:String(a.modelValue??"")),c=e.computed(()=>a.modelValue===!0||a.modelValue==="true"?"toggle-true":a.modelValue===!1||a.modelValue==="false"?"toggle-false":"toggle-default");return(d,m)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["u-toggle-show",c.value])},e.toDisplayString(r.value),3))}}),[["__scopeId","data-v-bac05efc"]]),ut=k(e.defineComponent({__name:"UCascaderShow",props:{modelValue:{},cascaderKey:{},separator:{default:" / "},showRawValue:{type:Boolean,default:!0}},setup(l){const a=l,t=e.ref(""),s=e.ref(!1),r=async()=>{if(!a.modelValue||!Array.isArray(a.modelValue)){t.value="";return}const c=a.modelValue;if(a.cascaderKey){s.value=!0;try{const d=await A(a.cascaderKey),o=c.map(n=>{const i=d.find(u=>u.value===n||String(u.value)===String(n));return i?i.label:a.showRawValue?String(n):""}).filter(n=>n!=="");t.value=o.join(a.separator)}catch(d){console.error("[UCascaderShow] 翻译失败:",d),t.value=a.showRawValue?c.join(a.separator):""}finally{s.value=!1}}else t.value=c.join(a.separator)};return e.watch(()=>a.modelValue,r,{immediate:!0}),e.onMounted(()=>{r()}),(c,d)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["u-cascader-show",{"u-cascader-loading":s.value}])},e.toDisplayString(t.value),3))}}),[["__scopeId","data-v-5d84df67"]]),pt=k(e.defineComponent({__name:"UDateShow",props:{modelValue:{},mode:{default:"single"},locale:{default:"zh-CN"},format:{},separator:{default:", "},rangeSeparator:{default:" ~ "}},setup(l){const a=l,t=e.computed(()=>a.locale==="en-US"?a.mode==="range"?" - ":", ":a.mode==="range"?a.rangeSeparator:a.separator),s=e.computed(()=>{const d=a.modelValue;return a.mode==="single"?d?r(d,a.format):"":a.mode==="multiple"?d?Array.isArray(d)?d.map(m=>r(m,a.format)).join(t.value):String(d):"":a.mode==="range"?d?typeof d=="object"&&d.from&&d.to?`${r(d.from,a.format)}${t.value}${r(d.to,a.format)}`:Array.isArray(d)&&d.length>=2?`${r(d[0],a.format)}${t.value}${r(d[1],a.format)}`:String(d):"":String(d??"")});function r(d,m){return d||""}const c=e.computed(()=>!s.value);return(d,m)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["u-date-show",{"u-date-empty":c.value}])},e.toDisplayString(s.value||(l.locale==="en-US"?"Empty":"暂无")),3))}}),[["__scopeId","data-v-930657df"]]),j=k(e.defineComponent({__name:"UFieldView",props:{type:{default:"text"},modelValue:{},dictType:{},mode:{},locale:{default:"zh-CN"},format:{},text:{},trueText:{default:"开启"},falseText:{default:"关闭"},useYesNo:{type:Boolean,default:!1},cascaderKey:{},multiline:{type:Boolean},defaultText:{default:""}},setup(l){const a=l,t=e.computed(()=>{if(!a.text)return null;const d=a.text.split("/");return d.length>=2?{trueText:d[0].trim(),falseText:d[1].trim()}:null}),s=e.computed(()=>{var d;return a.trueText||((d=t.value)==null?void 0:d.trueText)||"开启"}),r=e.computed(()=>{var d;return a.falseText||((d=t.value)==null?void 0:d.falseText)||"关闭"}),c=e.computed(()=>{switch(a.type){case"dict":return"UDictShow";case"switch":return"UToggleShow";case"cascader":return"UCascaderShow";case"date":return"UDateShow";case"input":case"text":default:return"UInputShow"}});return(d,m)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(c.value==="UDictShow"?dt:c.value==="UToggleShow"?mt:c.value==="UCascaderShow"?ut:c.value==="UDateShow"?pt:ct),{"model-value":l.modelValue,"dict-type":l.type==="dict"?l.dictType:void 0,"cascader-key":l.type==="cascader"?l.cascaderKey:void 0,mode:l.type==="date"?l.mode:void 0,locale:l.type==="date"?l.locale:void 0,format:l.type==="date"?l.format:void 0,"true-text":l.type==="switch"?s.value:void 0,"false-text":l.type==="switch"?r.value:void 0,"use-yes-no":l.type==="switch"?l.useYesNo:void 0,multiline:l.type==="input"||l.type==="text"?l.multiline:void 0,"default-text":l.type==="dict"?l.defaultText:void 0},null,8,["model-value","dict-type","cascader-key","mode","locale","format","true-text","false-text","use-yes-no","multiline","default-text"]))}}),[["__scopeId","data-v-05ef52d9"]]),ft={class:"table-grid"},v="col-",ht=160,gt=k(e.defineComponent({inheritAttrs:!1,__name:"TableGrid",props:{rows:{},columns:{},loading:{type:Boolean},actions:{},actionsWidth:{},keyField:{},selection:{type:[String,Boolean]},dictData:{},activeKey:{}},emits:["rowAction","rowClick","selectionChange"],setup(l,{emit:a}){const t=l,s=e.useSlots(),r=a;function c(n){return n==="actions"||n==="actions-extra"||n.startsWith(v)}const d=e.computed(()=>{var n,i;return{actionList:t.actions||[],actionColumnWidth:t.actionsWidth??((n=t.actions)!=null&&n.length?o.getActionColumnWidth():ht),hasUserEmpty:!!s.empty,forwardSlots:Object.keys(s).filter(u=>u!=="default"&&!c(u)),colSlots:Object.keys(s).filter(u=>u.startsWith(v)),hasActionsSlot:!!s.actions,hasActionsExtra:!!s["actions-extra"],showActionColumn:(((i=t.actions)==null?void 0:i.length)||0)>0||!!s.actions||!!s["actions-extra"]}}),m=e.computed(()=>{const n=t.columns.map(i=>{const u={prop:i.field,label:i.label};return typeof i.width=="number"&&(u.width=i.width),u});return d.value.showActionColumn&&n.push({prop:"actions",label:"操作",width:d.value.actionColumnWidth,fixed:"right"}),n}),o={colSlotName(n){return v+n},hasColSlot(n){return d.value.colSlots.includes(o.colSlotName(n))},actionText(n){return n.text?n.text:{add:"新增",edit:"编辑",delete:"删除",preview:"预览",back:"返回"}[n.action]||""},actionType(n){return n.style?n.style==="default"?"":n.style:{add:"primary",edit:"primary",delete:"danger",preview:"primary",back:"primary"}[n.action]||"primary"},getActionColumnWidth(){const i=(t.actions||[]).reduce((u,f)=>u+Math.max(52,o.actionText(f).length*16+12),0);return Math.max(80,Math.ceil(i)+16)},maskPhone(n){return!n||n.length<7?n:n.replace(/(\d{3})\d{4}(\d{4})/,"$1****$2")},maskIdCard(n){return!n||n.length<8?n:n.replace(/(\d{3})\d{11}(\d{4})/,"$1***********$2")},formatMoney(n){const i=Number(n);return isNaN(i)?String(n):i.toLocaleString("zh-CN",{minimumFractionDigits:2,maximumFractionDigits:2})},formatByType(n,i){if(!n)return"";switch(i){case"phone":return o.maskPhone(n);case"idcard":return o.maskIdCard(n);case"money":return o.formatMoney(n);case"percent":return String(n*100)+"%";default:return i&&i.includes("{}")?i.replace("{}",String(n)):String(n)}},getNestedValue(n,i){if(!i.includes("."))return n[i];const u=i.split(".");let f=n;for(const p of u)if(f&&typeof f=="object"&&p in f)f=f[p];else return;return f},useFieldView(n){return n.type?["dict","switch","cascader","date","input","text"].includes(n.type):!1},rowClassName({row:n}){if(!n||t.activeKey===void 0||t.activeKey===null)return"";const i=t.keyField||"id";return n[i]===t.activeKey?"table-grid-active-row":""},onSelectionChange(n){r("selectionChange",n)},onRowClick(n){r("rowClick",n)},onRowAction(n,i){r("rowAction",{action:n.action,item:n,row:i})}};return(n,i)=>{const u=C.ElTableColumn,f=C.ElButton,p=C.ElTable;return e.openBlock(),e.createElementBlock("div",ft,[e.createVNode(p,e.mergeProps({stripe:!0,border:!0,...n.$attrs},{data:t.rows.length?t.rows:[{}],loading:t.loading,"row-key":t.keyField||"id","row-class-name":o.rowClassName,onSelectionChange:o.onSelectionChange,onRowClick:i[0]||(i[0]=h=>o.onRowClick(h))}),e.createSlots({default:e.withCtx(()=>[t.selection?(e.openBlock(),e.createBlock(u,{key:0,type:"selection",width:"55"})):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.value,h=>(e.openBlock(),e.createBlock(u,{key:h.prop,prop:h.prop,label:h.label,width:h.width,fixed:h.fixed},{default:e.withCtx(({row:g})=>[Object.keys(g).length>0?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[h.prop==="actions"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[d.value.hasActionsSlot?e.renderSlot(n.$slots,"actions",{row:g,actions:d.value.actionList},void 0,!0,1):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(d.value.actionList,(y,x)=>(e.openBlock(),e.createBlock(f,{key:x,link:"",type:o.actionType(y),disabled:y.disabled===!0,size:"small",onClick:e.withModifiers(N=>o.onRowAction(y,g),["stop"])},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.actionText(y)),1)]),_:2},1032,["type","disabled","onClick"]))),128)),e.renderSlot(n.$slots,"actions-extra",{row:g},void 0,!0)],64)):o.hasColSlot(h.prop)?e.renderSlot(n.$slots,o.colSlotName(h.prop),{row:g,value:o.getNestedValue(g,h.prop),column:h},void 0,!0,1):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:2},e.renderList(t.columns,y=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:y.field},[y.field===h.prop&&o.useFieldView(y)?(e.openBlock(),e.createBlock(j,{key:0,type:y.type,"model-value":o.getNestedValue(g,y.field),"dict-type":y.dictType,mode:y.mode,locale:y.locale,format:y.format,text:y.text,"true-text":y.trueText,"false-text":y.falseText,"use-yes-no":y.useYesNo,"cascader-key":y.cascaderKey,multiline:y.multiline,"default-text":y.defaultText},null,8,["type","model-value","dict-type","mode","locale","format","text","true-text","false-text","use-yes-no","cascader-key","multiline","default-text"])):y.field===h.prop?(e.openBlock(),e.createElementBlock("span",{key:1,class:e.normalizeClass({"table-grid-format":y.format})},e.toDisplayString(o.formatByType(o.getNestedValue(g,y.field),y.format||"")),3)):e.createCommentVNode("",!0)],64))),128))],64)):e.createCommentVNode("",!0)]),_:2},1032,["prop","label","width","fixed"]))),128)),e.renderSlot(n.$slots,"default",{},void 0,!0)]),_:2},[e.renderList(d.value.forwardSlots,h=>({name:h,fn:e.withCtx(g=>[e.renderSlot(n.$slots,h,e.normalizeProps(e.guardReactiveProps(g||{})),void 0,!0)])})),d.value.hasUserEmpty?void 0:{name:"empty",fn:e.withCtx(()=>[i[1]||(i[1]=e.createElementVNode("div",{class:"no-data"},"暂无数据",-1))]),key:"0"}]),1040,["data","loading","row-key","row-class-name","onSelectionChange"])])}}}),[["__scopeId","data-v-d3eed11d"]]),yt={class:"table-pagination"},bt={class:"page-size-select"},wt={class:"total-text"},Ct={key:1,class:"load-more"},kt={key:2,class:"total-text"},xt=k(e.defineComponent({__name:"TablePagination",props:{page:{},pageSize:{},total:{},type:{}},emits:["update:page","update:pageSize"],setup(l,{emit:a}){const t=l,s=a,r=e.computed(()=>({totalPages:Math.ceil(t.total/t.pageSize),showPagination:t.type==="page"&&t.total>0})),c={onPageChange:d=>{s("update:page",d)},onPageSizeChange:d=>{s("update:pageSize",d)}};return(d,m)=>{const o=C.ElPagination,n=C.ElOption,i=C.ElSelect,u=C.ElButton;return e.openBlock(),e.createElementBlock("div",yt,[r.value.showPagination?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createVNode(o,{"current-page":t.page,"page-count":r.value.totalPages,"page-sizes":[10,20,50,100],"page-size":t.pageSize,layout:"total, prev, pager, next, jumper",onCurrentChange:c.onPageChange,onSizeChange:c.onPageSizeChange},null,8,["current-page","page-count","page-size","onCurrentChange","onSizeChange"]),e.createElementVNode("div",bt,[e.createVNode(i,{"model-value":t.pageSize,style:{width:"100px"},onChange:c.onPageSizeChange},{default:e.withCtx(()=>[e.createVNode(n,{value:10,label:"10条/页"}),e.createVNode(n,{value:20,label:"20条/页"}),e.createVNode(n,{value:50,label:"50条/页"}),e.createVNode(n,{value:100,label:"100条/页"})]),_:1},8,["model-value","onChange"]),e.createElementVNode("span",wt,"共 "+e.toDisplayString(t.total)+" 条",1)])],64)):t.type==="auto"?(e.openBlock(),e.createElementBlock("div",Ct,[e.createVNode(u,{disabled:t.page*t.pageSize>=t.total},{default:e.withCtx(()=>[...m[0]||(m[0]=[e.createTextVNode("加载更多",-1)])]),_:1},8,["disabled"])])):t.type==="all"?(e.openBlock(),e.createElementBlock("div",kt,"共 "+e.toDisplayString(t.total)+" 条",1)):e.createCommentVNode("",!0)])}}}),[["__scopeId","data-v-2ca77d18"]]),St={class:"table-detail"},Bt={key:0,class:"detail-header"},Vt={class:"detail-title"},_t={class:"detail-body"},Dt={key:0,class:"detail-status"},Et={key:1,class:"detail-content"},Tt={class:"detail-label"},Pt={class:"detail-value"},$t={key:2,class:"detail-status"},ee=k(e.defineComponent({__name:"TableDetail",props:{showHeader:{type:Boolean},title:{},loading:{type:Boolean},rowData:{},columns:{},emptyText:{},extraMode:{}},setup(l){const a=l,t=e.useSlots(),s=e.computed(()=>!!t["detail-extra"]),r=e.computed(()=>s.value),c=e.computed(()=>!s.value||a.extraMode==="append"),d=e.computed(()=>({showHeader:a.showHeader!==!1,title:a.title||"详情",emptyText:a.emptyText||"暂无数据",hasRow:!!a.rowData})),m={getNestedValue(o,n){if(!o||!n)return"";if(!n.includes("."))return o[n];const i=n.split(".");let u=o;for(const f of i)if(u&&typeof u=="object"&&f in u)u=u[f];else return"";return u}};return(o,n)=>(e.openBlock(),e.createElementBlock("div",St,[d.value.showHeader?(e.openBlock(),e.createElementBlock("div",Bt,[e.createElementVNode("div",Vt,e.toDisplayString(d.value.title),1)])):e.createCommentVNode("",!0),e.createElementVNode("div",_t,[c.value?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[a.loading?(e.openBlock(),e.createElementBlock("div",Dt,"加载中...")):d.value.hasRow?(e.openBlock(),e.createElementBlock("div",Et,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.columns,i=>(e.openBlock(),e.createElementBlock("div",{key:i.field,class:"detail-item"},[e.createElementVNode("div",Tt,e.toDisplayString(i.label),1),e.createElementVNode("div",Pt,[e.createVNode(j,{type:i.type,"model-value":m.getNestedValue(a.rowData,i.field),"dict-type":i.dictType,mode:i.mode,locale:i.locale,format:i.format,text:i.text,"true-text":i.trueText,"false-text":i.falseText,"use-yes-no":i.useYesNo,"cascader-key":i.cascaderKey,multiline:i.multiline,"default-text":i.defaultText},null,8,["type","model-value","dict-type","mode","locale","format","text","true-text","false-text","use-yes-no","cascader-key","multiline","default-text"])])]))),128))])):(e.openBlock(),e.createElementBlock("div",$t,e.toDisplayString(d.value.emptyText),1))],64)):e.createCommentVNode("",!0),r.value?e.renderSlot(o.$slots,"detail-extra",{rowData:a.rowData,columns:a.columns},void 0,!0,1):e.createCommentVNode("",!0)])]))}}),[["__scopeId","data-v-7e47b0ba"]]),Nt={class:"table-body"},Rt={class:"table-container"},ie=k(e.defineComponent({inheritAttrs:!1,__name:"TableRender",props:{formId:{},detailExtraMode:{}},emits:["back","toolbar-action","row-action"],setup(l,{expose:a,emit:t}){const s=["search-extra","search-actions","toolbar-left","toolbar-extra","detail-extra"],r=l,c=e.useAttrs(),d=e.useSlots(),m=t,o=new et,n=e.ref(null),i=e.reactive({searchParams:{},loaded:!1,dictData:{}});e.onMounted(async()=>{r.formId&&await f.loadConfig(r.formId)});const u=e.computed(()=>({tableConfig:o.data.tableConfig,rows:o.data.rows,total:o.data.total,loading:o.data.loading,pagination:o.data.pagination,searchFields:o.getSearchFields(),hasSearch:o.hasSearch(),columns:o.getColumns(),toolbar:o.getToolbar(),hasToolbar:o.hasToolbar(),actions:o.getActions(),currentRow:o.data.currentRow,currentKey:o.getCurrentKey(),showDetail:o.hasDetail(),detailMode:o.getDetailMode(),detailSide:o.getDetailPosition()==="left"?"left":"right",detailWidth:o.getDetailWidth(),detailDirection:o.getDetailDirection(),detailVisible:o.data.detailVisible,detailData:o.data.detailData,detailLoading:o.data.detailLoading,previewMounted:o.data.previewMounted,previewVisible:o.data.previewVisible,previewRow:o.data.previewRow,dictData:i.dictData})),f={getTableAttrs(){const{class:p,style:h,...g}=c;return g},getTableSlots(){const p={};for(const h of Object.keys(d))s.includes(h)||(p[h]=!0);return p},getDetailSlots(){return d["detail-extra"]?["detail-extra"]:[]},getDetailExtraMode(){return r.detailExtraMode==="append"?"append":"replace"},async loadConfig(p){try{await o.loadConfig(p)}catch(h){_((h==null?void 0:h.message)||"获取表格配置失败");return}i.searchParams={...o.data.searchParams},i.loaded=!0,await f.loadDictData(),await f.handleLoadData()},async handleLoadData(){try{await o.loadData()}catch(p){_((p==null?void 0:p.message)||"加载数据失败")}},async loadDictData(){const p=o.getColumns(),h=new Set;for(const g of p)g.type==="dict"&&g.dictType&&h.add(g.dictType);for(const g of h)try{const y=await B().Get(E.dictApi(g));y.status===200&&(i.dictData[g]=O(y.data))}catch(y){console.error(`[TableRender] 加载字典 ${g} 失败:`,y)}},async handleSearch(){o.data.searchParams={...i.searchParams};try{await o.search()}catch(p){_((p==null?void 0:p.message)||"查询失败")}},async handleReset(){i.searchParams={};try{await o.reset()}catch(p){_((p==null?void 0:p.message)||"重置失败")}},updateSearchParam(p,h){i.searchParams[p]=h},async handlePageChange(p){try{await o.changePage(p)}catch(h){_((h==null?void 0:h.message)||"加载数据失败")}},async handlePageSizeChange(p){try{await o.changePageSize(p)}catch(h){_((h==null?void 0:h.message)||"加载数据失败")}},handleRowClick(p){o.setCurrentRow(p)},handleDetailClose(){o.closeDetail()},handleDetailClosed(){o.resetDetail()},handlePreviewClose(){o.closePreview()},handlePreviewClosed(){o.resetPreview()},handlePreview(p){if(!p){D.warning("请先点击表格中的一行数据");return}o.openPreview(p)},handleToolbarAction(p){m("toolbar-action",p),f.dispatchAction(p)},handleRowAction(p){m("row-action",p),f.dispatchAction(p)},async dispatchAction(p){switch(p.action){case"add":await f.handleAdd(p.item);break;case"edit":await f.handleEdit(p.row,p.item);break;case"delete":await f.handleDelete(p.row,p.item);break;case"preview":f.handlePreview(p.row);break;case"back":m("back",p);break;case"export":await f.handleExport();break;default:await f.handleCustomAction(p)}},async handleAdd(p){const h=p?o.getButtonFormId(p):o.getFormId();if(!h){D.warning("未配置表单,无法新增");return}if(!n.value)return;await n.value.showForm(h)!=null&&await f.handleLoadData()},async handleEdit(p,h){if(!p){D.warning("请先点击表格中的一行数据");return}const g=h?o.getButtonFormId(h):o.getFormId();if(!g){D.warning("未配置表单,无法编辑");return}if(!n.value)return;const y=o.getKeyField();await n.value.showForm(g,`${y}=${p[y]}`)!=null&&await f.handleLoadData()},async handleDelete(p,h){if(!p){D.warning("请先点击表格中的一行数据");return}try{await V.ElMessageBox.confirm((h==null?void 0:h.confirm)||"确定要删除这条数据吗?","确认删除",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"})}catch{return}try{await o.deleteRow(p),D.success("删除成功")}catch(g){_((g==null?void 0:g.message)||"删除失败")}},async handleExport(){try{await o.exportData(),D.success("导出成功")}catch(p){_((p==null?void 0:p.message)||"导出失败")}},async handleCustomAction(p){const{item:h,row:g}=p;if(!(h!=null&&h.url)){D.warning(`未识别的按钮动作:${p.action}`);return}try{await V.ElMessageBox.confirm(h.confirm||"确定执行该操作吗?","确认",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"})}catch{return}try{const y=await B().Post(h.url,g||{});if(y.status!==200)throw new Error(y.message||"操作失败");D.success(y.message||"操作成功"),await f.handleLoadData()}catch(y){_((y==null?void 0:y.message)||"操作失败")}}};return a({loadConfig:f.loadConfig}),(p,h)=>{var y,x,N,se,re,ce,de;const g=C.ElDrawer;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["table-render",p.$attrs.class]),style:e.normalizeStyle(p.$attrs.style)},[u.value.hasSearch?(e.openBlock(),e.createBlock(lt,{key:0,fields:u.value.searchFields,modelValue:i.searchParams,"onUpdate:modelValue":h[0]||(h[0]=S=>i.searchParams=S),onSearch:f.handleSearch,onReset:f.handleReset},{"search-extra":e.withCtx(S=>[e.renderSlot(p.$slots,"search-extra",e.normalizeProps(e.guardReactiveProps(S||{})),void 0,!0)]),"search-actions":e.withCtx(S=>[e.renderSlot(p.$slots,"search-actions",e.normalizeProps(e.guardReactiveProps(S||{})),void 0,!0)]),_:3},8,["fields","modelValue","onSearch","onReset"])):e.createCommentVNode("",!0),e.createElementVNode("div",Nt,[e.createElementVNode("div",Rt,[e.createVNode(gt,e.mergeProps(f.getTableAttrs(),{rows:u.value.rows,columns:u.value.columns,loading:u.value.loading,actions:u.value.actions,"actions-width":(y=u.value.tableConfig)==null?void 0:y.actionsWidth,"key-field":(x=u.value.tableConfig)==null?void 0:x.key,"dict-data":u.value.dictData,"active-key":u.value.currentKey,onRowAction:f.handleRowAction,onRowClick:f.handleRowClick}),e.createSlots({_:2},[e.renderList(f.getTableSlots(),(S,P)=>({name:P,fn:e.withCtx(Mt=>[e.renderSlot(p.$slots,P,e.normalizeProps(e.guardReactiveProps(Mt||{})),void 0,!0)])}))]),1040,["rows","columns","loading","actions","actions-width","key-field","dict-data","active-key","onRowAction","onRowClick"]),e.createVNode(xt,{class:"table-pagination",page:u.value.pagination.page,"page-size":u.value.pagination.pageSize,total:u.value.total,type:(N=u.value.tableConfig)==null?void 0:N.pagination,"onUpdate:page":f.handlePageChange,"onUpdate:pageSize":f.handlePageSizeChange},null,8,["page","page-size","total","type","onUpdate:page","onUpdate:pageSize"])]),u.value.showDetail&&u.value.detailMode==="inline"?(e.openBlock(),e.createBlock(ee,{key:0,class:e.normalizeClass(["table-detail-inline",`table-detail-inline-${u.value.detailSide}`]),style:e.normalizeStyle({width:u.value.detailWidth}),title:(re=(se=u.value.tableConfig)==null?void 0:se.meta)==null?void 0:re.title,loading:u.value.detailLoading,"row-data":u.value.detailData,columns:u.value.columns,"empty-text":u.value.detailSide==="left"?"请点击右侧表格行查看详情":"请点击左侧表格行查看详情","extra-mode":f.getDetailExtraMode()},e.createSlots({_:2},[e.renderList(f.getDetailSlots(),S=>({name:S,fn:e.withCtx(P=>[e.renderSlot(p.$slots,S,e.normalizeProps(e.guardReactiveProps(P||{})),void 0,!0)])}))]),1032,["class","style","title","loading","row-data","columns","empty-text","extra-mode"])):e.createCommentVNode("",!0)]),u.value.showDetail&&u.value.detailMode==="drawer"?(e.openBlock(),e.createBlock(g,{key:1,"model-value":u.value.detailVisible,direction:u.value.detailDirection,size:u.value.detailWidth,title:((de=(ce=u.value.tableConfig)==null?void 0:ce.meta)==null?void 0:de.title)||"详情",onClose:f.handleDetailClose,onClosed:f.handleDetailClosed},{default:e.withCtx(()=>[e.createVNode(ee,{"show-header":!1,loading:u.value.detailLoading,"row-data":u.value.detailData,columns:u.value.columns,"extra-mode":f.getDetailExtraMode()},e.createSlots({_:2},[e.renderList(f.getDetailSlots(),S=>({name:S,fn:e.withCtx(P=>[e.renderSlot(p.$slots,S,e.normalizeProps(e.guardReactiveProps(P||{})),void 0,!0)])}))]),1032,["loading","row-data","columns","extra-mode"])]),_:3},8,["model-value","direction","size","title","onClose","onClosed"])):e.createCommentVNode("",!0),u.value.previewMounted?(e.openBlock(),e.createBlock(g,{key:2,"model-value":u.value.previewVisible,direction:u.value.detailDirection,size:u.value.detailWidth,title:"详情",onClose:f.handlePreviewClose,onClosed:f.handlePreviewClosed},{default:e.withCtx(()=>[e.createVNode(ee,{"show-header":!1,"row-data":u.value.previewRow,columns:u.value.columns,"extra-mode":f.getDetailExtraMode()},e.createSlots({_:2},[e.renderList(f.getDetailSlots(),S=>({name:S,fn:e.withCtx(P=>[e.renderSlot(p.$slots,S,e.normalizeProps(e.guardReactiveProps(P||{})),void 0,!0)])}))]),1032,["row-data","columns","extra-mode"])]),_:3},8,["model-value","direction","size","onClose","onClosed"])):e.createCommentVNode("",!0),u.value.hasToolbar?(e.openBlock(),e.createBlock(rt,{key:3,class:"table-toolbar-bottom",items:u.value.toolbar,"current-row":u.value.currentRow,onAction:f.handleToolbarAction},{"toolbar-left":e.withCtx(S=>[e.renderSlot(p.$slots,"toolbar-left",e.normalizeProps(e.guardReactiveProps(S||{})),void 0,!0)]),"toolbar-extra":e.withCtx(S=>[e.renderSlot(p.$slots,"toolbar-extra",e.normalizeProps(e.guardReactiveProps(S||{})),void 0,!0)]),_:3},8,["items","current-row","onAction"])):e.createCommentVNode("",!0),e.createVNode(Z,{ref_key:"formRef",ref:n},null,512)],6)}}}),[["__scopeId","data-v-1d0ae5e9"]]),At={UInput:R,UInputNumber:Q,UDict:I,UToggle:J,UCascader:X,UDate:z,UMenu:ne,FormRender:Z,TableRender:ie,UFieldView:j},It={install(l){l.use(V);for(const[a,t]of Object.entries(At))l.component(a,t)}};b.FormRender=Z,b.GetQf=xe,b.TableRender=ie,b.UCascader=X,b.UDate=z,b.UDict=I,b.UFieldView=j,b.UInput=R,b.UInputNumber=Q,b.UMenu=ne,b.UToggle=J,b.apis=E,b.clearDictCache=_e,b.default=It,b.flattenDictTree=Se,b.getDict=A,b.getQf=B,b.mapDictTree=W,b.normalizeDictNode=q,b.notify=D,b.notifyUtil=M,b.preloadDicts=Ve,b.resolveAppBase=ae,b.setDictCache=De,b.toDictOptions=O,b.translateDict=le,b.translateDictSync=Be,Object.defineProperties(b,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/dist/qf/http.d.ts CHANGED
@@ -1,48 +1,70 @@
1
- import { QfOptions } from './interface.ts';
1
+ import { HttpResponse, QfOptions } from './interface.ts';
2
2
  /**
3
- * 解析「免配」时的默认基地址 —— 也就是「后端 = 前端的 IP + 端口」这件事的兜底实现。
3
+ * 解析「本页面所在**目录**」的绝对地址(不含结尾斜杠)—— 免配模式下接口前缀的推导依据。
4
4
  *
5
- * 优先级(最终由 Http 决定):
6
- * 1. `QfOptions.baseUrl`(public/config/config.json 的 qfOptions.baseUrl)—— 配了就以它为准,
7
- * 用于前后端不同机/不同端口/走网关的场景;
8
- * 2. 本文档自己的地址 `document.baseURI` —— 免配默认值;
9
- * 3. `window.$wujie.location.origin` —— 无界子应用的兜底;
10
- * 4. `window.location.origin` —— 最后兜底。
5
+ * 结果只取决于**页面自己的地址**(`document.baseURI`),与构建/部署方式无关,
6
+ * 所以同一份产物放到任意路径下都能用:
11
7
  *
12
- * ⚠️ 为什么不能直接用 `window.location.origin`(历史写法,已改掉):
13
- * 被无界(wujie)以微前端方式嵌入时,子应用跑在一个 **同源的 `blob:` 空 iframe** 里,
14
- * 那个 iframe 的 location 就是**主应用**的地址 → `window.location.origin` 返回主应用的
15
- * 域名/端口,接口会被打到主应用上去(实测:主应用 8111、子应用 8000,登录请求发成了
16
- * `POST http://127.0.0.1:8111/api/user/Login`,必然失败)。
17
- * 而 `document.baseURI` 描述的是**文档自身**的地址 —— 无界会给子应用注入正确的
18
- * `<base href="子应用地址">`,所以「独立运行」和「被嵌入」两种情况下它都指向子应用自己。
8
+ * | 页面地址 | 返回 |
9
+ * |---|---|
10
+ * | `http://host/` | `http://host` |
11
+ * | `http://host/index.html` | `http://host` |
12
+ * | `http://host/qfcms/` | `http://host/qfcms` |
13
+ * | `http://host/qfcms`(末尾无斜杠,nginx try_files 的常见形态) | `http://host/qfcms` |
14
+ * | `http://host/qfcms/index.html` | `http://host/qfcms` |
19
15
  *
20
- * 只取 origin(不含路径):与前端的部署路径无关,接口一律按「同 IP + 同端口」发。
21
- * 需要带路径/别的域名时,在 config.json 里显式配 baseUrl。
16
+ * 两条容易踩的细节:
17
+ * 1. **只有当最后一段含 `.` 时才当成文件名丢掉**(`index.html` → 丢,`qfcms` → 保留)。
18
+ * 否则访问 `/qfcms`(无斜杠)会被误判成文件,前缀掉成站点根。
19
+ * 2. 不用 `window.location.origin`:无界(wujie)嵌入时子应用跑在同源 `blob:` 空 iframe 里,
20
+ * `window.location` 指向**主应用**(实测把请求发成了 `http://主应用:8111/api/...`)。
21
+ * `document.baseURI` 描述文档自身,无界会注入正确的 `<base href="子应用地址">`,
22
+ * 「独立运行」和「被嵌入」两种情况下都指向子应用自己。
23
+ */
24
+ export declare function resolveAppBase(): string;
25
+ /**
26
+ * 全库**唯一**的 HTTP 客户端(`Qf.WebApi`)。
27
+ *
28
+ * 组件、渲染器、工具函数一律通过 `getQf().Get/Post/...` 发请求,
29
+ * 不再各自 `axios.create`(历史上另有一份 `ts/http.ts`,已删)。
30
+ *
31
+ * 三条约定:
32
+ * 1. **鉴权头是 `token`**,不是 `Authorization`。httptoqfapi 会把全部 HTTP header
33
+ * 合并进请求参数,后端按 `Token` 取用 —— 所以只有 `token` 头能通过鉴权。
34
+ * 2. **响应做「业务码归一化」**:后端恒返回 `{code, message, data}`,`code === 0` 为成功。
35
+ * 这里给成功的响应补一个 `status = 200` 字段,让调用方可以继续写
36
+ * `if (res.status === 200)`(兼容旧后端的 status 字段,两边都认)。
37
+ * 3. **blob 原样返回**:下载/导出走 `Download` / `PostDownload`,拦截器不脱壳,
38
+ * 调用方自己取 `res.data as Blob`。
22
39
  */
23
- export declare function resolveBaseUrl(): string;
24
40
  export declare class Http {
25
41
  private axiosInstance;
26
- private baseUrl;
42
+ private baseCache;
27
43
  constructor(options: QfOptions);
28
44
  /**
29
- * POST 请求
45
+ * GET 请求(params 会被 axios 序列化成 query string)
30
46
  */
31
- Post(url: string, data?: any): Promise<any>;
47
+ Get<T = any>(url: string, params?: any): Promise<HttpResponse<T>>;
32
48
  /**
33
- * GET 请求
49
+ * POST 请求(body 支持普通对象与 FormData;
50
+ * FormData 时 axios 会自动让浏览器设置带 boundary 的 Content-Type)
34
51
  */
35
- Get(url: string, params?: any): Promise<any>;
52
+ Post<T = any>(url: string, data?: any): Promise<HttpResponse<T>>;
36
53
  /**
37
- * DELETE 请求
54
+ * DELETE 请求(参数走 query string,与后端路由约定一致)
38
55
  */
39
- Delete(url: string, params?: any): Promise<any>;
56
+ Delete<T = any>(url: string, params?: any): Promise<HttpResponse<T>>;
40
57
  /**
41
58
  * PUT 请求
42
59
  */
43
- Put(url: string, data?: any): Promise<any>;
60
+ Put<T = any>(url: string, data?: any): Promise<HttpResponse<T>>;
61
+ /**
62
+ * 下载文件(GET + blob)—— 返回**完整 AxiosResponse**,调用方取 `res.data as Blob`
63
+ */
64
+ Download<T = any>(url: string, params?: any): Promise<T>;
44
65
  /**
45
- * 下载文件
66
+ * 下载文件(POST + blob,用于「按查询条件导出」这类接口)——
67
+ * 同样返回完整 AxiosResponse。
46
68
  */
47
- Download(url: string, params?: any): Promise<any>;
69
+ PostDownload<T = any>(url: string, data?: any): Promise<T>;
48
70
  }
@@ -1,12 +1,31 @@
1
+ /**
2
+ * 后端统一响应包。
3
+ *
4
+ * httptoqfapi 恒返回 `{code, message, data}`,`code === 0` 表示成功;
5
+ * Http 的响应拦截器会给成功响应补一个 `status = 200`,所以
6
+ * `if (res.status === 200)` 与 `if (res.code === 0)` 两种写法都可用。
7
+ */
8
+ export interface HttpResponse<T = any> {
9
+ code?: number;
10
+ status?: number;
11
+ message?: string;
12
+ data: T;
13
+ [key: string]: any;
14
+ }
1
15
  export interface QfInterface {
2
16
  On(event: string, callback: any): void;
3
17
  Emit(event: string, data: any): void;
4
18
  Off(event: string, callback: any): void;
5
- Post<T>(url: string, data: any): Promise<T>;
6
- Get<T>(url: string, params: any): Promise<T>;
7
- Delete<T>(url: string, params: any): Promise<T>;
8
- Put<T>(url: string, data: any): Promise<T>;
19
+ Post<T>(url: string, data?: any): Promise<HttpResponse<T>>;
20
+ /** GET;params 可选(省略即不带 query string) */
21
+ Get<T>(url: string, params?: any): Promise<HttpResponse<T>>;
22
+ /** DELETE;参数走 query string */
23
+ Delete<T>(url: string, params?: any): Promise<HttpResponse<T>>;
24
+ Put<T>(url: string, data?: any): Promise<HttpResponse<T>>;
25
+ /** 下载(GET + blob):返回**完整 AxiosResponse**,调用方取 .data as Blob */
9
26
  Download<T>(url: string, params?: any): Promise<T>;
27
+ /** 导出(POST + blob):返回**完整 AxiosResponse**,调用方取 .data as Blob */
28
+ PostDownload<T>(url: string, data?: any): Promise<T>;
10
29
  RegNotice(topic: string, cb: (data: any) => void): void;
11
30
  }
12
31
  export interface QfOptions {