{% extends 'obj_form.html' %} {% load i18n %} {% load tj_filters %} {% block css %} {{ block.super }} #obj_form .datepicker{ width:100px } #obj_form select.adm{ min-width:100px; margin-left:5px; } #product_label{ min-width:380px; margin-left:15px; margin-right:7px; } #obj_form .btn-del{ float:right; } {% endblock %} {% block js %} {{ block.super }} var dt1,dt2; dt1=new Date(); dt2=new Date(); dt2.setFullYear(dt1.getFullYear(),11,31); $('.datepicker').datepicker({dateFormat: 'yy-mm-dd'}); $('#dt1,#dt1_product').datepicker('setDate',dt1); $('#dt2,#dt2_product').datepicker('setDate',dt2); setDatePickerZh(); $('#product_label').autocomplete({ source: {{products|safe}}, select: function (event, ui) { $("#product_id").val(ui.item.value); $("#product_label").val(ui.item.label); return false; } }); {% ifequal request.user.company.level.sn 0 %} $('#parent_label').autocomplete({ source: {{children|safe}}, select: function (event, ui) { var pid=ui.item.value; $("#id_parent").val(pid); $("#parent_label").val(ui.item.label); $.get( '/company/child/level/'+pid+'/', function(obj){ if (obj.level.id<0){ //bootbox.alert(obj.level.e); toastr.error( obj.level.e, "数据错误:", {timeOut: 800, positionClass: "toast-center-center"} ); }else{ $('#lv').text(obj.level.name); } } ); return false; } }); {% endifequal %} //被删除的授权ID var auth_del_ids=[]; var auth_del_ids_product=[]; $("#province").change(function() { var province_id = $(this).val(); getCity(province_id); }); $("#city").change(function() { var city_id = $(this).val(); getArea(city_id); }); function getCity(province_id) { var me=$("#city"); $.ajax({ url: "http://117.34.70.23:32176/gis/adm/2/"+province_id+"/", success: function(data) { $(me).empty(); $('#area').empty(); $.each(data,function(i,d){$(me).append("")}); $(me).append(""); }, dataType: 'jsonp', jsonp: 'callback' }); }; function getArea(city_id) { var me=$('#area'); $.ajax({ url: "http://117.34.70.23:32176/gis/adm/3/"+city_id+"/", success: function(data) { $(me).empty(); $.each(data,function(i,d){$(me).append("")}); $(me).append(""); }, dataType: 'jsonp', jsonp: 'callback' }); }; $('#tb_auth input[type="checkbox"]').removeClass('form-control'); // 列表中是否已有指定 adm_id function has_adm(id){ var b=0; $(".adm_id").each(function(i,el){ if($(el).val()==id){ b=1; return; }; }); return b; }; $("#tb_auth").on("click",".btn-del",function(){ var id=$(this).closest('tr').find('.auth_id').val(); if (id!=''){ auth_del_ids.push(parseInt(id)); }; $(this).closest('tr').remove(); }); // 列表中是否已有指定 product_id function has_product(id){ var b=0; $(".product_id").each(function(i,el){ if($(el).val()==id){ b=1; return; }; }); return b; }; $("#tb_auth_product").on("click",".btn-del",function(){ var id=$(this).closest('tr').find('.auth_id').val(); if (id!=''){ auth_del_ids_product.push(id); }; $(this).closest('tr').remove(); }); //添加销售区域授权 $('.btn-add').click(function(){ var id=''; if(!$.isEmpty($('#area').val())){ id=$('#area').val(); } else { if (!$.isEmpty($('#city').val())){ id=$('#city').val(); }else{ if(!$.isEmpty($('#province').val())){ id=$('#province').val(); } } } if(id==''){ //bootbox.alert("{% trans '请先选择授权区域!' %}"); toastr.error( "请先选择授权区域!", "操作错误:", {timeOut: 800, positionClass: "toast-center-center"} ); return; }; if (has_adm(id)){ //bootbox.alert("{% trans '当前授权区域已在列表中!' %}"); toastr.error( "当前授权区域已在列表中!", "操作错误:", {timeOut: 800, positionClass: "toast-center-center"} ); return; }; var html='