Files
zszq-trs/YLErpWeb/Views/System/UserIndex.cshtml
T

287 lines
12 KiB
Plaintext

@{
ViewBag.Title = "系统账号";
Layout = "~/Views/Shared/_MainLayout.cshtml";
var pageObj = new
{
HasGroup = ConsUserGroup.HasGroup,
isUserAdd = CurUser.系统管理.用户新增,
isUserEdit = CurUser.系统管理.用户修改,
isUserState = CurUser.系统管理.用户禁用,
isInitUser = CurUser.LoginName.ToLower() == "supera",
};
}
@section JS{
<script type="text/javascript">
var page = @Json.Serialize(pageObj);
//重置多选框
$.fn.ResetAceDropDown = function () {
this.each(function () {
$this = $(this);
$this.val('').trigger("chosen:updated");
});
//写的比较生硬,,
$(".filter-option-inner-inner").text('未选择...')
};
function getSelectedText() {
if (window.getSelection) {
return window.getSelection().toString();
} else if (document.getSelection) {
return document.getSelection();
} else if (document.selection) {
return document.selection.createRange().text;
}
return "";
}
$(function () {
var PostData = {};
@Html.Raw(JqGridSimple.OutGrid("UserSearchQuery"));
function AfterInsertRow(rowid, aData) {
grid.setCell(rowid, "State", aData.State == 0 ? "正常" : "禁用");
}
SetAceDropDown();
document.body.onkeydown = shorcutEvent;
document.body.onmouseup = selectText;
window.tdSelectionInfo = {
text: "",
searchParamId: ""
}
window.colNames = $("#listGrid").jqGrid('getGridParam', 'colNames');
});
var colModelGrid = [
{ name: 'id', key: true, index: 'id', width: 1, hidden: true },
{ name: 'LoginName', label: "登录名", index: 'LoginName', width: 150 },
{ name: 'Name', label: "姓名", index: 'Name', width: 150 },
{ name: 'Email', label: "邮箱", sortable: false, width: 250 },
{ name: 'Departments', label: "所属部门", sortable: false, align: 'left', width: 200 },
{ name: 'Tel', label: "座机", index: 'Tel', width: 100 },
{ name: 'Mobile', label: "手机", index: 'Mobile', width: 100 },
{ name: 'QQ', label: "QT", index: 'QQ', width: 100 },
{ name: 'OaAccount', label: "OA账号", index: 'OaAccount', width: 100 },
{ name: 'UserGroup', label: "用户组", sortable: false, width: 150, hide: page.HasGroup, optionHide: page.HasGroup },
{ name: 'Roles', label: "角色", sortable: false, align: 'left', width: 200 },
{ name: 'AccountPost', label: "账号岗位", sortable: false, align: 'left', width: 200 },
{
name: 'State', label: "状态", index: 'State', width: 100,
formatter: function ShowStructFormater(cellValue, options, rowObject) {
return rowObject.StateDesc;
}
},
{ name: '', label: "操作", index: '', width: 140, algin: 'center', formatter: showToolName },
{ name: '', label: "账号层级关系", index: '', width: 140, algin: 'center', formatter: showLevel },
];
function showToolName(cellValue, options, rowObject) {
var html = "";
if (page.isUserEdit && rowObject.StateDesc != "禁用") {
html += "<input type=\"button\" class=\"wentiEdit\" title='修改' onclick=\"modifyView('{0}')\" value=\"{1}\" />".template(rowObject.id, "修改");
}
else
{
html += "<input type=\"button\" class=\"wentiEdit\" title='修改' disabled='disabled'\" value=\"{1}\" />".template(rowObject.id, "修改");
}
if (page.isUserState && (rowObject.LoginName.toLowerCase() != "supera" || page.isInitUser)) {
if (rowObject.StateDesc == "禁用") {
html = html + "<input type=\"button\" class=\"wentiEdit\" title='启用' onclick=\"enable({0})\" value=\"{1}\" />".template(rowObject.id, "启用");
} else {
html = html + "<input type=\"button\" class=\"wentiEdit\" title='禁用' onclick=\"disable({0})\" value=\"{1}\" />".template(rowObject.id, "禁用");
}
}
else {
if (rowObject.StateDesc == "禁用") {
html = html + "<input type=\"button\" class=\"wentiEdit\" title='启用' disabled='disabled'\" value=\"{1}\" />".template(rowObject.id, "启用");
} else {
html = html + "<input type=\"button\" class=\"wentiEdit\" title='禁用' disabled='disabled'\" value=\"{1}\" />".template(rowObject.id, "禁用");
}
}
return html;
}
function showLevel(cellValue, options, rowObject) {
return `<button type="button" class=\"wentiEdit\" title='查看' onclick=\"openLevel('${rowObject.id}')\">查看</button>`;
}
function openLevel(id) {
var srcurl = "/System/UserLevelView?id=" + id;
layer.open({
type: 2,
title: "查看账号层级关系",
shadeClose: false,
shade: 0.4,
area: ['1000px', '400px'],
content: srcurl
});
}
function modifyView(id) {
main.infopage("修改用户信息", './UserEdit/' + id);
}
function enable(id) {
main.confirmPost("确认启用账号?", "/System/accountAble", { accountIds: id }).done(function (data) {
SearchClick(true);
});
}
function disable(id) {
main.confirmPost("确认禁用账号?", "/System/accountDisable", { accountIds: id }).done(function (data) {
SearchClick(true);
});
}
function rowdblclick(id) {
main.infopage("查看用户信息","./UserView/" + id, { area: ['600px', '80%'] });
}
function AddNew() {
main.infopage("新增用户", "./UserEdit/0", { area: ['600px', '80%'] });
}
function SearchClick(isSearchclick) {
var listGrid = $('#listGrid');
$('#listGrid').appendPostData({ Ids: $("#Name").val() == null ? "" : $("#Name").val().join(",") });
$('#listGrid').appendPostData({ RoleIds: $("#Role").val() == null ? "" : $("#Role").val().join(",") });
$('#listGrid').appendPostData({
DepartmentIds: $("#Department").val() == null ? "" : $("#Department").val().join(",")
});
$('#listGrid').appendPostData({ UserGroup: $("#UserGroup").val()});
if ($("#checkEnabled").prop("checked") && !$("#checkDisabled").prop("checked")) {
$('#listGrid').appendPostData({ State: 0 });
} else if ($("#checkDisabled").prop("checked") && !$("#checkEnabled").prop("checked")) {
$('#listGrid').appendPostData({ State: 1 });
} else {
$('#listGrid').appendPostData({ State: null });
}
if (typeof (isSearchclick) != "undefined" && isSearchclick) {
//点击搜索时默认第一页
listGrid.jqGrid('setGridParam',{page: 1});
}
$('#listGrid').trigger('reloadGrid');
}
function resetSearch() {
$("#Name").ResetAceDropDown();
$("#Role").ResetAceDropDown();
$("#Department").ResetAceDropDown();
$("#checkEnabled").prop("checked",false);
$("#checkDisabled").prop("checked",false);
SearchClick(true);
}
function selectText() {
var selectedText = getSelectedText();
if (selectedText == null || selectedText.trim() == "") {
return;
}
var targetEle = window.event.target.tagName == "TD" ? window.event.target : window.event.target.parentNode;
if (targetEle == null) {
return;
}
if (targetEle.tagName !== "TD" ||
$(targetEle).attr("role") == null ||
$(targetEle).attr("role") !== "gridcell") {
return;
}
var colIndex = $(targetEle).index();
var colName = colNames[colIndex];
switch (colName) {
case "姓名":
window.tdSelectionInfo.searchParamId = "Name";
break;
case "所属部门":
window.tdSelectionInfo.searchParamId = "Department";
break;
case "角色":
window.tdSelectionInfo.searchParamId = "Role";
break;
case "状态":
window.tdSelectionInfo.searchParamId = "State";
break;
default:
return;
}
window.tdSelectionInfo.text = selectedText.trim();
}
function shorcutEvent() {
//Ctrl+S
if ((window.event.keyCode == 83) && (event.ctrlKey)) {
if (window.tdSelectionInfo.text !== ""&&window.tdSelectionInfo.searchParamId!=="") {
$("#Name").ResetAceDropDown();
$("#Role").ResetAceDropDown();
$("#Department").ResetAceDropDown();
$("#checkEnabled").prop("checked",false);
$("#checkDisabled").prop("checked",false);
var flag = false;
if (window.tdSelectionInfo.searchParamId === "State") {
if (window.tdSelectionInfo.text === "正常") {
$("#checkEnabled").prop("checked", true);
flag = true;
} else if (window.tdSelectionInfo.text === "禁用") {
$("#checkDisabled").prop("checked", true);
flag = true;
}
} else {
$("#" + window.tdSelectionInfo.searchParamId).find("option").each(function() {
if (this.text == window.tdSelectionInfo.text) {
this.selected = true;
flag = true;
return;
}
});
if (flag) {
$("#" + window.tdSelectionInfo.searchParamId).trigger("chosen:updated");
}
}
if (flag) {
SearchClick(true);
}
}
return false;
}
//Ctrl+D
if ((window.event.keyCode == 68) && (event.ctrlKey)) {
resetSearch();
return false;
}
}
</script>
}
<div class="searchdiv">
@Html.MyAceDropdownInput("Name", "姓名", GlobalData.GetAllUser())
@Html.MyAceDropdownInput("Role", "角色", GlobalData.GetAllRole(CurUser, ""))
@if (ConsUserGroup.HasGroup)
{
<div class="search-group">
<span class="search-label" for="UserGroup">用户组</span>
<select class="" id="UserGroup" name="UserGroup">
<option value="">全部</option>
@foreach (var item in ConsUserGroup.GetGroups())
{
<option value="@(item.ItemValue)">@(item.ItemDesc)</option>
}
</select>
</div>
}
@Html.MyAceDropdownInput("Department", "所属部门", GlobalData.GetAllDepartements())
状态:<input type="checkbox" id="checkEnabled" />正常
<input type="checkbox" id="checkDisabled" />禁用
@MyControls.Btn("筛选", "return(SearchClick(true));")
@if (pageObj.isUserAdd)
{
@MyControls.Btn("新增", "AddNew()")
}
@MyControls.Btn("恢复筛选", "resetSearch()")
</div>
@Html.Raw(JqGridSimple.OutTable())