
@{
    string Id = Request.QueryString["id"];
}
<div class="main no-top-border">

    <form id="_form" class=" form-group-sm form ui-validForm" method="post" data-validate-params="beforeSubmit:'CkForm'" data-source="@Model">
        <div class="tabcontent" data-tab-params="tabName:'基础参数'">

            <div class="form-group">
                <label class="control-label" for="name">字段</label>
                <div class="controls">
                    <input type="text" name="Name" id="Name" maxlength="30" data-validate="dataType:'field',nullMsg:'请填写字段',errorMsg:''" class="form-control form-control-sm ui-edit-readonly">
                    <span class="help-block">字段只能用英文字符，数字或下划线组成</span>
                </div>
            </div>

            <div class="form-group">
                <label class="control-label" for="remark">备注</label>
                <div class="controls">
                    <input type="text" name="Remark" id="Remark" maxlength="30" data-validate="dataType:'*',nullMsg:'请填写字段标识'" class="form-control form-control-sm">
                    <span class="help-block">如：标题，用于标识</span>
                </div>
            </div>

            <div class="form-group">
                <label class="control-label" for="FieldType">表单类型</label>
                <div class="controls">
                    <select class="form-control form-control-sm" name="FieldType" id="FieldType" data-validate="dataType:'*',nullMsg:'请选择表单类型'" onchange="ChangeType()">
                        <option value="">请选择表单类型</option>
                        <option value="text" value_type="nvarchar,int,smallint,tinyint,decimal,datetime,date" transformType="text,password,hidden,select,radio,checkbox">单行文本输入框</option>
                        <option value="password" value_type="nvarchar,int,smallint,tinyint,decimal,datetime,date" transformType="text,password,hidden">密码输入框</option>
                        <option value="hidden" value_type="nvarchar,int,smallint,tinyint,decimal,datetime,date" transformType="text,password,hidden">隐藏域表单（hidden)</option>
                        <option value="select" value_type="nvarchar,int,smallint,tinyint,decimal,datetime,date" transformType="text,select,radio">下拉表单</option>
                        <option value="radio" value_type="nvarchar,int,smallint,tinyint,decimal" transformType="text,select,radio,checkbox">单选框</option>
                        <option value="checkbox" value_type="nvarchar" transformType="text,select,radio,checkbox">复选框</option>
                        <option value="textarea" value_type="nvarchar" transformType="textarea,editor">多行文本(textarea)</option>
                        <option value="editor" value_type="nvarchar" transformType="textarea,editor">编辑器</option>
                        <option value="image" value_type="nvarchar" transformType="image,file">图片</option>
                        <option value="images" value_type="int" transformType="files,images">图片组</option>
                        <option value="file" value_type="nvarchar" transformType="file,image">附件</option>
                        <option value="files" value_type="int" transformType="files,images">附件组</option>
                        <option value="subtable" value_type="int" transformType="subtable">附属表</option>
                    </select>
                    <span class="help-block">图片,图片组,附件,附件组和附表类型将创建一个格式为：表名_字段名的新表</span>
                </div>
            </div>

            <div class="form-group defaulthidden IsMultipleSelect" field_type="select">
                <label class="control-label" for="Items">下拉表单类型</label>
                <div class="controls radio">
                    <label class="radio-inline">
                        <input name="IsMultipleSelect" id="IsMultipleSelect" value="0" checked type="radio">单选下拉表单
                    </label>
                    <label class="radio-inline">
                        <input name="IsMultipleSelect" id="IsMultipleSelect" value="1" type="radio">多选下拉表单
                    </label>
                    <span class="help-block">多选下拉表单的数据类型建议设置为文本类</span>
                </div>
            </div>

            <div class="form-group" id="boxValueType">
                <label class="control-label" for="ValueType">数据类型</label>
                <div class="controls">
                    <select class="form-control ui-edit-readonly form-control-sm ui-show-hide" name="ValueType" id="ValueType" data-validate="dataType:'*',nullMsg:'请选择字段数据类型',ignoreHidden:true">
                        <option value="">请选择数据类型</option>
                        <option value="nvarchar" showObjs=".ValueLength" hideObjs=".decaimalAccuracy">文本类型/nvarchar</option>
                        <option value="int" title="从-2,147,483,648到2,147,483,647的整型数据，存储大小为4个字节" hideObjs=".decaimalAccuracy">整型/int</option>
                        <option value="smallint" title="从-32768到32767的整型数据，存储大小为2个字节" hideObjs=",.decaimalAccuracy">小整型/smallint</option>
                        <option value="tinyint" title="从0到255的整型数据，存储大小位1个字节" hideObjs=".decaimalAccuracy">微整型/tinyint</option>
                        <option value="decimal" title="system.decimal，无精度损失" showObjs=".decaimalAccuracy">小数/decimal</option>
                        <option value="datetime" hideObjs=".decaimalAccuracy">日期/DateTime</option>
                    </select>
                    <span class="help-block">设置后不可修改</span>
                </div>
            </div>

            <div class="form-group defaulthidden decaimalAccuracy">
                <label class="control-label">小数精度</label>
                <div class="controls">
                    <input type="text" name="DecimalAccuracy" id="DecimalAccuracy" maxlength="5" value="12,2" class="form-control form-control-sm" data-validate="dataType:'*',nullMsg:'请填写小数精度！',ignoreHidden:true">
                    <input type="hidden" name="DecimalAccuracyOld" id="DecimalAccuracyOld" class="form-control">
                    <span class="help-block">小数精度，格式为：12,2表示总最大长度为12位，其中小数点后只保留2位数，精度改小可能会导致已有数据丢失。</span>
                </div>
            </div>

            <div class="form-group  ValueLength">
                <label class="control-label">文本/输入框长度</label>
                <div class="controls">
                    <input type="text" name="ValueLength" id="ValueLength" maxlength="9" value="50" class="form-control form-control-sm" data-validate="dataType:'numeric',min:1,nullMsg:'请填写字段长度！',ignoreHidden:true">
                    <input type="hidden" name="ValueLengthOld" id="ValueLengthOld" class="form-control">
                    <span class="help-block">在数据库中，文本类型超过4000后将采用nvarchar(max),日期型只用于控制日期格式,数值型仅用于控制输入框的Maxlength</span>
                </div>
            </div>

            <div class="form-group defaulthidden DefaultValue" field_type="text,password,hidden,select,radio,checkbox,image,file">
                <label class="control-label" for="DefaultValue">默认值</label>
                <div class="controls">
                    <input type="text" name="DefaultValue" id="DefaultValue" maxlength="50" class="form-control form-control-sm">
                    <input type="hidden" name="DefaultValueOld" id="DefaultValueOld" class="form-control">

                    <span class="help-block">字段的默认值，不填写数值型默认值为0，日期型默认为当前日期</span>
                </div>
            </div>

            <div class="form-group defaulthidden Items" field_type="select,radio,checkbox">
                <label class="control-label" for="Items">自定义选项</label>
                <div class="controls">
                    <textarea id="Items" name="Items" class="form-control form-control-sm textarea " style="height:100px"></textarea>
                    <span class="help-block">每行为一个列表选项,值和文本用“,”隔开，如：1,推荐</span>
                </div>
            </div>

            <div class="form-group defaulthidden EditorStyle" field_type="editor">
                <label class="control-label" for="EditorStyle">编辑器类型</label>
                <div class="controls radio">
                    <label class="radio-inline">
                        <input name="EditorStyle" id="EditorStyle" value="small" checked type="radio">精简版
                    </label>
                    <label class="radio-inline">
                        <input name="EditorStyle" id="EditorStyle" value="simple" type="radio">简洁版
                    </label>
                    <label class="radio-inline">
                        <input name="EditorStyle" id="EditorStyle" value="normal" type="radio">通用版
                    </label>
                    <label class="radio-inline">
                        <input name="EditorStyle" id="EditorStyle" value="full" type="radio">全功能版
                    </label>
                    <span class="help-block"></span>
                </div>
            </div>

            <div class="form-group defaulthidden EditorWidth" field_type="editor">
                <label class="control-label" for="EditorWidth">编辑器宽度</label>
                <div class="controls">
                    <input type="text" name="EditorWidth" id="EditorWidth" value="100%" maxlength="10" class="form-control form-control-sm">
                    <span class="help-block">只能填写数值或百分比，填写则默认100%</span>
                </div>
            </div>

            <div class="form-group defaulthidden EditorHeight" field_type="editor">
                <label class="control-label" for="EditorHeight">编辑器高度</label>
                <div class="controls">
                    <input type="text" name="EditorHeight" id="EditorHeight" value="200" maxlength="10" class="form-control form-control-sm">
                    <span class="help-block">只能填写数值或百分比</span>
                </div>
            </div>


            <div class="defaulthidden form-group" field_type="image,file,images,files">
                <label class="control-label">上传文件重命名</label>
                <div class="controls">
                    <label class="radio-inline">
                        <input name="Rename" id="Rename" value="1" checked type="radio">是
                    </label>
                    <label class="radio-inline">
                        <input name="Rename" id="Rename" value="0" type="radio">否
                    </label>
                    <span class="help-block">建议上传文件都重命名</span>
                </div>
            </div>

            <div class="defaulthidden form-group" field_type="image,images">
                <label class="control-label">上传图片处理</label>
                <div class="controls">
                    <label class="checkbox-inline">
                        <input name="Watermark" id="Watermark" value="1" checked type="checkbox">加水印
                    </label>
                    <label class="checkbox-inline">
                        <input name="Thumbnail" id="Thumbnail" value="1" checked type="checkbox">生成缩略图
                    </label>
                    <span class="help-block">水印图片在系统设置》文件上传中设置</span>
                </div>
            </div>

            <div class="defaulthidden form-group" field_type="image,images">
                <label class="control-label">生成缩略图尺寸</label>
                <div class="controls form-inline">
                    缩略图宽<input class="form-control form-control-xs" name="ThumbnailWidth" id="ThumbnailWidth" value="400" maxlength="3" data-validate="dataType:'numeric',min:0,errorMsg:'只能填写大于20的数字！',ignoreHidden:true">px
                    缩缩略高<input class="form-control form-control-xs" name="ThumbnailHeight" id="ThumbnailHeight" value="0" maxlength="3" data-validate="dataType:'numeric',min:0,errorMsg:'只能填写大于20的数字！',ignoreHidden:true">px
                    <span class="help-block">图片超过设置尺寸则不会生成缩略图,0则表示不进行缩放</span>
                </div>
            </div>

            <div class="form-group defaulthidden UploadExt" field_type="image,file,images,files">
                <label class="control-label">上传格式</label>
                <div class="controls">
                    <input type="text" name="UploadExt" id="UploadExt" value=".jpg,.gif,.png" maxlength="50" class="form-control form-control-sm">
                    <span class="help-block">多个后缀用半角逗号隔开，如.jpg,.gif,.png</span>
                </div>
            </div>

            @*<div class="form-group defaulthidden minetype" field_type="image,file,images,files">
            <label class="control-label" for="UploadExt">mineType类型</label>
            <div class="controls">
                <input type="text" name="minetype" id="minetype" value="jpg,gif,png" maxlength="50" class="form-control form-control-sm">
                <span class="help-block">多个minetype用半角逗号隔开，支持*通配符，如图片：image/*,不填写则默认*/*</span>
            </div>
        </div>*@

            <div class="form-group defaulthidden UploadMaxsize" field_type="image,file,images,files">
                <label class="control-label" for="UploadMaxsize">上传尺寸限制</label>
                <div class="controls">
                    <input type="text" name="UploadMaxsize" id="UploadMaxsize" value=1024 maxlength="10" data-validate="dataType:'numeric',errorMsg:'上传尺寸限制只能填写数字！',ignoreHidden:true" class="form-control form-control-sm">
                    <span class="help-block">文件尺寸单位为KB</span>
                </div>
            </div>

            <div class="form-group defaulthidden" field_type="select">
                <label class="control-label" for="DatasourceOpen">外部数据源</label>
                <div class="controls">
                    <label class="checkbox-inline">
                        <input type="checkbox" name="DatasourceOpen" id="DatasourceOpen" value="1" class="ui-show-hide" showObjs=".DatasourceBox">启用数据源
                    </label>
                    <span class="help-block">外部数据源只对select表单有效</span>
                </div>
            </div>

            <div class="defaulthidden1 DatasourceBox">
                <div class="form-group  DatasourceShowtype">
                    <label class="control-label" for="DatasourceShowtype">数据选择方式</label>
                    <div class="controls radio">
                        <label class="radio-inline"><input type="radio" name="DatasourceShowType" id="DatasourceShowType" value="0" showObjs=".Orderby1" hideObjs=".WinSize1,.BtText1,.Pagesize1" class="ui-show-hide" checked />直接填充</label>
                        <label class="radio-inline"><input type="radio" name="DatasourceShowType" id="DatasourceShowType" value="1" showObjs=".WinSize1,.BtText1,.Orderby1" hideObjs=".Pagesize1" class="ui-show-hide" />新窗口单页列表</label>
                        <label class="radio-inline"><input type="radio" name="DatasourceShowType" id="DatasourceShowType" value="2" showObjs=".WinSize1,.BtText1,.Orderby1,.Pagesize1" class="ui-show-hide" />新窗口分页列表</label>
                        <span class="help-block"></span>
                    </div>
                </div>

                <div class="form-group DatasourceMultilevel">
                    <label class="control-label" for="DatasourceTable">是否多级分类</label>
                    <div class="controls radio">
                        <label class="radion-inline">
                            <input type="radio" name="DatasourceMultiLevel" id="DatasourceMultiLevel" value="0" checked>否
                        </label>
                        <label class="radion-inline">
                            <input type="radio" name="DatasourceMultiLevel" id="DatasourceMultiLevel" value="1">是
                            （<input type="checkbox" name="DatasourceOnlySelectFinal" id="DatasourceOnlySelectFinal" value="1">只能选最终分类）
                        </label>
                        <span class="help-block">多级分类表包含有固定格式的字段，如栏目表(pa_column),自定义分类表</span>
                    </div>
                </div>

                <div class="form-group  DatasourceTable">
                    <label class="control-label" for="DatasourceTable">数据源表</label>
                    <div class="controls">
                        <input type="text" name="DatasourceTable" id="DatasourceTable" maxlength="30" class="form-control form-control-sm">
                        <span class="help-block">必须填写已经存在的表</span>
                    </div>
                </div>

                <div class="form-group  DatasourceWhere">
                    <label class="control-label" for="DatasourceWhere">自定义条件</label>
                    <div class="controls">
                        <input type="text" name="DatasourceWhere" id="DatasourceWhere" maxlength="150" class="form-control form-control-sm">
                        <span class="help-block">如：id=5,采用sql语法,当前表名:{table},当前用户:{username}</span>
                    </div>
                </div>

                <div class="form-group  DatasourceValuefield">
                    <label class="control-label" for="DatasourceValuefield">数据源值字段</label>
                    <div class="controls">
                        <input type="text" name="DatasourceValueField" id="DatasourceValueField" value="id" maxlength="30" class="form-control form-control-sm" readonly>
                        <span class="help-block">select表单的value字段,只能为id字段</span>
                    </div>
                </div>

                <div class="form-group  DatasourceTextfield">
                    <label class="control-label" for="DatasourceTextfield">数据源文本字段</label>
                    <div class="controls form-inline">
                        字段名：<input type="text" name="DatasourceTextField" id="DatasourceTextField" maxlength="30" class="form-control form-control-xs">
                        字段描述：<input type="text" name="DatasourceTextFieldName" id="DatasourceTextFieldName" maxlength="30" class="form-control form-control-xs">
                        <span class="help-block">只能填写nvarchar、varchar类型的字段，字段名必须为数据库中的实际存在字段</span>
                    </div>
                </div>


                <div class="form-group WinSize1">
                    <label class="control-label">
                        窗口尺寸
                    </label>
                    <div class="controls form-inline">
                        窗口宽：<input type="text" name="WinWidth1" id="WinWidth1" maxlength="10" value="80%" class="form-control form-control-xs">
                        窗口高：<input type="text" name="WinHeight1" id="WinHeight1" maxlength="10" value="80%" class="form-control form-control-xs">
                        <span class="help-block">支持数字和百分比，数字必须加单位px</span>
                    </div>
                </div>

                <div class="form-group  BtText1">
                    <label class="control-label">
                        按钮文本
                    </label>
                    <div class="controls">
                        <input type="text" name="BtText1" id="BtText1" value="选择" maxlength="50" class="form-control form-control-xs">
                        <span class="help-block"></span>
                    </div>
                </div>


                <div class="form-group  Orderby1">
                    <label class="control-label">列表排序方式</label>
                    <div class="controls">
                        <input type="text" name="Orderby1" id="Orderby1" maxlength="50" class="form-control form-control-xs">
                        <span class="help-block">排序方式，如id desc,可留空</span>
                    </div>
                </div>

                <div class="form-group  Pagesize1">
                    <label class="control-label">每页显示数</label>
                    <div class="controls">
                        <input type="text" name="Pagesize1" id="Pagesize1" maxlength="4" value="20" data-validate="dataType:'numeric',errorMsg:'每页显示数只能填写数字！',ignoreHidden:true" class="form-control form-control-xs">
                        <span class="help-block">列表界面每页显示的记录数</span>
                    </div>
                </div>
            </div>


            <div class="form-group defaulthidden WinSize" field_type="subtable">
                <label class="control-label">
                    窗口尺寸
                </label>
                <div class="controls form-inline">
                    窗口宽：<input type="text" name="WinWidth" id="WinWidth" value="90%" maxlength="20" class="form-control form-control-xs">
                    窗口高：<input type="text" name="WinHeight" id="WinHeight" value="90%" maxlength="20" class="form-control form-control-xs">
                    <span class="help-block">支持数字和百分比</span>
                </div>
            </div>

            <div class="form-group defaulthidden BtTxt" field_type="subtable">
                <label class="control-label">
                    按钮文本
                </label>
                <div class="controls">
                    <input type="text" name="BtText" id="BtText" value="管理" maxlength="50" class="form-control form-control-sm">
                    <span class="help-block"></span>
                </div>
            </div>

            <div class="form-group defaulthidden SubTableType" field_type="subtable">
                <label class="control-label">主附表关系</label>
                <div class="controls radio">
                    <label class="radio-inline">
                        <input type="radio" name="SubTableType" id="SubTableType" value="single" checked  title="一条主表数据只对应一条附表数据" onclick="ChangeSubTableType()">一对一
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="SubTableType" id="SubTableType" value="multiple" title="一条主表数据是否可对应多条附表数据" onclick="ChangeSubTableType()">一对多
                    </label>
                    <span class="help-block">设置后不可修改</span>
                </div>
            </div>

            <div class="form-group defaulthidden MaxNum" field_type="images,files">
                <label class="control-label">最大发布数</label>
                <div class="controls">
                    <input type="text" name="MaxNum" id="MaxNum" value="5" maxlength="4" data-validate="dataType:'numeric',errorMsg:'最大发布数只能填写数字！',ignoreHidden:true" class="form-control form-control-sm">
                    <span class="help-block">0则为不限制</span>
                </div>
            </div>

            <div class="form-group defaulthidden Orderby">
                <label class="control-label">列表排序方式</label>
                <div class="controls">
                    <input type="text" name="Orderby" id="Orderby" maxlength="50" class="form-control form-control-sm">
                    <span class="help-block">排序方式，如id desc,可留空</span>
                </div>
            </div>

            <div class="form-group defaulthidden Pagesize">
                <label class="control-label">每页显示数</label>
                <div class="controls">
                    <input type="text" name="Pagesize" id="Pagesize" value="20" maxlength="4" data-validate="dataType:'numeric',errorMsg:'每页显示数只能大于0的数字！',ignoreHidden:true" class="form-control form-control-xs ui-queryString">
                    <span class="help-block">列表界面每页显示的记录数</span>
                </div>
            </div>

            <div class="form-group AasicArrtibute">
                <label class="control-label">基础属性</label>
                <div class="controls checkbox">
                    <label class="checkbox-inline">
                        <input type="checkbox" name="MustItem" id="MustItem" value="1">必填项
                    </label>
                    <label class="checkbox-inline OnlyItem">
                        <input type="checkbox" name="OnlyItem" id="OnlyItem" value="1">值唯一项
                    </label>

                    <label class="checkbox-inline  hidden">
                        <input type="checkbox" name="CollectionItem" id="CollectionItem" value="1">采集项
                    </label>
                    <label class="checkbox-inline OrderItem">
                        <input type="checkbox" name="OrderItem" id="OrderItem" value="1">排序项
                    </label>
                    <label class="checkbox-inline Htmlencode">
                        <input type="checkbox" name="Htmlencode" id="Htmlencode" value="1">htmlEncode编码
                    </label>
                    <span class="help-block">排序项只对数值和日期字段有效，htmlEncode编码只对字符型数据有意义</span>
                </div>
            </div>

            @*<div class="form-group AddNull">
            <label class="control-label">新增不规则数据</label>
            <div class="controls">
                <select class="form-control form-control-sm" name="AddNull" id="AddNull">
                    <option value="auto">自动</option>
                    <option value="default">默认值</option>
                    <option value="skip">跳过</option>
                    <option value="exception">异常</option>
                </select>
                <span class="help-block">添加数据时提交不符合字段数据类型的数据的处理方法</span>
            </div>
        </div>

        <div class="form-group EditNull">
            <label class="control-label" for="EditNull">修改不规则数据</label>
            <div class="controls">
                <select class="form-control form-control-sm" name="EditNull" id="EditNull">
                    <option value="auto">自动</option>
                    <option value="default">默认值</option>
                    <option value="skip">跳过</option>
                    <option value="exception">异常</option>
                </select>
                <span class="help-block">编辑数据时提交不符合字段数据类型的数据的处理方法</span>
            </div>
        </div>*@

            <div class="form-group SearchType">
                <label class="control-label" for="SearchType">搜索匹配</label>
                <div class="controls">
                    <select class="form-control form-control-sm" name="SearchType" id="SearchType" style="width:120px">
                        <option value="">无</option>
                        <option value="fuzzy">模糊匹配</option>
                        <option value="precise">精确匹配</option>
                        <option value="in">多值匹配(in)</option>
                        <option value="range">范围匹配</option>
                    </select>
                    <span class="help-block">根据url中传递的参数来搜索</span>
                </div>
            </div>

            <div class="form-group">
                <label class="control-label" for="xuhao">序号</label>
                <div class="controls">
                    <input type="text" name="Xuhao" id="Xuhao" maxlength="3" value="1" class="form-control form-control-xs ui-queryString" data-validate="dataType:'numeric',nullMsg:'请填写序号！'">
                    <span class="help-block"></span>
                </div>
            </div>
        </div>

        <div class="tabcontent" data-tab-params="tabName:'权限设置'">

            <div class="form-group ListItem">
                <label class="control-label">模板页数据读取</label>
                <div class="controls  form-inline">
                    <input type="checkbox" name="ListItem" id="ListItem" value="1" checked>列表页&nbsp;&nbsp;
                    <input type="checkbox" name="DetailItem" id="DetailItem" value="1" checked>内容页
                    <span class="help-block">在模板页面通过内置方法读取数据时，是否读取该字段值，只读取需要的字段可提高数据读取速度</span>
                </div>
            </div>

            <div class="form-group ListItem">
                <label class="control-label">管理列表页展示</label>
                <div class="controls  form-inline">
                    <input type="checkbox" name="AdminListItem" id="AdminListItem" value="1">后台管理列表&nbsp;&nbsp;
                    <input type="checkbox" name="MemberListItem" id="MemberListItem" value="1">会员管理列表
                    &nbsp;&nbsp;显示字数：<input type="text" name="ListWords" id="ListWords" maxlength="4" value="50" class="form-control form-control-xs" data-validate="dataType:'numeric', nullMsg:'请填写显示字数！'">
                    &nbsp;&nbsp;列宽：<input type="text" name="ListWidth" id="ListWidth" maxlength="10" value="" class="form-control form-control-xs" placeholder="宽度px或百分比">
                    <span class="help-block">数值型和日期型字段不受显示字数限制，多行文本和编辑器建议不要设为列表项，否则可能导致占用加载时间。</span>
                    <span class="help-block"></span>
                </div>
            </div>

            <div class="form-group">
                <label class="control-label">后台发布设置</label>
                <div class="controls radio">
                    <label class="radio-inline"><input type="checkbox" name="AdminCanAdd" id="AdminCanAdd" value="1" checked />可添加</label>
                    <label class="radio-inline"><input type="checkbox" name="AdminCanEdit" id="AdminCanEdit" value="1" checked />可编辑</label>
                    <span class="help-block">不选则在后台发布页面不显示此字段表单</span>
                </div>
            </div>

            <div class="form-group">
                <label class="control-label">会员发布设置</label>
                <div class="controls radio">
                    <label class="radio-inline"><input type="checkbox" name="MemberCanAdd" id="MemberCanAdd" value="1" checked />可添加</label>
                    <label class="radio-inline"><input type="checkbox" name="MemberCanEdit" id="MemberCanEdit" value="1" checked />可编辑</label>
                    <span class="help-block">不选则在会员中心对应的投稿页面不显示此字段表单</span>
                </div>
            </div>

            <div class="form-group">
                <label class="control-label">匿名投稿设置</label>
                <div class="controls radio">
                    <label class="radio-inline"><input type="checkbox" name="AnonymousCanAdd" id="AnonymousCanAdd" value="1" checked />可添加</label>
                    <label class="radio-inline hidden"><input type="checkbox" name="AnonymousCanEdit" id="AnonymousCanEdit" value="1" checked />可编辑</label>
                    <span class="help-block">不选则投稿表单中不生成对应字段的表单代码</span>
                </div>
            </div>

            <div class="form-group">
                <label class="control-label">会员组显示权限</label>
                <div class="controls">
                    <select id="MemberGroupIds" name="MemberGroupIds" class="form-control form-control-sm ui-convertSelect multiple-select" multiple style="display:block;height:110px;" data-custom-params="url:'@Url.Action("LoadListByIds","MemberGroup")',textField:'Name'"></select>
                    <div class="btn-group btn-group-sm">
                        <a href="javascript:void(0)" class="btn btn-default btn-sm ui-dialog" data-custom-params="title:'选择会员组',url:'@Url.Action("Select","MemberGroup")?objname=#MemberGroupIds',width:'600px',height:'90%',target:'_self'">选择会员组</a>
                        <a href="javascript:void(0)" class="btn btn-default btn-sm ui-removeSelectedOptions" title="按住Ctrl键可实现多选" data-custom-params="obj:'#MemberGroupIds'">删除选中</a>
                    </div>
                    <span class="help-block">不选择则默认所有会员组有权限，只用于会员中心</span>
                </div>
            </div>

            <div class="form-group">
                <label class="control-label">后台显示权限</label>
                <div class="controls">
                    <select id="RoleIds" name="RoleIds" class="form-control form-control-sm ui-convertSelect multiple-select" multiple style="display:block;height:110px;" data-custom-params="url:'@Url.Action("LoadListByIds","Role")',textField:'Name'"></select>
                    <div class="btn-group btn-group-sm">
                        <a href="javascript:void(0)" class="btn btn-default btn-sm ui-dialog" data-custom-params="title:'选择角色',url:'@Url.Action("Select","Role")?objname=#RoleIds',width:'600px',height:'90%',target:'_self'">选择角色</a>
                        <a href="javascript:void(0)" class="btn btn-default btn-sm ui-removeSelectedOptions" title="按住Ctrl键可实现多选" data-custom-params="obj:'#RoleIds'">删除选中</a>
                    </div>
                    <span class="help-block">不选择则默认所有管理员角色有权限，只用于后台信息管理</span>
                </div>
            </div>

            <div class="form-group">
                <label class="control-label" for="Items">无权限替换代码</label>
                <div class="controls">
                    <textarea id="NoPermissionContent" name="NoPermissionContent" class="form-control textarea" style="height:100px"></textarea>
                    <span class="help-block">无权限时这里内容将显示在表单代码中</span>
                </div>
            </div>
        </div>

        <div class="tabcontent" data-tab-params="tabName:'自定义属性'">

            <div class="form-group">
                <label class="control-label">数据验证类型</label>
                <div class="controls">
                    <input type="text" name="DataType" id="DataType" maxlength="100" class="form-control">
                    <span class="help-block">留空则由系统根据表单和值类型自动识别，如需个性化验证请在/e/js/datatype.js文件中自行添加后再填写。</span>
                </div>
            </div>

            <div class="form-group">
                <label class="control-label">字段提示</label>
                <div class="controls">
                    <input type="text" name="Tips" id="Tips" maxlength="100" class="form-control">
                    <span class="help-block">显示在字段对应的一下行</span>
                </div>
            </div>

            <div class="form-group">
                <label class="control-label" for="InputParams">自定义html属性</label>
                <div class="controls">
                    <textarea id="InputParams" name="InputParams" class="form-control textarea " style="height:100px"></textarea>
                    <span class="help-block">每行一个属性，将添加到html标签中</span>
                </div>
            </div>

            <div class="form-group">
                <label class="control-label">提交前运行js</label>
                <div class="controls">
                    <textarea id="BeforeSubmitJs" name="BeforeSubmitJs" class="form-control textarea " style="height:100px"></textarea>
                    <span class="help-block">在提交到服务器前执行的javascript脚本，必须返回true或flase,false则表单不提交</span>
                </div>
            </div>


            <div class="form-group">
                <label class="control-label">表单附加内容</label>
                <div class="controls">
                    <textarea id="AdditionalContent" name="AdditionalContent" class="form-control textarea" style="height:100px"></textarea>
                    <span class="help-block">自动加载到默认表单代码的后面</span>
                </div>
            </div>


            <div class="form-group">
                <label class="control-label">表单自定义内容</label>
                <div class="controls">
                    <textarea id="ZdyContent" name="ZdyContent" class="form-control textarea" style="height:150px"></textarea>
                    <span class="help-block">留空则由系统自动生成当前字段表单代码</span>
                </div>
            </div>
        </div>

        <div class="form-group postarea">
            <div class="controls">
                @Html.AntiForgeryToken()
                <input type="hidden" name="Id" id="Id" />
                <input type="hidden" name="TableName" id="TableName" value="@Request.QueryString["tableName"]" />
                <input type="hidden" name="SysField" id="SysField" value="0" />
                <input type="hidden" name="FieldChildType" id="FieldChildType" value="" />
                <input type="hidden" name="IsAutofield" id="IsAutofield" value="0" />
                <button type="button" class="btn btn-sm  btn-primary ui-pagePost" data-custom-params="url:'@Url.Action()',callBack:'PostRefreshBack'">提交</button>
                <button type="button" class="btn btn-sm btn-default ui-closeDialog">关闭</button>
                <span class="help-block"></span>
            </div>
        </div>
    </form>
