沙钢智慧能源系统前端代码
houzhongjian
2024-10-09 314507f8ddadd9c66e98d260c3b2a5dad1a04015
1
import{d as te,as as c,r as S,b as se,a,ad as $,w as R,P as le,Z as ce,k as g,Y as de,m as V,cT as pe,X as W,H as ue,J as ae,aS as ge,bS as me,o as P,c as G,bA as fe,i as he,B as z,j as K,g as B,O as M,D,h as L,aB as we,F as ye,U as be,V as xe,A as ve,di as ne,b9 as oe,aF as Se}from"./index-BP6bNRoi.js";import{g as I}from"./Form.vue_vue_type_style_index_0_scoped_09f6ff61_lang-D5RcC1zQ.js";import{E as Pe}from"./index-BZESAUPP.js";import{_ as Ae}from"./Form-CFzd3m81.js";import{u as ke}from"./useForm-sMS-5OOc.js";import{d as ze}from"./download-e0EdwhTv.js";const Le=ue(te({name:"Table",props:{pageSize:c.number.def(10),currentPage:c.number.def(1),selection:c.bool.def(!1),showOverflowTooltip:c.bool.def(!0),columns:{type:Array,default:()=>[]},expand:c.bool.def(!1),pagination:{type:Object,default:()=>{}},reserveSelection:c.bool.def(!1),loading:c.bool.def(!1),reserveIndex:c.bool.def(!1),align:c.string.validate(e=>["left","center","right"].includes(e)).def("center"),headerAlign:c.string.validate(e=>["left","center","right"].includes(e)).def("center"),data:{type:Array,default:()=>[]}},emits:["update:pageSize","update:currentPage","register"],setup(e,{attrs:o,slots:p,emit:m,expose:O}){const u=S();se(()=>{const t=a(u);m("register",t==null?void 0:t.$parent,u)});const b=S(e.pageSize),f=S(e.currentPage),n=S({}),i=S({}),r=$(()=>{const t={...e};return Object.assign(t,a(i)),t}),x=(t,T)=>{var A;const{columns:_}=a(r);for(const C of T||_)for(const F of t)C.field===F.field?pe(C,F.path,F.value):(A=C.children)!=null&&A.length&&x(t,C.children)},q=S([]),U=t=>{q.value=t};O({setProps:(t={})=>{i.value=Object.assign(a(i),t),n.value=t},setColumn:x,selections:q});const s=$(()=>Object.assign({small:!1,background:!0,pagerCount:document.body.clientWidth<992?5:7,layout:"total, sizes, prev, pager, next, jumper",pageSizes:[10,20,30,50,100],disabled:!1,hideOnSinglePage:!1,total:10},a(r).pagination));R(()=>a(r).pageSize,t=>{b.value=t}),R(()=>a(r).currentPage,t=>{f.value=t}),R(()=>b.value,t=>{m("update:pageSize",t)}),R(()=>f.value,t=>{m("update:currentPage",t)});const v=$(()=>{const t={...o,...e};return delete t.columns,delete t.data,t}),d=()=>{const{selection:t,reserveSelection:T,align:_,headerAlign:A}=a(r);return t?g(W,{type:"selection",reserveSelection:T,align:_,headerAlign:A,width:"50"},null):void 0},w=()=>{const{align:t,headerAlign:T,expand:_}=a(r);return _?g(W,{type:"expand",align:t,headerAlign:T},{default:A=>I(p,"expand",A)}):void 0},E=t=>{const{columns:T,reserveIndex:_,pageSize:A,currentPage:C,align:F,headerAlign:Q,showOverflowTooltip:ie}=a(r);return[w(),d()].concat((t||T).map(l=>{if(l.type==="index")return g(W,{type:"index",index:l.index?l.index:N=>((k,H,X,Y)=>{const J=H+1;return k?X*(Y-1)+J:J})(_,N,A,C),align:l.align||F,headerAlign:l.headerAlign||Q,label:l.label,width:"65px"},null);{const N={...l};return N.children&&delete N.children,g(W,V({showOverflowTooltip:ie,align:F,headerAlign:Q},N,{prop:l.field}),{default:k=>{var H;return l.children&&l.children.length?(X=>{const{align:Y,headerAlign:J,showOverflowTooltip:re}=a(r);return X.map(h=>{const Z={...h};return Z.children&&delete Z.children,g(W,V({showOverflowTooltip:re,align:Y,headerAlign:J},Z,{prop:h.field}),{default:j=>{var ee;return h.children&&h.children.length?E(h.children):I(p,h.field,j)||((ee=h==null?void 0:h.formatter)==null?void 0:ee.call(h,j.row,j.column,j.row[h.field],j.$index))||j.row[h.field]},header:I(p,`${h.field}-header`)})})})(l.children):I(p,l.field,k)||((H=l==null?void 0:l.formatter)==null?void 0:H.call(l,k.row,k.column,k.row[l.field],k.$index))||k.row[l.field]},header:()=>I(p,`${l.field}-header`)||l.label})}}))};return()=>le(g("div",null,[g(de,V({ref:u,data:a(r).data,"onSelection-change":U},a(v)),{default:()=>E(),append:()=>I(p,"append")}),a(r).pagination?g(Pe,V({pageSize:b.value,"onUpdate:pageSize":t=>b.value=t,currentPage:f.value,"onUpdate:currentPage":t=>f.value=t,class:"float-right mb-15px mt-15px"},a(s)),null):void 0]),[[ce,a(r).loading]])}}),[["__scopeId","data-v-1ee0f9ba"]]),Oe={key:0},Te=te({name:"Search",__name:"Search",props:{schema:{type:Array,default:()=>[]},isCol:c.bool.def(!1),labelWidth:c.oneOfType([String,Number]).def("auto"),layout:c.string.validate(e=>["inline","bottom"].includes(e)).def("inline"),buttomPosition:c.string.validate(e=>["left","center","right"].includes(e)).def("center"),showSearch:c.bool.def(!0),showReset:c.bool.def(!0),expand:c.bool.def(!1),expandField:c.string.def(""),inline:c.bool.def(!0),model:{type:Object,default:()=>({})}},emits:["search","reset"],setup(e,{emit:o}){const{t:p}=ae(),m=e,O=o,u=S(!0),b=$(()=>{let s=ge(m.schema);if(m.expand&&m.expandField&&!a(u)){const v=me(s,d=>d.field===m.expandField);if(v>-1){const d=s.length;s.splice(v+1,d)}}return m.layout==="inline"&&(s=s.concat([{field:"action",formItemProps:{labelWidth:"0px"}}])),s}),{register:f,elFormRef:n,methods:i}=ke({model:m.model||{}}),r=async()=>{var s;await((s=a(n))==null?void 0:s.validate(async v=>{if(v){const{getFormData:d}=i,w=await d();O("search",w)}}))},x=async()=>{var d;(d=a(n))==null||d.resetFields();const{getFormData:s}=i,v=await s();O("reset",v)},q=$(()=>({textAlign:m.buttomPosition})),U=()=>{var s;(s=a(n))==null||s.resetFields(),u.value=!a(u)};return(s,v)=>{const d=be,w=xe,E=Ae;return P(),G(ye,null,[g(E,{inline:e.inline,"is-col":e.isCol,"is-custom":!1,"label-width":e.labelWidth,schema:a(b),class:"-mb-15px","hide-required-asterisk":"",onRegister:a(f)},fe({action:z(()=>[e.layout==="inline"?(P(),G("div",Oe,[e.showSearch?(P(),B(w,{key:0,onClick:r},{default:z(()=>[g(d,{class:"mr-5px",icon:"ep:search"}),M(" "+D(a(p)("common.query")),1)]),_:1})):L("",!0),e.showReset?(P(),B(w,{key:1,onClick:x},{default:z(()=>[g(d,{class:"mr-5px",icon:"ep:refresh"}),M(" "+D(a(p)("common.reset")),1)]),_:1})):L("",!0),e.expand?(P(),B(w,{key:2,text:"",onClick:U},{default:z(()=>[M(D(a(p)(a(u)?"common.shrink":"common.expand"))+" ",1),g(d,{icon:a(u)?"ep:arrow-up":"ep:arrow-down"},null,8,["icon"])]),_:1})):L("",!0),K(s.$slots,"actionMore")])):L("",!0)]),_:2},[he(Object.keys(s.$slots),t=>({name:t,fn:z(()=>[K(s.$slots,t)])}))]),1032,["inline","is-col","label-width","schema","onRegister"]),e.layout==="bottom"?(P(),G("div",{key:0,style:we(a(q))},[e.showSearch?(P(),B(w,{key:0,type:"primary",onClick:r},{default:z(()=>[g(d,{class:"mr-5px",icon:"ep:search"}),M(" "+D(a(p)("common.query")),1)]),_:1})):L("",!0),e.showReset?(P(),B(w,{key:1,onClick:x},{default:z(()=>[g(d,{class:"mr-5px",icon:"ep:refresh-right"}),M(" "+D(a(p)("common.reset")),1)]),_:1})):L("",!0),e.expand?(P(),B(w,{key:2,text:"",onClick:U},{default:z(()=>[M(D(a(p)(a(u)?"common.shrink":"common.expand"))+" ",1),g(d,{icon:a(u)?"ep:arrow-up":"ep:arrow-down"},null,8,["icon"])]),_:1})):L("",!0),K(s.$slots,"actionMore")],4)):L("",!0)],64)}}}),{t:y}=ae(),_e=e=>{const o=ve({pageSize:10,currentPage:1,total:10,tableList:[],params:{...(e==null?void 0:e.defaultParams)||{}},loading:!0,exportLoading:!1,currentRow:null}),p=$(()=>({...o.params,pageSize:o.pageSize,pageNo:o.currentPage}));R(()=>o.currentPage,()=>{f.getList()}),R(()=>o.pageSize,()=>{o.currentPage===1||(o.currentPage=1),f.getList()});const m=S(),O=S(),u=async()=>{await Se();const n=a(m);return n||console.error("The table is not registered. Please use the register method to register"),n},b=async n=>{let i=1;n instanceof Array?(i=n.length,await Promise.all(n.map(async r=>{await((e==null?void 0:e.delListApi)&&(e==null?void 0:e.delListApi(r)))}))):await((e==null?void 0:e.delListApi)&&(e==null?void 0:e.delListApi(n))),ne.success(y("common.delSuccess")),o.currentPage=(o.total%o.pageSize===i||o.pageSize===1)&&o.currentPage>1?o.currentPage-1:o.currentPage,await f.getList()},f={getList:async()=>{o.loading=!0;const n=await(e==null?void 0:e.getListApi(a(p)).finally(()=>{o.loading=!1}));n&&(o.tableList=n.list,o.total=n.total??0)},setProps:async(n={})=>{const i=await u();i==null||i.setProps(n)},setColumn:async n=>{const i=await u();i==null||i.setColumn(n)},getSelections:async()=>{const n=await u();return(n==null?void 0:n.selections)||[]},setSearchParams:n=>{o.params=Object.assign(o.params,{pageSize:o.pageSize,pageNo:1,...n}),o.currentPage!==1?o.currentPage=1:f.getList()},delList:async(n,i,r=!0)=>{const x=await u();!i||x!=null&&x.selections.length?r?oe.confirm(y("common.delMessage"),y("common.confirmTitle"),{confirmButtonText:y("common.ok"),cancelButtonText:y("common.cancel"),type:"warning"}).then(async()=>{await b(n)}):await b(n):ne.warning(y("common.delNoData"))},exportList:async n=>{o.exportLoading=!0,oe.confirm(y("common.exportMessage"),y("common.confirmTitle"),{confirmButtonText:y("common.ok"),cancelButtonText:y("common.cancel"),type:"warning"}).then(async()=>{var r;const i=await((r=e==null?void 0:e.exportListApi)==null?void 0:r.call(e,a(p)));i&&ze.excel(i,n)}).finally(()=>{o.exportLoading=!1})}};return e!=null&&e.props&&f.setProps(e.props),{register:(n,i)=>{m.value=n,O.value=i},elTableRef:O,tableObject:o,methods:f,tableMethods:f}};export{Te as _,Le as a,_e as u};