@qy_better_lib/pc 0.0.2 → 0.0.5
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/@qy_better_lib/pc.min.js +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js +10 -4
- package/lib/utils/index.d.ts +33 -0
- package/lib/utils/index.js +79 -0
- package/package.json +3 -5
- package/src/contextMenu/index.ts +0 -8
- package/src/contextMenu/src/index.vue +0 -131
- package/src/index.ts +0 -16
- package/src/styles/contextMenu.scss +0 -47
- package/src/styles/index.scss +0 -3
- package/src/styles/lowcode.scss +0 -0
- package/src/styles/tableExtend.scss +0 -91
- package/src/styles/textButton.scss +0 -53
- package/src/tableExtend/index.ts +0 -10
- package/src/tableExtend/props.ts +0 -53
- package/src/tableExtend/src/colVisible.vue +0 -80
- package/src/tableExtend/src/index.vue +0 -178
- package/src/tableExtend/src/valueCol.vue +0 -25
- package/src/tableExtend/type.ts +0 -173
- package/src/tableExtend/useTable.ts +0 -136
- package/src/textButton/index.ts +0 -8
- package/src/textButton/src/index.vue +0 -39
- package/tsconfig.json +0 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(u,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("vue-i18n"),require("@qy_better_lib/core")):typeof define=="function"&&define.amd?define(["exports","vue","vue-i18n","@qy_better_lib/core"],e):(u=typeof globalThis<"u"?globalThis:u||self,e(u["@qy_better_lib/pc"]={},u.Vue,u.vueI18n,u.core))})(this,function(u,e,z,P){"use strict";const S=e.defineComponent({name:"TextButton",__name:"index",props:{type:{type:String,default:"primary",validator:o=>["default","primary","success","warning","info","danger"].includes(o)},disabled:Boolean},emits:["click"],setup(o,{emit:n}){const l=o,s=n;function d(m){l.disabled||s("click",m)}return(m,_)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["text-button",[`text-button-${o.type}`,o.disabled&&"is-disabled"]]),onClick:e.withModifiers(d,["prevent","stop"])},[e.renderSlot(m.$slots,"default")],2))}});S.install=o=>{o.component("TextButton",S)};var $=(o=>(o[o.PICTURE=1]="PICTURE",o[o.PDF=2]="PDF",o[o.OTHER=3]="OTHER",o))($||{});function R(o){var i,h;const n=e.getCurrentInstance(),l=n==null?void 0:n.props,s={rowKey:"Id","element-loading-text":"加载中…","element-loading-background":"rgba(0, 0, 0, 0.2)",highlightCurrentRow:!0,stripe:!0,border:!1,height:"100%"},d={headerAlign:void 0,align:void 0,prop:void 0,label:void 0,init:!0,width:void 0,showOverflowTooltip:!1,sortable:void 0,fixed:void 0},m=e.computed(()=>({...s,...Object.keys(l.options).length>0?l.options:{}})),_=e.reactive({count:0,rows:[]}),y=e.reactive({pageIndex:(i=l==null?void 0:l.paging)!=null&&i.pageIndex?e.toRef(l.paging,"pageIndex"):1,pageSize:(h=l==null?void 0:l.paging)!=null&&h.pageSize?e.toRef(l.paging,"pageSize"):10}),g=e.computed(()=>{var c,r;return((c=l==null?void 0:l.paging)==null?void 0:c.pageIndex)>0&&((r=l==null?void 0:l.paging)==null?void 0:r.pageSize)>0}),f=e.reactive({show:!1,filePathList:[],index:0}),a=e.reactive({showColumn:[],hiddenColumn:[]}),b=e.computed(()=>!a.showColumn||a.showColumn.length===0?[{prop:"default-prop",init:!0,label:""}]:a.showColumn.map(r=>(o&&r.langue&&(r.label=o(r.langue)),{...d,...r}))),C=e.computed(()=>{var c,r,p,x,t,B;return(((p=(r=n==null?void 0:(c=n.slots)["tool-left"])==null?void 0:r.call(c))==null?void 0:p.length)||0)>0||(((B=(t=n==null?void 0:(x=n.slots)["tool-right"])==null?void 0:t.call(x))==null?void 0:B.length)||0)>0}),w=e.computed(()=>b.value.some(c=>c.fileType&&c.fileType==$.PICTURE));return{defColSetting:d,selectionOptions:_,tableAttribute:m,pagination:y,hasPagination:g,imageViewer:f,columnConfig:a,colSettingList:b,showToolPanel:C,hasImageViewer:w}}function L(){return{options:{type:Object,default:()=>({})},tableData:{type:Array,default:[]},tableColums:{type:Array,default:()=>[]},tableLoading:Boolean,selectionCol:{type:Boolean,default:()=>!0},indexCol:{type:Boolean,default:()=>!0},isSetColumn:{type:Boolean,default:()=>!1},paging:{type:Object},total:Number,sizeList:{type:Array,default:()=>[15,20,30,50,100]}}}const D=e.defineComponent({__name:"valueCol",props:{row:{type:Object,default:()=>{}},colCfg:{type:Object,default:()=>{}}},setup(o){const n=o,l=e.computed(()=>{const{row:s,colCfg:d}=n;return s[d.prop]});return(s,d)=>(e.openBlock(),e.createElementBlock("span",null,e.toDisplayString(l.value!=null?l.value:"--"),1))}}),O={class:"set-column-list-wrap"},I={class:"fixed-wrap"},M=e.defineComponent({__name:"colVisible",setup(o){const n=e.inject("table-extend"),l=e.ref(!0),s=e.ref(!1),d=e.computed(()=>n&&n.columnConfig.showColumn.map(f=>f.prop)||[]),m=e.computed(()=>(n==null?void 0:n.tableColums.value)||[]);function _(f){f?n&&(n.columnConfig.showColumn=m.value):n&&(n.columnConfig.showColumn=[])}function y(f){if(n){n.columnConfig.showColumn=m.value.filter(b=>f.includes(b.prop));const a=f.length;l.value=a===m.value.length,s.value=a>0&&a<m.value.length}}function g(f,a){a.fixed===f?a.fixed=void 0:a.fixed=f}return(f,a)=>{const b=e.resolveComponent("Setting"),C=e.resolveComponent("el-icon"),w=e.resolveComponent("el-checkbox"),i=e.resolveComponent("Upload"),h=e.resolveComponent("el-divider"),c=e.resolveComponent("el-checkbox-group"),r=e.resolveComponent("el-popover");return e.openBlock(),e.createBlock(r,{placement:"bottom",title:"列显示设置",width:220},{reference:e.withCtx(()=>[e.createVNode(C,null,{default:e.withCtx(()=>[e.createVNode(b)]),_:1})]),default:e.withCtx(()=>[e.createElementVNode("div",O,[e.createVNode(w,{indeterminate:s.value,modelValue:l.value,"onUpdate:modelValue":a[0]||(a[0]=p=>l.value=p),onChange:_},{default:e.withCtx(()=>[e.createTextVNode("全选 ")]),_:1},8,["indeterminate","modelValue"]),e.createVNode(c,{class:"set-column-check-group",modelValue:d.value,"onUpdate:modelValue":a[1]||(a[1]=p=>d.value=p),onChange:y},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.value,p=>(e.openBlock(),e.createElementBlock("div",{class:"group-item",key:p.prop},[e.createVNode(w,{class:"set-column-check",label:p.prop},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(p.label),1)]),_:2},1032,["label"]),e.createElementVNode("div",I,[e.createVNode(C,{class:e.normalizeClass(["fixed-icon",p.fixed==="left"&&"active"]),title:"固定到左边",onClick:x=>g("left",p)},{default:e.withCtx(()=>[e.createVNode(i)]),_:2},1032,["class","onClick"]),e.createVNode(h,{direction:"vertical"}),e.createVNode(C,{class:e.normalizeClass(["fixed-icon",p.fixed==="right"&&"active"]),title:"固定到右边",onClick:x=>g("right",p)},{default:e.withCtx(()=>[e.createVNode(i)]),_:2},1032,["class","onClick"])])]))),128))]),_:1},8,["modelValue"])])]),_:1})}}}),j={class:"table-extend"},A={class:"tool-panel"},U={class:"left-panel"},q={class:"right-panel"},H={class:"default-tool"},X=["innerHTML"],V=e.defineComponent({__name:"index",props:{...L()},emits:["tableSort","handleSelectionChange","currentChange","pageSizeChange","rowClick","rowDblClick"],setup(o,{expose:n,emit:l}){const s=o,d=l,{t:m}=z.useI18n(),{selectionOptions:_,tableAttribute:y,pagination:g,hasPagination:f,columnConfig:a,colSettingList:b}=R(m);e.provide("table-extend",{tableProps:s,tableColums:e.toRef(s,"tableColums"),columnConfig:a});const C=e.ref(null),w=e.ref(!1);e.watch(()=>s.tableColums,()=>{a.showColumn=s.tableColums}),e.watch(()=>g.pageIndex,t=>{if(t&&t>0){if(w.value){w.value=!1;return}d("currentChange",t),C.value.setScrollTop(0)}}),e.watch(()=>g.pageSize,t=>{t&&t>0&&(w.value=!0,g.pageIndex=1,d("pageSizeChange",t),C.value.setScrollTop(0))}),e.onMounted(()=>{e.nextTick(()=>{s.tableColums&&s.tableColums.length>0&&(a.showColumn=s.tableColums)})}),n({clearSelection:p,toggleRowSelection:x});function i(t){d("tableSort",{sortName:t.prop,sortType:t.order==="descending"?"desc":t.order==="ascending"?"asc":""})}function h(t){_.rows=t,_.count=t&&t.length,d("handleSelectionChange",t)}function c(t){d("rowClick",t)}function r(t){d("rowDblClick",t)}function p(){var t;(t=C.value)==null||t.clearSelection()}function x(t){var B;(B=C.value)==null||B.toggleRowSelection(t)}return(t,B)=>{const N=e.resolveComponent("el-table-column"),J=e.resolveComponent("el-empty"),Q=e.resolveComponent("el-table"),Z=e.resolveComponent("el-pagination"),v=e.resolveDirective("loading");return e.openBlock(),e.createElementBlock("div",j,[e.createElementVNode("div",A,[e.createElementVNode("div",U,[e.renderSlot(t.$slots,"tool-left")]),e.createElementVNode("div",q,[e.renderSlot(t.$slots,"tool-right"),e.createElementVNode("div",H,[t.isSetColumn?(e.openBlock(),e.createBlock(M,{key:0})):e.createCommentVNode("",!0)])])]),e.withDirectives((e.openBlock(),e.createBlock(Q,e.mergeProps({ref_key:"tableRef",ref:C},e.unref(y),{data:t.tableData,onSortChange:i,onSelectionChange:h,onRowClick:c,onRowDblclick:r}),{empty:e.withCtx(()=>[e.createVNode(J,{"image-size":60})]),default:e.withCtx(()=>[t.selectionCol?(e.openBlock(),e.createBlock(N,{key:0,type:"selection",width:"48",fixed:"left"})):e.createCommentVNode("",!0),t.indexCol?(e.openBlock(),e.createBlock(N,{key:1,type:"index",width:"58",fixed:"left"})):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(b),k=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:k.prop},[k.isHtml?(e.openBlock(),e.createBlock(N,e.mergeProps({key:0,ref_for:!0},k),{default:e.withCtx(T=>[e.createElementVNode("div",{innerHTML:k.prop&&T.row[k.prop]},null,8,X)]),_:2},1040)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[k.init?(e.openBlock(),e.createBlock(N,e.mergeProps({key:0,ref_for:!0},k),{default:e.withCtx(T=>[e.renderSlot(t.$slots,`col_${k.prop}`,{data:T.row},()=>[e.createVNode(D,e.mergeProps({ref_for:!0},{row:T.row,colCfg:k}),null,16)])]),_:2},1040)):e.createCommentVNode("",!0)],64))],64))),128)),e.renderSlot(t.$slots,"operatColumn")]),_:3},16,["data"])),[[v,t.tableLoading]]),e.unref(f)?(e.openBlock(),e.createBlock(Z,{key:0,background:"","current-page":e.unref(g).pageIndex,"onUpdate:currentPage":B[0]||(B[0]=k=>e.unref(g).pageIndex=k),"page-size":e.unref(g).pageSize,"onUpdate:pageSize":B[1]||(B[1]=k=>e.unref(g).pageSize=k),"page-sizes":t.sizeList,layout:"total, sizes, prev, pager, next, jumper",total:t.total},null,8,["current-page","page-size","page-sizes","total"])):e.createCommentVNode("",!0)])}}});V.install=o=>{o.component("TableExtend",V)};const F={class:"contextmenu-wrap"},Y={class:"contextmenu-items"},W=["onClick"],E=e.defineComponent({__name:"index",props:{visible:{type:Boolean,default:()=>!1},position:{type:Object,default:()=>{}},options:{type:Array,default:[],required:!0}},emits:["menuClick","update:visible"],setup(o,{expose:n,emit:l}){const s=o,d=l;n({hide:C,show:a});const m=e.ref(!1),_=e.ref(null),y=e.reactive({left:0,top:0});e.watch(()=>s.visible,i=>{i&&(m.value=!0,e.nextTick(()=>{b(s.position)}))},{immediate:!0}),e.onMounted(()=>{var i;(i=_.value)==null||i.addEventListener("contextmenu",a)}),e.onBeforeUnmount(()=>{g()});function g(){var i;(i=_.value)==null||i.removeEventListener("contextmenu",a)}function f(i){d("menuClick",i),C()}async function a(i){i.preventDefault(),m.value=!0,await e.nextTick();const{pageX:h,pageY:c}=i;b({x:h,y:c})}function b(i){const{clientWidth:h,clientHeight:c}=_.value;!h||!c||(y.top=`${w("Y",i.y||0,c)}px`,y.left=`${w("X",i.x||0,h)}px`)}function C(){g(),m.value=!1,e.nextTick(()=>{d("update:visible",!1)})}function w(i,h,c){const r=i==="X"?window.innerWidth:window.innerHeight,p=i==="X"?window.scrollX:window.scrollY;let x=h-p;return x+c>r&&(x=Math.max(0,x-c)),x+p}return(i,h)=>{const c=e.resolveComponent("el-divider");return e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[m.value?e.withDirectives((e.openBlock(),e.createElementBlock("div",{key:0,class:"contextmenu",style:e.normalizeStyle({top:y.top,left:y.left}),ref_key:"contextMenuRef",ref:_},[e.createElementVNode("div",F,[e.createElementVNode("ul",Y,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.options,r=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:r.key},[(r==null?void 0:r.type)=="divider"?(e.openBlock(),e.createBlock(c,{key:0})):(e.openBlock(),e.createElementBlock("li",{key:1,class:"contextmenu-item",onClick:p=>f(r)},[e.renderSlot(i.$slots,"items",{data:{item:r,options:o.options}},()=>[e.createTextVNode(e.toDisplayString(r.label),1)])],8,W))],64))),128))])])],4)),[[e.unref(P.ClickOutside),C]]):e.createCommentVNode("",!0)])}}});E.install=o=>{o.component("ContextMenu",E)};const K=[S,V,E];function G(o){K.forEach(n=>{o.use(n)})}u.contextMenu=E,u.install=G,u.tableExtend=V,u.textButton=S,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(m,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("vue-i18n"),require("@qy_better_lib/core"),require("element-plus")):typeof define=="function"&&define.amd?define(["exports","vue","vue-i18n","@qy_better_lib/core","element-plus"],e):(m=typeof globalThis<"u"?globalThis:m||self,e(m["@qy_better_lib/pc"]={},m.Vue,m.vueI18n,m.core,m.elementPlus))})(this,function(m,e,R,D,S){"use strict";const V=e.defineComponent({name:"TextButton",__name:"index",props:{type:{type:String,default:"primary",validator:t=>["default","primary","success","warning","info","danger"].includes(t)},disabled:Boolean},emits:["click"],setup(t,{emit:o}){const n=t,i=o;function c(p){n.disabled||i("click",p)}return(p,C)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["text-button",[`text-button-${t.type}`,t.disabled&&"is-disabled"]]),onClick:e.withModifiers(c,["prevent","stop"])},[e.renderSlot(p.$slots,"default")],2))}});V.install=t=>{t.component("TextButton",V)};var z=(t=>(t[t.PICTURE=1]="PICTURE",t[t.PDF=2]="PDF",t[t.OTHER=3]="OTHER",t))(z||{});function A(t){var a,k;const o=e.getCurrentInstance(),n=o==null?void 0:o.props,i={rowKey:"Id","element-loading-text":"加载中…","element-loading-background":"rgba(0, 0, 0, 0.2)",highlightCurrentRow:!0,stripe:!0,border:!1,height:"100%"},c={headerAlign:void 0,align:void 0,prop:void 0,label:void 0,init:!0,width:void 0,showOverflowTooltip:!1,sortable:void 0,fixed:void 0},p=e.computed(()=>({...i,...Object.keys(n.options).length>0?n.options:{}})),C=e.reactive({count:0,rows:[]}),_=e.reactive({pageIndex:(a=n==null?void 0:n.paging)!=null&&a.pageIndex?e.toRef(n.paging,"pageIndex"):1,pageSize:(k=n==null?void 0:n.paging)!=null&&k.pageSize?e.toRef(n.paging,"pageSize"):10}),g=e.computed(()=>{var d,s;return((d=n==null?void 0:n.paging)==null?void 0:d.pageIndex)>0&&((s=n==null?void 0:n.paging)==null?void 0:s.pageSize)>0}),h=e.reactive({show:!1,filePathList:[],index:0}),r=e.reactive({showColumn:[],hiddenColumn:[]}),w=e.computed(()=>!r.showColumn||r.showColumn.length===0?[{prop:"default-prop",init:!0,label:""}]:r.showColumn.map(s=>(t&&s.langue&&(s.label=t(s.langue)),{...c,...s}))),u=e.computed(()=>{var d,s,f,y,l,B;return(((f=(s=o==null?void 0:(d=o.slots)["tool-left"])==null?void 0:s.call(d))==null?void 0:f.length)||0)>0||(((B=(l=o==null?void 0:(y=o.slots)["tool-right"])==null?void 0:l.call(y))==null?void 0:B.length)||0)>0}),x=e.computed(()=>w.value.some(d=>d.fileType&&d.fileType==z.PICTURE));return{defColSetting:c,selectionOptions:C,tableAttribute:p,pagination:_,hasPagination:g,imageViewer:h,columnConfig:r,colSettingList:w,showToolPanel:u,hasImageViewer:x}}function O(){return{options:{type:Object,default:()=>({})},tableData:{type:Array,default:[]},tableColums:{type:Array,default:()=>[]},tableLoading:Boolean,selectionCol:{type:Boolean,default:()=>!0},indexCol:{type:Boolean,default:()=>!0},isSetColumn:{type:Boolean,default:()=>!1},paging:{type:Object},total:Number,sizeList:{type:Array,default:()=>[15,20,30,50,100]}}}const I=e.defineComponent({__name:"valueCol",props:{row:{type:Object,default:()=>{}},colCfg:{type:Object,default:()=>{}}},setup(t){const o=t,n=e.computed(()=>{const{row:i,colCfg:c}=o;return i[c.prop]});return(i,c)=>(e.openBlock(),e.createElementBlock("span",null,e.toDisplayString(n.value!=null?n.value:"--"),1))}}),U={class:"set-column-list-wrap"},j={class:"fixed-wrap"},H=e.defineComponent({__name:"colVisible",setup(t){const o=e.inject("table-extend"),n=e.ref(!0),i=e.ref(!1),c=e.computed(()=>o&&o.columnConfig.showColumn.map(h=>h.prop)||[]),p=e.computed(()=>(o==null?void 0:o.tableColums.value)||[]);function C(h){h?o&&(o.columnConfig.showColumn=p.value):o&&(o.columnConfig.showColumn=[])}function _(h){if(o){o.columnConfig.showColumn=p.value.filter(w=>h.includes(w.prop));const r=h.length;n.value=r===p.value.length,i.value=r>0&&r<p.value.length}}function g(h,r){r.fixed===h?r.fixed=void 0:r.fixed=h}return(h,r)=>{const w=e.resolveComponent("Setting"),u=e.resolveComponent("el-icon"),x=e.resolveComponent("el-checkbox"),a=e.resolveComponent("Upload"),k=e.resolveComponent("el-divider"),d=e.resolveComponent("el-checkbox-group"),s=e.resolveComponent("el-popover");return e.openBlock(),e.createBlock(s,{placement:"bottom",title:"列显示设置",width:220},{reference:e.withCtx(()=>[e.createVNode(u,null,{default:e.withCtx(()=>[e.createVNode(w)]),_:1})]),default:e.withCtx(()=>[e.createElementVNode("div",U,[e.createVNode(x,{indeterminate:i.value,modelValue:n.value,"onUpdate:modelValue":r[0]||(r[0]=f=>n.value=f),onChange:C},{default:e.withCtx(()=>[e.createTextVNode("全选 ")]),_:1},8,["indeterminate","modelValue"]),e.createVNode(d,{class:"set-column-check-group",modelValue:c.value,"onUpdate:modelValue":r[1]||(r[1]=f=>c.value=f),onChange:_},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,f=>(e.openBlock(),e.createElementBlock("div",{class:"group-item",key:f.prop},[e.createVNode(x,{class:"set-column-check",label:f.prop},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(f.label),1)]),_:2},1032,["label"]),e.createElementVNode("div",j,[e.createVNode(u,{class:e.normalizeClass(["fixed-icon",f.fixed==="left"&&"active"]),title:"固定到左边",onClick:y=>g("left",f)},{default:e.withCtx(()=>[e.createVNode(a)]),_:2},1032,["class","onClick"]),e.createVNode(k,{direction:"vertical"}),e.createVNode(u,{class:e.normalizeClass(["fixed-icon",f.fixed==="right"&&"active"]),title:"固定到右边",onClick:y=>g("right",f)},{default:e.withCtx(()=>[e.createVNode(a)]),_:2},1032,["class","onClick"])])]))),128))]),_:1},8,["modelValue"])])]),_:1})}}}),q={class:"table-extend"},X={class:"tool-panel"},F={class:"left-panel"},Y={class:"right-panel"},W={class:"default-tool"},K=["innerHTML"],E=e.defineComponent({__name:"index",props:{...O()},emits:["tableSort","handleSelectionChange","currentChange","pageSizeChange","rowClick","rowDblClick"],setup(t,{expose:o,emit:n}){const i=t,c=n,{t:p}=R.useI18n(),{selectionOptions:C,tableAttribute:_,pagination:g,hasPagination:h,columnConfig:r,colSettingList:w}=A(p);e.provide("table-extend",{tableProps:i,tableColums:e.toRef(i,"tableColums"),columnConfig:r});const u=e.ref(null),x=e.ref(!1);e.watch(()=>i.tableColums,()=>{r.showColumn=i.tableColums}),e.watch(()=>g.pageIndex,l=>{if(l&&l>0){if(x.value){x.value=!1;return}c("currentChange",l),u.value.setScrollTop(0)}}),e.watch(()=>g.pageSize,l=>{l&&l>0&&(x.value=!0,g.pageIndex=1,c("pageSizeChange",l),u.value.setScrollTop(0))}),e.onMounted(()=>{e.nextTick(()=>{i.tableColums&&i.tableColums.length>0&&(r.showColumn=i.tableColums)})}),o({clearSelection:f,toggleRowSelection:y});function a(l){c("tableSort",{sortName:l.prop,sortType:l.order==="descending"?"desc":l.order==="ascending"?"asc":""})}function k(l){C.rows=l,C.count=l&&l.length,c("handleSelectionChange",l)}function d(l){c("rowClick",l)}function s(l){c("rowDblClick",l)}function f(){var l;(l=u.value)==null||l.clearSelection()}function y(l){var B;(B=u.value)==null||B.toggleRowSelection(l)}return(l,B)=>{const T=e.resolveComponent("el-table-column"),oe=e.resolveComponent("el-empty"),ne=e.resolveComponent("el-table"),le=e.resolveComponent("el-pagination"),ie=e.resolveDirective("loading");return e.openBlock(),e.createElementBlock("div",q,[e.createElementVNode("div",X,[e.createElementVNode("div",F,[e.renderSlot(l.$slots,"tool-left")]),e.createElementVNode("div",Y,[e.renderSlot(l.$slots,"tool-right"),e.createElementVNode("div",W,[l.isSetColumn?(e.openBlock(),e.createBlock(H,{key:0})):e.createCommentVNode("",!0)])])]),e.withDirectives((e.openBlock(),e.createBlock(ne,e.mergeProps({ref_key:"tableRef",ref:u},e.unref(_),{data:l.tableData,onSortChange:a,onSelectionChange:k,onRowClick:d,onRowDblclick:s}),{empty:e.withCtx(()=>[e.createVNode(oe,{"image-size":60})]),default:e.withCtx(()=>[l.selectionCol?(e.openBlock(),e.createBlock(T,{key:0,type:"selection",width:"48",fixed:"left"})):e.createCommentVNode("",!0),l.indexCol?(e.openBlock(),e.createBlock(T,{key:1,type:"index",width:"58",fixed:"left"})):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(w),b=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:b.prop},[b.isHtml?(e.openBlock(),e.createBlock(T,e.mergeProps({key:0,ref_for:!0},b),{default:e.withCtx($=>[e.createElementVNode("div",{innerHTML:b.prop&&$.row[b.prop]},null,8,K)]),_:2},1040)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[b.init?(e.openBlock(),e.createBlock(T,e.mergeProps({key:0,ref_for:!0},b),{default:e.withCtx($=>[e.renderSlot(l.$slots,`col_${b.prop}`,{data:$.row},()=>[e.createVNode(I,e.mergeProps({ref_for:!0},{row:$.row,colCfg:b}),null,16)])]),_:2},1040)):e.createCommentVNode("",!0)],64))],64))),128)),e.renderSlot(l.$slots,"operatColumn")]),_:3},16,["data"])),[[ie,l.tableLoading]]),e.unref(h)?(e.openBlock(),e.createBlock(le,{key:0,background:"","current-page":e.unref(g).pageIndex,"onUpdate:currentPage":B[0]||(B[0]=b=>e.unref(g).pageIndex=b),"page-size":e.unref(g).pageSize,"onUpdate:pageSize":B[1]||(B[1]=b=>e.unref(g).pageSize=b),"page-sizes":l.sizeList,layout:"total, sizes, prev, pager, next, jumper",total:l.total},null,8,["current-page","page-size","page-sizes","total"])):e.createCommentVNode("",!0)])}}});E.install=t=>{t.component("TableExtend",E)};const G={class:"contextmenu-wrap"},J={class:"contextmenu-items"},Q=["onClick"],N=e.defineComponent({__name:"index",props:{visible:{type:Boolean,default:()=>!1},position:{type:Object,default:()=>{}},options:{type:Array,default:[],required:!0}},emits:["menuClick","update:visible"],setup(t,{expose:o,emit:n}){const i=t,c=n;o({hide:u,show:r});const p=e.ref(!1),C=e.ref(null),_=e.reactive({left:0,top:0});e.watch(()=>i.visible,a=>{a&&(p.value=!0,e.nextTick(()=>{w(i.position)}))},{immediate:!0}),e.onMounted(()=>{var a;(a=C.value)==null||a.addEventListener("contextmenu",r)}),e.onBeforeUnmount(()=>{g()});function g(){var a;(a=C.value)==null||a.removeEventListener("contextmenu",r)}function h(a){c("menuClick",a),u()}async function r(a){a.preventDefault(),p.value=!0,await e.nextTick();const{pageX:k,pageY:d}=a;w({x:k,y:d})}function w(a){const{clientWidth:k,clientHeight:d}=C.value;!k||!d||(_.top=`${x("Y",a.y||0,d)}px`,_.left=`${x("X",a.x||0,k)}px`)}function u(){g(),p.value=!1,e.nextTick(()=>{c("update:visible",!1)})}function x(a,k,d){const s=a==="X"?window.innerWidth:window.innerHeight,f=a==="X"?window.scrollX:window.scrollY;let y=k-f;return y+d>s&&(y=Math.max(0,y-d)),y+f}return(a,k)=>{const d=e.resolveComponent("el-divider");return e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[p.value?e.withDirectives((e.openBlock(),e.createElementBlock("div",{key:0,class:"contextmenu",style:e.normalizeStyle({top:_.top,left:_.left}),ref_key:"contextMenuRef",ref:C},[e.createElementVNode("div",G,[e.createElementVNode("ul",J,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.options,s=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:s.key},[(s==null?void 0:s.type)=="divider"?(e.openBlock(),e.createBlock(d,{key:0})):(e.openBlock(),e.createElementBlock("li",{key:1,class:"contextmenu-item",onClick:f=>h(s)},[e.renderSlot(a.$slots,"items",{data:{item:s,options:t.options}},()=>[e.createTextVNode(e.toDisplayString(s.label),1)])],8,Q))],64))),128))])])],4)),[[e.unref(D.ClickOutside),u]]):e.createCommentVNode("",!0)])}}});N.install=t=>{t.component("ContextMenu",N)};function Z(t,o,n){switch(o){case"toast":P(n?"success":"error",t||(n?"执行成功":"执行失败"));break;case"dialog":L(t||(n?"执行成功":"执行失败"),()=>{},{title:"提示",type:n?"success":"error","show-cancel-button":!1});break;case"notif":M(o,t);break}}function v(t,o,n){const i={beforeClose:(c,p,C)=>{c==="confirm"?setTimeout(()=>{C()},0):C()},...n};S.ElMessageBox.confirm(`此操作将${t}, 是否继续?`,"提示",i).then(async()=>{o&&o()}).catch(()=>{})}function L(t,o,n){return new Promise((i,c)=>{const p={beforeClose:(C,_,g)=>{C==="confirm"?setTimeout(()=>{g()},0):g()},...n};S.ElMessageBox.confirm(`${t}`,"Tip",p).then(()=>{i(o&&o())}).catch(()=>{})})}function P(t,o="",n=!1,i=3e3){S.ElMessage({showClose:!0,message:o,type:t,duration:i,dangerouslyUseHTMLString:n})}function M(t,o="",n=!0,i="bottom-right",c=0){S.ElNotification({title:"消息通知",message:o,type:t,dangerouslyUseHTMLString:n,duration:c,showClose:!0,position:i})}const ee=[V,E,N];function te(t){ee.forEach(o=>{t.use(o)})}m.confirmBox=v,m.confirmBoxAsync=L,m.contextMenu=N,m.install=te,m.messageAlert=P,m.messageBox=Z,m.notification=M,m.tableExtend=E,m.textButton=V,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})});
|
package/lib/index.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ import { default as textButton } from './textButton';
|
|
|
2
2
|
import { default as tableExtend } from './tableExtend';
|
|
3
3
|
import { default as contextMenu } from './contextMenu';
|
|
4
4
|
import { App } from 'vue';
|
|
5
|
+
import { messageAlert, messageBox, confirmBox, confirmBoxAsync, notification } from './utils';
|
|
5
6
|
|
|
6
7
|
declare function install(app: App): void;
|
|
7
8
|
export type { TableProp, TableColumn } from './tableExtend';
|
|
8
|
-
export { install, textButton, tableExtend, contextMenu };
|
|
9
|
+
export { install, textButton, tableExtend, contextMenu, messageAlert, messageBox, confirmBox, confirmBoxAsync, notification, };
|
package/lib/index.js
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import "./textButton/index.js";
|
|
2
2
|
import "./tableExtend/index.js";
|
|
3
3
|
import "./contextMenu/index.js";
|
|
4
|
+
import { confirmBox as u, confirmBoxAsync as B, messageAlert as g, messageBox as A, notification as E } from "./utils/index.js";
|
|
4
5
|
import m from "./textButton/src/index.vue.js";
|
|
5
6
|
import n from "./tableExtend/src/index.vue.js";
|
|
6
7
|
import i from "./contextMenu/src/index.vue.js";
|
|
7
8
|
const r = [m, n, i];
|
|
8
|
-
function
|
|
9
|
-
r.forEach((
|
|
10
|
-
|
|
9
|
+
function x(o) {
|
|
10
|
+
r.forEach((t) => {
|
|
11
|
+
o.use(t);
|
|
11
12
|
});
|
|
12
13
|
}
|
|
13
14
|
export {
|
|
15
|
+
u as confirmBox,
|
|
16
|
+
B as confirmBoxAsync,
|
|
14
17
|
i as contextMenu,
|
|
15
|
-
|
|
18
|
+
x as install,
|
|
19
|
+
g as messageAlert,
|
|
20
|
+
A as messageBox,
|
|
21
|
+
E as notification,
|
|
16
22
|
n as tableExtend,
|
|
17
23
|
m as textButton
|
|
18
24
|
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare function messageBox(message: string, type: string, status: boolean): void;
|
|
2
|
+
/**
|
|
3
|
+
* 确认提示框
|
|
4
|
+
* @param str 提示信息
|
|
5
|
+
* @param callback 确认回调函数
|
|
6
|
+
* @param options MessageBox配置项,参考element-plus文档
|
|
7
|
+
*/
|
|
8
|
+
export declare function confirmBox(str: string, callback: () => any | void, options?: any): void;
|
|
9
|
+
/**
|
|
10
|
+
* 同步的确认提示框
|
|
11
|
+
* @param str 提示信息
|
|
12
|
+
* @param callback 确认回调函数
|
|
13
|
+
* @param options MessageBox配置项,参考element-plus文档
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
export declare function confirmBoxAsync(str: string, callback: () => any | void, options?: any): Promise<any>;
|
|
17
|
+
/**
|
|
18
|
+
* 消息提示
|
|
19
|
+
* @export
|
|
20
|
+
* @param type 类型
|
|
21
|
+
* @param message 消息
|
|
22
|
+
* @param html 是否为html
|
|
23
|
+
* @param duration 消失时间
|
|
24
|
+
*/
|
|
25
|
+
export declare function messageAlert(type: "success" | "warning" | "error", message?: string, html?: boolean, duration?: number): void;
|
|
26
|
+
/**
|
|
27
|
+
* 侧窗提示
|
|
28
|
+
* @param type
|
|
29
|
+
* @param message
|
|
30
|
+
* @param html
|
|
31
|
+
* @param duration
|
|
32
|
+
*/
|
|
33
|
+
export declare function notification(type: "success" | "warning" | "error" | "info", message?: string, html?: boolean, position?: "top-right" | "top-left" | "bottom-right" | "bottom-left", duration?: number): void;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { ElMessageBox as f, ElMessage as a, ElNotification as l } from "element-plus";
|
|
2
|
+
function p(t, e, o) {
|
|
3
|
+
switch (e) {
|
|
4
|
+
case "toast":
|
|
5
|
+
m(
|
|
6
|
+
o ? "success" : "error",
|
|
7
|
+
t || (o ? "执行成功" : "执行失败")
|
|
8
|
+
);
|
|
9
|
+
break;
|
|
10
|
+
case "dialog":
|
|
11
|
+
u(t || (o ? "执行成功" : "执行失败"), () => {
|
|
12
|
+
}, {
|
|
13
|
+
title: "提示",
|
|
14
|
+
type: o ? "success" : "error",
|
|
15
|
+
"show-cancel-button": !1
|
|
16
|
+
});
|
|
17
|
+
break;
|
|
18
|
+
case "notif":
|
|
19
|
+
h(e, t);
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function w(t, e, o) {
|
|
24
|
+
const n = {
|
|
25
|
+
beforeClose: (i, s, r) => {
|
|
26
|
+
i === "confirm" ? setTimeout(() => {
|
|
27
|
+
r();
|
|
28
|
+
}, 0) : r();
|
|
29
|
+
},
|
|
30
|
+
...o
|
|
31
|
+
};
|
|
32
|
+
f.confirm(`此操作将${t}, 是否继续?`, "提示", n).then(async () => {
|
|
33
|
+
e && e();
|
|
34
|
+
}).catch(() => {
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function u(t, e, o) {
|
|
38
|
+
return new Promise((n, i) => {
|
|
39
|
+
const s = {
|
|
40
|
+
beforeClose: (r, g, c) => {
|
|
41
|
+
r === "confirm" ? setTimeout(() => {
|
|
42
|
+
c();
|
|
43
|
+
}, 0) : c();
|
|
44
|
+
},
|
|
45
|
+
...o
|
|
46
|
+
};
|
|
47
|
+
f.confirm(`${t}`, "Tip", s).then(() => {
|
|
48
|
+
n(e && e());
|
|
49
|
+
}).catch(() => {
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function m(t, e = "", o = !1, n = 3e3) {
|
|
54
|
+
a({
|
|
55
|
+
showClose: !0,
|
|
56
|
+
message: e,
|
|
57
|
+
type: t,
|
|
58
|
+
duration: n,
|
|
59
|
+
dangerouslyUseHTMLString: o
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function h(t, e = "", o = !0, n = "bottom-right", i = 0) {
|
|
63
|
+
l({
|
|
64
|
+
title: "消息通知",
|
|
65
|
+
message: e,
|
|
66
|
+
type: t,
|
|
67
|
+
dangerouslyUseHTMLString: o,
|
|
68
|
+
duration: i,
|
|
69
|
+
showClose: !0,
|
|
70
|
+
position: n
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
export {
|
|
74
|
+
w as confirmBox,
|
|
75
|
+
u as confirmBoxAsync,
|
|
76
|
+
m as messageAlert,
|
|
77
|
+
p as messageBox,
|
|
78
|
+
h as notification
|
|
79
|
+
};
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qy_better_lib/pc",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.0.
|
|
5
|
-
"description": "qy better lib
|
|
4
|
+
"version": "0.0.5",
|
|
5
|
+
"description": "qy better lib pc compontens",
|
|
6
6
|
"author": "luhuiming",
|
|
7
7
|
"license": "ISC",
|
|
8
8
|
"scripts": {
|
|
@@ -35,11 +35,9 @@
|
|
|
35
35
|
".": {
|
|
36
36
|
"import": "./lib/index.js"
|
|
37
37
|
},
|
|
38
|
-
"./directives": "./lib/directives/index.js",
|
|
39
|
-
"./directives/*": "./lib/directives/*/*.js",
|
|
40
38
|
"./utils": "./lib/utils/index.js",
|
|
41
39
|
"./utils/*": "./lib/utils/*.js",
|
|
42
|
-
"./styles": "./
|
|
40
|
+
"./styles": "./lib/styles/index.scss",
|
|
43
41
|
"./styles/*": "./lib/styles/*"
|
|
44
42
|
},
|
|
45
43
|
"publishConfig": {
|
package/src/contextMenu/index.ts
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<Teleport to="body">
|
|
3
|
-
<div class="contextmenu" v-click-outside="hide" v-if="_visible"
|
|
4
|
-
:style="{ top: position.top, left: position.left }" ref="contextMenuRef">
|
|
5
|
-
<div class="contextmenu-wrap">
|
|
6
|
-
<ul class="contextmenu-items">
|
|
7
|
-
<template v-for="item in options" :key="item.key">
|
|
8
|
-
<el-divider v-if="item?.type == 'divider'" />
|
|
9
|
-
<li v-else class="contextmenu-item" @click="onMenuClick(item)">
|
|
10
|
-
<slot :data="{ item, options }" name="items">
|
|
11
|
-
{{ item.label }}
|
|
12
|
-
</slot>
|
|
13
|
-
</li>
|
|
14
|
-
</template>
|
|
15
|
-
</ul>
|
|
16
|
-
</div>
|
|
17
|
-
</div>
|
|
18
|
-
</Teleport>
|
|
19
|
-
</template>
|
|
20
|
-
|
|
21
|
-
<script lang="ts" setup>
|
|
22
|
-
import type { PropType } from 'vue';
|
|
23
|
-
import { nextTick, onBeforeUnmount, onMounted, reactive, ref, watch } from 'vue';
|
|
24
|
-
import { ClickOutside as vClickOutside } from '@qy_better_lib/core';
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* 通过visible显示的时候,需要提供position;
|
|
28
|
-
* 通过show显示,根据鼠标对象设置显示位置;
|
|
29
|
-
*/
|
|
30
|
-
const props = defineProps({
|
|
31
|
-
visible: {
|
|
32
|
-
type: Boolean,
|
|
33
|
-
default: () => false
|
|
34
|
-
},
|
|
35
|
-
position: {
|
|
36
|
-
type: Object as PropType<{ x: number, y: number }>,
|
|
37
|
-
default: () => { }
|
|
38
|
-
},
|
|
39
|
-
options: {
|
|
40
|
-
type: Array as PropType<Record<string, any>>,
|
|
41
|
-
default: [],
|
|
42
|
-
required: true
|
|
43
|
-
}
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
const emit = defineEmits(['menuClick', 'update:visible']);
|
|
47
|
-
|
|
48
|
-
defineExpose({
|
|
49
|
-
hide,
|
|
50
|
-
show
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
type Position = { left: number, top: number };
|
|
54
|
-
|
|
55
|
-
const _visible = ref<boolean>(false);
|
|
56
|
-
|
|
57
|
-
const contextMenuRef = ref<any>(null);
|
|
58
|
-
|
|
59
|
-
const position: any = reactive<Position>({
|
|
60
|
-
left: 0,
|
|
61
|
-
top: 0,
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
watch(() => props.visible, (v) => {
|
|
65
|
-
if (v) {
|
|
66
|
-
_visible.value = true;
|
|
67
|
-
nextTick(() => {
|
|
68
|
-
setPosition(props.position);
|
|
69
|
-
})
|
|
70
|
-
}
|
|
71
|
-
}, {
|
|
72
|
-
immediate: true
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
onMounted(() => {
|
|
76
|
-
contextMenuRef.value?.addEventListener("contextmenu", show);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
onBeforeUnmount(() => {
|
|
80
|
-
removeEvent();
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
function removeEvent() {
|
|
84
|
-
contextMenuRef.value?.removeEventListener("contextmenu", show);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* 菜单点击
|
|
89
|
-
* @param params
|
|
90
|
-
*/
|
|
91
|
-
function onMenuClick(params: any) {
|
|
92
|
-
emit('menuClick', params)
|
|
93
|
-
hide();
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* 右键菜单显示
|
|
98
|
-
*/
|
|
99
|
-
async function show(e: any) {
|
|
100
|
-
e.preventDefault();
|
|
101
|
-
_visible.value = true;
|
|
102
|
-
await nextTick();
|
|
103
|
-
const { pageX: x, pageY: y } = e;
|
|
104
|
-
setPosition({ x, y });
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function setPosition(pos: { x: number, y: number }) {
|
|
108
|
-
const { clientWidth, clientHeight } = contextMenuRef.value;
|
|
109
|
-
if (!clientWidth || !clientHeight) return;
|
|
110
|
-
position.top = `${calculatePosition("Y", pos.y || 0, clientHeight)}px`;
|
|
111
|
-
position.left = `${calculatePosition("X", pos.x || 0, clientWidth)}px`;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function hide() {
|
|
115
|
-
removeEvent();
|
|
116
|
-
_visible.value = false;
|
|
117
|
-
nextTick(() => {
|
|
118
|
-
emit("update:visible", false);
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function calculatePosition(axis: "X" | "Y", mousePos: number, elSize: number) {
|
|
123
|
-
const windowSize = axis === "X" ? window.innerWidth : window.innerHeight
|
|
124
|
-
const scrollPos = axis === "X" ? window.scrollX : window.scrollY
|
|
125
|
-
let pos = mousePos - scrollPos
|
|
126
|
-
if (pos + elSize > windowSize) {
|
|
127
|
-
pos = Math.max(0, pos - elSize)
|
|
128
|
-
}
|
|
129
|
-
return pos + scrollPos
|
|
130
|
-
}
|
|
131
|
-
</script>
|
package/src/index.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import textButton from "./textButton";
|
|
2
|
-
import tableExtend from "./tableExtend";
|
|
3
|
-
import contextMenu from "./contextMenu";
|
|
4
|
-
import type { App } from "vue";
|
|
5
|
-
|
|
6
|
-
const components: any[] = [textButton, tableExtend, contextMenu];
|
|
7
|
-
|
|
8
|
-
function install(app: App) {
|
|
9
|
-
components.forEach((component) => {
|
|
10
|
-
app.use(component);
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export type { TableProp, TableColumn } from "./tableExtend";
|
|
15
|
-
|
|
16
|
-
export { install, textButton, tableExtend, contextMenu };
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
.contextmenu {
|
|
2
|
-
position: fixed;
|
|
3
|
-
top: 110px;
|
|
4
|
-
left: 200px;
|
|
5
|
-
z-index: 10000;
|
|
6
|
-
|
|
7
|
-
&-wrap {
|
|
8
|
-
overflow: hidden;
|
|
9
|
-
color: var(--el-text-color-regular);
|
|
10
|
-
background-color: var(--el-bg-color);
|
|
11
|
-
border-radius: var(--el-border-radius-base);
|
|
12
|
-
box-shadow: var(--el-box-shadow);
|
|
13
|
-
padding: 5px 0;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
&-items {
|
|
18
|
-
list-style-type: none;
|
|
19
|
-
box-sizing: border-box;
|
|
20
|
-
|
|
21
|
-
.el-divider--horizontal {
|
|
22
|
-
margin: 5px 0;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
li {
|
|
26
|
-
cursor: pointer;
|
|
27
|
-
user-select: none;
|
|
28
|
-
height: 34px;
|
|
29
|
-
padding: 0 20px;
|
|
30
|
-
margin: 0 5px;
|
|
31
|
-
// border-bottom: 1px solid var(--el-border-color-extra-light);
|
|
32
|
-
display: flex;
|
|
33
|
-
gap: 10px;
|
|
34
|
-
align-items: center;
|
|
35
|
-
border-radius: var(--el-border-radius-base);
|
|
36
|
-
transition: background-color .3s cubic-bezier(.4, 0, .2, 1);
|
|
37
|
-
|
|
38
|
-
&:last-child {
|
|
39
|
-
border: none;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
&:hover {
|
|
43
|
-
background-color: var(--el-color-primary-light-7);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
package/src/styles/index.scss
DELETED
package/src/styles/lowcode.scss
DELETED
|
File without changes
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
.table-extend {
|
|
2
|
-
display: flex;
|
|
3
|
-
flex-direction: column;
|
|
4
|
-
flex: 1 0 0%;
|
|
5
|
-
align-items: center;
|
|
6
|
-
width: 100%;
|
|
7
|
-
height: 100%;
|
|
8
|
-
position: relative;
|
|
9
|
-
min-height: 200px;
|
|
10
|
-
|
|
11
|
-
.tool-panel {
|
|
12
|
-
display: flex;
|
|
13
|
-
width: 100%;
|
|
14
|
-
margin-bottom: 10px;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.left-panel,
|
|
18
|
-
.right-panel {
|
|
19
|
-
display: flex;
|
|
20
|
-
flex-wrap: wrap;
|
|
21
|
-
align-items: center;
|
|
22
|
-
gap: 10px;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.right-panel {
|
|
26
|
-
flex: 1 0 0;
|
|
27
|
-
justify-content: flex-end;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.el-table--border td {
|
|
31
|
-
border-right: none !important;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.el-pagination {
|
|
35
|
-
margin-top: 20px;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.el-empty {
|
|
39
|
-
padding: 0;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.el-empty__description {
|
|
43
|
-
margin-top: 0;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.default-tool {
|
|
48
|
-
font-size: 18px;
|
|
49
|
-
margin-left: 10px;
|
|
50
|
-
display: flex;
|
|
51
|
-
align-items: center;
|
|
52
|
-
height: 100%;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.set-column-list-wrap {
|
|
56
|
-
max-height: 70vh;
|
|
57
|
-
overflow: auto;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.set-column-check-group {
|
|
61
|
-
.group-item {
|
|
62
|
-
display: flex;
|
|
63
|
-
align-items: center;
|
|
64
|
-
justify-content: space-between;
|
|
65
|
-
min-height: 32px;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
.fixed-wrap {
|
|
69
|
-
display: flex;
|
|
70
|
-
justify-content: space-between;
|
|
71
|
-
width: 50px;
|
|
72
|
-
font-size: 16px;
|
|
73
|
-
color: #333;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
.fixed-icon {
|
|
77
|
-
cursor: pointer;
|
|
78
|
-
|
|
79
|
-
&:first-child {
|
|
80
|
-
transform: rotate(-90deg);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
&:last-child {
|
|
84
|
-
transform: rotate(90deg);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
&.active {
|
|
88
|
-
color: var(--el-color-primary);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
.text-button {
|
|
2
|
-
display: inline-block;
|
|
3
|
-
font-size: 12px;
|
|
4
|
-
cursor: pointer;
|
|
5
|
-
user-select: none;
|
|
6
|
-
|
|
7
|
-
&.is-disabled {
|
|
8
|
-
cursor: not-allowed !important;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
&-default {
|
|
12
|
-
color: inherit;
|
|
13
|
-
&.is-disabled {
|
|
14
|
-
color: var(--el-text-color-disabled);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
&-primary {
|
|
18
|
-
color: var(--el-color-primary);
|
|
19
|
-
&.is-disabled {
|
|
20
|
-
color: var(--el-color-primary-light-5);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
&-success {
|
|
24
|
-
color: var(--el-color-success);
|
|
25
|
-
&.is-disabled {
|
|
26
|
-
color: var(--el-color-success-light-5);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
&-warning {
|
|
30
|
-
color: var(--el-color-warning);
|
|
31
|
-
&.is-disabled {
|
|
32
|
-
color: var(--el-color-warning-light-5);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
&-danger {
|
|
36
|
-
color: var(--el-color-danger);
|
|
37
|
-
&.is-disabled {
|
|
38
|
-
color: var(--el-color-danger-light-5);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
&-error {
|
|
42
|
-
color: var(--el-color-error);
|
|
43
|
-
&.is-disabled {
|
|
44
|
-
color: var(--el-color-error-light-5);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
&-info {
|
|
48
|
-
color: var(--el-color-info);
|
|
49
|
-
&.is-disabled {
|
|
50
|
-
color: var(--el-color-info-light-5);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
package/src/tableExtend/index.ts
DELETED
package/src/tableExtend/props.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { PropType } from "vue";
|
|
2
|
-
import { TableAttr, TableColumn } from "./type";
|
|
3
|
-
|
|
4
|
-
/**表单组件属性 */
|
|
5
|
-
export default function props() {
|
|
6
|
-
return {
|
|
7
|
-
/**UI选项配置 */
|
|
8
|
-
options: {
|
|
9
|
-
type: Object as PropType<TableAttr>,
|
|
10
|
-
default: () => {
|
|
11
|
-
return {};
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
/**表格数据源 */
|
|
15
|
-
tableData: {
|
|
16
|
-
type: Array,
|
|
17
|
-
default: [],
|
|
18
|
-
},
|
|
19
|
-
/**表格列(所有列) */
|
|
20
|
-
tableColums: {
|
|
21
|
-
type: Array as PropType<Array<TableColumn>>,
|
|
22
|
-
default: () => [],
|
|
23
|
-
},
|
|
24
|
-
/**loading显示状态 */
|
|
25
|
-
tableLoading: Boolean,
|
|
26
|
-
/**是否显示列check */
|
|
27
|
-
selectionCol: {
|
|
28
|
-
type: Boolean,
|
|
29
|
-
default: () => true,
|
|
30
|
-
},
|
|
31
|
-
/**是否显示索引列 */
|
|
32
|
-
indexCol: {
|
|
33
|
-
type: Boolean,
|
|
34
|
-
default: () => true,
|
|
35
|
-
},
|
|
36
|
-
/**是否能设置表格列 */
|
|
37
|
-
isSetColumn: {
|
|
38
|
-
type: Boolean,
|
|
39
|
-
default: () => false,
|
|
40
|
-
},
|
|
41
|
-
/**是否显示分页 */
|
|
42
|
-
paging: {
|
|
43
|
-
type: Object as PropType<{ pageIndex: number; pageSize: number }>,
|
|
44
|
-
},
|
|
45
|
-
/**总数 */
|
|
46
|
-
total: Number,
|
|
47
|
-
/**可选页面大小 */
|
|
48
|
-
sizeList: {
|
|
49
|
-
type: Array as PropType<Array<number>>,
|
|
50
|
-
default: () => [15, 20, 30, 50, 100],
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<el-popover placement="bottom" title="列显示设置" :width="220">
|
|
3
|
-
<template #reference>
|
|
4
|
-
<el-icon>
|
|
5
|
-
<Setting />
|
|
6
|
-
</el-icon>
|
|
7
|
-
</template>
|
|
8
|
-
<div class="set-column-list-wrap">
|
|
9
|
-
<el-checkbox :indeterminate="isIndeterminate" v-model="checkAllColumns" @change="onCheckAllColumnChange">全选
|
|
10
|
-
</el-checkbox>
|
|
11
|
-
<el-checkbox-group class="set-column-check-group" v-model="checkColumnProp" @change="onCheckedColumnChange">
|
|
12
|
-
<div class="group-item" v-for="colum in tableColums" :key="colum.prop">
|
|
13
|
-
<el-checkbox class="set-column-check" :label="colum.prop">{{ colum.label }}</el-checkbox>
|
|
14
|
-
<div class="fixed-wrap">
|
|
15
|
-
<el-icon :class="['fixed-icon', colum.fixed === 'left' && 'active']" title="固定到左边"
|
|
16
|
-
@click="onChangeFixed('left', colum)">
|
|
17
|
-
<Upload />
|
|
18
|
-
</el-icon>
|
|
19
|
-
<el-divider direction="vertical" />
|
|
20
|
-
<el-icon :class="['fixed-icon', colum.fixed === 'right' && 'active']" title="固定到右边"
|
|
21
|
-
@click="onChangeFixed('right', colum)">
|
|
22
|
-
<Upload />
|
|
23
|
-
</el-icon>
|
|
24
|
-
</div>
|
|
25
|
-
</div>
|
|
26
|
-
</el-checkbox-group>
|
|
27
|
-
</div>
|
|
28
|
-
</el-popover>
|
|
29
|
-
</template>
|
|
30
|
-
|
|
31
|
-
<script lang="ts" setup>
|
|
32
|
-
import { computed, inject, ref } from 'vue';
|
|
33
|
-
import type { TableProvies } from './../type';
|
|
34
|
-
|
|
35
|
-
const tableProps = inject<TableProvies>("table-extend");
|
|
36
|
-
/**显示列设置-全选 */
|
|
37
|
-
const checkAllColumns = ref<boolean>(true);
|
|
38
|
-
/**显示列设置-全选状态 */
|
|
39
|
-
const isIndeterminate = ref<boolean>(false);
|
|
40
|
-
/**列设置-选中列 */
|
|
41
|
-
const checkColumnProp = computed<Array<string>>(() => {
|
|
42
|
-
return tableProps && tableProps.columnConfig.showColumn.map((m) => m.prop as string) || [];
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
const tableColums = computed(() => {
|
|
46
|
-
return tableProps?.tableColums.value || []
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
/**显示列全选 */
|
|
50
|
-
function onCheckAllColumnChange(e: boolean) {
|
|
51
|
-
if (e) {
|
|
52
|
-
tableProps && (
|
|
53
|
-
tableProps.columnConfig.showColumn = tableColums.value)
|
|
54
|
-
} else {
|
|
55
|
-
tableProps && (
|
|
56
|
-
tableProps.columnConfig.showColumn = []);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**显示列设置-列显示/隐藏切换 */
|
|
61
|
-
function onCheckedColumnChange(colProps: Array<string>) {
|
|
62
|
-
if (tableProps) {
|
|
63
|
-
tableProps.columnConfig.showColumn = tableColums.value.filter((f: any) => colProps.includes(f.prop));
|
|
64
|
-
const checkedCount = colProps.length;
|
|
65
|
-
checkAllColumns.value = checkedCount === tableColums.value.length;
|
|
66
|
-
isIndeterminate.value = checkedCount > 0 && checkedCount < tableColums.value.length;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**固定列 */
|
|
71
|
-
function onChangeFixed(type: 'left' | 'right', prop: any) {
|
|
72
|
-
if (prop.fixed === type) {
|
|
73
|
-
prop.fixed = undefined;
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
prop.fixed = type;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
</script>
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="table-extend">
|
|
3
|
-
<div class="tool-panel">
|
|
4
|
-
<div class="left-panel">
|
|
5
|
-
<slot name="tool-left"></slot>
|
|
6
|
-
</div>
|
|
7
|
-
<div class="right-panel">
|
|
8
|
-
<slot name="tool-right">
|
|
9
|
-
</slot>
|
|
10
|
-
<div class="default-tool">
|
|
11
|
-
<col-visible-setting v-if="isSetColumn"></col-visible-setting>
|
|
12
|
-
</div>
|
|
13
|
-
</div>
|
|
14
|
-
</div>
|
|
15
|
-
<el-table ref="tableRef" v-bind="tableAttribute" :data="tableData" v-loading="tableLoading" @sort-change="tableSort"
|
|
16
|
-
@selection-change="handleSelectionChange" @row-click="rowClick" @row-dblclick="rowDblClick">
|
|
17
|
-
<el-table-column v-if="selectionCol" type="selection" width="48" fixed="left"></el-table-column>
|
|
18
|
-
<el-table-column v-if="indexCol" type="index" width="58" fixed="left"></el-table-column>
|
|
19
|
-
<template v-for="item in colSettingList" :key="item.prop">
|
|
20
|
-
<el-table-column v-if="item.isHtml" v-bind="item">
|
|
21
|
-
<template #default="scope">
|
|
22
|
-
<div v-html="item.prop && scope.row[item.prop]"></div>
|
|
23
|
-
</template>
|
|
24
|
-
</el-table-column>
|
|
25
|
-
<template v-else>
|
|
26
|
-
<el-table-column v-if="item.init" v-bind="item">
|
|
27
|
-
<template #default="scope">
|
|
28
|
-
<slot :name="`col_${item.prop}`" :data="scope.row">
|
|
29
|
-
<value-col v-bind="{ row: scope.row, colCfg: item }"></value-col>
|
|
30
|
-
</slot>
|
|
31
|
-
</template>
|
|
32
|
-
</el-table-column>
|
|
33
|
-
</template>
|
|
34
|
-
</template>
|
|
35
|
-
<slot name="operatColumn"></slot>
|
|
36
|
-
<template #empty>
|
|
37
|
-
<el-empty :image-size="60"></el-empty>
|
|
38
|
-
</template>
|
|
39
|
-
</el-table>
|
|
40
|
-
<el-pagination v-if="hasPagination" background v-model:current-page="pagination.pageIndex"
|
|
41
|
-
v-model:page-size="pagination.pageSize" :page-sizes="sizeList" layout="total, sizes, prev, pager, next, jumper"
|
|
42
|
-
:total="total"></el-pagination>
|
|
43
|
-
</div>
|
|
44
|
-
</template>
|
|
45
|
-
|
|
46
|
-
<script lang="ts" setup>
|
|
47
|
-
import { nextTick, onMounted, provide, ref, toRef, watch } from "vue";
|
|
48
|
-
import { useI18n } from 'vue-i18n';
|
|
49
|
-
import useTable from "./../useTable";
|
|
50
|
-
import type { TableProvies } from "./../type";
|
|
51
|
-
import useProps from './../props';
|
|
52
|
-
import ValueCol from './valueCol.vue';
|
|
53
|
-
import ColVisibleSetting from './colVisible.vue';
|
|
54
|
-
|
|
55
|
-
const props = defineProps({ ...useProps() });
|
|
56
|
-
|
|
57
|
-
const emit = defineEmits([
|
|
58
|
-
"tableSort",
|
|
59
|
-
"handleSelectionChange",
|
|
60
|
-
"currentChange",
|
|
61
|
-
"pageSizeChange",
|
|
62
|
-
"rowClick",
|
|
63
|
-
"rowDblClick"
|
|
64
|
-
]);
|
|
65
|
-
|
|
66
|
-
const { t: i18nInstance } = useI18n();
|
|
67
|
-
|
|
68
|
-
const {
|
|
69
|
-
selectionOptions,
|
|
70
|
-
tableAttribute,
|
|
71
|
-
pagination,
|
|
72
|
-
hasPagination,
|
|
73
|
-
columnConfig,
|
|
74
|
-
colSettingList,
|
|
75
|
-
} = useTable(i18nInstance);
|
|
76
|
-
|
|
77
|
-
provide<TableProvies>("table-extend", {
|
|
78
|
-
tableProps: props,
|
|
79
|
-
tableColums: toRef(props, "tableColums"),
|
|
80
|
-
columnConfig,
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
const tableRef = ref<any>(null);
|
|
84
|
-
|
|
85
|
-
const isPageSizeChange = ref<boolean>(false);
|
|
86
|
-
|
|
87
|
-
watch(
|
|
88
|
-
() => props.tableColums,
|
|
89
|
-
() => {
|
|
90
|
-
columnConfig.showColumn = props.tableColums;
|
|
91
|
-
}
|
|
92
|
-
)
|
|
93
|
-
|
|
94
|
-
/**页面变更 */
|
|
95
|
-
watch(
|
|
96
|
-
() => pagination.pageIndex,
|
|
97
|
-
(page_index) => {
|
|
98
|
-
if (page_index && page_index > 0) {
|
|
99
|
-
if (isPageSizeChange.value) {
|
|
100
|
-
isPageSizeChange.value = false;
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
emit("currentChange", page_index);
|
|
104
|
-
tableRef.value.setScrollTop(0);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
)
|
|
108
|
-
|
|
109
|
-
/**分页大小变更 */
|
|
110
|
-
watch(() => pagination.pageSize,
|
|
111
|
-
(page_size) => {
|
|
112
|
-
if (page_size && page_size > 0) {
|
|
113
|
-
// pageSize变更时,取消pageIndex副作用
|
|
114
|
-
isPageSizeChange.value = true;
|
|
115
|
-
pagination.pageIndex = 1;
|
|
116
|
-
emit("pageSizeChange", page_size);
|
|
117
|
-
tableRef.value.setScrollTop(0);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
)
|
|
121
|
-
|
|
122
|
-
onMounted((): void => {
|
|
123
|
-
nextTick(() => {
|
|
124
|
-
props.tableColums && props.tableColums.length > 0 && (columnConfig.showColumn = props.tableColums);
|
|
125
|
-
})
|
|
126
|
-
})
|
|
127
|
-
|
|
128
|
-
defineExpose({
|
|
129
|
-
clearSelection,
|
|
130
|
-
toggleRowSelection
|
|
131
|
-
})
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* 排序
|
|
135
|
-
*/
|
|
136
|
-
function tableSort(column: any) {
|
|
137
|
-
emit("tableSort", {
|
|
138
|
-
sortName: column.prop,
|
|
139
|
-
sortType:
|
|
140
|
-
column.order === "descending"
|
|
141
|
-
? "desc"
|
|
142
|
-
: column.order === "ascending"
|
|
143
|
-
? "asc"
|
|
144
|
-
: "",
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* 行勾选事件
|
|
150
|
-
*/
|
|
151
|
-
function handleSelectionChange(rows: any) {
|
|
152
|
-
selectionOptions.rows = rows;
|
|
153
|
-
selectionOptions.count = rows && rows.length;
|
|
154
|
-
emit("handleSelectionChange", rows);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* 行点击事件
|
|
159
|
-
*/
|
|
160
|
-
function rowClick(rows: any) {
|
|
161
|
-
emit("rowClick", rows);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* 双击事件
|
|
166
|
-
*/
|
|
167
|
-
function rowDblClick(rows: any) {
|
|
168
|
-
emit('rowDblClick', rows);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
function clearSelection() {
|
|
172
|
-
tableRef.value?.clearSelection();
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
function toggleRowSelection(row: any) {
|
|
176
|
-
tableRef.value?.toggleRowSelection(row);
|
|
177
|
-
}
|
|
178
|
-
</script>
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<span>{{ column != undefined ? column : "--" }}</span>
|
|
3
|
-
</template>
|
|
4
|
-
|
|
5
|
-
<script lang="ts" setup>
|
|
6
|
-
import { computed } from 'vue';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const props = defineProps({
|
|
10
|
-
row: {
|
|
11
|
-
type: Object,
|
|
12
|
-
default: () => { }
|
|
13
|
-
},
|
|
14
|
-
colCfg: {
|
|
15
|
-
type: Object,
|
|
16
|
-
default: () => { }
|
|
17
|
-
}
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
const column = computed(() => {
|
|
21
|
-
const { row, colCfg } = props
|
|
22
|
-
return row[colCfg.prop]
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
</script>
|
package/src/tableExtend/type.ts
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import type { Ref } from "vue";
|
|
2
|
-
|
|
3
|
-
// 定义可设置table属性的结构
|
|
4
|
-
export type TableAttr = {
|
|
5
|
-
/**rowKey */
|
|
6
|
-
rowKey?: string;
|
|
7
|
-
/**loading显示文本 */
|
|
8
|
-
"element-loading-text"?: string;
|
|
9
|
-
/**loading 图标 */
|
|
10
|
-
"element-loading-spinner"?: string;
|
|
11
|
-
/**loading 遮罩背景色 */
|
|
12
|
-
"element-loading-background"?: string;
|
|
13
|
-
/** 选中行高亮*/
|
|
14
|
-
highlightCurrentRow?: boolean;
|
|
15
|
-
/**斑马样式 */
|
|
16
|
-
stripe?: boolean;
|
|
17
|
-
/**边框 */
|
|
18
|
-
border?: boolean;
|
|
19
|
-
/**空数据显示文本 */
|
|
20
|
-
emptyText?: string;
|
|
21
|
-
/**列合并方法 */
|
|
22
|
-
spanMethod?: Function;
|
|
23
|
-
/**合计列计算方法 */
|
|
24
|
-
summaryMethod?: Function;
|
|
25
|
-
/**树形配置 */
|
|
26
|
-
treeProps?: { children: string; hasChildren: string };
|
|
27
|
-
/**默认展开行 */
|
|
28
|
-
expandRowKeys?: Array<string | number>;
|
|
29
|
-
/**默认展开全部 */
|
|
30
|
-
defaultExpandAll?: boolean;
|
|
31
|
-
/**表格高度,默认自适应 */
|
|
32
|
-
height?: string | number;
|
|
33
|
-
/**主轴的最小尺寸 */
|
|
34
|
-
flexible?: boolean;
|
|
35
|
-
/**是否显示表头 */
|
|
36
|
-
showHeader?: boolean;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
/**分页 */
|
|
40
|
-
export type Pagination = {
|
|
41
|
-
/**页码 */
|
|
42
|
-
pageIndex: number | undefined;
|
|
43
|
-
/**每页显示数量 */
|
|
44
|
-
pageSize: number | undefined;
|
|
45
|
-
has: boolean;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
/**列配置 */
|
|
49
|
-
export type ColumnConfig = {
|
|
50
|
-
/**显示列 */
|
|
51
|
-
showColumn: TableColumn[];
|
|
52
|
-
/**隐藏列 */
|
|
53
|
-
hiddenColumn: TableColumn[];
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
/**注入结构 */
|
|
57
|
-
export type TableProvies = {
|
|
58
|
-
tableProps: TableProp;
|
|
59
|
-
tableColums: Ref<Array<TableColumn>>;
|
|
60
|
-
columnConfig: ColumnConfig;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export type ImageViewer = {
|
|
64
|
-
/**是否显示 */
|
|
65
|
-
show: boolean;
|
|
66
|
-
/**图片路径 */
|
|
67
|
-
filePathList: any[];
|
|
68
|
-
/**显示图片的索引 */
|
|
69
|
-
index: number;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
export enum FileType {
|
|
73
|
-
/** 图片 */
|
|
74
|
-
PICTURE = 1,
|
|
75
|
-
/** PDF */
|
|
76
|
-
PDF = 2,
|
|
77
|
-
/** 其他 */
|
|
78
|
-
OTHER = 3,
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**表格属性 */
|
|
82
|
-
export interface TableProp {
|
|
83
|
-
/**UI选项配置 */
|
|
84
|
-
options?: TableAttr;
|
|
85
|
-
/**表格数据源 */
|
|
86
|
-
tableData?: Array<any>;
|
|
87
|
-
/**表格列(所有列) */
|
|
88
|
-
tableColums: Array<TableColumn>;
|
|
89
|
-
/**Loading状态 */
|
|
90
|
-
tableLoading?: boolean;
|
|
91
|
-
/**是否显示列check,默认true */
|
|
92
|
-
selectionCol?: boolean;
|
|
93
|
-
/**是否显示索引列,默认true */
|
|
94
|
-
indexCol?: boolean;
|
|
95
|
-
/**是否能设置表格列,默认false */
|
|
96
|
-
isSetColumn?: boolean;
|
|
97
|
-
/**分页配置 */
|
|
98
|
-
paging?: {
|
|
99
|
-
pageIndex: number;
|
|
100
|
-
pageSize: number;
|
|
101
|
-
};
|
|
102
|
-
/**总数 */
|
|
103
|
-
total?: number;
|
|
104
|
-
/**可选页面大小 */
|
|
105
|
-
sizeList?: Array<number>;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export interface TableColumn {
|
|
109
|
-
/**
|
|
110
|
-
* 表头文本对齐方式
|
|
111
|
-
*/
|
|
112
|
-
headerAlign?: string;
|
|
113
|
-
/**
|
|
114
|
-
* 表格内容对齐方式
|
|
115
|
-
*/
|
|
116
|
-
align?: string;
|
|
117
|
-
/**
|
|
118
|
-
* 列绑定数据字段
|
|
119
|
-
*/
|
|
120
|
-
prop?: string;
|
|
121
|
-
/**
|
|
122
|
-
* 表头名称
|
|
123
|
-
*/
|
|
124
|
-
label?: string;
|
|
125
|
-
/**
|
|
126
|
-
* 是否显示
|
|
127
|
-
*/
|
|
128
|
-
init?: boolean;
|
|
129
|
-
/**
|
|
130
|
-
* 表格宽度
|
|
131
|
-
*/
|
|
132
|
-
width?: number;
|
|
133
|
-
/**
|
|
134
|
-
* 最小宽度
|
|
135
|
-
*/
|
|
136
|
-
minWidth?: number;
|
|
137
|
-
/**
|
|
138
|
-
* 是否显示单元格内容tooltip
|
|
139
|
-
*/
|
|
140
|
-
showOverflowTooltip?: boolean;
|
|
141
|
-
/**
|
|
142
|
-
* 是否能排序
|
|
143
|
-
*/
|
|
144
|
-
sortable?: boolean;
|
|
145
|
-
/** 是否固定 */
|
|
146
|
-
fixed?: "left" | "right";
|
|
147
|
-
/** 是否为文件 */
|
|
148
|
-
isFile?: boolean;
|
|
149
|
-
/**
|
|
150
|
-
* 图片类型
|
|
151
|
-
*/
|
|
152
|
-
fileType?: FileType;
|
|
153
|
-
/**
|
|
154
|
-
* 数据是否为HTML
|
|
155
|
-
*/
|
|
156
|
-
isHtml?: boolean;
|
|
157
|
-
/**
|
|
158
|
-
* 是否为进度条
|
|
159
|
-
*/
|
|
160
|
-
isProgress?: boolean;
|
|
161
|
-
/**
|
|
162
|
-
* 是否为工序进度
|
|
163
|
-
*/
|
|
164
|
-
isProcess?: boolean;
|
|
165
|
-
/**
|
|
166
|
-
* 组件配置列表
|
|
167
|
-
*/
|
|
168
|
-
componentOption?: any;
|
|
169
|
-
/**页面Id*/
|
|
170
|
-
// pageId?: number;
|
|
171
|
-
/**多语言配置 */
|
|
172
|
-
langue?: string;
|
|
173
|
-
}
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { computed, getCurrentInstance, reactive, toRef } from "vue";
|
|
2
|
-
import {
|
|
3
|
-
ColumnConfig,
|
|
4
|
-
ImageViewer,
|
|
5
|
-
TableAttr,
|
|
6
|
-
TableColumn,
|
|
7
|
-
FileType,
|
|
8
|
-
} from "./type";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* useTable
|
|
12
|
-
*/
|
|
13
|
-
export default function useTable(i18nInstance?: (key: string) => string) {
|
|
14
|
-
/**表格实例 */
|
|
15
|
-
const currentInstance = getCurrentInstance();
|
|
16
|
-
/**表格属性 */
|
|
17
|
-
const props: any = currentInstance?.props;
|
|
18
|
-
/**
|
|
19
|
-
* 默认外观配置
|
|
20
|
-
* @type {*}
|
|
21
|
-
*/
|
|
22
|
-
const defalutTableAttr: TableAttr = {
|
|
23
|
-
rowKey: "Id",
|
|
24
|
-
"element-loading-text": "加载中…",
|
|
25
|
-
"element-loading-background": "rgba(0, 0, 0, 0.2)",
|
|
26
|
-
highlightCurrentRow: true,
|
|
27
|
-
stripe: true,
|
|
28
|
-
border: false,
|
|
29
|
-
height: "100%",
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* 默认列配置
|
|
33
|
-
* @type {*}
|
|
34
|
-
*/
|
|
35
|
-
const defColSetting: TableColumn = {
|
|
36
|
-
headerAlign: undefined,
|
|
37
|
-
align: undefined,
|
|
38
|
-
prop: undefined,
|
|
39
|
-
label: undefined,
|
|
40
|
-
init: true,
|
|
41
|
-
width: undefined,
|
|
42
|
-
showOverflowTooltip: false,
|
|
43
|
-
sortable: undefined,
|
|
44
|
-
fixed: undefined,
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
/**表格属性 */
|
|
48
|
-
const tableAttribute = computed<Record<string, any>>(() => {
|
|
49
|
-
return {
|
|
50
|
-
...defalutTableAttr,
|
|
51
|
-
...(Object.keys(props.options).length > 0 ? props.options : {}),
|
|
52
|
-
};
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
/** 选中行 */
|
|
56
|
-
const selectionOptions = reactive<Record<string, any>>({
|
|
57
|
-
count: 0,
|
|
58
|
-
rows: [],
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
/**分页设置 */
|
|
62
|
-
const pagination = reactive({
|
|
63
|
-
pageIndex: props?.paging?.pageIndex ? toRef(props.paging, "pageIndex") : 1,
|
|
64
|
-
pageSize: props?.paging?.pageSize ? toRef(props.paging, "pageSize") : 10,
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
const hasPagination = computed(() => {
|
|
68
|
-
return props?.paging?.pageIndex > 0 && props?.paging?.pageSize > 0;
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
/**图片视图配置 */
|
|
72
|
-
const imageViewer = reactive<ImageViewer>({
|
|
73
|
-
/**是否显示 */
|
|
74
|
-
show: false,
|
|
75
|
-
/**图片路径 */
|
|
76
|
-
filePathList: [] as any[],
|
|
77
|
-
/**显示图片的索引 */
|
|
78
|
-
index: 0,
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
/**显示、隐藏列 */
|
|
82
|
-
const columnConfig = reactive<ColumnConfig>({
|
|
83
|
-
showColumn: [],
|
|
84
|
-
hiddenColumn: [],
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
/**表格显示列 */
|
|
88
|
-
const colSettingList = computed<TableColumn[]>(() => {
|
|
89
|
-
// 设置默认显示列(显示优化)
|
|
90
|
-
if (!columnConfig.showColumn || columnConfig.showColumn.length === 0) {
|
|
91
|
-
return [
|
|
92
|
-
{
|
|
93
|
-
prop: "default-prop",
|
|
94
|
-
init: true,
|
|
95
|
-
label: "",
|
|
96
|
-
},
|
|
97
|
-
];
|
|
98
|
-
}
|
|
99
|
-
const colList = columnConfig.showColumn.map((item: TableColumn) => {
|
|
100
|
-
i18nInstance && item.langue && (item.label = i18nInstance(item.langue));
|
|
101
|
-
return { ...defColSetting, ...item };
|
|
102
|
-
});
|
|
103
|
-
return colList;
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
/**是否显示工具栏按钮 */
|
|
107
|
-
const showToolPanel = computed(() => {
|
|
108
|
-
return (
|
|
109
|
-
(currentInstance?.slots["tool-left"]?.()?.length || 0) > 0 ||
|
|
110
|
-
(currentInstance?.slots["tool-right"]?.()?.length || 0) > 0
|
|
111
|
-
);
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* 是否包含图片预览功能
|
|
116
|
-
* @type {*}
|
|
117
|
-
*/
|
|
118
|
-
const hasImageViewer = computed<boolean>(() => {
|
|
119
|
-
return colSettingList.value.some(
|
|
120
|
-
(f: TableColumn) => f.fileType && f.fileType == FileType.PICTURE
|
|
121
|
-
);
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
return {
|
|
125
|
-
defColSetting,
|
|
126
|
-
selectionOptions,
|
|
127
|
-
tableAttribute,
|
|
128
|
-
pagination,
|
|
129
|
-
hasPagination,
|
|
130
|
-
imageViewer,
|
|
131
|
-
columnConfig,
|
|
132
|
-
colSettingList,
|
|
133
|
-
showToolPanel,
|
|
134
|
-
hasImageViewer,
|
|
135
|
-
};
|
|
136
|
-
}
|
package/src/textButton/index.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="text-button" :class="[
|
|
3
|
-
`text-button-${type}`,
|
|
4
|
-
disabled && 'is-disabled'
|
|
5
|
-
]" @click.prevent.stop="onClick">
|
|
6
|
-
<slot></slot>
|
|
7
|
-
</div>
|
|
8
|
-
</template>
|
|
9
|
-
|
|
10
|
-
<script lang="ts" setup>
|
|
11
|
-
|
|
12
|
-
defineOptions({ name: "TextButton" });
|
|
13
|
-
|
|
14
|
-
const props = defineProps({
|
|
15
|
-
type: {
|
|
16
|
-
type: String,
|
|
17
|
-
default: 'primary',
|
|
18
|
-
validator: (val: string) => {
|
|
19
|
-
return [
|
|
20
|
-
'default',
|
|
21
|
-
'primary',
|
|
22
|
-
'success',
|
|
23
|
-
'warning',
|
|
24
|
-
'info',
|
|
25
|
-
'danger',
|
|
26
|
-
].includes(val)
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
disabled: Boolean
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
const emit = defineEmits(["click"])
|
|
33
|
-
|
|
34
|
-
function onClick(e: any): void {
|
|
35
|
-
if (props.disabled) return;
|
|
36
|
-
emit("click", e)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
</script>
|