297 lines
12 KiB
Plaintext
297 lines
12 KiB
Plaintext
@using WX.CRM.WebHelper
|
||
@{
|
||
ViewBag.Title = "分配员工";
|
||
Layout = "~/Views/Shared/_Index_Layout2.cshtml";
|
||
}
|
||
<div class="mvctool">
|
||
@Html.ToolButton("btnQuery", "icon-search", "查询", true)
|
||
@Html.ToolButton("btnSave", "icon-save", "保存", true)
|
||
@*@Html.ToolButton("btnAll", "icon-detail", "所有销售组在职员工", true)
|
||
@Html.ToolButton("btnExcludeGroupLeader", "icon-detail", "除主管外的所有销售组在职员工", true)*@
|
||
</div>
|
||
<table style="width: 100%; border: 1px solid #95b8e7;">
|
||
<tr>
|
||
<td width="65%">
|
||
<div class="bas_datagrid">
|
||
<div id="tb" style="padding:5px;height:auto" class="grid_toolbar">
|
||
<ul class="toolBar_ul">
|
||
<li>销售组<input type="text" name="innerGroupId" id="innerGroupId" style="width:160px;" /><input type="hidden" name="txt_innerGroupId" id="txt_innerGroupId" value="" /> </li>
|
||
<li>工号:<input type="text" name="txt_eID" /> </li>
|
||
<li>姓名:<input type="text" name="txt_uName" /> </li>
|
||
</ul>
|
||
</div>
|
||
@Html.Raw(ViewBag.gridTable)
|
||
</div>
|
||
</td>
|
||
<td width="5%">
|
||
<input type="button" value=">" style="width:40px;" onclick="MoveDataToRight()" title="将选中的员工移至已选择" />
|
||
<input type="button" value="<" style="width:40px;" onclick="RemoveChooseData()" title="清空右边选中员工" />
|
||
<input type="button" value="<<" style="width:40px;" onclick="ClearAllRightData()" title="清除所有员工" />
|
||
</td>
|
||
<td style="border: 1px solid #95b8e7;">
|
||
<div class="bas_datagrid">
|
||
<div id="tb" style="padding:5px;height:auto;" class="grid_toolbar">
|
||
<span style="padding-right:40%">已选择员工:</span><a href="javasvript:void(0)" onclick="avg()">平均分配</a>
|
||
</div>
|
||
@Html.Raw(ViewBag.gridTable2)
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
<script type="text/javascript">
|
||
$(function () {
|
||
$("#btnSave").click(function () {
|
||
var rightRow = $('#tablis2').tablegrid('getAllRows');
|
||
if (rightRow == null || rightRow.length == 0) {
|
||
$.messager.alert('提示', '请添加你要分组的员工!');
|
||
return;
|
||
}
|
||
var requestId = "@Request.QueryString["id"]";
|
||
var strategy = "@Request["strategy"]";
|
||
var userIds = "";
|
||
var rate = 0;
|
||
$(rightRow).each(function (i, n) {
|
||
userIds += "0-" + n.pkid + "-" + n.map_uName + "-" + n.map_eID + "-" + $(n.resrate).attr("rate").toString() + ",";
|
||
rate += parseFloat($(n.resrate).attr("rate"));
|
||
});
|
||
if (rate != 100.00) {
|
||
$.messager.alert('提示', '比例必须是100%!');
|
||
return;
|
||
}
|
||
userIds = userIds.substr(0, userIds.length - 1);
|
||
$.r_ajax({
|
||
url: "/Res/SalesGroup/SaveSalesGroupDetial",
|
||
type: "Post",
|
||
//data: { id: requestId, userIds: userIds },
|
||
data: { id: requestId, userIds: userIds, usertype: 1, grouptype: 0, acttype: 'user', ratetype: 'rate', strategy: strategy },
|
||
dataType: "json",
|
||
loading: true,
|
||
success: function (data) {
|
||
if (data.type == 1) {
|
||
window.parent.frameReturnByMes(data.message);
|
||
window.parent.frameReturnByReload(true);
|
||
window.parent.frameReturnByClose()
|
||
}
|
||
else {
|
||
window.parent.frameReturnByMes(data.message);
|
||
}
|
||
}
|
||
});
|
||
});
|
||
});
|
||
function MoveDataToRight() {
|
||
var leftRow = $('#tablist').tablegrid('getSelections');
|
||
var rightRow = $('#tablis2').tablegrid('getAllRows');
|
||
var isMove = 1;
|
||
$(leftRow).each(function (i, n) {
|
||
isMove = 1;
|
||
$(rightRow).each(function (x, w) {
|
||
if (w.pkid == n.pkid) {
|
||
isMove = 0;
|
||
}
|
||
});
|
||
if (isMove == 1) {
|
||
var html = "<tr><td style='width:25px;'>" + i + "</td>" +
|
||
"<td style='width:25px;'><input type='checkbox'></td>" +
|
||
"<td style='display:none;' field='pkid'>" + n.pkid + "</td>" +
|
||
"<td field='map_eID'>" + n.map_eID + "</td>" +
|
||
"<td field='map_uName'>" + n.map_uName + "</td>" +
|
||
"<td field='resrate'><input type='text' value='0' style='width: 50px' onchange='setrate(this)' rate='0' />%</td>" +
|
||
"</tr>";
|
||
$("#tablis2").find("tbody").append(html);
|
||
}
|
||
});
|
||
RebuildIndex();
|
||
}
|
||
function RemoveChooseData() {
|
||
var rightRow = $('#tablis2').tablegrid('getSelections');
|
||
$("#tablis2").find("tbody tr").each(function (i, n) {
|
||
var nrow = $(this);
|
||
var npkid = $(nrow).find("td:[field='pkid']").text()
|
||
$(rightRow).each(function (x, w) {
|
||
if (w.pkid == npkid) {
|
||
$(nrow).remove()
|
||
}
|
||
});
|
||
});
|
||
$("#tablis2").find("tbody tr").each(function (i, n) {
|
||
$(this).find("td:first-child").html(i + 1);
|
||
});
|
||
}
|
||
function ClearAllRightData() {
|
||
$.messager.confirm('提示', '您确定要全部清除右边所选数据吗?', function (r) {
|
||
if (r) {
|
||
$('#tablis2').tablegrid('Clear');
|
||
}
|
||
});
|
||
|
||
}
|
||
//重建序号
|
||
function RebuildIndex() {
|
||
$("#tablis2").find("tbody tr").each(function (i, n) {
|
||
$(this).find("td:first-child").html(i + 1);
|
||
});
|
||
}
|
||
function setrate(obj) {
|
||
$(obj).attr("rate", obj.value);
|
||
}
|
||
function avg() {
|
||
var lastTr = $("#tablis2 tr:last");
|
||
var index = $(lastTr).find('td').eq(0).text();
|
||
//alert(index);
|
||
//var avg = parseFloat((1 / index) * 10 * 10).toFixed(2);
|
||
var avg = parseInt(10000 / index) / 100;
|
||
//alert(avg);
|
||
var total = 0;
|
||
$("#tablis2").find("tbody tr").each(function (i, n) {
|
||
var input = $(this).find("td:last-child input");
|
||
$(input).val(avg);
|
||
$(input).attr("rate", avg);
|
||
total += parseFloat(avg);
|
||
});
|
||
if (total < 100) {
|
||
var lastInput = $(lastTr).find("td:last-child input");
|
||
var diff = parseFloat(100 - total).toFixed(2);
|
||
lastInput.val((parseInt(avg * 100) + parseInt(diff * 100)) / 100);
|
||
lastInput.attr("rate", (parseInt(avg * 100) + parseInt(diff * 100)) / 100);
|
||
}
|
||
else if (total > 100) {
|
||
$.messager.alert('提示', '比例错误,请重新计算!');
|
||
return;
|
||
}
|
||
}
|
||
</script>
|
||
<script type="text/javascript">
|
||
function GetGroups() {
|
||
var node = $("#innerGroupId").combotree("tree").tree('getSelected');
|
||
var tree = $("#innerGroupId").tree;
|
||
var isLeaf = tree('isLeaf', node.target);
|
||
var gorupidvalues = "";
|
||
if (node.id.toString().indexOf("com_") == -1 && node.id.toString().indexOf("sale_") == -1)
|
||
gorupidvalues = node.id.toString() + ",";
|
||
if (!isLeaf) {//不是最底层
|
||
var child = $("#innerGroupId").combotree("tree").tree("getChildren", node.target);
|
||
if (node.id != 0 && child != null) {
|
||
for (var i = 0; i < child.length; i++) {
|
||
if (child[i].id.toString().indexOf("com_") == -1 && child[i].id.toString().indexOf("sale_") == -1)
|
||
gorupidvalues += child[i].id + ","
|
||
}
|
||
}
|
||
}
|
||
|
||
if (gorupidvalues.length > 0)
|
||
return gorupidvalues.substr(0, gorupidvalues.length - 1);
|
||
else
|
||
return "-1";
|
||
}
|
||
$(function () {
|
||
$("#innerGroupId").combotree({
|
||
url: "/Base/InnerGroup/GetTreeList?type=1",
|
||
height: 28,
|
||
onSelect: function (node) {
|
||
var groups = GetGroups();
|
||
$("#txt_innerGroupId").val(groups);//获取组
|
||
if (node.id.toString().indexOf("sale_") == -1 && node.id.toString().indexOf("com_") == -1 && node.attributes != null) {
|
||
$("#innerDept").combotree("setValues", [node.attributes])
|
||
} else if (!(node.id.toString().indexOf("sale_") == -1 && node.id.toString().indexOf("com_") == -1)) {
|
||
|
||
//$('#txt_innerGroupId').combotree('clear');
|
||
}
|
||
}
|
||
});
|
||
$("#innerDept").combotree({
|
||
url: "/Base/InnerDepartment/GetTreeJson",
|
||
height: 28,
|
||
onSelect: function (node) {
|
||
var tree = $(this).tree;
|
||
var isLeaf = tree('isLeaf', node.target);
|
||
var deptidvalues = node.id.toString() + ",";
|
||
if (!isLeaf) {//不是最底层
|
||
var child = $("#innerDept").combotree("tree").tree("getChildren", node.target);
|
||
if (node.id != 0 && child != null) {
|
||
for (var i = 0; i < child.length; i++) {
|
||
deptidvalues += child[i].id + ","
|
||
}
|
||
}
|
||
}
|
||
$("#txt_innerDeptId").val(deptidvalues.substr(0, deptidvalues.length - 1));
|
||
}
|
||
});
|
||
|
||
$('#tablist').tablegrid({
|
||
url: '/Res/SalesGroup/SalesGroupDetailsGetHtmlList',
|
||
height: $(window).height() - 110,
|
||
loadNow: false,
|
||
isCheckMore: true,
|
||
isPage: true
|
||
});
|
||
$('#tablis2').tablegrid({
|
||
url: '',
|
||
height: $(window).height() - 110,
|
||
loadNow: false,
|
||
isCheckMore: true,
|
||
isPage: false
|
||
});
|
||
$("#btnQuery").click(function () {//搜索按钮点击事件
|
||
//$('#tablist').tablegrid("Search");
|
||
$('#tablist').tablegrid({
|
||
url: '/Res/SalesGroup/SalesGroupDetailsGetHtmlList',
|
||
height: $(window).height() - 110,
|
||
loadNow: true,
|
||
isCheckMore: true,
|
||
isPage: true
|
||
});
|
||
});
|
||
$(window).resize(function () {//自动适应大小
|
||
$('#tablist').tablegrid('resize', {
|
||
height: $(window).height() - 110
|
||
});
|
||
$('#tablis2').tablegrid('resize', {
|
||
height: $(window).height() - 110
|
||
});
|
||
});
|
||
$('#tablis2').tablegrid('resize', {
|
||
height: $(window).height() - 110
|
||
});
|
||
});
|
||
function frameReturnByClose() {
|
||
$("#modalwindow").window('close');
|
||
}
|
||
function frameReturnByReload(flag) {
|
||
$("#tablist").tablegrid("Load");
|
||
}
|
||
function frameReturnByMes(mes) {
|
||
$.messageBox5s('提示', mes);
|
||
}
|
||
function getPageOptions(gridID) {
|
||
var option = $("#tablist").tablepage('getPagination');
|
||
var str = "rows=" + option.rows + "&page=" + option.page + "&order=" + option.order + "&sort=" + option.sort;
|
||
return str;
|
||
}
|
||
//获取datagrid头部及字段
|
||
function getDataGridHeader() {
|
||
var columns = $('#tablist').tablegrid("getHead");
|
||
return columns;
|
||
}
|
||
|
||
$("#btnAll").click(function () {//搜索按钮点击事件
|
||
$('#tablist').tablegrid({
|
||
url: '/Res/SalesGroup/SalesGroupDetailsGetHtmlList2?isDismiss=0&isLeader=false',
|
||
height: $(window).height() - 110,
|
||
loadNow: true,
|
||
isCheckMore: true,
|
||
isPage: false
|
||
});
|
||
});
|
||
|
||
$("#btnExcludeGroupLeader").click(function () {//搜索按钮点击事件
|
||
$('#tablist').tablegrid({
|
||
url: '/Res/SalesGroup/SalesGroupDetailsGetHtmlList2?isDismiss=0&isLeader=true',
|
||
height: $(window).height() - 110,
|
||
loadNow: true,
|
||
isCheckMore: true,
|
||
isPage: false
|
||
});
|
||
});
|
||
</script>
|