index.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  1. <style>
  2. .form-commonsearch .form-group {
  3. margin-left: 0;
  4. margin-right: 0;
  5. padding: 0;
  6. }
  7. form.form-commonsearch .control-label {
  8. padding-right: 0;
  9. }
  10. .tdtitle {
  11. margin-bottom: 5px;
  12. font-weight: 600;
  13. }
  14. #channeltree {
  15. margin-left: -6px;
  16. }
  17. #channelbar .panel-heading {
  18. height: 55px;
  19. line-height: 25px;
  20. font-size: 14px;
  21. }
  22. @media (max-width: 1230px) {
  23. .fixed-table-toolbar .search .form-control {
  24. display: none;
  25. }
  26. }
  27. @media (min-width: 1200px) {
  28. }
  29. .archives-label span.label {
  30. font-weight: normal;
  31. }
  32. .archives-title {
  33. max-width: 400px;
  34. min-width: 200px;
  35. overflow: hidden;
  36. text-overflow: ellipsis;
  37. }
  38. .setflag label {
  39. font-weight: 400;
  40. }
  41. .nav > li.toggle-channel {
  42. display: none;
  43. }
  44. .col-full-width .nav > li.toggle-channel {
  45. display: inline-block;
  46. }
  47. #myTabContent {
  48. background-color: #fff;
  49. }
  50. #channeloperate > span {
  51. font-size: 14px;
  52. color: #777;
  53. }
  54. #channeloperate > span:first-child {
  55. margin-right: 10px;
  56. }
  57. #channeloperate > span label {
  58. font-weight: 400;
  59. }
  60. .row-eq-height {
  61. display: -webkit-box;
  62. display: -webkit-flex;
  63. display: -ms-flexbox;
  64. display: flex;
  65. }
  66. </style>
  67. <style data-render="darktheme">
  68. body.darktheme #myTabContent {
  69. background-color: #333;
  70. }
  71. body.darktheme .tagsinput {
  72. background-color: #3c3e3d;
  73. border-color: #444;
  74. color: #ccc;
  75. }
  76. body.darktheme .sim-tree a {
  77. color: #ccc;
  78. }
  79. body.darktheme .sim-tree .sim-icon-d:before {
  80. border-top-color: #ccc;
  81. }
  82. body.darktheme .sim-tree .sim-icon-r:before {
  83. border-left-color: #ccc;
  84. }
  85. </style>
  86. <style>
  87. .form-commonsearch .form-group {
  88. margin-left: 0;
  89. margin-right: 0;
  90. padding: 0;
  91. }
  92. form.form-commonsearch .control-label {
  93. padding-right: 0;
  94. }
  95. .tdtitle {
  96. margin-bottom: 5px;
  97. font-weight: 600;
  98. }
  99. #channeltree {
  100. margin-left: -6px;
  101. }
  102. #channelbar .panel-heading {
  103. height: 55px;
  104. line-height: 25px;
  105. font-size: 14px;
  106. }
  107. @media (max-width: 1230px) {
  108. .fixed-table-toolbar .search .form-control {
  109. display: none;
  110. }
  111. }
  112. @media (min-width: 1200px) {
  113. }
  114. .archives-label span.label {
  115. font-weight: normal;
  116. }
  117. .archives-title {
  118. max-width: 400px;
  119. min-width: 200px;
  120. overflow: hidden;
  121. text-overflow: ellipsis;
  122. }
  123. .setflag label {
  124. font-weight: 400;
  125. }
  126. .nav > li.toggle-channel {
  127. display: none;
  128. }
  129. .col-full-width .nav > li.toggle-channel {
  130. display: inline-block;
  131. }
  132. #myTabContent {
  133. background-color: #fff;
  134. }
  135. #channeloperate > span {
  136. font-size: 14px;
  137. color: #777;
  138. }
  139. #channeloperate > span:first-child {
  140. margin-right: 10px;
  141. }
  142. #channeloperate > span label {
  143. font-weight: 400;
  144. }
  145. .row-eq-height {
  146. display: -webkit-box;
  147. display: -webkit-flex;
  148. display: -ms-flexbox;
  149. display: flex;
  150. }
  151. /* 树形菜单样式 */
  152. .channel-tree {
  153. font-size: 13px;
  154. line-height: 1.4;
  155. }
  156. .tree-node {
  157. position: relative;
  158. padding: 0;
  159. margin: 0;
  160. }
  161. .tree-item {
  162. display: flex;
  163. align-items: center;
  164. padding: 6px 8px;
  165. cursor: pointer;
  166. border-radius: 3px;
  167. transition: background-color 0.2s;
  168. margin: 1px 0;
  169. }
  170. .tree-item:hover {
  171. background-color: #f5f5f5;
  172. }
  173. .tree-item.active {
  174. background-color: #3c8dbc;
  175. color: white;
  176. }
  177. .tree-item.active:hover {
  178. background-color: #357ca5;
  179. }
  180. .tree-toggle {
  181. width: 16px;
  182. height: 16px;
  183. display: flex;
  184. align-items: center;
  185. justify-content: center;
  186. margin-right: 4px;
  187. cursor: pointer;
  188. font-size: 10px;
  189. color: #666;
  190. }
  191. .tree-toggle:before {
  192. content: "▶";
  193. transition: transform 0.2s;
  194. }
  195. .tree-toggle.expanded:before {
  196. transform: rotate(90deg);
  197. }
  198. .tree-toggle.empty {
  199. visibility: hidden;
  200. }
  201. .tree-checkbox {
  202. width: 16px;
  203. height: 16px;
  204. margin-right: 6px;
  205. cursor: pointer;
  206. }
  207. .tree-icon {
  208. width: 16px;
  209. height: 16px;
  210. margin-right: 6px;
  211. display: flex;
  212. align-items: center;
  213. justify-content: center;
  214. font-size: 12px;
  215. color: #666;
  216. }
  217. .tree-label {
  218. flex: 1;
  219. overflow: hidden;
  220. text-overflow: ellipsis;
  221. white-space: nowrap;
  222. }
  223. .tree-children {
  224. margin-left: 20px;
  225. display: none;
  226. }
  227. .tree-node.expanded > .tree-children {
  228. display: block;
  229. }
  230. /* 连接线样式 */
  231. .tree-node:before {
  232. content: "";
  233. position: absolute;
  234. left: 8px;
  235. top: 28px;
  236. bottom: 0;
  237. width: 1px;
  238. background-color: #ddd;
  239. }
  240. .tree-node:last-child:before {
  241. height: 22px;
  242. }
  243. .tree-node > .tree-item:before {
  244. content: "";
  245. position: absolute;
  246. left: 8px;
  247. top: 50%;
  248. width: 12px;
  249. height: 1px;
  250. background-color: #ddd;
  251. margin-top: -0.5px;
  252. }
  253. .tree-node.root:before,
  254. .tree-node.root > .tree-item:before {
  255. display: none;
  256. }
  257. /* 暗色主题支持 */
  258. body.darktheme #myTabContent {
  259. background-color: #333;
  260. }
  261. body.darktheme .tree-item:hover {
  262. background-color: #404040;
  263. }
  264. body.darktheme .tree-item {
  265. color: #ccc;
  266. }
  267. body.darktheme .tree-node:before,
  268. body.darktheme .tree-node > .tree-item:before {
  269. background-color: #555;
  270. }
  271. </style>
  272. <link rel="stylesheet" href="__CDN__/assets/addons/cms/css/simtree.css"/>
  273. <div class="row row-eq-height">
  274. <div class="col-md-2 pr-0" id="channelbar">
  275. <div class="panel panel-default panel-intro" style="height: 100%;">
  276. <div class="panel-heading">
  277. <div class="panel-lead">
  278. <div class="pull-left">
  279. <em>{:__('Channel list')}</em>
  280. </div>
  281. <div class="pull-right">
  282. <a href="javascript:;" class="btn btn-link btn-xs btn-channel hidden-xs hidden-sm"><i class="fa fa-bars"></i></a>
  283. </div>
  284. </div>
  285. </div>
  286. <div class="panel-body">
  287. <div id="channeltree">
  288. <!-- 树形菜单内容 -->
  289. <div class="channel-tree">
  290. <!-- 正确的结构:每个一级节点都是独立的 tree-node -->
  291. {foreach $tree as $k=>$v}
  292. <div class="tree-node root expanded">
  293. <div class="tree-item" data-id="{$v['id']}" onclick="toggleNode(this)">
  294. <span class="tree-toggle {if !empty($v['children'])}expanded{else}empty{/if}" onclick="event.stopPropagation(); toggleNode(this.parentNode)"></span>
  295. <span class="tree-label">{$v['name']}</span>
  296. </div>
  297. {if !empty($v['children'])}
  298. <div class="tree-children">
  299. <!-- 二级节点 -->
  300. {foreach $v["children"] as $kk=>$vv}
  301. <div class="tree-node expanded">
  302. <div class="tree-item" data-id="{$vv['id']}" onclick="toggleNode(this)">
  303. <span class="tree-toggle {if !empty($vv['children'])}expanded{else}empty{/if}" onclick="event.stopPropagation(); toggleNode(this.parentNode)"></span>
  304. <span class="tree-label">{$vv['name']}</span>
  305. </div>
  306. {if !empty($vv['children'])}
  307. <div class="tree-children">
  308. <!-- 三级节点 -->
  309. {foreach $vv['children'] as $kkk=>$vvv}
  310. <div class="tree-node">
  311. <div class="tree-item" data-id="{$vvv['id']}" onclick='refreshTableData("{$v["id"]}", "{$vv["id"]}", "{$vvv["id"]}")'>
  312. <span class="tree-toggle empty"></span>
  313. <span class="tree-label">{$vvv['name']}</span>
  314. </div>
  315. </div>
  316. {/foreach}
  317. </div>
  318. {/if}
  319. </div>
  320. {/foreach}
  321. </div>
  322. {/if}
  323. </div>
  324. {/foreach}
  325. </div>
  326. </div>
  327. </div>
  328. </div>
  329. </div>
  330. <script type="text/javascript">
  331. if (window.innerWidth < 768) {
  332. document.getElementById('channelbar').className = document.getElementById('channelbar').className.replace("pr-0", "hidden");
  333. }
  334. </script>
  335. <div class="col-xs-12 col-md-10" id="archivespanel">
  336. <div class="panel panel-default panel-intro">
  337. <div class="panel-heading">
  338. {:build_heading(null,FALSE)}
  339. <ul class="nav nav-tabs" data-field="status">
  340. <li class="toggle-channel"><a href="javascript:;" class="btn-channel"><i class="fa fa-bars"></i></a></li>
  341. </ul>
  342. </div>
  343. <div class="panel-body">
  344. <div id="myTabContent" class="tab-content">
  345. <div class="tab-pane fade active in" id="one">
  346. <div class="widget-body no-padding">
  347. <div id="toolbar" class="toolbar">
  348. {:build_toolbar('refresh,edit,del')}
  349. <div class="dropdown btn-group {:$auth->check('user/user/multi')?'':'hide'}">
  350. <a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
  351. <ul class="dropdown-menu text-left" role="menu">
  352. <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
  353. <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
  354. </ul>
  355. </div>
  356. </div>
  357. <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
  358. data-operate-edit="{:$auth->check('user/user/edit')}"
  359. data-operate-del="{:$auth->check('user/user/del')}"
  360. width="100%">
  361. </table>
  362. </div>
  363. </div>
  364. </div>
  365. </div>
  366. </div>
  367. </div>
  368. </div>
  369. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
  370. <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  371. <script>
  372. // 切换节点展开/收起
  373. function toggleNode(element) {
  374. const treeNode = element.closest('.tree-node');
  375. const toggle = element.querySelector('.tree-toggle') || element.closest('.tree-item').querySelector('.tree-toggle');
  376. if (treeNode) {
  377. treeNode.classList.toggle('expanded');
  378. if (toggle && !toggle.classList.contains('empty')) {
  379. toggle.classList.toggle('expanded');
  380. }
  381. }
  382. }
  383. // 选择节点
  384. function selectNode(element, nodeId) {
  385. // 移除所有活动状态
  386. document.querySelectorAll('.tree-item').forEach(item => {
  387. item.classList.remove('active');
  388. });
  389. // 添加当前节点的活动状态
  390. element.classList.add('active');
  391. console.log('选择了频道:', nodeId);
  392. // 这里可以触发数据加载
  393. if (typeof loadChannelData === 'function') {
  394. loadChannelData(nodeId);
  395. }
  396. // 如果有FastAdmin的表格刷新方法
  397. // if (typeof Table !== 'undefined' && Table.api) {
  398. // Table.api.ajax.reload();
  399. // }
  400. }
  401. // 复选框变化事件
  402. $(document).on('change', '.tree-checkbox', function() {
  403. const checked = this.checked;
  404. const treeNode = $(this).closest('.tree-node');
  405. // 选中/取消选中所有子节点
  406. treeNode.find('.tree-children .tree-checkbox').prop('checked', checked);
  407. // 向上更新父节点状态
  408. updateParentCheckbox(treeNode);
  409. });
  410. // 更新父节点复选框状态
  411. function updateParentCheckbox(treeNode) {
  412. const parentNode = treeNode.parent().closest('.tree-node');
  413. if (parentNode.length) {
  414. const siblings = parentNode.find('> .tree-children > .tree-node');
  415. const checkedSiblings = siblings.find('> .tree-item .tree-checkbox:checked');
  416. const parentCheckbox = parentNode.find('> .tree-item .tree-checkbox');
  417. if (checkedSiblings.length === 0) {
  418. parentCheckbox.prop('checked', false).prop('indeterminate', false);
  419. } else if (checkedSiblings.length === siblings.length) {
  420. parentCheckbox.prop('checked', true).prop('indeterminate', false);
  421. } else {
  422. parentCheckbox.prop('checked', false).prop('indeterminate', true);
  423. }
  424. updateParentCheckbox(parentNode);
  425. }
  426. }
  427. // 初始化
  428. $(document).ready(function() {
  429. // 初始化树形结构的展开状态
  430. $('.tree-node.expanded').each(function() {
  431. const toggle = $(this).find('> .tree-item .tree-toggle');
  432. if (!toggle.hasClass('empty')) {
  433. toggle.addClass('expanded');
  434. }
  435. });
  436. });
  437. function refreshTableData(level1Id, level2Id, level3Id) {
  438. // 解析参数
  439. var yearMonth = level1Id; // 如:2025-06
  440. var test2 = level2Id.split('_')[1]; // 如:asdf
  441. var test3 = level3Id.split('_')[2]; // 如:ewww
  442. console.log('筛选条件:', {
  443. yearMonth: yearMonth,
  444. test2: test2,
  445. test3: test3
  446. });
  447. // 直接刷新表格,传递筛选参数
  448. $("#table").bootstrapTable('refresh', {
  449. query: {
  450. yearMonth: yearMonth,
  451. test2: test2,
  452. test3: test3
  453. }
  454. });
  455. // 更新选中状态
  456. $('.tree-item').removeClass('active');
  457. $(event.target).closest('.tree-item').addClass('active');
  458. }
  459. </script>