<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <?php $shoname_name = D('Home/Front')->get_config_by_name('shoname'); ?>
  <title><?php echo $shoname; ?></title>
  <link rel="shortcut icon" href="" />

  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">

  <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">

  <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
  <!--[if lt IE 9]>
  <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
  <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
  <![endif]-->

  <link href="./resource/css/bootstrap.min.css?v=201903260001" rel="stylesheet">
  <link href="./resource/css/common.css?v=201903260001" rel="stylesheet">
  <script type="text/javascript">
    window.sysinfo = {
    <?php if (!empty($_W['uniacid']) ){ ?>'uniacid': '{$_W['uniacid']}',<?php } ?>

    <?php if( !empty($_W['acid'])  ){ ?>'acid': '{$_W['acid']}',<?php } ?>

    <?php if (!empty($_W['openid']) ) { ?>'openid': '{$_W['openid']}',<?php } ?>

    <?php if( !empty($_W['uid']) ) {  ?>'uid': '{$_W['uid']}',<?php } ?>

    'isfounder': <?php if (!empty($_W['isfounder']) ) { ?>1<?php  }else{  ?>0<?php } ?>,

    'siteroot': '{$_W['siteroot']}',
            'siteurl': '{$_W['siteurl']}',
            'attachurl': '{$_W['attachurl']}',
            'attachurl_local': '{$_W['attachurl_local']}',
            'attachurl_remote': '{$_W['attachurl_remote']}',
            'module' : {'url' : '<?php if( defined('MODULE_URL') ) { ?>{MODULE_URL}<?php } ?>', 'name' : '<?php if (defined('IN_MODULE') ) { ?>{IN_MODULE}<?php } ?>'},
    'cookie' : {'pre': ''},
    'account' : {:json_encode($_W['account'])},
    };
  </script>
  <style>
    .radio-inline, .checkbox-inline {
      padding-left: 0px;
    }
  </style>
  <script type="text/javascript" src="./resource/js/lib/jquery-1.11.1.min.js"></script>
  <script type="text/javascript" src="./resource/js/lib/bootstrap.min.js"></script>
  <script type="text/javascript" src="./resource/js/app/util.js?v=201903260001"></script>
  <script type="text/javascript" src="./resource/js/app/common.min.js?v=201903260001"></script>
  <script type="text/javascript" src="./resource/js/require.js?v=201903260001"></script>
  <script type="text/javascript" src="./resource/js/lib/jquery.nice-select.js?v=201903260001"></script>
  <script type="text/javascript" src="/layuiadmin/layui/layui.js?v=2021052500001"></script>
  <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
  <link href="/static/css/snailfish.css" rel="stylesheet">
  <link href="/static/css/szyV6.css" rel="stylesheet">
  <link href="/static/css/allform.css" rel="stylesheet">
</head>
<body layadmin-themealias="default">
<!-- 菜单组件 begin-->
<include file="Public/componts_menu"/>
<!-- 菜单组件end -->

