mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-18 09:44:28 +08:00
优化部分JS前端模块,后期统一按此结构调整
This commit is contained in:
@@ -1,140 +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="模块名称" %>
|
||||
<%@ Property Name="NeedViewModel" Type="Boolean" Category="Context" Default="False" Description="是否需要ViewModel" %>
|
||||
<%@ Property Name="CascadeId" Type="String" Category="" Default="ParentId" Description="级联字段" %>
|
||||
<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %>
|
||||
<%@ Assembly Name="SchemaExplorer" %>
|
||||
<%@ Import Namespace="SchemaExplorer" %>
|
||||
<script runat="template">
|
||||
public String GetModelName() {
|
||||
if (NeedViewModel)
|
||||
return ModuleName + "View";
|
||||
else
|
||||
return ModuleName;
|
||||
}
|
||||
</script>
|
||||
<%if(NeedViewModel){ %>
|
||||
@model OpenAuth.App.ViewModel.<%=GetModelName()%>
|
||||
<%} else{ %>
|
||||
@model OpenAuth.Domain.<%=GetModelName()%>
|
||||
<%} %>
|
||||
@{
|
||||
ViewBag.Title = "<%=GetModelName()%>编辑界面";
|
||||
Layout = null;
|
||||
}
|
||||
<div class="bjui-pageContent">
|
||||
<form action="/<%=ModuleName%>Manager/Add" class="pageForm" data-toggle="validate">
|
||||
<table class="table table-condensed table-hover">
|
||||
<tbody>
|
||||
<% foreach (ColumnSchema column in this.SourceTable.Columns) {
|
||||
if(column.Name == "CascadeId") continue; //cascadeId字段需要程序控制
|
||||
%>
|
||||
<tr>
|
||||
<td>
|
||||
<%if(column.IsPrimaryKeyMember){ %>
|
||||
@Html.HiddenFor(m =>m.<%=column.Name%>)
|
||||
<% } else if(column.Name == CascadeId) {%>
|
||||
@Html.HiddenFor(m =>m.<%=CascadeId %>)
|
||||
@if (Model.Id == 0) //添加
|
||||
{
|
||||
//这个只用于显示使用,并不会进行提交处理,真正提交的是cascadeId
|
||||
<label for="CascadeName" class="control-label x120">父节点流水号:</label>
|
||||
<input type="text" name="CascadeName" id="CascadeName"
|
||||
data-toggle="selectztree" size="20" data-tree="#j_select_tree1" value="">
|
||||
<ul id="j_select_tree1" class="ztree hide" data-toggle="ztree"></ul>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
Init();
|
||||
});
|
||||
function Init() {
|
||||
var setting = {
|
||||
view: {
|
||||
selectedMulti: false
|
||||
},
|
||||
check: {
|
||||
enable: true,
|
||||
chkStyle: "radio",
|
||||
radioType: "all"
|
||||
},
|
||||
data: {
|
||||
key: {
|
||||
name: 'Name',
|
||||
title: 'Name'
|
||||
},
|
||||
simpleData: {
|
||||
enable: true,
|
||||
idKey: 'Id',
|
||||
pIdKey: 'ParentId',
|
||||
rootPId: 'null'
|
||||
}
|
||||
},
|
||||
callback: {
|
||||
onClick: zTreeOnClick,
|
||||
onCheck: zTreeCheck
|
||||
}
|
||||
};
|
||||
$.getJSON('CategoryManager/LoadForTree', function (json) {
|
||||
var zTreeObj = $.fn.zTree.init($('#j_select_tree1'), setting, json);
|
||||
zTreeObj.expandAll(true);
|
||||
});
|
||||
}
|
||||
function zTreeCheck(e, treeId, treeNode) {
|
||||
var zTree = $.fn.zTree.getZTreeObj(treeId),
|
||||
nodes = zTree.getCheckedNodes(true);
|
||||
var ids = '', names = '';
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
ids += ',' + nodes[i].Id;
|
||||
names += ',' + nodes[i].Name;
|
||||
}
|
||||
if (ids.length > 0) { //去掉第一个逗号
|
||||
ids = ids.substr(1);
|
||||
names = names.substr(1);
|
||||
}
|
||||
var $from = $('#' + treeId).data('fromObj');
|
||||
if ($from && $from.length) $from.val(names);
|
||||
$('#<%=CascadeId%>').val(ids);
|
||||
}
|
||||
function zTreeOnClick(event, treeId, treeNode) {
|
||||
var zTree = $.fn.zTree.getZTreeObj(treeId);
|
||||
zTree.checkNode(treeNode, !treeNode.checked, true, true);
|
||||
event.preventDefault();
|
||||
}
|
||||
</script>
|
||||
}
|
||||
else //编辑
|
||||
{
|
||||
<label for="CascadeId" class="control-label x120">节点语义ID:</label>
|
||||
<input type="text" name="CascadeId" id="CascadeId" value="@Model.CascadeId"
|
||||
data-rule="required" size="20">
|
||||
}
|
||||
<% } else if(CSharpAlias[column.SystemType.FullName] == "bool") {%>
|
||||
<label for="<%=column.Name%>" class="control-label x120"><%=column.Description%>:</label>
|
||||
<select name="<%=column.Name%>" id="<%=column.Name%>" data-toggle="selectpicker" data-rule="required">
|
||||
<option value="0" @if (Model.<%=column.Name%>) { <text> selected="selected" </text> }>否</option>
|
||||
<option value="1" @if (!Model.<%=column.Name%>) { <text> selected="selected" </text> }>是</option>
|
||||
</select>
|
||||
<%} else{%>
|
||||
<label for="<%=column.Name%>" class="control-label x120"><%=column.Description%>:</label>
|
||||
<input type="text" name="<%=column.Name%>" id="<%=column.Name%>" value="@Model.<%=column.Name%>"
|
||||
data-rule="required" size="20">
|
||||
<%} %>
|
||||
</td>
|
||||
</tr>
|
||||
<% } %>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
<div class="bjui-pageFooter">
|
||||
<ul>
|
||||
<li><button type="button" class="btn-close">关闭</button></li>
|
||||
<li><button type="submit" class="btn-green">保存</button></li>
|
||||
</ul>
|
||||
</div>
|
@@ -1,148 +1,93 @@
|
||||
<%--
|
||||
Name: Database Table Properties
|
||||
Name: 列表页面
|
||||
Author: yubaolee
|
||||
Description: Create a list of properties from a database table
|
||||
Description: 列表页面
|
||||
--%>
|
||||
<%@ CodeTemplate Language="C#" Encoding="utf-8" TargetLanguage="C#" Debug="True" Description="Create a list of properties from database table." %>
|
||||
<%@ Property Name="SourceTable" Type="SchemaExplorer.TableSchema" Category="Context" Description="Table that the object is based on." %>
|
||||
<%@ 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" %>
|
||||
@{
|
||||
string _prefix = "<%=ModuleName%>";
|
||||
var _treeId = _prefix + "Tree";
|
||||
var _gridId = _prefix + "Grid";
|
||||
var _treeDetail = _prefix + "Detail";
|
||||
Layout = "~/Views/Shared/_BjuiLayout.cshtml";
|
||||
}
|
||||
|
||||
@{ Html.RenderAction("MenuHeader", "Home");}
|
||||
<div class="bjui-pageContent tableContent">
|
||||
<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="@_treeId" class="ztree"></ul>
|
||||
<ul id="tree" class="ztree"></ul>
|
||||
</div>
|
||||
|
||||
<div id="@_treeDetail" style="margin-left: 225px;">
|
||||
<div id="detail" style="margin-left: 225px;">
|
||||
<table id="maingrid" class="table table-bordered"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
var selectedId = 0;
|
||||
$(document).ready(function () {
|
||||
initZtree();
|
||||
loadDataGrid();
|
||||
});
|
||||
//加载数据到datagrid
|
||||
function loadDataGrid() {
|
||||
//b-jui的datagrid需要重新处理HTML
|
||||
$('#@_treeDetail').empty()
|
||||
.append('<table id="@_gridId" class="table table-bordered table-hover table-striped table-top"></table>');
|
||||
|
||||
$('#@_gridId').datagrid({
|
||||
showToolbar: false,
|
||||
filterThead: false,
|
||||
columns: [
|
||||
<% foreach (ColumnSchema column in this.SourceTable.Columns) { %>
|
||||
{
|
||||
name: '<%=column.Name%>',
|
||||
label: '<%=column.Description%>',
|
||||
width: 100
|
||||
<%if(column.IsPrimaryKeyMember){ %>
|
||||
, hide: true
|
||||
<!--编辑对话框-->
|
||||
<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"
|
||||
||(CSharpAlias[column.SystemType.FullName] == "int" && Tools.GetDescription(column).Contains("下拉选择"))) {%>
|
||||
<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">禁用</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>
|
||||
<%} %>
|
||||
<%else if(CSharpAlias[column.SystemType.FullName] == "System.DateTime") {%>
|
||||
, type: 'date',
|
||||
pattern: 'yyyy-MM-dd HH:mm:ss'
|
||||
<%} %>
|
||||
<%else if(CSharpAlias[column.SystemType.FullName] == "bool") {%>
|
||||
,type: 'select',
|
||||
align: 'center',
|
||||
items: [{ '0': '否' }, { '1': '是' }],
|
||||
<%} %>
|
||||
<%else if(CSharpAlias[column.SystemType.FullName] == "int") {%>
|
||||
,type: 'select',
|
||||
align: 'center',
|
||||
items: [{ '0': '默认' }, { '1': '状态1' }],
|
||||
<%} %>
|
||||
},
|
||||
<% } %>
|
||||
],
|
||||
dataUrl: '<%=ModuleName%>Manager/Load?parentId=' + selectedId,
|
||||
fullGrid: true,
|
||||
showLinenumber: true,
|
||||
showCheckboxcol: true,
|
||||
paging: true,
|
||||
filterMult: false,
|
||||
showTfoot: true,
|
||||
height: '700'
|
||||
});
|
||||
}
|
||||
</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>
|
||||
|
||||
function zTreeOnClick(event, treeId, treeNode) {
|
||||
selectedId = treeNode.Id;
|
||||
loadDataGrid();
|
||||
}
|
||||
|
||||
function initZtree() {
|
||||
var setting = {
|
||||
view: {selectedMulti: false},
|
||||
data: {
|
||||
key: {
|
||||
name: 'Name',
|
||||
title: 'Name'
|
||||
},
|
||||
simpleData: {
|
||||
enable: true,
|
||||
idKey: 'Id',
|
||||
pIdKey: 'ParentId',
|
||||
rootPId: 'null'
|
||||
}
|
||||
},
|
||||
callback: {onClick: zTreeOnClick}
|
||||
};
|
||||
$.getJSON('<%=ModuleName%>Manager/LoadForTree', function (json) {
|
||||
var zTreeObj = $.fn.zTree.init($('#@_treeId'), setting, json);
|
||||
zTreeObj.expandAll(true);
|
||||
});
|
||||
}
|
||||
|
||||
//删除
|
||||
function del<%=ModuleName%>() {
|
||||
var selected = getSelected('#@_gridId',2);
|
||||
if (selected == null) return;
|
||||
|
||||
$.getJSON('<%=ModuleName%>Manager/Delete?Id=' + selected, function (data) {
|
||||
if (data.statusCode == "200")
|
||||
loadDataGrid();
|
||||
else {
|
||||
$(this).alertmsg('warn', data.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//自定义的编辑按钮
|
||||
function edit<%=ModuleName%>() {
|
||||
var selected = getSelected('#@_gridId',2);
|
||||
if (selected == null) return;
|
||||
|
||||
$(this).dialog({
|
||||
id: 'editDialog',
|
||||
url: '/<%=ModuleName%>Manager/Add?id=' + selected,
|
||||
title: '编辑',
|
||||
onClose:function() {
|
||||
refresh<%=ModuleName%>Grid();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function refresh<%=ModuleName%>Grid() {
|
||||
$('#@_gridId').datagrid('refresh');
|
||||
// loadDataGrid();
|
||||
}
|
||||
//@@ sourceURL=<%=ModuleName%>ManagerIndex.js
|
||||
</script>
|
||||
<script src="~/BllScripts/grid.js"></script>
|
||||
<script src="~/BllScripts/<%=ModuleName%>.js"></script>
|
24
CodeSmith/Util.cs
Normal file
24
CodeSmith/Util.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using CodeSmith.Engine;
|
||||
using SchemaExplorer;
|
||||
|
||||
namespace Util{
|
||||
public class Tools{
|
||||
public static String GetDescription(ColumnSchema column) { //得到字段的描述
|
||||
if(string.IsNullOrEmpty(column.Description))
|
||||
return column.Name;
|
||||
else
|
||||
return column.Description;
|
||||
}
|
||||
|
||||
public static bool NeedCascade(TableSchema SourceTable){ //判断表中是否需要下拉选择树
|
||||
return SourceTable.Columns.Contains("ParentId")
|
||||
|| SourceTable.Columns.Contains("CascadeId") ;
|
||||
}
|
||||
}
|
||||
}
|
250
CodeSmith/editDlg.js.cst
Normal file
250
CodeSmith/editDlg.js.cst
Normal file
@@ -0,0 +1,250 @@
|
||||
<%--
|
||||
Name: 编辑修改JS
|
||||
Author: yubaolee
|
||||
Description: 编辑修改JS
|
||||
--%>
|
||||
<%@ 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" %>
|
||||
|
||||
|
||||
//grid列表模块
|
||||
function MainGrid() {
|
||||
var url = '/<%=ModuleName%>/Load?parentId=';
|
||||
var selectedId = 0; //ztree选中的模块
|
||||
this.maingrid = $('#maingrid').datagrid({
|
||||
showToolbar: false,
|
||||
filterThead: false,
|
||||
target: $(this),
|
||||
columns: [
|
||||
<% foreach (ColumnSchema column in this.SourceTable.Columns) { %>
|
||||
{
|
||||
name: '<%=column.Name%>',
|
||||
label: '<%=Tools.GetDescription(column)%>',
|
||||
width: 100
|
||||
<%if(column.IsPrimaryKeyMember){ %>
|
||||
, hide: true
|
||||
<%} %>
|
||||
<%else if(CSharpAlias[column.SystemType.FullName] == "bool") {%>
|
||||
,type: 'select',
|
||||
align: 'center',
|
||||
items: [{ '0': '否' }, { '1': '是' }],
|
||||
<%} %>
|
||||
<%else if(CSharpAlias[column.SystemType.FullName] == "int") {%>
|
||||
,type: 'select',
|
||||
align: 'center',
|
||||
items: [{ '0': '默认' }, { '1': '状态1' }],
|
||||
<%} %>
|
||||
},
|
||||
<% } %>
|
||||
],
|
||||
dataUrl: url + selectedId,
|
||||
fullGrid: true,
|
||||
showLinenumber: true,
|
||||
showCheckboxcol: true,
|
||||
paging: true,
|
||||
filterMult: false,
|
||||
showTfoot: false,
|
||||
height: '100%'
|
||||
});
|
||||
this.reload = function (id) {
|
||||
if (id != undefined) selectedId = id;
|
||||
this.maingrid.datagrid('reload', { dataUrl: url+ selectedId });
|
||||
};
|
||||
};
|
||||
MainGrid.prototype = new Grid();
|
||||
var list = new MainGrid();
|
||||
|
||||
//左边分类导航树
|
||||
var ztree = function () {
|
||||
var url = '/<%=ModuleName%>/LoadForTree';
|
||||
var setting = {
|
||||
view: { selectedMulti: false },
|
||||
data: {
|
||||
key: {
|
||||
name: 'Name',
|
||||
title: 'Name'
|
||||
},
|
||||
simpleData: {
|
||||
enable: true,
|
||||
idKey: 'Id',
|
||||
pIdKey: 'ParentId',
|
||||
rootPId: 'null'
|
||||
}
|
||||
},
|
||||
callback: { onClick: zTreeOnClick }
|
||||
};
|
||||
$.getJSON(url, function (json) {
|
||||
$.fn.zTree.init($("#tree"), setting, json).expandAll(true);
|
||||
});
|
||||
function zTreeOnClick(event, treeId, treeNode) {
|
||||
list.reload(treeNode.Id);
|
||||
}
|
||||
|
||||
return {
|
||||
reload:function() {
|
||||
$.getJSON(url, function (json) {
|
||||
$.fn.zTree.init($("#tree"), setting, json).expandAll(true);
|
||||
});
|
||||
}
|
||||
}
|
||||
}();
|
||||
|
||||
<%if(Tools.NeedCascade(SourceTable)){ %>
|
||||
//编辑时,选择上级弹出的树
|
||||
var parentTree = function () {
|
||||
var nameDom = "#ParentName";
|
||||
var idDom = "#ParentId";
|
||||
var zTreeObj;
|
||||
var setting = {
|
||||
view: {
|
||||
selectedMulti: false
|
||||
},
|
||||
check: {
|
||||
enable: true,
|
||||
chkStyle: "radio", //单选
|
||||
radioType: "all"
|
||||
},
|
||||
data: {
|
||||
key: {
|
||||
name: 'Name',
|
||||
title: 'Name'
|
||||
},
|
||||
simpleData: {
|
||||
enable: true,
|
||||
idKey: 'Id',
|
||||
pIdKey: 'ParentId',
|
||||
rootPId: 'null'
|
||||
}
|
||||
},
|
||||
callback: {
|
||||
onClick: zTreeOnClick,
|
||||
onCheck: zTreeCheck
|
||||
}
|
||||
};
|
||||
|
||||
function zTreeCheck(event, treeId, treeNode) {
|
||||
var nodes = zTreeObj.getCheckedNodes(true);
|
||||
var ids = nodes.map(function (e) { return e.Id; }).join(",");
|
||||
var names = nodes.map(function (e) { return e.Name; }).join(",");
|
||||
|
||||
$(nameDom).val(names);
|
||||
$(idDom).val(ids);
|
||||
}
|
||||
function zTreeOnClick(event, treeId, treeNode) {
|
||||
zTreeObj.checkNode(treeNode, !treeNode.checked, true, true);
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
return {
|
||||
show:function() {
|
||||
$.getJSON('/<%=ModuleName%>/LoadForTree', function (json) {
|
||||
zTreeObj = $.fn.zTree.init($('#j_select_tree1'), setting, json);
|
||||
var orgstr = $(idDom).val();
|
||||
var name = '';
|
||||
if (orgstr != '') {
|
||||
var nodeIds = orgstr.split(',');
|
||||
$.each(nodeIds, function () {
|
||||
var node = zTreeObj.getNodeByParam("Id", this, null);
|
||||
name += ',' + node.Name;
|
||||
zTreeObj.checkNode(node, true, true);
|
||||
});
|
||||
$(nameDom).val(name.substr(1)); //显示名称
|
||||
}
|
||||
zTreeObj.expandAll(true);
|
||||
});
|
||||
}
|
||||
};
|
||||
}();
|
||||
<%} %>
|
||||
|
||||
//添加(编辑)对话框
|
||||
var editDlg = function () {
|
||||
var update = false;
|
||||
var show = function () {
|
||||
BJUI.dialog({ id: 'editDlg', title: '编辑对话框', target: '#editDlg' });
|
||||
$("#btnSave").on("click", function() {
|
||||
editDlg.save();
|
||||
});
|
||||
}
|
||||
return {
|
||||
add: function () { //弹出添加
|
||||
update = false;
|
||||
show();
|
||||
$.CurrentDialog.find("form")[0].reset(); //reset方法只能通过dom调用
|
||||
$("#Id").val(0);
|
||||
|
||||
<%if(Tools.NeedCascade(SourceTable)){
|
||||
Response.WriteLine("parentTree.show()");
|
||||
}%>
|
||||
},
|
||||
update: function (ret) { //弹出编辑框
|
||||
update = true;
|
||||
show();
|
||||
<% foreach (ColumnSchema column in this.SourceTable.Columns) { %>
|
||||
<%if(CSharpAlias[column.SystemType.FullName] == "bool"
|
||||
||(CSharpAlias[column.SystemType.FullName] == "int" && Tools.GetDescription(column).Contains("下拉选择"))) {%>
|
||||
$('#<%=column.Name%>').selectpicker('val', ret.<%=column.Name%>);
|
||||
<%} else{ %>
|
||||
$('#<%=column.Name%>').val(ret.<%=column.Name%>);
|
||||
<%} %>
|
||||
<% } %>
|
||||
<%if(Tools.NeedCascade(SourceTable)){
|
||||
Response.WriteLine("parentTree.show()");
|
||||
}%>
|
||||
},
|
||||
save: function() { //编辑-->保存
|
||||
$('#editForm').isValid(function (v) {
|
||||
if (!v) return; //验证没通过
|
||||
$("#editForm").bjuiajax('ajaxForm', {
|
||||
reload: false,
|
||||
callback:function(json) {
|
||||
list.reload();
|
||||
ztree.reload();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
}();
|
||||
|
||||
//删除
|
||||
function del() {
|
||||
var selected = list.getSelectedObj();
|
||||
if (selected == null) return;
|
||||
|
||||
$.getJSON('/moduleManager/Delete?Id=' + selected.Id, function (data) {
|
||||
if (data.statusCode == "200") {
|
||||
list.reload();
|
||||
ztree.reload();
|
||||
}
|
||||
else {
|
||||
$(this).alertmsg('warn', data.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//自定义的编辑按钮
|
||||
function edit() {
|
||||
var selected = list.getSelectedObj();
|
||||
if (selected == null) {
|
||||
return;
|
||||
}
|
||||
editDlg.update(selected);
|
||||
}
|
||||
|
||||
function add() {
|
||||
editDlg.add();
|
||||
}
|
||||
|
||||
function refresh() {
|
||||
list.reload();
|
||||
}
|
||||
|
||||
//@@ sourceURL=<%=ModuleName%>.js
|
Reference in New Issue
Block a user