351 lines
14 KiB
Plaintext
351 lines
14 KiB
Plaintext
@{
|
|
ViewBag.Title = "资源分配";
|
|
Layout = "~/Views/Shared/_Index_LayoutEdit.cshtml";
|
|
var ulit = ViewData["ULIST"] as IEnumerable<WX.CRM.Model.Entity.BAS_INNERUSER>;
|
|
var dulist = ViewData["DULIST"] as IEnumerable<WX.CRM.Model.Entity.BAS_INNERUSER>;
|
|
int total = (int)ViewData["TOTAL"];
|
|
}
|
|
|
|
|
|
<div class="formContent">
|
|
<table class="fromEditTable setTextWidth300" style="margin-bottom:0">
|
|
<tr>
|
|
<td style="width:50%;">
|
|
|
|
剩余可分配数量:<label id="lblNum">@total</label>
|
|
<br />
|
|
<input type="button" value="全选" onclick="chkall()" />
|
|
<input type="button" value="平均分配" onclick="AvgAll()" />
|
|
<input type="button" value="分配固定数量" onclick="distbnum()" />
|
|
<input type="button" value="提交" id="save" onclick="distbuteSubmit()" />
|
|
<input type="button" value="正在提交..." id="wait" style="display:none;" disabled ="disabled" />
|
|
<p style="padding-top: 10px; display: none;">选择分类:<select id="category"><option></option><option value="A">A</option><option value="B">B</option><option value="C">C</option><option value="D">D</option></select></p>
|
|
</td>
|
|
<td>
|
|
操作指引:
|
|
<ol>
|
|
<li>1、先勾选需要根本的坐席(可全选或选择某个组);</li>
|
|
<li>2、平均分配 将所有可分配资源平均分配给勾选的坐席;</li>
|
|
<li>3、分配固定数量 为所有勾选的坐席分配输入的分配数量;</li>
|
|
<li>4、提交 将分配结果提交。</li>
|
|
</ol>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<table class="fromEditTable setTextWidth300" id="tblUsers">
|
|
|
|
@foreach (var gitem in ViewData["GLIST"] as List<WX.CRM.Model.Entity.BAS_INNERGROUP>)
|
|
{
|
|
var ulist = ulit.Where(item => item.map_GID == gitem.GID).OrderByDescending(p => p.ISHIDE).ToList();
|
|
for (int i = 0; i < ulist.Count(); i += 3)
|
|
{
|
|
var uitem = ulist[i];
|
|
<tr>
|
|
@if (i == 0)
|
|
{
|
|
<td rowspan="@(ulist.Count() / 3 + (ulist.Count() % 3>0?1:0))" width="80px" valign="top" style="padding-top:5px;">
|
|
@gitem.GNAME
|
|
<input type="button" value="全选组" onclick="chkall(@uitem.map_GID)" />
|
|
</td>
|
|
}
|
|
<td width="100px"><input type="checkbox" gid="@uitem.map_GID" uid="@uitem.PKID" onclick="ckNums(this)" />@uitem.UNAME</td>
|
|
<td><input type="text" style="width:40px;" onchange="caclnums()" /></td>
|
|
@*<td><select><option></option><option value="A">A</option><option value="B">B</option><option value="C">C</option><option value="D">D</option></select></td>*@
|
|
@if (ulist.Count() > i + 1)
|
|
{
|
|
uitem = ulist[i + 1];
|
|
<td width="100px"><input type="checkbox" gid="@uitem.map_GID" uid="@uitem.PKID" onclick="ckNums(this)" />@uitem.UNAME</td>
|
|
<td><input type="text" style="width:40px;" onchange="caclnums()" /></td>
|
|
@*<td><select><option></option><option value="A">A</option><option value="B">B</option><option value="C">C</option><option value="D">D</option></select></td>*@
|
|
}
|
|
else
|
|
{
|
|
<td width="50px"></td>
|
|
<td></td>
|
|
@*<td></td>*@
|
|
}
|
|
@if (ulist.Count() > i + 2)
|
|
{
|
|
uitem = ulist[i + 2];
|
|
<td width="100px"><input type="checkbox" gid="@uitem.map_GID" uid="@uitem.PKID" onclick="ckNums(this)" />@uitem.UNAME</td>
|
|
<td><input type="text" style="width:40px;" onchange="caclnums()" /></td>
|
|
@*<td><select><option></option><option value="A">A</option><option value="B">B</option><option value="C">C</option><option value="D">D</option></select></td>*@
|
|
}
|
|
else
|
|
{
|
|
<td width="50px"></td>
|
|
<td></td>
|
|
@*<td></td>*@
|
|
}
|
|
</tr>
|
|
}
|
|
}
|
|
|
|
@foreach (var gitem in ViewData["DLIST"] as List<WX.CRM.Model.Entity.BAS_SALESDEPARTMENT>)
|
|
{
|
|
var ulist = dulist.Where(item => item.map_GID == gitem.SALEDEPTID).OrderByDescending(p => p.ISHIDE).ToList();
|
|
for (int i = 0; i < ulist.Count(); i += 3)
|
|
{
|
|
var uitem = ulist[i];
|
|
<tr>
|
|
@if (i == 0)
|
|
{
|
|
<td rowspan="@(ulist.Count() / 3 + (ulist.Count() % 3>0?1:0))" width="80px" valign="top" style="padding-top:5px;">
|
|
@gitem.DEPTNAME
|
|
<input type="button" value="全选部门" onclick="chkall(@uitem.map_GID)" />
|
|
</td>
|
|
}
|
|
<td width="100px"><input type="checkbox" gid="@uitem.map_GID" uid="@uitem.PKID" onclick="ckNums(this)" />@uitem.UNAME</td>
|
|
<td><input type="text" style="width:40px;" onchange="caclnums()" /></td>
|
|
@*<td><select><option></option><option value="A">A</option><option value="B">B</option><option value="C">C</option><option value="D">D</option></select></td>*@
|
|
@if (ulist.Count() > i + 1)
|
|
{
|
|
uitem = ulist[i + 1];
|
|
<td width="100px"><input type="checkbox" gid="@uitem.map_GID" uid="@uitem.PKID" onclick="ckNums(this)" />@uitem.UNAME</td>
|
|
<td><input type="text" style="width:40px;" onchange="caclnums()" /></td>
|
|
@*<td><select><option></option><option value="A">A</option><option value="B">B</option><option value="C">C</option><option value="D">D</option></select></td>*@
|
|
}
|
|
else
|
|
{
|
|
<td width="50px"></td>
|
|
<td></td>
|
|
@*<td></td>*@
|
|
}
|
|
@if (ulist.Count() > i + 2)
|
|
{
|
|
uitem = ulist[i + 2];
|
|
<td width="100px"><input type="checkbox" gid="@uitem.map_GID" uid="@uitem.PKID" onclick="ckNums(this)" />@uitem.UNAME</td>
|
|
<td><input type="text" style="width:40px;" onchange="caclnums()" /></td>
|
|
@*<td><select><option></option><option value="A">A</option><option value="B">B</option><option value="C">C</option><option value="D">D</option></select></td>*@
|
|
}
|
|
else
|
|
{
|
|
<td width="50px"></td>
|
|
<td></td>
|
|
@*<td></td>*@
|
|
}
|
|
</tr>
|
|
}
|
|
}
|
|
</table>
|
|
</div>
|
|
<script type="text/javascript">
|
|
var re = /^[1-9]+[0-9]*]*$/;
|
|
function chkall(gid){
|
|
var all = null;
|
|
if(gid)
|
|
all = $("#tblUsers input[type='checkbox'][gid='"+gid+"']");
|
|
else
|
|
all = $("#tblUsers input[type='checkbox']");
|
|
all.each(function (i) {
|
|
this.checked = true;
|
|
});
|
|
}
|
|
function changetype(type) {
|
|
if ($("input[id=chkavg]")[0].checked)
|
|
AvgAll();
|
|
if (type == 1) {
|
|
$("table[id='tblUsers'] input[type=text]").each(function () {
|
|
$(this).parent().append("<label id='lblprecent'>%</label>");
|
|
});
|
|
} else {
|
|
$("table[id='tblUsers'] input[type=text]").each(function () {
|
|
$(this).next().remove();
|
|
});
|
|
}
|
|
}
|
|
//平均分配
|
|
function AvgAll() {
|
|
$("table[id='tblUsers'] input[type=text]").each(function () {
|
|
this.value = "";
|
|
});
|
|
var total = @total;
|
|
if($("input[type=radio]:checked").val()=="1")
|
|
total = 100;
|
|
var str1 = "#tblUsers input[type='checkbox']:checked";
|
|
var chklist = $(str1);
|
|
var usernum = chklist.length;
|
|
if(usernum==0)
|
|
{
|
|
alert("请选勾选坐席");
|
|
return;
|
|
}
|
|
var num = parseInt(total / usernum);
|
|
var s = total - num * usernum;
|
|
$(chklist).each(function (i) {
|
|
$(this).parent().next().children()[0].value = num + (i < s ? 1 : 0);
|
|
});
|
|
caclnums();
|
|
}
|
|
//分配固定
|
|
function distbnum(){
|
|
var str1 = "#tblUsers input[type='checkbox']:checked";
|
|
var chklist = $(str1);
|
|
var usernum = chklist.length;
|
|
if(usernum==0)
|
|
{
|
|
alert("请选勾选坐席");
|
|
return;
|
|
}
|
|
var num = prompt("请输入每个坐席需要分配的数量","1");
|
|
if (num!=null && num!=""&& !re.test(num)) {
|
|
alert("请输入正整数");
|
|
return;
|
|
}
|
|
if (num) {
|
|
$(chklist).each(function (i) {
|
|
$(this).parent().next().children()[0].value = num ;
|
|
});
|
|
caclnums();
|
|
}
|
|
}
|
|
function distbuteSubmit() {
|
|
//var uids = $("#tblUsers input[type=text]");
|
|
var canSubmit = true;
|
|
var total = @total;
|
|
var data = "";
|
|
var str = "#tblUsers input[type='checkbox']:checked";
|
|
if ($(str).length < 1) {
|
|
alert("请选择要分配人员");
|
|
return false;
|
|
}
|
|
var sum = 0;
|
|
$(str).each(function (i) {
|
|
var uid = $(this).attr("uid");
|
|
var txt = $(this).parent().next().children()[0];
|
|
var n = txt.value;
|
|
if (n == "") {
|
|
$(this).focus();
|
|
$(txt).css("border", "1px solid red");
|
|
canSubmit = false;
|
|
//return false;
|
|
}
|
|
//var m = $(this).parent().next().next().children()[0].value;
|
|
var m = 0;
|
|
data += uid + ":" + n + ":" + m + ",";
|
|
sum += parseInt(n);
|
|
});
|
|
if (sum > total) {
|
|
alert("没有足够的资源");
|
|
canSubmit = false;
|
|
return false;
|
|
}
|
|
if (!canSubmit) {
|
|
return false;
|
|
}
|
|
$("#save").hide();
|
|
$("#wait").show();
|
|
if (data.lastIndexOf(',') == data.length - 1) {
|
|
data = data.substring(0, data.length - 1);
|
|
}
|
|
if (data.length == 1) {
|
|
data = "";
|
|
}
|
|
//return false;
|
|
$.post("/Res/Allocate/DistbuteSubmit2",{
|
|
resid : '@Request.QueryString["resid"]',
|
|
HidRESOURCETAG : '@Request.QueryString["HidRESOURCETAG"]',
|
|
HidResourceId : '@Request.QueryString["HidResourceId"]',
|
|
isView : '@Request.QueryString["isView"]',
|
|
isNew : '@Request.QueryString["isNew"]',
|
|
AllocateTime1 : '@Request.QueryString["AllocateTime1"]',
|
|
AllocateTime2 : '@Request.QueryString["AllocateTime2"]',
|
|
distbuteData : data,
|
|
userId:'@Request.QueryString["userId"]',
|
|
groupId: '@Request.QueryString["groupId"]',
|
|
groupIds:'@Request.QueryString["groupIds"]',
|
|
pkids: '@ViewBag.pkids',
|
|
category: '@Request["category"]',
|
|
stimeTH: '@Request["stimeTH"]',
|
|
etimeTH: '@Request["etimeTH"]',
|
|
stimeGD: '@Request["stimeGD"]',
|
|
etimeGD: '@Request["etimeGD"]',
|
|
stimeKT: '@Request["stimeKT"]',
|
|
etimeKT: '@Request["etimeKT"]',
|
|
stimeFP: '@Request["stimeFP"]',
|
|
etimeFP: '@Request["etimeFP"]',
|
|
hasTH: '@Request["hasTH"]',
|
|
hasGD: '@Request["hasGD"]',
|
|
productId: '@Request["productId"]',
|
|
midproductid: '@Request["midproductid"]',
|
|
subproductId: '@Request["subproductId"]',
|
|
extxml: '@Request["extxml"]'
|
|
},function(msg){
|
|
if (msg.Success) {
|
|
window.parent.frameReturnByMes(msg.Message);
|
|
window.parent.CloseDistbuteWin();
|
|
}
|
|
else
|
|
$.messageBox5s('提示', msg.Message);
|
|
});
|
|
}
|
|
|
|
//计算剩余可分配数
|
|
function caclnums() {
|
|
var box = $("#tblUsers input[type=checkbox]");
|
|
var sum = 0;
|
|
box.each(function () {
|
|
//console.log($(this));
|
|
var n = $(this).parent().next().children()[0];
|
|
//if ($(this)[0].checked) {
|
|
// if (!re.test(n.value)) {
|
|
// n.value = "";
|
|
// }
|
|
// else
|
|
// sum += parseInt(n.value);
|
|
//}
|
|
//else
|
|
// n.value = "";
|
|
if (!re.test(n.value)) {
|
|
n.value = "";
|
|
}
|
|
else {
|
|
sum += parseInt(n.value);
|
|
$(this)[0].checked = true;
|
|
}
|
|
});
|
|
var total = @total;
|
|
//var rdtype = $("input[name=rdtype]:checked").val();
|
|
//if (rdtype == "1") {//按比例分配
|
|
// $("#lblNum").html(parseInt((100 - sum) / 100 * total));
|
|
//} else {
|
|
$("#lblNum").html(total - sum);
|
|
//}
|
|
if (parseInt($("#lblNum").html()) < 0) {
|
|
$("#save").hide();
|
|
$("#wait").val("提交").show();
|
|
$("#lblNum").html("<font color='red'>没有足够的资源,请重新分配</font>");
|
|
}
|
|
else {
|
|
$("#wait").val("正在提交...").hide();
|
|
$("#save").show();
|
|
}
|
|
}
|
|
|
|
function ckNums(obj) {
|
|
//console.log($(obj).is(':checked'));
|
|
var ck = $(obj).is(':checked');
|
|
if (!ck) {
|
|
//如果没有选中,就清空后面的数量,并重新计算
|
|
var inp = $(obj).parent().next().children()[0];
|
|
//console.log(inp);
|
|
inp.value = "";
|
|
}
|
|
caclnums();
|
|
}
|
|
|
|
$(function() {
|
|
$("#category").change(function () {
|
|
var c = this.value;
|
|
$("#tblUsers select").each(function(i, j) {
|
|
//console.log(j);
|
|
$(j).val(c);
|
|
});
|
|
});
|
|
|
|
$("#tblUsers input[type=text]").focus(function () {
|
|
$(this).css("border", "");
|
|
});
|
|
});
|
|
|
|
</script> |