select.html 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <php>
  2. if (!function_exists('_suggest_url')) {
  3. function _suggest_url($action, $url)
  4. {
  5. $actionArr = explode('/', $action);
  6. $params = array_keys($url['vars']);
  7. $urlDepr1Params = [];
  8. $urlDepr2Params = [];
  9. if (!empty($params)) {
  10. foreach ($params as $param) {
  11. if(empty($url['vars'][$param]['require'])){
  12. array_push($urlDepr1Params, "[:$param]");
  13. }else{
  14. array_push($urlDepr1Params, ":$param");
  15. }
  16. array_push($urlDepr2Params, htmlspecialchars('<') . $param . htmlspecialchars('>'));
  17. }
  18. }
  19. if ($actionArr[2] == 'index') {
  20. $actionArr[1] = cmf_parse_name($actionArr[1]);
  21. return empty($params) ? $actionArr[1].'$' : ($actionArr[1] . '/' . implode('/', $urlDepr1Params) /*. '或' . $actionArr[1] . '-' . implode('-', $urlDepr2Params)*/);
  22. } else {
  23. $actionArr[2] = cmf_parse_name($actionArr[2]);
  24. return empty($params) ? $actionArr[2].'$' : ($actionArr[2] . '/' . implode('/', $urlDepr1Params) /*. '或' . $actionArr[2] . '-' . implode('-', $urlDepr2Params)*/);
  25. }
  26. }
  27. }
  28. if (!function_exists('_url_vars')) {
  29. function _url_vars($url)
  30. {
  31. if (!empty($url['vars'])) {
  32. return implode(',', array_keys($url['vars']));
  33. }
  34. return '';
  35. }
  36. }
  37. </php>
  38. <include file="public@header"/>
  39. </head>
  40. <body>
  41. <div class="wrap js-check-wrap">
  42. <form method="post" class="js-ajax-form" action="{:url('AdminCategory/listorders')}">
  43. <table class="table table-hover table-bordered table-list">
  44. <thead>
  45. <tr>
  46. <th width="16">
  47. </th>
  48. <th width="50">URL</th>
  49. <th>URL名称</th>
  50. <th>参数</th>
  51. <th>建议优化</th>
  52. </tr>
  53. </thead>
  54. <tbody>
  55. <foreach name="urls" item="vo" key="action">
  56. <php>$suggestUrl=_suggest_url($action,$vo);</php>
  57. <tr class="data-item-tr">
  58. <td>
  59. <input type="radio" name="ids[]" class="js-radio" value="" data-name="{$vo.name}"
  60. data-action="{$action}" data-url="{$suggestUrl}" data-vars="{:_url_vars($vo)}">
  61. </td>
  62. <td>{$action}</td>
  63. <td>{$vo.name}</td>
  64. <td>
  65. <notempty name="vo.vars">
  66. {:_url_vars($vo)}
  67. </notempty>
  68. </td>
  69. <td>
  70. {$suggestUrl}
  71. </td>
  72. </tr>
  73. </foreach>
  74. </tbody>
  75. </table>
  76. </form>
  77. </div>
  78. <script src="__STATIC__/js/admin.js"></script>
  79. <script>
  80. $('.data-item-tr').click(function (e) {
  81. console.log(e);
  82. var $this = $(this);
  83. if ($(e.target).is('input')) {
  84. return;
  85. }
  86. var $input = $this.find('input');
  87. if ($input.is(':checked')) {
  88. $input.prop('checked', false);
  89. } else {
  90. $input.prop('checked', true);
  91. }
  92. });
  93. function confirm() {
  94. var $url = $('.js-radio:checked');
  95. if ($url.length > 0) {
  96. var selectedUrl = {
  97. action: $url.data('action'),
  98. name: $url.data('name'),
  99. url: $url.data('url'),
  100. vars:$url.data('vars')
  101. };
  102. return selectedUrl;
  103. } else {
  104. return false;
  105. }
  106. }
  107. </script>
  108. </body>
  109. </html>