vue3-smart-table 0.0.3 → 0.0.4
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/README.md +1 -0
- package/dist/vue3-smart-table.cjs.js +3 -3
- package/dist/vue3-smart-table.css +1 -1
- package/dist/vue3-smart-table.es.js +260 -248
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -45,6 +45,7 @@ SmartTable/
|
|
|
45
45
|
| permissions | `string[]` | `[]` | 当前用户权限列表 |
|
|
46
46
|
| pageKey | `string` | - | 列缓存 pageKey(可选) |
|
|
47
47
|
| userId | `string \| number` | - | 列缓存 userId(可选) |
|
|
48
|
+
| pagination | `{page: number, size: number}` | - | 序号列计算序号(可选),page:当前页,size:当前页显示条数,不填则默认序号 |
|
|
48
49
|
|
|
49
50
|
> 其余属性将 **透传给 el-table**。
|
|
50
51
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),w=require("element-plus");function h(n,t){if(!(!n||!t))return t.split(".").reduce((l,o)=>l==null?void 0:l[o],n)}function V(n,t,l){if(!n||!t)return;const o=t.split("."),s=o.pop(),r=o.reduce((i,a)=>(i[a]||(i[a]={}),i[a]),n);r[s]=l}const A=e.defineComponent({__name:"input",props:{row:{},col:{},onCellBlur:{type:Function},onCellEnter:{type:Function}},setup(n){const t=n,l=e.ref(h(t.row,t.col.key));e.watch(l,r=>{V(t.row,t.col.key,r)});const o=()=>{var r;return(r=t.onCellBlur)==null?void 0:r.call(t,t.row,t.col)},s=()=>{var r;return(r=t.onCellEnter)==null?void 0:r.call(t,t.row,t.col)};return(r,i)=>{const a=e.resolveComponent("el-input");return e.openBlock(),e.createBlock(a,e.mergeProps({modelValue:l.value,"onUpdate:modelValue":i[0]||(i[0]=d=>l.value=d)},{placeholder:"",size:"small",clearable:!0,...n.col.renderProps},{onBlur:o,onKeyup:e.withKeys(s,["enter"])}),null,16,["modelValue"])}}}),I=e.defineComponent({__name:"inputNumber",props:{row:{},col:{},onCellChange:{type:Function},onCellBlur:{type:Function},onCellEnter:{type:Function}},setup(n){const t=n,l=e.ref(h(t.row,t.col.key));e.watch(l,r=>{var i;V(t.row,t.col.key,r),(i=t.onCellChange)==null||i.call(t,t.row,t.col)});const o=()=>{var r;return(r=t.onCellBlur)==null?void 0:r.call(t,t.row,t.col)},s=()=>{var r;return(r=t.onCellEnter)==null?void 0:r.call(t,t.row,t.col)};return(r,i)=>{const a=e.resolveComponent("el-input-number");return e.openBlock(),e.createBlock(a,e.mergeProps({modelValue:l.value,"onUpdate:modelValue":i[0]||(i[0]=d=>l.value=d)},{min:0,max:99999,controls:!1,size:"small",...n.col.renderProps},{onBlur:o,onKeyup:e.withKeys(s,["enter"])}),null,16,["modelValue"])}}}),L=e.defineComponent({__name:"select",props:{row:{},col:{},onCellChange:{type:Function},onCellBlur:{type:Function},onCellEnter:{type:Function}},setup(n){const t=n,l=e.ref(h(t.row,t.col.key));e.watch(l,i=>{V(t.row,t.col.key,i)});const o=()=>{var i;return(i=t.onCellChange)==null?void 0:i.call(t,t.row,t.col)},s=()=>{var i;return(i=t.onCellBlur)==null?void 0:i.call(t,t.row,t.col)},r=()=>{var i;return(i=t.onCellEnter)==null?void 0:i.call(t,t.row,t.col)};return(i,a)=>{const d=e.resolveComponent("el-option"),p=e.resolveComponent("el-select");return e.openBlock(),e.createBlock(p,e.mergeProps({modelValue:l.value,"onUpdate:modelValue":a[0]||(a[0]=g=>l.value=g)},{placeholder:"请选择",size:"small",clearable:!0,...n.col.renderProps},{onChange:o,onBlur:s,onKeyup:e.withKeys(r,["enter"])}),{default:e.withCtx(()=>{var g;return[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(((g=n.col.renderProps)==null?void 0:g.options)||[],u=>(e.openBlock(),e.createBlock(d,{key:u.value,label:u.label,value:u.value},null,8,["label","value"]))),128))]}),_:1},16,["modelValue"])}}}),S=n=>e.defineComponent({props:["row","col","onCellChange","onCellBlur","onCellEnter","onClick"],setup(t){return()=>e.h(n,t)}});function M(n){return typeof n.formatter=="function"}function z(){return{input:S(A),"input-number":S(I),select:S(L),button:n=>{const t=n.col.renderProps||{},l=h(n.row,n.col.key);return e.h(w.ElButton,{type:t.type||"primary",...t,onClick:()=>{var o;return(o=n.onClick)==null?void 0:o.call(n,n.row,n.col)}},()=>t.label||l)},link:n=>{const t=n.col.renderProps||{},l=h(n.row,n.col.key);return e.h("a",{href:t.href||"#",target:t.blank?"_blank":"_self",style:t.style||"color:#409EFF;cursor:pointer;",onClick:o=>{var s;o.preventDefault(),(s=n.onClick)==null||s.call(n,n.row,n.col)}},t.label||l)},html:n=>{var l;const t=h(n.row,n.col.key);return e.h("div",{class:"line-clamp-2",innerHTML:t??"",...((l=n.col)==null?void 0:l.renderProps)||{}})},copy:n=>{const t=h(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,7 +8,7 @@
|
|
|
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(()=>{
|
|
11
|
+
`,onClick:()=>{if(t)try{if(navigator.clipboard&&navigator.clipboard.writeText)navigator.clipboard.writeText(t).then(()=>{w.ElMessage.success("复制成功")}).catch(()=>{w.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 o=document.execCommand("copy");document.body.removeChild(l),o?w.ElMessage.success("复制成功"):w.ElMessage.error("复制失败")}}catch{w.ElMessage.error("复制失败")}}},"📋")])},img:n=>{var i;const t=h(n.row,n.col.key)??"",l=((i=n.col)==null?void 0:i.renderProps)||{},s=t?Array.isArray(t)?t.filter(a=>a&&typeof a=="string"):[t]:[];if(s.length===0)return l.placeholder||"";const r={width:l.width||"80px",height:l.height||"80px",marginRight:s.length>1?"4px":"0",...l.style||{}};return s.length===1?e.h(w.ElImage,{src:s[0],previewSrcList:l.previewSrcList||s,fit:l.fit||"contain",style:r,...l}):(console.log(l.previewSrcList),e.h("div",{style:"display: flex; align-items: center; position: relative"},[e.h(w.ElImage,{src:s[0],previewSrcList:l.previewSrcList||s,fit:l.fit||"contain",style:r,...l}),s.length>1&&e.h("span",{style:`
|
|
12
12
|
margin-left: 8px;
|
|
13
13
|
font-size: 12px;
|
|
14
14
|
color: #666;
|
|
@@ -18,4 +18,4 @@
|
|
|
18
18
|
position: absolute;
|
|
19
19
|
top: 0;
|
|
20
20
|
right: 0;
|
|
21
|
-
`,title:`共 ${
|
|
21
|
+
`,title:`共 ${s.length} 张图片`},`+${s.length-1}`)]))},dict:n=>{const t=h(n.row,n.col.key)??"",l=n.col.renderProps||{},o=l.options??[],s=l.showValue??!1;if(t==null||t==="")return"";const r=Array.isArray(t)?t.map(String):[String(t)],i=o.filter(p=>r.includes(String(p.value))),a=r.filter(p=>!o.some(g=>String(g.value)===p)),d=i.map((p,g)=>e.h(w.ElTag,{key:p.value,type:p.listClass,class:p.cssClass,disableTransitions:!0},{default:()=>p.label+" "}));return s&&a.length>0&&d.push(e.h("span",{},a.join(" "))),e.h("div",{},d)},map:n=>{var o;const t=h(n.row,n.col.key)??"",l=((o=n.col.renderProps)==null?void 0:o.options)??{};return t!=null?l[t]??"":""},formatter:n=>{var s;const{col:t,row:l}=n,o=h(n.row,n.col.key)??"";return M(t)?(s=t.formatter)==null?void 0:s.call(t,o,l):o??""},icon:n=>{const t=h(n.row,n.col.key)??"",l=n.col.renderProps||{};return t?/^https?:\/\//.test(t)?e.h(w.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 T(n,t=10,l=[]){const s="*:*:*",r=c=>{if(!c)return!0;const f=Array.isArray(c)?c:[c];return l.some(y=>y===s||f.includes(y))},i=e.computed(()=>n.some(c=>r(c.permission))),a=e.computed(()=>n.filter(f=>r(f.permission)).slice(0,t).reduce((f,y)=>f+(y.width??60),0)),d=(c,f)=>r(c.permission)&&(c.visible?c.visible(f):!0),p=c=>n.filter(y=>d(y,c)).slice(0,t).reduce((y,b)=>y+(b.width??60),0);return{hasAnyButton:i,optWidth:a,hasAnyVisibleButton:c=>c!=null&&c.length?c.some(f=>n.some(y=>d(y,f))):!1,getMaxOptWidth:c=>c!=null&&c.length?c.reduce((f,y)=>Math.max(f,p(y)),0):a.value,getVisibleButtons:c=>n.filter(f=>d(f,c)).slice(0,t)}}const W=["title"],D=e.defineComponent({__name:"index",props:{col:{type:Object,required:!0},permissions:{type:Array,default:()=>[]},pagination:{type:Object,default:()=>({})}},emits:["cellBlur","cellEnter","cellChange","cellClick"],setup(n,{emit:t}){const l=n,o=t,s=m=>{var x,C;const v=(x=l.pagination)==null?void 0:x.page,B=(C=l.pagination)==null?void 0:C.size;return v&&B?(v-1)*B+m+1:m+1},{col:r}=e.toRefs(l),i=(m,v)=>o("cellChange",m,v),a=(m,v)=>o("cellBlur",m,v),d=(m,v)=>o("cellEnter",m,v),p=(m,v)=>o("cellClick",m,v),g=z(),{hasAnyButton:u,hasAnyVisibleButton:k,optWidth:c,getMaxOptWidth:f,getVisibleButtons:y}=T(r.value.buttons||[],r.value.maxbtn??10,l.permissions||[]),b=e.computed(()=>(r.value.buttons||[]).length?(r.value.__rows||[]).length?k(r.value.__rows||[]):u.value:!1),E=e.computed(()=>r.value.__rows?f(r.value.__rows):c.value);function $(m){return!(m.type==="selection"||m.type==="index"||m.type==="operation"&&!b.value||m.visible===!1)}return(m,v)=>{const B=e.resolveComponent("el-table-column"),x=e.resolveComponent("el-button");return e.unref(r).type==="selection"?(e.openBlock(),e.createBlock(B,e.mergeProps({key:0,type:"selection"},e.unref(r).columnProps),null,16)):e.unref(r).type==="index"?(e.openBlock(),e.createBlock(B,e.mergeProps({key:1,type:"index",label:e.unref(r).label||"#",align:"center"},e.unref(r).columnProps),{default:e.withCtx(({$index:C})=>[e.createTextVNode(e.toDisplayString(s(C)),1)]),_:1},16,["label"])):e.unref(r).type==="operation"&&b.value?(e.openBlock(),e.createBlock(B,e.mergeProps({key:2,label:e.unref(r).label||"操作",align:"center"},{...e.unref(r).columnProps,width:E.value}),{default:e.withCtx(({row:C})=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(y)(C),_=>(e.openBlock(),e.createBlock(x,{key:_.label,type:_.type||"primary",link:"",onClick:P=>_.action(C)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(_.label),1)]),_:2},1032,["type","onClick"]))),128))]),_:1},16,["label"])):$(e.unref(r))?(e.openBlock(),e.createBlock(B,e.mergeProps({key:3,label:e.unref(r).label,align:"center"},e.unref(r).columnProps||{}),{default:e.withCtx(C=>{var _,P,O,F;return[e.unref(r).render==="slot"&&m.$slots[((_=e.unref(r))==null?void 0:_.slot)||e.unref(r).key]?e.renderSlot(m.$slots,((P=e.unref(r))==null?void 0:P.slot)||e.unref(r).key,e.normalizeProps(e.mergeProps({key:0},C))):e.unref(r).render&&e.unref(g)[e.unref(r).render]?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(g)[e.unref(r).render]),{key:1,row:C.row,col:e.unref(r),onCellChange:i,onCellBlur:a,onCellEnter:d,onClick:p},null,40,["row","col"])):(e.openBlock(),e.createElementBlock("span",{key:2,style:e.normalizeStyle(((O=e.unref(r).renderProps)==null?void 0:O.style)||""),class:e.normalizeClass(((F=e.unref(r).renderProps)==null?void 0:F.class)||""),title:e.unref(h)(C.row,e.unref(r).key)},e.toDisplayString(e.unref(h)(C.row,e.unref(r).key)),15,W))]}),_:3},16,["label"])):e.createCommentVNode("",!0)}}}),N="table_columns_";function R(n,t){return`${N}${n}_${t}`}function K(n,t){if(!(t!=null&&t.length))return n;const l=new Map(t.map(o=>[o.key,o]));return n.map(o=>{const s=l.get(o.key);return s?{...o,visible:typeof s.visible=="boolean"?s.visible:o.visible}:o})}function j(n,t){const{pageKey:l,userId:o,storage:s=localStorage}=t||{},i=o?R(o,l||""):null,a=i?s.getItem(i):null,d=e.ref(K(n,a?JSON.parse(a):[]));return e.watch(d,p=>{if(!i)return;const g=p.map(u=>({key:u.key,visible:u.visible,columnOpts:u.columnOpts}));s.setItem(i,JSON.stringify(g))},{deep:!0}),{columns:d,setColumns(p){d.value=K(n,p),i&&s.setItem(i,JSON.stringify(p))},resetColumns(){d.value=n,i&&s.removeItem(i)}}}const q=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:""},pagination:{type:Object,default:()=>({})}},emits:["update:columns","cellChange","cellBlur","cellEnter","cell-click"],setup(n,{expose:t,emit:l}){const o=n,s=l,{columns:r}=j(o.columns,{pageKey:o.pageKey??"",userId:o.userId??""});e.watch(r,u=>s("update:columns",u),{deep:!0,immediate:!0});const i=(u,k)=>s("cellChange",u,k),a=(u,k)=>{s("cellBlur",u,k)},d=(u,k)=>{console.log("enter"),s("cellEnter",u,k)},p=(u,k)=>{k&&s("cell-click",u,k)},g=e.ref();return t({tableRef:g}),(u,k)=>{const c=e.resolveComponent("el-table"),f=e.resolveDirective("loading");return e.withDirectives((e.openBlock(),e.createBlock(c,e.mergeProps({ref_key:"tableRef",ref:g},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(r),y=>(e.openBlock(),e.createBlock(D,{key:y.key,col:y,permissions:n.permissions,pagination:n.pagination,onCellChange:i,onCellBlur:a,onCellEnter:d,onCellClick:p},e.createSlots({_:2},[e.renderList(e.unref(r),b=>({name:b.key,fn:e.withCtx(E=>[e.renderSlot(u.$slots,b.key,e.mergeProps({ref_for:!0},E),void 0,!0)])}))]),1032,["col","permissions","pagination"]))),128))]),_:3},16,["data","row-key"])),[[f,n.loading]])}}}),J=(n,t)=>{const l=n.__vccOpts||n;for(const[o,s]of t)l[o]=s;return l},U=J(q,[["__scopeId","data-v-7c94ec39"]]);exports.SmartTable=U;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.copy-wrapper:hover .copy-btn{display:inline-block!important}.smart-table[data-v-
|
|
1
|
+
.copy-wrapper:hover .copy-btn{display:inline-block!important}.smart-table[data-v-7c94ec39]{width:100%}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { ElImage as
|
|
1
|
+
import { defineComponent as O, ref as A, watch as F, resolveComponent as V, createBlock as _, openBlock as v, mergeProps as x, withKeys as R, withCtx as S, createElementBlock as I, Fragment as J, renderList as L, h as g, computed as z, toRefs as Q, createCommentVNode as Z, unref as s, createTextVNode as q, toDisplayString as T, renderSlot as Y, normalizeProps as ee, resolveDynamicComponent as te, normalizeClass as ne, normalizeStyle as le, resolveDirective as re, withDirectives as oe, createSlots as ie } from "vue";
|
|
2
|
+
import { ElImage as D, ElTag as se, ElMessage as $, ElButton as ae } from "element-plus";
|
|
3
3
|
function C(t, e) {
|
|
4
4
|
if (!(!t || !e))
|
|
5
|
-
return e.split(".").reduce((
|
|
5
|
+
return e.split(".").reduce((n, r) => n == null ? void 0 : n[r], t);
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function U(t, e, n) {
|
|
8
8
|
if (!t || !e) return;
|
|
9
|
-
const r = e.split("."),
|
|
10
|
-
|
|
9
|
+
const r = e.split("."), o = r.pop(), l = r.reduce((i, c) => (i[c] || (i[c] = {}), i[c]), t);
|
|
10
|
+
l[o] = n;
|
|
11
11
|
}
|
|
12
|
-
const
|
|
12
|
+
const ce = /* @__PURE__ */ O({
|
|
13
13
|
__name: "input",
|
|
14
14
|
props: {
|
|
15
15
|
row: {},
|
|
@@ -18,29 +18,29 @@ const ae = /* @__PURE__ */ V({
|
|
|
18
18
|
onCellEnter: { type: Function }
|
|
19
19
|
},
|
|
20
20
|
setup(t) {
|
|
21
|
-
const e = t,
|
|
22
|
-
F(
|
|
23
|
-
|
|
21
|
+
const e = t, n = A(C(e.row, e.col.key));
|
|
22
|
+
F(n, (l) => {
|
|
23
|
+
U(e.row, e.col.key, l);
|
|
24
24
|
});
|
|
25
25
|
const r = () => {
|
|
26
|
-
var
|
|
27
|
-
return (
|
|
28
|
-
},
|
|
29
|
-
var
|
|
30
|
-
return (
|
|
26
|
+
var l;
|
|
27
|
+
return (l = e.onCellBlur) == null ? void 0 : l.call(e, e.row, e.col);
|
|
28
|
+
}, o = () => {
|
|
29
|
+
var l;
|
|
30
|
+
return (l = e.onCellEnter) == null ? void 0 : l.call(e, e.row, e.col);
|
|
31
31
|
};
|
|
32
|
-
return (
|
|
33
|
-
const c =
|
|
34
|
-
return
|
|
35
|
-
modelValue:
|
|
36
|
-
"onUpdate:modelValue":
|
|
32
|
+
return (l, i) => {
|
|
33
|
+
const c = V("el-input");
|
|
34
|
+
return v(), _(c, x({
|
|
35
|
+
modelValue: n.value,
|
|
36
|
+
"onUpdate:modelValue": i[0] || (i[0] = (d) => n.value = d)
|
|
37
37
|
}, { placeholder: "", size: "small", clearable: !0, ...t.col.renderProps }, {
|
|
38
38
|
onBlur: r,
|
|
39
|
-
onKeyup:
|
|
39
|
+
onKeyup: R(o, ["enter"])
|
|
40
40
|
}), null, 16, ["modelValue"]);
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
|
-
}),
|
|
43
|
+
}), ue = /* @__PURE__ */ O({
|
|
44
44
|
__name: "inputNumber",
|
|
45
45
|
props: {
|
|
46
46
|
row: {},
|
|
@@ -50,30 +50,30 @@ const ae = /* @__PURE__ */ V({
|
|
|
50
50
|
onCellEnter: { type: Function }
|
|
51
51
|
},
|
|
52
52
|
setup(t) {
|
|
53
|
-
const e = t,
|
|
54
|
-
F(
|
|
55
|
-
var
|
|
56
|
-
|
|
53
|
+
const e = t, n = A(C(e.row, e.col.key));
|
|
54
|
+
F(n, (l) => {
|
|
55
|
+
var i;
|
|
56
|
+
U(e.row, e.col.key, l), (i = e.onCellChange) == null || i.call(e, e.row, e.col);
|
|
57
57
|
});
|
|
58
58
|
const r = () => {
|
|
59
|
-
var
|
|
60
|
-
return (
|
|
61
|
-
},
|
|
62
|
-
var
|
|
63
|
-
return (
|
|
59
|
+
var l;
|
|
60
|
+
return (l = e.onCellBlur) == null ? void 0 : l.call(e, e.row, e.col);
|
|
61
|
+
}, o = () => {
|
|
62
|
+
var l;
|
|
63
|
+
return (l = e.onCellEnter) == null ? void 0 : l.call(e, e.row, e.col);
|
|
64
64
|
};
|
|
65
|
-
return (
|
|
66
|
-
const c =
|
|
67
|
-
return
|
|
68
|
-
modelValue:
|
|
69
|
-
"onUpdate:modelValue":
|
|
65
|
+
return (l, i) => {
|
|
66
|
+
const c = V("el-input-number");
|
|
67
|
+
return v(), _(c, x({
|
|
68
|
+
modelValue: n.value,
|
|
69
|
+
"onUpdate:modelValue": i[0] || (i[0] = (d) => n.value = d)
|
|
70
70
|
}, { min: 0, max: 99999, controls: !1, size: "small", ...t.col.renderProps }, {
|
|
71
71
|
onBlur: r,
|
|
72
|
-
onKeyup:
|
|
72
|
+
onKeyup: R(o, ["enter"])
|
|
73
73
|
}), null, 16, ["modelValue"]);
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
|
-
}),
|
|
76
|
+
}), de = /* @__PURE__ */ O({
|
|
77
77
|
__name: "select",
|
|
78
78
|
props: {
|
|
79
79
|
row: {},
|
|
@@ -83,34 +83,34 @@ const ae = /* @__PURE__ */ V({
|
|
|
83
83
|
onCellEnter: { type: Function }
|
|
84
84
|
},
|
|
85
85
|
setup(t) {
|
|
86
|
-
const e = t,
|
|
87
|
-
F(
|
|
88
|
-
|
|
86
|
+
const e = t, n = A(C(e.row, e.col.key));
|
|
87
|
+
F(n, (i) => {
|
|
88
|
+
U(e.row, e.col.key, i);
|
|
89
89
|
});
|
|
90
90
|
const r = () => {
|
|
91
|
-
var
|
|
92
|
-
return (
|
|
93
|
-
},
|
|
94
|
-
var
|
|
95
|
-
return (
|
|
96
|
-
},
|
|
97
|
-
var
|
|
98
|
-
return (
|
|
91
|
+
var i;
|
|
92
|
+
return (i = e.onCellChange) == null ? void 0 : i.call(e, e.row, e.col);
|
|
93
|
+
}, o = () => {
|
|
94
|
+
var i;
|
|
95
|
+
return (i = e.onCellBlur) == null ? void 0 : i.call(e, e.row, e.col);
|
|
96
|
+
}, l = () => {
|
|
97
|
+
var i;
|
|
98
|
+
return (i = e.onCellEnter) == null ? void 0 : i.call(e, e.row, e.col);
|
|
99
99
|
};
|
|
100
|
-
return (
|
|
101
|
-
const
|
|
102
|
-
return
|
|
103
|
-
modelValue:
|
|
104
|
-
"onUpdate:modelValue": c[0] || (c[0] = (
|
|
100
|
+
return (i, c) => {
|
|
101
|
+
const d = V("el-option"), y = V("el-select");
|
|
102
|
+
return v(), _(y, x({
|
|
103
|
+
modelValue: n.value,
|
|
104
|
+
"onUpdate:modelValue": c[0] || (c[0] = (h) => n.value = h)
|
|
105
105
|
}, { placeholder: "请选择", size: "small", clearable: !0, ...t.col.renderProps }, {
|
|
106
106
|
onChange: r,
|
|
107
|
-
onBlur:
|
|
108
|
-
onKeyup:
|
|
107
|
+
onBlur: o,
|
|
108
|
+
onKeyup: R(l, ["enter"])
|
|
109
109
|
}), {
|
|
110
110
|
default: S(() => {
|
|
111
|
-
var
|
|
111
|
+
var h;
|
|
112
112
|
return [
|
|
113
|
-
(
|
|
113
|
+
(v(!0), I(J, null, L(((h = t.col.renderProps) == null ? void 0 : h.options) || [], (u) => (v(), _(d, {
|
|
114
114
|
key: u.value,
|
|
115
115
|
label: u.label,
|
|
116
116
|
value: u.value
|
|
@@ -121,66 +121,66 @@ const ae = /* @__PURE__ */ V({
|
|
|
121
121
|
}, 16, ["modelValue"]);
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
|
-
}),
|
|
124
|
+
}), N = (t) => O({
|
|
125
125
|
props: ["row", "col", "onCellChange", "onCellBlur", "onCellEnter", "onClick"],
|
|
126
126
|
setup(e) {
|
|
127
|
-
return () =>
|
|
127
|
+
return () => g(t, e);
|
|
128
128
|
}
|
|
129
129
|
});
|
|
130
|
-
function
|
|
130
|
+
function ye(t) {
|
|
131
131
|
return typeof t.formatter == "function";
|
|
132
132
|
}
|
|
133
|
-
function
|
|
133
|
+
function me() {
|
|
134
134
|
return {
|
|
135
|
-
input:
|
|
136
|
-
"input-number":
|
|
137
|
-
select:
|
|
135
|
+
input: N(ce),
|
|
136
|
+
"input-number": N(ue),
|
|
137
|
+
select: N(de),
|
|
138
138
|
button: (t) => {
|
|
139
|
-
const e = t.col.renderProps || {},
|
|
140
|
-
return
|
|
139
|
+
const e = t.col.renderProps || {}, n = C(t.row, t.col.key);
|
|
140
|
+
return g(ae, {
|
|
141
141
|
type: e.type || "primary",
|
|
142
142
|
...e,
|
|
143
143
|
onClick: () => {
|
|
144
144
|
var r;
|
|
145
145
|
return (r = t.onClick) == null ? void 0 : r.call(t, t.row, t.col);
|
|
146
146
|
}
|
|
147
|
-
}, () => e.label ||
|
|
147
|
+
}, () => e.label || n);
|
|
148
148
|
},
|
|
149
149
|
link: (t) => {
|
|
150
|
-
const e = t.col.renderProps || {},
|
|
151
|
-
return
|
|
150
|
+
const e = t.col.renderProps || {}, n = C(t.row, t.col.key);
|
|
151
|
+
return g("a", {
|
|
152
152
|
href: e.href || "#",
|
|
153
153
|
target: e.blank ? "_blank" : "_self",
|
|
154
154
|
style: e.style || "color:#409EFF;cursor:pointer;",
|
|
155
155
|
onClick: (r) => {
|
|
156
|
-
var
|
|
157
|
-
r.preventDefault(), (
|
|
156
|
+
var o;
|
|
157
|
+
r.preventDefault(), (o = t.onClick) == null || o.call(t, t.row, t.col);
|
|
158
158
|
}
|
|
159
|
-
}, e.label ||
|
|
159
|
+
}, e.label || n);
|
|
160
160
|
},
|
|
161
161
|
html: (t) => {
|
|
162
|
-
var
|
|
162
|
+
var n;
|
|
163
163
|
const e = C(t.row, t.col.key);
|
|
164
|
-
return
|
|
164
|
+
return g("div", {
|
|
165
165
|
class: "line-clamp-2",
|
|
166
166
|
innerHTML: e ?? "",
|
|
167
|
-
...((
|
|
167
|
+
...((n = t.col) == null ? void 0 : n.renderProps) || {}
|
|
168
168
|
});
|
|
169
169
|
},
|
|
170
170
|
copy: (t) => {
|
|
171
171
|
const e = C(t.row, t.col.key) ?? "";
|
|
172
|
-
return
|
|
172
|
+
return g(
|
|
173
173
|
"div",
|
|
174
174
|
{
|
|
175
175
|
class: "copy-wrapper",
|
|
176
176
|
style: "position: relative; display: inline-block;"
|
|
177
177
|
},
|
|
178
178
|
[
|
|
179
|
-
|
|
179
|
+
g("span", {
|
|
180
180
|
class: "copy-text line-clamp-1",
|
|
181
181
|
style: "padding-right: 20px;"
|
|
182
182
|
}, e),
|
|
183
|
-
|
|
183
|
+
g(
|
|
184
184
|
"span",
|
|
185
185
|
{
|
|
186
186
|
class: "copy-btn",
|
|
@@ -205,10 +205,10 @@ function ye() {
|
|
|
205
205
|
$.error("复制失败");
|
|
206
206
|
});
|
|
207
207
|
else {
|
|
208
|
-
const
|
|
209
|
-
|
|
208
|
+
const n = document.createElement("textarea");
|
|
209
|
+
n.value = e, n.style.position = "fixed", n.style.opacity = "0", document.body.appendChild(n), n.select();
|
|
210
210
|
const r = document.execCommand("copy");
|
|
211
|
-
document.body.removeChild(
|
|
211
|
+
document.body.removeChild(n), r ? $.success("复制成功") : $.error("复制失败");
|
|
212
212
|
}
|
|
213
213
|
} catch {
|
|
214
214
|
$.error("复制失败");
|
|
@@ -222,35 +222,35 @@ function ye() {
|
|
|
222
222
|
);
|
|
223
223
|
},
|
|
224
224
|
img: (t) => {
|
|
225
|
-
var
|
|
226
|
-
const e = C(t.row, t.col.key) ?? "",
|
|
227
|
-
if (
|
|
228
|
-
return
|
|
229
|
-
const
|
|
230
|
-
width:
|
|
231
|
-
height:
|
|
232
|
-
marginRight:
|
|
233
|
-
...
|
|
225
|
+
var i;
|
|
226
|
+
const e = C(t.row, t.col.key) ?? "", n = ((i = t.col) == null ? void 0 : i.renderProps) || {}, o = e ? Array.isArray(e) ? e.filter((c) => c && typeof c == "string") : [e] : [];
|
|
227
|
+
if (o.length === 0)
|
|
228
|
+
return n.placeholder || "";
|
|
229
|
+
const l = {
|
|
230
|
+
width: n.width || "80px",
|
|
231
|
+
height: n.height || "80px",
|
|
232
|
+
marginRight: o.length > 1 ? "4px" : "0",
|
|
233
|
+
...n.style || {}
|
|
234
234
|
};
|
|
235
|
-
return
|
|
236
|
-
src:
|
|
237
|
-
previewSrcList:
|
|
238
|
-
fit:
|
|
239
|
-
style:
|
|
240
|
-
...
|
|
241
|
-
}) : (console.log(
|
|
235
|
+
return o.length === 1 ? g(D, {
|
|
236
|
+
src: o[0],
|
|
237
|
+
previewSrcList: n.previewSrcList || o,
|
|
238
|
+
fit: n.fit || "contain",
|
|
239
|
+
style: l,
|
|
240
|
+
...n
|
|
241
|
+
}) : (console.log(n.previewSrcList), g("div", {
|
|
242
242
|
style: "display: flex; align-items: center; position: relative"
|
|
243
243
|
}, [
|
|
244
244
|
// 显示第一张图片,点击可预览所有
|
|
245
|
-
|
|
246
|
-
src:
|
|
247
|
-
previewSrcList:
|
|
248
|
-
fit:
|
|
249
|
-
style:
|
|
250
|
-
...
|
|
245
|
+
g(D, {
|
|
246
|
+
src: o[0],
|
|
247
|
+
previewSrcList: n.previewSrcList || o,
|
|
248
|
+
fit: n.fit || "contain",
|
|
249
|
+
style: l,
|
|
250
|
+
...n
|
|
251
251
|
}),
|
|
252
252
|
// 如果图片数量大于1,显示剩余图片数量
|
|
253
|
-
|
|
253
|
+
o.length > 1 && g("span", {
|
|
254
254
|
style: `
|
|
255
255
|
margin-left: 8px;
|
|
256
256
|
font-size: 12px;
|
|
@@ -262,228 +262,238 @@ function ye() {
|
|
|
262
262
|
top: 0;
|
|
263
263
|
right: 0;
|
|
264
264
|
`,
|
|
265
|
-
title: `共 ${
|
|
266
|
-
}, `+${
|
|
265
|
+
title: `共 ${o.length} 张图片`
|
|
266
|
+
}, `+${o.length - 1}`)
|
|
267
267
|
]));
|
|
268
268
|
},
|
|
269
269
|
dict: (t) => {
|
|
270
|
-
const e = C(t.row, t.col.key) ?? "",
|
|
270
|
+
const e = C(t.row, t.col.key) ?? "", n = t.col.renderProps || {}, r = n.options ?? [], o = n.showValue ?? !1;
|
|
271
271
|
if (e == null || e === "") return "";
|
|
272
|
-
const
|
|
272
|
+
const l = Array.isArray(e) ? e.map(String) : [String(e)], i = r.filter((y) => l.includes(String(y.value))), c = l.filter((y) => !r.some((h) => String(h.value) === y)), d = i.map((y, h) => g(
|
|
273
273
|
se,
|
|
274
|
-
{ key:
|
|
275
|
-
{ default: () =>
|
|
274
|
+
{ key: y.value, type: y.listClass, class: y.cssClass, disableTransitions: !0 },
|
|
275
|
+
{ default: () => y.label + " " }
|
|
276
276
|
));
|
|
277
|
-
return
|
|
277
|
+
return o && c.length > 0 && d.push(g("span", {}, c.join(" "))), g("div", {}, d);
|
|
278
278
|
},
|
|
279
279
|
map: (t) => {
|
|
280
280
|
var r;
|
|
281
|
-
const e = C(t.row, t.col.key) ?? "",
|
|
282
|
-
return e != null ?
|
|
281
|
+
const e = C(t.row, t.col.key) ?? "", n = ((r = t.col.renderProps) == null ? void 0 : r.options) ?? {};
|
|
282
|
+
return e != null ? n[e] ?? "" : "";
|
|
283
283
|
},
|
|
284
284
|
formatter: (t) => {
|
|
285
|
-
var
|
|
286
|
-
const { col: e, row:
|
|
287
|
-
return
|
|
285
|
+
var o;
|
|
286
|
+
const { col: e, row: n } = t, r = C(t.row, t.col.key) ?? "";
|
|
287
|
+
return ye(e) ? (o = e.formatter) == null ? void 0 : o.call(e, r, n) : r ?? "";
|
|
288
288
|
},
|
|
289
289
|
icon: (t) => {
|
|
290
|
-
const e = C(t.row, t.col.key) ?? "",
|
|
291
|
-
return e ? /^https?:\/\//.test(e) ?
|
|
290
|
+
const e = C(t.row, t.col.key) ?? "", n = t.col.renderProps || {};
|
|
291
|
+
return e ? /^https?:\/\//.test(e) ? g(D, {
|
|
292
292
|
src: e,
|
|
293
293
|
previewSrcList: [e],
|
|
294
294
|
fit: "contain",
|
|
295
295
|
style: "width:40px;height:40px",
|
|
296
|
-
...
|
|
297
|
-
}) : /^\s*<svg[\s\S]*<\/svg>\s*$/.test(e) ?
|
|
296
|
+
...n
|
|
297
|
+
}) : /^\s*<svg[\s\S]*<\/svg>\s*$/.test(e) ? g("div", {
|
|
298
298
|
innerHTML: e,
|
|
299
|
-
style: `width:40px;height:40px;display:inline-block;${
|
|
300
|
-
...
|
|
301
|
-
}) :
|
|
299
|
+
style: `width:40px;height:40px;display:inline-block;${n.style || ""}`,
|
|
300
|
+
...n
|
|
301
|
+
}) : g("i", {
|
|
302
302
|
class: e,
|
|
303
303
|
// val 直接当 className
|
|
304
|
-
style: `font-size:20px;${
|
|
305
|
-
...
|
|
304
|
+
style: `font-size:20px;${n.style || ""}`,
|
|
305
|
+
...n
|
|
306
306
|
}) : "";
|
|
307
307
|
}
|
|
308
308
|
};
|
|
309
309
|
}
|
|
310
|
-
function
|
|
311
|
-
const
|
|
310
|
+
function pe(t, e = 10, n = []) {
|
|
311
|
+
const o = "*:*:*", l = (a) => {
|
|
312
312
|
if (!a) return !0;
|
|
313
|
-
const
|
|
314
|
-
return
|
|
315
|
-
(
|
|
313
|
+
const p = Array.isArray(a) ? a : [a];
|
|
314
|
+
return n.some(
|
|
315
|
+
(f) => f === o || p.includes(f)
|
|
316
316
|
);
|
|
317
|
-
},
|
|
318
|
-
(
|
|
317
|
+
}, i = z(() => t.some((a) => l(a.permission))), c = z(() => t.filter((p) => l(p.permission)).slice(0, e).reduce(
|
|
318
|
+
(p, f) => p + (f.width ?? 60),
|
|
319
319
|
0
|
|
320
|
-
)),
|
|
321
|
-
(
|
|
320
|
+
)), d = (a, p) => l(a.permission) && (a.visible ? a.visible(p) : !0), y = (a) => t.filter((f) => d(f, a)).slice(0, e).reduce(
|
|
321
|
+
(f, B) => f + (B.width ?? 60),
|
|
322
322
|
0
|
|
323
323
|
);
|
|
324
324
|
return {
|
|
325
|
-
hasAnyButton:
|
|
325
|
+
hasAnyButton: i,
|
|
326
326
|
optWidth: c,
|
|
327
327
|
hasAnyVisibleButton: (a) => a != null && a.length ? a.some(
|
|
328
|
-
(
|
|
328
|
+
(p) => t.some((f) => d(f, p))
|
|
329
329
|
) : !1,
|
|
330
330
|
getMaxOptWidth: (a) => a != null && a.length ? a.reduce(
|
|
331
|
-
(
|
|
331
|
+
(p, f) => Math.max(p, y(f)),
|
|
332
332
|
0
|
|
333
333
|
) : c.value,
|
|
334
|
-
getVisibleButtons: (a) => t.filter((
|
|
334
|
+
getVisibleButtons: (a) => t.filter((p) => d(p, a)).slice(0, e)
|
|
335
335
|
};
|
|
336
336
|
}
|
|
337
|
-
const
|
|
337
|
+
const fe = ["title"], ge = /* @__PURE__ */ O({
|
|
338
338
|
__name: "index",
|
|
339
339
|
props: {
|
|
340
340
|
col: { type: Object, required: !0 },
|
|
341
|
-
permissions: { type: Array, default: () => [] }
|
|
341
|
+
permissions: { type: Array, default: () => [] },
|
|
342
|
+
pagination: { type: Object, default: () => ({}) }
|
|
342
343
|
},
|
|
343
344
|
emits: ["cellBlur", "cellEnter", "cellChange", "cellClick"],
|
|
344
345
|
setup(t, { emit: e }) {
|
|
345
|
-
const
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
346
|
+
const n = t, r = e, o = (m) => {
|
|
347
|
+
var K, w;
|
|
348
|
+
const k = (K = n.pagination) == null ? void 0 : K.page, E = (w = n.pagination) == null ? void 0 : w.size;
|
|
349
|
+
return k && E ? (k - 1) * E + m + 1 : m + 1;
|
|
350
|
+
}, { col: l } = Q(n), i = (m, k) => r("cellChange", m, k), c = (m, k) => r("cellBlur", m, k), d = (m, k) => r("cellEnter", m, k), y = (m, k) => r("cellClick", m, k), h = me(), {
|
|
351
|
+
hasAnyButton: u,
|
|
352
|
+
hasAnyVisibleButton: b,
|
|
353
|
+
optWidth: a,
|
|
354
|
+
getMaxOptWidth: p,
|
|
355
|
+
getVisibleButtons: f
|
|
356
|
+
} = pe(
|
|
357
|
+
l.value.buttons || [],
|
|
358
|
+
l.value.maxbtn ?? 10,
|
|
359
|
+
n.permissions || []
|
|
360
|
+
), B = z(() => (l.value.buttons || []).length ? (l.value.__rows || []).length ? b(l.value.__rows || []) : u.value : !1), W = z(() => l.value.__rows ? p(l.value.__rows) : a.value);
|
|
361
|
+
function G(m) {
|
|
362
|
+
return !(m.type === "selection" || m.type === "index" || m.type === "operation" && !B.value || m.visible === !1);
|
|
358
363
|
}
|
|
359
|
-
return (
|
|
360
|
-
const
|
|
361
|
-
return
|
|
364
|
+
return (m, k) => {
|
|
365
|
+
const E = V("el-table-column"), K = V("el-button");
|
|
366
|
+
return s(l).type === "selection" ? (v(), _(E, x({
|
|
362
367
|
key: 0,
|
|
363
368
|
type: "selection"
|
|
364
|
-
},
|
|
369
|
+
}, s(l).columnProps), null, 16)) : s(l).type === "index" ? (v(), _(E, x({
|
|
365
370
|
key: 1,
|
|
366
371
|
type: "index",
|
|
367
|
-
label:
|
|
372
|
+
label: s(l).label || "#",
|
|
368
373
|
align: "center"
|
|
369
|
-
},
|
|
374
|
+
}, s(l).columnProps), {
|
|
375
|
+
default: S(({ $index: w }) => [
|
|
376
|
+
q(T(o(w)), 1)
|
|
377
|
+
]),
|
|
378
|
+
_: 1
|
|
379
|
+
}, 16, ["label"])) : s(l).type === "operation" && B.value ? (v(), _(E, x({
|
|
370
380
|
key: 2,
|
|
371
|
-
label:
|
|
381
|
+
label: s(l).label || "操作",
|
|
372
382
|
align: "center"
|
|
373
383
|
}, {
|
|
374
|
-
...
|
|
375
|
-
width:
|
|
384
|
+
...s(l).columnProps,
|
|
385
|
+
width: W.value
|
|
376
386
|
}), {
|
|
377
|
-
default: S(({ row:
|
|
378
|
-
(
|
|
379
|
-
key:
|
|
380
|
-
type:
|
|
387
|
+
default: S(({ row: w }) => [
|
|
388
|
+
(v(!0), I(J, null, L(s(f)(w), (P) => (v(), _(K, {
|
|
389
|
+
key: P.label,
|
|
390
|
+
type: P.type || "primary",
|
|
381
391
|
link: "",
|
|
382
|
-
onClick: (
|
|
392
|
+
onClick: (M) => P.action(w)
|
|
383
393
|
}, {
|
|
384
394
|
default: S(() => [
|
|
385
|
-
|
|
395
|
+
q(T(P.label), 1)
|
|
386
396
|
]),
|
|
387
397
|
_: 2
|
|
388
398
|
}, 1032, ["type", "onClick"]))), 128))
|
|
389
399
|
]),
|
|
390
400
|
_: 1
|
|
391
|
-
}, 16, ["label"])) :
|
|
401
|
+
}, 16, ["label"])) : G(s(l)) ? (v(), _(E, x({
|
|
392
402
|
key: 3,
|
|
393
|
-
label:
|
|
403
|
+
label: s(l).label,
|
|
394
404
|
align: "center"
|
|
395
|
-
},
|
|
396
|
-
default: S((
|
|
397
|
-
var
|
|
405
|
+
}, s(l).columnProps || {}), {
|
|
406
|
+
default: S((w) => {
|
|
407
|
+
var P, M, j, H;
|
|
398
408
|
return [
|
|
399
|
-
|
|
409
|
+
s(l).render === "slot" && m.$slots[((P = s(l)) == null ? void 0 : P.slot) || s(l).key] ? Y(m.$slots, ((M = s(l)) == null ? void 0 : M.slot) || s(l).key, ee(x({ key: 0 }, w))) : s(l).render && s(h)[s(l).render] ? (v(), _(te(s(h)[s(l).render]), {
|
|
400
410
|
key: 1,
|
|
401
|
-
row:
|
|
402
|
-
col:
|
|
403
|
-
onCellChange:
|
|
404
|
-
onCellBlur:
|
|
405
|
-
onCellEnter:
|
|
411
|
+
row: w.row,
|
|
412
|
+
col: s(l),
|
|
413
|
+
onCellChange: i,
|
|
414
|
+
onCellBlur: c,
|
|
415
|
+
onCellEnter: d,
|
|
406
416
|
onClick: y
|
|
407
|
-
}, null, 40, ["row", "col"])) : (
|
|
417
|
+
}, null, 40, ["row", "col"])) : (v(), I("span", {
|
|
408
418
|
key: 2,
|
|
409
|
-
style:
|
|
410
|
-
class:
|
|
411
|
-
title:
|
|
412
|
-
},
|
|
419
|
+
style: le(((j = s(l).renderProps) == null ? void 0 : j.style) || ""),
|
|
420
|
+
class: ne(((H = s(l).renderProps) == null ? void 0 : H.class) || ""),
|
|
421
|
+
title: s(C)(w.row, s(l).key)
|
|
422
|
+
}, T(s(C)(w.row, s(l).key)), 15, fe))
|
|
413
423
|
];
|
|
414
424
|
}),
|
|
415
425
|
_: 3
|
|
416
|
-
}, 16, ["label"])) :
|
|
426
|
+
}, 16, ["label"])) : Z("", !0);
|
|
417
427
|
};
|
|
418
428
|
}
|
|
419
429
|
}), he = "table_columns_";
|
|
420
|
-
function
|
|
430
|
+
function ve(t, e) {
|
|
421
431
|
return `${he}${t}_${e}`;
|
|
422
432
|
}
|
|
423
|
-
function
|
|
433
|
+
function X(t, e) {
|
|
424
434
|
if (!(e != null && e.length)) return t;
|
|
425
|
-
const
|
|
435
|
+
const n = new Map(
|
|
426
436
|
e.map((r) => [r.key, r])
|
|
427
437
|
);
|
|
428
438
|
return t.map((r) => {
|
|
429
|
-
const
|
|
430
|
-
return
|
|
439
|
+
const o = n.get(r.key);
|
|
440
|
+
return o ? {
|
|
431
441
|
...r,
|
|
432
|
-
visible: typeof
|
|
442
|
+
visible: typeof o.visible == "boolean" ? o.visible : r.visible
|
|
433
443
|
} : r;
|
|
434
444
|
});
|
|
435
445
|
}
|
|
436
|
-
function
|
|
446
|
+
function Ce(t, e) {
|
|
437
447
|
const {
|
|
438
|
-
pageKey:
|
|
448
|
+
pageKey: n,
|
|
439
449
|
userId: r,
|
|
440
|
-
storage:
|
|
441
|
-
} = e || {},
|
|
442
|
-
|
|
450
|
+
storage: o = localStorage
|
|
451
|
+
} = e || {}, i = r ? ve(r, n || "") : null, c = i ? o.getItem(i) : null, d = A(
|
|
452
|
+
X(
|
|
443
453
|
t,
|
|
444
454
|
c ? JSON.parse(c) : []
|
|
445
455
|
)
|
|
446
456
|
);
|
|
447
457
|
return F(
|
|
448
|
-
|
|
449
|
-
(
|
|
450
|
-
if (!
|
|
451
|
-
const
|
|
458
|
+
d,
|
|
459
|
+
(y) => {
|
|
460
|
+
if (!i) return;
|
|
461
|
+
const h = y.map((u) => ({
|
|
452
462
|
key: u.key,
|
|
453
463
|
visible: u.visible,
|
|
454
464
|
columnOpts: u.columnOpts
|
|
455
465
|
}));
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
JSON.stringify(
|
|
466
|
+
o.setItem(
|
|
467
|
+
i,
|
|
468
|
+
JSON.stringify(h)
|
|
459
469
|
);
|
|
460
470
|
},
|
|
461
471
|
{ deep: !0 }
|
|
462
472
|
), {
|
|
463
473
|
/** 当前列配置(响应式) */
|
|
464
|
-
columns:
|
|
474
|
+
columns: d,
|
|
465
475
|
/**
|
|
466
476
|
* 主动设置列配置
|
|
467
477
|
* 常用于:列设置弹窗 / 拖拽排序完成
|
|
468
478
|
*/
|
|
469
|
-
setColumns(
|
|
470
|
-
|
|
479
|
+
setColumns(y) {
|
|
480
|
+
d.value = X(
|
|
471
481
|
t,
|
|
472
|
-
|
|
473
|
-
),
|
|
474
|
-
|
|
475
|
-
JSON.stringify(
|
|
482
|
+
y
|
|
483
|
+
), i && o.setItem(
|
|
484
|
+
i,
|
|
485
|
+
JSON.stringify(y)
|
|
476
486
|
);
|
|
477
487
|
},
|
|
478
488
|
/**
|
|
479
489
|
* 重置为默认列配置
|
|
480
490
|
*/
|
|
481
491
|
resetColumns() {
|
|
482
|
-
|
|
492
|
+
d.value = t, i && o.removeItem(i);
|
|
483
493
|
}
|
|
484
494
|
};
|
|
485
495
|
}
|
|
486
|
-
const
|
|
496
|
+
const be = /* @__PURE__ */ O({
|
|
487
497
|
__name: "index",
|
|
488
498
|
props: {
|
|
489
499
|
data: { type: Array, default: () => [] },
|
|
@@ -500,7 +510,8 @@ const Ce = /* @__PURE__ */ V({
|
|
|
500
510
|
/** 当前用户标识(可选,用于列缓存) */
|
|
501
511
|
type: [String, Number],
|
|
502
512
|
default: ""
|
|
503
|
-
}
|
|
513
|
+
},
|
|
514
|
+
pagination: { type: Object, default: () => ({}) }
|
|
504
515
|
},
|
|
505
516
|
emits: [
|
|
506
517
|
"update:columns",
|
|
@@ -509,65 +520,66 @@ const Ce = /* @__PURE__ */ V({
|
|
|
509
520
|
"cellEnter",
|
|
510
521
|
"cell-click"
|
|
511
522
|
],
|
|
512
|
-
setup(t, { expose: e, emit:
|
|
513
|
-
const r = t,
|
|
523
|
+
setup(t, { expose: e, emit: n }) {
|
|
524
|
+
const r = t, o = n, { columns: l } = Ce(r.columns, {
|
|
514
525
|
pageKey: r.pageKey ?? "",
|
|
515
526
|
userId: r.userId ?? ""
|
|
516
527
|
});
|
|
517
528
|
F(
|
|
518
|
-
|
|
519
|
-
(u) =>
|
|
529
|
+
l,
|
|
530
|
+
(u) => o("update:columns", u),
|
|
520
531
|
{ deep: !0, immediate: !0 }
|
|
521
532
|
);
|
|
522
|
-
const
|
|
523
|
-
|
|
524
|
-
},
|
|
525
|
-
console.log("enter"),
|
|
526
|
-
},
|
|
527
|
-
|
|
528
|
-
},
|
|
533
|
+
const i = (u, b) => o("cellChange", u, b), c = (u, b) => {
|
|
534
|
+
o("cellBlur", u, b);
|
|
535
|
+
}, d = (u, b) => {
|
|
536
|
+
console.log("enter"), o("cellEnter", u, b);
|
|
537
|
+
}, y = (u, b) => {
|
|
538
|
+
b && o("cell-click", u, b);
|
|
539
|
+
}, h = A();
|
|
529
540
|
return e({
|
|
530
|
-
tableRef:
|
|
531
|
-
}), (u,
|
|
532
|
-
const a =
|
|
533
|
-
return
|
|
541
|
+
tableRef: h
|
|
542
|
+
}), (u, b) => {
|
|
543
|
+
const a = V("el-table"), p = re("loading");
|
|
544
|
+
return oe((v(), _(a, x({
|
|
534
545
|
ref_key: "tableRef",
|
|
535
|
-
ref:
|
|
546
|
+
ref: h
|
|
536
547
|
}, u.$attrs, {
|
|
537
548
|
data: t.data,
|
|
538
549
|
"row-key": t.rowKey,
|
|
539
550
|
class: "smart-table"
|
|
540
551
|
}), {
|
|
541
552
|
default: S(() => [
|
|
542
|
-
(
|
|
543
|
-
key:
|
|
544
|
-
col:
|
|
553
|
+
(v(!0), I(J, null, L(s(l), (f) => (v(), _(ge, {
|
|
554
|
+
key: f.key,
|
|
555
|
+
col: f,
|
|
545
556
|
permissions: t.permissions,
|
|
546
|
-
|
|
557
|
+
pagination: t.pagination,
|
|
558
|
+
onCellChange: i,
|
|
547
559
|
onCellBlur: c,
|
|
548
|
-
onCellEnter:
|
|
549
|
-
onCellClick:
|
|
550
|
-
},
|
|
551
|
-
|
|
552
|
-
name:
|
|
560
|
+
onCellEnter: d,
|
|
561
|
+
onCellClick: y
|
|
562
|
+
}, ie({ _: 2 }, [
|
|
563
|
+
L(s(l), (B) => ({
|
|
564
|
+
name: B.key,
|
|
553
565
|
fn: S((W) => [
|
|
554
|
-
|
|
566
|
+
Y(u.$slots, B.key, x({ ref_for: !0 }, W), void 0, !0)
|
|
555
567
|
])
|
|
556
568
|
}))
|
|
557
|
-
]), 1032, ["col", "permissions"]))), 128))
|
|
569
|
+
]), 1032, ["col", "permissions", "pagination"]))), 128))
|
|
558
570
|
]),
|
|
559
571
|
_: 3
|
|
560
572
|
}, 16, ["data", "row-key"])), [
|
|
561
|
-
[
|
|
573
|
+
[p, t.loading]
|
|
562
574
|
]);
|
|
563
575
|
};
|
|
564
576
|
}
|
|
565
577
|
}), ke = (t, e) => {
|
|
566
|
-
const
|
|
567
|
-
for (const [r,
|
|
568
|
-
|
|
569
|
-
return
|
|
570
|
-
},
|
|
578
|
+
const n = t.__vccOpts || t;
|
|
579
|
+
for (const [r, o] of e)
|
|
580
|
+
n[r] = o;
|
|
581
|
+
return n;
|
|
582
|
+
}, xe = /* @__PURE__ */ ke(be, [["__scopeId", "data-v-7c94ec39"]]);
|
|
571
583
|
export {
|
|
572
|
-
|
|
584
|
+
xe as SmartTable
|
|
573
585
|
};
|