license_info copy.html 129 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>License 分发管理</title>
  7. <style>
  8. /* 保持样式不变 */
  9. body {
  10. font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  11. background-color: #f8f8f8;
  12. margin: 0;
  13. padding: 0;
  14. display: flex;
  15. }
  16. header {
  17. display: flex;
  18. justify-content: space-between;
  19. align-items: center;
  20. padding: 20px;
  21. background-color: #1169ff;
  22. color: white;
  23. width: 100%;
  24. margin: 0; /* 移除上下左右的空隙 */
  25. box-sizing: border-box; /* 确保padding不会影响元素的宽度 */
  26. border: 4px solid #1169ff; /* 确保红框颜色填满 */
  27. border-width: 4px 0 4px 0; /* 只显示上下的红框颜色 */
  28. border-radius: 10px; /* 设置圆角 */
  29. }
  30. h1 {
  31. font-size: 24px;
  32. font-weight: 600;
  33. margin: 0;
  34. }
  35. /* 扁平风格的选择框 */
  36. .flat-select {
  37. background-color: transparent; /* 背景色透明 */
  38. border: 1px solid #007aff; /* 边框颜色与按钮一致 */
  39. border-radius: 15px; /* 圆角边框 */
  40. padding: 5px 10px; /* 内边距 */
  41. font-size: 16px; /* 字体大小 */
  42. color: #007aff; /* 文字颜色 */
  43. outline: none; /* 移除默认的焦点样式 */
  44. appearance: none; /* 移除默认的下拉箭头样式 */
  45. -webkit-appearance: none; /* 对部分浏览器的兼容性处理 */
  46. -moz-appearance: none; /* 对部分浏览器的兼容性处理 */
  47. cursor: pointer; /* 鼠标指针样式 */
  48. margin-left: 10px; /* 添加左边距,使选择框与前面的元素有些距离 */
  49. box-shadow: none; /* 移除阴影效果 */
  50. transition: background-color 0.3s, color 0.3s; /* 添加过渡效果 */
  51. }
  52. /* 选择框在悬停时的效果 */
  53. .flat-select:hover {
  54. background-color: #007aff; /* 背景色变为蓝色 */
  55. color: white; /* 文字颜色变为白色 */
  56. }
  57. /* 选择框在聚焦时的效果 */
  58. .flat-select:focus {
  59. background-color: #e0f7ff; /* 聚焦时的背景颜色 */
  60. border-color: #0056b3; /* 聚焦时的边框颜色 */
  61. }
  62. /* 添加下拉箭头的样式 */
  63. .flat-select::after {
  64. content: '▼'; /* 使用字符作为下拉箭头 */
  65. position: absolute;
  66. right: 10px;
  67. pointer-events: none; /* 确保下拉箭头不会遮挡选择框 */
  68. }
  69. /* 扁平圆角风格的按钮样式 */
  70. .flat-rounded-button {
  71. background-color: white;
  72. color: #007aff;
  73. border: 2px solid #007aff;
  74. padding: 10px 20px;
  75. border-radius: 15px;
  76. cursor: pointer;
  77. font-size: 16px;
  78. font-weight: 500;
  79. box-shadow: none; /* 移除阴影效果 */
  80. transition: background-color 0.3s, color 0.3s;
  81. margin: 5px; /* 添加按钮之间的间距 */
  82. }
  83. /* 悬停时的效果 */
  84. .flat-rounded-button:hover {
  85. background-color: #0eb3ff;
  86. color: white;
  87. }
  88. /*lic 展示页 主行展开后变化*/
  89. .expanded-row {
  90. background-color: #0eb3ff; /* 展开时的背景颜色 */
  91. border-color: #04aa9c; /* 展开时的边框颜色 */
  92. border-width: 4px; /* 边框宽度 */
  93. border-radius: 35px; /* 边框圆角 */
  94. transition: all 0.2s ease; /* 添加过渡效果 */
  95. }
  96. /*苹果风格模态框*/
  97. .apple-modal-content {
  98. font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  99. padding: 20px;
  100. border-radius: 12px;
  101. background-color: white;
  102. box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  103. margin-bottom: 20px;
  104. }
  105. .apple-modal-title {
  106. font-size: 24px;
  107. font-weight: 600;
  108. color: #333;
  109. margin-bottom: 10px;
  110. }
  111. .apple-modal-subtitle {
  112. font-size: 20px;
  113. font-weight: 500;
  114. color: #555;
  115. margin-top: 20px;
  116. margin-bottom: 10px;
  117. }
  118. /* 苹果风格的文字样式 */
  119. .apple-modal-text {
  120. font-size: 16px;
  121. color: #555;
  122. line-height: 1.6;
  123. margin-bottom: 10px;
  124. }
  125. /* 强调部分 */
  126. .apple-modal-text strong {
  127. color: #333;
  128. }
  129. /* 苹果风格的模态框关闭按钮 */
  130. .apple-close {
  131. color: #aaa;
  132. font-size: 24px; /* 调整字体大小 */
  133. font-weight: bold;
  134. cursor: pointer;
  135. transition: color 0.3s;
  136. }
  137. .apple-close:hover {
  138. color: black;
  139. }
  140. /* 苹果风格的退出按钮 */
  141. .apple-logout-button {
  142. background-color: #007aff; /* 苹果风格的蓝色 */
  143. color: white;
  144. border: none;
  145. padding: 8px 16px; /* 减小内边距,使按钮更小 */
  146. border-radius: 10px; /* 圆角稍微减小 */
  147. font-size: 14px; /* 调整字体大小 */
  148. font-weight: 500;
  149. cursor: pointer;
  150. transition: background-color 0.3s, transform 0.3s;
  151. }
  152. .apple-logout-button:hover {
  153. background-color: #005bb5; /* 悬停时按钮颜色变深 */
  154. transform: scale(1.05); /* 悬停时按钮略微放大 */
  155. }
  156. .apple-logout-button:active {
  157. background-color: #003e7e; /* 点击时按钮颜色更深 */
  158. transform: scale(0.98); /* 点击时按钮略微缩小 */
  159. }
  160. .upload-button, .user-button {
  161. background-color: white;
  162. color: #007aff;
  163. border: none;
  164. padding: 10px 20px;
  165. border-radius: 10px;
  166. cursor: pointer;
  167. font-size: 16px;
  168. font-weight: 500;
  169. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  170. transition: background-color 0.3s;
  171. }
  172. .upload-button:hover, .user-button:hover {
  173. background-color: #f0f0f0;
  174. }
  175. .sidebar {
  176. width: 200px;
  177. background-color: #f1f1f1;
  178. padding: 20px;
  179. box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
  180. height: 100vh;
  181. transition: transform 0.3s ease;
  182. }
  183. .sidebar.hidden {
  184. transform: translateX(-100%);
  185. }
  186. .sidebar button {
  187. width: 100%;
  188. padding: 10px;
  189. margin-bottom: 10px;
  190. background-color: white;
  191. color: #007aff;
  192. border: none;
  193. border-radius: 10px;
  194. cursor: pointer;
  195. font-size: 16px;
  196. font-weight: 500;
  197. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  198. transition: background-color 0.3s;
  199. }
  200. .sidebar button:hover {
  201. background-color: #e0e0e0;
  202. }
  203. .content {
  204. flex-grow: 1;
  205. padding: 20px;
  206. transition: margin-left 0.3s ease;
  207. }
  208. .content.expanded {
  209. margin-left: -200px;
  210. }
  211. .toggle-sidebar {
  212. position: fixed;
  213. top: 50%; /* 垂直居中 */
  214. transform: translateY(-50%); /* 调整为居中对齐 */
  215. left: 0; /* 靠左对齐 */
  216. background-color: #007aff;
  217. color: white;
  218. border: none;
  219. padding: 10px;
  220. cursor: pointer;
  221. border-radius: 0 10px 10px 0; /* 右侧圆角,左侧保持平直 */
  222. width: 30px; /* 长条形箭头的宽度 */
  223. height: 60px; /* 长条形箭头的高度 */
  224. z-index: 1000;
  225. display: flex;
  226. align-items: center;
  227. justify-content: center;
  228. transition: all 0.3s ease; /* 添加动效 */
  229. }
  230. .sidebar.hidden + .content .toggle-sidebar {
  231. left: 0;
  232. transform: translateX(0) translateY(-50%);
  233. }
  234. /* 通用按钮样式 */
  235. .license-status-btn {
  236. display: inline-block;
  237. padding: 5px 15px;
  238. font-size: 14px;
  239. font-weight: bold;
  240. color: white;
  241. text-align: center;
  242. border-radius: 15px; /* 圆角样式 */
  243. cursor: pointer;
  244. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* 阴影效果 */
  245. transition: background-color 0.3s;
  246. border: none; /* 移除按钮边框 */
  247. }
  248. /* 分发按钮样式 */
  249. .license-status-btn.distribute {
  250. background-color: #007bff; /* 蓝色背景 */
  251. }
  252. .license-status-btn.distribute:hover {
  253. background-color: #0056b3; /* 悬停时的颜色 */
  254. }
  255. /* 生成按钮样式 */
  256. .license-status-btn.generate {
  257. background-color: #ffc107; /* 黄色背景 */
  258. }
  259. .license-status-btn.generate:hover {
  260. background-color: #e0a800; /* 悬停时的颜色 */
  261. }
  262. /* 默认状态下的箭头图标 */
  263. .arrow-icon {
  264. width: 10px;
  265. height: 10px;
  266. border: solid #007aff;
  267. border-width: 0 3px 3px 0;
  268. display: inline-block;
  269. padding: 3px;
  270. transform: rotate(45deg); /* 初始方向向下 */
  271. transition: transform 0.3s ease; /* 添加旋转过渡效果 */
  272. cursor: pointer;
  273. }
  274. /* 当行展开时旋转箭头图标 */
  275. .rotate-arrow {
  276. transform: rotate(-135deg); /* 旋转方向向上 */
  277. }
  278. /*分发历史样式*/
  279. #distributionHistoryModal .centered-modal-content {
  280. background-color: #ffffff;
  281. border: none;
  282. border-radius: 15px;
  283. padding: 20px;
  284. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  285. text-align: center;
  286. width: 30%; /* 设置宽度为屏幕的80% */
  287. max-width: 90%; /* 最大宽度设置为90%屏幕宽度 */
  288. height: auto; /* 高度自适应内容 */
  289. max-height: 80vh; /* 设置最大高度为屏幕的80% */
  290. overflow-y: auto; /* 如果内容超出则添加垂直滚动条 */
  291. overflow-x: hidden; /* 水平不出现滚动条 */
  292. margin: 0 auto; /* 居中显示 */
  293. }
  294. /* lic查看详细按钮样式 */
  295. .license-status-btn.view-details {
  296. background-color: #add8e6; /* 浅蓝色背景 */
  297. color: white; /* 白色文字 */
  298. border: none; /* 移除按钮边框 */
  299. padding: 8px 16px; /* 调整内边距,与“生成”按钮保持一致 */
  300. border-radius: 20px; /* 调整圆角,确保形状一致 */
  301. cursor: pointer;
  302. font-size: 14px; /* 调整字体大小,确保一致 */
  303. font-weight: 500; /* 字体权重,确保一致 */
  304. margin-left: 10px; /* 与其他按钮的间隔 */
  305. transition: background-color 0.3s, color 0.3s; /* 添加过渡效果 */
  306. }
  307. .license-status-btn.view-details:hover {
  308. background-color: #87ceeb; /* 悬停时颜色变深 */
  309. }
  310. /* 表格样式 */
  311. /* 表格容器 */
  312. /* 表格容器 */
  313. table {
  314. width: 100%;
  315. border-collapse: separate;
  316. border-spacing: 0 4px; /* 设置行间距为4px */
  317. /* background-color: transparent; 使表格背景透明,突出行间距效果 */
  318. margin: 20px 0;
  319. }
  320. th, td {
  321. padding: 15px 20px; /* 设置单元格内边距 */
  322. text-align: left;
  323. font-size: 16px;
  324. /* background-color: white; 单元格背景色 */
  325. }
  326. /* 鼠标悬停时改变边框颜色 */
  327. tr:hover {
  328. background-color: #e6f7ff; /* 设置悬停时的背景颜色 */
  329. border-color: #1169ff; /* 设置悬停时的边框颜色 */
  330. border-width: 4px; /* 设置悬停时的边框大小 */
  331. border-radius: 15px; /* 设置悬停时的圆角 */
  332. }
  333. th {
  334. background-color: #f8f8f8; /* 表头背景色 */
  335. font-weight: bold;
  336. color: #333;
  337. }
  338. td {
  339. color: #555;
  340. }
  341. /* 表格行样式 */
  342. tr {
  343. background-color: white; /* 每行背景色 */
  344. box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1); /* 设置阴影效果 */
  345. border-radius: 10px; /* 设置每行的圆角 */
  346. overflow: hidden; /* 确保圆角效果生效 */
  347. border: 2px solid transparent; /* 默认边框为透明 */
  348. transition: all 0.3s ease; /* 添加过渡效果 */
  349. }
  350. /* 确保单元格也适应行的圆角 */
  351. tr:first-child td:first-child {
  352. border-top-left-radius: 10px;
  353. }
  354. tr:first-child td:last-child {
  355. border-top-right-radius: 10px;
  356. }
  357. tr:last-child td:first-child {
  358. border-bottom-left-radius: 10px;
  359. }
  360. tr:last-child td:last-child {
  361. border-bottom-right-radius: 10px;
  362. }
  363. /*添加用户样式*/
  364. .flat-rounded-input {
  365. width: calc(100% - 40px); /* 与其他输入框一致的宽度 */
  366. padding: 15px 20px; /* 更大的内边距 */
  367. font-size: 18px; /* 更大的字体 */
  368. border: 2px solid #e0e0e0; /* 边框颜色 */
  369. border-radius: 25px; /* 圆角边框 */
  370. box-sizing: border-box;
  371. margin-bottom: 20px;
  372. background-color: #f8f8f8; /* 背景色 */
  373. transition: border-color 0.3s, box-shadow 0.3s; /* 添加动画效果 */
  374. }
  375. .flat-rounded-input:focus {
  376. border-color: #007aff; /* 聚焦时的边框颜色 */
  377. box-shadow: 0 0 8px rgba(0, 122, 255, 0.2); /* 聚焦时的阴影效果 */
  378. outline: none; /* 去掉默认的聚焦样式 */
  379. }
  380. .flat-rounded-button {
  381. background-color: #007aff;
  382. color: white;
  383. border: none;
  384. padding: 15px 20px;
  385. border-radius: 25px;
  386. cursor: pointer;
  387. font-size: 18px;
  388. font-weight: bold;
  389. box-shadow: none; /* 移除阴影效果 */
  390. transition: background-color 0.3s, color 0.3s;
  391. }
  392. .flat-rounded-button:hover {
  393. background-color: #005bb5;
  394. }
  395. .form-group {
  396. display: flex;
  397. align-items: center;
  398. margin-bottom: 15px;
  399. }
  400. .form-group label {
  401. flex: 0 0 80px; /* 固定标签宽度 */
  402. text-align: right;
  403. margin-right: 10px; /* 标签与输入框之间的间距 */
  404. }
  405. .form-group input {
  406. flex: 1; /* 输入框占据剩余空间 */
  407. }
  408. /* 分页按钮样式 */
  409. .pagination button {
  410. padding: 10px 20px;
  411. margin: 0 5px;
  412. cursor: pointer;
  413. border: none;
  414. border-radius: 15px;
  415. background-color: #007aff;
  416. color: white;
  417. font-size: 16px;
  418. font-weight: 500;
  419. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  420. transition: background-color 0.3s;
  421. }
  422. .pagination button:disabled {
  423. background-color: #b0c4de;
  424. cursor: not-allowed;
  425. }
  426. .pagination button:not(:disabled):hover {
  427. background-color: #005bb5;
  428. }
  429. .modal {
  430. display: none;
  431. position: fixed;
  432. z-index: 1;
  433. left: 0;
  434. top: 0;
  435. width: 100%;
  436. height: 100%;
  437. overflow: auto;
  438. background-color: rgba(0, 0, 0, 0.4);
  439. }
  440. .modal-content {
  441. position: fixed;
  442. top: 50%;
  443. left: 50%;
  444. transform: translate(-50%, -50%);
  445. background-color: #fefefe;
  446. padding: 20px;
  447. border: 1px solid #888;
  448. border-radius: 10px;
  449. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  450. max-width: 100%;
  451. max-height: 90%;
  452. overflow-y: auto;
  453. }
  454. /*修改license信息的样式*/
  455. .modify-license-modal-content {
  456. position: fixed;
  457. top: 50%;
  458. left: 50%;
  459. transform: translate(-50%, -50%);
  460. background-color: #fefefe;
  461. padding: 50px;
  462. border: 1px solid #888;
  463. border-radius: 10px;
  464. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  465. width: 400px;
  466. height: 80%; /* 设置为你希望的高度 */
  467. overflow-y: auto;
  468. text-align: center;
  469. }
  470. .modify-license-modal-content input[type="number"],
  471. .modify-license-modal-content input[type="date"],
  472. .modify-license-modal-content input[type="text"],
  473. .modify-license-modal-content input[type="email"],
  474. .modify-license-modal-content input[type="password"],
  475. .modify-license-modal-content textarea,
  476. .modify-license-modal-content select {
  477. width: calc(100% - 40px);
  478. padding: 15px 20px; /* 更大内边距 */
  479. font-size: 18px; /* 更大字体 */
  480. border: 2px solid #e0e0e0; /* 边框颜色 */
  481. border-radius: 25px; /* 圆形边框 */
  482. box-sizing: border-box;
  483. margin-bottom: 20px;
  484. background-color: #f8f8f8; /* 背景色更浅 */
  485. transition: border-color 0.3s, box-shadow 0.3s; /* 添加动画效果 */
  486. }
  487. .modify-license-modal-content input[type="number"]:focus,
  488. .modify-license-modal-content input[type="date"]:focus,
  489. .modify-license-modal-content input[type="text"]:focus,
  490. .modify-license-modal-content input[type="email"]:focus,
  491. .modify-license-modal-content input[type="password"]:focus,
  492. .modify-license-modal-content textarea:focus,
  493. .modify-license-modal-content select:focus {
  494. border-color: #007aff; /* 聚焦时的边框颜色 */
  495. box-shadow: 0 0 8px rgba(0, 122, 255, 0.2); /* 聚焦时的阴影效果 */
  496. outline: none; /* 去掉默认的聚焦样式 */
  497. }
  498. .modify-license-modal-content button {
  499. width: 100%;
  500. padding: 15px 20px;
  501. font-size: 18px;
  502. font-weight: bold;
  503. color: white;
  504. background-color: #007aff;
  505. border: none;
  506. border-radius: 25px;
  507. cursor: pointer;
  508. transition: background-color 0.3s;
  509. }
  510. .modify-license-modal-content button:hover {
  511. background-color: #005bb5; /* 鼠标悬停时的颜色变化 */
  512. }
  513. .modify-license-modal-content .close {
  514. color: #aaa;
  515. float: right;
  516. font-size: 30px;
  517. font-weight: bold;
  518. }
  519. .modify-license-modal-content .close:hover,
  520. .modify-license-modal-content .close:focus {
  521. color: black;
  522. text-decoration: none;
  523. cursor: pointer;
  524. }
  525. .modify-license-modal-content .extra-info {
  526. padding: 20px;
  527. background-color: white;
  528. border: 1px solid #ddd;
  529. border-radius: 10px;
  530. margin-top: 10px;
  531. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  532. line-height: 1.5; /* 增加行高,保证字段间距 */
  533. }
  534. .modal-content input[type="number"] {
  535. width: calc(100% - 40px);
  536. padding: 15px 20px; /* 与其他输入框的内边距一致 */
  537. font-size: 18px; /* 与其他输入框的字体大小一致 */
  538. border: 2px solid #e0e0e0; /* 与其他输入框的边框颜色一致 */
  539. border-radius: 25px; /* 与其他输入框的圆角一致 */
  540. box-sizing: border-box;
  541. margin-bottom: 20px;
  542. background-color: #f8f8f8; /* 与其他输入框的背景色一致 */
  543. transition: border-color 0.3s, box-shadow 0.3s; /* 与其他输入框的过渡效果一致 */
  544. }
  545. .modal-content input[type="number"]:focus {
  546. border-color: #007aff; /* 与其他输入框获得焦点时的边框颜色一致 */
  547. box-shadow: 0 0 8px rgba(0, 122, 255, 0.2); /* 与其他输入框获得焦点时的阴影效果一致 */
  548. outline: none; /* 移除默认的焦点轮廓 */
  549. }
  550. .modal-content input[type="date"] {
  551. width: calc(100% - 40px);
  552. padding: 15px 20px; /* 与其他输入框的内边距一致 */
  553. font-size: 18px; /* 与其他输入框的字体大小一致 */
  554. border: 2px solid #e0e0e0; /* 与其他输入框的边框颜色一致 */
  555. border-radius: 25px; /* 与其他输入框的圆角一致 */
  556. box-sizing: border-box;
  557. margin-bottom: 20px;
  558. background-color: #f8f8f8; /* 与其他输入框的背景色一致 */
  559. transition: border-color 0.3s, box-shadow 0.3s; /* 与其他输入框的过渡效果一致 */
  560. }
  561. .modal-content input[type="date"]:focus {
  562. border-color: #007aff; /* 与其他输入框获得焦点时的边框颜色一致 */
  563. box-shadow: 0 0 8px rgba(0, 122, 255, 0.2); /* 与其他输入框获得焦点时的阴影效果一致 */
  564. outline: none; /* 移除默认的焦点轮廓 */
  565. }
  566. /* 输入框样式 */
  567. .modal-content input[type="text"],
  568. .modal-content input[type="email"],
  569. .modal-content input[type="password"],
  570. .modal-content textarea,
  571. .modal-content select {
  572. width: calc(100% - 40px);
  573. padding: 15px 20px; /* 更大内边距 */
  574. font-size: 18px; /* 更大字体 */
  575. border: 2px solid #e0e0e0; /* 边框颜色 */
  576. border-radius: 25px; /* 圆形边框 */
  577. box-sizing: border-box;
  578. margin-bottom: 20px;
  579. background-color: #f8f8f8; /* 背景色更浅 */
  580. transition: border-color 0.3s, box-shadow 0.3s; /* 添加动画效果 */
  581. }
  582. /* 输入框聚焦时的样式 */
  583. .modal-content input[type="text"]:focus,
  584. .modal-content input[type="email"]:focus,
  585. .modal-content input[type="password"]:focus,
  586. .modal-content textarea:focus,
  587. .modal-content select:focus {
  588. border-color: #007aff; /* 聚焦时的边框颜色 */
  589. box-shadow: 0 0 8px rgba(0, 122, 255, 0.2); /* 聚焦时的阴影效果 */
  590. outline: none; /* 去掉默认的聚焦样式 */
  591. }
  592. /* 按钮样式 */
  593. .modal-content button {
  594. width: 100%;
  595. padding: 15px 20px;
  596. font-size: 18px;
  597. font-weight: bold;
  598. color: white;
  599. background-color: #007aff;
  600. border: none;
  601. border-radius: 25px;
  602. cursor: pointer;
  603. transition: background-color 0.3s;
  604. }
  605. .modal-content button:hover {
  606. background-color: #005bb5; /* 鼠标悬停时的颜色变化 */
  607. }
  608. .close {
  609. color: #aaa;
  610. float: right;
  611. font-size: 30px;
  612. font-weight: bold;
  613. text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
  614. }
  615. .close:hover {
  616. color: #000; /* 悬停时颜色变为黑色 */
  617. transform: scale(1.1); /* 悬停时稍微放大 */
  618. }
  619. .close:focus {
  620. color: black;
  621. text-decoration: none;
  622. cursor: pointer;
  623. }
  624. .extra-info {
  625. padding: 20px;
  626. background-color: white;
  627. border: 1px solid #ddd;
  628. border-radius: 10px;
  629. margin-top: 10px;
  630. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  631. line-height: 1.5; /* 增加行高,保证字段间距 */
  632. }
  633. .extra-info p {
  634. margin: 10px 0; /* 每个字段的间距 */
  635. word-wrap: break-word; /* 允许在单词内断行 */
  636. word-break: break-all; /* 允许在任何字符处断行 */
  637. white-space: pre-wrap; /* 保持空格和换行符 */
  638. border-bottom: 1px solid #f0f0f0; /* 每个字段下方加上细线 */
  639. padding-bottom: 8px; /* 加大下方内边距 */
  640. }
  641. /* 修改运维邮箱和销售邮箱的勾选框样式 */
  642. #emailInputs {
  643. display: flex;
  644. flex-direction: column; /* 确保每一行都垂直排列 */
  645. gap: 10px; /* 增加每行之间的间距 */
  646. }
  647. #emailInputs div {
  648. display: flex;
  649. align-items: center; /* 垂直居中 */
  650. }
  651. #emailInputs input[type="checkbox"] {
  652. appearance: none;
  653. background-color: #fff;
  654. margin: 0;
  655. font: inherit;
  656. color: #007aff;
  657. width: 1.15em;
  658. height: 1.15em;
  659. border: 0.15em solid #007aff;
  660. border-radius: 0.15em;
  661. transform: translateY(-0.075em);
  662. display: grid;
  663. place-content: center;
  664. }
  665. #emailInputs input[type="checkbox"]::before {
  666. content: "";
  667. width: 0.65em;
  668. height: 0.65em;
  669. clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 22%, 80% 0%, 43% 62%);
  670. transform: scale(0);
  671. transform-origin: bottom left;
  672. transition: transform 0.15s ease-in-out;
  673. box-shadow: inset 1em 1em #007aff;
  674. /* 使用淡蓝色与主题颜色匹配 */
  675. background-color: CanvasText;
  676. }
  677. #emailInputs input[type="checkbox"]:checked::before {
  678. transform: scale(1);
  679. }
  680. .user-info {
  681. position: absolute;
  682. width: 300px;
  683. background-color: white;
  684. padding: 20px;
  685. border: 1px solid #ddd;
  686. border-radius: 10px;
  687. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  688. display: none;
  689. }
  690. .user-info .close {
  691. position: absolute;
  692. top: 10px;
  693. right: 10px;
  694. color: #aaa;
  695. font-size: 24px;
  696. font-weight: bold;
  697. cursor: pointer;
  698. }
  699. .user-info .close:hover,
  700. .user-info .close:focus {
  701. color: black;
  702. text-decoration: none;
  703. }
  704. .centered-modal-content {
  705. position: fixed;
  706. top: 50%;
  707. left: 50%;
  708. transform: translate(-50%, -50%);
  709. background-color: #fefefe;
  710. padding: 50px;
  711. border: 1px solid #888;
  712. border-radius: 10px;
  713. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  714. width: 400px;
  715. height: 400px;
  716. overflow-y: auto;
  717. text-align: center;
  718. }
  719. .ios-button {
  720. width: 100%;
  721. padding: 10px;
  722. margin: 0;
  723. border: none;
  724. border-radius: 0;
  725. font-size: 16px;
  726. font-weight: 600;
  727. color: #007aff;
  728. background-color: transparent;
  729. text-align: center;
  730. cursor: pointer;
  731. transition: background-color 0.3s;
  732. }
  733. .ios-button:active {
  734. background-color: rgba(0, 122, 255, 0.1);
  735. }
  736. .email-modal-label {
  737. font-size: 18px;
  738. margin-bottom: 10px;
  739. display: block;
  740. }
  741. .email-modal-input {
  742. width: calc(100% - 20px);
  743. padding: 10px;
  744. font-size: 16px;
  745. border: 1px solid #ccc;
  746. border-radius: 5px;
  747. margin-bottom: 10px;
  748. }
  749. .email-modal .modal-content {
  750. width: 90%; /* 修改宽度 */
  751. max-width: 600px; /* 最大宽度 */
  752. height: auto; /* 自适应高度 */
  753. max-height: 80%; /* 最大高度,防止内容溢出屏幕 */
  754. overflow-y: auto; /* 添加垂直滚动条,如果内容超出 */
  755. }
  756. .add-email-button {
  757. display: block;
  758. width: 100%;
  759. padding: 10px 20px;
  760. margin-bottom: 10px;
  761. background-color: #007aff;
  762. color: white;
  763. border: none;
  764. text-align: center;
  765. font-size: 16px;
  766. cursor: pointer;
  767. border-radius: 5px;
  768. transition: background-color 0.3s;
  769. }
  770. .add-email-button:hover {
  771. background-color: #005bb5;
  772. }
  773. .action-modal-content {
  774. display: flex;
  775. flex-direction: column;
  776. align-items: flex-start;
  777. }
  778. .action-modal-content button {
  779. width: auto;
  780. padding: 10px 20px;
  781. margin: 5px 0;
  782. background-color: white;
  783. color: black;
  784. border: none;
  785. text-align: left;
  786. font-size: 16px;
  787. cursor: pointer;
  788. border-radius: 5px;
  789. transition: background-color 0.3s;
  790. }
  791. .action-modal-content button:hover {
  792. background-color: #f0f0f0;
  793. }
  794. .sort-button {
  795. background-color: transparent;
  796. border: none;
  797. color: #007aff;
  798. font-size: 16px;
  799. cursor: pointer;
  800. padding: 5px 10px;
  801. border-radius: 15px;
  802. transition: background-color 0.3s;
  803. }
  804. .sort-button:hover {
  805. background-color: rgba(0, 122, 255, 0.1);
  806. }
  807. #confirmGenerateModal .centered-modal-content {
  808. background-color: #ffffff;
  809. border: none;
  810. border-radius: 15px;
  811. padding: 20px;
  812. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  813. text-align: center;
  814. }
  815. #confirmGenerateModal .centered-modal-content button {
  816. background-color: #007aff;
  817. color: white;
  818. border: none;
  819. border-radius: 10px;
  820. padding: 10px 20px;
  821. cursor: pointer;
  822. font-size: 16px;
  823. margin: 10px;
  824. transition: all 0.3s;
  825. }
  826. #confirmGenerateModal .centered-modal-content button:hover {
  827. background-color: #005bb5;
  828. border: 1px solid #007aff;
  829. }
  830. #role-management {
  831. padding: 20px;
  832. background-color: white;
  833. border-radius: 10px;
  834. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  835. }
  836. /* 角色项的默认样式 */
  837. .role-item {
  838. background-color: white; /* 默认背景色 */
  839. box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1); /* 阴影效果 */
  840. border-radius: 10px; /* 圆角效果 */
  841. overflow: hidden; /* 确保圆角效果生效 */
  842. border: 2px solid transparent; /* 默认边框为透明 */
  843. transition: all 0.3s ease; /* 过渡效果 */
  844. margin-bottom: 20px; /* 每个角色之间的间距 */
  845. padding: 10px; /* 内边距 */
  846. }
  847. /* 置顶角色的样式 */
  848. .role-item.top-role {
  849. background-color: #d3d3d3; /* 灰色背景 */
  850. }
  851. /* 鼠标悬停时的样式 */
  852. .role-item:hover {
  853. background-color: #e6f7ff; /* 悬停时背景色 */
  854. border-color: #1169ff; /* 悬停时边框颜色 */
  855. border-width: 4px; /* 悬停时边框大小 */
  856. border-radius: 15px; /* 悬停时的圆角 */
  857. }
  858. /* 置顶角色在悬停时的样式 */
  859. .role-item.top-role:hover {
  860. background-color: #d3d3d3; /* 保持灰色背景不变 */
  861. border-color: #1169ff; /* 悬停时边框颜色 */
  862. border-width: 4px; /* 悬停时边框大小 */
  863. border-radius: 15px; /* 悬停时的圆角 */
  864. }
  865. .role-item h3 {
  866. margin-top: 0;
  867. }
  868. .role-item ul {
  869. padding-left: 20px;
  870. }
  871. .create-role-button {
  872. background-color: #007aff;
  873. color: white;
  874. border: none;
  875. padding: 10px 20px;
  876. border-radius: 10px;
  877. cursor: pointer;
  878. font-size: 16px;
  879. font-weight: 500;
  880. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  881. transition: background-color 0.3s;
  882. margin-left: 20px; /* 与标题之间的间距 */
  883. }
  884. .create-role-button:hover {
  885. background-color: #005bb5;
  886. }
  887. </style>
  888. </head>
  889. <body>
  890. <div class="sidebar" id="sidebar">
  891. <button onclick="showTable()">License 管理</button>
  892. <button onclick="showUserManagement()">用户管理</button>
  893. <button onclick="showRoleManagement()">角色管理</button>
  894. </div>
  895. <div class="content" id="content">
  896. <button class="toggle-sidebar" onclick="toggleSidebar()"></button>
  897. <header>
  898. <h1>License 管理平台</h1>
  899. <div>
  900. <!-- <button class="upload-button" onclick="window.location.href='/static/upload_xlsx/index.html'" style="display: none;">Upload File</button> --> <!-- 默认隐藏 -->
  901. <button class="user-button" onclick="toggleUserInfo()" id="username">User</button>
  902. </div>
  903. </header>
  904. <div id="table-container">
  905. <table id="applications-table">
  906. <thead>
  907. <tr>
  908. <th>创建人</th>
  909. <th>申请日期 <button class="sort-button" onclick="sortTableByDate()">排序</button></th>
  910. <th>关联项目</th>
  911. <th>销售人员</th>
  912. <th>技服人员</th>
  913. <th>总节点数</th>
  914. <th>使用单位</th>
  915. <th>产品名称</th>
  916. <th>版本</th>
  917. <th>节点数</th>
  918. <th>License状态</th>
  919. </tr>
  920. </thead>
  921. <tbody>
  922. </tbody>
  923. </table>
  924. <div class="pagination">
  925. <button id="prev-page">上一页</button>
  926. <button id="next-page">下一页</button>
  927. <select id="page-selector" class="flat-select"></select>
  928. <span id="pagination-info">第 1 页,共 0 页</span> <!-- 新增信息显示区域 -->
  929. </div>
  930. </div>
  931. <!-- License 详细信息的模态框 -->
  932. <div id="detailsModal" class="modal">
  933. <div class="modal-content">
  934. <span class="close" onclick="closeModal('detailsModal')">&times;</span>
  935. <h3>License 详细信息</h3>
  936. <div id="detailsContent"></div>
  937. <button class="close-button" onclick="closeModal('detailsModal')">关闭</button>
  938. </div>
  939. </div>
  940. <!-- 用户管理的添加用户 -->
  941. <div id="user-management" style="display: none;">
  942. <div style="display: flex; align-items: center; justify-content: space-between;">
  943. <h2>用户管理</h2>
  944. <button id="addUserButton" class="create-role-button" style="display: none;">添加用户</button> <!-- 默认隐藏 -->
  945. </div>
  946. <table id="users-table">
  947. <thead>
  948. <tr>
  949. <th>用户名</th>
  950. <th>电话</th>
  951. <th>邮箱</th>
  952. <th>权限</th>
  953. <th>账号</th>
  954. </tr>
  955. </thead>
  956. <tbody>
  957. </tbody>
  958. </table>
  959. </div>
  960. <!-- 新增的角色管理容器 -->
  961. <div id="role-management" style="display: none;">
  962. <div style="display: flex; align-items: center; justify-content: space-between;">
  963. <h2>角色管理</h2>
  964. <button id="createRoleButton" class="create-role-button">创建角色</button>
  965. </div>
  966. <div id="roles-container"></div>
  967. </div>
  968. </div>
  969. <!-- License 管理的弹出菜单 -->
  970. <div id="licenseActionModal" class="modal">
  971. <div class="modal-content action-modal-content" id="licenseActionModalContent">
  972. <span class="close" onclick="closeModal('licenseActionModal')">&times;</span>
  973. <!-- <button onclick="showExtraInfo()">查看额外信息</button>
  974. <button onclick="modifyLicenseInfo()">修改信息</button> 新增的修改信息按钮 -->
  975. <!-- <button onclick="showDistributionHistory()">分发历史</button>
  976. <button onclick="confirmDelete()">删除</button> -->
  977. </div>
  978. </div>
  979. <!-- 修改信息的表单框 -->
  980. <div id="modifyLicenseModal" class="modal">
  981. <div class="modify-license-modal-content">
  982. <span class="close" onclick="closeModal('modifyLicenseModal')">&times;</span>
  983. <h3>修改License信息</h3>
  984. <form id="modifyLicenseForm">
  985. <label for="creator">创建人:</label>
  986. <input type="text" id="creator" name="creator" required><br><br>
  987. <label for="applicationDate">申请日期:</label>
  988. <input type="date" id="applicationDate" name="applicationDate" class="form-control" required><br><br>
  989. <label for="associatedProject">关联项目:</label>
  990. <input type="text" id="associatedProject" name="associatedProject" required><br><br>
  991. <label for="salesPerson">销售人员:</label>
  992. <input type="text" id="salesPerson" name="salesPerson" required><br><br>
  993. <label for="salesEmail">销售邮箱:</label>
  994. <input type="email" id="salesEmail" name="salesEmail" required><br><br>
  995. <label for="supportPerson">技服人员:</label>
  996. <input type="text" id="supportPerson" name="supportPerson" required><br><br>
  997. <label for="supportEmail">技服邮箱:</label>
  998. <input type="email" id="supportEmail" name="supportEmail" required><br><br>
  999. <label for="totalNodes">总节点数:</label>
  1000. <input type="number" id="totalNodes" name="totalNodes" class="form-control" required><br><br>
  1001. <label for="company">使用单位:</label>
  1002. <input type="text" id="company" name="company" required><br><br>
  1003. <label for="productName">产品名称:</label>
  1004. <input type="text" id="productName" name="productName" required><br><br>
  1005. <label for="version"> 数据库版本: </label>
  1006. <input type="text" id="version" name="version" required><br><br>
  1007. <label for="nodeCount">节点数:</label>
  1008. <input type="number" id="nodeCount" name="nodeCount" class="form-control" required><br><br>
  1009. <button type="button" onclick="saveLicenseChanges()">保存</button>
  1010. </form>
  1011. </div>
  1012. </div>
  1013. <!-- 用户管理的弹出菜单 -->
  1014. <div id="userActionModal" class="modal">
  1015. <div class="modal-content action-modal-content" id="userActionModalContent">
  1016. <span class="close" onclick="closeModal('userActionModal')">&times;</span>
  1017. <button onclick="showMoreUserInfo()">更多用户信息</button>
  1018. <button onclick="showUserLicenseHistory()">查看license分发记录</button>
  1019. <button onclick="modifyUser()">修改用户</button>
  1020. </div>
  1021. </div>
  1022. <!-- 用户管理的添加用户 -->
  1023. <div id="addUserModal" class="modal">
  1024. <div class="centered-modal-content" style="height: 50vh; overflow-y: auto;">
  1025. <span class="close" onclick="closeModal('addUserModal')">&times;</span>
  1026. <h3>添加用户</h3>
  1027. <form id="addUserForm">
  1028. <div class="form-group">
  1029. <label for="addUsername">用户名:</label>
  1030. <input type="text" id="addUsername" name="username" class="flat-rounded-input" required>
  1031. </div>
  1032. <div class="form-group">
  1033. <label for="addPassword">密码:</label>
  1034. <input type="password" id="addPassword" name="password" class="flat-rounded-input" required>
  1035. </div>
  1036. <div class="form-group">
  1037. <label for="addAccount">账号:</label>
  1038. <input type="text" id="addAccount" name="account" class="flat-rounded-input" required>
  1039. </div>
  1040. <div class="form-group">
  1041. <label for="addTelephone">电话:</label>
  1042. <input type="text" id="addTelephone" name="telephone" class="flat-rounded-input" required>
  1043. </div>
  1044. <div class="form-group">
  1045. <label for="addEmail">邮箱:</label>
  1046. <input type="email" id="addEmail" name="email" class="flat-rounded-input" required>
  1047. </div>
  1048. <button type="button" onclick="saveNewUser()" class="flat-rounded-button">保存</button>
  1049. </form>
  1050. </div>
  1051. </div>
  1052. <!-- 邮箱和用户选择弹出框 -->
  1053. <div id="emailModal" class="modal">
  1054. <div class="modal-content centered-modal-content" style="height: 45vh; overflow-y: auto;">
  1055. <span class="close" onclick="closeModal('emailModal')">&times;</span>
  1056. <!-- 邮箱输入部分 -->
  1057. <label for="emailInput1" class="email-modal-label">选中要发送的邮箱:</label>
  1058. <div id="emailInputs">
  1059. <input type="text" id="emailInput1" class="email-modal-input">
  1060. </div>
  1061. <br>
  1062. <button onclick="addEmailInput()" class="add-email-button">添加邮箱</button>
  1063. <!-- 用户选择部分 -->
  1064. <label for="userSelect1" class="email-modal-label">选择要分发的用户:</label>
  1065. <div id="userInputs"></div>
  1066. <button onclick="addUserInput()" class="add-email-button">添加用户</button>
  1067. <!-- 发送按钮 -->
  1068. <button onclick="sendEmail()" class="ios-button">发送</button>
  1069. </div>
  1070. </div>
  1071. <!-- 其他模态框不变 -->
  1072. <div id="extraInfoModal" class="modal">
  1073. <div class="modal-content">
  1074. <span class="close" onclick="closeModal('extraInfoModal')">&times;</span>
  1075. <div id="extraInfoContent" class="extra-info"></div>
  1076. </div>
  1077. </div>
  1078. <div id="userModal" class="user-info">
  1079. <span class="close apple-close" onclick="closeUserInfo()">&times;</span> <!-- 关闭按钮 -->
  1080. <div id="userInfoContent"></div>
  1081. <br>
  1082. <button class="apple-logout-button" onclick="logout()">退出</button>
  1083. </div>
  1084. <!-- license删除模态框-->
  1085. <div id="confirmDeleteModal" class="modal">
  1086. <div class="centered-modal-content">
  1087. <span class="close" onclick="closeModal('confirmDeleteModal')">&times;</span>
  1088. </div>
  1089. </div>
  1090. <div id="confirmGenerateModal" class="modal">
  1091. <div class="centered-modal-content" style="height: 15vh; overflow-y: auto;">
  1092. <span class="close" onclick="closeModal('confirmGenerateModal')">&times;</span>
  1093. <p>确认生成License吗?</p>
  1094. <button id="confirm-generate-button">确认</button>
  1095. <button onclick="closeModal('confirmGenerateModal')">取消</button>
  1096. </div>
  1097. </div>
  1098. <div id="distributionHistoryModal" class="modal">
  1099. <div class="centered-modal-content">
  1100. <span class="close" onclick="closeModal('distributionHistoryModal')">&times;</span>
  1101. <h3>分发历史</h3>
  1102. <div id="distributionHistoryContent" class="extra-info"></div>
  1103. </div>
  1104. </div>
  1105. <script>
  1106. let currentPage = 1;
  1107. let pageSize = 10;
  1108. let LisOffset = 1;
  1109. let totalPages = 0; // 存储总页数
  1110. let selectedPage =1;
  1111. let nextPage =1;
  1112. let prevPage = 10;
  1113. const token = localStorage.getItem('Authorization');
  1114. let selectedRowData = null;
  1115. let isAscending = true;
  1116. let userMap = {}; // 用于存储用户名和用户ID的映射
  1117. let currentUserRole = ''; // 新增变量存储当前用户的权限
  1118. let currentUserName = ''; // 新增变量存储当前用户的名字
  1119. let userPermissions = [];// 全局变量,用于存储用户权限
  1120. let LicApplicationData = []; // 全局变量存储数据
  1121. let currentRolePermissions = []; // 这是您获取的当前角色的权限列表
  1122. function checkPermission(permission) {
  1123. console.log(`检查权限: ${permission} - ${hasPermission ? '有权限' : '无权限'}`);
  1124. return userPermissions.includes(permission);
  1125. }
  1126. //获取license展示信息
  1127. function fetchApplications(page, size) {
  1128. fetch(`http://127.0.0.1:8080/api/admin/GetAllLicenseInfo?page=${page}&pageSize=${size}`, {
  1129. method: 'GET',
  1130. headers: {
  1131. 'Authorization': `Bearer ${token}`,
  1132. 'Content-Type': 'application/json'
  1133. }
  1134. })
  1135. .then(response => response.json())
  1136. .then(data => {
  1137. LicApplicationData = data.data; // 将接收到的数据存储到全局变量
  1138. console.log(data); // 输出获取的数据结构
  1139. const hasGeneratePermission = userPermissions.includes("generate_license");
  1140. const hasDistributePermission = userPermissions.includes("dispat_license");
  1141. // 更新总页数
  1142. //totalPages = Math.ceil(data.total / 10);
  1143. // 在控制台打印权限结果
  1144. console.log(`hasGeneratePermission: ${hasGeneratePermission}, hasDistributePermission: ${hasDistributePermission}`);
  1145. totalPages = Math.ceil(data.total / 10);
  1146. const tableBody = document.querySelector('#applications-table tbody');
  1147. const tableHead = document.querySelector('#applications-table thead tr');
  1148. tableBody.innerHTML = '';
  1149. tableHead.innerHTML = `
  1150. <th></th> <!-- 添加一个空的表头用于放置下拉按钮 -->
  1151. <th>创建人</th>
  1152. <th>申请日期 <button class="sort-button" onclick="sortTableByDate()">排序</button></th>
  1153. <th>关联项目</th>
  1154. <th>销售人员</th>
  1155. <th>技服人员</th>
  1156. <th>总节点数</th>
  1157. <th>使用单位</th>
  1158. <th>操作</th> <!-- 新增的表头用于显示操作按钮 -->
  1159. `;
  1160. data.data.forEach(applicationArray => {
  1161. const firstApplication = applicationArray[0];
  1162. let showGenerateButton = false;
  1163. // Check if any child row has LicenseFlage as "未生成"
  1164. applicationArray.forEach(detail => {
  1165. if (detail.LicenseFlage === "未生成") {
  1166. showGenerateButton = true;
  1167. }
  1168. });
  1169. // 创建主行
  1170. const row = document.createElement('tr');
  1171. const dropdownButton = document.createElement('button');
  1172. // 使用CSS创建一个箭头图标
  1173. dropdownButton.innerHTML = '';
  1174. dropdownButton.classList.add('arrow-icon');
  1175. dropdownButton.style.cursor = 'pointer';
  1176. row.innerHTML = `
  1177. <td></td> <!-- 空的单元格用于放置下拉按钮 -->
  1178. <td>${createEllipsisText(firstApplication.Creator)}</td>
  1179. <td>${createEllipsisText(firstApplication.ApplicationDate)}</td>
  1180. <td>${createEllipsisText(firstApplication.GlxmName)}</td>
  1181. <td>${createEllipsisText(firstApplication.SalesPerson)}</td>
  1182. <td>${createEllipsisText(firstApplication.SupportPerson)}</td>
  1183. <td>${firstApplication.TotalNodes}</td>
  1184. <td>${createEllipsisText(firstApplication.Company)}</td>
  1185. `;
  1186. row.querySelector('td').appendChild(dropdownButton);
  1187. // 添加 License 状态按钮 (父级行)
  1188. if (hasGeneratePermission || hasDistributePermission) {
  1189. const licenseStatusCell = document.createElement('td');
  1190. if (hasGeneratePermission && showGenerateButton) {
  1191. licenseStatusCell.innerHTML += `<button class="license-status-btn generate" onclick="confirmGenerateLicense('${firstApplication.oa_request_id}', true)">生成</button>`;
  1192. } else if (hasDistributePermission && firstApplication.LicenseFlage === "已生成") {
  1193. licenseStatusCell.innerHTML += `<button class="license-status-btn distribute" onclick="showEmailModal('${firstApplication.SupportEmail}', '${firstApplication.SalesEmail}', '${firstApplication.UniqueID}')">分发</button>`;
  1194. }
  1195. // 添加一个分隔符
  1196. licenseStatusCell.innerHTML += `<span style="margin: 0 10px; display: inline-block; width: 1px; height: 20px; background-color: #ccc;"></span>`;
  1197. // 在这里添加“查看详情”按钮
  1198. licenseStatusCell.innerHTML += `<button class="license-status-btn view-details" onclick="showDetailsModal('${firstApplication.UniqueID}')">查看详情</button>`;
  1199. row.appendChild(licenseStatusCell);
  1200. }
  1201. tableBody.appendChild(row);
  1202. // 多行内容及表头 (子行)
  1203. const detailRow = document.createElement('tr');
  1204. const detailCell = document.createElement('td');
  1205. detailCell.colSpan = 11; // 占满所有列
  1206. detailCell.style.display = 'none';
  1207. const detailTable = document.createElement('table');
  1208. // 添加表头
  1209. const detailTableHeader = document.createElement('tr');
  1210. detailTableHeader.innerHTML = `
  1211. <th>产品名称</th>
  1212. <th>版本</th>
  1213. <th>节点数</th>
  1214. <th>处理器</th>
  1215. <th>操作系统</th>
  1216. <th>主MAC地址</th>
  1217. <th>副MAC地址</th>
  1218. <th> 查看</th>
  1219. `;
  1220. detailTable.appendChild(detailTableHeader);
  1221. // 添加详细信息行 (子行)
  1222. applicationArray.forEach(detail => {
  1223. const detailInnerRow = document.createElement('tr');
  1224. detailInnerRow.innerHTML = `
  1225. <td>${createEllipsisText(detail.ProductName)}</td>
  1226. <td>${createEllipsisText(detail.ProductVersion)}</td>
  1227. <td>${detail.NodeCount}</td>
  1228. <td>${createEllipsisText(detail.oa_cpu)}</td>
  1229. <td>${createEllipsisText(detail.oa_operating_system)}</td>
  1230. <td>${createEllipsisText(detail.oa_main_mac)}</td>
  1231. <td>${createEllipsisText(detail.oa_second_mac)}</td>
  1232. `;
  1233. // 添加 License 状态按钮 (子行)
  1234. // if (hasGeneratePermission || hasDistributePermission) {
  1235. // const licenseStatusDetailCell = document.createElement('td');
  1236. // if (hasGeneratePermission && detail.LicenseFlage === "未生成") {
  1237. // // 子行点击生成按钮时,传递 UniqueID 和 false 表示这是子行
  1238. // licenseStatusDetailCell.innerHTML = `<button class="license-status-btn generate" onclick="confirmGenerateLicense('${detail.UniqueID}', false)">生成</button>`;
  1239. // } else if (hasDistributePermission && detail.LicenseFlage === "已生成") {
  1240. // // 子行点击分发按钮时,传递 UniqueID 用于分发操作
  1241. // licenseStatusDetailCell.innerHTML = `<button class="license-status-btn distribute" onclick="showEmailModal('${detail.SupportEmail}', '${detail.SalesEmail}', '${detail.UniqueID}')">分发</button>`;
  1242. // }
  1243. // detailInnerRow.appendChild(licenseStatusDetailCell);
  1244. // }
  1245. detailTable.appendChild(detailInnerRow);
  1246. // 添加“查看详情”按钮 (子行)
  1247. const viewDetailsCell = document.createElement('td');
  1248. viewDetailsCell.innerHTML = `<button class="license-status-btn view-details" onclick="showDetailsModal('${detail.UniqueID}', true)">查看详情</button>`;
  1249. detailInnerRow.appendChild(viewDetailsCell);
  1250. detailTable.appendChild(detailInnerRow);
  1251. // 为每个详细信息行添加点击事件 (子行)
  1252. detailInnerRow.addEventListener('click', (event) => {
  1253. if (!event.target.closest('button')) {
  1254. openActionModal(event, detail, 'licenseActionModal');
  1255. }
  1256. });
  1257. detailInnerRow.addEventListener('contextmenu', (event) => {
  1258. event.preventDefault();
  1259. if (!event.target.closest('button')) {
  1260. openActionModal(event, detail, 'licenseActionModal');
  1261. }
  1262. });
  1263. });
  1264. detailCell.appendChild(detailTable);
  1265. detailRow.appendChild(detailCell);
  1266. tableBody.appendChild(detailRow);
  1267. // 主行的点击事件,用于切换下拉菜单的显示隐藏
  1268. // row.addEventListener('click', (event) => {
  1269. // if (!event.target.closest('button')) { // 如果点击的不是按钮
  1270. // detailCell.style.display = detailCell.style.display === 'none' ? 'table-cell' : 'none';
  1271. // }
  1272. // });
  1273. // // 点击下拉按钮切换显示隐藏
  1274. // dropdownButton.addEventListener('click', (event) => {
  1275. // event.stopPropagation(); // 阻止事件冒泡到行点击事件
  1276. // detailCell.style.display = detailCell.style.display === 'none' ? 'table-cell' : 'none';
  1277. // });
  1278. row.addEventListener('click', (event) => {
  1279. if (!event.target.closest('button')) { // 如果点击的不是按钮
  1280. // const isExpanded = detailCell.style.display === 'table-cell';
  1281. // detailCell.style.display = isExpanded ? 'none' : 'table-cell';
  1282. // row.classList.toggle('expanded-row', !isExpanded);
  1283. // dropdownButton.classList.toggle('rotate-arrow', !isExpanded); // 旋转箭头图标
  1284. if (!event.target.closest('button')) {
  1285. const isExpanded = detailCell.style.display === 'table-cell';
  1286. // 收回其他行
  1287. closeAllExpandedRows();
  1288. // 展开/收起当前行
  1289. detailCell.style.display = isExpanded ? 'none' : 'table-cell';
  1290. row.classList.toggle('expanded-row', !isExpanded);
  1291. dropdownButton.classList.toggle('rotate-arrow', !isExpanded);
  1292. }
  1293. }
  1294. });
  1295. dropdownButton.addEventListener('click', (event) => {
  1296. // event.stopPropagation(); // 阻止事件冒泡到行点击事件
  1297. // const isExpanded = detailCell.style.display === 'table-cell';
  1298. // detailCell.style.display = isExpanded ? 'none' : 'table-cell';
  1299. // row.classList.toggle('expanded-row', !isExpanded);
  1300. // dropdownButton.classList.toggle('rotate-arrow', !isExpanded); // 旋转箭头图标
  1301. event.stopPropagation(); // 阻止事件冒泡到行点击事件
  1302. const isExpanded = detailCell.style.display === 'table-cell';
  1303. // 收回其他行
  1304. closeAllExpandedRows();
  1305. // 展开/收起当前行
  1306. detailCell.style.display = isExpanded ? 'none' : 'table-cell';
  1307. row.classList.toggle('expanded-row', !isExpanded);
  1308. dropdownButton.classList.toggle('rotate-arrow', !isExpanded);
  1309. });
  1310. });
  1311. // 分页和其他控制逻辑
  1312. // 更新分页信息
  1313. // totalPages = Math.ceil(data.total / pageSize);
  1314. document.getElementById('pagination-info').textContent = `第 ${currentPage} 页,共 ${totalPages} 页`;
  1315. document.getElementById('prev-page').disabled = currentPage <= 1;
  1316. document.getElementById('next-page').disabled = currentPage >= totalPages;
  1317. const pageSelector = document.getElementById('page-selector');
  1318. pageSelector.innerHTML = '';
  1319. for (let i = 1; i <= totalPages; i++) {
  1320. const option = document.createElement('option');
  1321. option.value = i;
  1322. option.text = i;
  1323. if (i === selectedPage) {
  1324. option.selected = true;
  1325. document.getElementById('pagination-info').textContent = `第 ${selectedPage} 页,共 ${totalPages} 页`;
  1326. // LisOffset = selectedPage
  1327. // pageSize = LisOffset + 10;
  1328. // document.getElementById('prev-page').disabled = currentPage <= 1;
  1329. // document.getElementById('next-page').disabled = currentPage >= totalPages;
  1330. }
  1331. pageSelector.appendChild(option);
  1332. }
  1333. });
  1334. }
  1335. // 添加页数选择框的事件监听器
  1336. document.getElementById('page-selector').addEventListener('change', (event) => {
  1337. selectedPage = parseInt(event.target.value, 10);
  1338. const startRecord = (selectedPage - 1) * 10 + 1;
  1339. const endRecord = startRecord + 10;
  1340. LisOffset = selectedPage
  1341. pageSize = LisOffset* 10;
  1342. currentPage = selectedPage
  1343. fetchApplications(startRecord, endRecord);
  1344. });
  1345. // 分页按钮事件监听器
  1346. document.getElementById('prev-page').addEventListener('click', () => {
  1347. if (currentPage > 1) {
  1348. currentPage--;
  1349. selectedPage--
  1350. currentOffset -= itemsPerPage;
  1351. const startOffset = currentOffset;
  1352. const endOffset = currentOffset + itemsPerPage - 1;
  1353. fetchApplications(startOffset, endOffset);
  1354. }
  1355. });
  1356. let currentOffset = 1;
  1357. const itemsPerPage = 10;
  1358. document.getElementById('next-page').addEventListener('click', () => {
  1359. if (currentPage < totalPages) {
  1360. currentPage++
  1361. selectedPage++
  1362. LisOffset += pageSize-LisOffset;
  1363. pageSize += 10; // 增加页数时,增加 pageSize,规则可自定义
  1364. currentOffset += itemsPerPage;
  1365. const startOffset = currentOffset;
  1366. const endOffset = currentOffset + itemsPerPage - 1;
  1367. fetchApplications(startOffset, endOffset);
  1368. }
  1369. });
  1370. // 页面加载时默认调用第一页的数据
  1371. //fetchApplications(1);
  1372. // 页面初始化时调用 fetchUsername 函数
  1373. fetchUsername();
  1374. fetchApplications(LisOffset,pageSize);
  1375. //排序
  1376. // function sortTableByDate() {
  1377. // applicationData.sort((a, b) => {
  1378. // const dateTimeA = `${a[0].ApplicationDate} ${a[0].ApplicationTime}`;
  1379. // const dateTimeB = `${b[0].ApplicationDate} ${b[0].ApplicationTime}`;
  1380. // return isAscending ? dateTimeA.localeCompare(dateTimeB) : dateTimeB.localeCompare(dateTimeA);
  1381. // });
  1382. // renderTable(applicationData); // 排序后重新渲染表格
  1383. // isAscending = !isAscending; // 切换排序顺序
  1384. // }
  1385. // 关闭所有已经展开的行
  1386. function closeAllExpandedRows() {
  1387. const allExpandedRows = document.querySelectorAll('.expanded-row');
  1388. allExpandedRows.forEach(expandedRow => {
  1389. const detailCell = expandedRow.nextElementSibling.querySelector('td');
  1390. if (detailCell && detailCell.style.display === 'table-cell') {
  1391. detailCell.style.display = 'none';
  1392. expandedRow.classList.remove('expanded-row');
  1393. const dropdownButton = expandedRow.querySelector('.arrow-icon');
  1394. if (dropdownButton) {
  1395. dropdownButton.classList.remove('rotate-arrow');
  1396. }
  1397. }
  1398. });
  1399. }
  1400. // 创建带省略号的文本,并在鼠标悬停时显示完整内容
  1401. function createEllipsisText(text) {
  1402. const maxLength = 20; // 最大显示字符数
  1403. if (text == null || typeof text !== 'string') {
  1404. return ''; // 如果 text 是 null、undefined 或不是字符串,返回空字符串
  1405. }
  1406. if (text.length > maxLength) {
  1407. const span = document.createElement('span');
  1408. span.textContent = text.substring(0, maxLength) + '...';
  1409. span.title = text; // 鼠标悬停时显示完整内容
  1410. return span.outerHTML;
  1411. }
  1412. return text;
  1413. }
  1414. //生成licensestr
  1415. function confirmGenerateLicense(id, isParentRow) {
  1416. const confirmGenerateModal = document.getElementById('confirmGenerateModal');
  1417. confirmGenerateModal.style.display = 'block';
  1418. document.getElementById('confirm-generate-button').onclick = function() {
  1419. generateLicense(id, isParentRow);
  1420. };
  1421. }
  1422. function generateLicense(id, isParentRow) {
  1423. const payload = isParentRow ? { oa_request_id: id } : { uniqueID: id };
  1424. fetch('http://127.0.0.1:8080/api/admin/GenerateLicense', {
  1425. method: 'POST',
  1426. headers: {
  1427. 'Authorization': `Bearer ${token}`,
  1428. 'Content-Type': 'application/json'
  1429. },
  1430. body: JSON.stringify(payload)
  1431. })
  1432. .then(response => response.json())
  1433. .then(data => {
  1434. if (data.success) {
  1435. alert('License生成成功!');
  1436. fetchApplications(LisOffset, pageSize);
  1437. } else {
  1438. alert('License生成失败:' + data.error);
  1439. }
  1440. closeModal('confirmGenerateModal');
  1441. });
  1442. }
  1443. //查看lic所有信息
  1444. function showDetailsModal(uniqueID, isChildRow = false) {
  1445. let selectedData = null;
  1446. if (isChildRow) {
  1447. // 查找子行数据
  1448. for (let applicationArray of LicApplicationData) {
  1449. selectedData = applicationArray.find(data => data.UniqueID === uniqueID);
  1450. if (selectedData) {
  1451. break;
  1452. }
  1453. }
  1454. if (!selectedData) {
  1455. console.error('未找到对应的子行记录,UniqueID:', uniqueID);
  1456. alert('未找到对应的子行记录,请检查数据');
  1457. return;
  1458. }
  1459. // 准备在模态框中显示的子行内容
  1460. let detailsHtml = `<div class="apple-modal-content">`;
  1461. detailsHtml += `<h3 class="apple-modal-title">详细信息</h3>`;
  1462. detailsHtml += `
  1463. <p class="apple-modal-text"><strong>产品名称:</strong> ${selectedData.ProductName}</p>
  1464. <p class="apple-modal-text"><strong>版本:</strong> ${selectedData.ProductVersion}</p>
  1465. <p class="apple-modal-text"><strong>节点数:</strong> ${selectedData.NodeCount}</p>
  1466. <p class="apple-modal-text"><strong>处理器:</strong> ${selectedData.oa_cpu}</p>
  1467. <p class="apple-modal-text"><strong>操作系统:</strong> ${selectedData.oa_operating_system}</p>
  1468. <p class="apple-modal-text"><strong>主MAC地址:</strong> ${selectedData.oa_main_mac}</p>
  1469. <p class="apple-modal-text"><strong>副MAC地址:</strong> ${selectedData.oa_second_mac}</p>
  1470. `;
  1471. detailsHtml += `</div>`;
  1472. // 显示模态框
  1473. document.getElementById('detailsContent').innerHTML = detailsHtml;
  1474. document.getElementById('detailsModal').style.display = 'block';
  1475. } else {
  1476. // 查找主行数据
  1477. let selectedApplicationArray = null;
  1478. for (let applicationArray of LicApplicationData) {
  1479. if (applicationArray.some(data => data.UniqueID === uniqueID)) {
  1480. selectedApplicationArray = applicationArray;
  1481. break;
  1482. }
  1483. }
  1484. if (!selectedApplicationArray) {
  1485. console.error('未找到对应的记录,UniqueID:', uniqueID);
  1486. alert('未找到对应的记录,请检查数据');
  1487. return;
  1488. }
  1489. // 准备在模态框中显示的主行和子行的全部内容
  1490. let detailsHtml = `<div class="apple-modal-content">`;
  1491. detailsHtml += `<h3 class="apple-modal-title">项目信息</h3>`;
  1492. // 显示主行的第一条记录信息
  1493. const firstData = selectedApplicationArray[0];
  1494. detailsHtml += `
  1495. <p class="apple-modal-text"><strong>创建人:</strong> ${firstData.Creator}</p>
  1496. <p class="apple-modal-text"><strong>申请日期:</strong> ${firstData.ApplicationDate}</p>
  1497. <p class="apple-modal-text"><strong>关联项目:</strong> ${firstData.GlxmName}</p>
  1498. <p class="apple-modal-text"><strong>销售人员:</strong> ${firstData.SalesPerson}</p>
  1499. <p class="apple-modal-text"><strong>技服人员:</strong> ${firstData.SupportPerson}</p>
  1500. <p class="apple-modal-text"><strong>总节点数:</strong> ${firstData.TotalNodes}</p>
  1501. <p class="apple-modal-text"><strong>使用单位:</strong> ${firstData.Company}</p>
  1502. `;
  1503. // 显示子行的每条记录信息
  1504. detailsHtml += `<h3 class="apple-modal-title">集群信息</h3>`;
  1505. selectedApplicationArray.forEach((data, index) => {
  1506. detailsHtml += `
  1507. <h4 class="apple-modal-subtitle">集群 ${index + 1}</h4>
  1508. <p class="apple-modal-text"><strong>产品名称:</strong> ${data.ProductName}</p>
  1509. <p class="apple-modal-text"><strong>版本:</strong> ${data.ProductVersion}</p>
  1510. <p class="apple-modal-text"><strong>节点数:</strong> ${data.NodeCount}</p>
  1511. <p class="apple-modal-text"><strong>处理器:</strong> ${data.oa_cpu}</p>
  1512. <p class="apple-modal-text"><strong>操作系统:</strong> ${data.oa_operating_system}</p>
  1513. <p class="apple-modal-text"><strong>主MAC地址:</strong> ${data.oa_main_mac}</p>
  1514. <p class="apple-modal-text"><strong>副MAC地址:</strong> ${data.oa_second_mac}</p>
  1515. <h4 class="apple-modal-subtitle"> -------------------------------</h4>
  1516. `;
  1517. });
  1518. detailsHtml += `</div>`;
  1519. // 显示模态框
  1520. document.getElementById('detailsContent').innerHTML = detailsHtml;
  1521. document.getElementById('detailsModal').style.display = 'block';
  1522. }
  1523. }
  1524. // 用户管理菜单栏
  1525. function openUserActionModal(event, data, modalId) {
  1526. selectedRowData = data;
  1527. let modal = document.getElementById(modalId);
  1528. const modalContent = modal.querySelector('.modal-content');
  1529. // 清空之前的内容
  1530. modalContent.innerHTML = `
  1531. <span class="close" onclick="closeModal('${modalId}')">&times;</span>
  1532. `;
  1533. // 动态生成更多用户信息按钮
  1534. if (userPermissions.includes('read_user')) {
  1535. modalContent.innerHTML += `<button onclick="showMoreUserInfo(); closeModal('${modalId}');">更多用户信息</button>`;
  1536. }
  1537. // 检查是否有 `update_user` 权限,决定是否显示修改用户按钮
  1538. if (userPermissions.includes('update_user')) {
  1539. modalContent.innerHTML += `<button onclick="modifyUser(); closeModal('${modalId}');">修改用户</button>`;
  1540. }
  1541. // 检查是否有 `delete_user` 权限,决定是否显示删除按钮
  1542. if (userPermissions.includes('delete_user')) {
  1543. modalContent.innerHTML += `<button onclick="confirmDeleteUser('${data.UniqueID}'); closeModal('${modalId}');">删除用户</button>`;
  1544. }
  1545. // 显示菜单位置
  1546. modalContent.style.top = `${event.clientY}px`;
  1547. modalContent.style.left = `${event.clientX}px`;
  1548. modal.style.display = 'block';
  1549. }
  1550. // 为用户管理界面的每一行添加点击和右键事件监听器
  1551. function fetchUsers() {
  1552. fetch('http://127.0.0.1:8080/api/admin/userInfoAll', {
  1553. method: 'GET',
  1554. headers: {
  1555. 'Authorization': `Bearer ${token}`,
  1556. 'Content-Type': 'application/json'
  1557. }
  1558. })
  1559. .then(response => response.json())
  1560. .then(data => {
  1561. const tableBody = document.querySelector('#users-table tbody');
  1562. tableBody.innerHTML = '';
  1563. data.data.forEach(user => {
  1564. // 如果 ACCOUNT 字段为 'admin',则跳过这一行
  1565. if (user.Account === 'admin') {
  1566. return;
  1567. }
  1568. const row = document.createElement('tr');
  1569. row.innerHTML = `
  1570. <td>${user.Username}</td>
  1571. <td>${user.Telephone}</td>
  1572. <td>${user.Email}</td>
  1573. <td>${user.Role}</td>
  1574. <td>${user.Account}</td>
  1575. `;
  1576. row.addEventListener('click', (event) => {
  1577. if (!event.target.classList.contains('ios-button')) {
  1578. openUserActionModal(event, user, 'userActionModal');
  1579. }
  1580. });
  1581. row.addEventListener('contextmenu', (event) => {
  1582. event.preventDefault();
  1583. if (!event.target.classList.contains('ios-button')) {
  1584. openUserActionModal(event, user, 'userActionModal');
  1585. }
  1586. });
  1587. tableBody.appendChild(row);
  1588. });
  1589. });
  1590. }
  1591. //查看用户lic历史
  1592. function showUserLicenseHistory() {
  1593. fetch(`http://127.0.0.1:8080/api/admin/GetlicenseRecordInfoByUser`, {
  1594. method: 'POST',
  1595. headers: {
  1596. 'Authorization': `Bearer ${token}`,
  1597. 'Content-Type': 'application/json'
  1598. },
  1599. body: JSON.stringify({
  1600. Id: selectedRowData.Id,
  1601. UserName: selectedRowData.Username,
  1602. Page: 1,
  1603. PageSize: 10
  1604. })
  1605. })
  1606. .then(response => response.json())
  1607. .then(data => {
  1608. const extraInfoContent = document.getElementById('extraInfoContent');
  1609. extraInfoContent.innerHTML = `<h3>License 分发记录</h3>`;
  1610. if (data.data && data.data.length > 0) {
  1611. const table = document.createElement('table');
  1612. table.style.width = '100%';
  1613. table.style.borderCollapse = 'collapse';
  1614. table.style.marginTop = '10px';
  1615. const thead = document.createElement('thead');
  1616. const headerRow = document.createElement('tr');
  1617. const headers = ['分发日期', '关联项目', '产品名称', '版本', '节点数', 'Company'];
  1618. headers.forEach(headerText => {
  1619. const th = document.createElement('th');
  1620. th.textContent = headerText;
  1621. th.style.border = '1px solid #ddd';
  1622. th.style.padding = '8px';
  1623. th.style.backgroundColor = '#f1f1f1';
  1624. headerRow.appendChild(th);
  1625. });
  1626. thead.appendChild(headerRow);
  1627. table.appendChild(thead);
  1628. const tbody = document.createElement('tbody');
  1629. data.data.forEach(record => {
  1630. const row = document.createElement('tr');
  1631. const cells = [
  1632. record.up_time.Time,
  1633. record.AssociatedProject,
  1634. record.ProductName,
  1635. record.Version,
  1636. record.NodeCount,
  1637. record.Company
  1638. ];
  1639. cells.forEach(cellText => {
  1640. const td = document.createElement('td');
  1641. td.textContent = cellText;
  1642. td.style.border = '1px solid #ddd';
  1643. td.style.padding = '8px';
  1644. row.appendChild(td);
  1645. });
  1646. tbody.appendChild(row);
  1647. });
  1648. table.appendChild(tbody);
  1649. extraInfoContent.appendChild(table);
  1650. } else {
  1651. extraInfoContent.innerHTML += `<p>没有找到分发记录。</p>`;
  1652. }
  1653. document.getElementById('extraInfoModal').style.display = 'block';
  1654. });
  1655. }
  1656. //用户菜单栏
  1657. function openActionModal(event, data, modalId) {
  1658. selectedRowData = data;
  1659. let modal = document.getElementById(modalId);
  1660. const modalContent = modal.querySelector('.modal-content');
  1661. // 清空之前的内容
  1662. modalContent.innerHTML = `
  1663. <span class="close" onclick="closeModal('${modalId}')">&times;</span>
  1664. `;
  1665. // 动态生成查看分发记录
  1666. if (userPermissions.includes('read_license_record')) {
  1667. modalContent.innerHTML += `
  1668. <button onclick="showDistributionHistory(); closeModal('${modalId}');">查看分发记录</button>
  1669. `;
  1670. }
  1671. // 动态生成查看额外信息
  1672. if (userPermissions.includes('read_license')) {
  1673. modalContent.innerHTML += `
  1674. <button onclick="showExtraInfo(); closeModal('${modalId}');">查看额外信息</button>
  1675. `;
  1676. }
  1677. // 检查是否有 `update_license` 权限,决定是否显示修改信息按钮
  1678. if (userPermissions.includes('update_license')) {
  1679. modalContent.innerHTML += `<button onclick="modifyLicenseInfo(); closeModal('${modalId}');">修改信息</button>`;
  1680. }
  1681. // 检查是否有 `delete_license` 权限,决定是否显示删除按钮
  1682. if (userPermissions.includes('delete_license')) {
  1683. modalContent.innerHTML += `<button onclick="confirmDelete(); closeModal('${modalId}');">删除</button>`;
  1684. }
  1685. // 显示菜单位置
  1686. modalContent.style.top = `${event.clientY}px`;
  1687. modalContent.style.left = `${event.clientX}px`;
  1688. modal.style.display = 'block';
  1689. }
  1690. function closeModal(modalId) {
  1691. document.getElementById(modalId).style.display = 'none';
  1692. }
  1693. function closeUserInfo() {
  1694. document.getElementById('userModal').style.display = 'none';
  1695. }
  1696. function confirmDelete() {
  1697. const confirmDeleteModal = document.getElementById('confirmDeleteModal');
  1698. confirmDeleteModal.innerHTML = `
  1699. <div class="centered-modal-content">
  1700. <span class="close" onclick="closeModal('confirmDeleteModal')" style="font-size: 24px; font-weight: bold; color: #555; cursor: pointer;">&times;</span>
  1701. <div style="margin-bottom: 15px; border: 1px solid #ddd; padding: 10px; border-radius: 10px;">
  1702. <p><strong>申请日期:</strong> ${selectedRowData.ApplicationDate}</p>
  1703. <p><strong>关联项目:</strong> ${selectedRowData.AssociatedProject}</p>
  1704. <p><strong>使用单位:</strong> ${selectedRowData.Company}</p>
  1705. </div>
  1706. <p>确认删除此行数据吗?</p>
  1707. <button class="flat-rounded-button" onclick="deleteRow()">确认</button>
  1708. <button class="flat-rounded-button" onclick="closeModal('confirmDeleteModal')">取消</button>
  1709. </div>
  1710. `;
  1711. confirmDeleteModal.style.display = 'block';
  1712. }
  1713. //添加用户
  1714. document.getElementById('addUserButton').addEventListener('click', function() {
  1715. document.getElementById('addUserModal').style.display = 'block';
  1716. });
  1717. //添加用户
  1718. function saveNewUser() {
  1719. const username = document.getElementById('addUsername').value.trim();
  1720. const password = document.getElementById('addPassword').value.trim();
  1721. const account = document.getElementById('addAccount').value.trim();
  1722. const telephone = document.getElementById('addTelephone').value.trim();
  1723. const email = document.getElementById('addEmail').value.trim();
  1724. // 验证每个字段都不能为空
  1725. if (!username || !password || !account || !telephone || !email) {
  1726. alert('有空选项未填写');
  1727. return;
  1728. }
  1729. // 验证电话是否为11位数字
  1730. const phonePattern = /^\d{11}$/;
  1731. if (!phonePattern.test(telephone)) {
  1732. alert('电话必须是11位数字');
  1733. return;
  1734. }
  1735. // 验证密码长度是否至少为6位
  1736. if (password.length < 6) {
  1737. alert('密码长度必须至少为6位');
  1738. return;
  1739. }
  1740. // 验证邮箱是否包含@符号
  1741. if (!email.includes('@')) {
  1742. alert('邮箱必须包含@符号');
  1743. return;
  1744. }
  1745. // 验证账号长度是否至少为3位
  1746. if (account.length < 3) {
  1747. alert('账号长度必须至少为3位');
  1748. return;
  1749. }
  1750. const newUser = {
  1751. Username: username,
  1752. Password: password,
  1753. Account: account,
  1754. Telephone: telephone,
  1755. Email: email
  1756. };
  1757. fetch('http://127.0.0.1:8080/api/register', { // 修改为实际的API路径
  1758. method: 'POST',
  1759. headers: {
  1760. 'Authorization': `Bearer ${token}`,
  1761. 'Content-Type': 'application/json'
  1762. },
  1763. body: JSON.stringify(newUser)
  1764. })
  1765. .then(response => response.json())
  1766. .then(data => {
  1767. if (data.success) {
  1768. alert('用户创建成功!');
  1769. fetchUsers(); // 重新加载用户列表
  1770. closeModal('addUserModal'); // 关闭模态框
  1771. } else {
  1772. alert('用户创建失败:' + data.error);
  1773. }
  1774. });
  1775. }
  1776. function deleteUser(uniqueID) {
  1777. fetch('http://127.0.0.1:8080/api/admin/deleteUser', {
  1778. method: 'POST',
  1779. headers: {
  1780. 'Authorization': `Bearer ${token}`,
  1781. 'Content-Type': 'application/json'
  1782. },
  1783. body: JSON.stringify({ UniqueID: uniqueID })
  1784. })
  1785. .then(response => response.json())
  1786. .then(data => {
  1787. if (data.success) {
  1788. alert('用户删除成功!');
  1789. fetchUsers(); // 重新加载用户列表
  1790. } else {
  1791. alert('用户删除失败:' + data.error);
  1792. }
  1793. })
  1794. .catch(error => {
  1795. console.error('Error deleting user:', error);
  1796. alert('删除用户时发生错误,请稍后再试。');
  1797. });
  1798. }
  1799. function confirmDeleteUser(uniqueID) {
  1800. const confirmed = confirm("确认删除此用户吗?");
  1801. if (confirmed) {
  1802. deleteUser(uniqueID);
  1803. }
  1804. }
  1805. function deleteRow() {
  1806. fetch(`http://127.0.0.1:8080/api/admin/deleteLicRow`, {
  1807. method: 'POST',
  1808. headers: {
  1809. 'Authorization': `Bearer ${token}`,
  1810. 'Content-Type': 'application/json'
  1811. },
  1812. body: JSON.stringify({ uniqueID: selectedRowData.UniqueID })
  1813. }).then(response => {
  1814. if (response.ok) {
  1815. alert('删除成功');
  1816. closeModal('confirmDeleteModal');
  1817. fetchApplications(LisOffset, pageSize);
  1818. } else {
  1819. alert('删除失败');
  1820. }
  1821. });
  1822. }
  1823. function showEmailModal(supportEmail, salesEmail, uniqueID) {
  1824. // 清空并设置默认值
  1825. document.getElementById('emailInputs').innerHTML = `
  1826. <div>
  1827. <input type="checkbox" id="supportEmailCheckbox" value="${supportEmail}" checked>
  1828. <label for="supportEmailCheckbox"> 运维邮箱: ${supportEmail}</label>
  1829. </div>
  1830. <div>
  1831. <input type="checkbox" id="salesEmailCheckbox" value="${salesEmail}" checked>
  1832. <label for="salesEmailCheckbox"> 销售邮箱: ${salesEmail}</label>
  1833. </div>
  1834. `;
  1835. document.getElementById('userInputs').innerHTML = ''; // 清空用户输入
  1836. // 获取用户信息并填充第一个用户输入框
  1837. fetch('http://127.0.0.1:8080/api/admin/distributeLicenseByUserInfo', {
  1838. method: 'GET',
  1839. headers: {
  1840. 'Authorization': `Bearer ${token}`,
  1841. 'Content-Type': 'application/json'
  1842. }
  1843. })
  1844. .then(response => response.json())
  1845. .then(data => {
  1846. const userSelect = document.createElement('select');
  1847. userSelect.id = 'userSelect1';
  1848. userSelect.className = 'email-modal-input';
  1849. data.data.forEach(user => {
  1850. userMap[user.Username] = {// 存储用户名和用户ID的映射
  1851. Account: user.Account,
  1852. UniqueID: user.UniqueID,
  1853. Username: user.Username,
  1854. Email: user.Email,
  1855. Role: user.Role,
  1856. Telephone:user.Telephone
  1857. };
  1858. const option = document.createElement('option');
  1859. option.value = user.Username;
  1860. option.textContent = user.Username;
  1861. userSelect.appendChild(option);
  1862. });
  1863. //document.getElementById('userInputs').appendChild(userSelect);
  1864. });
  1865. document.getElementById('emailModal').style.display = 'block';
  1866. selectedRowData = { ...selectedRowData, UniqueID: uniqueID };
  1867. }
  1868. function addEmailInput() {
  1869. const emailInputs = document.getElementById('emailInputs');
  1870. const newInputDiv = document.createElement('div');
  1871. newInputDiv.style.display = 'flex';
  1872. newInputDiv.style.alignItems = 'center';
  1873. newInputDiv.style.marginBottom = '10px';
  1874. const newInput = document.createElement('input');
  1875. newInput.type = 'text';
  1876. newInput.className = 'email-modal-input';
  1877. newInput.style.flexGrow = '1';
  1878. newInputDiv.appendChild(newInput);
  1879. const deleteButton = document.createElement('button');
  1880. deleteButton.textContent = '✕';
  1881. deleteButton.style.background = 'none';
  1882. deleteButton.style.border = 'none';
  1883. deleteButton.style.color = '#007aff';
  1884. deleteButton.style.cursor = 'pointer';
  1885. deleteButton.style.fontSize = '12px'; /* 再次缩小字体大小 */
  1886. deleteButton.style.padding = '0'; /* 移除内边距 */
  1887. deleteButton.style.marginLeft = '3px'; /* 减少与输入框的间距 */
  1888. deleteButton.style.width = '20px'; /* 限制按钮宽度 */
  1889. deleteButton.style.height = '20px'; /* 限制按钮高度 */
  1890. deleteButton.onclick = () => {
  1891. newInputDiv.remove();
  1892. };
  1893. newInputDiv.appendChild(deleteButton);
  1894. emailInputs.appendChild(newInputDiv);
  1895. }
  1896. function addUserInput() {
  1897. const userInputs = document.getElementById('userInputs');
  1898. const newUserDiv = document.createElement('div');
  1899. newUserDiv.className = 'user-select-container';
  1900. newUserDiv.style.display = 'flex';
  1901. newUserDiv.style.alignItems = 'center';
  1902. newUserDiv.style.marginBottom = '10px';
  1903. const newUserSelect = document.createElement('select');
  1904. newUserSelect.className = 'email-modal-input';
  1905. newUserSelect.style.flexGrow = '1';
  1906. newUserSelect.style.marginRight = '5px';
  1907. // 添加一个默认的空白选项
  1908. const defaultOption = document.createElement('option');
  1909. defaultOption.value = '';
  1910. defaultOption.textContent = '请选择用户';
  1911. newUserSelect.appendChild(defaultOption);
  1912. // 获取当前已选择的用户
  1913. const selectedValues = Array.from(document.querySelectorAll('.user-select-container select'))
  1914. .map(select => select.value);
  1915. // 获取用户列表并填充到选择框中
  1916. fetch('http://127.0.0.1:8080/api/admin/distributeLicenseByUserInfo', {
  1917. method: 'GET',
  1918. headers: {
  1919. 'Authorization': `Bearer ${token}`,
  1920. 'Content-Type': 'application/json'
  1921. }
  1922. })
  1923. .then(response => response.json())
  1924. .then(data => {
  1925. data.data.forEach(user => {
  1926. // 仅显示未被选中的用户,并且过滤掉admin用户
  1927. if (!selectedValues.includes(user.Username) && user.Username !== 'admin') {
  1928. const option = document.createElement('option');
  1929. option.value = user.Username;
  1930. option.textContent = user.Username;
  1931. newUserSelect.appendChild(option);
  1932. }
  1933. });
  1934. });
  1935. const deleteButton = document.createElement('button');
  1936. deleteButton.textContent = '✕';
  1937. deleteButton.style.background = 'none';
  1938. deleteButton.style.border = 'none';
  1939. deleteButton.style.color = '#007aff';
  1940. deleteButton.style.cursor = 'pointer';
  1941. deleteButton.style.fontSize = '12px';
  1942. deleteButton.style.padding = '0';
  1943. deleteButton.style.marginLeft = '3px';
  1944. deleteButton.style.width = '20px';
  1945. deleteButton.style.height = '20px';
  1946. deleteButton.onclick = () => {
  1947. newUserDiv.remove();
  1948. updateUserOptions(); // 更新其他下拉框中的选项
  1949. };
  1950. newUserSelect.addEventListener('change', updateUserOptions);
  1951. newUserDiv.appendChild(newUserSelect);
  1952. newUserDiv.appendChild(deleteButton);
  1953. userInputs.appendChild(newUserDiv);
  1954. // 设置空白选项为默认选项
  1955. newUserSelect.selectedIndex = 0;
  1956. }
  1957. function updateUserOptions() {
  1958. const selectedValues = Array.from(document.querySelectorAll('.user-select-container select'))
  1959. .map(select => select.value);
  1960. document.querySelectorAll('.user-select-container select').forEach(select => {
  1961. const currentValue = select.value;
  1962. select.innerHTML = ''; // 清空现有选项
  1963. // 添加一个默认的空白选项
  1964. const defaultOption = document.createElement('option');
  1965. defaultOption.value = '';
  1966. defaultOption.textContent = '请选择用户';
  1967. select.appendChild(defaultOption);
  1968. fetch('http://127.0.0.1:8080/api/admin/userInfoAll', {
  1969. method: 'GET',
  1970. headers: {
  1971. 'Authorization': `Bearer ${token}`,
  1972. 'Content-Type': 'application/json'
  1973. }
  1974. })
  1975. .then(response => response.json())
  1976. .then(data => {
  1977. data.data.forEach(user => {
  1978. if (!selectedValues.includes(user.Username) || user.Username === currentValue) {
  1979. if (user.Username !== 'admin') { // 过滤掉admin用户
  1980. const option = document.createElement('option');
  1981. option.value = user.Username;
  1982. option.textContent = user.Username;
  1983. select.appendChild(option);
  1984. }
  1985. }
  1986. });
  1987. select.value = currentValue;
  1988. });
  1989. });
  1990. }
  1991. // 打开修改信息表单框
  1992. function modifyLicenseInfo() {
  1993. const form = document.getElementById('modifyLicenseForm');
  1994. // 将选中的行数据填充到表单中
  1995. form.creator.value = selectedRowData.Creator;
  1996. form.applicationDate.value = selectedRowData.ApplicationDate;
  1997. form.associatedProject.value = selectedRowData.GlxmName;
  1998. form.salesPerson.value = selectedRowData.SalesPerson;
  1999. form.salesEmail.value = selectedRowData.SalesEmail;
  2000. form.supportPerson.value = selectedRowData.SupportPerson;
  2001. form.supportEmail.value = selectedRowData.SupportEmail;
  2002. form.totalNodes.value = selectedRowData.TotalNodes;
  2003. form.company.value = selectedRowData.Company;
  2004. form.productName.value = selectedRowData.ProductName;
  2005. form.version.value = selectedRowData.ProductVersion;
  2006. form.nodeCount.value = selectedRowData.NodeCount;
  2007. document.getElementById('modifyLicenseModal').style.display = 'block';
  2008. }
  2009. // 保存修改后的数据
  2010. function saveLicenseChanges() {
  2011. const form = document.getElementById('modifyLicenseForm');
  2012. const updatedData = {
  2013. UniqueID: selectedRowData.UniqueID,
  2014. Creator: form.creator.value,
  2015. ApplicationDate: form.applicationDate.value,
  2016. AssociatedProject: form.associatedProject.value,
  2017. SalesPerson: form.salesPerson.value,
  2018. SalesEmail: form.salesEmail.value,
  2019. SupportPerson: form.supportPerson.value,
  2020. SupportEmail: form.supportEmail.value,
  2021. TotalNodes: parseInt(form.totalNodes.value, 10), // 将 TotalNodes 转换为整数
  2022. Company: form.company.value,
  2023. ProductName: form.productName.value,
  2024. Version: form.version.value,
  2025. NodeCount: parseInt(form.nodeCount.value, 10), // 将 NodeCount 转换为整数
  2026. };
  2027. fetch(`http://127.0.0.1:8080/api/admin/UpdateLicense`, {
  2028. method: 'POST',
  2029. headers: {
  2030. 'Authorization': `Bearer ${token}`,
  2031. 'Content-Type': 'application/json'
  2032. },
  2033. body: JSON.stringify(updatedData)
  2034. })
  2035. .then(response => response.json())
  2036. .then(data => {
  2037. if (data.success) {
  2038. alert('License信息更新成功!');
  2039. fetchApplications(LisOffset, pageSize);
  2040. closeModal('modifyLicenseModal');
  2041. } else {
  2042. alert('License信息更新失败:' + data.error);
  2043. }
  2044. });
  2045. }
  2046. function updateUserOptions() {
  2047. const selectedValues = Array.from(document.querySelectorAll('.user-select-container select'))
  2048. .map(select => select.value);
  2049. document.querySelectorAll('.user-select-container select').forEach(select => {
  2050. const currentValue = select.value; // 保留当前选择值
  2051. select.innerHTML = ''; // 清空现有选项
  2052. fetch('http://127.0.0.1:8080/api/admin/distributeLicenseByUserInfo', {
  2053. method: 'GET',
  2054. headers: {
  2055. 'Authorization': `Bearer ${token}`,
  2056. 'Content-Type': 'application/json'
  2057. }
  2058. })
  2059. .then(response => response.json())
  2060. .then(data => {
  2061. data.data.forEach(user => {
  2062. // 保留当前值,并排除已经在其他下拉框中选中的值
  2063. if (!selectedValues.includes(user.Username) || user.Username === currentValue) {
  2064. const option = document.createElement('option');
  2065. option.value = user.Username;
  2066. option.textContent = user.Username;
  2067. if (user.Username === currentValue) {
  2068. option.selected = true; // 保持当前选择
  2069. }
  2070. select.appendChild(option);
  2071. }
  2072. });
  2073. });
  2074. });
  2075. }
  2076. //lic分发给用户 与邮件
  2077. function sendEmail() {
  2078. console.log('Send button clicked');
  2079. const emailInputs = document.querySelectorAll('.email-modal-input[type="text"]');
  2080. let emails = Array.from(emailInputs)
  2081. .map(input => input.value.trim())
  2082. .filter(email => email && email.includes('@'))
  2083. .join(',');
  2084. const supportEmailChecked = document.getElementById('supportEmailCheckbox').checked;
  2085. const salesEmailChecked = document.getElementById('salesEmailCheckbox').checked;
  2086. const emailArray = emails ? [emails] : [];
  2087. if (supportEmailChecked) {
  2088. emailArray.push(document.getElementById('supportEmailCheckbox').value);
  2089. }
  2090. if (salesEmailChecked) {
  2091. emailArray.push(document.getElementById('salesEmailCheckbox').value);
  2092. }
  2093. emails = emailArray.join(',');
  2094. // if (!emails) {
  2095. // alert('请至少选择一个邮箱地址。');
  2096. // return;
  2097. // }
  2098. console.log('Emails to send:', emails);
  2099. const userInputs = document.querySelectorAll('select.email-modal-input');
  2100. console.log('userMap:', userMap);
  2101. const users = Array.from(userInputs)
  2102. .map(select => userMap[select.value].Account)
  2103. .join(',');
  2104. const userIds = Array.from(userInputs)
  2105. .map(select => userMap[select.value].UniqueID)
  2106. .join(',');
  2107. const userNames = Array.from(userInputs)
  2108. .map(select => userMap[select.value].Username);
  2109. const operatorUniqueID = userMap[currentUserName].UniqueID;
  2110. console.log('User IDs:', userIds);
  2111. console.log('Users:', users);
  2112. console.log(' selectedRowData.UniqueID:', selectedRowData.UniqueID);
  2113. if (!userIds) {
  2114. alert('请至少选择一个用户。');
  2115. return;
  2116. }
  2117. const requestData = {
  2118. LicenseUniqueID: selectedRowData.UniqueID,
  2119. UserUniqueIDs: userIds.split(','),
  2120. UserAccounts: users.split(','),
  2121. Emails: emails,
  2122. UserNames: userNames,
  2123. OperatorUniqueID: operatorUniqueID
  2124. };
  2125. console.log('requestData:', requestData);
  2126. fetch('http://127.0.0.1:8080/api/admin/distributeLicense', {
  2127. method: 'POST',
  2128. headers: {
  2129. 'Authorization': `Bearer ${token}`,
  2130. 'Content-Type': 'application/json'
  2131. },
  2132. body: JSON.stringify(requestData)
  2133. })
  2134. .then(response => {
  2135. console.log('Response received');
  2136. return response.json();
  2137. })
  2138. .then(data => {
  2139. if (data.success) {
  2140. alert('分发成功!');
  2141. closeModal('emailModal');
  2142. } else {
  2143. // 检查是否有 error 字段,并提示用户详细的错误信息
  2144. const errorMessage = data.error || '分发失败。';
  2145. alert(`分发失败: ${errorMessage}`);
  2146. }
  2147. })
  2148. .catch(error => {
  2149. console.error('Error occurred during email distribution:', error);
  2150. alert('分发失败,请检查网络或后端服务。');
  2151. });
  2152. }
  2153. function showDistributionHistory() {
  2154. fetch('http://127.0.0.1:8080/api/admin/GetlicenseRecord', {
  2155. method: 'POST',
  2156. headers: {
  2157. 'Authorization': `Bearer ${token}`,
  2158. 'Content-Type': 'application/json'
  2159. },
  2160. body: JSON.stringify({ uniqueID: selectedRowData.UniqueID })
  2161. })
  2162. .then(response => response.json())
  2163. .then(data => {
  2164. const distributionHistoryContent = document.getElementById('distributionHistoryContent');
  2165. const { license_record_to_user, license_record_to_emails } = data.data;
  2166. // 确保 license_record_to_user 和 license_record_to_emails 存在并且是数组
  2167. const userRecords = Array.isArray(license_record_to_user) ? license_record_to_user : [];
  2168. const emailRecords = Array.isArray(license_record_to_emails) ? license_record_to_emails : [];
  2169. if (userRecords.length > 0 || emailRecords.length > 0) {
  2170. const userHistoryHtml = userRecords.map(record => `
  2171. <div style="margin-bottom: 20px; padding: 10px; border: 1px solid #ddd; border-radius: 10px; background-color: #f9f9f9;">
  2172. <p><strong>已转发给用户:</strong> ${record.user_account}</p>
  2173. <p><strong>分发时间:</strong> ${new Date(record.up_time).toLocaleString()}</p>
  2174. </div>
  2175. `).join('');
  2176. const emailHistoryHtml = emailRecords.map(record => `
  2177. <div style="margin-bottom: 20px; padding: 10px; border: 1px solid #ddd; border-radius: 10px; background-color: #f9f9f9;">
  2178. <p><strong>已发给邮箱:</strong> ${record.emails}</p>
  2179. <p><strong>分发时间:</strong> ${new Date(record.up_time).toLocaleString()}</p>
  2180. </div>
  2181. `).join('');
  2182. distributionHistoryContent.innerHTML = userHistoryHtml + emailHistoryHtml;
  2183. } else {
  2184. distributionHistoryContent.innerHTML = `<p>没有分发历史记录。</p>`;
  2185. }
  2186. // 显示模态框
  2187. const distributionHistoryModal = document.getElementById('distributionHistoryModal');
  2188. distributionHistoryModal.style.display = 'block';
  2189. });
  2190. }
  2191. function showMoreUserInfo() {
  2192. const extraInfoContent = document.getElementById('extraInfoContent');
  2193. extraInfoContent.innerHTML = `
  2194. <p><strong>用户名:</strong> ${selectedRowData.Username}</p>
  2195. <p><strong>电话:</strong> ${selectedRowData.Telephone}</p>
  2196. <p><strong>邮箱:</strong> ${selectedRowData.Email}</p>
  2197. <p><strong>权限:</strong> ${selectedRowData.Role}</p>
  2198. `;
  2199. document.getElementById('extraInfoModal').style.display = 'block';
  2200. }
  2201. function modifyUser() {
  2202. const userInfoContent = document.getElementById('extraInfoContent');
  2203. userInfoContent.innerHTML = `
  2204. <p><strong>用户名:</strong> ${selectedRowData.Username}</p>
  2205. <p><strong>电话:</strong> ${selectedRowData.Telephone}</p>
  2206. <p><strong>邮箱:</strong> ${selectedRowData.Email}</p>
  2207. <p><strong>权限:</strong> ${selectedRowData.Role}</p>
  2208. <button onclick="showEditUserForm()">编辑用户信息</button>
  2209. `;
  2210. document.getElementById('extraInfoModal').style.display = 'block';
  2211. }
  2212. //查看额外信息
  2213. function showExtraInfo() {
  2214. const extraInfoContent = document.getElementById('extraInfoContent');
  2215. // 清空之前的内容
  2216. extraInfoContent.innerHTML = '';
  2217. // 使用预定义的字段名和中文翻译
  2218. const fieldTranslations = {
  2219. id: "ID",
  2220. user_id: "用户ID",
  2221. up_user: "上传用户",
  2222. up_time: "上传时间",
  2223. del_time: "删除时间",
  2224. License1: "License 1",
  2225. License2: "License 2",
  2226. LicenseFlage: "License 状态",
  2227. UniqueID: "唯一标识符",
  2228. Creator: "创建人",
  2229. ApplicationDate: "申请日期",
  2230. AssociatedProject: "关联项目",
  2231. SalesPerson: "销售人员",
  2232. SalesEmail: "销售邮箱",
  2233. SupportPerson: "支持人员",
  2234. SupportEmail: "支持邮箱",
  2235. TotalNodes: "总节点数",
  2236. Company: "公司",
  2237. ProductName: "产品名称",
  2238. Version: "版本",
  2239. NodeCount: "节点数",
  2240. Processor: "处理器",
  2241. OperatingSystem: "操作系统",
  2242. MasterMacAddress: "主MAC地址",
  2243. SecondaryMasterMacAddress: "备用主MAC地址"
  2244. };
  2245. // 使用指定的字段进行展示
  2246. const fieldsToShow = [
  2247. "id", "user_id", "up_user", "up_time", "del_time", "License1", "License2",
  2248. "LicenseFlage", "UniqueID", "Creator", "ApplicationDate", "AssociatedProject",
  2249. "SalesPerson", "SalesEmail", "SupportPerson", "SupportEmail", "TotalNodes",
  2250. "Company", "ProductName", "Version", "NodeCount", "Processor", "OperatingSystem",
  2251. "MasterMacAddress", "SecondaryMasterMacAddress"
  2252. ];
  2253. fieldsToShow.forEach(key => {
  2254. if (selectedRowData.hasOwnProperty(key)) {
  2255. let value = selectedRowData[key];
  2256. // 特殊处理 up_time 和 del_time
  2257. if (key === 'up_time' || key === 'del_time') {
  2258. if (value.Valid) {
  2259. value = new Date(value.Time).toLocaleString(); // 格式化日期时间
  2260. } else {
  2261. value = '无';
  2262. }
  2263. }
  2264. // 处理 License1 和 License2,提取字符串字段
  2265. if (key === 'License1' || key === 'License2') {
  2266. // 假设 License 对象包含一个名为 'Details' 的字符串字段
  2267. value = value.String || '[无数据]';
  2268. }
  2269. // 处理 MasterMacAddress 和 SecondaryMasterMacAddress,提取字符串字段
  2270. // if (key === 'MasterMacAddress' || key === 'SecondaryMasterMacAddress') {
  2271. // // 假设 License 对象包含一个名为 'Details' 的字符串字段
  2272. // value = value.String || '[无数据]';
  2273. // }
  2274. const infoElement = document.createElement('p');
  2275. infoElement.innerHTML = `<strong>${fieldTranslations[key]}:</strong> ${value}`;
  2276. extraInfoContent.appendChild(infoElement);
  2277. }
  2278. });
  2279. // 显示 modal
  2280. document.getElementById('extraInfoModal').style.display = 'block';
  2281. }
  2282. function showRoleManagement() {
  2283. document.getElementById('table-container').style.display = 'none';
  2284. document.getElementById('user-management').style.display = 'none'; // 隐藏用户管理页面
  2285. document.getElementById('role-management').style.display = 'block';;
  2286. fetchRoles();
  2287. }
  2288. function fetchRoles() {
  2289. fetch('http://127.0.0.1:8080/api/admin/GetRoles', {
  2290. method: 'POST',
  2291. headers: {
  2292. 'Authorization': `Bearer ${token}`,
  2293. 'Content-Type': 'application/json'
  2294. },
  2295. body: JSON.stringify({ Name: " " }) // 发送空的 Name 参数
  2296. })
  2297. .then(response => response.json())
  2298. .then(data => {
  2299. const roleContainer = document.getElementById('roles-container');
  2300. roleContainer.innerHTML = ''; // 清空之前的内容
  2301. const permissionMap = {
  2302. 'generate_license': '生成许可证',
  2303. 'upload_license': '上传许可证',
  2304. 'read_license': '读取许可证',
  2305. 'read_license_record': '读取许可证分发记录',
  2306. 'update_license': '修改许可证',
  2307. 'delete_license': '删除许可证',
  2308. 'dispat_license': '分发许可证',
  2309. 'create_user': '创建用户',
  2310. 'read_user': '读取用户',
  2311. 'update_user': '更新用户',
  2312. 'delete_user': '删除用户',
  2313. 'create_role': '创建角色',
  2314. 'delete_role': '删除角色',
  2315. 'update_role': '更新角色',
  2316. 'get_role': '获取角色'
  2317. };
  2318. // 检查用户是否有 create_role 权限
  2319. const hasCreateRolePermission = userPermissions.includes('create_role');
  2320. // 如果有权限则显示“创建角色”按钮
  2321. if (hasCreateRolePermission) {
  2322. document.getElementById('createRoleButton').style.display = 'block';
  2323. } else {
  2324. document.getElementById('createRoleButton').style.display = 'none';
  2325. }
  2326. // 处理置顶角色和其他角色的渲染(代码不变)
  2327. const topRoles = ['admin', 'guest', 'supportRole'];
  2328. topRoles.forEach(role => {
  2329. if (data.data[role]) {
  2330. renderRole(roleContainer, data.data[role], permissionMap, true);
  2331. }
  2332. });
  2333. Object.keys(data.data).forEach(role => {
  2334. if (!topRoles.includes(role)) {
  2335. renderRole(roleContainer, data.data[role], permissionMap, false);
  2336. }
  2337. });
  2338. });
  2339. }
  2340. function renderRole(container, roleInfo, permissionMap, isTopRole) {
  2341. const roleDiv = document.createElement('div');
  2342. roleDiv.className = 'role-item';
  2343. roleDiv.style.position = 'relative'; // 确保弹出菜单能够正确定位
  2344. if (isTopRole) {
  2345. roleDiv.classList.add('top-role'); // 应用置顶角色的样式
  2346. }
  2347. let permissions = roleInfo.Permissions.map(permission => permissionMap[permission]);
  2348. let permissionsHtml = permissions.join(','); // 使用逗号分隔并合并为一行
  2349. roleDiv.innerHTML = `
  2350. <h3>${roleInfo.Name}</h3>
  2351. <p>${permissionsHtml}</p>
  2352. `;
  2353. container.appendChild(roleDiv);
  2354. // 添加事件监听器,处理点击和右键点击弹出菜单
  2355. roleDiv.addEventListener('click', function(event) {
  2356. event.stopPropagation(); // 阻止事件冒泡
  2357. event.preventDefault(); // 阻止默认行为
  2358. showRoleActionMenu(event, roleInfo.Name);
  2359. });
  2360. roleDiv.addEventListener('contextmenu', function(event) {
  2361. event.preventDefault();
  2362. showRoleActionMenu(event, roleInfo.Name);
  2363. });
  2364. }
  2365. function showRoleActionMenu(event, roleName) {
  2366. const existingMenu = document.getElementById('role-action-menu');
  2367. if (existingMenu) {
  2368. existingMenu.remove();
  2369. }
  2370. const menu = document.createElement('div');
  2371. menu.id = 'role-action-menu';
  2372. menu.style.position = 'absolute';
  2373. menu.style.top = `${event.clientY}px`;
  2374. menu.style.left = `${event.clientX}px`;
  2375. menu.style.backgroundColor = '#fff';
  2376. menu.style.border = '1px solid #ccc';
  2377. menu.style.borderRadius = '5px';
  2378. menu.style.boxShadow = '0 2px 10px rgba(0, 0, 0, 0.2)';
  2379. menu.style.padding = '10px';
  2380. menu.style.zIndex = '1000';
  2381. const topRoles = ['admin', 'guest', 'support'];
  2382. if (topRoles.includes(roleName)) {
  2383. // 为 admin, guest, supportRole 设置灰色和不可点击样式
  2384. const disabledButton = document.createElement('button');
  2385. disabledButton.textContent = '不可操作';
  2386. disabledButton.style.display = 'block';
  2387. disabledButton.style.width = '100%';
  2388. disabledButton.style.padding = '10px 20px';
  2389. disabledButton.style.border = 'none';
  2390. disabledButton.style.borderRadius = '15px';
  2391. disabledButton.style.cursor = 'not-allowed';
  2392. disabledButton.style.backgroundColor = '#d3d3d3'; // 灰色背景
  2393. disabledButton.style.color = '#999'; // 灰色文字
  2394. menu.appendChild(disabledButton);
  2395. } else {
  2396. // 检查用户是否有 update_role 和 delete_role 权限
  2397. const hasUpdateRolePermission = userPermissions.includes('update_role');
  2398. const hasDeleteRolePermission = userPermissions.includes('delete_role');
  2399. // 创建和添加修改角色按钮
  2400. if (hasUpdateRolePermission) {
  2401. const modifyButton = document.createElement('button');
  2402. modifyButton.textContent = '修改角色';
  2403. modifyButton.style.display = 'block';
  2404. modifyButton.style.marginBottom = '10px';
  2405. modifyButton.style.width = '100%';
  2406. modifyButton.style.padding = '10px 20px';
  2407. modifyButton.style.border = 'none';
  2408. modifyButton.style.borderRadius = '15px';
  2409. modifyButton.style.cursor = 'pointer';
  2410. modifyButton.style.transition = 'background-color 0.3s, color 0.3s';
  2411. modifyButton.style.boxShadow = '0 2px 4px rgba(0, 0, 0, 0.1)';
  2412. modifyButton.style.backgroundColor = '#007aff';
  2413. modifyButton.style.color = '#fff';
  2414. modifyButton.addEventListener('mouseenter', function () {
  2415. modifyButton.style.backgroundColor = '#005bb5';
  2416. });
  2417. modifyButton.addEventListener('mouseleave', function () {
  2418. modifyButton.style.backgroundColor = '#007aff';
  2419. });
  2420. modifyButton.addEventListener('click', function () {
  2421. modifyRole(roleName);
  2422. menu.remove(); // 点击按钮后,关闭菜单栏
  2423. });
  2424. menu.appendChild(modifyButton);
  2425. }
  2426. // 创建和添加删除角色按钮
  2427. if (hasDeleteRolePermission) {
  2428. const deleteButton = document.createElement('button');
  2429. deleteButton.textContent = '删除角色';
  2430. deleteButton.style.display = 'block';
  2431. deleteButton.style.width = '100%';
  2432. deleteButton.style.padding = '10px 20px';
  2433. deleteButton.style.border = 'none';
  2434. deleteButton.style.borderRadius = '15px';
  2435. deleteButton.style.cursor = 'pointer';
  2436. deleteButton.style.transition = 'background-color 0.3s, color 0.3s';
  2437. deleteButton.style.boxShadow = '0 2px 4px rgba(0, 0, 0, 0.1)';
  2438. deleteButton.style.backgroundColor = '#ff3b30';
  2439. deleteButton.style.color = '#fff';
  2440. deleteButton.addEventListener('mouseenter', function () {
  2441. deleteButton.style.backgroundColor = '#c23321';
  2442. });
  2443. deleteButton.addEventListener('mouseleave', function () {
  2444. deleteButton.style.backgroundColor = '#ff3b30';
  2445. });
  2446. deleteButton.addEventListener('click', function () {
  2447. deleteRole(roleName);
  2448. menu.remove(); // 点击按钮后,关闭菜单栏
  2449. });
  2450. menu.appendChild(deleteButton);
  2451. }
  2452. // 如果用户没有修改或删除权限,则显示没有选项的提示
  2453. if (!hasUpdateRolePermission && !hasDeleteRolePermission) {
  2454. const noOption = document.createElement('div');
  2455. noOption.textContent = '没有可用的操作';
  2456. noOption.style.textAlign = 'center';
  2457. noOption.style.color = '#999';
  2458. menu.appendChild(noOption);
  2459. }
  2460. }
  2461. document.body.appendChild(menu);
  2462. document.addEventListener('click', function closeMenu(event) {
  2463. if (!menu.contains(event.target)) {
  2464. menu.remove();
  2465. document.removeEventListener('click', closeMenu);
  2466. }
  2467. });
  2468. }
  2469. //修改角色信息
  2470. function modifyRole(roleName) {
  2471. console.log(`modifyRole called with roleName: ${roleName}`);
  2472. fetchRoleInfo(roleName, function(roleInfo) {
  2473. console.log(`fetchRoleInfo returned:`, roleInfo);
  2474. if (!roleInfo) {
  2475. console.error('Role info is undefined or null');
  2476. return;
  2477. }
  2478. const extraInfoContent = document.getElementById('extraInfoContent');
  2479. if (!extraInfoContent) {
  2480. console.error('Element with id "extraInfoContent" not found');
  2481. return;
  2482. }
  2483. extraInfoContent.innerHTML = `
  2484. <h3>修改角色: ${roleInfo.Name}</h3>
  2485. <label for="roleName">角色名称:</label>
  2486. <input type="text" id="roleName" value="${roleInfo.Name}" required><br><br>
  2487. <label for="permissions">权限:</label><br>
  2488. <div id="permissions">
  2489. <div>
  2490. <input type="checkbox" id="license" name="permissions" value="license" onchange="toggleSubPermissions('license', this)">
  2491. <label for="license">许可证</label>
  2492. <div id="licenseSubPermissions" style="margin-left: 20px;">
  2493. <input type="checkbox" id="generate_license" name="permissions" value="generate_license">
  2494. <label for="generate_license">生成许可证</label><br>
  2495. <input type="checkbox" id="upload_license" name="permissions" value="upload_license">
  2496. <label for="upload_license">上传许可证</label><br>
  2497. <input type="checkbox" id="read_license" name="permissions" value="read_license">
  2498. <label for="read_license">读取许可证</label><br>
  2499. <input type="checkbox" id="update_license" name="permissions" value="update_license">
  2500. <label for="update_license">更新许可证</label><br>
  2501. <input type="checkbox" id="delete_license" name="permissions" value="delete_license">
  2502. <label for="delete_license">删除许可证</label><br>
  2503. </div>
  2504. </div>
  2505. <div>
  2506. <input type="checkbox" id="user" name="permissions" value="user" onchange="toggleSubPermissions('user', this)">
  2507. <label for="user">用户</label>
  2508. <div id="userSubPermissions" style="margin-left: 20px;">
  2509. <input type="checkbox" id="create_user" name="permissions" value="create_user">
  2510. <label for="create_user">创建用户</label><br>
  2511. <input type="checkbox" id="read_user" name="permissions" value="read_user">
  2512. <label for="read_user">读取用户</label><br>
  2513. <input type="checkbox" id="update_user" name="permissions" value="update_user">
  2514. <label for="update_user">更新用户</label><br>
  2515. <input type="checkbox" id="delete_user" name="permissions" value="delete_user">
  2516. <label for="delete_user">删除用户</label><br>
  2517. </div>
  2518. </div>
  2519. <div>
  2520. <input type="checkbox" id="role" name="permissions" value="role" onchange="toggleSubPermissions('role', this)">
  2521. <label for="role">角色</label>
  2522. <div id="roleSubPermissions" style="margin-left: 20px;">
  2523. <input type="checkbox" id="create_role" name="permissions" value="create_role">
  2524. <label for="create_role">创建角色</label><br>
  2525. <input type="checkbox" id="delete_role" name="permissions" value="delete_role">
  2526. <label for="delete_role">删除角色</label><br>
  2527. <input type="checkbox" id="update_role" name="permissions" value="update_role">
  2528. <label for="update_role">更新角色</label><br>
  2529. <input type="checkbox" id="get_role" name="permissions" value="get_role">
  2530. <label for="get_role">获取角色</label><br>
  2531. </div>
  2532. </div>
  2533. </div><br><br>
  2534. <button onclick="saveRoleChanges('${roleInfo.Id}')">保存</button>
  2535. `;
  2536. console.log('Form content added to extraInfoContent');
  2537. const checkboxes = document.querySelectorAll('#permissions input[type="checkbox"]');
  2538. // 遍历所有复选框
  2539. checkboxes.forEach(checkbox => {
  2540. if (roleInfo.Permissions.includes(checkbox.value)) {
  2541. checkbox.checked = true; // 如果当前权限在roleInfo.Permissions中,则勾选
  2542. }
  2543. });
  2544. const extraInfoModal = document.getElementById('extraInfoModal');
  2545. if (!extraInfoModal) {
  2546. console.error('Element with id "extraInfoModal" not found');
  2547. return;
  2548. }
  2549. extraInfoModal.style.display = 'block'; // 强制显示模态框
  2550. console.log('Modal should be visible now');
  2551. });
  2552. }
  2553. function getCheckboxOptions(selectedPermissions) {
  2554. const permissionMap = {
  2555. 'generate_license': '生成许可证',
  2556. 'upload_license': '上传许可证',
  2557. 'read_license': '读取许可证',
  2558. 'update_license': '修改许可证',
  2559. 'delete_license': '删除许可证',
  2560. 'dispat_license': '分发许可证',
  2561. 'read_license_record': '读取许可证分发记录',
  2562. // 'get_user_info': '获取用户信息',
  2563. 'create_user': '创建用户',
  2564. 'read_user': '读取用户',
  2565. 'update_user': '更新用户',
  2566. 'delete_user': '删除用户',
  2567. 'create_role': '创建角色',
  2568. 'delete_role': '删除角色',
  2569. 'update_role': '更新角色',
  2570. 'get_role': '获取角色'
  2571. };
  2572. return Object.keys(permissionMap).map(permission => `
  2573. <div>
  2574. <input type="checkbox" id="${permission}" name="permissions" value="${permission}" ${selectedPermissions.includes(permission) ? 'checked' : ''}>
  2575. <label for="${permission}">${permissionMap[permission]}</label>
  2576. </div>
  2577. `).join('');
  2578. }
  2579. function fetchRoleInfo(roleName, callback) {
  2580. console.log(`fetchRoleInfo called with roleName: ${roleName}`);
  2581. fetch('http://127.0.0.1:8080/api/admin/GetRoles', {
  2582. method: 'POST',
  2583. headers: {
  2584. 'Authorization': `Bearer ${token}`,
  2585. 'Content-Type': 'application/json'
  2586. },
  2587. body: JSON.stringify({ Name: roleName })
  2588. })
  2589. .then(response => {
  2590. console.log('fetchRoleInfo response received', response);
  2591. return response.json();
  2592. })
  2593. .then(data => {
  2594. console.log('fetchRoleInfo data received', data);
  2595. // 直接从 data.data 获取角色信息
  2596. if (data && data.data) {
  2597. console.log('Role info found:', data.data);
  2598. callback(data.data); // 直接返回 data.data 而不是 data.data[roleName]
  2599. } else {
  2600. console.error('Role not found or unexpected data structure', data);
  2601. callback(null); // 如果角色信息未找到,返回 null
  2602. }
  2603. })
  2604. .catch(error => {
  2605. console.error('Error in fetchRoleInfo:', error);
  2606. callback(null); // 捕获异常情况
  2607. });
  2608. }
  2609. function getPermissionsOptions(selectedPermissions) {
  2610. const permissionMap = {
  2611. 'generate_license': '生成许可证',
  2612. 'upload_license': '上传许可证',
  2613. 'read_license': '读取许可证',
  2614. 'update_license': '修改许可证',
  2615. 'delete_license': '删除许可证',
  2616. 'dispat_license': '分发许可证',
  2617. 'read_license_record': '读取许可证分发记录',
  2618. //'get_user_info': '获取用户信息',
  2619. 'create_user': '创建用户',
  2620. 'read_user': '读取用户',
  2621. 'update_user': '更新用户',
  2622. 'delete_user': '删除用户',
  2623. 'create_role': '创建角色',
  2624. 'delete_role': '删除角色',
  2625. 'update_role': '更新角色',
  2626. 'get_role': '获取角色'
  2627. };
  2628. return Object.keys(permissionMap).map(permission => `
  2629. <option value="${permission}" ${selectedPermissions.includes(permission) ? 'selected' : ''}>
  2630. ${permissionMap[permission]}
  2631. </option>
  2632. `).join('');
  2633. }
  2634. function saveRoleChanges(roleId) {
  2635. const updatedRoleName = document.getElementById('roleName').value.trim();
  2636. const selectedPermissions = Array.from(document.querySelectorAll('#permissions input[type="checkbox"]:checked'))
  2637. .map(checkbox => checkbox.value)
  2638. .filter(value => !['license', 'user', 'role'].includes(value)); // 过滤掉一级分类
  2639. if (!updatedRoleName) {
  2640. alert('角色名称不能为空!');
  2641. return;
  2642. }
  2643. const updateRole = {
  2644. Id: parseInt(roleId, 10), // 确保 roleId 被传递并转换为整数
  2645. Name: updatedRoleName,
  2646. Permissions: selectedPermissions
  2647. };
  2648. fetch('http://127.0.0.1:8080/api/admin/UpdateRole', {
  2649. method: 'POST',
  2650. headers: {
  2651. 'Authorization': `Bearer ${token}`,
  2652. 'Content-Type': 'application/json'
  2653. },
  2654. body: JSON.stringify(updateRole)
  2655. })
  2656. .then(response => response.json())
  2657. .then(data => {
  2658. if (data.success) {
  2659. alert('角色更新成功!');
  2660. fetchRoles(); // 刷新角色列表
  2661. closeModal('extraInfoModal'); // 关闭信息栏
  2662. } else {
  2663. alert('角色更新失败:' + data.error);
  2664. }
  2665. });
  2666. }
  2667. //删除角色
  2668. function deleteRole(roleName) {
  2669. console.log(`deleteRole called for role: ${roleName}`);
  2670. const confirmed = confirm(`确认删除角色: ${roleName} 吗?`);
  2671. if (!confirmed) {
  2672. return;
  2673. }
  2674. fetch('http://127.0.0.1:8080/api/admin/DeleteRole', {
  2675. method: 'POST',
  2676. headers: {
  2677. 'Authorization': `Bearer ${token}`,
  2678. 'Content-Type': 'application/json'
  2679. },
  2680. body: JSON.stringify({
  2681. name: roleName // 将角色名称传递给后端
  2682. })
  2683. })
  2684. .then(response => response.json())
  2685. .then(data => {
  2686. if (data.success) {
  2687. alert('角色删除成功!');
  2688. fetchRoles(); // 刷新角色列表
  2689. } else {
  2690. alert('角色删除失败:' + data.error);
  2691. }
  2692. })
  2693. .catch(error => {
  2694. console.error('Error deleting role:', error);
  2695. alert('删除角色时发生错误,请稍后再试。');
  2696. });
  2697. }
  2698. document.getElementById('createRoleButton').addEventListener('click', function() {
  2699. const extraInfoContent = document.getElementById('extraInfoContent');
  2700. extraInfoContent.innerHTML = `
  2701. <h3>创建新角色</h3>
  2702. <label for="newRoleName">角色名称:</label>
  2703. <input type="text" id="newRoleName" required><br><br>
  2704. <label for="newPermissions">权限:</label><br>
  2705. <div id="newPermissions">
  2706. <div>
  2707. <input type="checkbox" id="license" name="permissions" value="license" onchange="toggleSubPermissions('license', this)">
  2708. <label for="license">许可证</label>
  2709. <div id="licenseSubPermissions" style="margin-left: 20px;">
  2710. <input type="checkbox" id="generate_license" name="permissions" value="generate_license">
  2711. <label for="generate_license">生成许可证</label><br>
  2712. <input type="checkbox" id="upload_license" name="permissions" value="upload_license">
  2713. <label for="upload_license">上传许可证</label><br>
  2714. <input type="checkbox" id="read_license" name="permissions" value="read_license">
  2715. <label for="read_license">读取许可证</label><br>
  2716. <input type="checkbox" id="update_license" name="permissions" value="update_license">
  2717. <label for="update_license">更新许可证</label><br>
  2718. <input type="checkbox" id="delete_license" name="permissions" value="delete_license">
  2719. <label for="delete_license">删除许可证</label><br>
  2720. </div>
  2721. </div>
  2722. <div>
  2723. <input type="checkbox" id="user" name="permissions" value="user" onchange="toggleSubPermissions('user', this)">
  2724. <label for="user">用户</label>
  2725. <div id="userSubPermissions" style="margin-left: 20px;">
  2726. <input type="checkbox" id="create_user" name="permissions" value="create_user">
  2727. <label for="create_user">创建用户</label><br>
  2728. <input type="checkbox" id="read_user" name="permissions" value="read_user">
  2729. <label for="read_user">读取用户</label><br>
  2730. <input type="checkbox" id="update_user" name="permissions" value="update_user">
  2731. <label for="update_user">更新用户</label><br>
  2732. <input type="checkbox" id="delete_user" name="permissions" value="delete_user">
  2733. <label for="delete_user">删除用户</label><br>
  2734. </div>
  2735. </div>
  2736. <div>
  2737. <input type="checkbox" id="role" name="permissions" value="role" onchange="toggleSubPermissions('role', this)">
  2738. <label for="role">角色</label>
  2739. <div id="roleSubPermissions" style="margin-left: 20px;">
  2740. <input type="checkbox" id="create_role" name="permissions" value="create_role">
  2741. <label for="create_role">创建角色</label><br>
  2742. <input type="checkbox" id="delete_role" name="permissions" value="delete_role">
  2743. <label for="delete_role">删除角色</label><br>
  2744. <input type="checkbox" id="update_role" name="permissions" value="update_role">
  2745. <label for="update_role">更新角色</label><br>
  2746. <input type="checkbox" id="get_role" name="permissions" value="get_role">
  2747. <label for="get_role">获取角色</label><br>
  2748. </div>
  2749. </div>
  2750. </div><br><br>
  2751. <button onclick="createNewRole()">创建</button>
  2752. </div>
  2753. `;
  2754. document.getElementById('extraInfoModal').style.display = 'block';
  2755. });
  2756. function toggleSubPermissions(category, checkbox) {
  2757. const subPermissions = document.querySelectorAll(`#${category}SubPermissions input[type="checkbox"]`);
  2758. subPermissions.forEach(subCheckbox => {
  2759. subCheckbox.checked = checkbox.checked;
  2760. });
  2761. }
  2762. function createNewRole() {
  2763. const newRoleName = document.getElementById('newRoleName').value.trim();
  2764. const selectedPermissions = Array.from(document.querySelectorAll('#newPermissions input[type="checkbox"]:checked'))
  2765. .map(checkbox => checkbox.value)
  2766. .filter(value => !['license', 'user', 'role'].includes(value)); // 过滤掉一级分类
  2767. if (!newRoleName) {
  2768. alert('角色名称不能为空!');
  2769. return;
  2770. }
  2771. const newRole = {
  2772. Name: newRoleName,
  2773. Permissions: selectedPermissions
  2774. };
  2775. fetch('http://127.0.0.1:8080/api/admin/CreateRole', {
  2776. method: 'POST',
  2777. headers: {
  2778. 'Authorization': `Bearer ${token}`,
  2779. 'Content-Type': 'application/json'
  2780. },
  2781. body: JSON.stringify(newRole)
  2782. })
  2783. .then(response => response.json())
  2784. .then(data => {
  2785. if (data.success) {
  2786. alert('角色创建成功!');
  2787. fetchRoles(); // 刷新角色列表
  2788. closeModal('extraInfoModal'); // 关闭信息栏
  2789. } else {
  2790. alert('角色创建失败:' + data.error);
  2791. }
  2792. });
  2793. }
  2794. //显示用户信息
  2795. function showEditUserForm() {
  2796. const extraInfoContent = document.getElementById('extraInfoContent');
  2797. // 清空之前的内容
  2798. extraInfoContent.innerHTML = '';
  2799. // 创建表单
  2800. const form = document.createElement('form');
  2801. form.id = 'editUserForm';
  2802. form.style.width = '400px'; // 增加表单宽度
  2803. form.innerHTML = `
  2804. <div style="display: flex; align-items: center; margin-bottom: 15px;">
  2805. <label for="username" style="flex: 0 0 80px;">用户名:</label>
  2806. <input type="text" id="username" name="username" value="${selectedRowData.Username}" style="flex: 1;" required>
  2807. </div>
  2808. <div style="display: flex; align-items: center; margin-bottom: 15px;">
  2809. <label for="telephone" style="flex: 0 0 80px;">电话:</label>
  2810. <input type="text" id="telephone" name="telephone" value="${selectedRowData.Telephone}" style="flex: 1;" required>
  2811. </div>
  2812. <div style="display: flex; align-items: center; margin-bottom: 15px;">
  2813. <label for="email" style="flex: 0 0 80px;">邮箱:</label>
  2814. <input type="email" id="email" name="email" value="${selectedRowData.Email}" style="flex: 1;" required>
  2815. </div>
  2816. <div style="display: flex; align-items: center; margin-bottom: 15px;">
  2817. <label for="role" style="flex: 0 0 80px;">权限:</label>
  2818. <select id="role" name="role" style="flex: 1;" required></select>
  2819. </div>
  2820. <button type="button" onclick="saveUserChanges()" style="width: 100%; background-color: #007bff; color: white; border: none; padding: 10px; border-radius: 5px;">保存</button>
  2821. `;
  2822. // 将表单添加到弹出框内容中
  2823. extraInfoContent.appendChild(form);
  2824. // 获取角色列表并填充到选择框中
  2825. fetch('http://127.0.0.1:8080/api/admin/GetRoleNames', {
  2826. method: 'GET',
  2827. headers: {
  2828. 'Authorization': `Bearer ${token}`,
  2829. 'Content-Type': 'application/json'
  2830. }
  2831. })
  2832. .then(response => response.json())
  2833. .then(data => {
  2834. const roleSelect = document.getElementById('role');
  2835. data.roles.forEach(role => {
  2836. const option = document.createElement('option');
  2837. option.value = role;
  2838. option.textContent = role;
  2839. if (selectedRowData.Role === role) {
  2840. option.selected = true;
  2841. }
  2842. roleSelect.appendChild(option);
  2843. });
  2844. })
  2845. .catch(error => console.error('Error fetching roles:', error));
  2846. }
  2847. function saveUserChanges() {
  2848. const form = document.getElementById('editUserForm');
  2849. const formData = new FormData(form);
  2850. const updatedUser = {
  2851. Username: formData.get('username'),
  2852. Telephone: formData.get('telephone'),
  2853. Email: formData.get('email'),
  2854. Role: formData.get('role')
  2855. };
  2856. fetch(`http://127.0.0.1:8080/api/admin/updateUser`, {
  2857. method: 'POST',
  2858. headers: {
  2859. 'Authorization': `Bearer ${token}`,
  2860. 'Content-Type': 'application/json'
  2861. },
  2862. body: JSON.stringify({ ...updatedUser, Id: selectedRowData.Id })
  2863. })
  2864. .then(response => response.json())
  2865. .then(data => {
  2866. if (data.success) {
  2867. alert('用户信息更新成功!');
  2868. fetchUsers();
  2869. closeModal('extraInfoModal');
  2870. } else {
  2871. alert('用户信息更新失败:' + data.error);
  2872. }
  2873. });
  2874. }
  2875. function toggleUserInfo() {
  2876. const userModal = document.getElementById('userModal');
  2877. const userButton = document.getElementById('username');
  2878. const rect = userButton.getBoundingClientRect();
  2879. const modalWidth = 300; // 信息栏的宽度
  2880. const windowWidth = window.innerWidth; // 浏览器窗口的宽度
  2881. if (userModal.style.display === 'none' || userModal.style.display === '') {
  2882. fetch(`http://127.0.0.1:8080/api/admin/userInfo`, {
  2883. method: 'GET',
  2884. headers: {
  2885. 'Authorization': `Bearer ${token}`,
  2886. 'Content-Type': 'application/json'
  2887. }
  2888. })
  2889. .then(response => response.json())
  2890. .then(data => {
  2891. const userInfoContent = document.getElementById('userInfoContent');
  2892. let power;
  2893. switch (data.data.Role) {
  2894. case 'admin':
  2895. power = '至高无上的主';
  2896. break;
  2897. case 'supportRole':
  2898. power = '运维';
  2899. break;
  2900. case 'guest':
  2901. power = '访客';
  2902. break;
  2903. default:
  2904. power = data.data.Role;
  2905. }
  2906. userInfoContent.innerHTML = `
  2907. <h2> 个人信息</h2>
  2908. <div class="apple-modal-content">
  2909. <p class="apple-modal-text"><strong>用户名:</strong> ${data.data.Username}</p>
  2910. <p class="apple-modal-text"><strong>账号:</strong> ${data.data.Account}</p>
  2911. <p class="apple-modal-text"><strong>邮箱:</strong> ${data.data.Email}</p>
  2912. <p class="apple-modal-text"><strong>电话:</strong> ${data.data.Telephone}</p>
  2913. <p class="apple-modal-text"><strong>权限:</strong> ${power}</p>
  2914. </div>
  2915. `;
  2916. // 设置弹出框位置
  2917. userModal.style.top = `${rect.bottom + window.scrollY + 10}px`;
  2918. const leftPosition = rect.right + window.scrollX + 20; // 右侧位置
  2919. const rightEdge = leftPosition + modalWidth;
  2920. if (rightEdge > windowWidth) {
  2921. // 如果右侧超出窗口宽度,则将信息栏移动到按钮的左侧
  2922. const leftEdge = rect.left + window.scrollX - modalWidth - 20;
  2923. userModal.style.left = `${Math.max(20, leftEdge)}px`;
  2924. } else {
  2925. // 否则显示在按钮右侧
  2926. userModal.style.left = `${leftPosition}px`;
  2927. }
  2928. userModal.style.display = 'block';
  2929. userModal.style.opacity = '0'; // 先设置透明度为0
  2930. setTimeout(() => {
  2931. userModal.style.opacity = '1'; // 然后慢慢显示
  2932. }, 0); // 延迟一帧显示
  2933. // 增加过渡效果
  2934. userModal.style.transition = 'opacity 0.3s ease, top 0.3s ease, left 0.3s ease';
  2935. });
  2936. } else {
  2937. userModal.style.opacity = '0'; // 先设置透明度为0
  2938. setTimeout(() => {
  2939. userModal.style.display = 'none'; // 然后隐藏
  2940. }, 300); // 延迟0.3秒,等待过渡结束
  2941. }
  2942. }
  2943. function logout() {
  2944. localStorage.removeItem('Authorization');
  2945. window.location.href = '/';
  2946. }
  2947. // 添加到每个模态框的 JavaScript 部分
  2948. document.addEventListener('DOMContentLoaded', function() {
  2949. const modals = document.querySelectorAll('.modal');
  2950. modals.forEach(modal => {
  2951. modal.addEventListener('click', function(event) {
  2952. // 判断是否点击的是 modal 的背景
  2953. if (event.target === modal) {
  2954. modal.style.display = 'none';
  2955. }
  2956. });
  2957. });
  2958. });
  2959. function showUserManagement() {
  2960. document.getElementById('table-container').style.display = 'none';
  2961. document.getElementById('role-management').style.display = 'none'; // 隐藏角色管理页面
  2962. document.getElementById('user-management').style.display = 'block';
  2963. // 检查用户是否有 create_user 权限
  2964. const hasCreateUserPermission = userPermissions.includes('create_user');
  2965. // 获取添加用户按钮元素
  2966. const addUserButton = document.getElementById('addUserButton');
  2967. // 根据权限显示或隐藏添加用户按钮
  2968. if (hasCreateUserPermission) {
  2969. addUserButton.style.display = 'block';
  2970. } else {
  2971. addUserButton.style.display = 'none';
  2972. }
  2973. // 加载用户列表
  2974. fetchUsers();
  2975. }
  2976. function showTable() {
  2977. document.getElementById('user-management').style.display = 'none';
  2978. document.getElementById('role-management').style.display = 'none'; // 隐藏角色管理页面
  2979. document.getElementById('table-container').style.display = 'block';
  2980. }
  2981. function toggleSidebar() {
  2982. const sidebar = document.getElementById('sidebar');
  2983. const content = document.getElementById('content');
  2984. sidebar.classList.toggle('hidden');
  2985. content.classList.toggle('expanded');
  2986. const toggleButton = document.querySelector('.toggle-sidebar');
  2987. if (sidebar.classList.contains('hidden')) {
  2988. toggleButton.innerHTML = '>'; // 当侧边栏隐藏时,显示右箭头
  2989. } else {
  2990. toggleButton.innerHTML = '<'; // 当侧边栏显示时,显示左箭头
  2991. }
  2992. }
  2993. // document.getElementById('prev-page').addEventListener('click', () => {
  2994. // if (currentPage > 1) {
  2995. // fetchApplications(currentPage - 1, pageSize);
  2996. // }
  2997. // });
  2998. // document.getElementById('next-page').addEventListener('click', () => {
  2999. // fetchApplications(currentPage + 1, pageSize);
  3000. // });
  3001. function fetchUsername() {
  3002. fetch(`http://127.0.0.1:8080/api/admin/userInfo`, {
  3003. method: 'GET',
  3004. headers: {
  3005. 'Authorization': `Bearer ${token}`,
  3006. 'Content-Type': 'application/json'
  3007. }
  3008. })
  3009. .then(response => response.json())
  3010. .then(data => {
  3011. document.getElementById('username').textContent = data.data.Username;
  3012. currentUserRole = data.data.Role; // 存储当前用户的角色
  3013. currentUserName = data.data.Username
  3014. // 使用获取到的角色,调用获取权限的接口
  3015. fetchPermissionsByRole(currentUserRole)
  3016. .then(() => {
  3017. fetchApplications(LisOffset, pageSize); // 确保在权限获取之后才调用 fetchApplications
  3018. // 检查用户是否有 upload_license 权限
  3019. const hasUploadLicensePermission = userPermissions.includes('upload_license');
  3020. // 获取上传按钮元素
  3021. const uploadButton = document.querySelector('.upload-button');
  3022. // 根据权限显示或隐藏上传按钮
  3023. if (hasUploadLicensePermission) {
  3024. uploadButton.style.display = 'inline-block'; // 显示按钮
  3025. } else {
  3026. uploadButton.style.display = 'none'; // 隐藏按钮
  3027. }
  3028. });
  3029. });
  3030. }
  3031. function fetchPermissionsByRole(role) {
  3032. return fetch(`http://127.0.0.1:8080/api/admin/GetSelfRoles`, {
  3033. method: 'POST',
  3034. headers: {
  3035. 'Authorization': `Bearer ${token}`,
  3036. 'Content-Type': 'application/json'
  3037. },
  3038. body: JSON.stringify({ name: role })
  3039. })
  3040. .then(response => response.json())
  3041. .then(data => {
  3042. userPermissions = data.data.Permissions; // 获取用户的权限数组
  3043. console.log('userPermissions:', userPermissions);
  3044. // 定义权限类别
  3045. const licensePermissions = ['upload_license', 'read_license'];
  3046. const userPermissionsCheck = [ 'create_user', 'read_user', 'update_user', 'delete_user'];
  3047. const rolePermissions = ['create_role', 'delete_role', 'update_role', 'get_role'];
  3048. const hasLicenseAccess = licensePermissions.some(permission => userPermissions.includes(permission));
  3049. const hasUserManagementAccess = userPermissionsCheck.some(permission => userPermissions.includes(permission));
  3050. const hasRoleManagementAccess = rolePermissions.some(permission => userPermissions.includes(permission));
  3051. // 根据权限渲染菜单并显示初始页面
  3052. renderMenuAndInitialPage(hasLicenseAccess, hasUserManagementAccess, hasRoleManagementAccess);
  3053. });
  3054. }
  3055. function renderMenuAndInitialPage(hasLicenseAccess, hasUserManagementAccess, hasRoleManagementAccess) {
  3056. const sidebar = document.querySelector('.sidebar');
  3057. // 清空现有菜单项
  3058. sidebar.innerHTML = '';
  3059. let initialPageShown = false;
  3060. // 动态添加菜单项并确定初始显示的页面
  3061. if (hasLicenseAccess) {
  3062. const licenseButton = document.createElement('button');
  3063. licenseButton.textContent = 'License 管理';
  3064. licenseButton.onclick = showTable;
  3065. sidebar.appendChild(licenseButton);
  3066. if (!initialPageShown) {
  3067. showTable(); // 如果有License权限,先显示License页面
  3068. initialPageShown = true;
  3069. }
  3070. }
  3071. if (hasUserManagementAccess) {
  3072. const userManagementButton = document.createElement('button');
  3073. userManagementButton.textContent = '用户管理';
  3074. userManagementButton.onclick = showUserManagement;
  3075. sidebar.appendChild(userManagementButton);
  3076. if (!initialPageShown) {
  3077. showUserManagement(); // 如果没有License权限,但有用户管理权限,显示用户管理页面
  3078. initialPageShown = true;
  3079. }
  3080. }
  3081. if (hasRoleManagementAccess) {
  3082. const roleManagementButton = document.createElement('button');
  3083. roleManagementButton.textContent = '角色管理';
  3084. roleManagementButton.onclick = showRoleManagement;
  3085. sidebar.appendChild(roleManagementButton);
  3086. if (!initialPageShown) {
  3087. showRoleManagement(); // 如果没有License和用户管理权限,但有角色管理权限,显示角色管理页面
  3088. initialPageShown = true;
  3089. }
  3090. }
  3091. if (!initialPageShown && sidebar.firstChild) {
  3092. sidebar.firstChild.click(); // 如果没有优先的权限页面,则显示菜单中的第一个页面
  3093. }
  3094. }
  3095. // 页面初始化时调用 fetchUsername 函数
  3096. fetchUsername();
  3097. //fetchApplications(currentPage, pageSize);
  3098. </script>
  3099. </body>
  3100. </html>