ComplianceServer/oldcode/WEB/Views/Control/UserComBox.cshtml

156 lines
5.6 KiB
Plaintext

@{
ViewBag.Title = "UserComBox";
Layout = null;
}
@{ var controlType = (string)ViewBag.type;}
销售组:<input type="text" id="nb1_combox_innerGroup" class="easyui-combotree" style="width:160px;" />
<span style="@Html.Raw((controlType == "OnlyGroup") ? "display:none" : "")">
<span>员工:</span>
<select id="nb1_combox_user" style="cursor: pointer; width: 136px;" lay-ignore>
<option>请选择</option>
</select>
</span>
@{
if ((@ViewBag.isShowDismiss as string) == "True")
{
<span>状态:</span>
<select id="slt_isdismiss" name="slt_isdismiss">
<option value="">请选择</option>
<option value="0" selected="selected">在职</option>
<option value="1">离职</option>
</select>
}
}
<input id="level" type="hidden" value="@ViewBag.level" />
<input id="isShowDismiss" type="hidden" value="@ViewBag.isShowDismiss" />
<input id="isSelf" type="hidden" value="@ViewBag.isSelf" />
<input id="currentUserId" type="hidden" value="@ViewBag.currentUserId" />
<input id="currentGroupId" type="hidden" value="@ViewBag.currentGroupId" />
<input id="currentDeptId" type="hidden" value="@ViewBag.currentDeptId" />
<input id="currentCompanyId" type="hidden" value="@ViewBag.currentCompanyId" />
<input id="txt_companyId" name="txt_companyId" type="hidden" />
<input id="txt_deptId" name="txt_deptId" type="hidden" />
<input id="txt_groupIds" name="txt_groupIds" type="hidden" />
<input id="txt_userId" name="txt_userId" type="hidden" />
<script type="text/javascript">
var isFirst = true;
var isSelfFirst = true;
var treeData = @Html.Raw(ViewBag.tree);
var onload = function () {
if (isFirst) {
onLoadSucced();
isFirst = false;
}
};
function ComBoxLoad() {
$("#nb1_combox_innerGroup").combotree({
data: treeData,
onLoadSuccess: function () {
var level = $("#level").val();
var wocx = 0;
if (level == "Company") {
$("#nb1_combox_innerGroup").combotree('setValue', $("#currentCompanyId").val());
wocx = 1;
}
else if (level == "Dept") {
$("#nb1_combox_innerGroup").combotree('setValue', $("#currentDeptId").val());
wocx = 1;
}
else if (level == "Group")
{
$("#nb1_combox_innerGroup").combotree('setValue', $("#currentGroupId").val());
wocx = 1;
}
else if (level == "Self") {
$("#nb1_combox_innerGroup").combotree('setValue', $("#currentGroupId").val());
$("#txt_userId").val($("#currentUserId").val());
wocx = 1;
}
var isSelf = $("#isSelf").val();
if(isSelf == "True")
{
$("#nb1_combox_innerGroup").combotree('setValue', $("#currentGroupId").val());
wocx = 1;
}
//var tree = $('#nb1_combox_innerGroup').combotree('tree');
//var root = tree.tree('getRoot');
//var children = tree.tree('getChildren', root.target);
if (wocx == 0) {
var tree = $('#nb1_combox_innerGroup').combotree('tree');
//通过树tree对象获取根节点
var root = tree.tree('getRoot');
//设置默认选中根节点
$("#nb1_combox_innerGroup").combotree("setValue", root.id);
}
@*@Html.Raw((controlType == "OnlyGroup") ? "onload();" : "")*@
},
onSelect: function (node) {
var attr = JSON.parse(node.attributes);
$("#txt_companyId").val(attr.companyId);
$("#txt_deptId").val(attr.deptId);
$("#txt_groupIds").val(attr.groupId);
//console.log(node);
combox_GetUser();
}
});
}
var loaded = false;
$(function () {
if (!loaded) {
ComBoxLoad();
loaded = true;
}
$("#nb1_combox_user").change(function () {
$("#txt_userId").val($(this).val());
});
});
</script>
<script type="text/javascript">
function combox_GetUser() {
var companyId = $("#txt_companyId").val();
var deptId = $("#txt_deptId").val();
var groupId = $("#txt_groupIds").val();
var isShowDismiss = $("#isShowDismiss").val();
var level = $("#level").val();
if (companyId != "") {
$.r_post("/Control/GetUserCombo", { companyId, deptId, groupId, level, isShowDismiss }, function (res) {
//console.log(res);
$("#nb1_combox_user").empty();
if (level != "Self") {
$("#nb1_combox_user").append(new Option('请选择', ''));
}
$(res).each(function (n, m) {
$("#nb1_combox_user").append(new Option(m.Eid + '--' + m.UName + (m.IsDimiss == 1 ? '(离职)' : ''), m.UserId));
});
var isSelf = $("#isSelf").val();
if (isSelf == "True") {
$("#nb1_combox_user").val($("#currentUserId").val());
$("#txt_userId").val($("#currentUserId").val());
}
$("#nb1_combox_user").change();
$("#txt_userId").val($("#nb1_combox_user").val());
onload();
});
}
//else {
// onload();
//}
}
</script>