mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-04-04 05:47:28 +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"
|
||||
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" %>
|
||||
|
||||
@section header
|
||||
{
|
||||
<link rel="stylesheet" href="/css/treetable.css" />
|
||||
}
|
||||
<blockquote class="layui-elem-quote news_search toolList" id="menus">
|
||||
</blockquote>
|
||||
|
||||
<div class="layui-card">
|
||||
|
||||
<table class="layui-table" id="mainList"
|
||||
lay-data="{height: 'full-80', page:true, id:'mainList'}"
|
||||
lay-filter="list" lay-size="sm">
|
||||
</table>
|
||||
|
||||
<script type="text/html" id="Disable">
|
||||
{{# if(d.Disable){ }}
|
||||
<span class="layui-badge">已禁用</span>
|
||||
@ -35,41 +30,46 @@ Description="连接的数据库" %>
|
||||
<span class="layui-badge layui-bg-green">正常</span>
|
||||
{{# } }}
|
||||
</script>
|
||||
|
||||
</div>
|
||||
|
||||
<!--添加/编辑窗口-->
|
||||
<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) {
|
||||
var typename = CSharpAlias[column.SystemType.FullName];
|
||||
//Response.WriteLine(typename);
|
||||
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") {%>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><%=Tools.GetDescription(column)%></label>
|
||||
<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>
|
||||
<%}else if(CSharpAlias[column.SystemType.FullName] == "int" ) {%>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><%=Tools.GetDescription(column)%></label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="<%=column.Name%>" value="1" title="value1" checked>
|
||||
<input type="radio" name="<%=column.Name%>" value="0" title="value2">
|
||||
<input type="number" name="<%=column.Name%>" placeholder="" autocomplete="off" class="layui-input" min="0" step="1" lay-affix="number">
|
||||
</div>
|
||||
</div>
|
||||
<%} else {%>
|
||||
<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%>" 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">
|
||||
</div>
|
||||
</div>
|
||||
<%} %>
|
||||
<%} %>
|
||||
|
||||
<%if(Tools.NeedCascade(SourceTable)){ %>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">所属部门</label>
|
||||
@ -82,7 +82,6 @@ Description="连接的数据库" %>
|
||||
</div>
|
||||
</div>
|
||||
<%} %>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<button class="layui-btn" lay-submit lay-filter="formSubmit">立即提交</button>
|
||||
@ -91,8 +90,5 @@ Description="连接的数据库" %>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="/layui/layui.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="添加模块" %>
|
||||
<%@ 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" %>
|
||||
<%@ Assembly Name="SchemaExplorer" %>
|
||||
@ -13,9 +15,10 @@ Author: yubaolee
|
||||
|
||||
layui.config({
|
||||
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,
|
||||
layer = layui.layer,
|
||||
laydate = layui.laydate,
|
||||
$ = layui.jquery;
|
||||
var table = layui.table;
|
||||
var openauth = layui.openauth;
|
||||
@ -23,30 +26,49 @@ layui.config({
|
||||
|
||||
$("#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',
|
||||
{ page: 1, limit: 1 },
|
||||
function (data) {
|
||||
var columns = data.columnFields.filter(u => u.IsList ===true).map(function (e) {
|
||||
return {
|
||||
field: e.ColumnName,
|
||||
title: e.Remark
|
||||
};
|
||||
});
|
||||
columns.unshift({
|
||||
type: 'checkbox',
|
||||
fixed: 'left'
|
||||
});
|
||||
table.render({
|
||||
elem: '#mainList',
|
||||
page: true,
|
||||
url: '/<%=ModuleName%>s/Load',
|
||||
cols: [columns]
|
||||
, response: {
|
||||
statusCode: 200 //规定成功的状态码,默认:0
|
||||
}
|
||||
});
|
||||
{ page: 1, limit: 1 },
|
||||
function (data) {
|
||||
var columns = data.columnFields.filter(u => u.IsList ===true).map(function (e) {
|
||||
return {
|
||||
field: e.ColumnName,
|
||||
title: e.Remark
|
||||
};
|
||||
});
|
||||
columns.unshift({
|
||||
type: 'checkbox',
|
||||
fixed: 'left'
|
||||
});
|
||||
table.render({
|
||||
elem: '#mainList',
|
||||
page: true,
|
||||
url: '/<%=ModuleName%>s/Load',
|
||||
cols: [columns]
|
||||
, response: {
|
||||
statusCode: 200 //规定成功的状态码,默认:0
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -69,9 +91,7 @@ layui.config({
|
||||
|
||||
//添加(编辑)对话框
|
||||
var editDlg = function () {
|
||||
var vm;
|
||||
var update = false; //是否为更新
|
||||
var show = function (data) {
|
||||
var show = function (update, data) {
|
||||
var title = update ? "编辑信息" : "添加";
|
||||
layer.open({
|
||||
title: title,
|
||||
@ -79,32 +99,11 @@ layui.config({
|
||||
type: 1,
|
||||
content: $('#divEdit'),
|
||||
success: function () {
|
||||
if(vm == undefined){
|
||||
vm = new Vue({
|
||||
el: "#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)
|
||||
}
|
||||
if(data == undefined){
|
||||
form.val("formEdit", initVal);
|
||||
}else{
|
||||
form.val("formEdit", data);
|
||||
}
|
||||
},
|
||||
end: mainList
|
||||
});
|
||||
@ -125,15 +124,11 @@ layui.config({
|
||||
});
|
||||
}
|
||||
return {
|
||||
add: function () { //弹出添加
|
||||
update = false;
|
||||
show({
|
||||
Id: ''
|
||||
});
|
||||
add: function () { //弹出添加
|
||||
show(false);
|
||||
},
|
||||
update: function (data) { //弹出编辑框
|
||||
update = true;
|
||||
show(data);
|
||||
show(true, data);
|
||||
}
|
||||
};
|
||||
}();
|
||||
|
Loading…
Reference in New Issue
Block a user