$(function(){
/*@cc_on @*/
window.onerror = function () { return true; }
$.datepicker.regional['zh-CN'] =
{
clearText: '清除', clearStatus: '清除已选日期',
closeText: '关闭', closeStatus: '不改变当前选择',
prevText: '<上月', prevStatus: '显示上月',
nextText: '下月>', nextStatus: '显示下月',
currentText: '今天', currentStatus: '显示本月',
monthNames: ['一月','二月','三月','四月','五月','六月',
'七月','八月','九月','十月','十一月','十二月'],
monthNamesShort: ['一','二','三','四','五','六',
'七','八','九','十','十一','十二'],
monthStatus: '选择月份', yearStatus: '选择年份',
weekHeader: '周', weekStatus: '年内周次',
dayNames: ['星期日','星期一','星期二','星期三','星期四','星期五','星期六'],
dayNamesShort: ['周日','周一','周二','周三','周四','周五','周六'],
dayNamesMin: ['日','一','二','三','四','五','六'],
dayStatus: '设置 DD 为一周起始', dateStatus: '选择 m月 d日, DD',
dateFormat: 'yy-mm-dd', firstDay: 1,
initStatus: '请选择日期', isRTL: false
};
$.datepicker.setDefaults($.datepicker.regional['zh-CN']);
$('.form_datetime').datepicker({
inline: true,
dateFormat:'yy-mm-dd'
});
$('.date').datepicker({
inline: true,
dateFormat:'yy-mm-dd'
});
$('a').removeAttr('title');
$(".modal").draggable({ handle: ".modal-header" });
$('#country_code').focusout(function(){
var country_code = $('#country_code').val();
if(country_code != '' && country_code != null && country_code != undefined)
{
$.ajax({
type: "POST",
//async:false, // 设置同步方式
//cache:false,
url: "/order/Order/ShowCountrySlide",
data:{'index':country_code,'type':3},
success: function(data){
$('#show_centent').html(data);
}
});
}
});
earlyWarning();
});
function imgPreview()
{
$('ul#third li a').imgPreview({
containerID: 'imgPreviewWithStyles',
imgCSS: {
width: 300,
zoom:1000
},
onShow: function(link){
$(link).stop().animate({opacity:0.4});
$('img', this).stop().css({opacity:0});
},
onLoad: function(){
$(this).animate({opacity:1},300);
},
onHide: function(link){
$(link).stop().animate({opacity:1});
}
});
}
function login(id,url)
{
if(id =='exprot_us'){
$('#create_recharge_form').attr("action",url);
}
$('#'+id).modal('toggle');
}
function earlyWarning()
{
$('.status_1').hide();
$('.tr_red').parents('tr').find("td").css({'background':'#fbdbdb'});
$('.tr_price').parents('tr').find("td").css({'background':'#ddfbe6'});
$('.tr_cost').parents('tr').find("td").css({'background':'#e3df7e'});
var product_id = $('#product_id').val();
}
function loginCheck(id)
{
var username = $('#login_username').val();
var password = $('#login_password').val();
if(username == '' || username == null || username == undefined)
{
$(".error_content").text('请输入账号');
$(".alert").show();
$("#login_username").focus();
}else if(password == '' || password == null || password == undefined)
{
$(".error_content").text('请输入密码');
$(".alert").show();
$("#login_password").focus();
}else{
$(".alert").hide();
$('#'+id).submit();
}
}
function show_register_error(id,prompt)
{
$('#info_'+id).css({'display':'none'});
$('#correct_'+id).css({'display':'none'});
$('#error_'+id).html(prompt);
$('#error_'+id).css({'display':'block'});
}
function show_register_info(id,show)
{
$('#info_'+id).css({'display':'block'});
$('#error_'+id).css({'display':'none'});
$("#correct_"+id).css({'display':'none'});
}
function show_register_correct(id)
{
$('#info_'+id).css({'display':'none'});
$('#error_'+id).css({'display':'none'});
$("#correct_"+id).css({'display':'inline'});
}
function len(s) {
var l = 0;
var a = s.split("");
for (var i=0;i < a.length;i++)
{
if ( a[i].charCodeAt(0) < 299) {
l++;
} else {
l+=2;
}
}
return l;
}
function register_verification(id)
{
$("#username").focusin(function(){
show_register_info('username',1);
});
$("#username").focusout(function(){
var username = $('#username').val();
if(username == ""){
show_register_error('username','请输入用户名');
return;
}
if(len(username) < 6)
{
show_register_error('username','用户名长度不得少于6位');
return;
}else{
$.ajax({
type: "POST",
url: "/user/User/CheckUser",
data:{'username':username,'id':id},
beforeSend:showLoading(),
success: function(data){
hideLoading();
if(data ==1)
{
show_register_error('username','名字已存在请重新输入');
return false;
}else
{
show_register_correct('username');
}
}
});
return;
}
});
$("#userID").focusin(function(){
show_register_info('userID',1);
});
$("#userID").focusout(function(){
var userID = $('#userID').val();
if(userID != "")
{
if(len(userID) > 5||len(userID) < 4)
{
show_register_error('userID','用户名ID长必须为4-5位');
return;
}else{
$.ajax({
type: "POST",
url: "/user/User/CheckUserID",
data:{'userID':userID,'id':id},
beforeSend:showLoading(),
success: function(data){
hideLoading()
if(data)
{
$('#userID').val('');
$('#userID').focus();
show_register_error('userID',userID+'用户名ID已存在请重新输入');
return false;
}else
{
show_register_error('userID','');
}
}
});
return;
}
}else
{
show_register_correct('userID');
}
});
$("#password").focusin(function(){
show_register_info('password',1);
});
$("#password").focusout(function(){
var password = $("#password").val();
if(password == ""){
show_register_error('password','请输入密码');
return;
}else{
if(password.length < 4)
{
show_register_error('password','密码长度不得少于4位');
return;
}else{
show_register_correct('password');
}
}
});
$("#confirm_password").focusin(function(){
show_register_info('confirm_password',1);
});
$("#confirm_password").focusout(function(){
var password = $("#password").val();
var confirm_password = $("#confirm_password").val();
if(confirm_password == "")
{
show_register_error('confirm_password','请确认密码');
return;
}else if(confirm_password != password){
show_register_error('confirm_password','两次输入的密码不一致');
return;
}else{
show_register_correct('confirm_password');
}
});
$("#displayName").focusin(function(){
show_register_info('displayName',1);
});
$("#displayName").focusout(function(){
var displayName = $("#displayName").val();
if(displayName == ""){
show_register_error('displayName','请输入联系人');
return;
}else{
//if(len(displayName) < 4)
//{
//show_register_error('displayName','联系人长度不得小于四位字符');
//return;
//}else{
show_register_correct('displayName');
//}
}
});
$("#email").focusin(function(){
show_register_info('email',1);
});
$("#email").focusout(function(){
var email = $("#email").val();
if(email == "")
{
if(!(/^[a-zA-Z0-9_.-]+\@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]{2,3}){1,2}$/.test(email))){
show_register_error('email','请输入正确的邮箱地址');
return;
}else{
show_register_correct('email');
return;
}
}
});
$("#mobile").focusin(function(){
show_register_info('mobile',1);
$("#info_tel").hide();
$("#error_tel").hide();
$('#correct_tel').hide();
});
$("#tel").focusin(function(){
show_register_info('tel',1);
});
$("#mobile").focusout(function(){
var mobile = $("#mobile").val();
if(mobile == ""){
show_register_error('mobile','请输入手机号码');
return;
}else{
//if(!(/^1[3|4|5|8][0-9]\d{4,8}$/.test(mobile))){
//show_register_error('mobile','请输入正确的手机号码');
// return;
//}else{
//if(mobile.length == 11)
//{
show_register_correct('mobile');
//}else{
//show_register_error('mobile','手机号码为11位(数字)');
//return;
//}
//}
}
});
}
function register_submit(type)
{
var username = $('#username').val();
var userID = $('#userID').val();
var password = $("#password").val();
var confirm_password = $("#confirm_password").val();
var displayName = $("#displayName").val();
var email = $("#email").val();
var mobile = $("#mobile").val();
var address = $("#address").val();
if(username == ""){
show_register_error('username','请输入用户名');
return false;
}else if(len(username) < 6)
{
show_register_error('username','用户名长度不得少于6位');
return false;
}else if(password == ""){
show_register_error('password','请输入密码');
return false;
}else{
if(password.length < 4)
{
show_register_error('password','密码长度不得少于4位');
return false;
}else{
show_register_correct('password');
}
}
if(userID != ""&&(len(userID) > 5||len(userID)<4))
{
show_register_error('userID','用户名ID长度为4-5位');
return false;
}
if(type!='update')
{
if(confirm_password == "")
{
show_register_error('confirm_password','请确认密码');
return false;
}else if(confirm_password != password){
show_register_error('confirm_password','两次输入密码不一致');
return false;
}else{
show_register_correct('confirm_password');
}
}
if(displayName == ""){
show_register_error('displayName','请输入联系人');
return false;
}else{
//if(len(displayName) < 4)
//{
//show_register_error('displayName','联系人长度不得小于四位字符');
//return false;
//}else{
show_register_correct('displayName');
//}
}
if(email)
{
if(!(/^[a-zA-Z0-9_.-]+\@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]{2,3}){1,2}$/.test(email)))
{
show_register_error('email','请输入正确的邮箱地址');
return false;
}else if(!mobile){
show_register_error('mobile','请输入手机号码');
return false;
}else{
//if(!(/^1[3|4|5|8][0-9]\d{4,8}$/.test(mobile))){
//show_register_error('mobile','请输入正确的手机号码');
// return false;;
//}else{
//if(mobile.length == 11)
//{
show_register_correct('mobile');
//}else{
//show_register_error('mobile','手机号码为11位(数字)');
//return false;
//}
//}
}
}else if(mobile){
//if(!(/^1[3|4|5|8][0-9]\d{4,8}$/.test(mobile))){
//show_register_error('mobile','请输入正确的手机号码');
// return false;;
//}else{
//if(mobile.length == 11)
//{
show_register_correct('mobile');
//}else{
//show_register_error('mobile','手机号码为11位(数字)');
//return false;
//}
//}
}else{
show_register_error('mobile','请输入手机号码');
return false;
}
return true;
}
function confirm_delete()
{
var url = $('#delete_url').val();
var del_id = $('#del_id').val();
var content_id = $('#content_id').val();
var del_text_name = $('#del_text_name').val();
$.ajax({
type: "POST",
url: url,
data:{'ajax':'ajax'},
success: function(data){
if(data == 'no')
{
$('.not_delete').show();
$('#delete_no_name').text('('+del_text_name+')');
var content = $('.not_delete').html();
var msg;
msg = $.globalMessenger().post({
message: content,
type: 'error',
showCloseButton: true
});
$('.not_delete').hide();
}else if(data == 1)
{
$('#delete_save').show();
$('#delete_content').show();
$('#delete_no_content').hide();
$('#'+del_id).parents('tr:first').fadeOut(1000);
}
}
});
}
function dialog_update(id,url,u_id,u_name,c_order_id)
{
$('#u_url').val(url);
$('#u_id').val(u_id);
$('#u_name').val(u_name);
$('#type').val(type);
if(c_order_id!=null)
$('#c_order_id').text(c_order_id);
$('#'+id).modal('toggle');
}
function confirm_update(type)
{
var url = $('#u_url').val();
var u_id = $('#u_id').val();
var u_name = $('#u_name').val();
var memo = $('#memo').val();
var is_receive = 0;
if($('#is_receive').attr("checked")){
var is_receive = $('#is_receive').val();
}
var is_deliver = 0;
if($('#is_deliver').attr("checked")){
var is_deliver = $('#is_deliver').val();
}
if(memo == '')
{
$(".error_content").text('备注不能为空');
$('.alert').show();
return false;
}else
{
$('.alert').hide();
}
$.ajax({
type: "POST",
url: url,
data:{'ajax':'ajax','memo':memo,'is_receive':is_receive,'is_deliver':is_deliver},
success: function(data){
if(data == 1)
{
if(type==2)
{
$('#'+u_id).parents('tr:first').find('td').eq(12).empty();
$('#'+u_id).parents('tr:first').find('td').eq(12).html('签收');
}else
{
$('#'+u_id).parents('tr:first').find('td').eq(4).empty();
$('#'+u_id).parents('tr:first').find('td').eq(4).html('已完成');
}
$('#'+u_id).css('display','none');
}else
{
if(type==2)
{
if(data == 'is_return')
{
messages(false,'请先填订单的退件原因','error');
}
}else
{
if(data=='is_return')
{
messages(false,'警告:请先填写总单下的订单的退件原因','error');
}
}
}
$('#order_update_list_update').modal('hide');
}
});
}
function dialog(id,url,del_id,del_name,type_id)
{
if(id.indexOf("delete") <= 0){
if(url)
{
$.ajax({
type: "POST",
url: url,
//data:{},
success: function(data){
$('#'+id).html(data);
}
});
}
}else{
$('#delete_url').val(url);
$('#del_id').val(del_id);
$('#del_name').text('('+del_name+')');
$('#content_id').val(id);
$('#del_text_name').val(del_name);
}
$('#'+id).modal('toggle');
}
function sendAddrCheck(id)
{
if(id.indexOf("update") <= 0)
{
var first_name = $('#create_first_name').val();
var zip = $('#create_zip').val();
var cellphone = $('#create_cellphone').val();
var country = $('#create_country').val();
var province = $('#create_province').val();
var city = $('#create_city').val();
var address1 = $('#create_address1').val();
}else{
var first_name = $('#update_first_name').val();
var zip = $('#update_zip').val();
var cellphone = $('#update_cellphone').val();
var country = $('#update_country').val();
var province = $('#update_province').val();
var city = $('#update_city').val();
var address1 = $('#update_address1').val();
}
if(first_name == '' || first_name == null || first_name == undefined)
{
$(".error_content").text('请输入姓名');
$(".alert").show();
$("#create_first_name").focus();
}else if(zip == '' || zip == null || zip == undefined){
$(".error_content").text('请输入邮编');
$(".alert").show();
$("#create_zip").focus();
}else if(cellphone == '' || cellphone == null || cellphone == undefined){
$(".error_content").text('请输入电话');
$(".alert").show();
$("#create_cellphone").focus();
}else if(country == '' || country == null || country == undefined){
$(".error_content").text('请输入国家');
$(".alert").show();
$("#create_country").focus();
}else if(province == '' || province == null || province == undefined){
$(".error_content").text('请输入省/州');
$(".alert").show();
$("#create_province").focus();
}else if(city == '' || city == null || city == undefined){
$(".error_content").text('请输入城市');
$(".alert").show();
$("#create_city").focus();
}else if(address1 == '' || address1 == null || address1 == undefined){
$(".error_content").text('请输入地址1');
$(".alert").show();
$("#create_address1").focus();
}else{
$('#'+id).submit();
}
}
function createProductsCheck(id,index,type)
{
var name = $('#name').val();
var en_name = $('#en_name').val();
var code = $('#code').val();
var type_id = $('#type_id').val();
var currency_id = $('#currency_id').val();
var metric_factors = $('#metric_factors').val();
if(type==1)
{
var str = '产品';
var charter_code = $('#Product_charter_code').val();
}else
{
var Channel_product_id = $('#Channel_product_id').val();
var Channel_supply_id = $('#Channel_supply_id').val();
var charter_code = $('#Channel_charter_code').val();
var str = '渠道';
}
if(name == '' || name == null || name == undefined)
{
$(".error_content").empty();
$(".error_content").text('请填写'+str+'名称');
$('#'+id+' li:eq(0) a').tab('show');
$(".alert").show();
$("#name").focus();
return false;
}else if(name.length < 4)
{
$(".error_content").empty();
$(".error_content").text(str+'名称 太短 (最小值为 4 字符串).');
$('#'+id+' li:eq(0) a').tab('show');
$(".alert").show();
$("#name").focus();
return false;
/*
}else if(en_name == '' || en_name == null || en_name == undefined)
{
$(".error_content").empty();
$(".error_content").text('请填写'+str+'英文名称');
$('#'+id+' li:eq(0) a').tab('show');
$(".alert").show();
$("#en_name").focus();
return false;
}else if(en_name.length < 4)
{
$(".error_content").empty();
$(".error_content").text(str+'英文名称 太短 (最小值为 4 字符串).');
$('#'+id+' li:eq(0) a').tab('show');
$(".alert").show();
$("#en_name").focus();
return false;
*/
}else if(code == '' || code == null || code == undefined)
{
$(".error_content").empty();
$(".error_content").text('请填写'+str+'简码');
$('#'+id+' li:eq(0) a').tab('show');
$(".alert").show();
$("#code").focus();
return false;
}else if(code.length < 4)
{
$(".error_content").empty();
$(".error_content").text(str+'简码 太短 (最小值为 4 字符串).');
$('#'+id+' li:eq(0) a').tab('show');
$(".alert").show();
$("#code").focus();
return false;
}else if(code){
if(type==1)
{
$.ajax({
type: "POST",
url: "/products/Product/VerifyCode",
data:{'value':code},
success: function(data){
if(data == 2)
{
$(".error_content").text(code+'产品简码已存在,请重新填写');
$(".alert").show();
$('#code').focus();
return false;
}else if(type_id == '' || type_id == null || type_id == undefined)
{
$(".error_content").empty();
$(".error_content").text('请选择运输方式');
$('#'+id+' li:eq(0) a').tab('show');
$(".alert").show();
$("#type_id").focus();
return false;
}else if(currency_id == '' || currency_id == null || currency_id == undefined)
{
$(".error_content").empty();
$(".error_content").text('请选择货币类型');
$('#'+id+' li:eq(0) a').tab('show');
$(".alert").show();
$("#currency_id").focus();
return false;
}else if((charter_code == '' || charter_code == null || charter_code == undefined ||charter_code == 0 ||charter_code == '0')&&type==1)
{
$(".error_content").empty();
$(".error_content").text('请选择产品类型');
$('#'+id+' li:eq(0) a').tab('show');
$(".alert").show();
$("#charter_code").focus();
return false;
}else if(index==1)
{
$('#'+id+' li:eq(1) a').tab('show');
$('#'+id+' li:eq(0) a').tab('hide');
}else if(index==2)
{
$('#'+id+' li:eq(1) a').tab('show');
if(metric_factors == '' || metric_factors == null || metric_factors == undefined)
{
if(type_id==1||type_id==4)
{
$(".error_content").empty();
$(".error_content").text('请填写度量因子');
$(".alert").show();
$("#metric_factors").focus();
return false;
}else
{
verify_code(id,type);
$(".alert").hide();
$('#order_create_form').submit();
}
}else if(index==2||type==3)
{
verify_code(id,type);
$(".alert").hide();
$('#order_create_form').submit();
}
}else
{
verify_code(id,type);
$(".alert").hide();
if(index==1)
{
$('#address').show();
$('#basic').hide();
}else if(index==2||type==3)
{
$('#order_create_form').submit();
}
}
}
});
}else{
$.ajax({
type: "POST",
url: "/products/Channel/VerifyCode",
data:{'value':code},
success: function(data){
if(data == 2)
{
$(".error_content").text(code+'产品简码已存在,请重新填写');
$(".alert").show();
$('#code').focus();
return false;
}else if(type_id == '' || type_id == null || type_id == undefined)
{
$(".error_content").empty();
$(".error_content").text('请选择运输方式');
$('#'+id+' li:eq(0) a').tab('show');
$(".alert").show();
$("#type_id").focus();
return false;
}else if(currency_id == '' || currency_id == null || currency_id == undefined)
{
$(".error_content").empty();
$(".error_content").text('请选择货币类型');
$('#'+id+' li:eq(0) a').tab('show');
$(".alert").show();
$("#currency_id").focus();
return false;
}else if((charter_code == '' || charter_code == null || charter_code == undefined ||charter_code == 0 ||charter_code == '0')&&type==1)
{
$(".error_content").empty();
$(".error_content").text('请选择产品类型');
$('#'+id+' li:eq(0) a').tab('show');
$(".alert").show();
$("#charter_code").focus();
return false;
}else if(index==1)
{
$('#'+id+' li:eq(1) a').tab('show');
$('#'+id+' li:eq(0) a').tab('hide');
}else if(index==2)
{
$('#'+id+' li:eq(1) a').tab('show');
if(metric_factors == '' || metric_factors == null || metric_factors == undefined)
{
if(type_id==1||type_id==4)
{
$(".error_content").empty();
$(".error_content").text('请填写度量因子');
$(".alert").show();
$("#metric_factors").focus();
return false;
}else
{
verify_code(id,type);
$(".alert").hide();
$('#order_create_form').submit();
}
}else if(index==2||type==3)
{
verify_code(id,type);
$(".alert").hide();
$('#order_create_form').submit();
}
}else
{
verify_code(id,type);
$(".alert").hide();
if(index==1)
{
$('#address').show();
$('#basic').hide();
}else if(index==2||type==3)
{
$('#order_create_form').submit();
}
}
}
});
}
}else if(type_id == '' || type_id == null || type_id == undefined)
{
$(".error_content").empty();
$(".error_content").text('请选择运输方式');
$('#'+id+' li:eq(0) a').tab('show');
$(".alert").show();
$("#type_id").focus();
return false;
}else if(currency_id == '' || currency_id == null || currency_id == undefined)
{
$(".error_content").empty();
$(".error_content").text('请选择货币类型');
$('#'+id+' li:eq(0) a').tab('show');
$(".alert").show();
$("#currency_id").focus();
return false;
}else if((charter_code == '' || charter_code == null || charter_code == undefined ||charter_code == 0 ||charter_code == '0')&&type==1)
{
$(".error_content").empty();
$(".error_content").text('请选择产品类型');
$('#'+id+' li:eq(0) a').tab('show');
$(".alert").show();
$("#charter_code").focus();
return false;
}else if(index==1)
{
$('#'+id+' li:eq(1) a').tab('show');
$('#'+id+' li:eq(0) a').tab('hide');
}else if(index==2)
{
$('#'+id+' li:eq(1) a').tab('show');
if(metric_factors == '' || metric_factors == null || metric_factors == undefined)
{
if(type_id==1||type_id==4)
{
$(".error_content").empty();
$(".error_content").text('请填写度量因子');
$(".alert").show();
$("#metric_factors").focus();
return false;
}else
{
verify_code(id,type);
$(".alert").hide();
$('#order_create_form').submit();
}
}else if(index==2||type==3)
{
verify_code(id,type);
$(".alert").hide();
$('#order_create_form').submit();
}
}else
{
verify_code(id,type);
$(".alert").hide();
if(index==1)
{
$('#address').show();
$('#basic').hide();
}else if(index==2||type==3)
{
$('#order_create_form').submit();
}
}
$("#basic").show();
$('#'+id+' li:eq('+(index-1)+') a').tab('show');
}
function show_tab_index(id,index)
{
if(index==1)
{
$('#address').show();
$('#basic').hide();
}else if(index==2)
{
$('#address').hide();
$('#basic').show();
}
$('#'+id+' li:eq('+index+') a').tab('show');
}
function createOrderCheck(id,index)
{
var user_ID = $('#user_ID').val();
var quantity = $('#quantity').val();
quantity = 1;
var product_type = $('#product_type').val();
var country = $('#country_id').val();
var product_id = $('#create_product_id').val();
var sender_id = $('#create_sender_id').val();
var buyer_fullname = $('#create_buyer_fullname').val();
var buyer_state = $('#create_buyer_state').val();
var buyer_city = $('#create_buyer_city').val();
var buyer_zip = $('#create_buyer_zip').val();
var buyer_phone_number = $('#create_buyer_phone_number').val();
var buyer_address_1 = $('#create_buyer_address_1').val();
if(id == 'order_update_form'){
var channel_id = $('#create_channel_id').val();
}else{
var channel_id = true;
}
if(index == 1)
{
if(country == '' || country == null || country == undefined)
{
$(".error_content").text('请选择国家');
$(".alert-error").show();
$("#create_country_id").focus();
}else if(product_id == '' || product_id == null || product_id == undefined)
{
$(".error_content").text('请选择货运方式');
$(".alert-error").show();
$("#create_product_id").focus();
}else{
$(".alert-error").hide();
next(id,index);
}
}else if(index == 2)
{
if(buyer_fullname == '' || buyer_fullname == null || buyer_fullname == undefined)
{
$(".error_content").text('请输入收件人姓名');
$(".alert-error").show();
$("#create_buyer_fullname").focus();
}else if(buyer_address_1 == '' || buyer_address_1 == null || buyer_address_1 == undefined)
{
$(".error_content").text('请输入地址');
$(".alert-error").show();
$("#buyer_address_1").focus();
}else if(product_type == 1)
{
if(buyer_city == '' || buyer_city == null || buyer_city == undefined)
{
$(".error_content").text('请输入收件人姓名');
$(".alert-error").show();
$("#create_buyer_city").focus();
}else if(buyer_zip == '' || buyer_zip == null || buyer_zip == undefined)
{
$(".error_content").text('请输入收件人姓名');
$(".alert-error").show();
$("#create_buyer_zip").focus();
}else if(buyer_phone_number == '' || buyer_phone_number == null || buyer_phone_number == undefined)
{
$(".error_content").text('请输入电话或手机号码');
$(".alert-error").show();
$("#create_buyer_phone_number").focus();
}else if(buyer_address_1 == '' || buyer_address_1 == null || buyer_address_1 == undefined)
{
$(".error_content").text('请输入地址1');
$(".alert-error").show();
$("#create_buyer_address_1").focus();
}else{
$(".alert-error").hide();
next(id,index);
}
}else{
$(".alert-error").hide();
next(id,index);
}
}else if(index == 'submit'){
var next = true;
if(product_type == 1){
if(user_ID == '' || user_ID == null || user_ID == undefined)
{
$(".error_content").text('请选择用户');
$(".alert-error").show();
$("#user_ID").focus();
next = false;
}else if(country == '' || country == null || country == undefined)
{
$(".error_content").text('请选择国家');
$(".alert-error").show();
$("#create_country_name").focus();
next = false;
}else if(product_id == '' || product_id == null || product_id == undefined)
{
$(".error_content").text('请选择货运方式');
$(".alert-error").show();
$("#create_product_id").focus();
next = false;
}else if(id == 'order_update_form' && channel_id == ''){
$(".error_content").text('请选择渠道');
$(".alert-error").show();
$("#create_channel_id").focus();
next = false;
}else if(buyer_fullname == '' || buyer_fullname == null || buyer_fullname == undefined)
{
$(".error_content").text('请输入收件人姓名');
$(".alert-error").show();
$("#create_buyer_fullname").focus();
next = false;
}
}
if(next)
{
var product = $('#create_product_id').find("option:selected").text();
for(var i = 0;i < quantity;i++)
{
var product_name = 1;
$('input[name="product_name['+(i+1)+'][]"]').each(function(){
if($(this).val() == 0 || $(this).val() == '')
{
product_name = 0;
$(".error_content").text('箱数'+(i+1)+'产品描述为必填');
$(".alert-error").show();
//next('quantity_tabs',i,this);
$(this).focus();
}
});
if(product_name == 0)
{
return;
}
}
for(var i = 0;i < quantity;i++)
{
var product_val = 1;
if(product_name == 1)
{
$('input[name="product_value['+(i+1)+'][]"]').each(function(){
if($(this).val() == 0 || $(this).val() == '')
{
product_val = 0;
$(".error_content").text('箱数'+(i+1)+'产品申报价值为必填');
$(".alert-error").show();
//next('quantity_tabs',i,this);
$(this).focus();
}
});
}
if(product_val == 0)
{
return;
}
}
for(var i = 0;i < quantity;i++)
{
var customs_number = 1;
if(product.indexOf('CNFEDEX') == -1)
{
if(product_val == 1)
{
//$(".alert-error").hide();
//$('#'+id).submit();
}
}else{
if(product_val == 1)
{
$('input[name="customs_number['+(i+1)+'][]"]').each(function(){
if($(this).val() == 0 || $(this).val() == '')
{
customs_number = 0;
$(".error_content").text('箱数'+(i+1)+'请输入海关编码');
$(".alert-error").show();
//next('quantity_tabs',i,this);
$(this).focus();
}
});
}
}
if(customs_number == 0)
{
return;
}
}
if(customs_number == 1)
{
var return_val = countryMatch();
if(return_val == 1)
{
$(".alert-error").hide();
$('#'+id).submit();
return false;
}
}
}else{
var return_val = countryMatch();
if(return_val ==1)
{
$(".alert-error").hide();
$('#'+id).submit();
return false;
}
}
}
}
//下一步
function next(id,index,obj)
{
$('#'+id+' li:eq('+index+') a').tab('show');
if(id == 'order_create_tabs')
{
if(index == 0)
{
$('#basic').show();
$('#address').hide();
$('#product_customs').hide();
}else if(index ==1)
{
$('#basic').hide();
$('#address').show();
$('#product_customs').hide();
}else if(index == 2)
{
$('#basic').hide();
$('#address').hide();
$('#product_customs').show();
}
}
if(obj){
$(obj).focus();
}
}
function product_change()
{
var product_id = $('#create_product_id').val();
var product = $('#create_product_id').find("option:selected").text();
if(product_id == '' || product_id == null || product_id == undefined|| product_id == 'undefined')
{
var product_id = $('#shipping_service').val();
var product = $('#shipping_service').find("option:selected").text();
}
if(product_id != '' && product_id != null && product_id != undefined)
{
//countryMatch();
$.ajax({
type: "POST",
url: "/order/Order/GetPrdouctChannel",
data:{'product_id':product_id},
success: function(data){
if(data !=0)
{
var obj = eval('('+data+')');
$('#product_type').val(obj.product_type);
$('#is_tracking').val(obj.is_tracking);
show_customs_number(product);
if(obj.product_type == 1||obj.product_type == 4)
{
$('.express').show();
$('#remotes').show();
$('#quantity').removeAttr("readonly");
}else if(obj.product_type == 2||obj.product_type == 3){
$('.express').hide();
$('#remotes').hide();
$('#quantity').attr("readonly","readonly");
}else{
$('.express').hide();
}
$('#update_channel_id').empty();
$('#update_channel_id').html(obj.html);
}else{
alert(data);
}
}
});
}
}
function countryMatch()
{
var product_id = $('#create_product_id').val();
var country_id = $('#create_country_id').val();
var country_id_1 = $('#country_id').val();
if(country_id == '' || country_id == null || country_id == undefined){
country_id = country_id_1;
}
var return_val = false;
if(product_id)
{
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url: "/order/Order/CountryMatch",
data:{'product_id':product_id,'country_id':country_id},
success: function(data){
return_val = data;
if(data != 1)
{
$(".error_content").text('货运方式与国家不匹配,请重新选择');
$(".alert-error").show();
$("#create_product_id").focus();
}else{
$(".alert-error").hide();
}
}
});
}
return return_val;
}
function addTab() {
var product = $('#create_product_id').find("option:selected").text();
var cutoms_number = 0;
if(product.indexOf('CNFEDEX') == 0)
{
cutoms_number = 1;
}
var quantity = $('#quantity').val();
quantity = quantity-0+1;
$('#quantity').val(quantity);
quantity = get_index(1);
var tabs = $("#mytabs").tabs();
var tabTemplate = "
#{label}Remove Tab",
label = "箱数 " + quantity,
id = quantity,
li = $( tabTemplate.replace( /#\{href\}/g, "#" + id ).replace( /#\{label\}/g, label ) ),
content = '';
content +='';
content +='
'
content +='
';
content +='
';
content += '';
tabs.find(".ui-tabs-nav li:eq("+(quantity-2)+")").after(li);
tabs.append("" );
tabs.append("");
tabs.tabs( "refresh" );
}
function delete_tabs(obj,index)
{
var panelId = $( obj ).closest( "li" ).remove().attr( "aria-controls" );
$( "#" + panelId ).remove();
var quantity = $('#quantity').val();
quantity = quantity-1;
$('#quantity').val(quantity);
$('#quantity_'+index).remove();
totalValue();
var tabs = $("#mytabs").tabs();
tabs.tabs( "refresh" );
}
function get_index(index)
{
var input = $('#quantity_'+index).val();
if(input != undefined && index != undefined)
{
if(input == index)
{
index = parseInt(index)+1;
return get_index(index);
}else{
return index;
}
}else{
return index;
}
}
function add_product(id){
var product = $('#create_product_id').find("option:selected").text();
var mydate = new Date();
var tmp_id = Math.ceil(Math.random()*100000);
var new_product ='<';
new_product += 'tr id="tr_'+tmp_id+'">';
new_product +=' | ';
new_product +=' | ';
new_product +=' | ';
new_product +=' | ';
new_product +='USD($) | ';
new_product +='KG | ';
new_product +=' | ';
new_product +=' | ';
new_product +='<';
new_product += 'a id="undefined" href="javascript:void(0)" onclick="del_product('+tmp_id+','+id+')" class="icon-remove" title="删除">';
new_product += ' | ';
new_product += '';
$('#product_detail_'+id+' tr:last').after(new_product);
var quantity =$('#old_quantity_'+id).val();
$('#goods_quantity_'+id).val(parseInt(quantity)+1);
$('#old_quantity_'+id).val($('#goods_quantity_'+id).val());
}
function goods_quantity(id)
{
var goods_quantity = $('#goods_quantity_'+id).val();
var old_quantity = $('#old_quantity_'+id).val();
if(goods_quantity)
{
var leng = goods_quantity>old_quantity?goods_quantity-old_quantity:old_quantity-goods_quantity;
for(var i = 0;i < leng;i++)
{
if(goods_quantity>old_quantity)
{
add_product(id);
}else{
$('#product_detail_'+id+' tr:last').remove();
var quantity =$('#old_quantity_'+id).val();
$('#goods_quantity_'+id).val(quantity-1);
$('#old_quantity_'+id).val($('#goods_quantity_'+id).val());
}
}
}
}
function del_product(tr_id,id){
var quantity =$('#old_quantity_'+id).val();
$('#goods_quantity_'+id).val(quantity-1);
$('#old_quantity_'+id).val($('#goods_quantity_'+id).val());
$('#tr_'+tr_id).remove();
totalValue();
}
function pty_num(obj,id)
{
obj.value = obj.value.replace(/[^\d]/g,"");
if(id)
{
goods_quantity(id);
}else{
totalValue();
}
}
function qty_num(obj)
{
obj.value = obj.value.replace(/[^\d]/g,"");
var goods_quantity = $('#quantity').val();
var old_quantity = $('#old_quantity').val();
if(goods_quantity)
{
var leng = goods_quantity>old_quantity?goods_quantity-old_quantity:old_quantity-goods_quantity;
for(var i = 0;i < leng;i++)
{
if(goods_quantity>old_quantity)
{
add_input_volume();
}else{
$('#order_volume tr:last').remove();
var quantity =$('#old_quantity').val();
$('#quantity').val(parseInt(quantity)-1);
$('#old_quantity').val($('#quantity').val());
}
}
}
totalValue();
}
function add_input_volume(){
var quantity =$('#old_quantity').val();
var qty = (parseInt(quantity)+1);
var new_product ='<';
new_product += 'tr>';
new_product += '箱数'+qty+':重量: | ';
new_product += ' | ';
new_product += '材积: | ';
new_product += 'cmX';
new_product += 'cmX';
new_product += 'cm';
new_product += '0.0002KG';
new_product += ' | ';
new_product += '';
$('#order_volume tr:last').after(new_product);
$('#quantity').val(parseInt(quantity)+1);
$('#old_quantity').val($('#quantity').val());
}
function pty_input(obj){
obj.value = obj.value.replace(/[^\d]/g,"");
}
function discount_num_input(obj)
{
//先把非数字的都替换掉,除了数字和.
obj.value = obj.value.replace(/[^\d.-]/g,"");
//必须保证第一个为数字而不是.
obj.value = obj.value.replace(/^\./g,"");
//保证只有出现一个.而没有多个.
obj.value = obj.value.replace(/\.{2,}\-{2,}/g,"");
//保证.只出现一次,而不能出现两次以上
obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
obj.value = obj.value.replace("-","$#$").replace(/\-/g,"").replace("$#$","-");
}
function float_input(obj){
//先把非数字的都替换掉,除了数字和.
obj.value = obj.value.replace(/[^\d.]/g,"");
//必须保证第一个为数字而不是.
obj.value = obj.value.replace(/^\./g,"");
//保证只有出现一个.而没有多个.
obj.value = obj.value.replace(/\.{2,}/g,".");
//保证.只出现一次,而不能出现两次以上
obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
}
function nums_input(obj,id,ups)
{
//先把非数字的都替换掉,除了数字和.
obj.value = obj.value.replace(/[^\d.]/g,"");
//必须保证第一个为数字而不是.
obj.value = obj.value.replace(/^\./g,"");
//保证只有出现一个.而没有多个.
obj.value = obj.value.replace(/\.{2,}/g,".");
//保证.只出现一次,而不能出现两次以上
obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
if(id == 0 || id == '' || id == undefined)
{
totalValue();
}else{
CalculateVolume(id,ups);
}
}
function CalculateVolume(id,ups)
{
var length = $('#length_'+id).val();
var width = $('#width_'+id).val();
var height = $('#height_'+id).val();
var product_id = $('#create_product_id').val();
var weight = $('#product_weight_'+id).val();
if(product_id == '' || product_id == null || product_id == undefined)
{
$(".error_content").text('请选择运输方式,否则无法计算材积');
$(".alert-error").show();
$("#create_product_id").focus();
}else{
var ajax = true;
var is_ups = ups?ups:false;
if(ups)
{
var product = $('#create_product_id').find("option:selected").text();
var product_code = product.toUpperCase();
if(product_code.indexOf('UPS') != -1)
{
ajax = false;
}
}
if(ajax)
{
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url: "/order/Order/GetVolume",
data:{'length':length,'width':width,'height':height,'product_id':product_id,'weight':weight},
success: function(data){
$('#product_volume_'+id).text(data);
$('#product_input_volume_'+id).val(data);
}
});
totalValue(true);
}else{
totalValue(false);
}
}
}
function totalValue(ups){
var value = new Array();
var quantitys = new Array();
var weight = new Array();
var weight_volume = new Array();
var quantity = $('#goods_quantity_1').val()>$('#quantity').val()?$('#goods_quantity_1').val():$('#quantity').val();
var product_weight = 0;
var product_type = $('#product_type').val();
if(product_type ==2){
for(var i = 0;i < quantity;i++)
{
$('input[name="p_weight['+(i+1)+'][]"]').each(function(){
product_weight +=parseFloat($(this).val());
});
}
$('#product_weight_1').val(product_weight);
}
for(var i = 0;i < quantity;i++)
{
$('input[name="product_value['+(i+1)+'][]"]').each(function(){
value.push($(this).val());
});
$('input[name="product_qty['+(i+1)+'][]"]').each(function(){
quantitys.push($(this).val());
});
$('input[name="product_weight['+(i+1)+']"]').each(function(){
weight.push($(this).val());
});
$('input[name="product_weight_volume['+(i+1)+']"]').each(function(){
weight_volume.push($(this).val());
});
}
var total_value = 0;
for(var i = 0;i < value.length;i++)
{
if( value[i] != '' && quantitys[i] !='' && quantitys[i] != 0)
{
total_value +=parseFloat(value[i]*quantitys[i]);
}
}
var weight_value = 0;
var weight_volume_value = 0;
for(var i = 0;i < weight.length;i++)
{
if(weight[i])
{
weight_value +=parseFloat(weight[i])
}
if(weight_volume[i])
{
if(ups)
{
var w = parseFloat(weight[i])>parseFloat(weight_volume[i])?parseFloat(weight[i]):parseFloat(weight_volume[i]);
weight_volume_value += parseFloat(weight[i])>parseFloat(weight_volume[i])?parseFloat(weight[i]):parseFloat(weight_volume[i]);
}else{
weight_volume_value +=(parseFloat(weight_volume[i]));
}
}
}
if(weight_volume_value == 0)
{
for(var j = 0;j < weight_volume.length;j++)
{
weight_volume_value +=(parseFloat(weight_volume[j])*10000)/10000;
}
}
var volume = weight_value>weight_volume_value?weight_value:weight_volume_value;
$('#create_weight').val(Fractional(volume));
$('#create_weight_volume').val(Fractional(weight_volume_value));
if(total_value > 99)
{
$('#tariff_prompt').show();
}else{
$('#tariff_prompt').hide();
}
$('#declared_value').val(Fractional(total_value));
}
function show_customs_number(product)
{
if(product.indexOf('CNFEDEX') == 0)
{
$('.customs_number').show();
}else{
$('.customs_number').hide();
}
}
function Fractional(x) {
var f_x = parseFloat(x);
var f_x = Math.round(x * 100) / 100;
var s_x = f_x.toString();
var pos_decimal = s_x.indexOf('.');
if (pos_decimal < 0) {
pos_decimal = s_x.length;
}
return s_x;
}
function order_search_date_verification()
{
$('#is_export').val(0);
$('#is_generate').val(0);
var create_start_date = $('#create_date_start').val();
var create_end_date = $('#create_date_end').val();
var create_start_arr = create_start_date.split('-');
//转换后的UNIX时间戳
var create_start_datum = new Date(Date.UTC(create_start_arr[0],create_start_arr[1]-1,create_start_arr[2]));
create_start_datum = create_start_datum.getTime()/1000;
var create_end_arr = create_end_date.split('-');
//转换后的UNIX时间戳
var create_end_datum = new Date(Date.UTC(create_end_arr[0],create_end_arr[1]-1,create_end_arr[2]));
create_end_datum = create_end_datum.getTime()/1000;
if(create_start_datum > create_end_datum)
{
$('input[name=create_date_start]').val(create_end_date);
}
var delivery_date_start = $('#delivery_date_start').val();
var delivery_date_end = $('#delivery_date_end').val();
var delivery_start_arr = delivery_date_start.split('-');
//转换后的UNIX时间戳
var delivery_start_datum = new Date(Date.UTC(delivery_start_arr[0],delivery_start_arr[1]-1,delivery_start_arr[2]));
delivery_start_datum = delivery_start_datum.getTime()/1000;
var delivery_end_arr = delivery_date_end.split('-');
//转换后的UNIX时间戳
var delivery_end_datum = new Date(Date.UTC(delivery_end_arr[0],delivery_end_arr[1]-1,delivery_end_arr[2]));
delivery_end_datum = delivery_end_datum.getTime()/1000;
if(delivery_start_datum > delivery_end_datum)
{
$('input[name=delivery_date_start]').val(delivery_date_end);
}
//$('#order_search_form').submit();
}
function show_search(id,where,obj)
{
if(obj)
{
//$('.reed').each(function(i,search){$(search).removeClass('reed');});
//$(obj).addClass('reed');
}
$('#'+id).val(where);
$('#sift_order_form').submit();
}
function print_label(order_id,type)
{
$('#singapore_parcels_form').hide();
if(type=='shipping_service')
{
$('#singapore_print').show();
$('#order_print').hide();
$('#print_singapore').show();
}else
{
$('#order_print').show();
$('#singapore_print').hide();
$('.print_prompt').hide();
}
var data=new Array();
data.push(order_id);
$('#select_orders').val(data);
$('#select_print_order').val(data);
$('#ru_select_print_order').val(data);
$('.print_prompt').hide();
$('.print_singapore').hide();
if(type == 'shipping_service')
{
$('#singapore_parcels_form').show();
$('#singapore_print').modal('toggle');
}else if(type =='ru'){
$('#ru_form').show();
$('#ru_print').modal('toggle');
}else{
$('#order_print').modal('toggle');
}
}
function batch_processings(id,operating,confirm)
{
var data=new Array();
$("input:checkbox[name='select_orders[]']").each(function (){
if($(this).attr("checked")=='checked'){
data.push($(this).val());
}
});
if(data.length > 0){
if(operating == 'print')
{
if(confirm !=0){
var status = $('#sift_status').val();
if(status ==2)
{
$('#whether_posted').show();
}else{
$('#whether_posted').hide();
}
$('#new_print').val(confirm);
$('#select_orders').val(data);
$('#order_print').modal('toggle');
}else{
var shipping_service_type = 0;
var ru = 0;
$('#singapore_parcels_form').hide();
$('#ru_form').hide();
if($("input").hasClass("shipping_service"))
{
if($('.shipping_service').is(':checked'))
{
shipping_service_type =1;
$('.print_singapore').show();
}else{
$('.print_singapore').hide();
}
}
if($("input").hasClass("ru"))
{
if($('.ru').is(':checked'))
{
ru =1;
$('.print_ru').show();
}else{
$('.print_ru').hide();
}
}
var singapore = 0;
var ru_print = 0;
if($("input").hasClass("checked"))
{
$('.print_prompt').hide();
if($('.checked').is(':checked'))
{
if(shipping_service_type == 1)
{
$('.print_prompt').show();
}
if(ru == 1)
{
$('.print_ru').show();
}
$('#order_print').show();
$('#singapore_parcels_form').hide();
$('#ru_form').hide();
$('.print_other').show();
}else{
if(shipping_service_type == 1)
{
singapore = 1;
$('#singapore_parcels_form').show();
$('.print_prompt').hide();
$('.print_other').hide();
if(ru == 1)
{
$('.print_prompt').show();
$('#ru_form').show();
}
$('#labelPrint').hide();
$('#ru_form').hide();
}else{
if(ru == 1)
{
ru_print = 1;
$('#ru_form').show();
$('.print_prompt').hide();
$('#singapore_parcels_form').hide();
$('.print_other').hide();
$('#labelPrint').hide();
}
}
}
}else{
if(shipping_service_type == 1)
{
singapore = 1;
$('#singapore_parcels_form').show();
$('.print_prompt').hide();
$('.print_other').hide();
if(ru == 1)
{
$('.print_prompt').show();
}
$('#labelPrint').hide();
$('#ru_form').hide();
}else{
if(ru == 1)
{
ru_print = 1;
$('#ru_form').show();
$('.print_prompt').hide();
$('#singapore_parcels_form').hide();
$('.print_other').hide();
$('.print_singapore').hide();
$('#labelPrint').hide();
}
}
}
var status = $('#sift_status').val();
if(status ==2)
{
$('#whether_posted').show();
}else{
$('#whether_posted').hide();
}
$('#select_orders').val(data);
$('#select_print_order').val(data);
$('#ru_select_print_order').val(data);
if(singapore == 1)
{
$('#singapore_print').modal('toggle');
}else if(ru_print ==1){
$('#ru_print').modal('toggle');
}else{
$('#order_print').modal('toggle');
}
}
}else if(operating == 'generate_bills')
{
$('#create_bills').modal('toggle');
$('#select_orders').val(data);
$('#submit_id').val(id);
$('#batch_processing').val(operating);
}else if(operating == 'add_bills')
{
var bill_id = $('#bill_id').val();
if(bill_id == '' || bill_id == null || bill_id == undefined || bill_id==0)
{
$('#add_bills').modal('toggle');
$('#select_orders').val(data);
$('#submit_id').val(id);
$('#batch_processing').val(operating);
}else{
$('#batch_processing').val(operating);
$('#'+id).submit();
}
}else if(operating == 'batch_single_nuclear')
{
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url: "/financial/ReceiveBill/TotalPice",
data:{'orders':data},
beforeSend:showLoading(),
success: function(data){
hideLoading();
$('#total_price').text(data);
}
});
$('#order_qty').text(data.length);
$('#batch_single_nuclear').modal('toggle');
$('#select_orders').val(data);
$('#submit_id').val(id);
$('#batch_processing').val(operating);
}else if(operating == 'batch_change_channel'){
var channel_id = $('#select_channel_id').val();
if(channel_id == '' || channel_id == null || channel_id == undefined || channel_id==0)
{
$(".error_content").text('请选择渠道');
$(".alert").show();
}else{
$('#update_channel_id').val(channel_id);
$('#batch_processing').val(operating);
postSerialize(id);
//$('#'+id).submit();
}
}else if(operating == 'batch_change_product'){
var product_id = $('#select_product_id').val();
if(product_id == '' || product_id == null || product_id == undefined || product_id==0)
{
$(".error_content").text('请选择产品');
$(".alert").show();
}else{
$('#update_product_id').val(product_id);
$('#batch_processing').val(operating);
postSerialize(id);
//$('#'+id).submit();
}
}else if(confirm == true || confirm == 'ok'){
if(confirm == 'ok'){
$('#move_delete').modal('toggle');
$('#batch_processing').val(operating);
$('#sift_order_form').submit();
}else {
$.ajax({
type:"post",
url:"/order/Order/MoveDelete",
data:{},
//beforeSend:showLoading(),
success:function(data)
{
//hideLoading();
$('#move_delete').html(data);
//loading.hide();
//loading.show();
$('#move_delete').modal('toggle');
}
});
}
}else if(operating =='recal_culate_cost'){
$('#batch_processing').val(operating);
postSerialize(id);
}else if(operating =='batch_single_nuclear_channle'){
$('#batch_processing').val(operating);
postSerialize(id);
}else if(operating =='recal_culate_price'){
$('#batch_processing').val(operating);
postSerialize(id);
}else{
$('#batch_processing').val(operating);
$('#'+id).submit();
}
}else{
var msg;
msg = $.globalMessenger().post({
message: '请选择要操作的订单',
type: 'error',
showCloseButton: true
});
}
}
function batch_single_nuclear_submit()
{
var id = $('#submit_id').val();
var bills_mark = $('#bills_mark').val();
$('#bill_mark').val(bills_mark);
postSerialize(id);
}
function SingleNuclear(order_id,id)
{
$('#single_nuclear_order_id').val(order_id);
$('#'+id).modal('toggle');
}
function SingleNuclearSubmit(id)
{
alert(id);
$('#'+id).submit();
}
function create_bills_submit(id)
{
if(!id)
{
var id = $('#submit_id').val();
}
var currency_id = $('#create_currency_id').val();
var create_userID = $('#create_userID').val();
if(create_userID == '' || create_userID == null || create_userID == undefined || create_userID==0)
{
$(".error_content").text('请选择用户');
$(".alert").show();
$("#create_userID").focus();
}else if(currency_id == '' || currency_id == null || currency_id == undefined || currency_id==0)
{
$(".error_content").text('请选择币种');
$(".alert").show();
$("#create_currency_id").focus();
}else{
$('#select_userID').val(create_userID);
$('#select_currency_id').val(currency_id);
postSerialize(id);
}
}
function add_bills_submit()
{
var id = $('#submit_id').val();
var bill_code = $('#bill_code').val();
var add_userID = $('#add_userID').val();
if(add_userID == '' || add_userID == null || add_userID == undefined || add_userID==0)
{
$(".error_content").text('请选择用户');
$(".alert").show();
$("#add_userID").focus();
}else if(bill_code == '' || bill_code == null || bill_code == undefined || bill_code==0)
{
$(".error_content").text('请选择账单编号');
$(".alert").show();
$("#bill_code").focus();
}else{
$('#select_userID').val(add_userID);
postSerialize(id);
}
}
function create_payment_bills(id)
{
if(!id){
var id = $('#submit_id').val();
}
var currency_id = $('#create_currency_id').val();
var create_supply = $('#create_supply').val();
if(create_supply == '' || create_supply == null || create_supply == undefined || create_supply==0)
{
$(".error_content").text('请选择供应商');
$(".alert").show();
$("#create_supply").focus();
}else if(currency_id == '' || currency_id == null || currency_id == undefined || currency_id==0)
{
$(".error_content").text('请选择币种');
$(".alert").show();
$("#create_currency_id").focus();
}else{
$('#select_supply').val(create_supply);
$('#select_currency_id').val(currency_id);
postSerialize(id);
//$('#'+id).submit();
}
}
function add_payment_bills_submit()
{
var id = $('#submit_id').val();
var bill_code = $('#bill_code').val();
var supply_id = $('#add_supply_id').val();
if(supply_id == '' || supply_id == null || supply_id == undefined || supply_id==0)
{
$(".error_content").text('请选择供应商');
$(".alert").show();
$("#add_supply_id").focus();
}else if(bill_code == '' || bill_code == null || bill_code == undefined || bill_code==0)
{
$(".error_content").text('请选择账单编号');
$(".alert").show();
$("#bill_code").focus();
}else{
$('#select_supply').val(supply_id);
postSerialize(id);
}
}
function add_payment_single_bills(id,submit_id)
{
$('#submit_id').val(submit_id);
$('#order_id').val(id);
$.ajax({
type: "POST",
url: "/financial/PaymentBill/GetByOrderBill",
data:{'order_id':id},
beforeSend:showLoading(),
success: function(data){
hideLoading();
if(data)
{
$('#single_bill_code').html(data);
$('#add_single_bills').modal('toggle');
}else{
var msg;
msg = $.globalMessenger().post({
message: '该供应商没有未完成的账单,请创建账单',
type: 'error',
showCloseButton: true
});
}
}
});
}
function add_payment_bills()
{
$('#add_single_bills').modal('hide');
var id = $('#submit_id').val();
var bill_code = $('#single_bill_code').val();
var order_id = $('#order_id').val();
var bill_id = $('#select_bill_id').val();
if(bill_code == '' || bill_code == null || bill_code == undefined || bill_code==0)
{
$(".error_content").text('请选择账单编号');
$(".alert").show();
$("#single_bill_code").focus();
}else{
$.ajax({
type: "POST",
url: "/financial/PaymentBill/AddSingleBills",
data:{'order_id':order_id,'bill_id':bill_id},
beforeSend:showLoading(),
success: function(data){
hideLoading();
if(data)
{
$('#add_bills_'+order_id).parents('tr:first').fadeOut(1000);
var msg;
msg = $.globalMessenger().post({
message: '添加成功',
type: 'error',
showCloseButton: true
});
}else{
var msg;
msg = $.globalMessenger().post({
message: '添加失败,请联系管理员',
type: 'error',
showCloseButton: true
});
}
}
});
}
}
function complete_paymnet_bill(id,url,prepayments,bill_id,currency,order_quantity)
{
$('#delete_url').val(url);
$('#content_id').val(id);
$('#prepayments').val(prepayments);
$('#re_payment').val(prepayments);
$('#currency').text(currency);
$('#order_quantity').text(order_quantity);
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url: "/financial/PaymentBill/GetBillsStatus",
data:{'id':bill_id},
beforeSend:showLoading(),
success: function(data){
hideLoading();
if(data == 1)
{
var msg;
msg = $.globalMessenger().post({
message: '账单已经是已完成状态',
type: 'error',
showCloseButton: true
});
}else{
$('#'+id).modal('toggle');
}
}
});
}
function confirm_payment_complete_bill()
{
var url = $('#delete_url').val();
var content_id = $('#content_id').val();
var prepayments = $('#prepayments').val();
var re_payment = $('#re_payment').val();
var memo = $('#memo').val();
if(re_payment == '' || re_payment == null || re_payment == undefined || re_payment ==0)
{
$(".error_content").text('请输入实付款');
$(".alert").show();
$('#re_payment').focus();
}else{
if(re_payment != prepayments)
{
if(memo == '' || memo == null || memo == undefined || memo ==0)
{
$(".error_content").text('请填写备注');
$(".alert").show();
$('#memo').focus();
return;
}
}
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url:url,
data:{'re_payment':re_payment,'memo':memo},
beforeSend:showLoading(),
success: function(data){
hideLoading();
if(data == 1)
{
$('#'+content_id).modal('hide');
window.location.reload();
}else{
var msg;
msg = $.globalMessenger().post({
message: '完成失败,请联系管理员',
type: 'error',
showCloseButton: true
});
}
}
});
}
}
function delete_payment_bill(id,url,bill_id,bill_code)
{
$('#delete_url').val(url);
$('#del_id').val(bill_id);
$('#content_id').val(id);
$('#del_name').text(bill_code);
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url: "/financial/PaymentBill/GetBillsStatus",
data:{'id':bill_id},
beforeSend:showLoading(),
success: function(data){
hideLoading();
if(data == 1)
{
var msg;
msg = $.globalMessenger().post({
message: '不能删除状态为已完成的账单',
type: 'error',
showCloseButton: true
});
}else{
$('#'+id).modal('toggle');
}
}
});
}
function confirm_delete_payment_bill()
{
var url = $('#delete_url').val();
var bill_id = $('#del_id').val();
var content_id = $('#content_id').val();
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url:url,
beforeSend:showLoading(),
success: function(data){
hideLoading();
if(data == 1)
{
$('#'+content_id).modal('hide');
$('#delete_'+bill_id).parents('tr:first').fadeOut(1000);
var msg;
msg = $.globalMessenger().post({
message: '删除成功',
type: 'error',
showCloseButton: true
});
}else{
var msg;
msg = $.globalMessenger().post({
message: '删除失败,请联系管理员',
type: 'error',
showCloseButton: true
});
}
}
});
}
function delete_payment_bill_detail(id,url,c_order_id,bill_id)
{
$('#delete_url').val(url);
$('#del_id').val(c_order_id);
$('#content_id').val(id);
$('#del_name').text(c_order_id);
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url: "/financial/PaymentBill/GetBillsStatus",
data:{'id':bill_id},
beforeSend:showLoading(),
success: function(data){
hideLoading();
if(data == 1)
{
var msg;
msg = $.globalMessenger().post({
message: '不能删除状态为已完成的账单下的订单',
type: 'error',
showCloseButton: true
});
}else{
$('#'+id).modal('toggle');
}
}
});
}
function confirm_delete_payment_bill_detail()
{
var url = $('#delete_url').val();
var c_order_id = $('#del_id').val();
var content_id = $('#content_id').val();
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url:url,
beforeSend:showLoading(),
success: function(data){
hideLoading();
if(data)
{
$('#receivable').val(data);
$('#'+content_id).modal('hide');
$('#'+c_order_id).parents('tr:first').fadeOut(1000);
var msg;
msg = $.globalMessenger().post({
message: '删除成功',
type: 'error',
showCloseButton: true
});
}else{
var msg;
msg = $.globalMessenger().post({
message: '删除失败,请联系管理员',
type: 'error',
showCloseButton: true
});
}
}
});
}
function order_upload(id)
{
var fileName = $('#fileName').val();
var sender_id = $('#sender_id').val();
if(fileName == '' || fileName == null || fileName == undefined || fileName==0)
{
$(".error_content").text('请选择要上传的文件');
$(".alert").show();
$("#fileName").focus();
}else{
$(".alert").hide();
$("#"+id).submit();
}
}
function move_prompt(content)
{
var msg;
msg = $.globalMessenger().post({
message: content,
type: 'error',
showCloseButton: true
});
}
function merger_checkAll1()
{
if($('#checkAll').is(':checked')){
$('input[name="merger_key[]"]').each(function(){
$(this).attr('checked',true);
});
$('input[name="merger_orders[]"]').each(function(){
$(this).attr('checked',true);
});
}else{
$('input[name="merger_key[]"]').each(function(){
$(this).attr('checked',false);
});
$('input[name="merger_orders[]"]').each(function(){
$(this).attr('checked',false);
});
}
}
function merger_checked1(class_name)
{
if($('#'+class_name).is(':checked')){
$('.'+class_name).attr('checked',true)
}else{
$('.'+class_name).attr('checked',false)
}
}
function submitBatch(id)
{
if(id == 'direct_import')
{
$('#'+id).val(1);
}
$('#datafrom').submit();
}
function checkAll1()
{
if($('#checkAll').is(':checked')){
$('.checked').attr('checked',true);
$('.shipping_service').attr('checked',true);
}else{
$('.shipping_service').attr('checked',false);
$('.checked').attr('checked',false);
}
}
function forms_submit(id)
{
$('#'+id).submit();
}
function show_country(id)
{
$('#'+id).modal('toggle');
}
function showCountrySlide(index)
{
var type = $('input:radio[name="type"]:checked').val();
$.ajax({
type: "POST",
//async:false, // 设置同步方式
//cache:false,
url: "/order/Order/ShowCountrySlide",
data:{'index':index,'type':type},
success: function(data){
$('#show_centent').html(data);
}
});
}
function selected_country(id,country_name,country_id,country_name_cn,country_code)
{
var create_order_page = $('#create_order_page').val();
if(create_order_page == 1)
{
$('#create_country_name').val(country_name_cn+' '+country_code+'('+country_name+')');
$('#create_country_id').val(country_id);
}else{
$('#country_name').val(country_name_cn+' '+country_code+'('+country_name+')');
$('#country_id').val(country_id);
}
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url: "/order/Order/GetShowProduct",
data:{'country_id':country_id},
success: function(data){
$('#show_product_code').html(data);
}
});
$('#country_name_cn').text(country_name_cn);
$('#'+id).modal('hide');
}
function show_order_count()
{
show_order_status();
var status = $('#sift_status').val();
if(status==1||status==2||status==3)
{
$('.status').each(function(i,search){$(search).show()});
}else
{
$('.status').each(function(i,search){$(search).hide();});
}
$('.completely_remove').hide();
if(status == 6){
$('.completely_remove').show();
}
var params = $("#sift_order_form").serialize();
$.ajax({
type: "POST",
url: "/order/Order/ShowOrderCount",
data:params,
success: function(msg)
{
var data = eval('(' + msg + ')');
var len = data.length;
for(var i=0;i < len;i++)
{
$("#status_"+data[i]['status']).empty();
$("#status_"+data[i]['status']).html(data[i]['count']);
}
}
});
}
function show_order_counts()
{
var params = $("#sift_order_form").serialize();
$.ajax({
type: "POST",
url: "/logistics/Orders/ShowOrderCount",
data:params,
success: function(msg)
{
var data = eval('(' + msg + ')');
var len = data.length;
for(var i=0;i < len;i++)
{
$("#status_"+data[i]['status']).empty();
$("#status_"+data[i]['status']).html(data[i]['count']);
}
}
});
}
function marquee()
{
var speed=30;//滚动速度
function getElement(id){
return document.getElementById(id);
}
var speed=30;//滚动速度
var marquee=getElement("marquee");
var marquee2=getElement("marquee2");
var marquee1=getElement("marquee1");
$("#marquee2").html($("#marquee1").html());//复制marquee1中的图片到marquee2中
marquee.scrollLeft = 986;
function Marqueeleft(){//向左滚动
if(marquee2.offsetWidth-marquee.scrollLeft<0){
marquee.scrollLeft -= marquee1.offsetWidth;
}else{
if(marquee.scrollLeft == (marquee.scrollWidth-marquee.clientWidth))
{
marquee.scrollLeft = 0;
}
marquee.scrollLeft++;
}
}
function Marqueeright(){//向右滚动
if(marquee2.offsetWidth-marquee.scrollLeft >= 900){
marquee.scrollLeft += marquee1.offsetWidth;
}else{
marquee.scrollLeft--;
}
}
var MyMar=setInterval(Marqueeleft,speed)//自动开始滚动
Direction='Left';//设定初始方向为向左滚
$('#marquee').mouseover(function() {
clearInterval(MyMar)
});
$('#marquee').mouseout(function() {
if(Direction=='Left'){
MyMar=setInterval(Marqueeleft,speed);
}else if(Direction=='Right'){
MyMar=setInterval(Marqueeright,speed);
}
});
$('#left').click(function(){
clearInterval(MyMar);
MyMar=setInterval(Marqueeleft,speed);
Direction='Left';
});
$('#right').click(function(){
clearInterval(MyMar);
MyMar=setInterval(Marqueeright,speed);
Direction='Right';
});
}
function show_order_problem(id,order_problem_id)
{
$('#'+id).modal('toggle');
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url: "/order/Order/ShowProblemsPieces",
data:{'id':order_problem_id},
success: function(data)
{
$('#'+id+'_content').html(data);
imgPreview();
}
});
}
function update_order_problem(id,order_problem_id,c_order_id,status)
{
$('#order_problem_id').val(order_problem_id);
$('#c_order_id').text(c_order_id);
$('#status').val(status);
$('#'+id).modal('toggle');
}
function update_promble()
{
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url: "/order/Order/ShowProblemsPieces",
data:{'id':order_problem_id},
success: function(data)
{
$('#'+id+'_content').html(data);
}
});
}
function order_problem_submit(id,type)
{
var problem_id = $('#problem_id').val();
var data = $('#data').val();
var is_remote = $('#is_remote').val();
var reason_id = $('#reason_id').val();
if(type)
{
var status = type;
}else{
var status = '';
}
if(data == '' || data == null || data == undefined || data==0)
{
$(".error_content").text('请输入解决方案');
$(".alert-error").show();
$('#data').focus();
}else{
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url: "/order/Order/ShowProblemsPieces",
data:{'id':problem_id,'data':data,'reason_id':reason_id,'is_remote':is_remote,'status':status},
success: function(data){
$('#'+id+'_content').html(data);
}
});
}
$('input[name="memo_back"]:checked').each(function(){
$(this).remove();
});
}
function chanage_page()
{
var page = $("#page_num").val();
$("#page_value").val(page);
$("#pageSubmit").submit();
}
function confirm_add_memo(id)
{
var memo = $("#add_memo").val();
var price = $("#return_price").val();
var weight = $("#return_weight").val();
if(memo == ''&& weight==''&price=='')
{
$(".error_content").text('请填写退件金额或原因');
$('.alert').show();
return false;
}else
{
$('.alert').hide();
$("input[name='memo']").val(memo);
$('#select').submit();
$('#order_update_list_update').modal('hide');
}
}
function show_dialog(id)
{
var select =[];
$('input[name="select[]"]:checked').each(function(){
select.push($(this).val());
});
if(select.length == 0)
{
$(".error_content").text('请选择要操作的订单');
$(".alert").show();
return false;
}else
{
$(".error_content").empty();
$(".alert").hide();
$('#'+id).modal('toggle');
}
}
function confirm_product(id)
{
var select = [];
$('input[name="product[]"]:checked').each(function(){
select.push($(this).val());
});
if(select.length == 0)
{
$(".error_content").text('请选择产品');
$(".alert").show();
return false;
}else
{
var product_code = select.join(",");
}
$(".error_content").empty();
$(".alert").hide();
$("#Channel_product_id").attr('title',product_code);
$("#Channel_product_id").val(product_code);
$('#country_change').modal('hide');
}
function baseSubmit(type)
{
var product_id= $('#product_id').val();
if(type=='Channel')
{
var product_code = $('#'+type+'_channel_code').val();
var product_name = $('#'+type+'_channel_name').val();
var product_en_name = $('#'+type+'_channel_en_name').val();
var type_id = $('#type_id').val();
}else
{
var product_code = $('#'+type+'_product_code').val();
var product_name = $('#'+type+'_product_name').val();
var product_en_name = $('#'+type+'_product_en_name').val();
var type_id = $('#type_id').val();
}
if(product_code == '' || product_code == null || product_code == undefined || product_code==0)
{
$(".error_content").text('请填写产品简码');
$(".alert").show();
$('#'+type+'_product_code').addClass('error');
$('#'+type+'_product_code').focus();
return false;
}else if(product_code){
if(type=='Channel')
{
$.ajax({
type: "POST",
url: "/products/Channel/VerifyCode",
data:{'value':product_code,'id':product_id},
success: function(data){
if(data == 2)
{
$(".error_content").text(product_code+'简码已存在,请重新填写');
$(".alert").show();
$('#'+type+'_channel_code').addClass('error');
$('#'+type+'_channel_code').focus();
return false;
}else if(product_name == '' || product_name == null || product_name == undefined || product_name==0)
{
$(".error_content").text('请填写中文名');
$(".alert").show();
$('#'+type+'_product_name').addClass('error');
$('#'+type+'_product_name').focus();
return false;
}else if(product_en_name == '' || product_en_name == null || product_en_name == undefined || product_en_name==0)
{
$(".error_content").text('请填写英文名');
$(".alert").show();
$('#'+type+'_product_en_name').addClass('error');
$('#'+type+'_product_en_name').focus();
return false;
}else if(type_id == '' || type_id == null || type_id == undefined || type_id==0)
{
$(".error_content").text('请选择运输类型');
$(".alert").show();
$('#'+type+'_type_id').addClass('error');
$('#'+type+'_type_id').focus();
return false;
}else
{
$(".error_content").text('');
$(".alert").hide();
$("#horizontalForm").submit();
}
}
});
}else{
$.ajax({
type: "POST",
url: "/products/Product/VerifyCode",
data:{'value':product_code,'id':product_id},
success: function(data){
if(data == 2)
{
$(".error_content").text(product_code+'产品简码已存在,请重新填写');
$(".alert").show();
$('#'+type+'_product_code').addClass('error');
$('#'+type+'_product_code').focus();
return false;
}else if(product_name == '' || product_name == null || product_name == undefined || product_name==0)
{
$(".error_content").text('请填写产品英文名');
$(".alert").show();
$('#'+type+'_product_name').addClass('error');
$('#'+type+'_product_name').focus();
return false;
}else if(product_en_name == '' || product_en_name == null || product_en_name == undefined || product_en_name==0)
{
$(".error_content").text('请填写产品中文名');
$(".alert").show();
$('#'+type+'_product_en_name').addClass('error');
$('#'+type+'_product_en_name').focus();
return false;
}else if(type_id == '' || type_id == null || type_id == undefined || type_id==0)
{
$(".error_content").text('请选择运输类型');
$(".alert").show();
$('#'+type+'_type_id').addClass('error');
$('#'+type+'_type_id').focus();
return false;
}else
{
$(".error_content").text('');
$(".alert").hide();
$("#horizontalForm").submit();
}
}
});
}
}else if(product_name == '' || product_name == null || product_name == undefined || product_name==0)
{
$(".error_content").text('请填写产品英文名');
$(".alert").show();
$('#'+type+'_product_name').addClass('error');
$('#'+type+'_product_name').focus();
return false;
}else if(product_en_name == '' || product_en_name == null || product_en_name == undefined || product_en_name==0)
{
$(".error_content").text('请填写产品中文名');
$(".alert").show();
$('#'+type+'_product_en_name').addClass('error');
$('#'+type+'_product_en_name').focus();
return false;
}else if(type_id == '' || type_id == null || type_id == undefined || type_id==0)
{
$(".error_content").text('请选择运输类型');
$(".alert").show();
$('#'+type+'_type_id').addClass('error');
$('#'+type+'_type_id').focus();
return false;
}else
{
$(".error_content").text('');
$(".alert").hide();
$("#horizontalForm").submit();
}
}
function verify_code(id,type)
{
var value = $("#code").val();
if(type==1)
{
var url = "/products/Product/VerifyCode";
var str = '产品';
}else if(type==2)
{
var url = "/products/Channel/VerifyCode";
var str = '渠道';
}else if(type==3)
{
var url = "/products/Base/VerifyCode";
var str = '基础产品';
}
var ren = isChn(value);
if(!ren)
{
$(".error_content").text(str+'简码不能出现中文');
$(".alert").show();
$("#code").addClass('error');
$("#code").focus();
return false;
}else if(value == '' || value == null || value == undefined || value==0)
{
$(".error_content").text('请填写'+str+'简码');
$(".alert").show();
$("#code").addClass('error');
$("#code").focus();
return false;
}else if(value.length < 4)
{
$(".error_content").text(str+'简码不能少于4位');
$(".alert").show();
$("#code").addClass('error');
$("#code").focus();
return false;
}else
{
$.ajax({
type: "POST",
url: url,
data:{'value':value},
beforeSend:showLoading(),
success: function(data)
{
hideLoading();
if(data==1)
{
$(".error_content").text();
$(".alert").hide();
$("#code").removeClass('error');
}else
{
$(".error_content").text(value+'简称已存在,请重新填写');
$(".alert").show();
$("#code").addClass('error');
$("#code").empty();
$("#code").focus();
$('#'+id+' li:eq('+index+') a').tab('show');
return false;
}
}
});
}
}
function messages(prompt,mess,type)
{
if(!mess)
{
if(prompt==1)
{
mess='修改成功';
type='success';
}else if(prompt==2)
{
mess='删除成功';
type='success';
}else if(prompt==3)
{
mess='添加成功';
type='success';
}else if(prompt==4)
{
mess='扣费成功';
type='success';
}else if(prompt==5)
{
mess='余额不足,扣费失败';
type='error';
}else if(prompt==6)
{
mess='信用度不足,扣费失败';
type='error';
}else if(prompt==7)
{
mess='保存成功';
type='success';
}else if(prompt==8)
{
mess='导入成功';
type='success';
}else if(prompt==9)
{
mess='刷新成功';
type='success';
}else if(prompt==10)
{
mess='设置成功';
type='success';
}else if(prompt==11)
{
mess='验货成功';
type='success';
}else if(prompt==12)
{
mess='部分扣费成功,请检查扣费是否有金额为0的订单';
type='success';
}else if(prompt==13)
{
mess='设置失败';
type='error';
}else if(prompt==14)
{
mess='扫描录入成功';
type='success';
}else if(prompt==15)
{
mess='退款成功';
type='success';
}else if(prompt==16)
{
mess='添加失败';
type='error';
}else if(prompt==17){
mess='修改失败';
type='error'
}
}
msg = $.globalMessenger().post({
message: mess,
type: type,
showCloseButton: true
});
}
function showMess(mess,type)
{
msg = $.globalMessenger().post({
message: mess,
type: type,
showCloseButton: true
});
}
function ChanngePrice(type)
{
if(type==1)
{
var url = "/products/Product/ChanngePrice";
}else if(type==2)
{
var url = "/products/Channel/ChanngePrice";
}else if(type==3)
{
var url = "/products/Base/ChanngePrice";
}
var currency_id = $("#currency_id").val();
var p_id = $("#p_id").val();
var price_type = $("#price_type").val();
if(currency_id != '' && currency_id != null && currency_id != undefined )
{
$.ajax({
type: "POST",
url: url,
data:{'currency_id':currency_id,'p_id':p_id,'price_type':price_type},
beforeSend:showLoading(),
success: function(data)
{
hideLoading();
$("#load_price").html(data);
}
});
}
}
function _delete()
{
var product_id = $('#product_id').val();
var url = $('#delete_url').val();
var zone_id = $('#zone_id').val();
$.ajax({
type: "POST",
url: url,
success: function(data)
{
if(data == 1)
{
$('#'+zone_id).fadeOut(1000);
}else{
alert(data);
}
}
});
}
function DeleteDialog(delete_id,delete_url,delete_title,delete_content,type)
{
$('#delete_id'+type).val(delete_id);
$('#delete_url'+type).val(delete_url);
$('#delete_title'+type).text(delete_title);
$('#delete_content'+type).html(delete_content);
$('#id_'+type).modal('toggle');
}
function _delete(type)
{
var url = $('#delete_url'+type).val();
var id = $('#delete_id'+type).val();
if(url!='')
{
$.ajax({
type: "POST",
url: url,
success: function(data)
{
if(data == 1)
{
$('#'+id).fadeOut(1000);
}else{
alert(data);
}
}
});
}
}
function delete_discount(obj,id,url,delete_title,delete_content,type)
{
$(obj).parents('tr:first').attr('id',id);
DeleteDialog(id,url,delete_title,delete_content,type);
}
function check_data(type)
{
var select=new Array();
$("input[name^='import[c_order_id][]']").each(function(){
select.push($(this).val());
});
if(select.length!=0)
{
$(".alert").hide();
if(type)
{
$('#force_update').val(1);
}
$("#form1").submit();
}else
{
$(".error_content").text("没有有效导入的订单号,请先确定!!!");
$(".alert").show();
return false;
}
}
function select_bank()
{
var bank = $('#bank').val();
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url: "/financial/Recharge/ShowBank",
data:{'bank':bank},
success: function(data){
$('#account_bank').val(data);
}
});
}
function create_recharge(id)
{
if(id !== 'select_recharge')
{
$('#select_recharge').modal('hide');
}
$('#'+id).modal('toggle');
}
function create_recharge_submit(id)
{
if(id == 'cash_recharge_form')
{
var userID = $('#cash_userID').val();
var amount = $('#cash_amount').val();
if(userID == '' || userID == null || userID == undefined || userID==0)
{
$(".error_content").text('用户ID为必填');
$(".alert-error").show();
$('#cash_userID').focus();
}else if(amount == '' || amount == null || amount == undefined || amount==0)
{
$(".error_content").text('金额为必填');
$(".alert-error").show();
$('#cash_amount').focus();
}else{
$('#'+id).submit();
}
}else{
var userID = $('#userID').val();
var bank = $('#bank').val();
var account_name = $('#account_name').val();
var account = $('#account').val();
var account_bank = $('#account_bank').val();
var amount = $('#amount').val();
if(userID == '' || userID == null || userID == undefined || userID==0)
{
$(".error_content").text('用户ID为必填');
$(".alert-error").show();
$('#userID').focus();
}else if(amount == '' || amount == null || amount == undefined || amount==0)
{
$(".error_content").text('汇款金额为必填');
$(".alert-error").show();
$('#amount').focus();
}else{
$('#'+id).submit();
}
}
}
//核对用户是否存在
function checkUserID(value)
{
if(value)
{
var userID = value;
}else
{
var userID = $("#user_ID").val();
}
if(userID=='')
{
$(".error_content").text('请选择用户');
$(".alert").show();
$('#user_ID').focus();
return false;
}else
{
$.ajax({
type: "POST",
url: "/user/User/checkUserID",
async:false, // 设置同步方式
cache:false,
data:{'userID':userID},
success: function(data)
{
$(".alert").hide();
if(data)
{
if(value)
{
$(".alert").hide();
}else
{
$("#order-form").submit();
}
}else
{
$(".error_content").text('选择的用户错误');
$(".alert").show();
$('#user_ID').focus();
return false;
}
}
});
}
}
$(function (){
$("#add_zone :text:first").focus();
// $('#add_zone~input:text:first').focus();
// var $inp = $(':input:text');
var $inp = $("#add_zone :text");
$inp.bind('keydown', function (e) {
// alert($('.enter').size());
var key = e.which;
if (key == 13) {
e.preventDefault();
var nxtIdx = $inp.index(this) + 1;
// $(":input:text:eq(" + nxtIdx + ")").focus();
$(".enter:eq(" + nxtIdx + ")").focus();
}
});
});
function improt_price(id)
{
$('#'+id).modal('toggle');
}
function num_input(obj,weight_id,num_input,type)
{
//先把非数字的都替换掉,除了数字和.
obj.value = obj.value.replace(/[^\d.]/g,"");
//必须保证第一个为数字而不是.
obj.value = obj.value.replace(/^\./g,"");
//保证只有出现一个.而没有多个.
obj.value = obj.value.replace(/\.{2,}/g,".");
//保证.只出现一次,而不能出现两次以上
obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
if(weight_id == 0 || weight_id == '' || weight_id == undefined)
{
}else{
if(type==1)
{
totalWeight(weight_id,num_input);
}else
{
totalVolume(weight_id,num_input);
}
}
}
function accSubtr(arg1,arg2){
var r1,r2,m,n;
try{r1=arg1.toString().split(".")[1].length}catch(e){r1=0}
try{r2=arg2.toString().split(".")[1].length}catch(e){r2=0}
m=Math.pow(10,Math.max(r1,r2));
//动态控制精度长度
n=(r1>=r2)?r1:r2;
return ((arg1*m-arg2*m)/m).toFixed(n);
}
function del_order_volume(tr_id)
{
var weight_volume = $('#weight_'+tr_id).val();
var weight_actual = $('#actual_'+tr_id).val();
var volume_weight = $('#volume_weight').val();
var actual_weight = $('#actual_weight').val();
var total_volume = accSubtr(volume_weight,weight_volume);
var total_actual = accSubtr(actual_weight,weight_actual);
$('#volume_weight').val(Fractional(total_volume));
$('#actual_weight').val(Fractional(total_actual));
var deduction_weight =(parseFloat(total_volume)>=parseFloat(total_actual))?total_volume:total_actual;
$('#deduction_weight').val(Fractional(deduction_weight));
var quantity =$('#old_volume_quantity').val();
$('#quantity').val(quantity-1);
$('#old_volume_quantity').val($('#quantity').val());
$('#'+tr_id).remove();
var len=$('#order_volume').find('tr').length;
$("#quantitys").val(parseInt(len)-1);
$('#order_volume').find('tr').each(function(i,search){$('#order_volume').find('tr').eq(i).find('td:first').text(i);});
}
function input_num(obj,tmp_id)
{
var length = $('#length_'+tmp_id).val();
var width = $('#width_'+tmp_id).val();
var height = $('#height_'+tmp_id).val();
var product_id = $('#shipping_service').val();
var total_volume = 0;
if(product_id==''&&product_id=='0'&&product_id=='0')
{
$(".error_content").text('请选择运输方式');
$(".alert").show();
$('#shipping_service').focus();
}else
{
$("#alert").hide();
$.ajax({
type:"POST",
url:"/logistics/TotalReceive/getMetricFactors",
data:{'length':length,'width':width,'height':height,'product_id':product_id},
success:function(msg)
{
if(!isNaN(msg))
{
total_volume = msg;
$('#weight_'+weight_id).val(Fractional(total_volume));
var weight = new Array();
$('.volume_weight').each(function(){
weight.push($(this).val());
});
var volume_weight = 0;
for(var i=0;i < weight.length;i++)
{
volume_weight =parseFloat(weight[i])+parseFloat(volume_weight);
}
$('#volume_weight').val(Fractional(volume_weight));
$("input[name='new_volume_weight']").val(Fractional(volume_weight));
}
}
});
}
}
function set_page_submit(id)
{
var page = $('#set_page').val();
if(page == '' || page == null || page == undefined || page==0)
{
var msg;
msg = $.globalMessenger().post({
message: '请输入显示页数',
type: 'error',
showCloseButton: true
});
}else{
$('#set_page_value').val(page);
$('#'+id).submit();
}
}
function add_single_bills(id,submit_id)
{
$('#submit_id').val(submit_id);
$('#order_id').val(id);
$.ajax({
type: "POST",
url: "/financial/ReceiveBill/GetByOrderBill",
data:{'order_id':id},
beforeSend:showLoading(),
success: function(data){
hideLoading();
if(data)
{
$('#single_bill_code').html(data);
$('#add_single_bills').modal('toggle');
}else{
var msg;
msg = $.globalMessenger().post({
message: '该用户没有未完成的账单,请创建账单',
type: 'error',
showCloseButton: true
});
}
}
});
}
function add_bills()
{
$('#add_single_bills').modal('hide');
var id = $('#submit_id').val();
var bill_code = $('#single_bill_code').val();
var order_id = $('#order_id').val();
var bill_id = $('#select_bill_id').val();
if(bill_code == '' || bill_code == null || bill_code == undefined || bill_code==0)
{
$(".error_content").text('请选择账单编号');
$(".alert").show();
$("#single_bill_code").focus();
}else{
$.ajax({
type: "POST",
url: "/financial/ReceiveBill/AddSingleBills",
data:{'order_id':order_id,'bill_id':bill_id},
beforeSend:showLoading(),
success: function(data){
hideLoading();
if(data)
{
$('#add_bills_'+order_id).parents('tr:first').fadeOut(1000);
var msg;
msg = $.globalMessenger().post({
message: '添加成功',
type: 'error',
showCloseButton: true
});
}else{
var msg;
msg = $.globalMessenger().post({
message: '添加失败,请联系管理员',
type: 'error',
showCloseButton: true
});
}
}
});
}
}
function delete_receive_bill(id,url,bill_id,bill_code)
{
$('#delete_url').val(url);
$('#del_id').val(bill_id);
$('#content_id').val(id);
$('#del_name').text(bill_code);
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url: "/financial/ReceiveBill/GetBillsStatus",
data:{'id':bill_id},
beforeSend:showLoading(),
success: function(data){
hideLoading();
if(data == 1)
{
var msg;
msg = $.globalMessenger().post({
message: '不能删除状态为已完成的账单',
type: 'error',
showCloseButton: true
});
}else{
$('#'+id).modal('toggle');
}
}
});
}
function confirm_delete_receive_bill()
{
var url = $('#delete_url').val();
var bill_id = $('#del_id').val();
var content_id = $('#content_id').val();
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url:url,
beforeSend:showLoading(),
success: function(data){
hideLoading();
if(data == 1)
{
$('#'+content_id).modal('hide');
$('#delete_'+bill_id).parents('tr:first').fadeOut(1000);
var msg;
msg = $.globalMessenger().post({
message: '删除成功',
type: 'error',
showCloseButton: true
});
}else{
var msg;
msg = $.globalMessenger().post({
message: '删除失败,请联系管理员',
type: 'error',
showCloseButton: true
});
}
}
});
}
function delete_bill_detail(id,url,c_order_id,bill_id)
{
$('#delete_url').val(url);
$('#del_id').val(c_order_id);
$('#content_id').val(id);
$('#del_name').text(c_order_id);
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url: "/financial/ReceiveBill/GetBillsStatus",
data:{'id':bill_id},
beforeSend:showLoading(),
success: function(data){
hideLoading();
if(data == 1)
{
var msg;
msg = $.globalMessenger().post({
message: '不能删除状态为已完成的账单下的订单',
type: 'error',
showCloseButton: true
});
}else{
$('#'+id).modal('toggle');
}
}
});
}
function confirm_delete_bill_detail()
{
var url = $('#delete_url').val();
var c_order_id = $('#del_id').val();
var content_id = $('#content_id').val();
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url:url,
beforeSend:showLoading(),
success: function(data){
hideLoading();
if(data)
{
$('#receivable').val(data);
$('#'+content_id).modal('hide');
$('#'+c_order_id).parents('tr:first').fadeOut(1000);
var msg;
msg = $.globalMessenger().post({
message: '删除成功',
type: 'error',
showCloseButton: true
});
}else{
var msg;
msg = $.globalMessenger().post({
message: '删除失败,请联系管理员',
type: 'error',
showCloseButton: true
});
}
}
});
}
function complete_receive_bill(id,url,re_receive,bill_id,currency,order_quantity)
{
$('#delete_url').val(url);
$('#content_id').val(id);
$('#re_receive').val(re_receive);
$('#bill_receivable').val(re_receive);
$('#currency').text(currency);
$('#order_quantity').text(order_quantity);
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url: "/financial/ReceiveBill/GetBillsStatus",
data:{'id':bill_id},
beforeSend:showLoading(),
success: function(data){
hideLoading();
if(data == 1)
{
var msg;
msg = $.globalMessenger().post({
message: '账单已经是已完成状态',
type: 'error',
showCloseButton: true
});
}else{
$('#'+id).modal('toggle');
}
}
});
}
function confirm_complete_bill()
{
var url = $('#delete_url').val();
var content_id = $('#content_id').val();
var re_receive = $('#re_receive').val();
var receivable = $('#receivable').val();
var memo = $('#memo').val();
if(re_receive == '' || re_receive == null || re_receive == undefined || re_receive ==0)
{
$(".error_content").text('请输入实收款');
$(".alert").show();
$('#re_receive').focus();
}else{
if(re_receive != receivable)
{
if(memo == '' || memo == null || memo == undefined || memo ==0)
{
$(".error_content").text('请填写备注');
$(".alert").show();
$('#memo').focus();
return;
}
}
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url:url,
data:{'re_receive':re_receive,'memo':memo},
beforeSend:showLoading(),
success: function(data){
hideLoading();
if(data == 1)
{
$('#'+content_id).modal('hide');
window.location.reload();
}else{
var msg;
msg = $.globalMessenger().post({
message: '完成失败,请联系管理员',
type: 'error',
showCloseButton: true
});
}
}
});
}
}
function readScale(scale_type,comPort){
var i = 1;
var num = 0;
while(i == 1){
num++;
var data = getData(scale_type,comPort);
if(scale_type=='xpes30'){
if(data != ""){
data = data.replace('+','');
data = data.replace('kg','');
data = $.trim(data);
if(data >0){
return data
break;
}
}
}else{
var tmp_result=new Array()
tmp_result = data.split('=');
if(data != "" && tmp_result.length > 2){
i = 0;
return ruleWeight(data);
break;
}
}
if(num > 3) return 0;
}
}
function getData (scale_type,comPort)
{
var objComport,bandrate;
if(scale_type=='xpes30'){
bandrate = 9600;
}else{
bandrate = 1200;
}
objComport = new ActiveXObject("ActiveXperts.ComPort");
objComport.Device = comPort;
objComport.Baudrate = bandrate;
objComport.ComTimeout = 500;
objComport.LogFile = "ComLog.txt";
objComport.HardwareFlowControl = objComport.asFLOWCONTROL_DEFAULT;
objComport.Open();
var str="";
str=objComport.ReadString();
objComport.Close ();
return str;
}
function ruleWeight(weight){
var tmp_result=new Array();
var result=new Array();
var return_weight = '';;
tmp_result = weight.split('=');
result = tmp_result[1].split('');
for(var i= (result.length - 1);i>=0;i--){
return_weight += result[i];;
}
weight = parseFloat(return_weight);
return weight;
}
function errorVoice(){
$('#voice1').attr('src','http://img.fooing.cn/voice/notice/error.wav');
$('#voice2').attr('src','http://img.fooing.cn/voice/notice/error.wav');
}
function noticeVoice(){
$('#voice1').attr('src','http://img.fooing.cn/voice/notice/notice.wav');
$('#voice2').attr('src','http://img.fooing.cn/voice/notice/notice.wav');
}
function show_price(id)
{
$('#'+id).show();
$('#'+id).focus();
$('#'+id+'_show').hide();
}
function show_r_price(id)
{
$('#'+id+'_r_price').show();
$('#'+id+'_r_price').focus();
$('#'+id+'_show_r_price').hide();
}
function checkChannel(id)
{
var channel_id = $('#channel_id').val();
if(channel_id==0)
{
$(".error_content").text('请选择出货渠道');
$(".alert").show();
}else
{
$(".alert").hide();
$("#order-form").submit();
}
}
function switch_button(){
$('.switch')['bootstrapSwitch']();
$('a').removeAttr('title');
$('.switch').on('switch-change', function (e,data){
var url = $(this).attr('supplier');
if($(this).attr('supplier'))
{
var status = data.value == true?0:1;
$.ajax({
type: "POST",
url: url,
data:{'status':status},
success: function(data){
if(data == 1)
{
window.location.reload();
}
}
});
}
});
}
function add_account(id)
{
$('#'+id).modal('toggle');
}
function add_account_submit(id)
{
var name = $('#name').val();
var bank = $('#bank').val();
var account = $('#account').val();
if(name == '' || name == null || name == undefined || name ==0)
{
$(".error_content").text('请输入名称');
$(".alert").show();
$('#name').focus();
}else if(bank == '' || bank == null || bank == undefined || bank ==0)
{
$(".error_content").text('请输入银行');
$(".alert").show();
$('#bnak').focus();
}else if(account == '' || account == null || account == undefined || account ==0)
{
$(".error_content").text('请输入账号');
$(".alert").show();
$('#account').focus();
}else{
$('#'+id).submit();
}
}
function account_dialog(id,url)
{
$.ajax({
type: "POST",
url: url,
//data:{},
success: function(data){
$('#'+id).html(data);
}
});
$('#'+id).modal('toggle');
}
function update_account_submit(id)
{
var update_name = $('#update_name').val();
var update_bank = $('#update_bank').val();
var update_account = $('#update_account').val();
if(update_name == '' || update_name == null || update_name == undefined || update_name ==0)
{
$(".error_content").text('请输入名称');
$(".alert").show();
$('#update_name').focus();
}else if(update_bank == '' || update_bank == null || update_bank == undefined || update_bank ==0)
{
$(".error_content").text('请输入银行');
$(".alert").show();
$('#update_bnak').focus();
}else if(update_account == '' || update_account == null || update_account == undefined || update_account ==0)
{
$(".error_content").text('请输入账号');
$(".alert").show();
$('#update_account').focus();
}else{
$('#'+id).submit();
}
}
function check_country(value)
{
if(value!='')
{
$.ajax({
type: "POST",
url: "/order/Order/checkCountry",
data:{'value':value},
success: function(data)
{
if(data!='')
{
var obj = eval('('+data+')');
$('.alert').hide();
$('#country_name_cn').text(obj.country_name_cn);
$('#country_id').val(obj.country_id);
}else
{
$('.error_content').text('填写的国家不存在,请重新输入');
$('.alert').show();
$('#country_name').focus();
}
}
});
}else
{
$('#country_id').val('');
}
}
function ordre_adjust_submit(get_channel,is_updaet_cost,is_price)
{
var country_id = $('#country_id').val();
var product_id = $('#product_id').val();
var channel_id = $('#channel_id').val();
var weight = $('#weight').val();
var old_weight = $('#old_weight').val();
var send_weight = $('#send_weight').val();
var old_send_weight = $('#old_send_weight').val();
var order_id = $('#order_id').val();
var price = $('#price').val();
var old_price = $('#old_price').val();
var cost = $('#cost').val();
var old_cost = $('#old_cost').val();
var memo = $('#memo').val();
var old_memo = $('#old_memo').val();
var is_updaet_cost = is_updaet_cost?is_updaet_cost:0;
if(country_id == '' || country_id == null || country_id == undefined || country_id ==0)
{
$(".error_content").text('请选择国家');
$(".alert").show();
$('#country_id').focus();
}else if(product_id == '' || product_id == null || product_id == undefined || product_id ==0)
{
$(".error_content").text('请选择产品');
$(".alert").show();
$('#product_id').focus();
}else if(weight == '' || weight == null || weight == undefined || weight ==0)
{
$(".error_content").text('请输入扣费重量');
$(".alert").show();
$('#weight').focus();
}else if(is_updaet_cost){
if(get_channel == 'ok')
{
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url: "/financial/ReceiveBill/GetChannelByProduct",
data:{'product_id':product_id},
beforeSend:showLoading(),
success: function(data){
hideLoading();
$('#cost').val(0);
$('#channel_id').html(data);
$(".error_content").text('请选择渠道');
$(".alert").show();
}
});
}
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url: "/financial/ReceiveBill/OrderAdjust",
data:{'id':order_id,'product_id':product_id,'country_id':country_id,'weight':weight,'is_updaet_cost':is_updaet_cost,'channel_id':channel_id,'send_weight':send_weight},
beforeSend:showLoading(),
success: function(data){
hideLoading();
if(data == 'no_product_price')
{
$(".error_content").text('当前调整没有价格存在,请参考产品设置调整订单');
$(".alert").show();
}else if(data == 'no_channel_price'){
$('#cost').val(0);
$(".error_content").text('当前调整没有成本存在,请参考渠道设置调整订单');
$(".alert").show();
}else if(data == 'ok')
{
location = "";
}else if(data)
{
var obj = eval ("(" + data + ")");
$('#price').val(obj.product_price);
$('#cost').val(obj.cost_price);
$(".alert").hide();
$('#status_text').text(data);
$('#old_memo').val(data);
var msg;
msg = $.globalMessenger().post({
message: '保存成功',
type: 'error',
showCloseButton: true
});
}
}
});
}else if(is_price == 'price'){
if(price != old_price){
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url: "/financial/ReceiveBill/OrderAdjust",
data:{'id':order_id,'price':price},
beforeSend:showLoading(),
success: function(data){
hideLoading();
if(data)
{
$('#old_price').val(data);
var msg;
msg = $.globalMessenger().post({
message: '修改价格成功',
type: 'error',
showCloseButton: true
});
}else{
var msg;
msg = $.globalMessenger().post({
message: '修改价格失败',
type: 'error',
showCloseButton: true
});
}
}
});
}
}else if(is_price == 'cost'){
if(old_cost != cost){
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url: "/financial/ReceiveBill/OrderAdjust",
data:{'id':order_id,'cost':cost},
beforeSend:showLoading(),
success: function(data){
hideLoading();
if(data)
{
$('#old_cost').val(data);
var msg;
msg = $.globalMessenger().post({
message: '修改成本成功',
type: 'error',
showCloseButton: true
});
}else{
var msg;
msg = $.globalMessenger().post({
message: '修改成本失败',
type: 'error',
showCloseButton: true
});
}
}
});
}
}else if(is_price == 'memo'){
if(old_memo != memo){
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url: "/financial/ReceiveBill/OrderAdjust",
data:{'id':order_id,'memo':memo},
beforeSend:showLoading(),
success: function(data){
hideLoading();
if(data)
{
$('#old_memo').val(data);
var msg;
msg = $.globalMessenger().post({
message: '修改备注成功',
type: 'error',
showCloseButton: true
});
}else{
var msg;
msg = $.globalMessenger().post({
message: '修改备注失败',
type: 'error',
showCloseButton: true
});
}
}
});
}
}else if(is_price == 'weight'){
if(old_weight!= weight || old_send_weight!= send_weight){
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url: "/financial/ReceiveBill/OrderAdjust",
data:{'id':order_id,'product_id':product_id,'country_id':country_id,'weight':weight,'is_updaet_cost':is_updaet_cost,'channel_id':channel_id,'send_weight':send_weight},
beforeSend:showLoading(),
success: function(data){
hideLoading();
if(data == 'no_product_price')
{
$(".error_content").text('当前调整没有价格存在,请参考产品设置调整订单');
$(".alert").show();
}else if(data == 'no_channel_price'){
$('#cost').val(0);
$(".error_content").text('当前调整没有成本存在,请参考渠道设置调整订单');
$(".alert").show();
}else if(data == 'ok')
{
location = "";
}else if(data)
{
var obj = eval ("(" + data + ")");
$('#price').val(obj.product_price);
$('#cost').val(obj.cost_price);
$(".alert").hide();
$('#status_text').text(data);
$('#old_memo').val(data);
$('#old_weight').val(weight);
$('#old_send_weight').val(send_weight);
var msg;
msg = $.globalMessenger().post({
message: '保存成功',
type: 'error',
showCloseButton: true
});
}
}
});
}
}
}
function receive_bill_return(url)
{
var country_id = $('#country_id').val();
var product_id = $('#product_id').val();
var channel_id = $('#channel_id').val();
var weight = $('#weight').val();
if(country_id == '' || country_id == null || country_id == undefined || country_id ==0)
{
$(".error_content").text('请选择国家');
$(".alert").show();
$('#country_id').focus();
}else if(product_id == '' || product_id == null || product_id == undefined || product_id ==0)
{
$(".error_content").text('请选择产品');
$(".alert").show();
$('#product_id').focus();
}else if(channel_id == '' || channel_id == null || channel_id == undefined || channel_id ==0)
{
$(".error_content").text('请选择渠道');
$(".alert").show();
$('#channel_id').focus();
}else if(weight == '' || weight == null || weight == undefined || weight ==0)
{
$(".error_content").text('重量为必填项');
$(".alert").show();
$('#weight').focus();
}else{
if(url)
{
location = url;
}else{
location = "";
}
}
}
function payment_ordre_adjust_submit(is_cost)
{
var channel_id = $('#channel_id').val();
var order_id = $('#order_id').val();
var cost = $('#cost').val();
var old_cost = $('#old_cost').val();
var memo = $('#memo').val();
var old_memo = $('#old_memo').val();
var send_weight = $('#send_weight').val();
var old_send_weight = $('#old_send_weight').val();
if(is_cost == 'cost'){
if(cost != old_cost){
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url: "/financial/PaymentBill/OrderAdjust",
data:{'id':order_id,'cost':cost},
beforeSend:showLoading(),
success: function(data){
hideLoading();
if(data)
{
$('#old_cost').val(data);
var msg;
msg = $.globalMessenger().post({
message: '修改成本成功',
type: 'error',
showCloseButton: true
});
}else{
var msg;
msg = $.globalMessenger().post({
message: '修改成本失败',
type: 'error',
showCloseButton: true
});
}
}
});
}else{
$('#cost').val(old_cost);
}
}else if(is_cost == 'memo'){
if(old_memo != memo){
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url: "/financial/ReceiveBill/OrderAdjust",
data:{'id':order_id,'memo':memo},
beforeSend:showLoading(),
success: function(data){
hideLoading();
if(data)
{
$('#old_memo').val(data);
var msg;
msg = $.globalMessenger().post({
message: '修改备注成功',
type: 'error',
showCloseButton: true
});
}else{
var msg;
msg = $.globalMessenger().post({
message: '修改备注失败',
type: 'error',
showCloseButton: true
});
}
}
});
}
}else if(channel_id == '' || channel_id == null || channel_id == undefined || channel_id ==0)
{
$(".error_content").text('请选择渠道');
$(".alert").show();
$('#country_id').focus();
}else if(old_send_weight != send_weight){
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url: "/financial/PaymentBill/OrderAdjust",
data:{'id':order_id,'channel_id':channel_id,'send_weight':send_weight},
beforeSend:showLoading(),
success: function(data){
hideLoading();
if(data == 'no_channel_price'){
$('#cost').val(0);
$(".error_content").text('当前调整没有成本存在,请参考渠道设置调整订单');
$(".alert").show();
}else if(data == 'ok')
{
location = "";
}else if(data){
$('#cost').val(data);
$(".alert").hide();
$('#old_send_weight').val(send_weight);
msg = $.globalMessenger().post({
message: '保存成功',
type: 'error',
showCloseButton: true
});
}
}
});
}
}
//核对公司名是否存在
function checkcompany(value)
{
if(value=='')
{
$(".error_content").text('请填写公司名');
$(".alert").show();
$('#company_name').focus();
return false;
}else
{
$.ajax({
type: "POST",
url: "/setting/Company/checkCompany",
data:{'company_name':value},
success: function(data)
{
$(".alert").hide();
if(data==1)
{
$(".error_content").text('公司名已存在,请重新输入');
$(".alert").show();
$('#company_name').focus();
return false;
}else
{
$(".alert").hide();
return true;
}
}
});
}
}
//核对公司简称是否存在
function checkcompanyCode(value)
{
if(value=='')
{
$(".error_content").text('请填写公司简称');
$(".alert").show();
$('#company_code').focus();
return false;
}else
{
if(!isChn(value))
{
$(".error_content").text('公司简码中不能含有中文');
$(".alert").show();
$('#company_code').focus();
return false;
}
$.ajax({
type: "POST",
url: "/setting/Company/checkCompanyCode",
data:{'company_code':value},
success: function(data)
{
if(data==1)
{
$(".error_content").text('公司简称已存在,请重新输入');
$(".alert").show();
$('#company_code').focus();
return false;
}else
{
$(".alert").hide();
$('#company_tel').focus();
return true;
}
}
});
}
}
//验证公司
function check_add_company(type)
{
var company_name = $('#company_name').val();
var company_code = $('#company_code').val();
var company_address = $('#company_address').val();
var company_email = $('#company_email').val();
var company_tel = $('#company_tel').val();
if(company_name=='')
{
$(".error_content").text('请填写公司名');
$(".alert").show();
$('#company_name').focus();
return false;
}else if(company_code=='')
{
$(".error_content").text('请填写公司简码');
$(".alert").show();
$('#company_code').focus();
return false;
}else if(!isChn(company_code))
{
$(".error_content").text('公司简码中不能含有中文');
$(".alert").show();
$('#company_code').focus();
return false;
}else if(company_tel=='')
{
$(".error_content").text('请填写公司电话');
$(".alert").show();
$('#company_tel').focus();
return false;
}else if(company_email){
if(!(/^[a-zA-Z0-9_.-]+\@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]{2,3}){1,2}$/.test(company_email)))
{
$(".error_content").text('请填写正确的邮箱');
$(".alert-error").show();
$("#company_email").focus();
}else if(company_address=='')
{
$(".error_content").text('请填写公司地址');
$(".alert").show();
$('#company_address').focus();
return false;
}else
{
var str1 = true;
var str2 = true;
str1 = verfy_phone(company_tel);
if(company_email!='')
{
str2 = verfy_email(company_email);
}
if(str1 && str2)
{
$('.alert').hide();
$('#myModal').modal('hide');
if(type==1)
{
$.ajax({
type:"POST",
url: "/setting/Company/Create?type=1",
beforeSend:showLoading(),
data:{'EntCompany[company_name]':company_name,'EntCompany[company_code]':company_code,
'EntCompany[company_tel]':company_tel,'EntCompany[company_email]':company_email,
'EntCompany[company_address]':company_address
},
success: function(msg)
{
hideLoading();
$('#user_company').empty();
$('#user_company').html(msg);
}
});
}else
{
$('#company_form').submit();
}
}
}
}else if(company_address=='')
{
$(".error_content").text('请填写公司地址');
$(".alert").show();
$('#company_address').focus();
return false;
}else
{
var str1 = true;
var str2 = true;
str1 = verfy_phone(company_tel);
if(company_email!='')
{
str2 = verfy_email(company_email);
}
if(str1 && str2)
{
$('.alert').hide();
$('#myModal').modal('hide');
if(type==1)
{
$.ajax({
type:"POST",
url: "/setting/Company/Create?type=1",
beforeSend:showLoading(),
data:{'EntCompany[company_name]':company_name,'EntCompany[company_code]':company_code,
'EntCompany[company_tel]':company_tel,'EntCompany[company_email]':company_email,
'EntCompany[company_address]':company_address
},
success: function(msg)
{
hideLoading();
$('#user_company').empty();
$('#user_company').html(msg);
}
});
}else
{
$('#company_form').submit();
}
}
}
}
function select_standard(id)
{
if($('#input_'+(parseInt(id)+1)).is(':checked'))
{
var text = $('#standard_'+(parseInt(id)+1)).text();
var tr = '';
tr +='';
tr +='';
tr +=' | ';
tr +='';
tr +=text;
tr +=' | ';
tr += ' | ';
tr +'';
tr +=' | ';
tr +=' | ';
tr +='';
tr +='';
tr +='';
tr +='';
tr +=' | ';
tr += '
';
$('#relation table').append(tr);
}else{
$('.user_'+(parseInt(id)+1)).parent("tr:last").prev("tr").find("td").eq(0).find('input').attr('checked',true);
$('#tr_'+(parseInt(id)+1)).remove();
}
}
function select_user(id)
{
var order = $('#select_order').val();
if($('#user_input_'+(parseInt(id)+1)).is(':checked'))
{
if(order)
{
$('#select_order').val(order+','+(parseInt(id)+1));
}else{
$('#select_order').val((parseInt(id)+1));
}
}else{
var select_order = order.split(',');
var str = '';
for(var i in select_order)
{
if(select_order[i] != parseInt(id)+1)
{
if(str)
{
str +=','+select_order[i];
}else{
str +=select_order[i];
}
}
}
$('#select_order').val(str);
}
}
function mapping()
{
var order = $('#select_order').val();
var standard_number = $('input:radio[name="action_item"]:checked').val();
var checked = $('input:checkbox[name="orders"]:checked').val();
if(checked)
{
$(".alert-error").hide();
var select_order = order.split(',');
var text = '';
var number ='';
var key = '';
for(var i in select_order)
{
if(text)
{
text += ','+$('#user_'+select_order[i]).text();
}else{
text += $('#user_'+select_order[i]).text();
}
if(number)
{
key +=','+(select_order[i]-1);
number +=','+select_order[i];
}else{
key +=select_order[i]-1;
number +=select_order[i];
}
var user_number = $('.user_number_'+(parseInt(standard_number)+1)).text();
if(user_number != '')
{
$('#user_input_'+user_number).parents('tr:first').css('backgroundColor','#ffffff');
}
$('#user_input_'+select_order[i]).parents('tr:first').css('backgroundColor','#DDDDDD');
$('#user_input_'+select_order[i]).attr('checked',false);
}
$('.user_'+(parseInt(standard_number)+1)).text(text);
$('.user_number_'+(parseInt(standard_number)+1)).text(number);
$('#user_relation_'+(parseInt(standard_number)+1)).val(key);
$('#select_order').val('');
$('.user_'+(parseInt(standard_number)+1)).parent("tr:first").next("tr").find("td").eq(0).find('input').attr('checked',true);
}else{
$(".error_content").text('请至少选择一个客户模版数据');
$(".alert-error").show();
}
}
function delete_relation(id)
{
$('#input_'+(parseInt(id)+1)).attr('checked',false);
$('.user_'+(parseInt(id)+1)).parent("tr:last").prev("tr").find("td").eq(0).find('input').attr('checked',true);
$('#tr_'+(parseInt(id)+1)).remove();
}
function template_form_submit(id)
{
var name =$('#name').val();
var length =$('#length').val();
if(name == '' || name == null || name == undefined || name==0)
{
$(".error_content").text('请填写模版名称');
$(".alert-error").show();
$('#name').focus();
}else{
var data = new Array();
$("input:radio[name='action_item']").each(function (){
data.push($(this).val());
});
var user = false;
for(var i in data)
{
user = $('#user_relation_'+(parseInt(data[i])+1)).val();
if(user == '' || user == null || user == undefined)
{
var text = $('#standard_'+(parseInt(data[i])+1)).text()
$(".error_content").text('请选择关联 ,标准模版: '+text+' 的,客户模版字段');
$(".alert-error").show();
$('.user_'+(parseInt(data[i])+1)).attr('checked',true);
user = false;
return;
}
}
if(user != false)
{
if(id != 'update_template_form')
{
var file_name = $('#file_name').val();
var format = $('#format').val();
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url: "/order/Order/TemplateMatch",
data:{'file_name':file_name,'format':format},
success: function(data){
if(data == 1)
{
$('#'+id).submit();
}else{
$(".error_content").text('系统已存在相同模版 :'+data+',可直接导入模版');
$(".alert-error").show();
}
}
});
}else{
$('#'+id).submit();
}
}
}
}
function delete_template(id,url,del_id,name)
{
$('#delete_url').val(url);
$('#del_id').val(del_id);
$('#del_name').text('('+name+')');
$('#content_id').val(id);
$('#del_text_name').val(name);
$('#'+id).modal('toggle');
}
function confirm_delete_template()
{
var url = $('#delete_url').val();
var del_id = $('#del_id').val();
$.ajax({
type: "POST",
url: url,
data:{'ajax':'ajax'},
success: function(data){
if(data)
{
$('#'+del_id).parents('tr:first').fadeOut(1000);
}
}
});
}
function sigle_nuclear(id)
{
var supply_id = $('#supply_id').val();
var data = $('#data').val();
if(supply_id == '' || supply_id == null || supply_id == undefined || supply_id==0)
{
$(".error_content").text('请选择供应商');
$(".alert-error").show();
$('#supply_id').focus();
}else if(data == '' || data == null || data == undefined || data==0){
$(".error_content").text('请输入审核数据');
$(".alert-error").show();
}else{
$('#'+id).submit();
}
}
function all_nuclear_single(name)
{
var data=new Array();
$("input:hidden[name='select_orders[]']").each(function (){
data.push($(this).val());
});
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url: "/financial/PaymentBill/AllSingleSingle",
data:{'select_orders':data},
success: function(data){
if(data == 1)
{
var msg;
msg = $.globalMessenger().post({
message: '核单成功,可到生成账单界面查看订单',
type: 'error',
showCloseButton: true
});
}else{
var msg;
msg = $.globalMessenger().post({
message: '核单失败,请联系管理员',
type: 'error',
showCloseButton: true
});
}
}
});
}
function set_mark(name)
{
var data=new Array();
$("input:hidden[name='"+name+"[]']").each(function (){
data.push($(this).val());
});
var bill_mark = $('#'+name+'_mark').val();
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url: "/financial/PaymentBill/SetMark",
data:{'select_orders':data,'bill_mark':bill_mark},
success: function(data){
if(data == 1)
{
var msg;
msg = $.globalMessenger().post({
message: '设置标识成功',
type: 'error',
showCloseButton: true
});
}else{
var msg;
msg = $.globalMessenger().post({
message: '设置标识失败,请联系管理员',
type: 'error',
showCloseButton: true
});
}
}
});
}
function createRoleCheck(type)
{
var role_name = $('#role_name').val();
var role_grade_id = $('#role_grade_id').val();
if(role_name=='')
{
$('.error_content').text('角色名不能为空');
$('.alert').show();
return false;
}else
{
$.ajax({
type: "POST",
url: "/setting/Role/CheckRoleName",
data:{'role_name':role_name},
beforeSend:showLoading(),
success: function(data){
hideLoading();
if(data ==1)
{
$('.error_content').text('角色名已存在');
$('.alert').show();
return false;
}else
{
if(role_grade_id==''||role_grade_id==0)
{
$('.error_content').text('请选择角色名等级');
$('.alert').show();
return false;
}else
{
$('.alert').hide();
$('#role_create').modal('hide');
if(type==1)
{
$.ajax({
type:"POST",
url: "/setting/Role/Create?type=1",
beforeSend:showLoading(),
data:{'role_name':role_name,'role_grade_id':role_grade_id},
success: function(msg)
{
hideLoading();
$('#user_role').empty();
$('#user_role').html(msg);
}
});
}else
{
$('#role_create_form').submit();
}
}
}
}
});
}
}
function checkAllBox(self_id,checkBoxClass)
{
if($('#'+self_id).is(':checked'))
{
$('.'+checkBoxClass).attr('checked',true);
$('.shipping_service').attr('checked',true);
}else
{
$('.'+checkBoxClass).attr('checked',false);
$('.shipping_service').attr('checked',false);
}
}
function delete_weights(order_id)
{
var select =[];
if(order_id)
{
select.push(order_id);
}else{
$('input[name="operating_weight[]"]:checked').each(function(){
select.push($(this).val());
});
}
if(select.length == 0)
{
alert('请选择要操作的订单');
}else
{
$('#delete_weights').submit();
}
}
function deleteProductPrice(price_type)
{
var select =[];
$('input[name="operating_weight_'+price_type+'[]"]:checked').each(function(){
select.push($(this).val());
});
if(select.length == 0)
{
alert('请选择要操作的订单');
}else
{
$('#deleteProductPrice_'+price_type).submit();
}
}
function createProblemType(id)
{
var name = $('#create_name').val();
if(name == '' || name == null || name == undefined || name==0)
{
$(".error_content").text('名称为必填');
$(".alert-error").show();
$('#create_name').focus();
}else{
$('#'+id).submit();
}
}
function update_problem_type(id,url)
{
$.ajax({
type: "POST",
url: url,
//data:{},
success: function(data){
$('#'+id).html(data);
}
});
$('#'+id).modal('toggle');
}
function update_problem_type_submit(id)
{
var name = $('#update_name').val();
if(name == '' || name == null || name == undefined || name==0)
{
$(".error_content").text('名称为必填');
$(".alert-error").show();
$('#update_name').focus();
}else{
$('#'+id).submit();
}
}
function createProblemReason(id)
{
var type_id = $('#create_type_id').val();
var name = $('#create_name').val();
if(type_id == '' || type_id == null || type_id == undefined || type_id==0)
{
$(".error_content").text('请选择问题类型');
$(".alert-error").show();
$('#create_type_id').focus();
}else if(name == '' || name == null || name == undefined || name==0)
{
$(".error_content").text('名称为必填');
$(".alert-error").show();
$('#create_name').focus();
}else{
$('#'+id).submit();
}
}
function update_problem_reason_submit(id)
{
var type_id = $('#update_type_id').val();
var name = $('#update_name').val();
if(type_id == '' || type_id == null || type_id == undefined || type_id==0)
{
$(".error_content").text('请选择问题类型');
$(".alert-error").show();
$('#create_type_id').focus();
}else if(name == '' || name == null || name == undefined || name==0)
{
$(".error_content").text('名称为必填');
$(".alert-error").show();
$('#create_name').focus();
}else{
$('#'+id).submit();
}
}
function model_create_submit(id)
{
var class_name = $('#class_name').val();
var model_name = $('#model_name').val();
var model_key = $('#model_key').val();
if(class_name == '' || class_name == null || class_name == undefined || class_name==0)
{
$(".error_content").text('请选择模块');
$(".alert-error").show();
$('#class_name').focus();
}else if(model_name == '' || model_name == null || model_name == undefined || model_name==0)
{
$(".error_content").text('名称为必填');
$(".alert-error").show();
$('#model_name').focus();
}else if(model_key == '' || model_key == null || model_key == undefined || model_key==0)
{
$(".error_content").text('URL为必填');
$(".alert-error").show();
$('#model_key').focus();
}else{
$('#'+id).submit();
}
}
function check_country_code()
{
var country_code = $("#country_code").val();
if(country_code.length>0)
{
$.ajax({
type:"POST",
url:"/logistics/TotalReceive/checkCountryCode",
data: "country_code="+country_code,
beforeSend: showLoading(),
success:function(msg){
hideLoading();
if($.trim(msg) == 'error')
{
$(".error_content").text('该国家简写不存在!');
$(".alert").show();
$("#country_code").focus();
}else
{
$(".alert").hide();
$('#country').val($.trim(msg));
check_product_country();
//$("#country option[value='"+msg+"']").attr("selected","selected");
}
}
});
}
}
function check_product_country()
{
var shipping_service = $('#shipping_service').val();
if(shipping_service==undefined)
{
var shipping_service = $('#create_product_id').val();
}
var country = $('#country').val();
if(country==undefined)
{
var country = $('#country_id').val();
}
$('#product_country').val($('#shipping_service').find("option:selected").text());
$.ajax({
type:"POST",
url:"/logistics/Orders/CountryMatch",
data: "product_id="+shipping_service+"&country_id="+country,
beforeSend: showLoading(),
success:function(msg)
{
hideLoading();
var obj= eval('('+msg+')');
$('#country_code').val(obj.country_code);
if(shipping_service!='')
{
if(obj.success)
{
$('#product_country').val('1');
$('.alert').hide();
return true;
}else
{
$('.error_content').text("该运输方式不支持该国家");
$('.alert').show();
//$('#country_code').focus();
return false;
}
}
}
});
}
function delete_format(id,url,format_name,del_id)
{
$('#del_id').val(del_id);
$('#del_name').text('('+format_name+')');
$('#content_id').val(id);
$('#delete_url').val(url);
$('#'+id).modal('toggle');
}
function confirm_delete_format()
{
var url = $('#delete_url').val();
var del_id = $('#del_id').val();
$.ajax({
type: "POST",
url: url,
data:{'ajax':'ajax'},
success: function(data){
if(data ==1)
{
$('#delete_'+del_id).parents('tr:first').fadeOut(1000);
}else{
alert(data);
}
}
});
}
function check_memos()
{
var memo = $("#extra_text").val();
if(memo=='')
{
$(".error_content").text('请填写备注');
$(".alert").show();
return false;
}else
{
$(".error_content").text('');
$(".alert").hide();
$("#complete_total").submit();
}
}
function store_channge()
{
var store_start = $('#GoodsTransfer_store_start').val();
if(store_start==0)
{
$(".error_content").text('请选择出货仓库');
$(".alert").show();
return false;
}else
{
$(".alert").hide();
$.ajax({
type: "POST",
url: "/logistics/GoodsTransfer/StoreChange",
beforeSend: showLoading(),
data:{'store_start':store_start},
success:function(data){
hideLoading();
$("#store_end").empty();
$("#store_end").html(data);
}
});
}
}
function export_submit(id)
{
$('#is_export').val(1);
document.getElementById(id).submit();
}
function additional_chargeback(id)
{
$('#'+id).modal('toggle');
}
function additional_chargeback_confirm(id)
{
var userID = $('#select_userID').val();
var amount = $('#amount').val();
var currency_id = $('#currency_id').val();
var type_id = $('#type_id').val();
var memo = $('#memo').val();
if(userID == '' || userID == null || userID == undefined || userID==0)
{
$(".error_content").text('请选择用户');
$(".alert-error").show();
$('#select_userID').focus();
}else if(amount == '' || amount == null || amount == undefined || amount==0)
{
$(".error_content").text('金额为必填');
$(".alert-error").show();
$('#amount').focus();
}else if(currency_id == '' || currency_id == null || currency_id == undefined || currency_id==0)
{
$(".error_content").text('请选择币种');
$(".alert-error").show();
$('#currency_id').focus();
}else if(type_id == '' || type_id == null || type_id == undefined || type_id==0)
{
$(".error_content").text('请选择操作类型');
$(".alert-error").show();
$('#type_id').focus();
}else if(memo == '' || memo == null || memo == undefined || memo==0)
{
$(".error_content").text('请填写备注');
$(".alert-error").show();
$('#memo').focus();
}else{
$('#'+id).submit();
}
}
function upload_annex(id)
{
var arr= new Array('txt','jpg','png','xls','csv','jpeg','rar','zip','doc','docx','xlsx','TXT','JPG','PNG','XLS','CSV','JPEG','RAR','ZIP','DOC','DOCX','XLSX');
var file_name = $('#fileName').val();
if(file_name == '' || file_name == null || file_name == undefined || file_name==0)
{
$(".error_content").text('请选择附件');
$(".alert-error").show();
$('#fileName').focus();
}else{
var suffix = file_name.split('.');
var is_support = $.inArray(suffix[suffix.length-1],arr);
if(is_support == -1)
{
$(".error_content").text('暂不支持该格式上传');
$(".alert-error").show();
$('#fileName').focus();
}else{
$('#'+id).submit();
}
}
}
function delete_annex(id,annex_id,text)
{
$('#content_id').val(id);
$('#delete_id').val(annex_id);
$('#show_del_name').text(text);
$('#'+id).modal('show');
}
function annex_delete_confirm()
{
var id = $('#delete_id').val();
$.ajax({
type: "POST",
url: "/order/Order/DeletePorblemAnnex",
data:{'id':id},
success: function(data){
if(data)
{
$('#del_'+id).parents('li:first').fadeOut(1000);
}else{
var msg;
msg = $.globalMessenger().post({
message: '操作失败,请联系管理员',
type: 'error',
showCloseButton: true
});
}
}
});
}
//验证偏远
function get_remote(id)
{
var product_id = $('#shipping_service').val();
var city = $('#create_buyer_city').val();
var code = $('#create_buyer_zip').val();
var country_id = $('#country').val();
$('#remote').empty();
if(product_id=='')
{
$('#'+id+' li:eq(0) a').tab('show');
$('#shipping_service').focus();
$('.error_content').text('请选择运输方式');
$('.alert').show();
return false;
}else if(country_id=='0')
{
$('#'+id+' li:eq(0) a').tab('show');
$('#order_create_tabs_tab_1').tab('show');
$('#country').focus();
$('.error_content').text('请选择运国家');
$('.alert').show();
return false;
}else if(city=='' && code=='')
{
$('#'+id+' li:eq(1) a').tab('show');
if(city=='')
{
$('#create_buyer_city').focus();
$('.error_content').text('城市不能为空');
$('.alert').show();
}else
{
$('#create_buyer_zip').focus();
$('.error_content').text('邮编不能为空');
$('.alert').show();
}
}else
{
$.ajax({
type: "POST",
url: "/order/Order/GetRemote",
data:{'product_id':product_id,'city':city,'code':code,'country_id':country_id},
success: function(data){
if(data==1)
{
$('#remote').html('地址信息存在偏远');
$('#is_remote').val(1);//订单设置为偏远
}else
{
$('#remote').html('地址信息不是偏远');
}
}
});
}
}
//只能输入数字或者小数点
function check(e) {
var re = /^\d+(?=\.{0,1}\d+$|$)/
if (e.value != "")
{
if (!re.test(e.value))
{
// e.value = "";
$(e).focus();
}else
{
$(e).css('background-color','');
}
}else
{
$(e).css('background-color','#FFFFCC');
$(e).focus();
}
}
//只能输入数字或者小数点
function checkNum(val) {
var re = /^\d+(?=\.{0,1}\d+$|$)/
if (e.value != "")
{
if (!re.test(e.value))
{
return false;
}
}else
{
return false;
}
}
function onKeyNum(obj)
{
//先把非数字的都替换掉,除了数字和.
obj.value = obj.value.replace(/[^\d.]/g,"");
//必须保证第一个为数字而不是.
obj.value = obj.value.replace(/^\./g,"");
//保证只有出现一个.而没有多个.
obj.value = obj.value.replace(/\.{2,}/g,".");
//保证.只出现一次,而不能出现两次以上
obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
}
function changePriceTypes(id,tid,sid)
{
$('#'+tid+'_'+id).css('display','table-row');
$('#'+sid+'_'+id).css('display','none');
$('#type_'+id).val(tid);
if(tid == 'added')
{
$('#added_start_weight'+id).val($('#standard_start_weight'+id).val());
$('#added_end_weight'+id).val($('#standard_end_weight'+id).val());
$('#added_price'+id).val($('#standard_price'+id).val());
$('#added_r_price'+id).val($('#standard_price'+id).val());
$('#added_is_price_type_'+id).val(2);
}else
{
$('#standard_start_weight'+id).val($('#added_start_weight'+id).val());
$('#standard_end_weight'+id).val($('#added_end_weight'+id).val());
$('#standard_price'+id).val($('#added_price'+id).val());
$('#standard_is_price_type_'+id).val(1);
}
}
function change_factor()
{
var len = $('.checkbox:checked').length;
if(len>0)
{
var value = $('#factor').val();
$('.checkbox:checked').each(function(i,search)
{
var id = $(search).val();
$('#added_factor_'+id).val(value);
$(search).attr('checked',false);
});
$('#checkAllMenu').attr('checked',false);
}
}
function add_volume(length)
{
var len = $('#add_price tr').length;
var id = (len-1)/2+1;
var tr = '';
tr+='';
tr+='';
tr+='';
tr+=' | ';
tr+=' | ';
for(var i=0;i < length;i++)
{
tr+='';
tr+='';
tr+=' | ';
}
tr+=' | ';
tr+='
';
tr+='';
tr+='';
tr+='';
tr+=' | ';
tr+='';
tr+=' ';
tr+='-';
tr+='/';
tr+=' | ';
for(var i=0;i';
tr+='';
tr+='/';
tr+='';
}
tr+=' | ';
tr+='
';
$('#add_price').append(tr);
}
function drop_volume(id)
{
var len = $("#add_price").find('tr').size();
if(len>3)
{
$('#standard_'+id).remove();
$('#added_'+id).remove();
}
}
/**导入基础价格**/
function setting_verification(type)
{
var cn_name = $('#cn_name').val();
var en_name = $('#en_name').val();
var code = $('#code').val();
var percentage = $('input[name=percentage]').val();
var price_type = $("input[name='price_type[]']:checked").size();
if(cn_name =='')
{
$(".error_content").text('请填写产品名称');
$(".alert").show();
$('#cn_name').focus();
return false;
/*
}else if(en_name =='')
{
$(".error_content").text('请选填写产品英文');
$(".alert").show();
$('#en_name').focus();
return false;
*/
}else if(code =='')
{
$(".error_content").text('产品货运代号');
$(".alert").show();
$('#code').focus();
return false;
}else if(code)
{
if(type){
$.ajax({
type: "POST",
url: "/products/Channel/VerifyCode",
data:{'value':code},
success: function(data){
if(data == 2)
{
$(".error_content").text(code+'简称已存在,请重新填写');
$(".alert").show();
$('#code').focus();
return false;
}else if(price_type <=0)
{
$(".error_content").text('请选择价格类型');
$(".alert").show();
return false;
}else if(percentage == '')
{
$(".error_content").text('请输入百分比');
$(".alert").show();
$('input[name=percentage]').addClass('error');
$('input[name=percentage]').focus();
return false;
/*
}else if(type)
{
var product_code = $('input[name=product_code]').val();
if(product_code == '')
{
$(".error_content").text('请选择产品');
$(".alert").show();
$('input[name=product_code]').addClass('error');
$('input[name=product_code]').focus();
return false;
}else
{
$("#add_discount").submit();
}
*/
}else
{
$("#add_discount").submit();
}
}
});
}else{
$.ajax({
type: "POST",
url: "/products/Product/VerifyCode",
data:{'value':code},
success: function(data){
if(data == 2)
{
$(".error_content").text(code+'简称已存在,请重新填写');
$(".alert").show();
$('#code').focus();
return false;
}else if(price_type <=0)
{
$(".error_content").text('请选择价格类型');
$(".alert").show();
return false;
}else if(percentage == '')
{
$(".error_content").text('请输入百分比');
$(".alert").show();
$('input[name=percentage]').addClass('error');
$('input[name=percentage]').focus();
return false;
}else if(type)
{
var product_code = $('input[name=product_code]').val();
if(product_code == '')
{
$(".error_content").text('请选择产品');
$(".alert").show();
$('input[name=product_code]').addClass('error');
$('input[name=product_code]').focus();
return false;
}else
{
$("#add_discount").submit();
}
}else
{
$("#add_discount").submit();
}
}
});
}
}else if(price_type <=0)
{
$(".error_content").text('请选择价格类型');
$(".alert").show();
return false;
}else if(percentage == '')
{
$(".error_content").text('请输入百分比');
$(".alert").show();
$('input[name=percentage]').addClass('error');
$('input[name=percentage]').focus();
return false;
}else if(type)
{
var product_code = $('input[name=product_code]').val();
if(product_code == '')
{
$(".error_content").text('请选择产品');
$(".alert").show();
$('input[name=product_code]').addClass('error');
$('input[name=product_code]').focus();
return false;
}else
{
$("#add_discount").submit();
}
}else
{
$("#add_discount").submit();
}
}
/**导入基础价格**/
function set_verifin(type)
{
var code = $('#code').val();
var percentage = $('input[name=percentage]').val();
var price_size = $("input[name='price_type[]']:checked").size();
if(code =='')
{
$(".error_content").text('请选择运输方式');
$(".alert").show();
$('#code').focus();
return false;
}else if(price_size <=0)
{
$(".error_content").text('请选择价格类型');
$(".alert").show();
return false;
}else if(percentage == '')
{
$(".error_content").text('请输入百分比');
$(".alert").show();
$('input[name=percentage]').addClass('error');
$('input[name=percentage]').focus();
return false;
}else if(type)
{
var product_code = $('input[name=product_code]').val();
if(product_code == '')
{
$(".error_content").text('请选择产品');
$(".alert").show();
$('input[name=product_code]').addClass('error');
$('input[name=product_code]').focus();
return false;
}else
{
$("#add_discount").submit();
}
}else
{
$("#add_discount").submit();
}
}
function checkbox(id,fid)
{
if($('#'+id).attr('checked')=='checked')
{
$('#'+fid).removeAttr('checked');
}else
{
$('#'+fid).attr('checked',true);
}
}
function check_input()
{
var j = 0;
var x = 0;
var z = 0;
var m = 0;
var obj;
var obj1;
$('.stand:visible').each(
function(i,search)
{
z++;
var value = $(search).val();
if(value=='')
{
$(search).css('background-color','#FFFFCC');
if(x==0)
{
obj = $(search);
x++;
}
j++;
}else
{
$(search).css('background-color','white');
}
}
);
if(j==0)
{
$('.factor:visible').each(
function(i,search)
{
var value = $(search).val();
if(value > 0)
{
$(search).css('background-color','white');
}else{
$(search).css('background-color','#FFFFCC');
obj1 = $(search);
m++;
}
});
if(m>0)
{
$(".error_content").text('区间值必须大于0');
$(".alert-error").show();
$(obj1).focus();
return false;
}
}
if(j>0)
{
$(".error_content").text('重量与价格为空或者填写有误请确认');
$(".alert-error").show();
$(obj).focus();
return false;
}else if(z==0)
{
$(".error_content").text('数据不能为空');
$(".alert-error").show();
return false;
}else
{
$(".error_content").text('');
$(".alert-error").hide();
return true;
}
}
function add_zone_verification(product_id,url)
{
var zone_id = $('#zone_id').val();
if(zone_id == '' || zone_id == null || zone_id == undefined || zone_id ==0)
{
$(".error_content").text('分区不能为空');
$(".alert-error").show();
return false;
}else{
$.ajax({
type: "POST",
url: url,
data:{'add_zone':'add_zone','zone_id':zone_id,'product_id':product_id},
success: function(data){
if(data == 1)
{
$(".alert-error").hide();
$('#zone_error').empty();
$('#zone_id').removeClass('error');
$('#add_zone_form').submit();
}else{
$('#zone_id').addClass('error');
$('#zone_error').html(data);
}
}
});
}
}
function show_re_price(sid,tid)
{
$('#'+sid).show();
$('#'+sid).focus();
$('#'+tid).hide();
}
function form_submit(times)
{
var turn = check_input();
if(!turn)
{
$('form').submit();
return turn;
}
var strData = $('form').serialize();
var iCount; //拆分为多少个域
var strData; //原始数据
var iMaxChars = 50000;//考虑到汉字为双字节,域的最大字符数限制为50K
var iBottleNeck = 100000;//如果数据超过2M字,需要提示用户
var strHTML;
if (strData.length > iBottleNeck)
{
if (confirm("您要导入的数据量太大,如果您坚持提交,注意需要较长时间才能提交成功,\n建议您拆分为几部分分别导入。\n\n是否坚持提交?") == false)
{
return false;
}else
{
retValue = true;
}
}
iCount = parseInt(strData.length / iMaxChars) + 1;
//hdnCount记录原数据域拆分为多少个子域
strHTML ="";
if(times==1)
{
strHTML +="";
}
//生成各子域的HTML代码
strHTML += '数据正在导入,请稍后
';
for (var i = 1; i <= iCount; i++)
{
strHTML += "\n" + "";
}
//在Form中DIV(divHidden)内动态插入各hidden域的HTML代码
$('form').empty();
$('form').html(strHTML);
$('form').submit();
}
function notechange(val)
{
if(val==1)
{
$('#suser').val('所有用户');
$('#select_user').val('所有用户');
$('#select_id').val('所有用户');
}else if(val==2)
{
window.open('/user/Grade/SelectGrade', '',
'height=500, width=900, top=100,left=300, toolbar=yes, menubar=no,z-look=yes,alwaysRaised=yes, scrollbars=yes, resizable=yes,location=no, status=no');
}else if(val==3)
{
window.open('/user/User/SelectUser', '',
'height=500, width=900, top=100,left=300, toolbar=yes, menubar=no,z-look=yes, alwaysRaised=yes,scrollbars=yes, resizable=yes,location=no, status=no');
}
}
function add_grade(type)
{
var grade_name = $("#name").val();
if(grade_name!='')
{
$.ajax({
type:"POST",
url:"/user/Grade/CheckGrade",
data:{'name':grade_name},
success:function(data)
{
if(data==1)
{
$('.error_content').text('等级的名字已存在,请重新填写');
$('.alert').show();
return false;
}else
{
$('.alert').hide();
$('#myModal').modal('hide');
if(type==1)
{
$.ajax({
type:"POST",
url: "/user/User/getGrade",
beforeSend:showLoading(),
data:{'name':grade_name},
success: function(msg)
{
hideLoading();
$('#grade').empty();
$('#grade').html(msg);
}
});
}else
{
$("#user-grade-form").submit();
}
}
}
});
}else
{
$('.error_content').text('等级的名字不能为空');
$('.alert').show();
return false;
}
}
function show(obj,update_id,update_name,is_show_set_product,id)
{
$('#update_name').val(update_name);
$('#update_id').val(update_id);
$('#grade_id').val(id);
if(is_show_set_product == 1){
$('#update_is_show_set_product').attr("checked",true);
}
$('#'+obj).modal('toggle');
}
function update_grade()
{
var grade_name = $("#update_name").val();
var grade_id = $('#grade_id').val();
if(grade_name!='')
{
$.ajax({
type:"POST",
url:"/user/Grade/CheckGrade",
data:{'name':grade_name,'grade_id':grade_id},
success:function(data)
{
if(data==1)
{
$('.error_content').text('等级的名字已存在,请重新填写');
$('.alert').show();
return false;
}else
{
$('.alert').hide();
$("#update-grade-form").submit();
}
}
});
}else
{
$('.error_content').text('等级的名字不能为空');
$('.alert').show();
return false;
}
}
function show_track_order_counts()
{
var params = $("#sift_order_form").serialize();
$.ajax({
type: "POST",
url: "/logistics/Orders/ShowTrackOrderCount",
data:params,
success: function(msg)
{
var data = eval('(' + msg + ')');
var len = data.length;
for(var i=0;i < len;i++)
{
$("#status_"+data[i]['status']).empty();
$("#status_"+data[i]['status']).html(data[i]['count']);
}
}
});
}
function refushOnTime(id)
{
$.ajax({
type: "POST",
url: "/logistics/Orders/trackInfoNoTime",
data:{'id':id},
beforeSend:showTrackInfoLoading('trackinfo'),
success: function(msg)
{
$("#trackinfo").empty();
$("#trackinfo").html(msg);
}
});
}
function showTrackInfoLoading(obj)
{
$('#'+obj).empty();
var img = ' |
';
$('#'+obj).html(img);
}
function changePriceType(type)
{
var base_id = $('#base_id').val();
if(base_id!='')
{
$.ajax({
type: "POST",
url: "/products/Product/changePriceType",
data:{'id':base_id},
beforeSend:showLoading(),
success: function(msg)
{
hideLoading();
$('#is_checked').attr('checked',false);
if(msg==1)
{
$('#package').css('display','inline');
}else
{
$('#package').css('display','none');
}
}
});
}
}
function setProductAttrbute(obj)
{
var type_id = $('#type_id').val();
if(type_id==1||type_id==4)
{
$('#'+obj+'_deduction_method').val(3);
$('#'+obj+'_volumetric_weight').val(1);
$('#'+obj+'_is_tracking').val(1);
$('#'+obj+'_deduction_method option[value="1"]').hide();
$('#'+obj+'_deduction_method option[value="2"]').show();
$('#'+obj+'_deduction_method option[value="3"]').show();
$('#metric_factors_required').show();
}else
{
$('#'+obj+'_deduction_method').val(2);
$('#'+obj+'_volumetric_weight').val(0);
$('#'+obj+'_is_tracking').val(0);
$('#'+obj+'_deduction_method option[value="1"]').show();
$('#'+obj+'_deduction_method option[value="2"]').show();
$('#'+obj+'_deduction_method option[value="3"]').hide();
$('#metric_factors_required').hide();
}
}
function setProductType(obj)
{
var type_id = $('#type_id').val();
if(type_id==1||type_id==4)
{
$('#'+obj+'_deduction_method option[value="1"]').hide();
}else
{
$('#'+obj+'_deduction_method option[value="3"]').hide();
}
}
function isChn(str)
{
if(/.*[\u4e00-\u9fa5]+.*$/.test(str))
{
return false;
}
return true;
}
function refresh(){
location.href=location.href;
}
function check_batch()
{
var product_id = $('#product_id').val();
var zone_id = $('#zone_id').val();
var weight = $('#weight').val();
if(product_id == '' || product_id == null || product_id == undefined)
{
$(".error_content").text('请选择产品');
$(".alert").show();
$("#product_id").focus();
return false;
}else if(zone_id == '' || zone_id == null || zone_id == undefined)
{
$(".error_content").text('请选择分区');
$(".alert").show();
$("#zone_id").focus();
return false;
}else if(weight == '' || weight == null || weight == undefined)
{
$(".error_content").text('请填写重量');
$(".alert").show();
$("#weight").focus();
return false;
}else
{
return true;
}
}
function showInput(obj,id)
{
if($(obj).attr("checked")=='checked')
{
$("#"+id).show();
}else
{
$("#"+id).hide();
}
}
function showReadOnly(obj,id)
{
if($(obj).attr("checked")=='checked')
{
$("#"+id).removeAttr("readonly")
}else
{
$("#"+id).attr('readonly','readonly');
}
}
function fareToPrice(obj,fare,price)
{
var fare_price = $("#"+fare).val();
var surcharge_price = $(obj).val();
fare_price = fare_price==''?0:parseFloat(fare_price);
surcharge_price = surcharge_price==''?0:parseFloat(surcharge_price);
var total_price = Fractional(fare_price+surcharge_price);
$("#"+price).val(total_price);
}
function show_problem()
{
if($("#Select_prombles").attr('checked')=='checked')
{
$.ajax({
type: "POST",
url: "/logistics/TotalReceive/showProblem",
beforeSend:showLoading(),
success: function(msg)
{
hideLoading();
$('#show_promble').html(msg);
$('#show_promble').css('display','table-row');
}
});
}else
{
$('.none').each(function(i,search)
{
$(search).css('display','none');
});
}
}
function show_reason(id)
{
$("input[name='is_type']").each(
function(i,search)
{
if($(search).val()!=id)
{
$(search).attr('checked',false);
}
}
);
$.ajax({
type: "POST",
url: "/logistics/TotalReceive/showReason",
beforeSend:showLoading(),
data:{'id':id},
success:function(msg)
{
hideLoading();
$('#show_reason').html(msg);
$('#show_reason').css('display','table-row');
}
});
}
function bill_upload_annex(id)
{
$('#'+id).modal('show');
}
function bill_annex_delete_confirm()
{
var id = $('#delete_id').val();
$.ajax({
type: "POST",
url: "/financial/ReceiveBill/DeleteAnnex",
data:{'id':id},
success: function(data){
if(data)
{
$('#del_'+id).parents('li:first').fadeOut(1000);
}else{
var msg;
msg = $.globalMessenger().post({
message: '操作失败,请联系管理员',
type: 'error',
showCloseButton: true
});
}
}
});
}
//选择产品类型选择包裹类型
function selectPriceType(product_type,price_type)
{
var product_type = $('#'+product_type).val();
if(product_type==2||product_type==3)
{
$('#'+price_type+' option[value="1"]').hide();
}else
{
$('#'+price_type+' option[value="1"]').show();
}
}
//清仓列表显示按钮
function batch_order_status()
{
var data = new Array();
$("input:checkbox[name='select_orders[]']").each(function (){
if($(this).attr("checked")=='checked'){
data.push($(this).val());
}
});
if(data.length > 0)
{
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url: "/financial/ReceiveBill/TotalPice",
data:{'orders':data},
beforeSend:showLoading(),
success: function(data){
hideLoading();
$('#total_price').text(data);
}
});
}else
{
}
}
function bulls_channel_update(id){
var data=new Array();
$("input:checkbox[name='select_orders[]']").each(function (){
if($(this).attr("checked")=='checked'){
data.push($(this).val());
}
});
if(data.length > 0){
var product_id = $('#product_id').val();
if(product_id){
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url: "/financial/PaymentBill/GetChannel",
data:{'product_id':product_id},
beforeSend:showLoading(),
success: function(data){
hideLoading();
$('#update_channel').html(data);
}
});
$('#'+id).modal('show');
}else{
var msg;
msg = $.globalMessenger().post({
message: '请先点击筛选,然后选择产品',
type: 'error',
showCloseButton: true
});
}
}else{
var msg;
msg = $.globalMessenger().post({
message: '请选择要操作的订单',
type: 'error',
showCloseButton: true
});
}
}
function bulls_product_update(id){
var data=new Array();
$("input:checkbox[name='select_orders[]']").each(function (){
if($(this).attr("checked")=='checked'){
data.push($(this).val());
}
});
if(data.length > 0){
$('#'+id).modal('show');
}else{
var msg;
msg = $.globalMessenger().post({
message: '请选择要操作的订单',
type: 'error',
showCloseButton: true
});
}
}
function show_bill_search(id,where,obj,form_id)
{
$('.bill_prompt_color a').animate({ color: '#0088CC' });
$(obj).animate({ color: 'red' });
$('#'+id).val(where);
$('#'+form_id).submit();
}
function staff_submit(id)
{
var username = $('#username').val();
var password = $('#password').val();
var role_id = $('#user_role').val();
var company = $('#user_company').val();
var email = $('#email').val();
var mobile = $('#mobile').val();
if(username == '' || username == null || username == undefined)
{
$(".error_content").text('用户名为必填');
$(".alert").show();
$("#username").focus();
}else if(password == '' || password == null || password == undefined){
$(".error_content").text('密码为必填');
$(".alert").show();
$("#password").focus();
}else if(role_id == '' || role_id == null || role_id == undefined)
{
$(".error_content").text('请选择角色');
$(".alert").show();
}else if(company == '' || company == null || company == undefined){
$(".error_content").text('请选择公司');
$(".alert").show();
}else if(email){
if(!(/^[a-zA-Z0-9_.-]+\@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]{2,3}){1,2}$/.test(email)))
{
$(".error_content").text('请填写正确的邮箱');
$(".alert-error").show();
$("#email").focus();
}else{
$('#'+id).submit();
}
}else if(mobile){
if(!(/^1[3|4|5|8][0-9]\d{4,8}$/.test(mobile)) || mobile.length !=11)
{
$(".error_content").text('请填写正确的手机号码');
$(".alert-error").show();
$("#mobile").focus();
}else{
$('#'+id).submit();
}
}else{
$('#'+id).submit();
}
}
function getScanType(val)
{
if(val=='c_order_id')
{
var str = "系统订单号";
}else if(val=='track_number')
{
var str = "跟踪号";
}else
{
var str = "客户订单号";
}
return str;
}
function getSelectedText(name)
{
var value = "";
$("."+name).each(function(i,search){
if($(search).is(':checked'))
{
if (value == "") value += $(search).next().text() ;
else value += "," + $(search).next().text();
}
});
return value;
}
//验证手机
function verfy_phone(mobile)
{
if(!(/^1[3|4|5|8][0-9]\d{4,8}$/.test(mobile)))
{
$('.error_content').text('请输入正确的手机号码');
$('.alert').show();
return false;
}else
{
if(mobile.length == 11)
{
$('.alert').hide();
return true;
}else{
$('.error_content').text('手机号码为11位(数字)');
$('.alert').show();
return false;
}
}
}
//验证邮箱
function verfy_email(email)
{
if(!(/^[a-zA-Z0-9_.-]+\@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]{2,3}){1,2}$/.test(email)))
{
$('.error_content').text('请输入正确的邮箱地址');
$('.alert').show();
return false;
}else
{
$('.alert').hide();
return true;
}
}
//验证电话号码
function checkphone(tel)
{
var filter=/^(([0\+]\d{2,3}-)?(0\d{2,3}))?(\d{7,8})(-(\d{3,}))?$/
if(filter.test(tel))
{
$('.error_content').text('请输入正确的电话号码');
$('.alert').show();
return false;
}else
{
$('.alert').hide();
return true;
}
}
//验证区间值
function change_factor()
{
var value = $('#factor').val();
$('.factor').each(function(i,search)
{
$(search).val(value);
});
}
function select_deliver_type()
{
var deliver_type = $('#deliver_type').val();
$.ajax({
type:"post",
url:"/logistics/totalDeliver/selectDeliverType",
data:{'deliver_type':deliver_type},
beforeSend:showLoading(),
success:function(data)
{
hideLoading();
$('#deliver_change').html(data);
}
});
}
function printpres(value)
{
//editor1.post();
$("#form1").attr("target","_blank");
$('#preview').val(value);
if(valion())
{
$('#form1').submit();
}
}
function printPrintPres(value){
$("#form1").attr("target","_blank");
$('#preview').val(value);
$('#form1').submit();
}
function show_modal(id){
$('#'+id).modal('toggle');
}
function supply_log_submit(id){
var supply_id = $('#supply_id').val();
var currency_id = $('#currency_id').val();
var amount = $('#amount').val();
var memo = $('#memo').val();
if(supply_id == '' || supply_id == null || supply_id == undefined)
{
$(".error_content").text('请选择供应商');
$(".alert").show();
$("#username").focus();
}else if(currency_id == '' || currency_id == null || currency_id == undefined){
$(".error_content").text('请选择币种');
$(".alert").show();
$("#password").focus();
}else if(amount == '' || amount == null || amount == undefined)
{
$(".error_content").text('请填写金额');
$(".alert").show();
$("#amount").focus();
}else if(memo == '' || memo == null || memo == undefined){
$(".error_content").text('请填写备注');
$(".alert").show();
$("#memo").focus();
}else{
$('#'+id).submit();
}
}
function show_bug(id){
$.ajax({
type:"post",
url:"/setting/bug/view",
data:{},
beforeSend:showLoading(),
success:function(data)
{
hideLoading();
$('#'+id).html(data);
$('#'+id).modal('toggle');
}
});
}
//王翔
//用户提交
function bug_feedback_submit()
{
$(".error_content").text(' '); // 隐藏错误提示
$(".alert-error").hide();
var body = $('#bug_form #body').val();
body = $.trim(body);
$('#bug_form span input').blur(function(){
$(".error_content").text(' ');
$(".alert-error").hide();
});
if(body.length < 5){
$('#bug_feedback .error_content').text('内容不能少于5个字符');
$(".alert-error").show();
}
if (body.length >= 5){
var userfile = $('#userfile').val();
if(!userfile){
var body = $('#bug_form textarea[name="body"]').val();
$.ajax({
url: "/setting/bug/createBody",
type: 'post',
data: {'body': body},
cache: false,
success: function(data) {
var id = data;
var clas = $('#annex_box div:last-child').attr('class');
var annex_url = ''; // 发送附件路径到邮件
var tit = $('title').text();
body += '
问题页面: ';
body += tit;
body += '
';
body += '问题url: ';
body += window.location.href;
id_show_loading('bug_loading'); //刷新等待
if (clas){
var div = $('#annex_box').children()
$.each(div, function(i, n){
var dom = div.eq(i);
var file_url = dom.attr('value');
var www_url = dom.attr('url');
var name = dom.attr('name');
annex_url += ''+name+'
';
annex_info(file_url, www_url, name, id);
dom.detach();
});
bug_email(body, annex_url);
}else {
bug_email(body);
}
$('#bug_form textarea[name="body"]').val('');
}
});
}else {
$('#bug_feedback .error_content').text('你选中了附件,请先上传');
$(".alert-error").show();
}
}
}
//附件信息保存在数据库
function annex_info(file_url,www_url,name,feedback_id){
if (file_url && www_url && name && feedback_id){
$.ajax({
url: "/setting/bug/createAnnex",
type: 'post',
data: {'file_url': file_url, 'www_url':www_url, 'name':name, 'feedback_id':feedback_id},
cache: false,
success: function(data) {
}
});
}
}
/**
* 删除文件夹与页面的附件
* @clas 字符串 class名
*/
function bug_annex_dele(clas){
var annex_calss = $('div[class='+clas+']');
var annex_url = annex_calss.attr('value'),
annex_name = annex_calss.attr('name');
$.ajax({
url: "/setting/bug/deleteAnnex",
type: 'post',
data:{'annex_url':annex_url,'annex_name':annex_name},
cache: false,
success: function(data) {
if (data == 1){ //判断是否删除成功
annex_calss.detach();
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
$(".error_content").text('错误,请重试');
$(".alert-error").show();
}
});
}
/*
说明:ajax文件上传
*/
function ajaxFileUpload() {
var ajaxFileUpload = function(opts){
return new ajaxFileUpload.prototype.init(opts);
};
ajaxFileUpload.prototype = {
init:function(opts){
var set = this.extend({
url:"/setting/bug/admin",
id:'userfile',
callback:function(){}
},opts || {});
var _this = this;
var id = +new Date();
var form = this.createForm(id),frame = this.createIframe(id,set.url);
var oldFile = document.getElementById(set.id)
var newFile = oldFile.cloneNode(true);
var fileId = 'ajaxFileUploadFile'+id;
oldFile.setAttribute('id',fileId);
oldFile.parentNode.insertBefore(newFile,oldFile);
form.appendChild(oldFile);//注意浏览器安全问题,要将原文件域放到创建的form里提交
form.setAttribute('target',frame.id);//将form的target设置为iframe,这样提交后返回的内容就在iframe里
form.setAttribute('action',set.url);
setTimeout(function(){
form.submit();
if(frame.attachEvent){
frame.attachEvent('onload',function(){_this.uploadCallback(id,set.callback);});
}else{
frame.onload = function(){_this.uploadCallback(id,set.callback);}
}
},100);
},
/*
创建iframe,ie7和6比较蛋疼,得像下面那样创建,否则会跳转
*/
createIframe:function(id,url){
var frameId = 'ajaxFileUploadFrame'+id,iFrame;
var IE = /msie ((\d+\.)+\d+)/i.test(navigator.userAgent) ? (document.documentMode || RegExp['\x241']) : false,
url = url || 'javascript:false';
if(IE && IE < 8){
iFrame = document.createElement('');
iFrame.src = url;
}else{
iFrame = document.createElement('iframe');
this.attr(iFrame,{
'id':frameId,
'name':frameId,
'src':url
});
};
iFrame.style.cssText = 'position:absolute; top:-9999px; left:-9999px';
return document.body.appendChild(iFrame);
},
/*
创建form
*/
createForm:function(id){
var formId = 'ajaxFileUploadForm'+id;
var form = document.createElement('form');
this.attr(form,{
'action':'',
'method':'POST',
'name':formId,
'id':formId,
'enctype':'multipart/form-data',
'encoding':'multipart/form-data'
});
form.style.cssText = 'position:absolute; top:-9999px; left:-9999px';
return document.body.appendChild(form);
},
/*
获取iframe内容,执行回调函数,并移除生成的iframe和form
*/
uploadCallback:function(id,callback){
var frame = document.getElementById('ajaxFileUploadFrame'+id),form = document.getElementById('ajaxFileUploadForm'+id);data = {};
var db = document.body;
try{
if(frame.contentWindow){
data.responseText = frame.contentWindow.document.body ? frame.contentWindow.document.body.innerHTML : null;
data.responseXML = frame.contentWindow.document.XMLDocument ? frame.contentWindow.document.XMLDocument : frame.contentWindow.document;
}else{
data.responseText = frame.contentDocument.document.body ? frame.contentDocument.document.body.innerHTML : null;
data.responseXML = frame.contentDocument.document.XMLDocument ? frame.contentDocument.document.XMLDocument : frame.contentDocument.document;
}
}catch(e){};
callback && callback.call(data);
setTimeout(function(){
db.removeChild(frame);
db.removeChild(form);
},100);
},
attr:function(el,attrs){
for(var prop in attrs) el.setAttribute(prop,attrs[prop]);
return el;
},
extend:function(target,source){
for(var prop in source) target[prop] = source[prop];
return target;
}
};
ajaxFileUpload.prototype.init.prototype = ajaxFileUpload.prototype;
ajaxFileUpload({
id:'userfile',
callback:function(){
var src = this.responseText;
annex_dom(src);
}
});
function annex_dom(src){
var json = JSON.parse(src);
if (json.status){
if (json.status == 2 || json.status == 3 || json.status == 'false' || json.status == 4){
if (json.status == 2){
$(".error_content").text('附件不能大于2M');
$(".alert-error").show();
}else if(json.status == 3) {
$(".error_content").text('文件已存在');
$(".alert-error").show();
}else if(json.status === false) {
$(".error_content").text('文件上传失败');
$(".alert-error").show();
}else if (json.status == 4){
$(".error_content").text('保存文件失败');
$(".alert-error").show();
}
}else {
var div = $('#bug_form .'+json.clas).attr('class');
if (!div){
$('#bug_feedback #annex_box').append('');
}else{
$(".error_content").text('文件已存在');
$(".alert-error").show();
}
}
}
}
}
//发送bug邮件
function bug_email(body,annex_url){
$.ajax({
url:"/setting/bug/BugEmail",
type: 'post',
data: {'body': body, 'annex_url': annex_url},
cache: false,
success: function(data) {
id_hide_loading('bug_loading');
$('#bug_feedback').modal('hide'); //隐藏弹出框
if(data == 1){
messages(false,'反馈成功','success');
}else {
messages(false,'邮件发送失败','error');
}
}
});
}
//用户点击时间自动跳转
function time_change(id, start_id, end_id)
{
/*$('.form_datetime').datetimepicker({
inline: true,
format:'yyyy-mm-dd hh:ii'
});*/
var myDate = new Date();
var year = myDate.getFullYear();
var month = ("0" + (myDate.getMonth() + 1)).slice(-2);
var day = ("0" + myDate.getDate()).slice(-2);
var h = ("0" + myDate.getHours()).slice(-2);
var m = ("0" + myDate.getMinutes()).slice(-2);
var s = ("0" + myDate.getSeconds()).slice(-2);
var mi = ("00" + myDate.getMilliseconds()).slice(-3);
if(id != null)
{
var time1 = $('#'+id).val();
if(time1==0||time1==3)
{
var start_time = year+'-'+month+'-'+day;
$('#'+id).val(1);
}else if(time1==1)
{
var start_time = year+'-'+month+'-1';
$('#'+id).val(2);
}else if(time1==2)
{
var start_time = year+'-'+(month-1)+'-'+day;
$('#'+id).val(3);
}
var end_time = year+'-'+month+'-'+day;
$('#'+start_id).val(start_time);
$('#'+end_id).val(end_time);
}
}
function show_ship_total(type){
if(type){
var total_id = $('#sift_channel_id').val();
}else{
var total_id = $('#sift_supply_id').val();
}
$.ajax({
url:"/financial/paymentBill/showShipTotal",
type: 'post',
data: {'total_id':total_id, 'type':type},
cache: false,
success: function(data) {
$('#show_total_deliver').html(data);
}
});
}
function update_password_submit(id)
{
var old_password = $('#old_password').val();
var password = $('#password').val();
var confirm_password = $('#confirm_password').val();
if(old_password == '' || old_password == null || old_password == undefined)
{
$(".error_content").text('请输入旧密码');
$(".alert-error").show();
$("#old_password").focus();
}else{
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url: "/setting/staff/Verification",
data:{'password':old_password},
success: function(data){
if(data == 1)
{
if(password == '' || password == null || password == undefined)
{
$(".error_content").text('请输入新密码');
$(".alert-error").show();
$("#password").focus();
}else if(password.length <4){
$(".error_content").text('密码至少为四位');
$(".alert-error").show();
$("#password").focus();
}else if(confirm_password == '' || confirm_password == null || confirm_password == undefined){
$(".error_content").text('请确认密码');
$(".alert-error").show();
$("#confirm_password").focus();
}else if(password != confirm_password){
$(".error_content").text('两次输入密码不一致');
$(".alert-error").show();
$("#address").focus();
}else{
$('#'+id).submit();
}
}else{
$(".error_content").text('旧密码不正确');
$(".alert-error").show();
$("#old_password").focus();
}
}
});
}
}
function add_other_fee(id){
$('#'+id).modal('toggle');
}
function add_other_fee_submit(id){
var other_fee = $('#other_fee').val();
var memo = $('#memo').val();
if(other_fee == '' || other_fee == null || other_fee == undefined || other_fee==0)
{
$(".error_content").text('请填写金额');
$(".alert-error").show();
$('#other_fee').focus();
}else if(memo == '' || memo == null || memo == undefined || memo==0)
{
$(".error_content").text('请填写备注');
$(".alert-error").show();
$('#memo').focus();
}else{
$('#'+id).submit();
}
}
function add_sub_company(id,sub_id){
var name = $('#name').val();
var password = $('#password').val();
var confirm_password = $('#confirm_password').val();
var displayName = $('#displayName').val();
if(name == '' || name == null || name == undefined || name==0)
{
$(".error_content").text('请填名称');
$(".alert-error").show();
$('#name').focus();
}else{
var post_id = 0;
if(sub_id){
post_id =sub_id;
}
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url: "/setting/SubCompany/Verify",
data:{'name':name,'id':post_id},
success: function(data){
if(data == 1)
{
$(".error_content").text('名称已存在');
$(".alert-error").show();
$('#name').focus();
}else if(password == '' || password == null || password == undefined || password==0)
{
$(".error_content").text('请填写密码');
$(".alert-error").show();
$('#password').focus();
}else if(password.length < 4)
{
$(".error_content").text('密码不能少于4位字符');
$(".alert-error").show();
$('#password').focus();
}else if(confirm_password == '' || confirm_password == null || confirm_password == undefined || confirm_password==0)
{
$(".error_content").text('请确认密码');
$(".alert-error").show();
$('#confirm_password').focus();
}else if(confirm_password != password)
{
$(".error_content").text('两次输入的密码不一致');
$(".alert-error").show();
$('#confirm_password').focus();
}else if(displayName == '' || displayName == null || displayName == undefined || displayName==0)
{
$(".error_content").text('请填写联系人');
$(".alert-error").show();
$('#displayName').focus();
}else{
$('#'+id).submit();
}
}
});
}
}
function createSenstitive(id,type){
if(type){
var name = $('#update_name').val();
}else{
var name = $('#create_name').val();
}
if(name == '' || name == null || name == undefined || name==0)
{
$(".error_content").text('请填写名称');
$(".alert-error").show();
$('#create_name').focus();
}else{
$('#'+id).submit();
}
}
function createSpecialPrice(id){
var name = $('#create_name').val();
var price = $('#create_price').val();
if(name == '' || name == null || name == undefined || name==0)
{
$(".error_content").text('请填写名称');
$(".alert-error").show();
$('#create_name').focus();
}else if(price == '' || price == null || price == undefined || price==0)
{
$(".error_content").text('请填写金额');
$(".alert-error").show();
$('#create_price').focus();
}else{
$('#'+id).submit();
}
}
function update_special_price_submit(id){
var name = $('#update_name').val();
var price = $('#update_price').val();
if(name == '' || name == null || name == undefined || name==0)
{
$(".error_content").text('请填写名称');
$(".alert-error").show();
$('#create_name').focus();
}else if(price == '' || price == null || price == undefined || price==0)
{
$(".error_content").text('请填写金额');
$(".alert-error").show();
$('#create_price').focus();
}else{
$('#'+id).submit();
}
}
function update_special_price(id,url)
{
$.ajax({
type: "POST",
url: url,
//data:{},
success: function(data){
$('#'+id).html(data);
}
});
$('#'+id).modal('toggle');
}
function delete_special_price(name,id){
$('#del_id').val(id);
$('#del_name').text(name);
$('#delete_special_price').modal('toggle');
}
function delete_special_price_confirm(){
var id=$('#del_id').val();
$('#delete_special_price').modal('hide');
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url: "/setting/SpecialPrice/Delete",
data:{'id':id},
success: function(data){
if(data == 1)
{
$('#delete_'+id).parents('tr:first').fadeOut(1000);
}
}
});
}
$(function(){
$('.form_datetime').click(function(){
$('#ui-datepicker-div > .ui-corner-all').addClass("ui-state-hover");
});
$(".ui-corner-all").click(function(){
$('#ui-datepicker-div > .ui-corner-all').addClass("ui-state-hover");
})
});
function insert_zone(obj){
if(!(/^[0-9a-zA-Z_-]*$/g.test(obj.value))){
obj.value ='';
}
}
function createPickup(id){
var user_ID = $('#user_ID').val();
var p_addre_id = $('#p_addre_id').val();
var type_id = $('#type_id').val();
var p_time = $('#p_time').val();
var qty = $('#qty').val();
var weight = $('#weight').val();
if(user_ID == '' || user_ID == null || user_ID == undefined || user_ID==0)
{
$(".error_content").text('请选择用户');
$(".alert-error").show();
$('#user_ID').focus();
}else if(p_addre_id == '' || p_addre_id == null || p_addre_id == undefined || p_addre_id==0)
{
$(".error_content").text('请选择联系人');
$(".alert-error").show();
$('#p_addre_id').focus();
}else if(type_id == '' || type_id == null || type_id == undefined || type_id==0)
{
$(".error_content").text('请选择取件类型');
$(".alert-error").show();
$('#type_id').focus();
}else if(type_id == 2)
{
var data=new Array();
$("input:checkbox[name='p_date[]']").each(function (){
if($(this).attr("checked")=='checked'){
data.push($(this).val());
}
});
if(data.length ==0){
$(".error_content").text('请选择取件日期');
$(".alert-error").show();
}else if(p_time == '' || p_time == null || p_time == undefined || p_time==0)
{
$(".error_content").text('请选择取件时间');
$(".alert-error").show();
$('#p_time').focus();
}else if(qty == '' || qty == null || qty == undefined || qty==0)
{
$(".error_content").text('请填写数量');
$(".alert-error").show();
$('#qty').focus();
}else if(weight == '' || weight == null || weight == undefined || weight==0)
{
$(".error_content").text('请填写重量');
$(".alert-error").show();
$('#weight').focus();
}else{
$('#'+id).submit();
}
}else if(p_time == '' || p_time == null || p_time == undefined || p_time==0)
{
$(".error_content").text('请选择取件时间');
$(".alert-error").show();
$('#p_time').focus();
}else if(qty == '' || qty == null || qty == undefined || qty==0)
{
$(".error_content").text('请填写数量');
$(".alert-error").show();
$('#qty').focus();
}else if(weight == '' || weight == null || weight == undefined || weight==0)
{
$(".error_content").text('请填写重量');
$(".alert-error").show();
$('#weight').focus();
}else{
$('#'+id).submit();
}
}
function createDriver(id,type){
if(type){
var name = $('#update_name').val();
var tel = $('#update_tel').val();
}else{
var name = $('#create_name').val();
var tel = $('#create_tel').val();
}
if(name == '' || name == null || name == undefined || name==0)
{
$(".error_content").text('请填写名称');
$(".alert-error").show();
if(type){
$('#update_name').focus();
}else{
$('#create_name').focus();
}
}else if(tel == '' || tel == null || tel == undefined || tel==0)
{
$(".error_content").text('请填写电话');
$(".alert-error").show();
if(type){
$('#update_tel').focus();
}else{
$('#create_tel').focus();
}
}else{
$('#'+id).submit();
}
}
function recharge_confirm(url,id,type){
$('#delete_url').val(url);
$('#'+id).modal('toggle');
if(type){
$('#failure_content').hide();
$('#success_content').show();
}else{
$('#failure_content').show();
$('#success_content').hide();
}
}
function confirm_recharge(){
var url = $('#delete_url').val();
window.location = url;
}
function createPrintSetting(id,p_id){
$('#preview').val(1);
var name = $('#name').val();
var verif_name = VerifyName(name,p_id);
var product_id = $('#Channel_product_id').val();
var body = $('#ArticleContent_body').val();
var format = $('input[name="format"]:checked').val();
if(verif_name ==1){
$(".error_content").text('请输入名称');
$(".alert-error").show();
$("#name").focus();
}else if(verif_name ==2){
$(".error_content").text('名称已存在,请重新输入');
$(".alert-error").show();
$("#name").focus();
}else if(body == '' || body == null || body == undefined){
$(".error_content").text('请输入内容');
$(".alert-error").show();
$("#body").focus();
}else if(format == 1){
if(product_id == '' || product_id == null || product_id == undefined){
$(".error_content").text('请选择产品');
$(".alert-error").show();
$("#Channel_product_id").focus();
}else{
$('#'+id).submit();
}
}else{
$('#'+id).submit();
}
}
function VerifyName(name,p_id){
var return_val = '';
if(name == '' || name == null || name == undefined)
{
return_val = 1;//名称为空
}else if(name){
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url: "/setting/gadgets/verifyPrintName",
data:{'name':name,'p_id':p_id},
success: function(data){
if(data){
if(data ==1){
return_val = 2;//名称重复
}else{
return_val = 3;//正确
}
}
}
});
}
return return_val;
}
function select_print_type(type){
if(type ==1){
$('#print_size').show();
}else{
$('#print_size').hide();
}
}
function select_declaration(type){
if(type ==1){
$('#declaration').show();
$('#print_pres').show();
$('#print_product').show();
}else{
$('#declaration').hide();
$('#print_pres').hide();
$('#print_product').hide();
}
}
function delete_print_addre(content_id,name,id){
$('#del_id').val(id);
$('#content_id').val(content_id);
$('#del_name').text(name);
$('#'+content_id).modal('toggle');
}
function confirm_delete_print_addre(){
var url = $('#delete_url').val();
var id = $('#del_id').val();
var content_id = $('#content_id').val();
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url:"/setting/gadgets/DeletePrintAddre",
data:{'id':id},
beforeSend:showLoading(),
success: function(data){
hideLoading();
if(data == 1)
{
$('#'+content_id).modal('hide');
$('#delete_'+id).parents('tr:first').fadeOut(1000);
var msg;
msg = $.globalMessenger().post({
message: '删除成功',
type: 'error',
showCloseButton: true
});
}else{
var msg;
msg = $.globalMessenger().post({
message: '删除失败,请联系管理员',
type: 'error',
showCloseButton: true
});
}
}
});
}
function set_print_templabe(){
$('#print_templabe_change').modal('toggle');
}
function select_print_templabe(name,id,type_id){
var print_templabe = $('#print_templabe').val();
var type = $('#print_templabe_id_'+type_id).val();
if(print_templabe && type ==''){
$('#print_templabe').val(print_templabe+','+name);
}else{
$('#print_templabe').val(name);
}
$('#print_templabe_id_'+type_id).val(id);
}
function confirm_print_templabe(id){
var print_templabe_a4 = $("#print_templabe_id_2").val();
var print_templabe_thermal = $("#print_templabe_id_1").val();
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url:"/products/product/SeletePrintTemplabe",
data:{'product_id':id,'print_templabe_a4':print_templabe_a4,'print_templabe_thermal':print_templabe_thermal},
beforeSend:showLoading(),
success: function(data){
hideLoading();
if(data == 1)
{
var msg;
msg = $.globalMessenger().post({
message: '修改成功',
type: 'error',
showCloseButton: true
});
}
}
});
$('#print_templabe_change').modal('hide');
}
function select_default_templabe(){
var id = $('#templabe_id').val();
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url:"/setting/gadgets/SeletePrintTemplabe",
data:{'id':id},
success: function(data){
document.getElementsByTagName("iframe")[0].contentWindow.document.body.innerHTML =data;
}
});
}
function filter_track_number(track_number){
if(track_number!=null){
if(track_number.length == 30){
return track_number.substr(8);
}else{
return track_number;
}
}
}
function postSerialize(id){
var strData = $('#'+id).serialize();
var iCount; //拆分为多少个域
var iMaxChars = 50000;//考虑到汉字为双字节,域的最大字符数限制为50K
var iBottleNeck = 100000;//如果数据超过2M字,需要提示用户
var strHTML;
if (strData.length > iBottleNeck)
{
if (confirm("您要处理的数据量太大,请重新设置每页显示数量,最好在100左右,如果您坚持处理,注意需要较长时间才能提交成功,。\n\n是否继续处理?") == false)
{
return false;
}else
{
retValue = true;
}
}
iCount = parseInt(strData.length / iMaxChars) + 1;
//hdnCount记录原数据域拆分为多少个子域
strHTML ="";
//生成各子域的HTML代码
strHTML += '正在处理数据,请稍候
';
for (var i = 1; i <= iCount; i++)
{
strHTML += "\n" + "";
}
//在Form中DIV(divHidden)内动态插入各hidden域的HTML代码
$('#'+id).empty();
$('#'+id).html(strHTML);
$('#'+id).submit();
}
function postSerializeAudit(id){
var strData = $('#'+id).serialize();
var iCount; //拆分为多少个域
var iMaxChars = 50000;//考虑到汉字为双字节,域的最大字符数限制为50K
var iBottleNeck = 100000;//如果数据超过2M字,需要提示用户
var strHTML;
if (strData.length > iBottleNeck)
{
if (confirm("您要处理的数据量太大,请重新设置每页显示数量,最好在100左右,如果您坚持处理,注意需要较长时间才能提交成功,。\n\n是否继续处理?") == false)
{
return false;
}else
{
retValue = true;
}
}
iCount = parseInt(strData.length / iMaxChars) + 1;
//hdnCount记录原数据域拆分为多少个子域
strHTML ="";
//生成各子域的HTML代码
for (var i = 1; i <= iCount; i++)
{
strHTML += "\n" + "";
}
//在Form中DIV(divHidden)内动态插入各hidden域的HTML代码
$('#'+id+'_id').html(strHTML);
$('#'+id+'_id').submit();
}
function AccountAudit(id,type_id){
$('#type_id').val(type_id);
postSerializeAudit(id+'_form');
}
function number_pool_batch(id,operation){
var data=new Array();
$("input:checkbox[name='select_orders[]']").each(function (){
if($(this).attr("checked")=='checked'){
data.push($(this).val());
}
});
if(data.length > 0){
if(operation){
$('#batch_processing').val(operation);
}
if(operation == 'add_total'){
$('#'+operation).modal('toggle');
}else{
postSerialize(id);
}
}else{
var msg;
msg = $.globalMessenger().post({
message: '请选择要操作的订单',
type: 'error',
showCloseButton: true
});
}
}
function generateTotal(id){
$('#is_generate').val(1);
$('#'+id).submit();
}
function receive_volume(id){
var order_id = $('#select_order_id').val();
var volume_id = $('#volume_id').val();
$.ajax({
type: "POST",
async:false, // 设置同步方式
cache:false,
url:"/logistics/TotalReceive/GetOrderVolume",
data:{'order_id':order_id,'volume_id':volume_id},
success: function(data){
$('#'+id).html(data);
}
});
$('#'+id).modal('toggle');
}
function uploadTemplate(id){
$('#'+id).modal('toggle');
}
function print_upload(id)
{
var fileName = $('#fileName').val();
var file_name = fileName.split('.');
if(fileName == '' || fileName == null || fileName == undefined || fileName==0)
{
$(".error_content").text('请选择要上传的文件');
$(".alert").show();
$("#fileName").focus();
}else if(file_name[1] !='htm' && file_name[1] !='html'){
$(".error_content").text('只支持htm或html格式的文件');
$(".alert").show();
$("#fileName").focus();
}else{
$(".alert").hide();
$("#"+id).submit();
}
}
function showTrackLoading(obj){
var img='
';
$('#'+obj).html(img);
}
function chanage_status(id,url)
{
var status = $("#status_"+id).val();
$.ajax({
type: "POST",
url: url,
data:{'id':id,'status':status},
success: function(data){
if(data == 1)
{
status=(status==1)?'0':'1';
$("#status_"+id).val(status);
}else{
alert(data);
}
}
});
}/* customer js*/