Anthony

顾客评级模块化

define(function() {
define(['i18n!accountset/nls/resource', 'cls', 'base/index', 'index/index'], function (resource, Class, base, indexlayout) {
return {
resource:resource,
init : function(actId,isMember,flag,rakIndex) {
var panel = getSelectedPanel();
var panel = indexlayout.getSelectedPanel();
var page = panel.children(".crm-rank-detail").show().layout({fit:true});
var button = initButton();// 初始化按钮
var rankForm = page.find(".custLevelDetail").find(".custLevelAddForm");
var rankWindow = page.find(".custLevelDetail");
initValidateboxForm();//验证
var chkValidate=initValidate();
initOptionLevel();
......@@ -131,7 +131,7 @@ define(function() {
data:{scope:"RATED"},
async:false,//同步
success:function(result) {
if(responseUtils(result)){
if($.response(result)){
for(var i=0;i<result.list.length;i++){
page.find(".colNamesSelect").append("<option value='"+result.list[i].fldSql+"'>"+result.list[i].fldName+"</option>")
}
......@@ -164,7 +164,7 @@ define(function() {
ratDays:rankForm.find(".ratDays").val(),
rakExpiry:rankForm.find(".rakExpiry").val()
}, function(result){
if(responseUtils(result)){
if($.response(result)){
closeAndRefresh();
}
});
......@@ -183,7 +183,7 @@ define(function() {
ratDays:rankForm.find(".ratDays").val(),
rakExpiry:rankForm.find(".rakExpiry").val()
}, function(result){
if(responseUtils(result)){
if($.response(result)){
closeAndRefresh();
}
});
......@@ -191,7 +191,7 @@ define(function() {
}
function closeAndRefresh(){
closeSelectedPanel();
indexlayout.closeSelectedPanel();
var levelQuery="d02d277c-a662-4298-8fba-a98e815cc243";
//8c00b574-cdc7-4ade-b471-6599f5cceeee
//c1612bd8-0b0d-449b-976c-f790a1998f71
......@@ -204,14 +204,16 @@ define(function() {
var button = panel.find(".button");
button.rs_toolbar({
buttons:[{
text:resource.btn.submit,
text:base.resource.btn.submit,
iconCls:'btn-submit submit-condition',
handler:submitBtn
}],
tools:[{
text:resource.btn.refresh,
text:base.resource.btn.refresh,
iconCls:'btn-refresh',
handler:panelRefreshUtils
handler:function() {
indexlayout.getSelectedPanel().panel("refresh");
}
}],
content:button.children('div.custLevelDetail')
});
......@@ -327,7 +329,7 @@ define(function() {
//验证顾客等级是否重名字的方法
function isRepetitionName(){
$.JSON("./accountSetDetail/isRepetitionName.json",{rakName:rankForm.find(".rakName").val(),actId:actId}, function(result){
responseUtils(result)
$.response(result)
});
}
......@@ -335,7 +337,7 @@ define(function() {
//验证顾客等级代号是否重名字的方法
function isRepetitionRakId(){
$.JSON("./accountSetDetail/isRepetitionRakId.json",{rakId:rankForm.find(".rakId").val(),actId:actId}, function(result){
responseUtils(result)
$.response(result)
});
}
......
define(function() {
define(['i18n!accountset/nls/resource', 'cls', 'base/index', 'index/index'], function (resource, Class, base, indexlayout) {
return {
resource:resource,
init : function(actId,usId){
//页面初始化
var panel = getSelectedPanel();
var page = panel.children(".crm-accountset-detail").show().layout({fit:true});
var panel = indexlayout.getSelectedPanel();
var page = panel.children(".crm-accountset-detail").layout({fit:true});
var levelQuery="d02d277c-a662-4298-8fba-a98e815cc243";
var levelCondition="8c00b574-cdc7-4ade-b471-6599f5cceeee";
page.layout("panel","center").children('.easyuiTabs').tabs({fit:true});
......@@ -13,7 +14,6 @@ define(function() {
var custDiscountDialog = initSetCustDiscountDialog();//初始化顾客消费优惠折数
var custDiscountDatagrid = initSetCustDiscountDatagrid();//优惠折数datagrid
var isMember=panel.find(".isMember").val();
initValidateboxForm();//验证
var initLevelName = initLevelName();
panel.find(".isMember").combobox({
onChange:function(newValue){
......@@ -35,7 +35,7 @@ define(function() {
if(panel.find("input[name='ratName']").val()!=""){
updateRatName();
}else{
$.messager.alert(resource.msg_title, "评级名称不能为空!");
$.messager.alert(base.resource.msg_title, "评级名称不能为空!");
}
}); // 验证评级名称
......@@ -71,13 +71,13 @@ define(function() {
isMember:isMember,
isFans:isFans
}, function(result){
if(responseUtils(result)){
if($.response(result)){
panel.find(".setCustDiscountForm").find("input[name='actId']").val(ratingId);
datagridReload();
}
});
}else{
$.messager.alert(resource.msg_title, "请先选择CRM账套再操作!");
$.messager.alert(base.resource.msg_title, "请先选择CRM账套再操作!");
}
}
......@@ -90,10 +90,10 @@ define(function() {
actId:ratingId,
ratName:ratingName
}, function(result){
responseUtils(result)
$.response(result)
});
}else{
$.messager.alert(resource.msg_title, "请先选择CRM账套再操作!");
$.messager.alert(base.resource.msg_title, "请先选择CRM账套再操作!");
}
}
......@@ -126,28 +126,30 @@ define(function() {
function initcustLevelDatagrid(){
return panel.find(".custlevel").datagrid({
toolbar:$('<div class="clearfix"></div>').rs_toolbar({
authz:getAuthzUtils('customerRank'),
authz:base.getAuthz('customerRank'),
buttons:[
{
code:'add',
text:resource.btn.add,
text:base.resource.btn.add,
iconCls:'btn-add',
handler: addCustLevelDialog
},{
code:'edit',
text:resource.btn.edit,
text:base.resource.btn.edit,
iconCls:'btn-edit',
handler:editCustLevelDialog
},{
code:'delete',
text:resource.btn.remove,
text:base.resource.btn.remove,
iconCls:'btn-remove',
handler: removeCustLevelSubmit
}],
tools:[{
text:resource.btn.refresh,
text:base.resource.btn.refresh,
iconCls:'btn-refresh',
handler:panelRefreshUtils
handler:function() {
indexlayout.getSelectedPanel().panel("refresh");
}
}]
}),
url:"./query/"+levelQuery+".json?"+levelCondition+"="+actId,
......@@ -194,44 +196,44 @@ define(function() {
if(thisActId!=null&&thisActId!=""){
url = "./accountSetDetail/customerLevelInit?rankId="+rankId+"&actId="+thisActId+"&rankIndex="+rakIndex+"&flag=0&isMember="+isMember;
showTabUtils({text:"新增顾客评级页面",url:url}, true, function(){});
indexlayout.showPanel({text:"新增顾客评级页面",url:url}, true, function(){});
}else{
$.messager.alert(resource.msg_title, "请先选择CRM账套再操作!");
$.messager.alert(base.resource.msg_title, "请先选择CRM账套再操作!");
}
}
//弹出编辑顾客等级页面方法
function editCustLevelDialog(){
var row = selectRow();
if(row == null){
$.messager.alert(resource.msg_title, resource.msgEditTip);
$.messager.alert(base.resource.msg_title, base.resource.msgEditTip);
}else{
var thisActId=panel.find("input[name='actId']").val();
if(thisActId!=null&&thisActId!=""){
url = "./accountSetDetail/customerLevelInit?rankId="+row.rakId+"&actId="+row.actId+"&rankIndex="+row.rakIndex+"&flag=1&isMember="+isMember;
showTabUtils({text:"编辑顾客评级页面",url:url}, true, function(){});
indexlayout.showPanel({text:"编辑顾客评级页面",url:url}, true, function(){});
}else{
$.messager.alert(resource.msg_title, "请先选择CRM账套再操作!");
$.messager.alert(base.resource.msg_title, "请先选择CRM账套再操作!");
}
}
}
//验证顾客等级是否重名字的方法
function isRepetitionName(){
$.JSON("./accountSetDetail/isRepetitionName.json",{rakName:repeCustName.val(),actId:repeCustName.next().val()}, function(result){
responseUtils(result)
$.response(result)
});
}
//删除顾客等级的方法
function removeCustLevelSubmit(){
var row = selectRow();
if(row == null){
$.messager.alert(resource.msg_title, resource.msgRemoveTip);
$.messager.alert(base.resource.msg_title, base.resource.msgRemoveTip);
}else if(row.RAK_INDEX==1){
$.messager.alert(resource.msg_title, resource.accountset.deleteRank);
$.messager.alert(base.resource.msg_title, resource.accountset.deleteRank);
}else{
$.messager.confirm(resource.msg_title, resource.confirmDelete, function(result) {
$.messager.confirm(base.resource.msg_title, base.resource.confirmDelete, function(result) {
if(result){
$.JSON("./accountSetDetail/removeCustRank.json",row,function(r){
if(responseUtils(r)){
if($.response(r)){
datagridReload();
}
});
......@@ -247,14 +249,14 @@ define(function() {
setUpgrade.dialog({
buttons : [
/* {
text : resource.btn.discount,
text : base.resource.btn.discount,
handler : editCustDiscount
},*/
{
text : resource.btn.confirm,
text : base.resource.btn.confirm,
handler : updateConfim
}, {
text : resource.btn.cancel,
text : base.resource.btn.cancel,
handler :hideWindow
}],
......@@ -272,10 +274,10 @@ define(function() {
editDiscount.find("span[name='remove-row']").unbind("remove-row").bind("click.remove-row", removeEditDiscount);
editDiscount.dialog({
buttons : [ {
text : resource.btn.confirm,
text : base.resource.btn.confirm,
handler : confirmEditDiscount
}, {
text : resource.btn.cancel,
text : base.resource.btn.cancel,
handler :function(){
editDiscountDialog.dialog("close");
}
......@@ -310,14 +312,14 @@ define(function() {
function removeEditDiscount(){
var array = editDiscountDialog.find(".add-discount").length;
if(array>1){
$.messager.confirm(resource.msg_title, '你确定要删除最后一行吗?', function(result) {
$.messager.confirm(base.resource.msg_title, '你确定要删除最后一行吗?', function(result) {
if(result){
$("#"+array).remove();
$("#"+(array-1)).find("input:last").removeAttr("readonly");
}
});
}else{
$.messager.alert(resource.msg_title, "至少保留一行!");
$.messager.alert(base.resource.msg_title, "至少保留一行!");
}
}
//设置顾客等级消费折数
......@@ -332,7 +334,7 @@ define(function() {
//根据查询条件动态修改列样式
function initDiscount(){
$.post("./policyDiscount/query.json",custDiscountDialog.find(".setCustDiscountForm").serialize(), function(result){
if(responseUtils(result)){
if($.response(result)){
var dynamicColumns=[];
var total=0;
for (var i = 0; i < result.list.length; i++) {
......@@ -431,7 +433,7 @@ define(function() {
};
//先去删除然后在进行添加
$.JSON("./discountItem/update.json",param, function(result){
if(responseUtils(result)){
if($.response(result)){
editDiscountDialog.dialog('close');
custDiscountDialog.find(".datagrid").find(".datagrid-toolbar").empty();
initDiscount();
......@@ -470,9 +472,9 @@ define(function() {
rakId:custDiscountDialog.find(".setCustDiscountForm").find(".rakId").val()
};
$.JSON("./policyDiscount/queryBrIds.json",param,function(result){
if(responseUtils(result)){
if($.response(result)){
console.log('-----------fromDB_brIdArr = '+result.value.brIds);
showCondObject({id:"dff2379d-5995-40d2-8d28-6c835ecdd955",showGrid:true, singleSelect:false,onBeforeLoad:function(params){
base.showCondObject({id:"dff2379d-5995-40d2-8d28-6c835ecdd955",showGrid:true, singleSelect:false,onBeforeLoad:function(params){
var params;
params["aa3c85d3-e1e0-4b33-bf13-941fec1a8d92"]=panel.find("input[name='actId']").val(); // 当前账套ID
return params;
......@@ -508,7 +510,7 @@ define(function() {
list:list
}
$.JSON("./applyBrand/addBrand.json",pamra,function(result){
responseUtils(result);
$.response(result);
initDiscount();
});
}
......@@ -526,7 +528,7 @@ define(function() {
editDiscountDialog.find(".rakId").val(rakId);
editDiscountDialog.find(".actId").val(panel.find(".actId").val());
$.post("./discountItem/query.json",rows[0], function(result){
if(responseUtils(result)){
if($.response(result)){
editDiscountDialog.find(".dialog-form").children("div:not(:first)").remove();
var _len = result.list.length;
for(var i=0;i<_len;i++){
......@@ -557,7 +559,7 @@ define(function() {
}
});
}else{
$.messager.alert(resource.msg_title, '请先增加一条行数据!');
$.messager.alert(base.resource.msg_title, '请先增加一条行数据!');
}
}
//添加折数带(行)
......@@ -581,13 +583,13 @@ define(function() {
discountItemList:discountItemList
}
$.JSON("./policyDiscount/uptate.json",param, function(r){
if(responseUtils(r)){}
if($.response(r)){}
});
}
}
$.post("./policyDiscount/create.json",custDiscountDialog.find(".setCustDiscountForm").serialize(), function(result){
if(responseUtils(result)){
if($.response(result)){
custDiscountDialog.find(".datagrid").find(".datagrid-toolbar").empty();
initDiscount();
}
......@@ -597,12 +599,12 @@ define(function() {
function removeCustDiscountRow(){
var custDiscount = custDiscountDatagrid.datagrid('getSelected');
if(custDiscount == null){
$.messager.alert(resource.msg_title, resource.msgRemoveTip);
$.messager.alert(base.resource.msg_title, base.resource.msgRemoveTip);
}else{
$.messager.confirm(resource.msg_title, resource.confirmDelete, function(result) {
$.messager.confirm(base.resource.msg_title, base.resource.confirmDelete, function(result) {
if(result){
$.JSON("./policyDiscount/remove.json",custDiscount, function(r){
if(responseUtils(r)){
if($.response(r)){
custDiscountDialog.find(".datagrid").find(".datagrid-toolbar").empty();
initDiscount();
}
......@@ -633,7 +635,7 @@ define(function() {
discountItemList:discountItemList
}
$.JSON("./policyDiscount/uptate.json",param, function(r){
if(responseUtils(r)){
if($.response(r)){
custDiscountDialog.find(".datagrid").find(".datagrid-toolbar").empty();
initDiscount();
}
......