<div class="div-iframe">

  <div class="layui-fluid">
    <div class="layui-card">
      <div class="layui-card layadmin-header" style="display:block;">
        <div class="layui-breadcrumb" lay-filter="breadcrumb" style="visibility: visible;">
          <a href="{:U('application/index')}">应用</a><span lay-separator="">/</span>
          <a  href="{:U('allform/index')}"><cite>万能表单</cite></a><span lay-separator="">/</span>
          <a href="{:U('allform/index')}"><cite><?php if(empty($item)){?>新增<?php }else{?>修改<?php }?>表单</cite></a>
        </div>
      </div>
      <!--- 内容开始 -->
      <div class="layui-card-body" style="padding:5px;">
        <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
          <div class="layui-tab-content" style="margin: 0 auto;padding: 5px;">
            <div class="layui-tab-item" style="display: block">
              <div class="layui-card-body" style="">
                <form action="" class="layui-form" lay-filter="example" method="post">
                  <input type="hidden" name="id" value="<?php echo empty($item) ? '' : $item['id'];?>" />
                  <div class="layui-form-item" style="display: flex;">
                    <div class="diyphone">
                      <div class="page_content">
                        <div class="page-title">自定义表单预览</div>
                        <div class="phone-body">
                          <div class="phone-top">
                            <div class="phone-img">
                              <img src="/static/images/poster_1.png" style="width: 375px; height: 20px;">
                              <img src="/static/images/poster_3.png" style="width: 373px; height: 44px;">
                            </div>
                            <div class="phone-title">页面名称</div>
                          </div>
                          <div class="phone-main">
                            <div class="phone-main-content-box">
                              <div class="phone-main-content">
                                <?php echo !empty($item['phone_item']) ? $item['phone_item'] : '';?>
                              </div>
                            </div>
                            <div class="bottom-items" style="width: 100%;"></div>
                            <p class="no_element" style="text-align: center; line-height: 400px;
                						    <?php if(!empty($item) && !empty($item->phone_item)){?>
                                                display:none;
                                                <?php } ?>
                						">您还没有添加任何元素</p>
                          </div>
                        </div>
                      </div>
                    </div>
                    <div class="form-config">
                      <div class="layui-form-item">
                        <label class="layui-form-label "><span style="color:red;">*</span>&nbsp;表单名称：</label>
                        <div class="layui-input-block">
                          <input type="text" class="layui-input" name='form_name' value="<?php echo empty($item) ? '' : $item['form_name'];?>" maxlength="100">
                        </div>
                      </div>
                      <div class="layui-form-item">
                        <label class="layui-form-label">表单类型：</label>
                        <div class="layui-input-block">
                          <div class="input-group">
                            <label class="radio-inline">
                              <input type="radio" title="下单表单" name="form_type" lay-filter="form_type" value="order" <?php if(empty($item['form_type']) || $item['form_type'] == 'order'){ ?> checked="checked"<?php } ?>>
                            </label>
                          </div>
                          <div class="layui-form-mid layui-word-aux">商品表单位于商品规格下面进行显示，只能商品使用；<br/>下单表单位于订单提交页面进行显示，只能商品下单的时候使用；<br/>申请表单只能在申请分销商以及其他申请信息的时候使用</div>
                        </div>
                      </div>
                      <div class="layui-form-item">
                        <label class="layui-form-label">选择表单字段：</label>
                        <div class="layui-input-block">
                          <div class="form-item-adder">
                            <div class="btn act_btn" type="image">
                              <button type="button" class="oper-btn ivu-btn ivu-btn-primary">
                                  <span>
                                      <img src="/static/images/allform/img.svg" alt="" class="btn-svg"> 图片
                                      <div class="btn-shade"> 添加字段 </div>
                                  </span>
                              </button>
                            </div>
                            <div class="btn act_btn" type="text">
                              <button type="button" class="oper-btn ivu-btn ivu-btn-primary">
                                  <span>
                                      <img src="/static/images/allform/moretxt.svg" alt="" class="btn-svg"> 单行文本
                                      <div class="btn-shade"> 添加字段 </div>
                                  </span>
                              </button>
                            </div>
                            <div class="btn act_btn" type="textarea">
                              <button type="button" class="oper-btn ivu-btn ivu-btn-primary">
                                    <span>
                                        <img src="/static/images/allform/moretxt.svg" alt="" class="btn-svg"> 多行文本
                                        <div class="btn-shade"> 添加字段 </div>
                                    </span>
                              </button>
                            </div>
                            <div class="btn act_btn" type="select">
                              <button type="button" class="oper-btn ivu-btn ivu-btn-primary">
                                  <span>
                                      <img src="/static/images/allform/select.svg" alt="" class="btn-svg"> 下拉框
                                      <div class="btn-shade"> 添加字段 </div>
                                  </span>
                              </button>
                            </div>
                            <div class="btn act_btn" type="radiao">
                              <button type="button" class="oper-btn ivu-btn ivu-btn-primary">
                                  <span>
                                      <img src="/static/images/allform/oneradio.svg" alt="" class="btn-svg"> 单选框
                                      <div class="btn-shade"> 添加字段 </div>
                                  </span>
                              </button>
                            </div>
                            <div class="btn act_btn" type="checked">
                              <button type="button" class="oper-btn ivu-btn ivu-btn-primary">
                                  <span>
                                      <img src="/static/images/allform/checked.svg" alt="" class="btn-svg"> 多选框
                                      <div class="btn-shade"> 添加字段 </div>
                                  </span>
                              </button>
                            </div>
                            <div class="btn act_btn" type="area">
                              <button type="button" class="oper-btn ivu-btn ivu-btn-primary">
                                  <span>
                                      <img src="/static/images/allform/area.svg" alt="" class="btn-svg"> 地区
                                      <div class="btn-shade"> 添加字段 </div>
                                  </span>
                              </button>
                            </div>
                            <div class="btn act_btn" type="date">
                              <button type="button" class="oper-btn ivu-btn ivu-btn-primary">
                                  <span>
                                      <img src="/static/images/allform/date.svg" alt="" class="btn-svg"> 日期
                                      <div class="btn-shade"> 添加字段 </div>
                                  </span>
                              </button>
                            </div>
                            <div class="btn act_btn" type="date_range">
                              <button type="button" class="oper-btn ivu-btn ivu-btn-primary">
                                  <span>
                                      <img src="/static/images/allform/daterange.svg" alt="" class="btn-svg"> 日期范围
                                      <div class="btn-shade"> 添加字段 </div>
                                  </span>
                              </button>
                            </div>
                            <div class="btn act_btn" type="idcard">
                              <button type="button" class="oper-btn ivu-btn ivu-btn-primary">
                                  <span>
                                      <img src="/static/images/allform/idcard.svg" alt="" class="btn-svg"> 身份证号码
                                      <div class="btn-shade"> 添加字段 </div>
                                  </span>
                              </button>
                            </div>
                            <div class="btn act_btn" type="time">
                              <button type="button" class="oper-btn ivu-btn ivu-btn-primary">
                                  <span>
                                      <img src="/static/images/allform/time.svg" alt="" class="btn-svg"> 时间
                                      <div class="btn-shade"> 添加字段 </div>
                                  </span>
                              </button>
                            </div>
                            <div class="btn act_btn" type="time_range">
                              <button type="button" class="oper-btn ivu-btn ivu-btn-primary">
                                  <span>
                                      <img src="/static/images/allform/timerange.svg" alt="" class="btn-svg"> 时间范围
                                      <div class="btn-shade"> 添加字段 </div>
                                  </span>
                              </button>
                            </div>
                            <div class="btn act_btn" type="telephone">
                              <button type="button" class="oper-btn ivu-btn ivu-btn-primary">
                                  <span>
                                      <img src="/static/images/allform/telephone.svg" alt="" class="btn-svg"> 手机号码
                                      <div class="btn-shade"> 添加字段 </div>
                                  </span>
                              </button>
                            </div>
                          </div>
                        </div>
                      </div>
                      <div class="layui-form-item" style="margin-bottom: 5px;">
                        <label class="layui-form-label">表单设置：</label>
                      </div>
                      <div class="layui-form-item">
                        <div class="layui-input-block" style="margin-left: 0px;padding: 0 25px;">
                          <ul class="form-items" id="form_config_ul">
                            <?php echo !empty($item['item_li']) ? $item['item_li'] : '';?>
                          </ul>
                        </div>
                      </div>
                      <div class="layui-form-item" style="border-top: 1px solid #eceaea;padding-top: 10px;">
                        <label class="layui-form-label"></label>
                        <div class="layui-input-block">
                            <input type="submit" value="提交" lay-submit lay-filter="formDemo" class="btn btn-primary"  />
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <a class="btn btn-default" style='margin-left:10px;' href="{:U('allform/index')}">返回列表</a>
                        </div>
                      </div>
                    </div>
                  </div>
                </form>
              </div>
            </div>
          </div>
        </div>
      </div>
      <!--- 内容结束-->
    </div>
  </div>
