index.vue 163 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851
  1. <template>
  2. <div class="app-container">
  3. <el-card class="box-card">
  4. <!-- 培训申请子选项卡 -->
  5. <el-tabs v-model="trainingSubTab" @tab-click="handleTrainingSubTabClick">
  6. <el-tab-pane label="培训申请" name="application" v-hasPermi="['rs:trainingapplication:list']">
  7. <!-- 搜索区域 -->
  8. <transition :enter-active-class="animate.searchAnimate.enter" :leave-active-class="animate.searchAnimate.leave">
  9. <div v-show="showApplicationSearch" class="mb-[10px]">
  10. <el-card shadow="hover">
  11. <el-form ref="applicationQueryForm" :model="applicationQueryParams" label-width="100px">
  12. <el-row :gutter="20">
  13. <el-col :span="6">
  14. <el-form-item label="课程名称" prop="courseName">
  15. <el-input
  16. v-model="applicationQueryParams.courseName"
  17. placeholder="请输入课程名称"
  18. clearable
  19. @keyup.enter="handleApplicationQuery"
  20. />
  21. </el-form-item>
  22. </el-col>
  23. <el-col :span="6">
  24. <el-form-item label="培训地点" prop="location">
  25. <el-input
  26. v-model="applicationQueryParams.location"
  27. placeholder="请输入培训地点"
  28. clearable
  29. @keyup.enter="handleApplicationQuery"
  30. />
  31. </el-form-item>
  32. </el-col>
  33. <el-col :span="6">
  34. <el-form-item label="状态" prop="status">
  35. <el-select v-model="applicationQueryParams.status" placeholder="请选择状态" clearable style="width: 100%">
  36. <el-option v-for="dict in applicationStatusOptions" :key="dict.value" :label="dict.label" :value="dict.value" />
  37. </el-select>
  38. </el-form-item>
  39. </el-col>
  40. </el-row>
  41. <el-row>
  42. <el-col :span="24" class="search-btn-container">
  43. <el-form-item>
  44. <el-button type="primary" icon="Search" @click="handleApplicationQuery">搜索</el-button>
  45. <el-button icon="Refresh" @click="resetApplicationQuery">重置</el-button>
  46. </el-form-item>
  47. </el-col>
  48. </el-row>
  49. </el-form>
  50. </el-card>
  51. </div>
  52. </transition>
  53. <!-- 操作按钮区域 -->
  54. <el-card shadow="never" class="button-card table-card">
  55. <template #header>
  56. <el-row :gutter="10" class="mb8">
  57. <el-col :span="1.5">
  58. <el-button type="primary" plain icon="Plus" @click="handleAddApplication" v-hasPermi="['rs:trainingapplication:add']"
  59. >申请培训</el-button
  60. >
  61. </el-col>
  62. <el-col :span="1.5">
  63. <el-button
  64. icon="Download"
  65. @click="handleExportTrainingApplication"
  66. v-hasPermi="['rs:trainingapplication:export']"
  67. style="display: none"
  68. >导出</el-button
  69. >
  70. </el-col>
  71. <right-toolbar v-model:showSearch="showApplicationSearch" @queryTable="getApplicationList"></right-toolbar>
  72. </el-row>
  73. </template>
  74. <!-- 培训申请表格 -->
  75. <el-table v-loading="applicationLoading" border :data="applicationList" @row-dblclick="handleViewApplicant">
  76. <el-table-column label="主办单位" align="center" prop="organizerUnit" min-width="160" :show-overflow-tooltip="true" />
  77. <el-table-column label="培训地点" align="center" prop="location" min-width="120" :show-overflow-tooltip="true" />
  78. <el-table-column label="培训类型" align="center" prop="trainingType" min-width="120" :show-overflow-tooltip="true" />
  79. <el-table-column label="开始时间" align="center" prop="startTime" width="120">
  80. <template #default="scope">
  81. <span>{{ parseTime(scope.row.startTime, '{y}-{m}-{d}') || '暂无' }}</span>
  82. </template>
  83. </el-table-column>
  84. <el-table-column label="结束时间" align="center" prop="endTime" width="120">
  85. <template #default="scope">
  86. <span>{{ parseTime(scope.row.endTime, '{y}-{m}-{d}') || '暂无' }}</span>
  87. </template>
  88. </el-table-column>
  89. <el-table-column label="申请时间" align="center" prop="applyTime" width="160">
  90. <template #default="scope">
  91. <span>{{ parseTime(scope.row.applyTime) }}</span>
  92. </template>
  93. </el-table-column>
  94. <el-table-column label="申请状态" align="center" prop="status" width="100">
  95. <template #default="scope">
  96. <el-tag
  97. :type="scope.row.status === '0' ? 'warning' : scope.row.status === '1' ? 'success' : scope.row.status === '2' ? 'danger' : 'info'"
  98. >
  99. {{ getStatusLabel(scope.row.status) }}
  100. </el-tag>
  101. </template>
  102. </el-table-column>
  103. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="220">
  104. <template #default="scope">
  105. <el-tooltip content="查看详情" placement="top">
  106. <el-button
  107. link
  108. type="primary"
  109. icon="View"
  110. @click="handleViewApplicant(scope.row)"
  111. v-hasPermi="['rs:trainingapplication:query']"
  112. ></el-button>
  113. </el-tooltip>
  114. <!-- 待审核状态:显示撤回按钮 -->
  115. <el-tooltip content="撤回申请" placement="top" v-if="scope.row.status === '0'">
  116. <el-button
  117. link
  118. type="warning"
  119. icon="RefreshLeft"
  120. @click="handleCancelApplication(scope.row)"
  121. v-hasPermi="['rs:trainingapplication:cancel']"
  122. ></el-button>
  123. </el-tooltip>
  124. <!-- 已拒绝状态:显示重新提交按钮(需要修改并重新提交权限) -->
  125. <el-tooltip content="重新提交" placement="top" v-if="scope.row.status === '2'">
  126. <el-button
  127. link
  128. type="success"
  129. icon="RefreshRight"
  130. @click="handleUpdateAndResubmitApplication(scope.row)"
  131. v-hasPermi="['rs:trainingapplication:edit', 'rs:trainingapplication:submit']"
  132. ></el-button>
  133. </el-tooltip>
  134. <!-- 已通过和已拒绝状态:显示审批历史 -->
  135. <el-tooltip content="审批历史" placement="top" v-if="scope.row.status === '1' || scope.row.status === '2'">
  136. <el-button link type="info" icon="InfoFilled" @click="handleViewHistory(scope.row)"></el-button>
  137. </el-tooltip>
  138. <!-- 删除按钮:仅在未通过的状态下显示(待审核、已拒绝、已取消) -->
  139. <el-tooltip content="删除" placement="top" v-if="scope.row.status !== '1'">
  140. <el-button
  141. link
  142. type="danger"
  143. icon="Delete"
  144. @click="handleDeleteApplication(scope.row)"
  145. v-hasPermi="['rs:trainingapplication:remove']"
  146. ></el-button>
  147. </el-tooltip>
  148. </template>
  149. </el-table-column>
  150. </el-table>
  151. <div class="pagination-container">
  152. <pagination
  153. v-show="applicationTotal > 0"
  154. :total="applicationTotal"
  155. v-model:page="applicationQueryParams.pageNum"
  156. v-model:limit="applicationQueryParams.pageSize"
  157. @pagination="getApplicationList"
  158. />
  159. </div>
  160. </el-card>
  161. </el-tab-pane>
  162. <el-tab-pane label="培训记录" name="record" v-hasPermi="['rs:trainingrecord:list']">
  163. <!-- 搜索区域 -->
  164. <transition :enter-active-class="animate.searchAnimate.enter" :leave-active-class="animate.searchAnimate.leave">
  165. <div v-show="showRecordSearch" class="mb-[10px]">
  166. <el-card shadow="hover">
  167. <el-form ref="recordQueryForm" :model="recordQueryParams" label-width="100px">
  168. <el-row :gutter="20">
  169. <el-col :span="6">
  170. <el-form-item label="课程名称" prop="courseName">
  171. <el-input v-model="recordQueryParams.courseName" placeholder="请输入课程名称" clearable @keyup.enter="handleRecordQuery" />
  172. </el-form-item>
  173. </el-col>
  174. <el-col :span="6">
  175. <el-form-item label="培训地点" prop="location">
  176. <el-input v-model="recordQueryParams.location" placeholder="请输入培训地点" clearable @keyup.enter="handleRecordQuery" />
  177. </el-form-item>
  178. </el-col>
  179. <el-col :span="6">
  180. <el-form-item label="部门" prop="department">
  181. <el-input v-model="recordQueryParams.department" placeholder="请输入部门" clearable style="width: 100%" />
  182. </el-form-item>
  183. </el-col>
  184. </el-row>
  185. <el-row>
  186. <el-col :span="24" class="search-btn-container">
  187. <el-form-item>
  188. <el-button type="primary" icon="Search" @click="handleRecordQuery">搜索</el-button>
  189. <el-button icon="Refresh" @click="resetRecordQuery">重置</el-button>
  190. </el-form-item>
  191. </el-col>
  192. </el-row>
  193. </el-form>
  194. </el-card>
  195. </div>
  196. </transition>
  197. <!-- 培训记录管理内容 -->
  198. <el-card shadow="never" class="table-card">
  199. <template #header>
  200. <el-row :gutter="10" class="mb8">
  201. <el-col :span="1.5">
  202. <el-button icon="Download" @click="handleExportRecord" v-hasPermi="['rs:trainingrecord:export']" style="display: none"
  203. >导出</el-button
  204. >
  205. </el-col>
  206. <right-toolbar v-model:showSearch="showRecordSearch" @queryTable="getRecordList"></right-toolbar>
  207. </el-row>
  208. </template>
  209. <!-- 培训记录表格 -->
  210. <el-table
  211. v-loading="recordLoading"
  212. border
  213. :data="recordList"
  214. @selection-change="handleRecordSelectionChange"
  215. @row-dblclick="handleViewRecord"
  216. >
  217. <el-table-column type="selection" width="55" align="center" />
  218. <!-- 主办单位:从申请表course_name字段关联获取 -->
  219. <el-table-column label="主办单位" align="center" prop="organizerUnit" min-width="150" :show-overflow-tooltip="true">
  220. <template #default="scope">
  221. <span>{{ scope.row.organizerUnit || '暂无' }}</span>
  222. </template>
  223. </el-table-column>
  224. <!-- 培训类型:从申请表training_type字段关联获取 -->
  225. <el-table-column label="培训类型" align="center" prop="trainingType" min-width="110" :show-overflow-tooltip="true">
  226. <template #default="scope">
  227. <span>{{ scope.row.trainingType || '暂无' }}</span>
  228. </template>
  229. </el-table-column>
  230. <!-- 开始时间:从记录表start_time字段获取 -->
  231. <el-table-column label="开始时间" align="center" prop="startTime" width="120">
  232. <template #default="scope">
  233. <span>{{ parseTime(scope.row.startTime, '{y}-{m}-{d}') || '暂无' }}</span>
  234. </template>
  235. </el-table-column>
  236. <!-- 结束时间:从记录表end_time字段获取 -->
  237. <el-table-column label="结束时间" align="center" prop="endTime" width="120">
  238. <template #default="scope">
  239. <span>{{ parseTime(scope.row.endTime, '{y}-{m}-{d}') || '暂无' }}</span>
  240. </template>
  241. </el-table-column>
  242. <!-- 同行人员:从申请表companions字段关联获取,格式化为教师姓名 -->
  243. <el-table-column label="同行人员" align="center" prop="companions" min-width="120" :show-overflow-tooltip="true">
  244. <template #default="scope">
  245. <span v-if="scope.row.companions && scope.row.companions !== '[]'">
  246. {{ formatCompanions(scope.row.companions) }}
  247. </span>
  248. <span v-else>无</span>
  249. </template>
  250. </el-table-column>
  251. <el-table-column label="完成状态" align="center" prop="completionStatus" width="100">
  252. <template #default="scope">
  253. <el-tag :type="getCompletionStatusType(scope.row.completionStatus)">
  254. {{ getCompletionStatusLabel(scope.row.completionStatus) }}
  255. </el-tag>
  256. </template>
  257. </el-table-column>
  258. <el-table-column label="操作" align="center" width="150">
  259. <template #default="scope">
  260. <el-tooltip content="查看" placement="top">
  261. <el-button
  262. link
  263. type="primary"
  264. icon="View"
  265. @click.stop="handleViewRecord(scope.row)"
  266. v-hasPermi="['rs:trainingrecord:query']"
  267. ></el-button>
  268. </el-tooltip>
  269. <el-tooltip content="删除" placement="top">
  270. <el-button
  271. link
  272. type="danger"
  273. icon="Delete"
  274. @click.stop="handleDeleteRecord(scope.row)"
  275. v-hasPermi="['rs:trainingrecord:remove']"
  276. ></el-button>
  277. </el-tooltip>
  278. </template>
  279. </el-table-column>
  280. </el-table>
  281. <div class="pagination-container">
  282. <pagination
  283. v-show="recordTotal > 0"
  284. :total="recordTotal"
  285. v-model:page="recordQueryParams.pageNum"
  286. v-model:limit="recordQueryParams.pageSize"
  287. @pagination="getRecordList"
  288. />
  289. </div>
  290. </el-card>
  291. </el-tab-pane>
  292. </el-tabs>
  293. </el-card>
  294. <!-- 添加或修改培训课程对话框 -->
  295. <el-dialog :title="courseDialogTitle" v-model="courseDialogVisible" width="700px" append-to-body>
  296. <el-form ref="courseFormRef" :model="courseForm" :rules="courseRules" label-width="100px">
  297. <el-form-item label="课程名称" prop="title">
  298. <el-input v-model="courseForm.title" placeholder="请输入课程名称" />
  299. </el-form-item>
  300. <el-form-item label="课程类别" prop="category">
  301. <el-select v-model="courseForm.category" placeholder="请选择课程类别" style="width: 100%">
  302. <el-option v-for="dict in rs_training_category" :key="dict.value" :label="dict.label" :value="dict.value" />
  303. </el-select>
  304. </el-form-item>
  305. <el-form-item label="开始时间" prop="startTime">
  306. <el-date-picker
  307. v-model="courseForm.startTime"
  308. type="datetime"
  309. placeholder="选择开始时间"
  310. style="width: 100%"
  311. value-format="YYYY-MM-DD HH:mm:ss"
  312. />
  313. </el-form-item>
  314. <el-form-item label="结束时间" prop="endTime">
  315. <el-date-picker
  316. v-model="courseForm.endTime"
  317. type="datetime"
  318. placeholder="选择结束时间"
  319. style="width: 100%"
  320. value-format="YYYY-MM-DD HH:mm:ss"
  321. />
  322. </el-form-item>
  323. <el-form-item label="学时数" prop="duration">
  324. <el-input-number v-model="courseForm.duration" :min="1" :max="999" controls-position="right" style="width: 100%" />
  325. </el-form-item>
  326. <el-form-item label="培训地点" prop="location">
  327. <el-input v-model="courseForm.location" placeholder="请输入培训地点" />
  328. </el-form-item>
  329. <el-form-item label="课程描述" prop="description">
  330. <el-input v-model="courseForm.description" type="textarea" placeholder="请输入课程描述" :rows="4" />
  331. </el-form-item>
  332. <el-form-item label="状态" prop="status" v-if="courseForm.courseId">
  333. <el-radio-group v-model="courseForm.status">
  334. <el-radio label="0">正常</el-radio>
  335. <el-radio label="1">结束</el-radio>
  336. </el-radio-group>
  337. </el-form-item>
  338. <el-form-item label="备注" prop="remark">
  339. <el-input v-model="courseForm.remark" type="textarea" placeholder="请输入备注" />
  340. </el-form-item>
  341. </el-form>
  342. <template #footer>
  343. <div class="dialog-footer">
  344. <el-button :loading="courseDialogLoading" type="primary" @click="submitCourseForm">确 定</el-button>
  345. <el-button @click="cancelCourseDialog">取 消</el-button>
  346. </div>
  347. </template>
  348. </el-dialog>
  349. <!-- 查看培训课程详情对话框 -->
  350. <el-dialog title="培训课程详情" v-model="courseDetailDialogVisible" width="700px" append-to-body>
  351. <el-descriptions :column="2" border>
  352. <el-descriptions-item label="课程名称">{{ courseDetail.title }}</el-descriptions-item>
  353. <el-descriptions-item label="课程类别">{{ getCategoryLabel(courseDetail.category) }}</el-descriptions-item>
  354. <el-descriptions-item label="开始时间">{{ parseTime(courseDetail.startTime) }}</el-descriptions-item>
  355. <el-descriptions-item label="结束时间">{{ parseTime(courseDetail.endTime) }}</el-descriptions-item>
  356. <el-descriptions-item label="学时数">{{ courseDetail.duration }}</el-descriptions-item>
  357. <el-descriptions-item label="培训地点">{{ courseDetail.location || '暂无' }}</el-descriptions-item>
  358. <el-descriptions-item label="已报名人数">{{ courseDetail.currentParticipants || 0 }}</el-descriptions-item>
  359. <el-descriptions-item label="状态">
  360. <el-tag :type="courseDetail.status === '0' ? 'success' : 'info'">
  361. {{ courseDetail.status === '0' ? '正常' : '结束' }}
  362. </el-tag>
  363. </el-descriptions-item>
  364. <el-descriptions-item label="创建时间">{{ parseTime(courseDetail.createTime) }}</el-descriptions-item>
  365. <el-descriptions-item label="课程描述" :span="2">
  366. <div class="detail-text">{{ courseDetail.description || '暂无描述' }}</div>
  367. </el-descriptions-item>
  368. <el-descriptions-item label="备注" :span="2">{{ courseDetail.remark || '暂无备注' }}</el-descriptions-item>
  369. </el-descriptions>
  370. <template #footer>
  371. <div class="dialog-footer">
  372. <el-button
  373. type="primary"
  374. @click="handleViewApplications(courseDetail)"
  375. v-if="courseDetail.courseId"
  376. v-hasPermi="['rs:trainingapplication:list']"
  377. >查看申请记录</el-button
  378. >
  379. <el-button @click="courseDetailDialogVisible = false">关 闭</el-button>
  380. </div>
  381. </template>
  382. </el-dialog>
  383. <!-- 申请详情对话框 -->
  384. <el-dialog title="申请详情" v-model="applicationDetailOpen" width="800px" append-to-body>
  385. <el-descriptions :column="2" border>
  386. <!-- 情况基本信息 -->
  387. <el-descriptions-item label="申请人">{{ applicationDetail.nickName || applicationDetail.userName }}</el-descriptions-item>
  388. <el-descriptions-item label="所在部门(系部)">{{ applicationDetail.department }}</el-descriptions-item>
  389. <el-descriptions-item label="现职称">{{ applicationDetail.currentTitle || '暂无' }}</el-descriptions-item>
  390. <el-descriptions-item label="现岗位">{{ applicationDetail.currentPosition || '暂无' }}</el-descriptions-item>
  391. <el-descriptions-item label="参加工作时间">{{ parseTime(applicationDetail.workStartTime) || '暂无' }}</el-descriptions-item>
  392. <el-descriptions-item label="联系电话">{{ applicationDetail.phone || '暂无' }}</el-descriptions-item>
  393. <!-- 培训情况信息 -->
  394. <el-descriptions-item label="主办单位">{{ applicationDetail.organizerUnit || applicationDetail.courseName || '暂无' }}</el-descriptions-item>
  395. <el-descriptions-item label="培训地点">{{ applicationDetail.location }}</el-descriptions-item>
  396. <el-descriptions-item label="开始时间">{{ parseTime(applicationDetail.startTime) }}</el-descriptions-item>
  397. <el-descriptions-item label="结束时间">{{ parseTime(applicationDetail.endTime) }}</el-descriptions-item>
  398. <el-descriptions-item label="培训类型">{{ applicationDetail.trainingType || '暂无' }}</el-descriptions-item>
  399. <el-descriptions-item label="培训费用">{{
  400. applicationDetail.trainingFee ? `${applicationDetail.trainingFee}元` : '暂无'
  401. }}</el-descriptions-item>
  402. <el-descriptions-item label="申请状态">
  403. <el-tag
  404. :type="
  405. applicationDetail.status === '0'
  406. ? 'warning'
  407. : applicationDetail.status === '1'
  408. ? 'success'
  409. : applicationDetail.status === '2'
  410. ? 'danger'
  411. : 'info'
  412. "
  413. >
  414. {{ getStatusLabel(applicationDetail.status) }}
  415. </el-tag>
  416. </el-descriptions-item>
  417. <el-descriptions-item label="申请时间">{{ parseTime(applicationDetail.applyTime) }}</el-descriptions-item>
  418. <el-descriptions-item label="同行人" :span="2">{{ getCompanionNames(applicationDetail.companions) || '无' }}</el-descriptions-item>
  419. <el-descriptions-item label="培训目的" :span="2">{{
  420. applicationDetail.trainingPurpose || applicationDetail.reason || '暂无'
  421. }}</el-descriptions-item>
  422. <el-descriptions-item label="备注" :span="2">{{ applicationDetail.remark || '无' }}</el-descriptions-item>
  423. <!-- 显示拒绝原因,如果申请被拒绝 -->
  424. <el-descriptions-item v-if="applicationDetail.status === '2'" label="拒绝原因" :span="2" class="reject-reason">
  425. <div class="reject-info">
  426. <el-alert type="error" :closable="false">
  427. <template #title>
  428. <div class="reject-title">申请已被拒绝</div>
  429. </template>
  430. <div class="reject-content">{{ applicationDetail.adminRemark || '未提供拒绝原因' }}</div>
  431. </el-alert>
  432. <div class="reject-action">
  433. <el-button type="primary" size="small" @click="handleViewHistory(applicationDetail)">查看完整审批历史</el-button>
  434. </div>
  435. </div>
  436. </el-descriptions-item>
  437. </el-descriptions>
  438. <!-- 申请附件显示区域 -->
  439. <div v-if="applicationDetailAttachmentList.length > 0" class="attachment-section" style="margin-top: 20px">
  440. <div class="section-title" style="margin-bottom: 15px; padding: 10px; border-left: 4px solid #409eff; background-color: #f5f7fa">
  441. <el-icon style="margin-right: 8px"><Paperclip /></el-icon>
  442. <strong>申请附件</strong>
  443. </div>
  444. <el-table :data="applicationDetailAttachmentList" border size="small">
  445. <el-table-column label="序号" type="index" width="60" align="center" />
  446. <el-table-column label="文件名称" prop="name" align="left" show-overflow-tooltip />
  447. <el-table-column label="上传时间" prop="uploadTime" width="180" align="center">
  448. <template #default="scope">
  449. {{ parseTime(scope.row.uploadTime) }}
  450. </template>
  451. </el-table-column>
  452. <el-table-column label="操作" width="100" align="center">
  453. <template #default="scope">
  454. <el-button type="primary" link icon="Download" @click="handleDownloadApplicationAttachment(scope.row)" size="small"> 下载 </el-button>
  455. </template>
  456. </el-table-column>
  457. </el-table>
  458. </div>
  459. <template #footer>
  460. <div class="dialog-footer">
  461. <el-button @click="applicationDetailOpen = false">关闭</el-button>
  462. </div>
  463. </template>
  464. </el-dialog>
  465. <!-- 审批历史对话框 -->
  466. <el-dialog title="审批历史记录" v-model="approvalHistoryOpen" width="700px" append-to-body>
  467. <el-timeline>
  468. <el-timeline-item
  469. v-for="(approval, index) in approvalHistoryList"
  470. :key="index"
  471. :timestamp="parseTime(approval.approvalTime)"
  472. :type="approval.status === '1' ? 'success' : approval.status === '2' ? 'danger' : 'primary'"
  473. >
  474. <div class="approval-history-item">
  475. <div class="approval-header">
  476. <span class="approver-name">{{ approval.approverName }}</span>
  477. <span class="approval-level">[{{ getApprovalLevelLabel(approval.approvalLevel) }}]</span>
  478. <el-tag :type="approval.status === '0' ? 'info' : approval.status === '1' ? 'success' : 'danger'" size="small">
  479. {{ approval.status === '0' ? '待审核' : approval.status === '1' ? '已通过' : '已拒绝' }}
  480. </el-tag>
  481. </div>
  482. <div class="approval-opinion">{{ approval.opinion || '无审批意见' }}</div>
  483. </div>
  484. </el-timeline-item>
  485. </el-timeline>
  486. <div v-if="approvalHistoryList.length === 0" class="no-data">暂无审批记录</div>
  487. <template #footer>
  488. <div class="dialog-footer">
  489. <el-button @click="approvalHistoryOpen = false">关闭</el-button>
  490. </div>
  491. </template>
  492. </el-dialog>
  493. <!-- 培训申请对话框 -->
  494. <el-dialog :title="applicationDialogTitle" v-model="applicationDialogVisible" width="800px" append-to-body>
  495. <el-form ref="applicationFormRef" :model="applicationForm" :rules="applicationRules" label-width="140px">
  496. <!-- 基本情况信息 -->
  497. <el-divider content-position="left">
  498. <span style="font-weight: bold; color: #409eff">基本情况</span>
  499. </el-divider>
  500. <el-row :gutter="20">
  501. <el-col :span="12">
  502. <el-form-item label="姓名" prop="userName">
  503. <el-input v-model="applicationForm.userName" placeholder="申请人姓名" readonly class="readonly-input" />
  504. </el-form-item>
  505. </el-col>
  506. <el-col :span="12">
  507. <el-form-item label="所在部门(系部)" prop="department">
  508. <el-input v-model="applicationForm.department" placeholder="请输入所属部门" readonly class="readonly-input" />
  509. </el-form-item>
  510. </el-col>
  511. </el-row>
  512. <el-row :gutter="20">
  513. <el-col :span="12">
  514. <el-form-item label="现职称" prop="currentTitle">
  515. <el-input v-model="applicationForm.currentTitle" placeholder="请输入现职称" />
  516. </el-form-item>
  517. </el-col>
  518. <el-col :span="12">
  519. <el-form-item label="现岗位" prop="currentPosition">
  520. <el-radio-group v-model="applicationForm.currentPosition" style="display: flex; flex-wrap: nowrap; align-items: center">
  521. <el-radio label="教学" style="margin-right: 20px">教学</el-radio>
  522. <el-radio label="管理" style="margin-right: 20px">管理</el-radio>
  523. <el-radio label="其他">其他</el-radio>
  524. </el-radio-group>
  525. </el-form-item>
  526. </el-col>
  527. </el-row>
  528. <el-row :gutter="20">
  529. <el-col :span="12">
  530. <el-form-item label="参加工作时间" prop="workStartTime">
  531. <el-date-picker
  532. v-model="applicationForm.workStartTime"
  533. type="date"
  534. placeholder="选择参加工作时间"
  535. style="width: 100%"
  536. value-format="YYYY-MM-DD"
  537. />
  538. </el-form-item>
  539. </el-col>
  540. <el-col :span="12">
  541. <el-form-item label="联系电话" prop="phone">
  542. <el-input v-model="applicationForm.phone" placeholder="请输入联系电话" />
  543. </el-form-item>
  544. </el-col>
  545. </el-row>
  546. <!-- 培训情况信息 -->
  547. <el-divider content-position="left">
  548. <span style="font-weight: bold; color: #409eff">培训情况</span>
  549. </el-divider>
  550. <el-row :gutter="20">
  551. <el-col :span="12">
  552. <el-form-item label="主办单位" prop="organizerUnit">
  553. <el-input v-model="applicationForm.organizerUnit" placeholder="请输入主办单位" />
  554. </el-form-item>
  555. </el-col>
  556. <el-col :span="12">
  557. <el-form-item label="培训地点" prop="location">
  558. <el-input v-model="applicationForm.location" placeholder="请输入培训地点" />
  559. </el-form-item>
  560. </el-col>
  561. </el-row>
  562. <el-form-item label="培训时间" required>
  563. <el-col :span="11">
  564. <el-form-item prop="startTime">
  565. <el-date-picker v-model="applicationForm.startTime" type="date" placeholder="开始日期" style="width: 100%" value-format="YYYY-MM-DD" />
  566. </el-form-item>
  567. </el-col>
  568. <el-col :span="2" class="text-center">
  569. <span class="text-gray-500">至</span>
  570. </el-col>
  571. <el-col :span="11">
  572. <el-form-item prop="endTime">
  573. <el-date-picker v-model="applicationForm.endTime" type="date" placeholder="结束日期" style="width: 100%" value-format="YYYY-MM-DD" />
  574. </el-form-item>
  575. </el-col>
  576. </el-form-item>
  577. <el-form-item label="培训类型" prop="trainingType">
  578. <div style="display: flex; flex-wrap: wrap; gap: 20px; align-items: center">
  579. <el-radio-group v-model="applicationForm.trainingType" style="display: flex; flex-wrap: nowrap; gap: 20px">
  580. <el-radio label="教学">教学</el-radio>
  581. <el-radio label="德育">德育</el-radio>
  582. <el-radio label="行政">行政</el-radio>
  583. <el-radio label="管理">管理</el-radio>
  584. <el-radio label="其他">其他</el-radio>
  585. </el-radio-group>
  586. <el-input
  587. v-if="applicationForm.trainingType === '其他'"
  588. v-model="applicationForm.trainingTypeOther"
  589. placeholder="请输入具体培训类型"
  590. style="width: 200px; margin-left: 10px"
  591. clearable
  592. />
  593. </div>
  594. </el-form-item>
  595. <el-row :gutter="20">
  596. <el-col :span="12">
  597. <el-form-item label="同行人" prop="companions">
  598. <TeacherMultiSelector v-model="selectedCompanions" placeholder="请选择同行人员" @change="handleCompanionsChange" />
  599. </el-form-item>
  600. </el-col>
  601. <el-col :span="12">
  602. <el-form-item label="培训费用" prop="trainingFee">
  603. <el-input-number v-model="applicationForm.trainingFee" :min="0" :precision="2" style="width: 100%" placeholder="请输入培训费用">
  604. <template #append>元</template>
  605. </el-input-number>
  606. </el-form-item>
  607. </el-col>
  608. </el-row>
  609. <el-form-item label="培训目的" prop="trainingPurpose">
  610. <el-input v-model="applicationForm.trainingPurpose" type="textarea" placeholder="请输入培训目的" :rows="3" />
  611. </el-form-item>
  612. <el-form-item label="备注" prop="remark">
  613. <el-input v-model="applicationForm.remark" type="textarea" placeholder="请输入备注" :rows="2" />
  614. </el-form-item>
  615. <!-- 上传附件 -->
  616. <el-form-item label="上传附件">
  617. <div class="attachment-upload-container">
  618. <el-upload
  619. v-model:file-list="applicationAttachmentFileList"
  620. class="attachment-upload-demo"
  621. drag
  622. list-type="picture-card"
  623. :action="applicationUploadAction"
  624. :headers="applicationUploadHeaders"
  625. :data="applicationUploadData"
  626. :auto-upload="true"
  627. :before-upload="beforeApplicationAttachmentUpload"
  628. :on-success="handleApplicationAttachmentSuccess"
  629. :on-error="handleApplicationAttachmentError"
  630. :on-remove="handleRemoveApplicationAttachment"
  631. :limit="10"
  632. :show-file-list="true"
  633. accept=".pdf,.doc,.docx,.jpg,.jpeg,.png,.xls,.xlsx"
  634. >
  635. <!-- 拖拽上传区域 -->
  636. <div class="el-upload-dragger-attachment">
  637. <el-icon class="el-icon--upload"><Upload /></el-icon>
  638. <div class="el-upload__text">将附件文件拖到此处,或<em>点击上传</em></div>
  639. </div>
  640. <!-- 自定义文件卡片 -->
  641. <template #file="{ file }">
  642. <div class="upload-file-card">
  643. <!-- 缩略图区域 -->
  644. <div class="upload-file-thumb">
  645. <image-preview
  646. v-if="isImageFile(file) && file.url && getFileOssId(file)"
  647. :src="getFileOssId(file)"
  648. class="upload-thumb-image"
  649. :isOssId="true"
  650. />
  651. <div
  652. v-else-if="isImageFile(file) && file.url"
  653. class="upload-file-image"
  654. @click="handlePreviewApplicationAttachment(file)"
  655. style="cursor: pointer"
  656. >
  657. <img :src="file.url" :alt="file.name" style="width: 100%; height: 100%; object-fit: cover" />
  658. </div>
  659. <div v-else class="upload-file-placeholder">
  660. <el-icon><Document /></el-icon>
  661. <span class="file-ext">{{ getFileExt(file.name) }}</span>
  662. </div>
  663. <!-- loading 遮罩 -->
  664. <div v-if="file.status === 'uploading'" class="upload-file-loading">
  665. <el-icon class="is-loading"><Loading /></el-icon>
  666. <span class="loading-text">上传中...</span>
  667. </div>
  668. </div>
  669. <!-- 文件名称 -->
  670. <div class="upload-file-name" :title="file.name">
  671. {{ getShortFileName(file.name) }}
  672. </div>
  673. <!-- 操作按钮区域 -->
  674. <div class="upload-file-card-actions" v-if="file.status && file.status !== 'ready'">
  675. <el-button-group size="small">
  676. <el-button
  677. type="success"
  678. @click.stop="handleDownloadApplicationAttachment(file)"
  679. title="下载"
  680. :disabled="file.status !== 'success'"
  681. >
  682. <el-icon><Download /></el-icon>
  683. </el-button>
  684. <el-button type="danger" @click.stop="confirmRemoveApplicationAttachment(file)" title="删除">
  685. <el-icon><Delete /></el-icon>
  686. </el-button>
  687. </el-button-group>
  688. </div>
  689. </div>
  690. </template>
  691. </el-upload>
  692. </div>
  693. </el-form-item>
  694. </el-form>
  695. <template #footer>
  696. <div class="dialog-footer">
  697. <el-button :loading="applicationDialogLoading" type="primary" @click="submitApplicationForm">确 定</el-button>
  698. <el-button @click="cancelApplicationDialog">取 消</el-button>
  699. </div>
  700. </template>
  701. </el-dialog>
  702. <!-- 培训记录对话框 -->
  703. <el-dialog :title="recordDialogTitle" v-model="recordDialogVisible" width="700px" append-to-body>
  704. <el-form ref="recordFormRef" :model="recordForm" :rules="recordRules" label-width="100px">
  705. <el-form-item label="课程名称">
  706. <el-input v-model="recordForm.courseName" :disabled="true" />
  707. </el-form-item>
  708. <el-form-item label="学时">
  709. <el-input v-model="recordForm.duration" :disabled="true" />
  710. </el-form-item>
  711. <el-form-item label="完成状态" prop="completionStatus">
  712. <el-radio-group v-model="recordForm.completionStatus">
  713. <el-radio label="1">已完成</el-radio>
  714. <el-radio label="2">未完成</el-radio>
  715. </el-radio-group>
  716. </el-form-item>
  717. <el-form-item label="完成时间" prop="completionTime">
  718. <el-date-picker
  719. v-model="recordForm.completionTime"
  720. type="datetime"
  721. placeholder="选择完成时间"
  722. style="width: 100%"
  723. value-format="YYYY-MM-DD HH:mm:ss"
  724. />
  725. </el-form-item>
  726. <el-form-item label="证书编号" prop="certificateNumber">
  727. <el-input v-model="recordForm.certificateNumber" placeholder="请输入证书编号(如有)" />
  728. </el-form-item>
  729. <el-form-item label="培训证书" prop="certificatePath">
  730. <div class="certificate-upload-container">
  731. <el-upload
  732. v-model:file-list="recordCertificateFileList"
  733. class="certificate-upload-demo"
  734. drag
  735. list-type="picture-card"
  736. :action="recordCertificateUploadAction"
  737. :headers="recordCertificateUploadHeaders"
  738. :data="recordCertificateUploadData"
  739. :auto-upload="true"
  740. :before-upload="beforeRecordCertificateUpload"
  741. :on-success="handleRecordCertificateSuccess"
  742. :on-error="handleRecordCertificateError"
  743. :on-remove="handleRemoveCertificate"
  744. :limit="15"
  745. :show-file-list="true"
  746. accept=".pdf,.jpg,.jpeg,.png"
  747. >
  748. <!-- 拖拽上传区域 -->
  749. <div class="el-upload-dragger-certificate">
  750. <el-icon class="el-icon--upload"><Upload /></el-icon>
  751. <div class="el-upload__text">将证书文件拖到此处,或<em>点击上传</em></div>
  752. <div class="el-upload__tip" style="margin-top: 4px; font-size: 11px; color: #909399">
  753. 支持PDF/JPG/PNG格式,文件大小不超过10MB,最多上传15个文件
  754. </div>
  755. </div>
  756. <!-- 自定义文件卡片 -->
  757. <template #file="{ file }">
  758. <div class="upload-file-card">
  759. <!-- 缩略图区域 -->
  760. <div class="upload-file-thumb">
  761. <image-preview
  762. v-if="isImageFile(file) && file.url && getFileOssId(file)"
  763. :src="getFileOssId(file)"
  764. class="upload-thumb-image"
  765. :isOssId="true"
  766. />
  767. <div
  768. v-else-if="isImageFile(file) && file.url"
  769. class="upload-file-image"
  770. @click="handlePreviewCertificate(file)"
  771. style="cursor: pointer"
  772. >
  773. <img :src="file.url" :alt="file.name" style="width: 100%; height: 100%; object-fit: cover" />
  774. </div>
  775. <div v-else class="upload-file-placeholder">
  776. <el-icon><Document /></el-icon>
  777. <span class="file-ext">{{ getFileExt(file.name) }}</span>
  778. </div>
  779. <!-- loading 遮罩 -->
  780. <div v-if="file.status === 'uploading'" class="upload-file-loading">
  781. <el-icon class="is-loading"><Loading /></el-icon>
  782. <span class="loading-text">上传中...</span>
  783. </div>
  784. </div>
  785. <!-- 文件名称 -->
  786. <div class="upload-file-name" :title="file.name">
  787. {{ getShortFileName(file.name) }}
  788. </div>
  789. <!-- 操作按钮区域 -->
  790. <div class="upload-file-card-actions" v-if="file.status && file.status !== 'ready'">
  791. <el-button-group size="small">
  792. <el-button type="success" @click.stop="handleDownloadCertificate(file)" title="下载" :disabled="file.status !== 'success'">
  793. <el-icon><Download /></el-icon>
  794. </el-button>
  795. <el-button type="danger" @click.stop="confirmRemoveCertificate(file)" title="删除">
  796. <el-icon><Delete /></el-icon>
  797. </el-button>
  798. </el-button-group>
  799. </div>
  800. </div>
  801. </template>
  802. </el-upload>
  803. </div>
  804. </el-form-item>
  805. <el-form-item label="培训反馈" prop="feedback">
  806. <el-input v-model="recordForm.feedback" type="textarea" :rows="3" placeholder="请输入培训反馈意见" />
  807. </el-form-item>
  808. <el-form-item label="备注" prop="remark">
  809. <el-input v-model="recordForm.remark" type="textarea" placeholder="请输入备注" />
  810. </el-form-item>
  811. </el-form>
  812. <template #footer>
  813. <div class="dialog-footer">
  814. <el-button :loading="recordDialogLoading" type="primary" @click="submitRecordForm">确 定</el-button>
  815. <el-button @click="cancelRecordDialog">取 消</el-button>
  816. </div>
  817. </template>
  818. </el-dialog>
  819. <!-- 培训记录详情对话框 -->
  820. <el-dialog title="培训记录详情" v-model="recordDetailDialogVisible" width="800px" append-to-body>
  821. <el-descriptions :column="2" border>
  822. <!-- 学员基本信息 -->
  823. <el-descriptions-item label="学员姓名">{{ recordDetail.userName }}</el-descriptions-item>
  824. <el-descriptions-item label="所在部门(系部)">{{ recordDetail.department || '暂无' }}</el-descriptions-item>
  825. <el-descriptions-item label="现职称">{{ recordDetail.currentTitle || '暂无' }}</el-descriptions-item>
  826. <el-descriptions-item label="现岗位">{{ recordDetail.currentPosition || '暂无' }}</el-descriptions-item>
  827. <el-descriptions-item label="参加工作时间">{{ parseTime(recordDetail.workStartTime) || '暂无' }}</el-descriptions-item>
  828. <el-descriptions-item label="联系电话">{{ recordDetail.phone || '暂无' }}</el-descriptions-item>
  829. <!-- 培训情况信息 -->
  830. <el-descriptions-item label="主办单位">{{ recordDetail.organizerUnit || recordDetail.courseName || '暂无' }}</el-descriptions-item>
  831. <el-descriptions-item label="培训地点">{{ recordDetail.location || '暂无' }}</el-descriptions-item>
  832. <el-descriptions-item label="开始时间">{{ parseTime(recordDetail.startTime) || '暂无' }}</el-descriptions-item>
  833. <el-descriptions-item label="结束时间">{{ parseTime(recordDetail.endTime) || '暂无' }}</el-descriptions-item>
  834. <el-descriptions-item label="培训类型">{{ recordDetail.trainingType || '暂无' }}</el-descriptions-item>
  835. <el-descriptions-item label="培训费用">{{ recordDetail.trainingFee ? `${recordDetail.trainingFee}元` : '暂无' }}</el-descriptions-item>
  836. <el-descriptions-item label="申请时间">{{ parseTime(recordDetail.applyTime) || '暂无' }}</el-descriptions-item>
  837. <el-descriptions-item label="完成状态">
  838. <el-tag :type="getCompletionStatusType(recordDetail.completionStatus)">
  839. {{ getCompletionStatusLabel(recordDetail.completionStatus) }}
  840. </el-tag>
  841. </el-descriptions-item>
  842. <el-descriptions-item label="同行人" :span="2">{{ getCompanionNames(recordDetail.companions) || '无' }}</el-descriptions-item>
  843. <el-descriptions-item label="培训目的" :span="2">{{ recordDetail.trainingPurpose || recordDetail.reason || '暂无' }}</el-descriptions-item>
  844. <el-descriptions-item label="备注" :span="2">{{ recordDetail.remark || '暂无备注' }}</el-descriptions-item>
  845. </el-descriptions>
  846. <!-- 申请附件显示区域 -->
  847. <div v-if="recordDetailAttachmentList.length > 0" class="attachment-section" style="margin-top: 20px">
  848. <div class="section-title" style="margin-bottom: 15px; padding: 10px; border-left: 4px solid #409eff; background-color: #f5f7fa">
  849. <el-icon style="margin-right: 8px"><Paperclip /></el-icon>
  850. <strong>申请附件</strong>
  851. </div>
  852. <el-table :data="recordDetailAttachmentList" border size="small">
  853. <el-table-column label="序号" type="index" width="60" align="center" />
  854. <el-table-column label="文件名称" prop="name" align="left" show-overflow-tooltip />
  855. <el-table-column label="上传时间" prop="uploadTime" width="180" align="center">
  856. <template #default="scope">
  857. {{ parseTime(scope.row.uploadTime) }}
  858. </template>
  859. </el-table-column>
  860. <el-table-column label="操作" width="100" align="center">
  861. <template #default="scope">
  862. <el-button type="primary" link icon="Download" @click="handleDownloadApplicationAttachment(scope.row)" size="small"> 下载 </el-button>
  863. </template>
  864. </el-table-column>
  865. </el-table>
  866. </div>
  867. <template #footer>
  868. <div class="dialog-footer">
  869. <el-button @click="recordDetailDialogVisible = false">关 闭</el-button>
  870. </div>
  871. </template>
  872. </el-dialog>
  873. <!-- 上传证书对话框 -->
  874. <el-dialog title="上传培训证书" v-model="certificateDialogVisible" width="500px" append-to-body>
  875. <el-upload
  876. ref="uploadRef"
  877. :action="`/dev-api/rs/training/record/certificate/upload/${certificateUploadData.recordId}`"
  878. :headers="uploadHeaders"
  879. :before-upload="beforeCertificateUpload"
  880. :on-success="handleCertificateSuccess"
  881. :on-error="handleCertificateError"
  882. :file-list="certificateFileList"
  883. :limit="1"
  884. :auto-upload="true"
  885. accept=".pdf,.jpg,.jpeg,.png"
  886. class="certificate-upload"
  887. >
  888. <el-button type="primary">选择文件</el-button>
  889. <template #tip>
  890. <div class="el-upload__tip">只能上传PDF/JPG/PNG文件,且不超过10MB</div>
  891. </template>
  892. </el-upload>
  893. <template #footer>
  894. <div class="dialog-footer">
  895. <el-button @click="certificateDialogVisible = false">取 消</el-button>
  896. </div>
  897. </template>
  898. </el-dialog>
  899. </div>
  900. </template>
  901. <script setup lang="ts" name="TrainingManagement">
  902. import { ref, reactive, onMounted, onActivated, getCurrentInstance, ComponentInternalInstance, watch } from 'vue';
  903. import {
  904. Plus,
  905. Edit,
  906. Delete,
  907. Search,
  908. Download,
  909. Upload,
  910. View,
  911. Document,
  912. RefreshRight,
  913. RefreshLeft,
  914. InfoFilled,
  915. Loading,
  916. Picture,
  917. Paperclip
  918. } from '@element-plus/icons-vue';
  919. import ImagePreview from '@/components/ImagePreview/index.vue';
  920. import {
  921. // 培训课程相关接口已废弃 (2025-01-03)
  922. // listTrainingCourse, getTrainingCourse, addTrainingCourse, updateTrainingCourse, delTrainingCourse, toggleCourseStatus, exportTrainingCourse,
  923. listTrainingApplication,
  924. getTrainingApplication,
  925. addTrainingApplication,
  926. updateTrainingApplication,
  927. cancelTrainingApplication,
  928. exportTrainingApplication,
  929. listMyTrainingApplication,
  930. listTrainingRecord,
  931. getTrainingRecord,
  932. addTrainingRecord,
  933. updateTrainingRecord,
  934. delTrainingRecord,
  935. exportTrainingRecord,
  936. submitTrainingApplication,
  937. updateApplicationStatus,
  938. deleteTrainingApplication,
  939. getTrainingApprovalHistory,
  940. resubmitTrainingApplication,
  941. batchQueryCompanions,
  942. updateRecordAttachments,
  943. listAllApprovalRecords
  944. } from '@/api/rs/training';
  945. import { parseTime } from '@/utils/ruoyi';
  946. import request from '@/utils/request';
  947. import { ElLoading } from 'element-plus';
  948. import type {
  949. CourseQuery,
  950. CourseVO,
  951. CourseForm,
  952. RecordQuery,
  953. RecordVO,
  954. RecordForm,
  955. ApplicationQuery,
  956. ApplicationVO,
  957. ApplicationForm
  958. } from '@/api/rs/training';
  959. import { listDept, getDept } from '@/api/system/dept';
  960. import type { DeptVO } from '@/api/system/dept/types';
  961. import { getFilePreviewUrl } from '@/api/system/file';
  962. import { getToken } from '@/utils/auth';
  963. import { getInfo as getUserInfo } from '@/api/login';
  964. import { useUserStore } from '@/store/modules/user';
  965. // 🔧 修复雪花ID精度丢失问题:使用培训申请模块的本地组件
  966. // 原因:公共组件不能修改,会影响其他模块。在本地复制并修复雪花ID转Number导致的精度丢失问题
  967. import TeacherMultiSelector from './components/TeacherMultiSelector.vue';
  968. import { TeacherVO } from '@/api/system/teacher/types';
  969. import { listTeacher } from '@/api/system/teacher';
  970. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  971. const userStore = useUserStore();
  972. // 环境变量
  973. const baseApi = import.meta.env.VITE_APP_BASE_API;
  974. const clientId = import.meta.env.VITE_APP_CLIENT_ID;
  975. const animate = proxy?.animate || { searchAnimate: { enter: 'animate__fadeInUp', leave: 'animate__fadeOutDown' } };
  976. // ===== 申请培训附件上传配置(统一使用computed方式) =====
  977. const applicationUploadAction = computed(() => {
  978. const api = import.meta.env.VITE_APP_BASE_API + '/resource/oss/upload';
  979. console.log('[申请培训附件上传配置] 上传地址:', api);
  980. return api;
  981. });
  982. const applicationUploadHeaders = computed(() => {
  983. const token = getToken() || '';
  984. const headers = {
  985. 'Authorization': `Bearer ${token}`,
  986. 'clientid': import.meta.env.VITE_APP_CLIENT_ID || 'e5cd7e4891bf95d1d19206ce24a7b32e'
  987. };
  988. console.log('[申请培训附件上传配置] 请求头:', headers);
  989. return headers;
  990. });
  991. const applicationUploadData = computed(() => {
  992. return {
  993. bizType: 'training_application_attachment'
  994. };
  995. });
  996. // ===== 培训证书上传配置(统一使用computed方式) =====
  997. const recordCertificateUploadAction = computed(() => {
  998. const api = import.meta.env.VITE_APP_BASE_API + '/resource/oss/upload';
  999. console.log('[培训证书上传配置] 上传地址:', api);
  1000. return api;
  1001. });
  1002. const recordCertificateUploadHeaders = computed(() => {
  1003. const token = getToken() || '';
  1004. const headers = {
  1005. 'Authorization': `Bearer ${token}`,
  1006. 'clientid': import.meta.env.VITE_APP_CLIENT_ID || 'e5cd7e4891bf95d1d19206ce24a7b32e'
  1007. };
  1008. console.log('[培训证书上传配置] 请求头:', headers);
  1009. return headers;
  1010. });
  1011. const recordCertificateUploadData = computed(() => {
  1012. return {
  1013. bizType: 'training_certificate_attachment'
  1014. };
  1015. });
  1016. // 培训申请相关
  1017. // 培训课程遮罩层
  1018. const trainingLoading = ref(false);
  1019. // 培训选中数组
  1020. const trainingIds = ref<Array<string | number>>([]);
  1021. // 培训非单个禁用
  1022. const trainingSingle = ref(true);
  1023. // 培训非多个禁用
  1024. const trainingMultiple = ref(true);
  1025. // 显示培训搜索条件
  1026. const showTrainingSearch = ref(true);
  1027. // 显示申请搜索条件
  1028. const showApplicationSearch = ref(true);
  1029. // 培训总条数
  1030. const trainingTotal = ref(0);
  1031. // 培训课程表格数据
  1032. const courseList = ref<CourseVO[]>([]);
  1033. // 当前激活的子选项卡
  1034. const trainingSubTab = ref('application'); // 默认显示培训申请选项卡
  1035. // 添加缓存状态标记
  1036. const isInitialized = ref(false);
  1037. const isDataLoaded = ref(false);
  1038. // 课程类别选项改为字典
  1039. const { rs_training_category, rs_training_application_status } = toRefs<any>(
  1040. proxy?.useDict('rs_training_category', 'rs_training_application_status') || {}
  1041. );
  1042. // 课程状态选项(计算型)
  1043. const getCourseStatusType = (row: CourseVO): string => {
  1044. const now = new Date().getTime();
  1045. const startTime = new Date(row.startTime).getTime();
  1046. const endTime = new Date(row.endTime).getTime();
  1047. if (row.status !== '0') {
  1048. return 'info'; // 停用状态
  1049. } else if (now < startTime) {
  1050. return 'warning'; // 待开课
  1051. } else if (now >= startTime && now <= endTime) {
  1052. return 'success'; // 进行中
  1053. } else {
  1054. return 'info'; // 已结束,返回默认颜色
  1055. }
  1056. };
  1057. const getCourseStatusLabel = (row: CourseVO): string => {
  1058. const now = new Date().getTime();
  1059. const startTime = new Date(row.startTime).getTime();
  1060. const endTime = new Date(row.endTime).getTime();
  1061. if (row.status !== '0') {
  1062. return '已结束';
  1063. } else if (now < startTime) {
  1064. return '待开课';
  1065. } else if (now >= startTime && now <= endTime) {
  1066. return '进行中';
  1067. } else {
  1068. return '已结束';
  1069. }
  1070. };
  1071. // 培训课程查询参数
  1072. const trainingQueryParams = reactive<CourseQuery>({
  1073. pageNum: 1,
  1074. pageSize: 10,
  1075. title: '',
  1076. category: '',
  1077. status: '',
  1078. params: {}
  1079. });
  1080. // 培训课程对话框相关
  1081. const courseDialogVisible = ref(false);
  1082. const courseDialogTitle = ref('');
  1083. const courseDialogLoading = ref(false);
  1084. const courseForm = reactive<CourseForm>({
  1085. courseId: undefined,
  1086. title: '',
  1087. category: '',
  1088. description: '',
  1089. startTime: '',
  1090. endTime: '',
  1091. duration: 0,
  1092. location: '',
  1093. status: '0',
  1094. remark: ''
  1095. });
  1096. // 培训课程表单校验规则
  1097. const courseRules = reactive({
  1098. title: [
  1099. { required: true, message: '课程名称不能为空', trigger: 'blur' },
  1100. { min: 2, max: 100, message: '长度在 2 到 100 个字符', trigger: 'blur' }
  1101. ],
  1102. category: [{ required: true, message: '课程类别不能为空', trigger: 'change' }],
  1103. startTime: [{ required: true, message: '开始时间不能为空', trigger: 'change' }],
  1104. endTime: [{ required: true, message: '结束时间不能为空', trigger: 'change' }],
  1105. duration: [{ required: true, message: '学时数不能为空', trigger: 'blur' }]
  1106. } as any);
  1107. // 培训课程表单引用
  1108. const courseFormRef = ref<any>(null);
  1109. // 培训课程详情
  1110. const courseDetailDialogVisible = ref(false);
  1111. const courseDetail = reactive<CourseVO>({
  1112. courseId: undefined,
  1113. title: '',
  1114. category: '',
  1115. description: '',
  1116. startTime: '',
  1117. endTime: '',
  1118. duration: 0,
  1119. location: '',
  1120. maxParticipants: 0,
  1121. currentParticipants: 0,
  1122. status: '0',
  1123. applicationCount: 0,
  1124. createTime: '',
  1125. updateTime: '',
  1126. createBy: '',
  1127. updateBy: '',
  1128. remark: ''
  1129. });
  1130. // 培训申请相关
  1131. const applicationLoading = ref(false);
  1132. const applicationList = ref<any[]>([]);
  1133. const applicationTotal = ref(0);
  1134. const applicationQueryForm = ref<any>(null);
  1135. const applicationQueryParams = reactive({
  1136. pageNum: 1,
  1137. pageSize: 10,
  1138. courseId: undefined as string | number | undefined,
  1139. courseName: '',
  1140. location: '',
  1141. duration: undefined as number | undefined,
  1142. status: '',
  1143. excludeStatus: '1', // 默认排除已通过状态的数据
  1144. params: {}
  1145. });
  1146. // 申请状态选项改为字典
  1147. const applicationStatusOptions = rs_training_application_status;
  1148. // 教师列表数据
  1149. const teacherList = ref<
  1150. Array<{
  1151. teacherId: string | number;
  1152. teacherName: string;
  1153. teacherType: string;
  1154. }>
  1155. >([]);
  1156. // 申请详情相关
  1157. const applicationDetailOpen = ref(false);
  1158. const applicationDetail = reactive<any>({
  1159. applicationId: 0,
  1160. courseId: 0,
  1161. courseName: '',
  1162. userId: 0,
  1163. userName: '',
  1164. department: '',
  1165. status: '0',
  1166. applyTime: '',
  1167. approvalTime: '',
  1168. remark: '',
  1169. adminRemark: '',
  1170. certificatePath: '',
  1171. attachmentIds: '' // 添加附件ID字段
  1172. });
  1173. // 审批历史相关
  1174. const approvalHistoryOpen = ref(false);
  1175. const approvalHistoryList = ref<any[]>([]);
  1176. // 培训记录相关
  1177. const recordLoading = ref(false);
  1178. const recordList = ref<RecordVO[]>([]);
  1179. const recordTotal = ref(0);
  1180. const showRecordSearch = ref(true);
  1181. const recordQueryParams = reactive<RecordQuery>({
  1182. pageNum: 1,
  1183. pageSize: 20,
  1184. courseId: undefined as string | number | undefined,
  1185. courseName: '',
  1186. userId: undefined as string | number | undefined,
  1187. userName: '',
  1188. location: '',
  1189. department: '',
  1190. completionStatus: '',
  1191. includeApprovedApplications: true, // 包含已通过审批的申请数据
  1192. params: {}
  1193. });
  1194. // 培训记录对话框相关
  1195. const recordDialogVisible = ref(false);
  1196. const recordDialogTitle = ref('');
  1197. const recordDialogLoading = ref(false);
  1198. const recordFormRef = ref<any>(null);
  1199. const recordQueryForm = ref<any>(null);
  1200. const recordForm = reactive<RecordForm>({
  1201. recordId: undefined,
  1202. courseId: undefined,
  1203. userId: undefined,
  1204. completionStatus: '0',
  1205. score: '',
  1206. completionTime: '',
  1207. attachmentIds: '',
  1208. remark: ''
  1209. });
  1210. // 培训记录表单校验规则
  1211. const recordRules = reactive({
  1212. completionStatus: [{ required: true, message: '请选择完成状态', trigger: 'change' }]
  1213. });
  1214. // 培训记录详情
  1215. const recordDetailDialogVisible = ref(false);
  1216. const recordDetail = reactive<any>({
  1217. recordId: undefined,
  1218. courseId: undefined,
  1219. courseName: '',
  1220. userId: undefined,
  1221. userName: '',
  1222. completionStatus: '',
  1223. score: '',
  1224. completionTime: '',
  1225. certificatePath: '',
  1226. createTime: '',
  1227. updateTime: '',
  1228. createBy: '',
  1229. updateBy: '',
  1230. remark: '',
  1231. // 从培训申请获取的详细信息
  1232. department: '',
  1233. currentTitle: '',
  1234. currentPosition: '',
  1235. workStartTime: '',
  1236. phone: '',
  1237. organizerUnit: '',
  1238. trainingType: '',
  1239. trainingFee: '',
  1240. companions: '',
  1241. trainingPurpose: '',
  1242. location: '',
  1243. startTime: '',
  1244. endTime: '',
  1245. applyTime: ''
  1246. });
  1247. // 培训记录多选框选中数据
  1248. const recordIds = ref<Array<string | number>>([]);
  1249. // 培训记录非单个禁用
  1250. const recordSingle = ref(true);
  1251. // 培训记录非多个禁用
  1252. const recordMultiple = ref(true);
  1253. // 课程选项
  1254. const courseOptions = ref<CourseVO[]>([]);
  1255. // 用户选项
  1256. const userOptions = ref<any[]>([]);
  1257. // 证书上传相关
  1258. const certificateDialogVisible = ref(false);
  1259. const uploadRef = ref();
  1260. const certificateFileList = ref<any[]>([]);
  1261. const certificateUploadData = reactive({
  1262. recordId: '',
  1263. isApplication: false
  1264. });
  1265. // 培训记录修改对话框中的证书上传
  1266. const recordCertificateUploadRef = ref();
  1267. const recordCertificateFileList = ref<any[]>([]);
  1268. const uploadHeaders = {
  1269. Authorization: `Bearer ${getToken()}`
  1270. };
  1271. // 培训申请对话框相关
  1272. const applicationDialogVisible = ref(false);
  1273. const applicationDialogTitle = ref('');
  1274. const isResubmitMode = ref(false); // 标记是否为重新提交模式
  1275. const applicationDialogLoading = ref(false);
  1276. const applicationFormRef = ref<any>(null);
  1277. const applicationAttachmentFileList = ref<any[]>([]); // 申请培训附件文件列表
  1278. const applicationDetailAttachmentList = ref<any[]>([]); // 申请详情附件文件列表
  1279. const recordDetailAttachmentList = ref<any[]>([]); // 培训记录详情附件文件列表
  1280. const applicationForm = reactive<{
  1281. applicationId?: number | string;
  1282. // 情况基本信息
  1283. userName: string; // 姓名
  1284. department: string; // 所在部门(系部)
  1285. currentTitle: string; // 现职称
  1286. currentPosition: string; // 现岗位
  1287. workStartTime: string; // 参加工作时间
  1288. phone: string; // 联系电话
  1289. // 培训情况信息
  1290. organizerUnit: string; // 主办单位
  1291. location: string; // 培训地点
  1292. startTime: string; // 开始时间
  1293. endTime: string; // 结束时间
  1294. trainingType: string; // 培训类型
  1295. trainingTypeOther: string; // 其他培训类型描述
  1296. trainingFee: number; // 培训费用
  1297. companions: (string | number)[]; // 同行人
  1298. trainingPurpose: string; // 培训目的
  1299. remark: string; // 备注
  1300. // 兼容原有字段
  1301. courseName: string; // 培训课程(用于后端兼容)
  1302. duration: number; // 学时(用于后端兼容)
  1303. reason: string; // 申请理由(用于后端兼容)
  1304. attachmentIds: string[]; // 附件ID列表
  1305. }>({
  1306. applicationId: undefined,
  1307. // 情况基本信息
  1308. userName: '',
  1309. department: '',
  1310. currentTitle: '',
  1311. currentPosition: '',
  1312. workStartTime: '',
  1313. phone: '',
  1314. // 培训情况信息
  1315. organizerUnit: '',
  1316. location: '',
  1317. startTime: '',
  1318. endTime: '',
  1319. trainingType: '',
  1320. trainingTypeOther: '',
  1321. trainingFee: 0,
  1322. companions: [],
  1323. trainingPurpose: '',
  1324. remark: '',
  1325. // 兼容原有字段
  1326. courseName: '',
  1327. duration: 0,
  1328. reason: '',
  1329. attachmentIds: [] as string[] // 附件ID列表
  1330. });
  1331. // 同行人选择器相关
  1332. const selectedCompanions = ref<TeacherVO[]>([]);
  1333. // 同行人姓名缓存(用于详情展示)
  1334. const companionNamesCache = ref<Record<string, string>>({});
  1335. // 培训申请表单校验规则
  1336. const applicationRules = reactive<any>({
  1337. // 情况基本信息验证
  1338. userName: [{ required: true, message: '姓名不能为空', trigger: 'blur' }],
  1339. department: [{ required: true, message: '所属部门不能为空', trigger: 'blur' }],
  1340. currentTitle: [{ required: true, message: '请输入现职称', trigger: 'blur' }],
  1341. currentPosition: [{ required: true, message: '请选择现岗位', trigger: 'change' }],
  1342. workStartTime: [{ required: true, message: '请选择参加工作时间', trigger: 'change' }],
  1343. phone: [
  1344. { required: true, message: '请输入联系电话', trigger: 'blur' },
  1345. { pattern: /^1[3-9]\d{9}$/ as RegExp, message: '请输入正确的手机号码', trigger: 'blur' }
  1346. ],
  1347. // 培训情况信息验证
  1348. organizerUnit: [{ required: true, message: '请输入主办单位', trigger: 'blur' }],
  1349. location: [{ required: true, message: '请输入培训地点', trigger: 'blur' }],
  1350. startTime: [{ required: true, message: '请选择开始时间', trigger: 'change' }],
  1351. endTime: [{ required: true, message: '请选择结束时间', trigger: 'change' }],
  1352. trainingType: [{ required: true, message: '请选择培训类型', trigger: 'change' }],
  1353. trainingTypeOther: [
  1354. {
  1355. validator: (rule: any, value: string, callback: Function) => {
  1356. if (applicationForm.trainingType === '其他' && (!value || value.trim() === '')) {
  1357. callback(new Error('请输入具体的培训类型'));
  1358. } else {
  1359. callback();
  1360. }
  1361. },
  1362. trigger: 'blur'
  1363. }
  1364. ],
  1365. trainingFee: [{ required: true, message: '请输入培训费用', trigger: 'blur' }],
  1366. trainingPurpose: [{ required: true, message: '请输入培训目的', trigger: 'blur' }]
  1367. });
  1368. // 监听培训类型变化,清空其他类型输入
  1369. watch(
  1370. () => applicationForm.trainingType,
  1371. (newType) => {
  1372. if (newType !== '其他') {
  1373. applicationForm.trainingTypeOther = '';
  1374. }
  1375. }
  1376. );
  1377. // 部门选项 - 从数据库sys_dept表获取
  1378. const departmentOptions = ref<Array<{ value: string; label: string }>>([]);
  1379. /** 查询培训课程列表 - 已废弃 (2025-01-03) */
  1380. function getTrainingList() {
  1381. trainingLoading.value = true;
  1382. // 培训课程模块已废弃,课程信息现在通过培训申请管理
  1383. console.warn('培训课程模块已废弃,请使用培训申请功能');
  1384. courseList.value = [];
  1385. trainingTotal.value = 0;
  1386. trainingLoading.value = false;
  1387. }
  1388. /** 获取部门列表 */
  1389. function getDepartmentList() {
  1390. listDept({
  1391. pageNum: 1,
  1392. pageSize: 1000, // 获取所有部门
  1393. status: 0
  1394. })
  1395. .then((response) => {
  1396. const deptList = response.data || [];
  1397. // 过滤出二级学院和行政单位下的部门,作为培训部门选项
  1398. const filteredDepts = deptList.filter((dept: DeptVO) => {
  1399. // 包含二级学院(101)和行政单位(102)下的部门,排除顶级部门
  1400. return dept.parentId === 101 || dept.parentId === 102;
  1401. });
  1402. departmentOptions.value = filteredDepts.map((dept: DeptVO) => ({
  1403. value: dept.deptName,
  1404. label: dept.deptName
  1405. }));
  1406. console.log('培训申请部门选项已更新:', departmentOptions.value);
  1407. })
  1408. .catch((error) => {
  1409. console.error('获取部门列表失败:', error);
  1410. // 使用备用部门数据
  1411. departmentOptions.value = [
  1412. { value: '人文学院', label: '人文学院' },
  1413. { value: '智能控制学院', label: '智能控制学院' },
  1414. { value: '智能制造学院', label: '智能制造学院' },
  1415. { value: '医药健康学院', label: '医药健康学院' },
  1416. { value: '餐饮休闲学院', label: '餐饮休闲学院' },
  1417. { value: '数字信息学院', label: '数字信息学院' },
  1418. { value: '生态园林学院', label: '生态园林学院' },
  1419. { value: '人事处', label: '人事处' },
  1420. { value: '教务处', label: '教务处' },
  1421. { value: '学生处', label: '学生处' },
  1422. { value: '总务处', label: '总务处' }
  1423. ];
  1424. });
  1425. }
  1426. /** 获取课程类别标签 */
  1427. function getCategoryLabel(value: string): string {
  1428. const option = categoryOptions.value.find((item) => item.value === value);
  1429. return option ? option.label : value;
  1430. }
  1431. /** 表单重置 */
  1432. function resetCourseForm() {
  1433. courseForm.courseId = undefined;
  1434. courseForm.title = '';
  1435. courseForm.category = '';
  1436. courseForm.description = '';
  1437. courseForm.startTime = '';
  1438. courseForm.endTime = '';
  1439. courseForm.duration = 0;
  1440. courseForm.location = '';
  1441. courseForm.status = '0';
  1442. courseForm.remark = '';
  1443. courseFormRef.value?.resetFields();
  1444. }
  1445. /** 取消按钮 */
  1446. function cancelCourseDialog() {
  1447. courseDialogVisible.value = false;
  1448. resetCourseForm();
  1449. }
  1450. /** 新增培训课程 */
  1451. function handleAddCourse() {
  1452. resetCourseForm();
  1453. courseDialogVisible.value = true;
  1454. courseDialogTitle.value = '添加培训课程';
  1455. }
  1456. /** 修改培训课程 */
  1457. function handleUpdateCourse(row?: CourseVO) {
  1458. resetCourseForm();
  1459. const courseId = row?.courseId || trainingIds.value[0];
  1460. if (!courseId) {
  1461. return;
  1462. }
  1463. // 培训课程模块已废弃 (2025-01-03)
  1464. console.warn('培训课程编辑功能已废弃,请使用培训申请功能');
  1465. proxy?.$modal.msgWarning('培训课程模块已废弃,请使用培训申请功能');
  1466. }
  1467. /** 提交按钮 */
  1468. function submitCourseForm() {
  1469. courseFormRef.value?.validate((valid: boolean) => {
  1470. if (valid) {
  1471. courseDialogLoading.value = true;
  1472. // 培训课程模块已废弃 (2025-01-03)
  1473. console.warn('培训课程新增/编辑功能已废弃,请使用培训申请功能');
  1474. proxy?.$modal.msgWarning('培训课程模块已废弃,请使用培训申请功能');
  1475. courseDialogLoading.value = false;
  1476. }
  1477. });
  1478. }
  1479. /** 删除培训课程 */
  1480. function handleDeleteCourse(row?: CourseVO) {
  1481. const courseIds = row?.courseId || trainingIds.value;
  1482. if (!courseIds || (Array.isArray(courseIds) && courseIds.length === 0)) {
  1483. return;
  1484. }
  1485. let confirmMessage = '';
  1486. if (row) {
  1487. confirmMessage = `是否确认删除课程"${row.title}"?`;
  1488. } else {
  1489. const selectedItems = courseList.value.filter((item) => trainingIds.value.includes(item.courseId));
  1490. if (selectedItems.length === 1) {
  1491. confirmMessage = `是否确认删除课程"${selectedItems[0].title}"?`;
  1492. } else {
  1493. const names = selectedItems.map((item) => item.title).join('、');
  1494. confirmMessage = `是否确认删除课程"${names}"?`;
  1495. }
  1496. }
  1497. proxy?.$modal.confirm(confirmMessage).then(() => {
  1498. // 培训课程模块已废弃 (2025-01-03)
  1499. console.warn('培训课程删除功能已废弃,请使用培训申请功能');
  1500. proxy?.$modal.msgWarning('培训课程模块已废弃,请使用培训申请功能');
  1501. });
  1502. }
  1503. /** 导出培训课程 */
  1504. function handleExportCourse() {
  1505. proxy?.download(
  1506. 'rs/training/course/export',
  1507. {
  1508. ...trainingQueryParams
  1509. },
  1510. `training_course_${new Date().getTime()}.xlsx`
  1511. );
  1512. }
  1513. /** 查看培训课程详情 - 已废弃 (2025-01-03) */
  1514. function handleViewCourse(row: CourseVO) {
  1515. console.warn('培训课程查看功能已废弃,请使用培训申请功能');
  1516. proxy?.$modal.msgWarning('培训课程模块已废弃,请使用培训申请功能');
  1517. }
  1518. /** 切换课程状态 - 已废弃 (2025-01-03) */
  1519. function handleToggleStatus(row: CourseVO) {
  1520. console.warn('培训课程状态切换功能已废弃,请使用培训申请功能');
  1521. proxy?.$modal.msgWarning('培训课程模块已废弃,请使用培训申请功能');
  1522. }
  1523. /** 查看培训申请记录 */
  1524. function handleViewApplications(row: CourseVO) {
  1525. applicationQueryParams.courseId = row.courseId;
  1526. applicationQueryParams.pageNum = 1;
  1527. applicationTotal.value = 0; // Reset total for new search
  1528. getApplicationList();
  1529. proxy?.$modal.msgSuccess(`查看${row.title}的申请记录`);
  1530. // 此处可以跳转到申请记录页面或打开申请记录弹窗
  1531. }
  1532. /** 培训申请管理相关 */
  1533. function getApplicationList() {
  1534. applicationLoading.value = true;
  1535. // 构建查询参数,自动过滤掉已通过的数据
  1536. const queryParams = {
  1537. ...applicationQueryParams,
  1538. // 排除已通过状态的数据,只显示待审核、已拒绝、已取消等状态
  1539. excludeStatus: '1' // 1表示已通过状态
  1540. };
  1541. // 调用API获取申请列表
  1542. listTrainingApplication(queryParams)
  1543. .then((response) => {
  1544. // 获取申请列表数据
  1545. const applications = response.rows || [];
  1546. // 前端二次过滤,确保不显示已通过的数据
  1547. const filteredApplications = applications.filter((app) => app.status !== '1');
  1548. applicationList.value = filteredApplications;
  1549. applicationTotal.value = filteredApplications.length;
  1550. applicationLoading.value = false;
  1551. })
  1552. .catch(() => {
  1553. applicationLoading.value = false;
  1554. proxy?.$modal.msgError('获取培训申请列表失败');
  1555. });
  1556. }
  1557. /** 获取完成状态的标签类型 */
  1558. const getCompletionStatusType = (status: string) => {
  1559. // 培训记录的完成状态逻辑
  1560. if (status === '1') return 'success'; // 已完成 - 绿色
  1561. if (status === '2') return 'danger'; // 未完成 - 红色
  1562. // 对于空状态或其他状态,由于培训记录都是基于已通过审批的申请生成的,默认显示为已通过
  1563. return 'success'; // 已通过 - 绿色
  1564. };
  1565. /** 获取完成状态的标签文本 */
  1566. const getCompletionStatusLabel = (status: string) => {
  1567. // 培训记录的完成状态逻辑
  1568. if (status === '1') return '已完成';
  1569. if (status === '2') return '未完成';
  1570. // 对于空状态或其他状态,由于培训记录都是基于已通过审批的申请生成的,默认显示为已通过
  1571. return '已通过';
  1572. };
  1573. /** 获取教师列表 */
  1574. function getTeacherList() {
  1575. // 使用 system/teacher 接口获取教师列表,设置大的pageSize以获取所有教师
  1576. listTeacher({
  1577. pageNum: 1,
  1578. pageSize: 9999 // 设置足够大的pageSize以获取所有教师
  1579. })
  1580. .then((response: any) => {
  1581. const teachers = response.rows || [];
  1582. teacherList.value = teachers.map((item: TeacherVO) => ({
  1583. teacherId: item.userId, // 使用 userId 作为 teacherId
  1584. teacherName: item.nickName || item.userName, // 使用 nickName 或 userName
  1585. teacherType: '' // system/teacher 接口没有 teacherType 字段
  1586. }));
  1587. console.log('初始化教师列表加载完成:', teacherList.value.length, '位教师');
  1588. })
  1589. .catch(() => {
  1590. console.error('获取教师列表失败');
  1591. });
  1592. }
  1593. /** 异步加载教师列表用于详情显示(容错版,权限不足时不报错)*/
  1594. async function loadTeacherListForDisplay() {
  1595. try {
  1596. console.log('开始加载教师列表...');
  1597. // 使用 system/teacher 接口获取教师列表,设置大的pageSize以获取所有教师
  1598. const response: any = await listTeacher({
  1599. pageNum: 1,
  1600. pageSize: 9999 // 设置足够大的pageSize以获取所有教师
  1601. });
  1602. const teachers = response.rows || [];
  1603. teacherList.value = teachers.map((item: TeacherVO) => ({
  1604. teacherId: item.userId, // 使用 userId 作为 teacherId
  1605. teacherName: item.nickName || item.userName, // 使用 nickName 或 userName
  1606. teacherType: '' // system/teacher 接口没有 teacherType 字段
  1607. }));
  1608. console.log('教师列表加载完成:', teacherList.value.length, '位教师');
  1609. console.log(
  1610. '教师ID列表:',
  1611. teacherList.value.map((t) => t.teacherId)
  1612. );
  1613. } catch (error: any) {
  1614. console.warn('获取教师列表失败(可能是权限不足),将使用备用查询方式:', error);
  1615. // ⚠️ 不再抛出错误,允许使用备用的同行人查询接口
  1616. teacherList.value = [];
  1617. }
  1618. }
  1619. /** 处理申请详情的附件数据 */
  1620. async function handleApplicationDetailAttachmentData(attachmentIds: string | null | undefined) {
  1621. try {
  1622. if (!attachmentIds || !attachmentIds.toString().trim()) {
  1623. console.log('申请详情没有附件数据,清空附件列表');
  1624. applicationDetailAttachmentList.value = [];
  1625. return;
  1626. }
  1627. console.log('开始处理申请详情附件数据:', attachmentIds);
  1628. const ossIdsArray = attachmentIds
  1629. .toString()
  1630. .split(',')
  1631. .map((id) => id.trim())
  1632. .filter((id) => id);
  1633. if (ossIdsArray.length === 0) {
  1634. applicationDetailAttachmentList.value = [];
  1635. return;
  1636. }
  1637. const response = await request({
  1638. url: `/resource/oss/listByIds/${ossIdsArray.join(',')}`,
  1639. method: 'get'
  1640. });
  1641. if (response.code === 200 && response.data) {
  1642. console.log('获取到的申请附件信息:', response.data);
  1643. const attachmentFiles = response.data.map((item: any, index: number) => ({
  1644. uid: `application_detail_${index}_${Date.now()}`,
  1645. name: item.originalName || `申请附件${index + 1}`,
  1646. url: item.url,
  1647. ossId: item.ossId,
  1648. status: 'success',
  1649. fileSize: item.fileSize || 0, // 使用OSS表中的fileSize字段
  1650. uploadTime: item.createTime,
  1651. response: {
  1652. code: 200,
  1653. data: {
  1654. url: item.url,
  1655. ossId: item.ossId
  1656. }
  1657. }
  1658. }));
  1659. applicationDetailAttachmentList.value = attachmentFiles;
  1660. console.log('申请详情附件数据处理完成,共', attachmentFiles.length, '个附件');
  1661. } else {
  1662. console.warn('获取申请附件信息失败:', response);
  1663. applicationDetailAttachmentList.value = [];
  1664. }
  1665. } catch (error) {
  1666. console.error('处理申请详情附件数据失败:', error);
  1667. applicationDetailAttachmentList.value = [];
  1668. }
  1669. }
  1670. /** 新增培训申请 */
  1671. async function handleAddApplication() {
  1672. resetApplicationForm();
  1673. applicationDialogVisible.value = true;
  1674. applicationDialogTitle.value = '申请培训';
  1675. // 加载课程选项
  1676. if (courseOptions.value && courseOptions.value.length === 0) {
  1677. loadCourseOptions();
  1678. }
  1679. // 加载教师列表
  1680. if (teacherList.value.length === 0) {
  1681. getTeacherList();
  1682. }
  1683. // 自动获取登录用户的部门信息和申请人信息
  1684. try {
  1685. // 确保用户信息已加载
  1686. if (!userStore.userId) {
  1687. await userStore.getInfo();
  1688. }
  1689. console.log('开始自动填充用户信息:', {
  1690. userId: userStore.userId,
  1691. userName: userStore.name,
  1692. nickname: userStore.nickname,
  1693. cachedDeptName: userStore.deptName
  1694. });
  1695. // 自动填充申请人姓名(使用用户昵称,即真实姓名)
  1696. const displayName = userStore.nickname || userStore.name || `用户${userStore.userId}`;
  1697. applicationForm.userName = displayName;
  1698. console.log('申请人姓名自动填充:', {
  1699. userId: userStore.userId,
  1700. displayName: displayName,
  1701. nickname: userStore.nickname,
  1702. userName: userStore.name
  1703. });
  1704. // 重新获取用户信息以确保获取到deptId
  1705. await userStore.getInfo();
  1706. const userInfo = await getUserInfo();
  1707. const userDeptId = userInfo.data.user.deptId;
  1708. console.log('用户信息详情:', {
  1709. userId: userStore.userId,
  1710. deptId: userDeptId,
  1711. cachedDeptName: userStore.deptName
  1712. });
  1713. // 如果有deptId,从数据库sys_dept表实时获取部门名称
  1714. if (userDeptId) {
  1715. console.log('开始从数据库sys_dept表获取部门信息 - deptId:', userDeptId);
  1716. try {
  1717. const deptResponse = await getDept(userDeptId);
  1718. if (deptResponse.code === 200 && deptResponse.data) {
  1719. const realDeptName = deptResponse.data.deptName;
  1720. applicationForm.department = realDeptName;
  1721. console.log('培训申请部门自动匹配成功:', {
  1722. userId: userStore.userId,
  1723. userDeptId: userDeptId,
  1724. deptNameFromDatabase: realDeptName,
  1725. 关联逻辑: 'sys_user.dept_id -> sys_dept.dept_name'
  1726. });
  1727. } else {
  1728. console.warn('从数据库获取部门信息失败,使用缓存的部门名称');
  1729. applicationForm.department = userStore.deptName || '';
  1730. }
  1731. } catch (deptError) {
  1732. console.error('查询部门信息API调用失败:', deptError);
  1733. applicationForm.department = userStore.deptName || '';
  1734. }
  1735. } else {
  1736. console.warn('用户deptId不存在,使用缓存的部门名称');
  1737. applicationForm.department = userStore.deptName || '';
  1738. }
  1739. } catch (error) {
  1740. console.error('获取用户信息失败:', error);
  1741. // 如果获取失败,使用空字符串,用户可以手动输入
  1742. applicationForm.department = '';
  1743. applicationForm.userName = `用户${userStore.userId || '未知'}`;
  1744. }
  1745. }
  1746. /** 重置培训申请表单 */
  1747. function resetApplicationForm() {
  1748. applicationForm.applicationId = undefined;
  1749. // 情况基本信息
  1750. applicationForm.userName = '';
  1751. applicationForm.department = '';
  1752. applicationForm.currentTitle = '';
  1753. applicationForm.currentPosition = '';
  1754. applicationForm.workStartTime = '';
  1755. applicationForm.phone = '';
  1756. // 培训情况信息
  1757. applicationForm.organizerUnit = '';
  1758. applicationForm.location = '';
  1759. applicationForm.startTime = '';
  1760. applicationForm.endTime = '';
  1761. applicationForm.trainingType = '';
  1762. applicationForm.trainingTypeOther = '';
  1763. applicationForm.trainingFee = 0;
  1764. applicationForm.companions = [];
  1765. applicationForm.trainingPurpose = '';
  1766. applicationForm.remark = '';
  1767. // 兼容原有字段
  1768. applicationForm.courseName = '';
  1769. applicationForm.duration = 0;
  1770. applicationForm.reason = '';
  1771. applicationForm.attachmentIds = [];
  1772. applicationAttachmentFileList.value = [];
  1773. selectedCompanions.value = [];
  1774. applicationFormRef.value?.resetFields();
  1775. }
  1776. /** 处理同行人变化 */
  1777. function handleCompanionsChange(teachers: TeacherVO[]) {
  1778. selectedCompanions.value = teachers;
  1779. applicationForm.companions = teachers.map((teacher) => teacher.userId);
  1780. }
  1781. /** 加载编辑时的同行人数据 */
  1782. async function loadCompanionsForEdit() {
  1783. if (applicationForm.companions && applicationForm.companions.length > 0) {
  1784. try {
  1785. // 这里需要根据userId获取教师信息
  1786. // 由于TeacherMultiSelector组件需要完整的TeacherVO对象
  1787. // 我们需要调用API获取教师详细信息
  1788. const teacherPromises = applicationForm.companions.map(async (userId) => {
  1789. try {
  1790. // 这里需要调用获取教师详情的API
  1791. // 暂时使用teacherList中的数据进行匹配
  1792. const teacher = teacherList.value.find((t) => t.teacherId === userId);
  1793. if (teacher) {
  1794. return {
  1795. userId: teacher.teacherId,
  1796. nickName: teacher.teacherName,
  1797. userName: teacher.teacherName,
  1798. phonenumber: '',
  1799. email: '',
  1800. sex: '0',
  1801. deptName: ''
  1802. } as TeacherVO;
  1803. }
  1804. return null;
  1805. } catch (error) {
  1806. console.error('获取教师信息失败:', error);
  1807. return null;
  1808. }
  1809. });
  1810. const teachers = await Promise.all(teacherPromises);
  1811. selectedCompanions.value = teachers.filter((t) => t !== null) as TeacherVO[];
  1812. } catch (error) {
  1813. console.error('加载同行人数据失败:', error);
  1814. selectedCompanions.value = [];
  1815. }
  1816. } else {
  1817. selectedCompanions.value = [];
  1818. }
  1819. }
  1820. /** 取消培训申请对话框 */
  1821. function cancelApplicationDialog() {
  1822. applicationDialogVisible.value = false;
  1823. isResubmitMode.value = false; // 重置重新提交模式
  1824. resetApplicationForm();
  1825. }
  1826. /** 提交培训申请表单 */
  1827. function submitApplicationForm() {
  1828. applicationFormRef.value?.validate((valid: boolean) => {
  1829. if (valid) {
  1830. console.log('[提交培训申请] 提交前检查');
  1831. console.log('[提交培训申请] applicationForm.attachmentIds:', applicationForm.attachmentIds);
  1832. console.log('[提交培训申请] applicationAttachmentFileList:', applicationAttachmentFileList.value);
  1833. applicationDialogLoading.value = true;
  1834. // 创建符合API要求的数据结构
  1835. const apiData: any = {
  1836. courseId: 0, // 使用0表示自定义课程,确保是数字类型
  1837. // 基本字段(兼容原有API)
  1838. courseName: applicationForm.organizerUnit || '自定义培训', // 使用主办单位作为课程名称
  1839. department: applicationForm.department,
  1840. reason: applicationForm.trainingPurpose || '培训目的', // 使用培训目的作为申请理由
  1841. remark: applicationForm.remark,
  1842. location: applicationForm.location,
  1843. duration: Number(applicationForm.trainingFee) || 0, // 使用培训费用作为学时的临时方案
  1844. startTime: applicationForm.startTime,
  1845. endTime: applicationForm.endTime,
  1846. // 新增字段 - 将表单数据扩展字段添加到API中
  1847. currentTitle: applicationForm.currentTitle,
  1848. currentPosition: applicationForm.currentPosition,
  1849. workStartTime: applicationForm.workStartTime,
  1850. phone: applicationForm.phone,
  1851. organizerUnit: applicationForm.organizerUnit,
  1852. trainingType: applicationForm.trainingType === '其他' ? applicationForm.trainingTypeOther : applicationForm.trainingType,
  1853. trainingFee: Number(applicationForm.trainingFee),
  1854. trainingPurpose: applicationForm.trainingPurpose,
  1855. companions: JSON.stringify(applicationForm.companions || []),
  1856. // 附件信息
  1857. attachmentIds: applicationForm.attachmentIds.join(',')
  1858. };
  1859. console.log('[提交培训申请] 最终提交的API数据:', apiData);
  1860. console.log('[提交培训申请] attachmentIds字段值:', apiData.attachmentIds);
  1861. // 如果是编辑现有申请,添加applicationId
  1862. if (applicationForm.applicationId) {
  1863. apiData.applicationId = applicationForm.applicationId;
  1864. // 检查是否是被拒绝的申请重新提交
  1865. const currentApplication = applicationList.value.find((item) => item.applicationId === applicationForm.applicationId);
  1866. if (currentApplication && currentApplication.status === '2') {
  1867. // 如果是被拒绝的申请重新提交,将状态重置为待审核
  1868. apiData.status = '0';
  1869. }
  1870. // 如果是重新提交模式,使用专门的重新提交API
  1871. if (isResubmitMode.value) {
  1872. resubmitTrainingApplication(applicationForm.applicationId, apiData)
  1873. .then(() => {
  1874. proxy?.$modal.msgSuccess('修改并重新提交成功!您的申请已重新进入审批流程。');
  1875. isResubmitMode.value = false; // 重置重新提交模式
  1876. applicationDialogVisible.value = false;
  1877. getApplicationList();
  1878. })
  1879. .catch((error) => {
  1880. console.error('重新提交申请失败:', error);
  1881. proxy?.$modal.msgError(`重新提交失败: ${error.message || '服务器错误'}`);
  1882. })
  1883. .finally(() => {
  1884. applicationDialogLoading.value = false;
  1885. });
  1886. } else {
  1887. // 使用更新API
  1888. updateTrainingApplication(apiData)
  1889. .then(() => {
  1890. proxy?.$modal.msgSuccess('申请更新成功');
  1891. applicationDialogVisible.value = false;
  1892. getApplicationList();
  1893. })
  1894. .catch((error) => {
  1895. console.error('更新申请失败:', error);
  1896. proxy?.$modal.msgError(`更新失败: ${error.message || '服务器错误'}`);
  1897. })
  1898. .finally(() => {
  1899. applicationDialogLoading.value = false;
  1900. });
  1901. }
  1902. } else {
  1903. // 新增申请
  1904. console.log('提交的培训申请数据:', apiData); // 调试日志
  1905. // 使用无需权限验证的API
  1906. submitTrainingApplication(apiData)
  1907. .then((response) => {
  1908. console.log('提交申请响应:', response); // 记录成功响应
  1909. proxy?.$modal.msgSuccess('申请提交成功');
  1910. applicationDialogVisible.value = false;
  1911. getApplicationList();
  1912. })
  1913. .catch((error) => {
  1914. // 打印详细错误信息
  1915. console.error('提交申请失败:', error);
  1916. console.error('错误详情:', error.response ? error.response.data : '无响应数据');
  1917. // 如果是权限问题,提示用户
  1918. if (error.response && error.response.status === 401) {
  1919. proxy?.$modal.msgError('权限验证失败,请重新登录');
  1920. } else if (error.response && error.response.status === 403) {
  1921. proxy?.$modal.msgError('您没有权限执行此操作');
  1922. } else {
  1923. proxy?.$modal.msgError(`提交失败: ${error.message || '服务器错误'}`);
  1924. }
  1925. })
  1926. .finally(() => {
  1927. applicationDialogLoading.value = false;
  1928. });
  1929. }
  1930. }
  1931. });
  1932. }
  1933. /** 导出培训申请 */
  1934. function handleExportTrainingApplication() {
  1935. proxy?.download(
  1936. 'rs/training/application/export',
  1937. {
  1938. ...applicationQueryParams
  1939. },
  1940. `training_application_${new Date().getTime()}.xlsx`
  1941. );
  1942. }
  1943. /** 获取申请状态标签 */
  1944. function getStatusLabel(value: string): string {
  1945. const option = [
  1946. { value: '0', label: '待审核' },
  1947. { value: '1', label: '已通过' },
  1948. { value: '2', label: '已拒绝' },
  1949. { value: '3', label: '已取消' },
  1950. { value: '4', label: '已完成' }
  1951. ].find((item) => item.value === value);
  1952. return option ? option.label : value;
  1953. }
  1954. /** 格式化文件大小 */
  1955. function formatFileSize(bytes: number | string | undefined): string {
  1956. if (!bytes || bytes === 0) return '未知大小';
  1957. // 如果是字符串且包含中文,直接返回
  1958. if (typeof bytes === 'string' && /[\u4e00-\u9fa5]/.test(bytes)) {
  1959. return bytes;
  1960. }
  1961. const size = typeof bytes === 'string' ? parseInt(bytes) : bytes;
  1962. if (isNaN(size)) return '未知大小';
  1963. const k = 1024;
  1964. const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
  1965. const i = Math.floor(Math.log(size) / Math.log(k));
  1966. return parseFloat((size / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
  1967. }
  1968. /** 异步加载同行人姓名并缓存(使用新的批量查询接口)*/
  1969. async function loadCompanionNames(companions: (string | number)[] | string | null | undefined): Promise<string> {
  1970. if (!companions) {
  1971. return '';
  1972. }
  1973. // 生成缓存key
  1974. const cacheKey = typeof companions === 'string' ? companions : JSON.stringify(companions);
  1975. // 如果已缓存,直接返回
  1976. if (companionNamesCache.value[cacheKey]) {
  1977. return companionNamesCache.value[cacheKey];
  1978. }
  1979. let companionArray: number[] = [];
  1980. // 解析同行人ID列表
  1981. if (typeof companions === 'string') {
  1982. try {
  1983. const parsed = JSON.parse(companions);
  1984. if (Array.isArray(parsed)) {
  1985. companionArray = parsed.map((id) => Number(id));
  1986. }
  1987. console.log('[同行人解析] JSON解析成功:', companionArray);
  1988. } catch (e) {
  1989. // 如果JSON解析失败,可能是逗号分隔的字符串
  1990. companionArray = companions
  1991. .split(',')
  1992. .map((id) => Number(id.trim()))
  1993. .filter((id) => !isNaN(id));
  1994. console.log('[同行人解析] 使用逗号分隔解析:', companionArray);
  1995. }
  1996. } else if (Array.isArray(companions)) {
  1997. companionArray = companions.map((id) => Number(id));
  1998. console.log('[同行人解析] 直接使用数组:', companionArray);
  1999. }
  2000. if (companionArray.length === 0) {
  2001. return '';
  2002. }
  2003. try {
  2004. // 调用新的批量查询接口(不需要system:teacher:list权限)
  2005. console.log('[同行人查询] 调用批量查询接口:', companionArray);
  2006. const response: any = await batchQueryCompanions(companionArray);
  2007. const users = response.data || [];
  2008. console.log('[同行人查询] 查询结果:', users.length, '个用户');
  2009. // 拼接姓名
  2010. const names = companionArray
  2011. .map((userId) => {
  2012. const user = users.find((u: any) => u.userId === userId);
  2013. const name = user ? user.nickName || user.userName : `未知用户(ID:${userId})`;
  2014. console.log(`[同行人查询] ID ${userId} -> ${name}`);
  2015. return name;
  2016. })
  2017. .join('、');
  2018. // 缓存结果
  2019. companionNamesCache.value[cacheKey] = names;
  2020. console.log('[同行人查询] 最终结果:', names);
  2021. return names;
  2022. } catch (error) {
  2023. console.error('[同行人查询] 接口调用失败:', error);
  2024. // 降级方案:显示ID列表
  2025. const fallback = `同行人ID: ${companionArray.join('、')}`;
  2026. companionNamesCache.value[cacheKey] = fallback;
  2027. return fallback;
  2028. }
  2029. }
  2030. /** 获取同行人姓名列表(同步版,从缓存读取)*/
  2031. function getCompanionNames(companions: (string | number)[] | string | null | undefined): string {
  2032. if (!companions) {
  2033. return '';
  2034. }
  2035. const cacheKey = typeof companions === 'string' ? companions : JSON.stringify(companions);
  2036. // 从缓存返回
  2037. if (companionNamesCache.value[cacheKey]) {
  2038. return companionNamesCache.value[cacheKey];
  2039. }
  2040. // 如果缓存中没有,返回"加载中..."并异步加载
  2041. loadCompanionNames(companions);
  2042. return '加载中...';
  2043. }
  2044. /** 查看申请详情 */
  2045. async function handleViewApplicant(row: any) {
  2046. console.log('[查看申请详情] 原始数据:', {
  2047. userId: row.userId,
  2048. userName: row.userName,
  2049. nickName: row.nickName,
  2050. attachmentIds: row.attachmentIds // 添加附件ID日志
  2051. });
  2052. // 如果行数据中没有完整的课程名称,尝试从课程列表获取
  2053. if (!row.courseName && row.courseId) {
  2054. const course = courseList.value.find((c) => c.courseId === row.courseId);
  2055. if (course) {
  2056. row.courseName = course.title;
  2057. }
  2058. }
  2059. // 复制申请详情
  2060. Object.assign(applicationDetail, row);
  2061. console.log('[查看申请详情] 详情数据已设置:', {
  2062. userName: applicationDetail.userName,
  2063. nickName: applicationDetail.nickName,
  2064. companions: applicationDetail.companions,
  2065. attachmentIds: applicationDetail.attachmentIds
  2066. });
  2067. // 预加载同行人信息(使用新接口,不需要system:teacher:list权限)
  2068. if (row.companions) {
  2069. await loadCompanionNames(row.companions);
  2070. console.log('[查看申请详情] 同行人信息已预加载');
  2071. }
  2072. // 加载申请详情的附件数据
  2073. await handleApplicationDetailAttachmentData(row.attachmentIds);
  2074. applicationDetailOpen.value = true;
  2075. }
  2076. /** 修改培训申请 */
  2077. function handleEditApplication(row: any) {
  2078. resetApplicationForm();
  2079. applicationDialogVisible.value = true;
  2080. applicationDialogTitle.value = '修改培训申请';
  2081. // 复制申请数据到表单 - 新字段结构
  2082. applicationForm.userName = row.userName || userStore.nickname || userStore.name;
  2083. applicationForm.department = row.department;
  2084. applicationForm.currentTitle = row.currentTitle || '';
  2085. applicationForm.currentPosition = row.currentPosition || '';
  2086. applicationForm.workStartTime = row.workStartTime || '';
  2087. applicationForm.phone = row.phone || '';
  2088. applicationForm.organizerUnit = row.organizerUnit || row.courseName || '';
  2089. applicationForm.location = row.location;
  2090. applicationForm.startTime = row.startTime;
  2091. applicationForm.endTime = row.endTime;
  2092. // 处理培训类型和其他类型描述
  2093. const trainingType = row.trainingType || '';
  2094. const predefinedTypes = ['教学', '德育', '行政', '管理', '其他'];
  2095. if (predefinedTypes.includes(trainingType)) {
  2096. applicationForm.trainingType = trainingType;
  2097. applicationForm.trainingTypeOther = '';
  2098. } else {
  2099. // 如果是自定义类型,设置为"其他"并将具体内容放到other字段
  2100. applicationForm.trainingType = '其他';
  2101. applicationForm.trainingTypeOther = trainingType;
  2102. }
  2103. applicationForm.trainingFee = row.trainingFee || 0;
  2104. applicationForm.trainingPurpose = row.trainingPurpose || row.reason || '';
  2105. applicationForm.remark = row.remark;
  2106. // 处理同行人员字段 - 从JSON字符串解析为数组
  2107. if (row.companions) {
  2108. try {
  2109. if (typeof row.companions === 'string') {
  2110. applicationForm.companions = JSON.parse(row.companions);
  2111. } else if (Array.isArray(row.companions)) {
  2112. applicationForm.companions = row.companions;
  2113. } else {
  2114. applicationForm.companions = [];
  2115. }
  2116. } catch (e) {
  2117. console.warn('解析companions字段失败:', e);
  2118. applicationForm.companions = [];
  2119. }
  2120. } else {
  2121. applicationForm.companions = [];
  2122. }
  2123. // 处理附件ID列表 - 从逗号分隔字符串解析为数组
  2124. if (row.attachmentIds) {
  2125. applicationForm.attachmentIds = row.attachmentIds.split(',').filter((id) => id.trim());
  2126. } else {
  2127. applicationForm.attachmentIds = [];
  2128. }
  2129. // 兼容原有字段
  2130. applicationForm.courseName = row.courseName || '';
  2131. applicationForm.duration = row.duration || 0;
  2132. applicationForm.reason = row.reason || '';
  2133. // 保存当前编辑的申请ID
  2134. applicationForm.applicationId = row.applicationId;
  2135. // 加载同行人数据到选择器
  2136. loadCompanionsForEdit();
  2137. }
  2138. /** 撤回培训申请 */
  2139. function handleCancelApplication(row: any) {
  2140. proxy?.$modal
  2141. .confirm(`确认要撤回培训申请"${row.courseName || '未命名'}"吗?`)
  2142. .then(() => {
  2143. return cancelTrainingApplication(row.applicationId);
  2144. })
  2145. .then(() => {
  2146. getApplicationList();
  2147. proxy?.$modal.msgSuccess('申请已撤回');
  2148. })
  2149. .catch((error) => {
  2150. // 如果是用户取消操作,不显示错误提示
  2151. if (error === 'cancel' || error === 'close' || error.message === 'cancel') {
  2152. return;
  2153. }
  2154. console.error('撤回申请失败:', error);
  2155. proxy?.$modal.msgError(`撤回失败: ${error.message || '未知错误'}`);
  2156. });
  2157. }
  2158. /** 修改并重新提交申请(用于已拒绝状态) */
  2159. async function handleUpdateAndResubmitApplication(row: any) {
  2160. try {
  2161. // 获取申请详情
  2162. const response = await getTrainingApplication(row.applicationId);
  2163. if (response.code === 200 && response.data) {
  2164. // 设置表单数据 - 新字段结构
  2165. const data = response.data;
  2166. applicationForm.userName = data.userName || userStore.nickname || userStore.name;
  2167. applicationForm.department = data.department;
  2168. applicationForm.currentTitle = data.currentTitle || '';
  2169. applicationForm.currentPosition = data.currentPosition || '';
  2170. applicationForm.workStartTime = data.workStartTime || '';
  2171. applicationForm.phone = data.phone || '';
  2172. applicationForm.organizerUnit = data.organizerUnit || data.courseName || '';
  2173. applicationForm.location = data.location;
  2174. applicationForm.startTime = data.startTime;
  2175. applicationForm.endTime = data.endTime;
  2176. applicationForm.trainingType = data.trainingType || '';
  2177. applicationForm.trainingFee = data.trainingFee || 0;
  2178. applicationForm.trainingPurpose = data.trainingPurpose || data.reason || '';
  2179. applicationForm.remark = data.remark;
  2180. // 兼容原有字段
  2181. applicationForm.courseName = data.courseName || '';
  2182. applicationForm.duration = data.duration || 0;
  2183. applicationForm.reason = data.reason || '';
  2184. // 设置为编辑模式并标记为重新提交
  2185. applicationForm.applicationId = row.applicationId;
  2186. isResubmitMode.value = true;
  2187. // 打开编辑对话框
  2188. applicationDialogVisible.value = true;
  2189. applicationDialogTitle.value = '修改并重新提交申请';
  2190. } else {
  2191. proxy?.$modal.msgError('获取申请详情失败');
  2192. }
  2193. } catch (error) {
  2194. console.error('获取申请详情失败:', error);
  2195. proxy?.$modal.msgError('获取申请详情失败');
  2196. }
  2197. }
  2198. /** 重新提交被拒绝的培训申请 */
  2199. function handleResubmitApplication(row: any) {
  2200. resetApplicationForm();
  2201. applicationDialogVisible.value = true;
  2202. applicationDialogTitle.value = '重新提交培训申请';
  2203. // 复制申请数据到表单 - 新字段结构
  2204. applicationForm.userName = row.userName || userStore.nickname || userStore.name;
  2205. applicationForm.department = row.department;
  2206. applicationForm.currentTitle = row.currentTitle || '';
  2207. applicationForm.currentPosition = row.currentPosition || '';
  2208. applicationForm.workStartTime = row.workStartTime || '';
  2209. applicationForm.phone = row.phone || '';
  2210. applicationForm.organizerUnit = row.organizerUnit || row.courseName || '';
  2211. applicationForm.location = row.location;
  2212. applicationForm.startTime = row.startTime;
  2213. applicationForm.endTime = row.endTime;
  2214. // 处理培训类型和其他类型描述
  2215. const trainingType = row.trainingType || '';
  2216. const predefinedTypes = ['教学', '德育', '行政', '管理', '其他'];
  2217. if (predefinedTypes.includes(trainingType)) {
  2218. applicationForm.trainingType = trainingType;
  2219. applicationForm.trainingTypeOther = '';
  2220. } else {
  2221. // 如果是自定义类型,设置为"其他"并将具体内容放到other字段
  2222. applicationForm.trainingType = '其他';
  2223. applicationForm.trainingTypeOther = trainingType;
  2224. }
  2225. applicationForm.trainingFee = row.trainingFee || 0;
  2226. applicationForm.trainingPurpose = row.trainingPurpose || row.reason || '';
  2227. applicationForm.remark = row.remark;
  2228. // 兼容原有字段
  2229. applicationForm.courseName = row.courseName || '';
  2230. applicationForm.duration = row.duration || 0;
  2231. applicationForm.reason = row.reason || '';
  2232. // 保存当前编辑的申请ID
  2233. applicationForm.applicationId = row.applicationId;
  2234. }
  2235. /** 删除培训申请 */
  2236. function handleDeleteApplication(row: any) {
  2237. proxy?.$modal
  2238. .confirm(`确认删除培训申请"${row.courseName || '未命名'}"吗?`)
  2239. .then(() => {
  2240. return deleteTrainingApplication(row.applicationId);
  2241. })
  2242. .then(() => {
  2243. getApplicationList();
  2244. proxy?.$modal.msgSuccess('删除成功');
  2245. })
  2246. .catch((error) => {
  2247. // 如果是用户取消操作,不显示错误提示
  2248. if (error === 'cancel' || error === 'close' || error.message === 'cancel') {
  2249. return;
  2250. }
  2251. console.error('删除失败:', error);
  2252. proxy?.$modal.msgError(`删除失败: ${error.message || '未知错误'}`);
  2253. });
  2254. }
  2255. /** 更新申请状态 */
  2256. function handleUpdateStatus(row: any, status: string) {
  2257. let text = '';
  2258. switch (status) {
  2259. case '1':
  2260. text = '通过';
  2261. break;
  2262. case '2':
  2263. text = '拒绝';
  2264. break;
  2265. case '3':
  2266. text = '取消';
  2267. break;
  2268. case '4':
  2269. text = '完成';
  2270. break;
  2271. default:
  2272. text = '更新';
  2273. }
  2274. proxy?.$modal
  2275. .confirm(`确认要${text}该申请吗?`)
  2276. .then(() => {
  2277. // 调用更新申请状态的API
  2278. return updateApplicationStatus(row.applicationId, status);
  2279. })
  2280. .then(() => {
  2281. // 更新本地数据
  2282. row.status = status;
  2283. if (status === '1' || status === '2') {
  2284. row.approvalTime = new Date().toISOString();
  2285. }
  2286. proxy?.$modal.msgSuccess(`${text}申请成功`);
  2287. // 刷新申请列表
  2288. getApplicationList();
  2289. // 如果当前正在查看该申请的详情,更新详情中的状态
  2290. if (applicationDetailOpen.value && applicationDetail.applicationId === row.applicationId) {
  2291. applicationDetail.status = status;
  2292. if (status === '1' || status === '2') {
  2293. applicationDetail.approvalTime = new Date().toISOString();
  2294. }
  2295. }
  2296. })
  2297. .catch((error) => {
  2298. // 如果是用户取消操作,不显示错误提示
  2299. if (error === 'cancel' || error === 'close' || error.message === 'cancel') {
  2300. return;
  2301. }
  2302. console.error('更新申请状态失败:', error);
  2303. proxy?.$modal.msgError(`${text}申请失败: ${error.message || '未知错误'}`);
  2304. });
  2305. }
  2306. /** 上传申请培训证书 */
  2307. function handleUploadApplicationCertificate(row: any) {
  2308. certificateUploadData.recordId = row.applicationId;
  2309. certificateUploadData.isApplication = true;
  2310. certificateFileList.value = [];
  2311. certificateDialogVisible.value = true;
  2312. }
  2313. /** 查看申请培训证书 */
  2314. function viewApplicationCertificate(row: any) {
  2315. if (row.certificatePath) {
  2316. window.open(row.certificatePath);
  2317. } else {
  2318. proxy?.$modal.msgWarning('该培训申请暂无证书');
  2319. }
  2320. }
  2321. /** 保存管理员备注 */
  2322. function saveAdminRemark() {
  2323. proxy?.$modal.msgSuccess('保存备注功能开发中');
  2324. // 实际应该调用更新申请的API
  2325. applicationDetailOpen.value = false;
  2326. }
  2327. /** 获取审批级别标签 */
  2328. function getApprovalLevelLabel(level: number): string {
  2329. const levels = [
  2330. { value: 1, label: '部门主管' },
  2331. { value: 2, label: '分管领导' },
  2332. { value: 3, label: '校领导' }
  2333. ];
  2334. const levelObj = levels.find((item) => item.value === level);
  2335. return levelObj ? levelObj.label : '未知';
  2336. }
  2337. /** 培训课程搜索按钮操作 */
  2338. function handleTrainingQuery() {
  2339. trainingQueryParams.pageNum = 1;
  2340. getTrainingList();
  2341. }
  2342. /** 重置培训课程查询条件 */
  2343. function resetTrainingQuery() {
  2344. trainingQueryParams.title = '';
  2345. trainingQueryParams.category = '';
  2346. trainingQueryParams.status = '';
  2347. handleTrainingQuery();
  2348. }
  2349. /** 培训课程多选框选中数据 */
  2350. function handleTrainingSelectionChange(selection: CourseVO[]) {
  2351. trainingIds.value = selection.map((item) => item.courseId);
  2352. trainingSingle.value = selection.length !== 1;
  2353. trainingMultiple.value = !selection.length;
  2354. }
  2355. // 培训记录多选框选中数据
  2356. function handleRecordSelectionChange(selection: RecordVO[]) {
  2357. recordIds.value = selection.map((item) => item.recordId);
  2358. recordSingle.value = selection.length !== 1;
  2359. recordMultiple.value = !selection.length;
  2360. }
  2361. /** 培训子选项卡切换 */
  2362. function handleTrainingSubTabClick() {
  2363. if (trainingSubTab.value === 'application') {
  2364. getApplicationList();
  2365. // 确保教师列表已加载(用于同行人显示)
  2366. if (teacherList.value.length === 0) {
  2367. loadTeacherListForDisplay();
  2368. }
  2369. } else if (trainingSubTab.value === 'record') {
  2370. getRecordList();
  2371. // 确保教师列表已加载(用于同行人显示)
  2372. if (teacherList.value.length === 0) {
  2373. loadTeacherListForDisplay();
  2374. }
  2375. } else {
  2376. getTrainingList();
  2377. }
  2378. }
  2379. // 加载课程选项 - 已废弃 (2025-01-03)
  2380. function loadCourseOptions() {
  2381. // 培训课程模块已废弃,现在课程信息通过申请时的自定义课程名称管理
  2382. console.warn('培训课程选项已废弃,现在使用自定义课程名称');
  2383. courseOptions.value = [];
  2384. return Promise.resolve([]);
  2385. }
  2386. // 远程搜索用户
  2387. function remoteSearchUser(query: string) {
  2388. if (query) {
  2389. proxy?.$modal.loading('正在搜索...');
  2390. // 实际使用时应该调用后端搜索接口
  2391. // searchUsers({ username: query }).then(response => {
  2392. // userOptions.value = response.data;
  2393. // proxy?.$modal.closeLoading();
  2394. // });
  2395. // 模拟数据
  2396. setTimeout(() => {
  2397. userOptions.value = [
  2398. { userId: 1, nickName: '张三' },
  2399. { userId: 2, nickName: '李四' },
  2400. { userId: 3, nickName: '王五' },
  2401. { userId: 4, nickName: '赵六' }
  2402. ].filter((item) => item.nickName.includes(query));
  2403. proxy?.$modal.closeLoading();
  2404. }, 500);
  2405. } else {
  2406. userOptions.value = [];
  2407. }
  2408. }
  2409. /** 获取培训记录列表 */
  2410. function getRecordList() {
  2411. recordLoading.value = true;
  2412. // 构建查询参数,包含已通过审批的申请数据
  2413. const queryParams = {
  2414. ...recordQueryParams,
  2415. userId: userStore.userId, // 设置当前用户ID
  2416. // 确保包含已通过状态的培训申请数据
  2417. includeApprovedApplications: true
  2418. };
  2419. // 调用培训记录接口,获取培训记录数据
  2420. listTrainingRecord(queryParams)
  2421. .then((response) => {
  2422. recordList.value = response.rows;
  2423. recordTotal.value = response.total;
  2424. recordLoading.value = false;
  2425. // 确保教师列表已加载(用于同行人显示)
  2426. if (teacherList.value.length === 0) {
  2427. loadTeacherListForDisplay();
  2428. }
  2429. })
  2430. .catch(() => {
  2431. recordLoading.value = false;
  2432. });
  2433. }
  2434. /** 新增培训记录 */
  2435. function handleAddRecord() {
  2436. resetRecordForm();
  2437. recordDialogVisible.value = true;
  2438. recordDialogTitle.value = '添加培训记录';
  2439. // 加载课程选项
  2440. if (!courseOptions.value || courseOptions.value.length === 0) {
  2441. loadCourseOptions();
  2442. }
  2443. }
  2444. /** 重置培训记录表单 */
  2445. function resetRecordForm() {
  2446. console.log('resetRecordForm 开始执行');
  2447. recordForm.recordId = undefined;
  2448. recordForm.courseId = '';
  2449. recordForm.userId = '';
  2450. recordForm.completionStatus = '1';
  2451. recordForm.score = '';
  2452. recordForm.completionTime = '';
  2453. recordForm.certificatePath = '';
  2454. recordForm.certificateNumber = '';
  2455. recordForm.certificateFileName = '';
  2456. recordForm.attachmentIds = '';
  2457. recordForm.feedback = '';
  2458. recordForm.remark = '';
  2459. console.log('开始重置附件列表,当前 recordCertificateFileList.value:', recordCertificateFileList.value);
  2460. if (recordCertificateFileList.value) {
  2461. recordCertificateFileList.value = [];
  2462. } else {
  2463. console.warn('recordCertificateFileList.value 是 undefined,创建新数组');
  2464. recordCertificateFileList.value = [];
  2465. }
  2466. console.log('开始重置表单字段');
  2467. recordFormRef.value?.resetFields();
  2468. console.log('resetRecordForm 执行完成');
  2469. }
  2470. /** 取消培训记录对话框 */
  2471. function cancelRecordDialog() {
  2472. recordDialogVisible.value = false;
  2473. resetRecordForm();
  2474. }
  2475. /** 提交培训记录表单 */
  2476. function submitRecordForm() {
  2477. recordFormRef.value?.validate((valid: boolean) => {
  2478. if (valid) {
  2479. recordDialogLoading.value = true;
  2480. console.log('=== 提交表单数据 ===');
  2481. console.log('recordForm:', recordForm);
  2482. console.log('证书路径:', recordForm.certificatePath);
  2483. console.log('证书文件名:', recordForm.certificateFileName);
  2484. // 在提交前确保attachmentIds字段是最新的
  2485. updateRecordFormAttachmentIds();
  2486. console.log('提交前的attachmentIds:', recordForm.attachmentIds);
  2487. if (recordForm.recordId) {
  2488. // 修改记录时,保存证书信息到本地存储
  2489. if (recordForm.certificatePath) {
  2490. const certificateData = {
  2491. recordId: recordForm.recordId,
  2492. certificatePath: recordForm.certificatePath,
  2493. certificateFileName: recordForm.certificateFileName,
  2494. updateTime: new Date().toISOString()
  2495. };
  2496. // 保存到本地存储
  2497. const existingData = JSON.parse(localStorage.getItem('training_certificates') || '{}');
  2498. existingData[recordForm.recordId] = certificateData;
  2499. localStorage.setItem('training_certificates', JSON.stringify(existingData));
  2500. console.log('证书数据已保存到本地存储:', certificateData);
  2501. }
  2502. updateTrainingRecord(recordForm)
  2503. .then(() => {
  2504. proxy?.$modal.msgSuccess('修改成功');
  2505. recordDialogVisible.value = false;
  2506. getRecordList();
  2507. })
  2508. .catch((error) => {
  2509. console.log('API调用失败,使用模拟更新:', error);
  2510. // 模拟更新成功
  2511. setTimeout(() => {
  2512. proxy?.$modal.msgSuccess('修改成功');
  2513. recordDialogVisible.value = false;
  2514. getRecordList();
  2515. }, 500);
  2516. })
  2517. .finally(() => {
  2518. recordDialogLoading.value = false;
  2519. });
  2520. } else {
  2521. addTrainingRecord(recordForm)
  2522. .then(() => {
  2523. proxy?.$modal.msgSuccess('新增成功');
  2524. recordDialogVisible.value = false;
  2525. getRecordList();
  2526. })
  2527. .catch((error) => {
  2528. console.log('API调用失败,使用模拟新增:', error);
  2529. // 模拟新增成功
  2530. setTimeout(() => {
  2531. proxy?.$modal.msgSuccess('新增成功');
  2532. recordDialogVisible.value = false;
  2533. getRecordList();
  2534. }, 500);
  2535. })
  2536. .finally(() => {
  2537. recordDialogLoading.value = false;
  2538. });
  2539. }
  2540. }
  2541. });
  2542. }
  2543. /** 修改培训记录 */
  2544. async function handleUpdateRecord(row: RecordVO) {
  2545. console.log('=== 修改培训记录开始 ===');
  2546. console.log('row数据:', row);
  2547. try {
  2548. // 立即显示对话框,避免用户等待
  2549. recordDialogVisible.value = true;
  2550. recordDialogTitle.value = '修改培训记录';
  2551. // 重置表单
  2552. try {
  2553. console.log('开始重置表单...');
  2554. resetRecordForm();
  2555. console.log('表单重置完成');
  2556. } catch (error) {
  2557. console.error('重置表单时出错:', error);
  2558. throw error;
  2559. }
  2560. // 先设置基础数据,确保对话框内容可见
  2561. try {
  2562. console.log('开始设置基础数据...');
  2563. Object.assign(recordForm, {
  2564. recordId: row.recordId,
  2565. courseId: row.courseId,
  2566. courseName: row.courseName,
  2567. userId: row.userId,
  2568. userName: row.userName,
  2569. completionStatus: row.completionStatus || '0',
  2570. score: row.score || '',
  2571. duration: row.duration || '',
  2572. completionTime: row.completionTime || '',
  2573. certificatePath: row.certificatePath || '',
  2574. certificateNumber: row.certificateNumber || '',
  2575. certificateFileName: row.certificateFileName || '',
  2576. attachmentIds: (row as any).attachmentIds || '',
  2577. feedback: row.feedback || '',
  2578. remark: row.remark || ''
  2579. });
  2580. console.log('基础数据设置完成,attachmentIds:', recordForm.attachmentIds);
  2581. } catch (error) {
  2582. console.error('设置基础数据时出错:', error);
  2583. throw error;
  2584. }
  2585. console.log('设置基础数据后的recordForm:', recordForm);
  2586. console.log('当前courseOptions.value:', courseOptions.value);
  2587. // 异步加载课程选项(如果还没有加载)
  2588. try {
  2589. console.log('开始处理课程选项,当前courseOptions:', courseOptions.value);
  2590. if (!courseOptions.value || courseOptions.value.length === 0) {
  2591. console.log('需要加载课程选项');
  2592. loadCourseOptions()
  2593. .then(() => {
  2594. console.log('课程选项加载完成,开始匹配课程名称');
  2595. // 确保课程名称正确显示
  2596. if (!recordForm.courseName && recordForm.courseId && courseOptions.value) {
  2597. const course = courseOptions.value.find((c) => c.courseId === recordForm.courseId);
  2598. if (course) {
  2599. recordForm.courseName = course.title;
  2600. }
  2601. }
  2602. })
  2603. .catch((error) => {
  2604. console.warn('加载课程选项失败:', error);
  2605. });
  2606. } else {
  2607. console.log('使用现有课程选项');
  2608. // 确保课程名称正确显示
  2609. if (!recordForm.courseName && recordForm.courseId && courseOptions.value) {
  2610. const course = courseOptions.value.find((c) => c.courseId === recordForm.courseId);
  2611. if (course) {
  2612. recordForm.courseName = course.title;
  2613. }
  2614. }
  2615. }
  2616. console.log('课程选项处理完成');
  2617. } catch (error) {
  2618. console.error('处理课程选项时出错:', error);
  2619. throw error;
  2620. }
  2621. // 异步获取详细数据(可选)
  2622. try {
  2623. const response = await getTrainingRecord(row.recordId);
  2624. if (response.data) {
  2625. // 合并API返回的数据,保留已设置的基础数据
  2626. Object.assign(recordForm, response.data);
  2627. console.log('API返回的详细数据:', response.data);
  2628. }
  2629. } catch (error) {
  2630. console.log('获取详细数据失败,使用基础数据:', error);
  2631. // 使用基础数据继续,不影响对话框显示
  2632. }
  2633. // 异步处理证书附件数据
  2634. handleRecordAttachmentData().catch((error) => {
  2635. console.warn('处理附件数据失败:', error);
  2636. // 不影响对话框显示
  2637. });
  2638. console.log('=== 修改培训记录完成 ===');
  2639. } catch (error) {
  2640. console.error('修改培训记录过程中发生错误:', error);
  2641. // 即使出错也要显示对话框,让用户看到基础数据
  2642. proxy?.$modal.msgError('加载培训记录数据时发生错误,请重试');
  2643. }
  2644. }
  2645. /** 查看培训记录详情 */
  2646. async function handleViewRecord(row: RecordVO) {
  2647. try {
  2648. // 确保教师列表已加载(用于显示同行人姓名)
  2649. if (teacherList.value.length === 0) {
  2650. await loadTeacherListForDisplay();
  2651. }
  2652. // 首先复制记录的基本信息
  2653. Object.assign(recordDetail, row);
  2654. // 如果行数据中没有完整的课程名称,尝试从课程选项获取
  2655. if (!row.courseName && row.courseId) {
  2656. const course = courseOptions.value.find((c) => c.courseId === row.courseId);
  2657. if (course) {
  2658. recordDetail.courseName = course.title;
  2659. }
  2660. }
  2661. // 如果有申请ID,获取完整的申请详情来补充缺失的字段
  2662. if (row.applicationId) {
  2663. try {
  2664. const applicationResponse = await getTrainingApplication(row.applicationId);
  2665. const applicationData = applicationResponse.data;
  2666. // 合并申请数据中的详细信息到记录详情
  2667. Object.assign(recordDetail, {
  2668. // 保留记录的核心信息
  2669. recordId: row.recordId,
  2670. completionStatus: row.completionStatus,
  2671. completionTime: row.completionTime,
  2672. certificatePath: row.certificatePath,
  2673. certificateNumber: row.certificateNumber,
  2674. feedback: row.feedback,
  2675. // 从申请数据中获取详细信息
  2676. department: applicationData.department || row.department,
  2677. currentTitle: applicationData.currentTitle,
  2678. currentPosition: applicationData.currentPosition,
  2679. workStartTime: applicationData.workStartTime,
  2680. phone: applicationData.phone,
  2681. organizerUnit: applicationData.organizerUnit,
  2682. trainingType: applicationData.trainingType,
  2683. trainingFee: applicationData.trainingFee,
  2684. companions: applicationData.companions,
  2685. trainingPurpose: applicationData.trainingPurpose || applicationData.reason,
  2686. location: applicationData.location || row.location,
  2687. startTime: applicationData.startTime,
  2688. endTime: applicationData.endTime,
  2689. applyTime: applicationData.applyTime,
  2690. // 其他基本信息
  2691. courseName: applicationData.courseName || recordDetail.courseName,
  2692. userName: applicationData.userName || row.userName,
  2693. duration: applicationData.duration || row.duration,
  2694. remark: row.remark
  2695. });
  2696. // 加载申请附件数据
  2697. if (applicationData.attachmentIds) {
  2698. await handleApplicationDetailAttachmentData(applicationData.attachmentIds);
  2699. recordDetailAttachmentList.value = [...applicationDetailAttachmentList.value];
  2700. }
  2701. } catch (error) {
  2702. console.warn('获取申请详情失败,使用记录基本信息:', error);
  2703. // 如果获取申请详情失败,继续使用记录的基本信息
  2704. }
  2705. }
  2706. recordDetailDialogVisible.value = true;
  2707. } catch (error) {
  2708. console.error('查看培训记录详情失败:', error);
  2709. proxy?.$modal.msgError('获取培训记录详情失败,请重试');
  2710. }
  2711. }
  2712. /** 删除培训记录 */
  2713. function handleDeleteRecord(row?: RecordVO) {
  2714. const ids = row?.recordId || recordIds.value;
  2715. if (!ids || (Array.isArray(ids) && ids.length === 0)) {
  2716. return;
  2717. }
  2718. let confirmMessage = '';
  2719. if (row) {
  2720. confirmMessage = `是否确认删除学员"${row.userName}"的培训记录?`;
  2721. } else {
  2722. const selectedItems = recordList.value.filter((item) => recordIds.value.includes(item.applicationId as number | string));
  2723. if (selectedItems.length === 1) {
  2724. confirmMessage = `是否确认删除学员"${selectedItems[0].userName}"的培训记录?`;
  2725. } else {
  2726. const names = selectedItems.map((item) => item.userName).join('、');
  2727. confirmMessage = `是否确认删除学员"${names}"的培训记录?`;
  2728. }
  2729. }
  2730. proxy?.$modal
  2731. .confirm(confirmMessage)
  2732. .then(() => {
  2733. return delTrainingRecord(ids);
  2734. })
  2735. .then(() => {
  2736. getRecordList();
  2737. proxy?.$modal.msgSuccess('删除成功');
  2738. })
  2739. .catch((error) => {
  2740. // 如果是用户取消操作,不显示错误提示
  2741. if (error === 'cancel' || error === 'close' || error.message === 'cancel') {
  2742. return;
  2743. }
  2744. // 模拟删除成功,实际应使用API
  2745. setTimeout(() => {
  2746. getRecordList();
  2747. proxy?.$modal.msgSuccess('删除成功');
  2748. }, 300);
  2749. });
  2750. }
  2751. /** 证书上传前检查 */
  2752. function beforeCertificateUpload(file: File) {
  2753. const isValidType = ['application/pdf', 'image/jpeg', 'image/png'].includes(file.type);
  2754. const isLt10M = file.size / 1024 / 1024 < 10;
  2755. if (!isValidType) {
  2756. proxy?.$modal.msgError('上传证书文件只能是PDF/JPG/PNG格式!');
  2757. return false;
  2758. }
  2759. if (!isLt10M) {
  2760. proxy?.$modal.msgError('上传证书文件大小不能超过10MB!');
  2761. return false;
  2762. }
  2763. return true;
  2764. }
  2765. /** 证书上传成功处理 */
  2766. function handleCertificateSuccess(response: any) {
  2767. certificateDialogVisible.value = false;
  2768. if (certificateUploadData.isApplication) {
  2769. // 更新申请列表
  2770. getApplicationList();
  2771. // 如果当前正在查看该申请的详情,更新详情中的证书路径
  2772. if (applicationDetailOpen.value && applicationDetail.applicationId === certificateUploadData.recordId) {
  2773. if (response && response.data) {
  2774. applicationDetail.certificatePath = response.data.path || response.data.url;
  2775. }
  2776. }
  2777. proxy?.$modal.msgSuccess('申请培训证书上传成功!');
  2778. } else {
  2779. // 更新记录列表
  2780. getRecordList();
  2781. proxy?.$modal.msgSuccess('培训记录证书上传成功!');
  2782. }
  2783. // 重置标记
  2784. certificateUploadData.isApplication = false;
  2785. // 清空文件列表
  2786. certificateFileList.value = [];
  2787. }
  2788. /** 证书上传失败处理 */
  2789. function handleCertificateError(error: any) {
  2790. console.error('证书上传失败:', error);
  2791. let errorMessage = '证书上传失败,请重试!';
  2792. // 尝试从错误响应中获取具体错误信息
  2793. if (error && error.response && error.response.data) {
  2794. if (error.response.data.msg) {
  2795. errorMessage = error.response.data.msg;
  2796. } else if (error.response.data.message) {
  2797. errorMessage = error.response.data.message;
  2798. }
  2799. }
  2800. proxy?.$modal.msgError(errorMessage);
  2801. }
  2802. /** 查看证书 */
  2803. function viewCertificate(row: RecordVO) {
  2804. if (row.certificatePath) {
  2805. const ossId = extractOssIdFromPath(row.certificatePath);
  2806. if (ossId) {
  2807. // 如果有OSS ID,使用下载路径打开
  2808. const downloadUrl = `/dev-api/resource/oss/download/${ossId}`;
  2809. window.open(downloadUrl, '_blank');
  2810. } else {
  2811. // 后备方案:直接使用证书路径
  2812. window.open(row.certificatePath, '_blank');
  2813. }
  2814. } else {
  2815. proxy?.$modal.msgWarning('该培训记录暂无证书');
  2816. }
  2817. }
  2818. /** 培训记录修改对话框中的证书上传前检查 */
  2819. function beforeRecordCertificateUpload(file: File) {
  2820. const isValidType = ['application/pdf', 'image/jpeg', 'image/png'].includes(file.type);
  2821. const isLt10M = file.size / 1024 / 1024 < 10;
  2822. if (!isValidType) {
  2823. proxy?.$modal.msgError('上传证书文件只能是PDF/JPG/PNG格式!');
  2824. return false;
  2825. }
  2826. if (!isLt10M) {
  2827. proxy?.$modal.msgError('上传证书文件大小不能超过10MB!');
  2828. return false;
  2829. }
  2830. return true;
  2831. }
  2832. /** 培训记录修改对话框中的证书上传成功处理 */
  2833. function handleRecordCertificateSuccess(response: any, file: any) {
  2834. if (response.code === 200 && response.data) {
  2835. file.url = response.data.url;
  2836. file.ossId = response.data.ossId;
  2837. proxy?.$modal.msgSuccess('证书上传成功!');
  2838. console.log('证书上传成功:', response.data);
  2839. // 更新文件状态为成功
  2840. file.status = 'success';
  2841. file.response = response;
  2842. // 自动保存附件ID到后端
  2843. saveRecordAttachments();
  2844. // 同时更新recordForm中的attachmentIds字段,确保提交时包含附件信息
  2845. updateRecordFormAttachmentIds();
  2846. }
  2847. }
  2848. /** 培训记录修改对话框中的证书上传失败处理 */
  2849. function handleRecordCertificateError(error: any) {
  2850. console.error('证书上传失败:', error);
  2851. let errorMessage = '证书上传失败,请重试!';
  2852. // 尝试从错误响应中获取具体错误信息
  2853. if (error && error.response && error.response.data) {
  2854. if (error.response.data.msg) {
  2855. errorMessage = error.response.data.msg;
  2856. } else if (error.response.data.message) {
  2857. errorMessage = error.response.data.message;
  2858. }
  2859. }
  2860. proxy?.$modal.msgError(errorMessage);
  2861. }
  2862. /** 保存培训记录附件ID到后端 */
  2863. async function saveRecordAttachments() {
  2864. if (!recordForm.recordId) {
  2865. console.warn('记录ID为空,无法保存附件');
  2866. return;
  2867. }
  2868. try {
  2869. // 提取所有成功上传的ossId
  2870. const attachmentOssIds = recordCertificateFileList.value.filter((file) => file.status === 'success' && file.ossId).map((file) => file.ossId);
  2871. // 转换为逗号分隔的字符串
  2872. const attachmentIds = attachmentOssIds.join(',');
  2873. console.log('保存附件ID:', attachmentIds);
  2874. // 调用后端接口保存附件ID
  2875. await updateRecordAttachments(recordForm.recordId, { attachmentIds });
  2876. console.log('附件ID保存成功');
  2877. } catch (error) {
  2878. console.error('保存附件ID失败:', error);
  2879. proxy?.$modal.msgError('保存附件失败,请重试');
  2880. }
  2881. }
  2882. /** 更新recordForm中的attachmentIds字段 */
  2883. function updateRecordFormAttachmentIds() {
  2884. if (!recordForm.recordId) {
  2885. console.warn('记录ID为空,无法更新附件ID');
  2886. return;
  2887. }
  2888. // 提取所有成功上传的ossId
  2889. const attachmentOssIds = recordCertificateFileList.value.filter((file) => file.status === 'success' && file.ossId).map((file) => file.ossId);
  2890. // 转换为逗号分隔的字符串并更新recordForm
  2891. const attachmentIds = attachmentOssIds.join(',');
  2892. recordForm.attachmentIds = attachmentIds;
  2893. console.log('更新recordForm.attachmentIds:', attachmentIds);
  2894. }
  2895. /** 处理培训记录附件数据 */
  2896. async function handleRecordAttachmentData() {
  2897. try {
  2898. if (!recordForm.attachmentIds || !recordForm.attachmentIds.toString().trim()) {
  2899. console.log('没有附件数据,清空附件列表');
  2900. recordCertificateFileList.value = [];
  2901. return;
  2902. }
  2903. console.log('开始处理附件数据:', recordForm.attachmentIds);
  2904. const ossIdsArray = recordForm.attachmentIds
  2905. .toString()
  2906. .split(',')
  2907. .map((id) => id.trim())
  2908. .filter((id) => id);
  2909. if (ossIdsArray.length === 0) {
  2910. recordCertificateFileList.value = [];
  2911. return;
  2912. }
  2913. const response = await request({
  2914. url: `/resource/oss/listByIds/${ossIdsArray.join(',')}`,
  2915. method: 'get'
  2916. });
  2917. if (response.code === 200 && response.data) {
  2918. console.log('获取到的附件信息:', response.data);
  2919. const attachmentFiles = response.data.map((item: any, index: number) => ({
  2920. uid: `existing_${index}_${Date.now()}`,
  2921. name: item.originalName || `证书${index + 1}`,
  2922. url: item.url,
  2923. ossId: item.ossId,
  2924. status: 'success',
  2925. fileSize: item.fileSize || 0,
  2926. response: {
  2927. code: 200,
  2928. data: {
  2929. url: item.url,
  2930. ossId: item.ossId
  2931. }
  2932. }
  2933. }));
  2934. recordCertificateFileList.value = attachmentFiles;
  2935. console.log('设置附件列表成功:', recordCertificateFileList.value);
  2936. } else {
  2937. console.warn('获取附件信息失败:', response.msg);
  2938. recordCertificateFileList.value = [];
  2939. }
  2940. } catch (error) {
  2941. console.error('处理附件数据失败:', error);
  2942. recordCertificateFileList.value = [];
  2943. }
  2944. }
  2945. /** 从文件路径中提取文件名 */
  2946. function getFileNameFromPath(filePath: string): string {
  2947. if (!filePath) return '未知文件';
  2948. const pathParts = filePath.split('/');
  2949. const fileName = pathParts[pathParts.length - 1];
  2950. // 移除时间戳前缀(如果有的话)
  2951. return fileName.replace(/^\d+_/, '') || '证书文件';
  2952. }
  2953. /** 查看当前证书 */
  2954. function viewCurrentCertificate() {
  2955. if (recordForm.certificatePath) {
  2956. window.open(recordForm.certificatePath);
  2957. } else {
  2958. proxy?.$modal.msgWarning('当前记录暂无证书');
  2959. }
  2960. }
  2961. /** 预览证书文件 */
  2962. function handlePreviewCertificate(file: any) {
  2963. console.log('预览证书文件:', file);
  2964. console.log('file.url:', file.url);
  2965. console.log('file.ossId:', file.ossId);
  2966. if (!file) {
  2967. proxy?.$modal.msgError('文件不存在');
  2968. return;
  2969. }
  2970. // 如果是图片,使用图片预览
  2971. if (isImageFile(file)) {
  2972. let imageUrl = '';
  2973. // 优先使用 file.url(已上传的文件)
  2974. if (file.url) {
  2975. imageUrl = file.url;
  2976. }
  2977. // 如果是新上传的文件,使用预览URL
  2978. else if (file.raw) {
  2979. imageUrl = URL.createObjectURL(file.raw);
  2980. }
  2981. if (imageUrl) {
  2982. console.log('预览图片URL:', imageUrl);
  2983. // 创建图片预览弹窗
  2984. const img = new Image();
  2985. img.onload = function () {
  2986. const newWindow = window.open('', '_blank');
  2987. if (newWindow) {
  2988. newWindow.document.write(`
  2989. <!DOCTYPE html>
  2990. <html>
  2991. <head>
  2992. <title>图片预览 - ${file.name}</title>
  2993. <style>
  2994. body {
  2995. margin: 0;
  2996. padding: 20px;
  2997. background: #f5f5f5;
  2998. display: flex;
  2999. justify-content: center;
  3000. align-items: center;
  3001. min-height: 100vh;
  3002. }
  3003. img {
  3004. max-width: 90%;
  3005. max-height: 90%;
  3006. border: 1px solid #ddd;
  3007. border-radius: 4px;
  3008. box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  3009. }
  3010. </style>
  3011. </head>
  3012. <body>
  3013. <img src="${imageUrl}" alt="${file.name}" />
  3014. </body>
  3015. </html>
  3016. `);
  3017. newWindow.document.close();
  3018. }
  3019. };
  3020. img.onerror = function () {
  3021. proxy?.$modal.msgError('图片加载失败,可能需要登录权限');
  3022. // 如果图片加载失败,尝试使用OSS下载地址
  3023. const ossId = getFileOssId(file);
  3024. if (ossId) {
  3025. const downloadUrl = `/dev-api/resource/oss/download/${ossId}`;
  3026. window.open(downloadUrl, '_blank');
  3027. }
  3028. };
  3029. img.src = imageUrl;
  3030. } else {
  3031. proxy?.$modal.msgError('无法获取图片预览');
  3032. }
  3033. } else {
  3034. // 非图片文件,尝试在新窗口打开
  3035. const ossId = getFileOssId(file);
  3036. if (ossId) {
  3037. // 如果有OSS ID,使用下载地址
  3038. const downloadUrl = `/dev-api/resource/oss/download/${ossId}`;
  3039. window.open(downloadUrl, '_blank');
  3040. } else if (file.url) {
  3041. window.open(file.url, '_blank');
  3042. } else {
  3043. proxy?.$modal.msgError('无法预览此类型文件');
  3044. }
  3045. }
  3046. }
  3047. /** 判断是否为图片文件 */
  3048. function isImageFile(file: any): boolean {
  3049. const imageTypes = ['image/jpeg', 'image/png', 'image/gif', 'image/bmp', 'image/webp'];
  3050. return imageTypes.includes(file.raw?.type) || (file.url && /\.(jpg|jpeg|png|gif|bmp|webp)$/i.test(file.name));
  3051. }
  3052. /** 获取文件扩展名 */
  3053. function getFileExt(fileName: string): string {
  3054. const ext = fileName.split('.').pop()?.toUpperCase();
  3055. return ext || 'FILE';
  3056. }
  3057. /** 格式化文件名(长文件名显示省略号) */
  3058. function formatFileName(fileName: string): string {
  3059. if (!fileName) return '';
  3060. if (fileName.length <= 20) return fileName;
  3061. return fileName.substring(0, 10) + '...' + fileName.substring(fileName.length - 10);
  3062. }
  3063. /** 获取缩写的文件名(保留后缀) */
  3064. function getShortFileName(fileName: string): string {
  3065. if (!fileName) return '';
  3066. const lastDotIndex = fileName.lastIndexOf('.');
  3067. if (lastDotIndex === -1) {
  3068. return fileName.length > 12 ? fileName.substring(0, 12) + '...' : fileName;
  3069. }
  3070. const name = fileName.substring(0, lastDotIndex);
  3071. const ext = fileName.substring(lastDotIndex);
  3072. if (name.length <= 8) {
  3073. return fileName;
  3074. }
  3075. return name.substring(0, 8) + '...' + ext;
  3076. }
  3077. /** 从文件路径中提取OSS ID */
  3078. function extractOssIdFromPath(filePath: string): string {
  3079. if (!filePath) return '';
  3080. // 如果是下载路径 /resource/oss/download/{ossId},提取ossId
  3081. const downloadMatch = filePath.match(/\/resource\/oss\/download\/([^/?]+)/);
  3082. if (downloadMatch) {
  3083. return downloadMatch[1];
  3084. }
  3085. // 如果路径中包含ossId参数
  3086. const ossIdMatch = filePath.match(/[?&]ossId=([^&]+)/);
  3087. if (ossIdMatch) {
  3088. return ossIdMatch[1];
  3089. }
  3090. // 如果是直接的ossId(通常是数字)
  3091. if (/^\d+$/.test(filePath)) {
  3092. return filePath;
  3093. }
  3094. return '';
  3095. }
  3096. /** 获取证书路径(支持两种存储方式:certificatePath 和 attachmentIds) */
  3097. function getCertificatePath(record: any): string {
  3098. // 优先使用 attachmentIds(新方式,存储OSS ID)
  3099. if (record.attachmentIds && record.attachmentIds.toString().trim()) {
  3100. const ossIds = record.attachmentIds.toString().split(',');
  3101. if (ossIds.length > 0 && ossIds[0].trim()) {
  3102. return ossIds[0].trim(); // 返回第一个OSS ID
  3103. }
  3104. }
  3105. // 后备方案:使用 certificatePath(旧方式,存储文件路径)
  3106. return record.certificatePath || '';
  3107. }
  3108. /** 判断证书是否为图片格式 */
  3109. function isCertificateImage(filePath: string): boolean {
  3110. if (!filePath) return false;
  3111. const imageExtensions = ['.jpg', '.jpeg', '.png', '.gif', '.bmp', '.webp'];
  3112. const lowerPath = filePath.toLowerCase();
  3113. return imageExtensions.some((ext) => lowerPath.includes(ext));
  3114. }
  3115. /** 获取证书预览URL */
  3116. function getCertificatePreviewUrl(filePath: string): string {
  3117. if (!filePath) return '';
  3118. // 如果是纯数字,认为是OSS ID - 但这里不直接返回URL,需要异步获取
  3119. if (/^\d+$/.test(filePath.trim())) {
  3120. // 对于OSS ID,我们需要通过API获取临时URL
  3121. // 这里返回一个占位符,实际预览通过异步方式处理
  3122. return '';
  3123. }
  3124. const ossId = extractOssIdFromPath(filePath);
  3125. if (ossId) {
  3126. // 如果从路径中提取到OSS ID,使用下载路径
  3127. return `/dev-api/resource/oss/download/${ossId}`;
  3128. }
  3129. // 如果是相对路径,添加API前缀
  3130. if (filePath.startsWith('/')) {
  3131. return `/dev-api${filePath}`;
  3132. }
  3133. // 如果是完整的HTTP URL,直接使用
  3134. if (filePath.startsWith('http://') || filePath.startsWith('https://')) {
  3135. return filePath;
  3136. }
  3137. // 后备方案:假设是相对路径,添加API前缀
  3138. return `/dev-api/${filePath}`;
  3139. }
  3140. /** 异步获取证书预览URL(用于OSS资源)*/
  3141. async function getSecureCertificatePreviewUrl(filePath: string): Promise<string> {
  3142. if (!filePath) return '';
  3143. // 如果是纯数字,认为是OSS ID,需要通过API获取临时预览URL
  3144. if (/^\d+$/.test(filePath.trim())) {
  3145. try {
  3146. const response = await getFilePreviewUrl(filePath.trim());
  3147. // API返回的URL在msg字段中,而不是data字段
  3148. return response.msg || response.data || '';
  3149. } catch (error) {
  3150. console.error('获取OSS文件预览URL失败:', error);
  3151. return '';
  3152. }
  3153. }
  3154. // 其他情况使用同步方法
  3155. return getCertificatePreviewUrl(filePath);
  3156. }
  3157. /** 获取证书文件名 */
  3158. function getCertificateFileName(filePath: string): string {
  3159. if (!filePath) return '未知文件';
  3160. // 从路径中提取文件名
  3161. const fileName = filePath.split('/').pop() || filePath;
  3162. // 如果文件名太长,进行截断
  3163. if (fileName.length > 30) {
  3164. const lastDotIndex = fileName.lastIndexOf('.');
  3165. if (lastDotIndex !== -1) {
  3166. const name = fileName.substring(0, lastDotIndex);
  3167. const ext = fileName.substring(lastDotIndex);
  3168. return name.substring(0, 20) + '...' + ext;
  3169. }
  3170. return fileName.substring(0, 25) + '...';
  3171. }
  3172. return fileName;
  3173. }
  3174. /** 下载证书 */
  3175. function downloadCertificate(row: RecordVO) {
  3176. if (!row.certificatePath) {
  3177. proxy?.$modal.msgWarning('该培训记录暂无证书');
  3178. return;
  3179. }
  3180. const ossId = extractOssIdFromPath(row.certificatePath);
  3181. if (ossId) {
  3182. // 如果有OSS ID,使用下载路径
  3183. const downloadUrl = `/dev-api/resource/oss/download/${ossId}`;
  3184. const link = document.createElement('a');
  3185. link.href = downloadUrl;
  3186. link.download = getCertificateFileName(row.certificatePath);
  3187. document.body.appendChild(link);
  3188. link.click();
  3189. document.body.removeChild(link);
  3190. } else {
  3191. // 使用预览URL作为下载URL
  3192. const downloadUrl = getCertificatePreviewUrl(row.certificatePath);
  3193. window.open(downloadUrl, '_blank');
  3194. }
  3195. }
  3196. /** 处理培训证书数据 - 参考宿舍卫生检查的附件处理方式 */
  3197. async function handleCertificateData() {
  3198. try {
  3199. console.log('=== 处理证书数据开始 ===');
  3200. console.log('recordForm.recordId:', recordForm.recordId);
  3201. console.log('recordForm.certificatePath:', recordForm.certificatePath);
  3202. console.log('recordForm.certificateFileName:', recordForm.certificateFileName);
  3203. // 优先从本地存储获取证书信息
  3204. if (recordForm.recordId) {
  3205. try {
  3206. const certificatesData = JSON.parse(localStorage.getItem('training_certificates') || '{}');
  3207. const storedCertificate = certificatesData[recordForm.recordId];
  3208. console.log('本地存储的证书数据:', storedCertificate);
  3209. if (storedCertificate && storedCertificate.certificatePath) {
  3210. // 使用本地存储的数据更新表单
  3211. recordForm.certificatePath = storedCertificate.certificatePath;
  3212. recordForm.certificateFileName = storedCertificate.certificateFileName;
  3213. console.log('从本地存储恢复证书信息:', {
  3214. certificatePath: recordForm.certificatePath,
  3215. certificateFileName: recordForm.certificateFileName
  3216. });
  3217. }
  3218. } catch (error) {
  3219. console.warn('读取本地存储失败:', error);
  3220. }
  3221. }
  3222. if (!recordForm.certificatePath || !recordForm.certificatePath.toString().trim()) {
  3223. console.log('没有证书数据,清空证书列表');
  3224. recordCertificateFileList.value = [];
  3225. return;
  3226. }
  3227. console.log('开始处理证书数据:', recordForm.certificatePath);
  3228. // 尝试从路径中提取OSS ID
  3229. const ossId = extractOssIdFromPath(recordForm.certificatePath);
  3230. if (ossId) {
  3231. // 如果有OSS ID,通过API获取详细信息
  3232. try {
  3233. const response = await request({
  3234. url: `/resource/oss/listByIds/${ossId}`,
  3235. method: 'get'
  3236. });
  3237. if (response.code === 200 && response.data && response.data.length > 0) {
  3238. console.log('获取到的证书信息:', response.data);
  3239. const item = response.data[0];
  3240. const certificateFile = {
  3241. uid: `existing_${Date.now()}`,
  3242. name: item.originalName || recordForm.certificateFileName || getFileNameFromPath(recordForm.certificatePath),
  3243. url: item.url || recordForm.certificatePath,
  3244. ossId: item.ossId || ossId,
  3245. status: 'success',
  3246. response: {
  3247. code: 200,
  3248. data: {
  3249. url: item.url || recordForm.certificatePath,
  3250. ossId: item.ossId || ossId
  3251. }
  3252. }
  3253. };
  3254. recordCertificateFileList.value = [certificateFile];
  3255. console.log('设置证书列表成功:', recordCertificateFileList.value);
  3256. return;
  3257. }
  3258. } catch (error) {
  3259. console.warn('通过OSS API获取证书信息失败,使用本地信息:', error);
  3260. }
  3261. }
  3262. // 如果API获取失败或没有OSS ID,使用本地信息
  3263. const fileName = recordForm.certificateFileName || getFileNameFromPath(recordForm.certificatePath);
  3264. recordCertificateFileList.value = [
  3265. {
  3266. uid: Date.now(),
  3267. name: fileName,
  3268. url: recordForm.certificatePath,
  3269. ossId: ossId,
  3270. status: 'success'
  3271. }
  3272. ];
  3273. console.log('使用本地信息设置证书列表:', recordCertificateFileList.value);
  3274. } catch (error) {
  3275. console.error('处理证书数据失败:', error);
  3276. recordCertificateFileList.value = [];
  3277. }
  3278. }
  3279. /** 获取文件的OSS ID用于ImagePreview */
  3280. function getFileOssId(file: any): string {
  3281. return file.ossId || '';
  3282. }
  3283. /** 下载证书文件 */
  3284. async function handleDownloadCertificate(file: any) {
  3285. let downloadUrl = '';
  3286. let fileName = file.name || 'certificate';
  3287. if (file.response && file.response.data && file.response.data.filePath) {
  3288. downloadUrl = file.response.data.filePath;
  3289. fileName = file.response.data.fileName || fileName;
  3290. } else if (file.ossId) {
  3291. downloadUrl = file.ossId;
  3292. } else if (file.raw) {
  3293. const link = document.createElement('a');
  3294. link.href = URL.createObjectURL(file.raw);
  3295. link.download = fileName;
  3296. link.style.display = 'none';
  3297. document.body.appendChild(link);
  3298. link.click();
  3299. document.body.removeChild(link);
  3300. URL.revokeObjectURL(link.href);
  3301. console.log('下载本地文件:', fileName);
  3302. return;
  3303. }
  3304. if (!downloadUrl) {
  3305. proxy?.$modal.msgError('无法获取文件下载地址');
  3306. return;
  3307. }
  3308. try {
  3309. const loading = ElLoading.service({
  3310. text: '正在下载文件...',
  3311. target: document.body
  3312. });
  3313. const response = await request({
  3314. url: '/resource/oss/download/' + downloadUrl,
  3315. method: 'get',
  3316. responseType: 'blob',
  3317. timeout: 300000
  3318. });
  3319. if (!response) {
  3320. throw new Error('响应数据为空');
  3321. }
  3322. let blobData: Blob;
  3323. if (response instanceof Blob) {
  3324. blobData = response;
  3325. } else if (response.data instanceof Blob) {
  3326. blobData = response.data;
  3327. } else {
  3328. throw new Error('无效的响应数据格式');
  3329. }
  3330. const url = window.URL.createObjectURL(blobData);
  3331. const link = document.createElement('a');
  3332. link.href = url;
  3333. link.download = fileName;
  3334. link.style.display = 'none';
  3335. document.body.appendChild(link);
  3336. link.click();
  3337. document.body.removeChild(link);
  3338. window.URL.revokeObjectURL(url);
  3339. loading?.close();
  3340. console.log('下载服务器文件成功:', fileName);
  3341. } catch (error) {
  3342. console.error('下载文件失败:', error);
  3343. proxy?.$modal.msgError('下载文件失败,请稍后重试');
  3344. }
  3345. }
  3346. /** 确认删除证书文件 */
  3347. function confirmRemoveCertificate(file: any) {
  3348. proxy?.$modal
  3349. .confirm('确认要删除该证书文件吗?')
  3350. .then(() => {
  3351. handleRemoveCertificate(file);
  3352. })
  3353. .catch(() => {});
  3354. }
  3355. /** 移除证书文件 */
  3356. function handleRemoveCertificate(file: any) {
  3357. // 从文件列表中移除
  3358. const index = recordCertificateFileList.value.findIndex((item) => item.uid === file.uid);
  3359. if (index > -1) {
  3360. recordCertificateFileList.value.splice(index, 1);
  3361. }
  3362. // 自动保存附件ID到后端
  3363. saveRecordAttachments();
  3364. // 同时更新recordForm中的attachmentIds字段
  3365. updateRecordFormAttachmentIds();
  3366. proxy?.$modal.msgSuccess('证书文件已删除');
  3367. }
  3368. /** 搜索培训记录 */
  3369. function handleRecordQuery() {
  3370. recordQueryParams.pageNum = 1;
  3371. getRecordList();
  3372. }
  3373. /** 重置培训记录查询参数 */
  3374. function resetRecordQuery() {
  3375. recordQueryForm.value?.resetFields();
  3376. recordQueryParams.courseName = '';
  3377. recordQueryParams.location = '';
  3378. recordQueryParams.department = '';
  3379. handleRecordQuery();
  3380. }
  3381. /** 导出培训记录 */
  3382. function handleExportRecord() {
  3383. proxy?.download(
  3384. 'rs/training/record/export',
  3385. {
  3386. ...recordQueryParams
  3387. },
  3388. `training_record_${new Date().getTime()}.xlsx`
  3389. );
  3390. }
  3391. /** 搜索培训申请 */
  3392. function handleApplicationQuery() {
  3393. applicationQueryParams.pageNum = 1;
  3394. getApplicationList();
  3395. }
  3396. /** 重置培训申请查询参数 */
  3397. function resetApplicationQuery() {
  3398. applicationQueryForm.value?.resetFields();
  3399. applicationQueryParams.courseId = undefined;
  3400. applicationQueryParams.courseName = '';
  3401. applicationQueryParams.location = '';
  3402. applicationQueryParams.duration = undefined;
  3403. applicationQueryParams.status = '';
  3404. // 保持排除已通过状态的设置
  3405. applicationQueryParams.excludeStatus = '1';
  3406. handleApplicationQuery();
  3407. }
  3408. /** 查看审批历史 */
  3409. async function handleViewHistory(row: any) {
  3410. try {
  3411. proxy?.$modal.loading('正在加载审批历史...');
  3412. const response = await getTrainingApprovalHistory(row.applicationId);
  3413. approvalHistoryList.value = response.data || [];
  3414. approvalHistoryOpen.value = true;
  3415. proxy?.$modal.closeLoading();
  3416. } catch (error) {
  3417. console.error('获取审批历史失败:', error);
  3418. proxy?.$modal.msgError('获取审批历史失败');
  3419. proxy?.$modal.closeLoading();
  3420. }
  3421. }
  3422. // 新增:强制重新初始化函数
  3423. function forceReinitialize() {
  3424. console.log('强制重新初始化组件状态');
  3425. isInitialized.value = false;
  3426. isDataLoaded.value = false;
  3427. // 重置关键状态
  3428. courseOptions.value = [];
  3429. recordList.value = [];
  3430. applicationList.value = [];
  3431. // 重新加载当前选项卡数据
  3432. if (trainingSubTab.value === 'application') {
  3433. getApplicationList();
  3434. } else if (trainingSubTab.value === 'record') {
  3435. getRecordList();
  3436. } else {
  3437. getTrainingList();
  3438. }
  3439. }
  3440. // 删除复杂的初始化函数,采用培训审批页面的简单模式
  3441. // 新增:activated生命周期钩子 - 处理Keep-Alive缓存激活
  3442. onActivated(() => {
  3443. console.log('组件被激活,重新加载当前选项卡数据');
  3444. // 直接重新加载当前选项卡的数据,不依赖复杂的状态判断
  3445. if (trainingSubTab.value === 'application') {
  3446. console.log('重新加载培训申请数据');
  3447. getApplicationList();
  3448. } else if (trainingSubTab.value === 'record') {
  3449. console.log('重新加载培训记录数据');
  3450. getRecordList();
  3451. } else {
  3452. console.log('重新加载培训课程数据');
  3453. getTrainingList();
  3454. }
  3455. // 同时加载课程选项,确保下拉选项可用
  3456. loadCourseOptions();
  3457. // 确保教师列表已加载(用于同行人显示)
  3458. if (teacherList.value.length === 0) {
  3459. loadTeacherListForDisplay();
  3460. }
  3461. });
  3462. onMounted(() => {
  3463. console.log('组件挂载,开始初始化');
  3464. // 采用培训审批页面的成功模式:同时加载所有数据
  3465. getTrainingList();
  3466. getApplicationList();
  3467. getRecordList();
  3468. loadCourseOptions();
  3469. getDepartmentList();
  3470. // 加载教师列表(用于同行人显示)
  3471. loadTeacherListForDisplay();
  3472. });
  3473. // ===== 申请培训附件上传相关方法 =====
  3474. /** 申请培训附件上传前检查 */
  3475. function beforeApplicationAttachmentUpload(file: File) {
  3476. console.log('[申请培训附件上传前检查] 开始检查');
  3477. console.log('[申请培训附件上传前检查] 文件信息:', {
  3478. name: file.name,
  3479. type: file.type,
  3480. size: `${(file.size / 1024 / 1024).toFixed(2)}MB`
  3481. });
  3482. const isValidType = [
  3483. 'application/pdf',
  3484. 'application/msword',
  3485. 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
  3486. 'application/vnd.ms-excel',
  3487. 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
  3488. 'image/jpeg',
  3489. 'image/png'
  3490. ].includes(file.type);
  3491. const isLt20M = file.size / 1024 / 1024 < 20;
  3492. if (!isValidType) {
  3493. console.error('[申请培训附件上传前检查] 文件类型不符合要求:', file.type);
  3494. proxy?.$modal.msgError('上传附件文件只能是PDF/Word/Excel/图片格式!');
  3495. return false;
  3496. }
  3497. if (!isLt20M) {
  3498. console.error('[申请培训附件上传前检查] 文件大小超出限制:', `${(file.size / 1024 / 1024).toFixed(2)}MB`);
  3499. proxy?.$modal.msgError('上传附件文件大小不能超过20MB!');
  3500. return false;
  3501. }
  3502. console.log('[申请培训附件上传前检查] 检查通过');
  3503. return true;
  3504. }
  3505. /** 申请培训附件上传成功处理 */
  3506. function handleApplicationAttachmentSuccess(response: any, file: any) {
  3507. console.log('[申请培训附件上传成功] 响应数据:', response);
  3508. console.log('[申请培训附件上传成功] 文件对象:', file);
  3509. if (response.code === 200 && response.data) {
  3510. file.url = response.data.url;
  3511. file.ossId = response.data.ossId;
  3512. proxy?.$modal.msgSuccess('附件上传成功!');
  3513. console.log('[申请培训附件上传成功] OSS ID:', response.data.ossId);
  3514. // 更新文件状态为成功
  3515. file.status = 'success';
  3516. file.response = response;
  3517. // 更新applicationForm中的attachmentIds字段
  3518. updateApplicationFormAttachmentIds();
  3519. }
  3520. }
  3521. /** 申请培训附件上传失败处理 */
  3522. function handleApplicationAttachmentError(error: any, file: any) {
  3523. console.error('[申请培训附件上传失败] 错误对象:', error);
  3524. console.error('[申请培训附件上传失败] 文件对象:', file);
  3525. let errorMessage = '附件上传失败,请重试!';
  3526. let errorDetails = '';
  3527. // 尝试从错误响应中获取具体错误信息
  3528. if (error && error.response) {
  3529. console.error('[申请培训附件上传失败] HTTP响应:', {
  3530. status: error.response.status,
  3531. statusText: error.response.statusText,
  3532. data: error.response.data
  3533. });
  3534. if (error.response.data) {
  3535. if (error.response.data.msg) {
  3536. errorMessage = error.response.data.msg;
  3537. } else if (error.response.data.message) {
  3538. errorMessage = error.response.data.message;
  3539. }
  3540. }
  3541. // 常见错误状态码处理
  3542. if (error.response.status === 401) {
  3543. errorDetails = '认证失败,请重新登录';
  3544. } else if (error.response.status === 403) {
  3545. errorDetails = '没有上传权限';
  3546. } else if (error.response.status === 404) {
  3547. errorDetails = '上传接口不存在';
  3548. } else if (error.response.status === 413) {
  3549. errorDetails = '文件太大,服务器拒绝接收';
  3550. } else if (error.response.status >= 500) {
  3551. errorDetails = '服务器内部错误';
  3552. }
  3553. } else if (error.message) {
  3554. console.error('[申请培训附件上传失败] 错误信息:', error.message);
  3555. errorDetails = error.message;
  3556. }
  3557. const finalMessage = errorDetails ? `${errorMessage} (${errorDetails})` : errorMessage;
  3558. proxy?.$modal.msgError(finalMessage);
  3559. }
  3560. /** 更新applicationForm中的attachmentIds字段 */
  3561. function updateApplicationFormAttachmentIds() {
  3562. console.log('[更新附件IDs] 开始更新');
  3563. console.log('[更新附件IDs] 文件列表:', applicationAttachmentFileList.value);
  3564. // 提取所有成功上传的ossId
  3565. const attachmentOssIds = applicationAttachmentFileList.value.filter((file) => file.status === 'success' && file.ossId).map((file) => file.ossId);
  3566. // 更新applicationForm
  3567. applicationForm.attachmentIds = attachmentOssIds;
  3568. console.log('[更新附件IDs] 提取的OSS IDs:', attachmentOssIds);
  3569. console.log('[更新附件IDs] applicationForm.attachmentIds:', applicationForm.attachmentIds);
  3570. }
  3571. /** 移除申请培训附件 */
  3572. function handleRemoveApplicationAttachment(file: any) {
  3573. // 更新attachmentIds
  3574. updateApplicationFormAttachmentIds();
  3575. }
  3576. /** 确认移除申请培训附件 */
  3577. function confirmRemoveApplicationAttachment(file: any) {
  3578. proxy?.$modal
  3579. .confirm('确定要删除这个附件吗?')
  3580. .then(() => {
  3581. const index = applicationAttachmentFileList.value.findIndex((f) => f.uid === file.uid);
  3582. if (index > -1) {
  3583. applicationAttachmentFileList.value.splice(index, 1);
  3584. updateApplicationFormAttachmentIds();
  3585. proxy?.$modal.msgSuccess('附件删除成功');
  3586. }
  3587. })
  3588. .catch(() => {
  3589. console.log('取消删除附件');
  3590. });
  3591. }
  3592. /** 预览申请培训附件 */
  3593. function handlePreviewApplicationAttachment(file: any) {
  3594. if (file.url) {
  3595. window.open(file.url, '_blank');
  3596. }
  3597. }
  3598. /** 下载申请培训附件 */
  3599. async function handleDownloadApplicationAttachment(file: any) {
  3600. console.log('[下载申请培训附件] 开始下载');
  3601. console.log('[下载申请培训附件] 文件信息:', file);
  3602. if (!file.ossId) {
  3603. console.error('[下载申请培训附件] ossId为空,无法下载');
  3604. proxy?.$modal.msgError('文件信息不完整,无法下载');
  3605. return;
  3606. }
  3607. try {
  3608. console.log('[下载申请培训附件] 请求下载接口:', `/resource/oss/download/${file.ossId}`);
  3609. // 使用后端安全下载接口,通过request工具发送请求以包含认证头
  3610. const response = await request({
  3611. url: `/resource/oss/download/${file.ossId}`,
  3612. method: 'get',
  3613. responseType: 'blob' // 指定响应类型为blob
  3614. });
  3615. console.log('[下载申请培训附件] 接口响应:', response);
  3616. // 创建blob URL并触发下载
  3617. const blob = response instanceof Blob ? response : new Blob([response.data]);
  3618. const url = window.URL.createObjectURL(blob);
  3619. const link = document.createElement('a');
  3620. link.href = url;
  3621. link.download = file.name || '申请培训附件';
  3622. document.body.appendChild(link);
  3623. link.click();
  3624. // 清理资源
  3625. document.body.removeChild(link);
  3626. window.URL.revokeObjectURL(url);
  3627. console.log('[下载申请培训附件] 下载成功');
  3628. proxy?.$modal.msgSuccess('文件下载成功');
  3629. } catch (error: any) {
  3630. console.error('[下载申请培训附件] 下载失败:', error);
  3631. let errorMessage = '下载附件失败,请稍后重试';
  3632. if (error.response) {
  3633. console.error('[下载申请培训附件] HTTP响应错误:', {
  3634. status: error.response.status,
  3635. statusText: error.response.statusText
  3636. });
  3637. if (error.response.status === 401) {
  3638. errorMessage = '认证失败,请重新登录';
  3639. } else if (error.response.status === 403) {
  3640. errorMessage = '没有下载权限';
  3641. } else if (error.response.status === 404) {
  3642. errorMessage = '文件不存在或已被删除';
  3643. }
  3644. }
  3645. proxy?.$modal.msgError(errorMessage);
  3646. }
  3647. }
  3648. </script>
  3649. <style scoped>
  3650. .certificate-upload-container {
  3651. border: 1px dashed #d9d9d9;
  3652. border-radius: 6px;
  3653. padding: 15px;
  3654. background-color: #fafafa;
  3655. }
  3656. .certificate-upload-container:hover {
  3657. border-color: #409eff;
  3658. }
  3659. .attachment-upload-container {
  3660. border: 1px dashed #d9d9d9;
  3661. border-radius: 6px;
  3662. padding: 15px;
  3663. background-color: #fafafa;
  3664. box-sizing: border-box;
  3665. }
  3666. .attachment-upload-container .attachment-upload-demo {
  3667. width: 100%;
  3668. }
  3669. .attachment-upload-container .attachment-upload-demo .el-upload {
  3670. width: 100%;
  3671. height: auto;
  3672. background-color: transparent !important;
  3673. border: none !important;
  3674. }
  3675. .attachment-upload-container .attachment-upload-demo .el-upload:hover {
  3676. background-color: transparent !important;
  3677. }
  3678. .attachment-upload-container .el-upload-dragger {
  3679. background-color: transparent !important;
  3680. border: none !important;
  3681. width: 100% !important;
  3682. height: auto !important;
  3683. padding: 0 !important;
  3684. margin: 0 !important;
  3685. }
  3686. .attachment-upload-container .el-upload-dragger:hover {
  3687. background-color: transparent !important;
  3688. border: none !important;
  3689. }
  3690. .attachment-upload-container:hover {
  3691. border-color: #409eff;
  3692. }
  3693. .el-upload-dragger-attachment {
  3694. padding: 0 !important;
  3695. margin: 0 !important;
  3696. text-align: center;
  3697. background-color: transparent;
  3698. border: none;
  3699. min-height: 80px;
  3700. display: flex;
  3701. flex-direction: column;
  3702. align-items: center;
  3703. justify-content: center;
  3704. gap: 4px;
  3705. box-sizing: border-box;
  3706. }
  3707. .el-upload-dragger-attachment .el-icon--upload {
  3708. font-size: 24px;
  3709. color: #c0c4cc;
  3710. margin: 0;
  3711. }
  3712. .el-upload-dragger-attachment .el-upload__text {
  3713. color: #666666;
  3714. font-size: 12px;
  3715. line-height: 1.3;
  3716. margin: 0;
  3717. }
  3718. .el-upload-dragger-attachment .el-upload__text em {
  3719. color: #409eff;
  3720. font-style: normal;
  3721. font-weight: 500;
  3722. }
  3723. .el-upload-dragger-attachment .el-upload__tip {
  3724. font-size: 11px !important;
  3725. color: #909399 !important;
  3726. margin: 0 !important;
  3727. line-height: 1.2;
  3728. }
  3729. .record-certificate-upload {
  3730. margin-bottom: 10px;
  3731. }
  3732. .current-certificate {
  3733. margin-top: 10px;
  3734. padding: 8px;
  3735. background-color: #f0f9ff;
  3736. border: 1px solid #b3d8ff;
  3737. border-radius: 4px;
  3738. display: flex;
  3739. align-items: center;
  3740. justify-content: space-between;
  3741. }
  3742. .current-certificate .el-tag {
  3743. margin-right: 10px;
  3744. }
  3745. .detail-text {
  3746. white-space: pre-wrap;
  3747. word-break: break-word;
  3748. }
  3749. .pagination-container {
  3750. padding: 20px 0;
  3751. text-align: center;
  3752. }
  3753. .search-btn-container {
  3754. text-align: center;
  3755. }
  3756. .button-card {
  3757. margin-top: 10px;
  3758. }
  3759. .table-card {
  3760. margin-bottom: 10px;
  3761. }
  3762. /* 证书上传拖拽区域样式 - 紧凑设计 */
  3763. .el-upload-dragger-certificate {
  3764. text-align: center;
  3765. padding: 10px 15px;
  3766. min-height: 40px;
  3767. border: 2px dashed #d9d9d9;
  3768. border-radius: 6px;
  3769. background-color: #fafafa;
  3770. transition: border-color 0.3s;
  3771. }
  3772. .el-upload-dragger-certificate:hover {
  3773. border-color: #409eff;
  3774. }
  3775. .el-upload-dragger-certificate .el-icon--upload {
  3776. font-size: 18px;
  3777. color: #c0c4cc;
  3778. margin-bottom: 4px;
  3779. }
  3780. .el-upload-dragger-certificate .el-upload__text {
  3781. color: #606266;
  3782. font-size: 12px;
  3783. line-height: 1.2;
  3784. }
  3785. .el-upload-dragger-certificate .el-upload__text em {
  3786. color: #409eff;
  3787. font-style: normal;
  3788. }
  3789. /* 证书文件卡片样式 */
  3790. .certificate-file-card {
  3791. position: relative;
  3792. width: 100%;
  3793. height: 100%;
  3794. display: flex;
  3795. flex-direction: column;
  3796. background: #fff;
  3797. border-radius: 6px;
  3798. overflow: hidden;
  3799. }
  3800. .certificate-file-thumb {
  3801. position: relative;
  3802. width: 100%;
  3803. height: 120px;
  3804. background: #f5f7fa;
  3805. display: flex;
  3806. align-items: center;
  3807. justify-content: center;
  3808. overflow: hidden;
  3809. }
  3810. .certificate-thumb-image {
  3811. width: 100%;
  3812. height: 100%;
  3813. object-fit: cover;
  3814. }
  3815. .certificate-file-placeholder {
  3816. display: flex;
  3817. flex-direction: column;
  3818. align-items: center;
  3819. justify-content: center;
  3820. height: 100%;
  3821. color: #909399;
  3822. }
  3823. .certificate-file-placeholder .el-icon {
  3824. font-size: 36px;
  3825. margin-bottom: 8px;
  3826. }
  3827. .certificate-file-placeholder .file-ext {
  3828. font-size: 12px;
  3829. font-weight: bold;
  3830. color: #f56c6c;
  3831. }
  3832. .certificate-file-loading {
  3833. position: absolute;
  3834. top: 0;
  3835. left: 0;
  3836. right: 0;
  3837. bottom: 0;
  3838. background: rgba(255, 255, 255, 0.9);
  3839. display: flex;
  3840. flex-direction: column;
  3841. align-items: center;
  3842. justify-content: center;
  3843. z-index: 10;
  3844. }
  3845. .certificate-file-loading .el-icon {
  3846. font-size: 24px;
  3847. color: #409eff;
  3848. margin-bottom: 8px;
  3849. }
  3850. .certificate-file-loading .loading-text {
  3851. font-size: 12px;
  3852. color: #606266;
  3853. }
  3854. .certificate-file-name {
  3855. padding: 8px;
  3856. font-size: 12px;
  3857. color: #606266;
  3858. text-align: center;
  3859. background: #fff;
  3860. border-top: 1px solid #ebeef5;
  3861. overflow: hidden;
  3862. text-overflow: ellipsis;
  3863. white-space: nowrap;
  3864. }
  3865. .certificate-file-card-actions {
  3866. position: absolute;
  3867. top: 4px;
  3868. right: 4px;
  3869. background: rgba(255, 255, 255, 0.9);
  3870. border-radius: 4px;
  3871. padding: 2px;
  3872. }
  3873. .certificate-file-card-actions .el-button {
  3874. padding: 4px;
  3875. min-height: 24px;
  3876. }
  3877. .certificate-file-card-actions .el-button .el-icon {
  3878. font-size: 12px;
  3879. }
  3880. /* 证书上传整体容器优化 */
  3881. .certificate-upload-demo {
  3882. width: 100%;
  3883. }
  3884. /* 强制覆盖Element Plus默认高度 */
  3885. .certificate-upload-demo :deep(.el-upload) {
  3886. height: auto !important;
  3887. min-height: 40px !important;
  3888. }
  3889. .certificate-upload-demo :deep(.el-upload-dragger) {
  3890. height: auto !important;
  3891. min-height: 40px !important;
  3892. padding: 10px 15px !important;
  3893. }
  3894. .certificate-upload-demo :deep(.el-upload-list--picture-card) {
  3895. display: flex;
  3896. flex-wrap: wrap;
  3897. gap: 8px;
  3898. }
  3899. .certificate-upload-demo :deep(.el-upload--picture-card) {
  3900. width: auto;
  3901. height: auto;
  3902. min-height: 40px;
  3903. border: none;
  3904. background: transparent;
  3905. display: flex;
  3906. align-items: center;
  3907. }
  3908. .certificate-upload-demo :deep(.el-upload-list__item) {
  3909. width: 120px;
  3910. height: auto;
  3911. margin: 0;
  3912. border: 1px solid #ebeef5;
  3913. border-radius: 6px;
  3914. overflow: hidden;
  3915. }
  3916. /* 提示文字样式优化 */
  3917. .el-upload__tip {
  3918. margin-top: 8px !important;
  3919. font-size: 12px !important;
  3920. color: #909399 !important;
  3921. line-height: 1.4 !important;
  3922. }
  3923. /* 只读输入框样式 - 确保灰色背景被白色边框完全包裹 */
  3924. .readonly-input {
  3925. width: 100% !important;
  3926. }
  3927. /* 通用样式,适配不同版本的Element Plus */
  3928. .readonly-input :deep(.el-input),
  3929. .readonly-input :deep(.el-input__wrapper) {
  3930. background-color: #f5f7fa !important;
  3931. border: 1px solid #dcdfe6 !important;
  3932. border-radius: 4px !important;
  3933. box-shadow: none !important;
  3934. }
  3935. .readonly-input :deep(.el-input__wrapper) {
  3936. padding: 1px 11px !important;
  3937. min-height: 32px !important;
  3938. display: flex !important;
  3939. align-items: center !important;
  3940. }
  3941. .readonly-input :deep(.el-input__inner) {
  3942. background-color: transparent !important;
  3943. color: #606266 !important;
  3944. border: none !important;
  3945. cursor: not-allowed !important;
  3946. padding: 0 !important;
  3947. height: 30px !important;
  3948. line-height: 30px !important;
  3949. outline: none !important;
  3950. box-shadow: none !important;
  3951. }
  3952. /* 悬停和聚焦状态 */
  3953. .readonly-input :deep(.el-input:hover),
  3954. .readonly-input :deep(.el-input__wrapper:hover) {
  3955. border-color: #dcdfe6 !important;
  3956. box-shadow: none !important;
  3957. }
  3958. .readonly-input :deep(.el-input.is-focus),
  3959. .readonly-input :deep(.el-input__wrapper.is-focus) {
  3960. border-color: #dcdfe6 !important;
  3961. box-shadow: none !important;
  3962. }
  3963. .readonly-input :deep(.el-input:hover .el-input__inner),
  3964. .readonly-input :deep(.el-input.is-focus .el-input__inner) {
  3965. border-color: transparent !important;
  3966. box-shadow: none !important;
  3967. }
  3968. </style>
  3969. <style scoped>
  3970. .card-header {
  3971. display: flex;
  3972. justify-content: space-between;
  3973. align-items: center;
  3974. }
  3975. .el-tag {
  3976. margin-right: 5px;
  3977. }
  3978. /* 页面容器样式 */
  3979. .app-container {
  3980. padding: 8px;
  3981. }
  3982. /* 表格卡片布局 */
  3983. .table-card {
  3984. margin-top: 0;
  3985. }
  3986. .table-card :deep(.el-card__body) {
  3987. padding: 0px 20px 20px 20px !important;
  3988. }
  3989. /* 移除按钮栏底部边框 */
  3990. .button-card :deep(.el-card__header) {
  3991. border-bottom: none !important;
  3992. }
  3993. /* 分页容器样式 */
  3994. .pagination-container {
  3995. display: flex;
  3996. justify-content: flex-end;
  3997. padding: 16px 20px 0 0 !important;
  3998. background-color: #fff;
  3999. margin-top: 0px !important;
  4000. }
  4001. /* 搜索按钮容器样式 */
  4002. .search-btn-container {
  4003. display: flex;
  4004. justify-content: flex-end;
  4005. margin-top: 10px;
  4006. }
  4007. .search-btn-container :deep(.el-form-item) {
  4008. margin-bottom: 0 !important;
  4009. }
  4010. /* 表单提示信息 */
  4011. .el-form-item-msg {
  4012. font-size: 12px;
  4013. color: #909399;
  4014. margin-top: 5px;
  4015. }
  4016. /* 详情文本 */
  4017. .detail-text {
  4018. padding: 8px;
  4019. border: 1px solid #e4e7ed;
  4020. border-radius: 4px;
  4021. min-height: 60px;
  4022. max-height: 200px;
  4023. overflow-y: auto;
  4024. }
  4025. /* 审批历史项样式 */
  4026. .approval-history-item {
  4027. padding: 10px 0;
  4028. border-bottom: 1px solid #ebeef5;
  4029. }
  4030. .approval-history-item:last-child {
  4031. border-bottom: none;
  4032. }
  4033. .approval-header {
  4034. display: flex;
  4035. align-items: center;
  4036. margin-bottom: 5px;
  4037. }
  4038. .approver-name {
  4039. font-weight: bold;
  4040. margin-right: 10px;
  4041. }
  4042. .approval-level {
  4043. margin-right: 10px;
  4044. color: #909399;
  4045. }
  4046. .approval-opinion {
  4047. font-size: 14px;
  4048. color: #606266;
  4049. line-height: 1.6;
  4050. }
  4051. .no-data {
  4052. text-align: center;
  4053. padding: 20px;
  4054. color: #909399;
  4055. }
  4056. /* 文件卡片样式(参考宿舍卫生检查) */
  4057. .upload-file-card {
  4058. position: relative;
  4059. width: 100%;
  4060. height: 100%;
  4061. border-radius: 6px;
  4062. overflow: hidden;
  4063. background: #fff;
  4064. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  4065. transition: all 0.3s;
  4066. }
  4067. .upload-file-card:hover {
  4068. box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  4069. }
  4070. .upload-file-thumb {
  4071. position: relative;
  4072. width: 100%;
  4073. height: 110px;
  4074. background: #f5f5f5;
  4075. display: flex;
  4076. align-items: center;
  4077. justify-content: center;
  4078. overflow: hidden;
  4079. }
  4080. .upload-thumb-image {
  4081. width: 100%;
  4082. height: 100%;
  4083. object-fit: cover;
  4084. }
  4085. .upload-file-image {
  4086. width: 100%;
  4087. height: 100%;
  4088. display: flex;
  4089. align-items: center;
  4090. justify-content: center;
  4091. background: #f5f5f5;
  4092. }
  4093. .upload-file-loading {
  4094. position: absolute;
  4095. top: 0;
  4096. left: 0;
  4097. right: 0;
  4098. bottom: 0;
  4099. display: flex;
  4100. flex-direction: column;
  4101. align-items: center;
  4102. justify-content: center;
  4103. z-index: 10;
  4104. }
  4105. .upload-file-placeholder {
  4106. display: flex;
  4107. flex-direction: column;
  4108. align-items: center;
  4109. justify-content: center;
  4110. height: 100%;
  4111. color: #909399;
  4112. }
  4113. .upload-file-placeholder .file-ext {
  4114. font-size: 12px;
  4115. margin-top: 5px;
  4116. }
  4117. .loading-text {
  4118. margin-top: 8px;
  4119. font-size: 12px;
  4120. color: #606266;
  4121. }
  4122. .upload-file-name {
  4123. padding: 6px 8px;
  4124. font-size: 11px;
  4125. color: #303133;
  4126. text-align: center;
  4127. overflow: hidden;
  4128. text-overflow: ellipsis;
  4129. white-space: nowrap;
  4130. background: #fafafa;
  4131. border-top: 1px solid #f0f0f0;
  4132. line-height: 1.2;
  4133. height: 32px;
  4134. display: flex;
  4135. align-items: center;
  4136. justify-content: center;
  4137. word-break: break-all;
  4138. max-width: 100%;
  4139. }
  4140. .upload-file-card-actions {
  4141. display: flex;
  4142. justify-content: center;
  4143. align-items: center;
  4144. padding: 6px 8px;
  4145. background: #fafafa;
  4146. border-top: 1px solid #f0f0f0;
  4147. transition: all 0.3s;
  4148. height: 38px;
  4149. }
  4150. .upload-file-card-actions .el-button-group {
  4151. background: transparent;
  4152. border-radius: 4px;
  4153. padding: 0;
  4154. }
  4155. .upload-file-card-actions .el-button {
  4156. padding: 4px 8px;
  4157. border: 1px solid #e0e0e0;
  4158. background: #fff;
  4159. font-size: 12px;
  4160. margin: 0 2px;
  4161. border-radius: 3px;
  4162. transition: all 0.3s;
  4163. }
  4164. .upload-file-card-actions .el-button:hover {
  4165. background: #f5f5f5;
  4166. border-color: #409eff;
  4167. }
  4168. .upload-file-card-actions .el-button.is-disabled {
  4169. opacity: 0.5;
  4170. cursor: not-allowed;
  4171. background: #f5f5f5;
  4172. }
  4173. </style>
  4174. <style lang="scss" scoped>
  4175. .app-container {
  4176. // ... 现有样式
  4177. // 拒绝原因样式
  4178. .reject-reason {
  4179. :deep(.el-descriptions-item__content) {
  4180. padding: 12px;
  4181. }
  4182. .reject-info {
  4183. width: 100%;
  4184. .reject-title {
  4185. font-weight: bold;
  4186. font-size: 14px;
  4187. }
  4188. .reject-content {
  4189. margin-top: 8px;
  4190. padding: 8px;
  4191. background-color: #fef0f0;
  4192. border-radius: 4px;
  4193. color: #f56c6c;
  4194. white-space: pre-wrap;
  4195. word-break: break-word;
  4196. line-height: 1.5;
  4197. }
  4198. .reject-action {
  4199. margin-top: 10px;
  4200. text-align: right;
  4201. }
  4202. }
  4203. }
  4204. // 审批历史样式
  4205. .approval-history-item {
  4206. padding: 0 0 8px 0;
  4207. .approval-header {
  4208. display: flex;
  4209. align-items: center;
  4210. margin-bottom: 8px;
  4211. .approver-name {
  4212. font-weight: bold;
  4213. margin-right: 8px;
  4214. }
  4215. .approval-level {
  4216. color: #909399;
  4217. margin-right: 8px;
  4218. }
  4219. }
  4220. .approval-opinion {
  4221. background-color: #f5f7fa;
  4222. padding: 8px 12px;
  4223. border-radius: 4px;
  4224. color: #606266;
  4225. white-space: pre-wrap;
  4226. word-break: break-word;
  4227. line-height: 1.5;
  4228. }
  4229. }
  4230. .no-data {
  4231. text-align: center;
  4232. color: #909399;
  4233. padding: 30px 0;
  4234. }
  4235. // 证书预览样式
  4236. .certificate-preview {
  4237. .certificate-container {
  4238. display: flex;
  4239. align-items: center;
  4240. margin-bottom: 10px;
  4241. .image-preview {
  4242. .image-slot {
  4243. display: flex;
  4244. justify-content: center;
  4245. align-items: center;
  4246. flex-direction: column;
  4247. width: 100%;
  4248. height: 100%;
  4249. background: #f5f7fa;
  4250. color: #909399;
  4251. font-size: 14px;
  4252. .el-icon {
  4253. font-size: 24px;
  4254. margin-bottom: 5px;
  4255. }
  4256. }
  4257. }
  4258. .image-preview {
  4259. .el-image {
  4260. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  4261. transition: transform 0.2s;
  4262. &:hover {
  4263. transform: scale(1.02);
  4264. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  4265. }
  4266. }
  4267. .loading-preview {
  4268. background: #f9f9f9;
  4269. color: #909399;
  4270. font-size: 14px;
  4271. .el-icon {
  4272. margin-right: 8px;
  4273. font-size: 18px;
  4274. }
  4275. }
  4276. .image-slot {
  4277. display: flex;
  4278. flex-direction: column;
  4279. align-items: center;
  4280. justify-content: center;
  4281. height: 100%;
  4282. color: #909399;
  4283. .el-icon {
  4284. font-size: 32px;
  4285. margin-bottom: 8px;
  4286. }
  4287. div {
  4288. font-size: 14px;
  4289. }
  4290. }
  4291. }
  4292. .file-info {
  4293. display: flex;
  4294. flex-direction: column;
  4295. align-items: center;
  4296. padding: 20px;
  4297. border: 1px solid #dcdfe6;
  4298. border-radius: 4px;
  4299. background: #fafafa;
  4300. min-width: 200px;
  4301. .el-icon {
  4302. color: #909399;
  4303. margin-bottom: 10px;
  4304. }
  4305. .file-name {
  4306. font-size: 14px;
  4307. color: #606266;
  4308. margin-bottom: 5px;
  4309. word-break: break-all;
  4310. text-align: center;
  4311. }
  4312. .file-type {
  4313. font-size: 12px;
  4314. color: #909399;
  4315. }
  4316. }
  4317. }
  4318. .certificate-actions {
  4319. display: flex;
  4320. gap: 10px;
  4321. .el-button {
  4322. display: flex;
  4323. align-items: center;
  4324. gap: 5px;
  4325. }
  4326. }
  4327. }
  4328. .no-certificate {
  4329. display: flex;
  4330. justify-content: center;
  4331. align-items: center;
  4332. min-height: 120px;
  4333. }
  4334. }
  4335. </style>