project-detail.ts 179 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283
  1. import { Component, OnInit, OnDestroy, ChangeDetectorRef } from '@angular/core';
  2. import { CommonModule } from '@angular/common';
  3. import { ActivatedRoute, Router } from '@angular/router';
  4. import { FormsModule, ReactiveFormsModule, FormBuilder, FormGroup, Validators } from '@angular/forms';
  5. import { ProjectService } from '../../../services/project.service';
  6. import { PaymentVoucherRecognitionService } from '../../../services/payment-voucher-recognition.service';
  7. import { ProjectReviewService, ReviewReportExportRequest, ReviewReportShareRequest } from '../../../services/project-review.service';
  8. import {
  9. Project,
  10. RenderProgress,
  11. CustomerFeedback,
  12. DesignerChange,
  13. Settlement,
  14. ProjectStage,
  15. PanoramicSynthesis,
  16. ModelCheckItem
  17. } from '../../../models/project.model';
  18. import { RequirementsConfirmCardComponent } from '../../../shared/components/requirements-confirm-card/requirements-confirm-card';
  19. import { SettlementCardComponent } from '../../../shared/components/settlement-card/settlement-card';
  20. import { CustomerReviewCardComponent, DetailedCustomerReview } from '../../../shared/components/customer-review-card/customer-review-card';
  21. import { CustomerReviewFormComponent } from '../../../shared/components/customer-review-form/customer-review-form';
  22. import { ComplaintCardComponent } from '../../../shared/components/complaint-card/complaint-card';
  23. import { PanoramicSynthesisCardComponent } from '../../../shared/components/panoramic-synthesis-card/panoramic-synthesis-card';
  24. import { QuotationDetailsComponent, QuotationData } from './components/quotation-details/quotation-details.component';
  25. import { DesignerAssignmentComponent, DesignerAssignmentData, Designer as AssignmentDesigner } from './components/designer-assignment/designer-assignment.component';
  26. // 引入客户服务模块的设计师日历组件
  27. import { DesignerCalendarComponent, Designer as CalendarDesigner, ProjectGroup as CalendarProjectGroup } from '../../customer-service/consultation-order/components/designer-calendar/designer-calendar.component';
  28. import { ColorAnalysisResult } from '../../../shared/services/color-analysis.service';
  29. interface ExceptionHistory {
  30. id: string;
  31. type: 'failed' | 'stuck' | 'quality' | 'other';
  32. description: string;
  33. submitTime: Date;
  34. status: '待处理' | '处理中' | '已解决';
  35. response?: string;
  36. }
  37. interface ProjectMember {
  38. id: string;
  39. name: string;
  40. role: string;
  41. avatar: string;
  42. skillMatch: number;
  43. progress: number;
  44. contribution: number;
  45. }
  46. interface ProjectFile {
  47. id: string;
  48. name: string;
  49. type: string;
  50. size: string;
  51. date: string;
  52. url: string;
  53. }
  54. interface TimelineEvent {
  55. id: string;
  56. time: string;
  57. title: string;
  58. action: string;
  59. description: string;
  60. }
  61. // 新增:四大板块键类型(顶层声明,供组件与模板共同使用)
  62. type SectionKey = 'order' | 'requirements' | 'delivery' | 'aftercare';
  63. // 素材解析后的方案数据结构
  64. interface MaterialAnalysis {
  65. category: string;
  66. specifications: {
  67. type: string;
  68. grade: string;
  69. thickness?: string;
  70. finish?: string;
  71. durability: string;
  72. };
  73. usage: {
  74. area: string;
  75. percentage: number;
  76. priority: 'primary' | 'secondary' | 'accent';
  77. };
  78. properties: {
  79. texture: string;
  80. color: string;
  81. maintenance: string;
  82. };
  83. }
  84. interface DesignStyleAnalysis {
  85. primaryStyle: string;
  86. styleElements: {
  87. element: string;
  88. description: string;
  89. influence: number; // 影响程度 0-100
  90. }[];
  91. characteristics: {
  92. feature: string;
  93. value: string;
  94. importance: 'high' | 'medium' | 'low';
  95. }[];
  96. compatibility: {
  97. withMaterials: string[];
  98. withColors: string[];
  99. score: number; // 兼容性评分 0-100
  100. };
  101. }
  102. interface ColorSchemeAnalysis {
  103. palette: {
  104. color: string;
  105. hex: string;
  106. rgb: string;
  107. percentage: number;
  108. role: 'dominant' | 'secondary' | 'accent' | 'neutral';
  109. }[];
  110. harmony: {
  111. type: string; // 如:互补色、类似色、三角色等
  112. temperature: 'warm' | 'cool' | 'neutral';
  113. contrast: number; // 对比度 0-100
  114. };
  115. psychology: {
  116. mood: string;
  117. atmosphere: string;
  118. suitability: string[];
  119. };
  120. }
  121. interface SpaceAnalysis {
  122. dimensions: {
  123. length: number;
  124. width: number;
  125. height: number;
  126. area: number;
  127. volume: number;
  128. };
  129. functionalZones: {
  130. zone: string;
  131. area: number;
  132. percentage: number;
  133. requirements: string[];
  134. furniture: string[];
  135. }[];
  136. circulation: {
  137. mainPaths: string[];
  138. pathWidth: number;
  139. efficiency: number; // 动线效率 0-100
  140. };
  141. lighting: {
  142. natural: {
  143. direction: string[];
  144. intensity: string;
  145. duration: string;
  146. };
  147. artificial: {
  148. zones: string[];
  149. requirements: string[];
  150. };
  151. };
  152. }
  153. // 新增:项目复盘数据结构
  154. interface ProjectReview {
  155. id: string;
  156. projectId: string;
  157. generatedAt: Date;
  158. overallScore: number; // 项目总评分 0-100
  159. sopAnalysis: {
  160. stageName: string;
  161. plannedDuration: number; // 计划天数
  162. actualDuration: number; // 实际天数
  163. score: number; // 阶段评分 0-100
  164. executionStatus: 'excellent' | 'good' | 'average' | 'poor';
  165. issues?: string[]; // 问题列表
  166. }[];
  167. keyHighlights: string[]; // 项目亮点
  168. improvementSuggestions: string[]; // 改进建议
  169. customerSatisfaction: {
  170. overallRating: number; // 1-5星
  171. feedback?: string; // 客户反馈
  172. responseTime: number; // 响应时间(小时)
  173. completionTime: number; // 完成时间(天)
  174. };
  175. teamPerformance: {
  176. designerScore: number;
  177. communicationScore: number;
  178. timelinessScore: number;
  179. qualityScore: number;
  180. };
  181. budgetAnalysis: {
  182. plannedBudget: number;
  183. actualBudget: number;
  184. variance: number; // 预算偏差百分比
  185. costBreakdown: {
  186. category: string;
  187. planned: number;
  188. actual: number;
  189. }[];
  190. };
  191. lessonsLearned: string[]; // 经验教训
  192. recommendations: string[]; // 后续项目建议
  193. }
  194. interface ProposalAnalysis {
  195. id: string;
  196. name: string;
  197. version: string;
  198. createdAt: Date;
  199. status: 'analyzing' | 'completed' | 'approved' | 'rejected';
  200. materials: MaterialAnalysis[];
  201. designStyle: DesignStyleAnalysis;
  202. colorScheme: ColorSchemeAnalysis;
  203. spaceLayout: SpaceAnalysis;
  204. budget: {
  205. total: number;
  206. breakdown: {
  207. category: string;
  208. amount: number;
  209. percentage: number;
  210. }[];
  211. };
  212. timeline: {
  213. phase: string;
  214. duration: number;
  215. dependencies: string[];
  216. }[];
  217. feasibility: {
  218. technical: number; // 技术可行性 0-100
  219. budget: number; // 预算可行性 0-100
  220. timeline: number; // 时间可行性 0-100
  221. overall: number; // 综合可行性 0-100
  222. };
  223. }
  224. // 交付执行板块数据结构
  225. interface DeliverySpace {
  226. id: string;
  227. name: string; // 空间名称:卧室、餐厅、厨房等
  228. isExpanded: boolean; // 是否展开
  229. order: number; // 排序
  230. }
  231. interface DeliveryProcess {
  232. id: string;
  233. name: string; // 流程名称:建模、软装、渲染、后期
  234. type: 'modeling' | 'softDecor' | 'rendering' | 'postProcess';
  235. spaces: DeliverySpace[]; // 该流程下的空间列表
  236. isExpanded: boolean; // 是否展开
  237. content: {
  238. [spaceId: string]: {
  239. // 每个空间的具体内容
  240. images: Array<{ id: string; name: string; url: string; size?: string; reviewStatus?: 'pending' | 'approved' | 'rejected' }>;
  241. progress: number; // 进度百分比
  242. status: 'pending' | 'in_progress' | 'completed' | 'approved';
  243. notes: string; // 备注
  244. lastUpdated: Date;
  245. };
  246. };
  247. }
  248. @Component({
  249. selector: 'app-project-detail',
  250. standalone: true,
  251. imports: [CommonModule, FormsModule, ReactiveFormsModule, RequirementsConfirmCardComponent, SettlementCardComponent, CustomerReviewCardComponent, CustomerReviewFormComponent, ComplaintCardComponent, PanoramicSynthesisCardComponent, QuotationDetailsComponent, DesignerAssignmentComponent, DesignerCalendarComponent],
  252. templateUrl: './project-detail.html',
  253. styleUrls: ['./project-detail.scss', './debug-styles.scss', './horizontal-panel.scss']
  254. })
  255. export class ProjectDetail implements OnInit, OnDestroy {
  256. // 项目基本数据
  257. projectId: string = '';
  258. project: Project | undefined;
  259. renderProgress: RenderProgress | undefined;
  260. feedbacks: CustomerFeedback[] = [];
  261. detailedReviews: DetailedCustomerReview[] = [];
  262. designerChanges: DesignerChange[] = [];
  263. settlements: Settlement[] = [];
  264. requirementChecklist: string[] = [];
  265. reminderMessage: string = '';
  266. isLoadingRenderProgress: boolean = false;
  267. errorLoadingRenderProgress: boolean = false;
  268. feedbackTimeoutCountdown: number = 0;
  269. private countdownInterval: any;
  270. projects: {id: string, name: string, status: string}[] = [];
  271. showDropdown: boolean = false;
  272. currentStage: string = '';
  273. // 新增:尾款结算完成状态
  274. isSettlementCompleted: boolean = false;
  275. isConfirmingSettlement: boolean = false;
  276. isSettlementInitiated: boolean = false;
  277. // 新增:自动化功能状态跟踪
  278. miniprogramPaymentStatus: 'active' | 'inactive' = 'inactive';
  279. voucherRecognitionCount: number = 0;
  280. notificationsSent: number = 0;
  281. isAutoSettling: boolean = false;
  282. isPaymentVerified: boolean = false;
  283. // 客户信息卡片展开/收起状态
  284. isCustomerInfoExpanded: boolean = false;
  285. // 新增:订单分配表单相关
  286. orderCreationForm!: FormGroup;
  287. optionalForm!: FormGroup;
  288. isOptionalFormExpanded: boolean = false;
  289. orderCreationData: any = null;
  290. // 新增:方案分析相关数据
  291. proposalAnalysis: ProposalAnalysis | null = null;
  292. isAnalyzing: boolean = false;
  293. analysisProgress: number = 0;
  294. // 新增:右侧色彩分析结果展示
  295. colorAnalysisResult: ColorAnalysisResult | null = null;
  296. dominantColorHex: string | null = null;
  297. // 新增:区分展示的参考图片与CAD文件(来源于需求确认子组件)
  298. referenceImages: any[] = [];
  299. cadFiles: any[] = [];
  300. // 新增:详细分析数据属性
  301. enhancedColorAnalysis: any = null;
  302. formAnalysis: any = null;
  303. textureAnalysis: any = null;
  304. patternAnalysis: any = null;
  305. lightingAnalysis: any = null;
  306. materialAnalysisData: any[] = [];
  307. // 新增:9阶段顺序(串式流程)- 包含后期阶段
  308. stageOrder: ProjectStage[] = ['订单分配', '需求沟通', '方案确认', '建模', '软装', '渲染', '后期', '尾款结算', '客户评价', '投诉处理'];
  309. // 新增:阶段展开状态(默认全部收起,当前阶段在数据加载后自动展开)
  310. expandedStages: Partial<Record<ProjectStage, boolean>> = {
  311. '订单分配': false,
  312. '需求沟通': false,
  313. '方案确认': false,
  314. '建模': false,
  315. '软装': false,
  316. '渲染': false,
  317. '后期': false,
  318. '尾款结算': false,
  319. '客户评价': false,
  320. '投诉处理': false,
  321. };
  322. // 新增:四大板块定义与展开状态 - 交付执行板块调整为三个阶段
  323. sections: Array<{ key: SectionKey; label: string; stages: ProjectStage[] }> = [
  324. { key: 'order', label: '订单分配', stages: ['订单分配'] },
  325. { key: 'requirements', label: '确认需求', stages: ['需求沟通', '方案确认'] },
  326. { key: 'delivery', label: '交付执行', stages: ['建模', '软装', '渲染', '后期'] },
  327. { key: 'aftercare', label: '售后', stages: [] }
  328. ];
  329. expandedSection: SectionKey | null = null;
  330. // 渲染异常反馈相关属性
  331. exceptionType: 'failed' | 'stuck' | 'quality' | 'other' = 'failed';
  332. exceptionDescription: string = '';
  333. exceptionScreenshotUrl: string | null = null;
  334. exceptionHistories: ExceptionHistory[] = [];
  335. isSubmittingFeedback: boolean = false;
  336. selectedScreenshot: File | null = null;
  337. screenshotPreview: string | null = null;
  338. showExceptionForm: boolean = false;
  339. // 标签页相关
  340. activeTab: 'progress' | 'members' | 'files' = 'progress';
  341. tabs: Array<{ id: 'progress' | 'members' | 'files'; name: string }> = [
  342. { id: 'progress', name: '项目进度' },
  343. { id: 'members', name: '项目成员' },
  344. { id: 'files', name: '项目文件' }
  345. ];
  346. // 标准化阶段(视图层映射)
  347. standardPhases: Array<'待分配' | '需求方案' | '项目执行' | '收尾验收' | '归档'> = ['待分配', '需求方案', '项目执行', '收尾验收', '归档'];
  348. // 文件上传(通用)
  349. acceptedFileTypes: string = '.doc,.docx,.pdf,.jpg,.jpeg,.png,.zip,.rar,.max,.obj';
  350. isUploadingFile: boolean = false;
  351. projectMembers: ProjectMember[] = [];
  352. // 项目文件数据
  353. projectFiles: ProjectFile[] = [];
  354. // 团队协作时间轴
  355. timelineEvents: TimelineEvent[] = [];
  356. // 团队分配弹窗相关
  357. selectedDesigner: any = null;
  358. projectData: any = null;
  359. // ============ 阶段图片上传状态(新增) ============
  360. allowedImageTypes: string = '.jpg,.jpeg,.png';
  361. // 增加审核状态reviewStatus与是否已同步synced标记(仅由组长操作)
  362. whiteModelImages: Array<{ id: string; name: string; url: string; size?: string; reviewStatus?: 'pending' | 'approved' | 'rejected'; synced?: boolean }> = [];
  363. softDecorImages: Array<{ id: string; name: string; url: string; size?: string; reviewStatus?: 'pending' | 'approved' | 'rejected'; synced?: boolean }> = [];
  364. renderLargeImages: Array<{ id: string; name: string; url: string; size?: string; locked?: boolean; reviewStatus?: 'pending' | 'approved' | 'rejected'; synced?: boolean }> = [];
  365. postProcessImages: Array<{ id: string; name: string; url: string; size?: string; reviewStatus?: 'pending' | 'approved' | 'rejected'; synced?: boolean }> = [];
  366. showRenderUploadModal: boolean = false;
  367. pendingRenderLargeItems: Array<{ id: string; name: string; url: string; file: File }> = [];
  368. // 视图上下文:根据路由前缀识别角色视角(客服/设计师/组长)
  369. roleContext: 'customer-service' | 'designer' | 'team-leader' | 'technical' = 'designer';
  370. // ============ 模型检查项数据 ============
  371. modelCheckItems: ModelCheckItem[] = [
  372. { id: 'check-1', name: '户型匹配度检查', isPassed: false, notes: '' },
  373. { id: 'check-2', name: '尺寸精度验证', isPassed: false, notes: '' },
  374. { id: 'check-3', name: '材质贴图检查', isPassed: false, notes: '' },
  375. { id: 'check-4', name: '光影效果验证', isPassed: false, notes: '' },
  376. { id: 'check-5', name: '细节完整性检查', isPassed: false, notes: '' }
  377. ];
  378. // ============ 交付执行板块数据 ============
  379. deliveryProcesses: DeliveryProcess[] = [
  380. {
  381. id: 'modeling',
  382. name: '建模',
  383. type: 'modeling',
  384. isExpanded: true, // 默认展开第一个
  385. spaces: [
  386. { id: 'bedroom', name: '卧室', isExpanded: false, order: 1 },
  387. { id: 'living', name: '客厅', isExpanded: false, order: 2 },
  388. { id: 'kitchen', name: '厨房', isExpanded: false, order: 3 }
  389. ],
  390. content: {
  391. 'bedroom': { images: [], progress: 0, status: 'pending', notes: '', lastUpdated: new Date() },
  392. 'living': { images: [], progress: 0, status: 'pending', notes: '', lastUpdated: new Date() },
  393. 'kitchen': { images: [], progress: 0, status: 'pending', notes: '', lastUpdated: new Date() }
  394. }
  395. },
  396. {
  397. id: 'softDecor',
  398. name: '软装',
  399. type: 'softDecor',
  400. isExpanded: false,
  401. spaces: [
  402. { id: 'bedroom', name: '卧室', isExpanded: false, order: 1 },
  403. { id: 'living', name: '客厅', isExpanded: false, order: 2 },
  404. { id: 'kitchen', name: '厨房', isExpanded: false, order: 3 }
  405. ],
  406. content: {
  407. 'bedroom': { images: [], progress: 0, status: 'pending', notes: '', lastUpdated: new Date() },
  408. 'living': { images: [], progress: 0, status: 'pending', notes: '', lastUpdated: new Date() },
  409. 'kitchen': { images: [], progress: 0, status: 'pending', notes: '', lastUpdated: new Date() }
  410. }
  411. },
  412. {
  413. id: 'rendering',
  414. name: '渲染',
  415. type: 'rendering',
  416. isExpanded: false,
  417. spaces: [
  418. { id: 'bedroom', name: '卧室', isExpanded: false, order: 1 },
  419. { id: 'living', name: '客厅', isExpanded: false, order: 2 },
  420. { id: 'kitchen', name: '厨房', isExpanded: false, order: 3 }
  421. ],
  422. content: {
  423. 'bedroom': { images: [], progress: 0, status: 'pending', notes: '', lastUpdated: new Date() },
  424. 'living': { images: [], progress: 0, status: 'pending', notes: '', lastUpdated: new Date() },
  425. 'kitchen': { images: [], progress: 0, status: 'pending', notes: '', lastUpdated: new Date() }
  426. }
  427. },
  428. {
  429. id: 'postProcess',
  430. name: '后期',
  431. type: 'postProcess',
  432. isExpanded: false,
  433. spaces: [
  434. { id: 'bedroom', name: '卧室', isExpanded: false, order: 1 },
  435. { id: 'living', name: '客厅', isExpanded: false, order: 2 },
  436. { id: 'kitchen', name: '厨房', isExpanded: false, order: 3 }
  437. ],
  438. content: {
  439. 'bedroom': { images: [], progress: 0, status: 'pending', notes: '', lastUpdated: new Date() },
  440. 'living': { images: [], progress: 0, status: 'pending', notes: '', lastUpdated: new Date() },
  441. 'kitchen': { images: [], progress: 0, status: 'pending', notes: '', lastUpdated: new Date() }
  442. }
  443. }
  444. ];
  445. // 新增空间输入框状态
  446. newSpaceName: { [processId: string]: string } = {};
  447. showAddSpaceInput: { [processId: string]: boolean } = {};
  448. constructor(
  449. private route: ActivatedRoute,
  450. private projectService: ProjectService,
  451. private router: Router,
  452. private fb: FormBuilder,
  453. private cdr: ChangeDetectorRef,
  454. private paymentVoucherService: PaymentVoucherRecognitionService,
  455. private projectReviewService: ProjectReviewService
  456. ) {}
  457. // 切换标签页
  458. switchTab(tabId: 'progress' | 'members' | 'files') {
  459. this.activeTab = tabId;
  460. }
  461. // 类型安全的标签页检查方法
  462. isActiveTab(tabId: 'progress' | 'members' | 'files'): boolean {
  463. return this.activeTab === tabId;
  464. }
  465. // 根据事件类型获取作者名称
  466. getEventAuthor(action: string): string {
  467. // 根据不同的action类型返回对应的作者名称
  468. switch(action) {
  469. case '完成':
  470. case '更新':
  471. case '优化':
  472. return '李设计师';
  473. case '收到':
  474. return '李客服';
  475. case '提交':
  476. return '赵建模师';
  477. default:
  478. return '王组长';
  479. }
  480. }
  481. // 切换项目
  482. switchProject(projectId: string): void {
  483. this.projectId = projectId;
  484. this.loadProjectData();
  485. this.loadProjectMembers();
  486. this.loadProjectFiles();
  487. this.loadTimelineEvents();
  488. // 更新URL但不触发组件重载
  489. this.router.navigate([], { relativeTo: this.route, queryParamsHandling: 'merge', queryParams: { id: projectId } });
  490. }
  491. // 检查是否处于订单分配阶段,用于红色高亮显示
  492. isCurrentOrderCreation(): boolean {
  493. // 只有当订单分配阶段是当前活跃阶段时才标红显示
  494. // 修复逻辑:完成前序环节后才标红当前阶段
  495. const currentStage = this.project?.currentStage;
  496. if (!currentStage) return false;
  497. // 如果当前阶段就是订单分配阶段,说明需要标红显示
  498. if (currentStage === '订单分配') return true;
  499. // 如果当前阶段在订单分配之后,说明订单分配已完成,不应标红
  500. const stageOrder = [
  501. '订单分配', '需求沟通', '方案确认', '建模', '软装',
  502. '渲染', '尾款结算', '客户评价', '投诉处理'
  503. ];
  504. const currentIndex = stageOrder.indexOf(currentStage);
  505. const orderCreationIndex = stageOrder.indexOf('订单分配');
  506. // 如果当前阶段在订单分配之后,说明订单分配已完成
  507. return currentIndex <= orderCreationIndex;
  508. }
  509. // 返回工作台
  510. backToWorkbench(): void {
  511. this.router.navigate(['/designer/dashboard']);
  512. }
  513. // 检查阶段是否已完成
  514. isStageCompleted(stage: ProjectStage): boolean {
  515. if (!this.project) return false;
  516. // 定义阶段顺序
  517. const stageOrder = [
  518. '订单分配', '需求沟通', '方案确认', '建模', '软装',
  519. '渲染', '尾款结算', '客户评价', '投诉处理'
  520. ];
  521. // 获取当前阶段和检查阶段的索引
  522. const currentStageIndex = stageOrder.indexOf(this.project.currentStage);
  523. const checkStageIndex = stageOrder.indexOf(stage);
  524. // 如果检查阶段在当前阶段之前,则已完成
  525. return checkStageIndex < currentStageIndex;
  526. }
  527. // 获取阶段状态:completed/active/pending
  528. getStageStatus(stage: ProjectStage): 'completed' | 'active' | 'pending' {
  529. const order = this.stageOrder;
  530. // 优先使用 currentStage 属性,如果没有则使用 project.currentStage
  531. const current = (this.currentStage as ProjectStage) || (this.project?.currentStage as ProjectStage | undefined);
  532. const currentIdx = current ? order.indexOf(current) : -1;
  533. const idx = order.indexOf(stage);
  534. if (idx === -1) return 'pending';
  535. if (currentIdx === -1) return 'pending';
  536. if (idx < currentIdx) return 'completed';
  537. if (idx === currentIdx) return 'active';
  538. return 'pending';
  539. }
  540. // 切换阶段展开/收起,并保持单展开
  541. toggleStage(stage: ProjectStage): void {
  542. // 已移除所有展开按钮,本方法保留以兼容模板其它引用,如无需可进一步删除调用点和方法
  543. const exclusivelyOpen = true;
  544. if (exclusivelyOpen) {
  545. Object.keys(this.expandedStages).forEach((key) => (this.expandedStages[key as ProjectStage] = false));
  546. this.expandedStages[stage] = true;
  547. } else {
  548. this.expandedStages[stage] = !this.expandedStages[stage];
  549. }
  550. }
  551. // 查看阶段详情(已不再通过按钮触发,保留以兼容日志或未来调用)
  552. viewStageDetails(stage: ProjectStage): void {
  553. // 以往这里有 alert/导航行为,现清空用户交互,避免误触
  554. return;
  555. }
  556. ngOnInit(): void {
  557. // 初始化表单
  558. this.initializeForms();
  559. // 初始化需求关键信息数据
  560. this.ensureRequirementData();
  561. // 重置方案分析状态,确保需求信息展示区域能够显示
  562. this.resetProposalAnalysis();
  563. // 初始化售后模块示例数据
  564. this.initializeAftercareData();
  565. this.route.paramMap.subscribe(params => {
  566. this.projectId = params.get('id') || '';
  567. // 根据当前URL检测视图上下文
  568. this.roleContext = this.detectRoleContextFromUrl();
  569. this.loadProjectData();
  570. this.loadExceptionHistories();
  571. this.loadProjectMembers();
  572. this.loadProjectFiles();
  573. this.loadTimelineEvents();
  574. // 启动客户信息自动同步
  575. this.startAutoSync();
  576. });
  577. // 新增:监听查询参数,支持通过 activeTab 设置初始标签页和 currentStage 设置当前阶段
  578. this.route.queryParamMap.subscribe(qp => {
  579. const raw = qp.get('activeTab');
  580. const alias: Record<string, 'progress' | 'members' | 'files'> = {
  581. requirements: 'progress',
  582. overview: 'progress'
  583. };
  584. const tab = raw && (raw in alias ? alias[raw] : raw);
  585. if (tab === 'progress' || tab === 'members' || tab === 'files') {
  586. this.activeTab = tab;
  587. }
  588. // 处理 currentStage 查询参数
  589. const currentStageParam = qp.get('currentStage');
  590. if (currentStageParam) {
  591. this.currentStage = currentStageParam;
  592. // 根据当前阶段设置项目状态和展开相应区域
  593. this.initializeStageFromRoute(currentStageParam as ProjectStage);
  594. // 根据当前阶段自动展开对应的区域
  595. const sectionKey = this.getSectionKeyForStage(currentStageParam as ProjectStage);
  596. if (sectionKey) {
  597. this.expandedSection = sectionKey;
  598. }
  599. // 延迟滚动到对应阶段
  600. setTimeout(() => {
  601. this.scrollToStage(currentStageParam as ProjectStage);
  602. }, 500);
  603. }
  604. // 处理从客服项目列表传递的同步数据
  605. const syncDataParam = qp.get('syncData');
  606. if (syncDataParam) {
  607. try {
  608. const syncData = JSON.parse(syncDataParam);
  609. console.log('接收到客服同步数据:', syncData);
  610. // 设置同步状态
  611. this.isSyncingCustomerInfo = true;
  612. // 存储订单分配数据用于显示
  613. this.orderCreationData = syncData;
  614. // 更新projectData以传递给子组件
  615. this.projectData = {
  616. customerInfo: syncData.customerInfo,
  617. requirementInfo: syncData.requirementInfo,
  618. preferenceTags: syncData.preferenceTags
  619. };
  620. // 同步客户信息到表单
  621. if (syncData.customerInfo) {
  622. this.customerForm.patchValue({
  623. name: syncData.customerInfo.name || '',
  624. phone: syncData.customerInfo.phone || '',
  625. wechat: syncData.customerInfo.wechat || '',
  626. customerType: syncData.customerInfo.customerType || '新客户',
  627. source: syncData.customerInfo.source || '小程序',
  628. remark: syncData.customerInfo.remark || '',
  629. demandType: syncData.customerInfo.demandType || '',
  630. followUpStatus: syncData.customerInfo.followUpStatus || '待分配'
  631. });
  632. // 设置选中的客户
  633. this.selectedOrderCustomer = {
  634. id: syncData.customerInfo.id || 'temp-' + Date.now(),
  635. name: syncData.customerInfo.name,
  636. phone: syncData.customerInfo.phone,
  637. wechat: syncData.customerInfo.wechat,
  638. customerType: syncData.customerInfo.customerType,
  639. source: syncData.customerInfo.source,
  640. remark: syncData.customerInfo.remark
  641. };
  642. }
  643. // 同步需求信息
  644. if (syncData.requirementInfo) {
  645. this.syncRequirementKeyInfo(syncData.requirementInfo);
  646. }
  647. // 同步偏好标签到项目数据
  648. if (syncData.preferenceTags && this.project) {
  649. this.project.customerTags = syncData.preferenceTags.map((tag: string) => ({
  650. source: '客服填写',
  651. needType: tag,
  652. preference: tag,
  653. colorAtmosphere: tag
  654. }));
  655. }
  656. // 模拟同步完成
  657. setTimeout(() => {
  658. this.isSyncingCustomerInfo = false;
  659. this.lastSyncTime = new Date();
  660. this.cdr.detectChanges();
  661. console.log('客户信息同步完成');
  662. }, 1500);
  663. // 触发界面更新
  664. this.cdr.detectChanges();
  665. console.log('客服数据同步完成,orderCreationData:', this.orderCreationData);
  666. } catch (error) {
  667. console.error('解析同步数据失败:', error);
  668. this.isSyncingCustomerInfo = false;
  669. }
  670. }
  671. });
  672. // 添加点击事件监听器,当点击页面其他位置时关闭下拉菜单
  673. document.addEventListener('click', this.closeDropdownOnClickOutside);
  674. // 初始化客户表单(与客服端保持一致)
  675. this.customerForm = this.fb.group({
  676. name: ['', Validators.required],
  677. phone: ['', [Validators.required, Validators.pattern(/^1[3-9]\d{9}$/)]],
  678. wechat: [''],
  679. customerType: ['新客户'],
  680. source: [''],
  681. remark: [''],
  682. demandType: [''],
  683. followUpStatus: ['']
  684. });
  685. // 自动生成下单时间
  686. this.orderTime = new Date().toLocaleString('zh-CN', {
  687. year: 'numeric', month: '2-digit', day: '2-digit',
  688. hour: '2-digit', minute: '2-digit', second: '2-digit'
  689. });
  690. }
  691. // 新增:根据路由参数初始化阶段状态
  692. private initializeStageFromRoute(targetStage: ProjectStage): void {
  693. // 设置当前阶段
  694. this.currentStage = targetStage;
  695. // 根据目标阶段设置之前的阶段为已完成
  696. const targetIndex = this.stageOrder.indexOf(targetStage);
  697. if (targetIndex > 0) {
  698. // 将目标阶段之前的所有阶段设置为已完成
  699. for (let i = 0; i < targetIndex; i++) {
  700. const stage = this.stageOrder[i];
  701. this.expandedStages[stage] = false; // 已完成的阶段收起
  702. }
  703. }
  704. // 展开当前阶段
  705. this.expandedStages[targetStage] = true;
  706. // 如果项目对象存在,更新项目的当前阶段
  707. if (this.project) {
  708. this.project.currentStage = targetStage;
  709. }
  710. // 触发变更检测以更新UI
  711. this.cdr.detectChanges();
  712. }
  713. ngOnDestroy(): void {
  714. if (this.countdownInterval) {
  715. clearInterval(this.countdownInterval);
  716. }
  717. // 停止自动同步
  718. this.stopAutoSync();
  719. document.removeEventListener('click', this.closeDropdownOnClickOutside);
  720. // 释放所有 blob 预览 URL
  721. const revokeList: string[] = [];
  722. this.whiteModelImages.forEach(i => { if (i.url.startsWith('blob:')) revokeList.push(i.url); });
  723. this.softDecorImages.forEach(i => { if (i.url.startsWith('blob:')) revokeList.push(i.url); });
  724. this.renderLargeImages.forEach(i => { if (i.url.startsWith('blob:')) revokeList.push(i.url); });
  725. this.pendingRenderLargeItems.forEach(i => { if (i.url.startsWith('blob:')) revokeList.push(i.url); });
  726. revokeList.forEach(u => URL.revokeObjectURL(u));
  727. }
  728. // ============ 角色视图与只读控制(新增) ============
  729. private detectRoleContextFromUrl(): 'customer-service' | 'designer' | 'team-leader' | 'technical' {
  730. const url = this.router.url || '';
  731. // 首先检查查询参数中的role
  732. const queryParams = this.route.snapshot.queryParamMap;
  733. const roleParam = queryParams.get('role');
  734. if (roleParam === 'customer-service') {
  735. return 'customer-service';
  736. }
  737. if (roleParam === 'technical') {
  738. return 'technical';
  739. }
  740. // 如果没有role查询参数,则根据URL路径判断
  741. if (url.includes('/customer-service/')) return 'customer-service';
  742. if (url.includes('/team-leader/')) return 'team-leader';
  743. if (url.includes('/technical/')) return 'technical';
  744. return 'designer';
  745. }
  746. isDesignerView(): boolean { return this.roleContext === 'designer'; }
  747. isTeamLeaderView(): boolean { return this.roleContext === 'team-leader'; }
  748. isCustomerServiceView(): boolean { return this.roleContext === 'customer-service'; }
  749. isTechnicalView(): boolean { return this.roleContext === 'technical'; }
  750. // 只读规则:客服视角为只读
  751. isReadOnly(): boolean { return this.isCustomerServiceView(); }
  752. // 权限控制:客服只能编辑订单分配、确认需求、售后板块
  753. canEditSection(sectionKey: SectionKey): boolean {
  754. if (this.isCustomerServiceView()) {
  755. return sectionKey === 'order' || sectionKey === 'requirements' || sectionKey === 'aftercare';
  756. }
  757. return true; // 设计师和组长可以编辑所有板块
  758. }
  759. // 权限控制:客服只能编辑特定阶段
  760. canEditStage(stage: ProjectStage): boolean {
  761. if (this.isCustomerServiceView()) {
  762. const editableStages: ProjectStage[] = [
  763. '订单分配', '需求沟通', '方案确认', // 订单分配和确认需求板块
  764. '尾款结算', '客户评价', '投诉处理' // 售后板块
  765. ];
  766. return editableStages.includes(stage);
  767. }
  768. return true; // 设计师和组长可以编辑所有阶段
  769. }
  770. // 计算当前激活板块:优先用户点击的 expandedSection;否则取当前阶段所属板块;再否则回退首个板块
  771. private getActiveSectionKey(): SectionKey {
  772. if (this.expandedSection) return this.expandedSection;
  773. const current = this.project?.currentStage as ProjectStage | undefined;
  774. return current ? this.getSectionKeyForStage(current) : this.sections[0].key;
  775. }
  776. // 返回当前板块的全部阶段(所有角色一致):
  777. // 设计师也可查看 订单分配/确认需求/售后 板块内容
  778. getVisibleStages(): ProjectStage[] {
  779. const activeKey = this.getActiveSectionKey();
  780. const sec = this.sections.find(s => s.key === activeKey);
  781. return sec ? sec.stages : [];
  782. }
  783. // ============ 组长:同步上传与审核(新增,模拟实现) ============
  784. syncUploadedImages(phase: 'white' | 'soft' | 'render' | 'postProcess'): void {
  785. if (!this.isTeamLeaderView()) return;
  786. const markSynced = (arr: Array<{ reviewStatus?: 'pending'|'approved'|'rejected'; synced?: boolean }>) => {
  787. arr.forEach(img => {
  788. if (!img.synced) img.synced = true;
  789. if (!img.reviewStatus) img.reviewStatus = 'pending';
  790. });
  791. };
  792. if (phase === 'white') markSynced(this.whiteModelImages);
  793. if (phase === 'soft') markSynced(this.softDecorImages);
  794. if (phase === 'render') markSynced(this.renderLargeImages);
  795. if (phase === 'postProcess') markSynced(this.postProcessImages);
  796. alert('已同步该阶段的图片信息(模拟)');
  797. }
  798. reviewImage(imageId: string, phase: 'white' | 'soft' | 'render' | 'postProcess', status: 'approved' | 'rejected'): void {
  799. if (!this.isTeamLeaderView()) return;
  800. const setStatus = (arr: Array<{ id: string; reviewStatus?: 'pending'|'approved'|'rejected'; synced?: boolean }>) => {
  801. const target = arr.find(i => i.id === imageId);
  802. if (target) {
  803. target.reviewStatus = status;
  804. if (!target.synced) target.synced = true; // 审核时自动视为已同步
  805. }
  806. };
  807. if (phase === 'white') setStatus(this.whiteModelImages);
  808. if (phase === 'soft') setStatus(this.softDecorImages);
  809. if (phase === 'render') setStatus(this.renderLargeImages);
  810. if (phase === 'postProcess') setStatus(this.postProcessImages);
  811. }
  812. getImageReviewStatusText(img: { reviewStatus?: 'pending'|'approved'|'rejected'; synced?: boolean }): string {
  813. const synced = img.synced ? '已同步' : '未同步';
  814. const map: Record<string, string> = {
  815. 'pending': '待审',
  816. 'approved': '已通过',
  817. 'rejected': '已驳回'
  818. };
  819. const st = img.reviewStatus ? map[img.reviewStatus] : '未标记';
  820. return `${st} · ${synced}`;
  821. }
  822. // 点击页面其他位置时关闭下拉菜单
  823. private closeDropdownOnClickOutside = (event: MouseEvent): void => {
  824. const targetElement = event.target as HTMLElement;
  825. const projectSwitcher = targetElement.closest('.project-switcher');
  826. if (!projectSwitcher && this.showDropdown) {
  827. this.showDropdown = false;
  828. }
  829. };
  830. loadProjectData(): void {
  831. if (this.projectId) {
  832. this.loadProjectDetails();
  833. this.loadRenderProgress();
  834. this.loadCustomerFeedbacks();
  835. this.loadDesignerChanges();
  836. this.loadSettlements();
  837. this.loadRequirementChecklist();
  838. }
  839. // 初始化项目列表数据(模拟)
  840. this.projects = [
  841. { id: '1', name: '现代风格客厅设计', status: '进行中' },
  842. { id: '2', name: '北欧风卧室装修', status: '已完成' },
  843. { id: '3', name: '新中式书房改造', status: '进行中' },
  844. { id: '4', name: '工业风餐厅设计', status: '待处理' }
  845. ];
  846. }
  847. // 加载项目成员数据
  848. loadProjectMembers(): void {
  849. // 模拟API请求获取项目成员数据
  850. setTimeout(() => {
  851. this.projectMembers = [
  852. {
  853. id: '1',
  854. name: '李设计师',
  855. role: '主设计师',
  856. avatar: '李',
  857. skillMatch: 95,
  858. progress: 65,
  859. contribution: 75
  860. },
  861. {
  862. id: '2',
  863. name: '陈设计师',
  864. role: '助理设计师',
  865. avatar: '陈',
  866. skillMatch: 88,
  867. progress: 80,
  868. contribution: 60
  869. },
  870. {
  871. id: '3',
  872. name: '王组长',
  873. role: '项目组长',
  874. avatar: '王',
  875. skillMatch: 92,
  876. progress: 70,
  877. contribution: 70
  878. },
  879. {
  880. id: '4',
  881. name: '赵建模师',
  882. role: '3D建模师',
  883. avatar: '赵',
  884. skillMatch: 90,
  885. progress: 90,
  886. contribution: 85
  887. }
  888. ];
  889. }, 600);
  890. }
  891. // 加载项目文件数据
  892. loadProjectFiles(): void {
  893. // 模拟API请求获取项目文件数据
  894. setTimeout(() => {
  895. this.projectFiles = [
  896. {
  897. id: '1',
  898. name: '客厅设计方案V2.0.pdf',
  899. type: 'pdf',
  900. size: '2.5MB',
  901. date: '2024-02-10',
  902. url: '#'
  903. },
  904. {
  905. id: '2',
  906. name: '材质库集合.rar',
  907. type: 'rar',
  908. size: '45.8MB',
  909. date: '2024-02-08',
  910. url: '#'
  911. },
  912. {
  913. id: '3',
  914. name: '客厅渲染预览1.jpg',
  915. type: 'jpg',
  916. size: '3.2MB',
  917. date: '2024-02-14',
  918. url: '#'
  919. },
  920. {
  921. id: '4',
  922. name: '3D模型文件.max',
  923. type: 'max',
  924. size: '87.5MB',
  925. date: '2024-02-12',
  926. url: '#'
  927. },
  928. {
  929. id: '5',
  930. name: '客户需求文档.docx',
  931. type: 'docx',
  932. size: '1.2MB',
  933. date: '2024-01-15',
  934. url: '#'
  935. },
  936. {
  937. id: '6',
  938. name: '客厅渲染预览2.jpg',
  939. type: 'jpg',
  940. size: '3.8MB',
  941. date: '2024-02-15',
  942. url: '#'
  943. }
  944. ];
  945. }, 700);
  946. }
  947. // 加载团队协作时间轴数据
  948. loadTimelineEvents(): void {
  949. // 模拟API请求获取时间轴数据
  950. setTimeout(() => {
  951. this.timelineEvents = [
  952. {
  953. id: '1',
  954. time: '2024-02-15 14:30',
  955. title: '渲染完成',
  956. action: '完成',
  957. description: '客厅主视角渲染已完成,等待客户确认'
  958. },
  959. {
  960. id: '2',
  961. time: '2024-02-14 10:15',
  962. title: '材质调整',
  963. action: '更新',
  964. description: '根据客户反馈调整了沙发和窗帘材质'
  965. },
  966. {
  967. id: '3',
  968. time: '2024-02-12 16:45',
  969. title: '模型优化',
  970. action: '优化',
  971. description: '优化了模型面数,提高渲染效率'
  972. },
  973. {
  974. id: '4',
  975. time: '2024-02-10 09:30',
  976. title: '客户反馈',
  977. action: '收到',
  978. description: '收到客户关于颜色和储物空间的反馈意见'
  979. },
  980. {
  981. id: '5',
  982. time: '2024-02-08 15:20',
  983. title: '模型提交',
  984. action: '提交',
  985. description: '完成3D模型搭建并提交审核'
  986. }
  987. ];
  988. }, 800);
  989. }
  990. // 加载历史反馈记录
  991. loadExceptionHistories(): void {
  992. this.projectService.getExceptionHistories(this.projectId).subscribe(histories => {
  993. this.exceptionHistories = histories;
  994. });
  995. }
  996. loadProjectDetails(): void {
  997. console.log('=== loadProjectDetails 开始加载项目数据 ===');
  998. console.log('当前项目ID:', this.projectId);
  999. this.projectService.getProjectById(this.projectId).subscribe(project => {
  1000. console.log('获取到的项目数据:', project);
  1001. if (!project) {
  1002. console.error('未找到项目数据,项目ID:', this.projectId);
  1003. // 如果找不到项目,尝试使用默认项目ID
  1004. console.log('尝试使用默认项目ID: proj-001');
  1005. this.projectService.getProjectById('proj-001').subscribe(defaultProject => {
  1006. console.log('默认项目数据:', defaultProject);
  1007. if (defaultProject) {
  1008. this.project = defaultProject;
  1009. this.currentStage = defaultProject.currentStage || '';
  1010. console.log('使用默认项目,设置当前阶段:', this.currentStage);
  1011. this.setupStageExpansion(defaultProject);
  1012. }
  1013. });
  1014. return;
  1015. }
  1016. this.project = project;
  1017. // 设置当前阶段
  1018. if (project) {
  1019. this.currentStage = project.currentStage || '';
  1020. console.log('设置当前阶段:', this.currentStage);
  1021. this.setupStageExpansion(project);
  1022. }
  1023. // 检查技能匹配度 - 已注释掉以取消弹窗警告
  1024. // this.checkSkillMismatch();
  1025. });
  1026. }
  1027. private setupStageExpansion(project: any): void {
  1028. // 重置展开状态并默认展开当前阶段
  1029. this.stageOrder.forEach(s => this.expandedStages[s] = false);
  1030. const currentStage = project.currentStage as ProjectStage;
  1031. if (this.stageOrder.includes(currentStage)) {
  1032. this.expandedStages[currentStage] = true;
  1033. console.log('展开当前阶段:', currentStage);
  1034. }
  1035. // 新增:根据当前阶段默认展开所属板块
  1036. const currentSec = this.getSectionKeyForStage(currentStage);
  1037. this.expandedSection = currentSec;
  1038. console.log('展开板块:', currentSec);
  1039. // 新增:如果当前阶段是建模、软装或渲染,自动展开对应的折叠面板
  1040. if (currentStage === '建模' || currentStage === '软装' || currentStage === '渲染') {
  1041. const processTypeMap = {
  1042. '建模': 'modeling',
  1043. '软装': 'softDecor',
  1044. '渲染': 'rendering'
  1045. };
  1046. const processType = processTypeMap[currentStage] as 'modeling' | 'softDecor' | 'rendering';
  1047. const targetProcess = this.deliveryProcesses.find(p => p.type === processType);
  1048. if (targetProcess) {
  1049. // 展开对应的流程面板
  1050. targetProcess.isExpanded = true;
  1051. // 展开第一个空间以便用户操作
  1052. if (targetProcess.spaces.length > 0) {
  1053. targetProcess.spaces[0].isExpanded = true;
  1054. // 关闭其他空间
  1055. targetProcess.spaces.slice(1).forEach(space => space.isExpanded = false);
  1056. }
  1057. console.log('自动展开折叠面板:', currentStage, processType);
  1058. }
  1059. }
  1060. }
  1061. // 整理项目详情
  1062. organizeProject(): void {
  1063. // 模拟整理项目逻辑
  1064. alert('项目详情已整理');
  1065. }
  1066. // 检查当前阶段是否显示特定卡片
  1067. shouldShowCard(cardType: string): boolean {
  1068. // 改为始终显示:各阶段详情在看板下方就地展示,不再受当前阶段限制
  1069. return true;
  1070. }
  1071. loadRenderProgress(): void {
  1072. this.isLoadingRenderProgress = true;
  1073. this.errorLoadingRenderProgress = false;
  1074. // 模拟API加载过程
  1075. setTimeout(() => {
  1076. this.projectService.getRenderProgress(this.projectId).subscribe(progress => {
  1077. this.renderProgress = progress;
  1078. this.isLoadingRenderProgress = false;
  1079. // 模拟API加载失败的情况
  1080. if (!progress) {
  1081. this.errorLoadingRenderProgress = true;
  1082. // 通知技术组长
  1083. this.notifyTeamLeader('render-failed');
  1084. } else {
  1085. // 检查是否需要显示超时预警
  1086. this.checkRenderTimeout();
  1087. }
  1088. });
  1089. }, 1000);
  1090. }
  1091. loadCustomerFeedbacks(): void {
  1092. this.projectService.getCustomerFeedbacks().subscribe(feedbacks => {
  1093. this.feedbacks = feedbacks.filter(f => f.projectId === this.projectId);
  1094. // 为反馈添加分类标签
  1095. this.tagCustomerFeedbacks();
  1096. // 检查是否有需要处理的反馈并启动倒计时
  1097. this.checkFeedbackTimeout();
  1098. });
  1099. }
  1100. loadDesignerChanges(): void {
  1101. // 在实际应用中,这里应该从服务中获取设计师变更记录
  1102. // 这里使用模拟数据
  1103. this.designerChanges = [
  1104. {
  1105. id: 'dc1',
  1106. projectId: this.projectId,
  1107. oldDesignerId: 'designer2',
  1108. oldDesignerName: '设计师B',
  1109. newDesignerId: 'designer1',
  1110. newDesignerName: '设计师A',
  1111. changeTime: new Date('2025-09-05'),
  1112. acceptanceTime: new Date('2025-09-05'),
  1113. historicalAchievements: ['完成初步建模', '确定色彩方案'],
  1114. completedWorkload: 30
  1115. }
  1116. ];
  1117. }
  1118. loadSettlements(): void {
  1119. this.projectService.getSettlements().subscribe(settlements => {
  1120. this.settlements = settlements.filter(s => s.projectId === this.projectId);
  1121. });
  1122. }
  1123. loadRequirementChecklist(): void {
  1124. this.projectService.generateRequirementChecklist(this.projectId).subscribe(checklist => {
  1125. this.requirementChecklist = checklist;
  1126. });
  1127. }
  1128. updateFeedbackStatus(feedbackId: string, status: '处理中' | '已解决'): void {
  1129. this.projectService.updateFeedbackStatus(feedbackId, status).subscribe(() => {
  1130. this.loadCustomerFeedbacks(); // 重新加载反馈
  1131. // 清除倒计时
  1132. if (this.countdownInterval) {
  1133. clearInterval(this.countdownInterval);
  1134. this.feedbackTimeoutCountdown = 0;
  1135. }
  1136. });
  1137. }
  1138. updateProjectStage(stage: ProjectStage): void {
  1139. if (this.project) {
  1140. this.projectService.updateProjectStage(this.projectId, stage).subscribe(() => {
  1141. this.currentStage = stage; // 同步更新本地状态
  1142. this.project!.currentStage = stage; // 同步更新project对象的currentStage
  1143. this.loadProjectDetails(); // 重新加载项目详情
  1144. this.cdr.detectChanges(); // 触发变更检测以更新导航栏颜色
  1145. });
  1146. }
  1147. }
  1148. // 新增:根据给定阶段跳转到下一阶段
  1149. advanceToNextStage(afterStage: ProjectStage): void {
  1150. const idx = this.stageOrder.indexOf(afterStage);
  1151. if (idx >= 0 && idx < this.stageOrder.length - 1) {
  1152. const next = this.stageOrder[idx + 1];
  1153. this.updateProjectStage(next);
  1154. // 更新展开状态,折叠当前、展开下一阶段,提升体验
  1155. if (this.expandedStages[afterStage] !== undefined) this.expandedStages[afterStage] = false as any;
  1156. if (this.expandedStages[next] !== undefined) this.expandedStages[next] = true as any;
  1157. // 更新板块展开状态
  1158. const nextSection = this.getSectionKeyForStage(next);
  1159. this.expandedSection = nextSection;
  1160. // 新增:自动展开对应阶段的折叠面板
  1161. if (next === '软装' || next === '渲染') {
  1162. const processType = next === '软装' ? 'softDecor' : 'rendering';
  1163. const targetProcess = this.deliveryProcesses.find(p => p.type === processType);
  1164. if (targetProcess) {
  1165. // 展开对应的流程面板
  1166. targetProcess.isExpanded = true;
  1167. // 展开第一个空间以便用户操作
  1168. if (targetProcess.spaces.length > 0) {
  1169. targetProcess.spaces[0].isExpanded = true;
  1170. // 关闭其他空间
  1171. targetProcess.spaces.slice(1).forEach(space => space.isExpanded = false);
  1172. }
  1173. }
  1174. }
  1175. // 触发变更检测以更新导航栏颜色
  1176. this.cdr.detectChanges();
  1177. }
  1178. }
  1179. generateReminderMessage(): void {
  1180. this.projectService.generateReminderMessage('stagnation').subscribe(message => {
  1181. this.reminderMessage = message;
  1182. // 3秒后自动清除提醒
  1183. setTimeout(() => {
  1184. this.reminderMessage = '';
  1185. }, 3000);
  1186. });
  1187. }
  1188. // ============ 新增:标准化阶段映射与紧急程度 ============
  1189. // 计算距离截止日期的天数(向下取整)
  1190. getDaysToDeadline(): number | null {
  1191. if (!this.project?.deadline) return null;
  1192. const now = new Date();
  1193. const deadline = new Date(this.project.deadline);
  1194. const diffMs = deadline.getTime() - now.getTime();
  1195. return Math.floor(diffMs / (1000 * 60 * 60 * 24));
  1196. }
  1197. // 是否延期/临期/提示
  1198. getUrgencyBadge(): 'overdue' | 'due_3' | 'due_7' | null {
  1199. const d = this.getDaysToDeadline();
  1200. if (d === null) return null;
  1201. if (d < 0) return 'overdue';
  1202. if (d <= 3) return 'due_3';
  1203. if (d <= 7) return 'due_7';
  1204. return null;
  1205. }
  1206. // 是否存在不满意或待处理投诉/反馈
  1207. hasPendingComplaint(): boolean {
  1208. return this.feedbacks.some(f => !f.isSatisfied || f.status === '待处理');
  1209. }
  1210. // 将现有细分阶段映射为标准化阶段
  1211. mapToStandardPhase(stage: ProjectStage): '待分配' | '需求方案' | '项目执行' | '收尾验收' | '归档' {
  1212. const mapping: Record<ProjectStage, '待分配' | '需求方案' | '项目执行' | '收尾验收' | '归档'> = {
  1213. '订单分配': '待分配',
  1214. '需求沟通': '需求方案',
  1215. '方案确认': '需求方案',
  1216. '建模': '项目执行',
  1217. '软装': '项目执行',
  1218. '渲染': '项目执行',
  1219. '后期': '项目执行',
  1220. '尾款结算': '收尾验收',
  1221. '客户评价': '收尾验收',
  1222. '投诉处理': '收尾验收'
  1223. };
  1224. return mapping[stage] ?? '待分配';
  1225. }
  1226. getStandardPhaseIndex(): number {
  1227. if (!this.project?.currentStage) return 0;
  1228. const phase = this.mapToStandardPhase(this.project.currentStage);
  1229. return this.standardPhases.indexOf(phase);
  1230. }
  1231. isStandardPhaseCompleted(phase: '待分配' | '需求方案' | '项目执行' | '收尾验收' | '归档'): boolean {
  1232. return this.standardPhases.indexOf(phase) < this.getStandardPhaseIndex();
  1233. }
  1234. isStandardPhaseCurrent(phase: '待分配' | '需求方案' | '项目执行' | '收尾验收' | '归档'): boolean {
  1235. return this.standardPhases.indexOf(phase) === this.getStandardPhaseIndex();
  1236. }
  1237. // ============ 新增:项目报告导出 ============
  1238. exportProjectReport(): void {
  1239. if (!this.project) return;
  1240. const lines: string[] = [];
  1241. const d = this.getDaysToDeadline();
  1242. lines.push(`项目名称: ${this.project.name}`);
  1243. lines.push(`当前阶段(细分): ${this.project.currentStage}`);
  1244. lines.push(`当前阶段(标准化): ${this.mapToStandardPhase(this.project.currentStage)}`);
  1245. if (this.project.deadline) {
  1246. lines.push(`截止日期: ${this.formatDate(this.project.deadline)}`);
  1247. lines.push(`剩余天数: ${d !== null ? d : '-'}天`);
  1248. }
  1249. lines.push(`技能需求: ${(this.project.skillsRequired || []).join('、')}`);
  1250. lines.push('—— 渲染进度 ——');
  1251. lines.push(this.renderProgress ? `状态: ${this.renderProgress.status}, 完成度: ${this.renderProgress.completionRate}%` : '无渲染进度数据');
  1252. lines.push('—— 客户反馈 ——');
  1253. lines.push(this.feedbacks.length ? `${this.feedbacks.length} 条` : '暂无');
  1254. lines.push('—— 设计师变更 ——');
  1255. lines.push(this.designerChanges.length ? `${this.designerChanges.length} 条` : '暂无');
  1256. lines.push('—— 交付文件 ——');
  1257. lines.push(this.projectFiles.length ? this.projectFiles.map(f => `• ${f.name} (${f.type}, ${f.size})`).join('\n') : '暂无');
  1258. const content = lines.join('\n');
  1259. const blob = new Blob([content], { type: 'text/plain;charset=utf-8' });
  1260. const url = URL.createObjectURL(blob);
  1261. const a = document.createElement('a');
  1262. a.href = url;
  1263. a.download = `${this.project.name || '项目'}-阶段报告.txt`;
  1264. a.click();
  1265. URL.revokeObjectURL(url);
  1266. }
  1267. // ============ 新增:通用文件上传(含4K图片校验) ============
  1268. async onGeneralFilesSelected(event: Event): Promise<void> {
  1269. const input = event.target as HTMLInputElement;
  1270. if (!input.files || input.files.length === 0) return;
  1271. const files = Array.from(input.files);
  1272. this.isUploadingFile = true;
  1273. for (const file of files) {
  1274. // 对图片进行4K校验(最大边 >= 4000px)
  1275. if (/\.(jpg|jpeg|png)$/i.test(file.name)) {
  1276. const ok = await this.validateImage4K(file).catch(() => false);
  1277. if (!ok) {
  1278. alert(`图片不符合4K标准(最大边需≥4000像素):${file.name}`);
  1279. continue;
  1280. }
  1281. }
  1282. // 简化:直接追加到本地列表(实际应上传到服务器)
  1283. const fakeType = (file.name.split('.').pop() || '').toLowerCase();
  1284. const sizeMB = (file.size / (1024 * 1024)).toFixed(1) + 'MB';
  1285. const nowStr = this.formatDate(new Date());
  1286. this.projectFiles.unshift({
  1287. id: `file-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
  1288. name: file.name,
  1289. type: fakeType,
  1290. size: sizeMB,
  1291. date: nowStr,
  1292. url: '#'
  1293. });
  1294. }
  1295. this.isUploadingFile = false;
  1296. // 清空选择
  1297. input.value = '';
  1298. }
  1299. validateImage4K(file: File): Promise<boolean> {
  1300. return new Promise((resolve, reject) => {
  1301. const reader = new FileReader();
  1302. reader.onload = () => {
  1303. const img = new Image();
  1304. img.onload = () => {
  1305. const maxSide = Math.max(img.width, img.height);
  1306. resolve(maxSide >= 4000);
  1307. };
  1308. img.onerror = () => reject('image load error');
  1309. img.src = reader.result as string;
  1310. };
  1311. reader.onerror = () => reject('read error');
  1312. reader.readAsDataURL(file);
  1313. });
  1314. }
  1315. // 可选:列表 trackBy,优化渲染
  1316. trackById(_: number, item: { id: string }): string { return item.id; }
  1317. retryLoadRenderProgress(): void {
  1318. this.loadRenderProgress();
  1319. }
  1320. // 检查是否所有模型检查项都已通过
  1321. // 获取技能匹配度警告
  1322. getSkillMismatchWarning(): string | null {
  1323. if (!this.project) return null;
  1324. // 模拟技能匹配度检查
  1325. const designerSkills = ['现代风格', '硬装'];
  1326. const requiredSkills = this.project.skillsRequired;
  1327. const mismatchedSkills = requiredSkills.filter(skill => !designerSkills.includes(skill));
  1328. if (mismatchedSkills.length > 0) {
  1329. return `警告:您不擅长${mismatchedSkills.join('、')},建议联系组长协调`;
  1330. }
  1331. return null;
  1332. }
  1333. // 检查渲染是否超时
  1334. checkRenderTimeout(): void {
  1335. if (!this.renderProgress || !this.project) return;
  1336. // 模拟交付前3小时预警
  1337. const deliveryTime = new Date(this.project.deadline);
  1338. const currentTime = new Date();
  1339. const timeDifference = deliveryTime.getTime() - currentTime.getTime();
  1340. const hoursRemaining = Math.floor(timeDifference / (1000 * 60 * 60));
  1341. if (hoursRemaining <= 3 && hoursRemaining > 0) {
  1342. // 弹窗预警
  1343. alert('渲染进度预警:交付前3小时,请关注渲染进度');
  1344. }
  1345. if (hoursRemaining <= 1 && hoursRemaining > 0) {
  1346. // 更严重的预警
  1347. alert('渲染进度严重预警:交付前1小时,渲染可能无法按时完成!');
  1348. }
  1349. }
  1350. // 为客户反馈添加分类标签
  1351. tagCustomerFeedbacks(): void {
  1352. this.feedbacks.forEach(feedback => {
  1353. // 添加分类标签
  1354. if (feedback.content.includes('色彩') || feedback.problemLocation?.includes('色彩')) {
  1355. (feedback as any).tag = '色彩问题';
  1356. } else if (feedback.content.includes('家具') || feedback.problemLocation?.includes('家具')) {
  1357. (feedback as any).tag = '家具款式问题';
  1358. } else if (feedback.content.includes('光线') || feedback.content.includes('照明')) {
  1359. (feedback as any).tag = '光线问题';
  1360. } else {
  1361. (feedback as any).tag = '其他问题';
  1362. }
  1363. });
  1364. }
  1365. // 获取反馈标签的辅助方法
  1366. getFeedbackTag(feedback: CustomerFeedback): string {
  1367. return (feedback as any).tag || '';
  1368. }
  1369. // 检查反馈超时
  1370. checkFeedbackTimeout(): void {
  1371. const pendingFeedbacks = this.feedbacks.filter(f => f.status === '待处理');
  1372. if (pendingFeedbacks.length > 0) {
  1373. // 启动1小时倒计时
  1374. this.feedbackTimeoutCountdown = 3600; // 3600秒 = 1小时
  1375. this.startCountdown();
  1376. }
  1377. }
  1378. // 启动倒计时
  1379. startCountdown(): void {
  1380. this.countdownInterval = setInterval(() => {
  1381. if (this.feedbackTimeoutCountdown > 0) {
  1382. this.feedbackTimeoutCountdown--;
  1383. } else {
  1384. clearInterval(this.countdownInterval);
  1385. // 超时提醒
  1386. alert('客户反馈已超过1小时未响应,请立即处理!');
  1387. this.notifyTeamLeader('feedback-overdue');
  1388. }
  1389. }, 1000);
  1390. }
  1391. // 通知技术组长
  1392. notifyTeamLeader(type: 'render-failed' | 'feedback-overdue' | 'skill-mismatch'): void {
  1393. // 实际应用中应调用消息服务通知组长
  1394. console.log(`通知技术组长:${type} - 项目ID: ${this.projectId}`);
  1395. }
  1396. // 检查技能匹配度并提示
  1397. checkSkillMismatch(): void {
  1398. const warning = this.getSkillMismatchWarning();
  1399. if (warning) {
  1400. // 显示技能不匹配警告
  1401. if (confirm(`${warning}\n是否联系技术组长协调支持?`)) {
  1402. this.notifyTeamLeader('skill-mismatch');
  1403. }
  1404. }
  1405. }
  1406. // 发起设计师变更
  1407. initiateDesignerChange(reason: string): void {
  1408. // 实际应用中应调用API发起变更
  1409. console.log(`发起设计师变更,原因:${reason}`);
  1410. alert('已发起设计师变更申请,请等待新设计师承接');
  1411. }
  1412. // 确认承接变更项目
  1413. acceptDesignerChange(changeId: string): void {
  1414. // 实际应用中应调用API确认承接
  1415. console.log(`确认承接设计师变更:${changeId}`);
  1416. alert('已确认承接项目,系统已记录时间戳和责任人');
  1417. }
  1418. // 格式化倒计时显示
  1419. formatCountdown(seconds: number): string {
  1420. const hours = Math.floor(seconds / 3600);
  1421. const minutes = Math.floor((seconds % 3600) / 60);
  1422. const remainingSeconds = seconds % 60;
  1423. return `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${remainingSeconds.toString().padStart(2, '0')}`;
  1424. }
  1425. // 提交异常反馈
  1426. submitExceptionFeedback(): void {
  1427. if (!this.exceptionDescription.trim() || this.isSubmittingFeedback) {
  1428. alert('请填写异常类型和描述');
  1429. return;
  1430. }
  1431. this.isSubmittingFeedback = true;
  1432. // 模拟提交反馈到服务器
  1433. setTimeout(() => {
  1434. const newException: ExceptionHistory = {
  1435. id: `exception-${Date.now()}`,
  1436. type: this.exceptionType,
  1437. description: this.exceptionDescription,
  1438. submitTime: new Date(),
  1439. status: '待处理'
  1440. };
  1441. // 添加到历史记录中
  1442. this.exceptionHistories.unshift(newException);
  1443. // 通知客服和技术支持
  1444. this.notifyTechnicalSupport(newException);
  1445. // 清空表单
  1446. this.exceptionDescription = '';
  1447. this.clearExceptionScreenshot();
  1448. this.showExceptionForm = false;
  1449. // 显示成功消息
  1450. alert('异常反馈已提交,技术支持将尽快处理');
  1451. this.isSubmittingFeedback = false;
  1452. }, 1000);
  1453. }
  1454. // 上传异常截图
  1455. uploadExceptionScreenshot(event: Event): void {
  1456. const input = event.target as HTMLInputElement;
  1457. if (input.files && input.files[0]) {
  1458. const file = input.files[0];
  1459. // 在实际应用中,这里应该上传文件到服务器
  1460. // 这里我们使用FileReader来生成一个预览URL
  1461. const reader = new FileReader();
  1462. reader.onload = (e) => {
  1463. this.exceptionScreenshotUrl = e.target?.result as string;
  1464. };
  1465. reader.readAsDataURL(file);
  1466. }
  1467. }
  1468. // 清除异常截图
  1469. clearExceptionScreenshot(): void {
  1470. this.exceptionScreenshotUrl = null;
  1471. const input = document.getElementById('screenshot-upload') as HTMLInputElement;
  1472. if (input) {
  1473. input.value = '';
  1474. }
  1475. }
  1476. // 联系组长
  1477. contactTeamLeader() {
  1478. alert(`已联系${this.project?.assigneeName || '项目组长'}`);
  1479. }
  1480. // 处理渲染超时预警
  1481. handleRenderTimeout() {
  1482. alert('已发送渲染超时预警通知');
  1483. }
  1484. // 通知技术支持
  1485. notifyTechnicalSupport(exception: ExceptionHistory): void {
  1486. // 实际应用中应调用消息服务通知技术支持和客服
  1487. console.log(`通知技术支持和客服:渲染异常 - 项目ID: ${this.projectId}`);
  1488. console.log(`异常类型: ${this.getExceptionTypeText(exception.type)}, 描述: ${exception.description}`);
  1489. }
  1490. // 获取异常类型文本
  1491. getExceptionTypeText(type: string): string {
  1492. const typeMap: Record<string, string> = {
  1493. 'failed': '渲染失败',
  1494. 'stuck': '渲染卡顿',
  1495. 'quality': '渲染质量问题',
  1496. 'other': '其他问题'
  1497. };
  1498. return typeMap[type] || type;
  1499. }
  1500. // 格式化日期
  1501. formatDate(date: Date | string): string {
  1502. const d = typeof date === 'string' ? new Date(date) : date;
  1503. const year = d.getFullYear();
  1504. const month = String(d.getMonth() + 1).padStart(2, '0');
  1505. const day = String(d.getDate()).padStart(2, '0');
  1506. const hours = String(d.getHours()).padStart(2, '0');
  1507. const minutes = String(d.getMinutes()).padStart(2, '0');
  1508. return `${year}-${month}-${day} ${hours}:${minutes}`;
  1509. }
  1510. // 将字节格式化为易读尺寸
  1511. private formatFileSize(bytes: number): string {
  1512. if (bytes < 1024) return `${bytes}B`;
  1513. const kb = bytes / 1024;
  1514. if (kb < 1024) return `${kb.toFixed(1)}KB`;
  1515. const mb = kb / 1024;
  1516. if (mb < 1024) return `${mb.toFixed(1)}MB`;
  1517. const gb = mb / 1024;
  1518. return `${gb.toFixed(2)}GB`;
  1519. }
  1520. // 生成缩略图条目(并创建本地预览URL)
  1521. private makeImageItem(file: File): { id: string; name: string; url: string; size: string } {
  1522. const id = `img-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
  1523. const url = URL.createObjectURL(file);
  1524. return { id, name: file.name, url, size: this.formatFileSize(file.size) };
  1525. }
  1526. // 释放对象URL
  1527. private revokeUrl(url: string): void {
  1528. try { if (url && url.startsWith('blob:')) URL.revokeObjectURL(url); } catch {}
  1529. }
  1530. // =========== 建模阶段:白模上传 ===========
  1531. onWhiteModelSelected(event: Event): void {
  1532. const input = event.target as HTMLInputElement;
  1533. if (!input.files || input.files.length === 0) return;
  1534. const files = Array.from(input.files).filter(f => /\.(jpg|jpeg|png)$/i.test(f.name));
  1535. const items = files.map(f => this.makeImageItem(f));
  1536. this.whiteModelImages.unshift(...items);
  1537. input.value = '';
  1538. }
  1539. removeWhiteModelImage(id: string): void {
  1540. const target = this.whiteModelImages.find(i => i.id === id);
  1541. if (target) this.revokeUrl(target.url);
  1542. this.whiteModelImages = this.whiteModelImages.filter(i => i.id !== id);
  1543. }
  1544. // 新增:建模阶段 确认上传并自动进入下一阶段(软装)
  1545. confirmWhiteModelUpload(): void {
  1546. // 检查建模阶段的图片数据
  1547. const modelingProcess = this.deliveryProcesses.find(p => p.id === 'modeling');
  1548. if (!modelingProcess) return;
  1549. // 检查是否有任何空间上传了图片
  1550. const hasImages = modelingProcess.spaces.some(space => {
  1551. const content = modelingProcess.content[space.id];
  1552. return content && content.images && content.images.length > 0;
  1553. });
  1554. if (!hasImages) return;
  1555. this.advanceToNextStage('建模');
  1556. }
  1557. // =========== 软装阶段:小图上传(建议≤1MB,不强制) ===========
  1558. onSoftDecorSmallPicsSelected(event: Event): void {
  1559. const input = event.target as HTMLInputElement;
  1560. if (!input.files || input.files.length === 0) return;
  1561. const files = Array.from(input.files).filter(f => /\.(jpg|jpeg|png)$/i.test(f.name));
  1562. const warnOversize = files.filter(f => f.size > 1024 * 1024);
  1563. if (warnOversize.length > 0) {
  1564. // 仅提示,不阻断
  1565. console.warn('软装小图建议≤1MB,以下文件较大:', warnOversize.map(f => f.name));
  1566. }
  1567. const items = files.map(f => this.makeImageItem(f));
  1568. this.softDecorImages.unshift(...items);
  1569. input.value = '';
  1570. }
  1571. // 拖拽上传相关属性
  1572. isDragOver: boolean = false;
  1573. // 图片预览相关属性
  1574. showImagePreview: boolean = false;
  1575. previewImageData: any = null;
  1576. // 图片预览方法(含渲染大图加锁校验)
  1577. previewImage(img: any): void {
  1578. const isRenderLarge = !!this.renderLargeImages.find(i => i.id === img?.id);
  1579. if (isRenderLarge && img?.locked) {
  1580. alert('该渲染大图已加锁,需完成尾款结算并上传/识别支付凭证后方可预览。');
  1581. return;
  1582. }
  1583. this.previewImageData = img;
  1584. this.showImagePreview = true;
  1585. }
  1586. closeImagePreview(): void {
  1587. this.showImagePreview = false;
  1588. this.previewImageData = null;
  1589. }
  1590. downloadImage(img: any): void {
  1591. const isRenderLarge = !!this.renderLargeImages.find(i => i.id === img?.id);
  1592. if (isRenderLarge && img?.locked) {
  1593. alert('该渲染大图已加锁,需完成尾款结算并上传/识别支付凭证后方可下载。');
  1594. return;
  1595. }
  1596. if (img) {
  1597. const link = document.createElement('a');
  1598. link.href = img.url;
  1599. link.download = img.name;
  1600. link.click();
  1601. }
  1602. }
  1603. removeImageFromPreview(): void {
  1604. if (this.previewImageData) {
  1605. // 首先检查新的 deliveryProcesses 结构
  1606. let imageFound = false;
  1607. for (const process of this.deliveryProcesses) {
  1608. for (const space of process.spaces) {
  1609. if (process.content[space.id]?.images) {
  1610. const imageIndex = process.content[space.id].images.findIndex(img => img.id === this.previewImageData.id);
  1611. if (imageIndex > -1) {
  1612. this.removeSpaceImage(process.id, space.id, this.previewImageData.id);
  1613. imageFound = true;
  1614. break;
  1615. }
  1616. }
  1617. }
  1618. if (imageFound) break;
  1619. }
  1620. // 如果在新结构中没找到,检查旧的图片数组
  1621. if (!imageFound) {
  1622. if (this.whiteModelImages.find(i => i.id === this.previewImageData.id)) {
  1623. this.removeWhiteModelImage(this.previewImageData.id);
  1624. } else if (this.softDecorImages.find(i => i.id === this.previewImageData.id)) {
  1625. this.removeSoftDecorImage(this.previewImageData.id);
  1626. } else if (this.renderLargeImages.find(i => i.id === this.previewImageData.id)) {
  1627. this.removeRenderLargeImage(this.previewImageData.id);
  1628. } else if (this.postProcessImages.find(i => i.id === this.previewImageData.id)) {
  1629. this.removePostProcessImage(this.previewImageData.id);
  1630. }
  1631. }
  1632. this.closeImagePreview();
  1633. }
  1634. }
  1635. // 拖拽事件处理
  1636. onDragOver(event: DragEvent): void {
  1637. event.preventDefault();
  1638. event.stopPropagation();
  1639. this.isDragOver = true;
  1640. }
  1641. onDragLeave(event: DragEvent): void {
  1642. event.preventDefault();
  1643. event.stopPropagation();
  1644. this.isDragOver = false;
  1645. }
  1646. onFileDrop(event: DragEvent, type: 'whiteModel' | 'softDecor' | 'render' | 'postProcess'): void {
  1647. event.preventDefault();
  1648. event.stopPropagation();
  1649. this.isDragOver = false;
  1650. const files = event.dataTransfer?.files;
  1651. if (!files || files.length === 0) return;
  1652. // 创建模拟的input事件
  1653. const mockEvent = {
  1654. target: {
  1655. files: files
  1656. }
  1657. } as any;
  1658. // 根据类型调用相应的处理方法
  1659. switch (type) {
  1660. case 'whiteModel':
  1661. this.onWhiteModelSelected(mockEvent);
  1662. break;
  1663. case 'softDecor':
  1664. this.onSoftDecorSmallPicsSelected(mockEvent);
  1665. break;
  1666. case 'render':
  1667. this.onRenderLargePicsSelected(mockEvent);
  1668. break;
  1669. case 'postProcess':
  1670. this.onPostProcessPicsSelected(mockEvent);
  1671. break;
  1672. }
  1673. }
  1674. // 触发文件输入框
  1675. triggerFileInput(type: 'whiteModel' | 'softDecor' | 'render' | 'postProcess'): void {
  1676. let inputId: string;
  1677. switch (type) {
  1678. case 'whiteModel':
  1679. inputId = 'whiteModelFileInput';
  1680. break;
  1681. case 'softDecor':
  1682. inputId = 'softDecorFileInput';
  1683. break;
  1684. case 'render':
  1685. inputId = 'renderFileInput';
  1686. break;
  1687. case 'postProcess':
  1688. inputId = 'postProcessFileInput';
  1689. break;
  1690. }
  1691. const input = document.querySelector(`#${inputId}`) as HTMLInputElement;
  1692. if (input) {
  1693. input.click();
  1694. }
  1695. }
  1696. removeSoftDecorImage(id: string): void {
  1697. const target = this.softDecorImages.find(i => i.id === id);
  1698. if (target) this.revokeUrl(target.url);
  1699. this.softDecorImages = this.softDecorImages.filter(i => i.id !== id);
  1700. }
  1701. // 新增:后期阶段图片上传处理
  1702. async onPostProcessPicsSelected(event: Event): Promise<void> {
  1703. const input = event.target as HTMLInputElement;
  1704. if (!input.files || input.files.length === 0) return;
  1705. const files = Array.from(input.files).filter(f => /\.(jpg|jpeg|png)$/i.test(f.name));
  1706. for (const f of files) {
  1707. const item = this.makeImageItem(f);
  1708. this.postProcessImages.unshift({
  1709. id: item.id,
  1710. name: item.name,
  1711. url: item.url,
  1712. size: this.formatFileSize(f.size)
  1713. });
  1714. }
  1715. input.value = '';
  1716. }
  1717. removePostProcessImage(id: string): void {
  1718. const target = this.postProcessImages.find(i => i.id === id);
  1719. if (target) this.revokeUrl(target.url);
  1720. this.postProcessImages = this.postProcessImages.filter(i => i.id !== id);
  1721. }
  1722. // 新增:后期阶段 确认上传并自动进入下一阶段(尾款结算)
  1723. confirmPostProcessUpload(): void {
  1724. // 检查后期阶段的图片数据
  1725. const postProcessProcess = this.deliveryProcesses.find(p => p.id === 'post-processing');
  1726. if (!postProcessProcess) return;
  1727. // 检查是否有任何空间上传了图片
  1728. const hasImages = postProcessProcess.spaces.some(space => {
  1729. const content = postProcessProcess.content[space.id];
  1730. return content && content.images && content.images.length > 0;
  1731. });
  1732. if (!hasImages) return;
  1733. this.advanceToNextStage('后期');
  1734. }
  1735. // 新增:尾款结算阶段确认并自动进入下一阶段(客户评价)
  1736. confirmSettlement(): void {
  1737. if (this.isConfirmingSettlement) return;
  1738. this.isConfirmingSettlement = true;
  1739. // 模拟API调用延迟
  1740. setTimeout(() => {
  1741. this.isSettlementCompleted = true;
  1742. this.isConfirmingSettlement = false;
  1743. // 显示成功提示
  1744. alert('尾款结算已确认完成!');
  1745. // 进入下一阶段
  1746. this.advanceToNextStage('尾款结算');
  1747. }, 1500);
  1748. }
  1749. // 新增:投诉处理阶段确认并完成项目(基础版本,详细版本在售后模块中)
  1750. confirmComplaintBasic(): void {
  1751. console.log('确认投诉处理完成');
  1752. // 可以在这里添加更多逻辑,比如标记项目完成等
  1753. // 调用服务更新后端数据
  1754. // this.projectService.confirmComplaintResolution(this.projectId);
  1755. this.advanceToNextStage('投诉处理');
  1756. }
  1757. // 新增:软装阶段 确认上传并自动进入下一阶段(渲染)
  1758. confirmSoftDecorUpload(): void {
  1759. // 检查软装阶段的图片数据
  1760. const softDecorProcess = this.deliveryProcesses.find(p => p.id === 'soft-decoration');
  1761. if (!softDecorProcess) return;
  1762. // 检查是否有任何空间上传了图片
  1763. const hasImages = softDecorProcess.spaces.some(space => {
  1764. const content = softDecorProcess.content[space.id];
  1765. return content && content.images && content.images.length > 0;
  1766. });
  1767. if (!hasImages) return;
  1768. this.advanceToNextStage('软装');
  1769. }
  1770. // 新增:渲染阶段 确认上传并自动进入下一阶段(后期)
  1771. confirmRenderUpload(): void {
  1772. // 检查渲染阶段的图片数据
  1773. const renderProcess = this.deliveryProcesses.find(p => p.id === 'rendering');
  1774. if (!renderProcess) return;
  1775. // 检查是否有任何空间上传了图片
  1776. const hasImages = renderProcess.spaces.some(space => {
  1777. const content = renderProcess.content[space.id];
  1778. return content && content.images && content.images.length > 0;
  1779. });
  1780. if (!hasImages) return;
  1781. this.advanceToNextStage('渲染');
  1782. }
  1783. // =========== 渲染阶段:大图上传(弹窗 + 4K校验) ===========
  1784. openRenderUploadModal(): void {
  1785. this.showRenderUploadModal = true;
  1786. this.pendingRenderLargeItems = [];
  1787. }
  1788. closeRenderUploadModal(): void {
  1789. // 关闭时释放临时预览URL
  1790. this.pendingRenderLargeItems.forEach(i => this.revokeUrl(i.url));
  1791. this.pendingRenderLargeItems = [];
  1792. this.showRenderUploadModal = false;
  1793. }
  1794. async onRenderLargePicsSelected(event: Event): Promise<void> {
  1795. const input = event.target as HTMLInputElement;
  1796. if (!input.files || input.files.length === 0) return;
  1797. const files = Array.from(input.files).filter(f => /\.(jpg|jpeg|png)$/i.test(f.name));
  1798. for (const f of files) {
  1799. const ok = await this.validateImage4K(f).catch(() => false);
  1800. if (!ok) {
  1801. alert(`图片不符合4K标准(最大边需≥4000像素):${f.name}`);
  1802. continue;
  1803. }
  1804. const item = this.makeImageItem(f);
  1805. // 直接添加到正式列表,不再使用待确认列表
  1806. this.renderLargeImages.unshift({
  1807. id: item.id,
  1808. name: item.name,
  1809. url: item.url,
  1810. size: this.formatFileSize(f.size),
  1811. locked: true
  1812. });
  1813. }
  1814. input.value = '';
  1815. }
  1816. removeRenderLargeImage(id: string): void {
  1817. const target = this.renderLargeImages.find(i => i.id === id);
  1818. if (target) this.revokeUrl(target.url);
  1819. this.renderLargeImages = this.renderLargeImages.filter(i => i.id !== id);
  1820. }
  1821. // 根据阶段映射所属板块
  1822. getSectionKeyForStage(stage: ProjectStage): SectionKey {
  1823. switch (stage) {
  1824. case '订单分配':
  1825. return 'order';
  1826. case '需求沟通':
  1827. case '方案确认':
  1828. return 'requirements';
  1829. case '建模':
  1830. case '软装':
  1831. case '渲染':
  1832. case '后期':
  1833. return 'delivery';
  1834. case '尾款结算':
  1835. case '客户评价':
  1836. case '投诉处理':
  1837. return 'aftercare';
  1838. default:
  1839. return 'order';
  1840. }
  1841. }
  1842. // 获取板块状态:completed | 'active' | 'pending'
  1843. getSectionStatus(key: SectionKey): 'completed' | 'active' | 'pending' {
  1844. // 优先使用本地的currentStage,如果没有则使用project.currentStage
  1845. const current = (this.currentStage || this.project?.currentStage) as ProjectStage | undefined;
  1846. // 如果没有当前阶段(新创建的项目),默认订单分配板块为active(红色)
  1847. if (!current || current === '订单分配') {
  1848. return key === 'order' ? 'active' : 'pending';
  1849. }
  1850. // 获取当前阶段所属的板块
  1851. const currentSection = this.getSectionKeyForStage(current);
  1852. const sectionOrder = this.sections.map(s => s.key);
  1853. const currentIdx = sectionOrder.indexOf(currentSection);
  1854. const idx = sectionOrder.indexOf(key);
  1855. if (idx === -1 || currentIdx === -1) return 'pending';
  1856. // 已完成的板块:当前阶段所在板块之前的所有板块
  1857. if (idx < currentIdx) return 'completed';
  1858. // 当前进行中的板块:当前阶段所在的板块
  1859. if (idx === currentIdx) return 'active';
  1860. // 未开始的板块:当前阶段所在板块之后的所有板块
  1861. return 'pending';
  1862. }
  1863. // 切换四大板块(单展开)
  1864. toggleSection(key: SectionKey): void {
  1865. this.expandedSection = key;
  1866. // 点击板块按钮时,滚动到该板块的第一个可见阶段卡片
  1867. const sec = this.sections.find(s => s.key === key);
  1868. if (sec) {
  1869. // 设计师仅滚动到可见的三大执行阶段,否则取该板块第一个阶段
  1870. const candidate = this.isDesignerView()
  1871. ? sec.stages.find(st => ['建模', '软装', '渲染'].includes(st)) || sec.stages[0]
  1872. : sec.stages[0];
  1873. this.scrollToStage(candidate);
  1874. }
  1875. }
  1876. // 阶段到锚点的映射
  1877. stageToAnchor(stage: ProjectStage): string {
  1878. const map: Record<ProjectStage, string> = {
  1879. '订单分配': 'order',
  1880. '需求沟通': 'requirements-talk',
  1881. '方案确认': 'proposal-confirm',
  1882. '建模': 'modeling',
  1883. '软装': 'softdecor',
  1884. '渲染': 'render',
  1885. '后期': 'postprocess',
  1886. '尾款结算': 'settlement',
  1887. '客户评价': 'customer-review',
  1888. '投诉处理': 'complaint'
  1889. };
  1890. return `stage-${map[stage] || 'unknown'}`;
  1891. }
  1892. // 平滑滚动到指定阶段卡片
  1893. scrollToStage(stage: ProjectStage): void {
  1894. const anchor = this.stageToAnchor(stage);
  1895. const el = document.getElementById(anchor);
  1896. if (el) {
  1897. el.scrollIntoView({ behavior: 'smooth', block: 'start' });
  1898. }
  1899. }
  1900. // 订单分配阶段:客户信息(迁移自客服端"客户信息"卡片)
  1901. orderCreationMethod: 'miniprogram' | 'manual' = 'miniprogram';
  1902. isSyncing: boolean = false;
  1903. orderTime: string = '';
  1904. // 客户信息实时同步相关变量
  1905. isSyncingCustomerInfo: boolean = false;
  1906. lastSyncTime: Date | null = null;
  1907. syncInterval: any = null;
  1908. customerForm!: FormGroup;
  1909. customerSearchKeyword: string = '';
  1910. customerSearchResults: Array<{ id: string; name: string; phone: string; wechat?: string; avatar?: string; customerType?: string; source?: string; remark?: string }> = [];
  1911. selectedOrderCustomer: { id: string; name: string; phone: string; wechat?: string; avatar?: string; customerType?: string; source?: string; remark?: string } | null = null;
  1912. demandTypes = [
  1913. { value: 'price', label: '价格敏感' },
  1914. { value: 'quality', label: '质量敏感' },
  1915. { value: 'comprehensive', label: '综合要求' }
  1916. ];
  1917. followUpStatus = [
  1918. { value: 'quotation', label: '待报价' },
  1919. { value: 'confirm', label: '待确认需求' },
  1920. { value: 'lost', label: '已失联' }
  1921. ];
  1922. // 需求关键信息同步数据
  1923. requirementKeyInfo = {
  1924. colorAtmosphere: {
  1925. description: '',
  1926. mainColor: '',
  1927. colorTemp: '',
  1928. materials: [] as string[]
  1929. },
  1930. spaceStructure: {
  1931. lineRatio: 0,
  1932. blankRatio: 0,
  1933. flowWidth: 0,
  1934. aspectRatio: 0,
  1935. ceilingHeight: 0
  1936. },
  1937. materialWeights: {
  1938. fabricRatio: 0,
  1939. woodRatio: 0,
  1940. metalRatio: 0,
  1941. smoothness: 0,
  1942. glossiness: 0
  1943. },
  1944. presetAtmosphere: {
  1945. name: '',
  1946. rgb: '',
  1947. colorTemp: '',
  1948. materials: [] as string[]
  1949. }
  1950. };
  1951. // 客户信息:搜索/选择/清空/同步/快速填写 逻辑
  1952. searchCustomer(): void {
  1953. if (this.customerSearchKeyword.trim().length >= 2) {
  1954. this.customerSearchResults = [
  1955. { id: '1', name: '张先生', phone: '138****5678', customerType: '老客户', source: '官网咨询', avatar: "data:image/svg+xml,%3Csvg width='64' height='40' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='100%25' height='100%25' fill='%23E6E6E6'/%3E%3Ctext x='50%25' y='50%25' font-family='Arial' font-size='13.333333333333334' font-weight='bold' text-anchor='middle' fill='%23555555' dy='0.3em'%3EIMG%3C/text%3E%3C/svg%3E" },
  1956. { id: '2', name: '李女士', phone: '139****1234', customerType: 'VIP客户', source: '推荐介绍', avatar: "data:image/svg+xml,%3Csvg width='65' height='40' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='100%25' height='100%25' fill='%23DCDCDC'/%3E%3Ctext x='50%25' y='50%25' font-family='Arial' font-size='13.333333333333334' font-weight='bold' text-anchor='middle' fill='%23555555' dy='0.3em'%3EIMG%3C/text%3E%3C/svg%3E" }
  1957. ];
  1958. } else {
  1959. this.customerSearchResults = [];
  1960. }
  1961. }
  1962. selectCustomer(customer: { id: string; name: string; phone: string; wechat?: string; avatar?: string; customerType?: string; source?: string; remark?: string }): void {
  1963. this.selectedOrderCustomer = customer;
  1964. this.customerForm.patchValue({
  1965. name: customer.name,
  1966. phone: customer.phone,
  1967. wechat: customer.wechat || '',
  1968. customerType: customer.customerType || '新客户',
  1969. source: customer.source || '',
  1970. remark: customer.remark || ''
  1971. });
  1972. this.customerSearchResults = [];
  1973. this.customerSearchKeyword = '';
  1974. }
  1975. clearSelectedCustomer(): void {
  1976. this.selectedOrderCustomer = null;
  1977. this.customerForm.reset({ customerType: '新客户' });
  1978. }
  1979. quickFillCustomerInfo(keyword: string): void {
  1980. const k = (keyword || '').trim();
  1981. if (!k) return;
  1982. // 模拟:若有搜索结果,选择第一条
  1983. if (this.customerSearchResults.length === 0) this.searchCustomer();
  1984. if (this.customerSearchResults.length > 0) {
  1985. this.selectCustomer(this.customerSearchResults[0]);
  1986. }
  1987. }
  1988. syncMiniprogramCustomerInfo(): void {
  1989. if (this.isSyncing) return;
  1990. this.isSyncing = true;
  1991. setTimeout(() => {
  1992. // 模拟从小程序同步到客户表单
  1993. this.customerForm.patchValue({
  1994. name: '小程序用户',
  1995. phone: '13800001234',
  1996. wechat: 'wx_user_001',
  1997. customerType: '新客户',
  1998. source: '小程序下单'
  1999. });
  2000. this.isSyncing = false;
  2001. // 触发客户信息同步显示
  2002. this.syncCustomerInfoDisplay();
  2003. }, 1000);
  2004. }
  2005. // 同步客户信息显示
  2006. syncCustomerInfoDisplay(): void {
  2007. this.isSyncingCustomerInfo = true;
  2008. // 模拟同步过程
  2009. setTimeout(() => {
  2010. this.lastSyncTime = new Date();
  2011. this.isSyncingCustomerInfo = false;
  2012. // 触发界面更新
  2013. this.cdr.detectChanges();
  2014. console.log('客户信息显示已同步:', this.lastSyncTime);
  2015. }, 800);
  2016. }
  2017. // 启动自动同步
  2018. startAutoSync(): void {
  2019. if (this.syncInterval) {
  2020. clearInterval(this.syncInterval);
  2021. }
  2022. // 每30秒自动同步一次
  2023. this.syncInterval = setInterval(() => {
  2024. this.syncCustomerInfoDisplay();
  2025. }, 30000);
  2026. }
  2027. // 停止自动同步
  2028. stopAutoSync(): void {
  2029. if (this.syncInterval) {
  2030. clearInterval(this.syncInterval);
  2031. this.syncInterval = null;
  2032. }
  2033. }
  2034. // 格式化时间显示
  2035. formatTime(date: Date): string {
  2036. const now = new Date();
  2037. const diff = now.getTime() - date.getTime();
  2038. const minutes = Math.floor(diff / 60000);
  2039. if (minutes < 1) {
  2040. return '刚刚';
  2041. } else if (minutes < 60) {
  2042. return `${minutes}分钟前`;
  2043. } else {
  2044. const hours = Math.floor(minutes / 60);
  2045. return `${hours}小时前`;
  2046. }
  2047. }
  2048. downloadFile(file: ProjectFile): void {
  2049. // 实现文件下载逻辑
  2050. const link = document.createElement('a');
  2051. link.href = file.url;
  2052. link.download = file.name;
  2053. link.click();
  2054. }
  2055. previewFile(file: ProjectFile): void {
  2056. // 预览文件逻辑
  2057. console.log('预览文件:', file.name);
  2058. }
  2059. // 同步需求关键信息到客户信息卡片
  2060. syncRequirementKeyInfo(requirementData: any): void {
  2061. if (requirementData) {
  2062. // 同步色彩氛围信息
  2063. if (requirementData.colorIndicators) {
  2064. this.requirementKeyInfo.colorAtmosphere = {
  2065. description: requirementData.colorIndicators.colorRange || '',
  2066. mainColor: `rgb(${requirementData.colorIndicators.mainColor?.r || 0}, ${requirementData.colorIndicators.mainColor?.g || 0}, ${requirementData.colorIndicators.mainColor?.b || 0})`,
  2067. colorTemp: `${requirementData.colorIndicators.colorTemperature || 0}K`,
  2068. materials: []
  2069. };
  2070. }
  2071. // 同步空间结构信息
  2072. if (requirementData.spaceIndicators) {
  2073. this.requirementKeyInfo.spaceStructure = {
  2074. lineRatio: requirementData.spaceIndicators.lineRatio || 0,
  2075. blankRatio: requirementData.spaceIndicators.blankRatio || 0,
  2076. flowWidth: requirementData.spaceIndicators.flowWidth || 0,
  2077. aspectRatio: requirementData.spaceIndicators.aspectRatio || 0,
  2078. ceilingHeight: requirementData.spaceIndicators.ceilingHeight || 0
  2079. };
  2080. }
  2081. // 同步材质权重信息
  2082. if (requirementData.materialIndicators) {
  2083. this.requirementKeyInfo.materialWeights = {
  2084. fabricRatio: requirementData.materialIndicators.fabricRatio || 0,
  2085. woodRatio: requirementData.materialIndicators.woodRatio || 0,
  2086. metalRatio: requirementData.materialIndicators.metalRatio || 0,
  2087. smoothness: requirementData.materialIndicators.smoothness || 0,
  2088. glossiness: requirementData.materialIndicators.glossiness || 0
  2089. };
  2090. }
  2091. // 同步预设氛围信息
  2092. if (requirementData.selectedPresetAtmosphere) {
  2093. this.requirementKeyInfo.presetAtmosphere = {
  2094. name: requirementData.selectedPresetAtmosphere.name || '',
  2095. rgb: requirementData.selectedPresetAtmosphere.rgb || '',
  2096. colorTemp: requirementData.selectedPresetAtmosphere.colorTemp || '',
  2097. materials: requirementData.selectedPresetAtmosphere.materials || []
  2098. };
  2099. }
  2100. // 新增:实时更新左侧客户信息显示
  2101. if (this.project) {
  2102. // 更新项目的客户信息
  2103. if (requirementData.colorIndicators && requirementData.colorIndicators.length > 0) {
  2104. this.project.customerInfo = {
  2105. ...this.project.customerInfo,
  2106. colorPreference: requirementData.colorIndicators.map((indicator: any) => indicator.name).join(', ')
  2107. };
  2108. }
  2109. // 更新空间结构信息
  2110. if (requirementData.spaceIndicators && requirementData.spaceIndicators.length > 0) {
  2111. this.project.customerInfo = {
  2112. ...this.project.customerInfo,
  2113. spaceRequirements: requirementData.spaceIndicators.map((indicator: any) => `${indicator.name}: ${indicator.value}`).join(', ')
  2114. };
  2115. }
  2116. // 更新材质偏好
  2117. if (requirementData.materialIndicators && requirementData.materialIndicators.length > 0) {
  2118. this.project.customerInfo = {
  2119. ...this.project.customerInfo,
  2120. materialPreference: requirementData.materialIndicators.map((indicator: any) => `${indicator.name}: ${indicator.value}%`).join(', ')
  2121. };
  2122. }
  2123. // 触发变更检测以更新UI
  2124. this.cdr.detectChanges();
  2125. }
  2126. console.log('需求关键信息已同步:', this.requirementKeyInfo);
  2127. } else {
  2128. // 模拟数据用于演示
  2129. this.requirementKeyInfo = {
  2130. colorAtmosphere: {
  2131. description: '温馨暖调',
  2132. mainColor: 'rgb(255, 230, 180)',
  2133. colorTemp: '2700K',
  2134. materials: ['木质', '布艺']
  2135. },
  2136. spaceStructure: {
  2137. lineRatio: 60,
  2138. blankRatio: 30,
  2139. flowWidth: 0.9,
  2140. aspectRatio: 1.6,
  2141. ceilingHeight: 2.8
  2142. },
  2143. materialWeights: {
  2144. fabricRatio: 50,
  2145. woodRatio: 30,
  2146. metalRatio: 20,
  2147. smoothness: 7,
  2148. glossiness: 4
  2149. },
  2150. presetAtmosphere: {
  2151. name: '现代简约',
  2152. rgb: '200,220,240',
  2153. colorTemp: '5000K',
  2154. materials: ['金属', '玻璃']
  2155. }
  2156. };
  2157. }
  2158. }
  2159. // 新增:处理需求阶段完成事件
  2160. onRequirementsStageCompleted(event: { stage: string; allStagesCompleted: boolean }): void {
  2161. console.log('需求阶段完成事件:', event);
  2162. if (event.allStagesCompleted && event.stage === 'requirements-communication') {
  2163. // 自动推进到方案确认阶段
  2164. this.currentStage = '方案确认';
  2165. this.expandedStages['方案确认'] = true;
  2166. this.expandedStages['需求沟通'] = false;
  2167. // 更新项目状态
  2168. this.updateProjectStage('方案确认');
  2169. console.log('自动推进到方案确认阶段');
  2170. }
  2171. }
  2172. // 新增:确认方案方法
  2173. confirmProposal(): void {
  2174. console.log('确认方案按钮被点击');
  2175. // 使用统一的阶段推进方法
  2176. this.advanceToNextStage('方案确认');
  2177. console.log('已跳转到建模阶段');
  2178. }
  2179. // 获取同步的关键信息摘要
  2180. getRequirementSummary(): string[] {
  2181. const summary: string[] = [];
  2182. if (this.requirementKeyInfo.colorAtmosphere.description) {
  2183. summary.push(`色彩氛围: ${this.requirementKeyInfo.colorAtmosphere.description}`);
  2184. }
  2185. if (this.requirementKeyInfo.spaceStructure.aspectRatio > 0) {
  2186. summary.push(`空间比例: ${this.requirementKeyInfo.spaceStructure.aspectRatio.toFixed(1)}`);
  2187. }
  2188. if (this.requirementKeyInfo.materialWeights.woodRatio > 0) {
  2189. summary.push(`木质占比: ${this.requirementKeyInfo.materialWeights.woodRatio}%`);
  2190. }
  2191. if (this.requirementKeyInfo.presetAtmosphere.name) {
  2192. summary.push(`预设氛围: ${this.requirementKeyInfo.presetAtmosphere.name}`);
  2193. }
  2194. return summary;
  2195. }
  2196. // 检查必需阶段是否全部完成(流程进度 > 确认需求 > 需求沟通四个流程)
  2197. areRequiredStagesCompleted(): boolean {
  2198. // 检查项目是否已经进入方案确认阶段或更后的阶段
  2199. if (!this.project) {
  2200. return false;
  2201. }
  2202. const stageOrder = [
  2203. '订单分配', '需求沟通', '方案确认', '建模', '软装',
  2204. '渲染', '尾款结算', '客户评价', '投诉处理'
  2205. ];
  2206. const currentStageIndex = stageOrder.indexOf(this.project.currentStage);
  2207. const proposalStageIndex = stageOrder.indexOf('方案确认');
  2208. const requirementStageIndex = stageOrder.indexOf('需求沟通');
  2209. // 如果当前阶段是方案确认或之后的阶段,则认为需求阶段已完成
  2210. if (currentStageIndex >= proposalStageIndex) {
  2211. // 确保有基本的需求信息数据,如果没有则初始化模拟数据
  2212. this.ensureRequirementData();
  2213. return true;
  2214. }
  2215. // 如果当前阶段是需求沟通,检查需求沟通是否已完成
  2216. if (currentStageIndex === requirementStageIndex) {
  2217. // 检查需求关键信息是否有数据,或者检查需求沟通组件的完成状态
  2218. const hasRequirementData = this.getRequirementSummary().length > 0 &&
  2219. (!!this.requirementKeyInfo.colorAtmosphere.description ||
  2220. this.requirementKeyInfo.spaceStructure.aspectRatio > 0 ||
  2221. this.requirementKeyInfo.materialWeights.woodRatio > 0 ||
  2222. !!this.requirementKeyInfo.presetAtmosphere.name);
  2223. // 只有在真正有需求数据时才返回true,不再自动初始化模拟数据
  2224. if (hasRequirementData) {
  2225. return true;
  2226. }
  2227. // 如果没有需求数据,返回false,不允许进入下一阶段
  2228. return false;
  2229. }
  2230. // 其他情况返回false
  2231. return false;
  2232. }
  2233. // 确保有需求数据用于方案确认显示
  2234. private ensureRequirementData(): void {
  2235. // console.log('=== ensureRequirementData 开始确保需求数据 ===');
  2236. // console.log('当前requirementKeyInfo:', this.requirementKeyInfo);
  2237. // 修复条件判断:检查是否需要初始化数据
  2238. const needsInitialization =
  2239. !this.requirementKeyInfo.colorAtmosphere.description ||
  2240. this.requirementKeyInfo.spaceStructure.aspectRatio === 0 ||
  2241. this.requirementKeyInfo.materialWeights.woodRatio === 0 ||
  2242. !this.requirementKeyInfo.presetAtmosphere.name;
  2243. console.log('是否需要初始化数据:', needsInitialization);
  2244. if (needsInitialization) {
  2245. console.log('需求关键信息为空,初始化默认数据');
  2246. // 初始化模拟的需求数据
  2247. this.requirementKeyInfo = {
  2248. colorAtmosphere: {
  2249. description: '现代简约风格,以白色和灰色为主调',
  2250. mainColor: '#F5F5F5',
  2251. colorTemp: '冷色调',
  2252. materials: ['木质', '金属', '玻璃']
  2253. },
  2254. spaceStructure: {
  2255. lineRatio: 0.6,
  2256. blankRatio: 0.4,
  2257. flowWidth: 1.2,
  2258. aspectRatio: 1.8,
  2259. ceilingHeight: 2.8
  2260. },
  2261. materialWeights: {
  2262. fabricRatio: 20,
  2263. woodRatio: 45,
  2264. metalRatio: 25,
  2265. smoothness: 0.7,
  2266. glossiness: 0.3
  2267. },
  2268. presetAtmosphere: {
  2269. name: '现代简约',
  2270. rgb: '#F5F5F5',
  2271. colorTemp: '5000K',
  2272. materials: ['木质', '金属']
  2273. }
  2274. };
  2275. // console.log('初始化后的requirementKeyInfo:', this.requirementKeyInfo);
  2276. } else {
  2277. // console.log('需求关键信息已存在,无需初始化');
  2278. }
  2279. }
  2280. // 获取项目状态文本
  2281. getProjectStatusText(): string {
  2282. const current = (this.currentStage || this.project?.currentStage) as ProjectStage | undefined;
  2283. if (!current || current === '订单分配') {
  2284. return '待开始';
  2285. }
  2286. // 检查是否已完成所有阶段
  2287. const allStages: ProjectStage[] = ['订单分配', '需求沟通', '方案确认', '建模', '软装', '渲染', '尾款结算', '客户评价', '投诉处理'];
  2288. const currentIndex = allStages.indexOf(current);
  2289. if (currentIndex === allStages.length - 1) {
  2290. return '已完成';
  2291. }
  2292. return '进行中';
  2293. }
  2294. // 获取当前阶段文本
  2295. getCurrentStageText(): string {
  2296. const current = (this.currentStage || this.project?.currentStage) as ProjectStage | undefined;
  2297. if (!current || current === '订单分配') {
  2298. return '订单分配阶段';
  2299. }
  2300. return `${current}阶段`;
  2301. }
  2302. // 获取整体进度百分比
  2303. getOverallProgress(): number {
  2304. const current = (this.currentStage || this.project?.currentStage) as ProjectStage | undefined;
  2305. if (!current) {
  2306. return 0;
  2307. }
  2308. // 定义所有阶段及其权重
  2309. const stageWeights: Record<ProjectStage, number> = {
  2310. '订单分配': 5,
  2311. '需求沟通': 15,
  2312. '方案确认': 25,
  2313. '建模': 40,
  2314. '软装': 55,
  2315. '渲染': 70,
  2316. '后期': 80,
  2317. '尾款结算': 90,
  2318. '客户评价': 95,
  2319. '投诉处理': 100
  2320. };
  2321. return stageWeights[current] || 0;
  2322. }
  2323. // 获取必需阶段的完成进度百分比
  2324. getRequiredStagesProgress(): number {
  2325. let completedCount = 0;
  2326. const totalCount = 4; // 四个必需流程
  2327. // 检查各个关键信息是否已确认
  2328. if (this.requirementKeyInfo.colorAtmosphere.description) completedCount++;
  2329. if (this.requirementKeyInfo.spaceStructure.aspectRatio > 0) completedCount++;
  2330. if (this.requirementKeyInfo.materialWeights.woodRatio > 0 ||
  2331. this.requirementKeyInfo.materialWeights.fabricRatio > 0 ||
  2332. this.requirementKeyInfo.materialWeights.metalRatio > 0) completedCount++;
  2333. if (this.requirementKeyInfo.presetAtmosphere.name) completedCount++;
  2334. return Math.round((completedCount / totalCount) * 100);
  2335. }
  2336. // 订单金额
  2337. orderAmount: number = 0;
  2338. // 报价明细
  2339. quotationDetails: Array<{
  2340. id: string;
  2341. room: string;
  2342. amount: number;
  2343. description?: string;
  2344. }> = [];
  2345. // AI生成报价明细
  2346. generateQuotationDetails(): void {
  2347. // 基于项目信息生成报价明细
  2348. const rooms = ['客餐厅', '主卧', '次卧', '厨房', '卫生间'];
  2349. this.quotationDetails = rooms.map((room, index) => ({
  2350. id: `quote_${index + 1}`,
  2351. room: room,
  2352. amount: Math.floor(Math.random() * 1000) + 300, // 示例金额
  2353. description: `${room}装修设计费用`
  2354. }));
  2355. // 更新总订单金额
  2356. this.orderAmount = this.quotationDetails.reduce((total, item) => total + item.amount, 0);
  2357. }
  2358. // 添加报价明细项
  2359. addQuotationItem(): void {
  2360. this.quotationDetails.push({
  2361. id: `quote_${Date.now()}`,
  2362. room: '',
  2363. amount: 0,
  2364. description: ''
  2365. });
  2366. }
  2367. // 删除报价明细项
  2368. removeQuotationItem(id: string): void {
  2369. this.quotationDetails = this.quotationDetails.filter(item => item.id !== id);
  2370. this.updateOrderAmount();
  2371. }
  2372. // 更新订单总金额
  2373. updateOrderAmount(): void {
  2374. this.orderAmount = this.quotationDetails.reduce((total, item) => total + item.amount, 0);
  2375. }
  2376. // 报价组件数据
  2377. quotationData: QuotationData = {
  2378. items: [],
  2379. totalAmount: 0,
  2380. materialCost: 0,
  2381. laborCost: 0,
  2382. designFee: 0,
  2383. managementFee: 0
  2384. };
  2385. // 设计师指派数据
  2386. designerAssignmentData?: DesignerAssignmentData;
  2387. // 设计师日历弹窗状态与数据
  2388. showDesignerCalendar: boolean = false;
  2389. selectedCalendarDate: Date = new Date();
  2390. calendarDesigners: CalendarDesigner[] = [];
  2391. calendarGroups: CalendarProjectGroup[] = [];
  2392. onQuotationDataChange(data: QuotationData): void {
  2393. this.quotationData = { ...data };
  2394. this.orderAmount = data.totalAmount || 0;
  2395. }
  2396. onDesignerAssignmentChange(data: DesignerAssignmentData): void {
  2397. this.designerAssignmentData = { ...data };
  2398. }
  2399. onDesignerClick(designer: AssignmentDesigner): void {
  2400. const mapped = this.mapAssignmentDesignerToCalendar(designer);
  2401. this.calendarDesigners = [mapped];
  2402. this.calendarGroups = [{ id: designer.teamId, name: designer.teamName, leaderId: designer.id, memberIds: [designer.id] }];
  2403. this.selectedCalendarDate = new Date();
  2404. this.showDesignerCalendar = true;
  2405. }
  2406. closeDesignerCalendar(): void {
  2407. this.showDesignerCalendar = false;
  2408. }
  2409. onCalendarDesignerSelected(designer: CalendarDesigner): void {
  2410. this.selectedDesigner = designer;
  2411. this.closeDesignerCalendar();
  2412. }
  2413. onCalendarAssignmentRequested(designer: CalendarDesigner): void {
  2414. this.selectedDesigner = designer;
  2415. this.closeDesignerCalendar();
  2416. }
  2417. private mapAssignmentDesignerToCalendar(d: AssignmentDesigner): CalendarDesigner {
  2418. return {
  2419. id: d.id,
  2420. name: d.name,
  2421. avatar: d.avatar,
  2422. groupId: d.teamId,
  2423. groupName: d.teamName,
  2424. isLeader: !!d.isTeamLeader,
  2425. status: d.status === 'idle' ? 'available' : 'busy',
  2426. currentProjects: Math.max(0, d.recentOrders || 0),
  2427. lastOrderDate: d.lastOrderDate,
  2428. idleDays: Math.max(0, d.idleDays || 0),
  2429. completedThisMonth: Math.max(0, d.recentOrders || 0),
  2430. averageCycle: 15,
  2431. upcomingEvents: (d.reviewDates || []).map((dateStr, idx) => ({
  2432. id: `${d.id}-review-${idx}`,
  2433. date: new Date(dateStr),
  2434. title: '对图评审',
  2435. type: 'review',
  2436. projectId: undefined,
  2437. duration: 2
  2438. })),
  2439. workload: Math.max(0, d.workload || 0),
  2440. nextAvailableDate: new Date()
  2441. };
  2442. }
  2443. // 处理咨询订单表单提交
  2444. // 存储订单分配时的客户信息和需求信息
  2445. onConsultationOrderSubmit(formData: any): void {
  2446. console.log('咨询订单表单提交:', formData);
  2447. // 保存订单分配数据
  2448. this.orderCreationData = formData;
  2449. // 更新projectData以便传递给子组件(集成报价与指派信息)
  2450. this.projectData = {
  2451. customerInfo: formData.customerInfo,
  2452. requirementInfo: formData.requirementInfo,
  2453. preferenceTags: formData.preferenceTags,
  2454. quotation: this.quotationData ? { ...this.quotationData } : undefined,
  2455. assignment: this.designerAssignmentData ? { ...this.designerAssignmentData } : undefined,
  2456. orderAmount: this.quotationData?.totalAmount ?? this.orderAmount ?? 0
  2457. };
  2458. // 实时更新左侧客户信息显示
  2459. this.updateCustomerInfoDisplay(formData);
  2460. // 根据角色上下文处理数据同步
  2461. if (formData.roleContext === 'customer-service') {
  2462. // 客服端创建的订单需要同步到设计师端
  2463. this.syncOrderToDesignerView(formData);
  2464. }
  2465. // 根据报价数据更新订单金额
  2466. this.orderAmount = this.quotationData?.totalAmount ?? this.orderAmount ?? 0;
  2467. this.updateOrderAmount();
  2468. // 触发变更检测以更新UI
  2469. this.cdr.detectChanges();
  2470. }
  2471. // 新增:更新客户信息显示 - 优化后只更新实际存在的字段
  2472. private updateCustomerInfoDisplay(formData: any): void {
  2473. if (formData.customerInfo) {
  2474. // 更新项目对象中的客户信息 - 只更新实际存在的字段
  2475. if (this.project) {
  2476. // 由于已移除客户姓名和手机号字段,只更新微信和客户类型
  2477. if (formData.customerInfo.wechat) {
  2478. this.project.customerWechat = formData.customerInfo.wechat;
  2479. }
  2480. if (formData.customerInfo.customerType) {
  2481. this.project.customerType = formData.customerInfo.customerType;
  2482. }
  2483. if (formData.customerInfo.source) {
  2484. this.project.customerSource = formData.customerInfo.source;
  2485. }
  2486. if (formData.customerInfo.remark) {
  2487. this.project.customerRemark = formData.customerInfo.remark;
  2488. }
  2489. }
  2490. // 更新客户标签
  2491. if (formData.preferenceTags) {
  2492. this.project = {
  2493. ...this.project,
  2494. customerTags: formData.preferenceTags
  2495. } as any;
  2496. }
  2497. // 更新需求信息 - 只更新实际存在的字段
  2498. if (formData.requirementInfo) {
  2499. this.project = {
  2500. ...this.project,
  2501. // 移除已删除的字段:decorationType, firstDraftDate, style, budget, area, houseType
  2502. downPayment: formData.requirementInfo.downPayment,
  2503. smallImageTime: formData.requirementInfo.smallImageTime,
  2504. spaceRequirements: formData.requirementInfo.spaceRequirements,
  2505. designAngles: formData.requirementInfo.designAngles,
  2506. specialAreaHandling: formData.requirementInfo.specialAreaHandling,
  2507. materialRequirements: formData.requirementInfo.materialRequirements,
  2508. lightingRequirements: formData.requirementInfo.lightingRequirements
  2509. } as any;
  2510. }
  2511. console.log('客户信息已实时更新:', this.project);
  2512. }
  2513. }
  2514. // 新增:同步订单数据到设计师视图
  2515. private syncOrderToDesignerView(formData: any): void {
  2516. // 创建项目数据
  2517. const projectData = {
  2518. customerId: formData.customerInfo.id || 'customer-' + Date.now(),
  2519. customerName: formData.customerInfo.name,
  2520. requirement: formData.requirementInfo,
  2521. referenceCases: [],
  2522. tags: {
  2523. demandType: formData.customerInfo.demandType,
  2524. preferenceTags: formData.preferenceTags,
  2525. followUpStatus: formData.customerInfo.followUpStatus
  2526. },
  2527. // 新增:报价与指派信息(可选)
  2528. quotation: this.quotationData ? { ...this.quotationData } : undefined,
  2529. assignment: this.designerAssignmentData ? { ...this.designerAssignmentData } : undefined,
  2530. orderAmount: this.quotationData?.totalAmount ?? this.orderAmount ?? 0
  2531. };
  2532. // 调用项目服务创建项目
  2533. this.projectService.createProject(projectData).subscribe(
  2534. result => {
  2535. if (result.success) {
  2536. console.log('订单数据已同步到设计师端,项目ID:', result.projectId);
  2537. // 可以在这里添加成功提示或其他处理逻辑
  2538. }
  2539. },
  2540. error => {
  2541. console.error('同步订单数据到设计师端失败:', error);
  2542. }
  2543. );
  2544. }
  2545. // 确认团队分配
  2546. confirmTeamAssignment(designer: any): void {
  2547. if (designer) {
  2548. this.selectedDesigner = designer;
  2549. console.log('团队分配确认:', designer);
  2550. // 这里可以添加实际的团队分配逻辑
  2551. // 例如调用服务来分配设计师到项目
  2552. // 进入下一个阶段:需求沟通
  2553. this.updateProjectStage('需求沟通');
  2554. this.expandedStages['需求沟通'] = true;
  2555. this.expandedStages['订单分配'] = false;
  2556. // 显示成功消息
  2557. alert('团队分配成功!已进入需求沟通阶段');
  2558. console.log('团队分配完成,已跳转到需求沟通阶段');
  2559. }
  2560. }
  2561. // 项目创建完成事件处理
  2562. onProjectCreated(projectData: any): void {
  2563. console.log('项目创建完成:', projectData);
  2564. this.projectData = projectData;
  2565. // 团队分配已在子组件中完成并触发该事件:推进到需求沟通阶段
  2566. this.updateProjectStage('需求沟通');
  2567. // 更新项目对象的当前阶段,确保四大板块状态正确显示
  2568. if (this.project) {
  2569. this.project.currentStage = '需求沟通';
  2570. }
  2571. // 展开需求沟通阶段,收起订单分配阶段
  2572. this.expandedStages['需求沟通'] = true;
  2573. this.expandedStages['订单分配'] = false;
  2574. // 自动展开确认需求板块
  2575. this.expandedSection = 'requirements';
  2576. // 强制触发变更检测,确保UI更新
  2577. this.cdr.detectChanges();
  2578. // 延迟滚动到需求沟通阶段,确保DOM更新完成
  2579. setTimeout(() => {
  2580. this.scrollToStage('需求沟通');
  2581. // 再次触发变更检测,确保所有状态都已正确更新
  2582. this.cdr.detectChanges();
  2583. }, 100);
  2584. console.log('项目创建成功,已推进到需求沟通阶段,四大板块状态已更新');
  2585. }
  2586. // 新增:处理实时需求数据更新
  2587. onRequirementDataUpdated(data: any): void {
  2588. console.log('收到需求数据更新:', data);
  2589. // 同步关键信息
  2590. this.syncRequirementKeyInfo(data);
  2591. // 更新客户信息显示
  2592. if (data && this.project) {
  2593. // 更新项目的客户信息
  2594. if (data.colorIndicators && data.colorIndicators.length > 0) {
  2595. this.project.customerInfo = {
  2596. ...this.project.customerInfo,
  2597. colorPreference: data.colorIndicators.map((indicator: any) => indicator.name).join(', ')
  2598. };
  2599. }
  2600. // 更新空间结构信息
  2601. if (data.spaceIndicators && data.spaceIndicators.length > 0) {
  2602. this.project.customerInfo = {
  2603. ...this.project.customerInfo,
  2604. spaceRequirements: data.spaceIndicators.map((indicator: any) => `${indicator.name}: ${indicator.value}`).join(', ')
  2605. };
  2606. }
  2607. // 更新材质偏好
  2608. if (data.materialIndicators && data.materialIndicators.length > 0) {
  2609. this.project.customerInfo = {
  2610. ...this.project.customerInfo,
  2611. materialPreference: data.materialIndicators.map((indicator: any) => `${indicator.name}: ${indicator.value}%`).join(', ')
  2612. };
  2613. }
  2614. // 更新需求项目
  2615. if (data.requirementItems && data.requirementItems.length > 0) {
  2616. this.project.requirements = data.requirementItems.map((item: any) => ({
  2617. id: item.id,
  2618. description: item.description,
  2619. status: item.status,
  2620. priority: item.priority || 'medium'
  2621. }));
  2622. }
  2623. // 接收色彩分析结果并存储用于右侧展示
  2624. if (data.colorAnalysisResult) {
  2625. console.log('接收到色彩分析结果:', data.colorAnalysisResult);
  2626. this.colorAnalysisResult = data.colorAnalysisResult as ColorAnalysisResult;
  2627. console.log('设置colorAnalysisResult后:', this.colorAnalysisResult);
  2628. // 计算主色:按占比最高的颜色
  2629. const colors = this.colorAnalysisResult?.colors || [];
  2630. if (colors.length > 0) {
  2631. const dominant = colors.reduce((max, cur) => cur.percentage > max.percentage ? cur : max, colors[0]);
  2632. this.dominantColorHex = dominant.hex;
  2633. console.log('计算出的主色:', this.dominantColorHex);
  2634. } else {
  2635. this.dominantColorHex = null;
  2636. console.log('没有颜色数据,主色设为null');
  2637. }
  2638. } else {
  2639. console.log('没有接收到色彩分析结果');
  2640. }
  2641. // 新增:处理详细的分析数据
  2642. if (data.detailedAnalysis) {
  2643. console.log('接收到详细分析数据:', data.detailedAnalysis);
  2644. // 存储各类分析结果
  2645. this.enhancedColorAnalysis = data.detailedAnalysis.enhancedColorAnalysis;
  2646. this.formAnalysis = data.detailedAnalysis.formAnalysis;
  2647. this.textureAnalysis = data.detailedAnalysis.textureAnalysis;
  2648. this.patternAnalysis = data.detailedAnalysis.patternAnalysis;
  2649. this.lightingAnalysis = data.detailedAnalysis.lightingAnalysis;
  2650. console.log('详细分析数据已存储:', {
  2651. enhancedColorAnalysis: this.enhancedColorAnalysis,
  2652. formAnalysis: this.formAnalysis,
  2653. textureAnalysis: this.textureAnalysis,
  2654. patternAnalysis: this.patternAnalysis,
  2655. lightingAnalysis: this.lightingAnalysis
  2656. });
  2657. }
  2658. // 新增:处理材料分析数据
  2659. if (data.materialAnalysisData && data.materialAnalysisData.length > 0) {
  2660. console.log('接收到材料分析数据:', data.materialAnalysisData);
  2661. this.materialAnalysisData = data.materialAnalysisData;
  2662. }
  2663. // 新增:根据上传来源拆分材料文件用于左右区展示
  2664. const materials = Array.isArray(data?.materials) ? data.materials : [];
  2665. this.referenceImages = materials.filter((m: any) => m?.type === 'image');
  2666. this.cadFiles = materials.filter((m: any) => m?.type === 'cad');
  2667. // 触发变更检测以更新UI
  2668. this.cdr.detectChanges();
  2669. console.log('客户信息已实时更新,当前colorAnalysisResult状态:', !!this.colorAnalysisResult);
  2670. }
  2671. }
  2672. // 预览右侧色彩分析参考图
  2673. previewColorRefImage(): void {
  2674. const url = this.colorAnalysisResult?.originalImage;
  2675. if (url) {
  2676. window.open(url, '_blank');
  2677. }
  2678. }
  2679. // 新增:点击预览参考图片与CAD文件
  2680. previewImageFile(url?: string): void {
  2681. if (!url) return;
  2682. window.open(url, '_blank');
  2683. }
  2684. previewCadFile(url?: string): void {
  2685. if (!url) return;
  2686. window.open(url, '_blank');
  2687. }
  2688. // 切换客户信息卡片展开状态
  2689. toggleCustomerInfo(): void {
  2690. this.isCustomerInfoExpanded = !this.isCustomerInfoExpanded;
  2691. }
  2692. // 新增:重置方案分析状态的方法
  2693. resetProposalAnalysis(): void {
  2694. this.proposalAnalysis = null;
  2695. this.isAnalyzing = false;
  2696. this.analysisProgress = 0;
  2697. console.log('方案分析状态已重置');
  2698. }
  2699. // 新增:模拟素材解析方法
  2700. startMaterialAnalysis(): void {
  2701. this.isAnalyzing = true;
  2702. this.analysisProgress = 0;
  2703. const progressInterval = setInterval(() => {
  2704. this.analysisProgress += Math.random() * 15;
  2705. if (this.analysisProgress >= 100) {
  2706. this.analysisProgress = 100;
  2707. clearInterval(progressInterval);
  2708. this.completeMaterialAnalysis();
  2709. }
  2710. }, 500);
  2711. }
  2712. // 完成素材解析,生成方案数据
  2713. private completeMaterialAnalysis(): void {
  2714. this.isAnalyzing = false;
  2715. // 生成模拟的方案分析数据
  2716. this.proposalAnalysis = {
  2717. id: 'proposal-' + Date.now(),
  2718. name: '现代简约风格方案',
  2719. version: 'v1.0',
  2720. createdAt: new Date(),
  2721. status: 'completed',
  2722. materials: [
  2723. {
  2724. category: '地面材料',
  2725. specifications: {
  2726. type: '复合木地板',
  2727. grade: 'E0级',
  2728. thickness: '12mm',
  2729. finish: '哑光面',
  2730. durability: '家用33级'
  2731. },
  2732. usage: {
  2733. area: '客厅、卧室',
  2734. percentage: 65,
  2735. priority: 'primary'
  2736. },
  2737. properties: {
  2738. texture: '木纹理',
  2739. color: '浅橡木色',
  2740. maintenance: '日常清洁'
  2741. }
  2742. },
  2743. {
  2744. category: '墙面材料',
  2745. specifications: {
  2746. type: '乳胶漆',
  2747. grade: '净味抗甲醛',
  2748. finish: '丝光面',
  2749. durability: '15年'
  2750. },
  2751. usage: {
  2752. area: '全屋墙面',
  2753. percentage: 80,
  2754. priority: 'primary'
  2755. },
  2756. properties: {
  2757. texture: '平滑',
  2758. color: '暖白色',
  2759. maintenance: '可擦洗'
  2760. }
  2761. },
  2762. {
  2763. category: '软装面料',
  2764. specifications: {
  2765. type: '亚麻混纺',
  2766. grade: 'A级',
  2767. finish: '防污处理',
  2768. durability: '5-8年'
  2769. },
  2770. usage: {
  2771. area: '沙发、窗帘',
  2772. percentage: 25,
  2773. priority: 'secondary'
  2774. },
  2775. properties: {
  2776. texture: '自然纹理',
  2777. color: '米灰色系',
  2778. maintenance: '干洗'
  2779. }
  2780. }
  2781. ],
  2782. designStyle: {
  2783. primaryStyle: '现代简约',
  2784. styleElements: [
  2785. {
  2786. element: '线条设计',
  2787. description: '简洁流畅的直线条,避免繁复装饰',
  2788. influence: 85
  2789. },
  2790. {
  2791. element: '色彩搭配',
  2792. description: '以中性色为主,局部点缀暖色',
  2793. influence: 75
  2794. },
  2795. {
  2796. element: '材质选择',
  2797. description: '天然材质与现代工艺结合',
  2798. influence: 70
  2799. }
  2800. ],
  2801. characteristics: [
  2802. {
  2803. feature: '空间感',
  2804. value: '开放通透',
  2805. importance: 'high'
  2806. },
  2807. {
  2808. feature: '功能性',
  2809. value: '实用至上',
  2810. importance: 'high'
  2811. },
  2812. {
  2813. feature: '装饰性',
  2814. value: '简约精致',
  2815. importance: 'medium'
  2816. }
  2817. ],
  2818. compatibility: {
  2819. withMaterials: ['木材', '金属', '玻璃', '石材'],
  2820. withColors: ['白色', '灰色', '米色', '原木色'],
  2821. score: 92
  2822. }
  2823. },
  2824. colorScheme: {
  2825. palette: [
  2826. {
  2827. color: '暖白色',
  2828. hex: '#F8F6F0',
  2829. rgb: '248, 246, 240',
  2830. percentage: 45,
  2831. role: 'dominant'
  2832. },
  2833. {
  2834. color: '浅灰色',
  2835. hex: '#E5E5E5',
  2836. rgb: '229, 229, 229',
  2837. percentage: 30,
  2838. role: 'secondary'
  2839. },
  2840. {
  2841. color: '原木色',
  2842. hex: '#D4A574',
  2843. rgb: '212, 165, 116',
  2844. percentage: 20,
  2845. role: 'accent'
  2846. },
  2847. {
  2848. color: '深灰色',
  2849. hex: '#4A4A4A',
  2850. rgb: '74, 74, 74',
  2851. percentage: 5,
  2852. role: 'neutral'
  2853. }
  2854. ],
  2855. harmony: {
  2856. type: '类似色调和',
  2857. temperature: 'warm',
  2858. contrast: 65
  2859. },
  2860. psychology: {
  2861. mood: '宁静舒适',
  2862. atmosphere: '温馨自然',
  2863. suitability: ['居住', '办公', '休闲']
  2864. }
  2865. },
  2866. spaceLayout: {
  2867. dimensions: {
  2868. length: 12.5,
  2869. width: 8.2,
  2870. height: 2.8,
  2871. area: 102.5,
  2872. volume: 287
  2873. },
  2874. functionalZones: [
  2875. {
  2876. zone: '客厅区域',
  2877. area: 35.2,
  2878. percentage: 34.3,
  2879. requirements: ['会客', '娱乐', '休息'],
  2880. furniture: ['沙发', '茶几', '电视柜', '边几']
  2881. },
  2882. {
  2883. zone: '餐厅区域',
  2884. area: 18.5,
  2885. percentage: 18.0,
  2886. requirements: ['用餐', '储物'],
  2887. furniture: ['餐桌', '餐椅', '餐边柜']
  2888. },
  2889. {
  2890. zone: '厨房区域',
  2891. area: 12.8,
  2892. percentage: 12.5,
  2893. requirements: ['烹饪', '储存', '清洁'],
  2894. furniture: ['橱柜', '岛台', '吧台椅']
  2895. },
  2896. {
  2897. zone: '主卧区域',
  2898. area: 25.6,
  2899. percentage: 25.0,
  2900. requirements: ['睡眠', '储衣', '梳妆'],
  2901. furniture: ['床', '衣柜', '梳妆台', '床头柜']
  2902. },
  2903. {
  2904. zone: '次卧区域',
  2905. area: 10.4,
  2906. percentage: 10.2,
  2907. requirements: ['睡眠', '学习'],
  2908. furniture: ['床', '书桌', '衣柜']
  2909. }
  2910. ],
  2911. circulation: {
  2912. mainPaths: ['入户-客厅', '客厅-餐厅', '餐厅-厨房', '客厅-卧室'],
  2913. pathWidth: 1.2,
  2914. efficiency: 88
  2915. },
  2916. lighting: {
  2917. natural: {
  2918. direction: ['南向', '东向'],
  2919. intensity: '充足',
  2920. duration: '8-10小时'
  2921. },
  2922. artificial: {
  2923. zones: ['主照明', '局部照明', '装饰照明'],
  2924. requirements: ['无主灯设计', '分层控制', '调光调色']
  2925. }
  2926. }
  2927. },
  2928. budget: {
  2929. total: 285000,
  2930. breakdown: [
  2931. {
  2932. category: '基础装修',
  2933. amount: 142500,
  2934. percentage: 50
  2935. },
  2936. {
  2937. category: '主材采购',
  2938. amount: 85500,
  2939. percentage: 30
  2940. },
  2941. {
  2942. category: '软装配饰',
  2943. amount: 42750,
  2944. percentage: 15
  2945. },
  2946. {
  2947. category: '设计费用',
  2948. amount: 14250,
  2949. percentage: 5
  2950. }
  2951. ]
  2952. },
  2953. timeline: [
  2954. {
  2955. phase: '设计深化',
  2956. duration: 7,
  2957. dependencies: ['需求确认']
  2958. },
  2959. {
  2960. phase: '材料采购',
  2961. duration: 5,
  2962. dependencies: ['设计深化']
  2963. },
  2964. {
  2965. phase: '基础施工',
  2966. duration: 30,
  2967. dependencies: ['材料采购']
  2968. },
  2969. {
  2970. phase: '软装进场',
  2971. duration: 7,
  2972. dependencies: ['基础施工']
  2973. },
  2974. {
  2975. phase: '验收交付',
  2976. duration: 3,
  2977. dependencies: ['软装进场']
  2978. }
  2979. ],
  2980. feasibility: {
  2981. technical: 95,
  2982. budget: 88,
  2983. timeline: 92,
  2984. overall: 92
  2985. }
  2986. };
  2987. }
  2988. // 获取材质分类统计
  2989. getMaterialCategories(): { category: string; count: number; percentage: number }[] {
  2990. if (!this.proposalAnalysis) return [];
  2991. const categories = this.proposalAnalysis.materials.reduce((acc, material) => {
  2992. acc[material.category] = (acc[material.category] || 0) + 1;
  2993. return acc;
  2994. }, {} as Record<string, number>);
  2995. const total = Object.values(categories).reduce((sum, count) => sum + count, 0);
  2996. return Object.entries(categories).map(([category, count]) => ({
  2997. category,
  2998. count,
  2999. percentage: Math.round((count / total) * 100)
  3000. }));
  3001. }
  3002. // 获取设计风格特征摘要
  3003. getStyleSummary(): string {
  3004. if (!this.proposalAnalysis) return '';
  3005. const style = this.proposalAnalysis.designStyle;
  3006. const topElements = style.styleElements
  3007. .sort((a, b) => b.influence - a.influence)
  3008. .slice(0, 2)
  3009. .map(el => el.element)
  3010. .join('、');
  3011. return `${style.primaryStyle}风格,主要体现在${topElements}等方面`;
  3012. }
  3013. // 获取色彩方案摘要
  3014. getColorSummary(): string {
  3015. if (!this.proposalAnalysis) return '';
  3016. const scheme = this.proposalAnalysis.colorScheme;
  3017. const dominantColor = scheme.palette.find(p => p.role === 'dominant')?.color || '';
  3018. const accentColor = scheme.palette.find(p => p.role === 'accent')?.color || '';
  3019. return `以${dominantColor}为主调,${accentColor}作点缀,营造${scheme.psychology.mood}的氛围`;
  3020. }
  3021. // 获取空间效率评分
  3022. getSpaceEfficiency(): number {
  3023. if (!this.proposalAnalysis) return 0;
  3024. return this.proposalAnalysis.spaceLayout.circulation.efficiency;
  3025. }
  3026. private handlePaymentProofUpload(file: File): void {
  3027. // 显示上传进度
  3028. const uploadingMessage = `正在上传支付凭证:${file.name}...`;
  3029. console.log(uploadingMessage);
  3030. // 使用支付凭证识别服务处理上传
  3031. const settlementId = this.project?.id || 'default_settlement';
  3032. this.paymentVoucherService.processPaymentVoucherUpload(file, settlementId).subscribe({
  3033. next: (result) => {
  3034. if (result.success && result.recognitionResult) {
  3035. const recognition = result.recognitionResult;
  3036. // 更新识别计数
  3037. this.voucherRecognitionCount++;
  3038. // 显示识别结果
  3039. const successMessage = `
  3040. 支付凭证识别成功!
  3041. 支付方式:${recognition.paymentMethod}
  3042. 支付金额:¥${recognition.amount}
  3043. 交易号:${recognition.transactionNumber}
  3044. 置信度:${(recognition.confidence * 100).toFixed(1)}%
  3045. `;
  3046. alert(successMessage);
  3047. console.log('支付凭证识别完成', recognition);
  3048. // 自动标记验证通过并解锁渲染大图
  3049. this.isPaymentVerified = true;
  3050. this.renderLargeImages = this.renderLargeImages.map(img => ({ ...img, locked: false }));
  3051. // 触发自动通知流程
  3052. this.triggerPaymentCompletedNotification(recognition);
  3053. } else {
  3054. const errorMessage = `支付凭证识别失败:${result.error || '未知错误'}`;
  3055. alert(errorMessage);
  3056. console.error('支付凭证识别失败', result.error);
  3057. }
  3058. },
  3059. error: (error) => {
  3060. const errorMessage = `支付凭证处理出错:${error.message || '网络错误'}`;
  3061. alert(errorMessage);
  3062. console.error('支付凭证处理出错', error);
  3063. }
  3064. });
  3065. }
  3066. /**
  3067. * 触发支付完成通知流程
  3068. */
  3069. private triggerPaymentCompletedNotification(recognition: any): void {
  3070. console.log('触发支付完成自动通知流程...');
  3071. // 模拟调用通知服务发送多渠道通知
  3072. this.sendMultiChannelNotifications(recognition);
  3073. // 模拟发送通知
  3074. setTimeout(() => {
  3075. const notificationMessage = `
  3076. 🎉 尾款已到账,大图已解锁!
  3077. 支付信息:
  3078. • 支付方式:${recognition.paymentMethod}
  3079. • 支付金额:¥${recognition.amount}
  3080. • 处理时间:${new Date().toLocaleString()}
  3081. 📱 系统已自动发送通知至:
  3082. • 短信通知:138****8888
  3083. • 微信通知:已推送至微信
  3084. • 邮件通知:customer@example.com
  3085. 🖼️ 高清渲染图下载链接已发送
  3086. 您现在可以下载4K高清渲染图了!
  3087. `;
  3088. alert(notificationMessage);
  3089. console.log('自动通知发送完成');
  3090. }, 1000);
  3091. }
  3092. /**
  3093. * 发送多渠道通知
  3094. */
  3095. private sendMultiChannelNotifications(recognition: any): void {
  3096. console.log('开始发送多渠道通知...');
  3097. // 更新通知发送计数
  3098. this.notificationsSent++;
  3099. // 模拟发送短信通知
  3100. console.log('📱 发送短信通知: 尾款已到账,大图已解锁');
  3101. // 模拟发送微信通知
  3102. console.log('💬 发送微信通知: 支付成功,高清图片已准备就绪');
  3103. // 模拟发送邮件通知
  3104. console.log('📧 发送邮件通知: 包含下载链接的详细通知');
  3105. // 模拟发送应用内通知
  3106. console.log('🔔 发送应用内通知: 实时推送支付状态更新');
  3107. // 模拟通知发送结果
  3108. setTimeout(() => {
  3109. console.log('✅ 所有渠道通知发送完成');
  3110. console.log(`通知发送统计: 短信✅ 微信✅ 邮件✅ 应用内✅ (总计: ${this.notificationsSent} 次)`);
  3111. }, 500);
  3112. }
  3113. // 获取当前设计师名称
  3114. getCurrentDesignerName(): string {
  3115. // 这里应该从用户服务或认证信息中获取当前用户名称
  3116. // 暂时返回一个默认值
  3117. return '张设计师';
  3118. }
  3119. // ==================== 售后相关变量 ====================
  3120. // 售后标签页控制
  3121. activeAftercareTab: string = 'services'; // 当前激活的售后标签页
  3122. // 售后状态管理
  3123. afterSalesStage: string = '未开始'; // 售后阶段:未开始、进行中、已完成
  3124. afterSalesStatus: 'pending' | 'in_progress' | 'completed' | 'cancelled' = 'pending'; // 售后状态
  3125. afterSalesProgress: number = 0; // 售后进度百分比
  3126. // 售后服务数据
  3127. afterSalesServices: Array<{
  3128. id: string;
  3129. type: string; // 服务类型:维修、保养、咨询、投诉处理
  3130. description: string;
  3131. assignedTo: string; // 指派给的人员
  3132. scheduledDate?: Date; // 计划服务日期
  3133. completedDate?: Date; // 完成日期
  3134. status: 'pending' | 'scheduled' | 'in_progress' | 'completed' | 'cancelled';
  3135. priority: 'low' | 'medium' | 'high';
  3136. }> = [];
  3137. // 售后评价和反馈
  3138. afterSalesRating: number = 0; // 售后评分(0-5)
  3139. afterSalesFeedback: string = ''; // 售后反馈内容
  3140. afterSalesFeedbackDate?: Date; // 反馈日期
  3141. // 售后时间跟踪
  3142. afterSalesResponseTime?: Date; // 首次响应时间
  3143. afterSalesStartTime?: Date; // 售后开始时间
  3144. afterSalesCompletionTime?: Date; // 售后完成时间
  3145. afterSalesTotalDuration: number = 0; // 总耗时(小时)
  3146. // 售后联系人信息
  3147. afterSalesContact: {
  3148. name: string;
  3149. phone: string;
  3150. wechat?: string;
  3151. email?: string;
  3152. } = {
  3153. name: '',
  3154. phone: ''
  3155. };
  3156. // 售后问题记录
  3157. afterSalesIssues: Array<{
  3158. id: string;
  3159. title: string;
  3160. description: string;
  3161. severity: 'low' | 'medium' | 'high' | 'critical';
  3162. reportedDate: Date;
  3163. resolvedDate?: Date;
  3164. status: 'reported' | 'investigating' | 'resolved' | 'closed';
  3165. }> = [];
  3166. // 售后文件记录
  3167. afterSalesDocuments: Array<{
  3168. id: string;
  3169. name: string;
  3170. type: string; // 文件类型:合同、报告、照片、视频
  3171. uploadDate: Date;
  3172. url: string;
  3173. }> = [];
  3174. // 售后费用记录
  3175. afterSalesCosts: Array<{
  3176. id: string;
  3177. description: string;
  3178. amount: number;
  3179. category: 'material' | 'labor' | 'transportation' | 'other';
  3180. date: Date;
  3181. status: 'pending' | 'approved' | 'paid' | 'rejected';
  3182. }> = [];
  3183. // 售后沟通记录
  3184. afterSalesCommunications: Array<{
  3185. id: string;
  3186. type: 'phone' | 'wechat' | 'email' | 'visit';
  3187. date: Date;
  3188. summary: string;
  3189. participants: string[];
  3190. }> = [];
  3191. // 新增:项目复盘相关属性
  3192. projectReview: ProjectReview | null = null;
  3193. isGeneratingReview: boolean = false;
  3194. // 项目复盘 Tab 切换
  3195. activeReviewTab: 'sop' | 'experience' | 'suggestions' = 'sop';
  3196. // SOP执行数据
  3197. sopMetrics: any = {
  3198. communicationCount: 6,
  3199. avgCommunication: 5,
  3200. revisionCount: 3,
  3201. avgRevision: 2,
  3202. deliveryCycle: 18,
  3203. standardCycle: 15,
  3204. customerSatisfaction: 4.5
  3205. };
  3206. sopStagesData: any[] = [
  3207. { name: '订单分配', plannedDuration: 1, actualDuration: 1, score: 95, status: 'completed', statusText: '已完成', isDelayed: false, issues: [] },
  3208. { name: '需求沟通', plannedDuration: 3, actualDuration: 4, score: 75, status: 'completed', statusText: '已完成', isDelayed: true, issues: ['沟通次数超标'] },
  3209. { name: '方案确认', plannedDuration: 2, actualDuration: 2, score: 90, status: 'completed', statusText: '已完成', isDelayed: false, issues: [] },
  3210. { name: '建模', plannedDuration: 4, actualDuration: 5, score: 80, status: 'completed', statusText: '已完成', isDelayed: true, issues: ['细节调整耗时'] },
  3211. { name: '软装', plannedDuration: 2, actualDuration: 2, score: 92, status: 'completed', statusText: '已完成', isDelayed: false, issues: [] },
  3212. { name: '渲染', plannedDuration: 3, actualDuration: 4, score: 85, status: 'ongoing', statusText: '进行中', isDelayed: false, issues: [] }
  3213. ];
  3214. // 经验复盘数据
  3215. experienceData: any = {
  3216. customerNeeds: [
  3217. { text: '希望客厅采用现代简约风格,注重收纳功能', timestamp: '2024-01-15 10:30', source: '初次沟通' },
  3218. { text: '卧室需要温馨氛围,色调以暖色为主', timestamp: '2024-01-16 14:20', source: '需求确认' },
  3219. { text: '厨房要求实用性强,采用白色橱柜', timestamp: '2024-01-17 09:15', source: '细节讨论' }
  3220. ],
  3221. customerConcerns: [
  3222. { text: '担心渲染图与实际效果有差异', timestamp: '2024-01-18 16:40', resolved: true },
  3223. { text: '预算控制在合理范围内', timestamp: '2024-01-19 11:25', resolved: true }
  3224. ],
  3225. complaintPoints: [
  3226. { text: '首版方案色彩搭配不符合预期', timestamp: '2024-01-20 15:10', severity: 'medium', severityText: '中等', resolution: '已调整为客户偏好的配色方案' }
  3227. ],
  3228. projectHighlights: [
  3229. { text: '设计师对空间的功能分区把握精准', category: '设计亮点', praised: true },
  3230. { text: '材质选择符合客户品味且性价比高', category: '材质选择', praised: true },
  3231. { text: '渲染效果图质量优秀,客户非常满意', category: '技术表现', praised: true }
  3232. ],
  3233. communications: [
  3234. { timestamp: '2024-01-15 10:30', participant: '客户', type: 'requirement', typeText: '需求提出', message: '希望整体风格简约现代,注重实用性...', attachments: [] },
  3235. { timestamp: '2024-01-16 09:00', participant: '设计师', type: 'response', typeText: '设计反馈', message: '根据您的需求,我们建议采用...', attachments: ['方案草图.jpg'] },
  3236. { timestamp: '2024-01-20 14:30', participant: '客户', type: 'concern', typeText: '疑虑表达', message: '对配色方案有些疑虑...', attachments: [] }
  3237. ]
  3238. };
  3239. // 优化建议数据
  3240. optimizationSuggestions: any[] = [
  3241. {
  3242. priority: 'high',
  3243. priorityText: '高优先级',
  3244. category: '需求沟通',
  3245. expectedImprovement: '减少30%改图次数',
  3246. problem: '该项目因需求理解不够深入导致改图3次,超出平均水平',
  3247. dataPoints: [
  3248. { label: '实际改图次数', value: '3次', isWarning: true },
  3249. { label: '平均改图次数', value: '2次', isWarning: false },
  3250. { label: '超出比例', value: '+50%', isWarning: true }
  3251. ],
  3252. solution: '建议在需求沟通阶段增加确认环节,通过详细的需求确认清单和参考案例,确保设计师完全理解客户需求',
  3253. actionPlan: [
  3254. '制定标准化的需求确认清单,覆盖风格、色彩、材质、功能等核心要素',
  3255. '在方案设计前与客户进行一次需求复核会议',
  3256. '准备3-5个同类型案例供客户参考,明确设计方向',
  3257. '使用可视化工具(如情绪板)帮助客户表达偏好'
  3258. ],
  3259. references: ['项目A-123', '项目B-456']
  3260. },
  3261. {
  3262. priority: 'medium',
  3263. priorityText: '中优先级',
  3264. category: '时间管理',
  3265. expectedImprovement: '缩短15%交付周期',
  3266. problem: '项目交付周期为18天,超出标准周期15天',
  3267. dataPoints: [
  3268. { label: '实际周期', value: '18天', isWarning: true },
  3269. { label: '标准周期', value: '15天', isWarning: false },
  3270. { label: '延期', value: '+3天', isWarning: true }
  3271. ],
  3272. solution: '优化建模和渲染阶段的时间分配,采用并行工作模式提高效率',
  3273. actionPlan: [
  3274. '建模和软装选择可以部分并行进行',
  3275. '提前准备常用材质库,减少临时查找时间',
  3276. '设置阶段里程碑提醒,避免单一阶段耗时过长'
  3277. ],
  3278. references: ['时间优化案例-001']
  3279. },
  3280. {
  3281. priority: 'low',
  3282. priorityText: '低优先级',
  3283. category: '客户体验',
  3284. expectedImprovement: '提升客户满意度至4.8分',
  3285. problem: '当前客户满意度为4.5分,仍有提升空间',
  3286. dataPoints: [
  3287. { label: '当前满意度', value: '4.5/5', isWarning: false },
  3288. { label: '目标满意度', value: '4.8/5', isWarning: false }
  3289. ],
  3290. solution: '增加交付过程中的沟通频率,及时展示阶段性成果',
  3291. actionPlan: [
  3292. '每个关键节点完成后主动向客户汇报进度',
  3293. '提供阶段性预览图,让客户参与到创作过程中',
  3294. '建立客户反馈快速响应机制'
  3295. ],
  3296. references: []
  3297. }
  3298. ];
  3299. switchAftercareTab(tab: string): void {
  3300. this.activeAftercareTab = tab;
  3301. console.log('切换到售后标签页:', tab);
  3302. }
  3303. // ==================== 自动结算相关 ====================
  3304. // 检查项目是否已完成验收
  3305. isProjectAccepted(): boolean {
  3306. // 检查所有交付阶段是否完成
  3307. const deliveryStages: ProjectStage[] = ['建模', '软装', '渲染', '后期'];
  3308. return deliveryStages.every(stage => this.getStageStatus(stage) === 'completed');
  3309. }
  3310. // 启动自动结算(只有技术人员可触发)
  3311. initiateAutoSettlement(): void {
  3312. if (this.isAutoSettling) return;
  3313. // 权限检查
  3314. if (!this.isTechnicalView()) {
  3315. alert('⚠️ 仅技术人员可以启动自动化结算流程');
  3316. return;
  3317. }
  3318. // 验收状态检查
  3319. if (!this.isProjectAccepted()) {
  3320. const confirmStart = confirm('项目尚未完成全部验收,确定要启动结算流程吗?');
  3321. if (!confirmStart) return;
  3322. }
  3323. this.isAutoSettling = true;
  3324. console.log('启动自动化结算流程...');
  3325. // 模拟启动各个自动化功能
  3326. setTimeout(() => {
  3327. // 1. 启动小程序支付监听
  3328. this.miniprogramPaymentStatus = 'active';
  3329. this.isSettlementInitiated = true;
  3330. console.log('✅ 自动化结算已启动');
  3331. console.log('🟢 小程序支付监听已激活');
  3332. console.log('🔍 支付凭证智能识别已就绪');
  3333. console.log('📱 自动通知系统已就绪');
  3334. // 2. 自动生成尾款结算记录
  3335. this.createFinalPaymentRecord();
  3336. // 3. 通知客服跟进尾款
  3337. this.notifyCustomerServiceForFinalPayment();
  3338. // 4. 设置支付监听和自动化流程
  3339. this.setupPaymentAutomation();
  3340. this.isAutoSettling = false;
  3341. // 显示启动成功消息
  3342. alert(`🚀 自动化结算已成功启动!
  3343. ✅ 已启动功能:
  3344. • 小程序支付自动监听
  3345. • 支付凭证智能识别
  3346. • 多渠道自动通知
  3347. • 大图自动解锁
  3348. • 已通知客服跟进尾款
  3349. 系统将自动处理后续支付流程。`);
  3350. }, 2000);
  3351. }
  3352. // 创建尾款结算记录
  3353. private createFinalPaymentRecord(): void {
  3354. const finalPaymentRecord: Settlement = {
  3355. id: `settlement_${Date.now()}`,
  3356. projectId: this.projectId,
  3357. projectName: this.project?.name || '',
  3358. type: 'final_payment',
  3359. amount: this.project?.finalPaymentAmount || 0,
  3360. percentage: 30,
  3361. status: 'pending',
  3362. createdAt: new Date(),
  3363. initiatedBy: 'technical',
  3364. initiatedAt: new Date(),
  3365. notifiedCustomerService: false,
  3366. paymentReceived: false,
  3367. imagesUnlocked: false
  3368. };
  3369. // 添加到结算列表
  3370. if (!this.settlements.find(s => s.type === 'final_payment')) {
  3371. this.settlements.unshift(finalPaymentRecord);
  3372. }
  3373. console.log('📝 已创建尾款结算记录:', finalPaymentRecord);
  3374. }
  3375. // 通知客服跟进尾款
  3376. private notifyCustomerServiceForFinalPayment(): void {
  3377. const projectInfo = {
  3378. projectId: this.projectId,
  3379. projectName: this.project?.name || '未知项目',
  3380. customerName: this.project?.customerName || '未知客户',
  3381. customerPhone: this.project?.customerPhone || '',
  3382. finalPaymentAmount: this.project?.finalPaymentAmount || 0,
  3383. notificationTime: new Date(),
  3384. status: 'pending_followup',
  3385. priority: 'high',
  3386. autoGenerated: true,
  3387. message: `项目【${this.project?.name}】已完成技术验收,请及时跟进客户尾款支付。`
  3388. };
  3389. // 发送通知到客服系统
  3390. console.log('📢 正在通知客服跟进尾款...', projectInfo);
  3391. // 模拟API调用到客服通知系统
  3392. // this.customerServiceAPI.addPendingTask(projectInfo).subscribe(...)
  3393. setTimeout(() => {
  3394. console.log('✅ 客服通知已发送成功');
  3395. // 更新结算记录状态
  3396. const settlement = this.settlements.find(s => s.type === 'final_payment');
  3397. if (settlement) {
  3398. settlement.notifiedCustomerService = true;
  3399. }
  3400. }, 500);
  3401. }
  3402. // 设置支付自动化流程
  3403. private setupPaymentAutomation(): void {
  3404. console.log('⚙️ 设置支付自动化监听...');
  3405. // 模拟支付监听(实际应使用WebSocket或轮询)
  3406. // 这里仅作演示
  3407. this.monitorPaymentStatus();
  3408. }
  3409. // 监听支付状态
  3410. private monitorPaymentStatus(): void {
  3411. // 实际应该使用WebSocket连接或定时轮询API
  3412. // 这里仅作演示用setTimeout模拟
  3413. console.log('👀 开始监听支付状态...');
  3414. // 当检测到支付完成时,自动触发后续流程
  3415. // this.onPaymentReceived();
  3416. }
  3417. // 支付到账回调
  3418. onPaymentReceived(paymentInfo?: any): void {
  3419. console.log('💰 检测到支付到账:', paymentInfo);
  3420. const settlement = this.settlements.find(s => s.type === 'final_payment');
  3421. if (!settlement) return;
  3422. // 更新结算状态
  3423. settlement.status = '已结算';
  3424. settlement.settledAt = new Date();
  3425. settlement.paymentReceived = true;
  3426. settlement.paymentReceivedAt = new Date();
  3427. // 自动解锁并发送大图
  3428. this.autoUnlockAndSendImages();
  3429. // 通知客户和客服
  3430. this.sendPaymentConfirmationNotifications();
  3431. }
  3432. // 自动解锁并发送大图
  3433. private autoUnlockAndSendImages(): void {
  3434. console.log('🔓 自动解锁大图...');
  3435. // 更新结算记录
  3436. const settlement = this.settlements.find(s => s.type === 'final_payment');
  3437. if (settlement) {
  3438. settlement.imagesUnlocked = true;
  3439. settlement.imagesUnlockedAt = new Date();
  3440. }
  3441. // 自动发送大图给客户(通过客服)
  3442. this.autoSendImagesToCustomer();
  3443. console.log('✅ 大图已解锁并准备发送');
  3444. }
  3445. // 自动发送图片给客户
  3446. private autoSendImagesToCustomer(): void {
  3447. console.log('📤 自动发送大图给客户...');
  3448. // 收集所有渲染大图
  3449. const renderProcess = this.deliveryProcesses.find(p => p.id === 'rendering');
  3450. const images: string[] = [];
  3451. if (renderProcess) {
  3452. Object.keys(renderProcess.content).forEach(spaceId => {
  3453. const content = renderProcess.content[spaceId];
  3454. if (content.images) {
  3455. content.images.forEach(img => {
  3456. images.push(img.url);
  3457. });
  3458. }
  3459. });
  3460. }
  3461. const sendInfo = {
  3462. projectId: this.projectId,
  3463. customerName: this.project?.customerName || '',
  3464. images: images,
  3465. sendMethod: 'wechat',
  3466. autoGenerated: true
  3467. };
  3468. console.log('📨 准备发送的大图信息:', sendInfo);
  3469. // 调用客服系统API一键发图
  3470. // this.customerServiceAPI.sendImagesToCustomer(sendInfo).subscribe(...)
  3471. }
  3472. // 发送支付确认通知
  3473. private sendPaymentConfirmationNotifications(): void {
  3474. console.log('📱 发送支付确认通知...');
  3475. // 通知客户
  3476. const customerMessage = `尊敬的${this.project?.customerName || '客户'},您的尾款支付已确认,大图已自动解锁并发送,请查收。感谢您的信任!`;
  3477. // 通知客服
  3478. const csMessage = `项目【${this.project?.name}】尾款已到账,大图已自动解锁,请一键发送给客户。`;
  3479. console.log('📧 客户通知:', customerMessage);
  3480. console.log('📧 客服通知:', csMessage);
  3481. // 实际发送通知
  3482. // this.notificationService.send({ to: 'customer', message: customerMessage });
  3483. // this.notificationService.send({ to: 'customer_service', message: csMessage });
  3484. }
  3485. // ==================== 全景图合成相关 ====================
  3486. // 全景图合成数据
  3487. panoramicSyntheses: PanoramicSynthesis[] = [];
  3488. isUploadingPanoramicImages: boolean = false;
  3489. panoramicUploadProgress: number = 0;
  3490. // 启动全景图合成流程
  3491. // 上传支付凭证
  3492. uploadPaymentProof(): void {
  3493. console.log('📎 打开支付凭证上传...');
  3494. const fileInput = document.createElement('input');
  3495. fileInput.type = 'file';
  3496. fileInput.accept = 'image/*';
  3497. fileInput.onchange = (event: any) => {
  3498. const file = (event.target as HTMLInputElement).files?.[0];
  3499. if (!file) return;
  3500. console.log('📄 上传的凭证文件:', file.name);
  3501. alert(`📎 支付凭证已上传:${file.name}\n\n系统将自动识别支付金额和支付方式。`);
  3502. // 模拟凭证识别和处理
  3503. setTimeout(() => {
  3504. const mockPaymentInfo = {
  3505. amount: this.project?.finalPaymentAmount || 5000,
  3506. method: '微信支付',
  3507. imageUrl: URL.createObjectURL(file),
  3508. uploadTime: new Date()
  3509. };
  3510. console.log('✅ 支付凭证识别完成:', mockPaymentInfo);
  3511. this.onPaymentReceived(mockPaymentInfo);
  3512. }, 1500);
  3513. };
  3514. fileInput.click();
  3515. }
  3516. startPanoramicSynthesis(): void {
  3517. console.log('🎨 启动全景图合成...');
  3518. // 打开文件选择对话框,支持多文件选择
  3519. const fileInput = document.createElement('input');
  3520. fileInput.type = 'file';
  3521. fileInput.accept = 'image/*';
  3522. fileInput.multiple = true;
  3523. fileInput.onchange = (event: any) => {
  3524. const files = Array.from(event.target.files || []) as File[];
  3525. if (files.length === 0) return;
  3526. console.log(`📸 选择了 ${files.length} 张图片进行合成`);
  3527. this.processPanoramicImages(files);
  3528. };
  3529. fileInput.click();
  3530. }
  3531. // 处理全景图片上传和合成
  3532. private processPanoramicImages(files: File[]): void {
  3533. this.isUploadingPanoramicImages = true;
  3534. this.panoramicUploadProgress = 0;
  3535. console.log(`📸 开始处理 ${files.length} 张全景图片...`);
  3536. // 模拟上传进度
  3537. const uploadInterval = setInterval(() => {
  3538. this.panoramicUploadProgress += 10;
  3539. if (this.panoramicUploadProgress >= 100) {
  3540. clearInterval(uploadInterval);
  3541. this.panoramicUploadProgress = 100;
  3542. // 上传完成后开始合成
  3543. this.synthesizePanoramicView(files);
  3544. }
  3545. }, 300);
  3546. }
  3547. // 合成全景漫游
  3548. private synthesizePanoramicView(files: File[]): void {
  3549. console.log('🔄 开始合成全景漫游...');
  3550. // 创建合成记录
  3551. const synthesis: PanoramicSynthesis = {
  3552. id: 'panoramic-' + Date.now(),
  3553. projectId: this.projectId,
  3554. projectName: this.project?.name || '未知项目',
  3555. spaces: [],
  3556. status: 'processing',
  3557. quality: 'high',
  3558. createdAt: new Date(),
  3559. updatedAt: new Date(),
  3560. progress: 0
  3561. };
  3562. // 根据上传的文件创建空间列表
  3563. files.forEach((file, index) => {
  3564. // 从文件名提取空间名称(如"客厅-角度1.jpg")
  3565. const fileName = file.name.replace(/\.(jpg|jpeg|png|gif)$/i, '');
  3566. const match = fileName.match(/^(.+?)-/);
  3567. const spaceName = match ? match[1] : `空间${index + 1}`;
  3568. // 根据空间名称推断类型
  3569. let spaceType: 'living_room' | 'bedroom' | 'kitchen' | 'bathroom' | 'dining_room' | 'study' | 'balcony' = 'living_room';
  3570. if (spaceName.includes('客厅')) spaceType = 'living_room';
  3571. else if (spaceName.includes('卧室')) spaceType = 'bedroom';
  3572. else if (spaceName.includes('厨房')) spaceType = 'kitchen';
  3573. else if (spaceName.includes('卫生间') || spaceName.includes('浴室')) spaceType = 'bathroom';
  3574. else if (spaceName.includes('餐厅')) spaceType = 'dining_room';
  3575. else if (spaceName.includes('书房')) spaceType = 'study';
  3576. else if (spaceName.includes('阳台')) spaceType = 'balcony';
  3577. synthesis.spaces.push({
  3578. id: `space_${Date.now()}_${index}`,
  3579. name: spaceName,
  3580. type: spaceType,
  3581. imageCount: 1,
  3582. viewAngle: fileName
  3583. });
  3584. });
  3585. this.panoramicSyntheses.unshift(synthesis);
  3586. // 模拟KR Panel合成进度
  3587. let progress = 0;
  3588. const synthesisInterval = setInterval(() => {
  3589. progress += 15;
  3590. synthesis.progress = Math.min(progress, 100);
  3591. synthesis.updatedAt = new Date();
  3592. if (progress >= 100) {
  3593. clearInterval(synthesisInterval);
  3594. // 合成完成
  3595. synthesis.status = 'completed';
  3596. synthesis.completedAt = new Date();
  3597. synthesis.previewUrl = this.generateMockPanoramicUrl(synthesis.id);
  3598. synthesis.downloadUrl = this.generateMockDownloadUrl(synthesis.id);
  3599. synthesis.renderTime = 120 + Math.floor(Math.random() * 60);
  3600. synthesis.fileSize = files.reduce((sum, f) => sum + f.size, 0);
  3601. this.isUploadingPanoramicImages = false;
  3602. console.log('✅ 全景图合成完成:', synthesis);
  3603. // 自动生成分享链接
  3604. this.generatePanoramicShareLink(synthesis);
  3605. }
  3606. }, 500);
  3607. }
  3608. // 生成全景图分享链接
  3609. private generatePanoramicShareLink(synthesis: PanoramicSynthesis): void {
  3610. const shareLink = `https://panoramic.example.com/view/${synthesis.id}`;
  3611. synthesis.shareLink = shareLink;
  3612. console.log('🔗 全景图分享链接:', shareLink);
  3613. // 自动通知客服发送给客户
  3614. this.notifyCustomerServiceForPanoramicLink(synthesis);
  3615. }
  3616. // 通知客服发送全景图链接
  3617. private notifyCustomerServiceForPanoramicLink(synthesis: PanoramicSynthesis): void {
  3618. const notification = {
  3619. type: 'panoramic_ready',
  3620. projectId: this.projectId,
  3621. projectName: synthesis.projectName,
  3622. shareLink: synthesis.shareLink,
  3623. message: `项目【${synthesis.projectName}】的全景漫游已生成完成,请发送给客户查看。`,
  3624. timestamp: new Date()
  3625. };
  3626. console.log('📢 通知客服发送全景图链接:', notification);
  3627. // 调用客服通知API
  3628. // this.customerServiceAPI.notifyPanoramicReady(notification).subscribe(...)
  3629. }
  3630. // 生成模拟全景图URL
  3631. private generateMockPanoramicUrl(id: string): string {
  3632. return `https://panoramic.example.com/preview/${id}`;
  3633. }
  3634. // 生成模拟下载URL
  3635. private generateMockDownloadUrl(id: string): string {
  3636. return `https://panoramic.example.com/download/${id}`;
  3637. }
  3638. // 查看全景图画廊
  3639. viewPanoramicGallery(): void {
  3640. console.log('打开全景图画廊');
  3641. if (this.panoramicSyntheses.length === 0) {
  3642. alert('暂无全景图记录');
  3643. return;
  3644. }
  3645. // 显示全景图列表
  3646. const galleryInfo = this.panoramicSyntheses.map((s, i) =>
  3647. `${i + 1}. ${s.projectName} - ${s.status === 'completed' ? '已完成' : '处理中'} (${s.spaces.length}个空间)`
  3648. ).join('\n');
  3649. alert(`全景图画廊\n\n${galleryInfo}\n\n点击查看详情功能开发中...`);
  3650. }
  3651. // 复制全景图链接
  3652. copyPanoramicLink(synthesis: PanoramicSynthesis): void {
  3653. if (!synthesis.shareLink) {
  3654. alert('全景图链接尚未生成');
  3655. return;
  3656. }
  3657. navigator.clipboard.writeText(synthesis.shareLink).then(() => {
  3658. alert(`✅ 全景图链接已复制!\n\n${synthesis.shareLink}`);
  3659. }).catch(() => {
  3660. alert(`全景图链接:\n${synthesis.shareLink}`);
  3661. });
  3662. }
  3663. // ==================== 评价统计相关 ====================
  3664. // 评价统计数据
  3665. reviewStats: {
  3666. overallScore: number;
  3667. timelinessScore: number;
  3668. qualityScore: number;
  3669. communicationScore: number;
  3670. } = {
  3671. overallScore: 4.8,
  3672. timelinessScore: 4.7,
  3673. qualityScore: 4.9,
  3674. communicationScore: 4.6
  3675. };
  3676. // ==================== 客户评价相关 ====================
  3677. // 生成评价链接
  3678. generateReviewLink(): void {
  3679. console.log('📋 生成客户评价链接...');
  3680. // 生成唯一的评价令牌
  3681. const reviewToken = this.generateReviewToken();
  3682. const reviewLink = `https://review.yss.com/project/${this.projectId}?token=${reviewToken}`;
  3683. // 保存评价链接记录
  3684. const reviewRecord = {
  3685. projectId: this.projectId,
  3686. projectName: this.project?.name || '',
  3687. customerName: this.project?.customerName || '',
  3688. reviewLink: reviewLink,
  3689. token: reviewToken,
  3690. createdAt: new Date(),
  3691. expiresAt: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000), // 30天有效期
  3692. status: 'active',
  3693. accessed: false
  3694. };
  3695. console.log('✅ 评价链接已生成:', reviewRecord);
  3696. // 复制到剪贴板
  3697. navigator.clipboard.writeText(reviewLink).then(() => {
  3698. alert(`✅ 评价链接已复制到剪贴板!\n\n链接:${reviewLink}\n\n有效期:30天\n\n请通过企业微信发送给客户`);
  3699. }).catch(() => {
  3700. alert(`评价链接:\n\n${reviewLink}\n\n有效期:30天\n\n请通过企业微信发送给客户`);
  3701. });
  3702. // 通知客服发送评价链接
  3703. this.notifyCustomerServiceForReviewLink(reviewRecord);
  3704. }
  3705. // 生成评价令牌
  3706. private generateReviewToken(): string {
  3707. return `review_${this.projectId}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
  3708. }
  3709. // 通知客服发送评价链接
  3710. private notifyCustomerServiceForReviewLink(reviewRecord: any): void {
  3711. const notification = {
  3712. type: 'review_link_ready',
  3713. projectId: this.projectId,
  3714. projectName: reviewRecord.projectName,
  3715. customerName: reviewRecord.customerName,
  3716. reviewLink: reviewRecord.reviewLink,
  3717. message: `项目【${reviewRecord.projectName}】的客户评价链接已生成,请发送给客户。`,
  3718. timestamp: new Date()
  3719. };
  3720. console.log('📢 通知客服发送评价链接:', notification);
  3721. // 调用客服通知API
  3722. // this.customerServiceAPI.notifyReviewLinkReady(notification).subscribe(...)
  3723. }
  3724. // 确认客户评价完成
  3725. confirmCustomerReview(): void {
  3726. console.log('✅ 确认客户评价完成');
  3727. // 更新项目状态
  3728. if (this.project) {
  3729. this.project.customerReviewCompleted = true;
  3730. this.project.customerReviewCompletedAt = new Date();
  3731. }
  3732. alert('✅ 客户评价已确认完成!');
  3733. // 可选:自动进入下一阶段
  3734. // this.advanceToNextStage('客户评价');
  3735. }
  3736. // ==================== 投诉管理相关 ====================
  3737. // 关键词监控配置
  3738. complaintKeywords: string[] = ['不满意', '投诉', '退款', '差评', '质量问题', '延期', '态度差'];
  3739. isKeywordMonitoringActive: boolean = false;
  3740. // 手动创建投诉
  3741. createComplaintManually(): void {
  3742. console.log('📝 手动创建投诉');
  3743. // 弹出创建投诉表单
  3744. const complaintReason = prompt('请输入投诉原因:');
  3745. if (!complaintReason || complaintReason.trim() === '') return;
  3746. const complaintStage = prompt('请输入投诉环节(如:需求沟通、建模、渲染等):') || '未指定';
  3747. // 创建投诉记录
  3748. const complaint: any = {
  3749. id: `complaint_${Date.now()}`,
  3750. projectId: this.projectId,
  3751. projectName: this.project?.name || '',
  3752. customerName: this.project?.customerName || '',
  3753. type: '人工创建',
  3754. stage: complaintStage,
  3755. reason: complaintReason,
  3756. severity: 'medium',
  3757. status: 'pending',
  3758. createdBy: 'manual',
  3759. createdAt: new Date(),
  3760. handler: '',
  3761. resolution: '',
  3762. resolvedAt: null
  3763. };
  3764. // 智能标注核心问题
  3765. complaint.tags = this.analyzeComplaintTags(complaintReason);
  3766. // 添加到投诉列表
  3767. this.exceptionHistories.unshift(complaint);
  3768. console.log('✅ 投诉记录已创建:', complaint);
  3769. alert(`✅ 投诉记录已创建!\n\n投诉环节:${complaintStage}\n核心问题:${complaint.tags.join('、')}\n\n系统将自动跟踪处理进度。`);
  3770. // 通知相关人员
  3771. this.notifyComplaintHandlers(complaint);
  3772. }
  3773. // 分析投诉标签
  3774. private analyzeComplaintTags(reason: string): string[] {
  3775. const tags: string[] = [];
  3776. const tagPatterns = {
  3777. '需求理解': ['需求', '理解', '沟通', '误解'],
  3778. '设计质量': ['质量', '效果', '不好', '不满意'],
  3779. '交付延期': ['延期', '超时', '慢', '着急'],
  3780. '服务态度': ['态度', '不礼貌', '敷衍', '回复慢'],
  3781. '价格问题': ['价格', '费用', '贵', '退款']
  3782. };
  3783. Object.entries(tagPatterns).forEach(([tag, keywords]) => {
  3784. if (keywords.some(keyword => reason.includes(keyword))) {
  3785. tags.push(tag);
  3786. }
  3787. });
  3788. return tags.length > 0 ? tags : ['其他'];
  3789. }
  3790. // 通知投诉处理人员
  3791. private notifyComplaintHandlers(complaint: any): void {
  3792. const notification = {
  3793. type: 'new_complaint',
  3794. projectId: this.projectId,
  3795. complaintId: complaint.id,
  3796. projectName: complaint.projectName,
  3797. customerName: complaint.customerName,
  3798. severity: complaint.severity,
  3799. tags: complaint.tags,
  3800. message: `项目【${complaint.projectName}】收到新投诉,请及时处理。`,
  3801. timestamp: new Date()
  3802. };
  3803. console.log('📢 通知投诉处理人员:', notification);
  3804. // 调用通知API
  3805. // this.complaintService.notifyHandlers(notification).subscribe(...)
  3806. }
  3807. // 设置关键词监控
  3808. setupKeywordMonitoring(): void {
  3809. console.log('⚙️ 设置关键词监控');
  3810. if (this.isKeywordMonitoringActive) {
  3811. const confirmStop = confirm('关键词监控已激活,是否停止监控?');
  3812. if (confirmStop) {
  3813. this.isKeywordMonitoringActive = false;
  3814. alert('✅ 关键词监控已停止');
  3815. }
  3816. return;
  3817. }
  3818. // 显示当前监控关键词
  3819. const currentKeywords = this.complaintKeywords.join('、');
  3820. const newKeywords = prompt(`当前监控关键词:\n\n${currentKeywords}\n\n请输入要添加的关键词(多个关键词用逗号分隔):`);
  3821. if (newKeywords && newKeywords.trim()) {
  3822. const keywords = newKeywords.split(/[,,、]/).map(k => k.trim()).filter(k => k);
  3823. this.complaintKeywords = [...new Set([...this.complaintKeywords, ...keywords])];
  3824. }
  3825. // 激活监控
  3826. this.isKeywordMonitoringActive = true;
  3827. this.startKeywordMonitoring();
  3828. alert(`✅ 关键词监控已激活!\n\n监控关键词:${this.complaintKeywords.join('、')}\n\n系统将自动检测企业微信群消息中的关键词并创建投诉记录。`);
  3829. }
  3830. // 开始关键词监控
  3831. private startKeywordMonitoring(): void {
  3832. console.log('👀 开始关键词监控...');
  3833. console.log('监控关键词:', this.complaintKeywords);
  3834. // 模拟监控企业微信消息(实际应使用企业微信API或webhook)
  3835. // 这里仅作演示
  3836. // 监控到关键词后自动创建投诉
  3837. // this.onKeywordDetected(message, keyword);
  3838. }
  3839. // 关键词检测回调
  3840. onKeywordDetected(message: string, keyword: string): void {
  3841. console.log('🚨 检测到关键词:', keyword);
  3842. console.log('消息内容:', message);
  3843. // 自动创建投诉记录
  3844. const complaint: any = {
  3845. id: `complaint_auto_${Date.now()}`,
  3846. projectId: this.projectId,
  3847. projectName: this.project?.name || '',
  3848. customerName: this.project?.customerName || '',
  3849. type: '关键词自动抓取',
  3850. keyword: keyword,
  3851. message: message,
  3852. severity: this.assessComplaintSeverity(message),
  3853. status: 'pending',
  3854. createdBy: 'auto',
  3855. createdAt: new Date(),
  3856. handler: '',
  3857. resolution: '',
  3858. resolvedAt: null
  3859. };
  3860. // 智能标注问题环节和核心问题
  3861. complaint.stage = this.identifyComplaintStage(message);
  3862. complaint.tags = this.analyzeComplaintTags(message);
  3863. // 添加到投诉列表
  3864. this.exceptionHistories.unshift(complaint);
  3865. console.log('✅ 自动投诉记录已创建:', complaint);
  3866. // 实时通知相关人员
  3867. this.notifyComplaintHandlers(complaint);
  3868. }
  3869. // 评估投诉严重程度
  3870. private assessComplaintSeverity(message: string): 'low' | 'medium' | 'high' {
  3871. const highSeverityKeywords = ['退款', '投诉', '举报', '律师', '曝光'];
  3872. const mediumSeverityKeywords = ['不满意', '差评', '质量问题'];
  3873. if (highSeverityKeywords.some(k => message.includes(k))) return 'high';
  3874. if (mediumSeverityKeywords.some(k => message.includes(k))) return 'medium';
  3875. return 'low';
  3876. }
  3877. // 识别投诉环节
  3878. private identifyComplaintStage(message: string): string {
  3879. const stageKeywords = {
  3880. '需求沟通': ['需求', '沟通', '理解'],
  3881. '方案确认': ['方案', '设计', '效果'],
  3882. '建模': ['建模', '模型', '白模'],
  3883. '软装': ['软装', '家具', '配饰'],
  3884. '渲染': ['渲染', '出图', '大图'],
  3885. '交付': ['交付', '发送', '收到']
  3886. };
  3887. for (const [stage, keywords] of Object.entries(stageKeywords)) {
  3888. if (keywords.some(k => message.includes(k))) {
  3889. return stage;
  3890. }
  3891. }
  3892. return '未指定';
  3893. }
  3894. // 确认投诉处理完成
  3895. confirmComplaint(): void {
  3896. console.log('✅ 确认投诉处理完成');
  3897. // 检查是否有未处理的投诉
  3898. const pendingComplaints = this.exceptionHistories.filter(c => c.status === '待处理');
  3899. if (pendingComplaints.length > 0) {
  3900. const confirmAnyway = confirm(`还有 ${pendingComplaints.length} 个投诉未处理,确定要标记为已完成吗?`);
  3901. if (!confirmAnyway) return;
  3902. }
  3903. alert('✅ 所有投诉已确认处理完成!');
  3904. }
  3905. // 处理评价表单提交
  3906. onReviewSubmitted(reviewData: any): void {
  3907. console.log('客户评价已提交:', reviewData);
  3908. // 这里应该调用API将评价数据保存到服务器
  3909. // 模拟API调用
  3910. setTimeout(() => {
  3911. alert('客户评价提交成功!评价数据已保存。');
  3912. // 更新本地反馈数据
  3913. const newFeedback: CustomerFeedback = {
  3914. id: Date.now().toString(),
  3915. customerName: '客户', // 应该从项目信息中获取
  3916. rating: reviewData.overallRating,
  3917. content: reviewData.improvementSuggestions || '无具体建议',
  3918. createdAt: new Date(),
  3919. status: '已解决',
  3920. isSatisfied: reviewData.overallRating >= 4,
  3921. projectId: this.projectId
  3922. };
  3923. this.feedbacks = [...this.feedbacks, newFeedback];
  3924. // 自动标记客户评价完成
  3925. this.confirmCustomerReview();
  3926. }, 1000);
  3927. }
  3928. // 处理评价表单保存草稿
  3929. onReviewSaved(reviewData: any): void {
  3930. console.log('客户评价草稿已保存:', reviewData);
  3931. // 这里应该调用API将草稿数据保存到服务器
  3932. // 模拟API调用
  3933. setTimeout(() => {
  3934. alert('评价草稿保存成功!您可以稍后继续完善。');
  3935. }, 500);
  3936. }
  3937. // ============ 缺少的方法实现 ============
  3938. // 初始化售后模块数据
  3939. private initializeAftercareData(): void {
  3940. // 初始化一些示例全景图合成记录
  3941. this.panoramicSyntheses = [
  3942. {
  3943. id: 'panoramic_001',
  3944. projectId: this.projectId,
  3945. projectName: '示例项目',
  3946. spaces: [
  3947. { id: 'space_001', name: '客厅', type: 'living_room' as const, imageCount: 3, viewAngle: '客厅-角度1' },
  3948. { id: 'space_002', name: '卧室', type: 'bedroom' as const, imageCount: 2, viewAngle: '卧室-角度1' }
  3949. ],
  3950. status: 'completed' as const,
  3951. quality: 'high' as const,
  3952. createdAt: new Date(Date.now() - 2 * 24 * 60 * 60 * 1000),
  3953. updatedAt: new Date(Date.now() - 2 * 24 * 60 * 60 * 1000),
  3954. completedAt: new Date(Date.now() - 2 * 24 * 60 * 60 * 1000),
  3955. previewUrl: 'https://panoramic.example.com/preview/panoramic_001',
  3956. downloadUrl: 'https://panoramic.example.com/download/panoramic_001',
  3957. shareLink: 'https://panoramic.example.com/view/panoramic_001',
  3958. renderTime: 135,
  3959. fileSize: 52428800,
  3960. progress: 100
  3961. }
  3962. ];
  3963. // 初始化一些示例结算记录
  3964. if (this.settlements.length === 0) {
  3965. this.settlements = [
  3966. {
  3967. id: 'settlement_001',
  3968. projectId: this.projectId,
  3969. projectName: '示例项目',
  3970. type: 'deposit',
  3971. amount: 5000,
  3972. percentage: 30,
  3973. status: '已结算',
  3974. createdAt: new Date(Date.now() - 30 * 24 * 60 * 60 * 1000),
  3975. settledAt: new Date(Date.now() - 28 * 24 * 60 * 60 * 1000)
  3976. },
  3977. {
  3978. id: 'settlement_002',
  3979. projectId: this.projectId,
  3980. projectName: '示例项目',
  3981. type: 'progress',
  3982. amount: 7000,
  3983. percentage: 40,
  3984. status: '已结算',
  3985. createdAt: new Date(Date.now() - 15 * 24 * 60 * 60 * 1000),
  3986. settledAt: new Date(Date.now() - 13 * 24 * 60 * 60 * 1000)
  3987. }
  3988. ];
  3989. }
  3990. // 初始化一些示例客户反馈
  3991. if (this.feedbacks.length === 0) {
  3992. this.feedbacks = [
  3993. {
  3994. id: 'feedback_001',
  3995. projectId: this.projectId,
  3996. customerName: '张先生',
  3997. rating: 5,
  3998. content: '设计师非常专业,效果图很满意!',
  3999. isSatisfied: true,
  4000. status: '已解决',
  4001. createdAt: new Date(Date.now() - 5 * 24 * 60 * 60 * 1000)
  4002. }
  4003. ];
  4004. }
  4005. // 初始化一些示例投诉记录
  4006. if (this.exceptionHistories.length === 0) {
  4007. this.exceptionHistories = [];
  4008. }
  4009. }
  4010. // 初始化表单
  4011. initializeForms(): void {
  4012. // 初始化订单分配表单(必填项)
  4013. this.orderCreationForm = this.fb.group({
  4014. orderAmount: ['', [Validators.required, Validators.min(0)]],
  4015. smallImageDeliveryTime: ['', Validators.required],
  4016. decorationType: ['', Validators.required],
  4017. requirementReason: ['', Validators.required],
  4018. isMultiDesigner: [false] // 移除requiredTrue验证,改为普通布尔值
  4019. });
  4020. // 初始化可选信息表单
  4021. this.optionalForm = this.fb.group({
  4022. largeImageDeliveryTime: [''],
  4023. spaceRequirements: [''],
  4024. designAngles: [''],
  4025. specialAreaHandling: [''],
  4026. materialRequirements: [''],
  4027. lightingRequirements: ['']
  4028. });
  4029. }
  4030. // 检查是否可以创建订单
  4031. canCreateOrder(): boolean {
  4032. return this.orderCreationForm ? this.orderCreationForm.valid : false;
  4033. }
  4034. // 创建订单
  4035. createOrder(): void {
  4036. if (!this.canCreateOrder()) {
  4037. // 标记所有字段为已触摸,以显示验证错误
  4038. this.orderCreationForm.markAllAsTouched();
  4039. return;
  4040. }
  4041. const orderData = {
  4042. ...this.orderCreationForm.value,
  4043. ...this.optionalForm.value,
  4044. customerInfo: this.orderCreationData?.customerInfo,
  4045. quotationData: this.quotationData,
  4046. designerAssignment: this.designerAssignmentData
  4047. };
  4048. console.log('创建订单:', orderData);
  4049. // 这里应该调用API创建订单
  4050. // 模拟API调用
  4051. setTimeout(() => {
  4052. alert('订单分配成功!');
  4053. // 订单分配成功后自动切换到下一环节
  4054. this.advanceToNextStage('订单分配');
  4055. }, 500);
  4056. }
  4057. // 处理空间文件选择
  4058. onSpaceFileSelected(event: Event, processId: string, spaceId: string): void {
  4059. const input = event.target as HTMLInputElement;
  4060. if (!input.files || input.files.length === 0) return;
  4061. const files = Array.from(input.files);
  4062. const process = this.deliveryProcesses.find(p => p.id === processId);
  4063. if (!process || !process.content[spaceId]) return;
  4064. files.forEach(file => {
  4065. if (/\.(jpg|jpeg|png)$/i.test(file.name)) {
  4066. const imageItem = this.makeImageItem(file);
  4067. process.content[spaceId].images.push({
  4068. id: imageItem.id,
  4069. name: imageItem.name,
  4070. url: imageItem.url,
  4071. size: this.formatFileSize(file.size)
  4072. });
  4073. }
  4074. });
  4075. // 清空输入
  4076. input.value = '';
  4077. }
  4078. // 更新模型检查项状态
  4079. updateModelCheckItem(itemId: string, isPassed: boolean): void {
  4080. const item = this.modelCheckItems.find(i => i.id === itemId);
  4081. if (item) {
  4082. item.isPassed = isPassed;
  4083. console.log(`模型检查项 ${item.name} 状态更新为: ${isPassed ? '已通过' : '待处理'}`);
  4084. }
  4085. }
  4086. // 删除空间图片
  4087. removeSpaceImage(processId: string, spaceId: string, imageId: string): void {
  4088. const process = this.deliveryProcesses.find(p => p.id === processId);
  4089. if (process && process.content[spaceId]) {
  4090. const images = process.content[spaceId].images;
  4091. const imageIndex = images.findIndex(img => img.id === imageId);
  4092. if (imageIndex > -1) {
  4093. // 释放URL资源
  4094. const image = images[imageIndex];
  4095. if (image.url && image.url.startsWith('blob:')) {
  4096. URL.revokeObjectURL(image.url);
  4097. }
  4098. // 从数组中移除
  4099. images.splice(imageIndex, 1);
  4100. console.log(`已删除空间图片: ${processId}/${spaceId}/${imageId}`);
  4101. }
  4102. }
  4103. }
  4104. // 项目复盘相关方法
  4105. getReviewStatus(): 'not_started' | 'generating' | 'completed' {
  4106. if (this.isGeneratingReview) return 'generating';
  4107. if (this.projectReview) return 'completed';
  4108. return 'not_started';
  4109. }
  4110. getReviewStatusText(): string {
  4111. const status = this.getReviewStatus();
  4112. switch (status) {
  4113. case 'not_started': return '未开始';
  4114. case 'generating': return '生成中';
  4115. case 'completed': return '已完成';
  4116. default: return '未知';
  4117. }
  4118. }
  4119. getScoreClass(score: number): string {
  4120. if (score >= 90) return 'excellent';
  4121. if (score >= 80) return 'good';
  4122. if (score >= 70) return 'average';
  4123. return 'poor';
  4124. }
  4125. getExecutionStatusText(status: 'excellent' | 'good' | 'average' | 'poor'): string {
  4126. switch (status) {
  4127. case 'excellent': return '优秀';
  4128. case 'good': return '良好';
  4129. case 'average': return '一般';
  4130. case 'poor': return '较差';
  4131. default: return '未知';
  4132. }
  4133. }
  4134. generateReviewReport(): void {
  4135. if (this.isGeneratingReview) return;
  4136. this.isGeneratingReview = true;
  4137. // 基于真实项目数据生成复盘报告
  4138. setTimeout(() => {
  4139. const sopAnalysisData = this.analyzeSopExecution();
  4140. const experienceInsights = this.generateExperienceInsights();
  4141. const performanceMetrics = this.calculatePerformanceMetrics();
  4142. const plannedBudget = this.quotationData.totalAmount || 150000;
  4143. const actualBudget = this.calculateActualBudget();
  4144. this.projectReview = {
  4145. id: 'review_' + Date.now(),
  4146. projectId: this.projectId,
  4147. generatedAt: new Date(),
  4148. overallScore: this.calculateOverallScore(),
  4149. sopAnalysis: sopAnalysisData,
  4150. keyHighlights: experienceInsights.keyHighlights,
  4151. improvementSuggestions: experienceInsights.improvementSuggestions,
  4152. customerSatisfaction: {
  4153. overallRating: this.reviewStats.overallScore,
  4154. feedback: this.detailedReviews.length > 0 ? this.detailedReviews[0].overallFeedback : '客户反馈良好,对项目整体满意',
  4155. responseTime: this.calculateAverageResponseTime(),
  4156. completionTime: this.calculateProjectDuration()
  4157. },
  4158. teamPerformance: performanceMetrics,
  4159. budgetAnalysis: {
  4160. plannedBudget: plannedBudget,
  4161. actualBudget: actualBudget,
  4162. variance: this.calculateBudgetVariance(plannedBudget, actualBudget),
  4163. costBreakdown: [
  4164. { category: '设计费', planned: plannedBudget * 0.3, actual: actualBudget * 0.3 },
  4165. { category: '材料费', planned: plannedBudget * 0.6, actual: actualBudget * 0.57 },
  4166. { category: '人工费', planned: plannedBudget * 0.1, actual: actualBudget * 0.13 }
  4167. ]
  4168. },
  4169. lessonsLearned: experienceInsights.lessonsLearned,
  4170. recommendations: experienceInsights.recommendations
  4171. };
  4172. this.isGeneratingReview = false;
  4173. alert('复盘报告生成完成!基于真实SOP执行数据和智能分析生成。');
  4174. }, 3000);
  4175. }
  4176. regenerateReviewReport(): void {
  4177. this.projectReview = null;
  4178. this.generateReviewReport();
  4179. }
  4180. exportReviewReport(): void {
  4181. if (!this.projectReview) return;
  4182. const exportRequest: ReviewReportExportRequest = {
  4183. projectId: this.projectId,
  4184. reviewId: this.projectReview.id,
  4185. format: 'pdf',
  4186. includeCharts: true,
  4187. includeDetails: true,
  4188. language: 'zh-CN'
  4189. };
  4190. this.projectReviewService.exportReviewReport(exportRequest).subscribe({
  4191. next: (response) => {
  4192. if (response.success && response.downloadUrl) {
  4193. // 创建下载链接
  4194. const link = document.createElement('a');
  4195. link.href = response.downloadUrl;
  4196. link.download = response.fileName || `复盘报告_${this.project?.name || '项目'}_${new Date().toISOString().split('T')[0]}.pdf`;
  4197. document.body.appendChild(link);
  4198. link.click();
  4199. document.body.removeChild(link);
  4200. alert('复盘报告导出成功!');
  4201. } else {
  4202. alert('导出失败:' + (response.message || '未知错误'));
  4203. }
  4204. },
  4205. error: (error) => {
  4206. console.error('导出复盘报告失败:', error);
  4207. alert('导出失败,请稍后重试');
  4208. }
  4209. });
  4210. }
  4211. shareReviewReport(): void {
  4212. if (!this.projectReview) return;
  4213. const shareRequest: ReviewReportShareRequest = {
  4214. projectId: this.projectId,
  4215. reviewId: this.projectReview.id,
  4216. shareType: 'link',
  4217. expirationDays: 30,
  4218. allowDownload: true,
  4219. requirePassword: false
  4220. };
  4221. this.projectReviewService.shareReviewReport(shareRequest).subscribe({
  4222. next: (response) => {
  4223. if (response.success && response.shareUrl) {
  4224. // 复制到剪贴板
  4225. if (navigator.clipboard) {
  4226. navigator.clipboard.writeText(response.shareUrl).then(() => {
  4227. alert(`复盘报告分享链接已复制到剪贴板!\n链接有效期:${response.expirationDate ? new Date(response.expirationDate).toLocaleDateString() : '30天'}`);
  4228. }).catch(() => {
  4229. alert(`复盘报告分享链接:\n${response.shareUrl}\n\n链接有效期:${response.expirationDate ? new Date(response.expirationDate).toLocaleDateString() : '30天'}`);
  4230. });
  4231. } else {
  4232. alert(`复盘报告分享链接:\n${response.shareUrl}\n\n链接有效期:${response.expirationDate ? new Date(response.expirationDate).toLocaleDateString() : '30天'}`);
  4233. }
  4234. } else {
  4235. alert('分享失败:' + (response.message || '未知错误'));
  4236. }
  4237. },
  4238. error: (error) => {
  4239. console.error('分享复盘报告失败:', error);
  4240. alert('分享失败,请稍后重试');
  4241. }
  4242. });
  4243. }
  4244. // 项目复盘工具方法
  4245. getMaxDuration(): number {
  4246. if (!this.sopStagesData || this.sopStagesData.length === 0) return 1;
  4247. return Math.max(...this.sopStagesData.map(s => Math.max(s.plannedDuration, s.actualDuration)));
  4248. }
  4249. getAverageScore(): number {
  4250. if (!this.sopStagesData || this.sopStagesData.length === 0) return 0;
  4251. const sum = this.sopStagesData.reduce((acc, s) => acc + s.score, 0);
  4252. return Math.round(sum / this.sopStagesData.length);
  4253. }
  4254. getSuggestionCountByPriority(priority: string): number {
  4255. if (!this.optimizationSuggestions) return 0;
  4256. return this.optimizationSuggestions.filter(s => s.priority === priority).length;
  4257. }
  4258. getAverageImprovementPercent(): number {
  4259. if (!this.optimizationSuggestions || this.optimizationSuggestions.length === 0) return 0;
  4260. return 25;
  4261. }
  4262. acceptSuggestion(suggestion: any): void {
  4263. console.log('采纳建议:', suggestion);
  4264. }
  4265. viewSuggestionDetail(suggestion: any): void {
  4266. console.log('查看建议详情:', suggestion);
  4267. }
  4268. // 分析SOP执行情况
  4269. private analyzeSopExecution(): any[] {
  4270. const sopStages = [
  4271. { name: '需求沟通', planned: 3, actual: 2.5 },
  4272. { name: '方案确认', planned: 5, actual: 4 },
  4273. { name: '建模', planned: 7, actual: 8 },
  4274. { name: '软装', planned: 3, actual: 3.5 },
  4275. { name: '渲染', planned: 5, actual: 4.5 },
  4276. { name: '后期', planned: 2, actual: 2 }
  4277. ];
  4278. return sopStages.map(stage => {
  4279. const variance = ((stage.actual - stage.planned) / stage.planned) * 100;
  4280. let executionStatus: 'excellent' | 'good' | 'average' | 'poor';
  4281. let score: number;
  4282. if (variance <= -10) {
  4283. executionStatus = 'excellent';
  4284. score = 95;
  4285. } else if (variance <= 0) {
  4286. executionStatus = 'good';
  4287. score = 85;
  4288. } else if (variance <= 20) {
  4289. executionStatus = 'average';
  4290. score = 70;
  4291. } else {
  4292. executionStatus = 'poor';
  4293. score = 50;
  4294. }
  4295. const issues: string[] = [];
  4296. if (variance > 20) {
  4297. issues.push('执行时间超出计划较多');
  4298. }
  4299. if (stage.name === '建模' && variance > 0) {
  4300. issues.push('建模阶段需要优化流程');
  4301. }
  4302. return {
  4303. stageName: stage.name,
  4304. plannedDuration: stage.planned,
  4305. actualDuration: stage.actual,
  4306. score,
  4307. executionStatus,
  4308. issues: issues.length > 0 ? issues : undefined
  4309. };
  4310. });
  4311. }
  4312. // 生成经验洞察
  4313. private generateExperienceInsights(): { keyHighlights: string[]; improvementSuggestions: string[]; lessonsLearned: string[]; recommendations: string[] } {
  4314. return {
  4315. keyHighlights: [
  4316. '需求沟通阶段效率显著提升,客户满意度高',
  4317. '渲染质量获得客户高度认可',
  4318. '团队协作配合默契,沟通顺畅',
  4319. '项目交付时间控制良好'
  4320. ],
  4321. improvementSuggestions: [
  4322. '建模阶段可以进一步优化工作流程',
  4323. '加强前期需求确认的深度和准确性',
  4324. '建立更完善的质量检查机制',
  4325. '提升跨部门协作效率'
  4326. ],
  4327. lessonsLearned: [
  4328. '充分的前期沟通能显著减少后期修改',
  4329. '标准化流程有助于提高执行效率',
  4330. '及时的客户反馈对项目成功至关重要',
  4331. '团队技能匹配度直接影响项目质量'
  4332. ],
  4333. recommendations: [
  4334. '建议在类似项目中复用成功的沟通模式',
  4335. '可以将本项目的渲染标准作为团队参考',
  4336. '建议建立项目经验知识库',
  4337. '推荐定期进行团队技能培训'
  4338. ]
  4339. };
  4340. }
  4341. // 计算绩效指标
  4342. private calculatePerformanceMetrics(): { designerScore: number; communicationScore: number; timelinessScore: number; qualityScore: number } {
  4343. return {
  4344. designerScore: 88,
  4345. communicationScore: 92,
  4346. timelinessScore: 85,
  4347. qualityScore: 90
  4348. };
  4349. }
  4350. // 计算总体评分
  4351. private calculateOverallScore(): number {
  4352. const metrics = this.calculatePerformanceMetrics();
  4353. return Math.round((metrics.designerScore + metrics.communicationScore + metrics.timelinessScore + metrics.qualityScore) / 4);
  4354. }
  4355. // 计算平均响应时间
  4356. private calculateAverageResponseTime(): number {
  4357. // 模拟计算平均响应时间(小时)
  4358. return 2.5;
  4359. }
  4360. // 计算项目持续时间
  4361. private calculateProjectDuration(): number {
  4362. // 模拟计算项目持续时间(天)
  4363. return 28;
  4364. }
  4365. // 计算实际预算
  4366. private calculateActualBudget(): number {
  4367. // 基于订单金额计算实际预算
  4368. return this.orderAmount || 150000;
  4369. }
  4370. // 计算预算偏差
  4371. private calculateBudgetVariance(plannedBudget: number, actualBudget: number): number {
  4372. return ((actualBudget - plannedBudget) / plannedBudget) * 100;
  4373. }
  4374. formatDateTime(date: Date): string {
  4375. return date.toLocaleString('zh-CN', {
  4376. year: 'numeric',
  4377. month: '2-digit',
  4378. day: '2-digit',
  4379. hour: '2-digit',
  4380. minute: '2-digit'
  4381. });
  4382. }
  4383. // ============ 空间管理相关方法 ============
  4384. // 添加新空间
  4385. addSpace(processId: string): void {
  4386. const spaceName = this.newSpaceName[processId]?.trim();
  4387. if (!spaceName) return;
  4388. const process = this.deliveryProcesses.find(p => p.id === processId);
  4389. if (!process) return;
  4390. // 生成新的空间ID
  4391. const spaceId = `space_${Date.now()}`;
  4392. // 添加到spaces数组
  4393. const newSpace: DeliverySpace = {
  4394. id: spaceId,
  4395. name: spaceName,
  4396. isExpanded: false,
  4397. order: process.spaces.length + 1
  4398. };
  4399. process.spaces.push(newSpace);
  4400. // 初始化content数据
  4401. process.content[spaceId] = {
  4402. images: [],
  4403. progress: 0,
  4404. status: 'pending',
  4405. notes: '',
  4406. lastUpdated: new Date()
  4407. };
  4408. // 清空输入框并隐藏
  4409. this.newSpaceName[processId] = '';
  4410. this.showAddSpaceInput[processId] = false;
  4411. console.log(`已添加空间: ${spaceName} 到流程 ${process.name}`);
  4412. }
  4413. // 取消添加空间
  4414. cancelAddSpace(processId: string): void {
  4415. this.newSpaceName[processId] = '';
  4416. this.showAddSpaceInput[processId] = false;
  4417. }
  4418. // 获取指定流程的活跃空间列表
  4419. getActiveProcessSpaces(processId: string): DeliverySpace[] {
  4420. const process = this.deliveryProcesses.find(p => p.id === processId);
  4421. if (!process) return [];
  4422. return process.spaces.sort((a, b) => a.order - b.order);
  4423. }
  4424. // 切换空间展开状态
  4425. toggleSpace(processId: string, spaceId: string): void {
  4426. const process = this.deliveryProcesses.find(p => p.id === processId);
  4427. if (!process) return;
  4428. const space = process.spaces.find(s => s.id === spaceId);
  4429. if (space) {
  4430. space.isExpanded = !space.isExpanded;
  4431. }
  4432. }
  4433. // 获取空间进度
  4434. getSpaceProgress(processId: string, spaceId: string): number {
  4435. const process = this.deliveryProcesses.find(p => p.id === processId);
  4436. if (!process || !process.content[spaceId]) return 0;
  4437. return process.content[spaceId].progress || 0;
  4438. }
  4439. // 删除空间
  4440. removeSpace(processId: string, spaceId: string): void {
  4441. const process = this.deliveryProcesses.find(p => p.id === processId);
  4442. if (!process) return;
  4443. // 从spaces数组中移除
  4444. const spaceIndex = process.spaces.findIndex(s => s.id === spaceId);
  4445. if (spaceIndex > -1) {
  4446. const spaceName = process.spaces[spaceIndex].name;
  4447. process.spaces.splice(spaceIndex, 1);
  4448. // 清理content数据
  4449. if (process.content[spaceId]) {
  4450. // 释放图片URL资源
  4451. process.content[spaceId].images.forEach(img => {
  4452. if (img.url && img.url.startsWith('blob:')) {
  4453. URL.revokeObjectURL(img.url);
  4454. }
  4455. });
  4456. delete process.content[spaceId];
  4457. }
  4458. console.log(`已删除空间: ${spaceName} 从流程 ${process.name}`);
  4459. }
  4460. }
  4461. // 触发空间文件输入
  4462. triggerSpaceFileInput(processId: string, spaceId: string): void {
  4463. const inputId = `space-file-input-${processId}-${spaceId}`;
  4464. const input = document.getElementById(inputId) as HTMLInputElement;
  4465. if (input) {
  4466. input.click();
  4467. }
  4468. }
  4469. // 处理空间文件拖拽
  4470. onSpaceFileDrop(event: DragEvent, processId: string, spaceId: string): void {
  4471. event.preventDefault();
  4472. event.stopPropagation();
  4473. const files = event.dataTransfer?.files;
  4474. if (!files || files.length === 0) return;
  4475. this.handleSpaceFiles(Array.from(files), processId, spaceId);
  4476. }
  4477. // 处理空间文件
  4478. private handleSpaceFiles(files: File[], processId: string, spaceId: string): void {
  4479. const process = this.deliveryProcesses.find(p => p.id === processId);
  4480. if (!process || !process.content[spaceId]) return;
  4481. files.forEach(file => {
  4482. if (/\.(jpg|jpeg|png|gif|bmp|webp)$/i.test(file.name)) {
  4483. const imageItem = this.makeImageItem(file);
  4484. process.content[spaceId].images.push({
  4485. id: imageItem.id,
  4486. name: imageItem.name,
  4487. url: imageItem.url,
  4488. size: this.formatFileSize(file.size),
  4489. reviewStatus: 'pending'
  4490. });
  4491. // 更新进度
  4492. this.updateSpaceProgress(processId, spaceId);
  4493. }
  4494. });
  4495. }
  4496. // 获取空间图片列表
  4497. getSpaceImages(processId: string, spaceId: string): Array<{ id: string; name: string; url: string; size?: string; reviewStatus?: 'pending' | 'approved' | 'rejected' }> {
  4498. const process = this.deliveryProcesses.find(p => p.id === processId);
  4499. if (!process || !process.content[spaceId]) return [];
  4500. return process.content[spaceId].images || [];
  4501. }
  4502. // 确认阶段上传并推进工作流
  4503. confirmStageUpload(stageId: string): void {
  4504. const stageMap: { [key: string]: ProjectStage } = {
  4505. 'modeling': '建模',
  4506. 'softDecor': '软装',
  4507. 'rendering': '渲染',
  4508. 'postProduction': '后期'
  4509. };
  4510. const currentStage = stageMap[stageId];
  4511. if (!currentStage) return;
  4512. // 检查当前阶段是否有上传的图片
  4513. const process = this.deliveryProcesses.find(p => p.id === stageId);
  4514. if (!process) return;
  4515. const hasImages = Object.values(process.content).some(space =>
  4516. space.images && space.images.length > 0
  4517. );
  4518. if (!hasImages) {
  4519. alert('请先上传图片再确认');
  4520. return;
  4521. }
  4522. // 推进到下一阶段
  4523. const currentIndex = this.stageOrder.indexOf(currentStage);
  4524. if (currentIndex < this.stageOrder.length - 1) {
  4525. const nextStage = this.stageOrder[currentIndex + 1];
  4526. // 更新当前阶段
  4527. this.currentStage = nextStage;
  4528. if (this.project) {
  4529. this.project.currentStage = nextStage;
  4530. }
  4531. // 展开下一阶段
  4532. this.expandedStages[nextStage] = true;
  4533. // 滚动到下一阶段
  4534. setTimeout(() => {
  4535. this.scrollToStage(nextStage);
  4536. }, 100);
  4537. console.log(`阶段推进: ${currentStage} -> ${nextStage}`);
  4538. } else {
  4539. // 如果是最后一个阶段,标记为完成
  4540. console.log(`交付执行阶段完成: ${currentStage}`);
  4541. alert('交付执行阶段已完成!');
  4542. }
  4543. }
  4544. // 检查是否可以确认阶段上传
  4545. canConfirmStageUpload(stageId: string): boolean {
  4546. // 检查是否有上传的图片
  4547. const process = this.deliveryProcesses.find(p => p.id === stageId);
  4548. if (!process) return false;
  4549. return Object.values(process.content).some(space =>
  4550. space.images && space.images.length > 0
  4551. );
  4552. }
  4553. // 获取空间备注
  4554. getSpaceNotes(processId: string, spaceId: string): string {
  4555. const process = this.deliveryProcesses.find(p => p.id === processId);
  4556. if (!process || !process.content[spaceId]) return '';
  4557. return process.content[spaceId].notes || '';
  4558. }
  4559. // 更新空间备注
  4560. updateSpaceNotes(processId: string, spaceId: string, notes: string): void {
  4561. const process = this.deliveryProcesses.find(p => p.id === processId);
  4562. if (!process || !process.content[spaceId]) return;
  4563. process.content[spaceId].notes = notes;
  4564. process.content[spaceId].lastUpdated = new Date();
  4565. console.log(`已更新空间备注: ${processId}/${spaceId}`);
  4566. }
  4567. // 更新空间进度
  4568. private updateSpaceProgress(processId: string, spaceId: string): void {
  4569. const process = this.deliveryProcesses.find(p => p.id === processId);
  4570. if (!process || !process.content[spaceId]) return;
  4571. const content = process.content[spaceId];
  4572. const imageCount = content.images.length;
  4573. // 根据图片数量和状态计算进度
  4574. if (imageCount === 0) {
  4575. content.progress = 0;
  4576. content.status = 'pending';
  4577. } else if (imageCount < 3) {
  4578. content.progress = Math.min(imageCount * 30, 90);
  4579. content.status = 'in_progress';
  4580. } else {
  4581. content.progress = 100;
  4582. content.status = 'completed';
  4583. }
  4584. content.lastUpdated = new Date();
  4585. }
  4586. // ==================== 功能卡片点击事件 ====================
  4587. /**
  4588. * 显示功能详情
  4589. * @param title 功能标题
  4590. * @param description 功能详细描述
  4591. */
  4592. showFeatureDetail(title: string, description: string): void {
  4593. console.log(`📋 功能详情: ${title}`);
  4594. console.log(`📝 ${description}`);
  4595. alert(`✨ ${title}\n\n${description}\n\n点击确定关闭`);
  4596. }
  4597. }