ComplianceServer/oldcode/Core.Web/Views/Role/Index.cshtml

270 lines
10 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@using Core.Web.WebHelper
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<div class="x-body" id="contentBody">
<div class="layui-btn-group" style="padding-bottom:10px;">
@Html.Action("ToolBar", "Home",
new {
area="",
rightcode = (ViewBag.rightCode as string),
otherToolBars =new Core.Web.WebHelper.ToolBar[]
{ new Core.Web.WebHelper.ToolBar(ToolBarConfig.CONST_Other1, "向上", "layui-btn-warm","layui-icon-up") ,
new Core.Web.WebHelper.ToolBar(ToolBarConfig.CONST_Other2, "向下", "layui-btn-warm" ,"layui-icon-down"),
new Core.Web.WebHelper.ToolBar(ToolBarConfig.CONST_Other3, "配置事业部", "layui-btn-normal" ,"")
}
}
)
</div>
<table class="layui-hide" id="tabl1" lay-filter="tabl1"></table>
</div>
<!--确定宽度-->
<script>
var table;
$(function () {
//var tempwidth = 1410;
//var tempheight = 1115;
//var width = $(window).width();
//var height = Math.ceil(width * (tempheight / tempwidth));
//$("body").height($(window).height() + 150);
//$(window).resize(function () {//自动适应大小
// console.log("resize");
// table.resize('tab_kefuzhuangtaiyi1');
//});
});
</script>
<script>
var selectRow = {};
var winindex;
var layer;
var rowid;
//注意:选项卡 依赖 element 模块,否则无法进行功能性操作
layui.use('element', function () {
var element = layui.element;
element.on('tab(tonghuajiankong)', function (n) {
$(".bodytable").addClass("hidden");
$("#kefuzhuangtai" + (n.index + 1)).removeClass("hidden");
});
element.on('tab(maintab)', function (n) {
if (n.index == 0)
$("#bottomcard").removeClass("hidden");
else
$("#bottomcard").addClass("hidden");
});
});
layui.use(['laypage', 'layer', 'table', 'laydate'], function () {
var laydate = layui.laydate;
layer = layui.layer;
table = layui.table;
table.render({
id: 'testReload'//列表别名ID
, elem: '#tabl1'
, url: 'GetList'
, method: 'POST'
, height: "full-200"
, cellMinWidth: 80 //全局定义常规单元格的最小宽度layui 2.2.1 新增
, page: false
//, limit: 30
//, height: "full-250"
//, size:"sm"
, cols: [[
{ field: 'numbers', type: 'numbers' }
, { field: 'RNAME', title: '角色名称' }
, { field: 'CODE', title: '编码' }
, { field: 'CTIME', title: '创建时间' }
, { field: 'ROLEID', title: 'ID', width: 80 }
]],
done: function () {
if (rowid != null && rowid != "")
$("#contentBody").find("td[data-field='ROLEID']:contains('" + rowid + "')").click();
}
});
//监听行单击事件单击事件为rowDouble
table.on('row(tabl1)', function (obj) {
var data = obj.data;
obj.tr.addClass('self-table-click').siblings().removeClass('self-table-click');
selectRow = data;
});
var active = {
add: function () {
winindex = layer.open({
type: 2,
content: 'Edit',
title: "添加",
area: ['500px', '400px']
});
}, other1: function () {
if (selectRow.ORDERID == "undefined" || selectRow.ROLEID == null) {
layer.alert("请先选中一条记录!", { title: '提示' });
return;
}
//console.log(selectRow);
var prevtext = "";
$("#contentBody").find("td[data-field='ROLEID']").each(function (n, data) {
var text = $(data).text();
//console.log(data);
if (text == selectRow.ROLEID) {
var ss = $(data).parent().prev();
if (ss.length == 0) {
layer.msg("不能在往上排序了!", { icon: 2 });
} else {
prevtext = $(ss).find("td[data-field='ROLEID']").text();
}
return false;
}
});
if (prevtext != "") {
rowid = selectRow.ROLEID;
var loadingindex = layer.load(3, { shade: true });
$.ajax({
type: "POST",
url: "Sort",
data: { id1: selectRow.ROLEID, id2: prevtext },
dataType: "json",
success: function (da) {
layer.close(loadingindex);
if (da.result == true) {
layer.msg('排序成功!', { icon: 1 });
TableReload();
} else {
layer.msg(da.retmsg, { icon: 2 });
}
},
error: function () {
layer.close(loadingindex);
layer.msg('排序失败!', { icon: 2 });
}
});
}
}, other2: function () {
if (selectRow.ORDERID == "undefined" || selectRow.ROLEID == null) {
layer.alert("请先选中一条记录!", { title: '提示' });
return;
}
var toptext = "";
$("#contentBody").find("td[data-field='ROLEID']").each(function (n, data) {
var text = $(data).text();
//console.log(data);
if (text == selectRow.ROLEID) {
var ss = $(data).parent().next();
if (ss.length == 0)
layer.msg("不能在往下排序了!", { icon: 2 });
toptext = $(ss).find("td[data-field='ROLEID']").text();
return false;
}
});
if (toptext != "") {
rowid = selectRow.ROLEID;
var loadingindex = layer.load(3, { shade: true });
$.ajax({
type: "POST",
url: "Sort",
data: { id1: selectRow.ROLEID, id2: toptext },
dataType: "json",
success: function (da) {
layer.close(loadingindex);
if (da.result == true) {
layer.msg('排序成功!', { icon: 1 });
TableReload();
} else {
layer.msg(da.retmsg, { icon: 2 });
}
},
error: function () {
layer.close(loadingindex);
layer.msg('排序失败!', { icon: 2 });
}
});
}
}, edit: function () {
if (selectRow.ORDERID == "undefined" || selectRow.ROLEID == null) {
//layer.alert("请先选中一条记录!", { title: '提示' });
layer.msg("请先选中一条记录!", { icon: 7 });
return;
}
winindex = layer.open({
type: 2,
title: "编辑",
content: 'Edit?id=' + selectRow.ROLEID,
area: ['500px', '400px']
});
}, delete: function () {
if (selectRow.ROLEID == "undefined" || selectRow.ROLEID == null) {
layer.alert("请先选中一条记录!", { title: '提示' });
return;
}
layer.confirm('你确定要删除这条记录吗?', { icon: 3, title: '提示' }, function (index) {
//do something
var loadingindex = layer.load(3, { shade: false });
var data = { id: selectRow.ROLEID };
$.ajax({
type: "POST",
url: "Delete",
data: data,
dataType: "json",
success: function (da) {
layer.close(loadingindex);
if (da.result == true) {
layer.msg('操作成功!', { icon: 1 });
TableReload();
} else {
layer.msg(da.retmsg, { icon: 2 });
}
},
error: function () {
layer.close(loadingindex);
layer.msg('操作失败!', { icon: 2 });
}
});
//layer.close(index);
});
}, other3: function () {
if (selectRow.ORDERID == "undefined" || selectRow.ROLEID == null) {
//layer.alert("请先选中一条记录!", { title: '提示' });
layer.msg("请先选中一条记录!", { icon: 7 });
return;
}
winindex = layer.open({
type: 2,
title: "配置事业部",
content: 'ConfigCom?id=' + selectRow.ROLEID,
area: ['500px', '400px']
});
}
};
$('.layui-btn').on('click', function () {
var othis = $(this), method = othis.data('method');
console.log(method);
active[method] ? active[method].call(this, othis) : '';
});
});
function Closed() {
layer.close(winindex);
}
function TableReload() {
table.reload('testReload', {
page: {
curr: 1 //重新从第 1 页开始
}
});
}
</script>