2 lines
6.0 KiB
Java
2 lines
6.0 KiB
Java
|
|
var ie=Object.defineProperty;var G=Object.getOwnPropertySymbols;var ce=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable;var J=(p,m,a)=>m in p?ie(p,m,{enumerable:!0,configurable:!0,writable:!0,value:a}):p[m]=a,R=(p,m)=>{for(var a in m||(m={}))ce.call(m,a)&&J(p,a,m[a]);if(G)for(var a of G(m))re.call(m,a)&&J(p,a,m[a]);return p};import{e as ue,h as me,C,z as _,Q as w,H as K,f,A as x,F as z,D as L,c as b,T as pe,K as de,E as S,R as N,J as fe,b as ve}from"./vue-vendor-DNhG1Cve.js";import{aE as Ce,av as _e,aw as xe,aG as ge,au as we}from"./index-X7Y8jykP.js";import Me from"./index-DklMb9Qc.js";import"./emoji-mart-vue-fast-R0uJEDq-.js";import"./UpOutlined-B1UMbtrP.js";const he={class:"header-config-editor"},be={class:"toolbar"},Se={class:"grid-table"},ye=["rowspan","colspan","onMousedown","onMousemove","onContextmenu"],$e=ue({__name:"TableHeaderConfigEditor",props:{rowCount:{},colCount:{},columnTitles:{},value:{}},emits:["update:value"],setup(p,{emit:m}){const a=p,A=m,o=ve({cells:[],selecting:!1,selection:{r1:0,c1:0,r2:0,c2:0},contextMenu:{visible:!1,x:0,y:0}}),M=b(()=>Math.max(1,Number(a.colCount||1))),g=b(()=>Math.max(1,Number(a.rowCount||1)));function B(t){var n;const e=(n=a.columnTitles)==null?void 0:n[t];return String(e||`列${t+1}`)}function E(t,e){const n=[];for(let l=0;l<t;l+=1)for(let i=0;i<e;i+=1)n.push({id:`h_${l}_${i}_${Math.random().toString(36).slice(2,8)}`,row:l,col:i,rowspan:1,colspan:1,title:l===t-1?B(i):`表头${l+1}-${i+1}`,align:"center"});return n}function Q(t,e,n){return!n||!Array.isArray(n.cells)||n.colCount!==e||n.rowCount!==t?E(t,e):n.cells.map(l=>R({},l))}me(()=>[a.rowCount,a.colCount,a.value],()=>{o.cells=Q(g.value,M.value,a.value)},{immediate:!0,deep:!0});function y(){A("update:value",{rowCount:g.value,colCount:M.value,cells:o.cells.map(t=>R({},t))})}function v(t,e){return o.cells.find(n=>n.row===t&&n.col===e)}function $(t,e){return o.cells.find(n=>t>=n.row&&t<n.row+n.rowspan&&e>=n.col&&e<n.col+n.colspan)}function X(t,e){return!!v(t,e)}function V(t,e){const n=Math.min(o.selection.r1,o.selection.r2),l=Math.max(o.selection.r1,o.selection.r2),i=Math.min(o.selection.c1,o.selection.c2),r=Math.max(o.selection.c1,o.selection.c2);return t>=n&&t<=l&&e>=i&&e<=r}function Y(t,e){var l;const n=v(t,e);return{selected:V(t,e),focused:(n==null?void 0:n.id)===((l=$(o.selection.r2,o.selection.c2))==null?void 0:l.id)}}function q(t,e){o.selecting=!0,o.selection={r1:t,c1:e,r2:t,c2:e},k()}function P(t,e){o.selecting&&(o.selection.r2=t,o.selection.c2=e)}function W(){o.selecting=!1}function Z(t,e,n){const l=v(t,e);l&&(l.title=String(n||""),y())}function U(){return{minR:Math.min(o.selection.r1,o.selection.r2),maxR:Math.max(o.selection.r1,o.selection.r2),minC:Math.min(o.selection.c1,o.selection.c2),maxC:Math.max(o.selection.c1,o.selection.c2)}}function ee(){const{minR:t,maxR:e,minC:n,maxC:l}=U(),i=o.cells.filter(s=>s.row>=t&&s.row<=e&&s.col>=n&&s.col<=l),r=(e-t+1)*(l-n+1);return i.length===r&&i.every(s=>s.rowspan===1&&s.colspan===1)}function H(){if(!ee())return;const{minR:t,maxR:e,minC:n,maxC:l}=U(),i=Array.from({length:l-n+1}).map((s,d)=>{const c=n+d,u=$(g.value-1,c);return String((u==null?void 0:u.title)||B(c))}),r=v(t,n);r&&(r.rowspan=e-t+1,r.colspan=l-n+1,e===g.value-1&&(r.title=n===l?i[0]:i.join(" / ")),o.cells=o.cells.filter(s=>s===r||s.row<t||s.row>e||s.col<n||s.col>l),y())}function D(){const t=$(o.selection.r2,o.selection.c2);if(!t||t.rowspan===1&&t.colspan===1)return;const{row:e,col:n,rowspan:l,colspan:i,title:r}=t;o.cells=o.cells.filter(s=>s.id!==t.id);for(let s=e;s<e+l;s+=1)for(let d=n;d<n+i;d+=1)o.cells.push({id:`h_${s}_${d}_${Math.random().toString(36).slice(2,8)}`,row:s,col:d,rowspan:1,colspan:1,title:s===e&&d===n?r:"",align:t.align||"center"});y()}function te(t){const e=Math.max(1,Math.min(6,Number(t||1)));o.cells=E(e,M.value),A("update:value",{rowCount:e,colCount:M.value,cells:o.cells.map(n=>R({},n))})}function ne(t,e,n){V(e,n)||(o.selection={r1:e,c1:n,r2:e,c2:n}),o.contextMenu={visible:!0,x:t.clientX,y:t.clientY}}function k(){o.contextMenu.visible=!1}function oe(){H(),k()}function le(){
|