///
$(function () {
//下拉菜单
selectHelper.GetSelect({
url: "/Teacher/Value/GetFinancialTypeList",
Id: "#selectFinancialType",
value: "全部"
});
//列表
GetList("", "");
//搜索
$("#btnSearch").unbind("click").click(function () {
//获取查询条件
var TypeId = "";
var KeyWord = "";
var type = $("#selectFinancialType").val();
if (parseInt(type) != 0) {
TypeId = type;
}
var key = $.trim($("#txtKeyWord").val()).replace(/[<>&"]/g, function (c) { return { '<': '<', '>': '>', '&': '&', '"': '"', '"': '"', "'": '′', "'": '′' }[c]; });
if (key == "客户姓名/身份证号")
{ key = ""; }
if (key != null && key != "" && key.length > 0) {
KeyWord = key;
}
GetList(TypeId, KeyWord);
});
$("#txtKeyWord").unbind("focus").focus(function ()
{
$("#txtKeyWord").val("").css("color", "black");
});
});
/**
* @name 获取案例列表
*/
function GetList(TypeId, KeyWord) {
pageHelper.Init({
url: "/Teacher/Case/CaseList",
type: "POST",
pageDiv: "#CasePage",
data:
{
FinancialTypeId: TypeId,
KeyWords: KeyWord,
rId: Math.random()
},
bind: function (data) {
var html = "";
$(data.Data).each(function (index, dom) {
//每行html
var trHtml = "";
trHtml += "
";
trHtml += "{0} | ";
trHtml += "{1} | ";
trHtml += "{2} | ";
trHtml += "{3} | ";
trHtml += "{4} | ";
trHtml += "{5} | ";
trHtml += "";
trHtml += "查看";
if (dom.CaseSource != EnumList.CaseSource.System) {
trHtml += "编辑";
}
trHtml += "删除";
trHtml += " | ";
trHtml += "
";
//拼接tbody
html += StringHelper.FormatStr(trHtml,
((data.PageIndex - 1) * data.PageSize + index + 1), //0 序号
dom.CustomerName, //1 客户姓名
dom.IDNum, //2 身份证号
dom.strFinancialType, //3 理财类型
dom.strCaseSource, //4 来源
dom.strCreateDate, //5 创建日期
dom.Id, //6 Id
dom.CaseSource //7 来源Id
);
});
$("#caseList").html(html);
}
});
}
/**
* @name 修改案例
*/
function EditCase(id) {
var flg = CheckCaseByUsed(id);
if (flg) {
dialogHelper.Error({
content: "不能编辑,该案例已被待发布的销售机会或实训考核引用"
});
return;
}
location.href = "/Teacher/Case/EditCase?Id=" + id + "&Status=Edit";
}
/**
* @name 查看案例
*/
function ViewCase(id) {
location.href = "/Teacher/Case/EditCase?Id=" + id + "&Status=View";
}
/**
* @name 删除案例
*/
function DelCase(id, source) {
//弹出确认框
dialogHelper.Confirm({
content: "确定删除该案例?",
success: function () {
var flg = CheckCaseByUsed(id);
if (flg) {
dialogHelper.Error({
content: "不能删除,该案例已被待发布的销售机会或实训考核引用"
});
return;
}
if (parseInt(source) == EnumList.CaseSource.System) {
//内置
$.ajax({
url: "/Teacher/Case/HiddenCase",
type: "POST",
async: true,
dataType: "json",
data:
{
Id: id,
rId: Math.random()
},
success: function (data) {
dialogHelper.Success({
content: "删除成功!",
success: function () {
//刷新当前页
location.href = location.href;
}
});
}
});
} else {
//自定义
$.ajax({
url: "/Teacher/Case/DelCase",
type: "POST",
async: true,
dataType: "json",
data:
{
Id: id,
rId: Math.random()
},
success: function (data) {
dialogHelper.Success({
content: "删除成功!",
success: function () {
//刷新当前页
location.href = location.href;
}
});
}
});
}
}
})
}
//检查案列是否被用在未发布的销售机会/实训中,编辑和删除前需要判断
function CheckCaseByUsed(Id) {
var Flag = false;
$.ajax({
url: "/Teacher/Case/CheckCaseByUsed",
type: "POST",
async: false,
dataType: "json",
data:
{
caseId: Id,
},
success: function (data) {
//刷新当前页
Flag = data
}
});
return Flag;
}