calculator2026/33/static/js/HourlyFeeGrid-DixkKG6W.js
2026-06-25 09:43:48 +08:00

1 line
14 KiB
JavaScript

import{$ as e,At as t,Bt as n,Cr as r,Dt as i,Er as a,H as o,K as s,Mt as c,Ot as l,Pt as u,U as d,Wn as f,er as p,mn as m,tt as h,xr as ee}from"./vendor-ag-grid~XmMajorFactor~XmConsultCategoryFactor~xmInfo~ZxFwView~HtFeeMethodTypeLineVie~ntegcu2a-CFxQnYK4.js";import{t as te}from"./vendor-ag-grid~XmMajorFactor~XmConsultCategoryFactor~xmInfo~ZxFwView~HtFeeMethodTypeLineVie~ntegcu2a-BnO-wAhh.js";import{D as g}from"./workspace-DxKKyh8w.js";import{a as _,i as v,o as y,s as b}from"./decimal-D3bp1pbs.js";import{r as x}from"./numberFormat-jhZZmX17.js";import{n as S}from"./sql-C69Jo4HU.js";import{t as C}from"./_plugin-vue_export-helper-DUFB50Ey.js";import{C as ne,n as w}from"./index-CAPJG_im.js";import{t as re}from"./vendor-ag-grid~XmMajorFactor~XmConsultCategoryFactor~xmInfo~ZxFwView~HtFeeMethodTypeLineVie~ntegcu2a-DXO754eW.js";import{a as ie,i as ae,o as T,r as E,t as D}from"./agGridReadonlyAutoHeight-BpRhYCq1.js";var O={class:`h-full min-h-0 flex flex-col`},k={class:`rounded-lg border bg-card xmMx flex min-h-0 flex-1 flex-col`},oe={class:`flex items-center justify-between border-b px-4 py-3`},se={class:`text-sm font-semibold text-foreground`},A=C(h({__name:`HourlyFeeGrid`,props:{storageKey:{},title:{default:void 0},contractId:{},serviceId:{},enableZxFwSync:{type:Boolean,default:!1},syncField:{default:`hourly`},htMainStorageKey:{},htRowId:{},htMethodType:{}},setup(h){let C=h;ne();let{t:A,locale:j}=g(),M=f([]),N=f(null),ce=o(()=>C.syncField===`investScale`?`investScale`:C.syncField===`landScale`?`landScale`:C.syncField===`workload`?`workload`:C.syncField===`hourly`?`hourly`:null);o(()=>!!(C.enableZxFwSync&&C.contractId&&C.serviceId!=null&&ce.value)),o(()=>!!(C.htMainStorageKey&&C.htRowId&&C.htMethodType));let P=o({get:()=>M.value,set:e=>{M.value=e}}),F=e=>e?String(j.value).toLowerCase().startsWith(`en`)&&e.nameEn||e.name:``;Object.entries(S).sort((e,t)=>Number(e[0])-Number(t[0])).filter(e=>{let t=e[1];return!!(t?.code&&t?.name)});let I=(e,t)=>{let n=typeof e==`number`&&Number.isFinite(e),r=typeof t==`number`&&Number.isFinite(t);return n&&r?`${e}-${t}`:n?String(e):r?String(t):``},L=e=>typeof e.manageCoe!=`number`||!Number.isFinite(e.manageCoe)?``:I(typeof e.minPrice==`number`&&Number.isFinite(e.minPrice)?v(b(e.minPrice).mul(e.manageCoe),2):null,typeof e.maxPrice==`number`&&Number.isFinite(e.maxPrice)?v(b(e.maxPrice).mul(e.manageCoe),2):null),R=e=>typeof e.defPrice!=`number`||!Number.isFinite(e.defPrice)||typeof e.manageCoe!=`number`||!Number.isFinite(e.manageCoe)?null:v(b(e.defPrice).mul(e.manageCoe),2),z=async()=>{let e=[],t=await w().query([{field:`type`,value:`${C.contractId}-zxFw`,operator:`eq`}]);for(let n of t){if(n.typel.workDay==0)continue;let t=n.id||n._id,r=`${C.contractId}-hourly-${t}`;e.push({id:r,type:`${C.contractId}-hourly`,expertCode:n.code,expertName:F(n),laborBudgetUnitPrice:I(n.minPrice,n.maxPrice),compositeBudgetUnitPrice:L(n),adoptedBudgetUnitPrice:R(n),personnelCount:null,workdayCount:null,serviceBudget:null,unitPrice2:1600,unitPrice3:2400,unitPrice4:3200,unitPrice5:4e3,workdayCount2:1,workdayCount3:1,workdayCount4:1,workdayCount5:1,feeSubtotal2:1600,feeSubtotal3:2400,feeSubtotal4:3200,feeSubtotal5:4e3,remark:``,path:[r]})}return e},B=e=>{if(e===``||e==null)return null;let t=x(e,{sanitize:!0,precision:0});return t==null||!Number.isSafeInteger(t)||t<0?null:t},V=e=>{let t=e?.adoptedBudgetUnitPrice,n=e?.personnelCount,r=e?.workdayCount;return typeof t!=`number`||!Number.isFinite(t)||typeof n!=`number`||!Number.isFinite(n)||typeof r!=`number`||!Number.isFinite(r)?null:v(b(t).mul(n).mul(r),2)},H=()=>{for(let e of P.value){let t=Number(e.workdayCount2)||0,n=Number(e.workdayCount3)||0,r=Number(e.workdayCount4)||0,i=Number(e.workdayCount5)||0,a=Number(e.unitPrice2)||0,o=Number(e.unitPrice3)||0,s=Number(e.unitPrice4)||0,c=Number(e.unitPrice5)||0;e.feeSubtotal2=Math.round(a*t),e.feeSubtotal3=Math.round(o*n),e.feeSubtotal4=Math.round(s*r),e.feeSubtotal5=Math.round(c*i),e.workdayCount6=t+n+r+i,e.feeSubtotal6=Math.round(a*t+o*n+s*r+c*i);let l=e.workdayCount6;e.avgUnitPrice=l>0?Math.round(e.feeSubtotal6/l):0}};function U(e,t,n={}){let{decimals:r=0,aggFunc:i=`sum`}=n;return{width:100,field:e,headerName:t,editable:!0,cellDataType:`number`,valueFormatter:e=>{if(e.node?.rowPinned===`bottom`)return`/`;let t=e.value;return t==null?`0.00`:Number(t).toFixed(2)},aggFunc:i}}function W(e,t,n={}){let{decimals:r=0,aggFunc:i=`sum`}=n;return{width:100,field:e,headerName:t,editable:!0,cellDataType:`number`,valueParser:e=>{let t=e.newValue?.trim();if(!t)return null;let n=parseFloat(t);return isNaN(n)||n<0?null:n},valueFormatter:e=>{let t=e.value;return t==null?0:r===0?Math.round(t).toString():t},aggFunc:i}}function G(e,t,n=`unitPrice`,r=`workdayCount`){return{width:100,field:e,headerName:t,editable:!1,cellDataType:`number`,valueGetter:e=>{let t=(e.data?.[n]??0)*(e.data?.[r]??0);if(e.node?.rowPinned===`bottom`){let e=M.value.reduce((e,t)=>e+(t[n]||0)*(t[r]||0),0);return Math.round(e)}return Math.round(t)},valueFormatter:e=>{if(e.node?.rowPinned===`bottom`)return`/`;let t=e.value;return t==null?`0.00`:Number(t).toFixed(2)},aggFunc:`sum`}}function le(e,t,n){let{decimals:r=0,aggFunc:i=`sum`}=n;return{width:100,field:e,headerName:t,editable:!1,cellDataType:`number`,valueGetter:e=>{let t=e.data?.workdayCount??0,n=e.data?.workdayCount2??0,r=e.data?.workdayCount3??0,i=e.data?.workdayCount4??0,a=e.data?.workdayCount5??0;return t+n+r+i+a},valueFormatter:e=>{let t=e.value;return t==null?``:r===0?Math.round(t).toString():Number(t).toFixed(0)}}}function ue(e,t,n){let{decimals:r=0,aggFunc:i=`sum`}=n;return{width:100,field:e,headerName:t,editable:!1,cellDataType:`number`,valueFormatter:e=>{if(e.node?.rowPinned===`bottom`)return`/`;let t=e.data?.avgUnitPrice;return(Number.isFinite(Number(t))?Number(t):0).toFixed(2)}}}function de(e,t,n){let{decimals:r=0,aggFunc:i=`sum`}=n;return{width:100,field:e,headerName:t,editable:!1,cellDataType:`number`,valueFormatter:e=>{let t=e.value;return t==null?``:Number(t).toFixed(2)}}}let fe=[{headerName:A(`hourlyFeeGrid.columns.code`),field:`expertCode`,minWidth:90,width:100,pinned:`left`,colSpan:e=>e.node?.rowPinned?2:1,valueFormatter:e=>e.node?.rowPinned?A(`hourlyFeeGrid.total`):e.value||0},{headerName:A(`hourlyFeeGrid.columns.name`),field:`expertName`,minWidth:210,width:230,pinned:`left`,tooltipField:`expertName`,wrapText:!0,autoHeight:!0,cellClass:`hourly-fee-name-cell`,cellStyle:{whiteSpace:`normal`,lineHeight:`1.2`},valueFormatter:e=>e.node?.rowPinned?``:e.value||``},{headerName:A(`hourlyFeeGrid.columns.assistantEngineer`),marryChildren:!0,children:[U(`unitPrice2`,A(`hourlyFeeGrid.columns.unitPrice`),{decimals:0}),W(`workdayCount2`,A(`hourlyFeeGrid.columns.workdayCount`),{decimals:1}),G(`feeSubtotal2`,A(`hourlyFeeGrid.columns.subtotal`),`unitPrice2`,`workdayCount2`)]},{headerName:A(`hourlyFeeGrid.columns.midEngineer`),marryChildren:!0,children:[U(`unitPrice3`,A(`hourlyFeeGrid.columns.unitPrice`),{decimals:0}),W(`workdayCount3`,A(`hourlyFeeGrid.columns.workdayCount`),{decimals:1}),G(`feeSubtotal3`,A(`hourlyFeeGrid.columns.subtotal`),`unitPrice3`,`workdayCount3`)]},{headerName:A(`hourlyFeeGrid.columns.seniorEngineer`),marryChildren:!0,children:[U(`unitPrice4`,A(`hourlyFeeGrid.columns.unitPrice`),{decimals:0}),W(`workdayCount4`,A(`hourlyFeeGrid.columns.workdayCount`),{decimals:1}),G(`feeSubtotal4`,A(`hourlyFeeGrid.columns.subtotal`),`unitPrice4`,`workdayCount4`)]},{headerName:A(`hourlyFeeGrid.columns.profSeniorEngineer`),marryChildren:!0,children:[U(`unitPrice5`,A(`hourlyFeeGrid.columns.unitPrice`),{decimals:0}),W(`workdayCount5`,A(`hourlyFeeGrid.columns.workdayCount`),{decimals:1}),G(`feeSubtotal5`,A(`hourlyFeeGrid.columns.subtotal`),`unitPrice5`,`workdayCount5`)]},{headerName:A(`hourlyFeeGrid.columns.total`),marryChildren:!0,children:[le(`workdayCount6`,A(`hourlyFeeGrid.columns.workdayCount`),{decimals:1}),de(`feeSubtotal6`,A(`hourlyFeeGrid.columns.subtotal`),{decimals:0}),ue(`avgUnitPrice`,A(`hourlyFeeGrid.columns.avgUnitPrice`),{decimals:0})]},{headerName:A(`hourlyFeeGrid.columns.remark`),field:`remark`,minWidth:120,flex:1,cellEditor:`agLargeTextCellEditor`,wrapText:!0,autoHeight:!0,cellStyle:{whiteSpace:`normal`,lineHeight:`1.4`},editable:e=>!e.node?.group&&!e.node?.rowPinned,valueFormatter:e=>!e.node?.group&&!e.node?.rowPinned&&!e.value?A(`hourlyFeeGrid.clickToInput`):e.value||``,cellClass:e=>!e.node?.group&&!e.node?.rowPinned?` remark-wrap-cell`:``,cellClassRules:{"editable-cell-empty":e=>!e.node?.group&&!e.node?.rowPinned&&(e.value==null||e.value===``)}}],pe=o(()=>D(fe)),me=o(()=>_(P.value,e=>e.workdayCount)),he=o(()=>_(P.value,e=>e.workdayCount2)),ge=o(()=>_(P.value,e=>e.workdayCount3)),K=o(()=>_(P.value,e=>e.workdayCount4)),_e=o(()=>_(P.value,e=>e.workdayCount5));o(()=>_(P.value,e=>e.feeSubtotal));let ve=o(()=>_(P.value,e=>e.feeSubtotal2)),ye=o(()=>_(P.value,e=>e.feeSubtotal3)),be=o(()=>_(P.value,e=>e.feeSubtotal4)),xe=o(()=>_(P.value,e=>e.feeSubtotal5)),Se=o(()=>P.value.reduce((e,t)=>e+(Number(t.feeSubtotal6)||0),0)),Ce=o(()=>_(P.value,e=>e.avgUnitPrice));o(()=>_(P.value,e=>e.personnelCount));let we=o(()=>y(P.value.map(e=>V(e)))),Te=o(()=>[{id:`pinned-total-row`,expertCode:A(`hourlyFeeGrid.total`),expertName:``,laborBudgetUnitPrice:``,compositeBudgetUnitPrice:``,adoptedBudgetUnitPrice:null,unitPrice:`/`,workdayCount:me.value,workdayCount2:he.value,workdayCount3:ge.value,workdayCount4:K.value,workdayCount5:_e.value,avgUnitPrice:Ce.value,feeSubtotal2:ve.value,feeSubtotal3:ye.value,feeSubtotal4:be.value,feeSubtotal5:xe.value,feeSubtotal6:Se.value,serviceBudget:we.value,remark:``,path:[`TOTAL`]}]),q=async()=>{try{H();let e=P.value.filter(e=>e.id!==`pinned-total-row`).map(e=>({...e}));await w().upsertBatch(e)}catch(e){console.error(`save error`,e)}},J=async()=>{try{let e=await z(),t=(await w().query([{field:`type`,value:`${C.contractId}-hourly`,operator:`eq`}])).map(e=>({id:String(e.id||``),expertCode:String(e.expertCode||``),expertName:String(e.expertName||``),laborBudgetUnitPrice:String(e.laborBudgetUnitPrice||``),compositeBudgetUnitPrice:String(e.compositeBudgetUnitPrice||``),adoptedBudgetUnitPrice:e.adoptedBudgetUnitPrice==null?null:Number(e.adoptedBudgetUnitPrice),personnelCount:e.personnelCount==null?null:Number(e.personnelCount),workdayCount:e.workdayCount==null?null:Number(e.workdayCount),serviceBudget:e.serviceBudget==null?null:Number(e.serviceBudget),remark:String(e.remark||``),path:Array.isArray(e.path)?e.path:[],unitPrice2:e.unitPrice2==null?1600:Number(e.unitPrice2),workdayCount2:e.workdayCount2==null?null:Number(e.workdayCount2),feeSubtotal2:e.feeSubtotal2==null?null:Number(e.feeSubtotal2),unitPrice3:e.unitPrice3==null?2400:Number(e.unitPrice3),workdayCount3:e.workdayCount3==null?null:Number(e.workdayCount3),feeSubtotal3:e.feeSubtotal3==null?null:Number(e.feeSubtotal3),unitPrice4:e.unitPrice4==null?3200:Number(e.unitPrice4),workdayCount4:e.workdayCount4==null?null:Number(e.workdayCount4),feeSubtotal4:e.feeSubtotal4==null?null:Number(e.feeSubtotal4),unitPrice5:e.unitPrice5==null?4e3:Number(e.unitPrice5),workdayCount5:e.workdayCount5==null?null:Number(e.workdayCount5),feeSubtotal5:e.feeSubtotal5==null?null:Number(e.feeSubtotal5),workdayCount6:e.workdayCount6==null?null:Number(e.workdayCount6),feeSubtotal6:e.feeSubtotal6==null?null:Number(e.feeSubtotal6),avgUnitPrice:e.avgUnitPrice==null?null:Number(e.avgUnitPrice)})),n=new Map;t.forEach(e=>n.set(e.expertCode,e)),M.value=e.map(e=>{let t=n.get(e.expertCode);return t?{...e,personnelCount:t.personnelCount,workdayCount:t.workdayCount,serviceBudget:t.serviceBudget,adoptedBudgetUnitPrice:t.adoptedBudgetUnitPrice,unitPrice2:t.unitPrice2,workdayCount2:t.workdayCount2,feeSubtotal2:t.feeSubtotal2,unitPrice3:t.unitPrice3,workdayCount3:t.workdayCount3,feeSubtotal3:t.feeSubtotal3,unitPrice4:t.unitPrice4,workdayCount4:t.workdayCount4,feeSubtotal4:t.feeSubtotal4,unitPrice5:t.unitPrice5,workdayCount5:t.workdayCount5,feeSubtotal5:t.feeSubtotal5,workdayCount6:t.workdayCount6,feeSubtotal6:t.feeSubtotal6,avgUnitPrice:t.avgUnitPrice,remark:t.remark}:e}),console.log(`✅ 按专家编码智能加载:保留用户数据 + 同步最新结构`)}catch(e){console.error(`❌ 加载失败`,e),M.value=await z()}},Ee=async()=>{if(P.value.length===0)return;let e=!1;P.value=P.value.map(t=>{let n=String(t.id||``).match(/^expert-(\d+)$/);if(!n)return t;let r=S[n[1]];if(!r)return t;let i=F(r);return t.expertName===i?t:(e=!0,{...t,expertName:i})}),N.value?.refreshCells({force:!0}),e&&await q()},De=e=>{q(),H(),N.value?.refreshCells()},Y=()=>{},X=e=>{},Oe=e=>{N.value=e.api,$()},Z=null,Q=e=>!!(e&&!e.isDestroyed?.()),ke=()=>{setTimeout(()=>{let e=N.value;Q(e)&&(e.refreshCells({force:!0}),e.redrawRows())},16)},Ae=async()=>{await i();let e=N.value;Q(e)&&(e.onRowHeightChanged(),e.refreshCells({force:!0}),e.redrawRows(),ke())},$=()=>{Z&&clearTimeout(Z),Z=setTimeout(()=>{Z=null,Q(N.value)&&Ae()},0)},je=()=>{$()},Me=()=>{$()},Ne=e=>{$()},Pe=e=>{$()},Fe=e=>Array.isArray(e.value)?JSON.stringify(e.value):e.value,Ie=e=>{let t=String(e.column?.getColDef?.().field||``);if(t===`personnelCount`)return B(e.value);if(t===`adoptedBudgetUnitPrice`||t===`workdayCount`)return x(e.value,{precision:3});try{let t=JSON.parse(e.value);if(Array.isArray(t))return t}catch{return e.value}return e.value};return u(async()=>{console.log(`🚀 组件挂载`),await J(),$()}),l(async()=>{console.log(`🔙 组件激活`),await J(),$()}),m(()=>w().items,async e=>{Object.keys(e).length>0&&J()},{immediate:!0,deep:!0}),m(()=>C.storageKey,()=>{J(),$()}),m(()=>P.value.length,()=>{$()}),m(()=>j.value,()=>{Ee()}),c(()=>{console.log(`🔄 组件失活,保存数据`),N.value?.stopEditing(),q()}),t(()=>{console.log(`💔 组件卸载,保存数据`),N.value?.stopEditing(),N.value=null,Z&&=(clearTimeout(Z),null),q()}),(t,i)=>(n(),s(`div`,O,[d(`div`,k,[d(`div`,oe,[d(`h3`,se,a(C.title||p(A)(`hourlyFeeGrid.title`)),1),i[0]||=d(`div`,{class:`text-xs text-muted-foreground`},null,-1)]),d(`div`,{class:ee(p(ae))},[e(p(te),{style:r(p(E)),rowData:P.value,pinnedBottomRowData:Te.value,columnDefs:pe.value,gridOptions:p(ie),theme:p(T),animateRows:!0,treeData:!1,onCellValueChanged:De,onPasteStart:Y,onPasteEnd:X,onFillStart:Y,onFillEnd:X,suppressColumnVirtualisation:!0,suppressRowVirtualisation:!0,cellSelection:{handle:{mode:`range`}},enableClipboard:!0,localeText:p(re),tooltipShowDelay:500,headerHeight:50,processCellForClipboard:Fe,processCellFromClipboard:Ie,undoRedoCellEditing:!0,undoRedoCellEditingLimit:20,onGridReady:Oe,onFirstDataRendered:Ne,onRowDataUpdated:Pe,onGridSizeChanged:je,onColumnResized:Me},null,8,[`style`,`rowData`,`pinnedBottomRowData`,`columnDefs`,`gridOptions`,`theme`,`localeText`])],2)])]))}}),[[`__scopeId`,`data-v-ec557cf6`]]);export{A as t};