<%
#include "FormEleLib.js_"

var parentPkgName=GetGParamValue('EZGEN_ROOT_PKGNAME'); //上级包名
if(!parentPkgName)parentPkgName='com.ruoyi.project';
var modelPkgName=AutoCapProc(curModel.name,'JavaPackageName');
var modelCap=curModel.caption?curModel.caption:curModel.name;
var tb=curTable; //当前表
var tbPkgName=AutoCapProc(tb.name,'JavaPackageName');
var ClsName=AutoCapProc(tb.name,'ClassName'); //类名（驼峰命名，首字母大写）
var instName=AutoCapProc(tb.name,'FieldName'); //类名（驼峰命名，首字母小写）
var dispName=tb.UIDisplayName; //逻辑显示名
if(!dispName)dispName=ClsName;

var fds=tb.metaFields;
var idName='id';
var idCol='id';
var idTp='Long';
var pk=tb.getPrimaryKeyField();
if(pk){
    idName=AutoCapProc(pk.name,'FieldName');
    idCol=pk.name;
    if(pk.dataType!='cfdtInteger')
        idTp='String';
}
var _LfKeyL='${';

%><!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改${dispName}')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-${tbPkgName}-edit" th:object="${_LfKeyL}${instName}}">
<%
  //确保有输出ID
  if(!pk || !pk.canDisplay('sheet')){
    curOut.add('            <input name="'+idName+'" th:field="*{'+idName+'}" type="hidden">');
  }
  //遍历所有字段
  for(var k=0; k<fds.count; k++)
  {
    var fd = fds.getItem(k); //取第k个字段
    if(!fd.canDisplay('sheet'))
      continue; 
      
    var reqd='';
    if (fd.isRequired())
      reqd=' is-required';
%>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label${reqd}">${fd.getLabelText()}：</label>
                    <div class="col-sm-8"><% 
    writeFieldFormItem(fd,true); //表单项比较复杂，改用脚本输出 
%>
                    </div>
                </div>
            </div><%
  }%>

        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "${modelPkgName}/${tbPkgName}";
        $("#form-${tbPkgName}-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-${tbPkgName}-edit').serialize());
            }
        }

<%  //输出日期配置
  for(var k=0; k<fds.count; k++)
  {
    var fd = fds.getItem(k); //取第k个字段
    if(!fd.canDisplay('sheet'))
      continue;
    var fdName=AutoCapProc(fd.name,'FieldName');
    var dtpickOpt=datePickerJs['_datePickerOpt_'+fdName];
    if(!dtpickOpt)
      continue;
    %>
        $("input[name='${fdName}']").datetimepicker(${dtpickOpt});
<%
  }%>

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