123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431 |
- /**
- *
- */
- $.namespace("hxgl.detail");
- hxgl.detail.init=function(){
- hxgl.detail.flag=null;
- }
- /**
- * 弹出新增页面
- * */
- hxgl.detail.add=function(){
- var rq=$("#rq").val();
- location.href=$.app+"/hxgl/add?month="+rq;
- }
- hxgl.detail.view=function(data){
- var rq=$("#rq").val();
- location.href=$.app+"/hxgl/view?id="+data+"&month="+rq;
- }
- hxgl.detail.edit=function(data,month){
- var rq=$("#rq").val();
- location.href=$.app+"/hxgl/edit?id="+data+"&month="+rq;
- }
- hxgl.detail.back=function(){
- var rq=$("#rq").val();
- location.href=$.app+'/hxgl/addmain?rq='+rq
- }
- hxgl.detail.backmain=function(){
- location.href=$.app+'/hxgl/main';
- }
- hxgl.detail.search=function(){
- $("#hxgladdform").submit();
- }
- hxgl.detail.save=function(){
- if(isEmpty($('#hxmc').val())){
- ts("请输入航线名称",$('#hxmc'));
- return false;
- }
- if(isEmpty($('#hxlxid').val())){
- ts("请选择航线类型",$('#hxlxid'));
- return false;
- }
- if(isEmpty($('#szdid').val())){
- ts("请选择所在地",$('#szdid'));
- return false;
- }
- if(isEmpty($('#szgkid').val())){
- ts("请选择所在港口",$('#szgkid'));
- return false;
- }
- if(isEmpty($('#szgqid').val())){
- ts("请选择所在港区",$('#szgqid'));
- return false;
- }
- if(isEmpty($('#cgs').val())){
- ts("请输入船公司",$('#cgs'));
- return false;
- }
- if(isEmpty($('#hc').val())){
- ts("请输入航程",$('#hc'));
- return false;
- }
- //验证浮点类型
- if(van($('#addform input[name=hc]'),"航程")==false){return false;}
- if(van($('#addform input[name=bcs0]'),"班次数")==false){return false;}
- if(van($('#addform input[name=bcs1]'),"班次数")==false){return false;}
- if(van($('#addform input[name=bcs2]'),"班次数")==false){return false;}
- if(van($('#addform input[name=bcs3]'),"班次数")==false){return false;}
- if(van($('#addform input[name=bcs4]'),"班次数")==false){return false;}
- if(van($('#addform input[name=bynmwcl]'),"本月内贸完成量")==false){return false;}
- if(van($('#addform input[name=bywmwcl]'),"本月外贸完成量")==false){return false;}
- $.ajax({
- url:$.app+"/hxgl/save",
- data:$("#addform").serialize(),
- type:"post",
- dataType:"json",
- success:function(data){//ajax返回的数据
- if (data.success) {
- $.alert({
- title: '提示',
- content: '操作成功',
- confirm: function(){
- location.href=$.app+'/hxgl/addmain?rq='+$("#rq").val();
- }
- });
- }else {
- $.alert({
- title: '提示',
- content: data.message,
- confirm: function(){
- }
- });
- }
- }
- });
- }
- //构建航线类型下拉
- function initHxlxSelect(divid,existVal,width){
- $.post($.app+"/hxgl/selectHxlx",{
- },function(data) {
- var str="";
- str+="<select class='hxlxselectpicker' name='hxlxid' id='hxlxid'>";
- str+="<option></option>";
- if(data){
- for(var i=0;i<data.length;i++){
- var hxlx=data[i];
- if(hxlx.id==existVal){
- str+=" <option selected='selected' value='"+hxlx.id+"' >"+hxlx.text+"</option>";
- }else{
- str+="<option value='"+hxlx.id+"'>"+hxlx.text+"</option>" ;
- }
- }
- }
- str+="</select>";
- $("#"+divid).empty;
- $("#"+divid).append(str);
- $('.hxlxselectpicker').selectpicker({
- width:width
- });
- }, "json");
- }
- //构建是否停航下拉
- function initSfthSelect(divid,existVal,width){
- $.post($.app+"/hxgl/selectSfth",{
- },function(data) {
- var str="";
- str+="<select class='sfthselectpicker' name='sfthid' id='sfthid'>";
- str+="<option></option>";
- if(data){
- for(var i=0;i<data.length;i++){
- var sfth=data[i];
- if(sfth.id==existVal){
- str+=" <option selected='selected' value='"+sfth.id+"' >"+sfth.text+"</option>";
- }else{
- str+="<option value='"+sfth.id+"'>"+sfth.text+"</option>" ;
- }
- }
- }
- str+="</select>";
- $("#"+divid).empty();
- $("#"+divid).append(str);
- $('.sfthselectpicker').selectpicker({
- width:width
- });
- }, "json");
- }
- //构建船期下拉
- function initCqSelect(divid,existVal,width,changefunc){
- $.post($.app+"/hxgl/selectCq",{
- },function(data) {
- var str="";
- str+="<select class='cqselectpicker' onchange='"+changefunc+"()' name='cqid' id='cqid'>";
- str+="<option></option>";
- if(data){
- for(var i=0;i<data.length;i++){
- var cq=data[i];
- if(cq.id==existVal){
- str+=" <option selected='selected' value='"+cq.id+"' >"+cq.text+"</option>";
- }else{
- str+="<option value='"+cq.id+"'>"+cq.text+"</option>" ;
- }
- }
- }
- str+="</select>";
- $("#"+divid).empty();
- $("#"+divid).append(str);
- $('.cqselectpicker').selectpicker({
- width:width
- });
- }, "json");
- }
- //展现船期列表
- function showcqtb(){
- //编辑页面应先删除子表内容
- if(hxgl.detail.flag==1){
- $.ajax({
- url:$.app+"/hxgl/sccq",
- data:{
- id:$("#recordid").val()
- },
- type:"post",
- success:function(data){//ajax返回的数据
- $.ajax({
- url:$.app+"/hxgl/showcqtb",
- data:{
- cqid:$("#cqid").val()
- },
- type:"post",
- dataType:"json",
- success:function(data){//ajax返回的数据
- var str="";
- if (data) {
- for(var i=0;i<data.length-1;i++){
- str+="<tr id=\"tr"+i+"\">";
- var cq=data[i];
- str+="<td><span>"+data[data.length-1]+"</span></td>";
- str+="<input type=\"hidden\" name=\"cq\">";
- str+="<td><span id='kcrq"+i+"'>"+cq+"</span><input type=\"hidden\" value=\""+cq+"\" name=\"kcrq"+i+"\"></td>";
- str+="<td><input type=\"text\" class=\"form-control\" name=\"bcs"+i+"\"></td>";
- str+="<td><a class=\"btn btn-default btn-xs\" href=\"#\" onclick=\"hxgl.detail.shanchu("+i+")\"><i class=\"glyphicon glyphicon-trash\"></i>删除</a></td>"
- str+="</tr>"
- }
- $("#cqtb").empty();
- for(var i=0;i<6;i++){
- $("#deltr"+i).remove();
- }
- $("#cqtb").append(str);
- }
- }
- });
- }
- });
- }else{
- $.ajax({
- url:$.app+"/hxgl/showcqtb",
- data:{
- cqid:$("#cqid").val()
- },
- type:"post",
- dataType:"json",
- success:function(data){//ajax返回的数据
- var str="";
- if (data) {
- for(var i=0;i<data.length-1;i++){
- str+="<tr id=\"tr"+i+"\">";
- var cq=data[i];
- str+="<td><span>"+data[data.length-1]+"</span></td>";
- str+="<input type=\"hidden\" name=\"cq\">";
- str+="<td><span id='kcrq"+i+"'>"+cq+"</span><input type=\"hidden\" value=\""+cq+"\" name=\"kcrq"+i+"\"></td>";
- str+="<td><input type=\"text\" class=\"form-control\" name=\"bcs"+i+"\"></td>";
- str+="<td><a class=\"btn btn-default btn-xs\" href=\"#\" onclick=\"hxgl.detail.shanchu("+i+")\"><i class=\"glyphicon glyphicon-trash\"></i>删除</a></td>"
- str+="</tr>"
- }
- $("#cqtb").empty();
- for(var i=0;i<6;i++){
- $("#deltr"+i).remove();
- }
- $("#cqtb").append(str);
- }
- }
- });
- }
-
- }
- van=function(a,b){
- if(!isFDS(a.val())){
- ts(b+"必须为正数",a);
- return false;
- }
- };
- hxgl.detail.shanchu=function(i){
- $.confirm({
- title: '确认框',
- content: '确认删除吗',
- confirm: function(){
- $("#tr"+i).remove();
- },
- cancel: function(){
- }
- });
- }
- hxgl.detail.del=function(data){
- $.confirm({
- title: '确认框',
- content: '确认删除吗',
- confirm: function(){
- $.post($.app + "/hxgl/delete", {
- id : data
- }, function(data) {
- if (data.success) {
- $.alert({
- title: '提示',
- content: '删除成功',
- confirm: function(){
- $("#hxglform").submit();
- $("#hxgladdform").submit();
- }
- });
- } else {
- $.alert({
- title: '提示',
- content: data.message,
- confirm: function(){
-
- }
- });
- }
- }, "json");
- },
- cancel: function(){
-
- }
- });
- }
- hxgl.detail.dele=function(data,trid){
- $.confirm({
- title: '确认框',
- content: '确认删除吗',
- confirm: function(){
- $.post($.app + "/hxgl/dele", {
- id : data
- }, function(data) {
- if (data.success) {
- $.alert({
- title: '提示',
- content: '删除成功',
- confirm: function(){
- $("#deltr"+trid).remove();
- if(trid==0){
- $("#deltr1").attr('id','deltr0');
- $("#deltr2").attr('id','deltr1');
- $("#deltr3").attr('id','deltr2');
- $("#deltr4").attr('id','deltr3');
- $("#kcrq1").attr('name','kcrq0');
- $("#kcrq2").attr('name','kcrq1');
- $("#kcrq3").attr('name','kcrq2');
- $("#kcrq4").attr('name','kcrq3');
- $("#bcs1").attr('name','bcs0');
- $("#bcs2").attr('name','bcs1');
- $("#bcs3").attr('name','bcs2');
- $("#bcs4").attr('name','bcs3');
- }else if(trid==1){
- $("#deltr2").attr('id','deltr1');
- $("#deltr3").attr('id','deltr2');
- $("#deltr4").attr('id','deltr3');
- $("#kcrq2").attr('id','kcrq1');
- $("#kcrq3").attr('id','kcrq2');
- $("#kcrq4").attr('id','kcrq3');
- $("#bcs2").attr('id','bcs1');
- $("#bcs3").attr('id','bcs2');
- $("#bcs4").attr('id','bcs3');
- }else if(trid==2){
- $("#deltr3").attr('id','deltr2');
- $("#deltr4").attr('id','deltr3');
- $("#kcrq3").attr('id','kcrq2');
- $("#kcrq4").attr('id','kcrq3');
- $("#bcs3").attr('id','bcs2');
- $("#bcs4").attr('id','bcs3');
- }else if(trid==3){
- $("#deltr4").attr('id','deltr3');
- $("#kcrq4").attr('id','kcrq3');
- $("#bcs4").attr('id','bcs3');
- }
- }
- });
- } else {
- $.alert({
- title: '提示',
- content: data.message,
- confirm: function(){
-
- }
- });
- }
- }, "json");
- },
- cancel: function(){
-
- }
- });
- }
- hxgl.detail.fuzhi=function(){
- /*location.href=$.app+"/hxgl/fuzhi?rq="+$("#rq").val();*/
- $.ajax({
- url:$.app+"/hxgl/fuzhi",
- data:{
- rq:$("#rq").val()
- },
- type:"post",
- success:function(data){//ajax返回的数据
- $.alert({
- title: '提示',
- content: '操作成功',
- confirm: function(){
- hxgl.detail.search();
- }
- });
- }
- });
-
- }
- hxgl.detail.tinghang=function(data){
- $.confirm({
- title: '确认框',
- content: '确认停航吗',
- confirm: function(){
- $.post($.app + "/hxgl/tinghang", {
- id : data
- }, function(data) {
- if (data.success) {
- $.alert({
- title: '提示',
- content: '停航成功',
- confirm: function(){
- hxgl.detail.search();
- }
- });
- } else {
- $.alert({
- title: '提示',
- content: data.message,
- confirm: function(){
-
- }
- });
- }
- }, "json");
- },
- cancel: function(){
-
- }
- });
- }
|