urit-qf-ui 0.2.6 → 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.
- package/dist/index.d.ts +4 -4
- package/dist/index.js +730 -743
- package/dist/index.umd.cjs +2 -2
- package/dist/qf/http.d.ts +50 -28
- package/dist/qf/interface.d.ts +23 -4
- package/dist/qf/qf.d.ts +30 -6
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/index.umd.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(b,B){typeof exports=="object"&&typeof module<"u"?B(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"],B):(b=typeof globalThis<"u"?globalThis:b||self,B(b.UritQfUI={},b.ElementPlus,b.ElementPlus,b.ElementPlus,b.ElementPlus,b.ElementPlus,b.Vue,b.ElementPlus,b.ElementPlus,b.ElementPlus,b.axios,b.ElementPlus,b.ElementPlus,b.ElementPlus,b.ElementPlus,b.ElementPlus,b.ElementPlus,b.ElementPlus,b.ElementPlus,b.ElementPlus,b.ElementPlusIconsVue,b.ElementPlus,b.ElementPlus,b.ElementPlus,b.ElementPlus,b.mitt,b.mqtt))})(this,function(b,B,M,C,Mt,Ut,e,zt,Ft,Lt,ee,qt,Wt,Ot,jt,Yt,Qt,Kt,Ht,Gt,te,Jt,Xt,Zt,vt,de,me){"use strict";var At=Object.defineProperty;var It=(b,B,M)=>B in b?At(b,B,{enumerable:!0,configurable:!0,writable:!0,value:M}):b[B]=M;var w=(b,B,M)=>It(b,typeof B!="symbol"?B+"":B,M);const ue=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,s=a,c=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}),d=e.computed(()=>({"u-input-label-left":t.labelPosition==="left","u-input-label-top":t.labelPosition==="top"})),r={onInput(m){s("update:modelValue",m)}};return(m,o)=>{const l=C.ElInput;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["u-input",d.value])},[n.fieldLabel?(e.openBlock(),e.createElementBlock("div",{key:0,class:"u-input-label",style:e.normalizeStyle(c.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(l,{"model-value":n.modelValue,placeholder:n.placeholder,type:n.type,disabled:n.disable,readonly:n.readonly,maxlength:n.maxlength,"onUpdate:modelValue":r.onInput},null,8,["model-value","placeholder","type","disabled","readonly","maxlength","onUpdate:modelValue"])],2)],2)}}}),k=(n,a)=>{const t=n.__vccOpts||n;for(const[s,c]of a)t[s]=c;return t},N=k(ue,[["__scopeId","data-v-ecf5177c"]]),pe={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,s=a,c=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}),d=e.computed(()=>({"u-input-number-label-left":t.labelPosition==="left","u-input-number-label-top":t.labelPosition==="top"})),r={onUpdate(m){s("update:modelValue",m===void 0?0:m)}};return(m,o)=>{const l=C.ElInputNumber;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["u-input-number",d.value])},[n.fieldLabel?(e.openBlock(),e.createElementBlock("div",{key:0,class:"u-input-number-label",style:e.normalizeStyle(c.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",pe,[e.createVNode(l,{"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:r.onUpdate},null,8,["model-value","placeholder","disabled","min","max","step","precision","onChange"])])],2)}}}),[["__scopeId","data-v-cb70bd5b"]]),U=ee.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,s=t===0||t===200||Number(t)===0||Number(t)===200;a.status=s?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,s;const a=((s=(t=n.response)==null?void 0:t.data)==null?void 0:s.message)||n.message||"请求失败";return console.error("[HTTP Error]",a),Promise.reject(n)});const V={get(n,a){return U.get(n,a).then(t=>t.data)},post(n,a,t){return U.post(n,a,t).then(s=>s.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),s=a.children;return Array.isArray(s)&&s.length>0&&(t.children=q(s)),t}):[]}function W(n){return Array.isArray(n)?n.filter(a=>a&&typeof a=="object").map(a=>L(a)):[]}function fe(n){if(!Array.isArray(n))return[];const a=[],t=s=>{for(const c of s){if(!c||typeof c!="object")continue;const d=c.children;a.push(L(c)),Array.isArray(d)&&d.length>0&&t(d)}};return t(n),a}async function R(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 V.get(D.dictApi(n));if(t.status===200){const s=W(t.data);return T[n]=s,s}return[]}catch(t){return console.error(`[dict] 加载字典 ${n} 失败:`,t),[]}finally{delete F[n]}})();return F[n]=a,a}async function ae(n,a,t=""){if(a==null||a==="")return t;const s=T[n];if(s&&s.length>0)return K(s,a);const c=await R(n);return c&&c.length>0?K(c,a):t||String(a)}function K(n,a){const t=n.find(s=>s.value===a||String(s.value)===String(a));return t?t.label:String(a)}function he(n,a,t=""){if(a==null||a==="")return t;const s=T[n];return s&&s.length>0?K(s,a):t||String(a)}async function ge(n){await Promise.all(n.map(a=>R(a)))}function ye(n){n?delete T[n]:Object.keys(T).forEach(a=>{delete T[a]})}function be(n,a){T[n]=a}const we={class:"u-dict-field"},A=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,s=a,c=e.reactive({excluded:["fieldLabel","labelPosition","labelWidth","labelAlign","required","modelValue","dictType"],options:[],loading:!1}),d=async()=>{if(t.dictType){c.loading=!0;try{const l=await V.get(D.dictApi(t.dictType));l.status===200?c.options=W(l.data):(console.error("[UDict] 请求失败:",l.message),c.options=[])}catch(l){console.error("[UDict] 加载字典失败:",l),c.options=[]}finally{c.loading=!1}}};e.watch(()=>t.dictType,()=>{d()},{immediate:!0});const r=e.computed(()=>{const l={};return t.labelPosition==="left"&&t.labelWidth&&(l.width=typeof t.labelWidth=="number"?`${t.labelWidth}px`:t.labelWidth),t.labelAlign&&(l.textAlign=t.labelAlign),l}),m=e.computed(()=>({"u-dict-label-left":t.labelPosition==="left","u-dict-label-top":t.labelPosition==="top"})),o={onUpdate(l){s("update:modelValue",l)}};return(l,i)=>{const u=C.ElOption,f=C.ElSelect;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["u-dict",m.value])},[n.fieldLabel?(e.openBlock(),e.createElementBlock("div",{key:0,class:"u-dict-label",style:e.normalizeStyle(r.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",we,[e.createVNode(f,{"model-value":n.modelValue,placeholder:n.placeholder||"请选择",loading:c.loading,disabled:n.disable,style:{width:"100%"},onChange:o.onUpdate},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.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-8bfd4dcf"]]),Ce={class:"u-toggle-field"},H=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,s=a,c=e.reactive({excluded:["fieldLabel","labelPosition","labelWidth","labelAlign","required","modelValue","trueValue","falseValue","activeText","inactiveText","activeColor","inactiveColor"]}),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},r=e.computed({get:()=>t.modelValue===t.trueValue,set:o=>{s("update:modelValue",o?t.trueValue:t.falseValue)}}),m=e.computed(()=>{const o={};for(const l in t)!c.excluded.includes(l)&&l!=="modelValue"&&(o[l]=t[l]);return o});return(o,l)=>{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(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,e.mergeProps({modelValue:r.value,"onUpdate:modelValue":l[0]||(l[0]=u=>r.value=u)},m.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"]]),ke={class:"u-cascader-levels"},G=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,s=a,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.ref([]),r=e.computed(()=>{const o=[];let l=t.options||[];for(let i=0;i<t.depth;i++)if(o.push(l),d.value[i]!==void 0){const u=l.find(f=>f.value===d.value[i]);u&&u.children?l=u.children:l=[]}else l=[];return o});e.watch(()=>t.modelValue,o=>{o!=null?d.value=Array.isArray(o)?o:[o]:d.value=[]},{immediate:!0});const m=(o,l)=>{d.value[o]=l;for(let u=o+1;u<t.depth;u++)d.value[u]=void 0;const i=d.value.filter(u=>u!==void 0);s("update:modelValue",i)};return(o,l)=>{const i=C.ElOption,u=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(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",ke,[(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(u,{"model-value":d.value[f-1],options:r.value[f-1]||[],disabled:f>1&&d.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(r.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"]]),xe={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,s=a,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.ref("");e.watch(()=>t.modelValue,o=>{t.mode==="single"?d.value=o||"":t.mode==="multiple"?d.value=Array.isArray(o)?o:o?[o]:[]:t.mode==="range"&&(o&&typeof o=="object"&&o.from&&o.to?d.value=[o.from,o.to]:d.value=[])},{immediate:!0});const r=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,l)=>{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(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",xe,[e.createVNode(i,{modelValue:d.value,"onUpdate:modelValue":l[0]||(l[0]=u=>d.value=u),type:m.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:r},null,8,["modelValue","type","placeholder","range-separator","start-placeholder","end-placeholder","format","value-format"])])],2)}}}),[["__scopeId","data-v-9cd05064"]]);function I(n,a="info"){B.ElMessage({message:n,type:a,duration:1e3,showClose:!1})}function _(n){B.ElMessage({message:n,type:"error",duration:2e3,showClose:!1})}function Se(n){I(n,"success")}function Be(n){I(n,"error")}function Ve(n){I(n,"warning")}function _e(n){I(n,"info")}const E={notify:I,success:Se,error:Be,warning:Ve,info:_e,alertError:_},Ee={key:0,class:"u-menu-brand"},De=["src"],Te={class:"u-menu-brand-text"},Pe={key:1,class:"u-menu-logout"},oe=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 s=n,c=t,d=e.reactive({config:null,menus:[],activePath:"",iconMap:{},iconsLoaded:!1}),r=e.computed(()=>{var o,l,i,u,f,p,h,g;return{projectName:s.projectName??((o=d.config)==null?void 0:o.projectName)??"",logo:((l=d.config)==null?void 0:l.logo)||"",mode:s.mode??((i=d.config)==null?void 0:i.mode)??"sidebar",isHorizontal:(s.mode??((u=d.config)==null?void 0:u.mode)??"sidebar")==="horizontal",elMode:(s.mode??((f=d.config)==null?void 0:f.mode)??"sidebar")==="horizontal"?"horizontal":"vertical",width:s.width??((p=d.config)==null?void 0:p.width)??220,menus:d.menus,activeIndex:m.getIndexByPath(d.activePath),showLogout:((h=d.config)==null?void 0:h.showLogout)!==!1,logoutText:((g=d.config)==null?void 0:g.logoutText)||"退出登录",iconMap:d.iconMap}}),m={async init(){await m.ensureIcons(),s.config?(d.config=s.config,d.menus=m.normalizeMenus(s.config.menus)):await m.loadConfig(s.menuId),d.activePath=s.activePath||d.activePath},async loadConfig(o){if(o)try{const l=await V.get(D.formCfgApi(o,"menus"));if(l.status!==200){_(l.message||"获取菜单配置失败");return}const i=l.data||{};d.config=i,i.dictType?await m.loadDictMenus(i.dictType):d.menus=m.normalizeMenus(i.menus)}catch(l){_((l==null?void 0:l.message)||"获取菜单配置失败"),d.menus=[]}},async loadDictMenus(o){try{const l=await V.get(D.cascaderApi(o));if(l.status!==200){_(l.message||"获取菜单字典失败");return}d.menus=m.normalizeMenus(q(l.data))}catch(l){_((l==null?void 0:l.message)||"获取菜单字典失败"),d.menus=[]}},normalizeMenus(o){return Array.isArray(o)?o.map(l=>m.normalizeMenuNode(l)).filter(Boolean):[]},normalizeMenuNode(o){if(!o||typeof o!="object")return null;const l=m.parseInfo(o.info),i=o.label??o.dict_value??o.name;if(!i)return null;const u=l.path??o.path??o.dict_code??o.value??"",f=l.type??o.type??"route",p={...o,label:String(i),type:f,path:String(u??""),icon:l.icon??o.icon??""},h=l.id??o.id;h!=null&&h!==""&&(p.id=String(h));const g=l.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 l=JSON.parse(o);return l&&typeof l=="object"?l:{}}catch{return{path:o}}return{}},itemIndex(o,l){return o.path||`menu-${l}`},childIndex(o,l,i,u){return i.path?i.path:`${m.itemIndex(o,l)}-${u}`},hasChildren(o){return Array.isArray(o.children)&&o.children.length>0},getIndexByPath(o){if(!o)return"";for(let l=0;l<d.menus.length;l++){const i=d.menus[l];if(i.path===o)return m.itemIndex(i,l);const u=i.children||[];for(let f=0;f<u.length;f++)if(u[f].path===o)return m.childIndex(i,l,u[f],f)}return""},findItemByIndex(o,l){for(let i=0;i<d.menus.length;i++){const u=d.menus[i],f=m.itemIndex(u,i);if(f===o)return{item:u,level:1,indexPath:l||[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:l||[f,y],index:o}}}return null},resolveTarget(o){const l=o.type||"route",i=o.path||"";return l==="url"?{type:l,path:i,url:i,open:o.open||"new"}:l==="form"||l==="table"||l==="menu"?{type:l,path:i,id:o.id||i}:{type:"route",path:i,route:i}},handleSelect(o,l){const i=m.findItemByIndex(o,l);if(!i||m.hasChildren(i.item))return;const u=m.resolveTarget(i.item);d.activePath=i.item.path||o;const f={...u,item:i.item,level:i.level,indexPath:i.indexPath,index:o};c("menu-click",f)},handleLogout(){c("logout")},setActivePath(o){d.activePath=o},async ensureIcons(){if(!d.iconsLoaded){d.iconsLoaded=!0;try{const o=await import("@element-plus/icons-vue"),l=o!=null&&o.default?{...o.default,...o}:{...o},i={};for(const[u,f]of Object.entries(l))i[u]=e.markRaw(f);d.iconMap=i}catch(o){console.warn("[UMenu] @element-plus/icons-vue 不可用,菜单图标将被忽略",o)}}},getIcon(o){return o&&d.iconMap[o]||null}};return e.watch(()=>s.menuId,o=>{s.config||m.loadConfig(o)}),e.watch(()=>s.activePath,o=>{d.activePath=o||""}),e.watch(()=>s.config,o=>{o&&(d.config=o,d.menus=m.normalizeMenus(o.menus))}),e.onMounted(()=>{m.init()}),a({loadConfig:m.loadConfig,setActivePath:m.setActivePath}),(o,l)=>{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--${r.value.mode}`,{"u-menu--no-brand":!r.value.projectName}]]),style:e.normalizeStyle(r.value.isHorizontal?{}:{width:r.value.width+"px"})},[r.value.projectName?(e.openBlock(),e.createElementBlock("div",Ee,[e.renderSlot(o.$slots,"brand",{projectName:r.value.projectName,mode:r.value.mode},()=>[r.value.logo?(e.openBlock(),e.createElementBlock("img",{key:0,class:"u-menu-logo",src:r.value.logo,alt:"logo"},null,8,De)):e.createCommentVNode("",!0),e.createElementVNode("span",Te,e.toDisplayString(r.value.projectName),1)],!0)])):e.createCommentVNode("",!0),e.createVNode(p,{class:"u-menu-list",mode:r.value.elMode,"default-active":r.value.activeIndex,"unique-opened":!r.value.isHorizontal,onSelect:m.handleSelect},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.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,$)=>(e.openBlock(),e.createBlock(u,{key:m.childIndex(g,y,x,$),index:m.childIndex(g,y,x,$)},{default:e.withCtx(()=>[e.renderSlot(o.$slots,"menu-item",{item:x,level:2,index:$,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"]),r.value.showLogout?(e.openBlock(),e.createElementBlock("div",Pe,[e.renderSlot(o.$slots,"logout",{mode:r.value.mode},()=>[e.createVNode(h,{class:"u-menu-logout-btn",text:"",onClick:m.handleLogout},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(r.value.logoutText),1)]),_:1},8,["onClick"])],!0)])):e.createCommentVNode("",!0)],6)}}}),[["__scopeId","data-v-fe63251c"]]),$e={class:"form-content"},Ne={key:1,class:"form-layout"},Re={key:0,class:"form-header"},Ae={class:"title"},Ie={class:"form-body"},Me={key:1,class:"form-footer"},Ue=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,s=a,{visible:c}=e.toRefs(t),d=e.computed(()=>t.layout.open==="normal"),r=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,l)=>{const i=C.ElIcon,u=C.ElDialog;return d.value?e.unref(c)?(e.openBlock(),e.createElementBlock("div",Ne,[n.title?(e.openBlock(),e.createElementBlock("div",Re,[e.createElementVNode("div",Ae,e.toDisplayString(n.title),1)])):e.createCommentVNode("",!0),e.createElementVNode("div",Ie,[n.loading?(e.openBlock(),e.createBlock(i,{key:0,class:"is-loading",size:40},{default:e.withCtx(()=>[e.createVNode(e.unref(te.Loading))]),_:1})):e.renderSlot(o.$slots,"default",{},void 0,!0,1)]),o.$slots.actions?(e.openBlock(),e.createElementBlock("div",Me,[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(c),title:n.title,width:r.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",$e,[n.loading?(e.openBlock(),e.createBlock(i,{key:0,class:"is-loading",size:40},{default:e.withCtx(()=>[e.createVNode(e.unref(te.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"]]),ze=k(e.defineComponent({__name:"FormGrid",props:{fields:{},layout:{}},setup(n){const a=n,t=e.reactive({columns:e.computed(()=>a.layout.columns||1)}),s={getColSpan(c){const d=c.colSpan||1;return Math.min(d,t.columns)}};return(c,d)=>(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,r=>(e.openBlock(),e.createElementBlock("div",{key:r.field,class:"form-grid-item",style:e.normalizeStyle({gridColumn:`span ${s.getColSpan(r)}`})},[e.renderSlot(c.$slots,"default",{field:r},void 0,!0)],4))),128))],4))}}),[["__scopeId","data-v-90ed35a4"]]),Fe={class:"form-field"},Le=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,s=a,c=e.reactive({componentMap:e.markRaw({input:N,"input-number":Q,dict:A,switch:H,cascader:G,date:z}),cascaderOptions:[]}),d=()=>{t.field.cascaderKey&&V.get(D.cascaderApi(t.field.cascaderKey)).then(i=>{i.status===200&&(c.cascaderOptions=q(i.data))})};e.watch(()=>t.field.cascaderKey,d,{immediate:!0});const r=e.computed(()=>c.componentMap[t.field.type]||N),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=c.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}),l={handleUpdate(i){s("update:modelValue",i)}};return(i,u)=>(e.openBlock(),e.createElementBlock("div",Fe,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(r.value),e.mergeProps(o.value,{"onUpdate:modelValue":l.handleUpdate}),null,16,["onUpdate:modelValue"])),e.createElementVNode("div",{class:e.normalizeClass(["field-error",{"field-error--visible":n.error}]),style:e.normalizeStyle(m.value)},e.toDisplayString(n.error||""),7)]))}}),[["__scopeId","data-v-10299c8d"]]);class qe{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 We=class{constructor(){w(this,"data",e.reactive(new qe))}parseQuery(a){if(!a)return{};const t={},s=a.split("&");for(const c of s){const[d,r]=c.split("=");d&&(t[d]=r||"")}return t}async fetchFormConfig(a){const t=await V.get(D.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,c=await V.get(s);if(c.status!==200)throw new Error(c.message||"获取表单数据失败");return c.data}async submitForm(a,t){return await V.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 c=this.data.formData[s.field];if(s.required&&(c==null||c==="")){this.data.errors.push({field:s.field,message:`${s.label}为必填项`});continue}if(s.rules&&s.rules.length>0&&c){for(const d of s.rules)if(d.pattern&&!new RegExp(d.pattern).test(c)){this.data.errors.push({field:s.field,message:d.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 c=await this.fetchFormData(s.api.get,t),d=this.nestedToFlat(c);this.data.formData={...this.data.formData,...d}}}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 c=await this.submitForm(t,s);if(c.status===200)return c.data;throw new Error(c.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 c=a[s];if(s.includes(".")){const d=s.split(".");let r=t;for(let m=0;m<d.length-1;m++){const o=d[m];r[o]||(r[o]={}),r=r[o]}r[d[d.length-1]]=c}else t[s]=c}return t}nestedToFlat(a,t=""){const s={};for(const c in a){const d=a[c],r=t?`${t}.${c}`:c;d&&typeof d=="object"&&!Array.isArray(d)?Object.keys(d).length===2&&"from"in d&&"to"in d?s[r]=d:Object.assign(s,this.nestedToFlat(d,r)):s[r]=d}return s}};const J=k(e.defineComponent({__name:"FormRender",setup(n,{expose:a}){const t=new We,s=e.ref(null),c=e.reactive({currentQuery:{},submitResolve:null}),d=e.computed(()=>{var p;const f={};if(!t.data.isEditMode||!c.currentQuery)return f;for(const h of((p=t.data.formConfig)==null?void 0:p.fields)||[])c.currentQuery[h.field]!==void 0&&(f[h.field]=!0);return f}),r=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)||"表单"}),l=e.computed(()=>r.value.buttonAlign||"right"),i=e.computed(()=>r.value.open==="normal"),u={async showForm(f,p){c.currentQuery=t.parseQuery(p||"");try{await t.openForm(f,p)}catch(h){return _((h==null?void 0:h.message)||"打开表单失败"),null}return new Promise(h=>{c.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 E.success(g),c.submitResolve&&(c.submitResolve(h),c.submitResolve=null),i.value||t.closeForm(),h}catch(h){return c.submitResolve&&(c.submitResolve(null),c.submitResolve=null),h!=null&&h.message&&h.message!=="请完善表单信息"&&_(h.message),null}},resolvePending(){c.submitResolve&&(c.submitResolve(null),c.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(Ue,{visible:e.unref(t).data.visible,"onUpdate:visible":p[0]||(p[0]=y=>e.unref(t).data.visible=y),layout:r.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",l.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(ze,{fields:m.value,layout:r.value},{default:e.withCtx(({field:y})=>[e.createVNode(Le,{modelValue:e.unref(t).data.formData[y.field],"onUpdate:modelValue":x=>e.unref(t).data.formData[y.field]=x,field:y,layout:r.value,disabled:d.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 Oe{constructor(a){this.config=a}async fetchList(a,t){const s={page:t.page,pageSize:t.pageSize,...a},c={};for(const o in s){const l=s[o];l!==""&&l!==null&&l!==void 0&&(c[o]=l)}const d=new URLSearchParams;for(const o in c)d.append(o,String(c[o]));const r=`${this.config.api.list}${d.toString()?"?"+d.toString():""}`,m=await V.get(r);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],c=`${this.config.api.delete}?${encodeURIComponent(t)}=${encodeURIComponent(String(s??""))}`,d=await V.post(c);if(d.status!==200)throw new Error(d.message||"删除失败")}async batchDelete(a){if(!this.config.api.delete)throw new Error("未配置删除API");const t=await V.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 V.post(this.config.api.export,a,{responseType:"blob"})).data,c=window.URL.createObjectURL(s),d=document.createElement("a");d.href=c,d.download=`export_${Date.now()}.xlsx`,d.click(),window.URL.revokeObjectURL(c)}async downloadTemplate(){if(!this.config.api.import)throw new Error("未配置导入API");const t=(await V.get(`${this.config.api.import}/template`,{responseType:"blob"})).data,s=window.URL.createObjectURL(t),c=document.createElement("a");c.href=s,c.download=`template_${Date.now()}.xlsx`,c.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 V.post(this.config.api.import,t,{headers:{"Content-Type":"multipart/form-data"}});if(s.status!==200)throw new Error(s.message||"导入失败");return s.data}}class je{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 Ye=class{constructor(){w(this,"data",e.reactive(new je));w(this,"dataService",null)}async loadConfig(a){var c;const t=D.formCfgApi(a,"tables");console.log("load config url =",t);const s=await V.get(t);if(console.log("---"),s.status!==200)throw new Error(s.message||"获取表格配置失败");this.data.tableConfig=s.data,this.dataService=new Oe(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:(c=this.data.tableConfig)==null?void 0:c.detail}),this.initSearchParams()}initSearchParams(){var s;const a={},t=((s=this.data.tableConfig)==null?void 0:s.search)||[];for(const c of t)a[c.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(),c=d=>d&&this.data.rows.find(r=>r[s]===d[s])||null;this.data.currentRow=c(a),this.data.detailData&&(this.data.detailData=c(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 Qe={class:"table-search"},Ke={class:"search-fields"},He={class:"search-actions"},Ge=k(e.defineComponent({__name:"TableSearch",props:{fields:{},modelValue:{}},emits:["update:modelValue","search","reset"],setup(n,{emit:a}){const t=n,s=a,c={input:N,dict:A,dept:A,role:A,date:z,daterange:z},d={getComponent(r){return c[r]||N},updateValue(r,m){const o={...t.modelValue,[r]:m};s("update:modelValue",o)},handleSearch(){const r={};for(const m in t.modelValue){const o=t.modelValue[m];r[m]=typeof o=="string"?o.trim():o}s("update:modelValue",r),s("search")},handleReset(){s("reset")}};return(r,m)=>{const o=C.ElButton;return e.openBlock(),e.createElementBlock("div",Qe,[e.createElementVNode("div",Ke,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.fields,l=>(e.openBlock(),e.createElementBlock("div",{key:l.field,class:"search-field"},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(d.getComponent(l.type)),{"model-value":t.modelValue[l.field],"field-label":l.label,"dict-type":l.dictType,mode:l.type==="daterange"?"range":void 0,"label-position":"left","onUpdate:modelValue":i=>d.updateValue(l.field,i)},null,8,["model-value","field-label","dict-type","mode","onUpdate:modelValue"]))]))),128)),e.renderSlot(r.$slots,"search-extra",{params:t.modelValue,update:d.updateValue},void 0,!0)]),e.createElementVNode("div",He,[e.createVNode(o,{type:"primary",onClick:d.handleSearch},{default:e.withCtx(()=>[...m[0]||(m[0]=[e.createTextVNode("查询",-1)])]),_:1},8,["onClick"]),e.createVNode(o,{onClick:d.handleReset},{default:e.withCtx(()=>[...m[1]||(m[1]=[e.createTextVNode("重置",-1)])]),_:1},8,["onClick"]),e.renderSlot(r.$slots,"search-actions",{params:t.modelValue,search:d.handleSearch,reset:d.handleReset},void 0,!0)])])}}}),[["__scopeId","data-v-0281d2ce"]]),Je={class:"table-toolbar"},Xe={class:"toolbar-items"},Ze={key:1},ve=k(e.defineComponent({__name:"TableToolbar",props:{items:{},currentRow:{}},emits:["action"],setup(n,{emit:a}){const t=n,s=a,c=e.reactive({iconMap:{}}),d=e.computed(()=>({hasCurrentRow:!!t.currentRow})),r={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:r.needRow(m.action)&&!d.value.hasCurrentRow},getIcon(m){return m.icon?c.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=await import("@element-plus/icons-vue"),l={...c.iconMap};for(const i of m)o[i]&&(l[i]=e.markRaw(o[i]));c.iconMap=e.markRaw(l)}};return e.onMounted(()=>{r.ensureIcons()}),e.watch(()=>t.items,()=>{r.ensureIcons()}),(m,o)=>{const l=C.ElIcon,i=C.ElButton;return e.openBlock(),e.createElementBlock("div",Je,[e.renderSlot(m.$slots,"toolbar-left",{currentRow:t.currentRow},void 0,!0),e.createElementVNode("div",Xe,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.items,(u,f)=>(e.openBlock(),e.createBlock(i,{key:f,type:r.getButtonType(u),disabled:r.isDisabled(u),onClick:p=>r.handleClick(u)},{default:e.withCtx(()=>[r.getIcon(u)?(e.openBlock(),e.createBlock(l,{key:0},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(r.getIcon(u))))]),_:2},1024)):e.createCommentVNode("",!0),r.getText(u)?(e.openBlock(),e.createElementBlock("span",Ze,e.toDisplayString(r.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-0538c013"]]),et=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)),s=e.computed(()=>a.multiline||t.value.includes(`
|
|
2
|
-
`)),c=e.computed(()=>a.maxLines>0&&s.value?{display:"-webkit-box",WebkitLineClamp:a.maxLines,WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis"}:{});return(d,r)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["u-input-show",{"u-input-multiline":s.value}]),style:e.normalizeStyle(c.value)},e.toDisplayString(t.value),7))}}),[["__scopeId","data-v-c78b151e"]]),tt=k(e.defineComponent({__name:"UDictShow",props:{modelValue:{},dictType:{},defaultText:{default:""}},setup(n){const a=n,t=e.ref(""),s=e.ref(!1),c=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 d=await ae(a.dictType,a.modelValue,a.defaultText);t.value=d}catch(d){console.error("[UDictShow] 翻译失败:",d),t.value=String(a.modelValue)}finally{s.value=!1}};return e.watch(()=>a.modelValue,c,{immediate:!0}),e.watch(()=>a.dictType,()=>{a.dictType&&R(a.dictType).then(()=>c())}),e.onMounted(()=>{a.dictType?R(a.dictType).then(()=>c()):c()}),(d,r)=>(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"]]),at=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),s=e.computed(()=>a.useYesNo?"否":a.falseText),c=e.computed(()=>a.modelValue===!0||a.modelValue==="true"?t.value:a.modelValue===!1||a.modelValue==="false"?s.value:String(a.modelValue??"")),d=e.computed(()=>a.modelValue===!0||a.modelValue==="true"?"toggle-true":a.modelValue===!1||a.modelValue==="false"?"toggle-false":"toggle-default");return(r,m)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["u-toggle-show",d.value])},e.toDisplayString(c.value),3))}}),[["__scopeId","data-v-bac05efc"]]),ot=k(e.defineComponent({__name:"UCascaderShow",props:{modelValue:{},cascaderKey:{},separator:{default:" / "},showRawValue:{type:Boolean,default:!0}},setup(n){const a=n,t=e.ref(""),s=e.ref(!1),c=async()=>{if(!a.modelValue||!Array.isArray(a.modelValue)){t.value="";return}const d=a.modelValue;if(a.cascaderKey){s.value=!0;try{const r=await R(a.cascaderKey),o=d.map(l=>{const i=r.find(u=>u.value===l||String(u.value)===String(l));return i?i.label:a.showRawValue?String(l):""}).filter(l=>l!=="");t.value=o.join(a.separator)}catch(r){console.error("[UCascaderShow] 翻译失败:",r),t.value=a.showRawValue?d.join(a.separator):""}finally{s.value=!1}}else t.value=d.join(a.separator)};return e.watch(()=>a.modelValue,c,{immediate:!0}),e.onMounted(()=>{c()}),(d,r)=>(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"]]),nt=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),s=e.computed(()=>{const r=a.modelValue;return a.mode==="single"?r?c(r,a.format):"":a.mode==="multiple"?r?Array.isArray(r)?r.map(m=>c(m,a.format)).join(t.value):String(r):"":a.mode==="range"?r?typeof r=="object"&&r.from&&r.to?`${c(r.from,a.format)}${t.value}${c(r.to,a.format)}`:Array.isArray(r)&&r.length>=2?`${c(r[0],a.format)}${t.value}${c(r[1],a.format)}`:String(r):"":String(r??"")});function c(r,m){return r||""}const d=e.computed(()=>!s.value);return(r,m)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["u-date-show",{"u-date-empty":d.value}])},e.toDisplayString(s.value||(n.locale==="en-US"?"Empty":"暂无")),3))}}),[["__scopeId","data-v-930657df"]]),O=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 r=a.text.split("/");return r.length>=2?{trueText:r[0].trim(),falseText:r[1].trim()}:null}),s=e.computed(()=>{var r;return a.trueText||((r=t.value)==null?void 0:r.trueText)||"开启"}),c=e.computed(()=>{var r;return a.falseText||((r=t.value)==null?void 0:r.falseText)||"关闭"}),d=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(r,m)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(d.value==="UDictShow"?tt:d.value==="UToggleShow"?at:d.value==="UCascaderShow"?ot:d.value==="UDateShow"?nt:et),{"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"?s.value:void 0,"false-text":n.type==="switch"?c.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-05ef52d9"]]),lt={class:"table-grid"},X="col-",it=160,st=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(n,{emit:a}){const t=n,s=e.useSlots(),c=a;function d(l){return l==="actions"||l==="actions-extra"||l.startsWith(X)}const r=e.computed(()=>{var l,i;return{actionList:t.actions||[],actionColumnWidth:t.actionsWidth??((l=t.actions)!=null&&l.length?o.getActionColumnWidth():it),hasUserEmpty:!!s.empty,forwardSlots:Object.keys(s).filter(u=>u!=="default"&&!d(u)),colSlots:Object.keys(s).filter(u=>u.startsWith(X)),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 l=t.columns.map(i=>{const u={prop:i.field,label:i.label};return typeof i.width=="number"&&(u.width=i.width),u});return r.value.showActionColumn&&l.push({prop:"actions",label:"操作",width:r.value.actionColumnWidth,fixed:"right"}),l}),o={colSlotName(l){return X+l},hasColSlot(l){return r.value.colSlots.includes(o.colSlotName(l))},actionText(l){return l.text?l.text:{add:"新增",edit:"编辑",delete:"删除",preview:"预览",back:"返回"}[l.action]||""},actionType(l){return l.style?l.style==="default"?"":l.style:{add:"primary",edit:"primary",delete:"danger",preview:"primary",back:"primary"}[l.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(l){return!l||l.length<7?l:l.replace(/(\d{3})\d{4}(\d{4})/,"$1****$2")},maskIdCard(l){return!l||l.length<8?l:l.replace(/(\d{3})\d{11}(\d{4})/,"$1***********$2")},formatMoney(l){const i=Number(l);return isNaN(i)?String(l):i.toLocaleString("zh-CN",{minimumFractionDigits:2,maximumFractionDigits:2})},formatByType(l,i){if(!l)return"";switch(i){case"phone":return o.maskPhone(l);case"idcard":return o.maskIdCard(l);case"money":return o.formatMoney(l);case"percent":return String(l*100)+"%";default:return i&&i.includes("{}")?i.replace("{}",String(l)):String(l)}},getNestedValue(l,i){if(!i.includes("."))return l[i];const u=i.split(".");let f=l;for(const p of u)if(f&&typeof f=="object"&&p in f)f=f[p];else return;return f},useFieldView(l){return l.type?["dict","switch","cascader","date","input","text"].includes(l.type):!1},rowClassName({row:l}){if(!l||t.activeKey===void 0||t.activeKey===null)return"";const i=t.keyField||"id";return l[i]===t.activeKey?"table-grid-active-row":""},onSelectionChange(l){c("selectionChange",l)},onRowClick(l){c("rowClick",l)},onRowAction(l,i){c("rowAction",{action:l.action,item:l,row:i})}};return(l,i)=>{const u=C.ElTableColumn,f=C.ElButton,p=C.ElTable;return e.openBlock(),e.createElementBlock("div",lt,[e.createVNode(p,e.mergeProps({stripe:!0,border:!0,...l.$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},[r.value.hasActionsSlot?e.renderSlot(l.$slots,"actions",{row:g,actions:r.value.actionList},void 0,!0,1):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(r.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($=>o.onRowAction(y,g),["stop"])},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.actionText(y)),1)]),_:2},1032,["type","disabled","onClick"]))),128)),e.renderSlot(l.$slots,"actions-extra",{row:g},void 0,!0)],64)):o.hasColSlot(h.prop)?e.renderSlot(l.$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(O,{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(l.$slots,"default",{},void 0,!0)]),_:2},[e.renderList(r.value.forwardSlots,h=>({name:h,fn:e.withCtx(g=>[e.renderSlot(l.$slots,h,e.normalizeProps(e.guardReactiveProps(g||{})),void 0,!0)])})),r.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"]]),rt={class:"table-pagination"},ct={class:"page-size-select"},dt={class:"total-text"},mt={key:1,class:"load-more"},ut={key:2,class:"total-text"},pt=k(e.defineComponent({__name:"TablePagination",props:{page:{},pageSize:{},total:{},type:{}},emits:["update:page","update:pageSize"],setup(n,{emit:a}){const t=n,s=a,c=e.computed(()=>({totalPages:Math.ceil(t.total/t.pageSize),showPagination:t.type==="page"&&t.total>0})),d={onPageChange:r=>{s("update:page",r)},onPageSizeChange:r=>{s("update:pageSize",r)}};return(r,m)=>{const o=C.ElPagination,l=C.ElOption,i=C.ElSelect,u=C.ElButton;return e.openBlock(),e.createElementBlock("div",rt,[c.value.showPagination?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createVNode(o,{"current-page":t.page,"page-count":c.value.totalPages,"page-sizes":[10,20,50,100],"page-size":t.pageSize,layout:"total, prev, pager, next, jumper",onCurrentChange:d.onPageChange,onSizeChange:d.onPageSizeChange},null,8,["current-page","page-count","page-size","onCurrentChange","onSizeChange"]),e.createElementVNode("div",ct,[e.createVNode(i,{"model-value":t.pageSize,style:{width:"100px"},onChange:d.onPageSizeChange},{default:e.withCtx(()=>[e.createVNode(l,{value:10,label:"10条/页"}),e.createVNode(l,{value:20,label:"20条/页"}),e.createVNode(l,{value:50,label:"50条/页"}),e.createVNode(l,{value:100,label:"100条/页"})]),_:1},8,["model-value","onChange"]),e.createElementVNode("span",dt,"共 "+e.toDisplayString(t.total)+" 条",1)])],64)):t.type==="auto"?(e.openBlock(),e.createElementBlock("div",mt,[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",ut,"共 "+e.toDisplayString(t.total)+" 条",1)):e.createCommentVNode("",!0)])}}}),[["__scopeId","data-v-2ca77d18"]]),ft={class:"table-detail"},ht={key:0,class:"detail-header"},gt={class:"detail-title"},yt={class:"detail-body"},bt={key:0,class:"detail-status"},wt={key:1,class:"detail-content"},Ct={class:"detail-label"},kt={class:"detail-value"},xt={key:2,class:"detail-status"},Z=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(),s=e.computed(()=>!!t["detail-extra"]),c=e.computed(()=>s.value),d=e.computed(()=>!s.value||a.extraMode==="append"),r=e.computed(()=>({showHeader:a.showHeader!==!1,title:a.title||"详情",emptyText:a.emptyText||"暂无数据",hasRow:!!a.rowData})),m={getNestedValue(o,l){if(!o||!l)return"";if(!l.includes("."))return o[l];const i=l.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,l)=>(e.openBlock(),e.createElementBlock("div",ft,[r.value.showHeader?(e.openBlock(),e.createElementBlock("div",ht,[e.createElementVNode("div",gt,e.toDisplayString(r.value.title),1)])):e.createCommentVNode("",!0),e.createElementVNode("div",yt,[d.value?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[a.loading?(e.openBlock(),e.createElementBlock("div",bt,"加载中...")):r.value.hasRow?(e.openBlock(),e.createElementBlock("div",wt,[(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",Ct,e.toDisplayString(i.label),1),e.createElementVNode("div",kt,[e.createVNode(O,{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",xt,e.toDisplayString(r.value.emptyText),1))],64)):e.createCommentVNode("",!0),c.value?e.renderSlot(o.$slots,"detail-extra",{rowData:a.rowData,columns:a.columns},void 0,!0,1):e.createCommentVNode("",!0)])]))}}),[["__scopeId","data-v-7e47b0ba"]]),St={class:"table-body"},Bt={class:"table-container"},ne=k(e.defineComponent({inheritAttrs:!1,__name:"TableRender",props:{formId:{},detailExtraMode:{}},emits:["back","toolbar-action","row-action"],setup(n,{expose:a,emit:t}){const s=["search-extra","search-actions","toolbar-left","toolbar-extra","detail-extra"],c=n,d=e.useAttrs(),r=e.useSlots(),m=t,o=new Ye,l=e.ref(null),i=e.reactive({searchParams:{},loaded:!1,dictData:{}});e.onMounted(async()=>{c.formId&&await f.loadConfig(c.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}=d;return g},getTableSlots(){const p={};for(const h of Object.keys(r))s.includes(h)||(p[h]=!0);return p},getDetailSlots(){return r["detail-extra"]?["detail-extra"]:[]},getDetailExtraMode(){return c.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 V.get(D.dictApi(g));y.status===200&&(i.dictData[g]=W(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){E.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){E.warning("未配置表单,无法新增");return}if(!l.value)return;await l.value.showForm(h)!=null&&await f.handleLoadData()},async handleEdit(p,h){if(!p){E.warning("请先点击表格中的一行数据");return}const g=h?o.getButtonFormId(h):o.getFormId();if(!g){E.warning("未配置表单,无法编辑");return}if(!l.value)return;const y=o.getKeyField();await l.value.showForm(g,`${y}=${p[y]}`)!=null&&await f.handleLoadData()},async handleDelete(p,h){if(!p){E.warning("请先点击表格中的一行数据");return}try{await B.ElMessageBox.confirm((h==null?void 0:h.confirm)||"确定要删除这条数据吗?","确认删除",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"})}catch{return}try{await o.deleteRow(p),E.success("删除成功")}catch(g){_((g==null?void 0:g.message)||"删除失败")}},async handleExport(){try{await o.exportData(),E.success("导出成功")}catch(p){_((p==null?void 0:p.message)||"导出失败")}},async handleCustomAction(p){const{item:h,row:g}=p;if(!(h!=null&&h.url)){E.warning(`未识别的按钮动作:${p.action}`);return}try{await B.ElMessageBox.confirm(h.confirm||"确定执行该操作吗?","确认",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"})}catch{return}try{const y=await V.post(h.url,g||{});if(y.status!==200)throw new Error(y.message||"操作失败");E.success(y.message||"操作成功"),await f.handleLoadData()}catch(y){_((y==null?void 0:y.message)||"操作失败")}}};return a({loadConfig:f.loadConfig}),(p,h)=>{var y,x,$,ie,se,re,ce;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(Ge,{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",St,[e.createElementVNode("div",Bt,[e.createVNode(st,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(Rt=>[e.renderSlot(p.$slots,P,e.normalizeProps(e.guardReactiveProps(Rt||{})),void 0,!0)])}))]),1040,["rows","columns","loading","actions","actions-width","key-field","dict-data","active-key","onRowAction","onRowClick"]),e.createVNode(pt,{class:"table-pagination",page:u.value.pagination.page,"page-size":u.value.pagination.pageSize,total:u.value.total,type:($=u.value.tableConfig)==null?void 0:$.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(Z,{key:0,class:e.normalizeClass(["table-detail-inline",`table-detail-inline-${u.value.detailSide}`]),style:e.normalizeStyle({width:u.value.detailWidth}),title:(se=(ie=u.value.tableConfig)==null?void 0:ie.meta)==null?void 0:se.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:((ce=(re=u.value.tableConfig)==null?void 0:re.meta)==null?void 0:ce.title)||"详情",onClose:f.handleDetailClose,onClosed:f.handleDetailClosed},{default:e.withCtx(()=>[e.createVNode(Z,{"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(Z,{"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(ve,{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(J,{ref_key:"formRef",ref:l},null,512)],6)}}}),[["__scopeId","data-v-5d8fe268"]]);function le(){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 Vt{constructor(a){w(this,"axiosInstance");w(this,"baseUrl","");this.axiosInstance=ee.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=le()),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 _t{constructor(){w(this,"emitter");this.emitter=de()}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 Et{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..."),this.mqttClient=me.connect(s,t),!this.mqttClient){console.log("connect mqtt failed");return}this.mqttClient.on("connect",()=>{console.log("=====> mqtt connect success!"),this.mqttClient.subscribe(v,{qos:0},c=>{console.log(c?`mqtt subscribe [${v}] failed`:`mqtt subscribe [${v}] success`)})}),this.mqttClient.on("message",(c,d)=>{const r=d.toString();if(!r){console.error("Received empty message",c);return}let m=null;try{m=JSON.parse(r)}catch(o){console.error("Failed to parse message JSON",c,r,o);return}if(!m||m.Content===void 0||m.Content===null||!m.PType){console.log("parse notice failed!",r);return}m.PType==Dt&&this.eventBus.Emit(m.Route,m.Content)}),this.mqttClient.on(j.OffLine,()=>{console.log("mqtt offline...")}),this.mqttClient.on(j.Reconnect,()=>{console.log("mqtt reconnecting...")}),this.mqttClient.on(j.Close,()=>{console.log("mqtt close")}),this.mqttClient.on(j.Error,c=>{console.log("mqtt error")})}randomStr(a){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let s="";for(let c=0;c<a;c++)s+=t.charAt(Math.floor(Math.random()*t.length));return s}}const v="Notice",Dt="NOTICE",j={OffLine:"offline",Close:"close",Reconnect:"reconnect",Error:"error"};let Y;const Tt=n=>{if(!n)throw new Error("QfOptions is undefined");if(!Y&&n&&(Y=new Pt(n)),!Y)throw new Error("Qf not initialized, please call GetQf(options) first");return Y};class Pt{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 _t,this.WebApi=new Vt(a),this.options.useMqtt&&(this.Mqtt=new Et(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 $t={UInput:N,UInputNumber:Q,UDict:A,UToggle:H,UCascader:G,UDate:z,UMenu:oe,FormRender:J,TableRender:ne,UFieldView:O},Nt={install(n){n.use(B);for(const[a,t]of Object.entries($t))n.component(a,t)}};b.FormRender=J,b.GetQf=Tt,b.TableRender=ne,b.UCascader=G,b.UDate=z,b.UDict=A,b.UFieldView=O,b.UInput=N,b.UInputNumber=Q,b.UMenu=oe,b.UToggle=H,b.apis=D,b.clearDictCache=ye,b.default=Nt,b.flattenDictTree=fe,b.getDict=R,b.mapDictTree=q,b.normalizeDictNode=L,b.notify=E,b.notifyUtil=I,b.preloadDicts=ge,b.resolveBaseUrl=le,b.setDictCache=be,b.toDictOptions=W,b.translateDict=ae,b.translateDictSync=he,Object.defineProperties(b,{__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
|
-
*
|
|
3
|
+
* 解析「本页面所在**目录**」的绝对地址(不含结尾斜杠)—— 免配模式下接口前缀的推导依据。
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* 用于前后端不同机/不同端口/走网关的场景;
|
|
8
|
-
* 2. 本文档自己的地址 `document.baseURI` —— 免配默认值;
|
|
9
|
-
* 3. `window.$wujie.location.origin` —— 无界子应用的兜底;
|
|
10
|
-
* 4. `window.location.origin` —— 最后兜底。
|
|
5
|
+
* 结果只取决于**页面自己的地址**(`document.baseURI`),与构建/部署方式无关,
|
|
6
|
+
* 所以同一份产物放到任意路径下都能用:
|
|
11
7
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
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
|
-
*
|
|
21
|
-
*
|
|
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
|
|
42
|
+
private baseCache;
|
|
27
43
|
constructor(options: QfOptions);
|
|
28
44
|
/**
|
|
29
|
-
*
|
|
45
|
+
* GET 请求(params 会被 axios 序列化成 query string)
|
|
30
46
|
*/
|
|
31
|
-
|
|
47
|
+
Get<T = any>(url: string, params?: any): Promise<HttpResponse<T>>;
|
|
32
48
|
/**
|
|
33
|
-
*
|
|
49
|
+
* POST 请求(body 支持普通对象与 FormData;
|
|
50
|
+
* FormData 时 axios 会自动让浏览器设置带 boundary 的 Content-Type)
|
|
34
51
|
*/
|
|
35
|
-
|
|
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<
|
|
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<
|
|
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
|
-
|
|
69
|
+
PostDownload<T = any>(url: string, data?: any): Promise<T>;
|
|
48
70
|
}
|
package/dist/qf/interface.d.ts
CHANGED
|
@@ -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
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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 {
|