var edit_id = helper.request.queryString("edit_id");
$(function() {
// //获取所属行业//获取税务类别//获取客户信誉等级
// $.when(helper.getDropList.getlistDropByDic($('#customer_subtrade'), 'KHSSHY'),
// helper.getDropList.getlistDropByDic($('#customer_taxCategory'), 'SWLB'),
// helper.getDropList.getlistDropByDic($('#customer_layer'), 'KHLayer'))
// .done(function() {
if (edit_id) {
getCustomer(edit_id);
}
$('.project_save').click((function(){
addedit_customer(edit_id)
}))
// });
});
//点击显示
$("#customer_taxPointDes").change(function(){
if($("#customer_taxPointDes").find("option:selected").text()=="二级商"){
$("#bbb").show()
}else{
$("#bbb").hide()
}
// $(this).find("option").each(function(){
// if ($(this).prop("selected")) {
// $("#bbb"+$(this).val()).show()
// } else {
// $("#bbb"+$(this).val()).hide()
// }
// })
})
$("#customer_taxPointDes").change(function(){
if($("#customer_taxPointDes").find("option:selected").text()=="种田大户"){
$("#ccc").show()
}else{
$("#ccc").hide()
}
})
$("#customer_feeEx").change(function(){
if($("#customer_feeEx").find("option:selected").text()=="其他"){
$("#ddd").show()
}else{
$("#ddd").hide()
}
})
$("#customer_Qualification").change(function(){
if($("#customer_Qualification").find("option:selected").text()=="其他"){
$("#eee").show()
}else{
$("#eee").hide()
}
})
//获取详情
function getCustomer(ids) {
$.getJSON(huayi.config.callcenter_url + "CustomerNew/GetCustomer", {
cusid: ids, //id
token: $.cookie("token")
}, function(data) {
if (data.state.toLowerCase() == "success") {
data = data.data;
if (data) {
$('#customer_code').val(data.F_CustomerCode);
$('#customer_companyname').val(data.F_CompanyName);
$('#customer_comaddress').val(data.F_AreaID);
$('#customer_legalName').val(data.F_BranchID);
$('#customer_lehalTel').val(data.F_Salesman);
$('#customer_subtrade').val(data.F_SalesPhone);
$('#customer_taxCategory').val(data.F_CustomerNature);
$('#customer_taxPointDes').val(data.F_Channel);
$('#customer_invoiceRange').val(data.F_Credit);
$('#customer_layer').val(data.F_Legal);
$('#customer_bedept').val(data.F_LegalPhone);
$('#source').val(data.F_AddressProvince);
$('#type').val(data.F_AddressCity);
$('#keyid').val(data.F_AddressCountry);
$('#input_area').val(data.F_AddressTownship);
$('#customer_LegalIDCards').val(data.F_AddressFull);
$('#customer_Qualification').val(data.F_Brands);
$('#customer_FinancialManager').val(data.F_Product);
$('#customer_BusinessOwner').val(data.F_FrozenFlag);
$('#customer_isbankSlips').val(data.F_IsOpenAccount);
$('#customer_Remark2').val(data.F_LevelCode);
$('#customer_Remark3').val(data.F_LevelName);
$('#customer_service').val(data.F_MnemonicCode);
$('#customer_handoverDate').val(data.F_InvoiceBank);
$('#customer_address').val(data.F_InvoiceBankAccount);
$('#customer_address1').val(data.F_TaxRegCode);
$('#customer').val(data.F_IsRunXLX);
$('#customer_address2').val(data.F_AnnualSales);
$('#customer_address3').val(data.F_Formula);
$('#customer_address4').val(data.F_RaiseCrops);
$('#customer_feeExpires').val(data.F_PlantingArea);
$('#customer_feeEx').val(data.F_FertilizerBrand);
// if(data.F_BusContent){
// $('#bus_content').html(decodeURIComponent(data.model.F_BusContent));// string 物料内容
// }else{
// $('#bus_content').text('暂无内容。。。');
// }
$('#F_Remark').html(helper.filter.content(data.F_Remark));// string 备注
}
}
// alert(111111111111111);
});
}
//修改保存
function addedit_customer(editId) {
$.post(huayi.config.callcenter_url + "CustomerNew/Update", {
F_CustomerId:editId,
F_MaterialCode: $("#F_MaterialCode").val(),//物料编码
F_CustomerCode: $('#customer_code').val(),
F_CompanyName: $('#customer_companyname').val(),
F_AreaName: $('#customer_comaddress').val(),
F_BranchName: $('#customer_legalName').val(),
F_Salesman:$('#customer_lehalTel').val(),
F_SalesPhone:$('#customer_subtrade').val(),
F_CustomerNature:$('#customer_taxCategory').val(),
F_Channel:$('#customer_taxPointDes').val(),
F_Credit:$('#customer_invoiceRange').val(),
F_Legal:$('#customer_layer').val(),
F_LegalPhone:$('#customer_bedept').val(),
F_AddressProvince:$('#source').val(),
F_AddressCity:$('#type').val(),
F_AddressCountry:$('#keyid').val(),
F_AddressTownship:$('#input_area').val(),
F_AddressFull:$('#customer_LegalIDCards').val(),
F_Brands:$('#customer_Qualification').val(),
F_Product:$('#customer_FinancialManager').val(),
F_FrozenFlag:$('#customer_BusinessOwner').val(),
F_IsOpenAccount:$('#customer_isbankSlips').val(),
F_LevelCode:$('#customer_Remark2').val(),
F_LevelName:$('#customer_Remark3').val(),
F_MnemonicCode:$('#customer_service').val(),
F_InvoiceBank:$('#customer_handoverDate').val(),
F_InvoiceBankAccount:$('#customer_address').val(),
F_TaxRegCode:$('#customer_address1').val(),
F_IsRunXLX:$('#customer').val(),
F_Gender:$('#gender').val(),//男女
F_AnnualSales:$('#customer_address2').val(),
F_Formula:$('#customer_address3').val(),
F_RaiseCrops:$('#customer_address4').val(),
F_PlantingArea:$('#customer_feeExpires').val(),
F_FertilizerBrand:$('#customer_feeEx').val(),
F_Remark:$('#F_Remark').val(),
token: $.cookie("token")
}, function(result) {
result = $.parseJSON(result);
if(result.state.toLowerCase() == "success") {
debugger
var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
parent.layer.close(index); //再执行关闭
parent.$('#cusList').bootstrapTable('refresh');
parent.layer.msg("修改成功");
top.workcount();
}
})
}
$(document).ready(function () {
var wid = helper.request.queryString("wid");
LAISHENG($("#source"));//省
CHOUDQ($("#customer_comaddress"));//大区
QDLX($("#customer_taxPointDes"));//渠道类型
XYDJ($("#customer_invoiceRange"));//信用等级
JYPP($("#customer_Qualification"));//经营品牌
CAPI($("#customer_FinancialManager"));//产品
YFPP($("#customer_feeEx"));//用肥品牌
});
function YFPP(obj) {
obj.empty();
obj.append('');
$.getJSON(huayi.config.callcenter_url + "Dictionary/GetDicValueListByFlag", {
"token": $.cookie("token"),
flag:"YFPP",
}, function (data) {
if (data.state.toLowerCase() == "success") {
var content = data.data;
$(content).each(function (i, n) {
$("").appendTo(obj);
})
}
})
}
// 省/市/区/县
function LAISHENG(obj) {
obj.empty();
obj.append('');
$.getJSON(huayi.config.callcenter_url + "RegionCategory/GetAllList", {
"token": $.cookie("token"),
F_Layer: 1,
}, function (data) {
if (data.state.toLowerCase() == "success") {
var content = data.data;
$(content).each(function (i, n) {
$("").appendTo(obj);
})
}
})
}
//市
function LAISHI(obj) {
obj.empty();
obj.append('');
$.getJSON(huayi.config.callcenter_url + "RegionCategory/GetAllList", {
"token": $.cookie("token"),
F_Layer: 2,
F_RegionName:$('#source').val()
}, function (data) {
if (data.state.toLowerCase() == "success") {
var content = data.data;
$(content).each(function (i, n) {
$("").appendTo(obj);
})
}
})
}
// 区/县
function LAIQU(obj) {
obj.empty();
obj.append('');
$.getJSON(huayi.config.callcenter_url + "RegionCategory/GetAllList", {
"token": $.cookie("token"),
F_Layer: 3,
F_RegionName:$('#type').val()
}, function (data) {
if (data.state.toLowerCase() == "success") {
var content = data.data;
$(content).each(function (i, n) {
$("").appendTo(obj);
})
}
})
}
// 乡
function LAIXIANG(obj) {
obj.empty();
obj.append('');
$.getJSON(huayi.config.callcenter_url + "RegionCategory/GetAllList", {
"token": $.cookie("token"),
F_Layer: 4,
F_RegionName:$('#keyid').val()
}, function (data) {
if (data.state.toLowerCase() == "success") {
var content = data.data;
$(content).each(function (i, n) {
$("").appendTo(obj);
})
}
})
}
$('#source').on('change',function(){
$.getJSON(huayi.config.callcenter_url + "RegionCategory/GetAllList", {
"token": $.cookie("token"),
F_Layer: 2,
F_RegionName:$('#source').val(),
}, function (data) {
if (data.state.toLowerCase() == "success") {
var content = data.data;
$(content).each(function (i, n) {
$("").appendTo("#type");
})
LAISHI($("#type"));
}
})
});
$('#type').on('change',function(){
$.getJSON(huayi.config.callcenter_url + "RegionCategory/GetAllList", {
"token": $.cookie("token"),
F_Layer: 3,
F_RegionName:$('#type').val()
}, function (data) {
if (data.state.toLowerCase() == "success") {
var content = data.data;
$(content).each(function (i, n) {
$("").appendTo("#keyid");
})
LAIQU($("#keyid"));
}
})
});
$('#keyid').on('change',function(){
$.getJSON(huayi.config.callcenter_url + "RegionCategory/GetAllList", {
"token": $.cookie("token"),
F_Layer: 4,
F_RegionName:$('#keyid').val()
}, function (data) {
if (data.state.toLowerCase() == "success") {
var content = data.data;
$(content).each(function (i, n) {
$("").appendTo("#input_area");
})
LAIXIANG($('#input_area'));
}
})
});
function CHOUDQ(obj) {
obj.empty();
obj.append('');
$.getJSON(huayi.config.callcenter_url + "Department/GetList", {
"token": $.cookie("token"),
F_Layer: 1,
}, function (data) {
if (data.state.toLowerCase() == "success") {
var content = data.data;
$(content).each(function (i, n) {
$("").appendTo(obj);
})
}
})
}
function CHOUFEN(obj) {
obj.empty();
obj.append('');
$.getJSON(huayi.config.callcenter_url + "Department/GetList", {
"token": $.cookie("token"),
F_Layer:2,
F_DeptName:$("#customer_comaddress").find("option:selected").text(),
}, function (data) {
if (data.state.toLowerCase() == "success") {
var content = data.data;
$(content).each(function (i, n) {
$("").appendTo(obj);
})
}
})
}
$('#customer_comaddress').on('change',function(){
$.getJSON(huayi.config.callcenter_url + "Department/GetList", {
"token": $.cookie("token"),
F_Layer: 2,
F_DeptName:$("#customer_comaddress").find("option:selected").text(),
}, function (data) {
if (data.state.toLowerCase() == "success") {
var content = data.data;
$(content).each(function (i, n) {
$("").appendTo("#customer_legalName");
})
CHOUFEN($('#customer_legalName'));
}
})
});
//渠道类型
function QDLX(obj) {
obj.empty();
obj.append('');
$.getJSON(huayi.config.callcenter_url + "Dictionary/GetDicValueListByFlag", {
"token": $.cookie("token"),
flag:"QDLX",
}, function (data) {
if (data.state.toLowerCase() == "success") {
var content = data.data;
$(content).each(function (i, n) {
$("").appendTo(obj);
})
}
})
}
//信用等级
function XYDJ(obj) {
obj.empty();
obj.append('');
$.getJSON(huayi.config.callcenter_url + "Dictionary/GetDicValueListByFlag", {
"token": $.cookie("token"),
flag:"XYDJ",
}, function (data) {
if (data.state.toLowerCase() == "success") {
var content = data.data;
$(content).each(function (i, n) {
$("").appendTo(obj);
})
}
})
}
//经营品牌
function JYPP(obj) {
obj.empty();
obj.append('');
$.getJSON(huayi.config.callcenter_url + "Dictionary/GetDicValueListByFlag", {
"token": $.cookie("token"),
flag:"JYPP",
}, function (data) {
if (data.state.toLowerCase() == "success") {
var content = data.data;
$(content).each(function (i, n) {
$("").appendTo(obj);
})
}
})
}
//产品
function CAPI(obj) {
obj.empty();
obj.append('');
$.getJSON(huayi.config.callcenter_url + "Dictionary/GetDicValueListByFlag", {
"token": $.cookie("token"),
flag:"CAPI",
}, function (data) {
if (data.state.toLowerCase() == "success") {
var content = data.data;
$(content).each(function (i, n) {
$("").appendTo(obj);
})
}
})
}