edit_config.html 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. {include file="public/header" /}
  2. <body class="gray-bg">
  3. <div class="layui-fluid layui-col-md12">
  4. <div class="layui-card">
  5. <div class="layui-card-body layui-form">
  6. <input type="hidden" name="id" value="{$info.id}">
  7. <div class="layui-row layui-col-space10 layui-form-item ">
  8. <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
  9. <label class="layui-form-label">配置标识</label>
  10. <div class="layui-input-block">
  11. <input type="text" name="name" lay-verify="required|name" placeholder="用于config函数调用,只能使用英文且不能重复" class="layui-input " value="{$info.name}">
  12. </div>
  13. </div>
  14. <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
  15. <label class="layui-form-label">配置标题</label>
  16. <div class="layui-input-block">
  17. <input type="text" name="title" lay-verify="required" placeholder="用于后台显示的配置标题" class="layui-input " value="{$info.title}" >
  18. </div>
  19. </div>
  20. <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
  21. <label class="layui-form-label">配置类型</label>
  22. <div class="layui-input-block">
  23. <select name="type" id="type" lay-verify="required" lay-search="" lay-filter="types" >
  24. <option value="">请选择类型</option>
  25. {if !empty($Think.config.config_type_list)}
  26. {volist name="Think.config.config_type_list" id="type"}
  27. <option value="{$key}" {eq name="$key" value="$info.type"}selected{/eq}>{$type}</option>
  28. {/volist}
  29. {/if}
  30. </select>
  31. </div>
  32. </div>
  33. <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
  34. <label class="layui-form-label">配置分组</label>
  35. <div class="layui-input-block">
  36. <select name="group" lay-verify="required" lay-search="">
  37. <option value="">请选择分组</option>
  38. {if !empty($Think.config.config_group_list)}
  39. {volist name="Think.config.config_group_list" id="type"}
  40. <option value="{$key}" {eq name="$key" value="$info.group"}selected{/eq} >{$type}</option>
  41. {/volist}
  42. {/if}
  43. </select>
  44. </div>
  45. </div>
  46. <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
  47. <label class="layui-form-label">配置值</label>
  48. <div class="layui-input-block">
  49. <input type="text" name="value" lay-verify="required" placeholder="用于config函数调用显示的值" class="layui-input " value="{$info.value}">
  50. </div>
  51. </div>
  52. <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
  53. <label class="layui-form-label">配置项</label>
  54. <div class="layui-input-block">
  55. <textarea name="extra" placeholder="如果是枚举型,需要配置该项" lay-verify="extra" class="layui-textarea">{$info.extra}</textarea>
  56. </div>
  57. </div>
  58. <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
  59. <label class="layui-form-label">配置描述</label>
  60. <div class="layui-input-block">
  61. <textarea name="remark" lay-verify="required" placeholder="配置详细说明" class="layui-textarea">{$info.remark}</textarea>
  62. </div>
  63. </div>
  64. <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
  65. <label class="layui-form-label">排序</label>
  66. <div class="layui-input-block">
  67. <input type="text" name="sort" lay-verify="required|sort" placeholder="用于显示的顺序" class="layui-input " value="{$info.sort}">
  68. </div>
  69. </div>
  70. <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
  71. <div class="layui-input-block">
  72. <button class="layui-btn" lay-submit="" lay-filter="component-form-element">保存
  73. </button>
  74. <button class="layui-btn layui-btn-primary" onclick="wk.layer_close('close')">关闭</button>
  75. </div>
  76. </div>
  77. </div>
  78. </div>
  79. </div>
  80. </div>
  81. {include file="public/footer" /}
  82. <script>
  83. layui.use(['form'], function() {
  84. var form = layui.form;
  85. form.verify({
  86. name:function(value,item){
  87. if(!/^[a-zA-Z_]*$/.test(value)){
  88. return '只能使用英文和下划线且不能重复';
  89. }
  90. var checkResult = "";
  91. $.ajax({
  92. url:"{:url('Config/checkConfig')}",
  93. type:'post',
  94. data:"name="+value + "&id=" + $('input[name=id]').val(),
  95. async: false,//必须同步
  96. success:function(res){
  97. if(res.code == 100){
  98. checkResult = "该配置标识已存在";
  99. }
  100. }
  101. })
  102. return checkResult;
  103. },
  104. extra: function(value,item){
  105. var type = $('#type').find("option:selected").text();
  106. if(type == "枚举" && value == ""){
  107. return "配置类型为枚举,配置项必填";
  108. }
  109. },
  110. sort:[/^(0|[1-9]\d*)$/,'排序值只能为非负整数']
  111. });
  112. form.on('submit(component-form-element)', function (data) {
  113. $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
  114. $.ajax({
  115. url:"{:url('edit_config')}",
  116. type:'post',
  117. dataType:'json',
  118. data:data.field,
  119. success:function(res){
  120. if (res.code == 200) {
  121. wk.success(res.msg,'wk.layer_close()');
  122. } else {
  123. wk.error(res.msg,'$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\')');
  124. }
  125. }
  126. })
  127. });
  128. });
  129. </script>
  130. </body>
  131. </html>