</div>
<script>
  var add_item_url = "{:U('allform/add_item')}";
</script>
<script type="text/javascript" src="/static/js/allform/allform.js?v=202105240001"></script>
<script type="text/javascript" src="/static/js/dist/area/area_form.js?v=202105240001"></script>
<script>
  layui.config({
    base: '/layuiadmin/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use('index');
</script>

<script>
  //由于模块都一次性加载，因此不用执行 layui.use() 来加载对应模块，直接使用即可：
  var layer = layui.layer;
  var $;

  layui.use(['jquery', 'layer','form'], function(){
    $ = layui.$;
    var form = layui.form;

    $('.sub-nav').css('height',  $(window).height() + 'px');

    //监听提交
    form.on('submit(formDemo)', function(data){
      var loadingIndex = layer.load(); // 加载中动画遮罩层（1）

      $.ajax({
        url: data.form.action,
        type: data.form.method,
        data: data.field,
        dataType:'json',
        success: function (info) {
          layer.close(loadingIndex); // 提交成功失败都需要关闭
          if(info.status == 0)
          {
            layer.msg(info.result.message,{icon: 1,time: 2000});
            can_sub = true;
          }else if(info.status == 1){
            var go_url = location.href;
            if( info.result.hasOwnProperty("url") )
            {
              go_url = info.result.url;
            }

            layer.msg('操作成功',{time: 1000,
              end:function(){

                location.href = go_url;
              }
            });
            can_sub = true;
          }
        }
      });
      return false;
    });
  })

</script>
</body>
</html>


