mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-20 10:37:55 +08:00
优化CodeSmith代码生成
This commit is contained in:
@@ -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);
|
||||
}
|
||||
};
|
||||
}();
|
||||
|
Reference in New Issue
Block a user