hxgldetail.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  1. /**
  2. *
  3. */
  4. $.namespace("hxgl.detail");
  5. hxgl.detail.init=function(){
  6. hxgl.detail.flag=null;
  7. }
  8. /**
  9. * 弹出新增页面
  10. * */
  11. hxgl.detail.add=function(){
  12. var rq=$("#rq").val();
  13. location.href=$.app+"/hxgl/add?month="+rq;
  14. }
  15. hxgl.detail.view=function(data){
  16. var rq=$("#rq").val();
  17. location.href=$.app+"/hxgl/view?id="+data+"&month="+rq;
  18. }
  19. hxgl.detail.edit=function(data,month){
  20. var rq=$("#rq").val();
  21. location.href=$.app+"/hxgl/edit?id="+data+"&month="+rq;
  22. }
  23. hxgl.detail.back=function(){
  24. var rq=$("#rq").val();
  25. location.href=$.app+'/hxgl/addmain?rq='+rq
  26. }
  27. hxgl.detail.backmain=function(){
  28. location.href=$.app+'/hxgl/main';
  29. }
  30. hxgl.detail.search=function(){
  31. $("#hxgladdform").submit();
  32. }
  33. hxgl.detail.save=function(){
  34. if(isEmpty($('#hxmc').val())){
  35. ts("请输入航线名称",$('#hxmc'));
  36. return false;
  37. }
  38. if(isEmpty($('#hxlxid').val())){
  39. ts("请选择航线类型",$('#hxlxid'));
  40. return false;
  41. }
  42. if(isEmpty($('#szdid').val())){
  43. ts("请选择所在地",$('#szdid'));
  44. return false;
  45. }
  46. if(isEmpty($('#szgkid').val())){
  47. ts("请选择所在港口",$('#szgkid'));
  48. return false;
  49. }
  50. if(isEmpty($('#szgqid').val())){
  51. ts("请选择所在港区",$('#szgqid'));
  52. return false;
  53. }
  54. if(isEmpty($('#cgs').val())){
  55. ts("请输入船公司",$('#cgs'));
  56. return false;
  57. }
  58. if(isEmpty($('#hc').val())){
  59. ts("请输入航程",$('#hc'));
  60. return false;
  61. }
  62. //验证浮点类型
  63. if(van($('#addform input[name=hc]'),"航程")==false){return false;}
  64. if(van($('#addform input[name=bcs0]'),"班次数")==false){return false;}
  65. if(van($('#addform input[name=bcs1]'),"班次数")==false){return false;}
  66. if(van($('#addform input[name=bcs2]'),"班次数")==false){return false;}
  67. if(van($('#addform input[name=bcs3]'),"班次数")==false){return false;}
  68. if(van($('#addform input[name=bcs4]'),"班次数")==false){return false;}
  69. if(van($('#addform input[name=bynmwcl]'),"本月内贸完成量")==false){return false;}
  70. if(van($('#addform input[name=bywmwcl]'),"本月外贸完成量")==false){return false;}
  71. $.ajax({
  72. url:$.app+"/hxgl/save",
  73. data:$("#addform").serialize(),
  74. type:"post",
  75. dataType:"json",
  76. success:function(data){//ajax返回的数据
  77. if (data.success) {
  78. $.alert({
  79. title: '提示',
  80. content: '操作成功',
  81. confirm: function(){
  82. location.href=$.app+'/hxgl/addmain?rq='+$("#rq").val();
  83. }
  84. });
  85. }else {
  86. $.alert({
  87. title: '提示',
  88. content: data.message,
  89. confirm: function(){
  90. }
  91. });
  92. }
  93. }
  94. });
  95. }
  96. //构建航线类型下拉
  97. function initHxlxSelect(divid,existVal,width){
  98. $.post($.app+"/hxgl/selectHxlx",{
  99. },function(data) {
  100. var str="";
  101. str+="<select class='hxlxselectpicker' name='hxlxid' id='hxlxid'>";
  102. str+="<option></option>";
  103. if(data){
  104. for(var i=0;i<data.length;i++){
  105. var hxlx=data[i];
  106. if(hxlx.id==existVal){
  107. str+=" <option selected='selected' value='"+hxlx.id+"' >"+hxlx.text+"</option>";
  108. }else{
  109. str+="<option value='"+hxlx.id+"'>"+hxlx.text+"</option>" ;
  110. }
  111. }
  112. }
  113. str+="</select>";
  114. $("#"+divid).empty;
  115. $("#"+divid).append(str);
  116. $('.hxlxselectpicker').selectpicker({
  117. width:width
  118. });
  119. }, "json");
  120. }
  121. //构建是否停航下拉
  122. function initSfthSelect(divid,existVal,width){
  123. $.post($.app+"/hxgl/selectSfth",{
  124. },function(data) {
  125. var str="";
  126. str+="<select class='sfthselectpicker' name='sfthid' id='sfthid'>";
  127. str+="<option></option>";
  128. if(data){
  129. for(var i=0;i<data.length;i++){
  130. var sfth=data[i];
  131. if(sfth.id==existVal){
  132. str+=" <option selected='selected' value='"+sfth.id+"' >"+sfth.text+"</option>";
  133. }else{
  134. str+="<option value='"+sfth.id+"'>"+sfth.text+"</option>" ;
  135. }
  136. }
  137. }
  138. str+="</select>";
  139. $("#"+divid).empty();
  140. $("#"+divid).append(str);
  141. $('.sfthselectpicker').selectpicker({
  142. width:width
  143. });
  144. }, "json");
  145. }
  146. //构建船期下拉
  147. function initCqSelect(divid,existVal,width,changefunc){
  148. $.post($.app+"/hxgl/selectCq",{
  149. },function(data) {
  150. var str="";
  151. str+="<select class='cqselectpicker' onchange='"+changefunc+"()' name='cqid' id='cqid'>";
  152. str+="<option></option>";
  153. if(data){
  154. for(var i=0;i<data.length;i++){
  155. var cq=data[i];
  156. if(cq.id==existVal){
  157. str+=" <option selected='selected' value='"+cq.id+"' >"+cq.text+"</option>";
  158. }else{
  159. str+="<option value='"+cq.id+"'>"+cq.text+"</option>" ;
  160. }
  161. }
  162. }
  163. str+="</select>";
  164. $("#"+divid).empty();
  165. $("#"+divid).append(str);
  166. $('.cqselectpicker').selectpicker({
  167. width:width
  168. });
  169. }, "json");
  170. }
  171. //展现船期列表
  172. function showcqtb(){
  173. //编辑页面应先删除子表内容
  174. if(hxgl.detail.flag==1){
  175. $.ajax({
  176. url:$.app+"/hxgl/sccq",
  177. data:{
  178. id:$("#recordid").val()
  179. },
  180. type:"post",
  181. success:function(data){//ajax返回的数据
  182. $.ajax({
  183. url:$.app+"/hxgl/showcqtb",
  184. data:{
  185. cqid:$("#cqid").val()
  186. },
  187. type:"post",
  188. dataType:"json",
  189. success:function(data){//ajax返回的数据
  190. var str="";
  191. if (data) {
  192. for(var i=0;i<data.length-1;i++){
  193. str+="<tr id=\"tr"+i+"\">";
  194. var cq=data[i];
  195. str+="<td><span>"+data[data.length-1]+"</span></td>";
  196. str+="<input type=\"hidden\" name=\"cq\">";
  197. str+="<td><span id='kcrq"+i+"'>"+cq+"</span><input type=\"hidden\" value=\""+cq+"\" name=\"kcrq"+i+"\"></td>";
  198. str+="<td><input type=\"text\" class=\"form-control\" name=\"bcs"+i+"\"></td>";
  199. str+="<td><a class=\"btn btn-default btn-xs\" href=\"#\" onclick=\"hxgl.detail.shanchu("+i+")\"><i class=\"glyphicon glyphicon-trash\"></i>删除</a></td>"
  200. str+="</tr>"
  201. }
  202. $("#cqtb").empty();
  203. for(var i=0;i<6;i++){
  204. $("#deltr"+i).remove();
  205. }
  206. $("#cqtb").append(str);
  207. }
  208. }
  209. });
  210. }
  211. });
  212. }else{
  213. $.ajax({
  214. url:$.app+"/hxgl/showcqtb",
  215. data:{
  216. cqid:$("#cqid").val()
  217. },
  218. type:"post",
  219. dataType:"json",
  220. success:function(data){//ajax返回的数据
  221. var str="";
  222. if (data) {
  223. for(var i=0;i<data.length-1;i++){
  224. str+="<tr id=\"tr"+i+"\">";
  225. var cq=data[i];
  226. str+="<td><span>"+data[data.length-1]+"</span></td>";
  227. str+="<input type=\"hidden\" name=\"cq\">";
  228. str+="<td><span id='kcrq"+i+"'>"+cq+"</span><input type=\"hidden\" value=\""+cq+"\" name=\"kcrq"+i+"\"></td>";
  229. str+="<td><input type=\"text\" class=\"form-control\" name=\"bcs"+i+"\"></td>";
  230. str+="<td><a class=\"btn btn-default btn-xs\" href=\"#\" onclick=\"hxgl.detail.shanchu("+i+")\"><i class=\"glyphicon glyphicon-trash\"></i>删除</a></td>"
  231. str+="</tr>"
  232. }
  233. $("#cqtb").empty();
  234. for(var i=0;i<6;i++){
  235. $("#deltr"+i).remove();
  236. }
  237. $("#cqtb").append(str);
  238. }
  239. }
  240. });
  241. }
  242. }
  243. van=function(a,b){
  244. if(!isFDS(a.val())){
  245. ts(b+"必须为正数",a);
  246. return false;
  247. }
  248. };
  249. hxgl.detail.shanchu=function(i){
  250. $.confirm({
  251. title: '确认框',
  252. content: '确认删除吗',
  253. confirm: function(){
  254. $("#tr"+i).remove();
  255. },
  256. cancel: function(){
  257. }
  258. });
  259. }
  260. hxgl.detail.del=function(data){
  261. $.confirm({
  262. title: '确认框',
  263. content: '确认删除吗',
  264. confirm: function(){
  265. $.post($.app + "/hxgl/delete", {
  266. id : data
  267. }, function(data) {
  268. if (data.success) {
  269. $.alert({
  270. title: '提示',
  271. content: '删除成功',
  272. confirm: function(){
  273. $("#hxglform").submit();
  274. $("#hxgladdform").submit();
  275. }
  276. });
  277. } else {
  278. $.alert({
  279. title: '提示',
  280. content: data.message,
  281. confirm: function(){
  282. }
  283. });
  284. }
  285. }, "json");
  286. },
  287. cancel: function(){
  288. }
  289. });
  290. }
  291. hxgl.detail.dele=function(data,trid){
  292. $.confirm({
  293. title: '确认框',
  294. content: '确认删除吗',
  295. confirm: function(){
  296. $.post($.app + "/hxgl/dele", {
  297. id : data
  298. }, function(data) {
  299. if (data.success) {
  300. $.alert({
  301. title: '提示',
  302. content: '删除成功',
  303. confirm: function(){
  304. $("#deltr"+trid).remove();
  305. if(trid==0){
  306. $("#deltr1").attr('id','deltr0');
  307. $("#deltr2").attr('id','deltr1');
  308. $("#deltr3").attr('id','deltr2');
  309. $("#deltr4").attr('id','deltr3');
  310. $("#kcrq1").attr('name','kcrq0');
  311. $("#kcrq2").attr('name','kcrq1');
  312. $("#kcrq3").attr('name','kcrq2');
  313. $("#kcrq4").attr('name','kcrq3');
  314. $("#bcs1").attr('name','bcs0');
  315. $("#bcs2").attr('name','bcs1');
  316. $("#bcs3").attr('name','bcs2');
  317. $("#bcs4").attr('name','bcs3');
  318. }else if(trid==1){
  319. $("#deltr2").attr('id','deltr1');
  320. $("#deltr3").attr('id','deltr2');
  321. $("#deltr4").attr('id','deltr3');
  322. $("#kcrq2").attr('id','kcrq1');
  323. $("#kcrq3").attr('id','kcrq2');
  324. $("#kcrq4").attr('id','kcrq3');
  325. $("#bcs2").attr('id','bcs1');
  326. $("#bcs3").attr('id','bcs2');
  327. $("#bcs4").attr('id','bcs3');
  328. }else if(trid==2){
  329. $("#deltr3").attr('id','deltr2');
  330. $("#deltr4").attr('id','deltr3');
  331. $("#kcrq3").attr('id','kcrq2');
  332. $("#kcrq4").attr('id','kcrq3');
  333. $("#bcs3").attr('id','bcs2');
  334. $("#bcs4").attr('id','bcs3');
  335. }else if(trid==3){
  336. $("#deltr4").attr('id','deltr3');
  337. $("#kcrq4").attr('id','kcrq3');
  338. $("#bcs4").attr('id','bcs3');
  339. }
  340. }
  341. });
  342. } else {
  343. $.alert({
  344. title: '提示',
  345. content: data.message,
  346. confirm: function(){
  347. }
  348. });
  349. }
  350. }, "json");
  351. },
  352. cancel: function(){
  353. }
  354. });
  355. }
  356. hxgl.detail.fuzhi=function(){
  357. /*location.href=$.app+"/hxgl/fuzhi?rq="+$("#rq").val();*/
  358. $.ajax({
  359. url:$.app+"/hxgl/fuzhi",
  360. data:{
  361. rq:$("#rq").val()
  362. },
  363. type:"post",
  364. success:function(data){//ajax返回的数据
  365. $.alert({
  366. title: '提示',
  367. content: '操作成功',
  368. confirm: function(){
  369. hxgl.detail.search();
  370. }
  371. });
  372. }
  373. });
  374. }
  375. hxgl.detail.tinghang=function(data){
  376. $.confirm({
  377. title: '确认框',
  378. content: '确认停航吗',
  379. confirm: function(){
  380. $.post($.app + "/hxgl/tinghang", {
  381. id : data
  382. }, function(data) {
  383. if (data.success) {
  384. $.alert({
  385. title: '提示',
  386. content: '停航成功',
  387. confirm: function(){
  388. hxgl.detail.search();
  389. }
  390. });
  391. } else {
  392. $.alert({
  393. title: '提示',
  394. content: data.message,
  395. confirm: function(){
  396. }
  397. });
  398. }
  399. }, "json");
  400. },
  401. cancel: function(){
  402. }
  403. });
  404. }