This commit is contained in:
yubaolee@163.com 2017-11-27 17:40:25 +08:00
parent 64756cfd31
commit 65cc53456e
3 changed files with 27 additions and 113 deletions

View File

@ -1,105 +0,0 @@
<%--
Name: 列表页面
Author: yubaolee
Description: 列表页面
--%>
<%@ CodeTemplate Language="C#" TargetLanguage="C#" Debug="False" Encoding="utf-8" Description="添加模块" %>
<%@ Property Name="SourceTable" Type="SchemaExplorer.TableSchema" Category="Context"
Description="连接的数据库" %>
<%@ Property Name="ModuleName" Type="String" Category="Context" Description="模块名称" %>
<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %>
<%@ Assembly Name="SchemaExplorer" %>
<%@ Import Namespace="SchemaExplorer" %>
<%@ Assembly Src="Util.cs" %>
<%@ Import Namespace="Util" %>
@{
Layout = "~/Views/Shared/_BjuiLayout.cshtml";
}
@{ Html.RenderAction("MenuHeader", "Home");}
<div class="bjui-pageContent tableContent" style="position: relative">
<div class="clearfix">
<div style="float: left; width: 220px; overflow: auto;" class="table table-bordered">
<ul id="tree" class="ztree"></ul>
</div>
<div id="detail" style="margin-left: 225px;">
<table id="maingrid" class="table table-bordered"></table>
</div>
</div>
</div>
<!--编辑对话框-->
<div class="bjui-dialog hidden bjui-dialog-container" id="editDlg" data-noinit="true">
<div class="bjui-pageContent">
<form action="/<%=ModuleName%>/Add" class="pageForm" data-toggle="validate" data-reload="false" id="editForm">
<table class="table table-condensed table-hover">
<tbody>
<% foreach (ColumnSchema column in this.SourceTable.Columns) {
if(column.IsPrimaryKeyMember){%>
<input type="text" id="<%=column.Name%>" name="<%=column.Name%>" value="" class="hidden" />
<%}else if(CSharpAlias[column.SystemType.FullName] == "bool") {%>
<tr>
<td>
<label for="<%=column.Name%>" class="control-label x120"><%=Tools.GetDescription(column)%></label>
<select name="<%=column.Name%>" id="<%=column.Name%>" data-toggle="selectpicker" data-rule="required">
<option value="false">否</option>
<option value="true">是</option>
</select>
</td>
</tr>
<%}else if(CSharpAlias[column.SystemType.FullName] == "int" ) {%>
<tr>
<td>
<label for="<%=column.Name%>" class="control-label x120"><%=Tools.GetDescription(column)%></label>
<select name="<%=column.Name%>" id="<%=column.Name%>" data-toggle="selectpicker" data-rule="required">
<option value="0">默认</option>
<option value="1">状态1</option>
<option value="2">状态2</option>
</select>
</td>
</tr>
<%}else if(CSharpAlias[column.SystemType.FullName].Contains("DateTime")) {%>
<tr>
<td>
<label for="<%=column.Name%>" class="control-label x120"><%=Tools.GetDescription(column)%></label>
<input type="text" id="<%=column.Name%>" name="<%=column.Name%>" value="" data-toggle="datepicker"/>
</td>
</tr>
<%} else {%>
<tr>
<td>
<label for="<%=column.Name%>" class="control-label x120"><%=Tools.GetDescription(column)%></label>
<input type="text" id="<%=column.Name%>" name="<%=column.Name%>" value=""/>
</td>
</tr>
<%} %>
<%} %>
<%if(Tools.NeedCascade(SourceTable)){ %>
<tr>
<td>
<label for="ParentName" class="control-label x120">上级分类:</label>
<input id="ParentId" name="ParentId" style="display: none" />
<input type="text" name="ParentName" id="ParentName"
data-toggle="selectztree" data-tree="#j_select_tree1">
<ul id="j_select_tree1" class="ztree hide" data-toggle="ztree"></ul>
</td>
</tr>
<%} %>
</tbody>
</table>
</form>
</div>
<div class="bjui-pageFooter">
<ul>
<li><button type="button" class="btn btn-close">关闭</button></li>
<li><button type="button" class="btn btn-primary" id="btnSave">保存</button></li>
</ul>
</div>
</div>
<script src="~/BllScripts/grid.js"></script>
<script src="~/BllScripts/<%=ModuleName%>.js"></script>