</div>


<script type="text/javascript">
    $(".tabcontent").InitTab();
    var isEdit = false;
    var $defaulthidden = $(".defaulthidden");
    $defaulthidden.css("display", "none");


    //设置表单类型可设置的值类型
    function SetValueType() {
        if ($("#ValueType").attr("disabled") == "disabled" || $("#ValueType").attr("readonly") == "readonly") {
            return;
        }
        var valueType = $('#FieldType option:selected').attr("value_type");
        if (typeof (valueType) == "undefined") { $("#ValueType option").show(); return; }
        $("#ValueType option").each(function () {
            if ($(this).val() == "") { return true;}
            $(this).removeAttr("selected");
            if (!valueType.split(',').Contains($(this).val())) {
                $(this).hide();
            }
            else {
                $(this).show();
            }
        });
    }
    //修改时，设置可以相互转换的表单类型
    function SetFieldType() {
        var transformType = $('#FieldType option:selected').attr("transformType");
        if (typeof (transformType) == "undefined") { $("#FieldType option").show(); return; }
        $("#FieldType option").each(function () {
            if (!transformType.split(',').Contains($(this).val())) {
                $(this).hide();
            }
            else {
                $(this).show();
            }
        });
    }
    var $boxValueType=$("#boxValueType");
    var $fieldChildType = $("#FieldChildType");
    var $subTableType = $("input[name='SubTableType']");
    var $MaxNum = $(".MaxNum");
    var $Orderby = $(".Orderby");
    var $Pagesize = $(".Pagesize");
    
    function ChangeSubTableType()
    {
        if ($subTableType.prop("checked"))
        {
            $MaxNum.hide();
            $Orderby.hide();
            $Pagesize.hide();
        }
        else
        {
            $MaxNum.show()
            $Orderby.show();
            $Pagesize.show();
        }
    }

    //设置字段类型和显示对象属性
    function ChangeType(isLoad) {
        if (arguments.length == 0) {
            isLoad = false;
        }
        var fieldType = $('#FieldType option:selected').val();
        var valueType = $('#ValueType option:selected').val();
        if (!isLoad) {
            SetValueType();
        }
        $defaulthidden.hide();
        $defaulthidden.each(function () {
            var can_field_type = $(this).attr("field_type");
            if (typeof (can_field_type) == "undefined") { return true; }
            if (!can_field_type.split(',').Contains(fieldType)) {
                $(this).hide();
            }
            else {
                $(this).show();
            }
        }
        );
        if (fieldType != "select") {
            $("#DatasourceOpen").attr("checked", false);
            $(".DatasourceBox").hide();
        }
        //设置默认的值类型
        //if (fieldType == "subtable") {
        //    $("#ValueType").val("int");
        //    $(".ValueLength").hide();
        //}
        //if (fieldType == "images" || fieldType == "fiels") {
        //    $("#ValueType").val("nvarchar");
        //    //$("#ValueLength").val("1000");
        //    $(".ValueLength").show();
        //}
        //else if (fieldType == "file" || fieldType == "image") {
        //    $("#ValueType").val("nvarchar");
        //    //$("#ValueLength").val("50");
        //    $(".ValueLength").show();
        //}
        //else if (fieldType == "editor" || fieldType == "textarea") {
        //    $("#ValueType").val("nvarchar");
        //    //$("#ValueLength").val("4001");
        //    $(".ValueLength").show();
        //}
        //else if (valueType == "nvarchar") {
        //    //$("#ValueLength").val("50");
        //    $(".ValueLength").show();
        //}
        //else {
        //    $(".ValueLength").show();
        //}
        $("#ValueType").trigger("change");
        if (fieldType == "subtable" || fieldType == "files" || fieldType == "images") {
            $("#ValueType").val("");
            $(".ValueLength").hide();
            $boxValueType.hide();
        }
        else
        {
            $boxValueType.show();
            if (!isLoad && !isEdit)
            {
                $("#ValueType").val("");
            }

        }
        if (fieldType == "subtable")
        {
            ChangeSubTableType();
        } 
    }
    var id = Request("id");
    if (IsInt(id)) {
        isEdit = true;
        bindForm();
    }
    else {
        ChangeType(true);
    }

    function bindForm()
    {
        $("#_form").FormBind({ dataSourceFrom: "attr" });
        $("#ValueLengthOld").val($("#ValueLength").val());
        $("#DefaultValueOld").val($("#DefaultValue").val());
        $("#DecimalAccuracyOld").val($("#DecimalAccuracy").val());

        //SetValueType();
        SetFieldType();
        ChangeType(true);

        //数据源区域手工赋值
        $("#WinWidth1").val($("#WinWidth").val());
        $("#WinHeight1").val($("#WinHeight").val());
        $("#BtText1").val($("#BtText").val());
        $("#Orderby1").val($("#Orderby").val());
        $("#Pagesize1").val($("#Pagesize").val());
        var fieldType = $('#FieldType option:selected').val();
        if (fieldType == "subtable") {
            if ($fieldChildType.val() == "multiple") {
                $subTableType.eq(1).click();
            }
            $subTableType.attr("disabled", "disabled");
        }
    }
    function CkForm() {
        var $field_type = $("#FieldType");
        var fieldType = $field_type.val();
        if (fieldType== "select") {
            //数据源区域赋值到对应字段
            $("#WinWidth").val($("#WinWidth1").val());
            $("#WinHeight").val($("#WinHeight1").val());
            $("#BtText").val($("#BtText1").val());
            $("#Orderby").val($("#Orderby1").val());
            $("#Pagesize").val($("#Pagesize1").val());
        }
       else if (fieldType== "subtable") {
            //数据源区域赋值到对应字段
            var subTableType = $subTableType.GetValue();
            if (subTableType != "")
            {
                $fieldChildType.val(subTableType);
            }

        }
        return true;
    }
    function postback() {
        return true;
    }
</script>
