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

2 lines
8.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import{$ as e,At as t,Bt as n,Dt as r,Er as i,H as a,K as o,Ot as s,Pt as c,U as l,Wn as u,er as d,ft as f,mn as p,qn as m,tt as h}from"./vendor-ag-grid~XmMajorFactor~XmConsultCategoryFactor~xmInfo~ZxFwView~HtFeeMethodTypeLineVie~ntegcu2a-CFxQnYK4.js";import{t as g}from"./vendor-ag-grid~XmMajorFactor~XmConsultCategoryFactor~xmInfo~ZxFwView~HtFeeMethodTypeLineVie~ntegcu2a-BnO-wAhh.js";import"./vendor-vue-CSlAvuUs.js";import{D as _}from"./workspace-DxKKyh8w.js";import{i as v,l as y}from"./decimal-D3bp1pbs.js";import{n as b,t as x}from"./numberFormat-jhZZmX17.js";import{t as S,x as C}from"./sql-C69Jo4HU.js";import{t as w}from"./_plugin-vue_export-helper-DUFB50Ey.js";import{C as T}from"./index-CAPJG_im.js";import{t as E}from"./vendor-ag-grid~XmMajorFactor~XmConsultCategoryFactor~xmInfo~ZxFwView~HtFeeMethodTypeLineVie~ntegcu2a-DXO754eW.js";import{a as D,o as O,t as k}from"./agGridReadonlyAutoHeight-BpRhYCq1.js";var ee={class:`flex flex-col gap-3`},te={class:`rounded-lg border bg-card xmMx flex flex-col overflow-hidden`},ne={class:`flex items-center justify-between border-b px-3 py-2`},A={class:`text-xs font-semibold text-foreground leading-none`},j={class:`ag-theme-quartz w-full`},M={class:`rounded-lg border bg-card p-3 space-y-2`},N={class:`text-xs font-semibold text-foreground`},P=[`value`,`placeholder`],F=w(h({__name:`HtContractSummary`,props:{contractId:{}},setup(w){let F=w,{t:I}=_(),L=T(),R=m(null),z=u([]),B=u(``),V=null,H=e=>{let t=e.filter(e=>y(e)!=null);return t.length===0?null:v(t.reduce((e,t)=>e+t,0),3)},U=e=>{let t=Array.isArray(e?.detailRows)?e.detailRows:[];if(t.length===0)return null;let n=0,r=!1;for(let e of t){let t=y(e?.serviceBudget);if(t!=null){n+=t,r=!0;continue}let i=y(e?.adoptedBudgetUnitPrice),a=y(e?.personnelCount),o=y(e?.workdayCount);i==null||a==null||o==null||(n+=i*a*o,r=!0)}return r?v(n,3):null},W=e=>{let t=Array.isArray(e?.detailRows)?e.detailRows:[];if(t.length===0)return null;let n=0,r=!1;for(let e of t){if(String(e?.id||``)===`fee-subtotal-fixed`)continue;let t=y(e?.budgetFee);if(t!=null){n+=t,r=!0;continue}let i=y(e?.quantity),a=y(e?.unitPrice);i==null||a==null||(n+=i*a,r=!0)}return r?v(n,3):null},G=async(e,t)=>{let[n,r,i]=await Promise.all([L.loadHtFeeMethodState(e,t,`rate-fee`),L.loadHtFeeMethodState(e,t,`hourly-fee`),L.loadHtFeeMethodState(e,t,`quantity-unit-price-fee`)]),a=y(n?.budgetFee),o=y(n?.rate),s=U(r),c=W(i);return{subtotal:H([a,s,c]),m0:a==null?null:{coe:o==null?`--`:String(o),fee:v(a,2)},m4:s==null?null:{fee:v(s,2)},m5:c==null?null:{fee:v(c,2)}}},K=async(e,t)=>{let n=`htExtraFee-${F.contractId}-${e===`additional`?`additional-work`:`reserve`}`;await L.loadHtFeeMainState(n);let r=await Promise.all(t.map(async t=>{let r=await G(n,String(t.id)),i=[];r.m0&&i.push(I(`htSummary.explainByRate`,{rate:r.m0.coe,fee:r.m0.fee})),r.m4&&i.push(I(`htSummary.explainByHourly`,{fee:r.m4.fee})),r.m5&&i.push(I(`htSummary.explainByQuantity`,{fee:r.m5.fee}));let a=I(e===`additional`?`htSummary.additionalPrefix`:`htSummary.reservePrefix`),o=i.length>0?`${a}-${t.name}${i.join(`;`)}`:``;return{row:{id:`${e}-${t.id}`,rowType:e,code:t.code,name:t.name,investScale:null,landScale:null,workload:null,hourly:null,subtotal:r.subtotal,finalFee:r.subtotal},explainLine:o}}));return{rows:r.map(e=>e.row).filter(e=>e.subtotal!=null),explainLines:r.filter(e=>e.row.subtotal!=null&&e.explainLine).map(e=>e.explainLine)}},q=()=>{let e=L.getContractState(F.contractId),t=new Set((e?.selectedIds||[]).map(e=>String(e)));return(Array.isArray(e?.detailRows)?e.detailRows:[]).filter(e=>String(e.id)!==`fixed-budget-c`&&t.has(String(e.id))).map(e=>({id:`service-${e.id}`,rowType:`service`,code:e.code||``,name:e.name||``,investScale:y(e.investScale),landScale:y(e.landScale),workload:y(e.workload),hourly:y(e.hourly),subtotal:y(e.subtotal),finalFee:y(e.finalFee)??y(e.subtotal)}))},J=async()=>{await L.loadContract(F.contractId);let[e,t]=await Promise.all([K(`additional`,S.map(e=>({id:e.id,name:e.name,code:e.code}))),K(`reserve`,C.map(e=>({id:e.id,name:e.name,code:e.code})))]);z.value=[...q(),...e.rows,...t.rows],B.value=[...e.explainLines,...t.explainLines].join(`
`)},Y=()=>{V&&clearTimeout(V),V=setTimeout(()=>{J()},80)},X=a(()=>{let e=`htExtraFee-${F.contractId}-additional-work`,t=`htExtraFee-${F.contractId}-reserve`;return JSON.stringify({contract:L.contracts[F.contractId]||null,addMain:L.htFeeMainStates[e]||null,reserveMain:L.htFeeMainStates[t]||null,addMethods:L.htFeeMethodStates[e]||null,reserveMethods:L.htFeeMethodStates[t]||null})}),re=a(()=>{let e=e=>H(z.value.map(e));return{id:`summary-total-row`,rowType:`total`,code:``,name:I(`htSummary.total`),investScale:e(e=>e.investScale),landScale:e(e=>e.landScale),workload:e(e=>e.workload),hourly:e(e=>e.hourly),subtotal:null,finalFee:e(e=>e.finalFee)}}),ie=h({name:`RichCodeRenderer`,props:{params:{type:Object,required:!0}},setup(e){return()=>{if(e.params.data?.rowType===`total`)return f(`span`,e.params.data.name||I(`htSummary.total`));let t=e.params.value;return!t||typeof t==`string`?f(`span`,t||``):f(`span`,{class:`inline-flex items-baseline gap-[1px]`},(Array.isArray(t.richText)?t.richText:[]).map((e,t)=>f(`span`,{key:`${t}-${e.text||``}`,style:{fontStyle:e?.font?.italic?`italic`:`normal`,verticalAlign:e?.font?.vertAlign===`subscript`?`sub`:e?.font?.vertAlign===`superscript`?`super`:`baseline`,fontSize:e?.font?.vertAlign?`0.85em`:`1em`}},e?.text||``)))}}}),ae=[{headerName:I(`htSummary.columns.code`),field:`code`,minWidth:90,maxWidth:140,colSpan:e=>e.data?.rowType===`total`?2:1,valueFormatter:e=>e.data?.rowType===`total`?e.data.name||I(`htSummary.total`):typeof e.value==`string`?e.value:``,cellRenderer:ie},{headerName:I(`htSummary.columns.name`),field:`name`,minWidth:220,flex:2,wrapText:!0,autoHeight:!0,cellStyle:{"line-height":1.6}},{headerName:I(`htSummary.columns.investScale`),field:`investScale`,minWidth:120,flex:1.2,headerClass:`ag-right-aligned-header`,cellClassRules:{"ag-right-aligned-cell":()=>!0},colSpan:e=>e.data&&(e.data.rowType===`total`||e.data.rowType===`additional`||e.data.rowType===`reserve`)?5:1,valueFormatter:e=>e.data?.rowType===`total`||e.value==null?``:b(e.value,3)},{headerName:I(`htSummary.columns.landScale`),field:`landScale`,minWidth:120,flex:1.2,headerClass:`ag-right-aligned-header`,cellClassRules:{"ag-right-aligned-cell":()=>!0},valueFormatter:e=>e.data?.rowType===`total`||e.value==null?``:b(e.value,3)},{headerName:I(`htSummary.columns.workload`),field:`workload`,minWidth:110,flex:1.2,headerClass:`ag-right-aligned-header`,cellClassRules:{"ag-right-aligned-cell":()=>!0},valueFormatter:e=>e.data?.rowType===`total`||e.value==null?``:b(e.value,3)},{headerName:I(`htSummary.columns.hourly`),field:`hourly`,minWidth:110,flex:1.2,headerClass:`ag-right-aligned-header`,cellClassRules:{"ag-right-aligned-cell":()=>!0},valueFormatter:e=>e.data?.rowType===`total`||e.value==null?``:b(e.value,3)},{headerName:I(`htSummary.columns.subtotal`),field:`subtotal`,minWidth:120,flex:1.2,headerClass:`ag-right-aligned-header`,cellClassRules:{"ag-right-aligned-cell":()=>!0},valueFormatter:e=>e.value==null?``:x(e.value,2)},{headerName:I(`htSummary.columns.finalFee`),field:`finalFee`,minWidth:120,flex:1.2,headerClass:`ag-right-aligned-header`,cellClassRules:{"ag-right-aligned-cell":()=>!0},valueFormatter:e=>e.value==null?``:x(e.value,2)}],oe=a(()=>k(ae)),se={...D,treeData:!1,getDataPath:void 0,domLayout:`autoHeight`,suppressNoRowsOverlay:!0,rowSelection:{mode:`singleRow`,checkboxes:!1,enableClickSelection:!1},getRowId:e=>e.data.id,getRowClass:e=>e.data?.rowType===`additional`||e.data?.rowType===`reserve`?`ht-summary-fee-row`:``},ce=e=>{R.value=e.api,Q()},Z=e=>!!(e&&!e.isDestroyed?.()),Q=async()=>{await r();let e=R.value;Z(e)&&(e.onRowHeightChanged(),e.refreshCells({force:!0}))},le=e=>{Q()},$=e=>{Q()};return p(X,(e,t)=>{e!==t&&Y()}),p(()=>z.value.length,()=>{Q()}),c(()=>{J()}),s(()=>{J()}),t(()=>{Z(R.value)&&R.value.stopEditing(),R.value=null}),(t,r)=>(n(),o(`div`,ee,[l(`div`,te,[l(`div`,ne,[l(`h3`,A,i(d(I)(`htSummary.title`)),1)]),l(`div`,j,[e(d(g),{style:{width:`100%`},rowData:z.value,pinnedBottomRowData:[re.value],columnDefs:oe.value,gridOptions:se,theme:d(O),animateRows:!0,localeText:d(E),onGridReady:ce,onFirstDataRendered:le,onRowDataUpdated:$},null,8,[`rowData`,`pinnedBottomRowData`,`columnDefs`,`theme`,`localeText`])])]),l(`form`,M,[l(`div`,N,i(d(I)(`htSummary.remark`)),1),l(`textarea`,{value:B.value,rows:`3`,placeholder:d(I)(`htSummary.placeholder`),readonly:``,class:`w-full rounded-md border bg-muted/40 px-3 py-2 text-sm text-foreground outline-none`},null,8,P)])]))}}),[[`__scopeId`,`data-v-174cd11a`]]);export{F as default};