vue3-smart-table 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),C=require("element-plus"),S=e.defineComponent({__name:"input",props:{row:{},col:{},onCellBlur:{type:Function},onCellEnter:{type:Function}},setup(n){const t=n,l=e.ref(t.row[t.col.key]);e.watch(l,s=>{t.row[t.col.key]=s});const r=()=>{var s;return(s=t.onCellBlur)==null?void 0:s.call(t,t.row,t.col)},o=()=>{var s;return(s=t.onCellEnter)==null?void 0:s.call(t,t.row,t.col)};return(s,c)=>{const m=e.resolveComponent("el-input");return e.openBlock(),e.createBlock(m,e.mergeProps({modelValue:l.value,"onUpdate:modelValue":c[0]||(c[0]=d=>l.value=d)},{placeholder:"",size:"small",clearable:!0,...n.col.renderProps},{onBlur:r,onKeyup:e.withKeys(o,["enter"])}),null,16,["modelValue"])}}}),V=e.defineComponent({__name:"inputNumber",props:{row:{},col:{},onCellChange:{type:Function},onCellBlur:{type:Function},onCellEnter:{type:Function}},setup(n){const t=n,l=e.ref(t.row[t.col.key]);e.watch(l,s=>{var c;t.row[t.col.key]=s,(c=t.onCellChange)==null||c.call(t,t.row,t.col)});const r=()=>{var s;return(s=t.onCellBlur)==null?void 0:s.call(t,t.row,t.col)},o=()=>{var s;return(s=t.onCellEnter)==null?void 0:s.call(t,t.row,t.col)};return(s,c)=>{const m=e.resolveComponent("el-input-number");return e.openBlock(),e.createBlock(m,e.mergeProps({modelValue:l.value,"onUpdate:modelValue":c[0]||(c[0]=d=>l.value=d)},{min:0,max:99999,controls:!1,size:"small",...n.col.renderProps},{onBlur:r,onKeyup:e.withKeys(o,["enter"])}),null,16,["modelValue"])}}}),F=e.defineComponent({__name:"select",props:{row:{},col:{},onCellChange:{type:Function},onCellBlur:{type:Function},onCellEnter:{type:Function}},setup(n){const t=n,l=e.ref(t.row[t.col.key]);e.watch(l,c=>{t.row[t.col.key]=c});const r=()=>{var c;return(c=t.onCellChange)==null?void 0:c.call(t,t.row,t.col)},o=()=>{var c;return(c=t.onCellBlur)==null?void 0:c.call(t,t.row,t.col)},s=()=>{var c;return(c=t.onCellEnter)==null?void 0:c.call(t,t.row,t.col)};return(c,m)=>{const d=e.resolveComponent("el-option"),i=e.resolveComponent("el-select");return e.openBlock(),e.createBlock(i,e.mergeProps({modelValue:l.value,"onUpdate:modelValue":m[0]||(m[0]=f=>l.value=f)},{placeholder:"请选择",size:"small",clearable:!0,...n.col.renderProps},{onChange:r,onBlur:o,onKeyup:e.withKeys(s,["enter"])}),{default:e.withCtx(()=>{var f;return[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(((f=n.col.renderProps)==null?void 0:f.options)||[],u=>(e.openBlock(),e.createBlock(d,{key:u.value,label:u.label,value:u.value},null,8,["label","value"]))),128))]}),_:1},16,["modelValue"])}}}),_=n=>e.defineComponent({props:["row","col","onCellChange","onCellBlur","onCellEnter","onClick"],setup(t){return()=>e.h(n,t)}});function A(n){return typeof n.formatter=="function"}function K(){return{input:_(S),"input-number":_(V),select:_(F),button:n=>{const t=n.col.renderProps||{};return e.h(C.ElButton,{type:t.type||"primary",...t,onClick:()=>{var l;return(l=n.onClick)==null?void 0:l.call(n,n.row,n.col)}},()=>t.label||n.row[n.col.key])},link:n=>{const t=n.col.renderProps||{};return e.h("a",{href:t.href||"#",target:t.blank?"_blank":"_self",style:t.style||"color:#409EFF;cursor:pointer;",onClick:l=>{var r;l.preventDefault(),(r=n.onClick)==null||r.call(n,n.row,n.col)}},t.label||n.row[n.col.key])},html:n=>{var t;return e.h("div",{class:"line-clamp-2",innerHTML:n.row[n.col.key]??"",...((t=n.col)==null?void 0:t.renderProps)||{}})},copy:n=>{const t=n.row[n.col.key]??"";return e.h("div",{class:"copy-wrapper",style:"position: relative; display: inline-block;"},[e.h("span",{class:"copy-text line-clamp-1",style:"padding-right: 20px;"},t),e.h("span",{class:"copy-btn",style:`
|
|
2
2
|
position: absolute;
|
|
3
3
|
right: 0;
|
|
4
4
|
top: 50%;
|
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
font-size: 12px;
|
|
9
9
|
color: #409EFF;
|
|
10
10
|
user-select: none;
|
|
11
|
-
`,onClick:()=>{if(t)try{if(navigator.clipboard&&navigator.clipboard.writeText)navigator.clipboard.writeText(t).then(()=>{C.ElMessage.success("复制成功")}).catch(()=>{C.ElMessage.error("复制失败")});else{const l=document.createElement("textarea");l.value=t,l.style.position="fixed",l.style.opacity="0",document.body.appendChild(l),l.select();const r=document.execCommand("copy");document.body.removeChild(l),r?C.ElMessage.success("复制成功"):C.ElMessage.error("复制失败")}}catch{C.ElMessage.error("复制失败")}}},"📋")])},img:n=>{var r;const t=n.row[n.col.key]??"",l=((r=n.col)==null?void 0:r.renderProps)||{};return e.h(C.ElImage,{src:t,previewSrcList:(l==null?void 0:l.previewSrcList)??(Array.isArray(t)?t:[t]),fit:"contain",style:"width:80px;height:80px",...l})},dict:n=>{const t=n.row[n.col.key],l=n.col.renderProps||{},r=l.options??[],o=l.showValue??!1;if(t==null||t==="")return"";const s=Array.isArray(t)?t.map(String):[String(t)],c=r.filter(i=>s.includes(String(i.value))),m=s.filter(i=>!r.some(f=>String(f.value)===i)),d=c.map((i,f)=>e.h(C.ElTag,{key:i.value,type:i.listClass,class:i.cssClass,disableTransitions:!0},{default:()=>i.label+" "}));return o&&m.length>0&&d.push(e.h("span",{},m.join(" "))),e.h("div",{},d)},map:n=>{var r;const t=n.row[n.col.key],l=((r=n.col.renderProps)==null?void 0:r.options)??{};return t!=null?l[t]??"":""},formatter:n=>{var o;const{col:t,row:l}=n,r=l[t.key];return
|
|
11
|
+
`,onClick:()=>{if(t)try{if(navigator.clipboard&&navigator.clipboard.writeText)navigator.clipboard.writeText(t).then(()=>{C.ElMessage.success("复制成功")}).catch(()=>{C.ElMessage.error("复制失败")});else{const l=document.createElement("textarea");l.value=t,l.style.position="fixed",l.style.opacity="0",document.body.appendChild(l),l.select();const r=document.execCommand("copy");document.body.removeChild(l),r?C.ElMessage.success("复制成功"):C.ElMessage.error("复制失败")}}catch{C.ElMessage.error("复制失败")}}},"📋")])},img:n=>{var r;const t=n.row[n.col.key]??"",l=((r=n.col)==null?void 0:r.renderProps)||{};return e.h(C.ElImage,{src:t,previewSrcList:(l==null?void 0:l.previewSrcList)??(Array.isArray(t)?t:[t]),fit:"contain",style:"width:80px;height:80px",...l})},dict:n=>{const t=n.row[n.col.key],l=n.col.renderProps||{},r=l.options??[],o=l.showValue??!1;if(t==null||t==="")return"";const s=Array.isArray(t)?t.map(String):[String(t)],c=r.filter(i=>s.includes(String(i.value))),m=s.filter(i=>!r.some(f=>String(f.value)===i)),d=c.map((i,f)=>e.h(C.ElTag,{key:i.value,type:i.listClass,class:i.cssClass,disableTransitions:!0},{default:()=>i.label+" "}));return o&&m.length>0&&d.push(e.h("span",{},m.join(" "))),e.h("div",{},d)},map:n=>{var r;const t=n.row[n.col.key],l=((r=n.col.renderProps)==null?void 0:r.options)??{};return t!=null?l[t]??"":""},formatter:n=>{var o;const{col:t,row:l}=n,r=l[t.key];return A(t)?(o=t.formatter)==null?void 0:o.call(t,r,l):r??""},icon:n=>{const t=n.row[n.col.key]??"",l=n.col.renderProps||{};return t?/^https?:\/\//.test(t)?e.h(C.ElImage,{src:t,previewSrcList:[t],fit:"contain",style:"width:40px;height:40px",...l}):/^\s*<svg[\s\S]*<\/svg>\s*$/.test(t)?e.h("div",{innerHTML:t,style:`width:40px;height:40px;display:inline-block;${l.style||""}`,...l}):e.h("i",{class:t,style:`font-size:20px;${l.style||""}`,...l}):""}}}function O(n,t=10,l=[]){const o="*:*:*",s=a=>{if(!a)return!0;const p=Array.isArray(a)?a:[a];return l.some(y=>y===o||p.includes(y))},c=e.computed(()=>n.some(a=>s(a.permission))),m=e.computed(()=>n.filter(p=>s(p.permission)).slice(0,t).reduce((p,y)=>p+(y.width??55),0)),d=(a,p)=>s(a.permission)&&(a.visible?a.visible(p):!0),i=a=>n.filter(y=>d(y,a)).slice(0,t).reduce((y,w)=>y+(w.width??55),0);return{hasAnyButton:c,optWidth:m,hasAnyVisibleButton:a=>a!=null&&a.length?a.some(p=>n.some(y=>d(y,p))):!1,getMaxOptWidth:a=>a!=null&&a.length?a.reduce((p,y)=>Math.max(p,i(y)),0):m.value,getVisibleButtons:a=>n.filter(p=>d(p,a)).slice(0,t)}}const M=e.defineComponent({__name:"index",props:{col:{type:Object,required:!0},permissions:{type:Array,default:()=>[]}},emits:["cellBlur","cellEnter","cellChange","cellClick"],setup(n,{emit:t}){const l=n,r=t,{col:o}=e.toRefs(l),s=(h,k)=>r("cellChange",h,k),c=(h,k)=>r("cellBlur",h,k),m=(h,k)=>r("cellEnter",h,k),d=(h,k)=>r("cellClick",h,k),i=K(),{hasAnyButton:f,hasAnyVisibleButton:u,optWidth:g,getMaxOptWidth:a,getVisibleButtons:p}=O(o.value.buttons||[],o.value.maxbtn??10,l.permissions||[]),y=e.computed(()=>(o.value.buttons||[]).length?(o.value.__rows||[]).length?u(o.value.__rows||[]):f.value:!1),w=e.computed(()=>o.value.__rows?a(o.value.__rows):g.value);function E(h){return!(h.type==="selection"||h.type==="index"||h.type==="operation"&&!y.value||h.visible===!1)}return(h,k)=>{const b=e.resolveComponent("el-table-column"),P=e.resolveComponent("el-button");return e.unref(o).type==="selection"?(e.openBlock(),e.createBlock(b,e.mergeProps({key:0,type:"selection"},e.unref(o).columnProps),null,16)):e.unref(o).type==="index"?(e.openBlock(),e.createBlock(b,e.mergeProps({key:1,type:"index",label:e.unref(o).label||"#",align:"center"},e.unref(o).columnProps),null,16,["label"])):e.unref(o).type==="operation"&&y.value?(e.openBlock(),e.createBlock(b,e.mergeProps({key:2,label:e.unref(o).label||"操作",align:"center"},{...e.unref(o).columnProps,width:w.value}),{default:e.withCtx(({row:v})=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(p)(v),B=>(e.openBlock(),e.createBlock(P,{key:B.label,type:B.type||"primary",link:"",onClick:N=>B.action(v)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(B.label),1)]),_:2},1032,["type","onClick"]))),128))]),_:1},16,["label"])):E(e.unref(o))?(e.openBlock(),e.createBlock(b,e.mergeProps({key:3,prop:e.unref(o).key,label:e.unref(o).label,align:"center"},e.unref(o).columnProps||{}),{default:e.withCtx(({row:v})=>[e.unref(o).render&&e.unref(i)[e.unref(o).render]?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(i)[e.unref(o).render]),{key:0,row:v,col:e.unref(o),onCellChange:s,onCellBlur:c,onCellEnter:m,onClick:d},null,40,["row","col"])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode(e.toDisplayString(v[e.unref(o).key]),1)],64))]),_:1},16,["prop","label"])):e.createCommentVNode("",!0)}}}),I="table_columns_";function $(n,t){return`${I}${n}_${t}`}function x(n,t){if(!(t!=null&&t.length))return n;const l=new Map(t.map(r=>[r.key,r]));return n.map(r=>{const o=l.get(r.key);return o?{...r,visible:typeof o.visible=="boolean"?o.visible:r.visible}:r})}function T(n,t){const{pageKey:l,userId:r,storage:o=localStorage}=t||{},c=r?$(r,l||""):null,m=c?o.getItem(c):null,d=e.ref(x(n,m?JSON.parse(m):[]));return e.watch(d,i=>{if(!c)return;const f=i.map(u=>({key:u.key,visible:u.visible,columnOpts:u.columnOpts}));o.setItem(c,JSON.stringify(f))},{deep:!0}),{columns:d,setColumns(i){d.value=x(n,i),c&&o.setItem(c,JSON.stringify(i))},resetColumns(){d.value=n,c&&o.removeItem(c)}}}const W=e.defineComponent({__name:"index",props:{data:{type:Array,default:()=>[]},columns:{type:Array,default:()=>[]},pageKey:String,rowKey:{type:String,default:"id"},loading:{type:Boolean,default:!1},permissions:{type:Array,default:()=>[]},userId:{type:[String,Number],default:""}},emits:["update:columns","cellChange","cellBlur","cellEnter","cell-click"],setup(n,{expose:t,emit:l}){const r=n,o=l,{columns:s}=T(r.columns,{pageKey:r.pageKey??"",userId:r.userId??""});e.watch(s,u=>o("update:columns",u),{deep:!0,immediate:!0});const c=(u,g)=>o("cellChange",u,g),m=(u,g)=>{o("cellBlur",u,g)},d=(u,g)=>{console.log("enter"),o("cellEnter",u,g)},i=(u,g)=>{g&&o("cell-click",u,g)},f=e.ref();return t({tableRef:f}),(u,g)=>{const a=e.resolveComponent("el-table"),p=e.resolveDirective("loading");return e.withDirectives((e.openBlock(),e.createBlock(a,e.mergeProps({ref_key:"tableRef",ref:f},u.$attrs,{data:n.data,"row-key":n.rowKey,class:"smart-table"}),{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(s),y=>(e.openBlock(),e.createBlock(M,{key:y.key,col:y,permissions:n.permissions,onCellChange:c,onCellBlur:m,onCellEnter:d,onCellClick:i},null,8,["col","permissions"]))),128))]),_:1},16,["data","row-key"])),[[p,n.loading]])}}}),D=(n,t)=>{const l=n.__vccOpts||n;for(const[r,o]of t)l[r]=o;return l},L=D(W,[["__scopeId","data-v-338b77db"]]);exports.SmartTable=L;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as x, ref as V, watch as S, resolveComponent as w, createBlock as b, openBlock as f, mergeProps as _, withKeys as M, withCtx as P, createElementBlock as O, Fragment as K, renderList as T, h as g, computed as $, toRefs as U, createCommentVNode as j, unref as d, createTextVNode as D, toDisplayString as N, resolveDynamicComponent as H, resolveDirective as q, withDirectives as X } from "vue";
|
|
2
2
|
import { ElImage as L, ElTag as Y, ElMessage as E, ElButton as G } from "element-plus";
|
|
3
|
-
const Q = /* @__PURE__ */
|
|
3
|
+
const Q = /* @__PURE__ */ x({
|
|
4
4
|
__name: "input",
|
|
5
5
|
props: {
|
|
6
6
|
row: {},
|
|
@@ -31,7 +31,7 @@ const Q = /* @__PURE__ */ B({
|
|
|
31
31
|
}), null, 16, ["modelValue"]);
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
-
}), Z = /* @__PURE__ */
|
|
34
|
+
}), Z = /* @__PURE__ */ x({
|
|
35
35
|
__name: "inputNumber",
|
|
36
36
|
props: {
|
|
37
37
|
row: {},
|
|
@@ -64,7 +64,7 @@ const Q = /* @__PURE__ */ B({
|
|
|
64
64
|
}), null, 16, ["modelValue"]);
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
|
-
}), ee = /* @__PURE__ */
|
|
67
|
+
}), ee = /* @__PURE__ */ x({
|
|
68
68
|
__name: "select",
|
|
69
69
|
props: {
|
|
70
70
|
row: {},
|
|
@@ -89,8 +89,8 @@ const Q = /* @__PURE__ */ B({
|
|
|
89
89
|
return (o = e.onCellEnter) == null ? void 0 : o.call(e, e.row, e.col);
|
|
90
90
|
};
|
|
91
91
|
return (o, y) => {
|
|
92
|
-
const u = w("el-option"),
|
|
93
|
-
return f(), b(
|
|
92
|
+
const u = w("el-option"), i = w("el-select");
|
|
93
|
+
return f(), b(i, _({
|
|
94
94
|
modelValue: n.value,
|
|
95
95
|
"onUpdate:modelValue": y[0] || (y[0] = (h) => n.value = h)
|
|
96
96
|
}, { placeholder: "请选择", size: "small", clearable: !0, ...t.col.renderProps }, {
|
|
@@ -101,10 +101,10 @@ const Q = /* @__PURE__ */ B({
|
|
|
101
101
|
default: P(() => {
|
|
102
102
|
var h;
|
|
103
103
|
return [
|
|
104
|
-
(f(!0), O(K, null, T(((h = t.col.renderProps) == null ? void 0 : h.options) || [], (
|
|
105
|
-
key:
|
|
106
|
-
label:
|
|
107
|
-
value:
|
|
104
|
+
(f(!0), O(K, null, T(((h = t.col.renderProps) == null ? void 0 : h.options) || [], (a) => (f(), b(u, {
|
|
105
|
+
key: a.value,
|
|
106
|
+
label: a.label,
|
|
107
|
+
value: a.value
|
|
108
108
|
}, null, 8, ["label", "value"]))), 128))
|
|
109
109
|
];
|
|
110
110
|
}),
|
|
@@ -112,7 +112,7 @@ const Q = /* @__PURE__ */ B({
|
|
|
112
112
|
}, 16, ["modelValue"]);
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
|
-
}), W = (t) =>
|
|
115
|
+
}), W = (t) => x({
|
|
116
116
|
props: ["row", "col", "onCellChange", "onCellBlur", "onCellEnter", "onClick"],
|
|
117
117
|
setup(e) {
|
|
118
118
|
return () => g(t, e);
|
|
@@ -225,10 +225,10 @@ function ne() {
|
|
|
225
225
|
dict: (t) => {
|
|
226
226
|
const e = t.row[t.col.key], n = t.col.renderProps || {}, r = n.options ?? [], l = n.showValue ?? !1;
|
|
227
227
|
if (e == null || e === "") return "";
|
|
228
|
-
const c = Array.isArray(e) ? e.map(String) : [String(e)], o = r.filter((
|
|
228
|
+
const c = Array.isArray(e) ? e.map(String) : [String(e)], o = r.filter((i) => c.includes(String(i.value))), y = c.filter((i) => !r.some((h) => String(h.value) === i)), u = o.map((i, h) => g(
|
|
229
229
|
Y,
|
|
230
|
-
{ key:
|
|
231
|
-
{ default: () =>
|
|
230
|
+
{ key: i.value, type: i.listClass, class: i.cssClass, disableTransitions: !0 },
|
|
231
|
+
{ default: () => i.label + " " }
|
|
232
232
|
));
|
|
233
233
|
return l && y.length > 0 && u.push(g("span", {}, y.join(" "))), g("div", {}, u);
|
|
234
234
|
},
|
|
@@ -273,7 +273,7 @@ function le(t, e = 10, n = []) {
|
|
|
273
273
|
}, o = $(() => t.some((s) => c(s.permission))), y = $(() => t.filter((m) => c(m.permission)).slice(0, e).reduce(
|
|
274
274
|
(m, p) => m + (p.width ?? 55),
|
|
275
275
|
0
|
|
276
|
-
)), u = (s, m) => c(s.permission) && (s.visible ? s.visible(m) : !0),
|
|
276
|
+
)), u = (s, m) => c(s.permission) && (s.visible ? s.visible(m) : !0), i = (s) => t.filter((p) => u(p, s)).slice(0, e).reduce(
|
|
277
277
|
(p, I) => p + (I.width ?? 55),
|
|
278
278
|
0
|
|
279
279
|
);
|
|
@@ -284,13 +284,13 @@ function le(t, e = 10, n = []) {
|
|
|
284
284
|
(m) => t.some((p) => u(p, m))
|
|
285
285
|
) : !1,
|
|
286
286
|
getMaxOptWidth: (s) => s != null && s.length ? s.reduce(
|
|
287
|
-
(m, p) => Math.max(m,
|
|
287
|
+
(m, p) => Math.max(m, i(p)),
|
|
288
288
|
0
|
|
289
289
|
) : y.value,
|
|
290
290
|
getVisibleButtons: (s) => t.filter((m) => u(m, s)).slice(0, e)
|
|
291
291
|
};
|
|
292
292
|
}
|
|
293
|
-
const re = /* @__PURE__ */
|
|
293
|
+
const re = /* @__PURE__ */ x({
|
|
294
294
|
__name: "index",
|
|
295
295
|
props: {
|
|
296
296
|
col: { type: Object, required: !0 },
|
|
@@ -298,9 +298,9 @@ const re = /* @__PURE__ */ B({
|
|
|
298
298
|
},
|
|
299
299
|
emits: ["cellBlur", "cellEnter", "cellChange", "cellClick"],
|
|
300
300
|
setup(t, { emit: e }) {
|
|
301
|
-
const n = t, r = e, { col: l } = U(n), c = (v, k) => r("cellChange", v, k), o = (v, k) => r("cellBlur", v, k), y = (v, k) => r("cellEnter", v, k), u = (v, k) => r("cellClick", v, k),
|
|
301
|
+
const n = t, r = e, { col: l } = U(n), c = (v, k) => r("cellChange", v, k), o = (v, k) => r("cellBlur", v, k), y = (v, k) => r("cellEnter", v, k), u = (v, k) => r("cellClick", v, k), i = ne(), {
|
|
302
302
|
hasAnyButton: h,
|
|
303
|
-
hasAnyVisibleButton:
|
|
303
|
+
hasAnyVisibleButton: a,
|
|
304
304
|
optWidth: C,
|
|
305
305
|
getMaxOptWidth: s,
|
|
306
306
|
getVisibleButtons: m
|
|
@@ -308,7 +308,7 @@ const re = /* @__PURE__ */ B({
|
|
|
308
308
|
l.value.buttons || [],
|
|
309
309
|
l.value.maxbtn ?? 10,
|
|
310
310
|
n.permissions || []
|
|
311
|
-
), p = $(() => (l.value.buttons || []).length ? (l.value.__rows || []).length ?
|
|
311
|
+
), p = $(() => (l.value.buttons || []).length ? (l.value.__rows || []).length ? a(l.value.__rows || []) : h.value : !1), I = $(() => l.value.__rows ? s(l.value.__rows) : C.value);
|
|
312
312
|
function z(v) {
|
|
313
313
|
return !(v.type === "selection" || v.type === "index" || v.type === "operation" && !p.value || v.visible === !1);
|
|
314
314
|
}
|
|
@@ -330,12 +330,12 @@ const re = /* @__PURE__ */ B({
|
|
|
330
330
|
...d(l).columnProps,
|
|
331
331
|
width: I.value
|
|
332
332
|
}), {
|
|
333
|
-
default: P(({ row:
|
|
334
|
-
(f(!0), O(K, null, T(d(m)(
|
|
333
|
+
default: P(({ row: B }) => [
|
|
334
|
+
(f(!0), O(K, null, T(d(m)(B), (F) => (f(), b(J, {
|
|
335
335
|
key: F.label,
|
|
336
336
|
type: F.type || "primary",
|
|
337
337
|
link: "",
|
|
338
|
-
onClick: (ue) => F.action(
|
|
338
|
+
onClick: (ue) => F.action(B)
|
|
339
339
|
}, {
|
|
340
340
|
default: P(() => [
|
|
341
341
|
D(N(F.label), 1)
|
|
@@ -350,17 +350,17 @@ const re = /* @__PURE__ */ B({
|
|
|
350
350
|
label: d(l).label,
|
|
351
351
|
align: "center"
|
|
352
352
|
}, d(l).columnProps || {}), {
|
|
353
|
-
default: P(({ row:
|
|
354
|
-
d(l).render && d(
|
|
353
|
+
default: P(({ row: B }) => [
|
|
354
|
+
d(l).render && d(i)[d(l).render] ? (f(), b(H(d(i)[d(l).render]), {
|
|
355
355
|
key: 0,
|
|
356
|
-
row:
|
|
356
|
+
row: B,
|
|
357
357
|
col: d(l),
|
|
358
358
|
onCellChange: c,
|
|
359
359
|
onCellBlur: o,
|
|
360
360
|
onCellEnter: y,
|
|
361
361
|
onClick: u
|
|
362
362
|
}, null, 40, ["row", "col"])) : (f(), O(K, { key: 1 }, [
|
|
363
|
-
D(N(
|
|
363
|
+
D(N(B[d(l).key]), 1)
|
|
364
364
|
], 64))
|
|
365
365
|
]),
|
|
366
366
|
_: 1
|
|
@@ -397,12 +397,12 @@ function se(t, e) {
|
|
|
397
397
|
);
|
|
398
398
|
return S(
|
|
399
399
|
u,
|
|
400
|
-
(
|
|
400
|
+
(i) => {
|
|
401
401
|
if (!o) return;
|
|
402
|
-
const h =
|
|
403
|
-
key:
|
|
404
|
-
visible:
|
|
405
|
-
columnOpts:
|
|
402
|
+
const h = i.map((a) => ({
|
|
403
|
+
key: a.key,
|
|
404
|
+
visible: a.visible,
|
|
405
|
+
columnOpts: a.columnOpts
|
|
406
406
|
}));
|
|
407
407
|
l.setItem(
|
|
408
408
|
o,
|
|
@@ -417,13 +417,13 @@ function se(t, e) {
|
|
|
417
417
|
* 主动设置列配置
|
|
418
418
|
* 常用于:列设置弹窗 / 拖拽排序完成
|
|
419
419
|
*/
|
|
420
|
-
setColumns(
|
|
420
|
+
setColumns(i) {
|
|
421
421
|
u.value = R(
|
|
422
422
|
t,
|
|
423
|
-
|
|
423
|
+
i
|
|
424
424
|
), o && l.setItem(
|
|
425
425
|
o,
|
|
426
|
-
JSON.stringify(
|
|
426
|
+
JSON.stringify(i)
|
|
427
427
|
);
|
|
428
428
|
},
|
|
429
429
|
/**
|
|
@@ -434,7 +434,7 @@ function se(t, e) {
|
|
|
434
434
|
}
|
|
435
435
|
};
|
|
436
436
|
}
|
|
437
|
-
const
|
|
437
|
+
const ie = /* @__PURE__ */ x({
|
|
438
438
|
__name: "index",
|
|
439
439
|
props: {
|
|
440
440
|
data: { type: Array, default: () => [] },
|
|
@@ -467,24 +467,24 @@ const ae = /* @__PURE__ */ B({
|
|
|
467
467
|
});
|
|
468
468
|
S(
|
|
469
469
|
c,
|
|
470
|
-
(
|
|
470
|
+
(a) => l("update:columns", a),
|
|
471
471
|
{ deep: !0, immediate: !0 }
|
|
472
472
|
);
|
|
473
|
-
const o = (
|
|
474
|
-
l("cellBlur",
|
|
475
|
-
}, u = (
|
|
476
|
-
console.log("enter"), l("cellEnter",
|
|
477
|
-
},
|
|
478
|
-
C && l("cell-click",
|
|
473
|
+
const o = (a, C) => l("cellChange", a, C), y = (a, C) => {
|
|
474
|
+
l("cellBlur", a, C);
|
|
475
|
+
}, u = (a, C) => {
|
|
476
|
+
console.log("enter"), l("cellEnter", a, C);
|
|
477
|
+
}, i = (a, C) => {
|
|
478
|
+
C && l("cell-click", a, C);
|
|
479
479
|
}, h = V();
|
|
480
480
|
return e({
|
|
481
481
|
tableRef: h
|
|
482
|
-
}), (
|
|
482
|
+
}), (a, C) => {
|
|
483
483
|
const s = w("el-table"), m = q("loading");
|
|
484
484
|
return X((f(), b(s, _({
|
|
485
485
|
ref_key: "tableRef",
|
|
486
486
|
ref: h
|
|
487
|
-
},
|
|
487
|
+
}, a.$attrs, {
|
|
488
488
|
data: t.data,
|
|
489
489
|
"row-key": t.rowKey,
|
|
490
490
|
class: "smart-table"
|
|
@@ -497,7 +497,7 @@ const ae = /* @__PURE__ */ B({
|
|
|
497
497
|
onCellChange: o,
|
|
498
498
|
onCellBlur: y,
|
|
499
499
|
onCellEnter: u,
|
|
500
|
-
onCellClick:
|
|
500
|
+
onCellClick: i
|
|
501
501
|
}, null, 8, ["col", "permissions"]))), 128))
|
|
502
502
|
]),
|
|
503
503
|
_: 1
|
|
@@ -506,13 +506,12 @@ const ae = /* @__PURE__ */ B({
|
|
|
506
506
|
]);
|
|
507
507
|
};
|
|
508
508
|
}
|
|
509
|
-
}),
|
|
509
|
+
}), ae = (t, e) => {
|
|
510
510
|
const n = t.__vccOpts || t;
|
|
511
511
|
for (const [r, l] of e)
|
|
512
512
|
n[r] = l;
|
|
513
513
|
return n;
|
|
514
|
-
}, me = /* @__PURE__ */ ie
|
|
514
|
+
}, me = /* @__PURE__ */ ae(ie, [["__scopeId", "data-v-338b77db"]]);
|
|
515
515
|
export {
|
|
516
|
-
me as SmartTable
|
|
517
|
-
me as default
|
|
516
|
+
me as SmartTable
|
|
518
517
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue3-smart-table",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "基于 Vue 3 + Element Plus 的高可复用表格组件",
|
|
5
5
|
"main": "dist/vue3-smart-table.cjs.js",
|
|
6
6
|
"module": "dist/vue3-smart-table.es.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"author": "xiechen",
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"scripts": {
|
|
20
|
-
"build": "vue-tsc --
|
|
20
|
+
"build": "vue-tsc --declaration --emitDeclarationOnly && vite build",
|
|
21
21
|
"dev:demo": "cd demo && vite",
|
|
22
22
|
"preview:demo": "vite preview demo"
|
|
23
23
|
},
|
|
@@ -35,7 +35,5 @@
|
|
|
35
35
|
"vue": "^3.5.25",
|
|
36
36
|
"vue-tsc": "^3.1.8"
|
|
37
37
|
},
|
|
38
|
-
"dependencies": {
|
|
39
|
-
"vue-router": "^4.6.4"
|
|
40
|
-
}
|
|
38
|
+
"dependencies": {}
|
|
41
39
|
}
|