license_info - 副本.html 127 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563
  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 = 0;
  1109. let totalPages = 0; // 存储总页数
  1110. let selectedPage =1;
  1111. const token = localStorage.getItem('Authorization');
  1112. let selectedRowData = null;
  1113. let isAscending = true;
  1114. let userMap = {}; // 用于存储用户名和用户ID的映射
  1115. let currentUserRole = ''; // 新增变量存储当前用户的权限
  1116. let currentUserName = ''; // 新增变量存储当前用户的名字
  1117. let userPermissions = [];// 全局变量,用于存储用户权限
  1118. let LicApplicationData = []; // 全局变量存储数据
  1119. let currentRolePermissions = []; // 这是您获取的当前角色的权限列表
  1120. function checkPermission(permission) {
  1121. console.log(`检查权限: ${permission} - ${hasPermission ? '有权限' : '无权限'}`);
  1122. return userPermissions.includes(permission);
  1123. }
  1124. //获取license展示信息
  1125. function fetchApplications(page, size) {
  1126. fetch(`http://127.0.0.1:8080/api/admin/GetAllLicenseInfo?page=${page}&pageSize=${size}`, {
  1127. method: 'GET',
  1128. headers: {
  1129. 'Authorization': `Bearer ${token}`,
  1130. 'Content-Type': 'application/json'
  1131. }
  1132. })
  1133. .then(response => response.json())
  1134. .then(data => {
  1135. LicApplicationData = data.data; // 将接收到的数据存储到全局变量
  1136. console.log(data); // 输出获取的数据结构
  1137. const hasGeneratePermission = userPermissions.includes("generate_license");
  1138. const hasDistributePermission = userPermissions.includes("dispat_license");
  1139. // 更新总页数
  1140. //totalPages = Math.ceil(data.total / 10);
  1141. // 在控制台打印权限结果
  1142. console.log(`hasGeneratePermission: ${hasGeneratePermission}, hasDistributePermission: ${hasDistributePermission}`);
  1143. totalPages = Math.ceil(data.total / 10);
  1144. const tableBody = document.querySelector('#applications-table tbody');
  1145. const tableHead = document.querySelector('#applications-table thead tr');
  1146. tableBody.innerHTML = '';
  1147. tableHead.innerHTML = `
  1148. <th></th> <!-- 添加一个空的表头用于放置下拉按钮 -->
  1149. <th>创建人</th>
  1150. <th>申请日期 <button class="sort-button" onclick="sortTableByDate()">排序</button></th>
  1151. <th>关联项目</th>
  1152. <th>销售人员</th>
  1153. <th>技服人员</th>
  1154. <th>总节点数</th>
  1155. <th>使用单位</th>
  1156. <th>操作</th> <!-- 新增的表头用于显示操作按钮 -->
  1157. `;
  1158. data.data.forEach(applicationArray => {
  1159. const firstApplication = applicationArray[0];
  1160. let showGenerateButton = false;
  1161. // Check if any child row has LicenseFlage as "未生成"
  1162. applicationArray.forEach(detail => {
  1163. if (detail.LicenseFlage === "未生成") {
  1164. showGenerateButton = true;
  1165. }
  1166. });
  1167. // 创建主行
  1168. const row = document.createElement('tr');
  1169. const dropdownButton = document.createElement('button');
  1170. // 使用CSS创建一个箭头图标
  1171. dropdownButton.innerHTML = '';
  1172. dropdownButton.classList.add('arrow-icon');
  1173. dropdownButton.style.cursor = 'pointer';
  1174. row.innerHTML = `
  1175. <td></td> <!-- 空的单元格用于放置下拉按钮 -->
  1176. <td>${createEllipsisText(firstApplication.Creator)}</td>
  1177. <td>${createEllipsisText(firstApplication.ApplicationDate)}</td>
  1178. <td>${createEllipsisText(firstApplication.GlxmName)}</td>
  1179. <td>${createEllipsisText(firstApplication.SalesPerson)}</td>
  1180. <td>${createEllipsisText(firstApplication.SupportPerson)}</td>
  1181. <td>${firstApplication.TotalNodes}</td>
  1182. <td>${createEllipsisText(firstApplication.Company)}</td>
  1183. `;
  1184. row.querySelector('td').appendChild(dropdownButton);
  1185. // 添加 License 状态按钮 (父级行)
  1186. if (hasGeneratePermission || hasDistributePermission) {
  1187. const licenseStatusCell = document.createElement('td');
  1188. if (hasGeneratePermission && showGenerateButton) {
  1189. licenseStatusCell.innerHTML += `<button class="license-status-btn generate" onclick="confirmGenerateLicense('${firstApplication.oa_request_id}', true)">生成</button>`;
  1190. } else if (hasDistributePermission && firstApplication.LicenseFlage === "已生成") {
  1191. licenseStatusCell.innerHTML += `<button class="license-status-btn distribute" onclick="showEmailModal('${firstApplication.SupportEmail}', '${firstApplication.SalesEmail}', '${firstApplication.UniqueID}')">分发</button>`;
  1192. }
  1193. // 添加一个分隔符
  1194. licenseStatusCell.innerHTML += `<span style="margin: 0 10px; display: inline-block; width: 1px; height: 20px; background-color: #ccc;"></span>`;
  1195. // 在这里添加“查看详情”按钮
  1196. licenseStatusCell.innerHTML += `<button class="license-status-btn view-details" onclick="showDetailsModal('${firstApplication.UniqueID}')">查看详情</button>`;
  1197. row.appendChild(licenseStatusCell);
  1198. }
  1199. tableBody.appendChild(row);
  1200. // 多行内容及表头 (子行)
  1201. const detailRow = document.createElement('tr');
  1202. const detailCell = document.createElement('td');
  1203. detailCell.colSpan = 11; // 占满所有列
  1204. detailCell.style.display = 'none';
  1205. const detailTable = document.createElement('table');
  1206. // 添加表头
  1207. const detailTableHeader = document.createElement('tr');
  1208. detailTableHeader.innerHTML = `
  1209. <th>产品名称</th>
  1210. <th>版本</th>
  1211. <th>节点数</th>
  1212. <th>处理器</th>
  1213. <th>操作系统</th>
  1214. <th>主MAC地址</th>
  1215. <th>副MAC地址</th>
  1216. <th> 查看</th>
  1217. `;
  1218. detailTable.appendChild(detailTableHeader);
  1219. // 添加详细信息行 (子行)
  1220. applicationArray.forEach(detail => {
  1221. const detailInnerRow = document.createElement('tr');
  1222. detailInnerRow.innerHTML = `
  1223. <td>${createEllipsisText(detail.ProductName)}</td>
  1224. <td>${createEllipsisText(detail.ProductVersion)}</td>
  1225. <td>${detail.NodeCount}</td>
  1226. <td>${createEllipsisText(detail.oa_cpu)}</td>
  1227. <td>${createEllipsisText(detail.oa_operating_system)}</td>
  1228. <td>${createEllipsisText(detail.oa_main_mac)}</td>
  1229. <td>${createEllipsisText(detail.oa_second_mac)}</td>
  1230. `;
  1231. // 添加 License 状态按钮 (子行)
  1232. // if (hasGeneratePermission || hasDistributePermission) {
  1233. // const licenseStatusDetailCell = document.createElement('td');
  1234. // if (hasGeneratePermission && detail.LicenseFlage === "未生成") {
  1235. // // 子行点击生成按钮时,传递 UniqueID 和 false 表示这是子行
  1236. // licenseStatusDetailCell.innerHTML = `<button class="license-status-btn generate" onclick="confirmGenerateLicense('${detail.UniqueID}', false)">生成</button>`;
  1237. // } else if (hasDistributePermission && detail.LicenseFlage === "已生成") {
  1238. // // 子行点击分发按钮时,传递 UniqueID 用于分发操作
  1239. // licenseStatusDetailCell.innerHTML = `<button class="license-status-btn distribute" onclick="showEmailModal('${detail.SupportEmail}', '${detail.SalesEmail}', '${detail.UniqueID}')">分发</button>`;
  1240. // }
  1241. // detailInnerRow.appendChild(licenseStatusDetailCell);
  1242. // }
  1243. detailTable.appendChild(detailInnerRow);
  1244. // 添加“查看详情”按钮 (子行)
  1245. const viewDetailsCell = document.createElement('td');
  1246. viewDetailsCell.innerHTML = `<button class="license-status-btn view-details" onclick="showDetailsModal('${detail.UniqueID}', true)">查看详情</button>`;
  1247. detailInnerRow.appendChild(viewDetailsCell);
  1248. detailTable.appendChild(detailInnerRow);
  1249. // 为每个详细信息行添加点击事件 (子行)
  1250. detailInnerRow.addEventListener('click', (event) => {
  1251. if (!event.target.closest('button')) {
  1252. openActionModal(event, detail, 'licenseActionModal');
  1253. }
  1254. });
  1255. detailInnerRow.addEventListener('contextmenu', (event) => {
  1256. event.preventDefault();
  1257. if (!event.target.closest('button')) {
  1258. openActionModal(event, detail, 'licenseActionModal');
  1259. }
  1260. });
  1261. });
  1262. detailCell.appendChild(detailTable);
  1263. detailRow.appendChild(detailCell);
  1264. tableBody.appendChild(detailRow);
  1265. // 主行的点击事件,用于切换下拉菜单的显示隐藏
  1266. // row.addEventListener('click', (event) => {
  1267. // if (!event.target.closest('button')) { // 如果点击的不是按钮
  1268. // detailCell.style.display = detailCell.style.display === 'none' ? 'table-cell' : 'none';
  1269. // }
  1270. // });
  1271. // // 点击下拉按钮切换显示隐藏
  1272. // dropdownButton.addEventListener('click', (event) => {
  1273. // event.stopPropagation(); // 阻止事件冒泡到行点击事件
  1274. // detailCell.style.display = detailCell.style.display === 'none' ? 'table-cell' : 'none';
  1275. // });
  1276. row.addEventListener('click', (event) => {
  1277. if (!event.target.closest('button')) { // 如果点击的不是按钮
  1278. const isExpanded = detailCell.style.display === 'table-cell';
  1279. detailCell.style.display = isExpanded ? 'none' : 'table-cell';
  1280. row.classList.toggle('expanded-row', !isExpanded);
  1281. dropdownButton.classList.toggle('rotate-arrow', !isExpanded); // 旋转箭头图标
  1282. }
  1283. });
  1284. dropdownButton.addEventListener('click', (event) => {
  1285. event.stopPropagation(); // 阻止事件冒泡到行点击事件
  1286. const isExpanded = detailCell.style.display === 'table-cell';
  1287. detailCell.style.display = isExpanded ? 'none' : 'table-cell';
  1288. row.classList.toggle('expanded-row', !isExpanded);
  1289. dropdownButton.classList.toggle('rotate-arrow', !isExpanded); // 旋转箭头图标
  1290. });
  1291. });
  1292. // 分页和其他控制逻辑
  1293. // 更新分页信息
  1294. // totalPages = Math.ceil(data.total / pageSize);
  1295. document.getElementById('pagination-info').textContent = `第 ${currentPage} 页,共 ${totalPages} 页`;
  1296. document.getElementById('prev-page').disabled = currentPage <= 1;
  1297. document.getElementById('next-page').disabled = currentPage >= totalPages;
  1298. const pageSelector = document.getElementById('page-selector');
  1299. pageSelector.innerHTML = '';
  1300. for (let i = 1; i <= totalPages; i++) {
  1301. const option = document.createElement('option');
  1302. option.value = i;
  1303. option.text = i;
  1304. if (i === selectedPage) {
  1305. option.selected = true;
  1306. document.getElementById('pagination-info').textContent = `第 ${selectedPage} 页,共 ${totalPages} 页`;
  1307. // LisOffset = selectedPage
  1308. // pageSize = LisOffset + 10;
  1309. // document.getElementById('prev-page').disabled = currentPage <= 1;
  1310. // document.getElementById('next-page').disabled = currentPage >= totalPages;
  1311. }
  1312. pageSelector.appendChild(option);
  1313. }
  1314. });
  1315. }
  1316. // 添加页数选择框的事件监听器
  1317. document.getElementById('page-selector').addEventListener('change', (event) => {
  1318. selectedPage = parseInt(event.target.value, 10);
  1319. const startRecord = (selectedPage - 1) * 10 + 1;
  1320. const endRecord = startRecord + 10;
  1321. LisOffset = selectedPage
  1322. pageSize = LisOffset* 10;
  1323. currentPage = selectedPage
  1324. fetchApplications(startRecord, endRecord);
  1325. });
  1326. // 分页按钮事件监听器
  1327. document.getElementById('prev-page').addEventListener('click', () => {
  1328. if (currentPage > 1) {
  1329. currentPage--;
  1330. selectedPage--
  1331. LisOffset -= pageSize-LisOffset;
  1332. pageSize -= 10; // 减少一页时也减小 pageSize,规则可自定义
  1333. fetchApplications(LisOffset, pageSize);
  1334. }
  1335. });
  1336. document.getElementById('next-page').addEventListener('click', () => {
  1337. if (currentPage < totalPages) {
  1338. currentPage++
  1339. selectedPage++
  1340. LisOffset += pageSize-LisOffset;
  1341. pageSize += 10; // 增加页数时,增加 pageSize,规则可自定义
  1342. fetchApplications(LisOffset, pageSize);
  1343. }
  1344. });
  1345. // 页面加载时默认调用第一页的数据
  1346. //fetchApplications(1);
  1347. // 页面初始化时调用 fetchUsername 函数
  1348. fetchUsername();
  1349. fetchApplications(LisOffset,pageSize);
  1350. //排序
  1351. // function sortTableByDate() {
  1352. // applicationData.sort((a, b) => {
  1353. // const dateTimeA = `${a[0].ApplicationDate} ${a[0].ApplicationTime}`;
  1354. // const dateTimeB = `${b[0].ApplicationDate} ${b[0].ApplicationTime}`;
  1355. // return isAscending ? dateTimeA.localeCompare(dateTimeB) : dateTimeB.localeCompare(dateTimeA);
  1356. // });
  1357. // renderTable(applicationData); // 排序后重新渲染表格
  1358. // isAscending = !isAscending; // 切换排序顺序
  1359. // }
  1360. // 创建带省略号的文本,并在鼠标悬停时显示完整内容
  1361. function createEllipsisText(text) {
  1362. const maxLength = 20; // 最大显示字符数
  1363. if (text == null || typeof text !== 'string') {
  1364. return ''; // 如果 text 是 null、undefined 或不是字符串,返回空字符串
  1365. }
  1366. if (text.length > maxLength) {
  1367. const span = document.createElement('span');
  1368. span.textContent = text.substring(0, maxLength) + '...';
  1369. span.title = text; // 鼠标悬停时显示完整内容
  1370. return span.outerHTML;
  1371. }
  1372. return text;
  1373. }
  1374. //生成licensestr
  1375. function confirmGenerateLicense(id, isParentRow) {
  1376. const confirmGenerateModal = document.getElementById('confirmGenerateModal');
  1377. confirmGenerateModal.style.display = 'block';
  1378. document.getElementById('confirm-generate-button').onclick = function() {
  1379. generateLicense(id, isParentRow);
  1380. };
  1381. }
  1382. function generateLicense(id, isParentRow) {
  1383. const payload = isParentRow ? { oa_request_id: id } : { uniqueID: id };
  1384. fetch('http://127.0.0.1:8080/api/admin/GenerateLicense', {
  1385. method: 'POST',
  1386. headers: {
  1387. 'Authorization': `Bearer ${token}`,
  1388. 'Content-Type': 'application/json'
  1389. },
  1390. body: JSON.stringify(payload)
  1391. })
  1392. .then(response => response.json())
  1393. .then(data => {
  1394. if (data.success) {
  1395. alert('License生成成功!');
  1396. fetchApplications(LisOffset, pageSize);
  1397. } else {
  1398. alert('License生成失败:' + data.error);
  1399. }
  1400. closeModal('confirmGenerateModal');
  1401. });
  1402. }
  1403. //查看lic所有信息
  1404. function showDetailsModal(uniqueID, isChildRow = false) {
  1405. let selectedData = null;
  1406. if (isChildRow) {
  1407. // 查找子行数据
  1408. for (let applicationArray of LicApplicationData) {
  1409. selectedData = applicationArray.find(data => data.UniqueID === uniqueID);
  1410. if (selectedData) {
  1411. break;
  1412. }
  1413. }
  1414. if (!selectedData) {
  1415. console.error('未找到对应的子行记录,UniqueID:', uniqueID);
  1416. alert('未找到对应的子行记录,请检查数据');
  1417. return;
  1418. }
  1419. // 准备在模态框中显示的子行内容
  1420. let detailsHtml = `<div class="apple-modal-content">`;
  1421. detailsHtml += `<h3 class="apple-modal-title">详细信息</h3>`;
  1422. detailsHtml += `
  1423. <p class="apple-modal-text"><strong>产品名称:</strong> ${selectedData.ProductName}</p>
  1424. <p class="apple-modal-text"><strong>版本:</strong> ${selectedData.ProductVersion}</p>
  1425. <p class="apple-modal-text"><strong>节点数:</strong> ${selectedData.NodeCount}</p>
  1426. <p class="apple-modal-text"><strong>处理器:</strong> ${selectedData.oa_cpu}</p>
  1427. <p class="apple-modal-text"><strong>操作系统:</strong> ${selectedData.oa_operating_system}</p>
  1428. <p class="apple-modal-text"><strong>主MAC地址:</strong> ${selectedData.oa_main_mac}</p>
  1429. <p class="apple-modal-text"><strong>副MAC地址:</strong> ${selectedData.oa_second_mac}</p>
  1430. `;
  1431. detailsHtml += `</div>`;
  1432. // 显示模态框
  1433. document.getElementById('detailsContent').innerHTML = detailsHtml;
  1434. document.getElementById('detailsModal').style.display = 'block';
  1435. } else {
  1436. // 查找主行数据
  1437. let selectedApplicationArray = null;
  1438. for (let applicationArray of LicApplicationData) {
  1439. if (applicationArray.some(data => data.UniqueID === uniqueID)) {
  1440. selectedApplicationArray = applicationArray;
  1441. break;
  1442. }
  1443. }
  1444. if (!selectedApplicationArray) {
  1445. console.error('未找到对应的记录,UniqueID:', uniqueID);
  1446. alert('未找到对应的记录,请检查数据');
  1447. return;
  1448. }
  1449. // 准备在模态框中显示的主行和子行的全部内容
  1450. let detailsHtml = `<div class="apple-modal-content">`;
  1451. detailsHtml += `<h3 class="apple-modal-title">项目信息</h3>`;
  1452. // 显示主行的第一条记录信息
  1453. const firstData = selectedApplicationArray[0];
  1454. detailsHtml += `
  1455. <p class="apple-modal-text"><strong>创建人:</strong> ${firstData.Creator}</p>
  1456. <p class="apple-modal-text"><strong>申请日期:</strong> ${firstData.ApplicationDate}</p>
  1457. <p class="apple-modal-text"><strong>关联项目:</strong> ${firstData.GlxmName}</p>
  1458. <p class="apple-modal-text"><strong>销售人员:</strong> ${firstData.SalesPerson}</p>
  1459. <p class="apple-modal-text"><strong>技服人员:</strong> ${firstData.SupportPerson}</p>
  1460. <p class="apple-modal-text"><strong>总节点数:</strong> ${firstData.TotalNodes}</p>
  1461. <p class="apple-modal-text"><strong>使用单位:</strong> ${firstData.Company}</p>
  1462. `;
  1463. // 显示子行的每条记录信息
  1464. detailsHtml += `<h3 class="apple-modal-title">集群信息</h3>`;
  1465. selectedApplicationArray.forEach((data, index) => {
  1466. detailsHtml += `
  1467. <h4 class="apple-modal-subtitle">集群 ${index + 1}</h4>
  1468. <p class="apple-modal-text"><strong>产品名称:</strong> ${data.ProductName}</p>
  1469. <p class="apple-modal-text"><strong>版本:</strong> ${data.ProductVersion}</p>
  1470. <p class="apple-modal-text"><strong>节点数:</strong> ${data.NodeCount}</p>
  1471. <p class="apple-modal-text"><strong>处理器:</strong> ${data.oa_cpu}</p>
  1472. <p class="apple-modal-text"><strong>操作系统:</strong> ${data.oa_operating_system}</p>
  1473. <p class="apple-modal-text"><strong>主MAC地址:</strong> ${data.oa_main_mac}</p>
  1474. <p class="apple-modal-text"><strong>副MAC地址:</strong> ${data.oa_second_mac}</p>
  1475. <h4 class="apple-modal-subtitle"> -------------------------------</h4>
  1476. `;
  1477. });
  1478. detailsHtml += `</div>`;
  1479. // 显示模态框
  1480. document.getElementById('detailsContent').innerHTML = detailsHtml;
  1481. document.getElementById('detailsModal').style.display = 'block';
  1482. }
  1483. }
  1484. // 用户管理菜单栏
  1485. function openUserActionModal(event, data, modalId) {
  1486. selectedRowData = data;
  1487. let modal = document.getElementById(modalId);
  1488. const modalContent = modal.querySelector('.modal-content');
  1489. // 清空之前的内容
  1490. modalContent.innerHTML = `
  1491. <span class="close" onclick="closeModal('${modalId}')">&times;</span>
  1492. `;
  1493. // 动态生成更多用户信息按钮
  1494. if (userPermissions.includes('read_user')) {
  1495. modalContent.innerHTML += `<button onclick="showMoreUserInfo(); closeModal('${modalId}');">更多用户信息</button>`;
  1496. }
  1497. // 检查是否有 `update_user` 权限,决定是否显示修改用户按钮
  1498. if (userPermissions.includes('update_user')) {
  1499. modalContent.innerHTML += `<button onclick="modifyUser(); closeModal('${modalId}');">修改用户</button>`;
  1500. }
  1501. // 检查是否有 `delete_user` 权限,决定是否显示删除按钮
  1502. if (userPermissions.includes('delete_user')) {
  1503. modalContent.innerHTML += `<button onclick="confirmDeleteUser('${data.UniqueID}'); closeModal('${modalId}');">删除用户</button>`;
  1504. }
  1505. // 显示菜单位置
  1506. modalContent.style.top = `${event.clientY}px`;
  1507. modalContent.style.left = `${event.clientX}px`;
  1508. modal.style.display = 'block';
  1509. }
  1510. // 为用户管理界面的每一行添加点击和右键事件监听器
  1511. function fetchUsers() {
  1512. fetch('http://127.0.0.1:8080/api/admin/userInfoAll', {
  1513. method: 'GET',
  1514. headers: {
  1515. 'Authorization': `Bearer ${token}`,
  1516. 'Content-Type': 'application/json'
  1517. }
  1518. })
  1519. .then(response => response.json())
  1520. .then(data => {
  1521. const tableBody = document.querySelector('#users-table tbody');
  1522. tableBody.innerHTML = '';
  1523. data.data.forEach(user => {
  1524. // 如果 ACCOUNT 字段为 'admin',则跳过这一行
  1525. if (user.Account === 'admin') {
  1526. return;
  1527. }
  1528. const row = document.createElement('tr');
  1529. row.innerHTML = `
  1530. <td>${user.Username}</td>
  1531. <td>${user.Telephone}</td>
  1532. <td>${user.Email}</td>
  1533. <td>${user.Role}</td>
  1534. <td>${user.Account}</td>
  1535. `;
  1536. row.addEventListener('click', (event) => {
  1537. if (!event.target.classList.contains('ios-button')) {
  1538. openUserActionModal(event, user, 'userActionModal');
  1539. }
  1540. });
  1541. row.addEventListener('contextmenu', (event) => {
  1542. event.preventDefault();
  1543. if (!event.target.classList.contains('ios-button')) {
  1544. openUserActionModal(event, user, 'userActionModal');
  1545. }
  1546. });
  1547. tableBody.appendChild(row);
  1548. });
  1549. });
  1550. }
  1551. //查看用户lic历史
  1552. function showUserLicenseHistory() {
  1553. fetch(`http://127.0.0.1:8080/api/admin/GetlicenseRecordInfoByUser`, {
  1554. method: 'POST',
  1555. headers: {
  1556. 'Authorization': `Bearer ${token}`,
  1557. 'Content-Type': 'application/json'
  1558. },
  1559. body: JSON.stringify({
  1560. Id: selectedRowData.Id,
  1561. UserName: selectedRowData.Username,
  1562. Page: 1,
  1563. PageSize: 10
  1564. })
  1565. })
  1566. .then(response => response.json())
  1567. .then(data => {
  1568. const extraInfoContent = document.getElementById('extraInfoContent');
  1569. extraInfoContent.innerHTML = `<h3>License 分发记录</h3>`;
  1570. if (data.data && data.data.length > 0) {
  1571. const table = document.createElement('table');
  1572. table.style.width = '100%';
  1573. table.style.borderCollapse = 'collapse';
  1574. table.style.marginTop = '10px';
  1575. const thead = document.createElement('thead');
  1576. const headerRow = document.createElement('tr');
  1577. const headers = ['分发日期', '关联项目', '产品名称', '版本', '节点数', 'Company'];
  1578. headers.forEach(headerText => {
  1579. const th = document.createElement('th');
  1580. th.textContent = headerText;
  1581. th.style.border = '1px solid #ddd';
  1582. th.style.padding = '8px';
  1583. th.style.backgroundColor = '#f1f1f1';
  1584. headerRow.appendChild(th);
  1585. });
  1586. thead.appendChild(headerRow);
  1587. table.appendChild(thead);
  1588. const tbody = document.createElement('tbody');
  1589. data.data.forEach(record => {
  1590. const row = document.createElement('tr');
  1591. const cells = [
  1592. record.up_time.Time,
  1593. record.AssociatedProject,
  1594. record.ProductName,
  1595. record.Version,
  1596. record.NodeCount,
  1597. record.Company
  1598. ];
  1599. cells.forEach(cellText => {
  1600. const td = document.createElement('td');
  1601. td.textContent = cellText;
  1602. td.style.border = '1px solid #ddd';
  1603. td.style.padding = '8px';
  1604. row.appendChild(td);
  1605. });
  1606. tbody.appendChild(row);
  1607. });
  1608. table.appendChild(tbody);
  1609. extraInfoContent.appendChild(table);
  1610. } else {
  1611. extraInfoContent.innerHTML += `<p>没有找到分发记录。</p>`;
  1612. }
  1613. document.getElementById('extraInfoModal').style.display = 'block';
  1614. });
  1615. }
  1616. //用户菜单栏
  1617. function openActionModal(event, data, modalId) {
  1618. selectedRowData = data;
  1619. let modal = document.getElementById(modalId);
  1620. const modalContent = modal.querySelector('.modal-content');
  1621. // 清空之前的内容
  1622. modalContent.innerHTML = `
  1623. <span class="close" onclick="closeModal('${modalId}')">&times;</span>
  1624. `;
  1625. // 动态生成查看分发记录
  1626. if (userPermissions.includes('read_license_record')) {
  1627. modalContent.innerHTML += `
  1628. <button onclick="showDistributionHistory(); closeModal('${modalId}');">查看分发记录</button>
  1629. `;
  1630. }
  1631. // 动态生成查看额外信息
  1632. if (userPermissions.includes('read_license')) {
  1633. modalContent.innerHTML += `
  1634. <button onclick="showExtraInfo(); closeModal('${modalId}');">查看额外信息</button>
  1635. `;
  1636. }
  1637. // 检查是否有 `update_license` 权限,决定是否显示修改信息按钮
  1638. if (userPermissions.includes('update_license')) {
  1639. modalContent.innerHTML += `<button onclick="modifyLicenseInfo(); closeModal('${modalId}');">修改信息</button>`;
  1640. }
  1641. // 检查是否有 `delete_license` 权限,决定是否显示删除按钮
  1642. if (userPermissions.includes('delete_license')) {
  1643. modalContent.innerHTML += `<button onclick="confirmDelete(); closeModal('${modalId}');">删除</button>`;
  1644. }
  1645. // 显示菜单位置
  1646. modalContent.style.top = `${event.clientY}px`;
  1647. modalContent.style.left = `${event.clientX}px`;
  1648. modal.style.display = 'block';
  1649. }
  1650. function closeModal(modalId) {
  1651. document.getElementById(modalId).style.display = 'none';
  1652. }
  1653. function closeUserInfo() {
  1654. document.getElementById('userModal').style.display = 'none';
  1655. }
  1656. function confirmDelete() {
  1657. const confirmDeleteModal = document.getElementById('confirmDeleteModal');
  1658. confirmDeleteModal.innerHTML = `
  1659. <div class="centered-modal-content">
  1660. <span class="close" onclick="closeModal('confirmDeleteModal')" style="font-size: 24px; font-weight: bold; color: #555; cursor: pointer;">&times;</span>
  1661. <div style="margin-bottom: 15px; border: 1px solid #ddd; padding: 10px; border-radius: 10px;">
  1662. <p><strong>申请日期:</strong> ${selectedRowData.ApplicationDate}</p>
  1663. <p><strong>关联项目:</strong> ${selectedRowData.AssociatedProject}</p>
  1664. <p><strong>使用单位:</strong> ${selectedRowData.Company}</p>
  1665. </div>
  1666. <p>确认删除此行数据吗?</p>
  1667. <button class="flat-rounded-button" onclick="deleteRow()">确认</button>
  1668. <button class="flat-rounded-button" onclick="closeModal('confirmDeleteModal')">取消</button>
  1669. </div>
  1670. `;
  1671. confirmDeleteModal.style.display = 'block';
  1672. }
  1673. //添加用户
  1674. document.getElementById('addUserButton').addEventListener('click', function() {
  1675. document.getElementById('addUserModal').style.display = 'block';
  1676. });
  1677. //添加用户
  1678. function saveNewUser() {
  1679. const username = document.getElementById('addUsername').value.trim();
  1680. const password = document.getElementById('addPassword').value.trim();
  1681. const account = document.getElementById('addAccount').value.trim();
  1682. const telephone = document.getElementById('addTelephone').value.trim();
  1683. const email = document.getElementById('addEmail').value.trim();
  1684. // 验证每个字段都不能为空
  1685. if (!username || !password || !account || !telephone || !email) {
  1686. alert('有空选项未填写');
  1687. return;
  1688. }
  1689. // 验证电话是否为11位数字
  1690. const phonePattern = /^\d{11}$/;
  1691. if (!phonePattern.test(telephone)) {
  1692. alert('电话必须是11位数字');
  1693. return;
  1694. }
  1695. // 验证密码长度是否至少为6位
  1696. if (password.length < 6) {
  1697. alert('密码长度必须至少为6位');
  1698. return;
  1699. }
  1700. // 验证邮箱是否包含@符号
  1701. if (!email.includes('@')) {
  1702. alert('邮箱必须包含@符号');
  1703. return;
  1704. }
  1705. // 验证账号长度是否至少为3位
  1706. if (account.length < 3) {
  1707. alert('账号长度必须至少为3位');
  1708. return;
  1709. }
  1710. const newUser = {
  1711. Username: username,
  1712. Password: password,
  1713. Account: account,
  1714. Telephone: telephone,
  1715. Email: email
  1716. };
  1717. fetch('http://127.0.0.1:8080/api/register', { // 修改为实际的API路径
  1718. method: 'POST',
  1719. headers: {
  1720. 'Authorization': `Bearer ${token}`,
  1721. 'Content-Type': 'application/json'
  1722. },
  1723. body: JSON.stringify(newUser)
  1724. })
  1725. .then(response => response.json())
  1726. .then(data => {
  1727. if (data.success) {
  1728. alert('用户创建成功!');
  1729. fetchUsers(); // 重新加载用户列表
  1730. closeModal('addUserModal'); // 关闭模态框
  1731. } else {
  1732. alert('用户创建失败:' + data.error);
  1733. }
  1734. });
  1735. }
  1736. function deleteUser(uniqueID) {
  1737. fetch('http://127.0.0.1:8080/api/admin/deleteUser', {
  1738. method: 'POST',
  1739. headers: {
  1740. 'Authorization': `Bearer ${token}`,
  1741. 'Content-Type': 'application/json'
  1742. },
  1743. body: JSON.stringify({ UniqueID: uniqueID })
  1744. })
  1745. .then(response => response.json())
  1746. .then(data => {
  1747. if (data.success) {
  1748. alert('用户删除成功!');
  1749. fetchUsers(); // 重新加载用户列表
  1750. } else {
  1751. alert('用户删除失败:' + data.error);
  1752. }
  1753. })
  1754. .catch(error => {
  1755. console.error('Error deleting user:', error);
  1756. alert('删除用户时发生错误,请稍后再试。');
  1757. });
  1758. }
  1759. function confirmDeleteUser(uniqueID) {
  1760. const confirmed = confirm("确认删除此用户吗?");
  1761. if (confirmed) {
  1762. deleteUser(uniqueID);
  1763. }
  1764. }
  1765. function deleteRow() {
  1766. fetch(`http://127.0.0.1:8080/api/admin/deleteLicRow`, {
  1767. method: 'POST',
  1768. headers: {
  1769. 'Authorization': `Bearer ${token}`,
  1770. 'Content-Type': 'application/json'
  1771. },
  1772. body: JSON.stringify({ uniqueID: selectedRowData.UniqueID })
  1773. }).then(response => {
  1774. if (response.ok) {
  1775. alert('删除成功');
  1776. closeModal('confirmDeleteModal');
  1777. fetchApplications(LisOffset, pageSize);
  1778. } else {
  1779. alert('删除失败');
  1780. }
  1781. });
  1782. }
  1783. function showEmailModal(supportEmail, salesEmail, uniqueID) {
  1784. // 清空并设置默认值
  1785. document.getElementById('emailInputs').innerHTML = `
  1786. <div>
  1787. <input type="checkbox" id="supportEmailCheckbox" value="${supportEmail}" checked>
  1788. <label for="supportEmailCheckbox"> 运维邮箱: ${supportEmail}</label>
  1789. </div>
  1790. <div>
  1791. <input type="checkbox" id="salesEmailCheckbox" value="${salesEmail}" checked>
  1792. <label for="salesEmailCheckbox"> 销售邮箱: ${salesEmail}</label>
  1793. </div>
  1794. `;
  1795. document.getElementById('userInputs').innerHTML = ''; // 清空用户输入
  1796. // 获取用户信息并填充第一个用户输入框
  1797. fetch('http://127.0.0.1:8080/api/admin/distributeLicenseByUserInfo', {
  1798. method: 'GET',
  1799. headers: {
  1800. 'Authorization': `Bearer ${token}`,
  1801. 'Content-Type': 'application/json'
  1802. }
  1803. })
  1804. .then(response => response.json())
  1805. .then(data => {
  1806. const userSelect = document.createElement('select');
  1807. userSelect.id = 'userSelect1';
  1808. userSelect.className = 'email-modal-input';
  1809. data.data.forEach(user => {
  1810. userMap[user.Username] = {// 存储用户名和用户ID的映射
  1811. Account: user.Account,
  1812. UniqueID: user.UniqueID,
  1813. Username: user.Username,
  1814. Email: user.Email,
  1815. Role: user.Role,
  1816. Telephone:user.Telephone
  1817. };
  1818. const option = document.createElement('option');
  1819. option.value = user.Username;
  1820. option.textContent = user.Username;
  1821. userSelect.appendChild(option);
  1822. });
  1823. //document.getElementById('userInputs').appendChild(userSelect);
  1824. });
  1825. document.getElementById('emailModal').style.display = 'block';
  1826. selectedRowData = { ...selectedRowData, UniqueID: uniqueID };
  1827. }
  1828. function addEmailInput() {
  1829. const emailInputs = document.getElementById('emailInputs');
  1830. const newInputDiv = document.createElement('div');
  1831. newInputDiv.style.display = 'flex';
  1832. newInputDiv.style.alignItems = 'center';
  1833. newInputDiv.style.marginBottom = '10px';
  1834. const newInput = document.createElement('input');
  1835. newInput.type = 'text';
  1836. newInput.className = 'email-modal-input';
  1837. newInput.style.flexGrow = '1';
  1838. newInputDiv.appendChild(newInput);
  1839. const deleteButton = document.createElement('button');
  1840. deleteButton.textContent = '✕';
  1841. deleteButton.style.background = 'none';
  1842. deleteButton.style.border = 'none';
  1843. deleteButton.style.color = '#007aff';
  1844. deleteButton.style.cursor = 'pointer';
  1845. deleteButton.style.fontSize = '12px'; /* 再次缩小字体大小 */
  1846. deleteButton.style.padding = '0'; /* 移除内边距 */
  1847. deleteButton.style.marginLeft = '3px'; /* 减少与输入框的间距 */
  1848. deleteButton.style.width = '20px'; /* 限制按钮宽度 */
  1849. deleteButton.style.height = '20px'; /* 限制按钮高度 */
  1850. deleteButton.onclick = () => {
  1851. newInputDiv.remove();
  1852. };
  1853. newInputDiv.appendChild(deleteButton);
  1854. emailInputs.appendChild(newInputDiv);
  1855. }
  1856. function addUserInput() {
  1857. const userInputs = document.getElementById('userInputs');
  1858. const newUserDiv = document.createElement('div');
  1859. newUserDiv.className = 'user-select-container';
  1860. newUserDiv.style.display = 'flex';
  1861. newUserDiv.style.alignItems = 'center';
  1862. newUserDiv.style.marginBottom = '10px';
  1863. const newUserSelect = document.createElement('select');
  1864. newUserSelect.className = 'email-modal-input';
  1865. newUserSelect.style.flexGrow = '1';
  1866. newUserSelect.style.marginRight = '5px';
  1867. // 添加一个默认的空白选项
  1868. const defaultOption = document.createElement('option');
  1869. defaultOption.value = '';
  1870. defaultOption.textContent = '请选择用户';
  1871. newUserSelect.appendChild(defaultOption);
  1872. // 获取当前已选择的用户
  1873. const selectedValues = Array.from(document.querySelectorAll('.user-select-container select'))
  1874. .map(select => select.value);
  1875. // 获取用户列表并填充到选择框中
  1876. fetch('http://127.0.0.1:8080/api/admin/distributeLicenseByUserInfo', {
  1877. method: 'GET',
  1878. headers: {
  1879. 'Authorization': `Bearer ${token}`,
  1880. 'Content-Type': 'application/json'
  1881. }
  1882. })
  1883. .then(response => response.json())
  1884. .then(data => {
  1885. data.data.forEach(user => {
  1886. // 仅显示未被选中的用户,并且过滤掉admin用户
  1887. if (!selectedValues.includes(user.Username) && user.Username !== 'admin') {
  1888. const option = document.createElement('option');
  1889. option.value = user.Username;
  1890. option.textContent = user.Username;
  1891. newUserSelect.appendChild(option);
  1892. }
  1893. });
  1894. });
  1895. const deleteButton = document.createElement('button');
  1896. deleteButton.textContent = '✕';
  1897. deleteButton.style.background = 'none';
  1898. deleteButton.style.border = 'none';
  1899. deleteButton.style.color = '#007aff';
  1900. deleteButton.style.cursor = 'pointer';
  1901. deleteButton.style.fontSize = '12px';
  1902. deleteButton.style.padding = '0';
  1903. deleteButton.style.marginLeft = '3px';
  1904. deleteButton.style.width = '20px';
  1905. deleteButton.style.height = '20px';
  1906. deleteButton.onclick = () => {
  1907. newUserDiv.remove();
  1908. updateUserOptions(); // 更新其他下拉框中的选项
  1909. };
  1910. newUserSelect.addEventListener('change', updateUserOptions);
  1911. newUserDiv.appendChild(newUserSelect);
  1912. newUserDiv.appendChild(deleteButton);
  1913. userInputs.appendChild(newUserDiv);
  1914. // 设置空白选项为默认选项
  1915. newUserSelect.selectedIndex = 0;
  1916. }
  1917. function updateUserOptions() {
  1918. const selectedValues = Array.from(document.querySelectorAll('.user-select-container select'))
  1919. .map(select => select.value);
  1920. document.querySelectorAll('.user-select-container select').forEach(select => {
  1921. const currentValue = select.value;
  1922. select.innerHTML = ''; // 清空现有选项
  1923. // 添加一个默认的空白选项
  1924. const defaultOption = document.createElement('option');
  1925. defaultOption.value = '';
  1926. defaultOption.textContent = '请选择用户';
  1927. select.appendChild(defaultOption);
  1928. fetch('http://127.0.0.1:8080/api/admin/userInfoAll', {
  1929. method: 'GET',
  1930. headers: {
  1931. 'Authorization': `Bearer ${token}`,
  1932. 'Content-Type': 'application/json'
  1933. }
  1934. })
  1935. .then(response => response.json())
  1936. .then(data => {
  1937. data.data.forEach(user => {
  1938. if (!selectedValues.includes(user.Username) || user.Username === currentValue) {
  1939. if (user.Username !== 'admin') { // 过滤掉admin用户
  1940. const option = document.createElement('option');
  1941. option.value = user.Username;
  1942. option.textContent = user.Username;
  1943. select.appendChild(option);
  1944. }
  1945. }
  1946. });
  1947. select.value = currentValue;
  1948. });
  1949. });
  1950. }
  1951. // 打开修改信息表单框
  1952. function modifyLicenseInfo() {
  1953. const form = document.getElementById('modifyLicenseForm');
  1954. // 将选中的行数据填充到表单中
  1955. form.creator.value = selectedRowData.Creator;
  1956. form.applicationDate.value = selectedRowData.ApplicationDate;
  1957. form.associatedProject.value = selectedRowData.GlxmName;
  1958. form.salesPerson.value = selectedRowData.SalesPerson;
  1959. form.salesEmail.value = selectedRowData.SalesEmail;
  1960. form.supportPerson.value = selectedRowData.SupportPerson;
  1961. form.supportEmail.value = selectedRowData.SupportEmail;
  1962. form.totalNodes.value = selectedRowData.TotalNodes;
  1963. form.company.value = selectedRowData.Company;
  1964. form.productName.value = selectedRowData.ProductName;
  1965. form.version.value = selectedRowData.ProductVersion;
  1966. form.nodeCount.value = selectedRowData.NodeCount;
  1967. document.getElementById('modifyLicenseModal').style.display = 'block';
  1968. }
  1969. // 保存修改后的数据
  1970. function saveLicenseChanges() {
  1971. const form = document.getElementById('modifyLicenseForm');
  1972. const updatedData = {
  1973. UniqueID: selectedRowData.UniqueID,
  1974. Creator: form.creator.value,
  1975. ApplicationDate: form.applicationDate.value,
  1976. AssociatedProject: form.associatedProject.value,
  1977. SalesPerson: form.salesPerson.value,
  1978. SalesEmail: form.salesEmail.value,
  1979. SupportPerson: form.supportPerson.value,
  1980. SupportEmail: form.supportEmail.value,
  1981. TotalNodes: parseInt(form.totalNodes.value, 10), // 将 TotalNodes 转换为整数
  1982. Company: form.company.value,
  1983. ProductName: form.productName.value,
  1984. Version: form.version.value,
  1985. NodeCount: parseInt(form.nodeCount.value, 10), // 将 NodeCount 转换为整数
  1986. };
  1987. fetch(`http://127.0.0.1:8080/api/admin/UpdateLicense`, {
  1988. method: 'POST',
  1989. headers: {
  1990. 'Authorization': `Bearer ${token}`,
  1991. 'Content-Type': 'application/json'
  1992. },
  1993. body: JSON.stringify(updatedData)
  1994. })
  1995. .then(response => response.json())
  1996. .then(data => {
  1997. if (data.success) {
  1998. alert('License信息更新成功!');
  1999. fetchApplications(LisOffset, pageSize);
  2000. closeModal('modifyLicenseModal');
  2001. } else {
  2002. alert('License信息更新失败:' + data.error);
  2003. }
  2004. });
  2005. }
  2006. function updateUserOptions() {
  2007. const selectedValues = Array.from(document.querySelectorAll('.user-select-container select'))
  2008. .map(select => select.value);
  2009. document.querySelectorAll('.user-select-container select').forEach(select => {
  2010. const currentValue = select.value; // 保留当前选择值
  2011. select.innerHTML = ''; // 清空现有选项
  2012. fetch('http://127.0.0.1:8080/api/admin/distributeLicenseByUserInfo', {
  2013. method: 'GET',
  2014. headers: {
  2015. 'Authorization': `Bearer ${token}`,
  2016. 'Content-Type': 'application/json'
  2017. }
  2018. })
  2019. .then(response => response.json())
  2020. .then(data => {
  2021. data.data.forEach(user => {
  2022. // 保留当前值,并排除已经在其他下拉框中选中的值
  2023. if (!selectedValues.includes(user.Username) || user.Username === currentValue) {
  2024. const option = document.createElement('option');
  2025. option.value = user.Username;
  2026. option.textContent = user.Username;
  2027. if (user.Username === currentValue) {
  2028. option.selected = true; // 保持当前选择
  2029. }
  2030. select.appendChild(option);
  2031. }
  2032. });
  2033. });
  2034. });
  2035. }
  2036. //lic分发给用户 与邮件
  2037. function sendEmail() {
  2038. console.log('Send button clicked');
  2039. const emailInputs = document.querySelectorAll('.email-modal-input[type="text"]');
  2040. let emails = Array.from(emailInputs)
  2041. .map(input => input.value.trim())
  2042. .filter(email => email && email.includes('@'))
  2043. .join(',');
  2044. const supportEmailChecked = document.getElementById('supportEmailCheckbox').checked;
  2045. const salesEmailChecked = document.getElementById('salesEmailCheckbox').checked;
  2046. const emailArray = emails ? [emails] : [];
  2047. if (supportEmailChecked) {
  2048. emailArray.push(document.getElementById('supportEmailCheckbox').value);
  2049. }
  2050. if (salesEmailChecked) {
  2051. emailArray.push(document.getElementById('salesEmailCheckbox').value);
  2052. }
  2053. emails = emailArray.join(',');
  2054. // if (!emails) {
  2055. // alert('请至少选择一个邮箱地址。');
  2056. // return;
  2057. // }
  2058. console.log('Emails to send:', emails);
  2059. const userInputs = document.querySelectorAll('select.email-modal-input');
  2060. console.log('userMap:', userMap);
  2061. const users = Array.from(userInputs)
  2062. .map(select => userMap[select.value].Account)
  2063. .join(',');
  2064. const userIds = Array.from(userInputs)
  2065. .map(select => userMap[select.value].UniqueID)
  2066. .join(',');
  2067. const userNames = Array.from(userInputs)
  2068. .map(select => userMap[select.value].Username);
  2069. const operatorUniqueID = userMap[currentUserName].UniqueID;
  2070. console.log('User IDs:', userIds);
  2071. console.log('Users:', users);
  2072. console.log(' selectedRowData.UniqueID:', selectedRowData.UniqueID);
  2073. if (!userIds) {
  2074. alert('请至少选择一个用户。');
  2075. return;
  2076. }
  2077. const requestData = {
  2078. LicenseUniqueID: selectedRowData.UniqueID,
  2079. UserUniqueIDs: userIds.split(','),
  2080. UserAccounts: users.split(','),
  2081. Emails: emails,
  2082. UserNames: userNames,
  2083. OperatorUniqueID: operatorUniqueID
  2084. };
  2085. console.log('requestData:', requestData);
  2086. fetch('http://127.0.0.1:8080/api/admin/distributeLicense', {
  2087. method: 'POST',
  2088. headers: {
  2089. 'Authorization': `Bearer ${token}`,
  2090. 'Content-Type': 'application/json'
  2091. },
  2092. body: JSON.stringify(requestData)
  2093. })
  2094. .then(response => {
  2095. console.log('Response received');
  2096. return response.json();
  2097. })
  2098. .then(data => {
  2099. if (data.success) {
  2100. alert('分发成功!');
  2101. closeModal('emailModal');
  2102. } else {
  2103. // 检查是否有 error 字段,并提示用户详细的错误信息
  2104. const errorMessage = data.error || '分发失败。';
  2105. alert(`分发失败: ${errorMessage}`);
  2106. }
  2107. })
  2108. .catch(error => {
  2109. console.error('Error occurred during email distribution:', error);
  2110. alert('分发失败,请检查网络或后端服务。');
  2111. });
  2112. }
  2113. function showDistributionHistory() {
  2114. fetch('http://127.0.0.1:8080/api/admin/GetlicenseRecord', {
  2115. method: 'POST',
  2116. headers: {
  2117. 'Authorization': `Bearer ${token}`,
  2118. 'Content-Type': 'application/json'
  2119. },
  2120. body: JSON.stringify({ uniqueID: selectedRowData.UniqueID })
  2121. })
  2122. .then(response => response.json())
  2123. .then(data => {
  2124. const distributionHistoryContent = document.getElementById('distributionHistoryContent');
  2125. const { license_record_to_user, license_record_to_emails } = data.data;
  2126. // 确保 license_record_to_user 和 license_record_to_emails 存在并且是数组
  2127. const userRecords = Array.isArray(license_record_to_user) ? license_record_to_user : [];
  2128. const emailRecords = Array.isArray(license_record_to_emails) ? license_record_to_emails : [];
  2129. if (userRecords.length > 0 || emailRecords.length > 0) {
  2130. const userHistoryHtml = userRecords.map(record => `
  2131. <div style="margin-bottom: 20px; padding: 10px; border: 1px solid #ddd; border-radius: 10px; background-color: #f9f9f9;">
  2132. <p><strong>已转发给用户:</strong> ${record.user_account}</p>
  2133. <p><strong>分发时间:</strong> ${new Date(record.up_time).toLocaleString()}</p>
  2134. </div>
  2135. `).join('');
  2136. const emailHistoryHtml = emailRecords.map(record => `
  2137. <div style="margin-bottom: 20px; padding: 10px; border: 1px solid #ddd; border-radius: 10px; background-color: #f9f9f9;">
  2138. <p><strong>已发给邮箱:</strong> ${record.emails}</p>
  2139. <p><strong>分发时间:</strong> ${new Date(record.up_time).toLocaleString()}</p>
  2140. </div>
  2141. `).join('');
  2142. distributionHistoryContent.innerHTML = userHistoryHtml + emailHistoryHtml;
  2143. } else {
  2144. distributionHistoryContent.innerHTML = `<p>没有分发历史记录。</p>`;
  2145. }
  2146. // 显示模态框
  2147. const distributionHistoryModal = document.getElementById('distributionHistoryModal');
  2148. distributionHistoryModal.style.display = 'block';
  2149. });
  2150. }
  2151. function showMoreUserInfo() {
  2152. const extraInfoContent = document.getElementById('extraInfoContent');
  2153. extraInfoContent.innerHTML = `
  2154. <p><strong>用户名:</strong> ${selectedRowData.Username}</p>
  2155. <p><strong>电话:</strong> ${selectedRowData.Telephone}</p>
  2156. <p><strong>邮箱:</strong> ${selectedRowData.Email}</p>
  2157. <p><strong>权限:</strong> ${selectedRowData.Role}</p>
  2158. `;
  2159. document.getElementById('extraInfoModal').style.display = 'block';
  2160. }
  2161. function modifyUser() {
  2162. const userInfoContent = document.getElementById('extraInfoContent');
  2163. userInfoContent.innerHTML = `
  2164. <p><strong>用户名:</strong> ${selectedRowData.Username}</p>
  2165. <p><strong>电话:</strong> ${selectedRowData.Telephone}</p>
  2166. <p><strong>邮箱:</strong> ${selectedRowData.Email}</p>
  2167. <p><strong>权限:</strong> ${selectedRowData.Role}</p>
  2168. <button onclick="showEditUserForm()">编辑用户信息</button>
  2169. `;
  2170. document.getElementById('extraInfoModal').style.display = 'block';
  2171. }
  2172. //查看额外信息
  2173. function showExtraInfo() {
  2174. const extraInfoContent = document.getElementById('extraInfoContent');
  2175. // 清空之前的内容
  2176. extraInfoContent.innerHTML = '';
  2177. // 使用预定义的字段名和中文翻译
  2178. const fieldTranslations = {
  2179. id: "ID",
  2180. user_id: "用户ID",
  2181. up_user: "上传用户",
  2182. up_time: "上传时间",
  2183. del_time: "删除时间",
  2184. License1: "License 1",
  2185. License2: "License 2",
  2186. LicenseFlage: "License 状态",
  2187. UniqueID: "唯一标识符",
  2188. Creator: "创建人",
  2189. ApplicationDate: "申请日期",
  2190. AssociatedProject: "关联项目",
  2191. SalesPerson: "销售人员",
  2192. SalesEmail: "销售邮箱",
  2193. SupportPerson: "支持人员",
  2194. SupportEmail: "支持邮箱",
  2195. TotalNodes: "总节点数",
  2196. Company: "公司",
  2197. ProductName: "产品名称",
  2198. Version: "版本",
  2199. NodeCount: "节点数",
  2200. Processor: "处理器",
  2201. OperatingSystem: "操作系统",
  2202. MasterMacAddress: "主MAC地址",
  2203. SecondaryMasterMacAddress: "备用主MAC地址"
  2204. };
  2205. // 使用指定的字段进行展示
  2206. const fieldsToShow = [
  2207. "id", "user_id", "up_user", "up_time", "del_time", "License1", "License2",
  2208. "LicenseFlage", "UniqueID", "Creator", "ApplicationDate", "AssociatedProject",
  2209. "SalesPerson", "SalesEmail", "SupportPerson", "SupportEmail", "TotalNodes",
  2210. "Company", "ProductName", "Version", "NodeCount", "Processor", "OperatingSystem",
  2211. "MasterMacAddress", "SecondaryMasterMacAddress"
  2212. ];
  2213. fieldsToShow.forEach(key => {
  2214. if (selectedRowData.hasOwnProperty(key)) {
  2215. let value = selectedRowData[key];
  2216. // 特殊处理 up_time 和 del_time
  2217. if (key === 'up_time' || key === 'del_time') {
  2218. if (value.Valid) {
  2219. value = new Date(value.Time).toLocaleString(); // 格式化日期时间
  2220. } else {
  2221. value = '无';
  2222. }
  2223. }
  2224. // 处理 License1 和 License2,提取字符串字段
  2225. if (key === 'License1' || key === 'License2') {
  2226. // 假设 License 对象包含一个名为 'Details' 的字符串字段
  2227. value = value.String || '[无数据]';
  2228. }
  2229. // 处理 MasterMacAddress 和 SecondaryMasterMacAddress,提取字符串字段
  2230. // if (key === 'MasterMacAddress' || key === 'SecondaryMasterMacAddress') {
  2231. // // 假设 License 对象包含一个名为 'Details' 的字符串字段
  2232. // value = value.String || '[无数据]';
  2233. // }
  2234. const infoElement = document.createElement('p');
  2235. infoElement.innerHTML = `<strong>${fieldTranslations[key]}:</strong> ${value}`;
  2236. extraInfoContent.appendChild(infoElement);
  2237. }
  2238. });
  2239. // 显示 modal
  2240. document.getElementById('extraInfoModal').style.display = 'block';
  2241. }
  2242. function showRoleManagement() {
  2243. document.getElementById('table-container').style.display = 'none';
  2244. document.getElementById('user-management').style.display = 'none'; // 隐藏用户管理页面
  2245. document.getElementById('role-management').style.display = 'block';;
  2246. fetchRoles();
  2247. }
  2248. function fetchRoles() {
  2249. fetch('http://127.0.0.1:8080/api/admin/GetRoles', {
  2250. method: 'POST',
  2251. headers: {
  2252. 'Authorization': `Bearer ${token}`,
  2253. 'Content-Type': 'application/json'
  2254. },
  2255. body: JSON.stringify({ Name: " " }) // 发送空的 Name 参数
  2256. })
  2257. .then(response => response.json())
  2258. .then(data => {
  2259. const roleContainer = document.getElementById('roles-container');
  2260. roleContainer.innerHTML = ''; // 清空之前的内容
  2261. const permissionMap = {
  2262. 'generate_license': '生成许可证',
  2263. 'upload_license': '上传许可证',
  2264. 'read_license': '读取许可证',
  2265. 'read_license_record': '读取许可证分发记录',
  2266. 'update_license': '修改许可证',
  2267. 'delete_license': '删除许可证',
  2268. 'dispat_license': '分发许可证',
  2269. 'create_user': '创建用户',
  2270. 'read_user': '读取用户',
  2271. 'update_user': '更新用户',
  2272. 'delete_user': '删除用户',
  2273. 'create_role': '创建角色',
  2274. 'delete_role': '删除角色',
  2275. 'update_role': '更新角色',
  2276. 'get_role': '获取角色'
  2277. };
  2278. // 检查用户是否有 create_role 权限
  2279. const hasCreateRolePermission = userPermissions.includes('create_role');
  2280. // 如果有权限则显示“创建角色”按钮
  2281. if (hasCreateRolePermission) {
  2282. document.getElementById('createRoleButton').style.display = 'block';
  2283. } else {
  2284. document.getElementById('createRoleButton').style.display = 'none';
  2285. }
  2286. // 处理置顶角色和其他角色的渲染(代码不变)
  2287. const topRoles = ['admin', 'guest', 'supportRole'];
  2288. topRoles.forEach(role => {
  2289. if (data.data[role]) {
  2290. renderRole(roleContainer, data.data[role], permissionMap, true);
  2291. }
  2292. });
  2293. Object.keys(data.data).forEach(role => {
  2294. if (!topRoles.includes(role)) {
  2295. renderRole(roleContainer, data.data[role], permissionMap, false);
  2296. }
  2297. });
  2298. });
  2299. }
  2300. function renderRole(container, roleInfo, permissionMap, isTopRole) {
  2301. const roleDiv = document.createElement('div');
  2302. roleDiv.className = 'role-item';
  2303. roleDiv.style.position = 'relative'; // 确保弹出菜单能够正确定位
  2304. if (isTopRole) {
  2305. roleDiv.classList.add('top-role'); // 应用置顶角色的样式
  2306. }
  2307. let permissions = roleInfo.Permissions.map(permission => permissionMap[permission]);
  2308. let permissionsHtml = permissions.join(','); // 使用逗号分隔并合并为一行
  2309. roleDiv.innerHTML = `
  2310. <h3>${roleInfo.Name}</h3>
  2311. <p>${permissionsHtml}</p>
  2312. `;
  2313. container.appendChild(roleDiv);
  2314. // 添加事件监听器,处理点击和右键点击弹出菜单
  2315. roleDiv.addEventListener('click', function(event) {
  2316. event.stopPropagation(); // 阻止事件冒泡
  2317. event.preventDefault(); // 阻止默认行为
  2318. showRoleActionMenu(event, roleInfo.Name);
  2319. });
  2320. roleDiv.addEventListener('contextmenu', function(event) {
  2321. event.preventDefault();
  2322. showRoleActionMenu(event, roleInfo.Name);
  2323. });
  2324. }
  2325. function showRoleActionMenu(event, roleName) {
  2326. const existingMenu = document.getElementById('role-action-menu');
  2327. if (existingMenu) {
  2328. existingMenu.remove();
  2329. }
  2330. const menu = document.createElement('div');
  2331. menu.id = 'role-action-menu';
  2332. menu.style.position = 'absolute';
  2333. menu.style.top = `${event.clientY}px`;
  2334. menu.style.left = `${event.clientX}px`;
  2335. menu.style.backgroundColor = '#fff';
  2336. menu.style.border = '1px solid #ccc';
  2337. menu.style.borderRadius = '5px';
  2338. menu.style.boxShadow = '0 2px 10px rgba(0, 0, 0, 0.2)';
  2339. menu.style.padding = '10px';
  2340. menu.style.zIndex = '1000';
  2341. const topRoles = ['admin', 'guest', 'support'];
  2342. if (topRoles.includes(roleName)) {
  2343. // 为 admin, guest, supportRole 设置灰色和不可点击样式
  2344. const disabledButton = document.createElement('button');
  2345. disabledButton.textContent = '不可操作';
  2346. disabledButton.style.display = 'block';
  2347. disabledButton.style.width = '100%';
  2348. disabledButton.style.padding = '10px 20px';
  2349. disabledButton.style.border = 'none';
  2350. disabledButton.style.borderRadius = '15px';
  2351. disabledButton.style.cursor = 'not-allowed';
  2352. disabledButton.style.backgroundColor = '#d3d3d3'; // 灰色背景
  2353. disabledButton.style.color = '#999'; // 灰色文字
  2354. menu.appendChild(disabledButton);
  2355. } else {
  2356. // 检查用户是否有 update_role 和 delete_role 权限
  2357. const hasUpdateRolePermission = userPermissions.includes('update_role');
  2358. const hasDeleteRolePermission = userPermissions.includes('delete_role');
  2359. // 创建和添加修改角色按钮
  2360. if (hasUpdateRolePermission) {
  2361. const modifyButton = document.createElement('button');
  2362. modifyButton.textContent = '修改角色';
  2363. modifyButton.style.display = 'block';
  2364. modifyButton.style.marginBottom = '10px';
  2365. modifyButton.style.width = '100%';
  2366. modifyButton.style.padding = '10px 20px';
  2367. modifyButton.style.border = 'none';
  2368. modifyButton.style.borderRadius = '15px';
  2369. modifyButton.style.cursor = 'pointer';
  2370. modifyButton.style.transition = 'background-color 0.3s, color 0.3s';
  2371. modifyButton.style.boxShadow = '0 2px 4px rgba(0, 0, 0, 0.1)';
  2372. modifyButton.style.backgroundColor = '#007aff';
  2373. modifyButton.style.color = '#fff';
  2374. modifyButton.addEventListener('mouseenter', function () {
  2375. modifyButton.style.backgroundColor = '#005bb5';
  2376. });
  2377. modifyButton.addEventListener('mouseleave', function () {
  2378. modifyButton.style.backgroundColor = '#007aff';
  2379. });
  2380. modifyButton.addEventListener('click', function () {
  2381. modifyRole(roleName);
  2382. menu.remove(); // 点击按钮后,关闭菜单栏
  2383. });
  2384. menu.appendChild(modifyButton);
  2385. }
  2386. // 创建和添加删除角色按钮
  2387. if (hasDeleteRolePermission) {
  2388. const deleteButton = document.createElement('button');
  2389. deleteButton.textContent = '删除角色';
  2390. deleteButton.style.display = 'block';
  2391. deleteButton.style.width = '100%';
  2392. deleteButton.style.padding = '10px 20px';
  2393. deleteButton.style.border = 'none';
  2394. deleteButton.style.borderRadius = '15px';
  2395. deleteButton.style.cursor = 'pointer';
  2396. deleteButton.style.transition = 'background-color 0.3s, color 0.3s';
  2397. deleteButton.style.boxShadow = '0 2px 4px rgba(0, 0, 0, 0.1)';
  2398. deleteButton.style.backgroundColor = '#ff3b30';
  2399. deleteButton.style.color = '#fff';
  2400. deleteButton.addEventListener('mouseenter', function () {
  2401. deleteButton.style.backgroundColor = '#c23321';
  2402. });
  2403. deleteButton.addEventListener('mouseleave', function () {
  2404. deleteButton.style.backgroundColor = '#ff3b30';
  2405. });
  2406. deleteButton.addEventListener('click', function () {
  2407. deleteRole(roleName);
  2408. menu.remove(); // 点击按钮后,关闭菜单栏
  2409. });
  2410. menu.appendChild(deleteButton);
  2411. }
  2412. // 如果用户没有修改或删除权限,则显示没有选项的提示
  2413. if (!hasUpdateRolePermission && !hasDeleteRolePermission) {
  2414. const noOption = document.createElement('div');
  2415. noOption.textContent = '没有可用的操作';
  2416. noOption.style.textAlign = 'center';
  2417. noOption.style.color = '#999';
  2418. menu.appendChild(noOption);
  2419. }
  2420. }
  2421. document.body.appendChild(menu);
  2422. document.addEventListener('click', function closeMenu(event) {
  2423. if (!menu.contains(event.target)) {
  2424. menu.remove();
  2425. document.removeEventListener('click', closeMenu);
  2426. }
  2427. });
  2428. }
  2429. //修改角色信息
  2430. function modifyRole(roleName) {
  2431. console.log(`modifyRole called with roleName: ${roleName}`);
  2432. fetchRoleInfo(roleName, function(roleInfo) {
  2433. console.log(`fetchRoleInfo returned:`, roleInfo);
  2434. if (!roleInfo) {
  2435. console.error('Role info is undefined or null');
  2436. return;
  2437. }
  2438. const extraInfoContent = document.getElementById('extraInfoContent');
  2439. if (!extraInfoContent) {
  2440. console.error('Element with id "extraInfoContent" not found');
  2441. return;
  2442. }
  2443. extraInfoContent.innerHTML = `
  2444. <h3>修改角色: ${roleInfo.Name}</h3>
  2445. <label for="roleName">角色名称:</label>
  2446. <input type="text" id="roleName" value="${roleInfo.Name}" required><br><br>
  2447. <label for="permissions">权限:</label><br>
  2448. <div id="permissions">
  2449. <div>
  2450. <input type="checkbox" id="license" name="permissions" value="license" onchange="toggleSubPermissions('license', this)">
  2451. <label for="license">许可证</label>
  2452. <div id="licenseSubPermissions" style="margin-left: 20px;">
  2453. <input type="checkbox" id="generate_license" name="permissions" value="generate_license">
  2454. <label for="generate_license">生成许可证</label><br>
  2455. <input type="checkbox" id="upload_license" name="permissions" value="upload_license">
  2456. <label for="upload_license">上传许可证</label><br>
  2457. <input type="checkbox" id="read_license" name="permissions" value="read_license">
  2458. <label for="read_license">读取许可证</label><br>
  2459. <input type="checkbox" id="update_license" name="permissions" value="update_license">
  2460. <label for="update_license">更新许可证</label><br>
  2461. <input type="checkbox" id="delete_license" name="permissions" value="delete_license">
  2462. <label for="delete_license">删除许可证</label><br>
  2463. </div>
  2464. </div>
  2465. <div>
  2466. <input type="checkbox" id="user" name="permissions" value="user" onchange="toggleSubPermissions('user', this)">
  2467. <label for="user">用户</label>
  2468. <div id="userSubPermissions" style="margin-left: 20px;">
  2469. <input type="checkbox" id="create_user" name="permissions" value="create_user">
  2470. <label for="create_user">创建用户</label><br>
  2471. <input type="checkbox" id="read_user" name="permissions" value="read_user">
  2472. <label for="read_user">读取用户</label><br>
  2473. <input type="checkbox" id="update_user" name="permissions" value="update_user">
  2474. <label for="update_user">更新用户</label><br>
  2475. <input type="checkbox" id="delete_user" name="permissions" value="delete_user">
  2476. <label for="delete_user">删除用户</label><br>
  2477. </div>
  2478. </div>
  2479. <div>
  2480. <input type="checkbox" id="role" name="permissions" value="role" onchange="toggleSubPermissions('role', this)">
  2481. <label for="role">角色</label>
  2482. <div id="roleSubPermissions" style="margin-left: 20px;">
  2483. <input type="checkbox" id="create_role" name="permissions" value="create_role">
  2484. <label for="create_role">创建角色</label><br>
  2485. <input type="checkbox" id="delete_role" name="permissions" value="delete_role">
  2486. <label for="delete_role">删除角色</label><br>
  2487. <input type="checkbox" id="update_role" name="permissions" value="update_role">
  2488. <label for="update_role">更新角色</label><br>
  2489. <input type="checkbox" id="get_role" name="permissions" value="get_role">
  2490. <label for="get_role">获取角色</label><br>
  2491. </div>
  2492. </div>
  2493. </div><br><br>
  2494. <button onclick="saveRoleChanges('${roleInfo.Id}')">保存</button>
  2495. `;
  2496. console.log('Form content added to extraInfoContent');
  2497. const checkboxes = document.querySelectorAll('#permissions input[type="checkbox"]');
  2498. // 遍历所有复选框
  2499. checkboxes.forEach(checkbox => {
  2500. if (roleInfo.Permissions.includes(checkbox.value)) {
  2501. checkbox.checked = true; // 如果当前权限在roleInfo.Permissions中,则勾选
  2502. }
  2503. });
  2504. const extraInfoModal = document.getElementById('extraInfoModal');
  2505. if (!extraInfoModal) {
  2506. console.error('Element with id "extraInfoModal" not found');
  2507. return;
  2508. }
  2509. extraInfoModal.style.display = 'block'; // 强制显示模态框
  2510. console.log('Modal should be visible now');
  2511. });
  2512. }
  2513. function getCheckboxOptions(selectedPermissions) {
  2514. const permissionMap = {
  2515. 'generate_license': '生成许可证',
  2516. 'upload_license': '上传许可证',
  2517. 'read_license': '读取许可证',
  2518. 'update_license': '修改许可证',
  2519. 'delete_license': '删除许可证',
  2520. 'dispat_license': '分发许可证',
  2521. 'read_license_record': '读取许可证分发记录',
  2522. // 'get_user_info': '获取用户信息',
  2523. 'create_user': '创建用户',
  2524. 'read_user': '读取用户',
  2525. 'update_user': '更新用户',
  2526. 'delete_user': '删除用户',
  2527. 'create_role': '创建角色',
  2528. 'delete_role': '删除角色',
  2529. 'update_role': '更新角色',
  2530. 'get_role': '获取角色'
  2531. };
  2532. return Object.keys(permissionMap).map(permission => `
  2533. <div>
  2534. <input type="checkbox" id="${permission}" name="permissions" value="${permission}" ${selectedPermissions.includes(permission) ? 'checked' : ''}>
  2535. <label for="${permission}">${permissionMap[permission]}</label>
  2536. </div>
  2537. `).join('');
  2538. }
  2539. function fetchRoleInfo(roleName, callback) {
  2540. console.log(`fetchRoleInfo called with roleName: ${roleName}`);
  2541. fetch('http://127.0.0.1:8080/api/admin/GetRoles', {
  2542. method: 'POST',
  2543. headers: {
  2544. 'Authorization': `Bearer ${token}`,
  2545. 'Content-Type': 'application/json'
  2546. },
  2547. body: JSON.stringify({ Name: roleName })
  2548. })
  2549. .then(response => {
  2550. console.log('fetchRoleInfo response received', response);
  2551. return response.json();
  2552. })
  2553. .then(data => {
  2554. console.log('fetchRoleInfo data received', data);
  2555. // 直接从 data.data 获取角色信息
  2556. if (data && data.data) {
  2557. console.log('Role info found:', data.data);
  2558. callback(data.data); // 直接返回 data.data 而不是 data.data[roleName]
  2559. } else {
  2560. console.error('Role not found or unexpected data structure', data);
  2561. callback(null); // 如果角色信息未找到,返回 null
  2562. }
  2563. })
  2564. .catch(error => {
  2565. console.error('Error in fetchRoleInfo:', error);
  2566. callback(null); // 捕获异常情况
  2567. });
  2568. }
  2569. function getPermissionsOptions(selectedPermissions) {
  2570. const permissionMap = {
  2571. 'generate_license': '生成许可证',
  2572. 'upload_license': '上传许可证',
  2573. 'read_license': '读取许可证',
  2574. 'update_license': '修改许可证',
  2575. 'delete_license': '删除许可证',
  2576. 'dispat_license': '分发许可证',
  2577. 'read_license_record': '读取许可证分发记录',
  2578. //'get_user_info': '获取用户信息',
  2579. 'create_user': '创建用户',
  2580. 'read_user': '读取用户',
  2581. 'update_user': '更新用户',
  2582. 'delete_user': '删除用户',
  2583. 'create_role': '创建角色',
  2584. 'delete_role': '删除角色',
  2585. 'update_role': '更新角色',
  2586. 'get_role': '获取角色'
  2587. };
  2588. return Object.keys(permissionMap).map(permission => `
  2589. <option value="${permission}" ${selectedPermissions.includes(permission) ? 'selected' : ''}>
  2590. ${permissionMap[permission]}
  2591. </option>
  2592. `).join('');
  2593. }
  2594. function saveRoleChanges(roleId) {
  2595. const updatedRoleName = document.getElementById('roleName').value.trim();
  2596. const selectedPermissions = Array.from(document.querySelectorAll('#permissions input[type="checkbox"]:checked'))
  2597. .map(checkbox => checkbox.value)
  2598. .filter(value => !['license', 'user', 'role'].includes(value)); // 过滤掉一级分类
  2599. if (!updatedRoleName) {
  2600. alert('角色名称不能为空!');
  2601. return;
  2602. }
  2603. const updateRole = {
  2604. Id: parseInt(roleId, 10), // 确保 roleId 被传递并转换为整数
  2605. Name: updatedRoleName,
  2606. Permissions: selectedPermissions
  2607. };
  2608. fetch('http://127.0.0.1:8080/api/admin/UpdateRole', {
  2609. method: 'POST',
  2610. headers: {
  2611. 'Authorization': `Bearer ${token}`,
  2612. 'Content-Type': 'application/json'
  2613. },
  2614. body: JSON.stringify(updateRole)
  2615. })
  2616. .then(response => response.json())
  2617. .then(data => {
  2618. if (data.success) {
  2619. alert('角色更新成功!');
  2620. fetchRoles(); // 刷新角色列表
  2621. closeModal('extraInfoModal'); // 关闭信息栏
  2622. } else {
  2623. alert('角色更新失败:' + data.error);
  2624. }
  2625. });
  2626. }
  2627. //删除角色
  2628. function deleteRole(roleName) {
  2629. console.log(`deleteRole called for role: ${roleName}`);
  2630. const confirmed = confirm(`确认删除角色: ${roleName} 吗?`);
  2631. if (!confirmed) {
  2632. return;
  2633. }
  2634. fetch('http://127.0.0.1:8080/api/admin/DeleteRole', {
  2635. method: 'POST',
  2636. headers: {
  2637. 'Authorization': `Bearer ${token}`,
  2638. 'Content-Type': 'application/json'
  2639. },
  2640. body: JSON.stringify({
  2641. name: roleName // 将角色名称传递给后端
  2642. })
  2643. })
  2644. .then(response => response.json())
  2645. .then(data => {
  2646. if (data.success) {
  2647. alert('角色删除成功!');
  2648. fetchRoles(); // 刷新角色列表
  2649. } else {
  2650. alert('角色删除失败:' + data.error);
  2651. }
  2652. })
  2653. .catch(error => {
  2654. console.error('Error deleting role:', error);
  2655. alert('删除角色时发生错误,请稍后再试。');
  2656. });
  2657. }
  2658. document.getElementById('createRoleButton').addEventListener('click', function() {
  2659. const extraInfoContent = document.getElementById('extraInfoContent');
  2660. extraInfoContent.innerHTML = `
  2661. <h3>创建新角色</h3>
  2662. <label for="newRoleName">角色名称:</label>
  2663. <input type="text" id="newRoleName" required><br><br>
  2664. <label for="newPermissions">权限:</label><br>
  2665. <div id="newPermissions">
  2666. <div>
  2667. <input type="checkbox" id="license" name="permissions" value="license" onchange="toggleSubPermissions('license', this)">
  2668. <label for="license">许可证</label>
  2669. <div id="licenseSubPermissions" style="margin-left: 20px;">
  2670. <input type="checkbox" id="generate_license" name="permissions" value="generate_license">
  2671. <label for="generate_license">生成许可证</label><br>
  2672. <input type="checkbox" id="upload_license" name="permissions" value="upload_license">
  2673. <label for="upload_license">上传许可证</label><br>
  2674. <input type="checkbox" id="read_license" name="permissions" value="read_license">
  2675. <label for="read_license">读取许可证</label><br>
  2676. <input type="checkbox" id="update_license" name="permissions" value="update_license">
  2677. <label for="update_license">更新许可证</label><br>
  2678. <input type="checkbox" id="delete_license" name="permissions" value="delete_license">
  2679. <label for="delete_license">删除许可证</label><br>
  2680. </div>
  2681. </div>
  2682. <div>
  2683. <input type="checkbox" id="user" name="permissions" value="user" onchange="toggleSubPermissions('user', this)">
  2684. <label for="user">用户</label>
  2685. <div id="userSubPermissions" style="margin-left: 20px;">
  2686. <input type="checkbox" id="create_user" name="permissions" value="create_user">
  2687. <label for="create_user">创建用户</label><br>
  2688. <input type="checkbox" id="read_user" name="permissions" value="read_user">
  2689. <label for="read_user">读取用户</label><br>
  2690. <input type="checkbox" id="update_user" name="permissions" value="update_user">
  2691. <label for="update_user">更新用户</label><br>
  2692. <input type="checkbox" id="delete_user" name="permissions" value="delete_user">
  2693. <label for="delete_user">删除用户</label><br>
  2694. </div>
  2695. </div>
  2696. <div>
  2697. <input type="checkbox" id="role" name="permissions" value="role" onchange="toggleSubPermissions('role', this)">
  2698. <label for="role">角色</label>
  2699. <div id="roleSubPermissions" style="margin-left: 20px;">
  2700. <input type="checkbox" id="create_role" name="permissions" value="create_role">
  2701. <label for="create_role">创建角色</label><br>
  2702. <input type="checkbox" id="delete_role" name="permissions" value="delete_role">
  2703. <label for="delete_role">删除角色</label><br>
  2704. <input type="checkbox" id="update_role" name="permissions" value="update_role">
  2705. <label for="update_role">更新角色</label><br>
  2706. <input type="checkbox" id="get_role" name="permissions" value="get_role">
  2707. <label for="get_role">获取角色</label><br>
  2708. </div>
  2709. </div>
  2710. </div><br><br>
  2711. <button onclick="createNewRole()">创建</button>
  2712. </div>
  2713. `;
  2714. document.getElementById('extraInfoModal').style.display = 'block';
  2715. });
  2716. function toggleSubPermissions(category, checkbox) {
  2717. const subPermissions = document.querySelectorAll(`#${category}SubPermissions input[type="checkbox"]`);
  2718. subPermissions.forEach(subCheckbox => {
  2719. subCheckbox.checked = checkbox.checked;
  2720. });
  2721. }
  2722. function createNewRole() {
  2723. const newRoleName = document.getElementById('newRoleName').value.trim();
  2724. const selectedPermissions = Array.from(document.querySelectorAll('#newPermissions input[type="checkbox"]:checked'))
  2725. .map(checkbox => checkbox.value)
  2726. .filter(value => !['license', 'user', 'role'].includes(value)); // 过滤掉一级分类
  2727. if (!newRoleName) {
  2728. alert('角色名称不能为空!');
  2729. return;
  2730. }
  2731. const newRole = {
  2732. Name: newRoleName,
  2733. Permissions: selectedPermissions
  2734. };
  2735. fetch('http://127.0.0.1:8080/api/admin/CreateRole', {
  2736. method: 'POST',
  2737. headers: {
  2738. 'Authorization': `Bearer ${token}`,
  2739. 'Content-Type': 'application/json'
  2740. },
  2741. body: JSON.stringify(newRole)
  2742. })
  2743. .then(response => response.json())
  2744. .then(data => {
  2745. if (data.success) {
  2746. alert('角色创建成功!');
  2747. fetchRoles(); // 刷新角色列表
  2748. closeModal('extraInfoModal'); // 关闭信息栏
  2749. } else {
  2750. alert('角色创建失败:' + data.error);
  2751. }
  2752. });
  2753. }
  2754. //显示用户信息
  2755. function showEditUserForm() {
  2756. const extraInfoContent = document.getElementById('extraInfoContent');
  2757. // 清空之前的内容
  2758. extraInfoContent.innerHTML = '';
  2759. // 创建表单
  2760. const form = document.createElement('form');
  2761. form.id = 'editUserForm';
  2762. form.style.width = '400px'; // 增加表单宽度
  2763. form.innerHTML = `
  2764. <div style="display: flex; align-items: center; margin-bottom: 15px;">
  2765. <label for="username" style="flex: 0 0 80px;">用户名:</label>
  2766. <input type="text" id="username" name="username" value="${selectedRowData.Username}" style="flex: 1;" required>
  2767. </div>
  2768. <div style="display: flex; align-items: center; margin-bottom: 15px;">
  2769. <label for="telephone" style="flex: 0 0 80px;">电话:</label>
  2770. <input type="text" id="telephone" name="telephone" value="${selectedRowData.Telephone}" style="flex: 1;" required>
  2771. </div>
  2772. <div style="display: flex; align-items: center; margin-bottom: 15px;">
  2773. <label for="email" style="flex: 0 0 80px;">邮箱:</label>
  2774. <input type="email" id="email" name="email" value="${selectedRowData.Email}" style="flex: 1;" required>
  2775. </div>
  2776. <div style="display: flex; align-items: center; margin-bottom: 15px;">
  2777. <label for="role" style="flex: 0 0 80px;">权限:</label>
  2778. <select id="role" name="role" style="flex: 1;" required></select>
  2779. </div>
  2780. <button type="button" onclick="saveUserChanges()" style="width: 100%; background-color: #007bff; color: white; border: none; padding: 10px; border-radius: 5px;">保存</button>
  2781. `;
  2782. // 将表单添加到弹出框内容中
  2783. extraInfoContent.appendChild(form);
  2784. // 获取角色列表并填充到选择框中
  2785. fetch('http://127.0.0.1:8080/api/admin/GetRoleNames', {
  2786. method: 'GET',
  2787. headers: {
  2788. 'Authorization': `Bearer ${token}`,
  2789. 'Content-Type': 'application/json'
  2790. }
  2791. })
  2792. .then(response => response.json())
  2793. .then(data => {
  2794. const roleSelect = document.getElementById('role');
  2795. data.roles.forEach(role => {
  2796. const option = document.createElement('option');
  2797. option.value = role;
  2798. option.textContent = role;
  2799. if (selectedRowData.Role === role) {
  2800. option.selected = true;
  2801. }
  2802. roleSelect.appendChild(option);
  2803. });
  2804. })
  2805. .catch(error => console.error('Error fetching roles:', error));
  2806. }
  2807. function saveUserChanges() {
  2808. const form = document.getElementById('editUserForm');
  2809. const formData = new FormData(form);
  2810. const updatedUser = {
  2811. Username: formData.get('username'),
  2812. Telephone: formData.get('telephone'),
  2813. Email: formData.get('email'),
  2814. Role: formData.get('role')
  2815. };
  2816. fetch(`http://127.0.0.1:8080/api/admin/updateUser`, {
  2817. method: 'POST',
  2818. headers: {
  2819. 'Authorization': `Bearer ${token}`,
  2820. 'Content-Type': 'application/json'
  2821. },
  2822. body: JSON.stringify({ ...updatedUser, Id: selectedRowData.Id })
  2823. })
  2824. .then(response => response.json())
  2825. .then(data => {
  2826. if (data.success) {
  2827. alert('用户信息更新成功!');
  2828. fetchUsers();
  2829. closeModal('extraInfoModal');
  2830. } else {
  2831. alert('用户信息更新失败:' + data.error);
  2832. }
  2833. });
  2834. }
  2835. function toggleUserInfo() {
  2836. const userModal = document.getElementById('userModal');
  2837. const userButton = document.getElementById('username');
  2838. const rect = userButton.getBoundingClientRect();
  2839. const modalWidth = 300; // 信息栏的宽度
  2840. const windowWidth = window.innerWidth; // 浏览器窗口的宽度
  2841. if (userModal.style.display === 'none' || userModal.style.display === '') {
  2842. fetch(`http://127.0.0.1:8080/api/admin/userInfo`, {
  2843. method: 'GET',
  2844. headers: {
  2845. 'Authorization': `Bearer ${token}`,
  2846. 'Content-Type': 'application/json'
  2847. }
  2848. })
  2849. .then(response => response.json())
  2850. .then(data => {
  2851. const userInfoContent = document.getElementById('userInfoContent');
  2852. let power;
  2853. switch (data.data.Role) {
  2854. case 'admin':
  2855. power = '至高无上的主';
  2856. break;
  2857. case 'supportRole':
  2858. power = '运维';
  2859. break;
  2860. case 'guest':
  2861. power = '访客';
  2862. break;
  2863. default:
  2864. power = data.data.Role;
  2865. }
  2866. userInfoContent.innerHTML = `
  2867. <div class="apple-modal-content">
  2868. <p class="apple-modal-text"><strong>用户名:</strong> ${data.data.Username}</p>
  2869. <p class="apple-modal-text"><strong>账号:</strong> ${data.data.Account}</p>
  2870. <p class="apple-modal-text"><strong>邮箱:</strong> ${data.data.Email}</p>
  2871. <p class="apple-modal-text"><strong>电话:</strong> ${data.data.Telephone}</p>
  2872. <p class="apple-modal-text"><strong>权限:</strong> ${power}</p>
  2873. </div>
  2874. `;
  2875. // 设置弹出框位置
  2876. userModal.style.top = `${rect.bottom + window.scrollY + 10}px`;
  2877. const leftPosition = rect.right + window.scrollX + 20; // 右侧位置
  2878. const rightEdge = leftPosition + modalWidth;
  2879. if (rightEdge > windowWidth) {
  2880. // 如果右侧超出窗口宽度,则将信息栏移动到按钮的左侧
  2881. const leftEdge = rect.left + window.scrollX - modalWidth - 20;
  2882. userModal.style.left = `${Math.max(20, leftEdge)}px`;
  2883. } else {
  2884. // 否则显示在按钮右侧
  2885. userModal.style.left = `${leftPosition}px`;
  2886. }
  2887. userModal.style.display = 'block';
  2888. userModal.style.opacity = '0'; // 先设置透明度为0
  2889. setTimeout(() => {
  2890. userModal.style.opacity = '1'; // 然后慢慢显示
  2891. }, 0); // 延迟一帧显示
  2892. // 增加过渡效果
  2893. userModal.style.transition = 'opacity 0.3s ease, top 0.3s ease, left 0.3s ease';
  2894. });
  2895. } else {
  2896. userModal.style.opacity = '0'; // 先设置透明度为0
  2897. setTimeout(() => {
  2898. userModal.style.display = 'none'; // 然后隐藏
  2899. }, 300); // 延迟0.3秒,等待过渡结束
  2900. }
  2901. }
  2902. function logout() {
  2903. localStorage.removeItem('Authorization');
  2904. window.location.href = '/';
  2905. }
  2906. // 添加到每个模态框的 JavaScript 部分
  2907. document.addEventListener('DOMContentLoaded', function() {
  2908. const modals = document.querySelectorAll('.modal');
  2909. modals.forEach(modal => {
  2910. modal.addEventListener('click', function(event) {
  2911. // 判断是否点击的是 modal 的背景
  2912. if (event.target === modal) {
  2913. modal.style.display = 'none';
  2914. }
  2915. });
  2916. });
  2917. });
  2918. function showUserManagement() {
  2919. document.getElementById('table-container').style.display = 'none';
  2920. document.getElementById('role-management').style.display = 'none'; // 隐藏角色管理页面
  2921. document.getElementById('user-management').style.display = 'block';
  2922. // 检查用户是否有 create_user 权限
  2923. const hasCreateUserPermission = userPermissions.includes('create_user');
  2924. // 获取添加用户按钮元素
  2925. const addUserButton = document.getElementById('addUserButton');
  2926. // 根据权限显示或隐藏添加用户按钮
  2927. if (hasCreateUserPermission) {
  2928. addUserButton.style.display = 'block';
  2929. } else {
  2930. addUserButton.style.display = 'none';
  2931. }
  2932. // 加载用户列表
  2933. fetchUsers();
  2934. }
  2935. function showTable() {
  2936. document.getElementById('user-management').style.display = 'none';
  2937. document.getElementById('role-management').style.display = 'none'; // 隐藏角色管理页面
  2938. document.getElementById('table-container').style.display = 'block';
  2939. }
  2940. function toggleSidebar() {
  2941. const sidebar = document.getElementById('sidebar');
  2942. const content = document.getElementById('content');
  2943. sidebar.classList.toggle('hidden');
  2944. content.classList.toggle('expanded');
  2945. const toggleButton = document.querySelector('.toggle-sidebar');
  2946. if (sidebar.classList.contains('hidden')) {
  2947. toggleButton.innerHTML = '>'; // 当侧边栏隐藏时,显示右箭头
  2948. } else {
  2949. toggleButton.innerHTML = '<'; // 当侧边栏显示时,显示左箭头
  2950. }
  2951. }
  2952. // document.getElementById('prev-page').addEventListener('click', () => {
  2953. // if (currentPage > 1) {
  2954. // fetchApplications(currentPage - 1, pageSize);
  2955. // }
  2956. // });
  2957. // document.getElementById('next-page').addEventListener('click', () => {
  2958. // fetchApplications(currentPage + 1, pageSize);
  2959. // });
  2960. function fetchUsername() {
  2961. fetch(`http://127.0.0.1:8080/api/admin/userInfo`, {
  2962. method: 'GET',
  2963. headers: {
  2964. 'Authorization': `Bearer ${token}`,
  2965. 'Content-Type': 'application/json'
  2966. }
  2967. })
  2968. .then(response => response.json())
  2969. .then(data => {
  2970. document.getElementById('username').textContent = data.data.Username;
  2971. currentUserRole = data.data.Role; // 存储当前用户的角色
  2972. currentUserName = data.data.Username
  2973. // 使用获取到的角色,调用获取权限的接口
  2974. fetchPermissionsByRole(currentUserRole)
  2975. .then(() => {
  2976. fetchApplications(LisOffset, pageSize); // 确保在权限获取之后才调用 fetchApplications
  2977. // 检查用户是否有 upload_license 权限
  2978. const hasUploadLicensePermission = userPermissions.includes('upload_license');
  2979. // 获取上传按钮元素
  2980. const uploadButton = document.querySelector('.upload-button');
  2981. // 根据权限显示或隐藏上传按钮
  2982. if (hasUploadLicensePermission) {
  2983. uploadButton.style.display = 'inline-block'; // 显示按钮
  2984. } else {
  2985. uploadButton.style.display = 'none'; // 隐藏按钮
  2986. }
  2987. });
  2988. });
  2989. }
  2990. function fetchPermissionsByRole(role) {
  2991. return fetch(`http://127.0.0.1:8080/api/admin/GetSelfRoles`, {
  2992. method: 'POST',
  2993. headers: {
  2994. 'Authorization': `Bearer ${token}`,
  2995. 'Content-Type': 'application/json'
  2996. },
  2997. body: JSON.stringify({ name: role })
  2998. })
  2999. .then(response => response.json())
  3000. .then(data => {
  3001. userPermissions = data.data.Permissions; // 获取用户的权限数组
  3002. console.log('userPermissions:', userPermissions);
  3003. // 定义权限类别
  3004. const licensePermissions = ['upload_license', 'read_license'];
  3005. const userPermissionsCheck = [ 'create_user', 'read_user', 'update_user', 'delete_user'];
  3006. const rolePermissions = ['create_role', 'delete_role', 'update_role', 'get_role'];
  3007. const hasLicenseAccess = licensePermissions.some(permission => userPermissions.includes(permission));
  3008. const hasUserManagementAccess = userPermissionsCheck.some(permission => userPermissions.includes(permission));
  3009. const hasRoleManagementAccess = rolePermissions.some(permission => userPermissions.includes(permission));
  3010. // 根据权限渲染菜单并显示初始页面
  3011. renderMenuAndInitialPage(hasLicenseAccess, hasUserManagementAccess, hasRoleManagementAccess);
  3012. });
  3013. }
  3014. function renderMenuAndInitialPage(hasLicenseAccess, hasUserManagementAccess, hasRoleManagementAccess) {
  3015. const sidebar = document.querySelector('.sidebar');
  3016. // 清空现有菜单项
  3017. sidebar.innerHTML = '';
  3018. let initialPageShown = false;
  3019. // 动态添加菜单项并确定初始显示的页面
  3020. if (hasLicenseAccess) {
  3021. const licenseButton = document.createElement('button');
  3022. licenseButton.textContent = 'License 管理';
  3023. licenseButton.onclick = showTable;
  3024. sidebar.appendChild(licenseButton);
  3025. if (!initialPageShown) {
  3026. showTable(); // 如果有License权限,先显示License页面
  3027. initialPageShown = true;
  3028. }
  3029. }
  3030. if (hasUserManagementAccess) {
  3031. const userManagementButton = document.createElement('button');
  3032. userManagementButton.textContent = '用户管理';
  3033. userManagementButton.onclick = showUserManagement;
  3034. sidebar.appendChild(userManagementButton);
  3035. if (!initialPageShown) {
  3036. showUserManagement(); // 如果没有License权限,但有用户管理权限,显示用户管理页面
  3037. initialPageShown = true;
  3038. }
  3039. }
  3040. if (hasRoleManagementAccess) {
  3041. const roleManagementButton = document.createElement('button');
  3042. roleManagementButton.textContent = '角色管理';
  3043. roleManagementButton.onclick = showRoleManagement;
  3044. sidebar.appendChild(roleManagementButton);
  3045. if (!initialPageShown) {
  3046. showRoleManagement(); // 如果没有License和用户管理权限,但有角色管理权限,显示角色管理页面
  3047. initialPageShown = true;
  3048. }
  3049. }
  3050. if (!initialPageShown && sidebar.firstChild) {
  3051. sidebar.firstChild.click(); // 如果没有优先的权限页面,则显示菜单中的第一个页面
  3052. }
  3053. }
  3054. // 页面初始化时调用 fetchUsername 函数
  3055. fetchUsername();
  3056. //fetchApplications(currentPage, pageSize);
  3057. </script>
  3058. </body>
  3059. </html>