Files
qhmes/deploy-qhmes/frontend/js/TableHeaderConfigEditor-BhGCsOeV.js

2 lines
6.0 KiB
Java
Raw Normal View History

2026-05-15 11:34:12 +08:00
var ce=Object.defineProperty;var X=Object.getOwnPropertySymbols;var re=Object.prototype.hasOwnProperty,ue=Object.prototype.propertyIsEnumerable;var Y=(p,m,a)=>m in p?ce(p,m,{enumerable:!0,configurable:!0,writable:!0,value:a}):p[m]=a,N=(p,m)=>{for(var a in m||(m={}))re.call(m,a)&&Y(p,a,m[a]);if(X)for(var a of X(m))ue.call(m,a)&&Y(p,a,m[a]);return p};import{d as me,w as pe,r as de,ah as w,ar as C,as as _,au as M,ag as q,k as f,aF as x,e as S,G as y,F as z,aD as I,A as T,at as fe,aB as ve}from"./vue-vendor-C7Zq48Yl.js";import{d as Ce}from"./index-BI6CMai0.js";import"./antd-vue-vendor-BPnV8VqP.js";import"./vxe-table-vendor-B88kchpX.js";const _e={class:"header-config-editor"},xe={class:"toolbar"},ge={class:"grid-table"},we=["rowspan","colspan","onMousedown","onMousemove","onContextmenu"],Me=me({__name:"TableHeaderConfigEditor",props:{rowCount:{},colCount:{},columnTitles:{},value:{}},emits:["update:value"],setup(p,{emit:m}){const a=p,B=m,o=de({cells:[],selecting:!1,selection:{r1:0,c1:0,r2:0,c2:0},contextMenu:{visible:!1,x:0,y:0}}),h=S(()=>Math.max(1,Number(a.colCount||1))),g=S(()=>Math.max(1,Number(a.rowCount||1)));function V(t){var n;const e=(n=a.columnTitles)==null?void 0:n[t];return String(e||`列${t+1}`)}function U(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?V(i):`表头${l+1}-${i+1}`,align:"center"});return n}function J(t,e,n){return!n||!Array.isArray(n.cells)||n.colCount!==e||n.rowCount!==t?U(t,e):n.cells.map(l=>N({},l))}pe(()=>[a.rowCount,a.colCount,a.value],()=>{o.cells=J(g.value,h.value,a.value)},{immediate:!0,deep:!0});function $(){B("update:value",{rowCount:g.value,colCount:h.value,cells:o.cells.map(t=>N({},t))})}function v(t,e){return o.cells.find(n=>n.row===t&&n.col===e)}function k(t,e){return o.cells.find(n=>t>=n.row&&t<n.row+n.rowspan&&e>=n.col&&e<n.col+n.colspan)}function K(t,e){return!!v(t,e)}function E(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 P(t,e){var l;const n=v(t,e);return{selected:E(t,e),focused:(n==null?void 0:n.id)===((l=k(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},R()}function W(t,e){o.selecting&&(o.selection.r2=t,o.selection.c2=e)}function Z(){o.selecting=!1}function ee(t,e,n){const l=v(t,e);l&&(l.title=String(n||""),$())}function F(){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 te(){const{minR:t,maxR:e,minC:n,maxC:l}=F(),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 D(){if(!te())return;const{minR:t,maxR:e,minC:n,maxC:l}=F(),i=Array.from({length:l-n+1}).map((s,d)=>{const c=n+d,u=k(g.value-1,c);return String((u==null?void 0:u.title)||V(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),$())}function H(){const t=k(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"});$()}function ne(t){const e=Math.max(1,Math.min(6,Number(t||1)));o.cells=U(e,h.value),B("update:value",{rowCount:e,colCount:h.value,cells:o.cells.map(n=>N({},n))})}function oe(t,e,n){E(e,n)||(o.selection={r1:e,c1:n,r2:e,c2:n}),o.contextMenu={visible:!0,x:t.clientX,y:t.clientY}}function R(){o.contextMenu.visible=!1}function le(){D(),R()}function se(){H(),R()}const A=S(()=>o.contextMenu),j=S(()=>k(o.sel