<!-- <fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
  <legend>赋值和取值</legend>
</fieldset> -->
<?
$fields=$duoduo->get_table_desc(MOD);
$row=$duoduo->select(MOD,"*","id=".$_GET['id']);

?>
 <br>
<div class="layui-form layuimini-main">


  <?
   foreach ($fields as $key => $value) {

         $title=$value['title'];
         $name=$value['field'];
         if ($row['id']>0)
             $fvalue=$row[$value['field']];
         $field=$value['field'];

  ?>

     <? if(empty($value['type'])){?>
    <div class="layui-form-item">
      <label class="layui-form-label"><?=$value['title']?></label>
      <div class="layui-input-block">
        <input type="text" name="<?=$value['field']?>"  autocomplete="off" lay-verify="required" placeholder="请输入<?=$value['title']?>" class="layui-input" value="<?=$row[$value['field']]?$row[$value['field']]:dvalue($value['field'])?>">
      </div>
    </div>
    <? }?>
    
    <? if($value['type']=="number"){?>
    <div class="layui-form-item">
      <label class="layui-form-label"><?=$value['title']?></label>
      <div class="layui-input-block">
         <input type="text" lay-verify="required|number" name="<?=$value['field']?>"  autocomplete="off"  placeholder="请输入<?=$value['title']?>" class="layui-input" value="<?=$row[$value['field']]?$row[$value['field']]:dvalue($value['field'])?>">
      </div>
    </div>
    <? }?>
    
     <? if($value['type']=="pwd"){?>
    <div class="layui-form-item">
      <label class="layui-form-label"><?=$value['title']?></label>
      <div class="layui-input-block">
         <input  type="password"  name="<?=$value['field']?>"  autocomplete="off"  placeholder="请输入<?=$value['title']?>" class="layui-input" value="">
      </div>
    </div>
    <? }?>


     <? if($value['type']=="img"){
         include(ADMINROOT.'/template/tpl/img.tpl.php'); //
     }?>
         
    <? if($value['type']=="time"){
      
       include(ADMINROOT.'/template/tpl/time.tpl.php'); //公共模板
    }?>
    



    <? if($value['type']=="switch"){?>
    <div class="layui-form-item">
    <label class="layui-form-label"><?=$value['title']?></label>
    <div class="layui-input-block">
      <input type="checkbox"  <?=swicth_checked($row[$value['field']],$data['switch'][$value['field']])?>   name="<?=$value['field']?>" lay-skin="switch" lay-text="ON|OFF"><div class="layui-unselect layui-form-switch" lay-skin="_switch"><em>ON</em><i></i></div>
    </div>
  </div>
  <? }?>
   <? if($value['type']=="desc"){?>
   <div class="layui-form-item layui-form-text">
    <label class="layui-form-label"><?=$value['title']?></label>
    <div class="layui-input-block">
      <textarea placeholder="请输入<?=$value['title']?>" class="layui-textarea"  name="<?=$value['field']?>"><?=$row[$value['field']]?></textarea>
    </div>
  </div>
     <? }?>


    <? if($value['type']=="content"){?>
    <div class="layui-form-item">
    <label class="layui-form-label"><?=$value['title']?></label>
     <div class="layui-input-block">
         <textarea id="<?=$value['field']?>" name="<?=$value['field']?>" style="display: none;"><?=$row[$value['field']]?></textarea>
    </div>
  </div>
    <? }?>
     <? if($value['type']=="select"){?>
    <div class="layui-form-item">
    <label class="layui-form-label"><?=$value['title']?></label>
     <div class="layui-input-block">
          <?=select3($data[$value['field']],$row[$value['field']],$value['field'])?>
    </div>
  </div>
    
     <? }?>            

<? }?>
  <div class="layui-form-item">
    <div class="layui-input-block">
      <input type="hidden" value="<?=$row['id']?>" name="id">
        <button class="layui-btn layui-btn-normal jian_save" lay-submit lay-filter="saveBtn">确认保存</button>
    </div>
  </div>
</div>


<script>

    layui.use(['form','miniAdmin','layedit'], function () {
        var form = layui.form,
            layer = layui.layer,
            miniAdmin = layui.miniAdmin,
            $ = layui.jquery;
            layedit = layui.layedit;
       
        /**
         * 初始化表单，要加上，不然刷新部分组件可能会不加载
         */
       
        form.render();
      
        // 当前弹出层，防止ID被覆盖
        var parentIndex = layer.index;
        //单选 事件
  layedit.set({
        uploadImage: {
          url: 'ajax.php?act=upload' //接口url
          ,type: '' //默认post
          }
        });
  var edit_content=layedit.build('content'); //建立编辑器

  $(".jian_save").click(function(){
    if($("#content")[0]){
      $("#content").html(layedit.getContent(edit_content));
    }
     
  })



  
  })  

 function throttle(method, context) {
     clearTimeout(method.tId);
     method.tId = setTimeout(function(){
         method.call(context);
     },200);
 }
</script>