View File

@ -100,6 +100,6 @@ Description="连接的数据库" %>
</div>
<script type="text/javascript" src="/layui/layui.js"></script>
<script type="text/javascript" src="/js/<%=ModuleName%>.js"></script>
<script type="text/javascript" src="/js/<%=ModuleName%>Manager.js"></script>

View File

@ -34,7 +34,6 @@ Description="连接的数据库" %>
<%@ Property Name="NeedViewModel"
Type="Boolean"
Category="5.Customization"
Default="False"
Optional="True"
Description="是否需要ViewModel" %>
@ -46,6 +45,9 @@ Description="连接的数据库" %>
<%@ Register Name="HtmlGenerateClass"
Template="Web\Index.cshtml.cst"
MergeProperties="False" %>
<%@ Register Name="JSGenerateClass"
Template="Web\index.js.cst"
MergeProperties="False" %>
Generating Entities ...
<% Generate(); %>
@ -58,14 +60,18 @@ Generating Entities ...
if (!Directory.Exists(directory)) //根目录
Directory.CreateDirectory(directory);
if (!Directory.Exists(directory +"/views")) //视图根文件夹
if (!Directory.Exists(directory +"/views")) //视图根文件夹
Directory.CreateDirectory(directory +"/views");
if (!Directory.Exists(directory +"/js")) //js根目录
Directory.CreateDirectory(directory +"/js");
if (!Directory.Exists(directory +"/views/"+ModuleName)) //视图文件夹
Directory.CreateDirectory(directory +"/views/"+ModuleName);
if (!Directory.Exists(directory +"/views/"+ModuleName +"Manager")) //视图文件夹
Directory.CreateDirectory(directory +"/views/"+ModuleName +"Manager");
CreateApplicationClass();
CreateHtmlClass();
CreateJSClass();
this.RegisterReference("System.Configuration");
this.RegisterReference("System.Data");
@ -77,7 +83,7 @@ Generating Entities ...
Response.WriteLine("Generate Time: " + watch.ElapsedMilliseconds + " ms");
}
//创建APP层
//创建APP层,如UserApp.cs
public void CreateApplicationClass()
{
ApplicationGenerateClass generatedClass = this.Create<ApplicationGenerateClass>();
@ -95,13 +101,13 @@ Generating Entities ...
generatedClass.RenderToFile(generatedFile, generatedFile, true);
}
//创建视图
//创建视图,如views/Users/index.html
public void CreateHtmlClass()
{
HtmlGenerateClass generatedClass = this.Create<HtmlGenerateClass>();
this.CopyPropertiesTo(generatedClass);
generatedFile = Path.GetFullPath(directory) + "/views/"+ModuleName+"/" + "index.cshtml";
string generatedFile = Path.GetFullPath(directory) + "/views/"+ModuleName+"Manager/" + "index.cshtml";
generatedClass.ModuleName = ModuleName;
generatedClass.SourceTable = SourceTable;
@ -110,6 +116,19 @@ Generating Entities ...
generatedClass.RenderToFile(generatedFile, generatedFile, true);
}
//创建视图,如js/userManager.js
public void CreateJSClass()
{
JSGenerateClass generatedClass = this.Create<JSGenerateClass>();
this.CopyPropertiesTo(generatedClass);
string generatedFile = Path.GetFullPath(directory) + "/js/"+ModuleName+"Manager.js";
generatedClass.ModuleName = ModuleName;
generatedClass.SourceTable = SourceTable;
Response.WriteLine(generatedFile);
generatedClass.RenderToFile(generatedFile, generatedFile, true);
}
</script>