config.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <form id="config-form" class="edit-form form-horizontal" role="form" data-toggle="validator" method="POST" action="">
  2. {if $addon.tips && $addon.tips.value}
  3. <div class="alert {$addon.tips.extend|default='alert-info-light'}" style="margin-bottom:10px;">
  4. {if $addon.tips.title}
  5. <b>{$addon.tips.title}</b><br>
  6. {/if}
  7. {$addon.tips.value}
  8. </div>
  9. {/if}
  10. <div class="panel panel-default panel-intro">
  11. {if count($groupList)>1}
  12. <div class="panel-heading mb-3">
  13. <ul class="nav nav-tabs nav-group">
  14. <li class="active"><a href="#all" data-toggle="tab">全部</a></li>
  15. {foreach name="groupList" id="tab"}
  16. <li><a href="#tab-{$key}" title="{$tab}" data-toggle="tab">{$tab}</a></li>
  17. {/foreach}
  18. </ul>
  19. </div>
  20. {/if}
  21. <div class="panel-body no-padding">
  22. <div id="myTabContent" class="tab-content">
  23. {foreach name="groupList" id="group" key="groupName"}
  24. <div class="tab-pane fade active in" id="tab-{$groupName}">
  25. <table class="table table-striped table-config mb-0">
  26. <tbody>
  27. {foreach name="$addon.config" id="item"}
  28. {if ((!isset($item['group']) || $item['group']=='') && $groupName=='other') || (isset($item['group']) && $item['group']==$group)}
  29. <tr data-favisible="{$item.visible|default=''|htmlentities}" data-name="{$item.name|htmlentities}" class="{if $item.visible??''}hidden{/if}">
  30. <td width="15%">
  31. {$item.title}
  32. {if $item.type=='array' && $item.tip}
  33. <a href="javascript:" class="text-info" data-toggle="popover" data-content="{$item.tip}" data-trigger="click" data-title="配置提示" data-html="true"><i class="fa fa-info-circle"></i></a>
  34. {/if}
  35. </td>
  36. <td>
  37. <div class="row">
  38. <div class="col-sm-8 col-xs-12">
  39. {switch $item.type}
  40. {case string}
  41. <input {$item.extend|htmlentities} type="text" name="row[{$item.name|htmlentities}]" value="{$item.value|htmlentities}" class="form-control" data-rule="{$item.rule}" data-tip="{$item.tip}"/>
  42. {/case}
  43. {case password}
  44. <input {$item.extend|htmlentities} type="password" name="row[{$item.name|htmlentities}]" value="{$item.value|htmlentities}" class="form-control" data-rule="{$item.rule}" data-tip="{$item.tip}"/>
  45. {/case}
  46. {case text}
  47. <textarea {$item.extend|htmlentities} name="row[{$item.name|htmlentities}]" class="form-control" data-rule="{$item.rule}" rows="5" data-tip="{$item.tip}">{$item.value|htmlentities}</textarea>
  48. {/case}
  49. {case array}
  50. <dl class="fieldlist" data-name="row[{$item.name|htmlentities}]">
  51. <dd>
  52. <ins>{:__('Array key')}</ins>
  53. <ins>{:__('Array value')}</ins>
  54. </dd>
  55. <dd>
  56. <a href="javascript:;" class="btn btn-sm btn-success btn-append"><i class="fa fa-plus"></i> {:__('Append')}</a>
  57. {if $item.name=='rewrite'}
  58. <a href="javascript:" class="btn btn-sm btn-warning btn-removerewrite" data-text="/wwh">一键移除URL中的/wwh</a>
  59. {/if}
  60. </dd>
  61. <textarea name="row[{$item.name|htmlentities}]" cols="30" rows="5" class="hide">{$item.value|json_encode|htmlentities}</textarea>
  62. </dl>
  63. {/case}
  64. {case date}
  65. <input {$item.extend|htmlentities} type="text" name="row[{$item.name|htmlentities}]" value="{$item.value|htmlentities}" class="form-control datetimepicker" data-date-format="YYYY-MM-DD" data-tip="{$item.tip}" data-rule="{$item.rule}"/>
  66. {/case}
  67. {case time}
  68. <input {$item.extend|htmlentities} type="text" name="row[{$item.name|htmlentities}]" value="{$item.value|htmlentities}" class="form-control datetimepicker" data-date-format="HH:mm:ss" data-tip="{$item.tip}" data-rule="{$item.rule}"/>
  69. {/case}
  70. {case datetime}
  71. <input {$item.extend|htmlentities} type="text" name="row[{$item.name|htmlentities}]" value="{$item.value|htmlentities}" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-tip="{$item.tip}" data-rule="{$item.rule}"/>
  72. {/case}
  73. {case number}
  74. <input {$item.extend|htmlentities} type="number" name="row[{$item.name|htmlentities}]" value="{$item.value|htmlentities}" class="form-control" data-tip="{$item.tip}" data-rule="{$item.rule}"/>
  75. {/case}
  76. {case checkbox}
  77. {foreach name="item.content" item="vo"}
  78. <label for="row[{$item.name|htmlentities}][]-{$key}"><input id="row[{$item.name|htmlentities}][]-{$key}" name="row[{$item.name|htmlentities}][]" type="checkbox" value="{$key}" data-tip="{$item.tip}" {in name="key" value="$item.value" }checked{/in} /> {$vo}</label>
  79. {/foreach}
  80. <span class="msg-box n-right" for="c-{$item.name|htmlentities}"></span>
  81. {/case}
  82. {case radio}
  83. {foreach name="item.content" item="vo"}
  84. <label for="row[{$item.name|htmlentities}]-{$key}"><input id="row[{$item.name|htmlentities}]-{$key}" name="row[{$item.name|htmlentities}]" type="radio" value="{$key}" data-tip="{$item.tip}" {in name="key" value="$item.value" }checked{/in} /> {$vo}</label>
  85. {/foreach}
  86. <span class="msg-box n-right" for="c-{$item.name|htmlentities}"></span>
  87. {/case}
  88. {case value="select" break="0"}{/case}
  89. {case value="selects"}
  90. <select {$item.extend|htmlentities} name="row[{$item.name|htmlentities}]{$item.type=='selects'?'[]':''}" class="form-control selectpicker" data-tip="{$item.tip}" {$item.type=='selects'?'multiple':''}>
  91. {foreach name="item.content" item="vo"}
  92. <option value="{$key}" {in name="key" value="$item.value" }selected{/in}>{$vo}</option>
  93. {/foreach}
  94. </select>
  95. {/case}
  96. {case value="image" break="0"}{/case}
  97. {case value="images"}
  98. <div class="form-inline">
  99. <input id="c-{$item.name|htmlentities}" class="form-control" size="35" name="row[{$item.name|htmlentities}]" type="text" value="{$item.value|htmlentities}" data-tip="{$item.tip}">
  100. <span><button type="button" id="plupload-{$item.name|htmlentities}" class="btn btn-danger plupload" data-input-id="c-{$item.name|htmlentities}" data-mimetype="image/*" data-multiple="{$item.type=='image'?'false':'true'}" data-preview-id="p-{$item.name|htmlentities}"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
  101. <span><button type="button" id="fachoose-{$item.name|htmlentities}" class="btn btn-primary fachoose" data-input-id="c-{$item.name|htmlentities}" data-mimetype="image/*" data-multiple="{$item.type=='image'?'false':'true'}"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
  102. <ul class="row list-inline plupload-preview" id="p-{$item.name|htmlentities}"></ul>
  103. </div>
  104. {/case}
  105. {case value="file" break="0"}{/case}
  106. {case value="files"}
  107. <div class="form-inline">
  108. <input id="c-{$item.name|htmlentities}" class="form-control" size="35" name="row[{$item.name|htmlentities}]" type="text" value="{$item.value|htmlentities}" data-tip="{$item.tip}">
  109. <span><button type="button" id="plupload-{$item.name|htmlentities}" class="btn btn-danger plupload" data-input-id="c-{$item.name|htmlentities}" data-multiple="{$item.type=='file'?'false':'true'}"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
  110. <span><button type="button" id="fachoose-{$item.name|htmlentities}" class="btn btn-primary fachoose" data-input-id="c-{$item.name|htmlentities}" data-multiple="{$item.type=='file'?'false':'true'}"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
  111. </div>
  112. {/case}
  113. {case bool}
  114. <label for="row[{$item.name|htmlentities}]-yes"><input id="row[{$item.name|htmlentities}]-yes" name="row[{$item.name|htmlentities}]" type="radio" value="1" {$item.value?'checked':''} data-tip="{$item.tip}" /> {:__('Yes')}</label>
  115. <label for="row[{$item.name|htmlentities}]-no"><input id="row[{$item.name|htmlentities}]-no" name="row[{$item.name|htmlentities}]" type="radio" value="0" {$item.value?'':'checked'} data-tip="{$item.tip}" /> {:__('No')}</label>
  116. {/case}
  117. {default /}{$item.value}
  118. {/switch}
  119. </div>
  120. <div class="col-sm-4"></div>
  121. </div>
  122. </td>
  123. </tr>
  124. {/if}
  125. {/foreach}
  126. </tbody>
  127. </table>
  128. </div>
  129. {/foreach}
  130. <div class="form-group layer-footer">
  131. <label class="control-label col-xs-12 col-sm-2" style="width:15%;"></label>
  132. <div class="col-xs-12 col-sm-8">
  133. <button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
  134. <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
  135. </div>
  136. </div>
  137. </div>
  138. </div>
  139. </div>
  140. </form>
  141. <script>
  142. require.callback = function () {
  143. var tabevent = function () {
  144. $(document).on("click", ".btn-removerewrite", function () {
  145. $("dd", $(this).closest("dl.fieldlist")).each(function () {
  146. });
  147. var reg = new RegExp($(this).data("text"));
  148. $(this).closest("dl.fieldlist").find("input[name$='[value]']").each(function () {
  149. $(this).val($(this).val().replace(reg, ''));
  150. });
  151. $(this).closest("dl.fieldlist").find("input[name$='[value]']:first").trigger("change");
  152. });
  153. }
  154. define('backend/addon', ['jquery', 'form'], function ($, Form) {
  155. var Controller = {
  156. config: function () {
  157. Form.api.bindevent($("form[role=form]"));
  158. tabevent();
  159. }
  160. };
  161. return Controller;
  162. });
  163. }
  164. </script>