mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-04-05 17:38:01 +08:00
优化CodeSmith代码生成
This commit is contained in:
parent
b909a98d96
commit
04a557b6e6
@ -7,27 +7,22 @@ Description: 列表页面
|
|||||||
<%@ Property Name="SourceTable" Type="SchemaExplorer.TableSchema" Category="Context"
|
<%@ Property Name="SourceTable" Type="SchemaExplorer.TableSchema" Category="Context"
|
||||||
Description="连接的数据库" %>
|
Description="连接的数据库" %>
|
||||||
<%@ Property Name="ModuleName" Type="String" Category="Context" Description="模块名称" %>
|
<%@ Property Name="ModuleName" Type="String" Category="Context" Description="模块名称" %>
|
||||||
|
|
||||||
<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %>
|
<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %>
|
||||||
<%@ Assembly Name="SchemaExplorer" %>
|
<%@ Assembly Name="SchemaExplorer" %>
|
||||||
<%@ Import Namespace="SchemaExplorer" %>
|
<%@ Import Namespace="SchemaExplorer" %>
|
||||||
<%@ Assembly Src="Util.cs" %>
|
<%@ Assembly Src="Util.cs" %>
|
||||||
<%@ Import Namespace="Util" %>
|
<%@ Import Namespace="Util" %>
|
||||||
|
|
||||||
@section header
|
@section header
|
||||||
{
|
{
|
||||||
<link rel="stylesheet" href="/css/treetable.css" />
|
<link rel="stylesheet" href="/css/treetable.css" />
|
||||||
}
|
}
|
||||||
<blockquote class="layui-elem-quote news_search toolList" id="menus">
|
<blockquote class="layui-elem-quote news_search toolList" id="menus">
|
||||||
</blockquote>
|
</blockquote>
|
||||||
|
|
||||||
<div class="layui-card">
|
<div class="layui-card">
|
||||||
|
|
||||||
<table class="layui-table" id="mainList"
|
<table class="layui-table" id="mainList"
|
||||||
lay-data="{height: 'full-80', page:true, id:'mainList'}"
|
lay-data="{height: 'full-80', page:true, id:'mainList'}"
|
||||||
lay-filter="list" lay-size="sm">
|
lay-filter="list" lay-size="sm">
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<script type="text/html" id="Disable">
|
<script type="text/html" id="Disable">
|
||||||
{{# if(d.Disable){ }}
|
{{# if(d.Disable){ }}
|
||||||
<span class="layui-badge">已禁用</span>
|
<span class="layui-badge">已禁用</span>
|
||||||
@ -35,41 +30,46 @@ Description="连接的数据库" %>
|
|||||||
<span class="layui-badge layui-bg-green">正常</span>
|
<span class="layui-badge layui-bg-green">正常</span>
|
||||||
{{# } }}
|
{{# } }}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!--添加/编辑窗口-->
|
<!--添加/编辑窗口-->
|
||||||
<div id="divEdit" style="display: none">
|
<div id="divEdit" style="display: none">
|
||||||
<form class="layui-form" action="" id="formEdit">
|
<form class="layui-form" action="" id="formEdit" lay-filter="formEdit">
|
||||||
<% foreach (ColumnSchema column in this.SourceTable.Columns) {
|
<% foreach (ColumnSchema column in this.SourceTable.Columns) {
|
||||||
|
var typename = CSharpAlias[column.SystemType.FullName];
|
||||||
|
//Response.WriteLine(typename);
|
||||||
if(column.IsPrimaryKeyMember){%>
|
if(column.IsPrimaryKeyMember){%>
|
||||||
<input type="hidden" name="<%=column.Name%>" v-model="tmp.<%=column.Name%>" />
|
<input type="hidden" name="<%=column.Name%>" />
|
||||||
<%}else if(CSharpAlias[column.SystemType.FullName] == "bool") {%>
|
<%}else if(CSharpAlias[column.SystemType.FullName] == "bool") {%>
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="layui-form-label"><%=Tools.GetDescription(column)%></label>
|
<label class="layui-form-label"><%=Tools.GetDescription(column)%></label>
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
<input type="checkbox" name="<%=column.Name%>" v-model="tmp.<%=column.Name%>" lay-skin="switch" value="1">
|
<input type="checkbox" name="<%=column.Name%>" lay-skin="switch" value="1">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<%}else if(CSharpAlias[column.SystemType.FullName] == "System.DateTime") {%>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label"><%=Tools.GetDescription(column)%></label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<input type="text" name="<%=column.Name%>" id="<%=column.Name%>" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<%}else if(CSharpAlias[column.SystemType.FullName] == "int" ) {%>
|
<%}else if(CSharpAlias[column.SystemType.FullName] == "int" ) {%>
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="layui-form-label"><%=Tools.GetDescription(column)%></label>
|
<label class="layui-form-label"><%=Tools.GetDescription(column)%></label>
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
<input type="radio" name="<%=column.Name%>" value="1" title="value1" checked>
|
<input type="number" name="<%=column.Name%>" placeholder="" autocomplete="off" class="layui-input" min="0" step="1" lay-affix="number">
|
||||||
<input type="radio" name="<%=column.Name%>" value="0" title="value2">
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<%} else {%>
|
<%} else {%>
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="layui-form-label"><%=Tools.GetDescription(column)%></label>
|
<label class="layui-form-label"><%=Tools.GetDescription(column)%></label>
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
<input type="text" name="<%=column.Name%>" v-model="tmp.<%=column.Name%>" required lay-verify="required"
|
<input type="text" name="<%=column.Name%>" required lay-verify="required"
|
||||||
placeholder="<%=Tools.GetDescription(column)%>" autocomplete="off" class="layui-input">
|
placeholder="<%=Tools.GetDescription(column)%>" autocomplete="off" class="layui-input">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<%} %>
|
<%} %>
|
||||||
<%} %>
|
<%} %>
|
||||||
|
|
||||||
<%if(Tools.NeedCascade(SourceTable)){ %>
|
<%if(Tools.NeedCascade(SourceTable)){ %>
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="layui-form-label">所属部门</label>
|
<label class="layui-form-label">所属部门</label>
|
||||||
@ -82,7 +82,6 @@ Description="连接的数据库" %>
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<%} %>
|
<%} %>
|
||||||
|
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
<button class="layui-btn" lay-submit lay-filter="formSubmit">立即提交</button>
|
<button class="layui-btn" lay-submit lay-filter="formSubmit">立即提交</button>
|
||||||
@ -91,8 +90,5 @@ Description="连接的数据库" %>
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="text/javascript" src="/layui/layui.js"></script>
|
<script type="text/javascript" src="/layui/layui.js"></script>
|
||||||
<script type="text/javascript" src="/userJs/<%=ModuleName.ToLower()%>s.js"></script>
|
<script type="text/javascript" src="/userJs/<%=ModuleName.ToLower()%>s.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@ Author: yubaolee
|
|||||||
--%>
|
--%>
|
||||||
<%@ CodeTemplate Language="C#" TargetLanguage="C#" Debug="False" Encoding="utf-8" Description="添加模块" %>
|
<%@ CodeTemplate Language="C#" TargetLanguage="C#" Debug="False" Encoding="utf-8" Description="添加模块" %>
|
||||||
<%@ Property Name="ModuleName" Type="String" Category="Context" Description="模块名称" %>
|
<%@ Property Name="ModuleName" Type="String" Category="Context" Description="模块名称" %>
|
||||||
|
<%@ Property Name="SourceTable" Type="SchemaExplorer.TableSchema" Category="Context"
|
||||||
|
Description="连接的数据库" %>
|
||||||
|
|
||||||
<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %>
|
<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %>
|
||||||
<%@ Assembly Name="SchemaExplorer" %>
|
<%@ Assembly Name="SchemaExplorer" %>
|
||||||
@ -13,9 +15,10 @@ Author: yubaolee
|
|||||||
|
|
||||||
layui.config({
|
layui.config({
|
||||||
base: "/js/"
|
base: "/js/"
|
||||||
}).use(['form', 'vue', 'ztree', 'layer', 'jquery', 'table', 'droptree', 'openauth', 'utils'], function () {
|
}).use(['form', 'laydate', 'ztree', 'layer', 'jquery', 'table', 'droptree', 'openauth', 'utils'], function () {
|
||||||
var form = layui.form,
|
var form = layui.form,
|
||||||
layer = layui.layer,
|
layer = layui.layer,
|
||||||
|
laydate = layui.laydate,
|
||||||
$ = layui.jquery;
|
$ = layui.jquery;
|
||||||
var table = layui.table;
|
var table = layui.table;
|
||||||
var openauth = layui.openauth;
|
var openauth = layui.openauth;
|
||||||
@ -23,30 +26,49 @@ layui.config({
|
|||||||
|
|
||||||
$("#menus").loadMenus("<%=ModuleName%>");
|
$("#menus").loadMenus("<%=ModuleName%>");
|
||||||
|
|
||||||
|
<% foreach (ColumnSchema column in this.SourceTable.Columns) {
|
||||||
|
if(CSharpAlias[column.SystemType.FullName] == "System.DateTime") { %>
|
||||||
|
laydate.render({
|
||||||
|
elem: '#<%=column.Name%>'
|
||||||
|
});
|
||||||
|
<%} }%>
|
||||||
|
|
||||||
|
var initVal = { //初始化的值
|
||||||
|
<% foreach (ColumnSchema column in this.SourceTable.Columns) {
|
||||||
|
if(CSharpAlias[column.SystemType.FullName] == "bool") { %>
|
||||||
|
<%=column.Name%>: false,
|
||||||
|
<%}else if(CSharpAlias[column.SystemType.FullName] == "int" ) {%>
|
||||||
|
<%=column.Name%>: 0,
|
||||||
|
<%}else if(CSharpAlias[column.SystemType.FullName] == "System.DateTime") {%>
|
||||||
|
<%=column.Name%>: new Date().toISOString().split('T')[0],
|
||||||
|
<%} else {%>
|
||||||
|
<%=column.Name%>: '',
|
||||||
|
<%} }%>
|
||||||
|
}
|
||||||
|
|
||||||
//加载表头
|
//加载表头
|
||||||
$.getJSON('/<%=ModuleName%>s/Load',
|
$.getJSON('/<%=ModuleName%>s/Load',
|
||||||
{ page: 1, limit: 1 },
|
{ page: 1, limit: 1 },
|
||||||
function (data) {
|
function (data) {
|
||||||
var columns = data.columnFields.filter(u => u.IsList ===true).map(function (e) {
|
var columns = data.columnFields.filter(u => u.IsList ===true).map(function (e) {
|
||||||
return {
|
return {
|
||||||
field: e.ColumnName,
|
field: e.ColumnName,
|
||||||
title: e.Remark
|
title: e.Remark
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
columns.unshift({
|
columns.unshift({
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
fixed: 'left'
|
fixed: 'left'
|
||||||
});
|
});
|
||||||
table.render({
|
table.render({
|
||||||
elem: '#mainList',
|
elem: '#mainList',
|
||||||
page: true,
|
page: true,
|
||||||
url: '/<%=ModuleName%>s/Load',
|
url: '/<%=ModuleName%>s/Load',
|
||||||
cols: [columns]
|
cols: [columns]
|
||||||
, response: {
|
, response: {
|
||||||
statusCode: 200 //规定成功的状态码,默认:0
|
statusCode: 200 //规定成功的状态码,默认:0
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -69,9 +91,7 @@ layui.config({
|
|||||||
|
|
||||||
//添加(编辑)对话框
|
//添加(编辑)对话框
|
||||||
var editDlg = function () {
|
var editDlg = function () {
|
||||||
var vm;
|
var show = function (update, data) {
|
||||||
var update = false; //是否为更新
|
|
||||||
var show = function (data) {
|
|
||||||
var title = update ? "编辑信息" : "添加";
|
var title = update ? "编辑信息" : "添加";
|
||||||
layer.open({
|
layer.open({
|
||||||
title: title,
|
title: title,
|
||||||
@ -79,32 +99,11 @@ layui.config({
|
|||||||
type: 1,
|
type: 1,
|
||||||
content: $('#divEdit'),
|
content: $('#divEdit'),
|
||||||
success: function () {
|
success: function () {
|
||||||
if(vm == undefined){
|
if(data == undefined){
|
||||||
vm = new Vue({
|
form.val("formEdit", initVal);
|
||||||
el: "#formEdit",
|
}else{
|
||||||
data(){
|
form.val("formEdit", data);
|
||||||
return {
|
}
|
||||||
tmp:data //使用一个tmp封装一下,后面可以直接用vm.tmp赋值
|
|
||||||
}
|
|
||||||
},
|
|
||||||
watch:{
|
|
||||||
tmp(val){
|
|
||||||
this.$nextTick(function () {
|
|
||||||
form.render(); //刷新select等
|
|
||||||
layui.droptree("/Applications/GetList", "#AppName", "#AppId", false);
|
|
||||||
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted(){
|
|
||||||
form.render();
|
|
||||||
layui.droptree("/Applications/GetList", "#AppName", "#AppId", false);
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}else{
|
|
||||||
vm.tmp = Object.assign({}, vm.tmp,data)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
end: mainList
|
end: mainList
|
||||||
});
|
});
|
||||||
@ -125,15 +124,11 @@ layui.config({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
add: function () { //弹出添加
|
add: function () { //弹出添加
|
||||||
update = false;
|
show(false);
|
||||||
show({
|
|
||||||
Id: ''
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
update: function (data) { //弹出编辑框
|
update: function (data) { //弹出编辑框
|
||||||
update = true;
|
show(true, data);
|
||||||
show(data);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}();
|
}();
|
||||||
|
Loading…
Reference in New Issue
Block a user