_useOutJs.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  1. <script src="/js/productset/jquery.min.js"></script>
  2. <script src="/js/ims/jquery.datetimepicker.js"></script>
  3. <script src="/js/layer/layer.js"></script>
  4. <script src="/js/ims/xsgl.js"></script>
  5. <script type="text/javascript" src="/js/ims/qrcode.min.js"></script>
  6. <script>
  7. $(document).ready(function () {
  8. <?php if (isset($_GET['startDate'])):?>
  9. $("#some_class_1").attr("value", "<?php echo $_GET['startDate']?>");
  10. $("#some_class_2").attr("value", "<?php echo $_GET['endDate']?>");
  11. <?php endif;?>
  12. <?php if (isset($_GET['inCode'])):?>
  13. $("#inCode").attr("value", "<?php echo $_GET['inCode']?>");
  14. <?php endif;?>
  15. <?php if(isset($_GET['isUse'])):?>
  16. var isUse = "<?php echo $_GET['isUse'];?>";
  17. $('#isUse').val(isUse);
  18. var txt = $('.select-isUse li[val=' + isUse + ']').html();
  19. $('.select-isUse .diy_select_txt').html(txt);
  20. <?php endif;?>
  21. <?php if(isset($_GET['itemId']) && $_GET['itemId'] != ''):?>
  22. var itemId = "<?php echo $_GET['itemId'];?>";
  23. $('#itemId').val(itemId);
  24. var txt = $('.select-itemId li[val=' + itemId + ']').html();
  25. $('.select-itemId .diy_select_txt').html(txt);
  26. <?php endif;?>
  27. <?php if(isset($_GET['itemType']) && $_GET['itemType'] != ''):?>
  28. var itemType = "<?php echo $_GET['itemType'];?>";
  29. $('#itemType').val(itemId);
  30. var txt = $('.select-itemType li[val=' + itemType + ']').html();
  31. $('.select-itemType .diy_select_txt').html(txt);
  32. <?php endif;?>
  33. <?php if(isset($_GET['inputStatus']) && $_GET['inputStatus'] != ''):?>
  34. var inputStatus = "<?php echo $_GET['inputStatus'];?>";
  35. $('#inputStatus').val(inputStatus);
  36. var txt = $('.select-inputStatus li[val=' + inputStatus + ']').html();
  37. $('.select-inputStatus .diy_select_txt').html(txt);
  38. <?php endif;?>
  39. $('.some_class').datetimepicker({
  40. format: "Y-m-d", //格式化日期
  41. timepicker: false //关闭时间选项
  42. });
  43. //初始化状态
  44. var currStatus = "<?php echo isset($_GET['status']) ? $_GET['status'] : '';?>";
  45. if (currStatus > 0) {
  46. var statusText = $(".pm_status>li[val='" + currStatus + "']").text();
  47. $(".pm_status_txt").text(statusText);
  48. }
  49. //初始化品目
  50. var currPmId = "<?php echo isset($_GET['itemId']) ? $_GET['itemId'] : '';?>";
  51. if (currPmId > 0) {
  52. var pmNameText = $(".pm_name>li[val='" + currPmId + "']").text();
  53. $(".select-itemId .pm_name_txt").text(pmNameText);
  54. }
  55. //增加出库单
  56. $(".add_use_order").click(function () {
  57. window.location.href = "<?php echo $this->createUrl('imsStore/useAddEdit');?>";
  58. });
  59. //增加退库库单
  60. $(".add_out_order").click(function () {
  61. window.location.href = "<?php echo $this->createUrl('imsStore/outAddEdit');?>";
  62. });
  63. //取消发放新增
  64. $(".cancle_out").click(function () {
  65. window.location.href = "<?php echo $this->createUrl('imsStore/deliveryOutAdd');?>";
  66. });
  67. //切换领用和出库
  68. $(".use-out>a").click(function () {
  69. $(this).addClass("active").siblings().removeClass("active");
  70. var index = $(this).index();
  71. var type = $(this).attr('type');
  72. var url = '';
  73. if(type == 'out'){
  74. url = "<?php echo $this->createUrl('imsStore/useOut',array('useOutType'=>'out'));?>";
  75. }else if(type == 'use'){
  76. url = "<?php echo $this->createUrl('imsStore/useOut',array('useOutType'=>'use'));?>";
  77. }else{
  78. url = "<?php echo $this->createUrl('imsStore/useOut',array('useOutType'=>'cancle'));?>";
  79. }
  80. window.location.href = url;
  81. // $(".ims-box").eq(index).removeClass('hidden').siblings(".ims-box").addClass('hidden');
  82. });
  83. $("body").delegate(".grade>span", "click", function () {
  84. $(this).parent().children(".student-list").toggle();
  85. return false;
  86. });
  87. $("body").delegate(".student-list>.class-li>span", "click", function () {
  88. $(this).parent().toggleClass("active");
  89. $(this).parent().children(".student-name_box").toggle();
  90. return false;
  91. });
  92. // 单选按钮
  93. $('body').on('change', "input[name='studentName']", function () {
  94. getsStudentSelected();
  95. });
  96. //关联订单
  97. $(".rel-order").click(function () {
  98. var isUse = $(this).attr('isUse');
  99. if(isUse <= 0){
  100. layer.alert('请先完成签字', {icon: 7});
  101. return false;
  102. }
  103. });
  104. //指定明细
  105. //-----------------------编辑名单-common---------------------------
  106. function selectedSet(selectObj){
  107. selectObj.each(function(idx){
  108. var val = $(this).attr('value');
  109. $('.student-list_box').find('input[value='+val+']').prop("checked",true)
  110. })
  111. $(".student-list").each(function(){
  112. var count = 0;
  113. $(this).find('input').each(function(){
  114. if($(this).is(":checked")){
  115. count++;
  116. }
  117. })
  118. if(count == $(this).find('input').length){
  119. $(this).find('.btn-select_all').addClass('isSelected')
  120. }else{
  121. $(this).find('.btn-select_all').removeClass('isSelected')
  122. }
  123. })
  124. }
  125. $("body").delegate('.appoint-detail',"click", function () {
  126. var orderId = $(this).attr('orderId');
  127. var outId = $(this).attr('outId');
  128. var appointObj = $(this);
  129. $.ajax({
  130. type: 'POST',
  131. url: "<?php echo $this->createUrl('imsStore/ajaxAppointDetail');?>",
  132. data: {orderId: orderId,outId:outId},
  133. async: false,
  134. dataType: 'json',
  135. success: function (result) {
  136. if (result.status == 1) {
  137. $('.student-list_box').html(result.data);
  138. isGetStu = true;
  139. } else {
  140. layer.msg('学生列表获取失败!');
  141. return false;
  142. }
  143. },
  144. error: function (jqXHR, textStatus, errorThrown) {
  145. layer.msg('学生列表获取失败!');
  146. return false;
  147. }
  148. });
  149. //初始化选择的学生
  150. getsStudentSelected();
  151. // if (isGetStu == false) {
  152. // return false;
  153. // }
  154. selectedSet($(".student-selected i"));
  155. var layerEditIndex = layer.open({
  156. type: 1,
  157. title: '明细订单',
  158. btn: ['保存'],
  159. area: ['800px', '420px'], //宽高
  160. btnAlign: 'c',
  161. content: $('.layer-edit'),
  162. yes: function (index, layero) {
  163. //选择的学生
  164. var stuSeled = $(".student-selected i");
  165. var _studentIds = [];
  166. var _classId = 0;
  167. stuSeled.each(function () {
  168. _classId = $(this).attr('classId');
  169. _studentIds.push($(this).attr('value'));
  170. });
  171. if(_studentIds.length <= 0){
  172. layer.msg('请选择学生!');
  173. return false;
  174. }
  175. $.ajax({
  176. type: 'post',
  177. url: "<?php echo Yii::app()->createUrl('imsStore/ajaxSaveRelOrder');?>",
  178. data: {'outId':outId,studentIds:_studentIds},
  179. dataType: 'json',
  180. success: function (data) {
  181. if (data.status) {
  182. layer.alert("操作成功", {icon:1,closeBtn:0})
  183. layer.closeAll();
  184. location.reload();
  185. } else {
  186. layer.alert(data.msg, {icon: 7});
  187. return false;
  188. }
  189. },
  190. error: function () {
  191. layer.msg("网络异常");
  192. return false;
  193. }
  194. })
  195. layer.close(layerEditIndex);
  196. }
  197. });
  198. return false;
  199. });
  200. // 全选按钮
  201. $("body").delegate(".btn-select_all", "click", function () {
  202. var obj = $(this).parent().find("input");
  203. if($(this).hasClass('isSelected')){
  204. obj.each(function () {
  205. $(this).prop("checked", false);
  206. })
  207. $(this).removeClass("isSelected");
  208. }else{
  209. obj.each(function () {
  210. $(this).prop("checked", true);
  211. })
  212. $(this).addClass("isSelected");
  213. }
  214. getsStudentSelected();
  215. return false;
  216. });
  217. //删除学生
  218. $(".student-selected").on("click", ".btn-delete", function () {
  219. $(this).parent().remove();
  220. var studentValue = $(this).attr('value');
  221. $("input[value='" + studentValue + "']").prop("checked", false);
  222. var selectedData = $("input[name='studentName']:checked"); //获取所以选中学生
  223. $('#studentSelectedLength').text(selectedData.length);
  224. return false;
  225. });
  226. //选择学生
  227. function getsStudentSelected() {
  228. var selectedData = $("input[name='studentName']:checked"); //获取所以选中学生
  229. var selectedDataList = [];
  230. var studentName, studentClass = '';
  231. var classId = 0;
  232. for (var i = 0; i < selectedData.length; i++) {
  233. studentName = $(selectedData[i]).parent().text();
  234. classId = $(selectedData[i]).attr('classId');
  235. console.log(classId)
  236. studentClass = $(selectedData[i]).parents('li').children('span.classTitle').text();
  237. selectedDataList.push('<li><span class="stu_name">' + studentName + '</span>--<span class="stu_class">' + studentClass + '</span><i class="btn-delete" classId="'+classId+'" value="' + selectedData[i].value + '" gradeName="' + $(selectedData[i]).attr('gradeName') + '" className="' + $(selectedData[i]).attr('className') + '">X</i></li>');
  238. }
  239. $('.student-selected').html(selectedDataList);
  240. $('#studentSelectedLength').text(selectedData.length);
  241. };
  242. //加减库存
  243. $(".reduce-out").click(function () {
  244. var obj = $("input[name='out_stock_num']");
  245. var stock_nun = parseInt(obj.val());
  246. if(stock_nun > 1){
  247. obj.val(stock_nun - 1);
  248. }
  249. });
  250. $(".add-out").click(function () {
  251. var obj = $("input[name='out_stock_num']");
  252. var stock_nun = parseInt(obj.val());
  253. if(stock_nun < $(".valid-num").text()){
  254. obj.val(stock_nun + 1);
  255. }
  256. });
  257. //生成二维码
  258. $(".sign-btn").click(function () {
  259. var url = $(this).attr('url');
  260. $("#qrcode").html('');
  261. if(!url){
  262. layer.msg("没有地址");
  263. return false;
  264. }
  265. var qrcode = new QRCode(document.getElementById("qrcode"), {
  266. width : 100,
  267. height : 100
  268. });
  269. qrcode.makeCode(url);
  270. $(".qrcode-fram img").on('load',function(){
  271. layer.open({
  272. type: 1,
  273. title: '签字二维码',
  274. btn: ['关闭'],
  275. area: ['340px', '240px'], //宽高
  276. btnAlign: 'c',
  277. content: '<div style="text-align:center;"><div id="imsCode">'+$("#qrcode").html()+'</div><p style="font-size: 12px">手机扫描二维码,到手机浏览器打开签字链接</p></div>',
  278. yes: function(index){
  279. location.reload();
  280. },
  281. btn2: function (index, layero) {
  282. //取消按钮
  283. // console.log(111)
  284. //return false 开启该代码可禁止点击该按钮关闭
  285. }
  286. });
  287. });
  288. return false;
  289. });
  290. $(".signed-btn").click(function () {
  291. var imgUrl = $(this).attr('imgUrl');
  292. if(!imgUrl){
  293. return false;
  294. }
  295. layer.open({
  296. type: 1,
  297. title: '签字图片',
  298. btn: ['关闭'],
  299. area: ['500px', '300px'], //宽高
  300. btnAlign: 'c',
  301. content: '<div style="text-align:center;"><img style="max-width:100%;" src="'+imgUrl+'"/> </div>',
  302. btn2: function (index, layero) {
  303. //取消按钮
  304. // console.log(111)
  305. //return false 开启该代码可禁止点击该按钮关闭
  306. }
  307. });
  308. });
  309. /*************************************************** 退库 *************************************/
  310. //删除
  311. $(".del-btn").on("click", function () {
  312. var outId = $(this).attr('outId');
  313. layer.confirm('您确定删除吗?', {
  314. btn: ['确定', '取消'] //按钮
  315. }, function () {
  316. $.ajax({
  317. type: 'post',
  318. url: "<?php echo Yii::app()->createUrl('imsStore/ajaxDelOut');?>",
  319. data: {'outId': outId},
  320. dataType: 'json',
  321. success: function (data) {
  322. if (data.status) {
  323. layer.alert("删除成功", {icon:1,closeBtn:0},function (index) {
  324. location.reload();
  325. layer.closeAll();
  326. });
  327. } else {
  328. layer.alert(data.msg, {icon: 7});
  329. }
  330. },
  331. error: function () {
  332. layer.msg("网络异常");
  333. }
  334. })
  335. });
  336. });
  337. //确认退库
  338. $(".confirm-out").click(function () {
  339. var outId = $(this).attr('outId');
  340. $.ajax({
  341. type: 'get',
  342. url: "<?php echo Yii::app()->createUrl('imsStore/ajaxConfirmOut');?>",
  343. data: {'outId': outId},
  344. dataType: 'json',
  345. success: function (data) {
  346. if (data.status) {
  347. layer.alert("提交成功", {icon: 1,closeBtn:0},function (index) {
  348. location.reload();
  349. layer.closeAll();
  350. });
  351. } else {
  352. layer.alert(data.msg, {icon: 7});
  353. return false;
  354. }
  355. },
  356. error: function () {
  357. layer.msg("网络异常");
  358. return false;
  359. }
  360. })
  361. layer.closeAll();
  362. });
  363. //出库和退库,删除和中止
  364. $(".del-stop-btn").click(function () {
  365. var businessKey = $(this).attr('businessKey');
  366. var doType = $(this).attr('doType');
  367. $.ajax({
  368. type: 'get',
  369. url: "<?php echo Yii::app()->createUrl('imsStore/ajaxOutDelStop');?>",
  370. data: {'businessKey': businessKey,doType:doType},
  371. dataType: 'json',
  372. success: function (data) {
  373. if (data.status) {
  374. layer.alert("提交成功", {icon: 1,closeBtn:0},function (index) {
  375. location.reload();
  376. layer.closeAll();
  377. });
  378. } else {
  379. layer.alert(data.msg, {icon: 7});
  380. return false;
  381. }
  382. },
  383. error: function () {
  384. layer.msg("网络异常");
  385. return false;
  386. }
  387. })
  388. });
  389. //催办
  390. $("body").on("click", ".btn-urge", function () {
  391. var flag = true;
  392. var businessKey = $(this).attr('businessKey');
  393. layer.open({
  394. type: 1,
  395. title: '催办',
  396. btn: ['确定', '取消'],
  397. area: ['600px', '400px'], //宽高
  398. btnAlign: 'c',
  399. content: '<p style="color: red;display: none;" class="alert-msg"></p><div class="urge-layer-box"><span>内容:</span><textarea rows="10" cols="60" id="urgeText" /></div>',
  400. yes: function (index, layero) {
  401. //提交
  402. var text = $('#urgeText').val();
  403. var data = {
  404. 'smeDesc': text,
  405. 'businessKey': businessKey
  406. };
  407. if ($.trim(text)) {
  408. if (flag) {
  409. flag = false;
  410. $.ajax({
  411. type: 'post',
  412. url: "<?php echo Yii::app()->createUrl('imsSale/urge');?>",
  413. data: data,
  414. dataType: 'json',
  415. success: function (data) {
  416. if (data.status) {
  417. layer.closeAll();
  418. location.reload();
  419. } else {
  420. flag = true;
  421. $('.alert-msg').html(data.msg).fadeIn();
  422. }
  423. },
  424. error: function () {
  425. flag = true;
  426. $('.alert-msg').html("异常错误").fadeIn();
  427. }
  428. });
  429. }
  430. } else {
  431. $('.alert-msg').html("请填写内容").fadeIn();
  432. }
  433. },
  434. btn2: function (index, layero) {
  435. //取消按钮
  436. console.log(111)
  437. //return false 开启该代码可禁止点击该按钮关闭
  438. }
  439. });
  440. });
  441. $(".viewStudent").on("click", function () {
  442. var inId = $(this).attr('inId');
  443. loadStudent(inId,1);
  444. return false;
  445. });
  446. function loadStudent(inId,page){
  447. $('.layer-relate').find('tbody').html('');
  448. $('input[name=inId]').val(inId);
  449. $.ajax({
  450. type: 'post',
  451. url: "<?php echo Yii::app()->createUrl('imsStore/AjaxSaleStudentList');?>",
  452. data: {'inId': inId,'page':page},
  453. dataType: 'json',
  454. success: function (res) {
  455. if(res.status==1){
  456. list=res.data.list;
  457. if(list.length>0){
  458. var html='';
  459. for(var i=0;i<list.length;i++){
  460. html+='<tr>';
  461. html+='<td>'+list[i]['clazzName']+'</td>';
  462. html+='<td>'+list[i]['studentName']+'</td>';
  463. html+='</tr>';
  464. }
  465. $('.layer-relate').find('tbody').html(html);
  466. }
  467. $('.last_page').html(res.data['lastPage']);
  468. $('.now_page').html(res.data['pageNum']);
  469. if(res.data['pageNum']==1){
  470. $('.prev').addClass('hide');
  471. }
  472. if(res.data['pageNum']==res.data['lastPage']){
  473. $('.next').addClass('hide');
  474. }
  475. layer.open({
  476. type: 1,
  477. title: '学生列表',
  478. btn: ['关闭'],
  479. area: ['810px', '420px'], //宽高
  480. btnAlign: 'c',
  481. content: $('.layer-relate'),
  482. yes: function (index, layero) {
  483. layer.closeAll();
  484. }
  485. });
  486. }
  487. }
  488. });
  489. $('.prev').click(function(){
  490. var now_page=parseInt($('.now_page').html());
  491. if(now_page<=1){
  492. return false;
  493. }
  494. var idId=$('input[name=inId]').val();
  495. loadStudent(idId,(now_page-1));
  496. });
  497. $('.next').click(function(){
  498. var now_page=parseInt($('.now_page').html());
  499. var last_page=parseInt($('.last_page').html());
  500. if(now_page>=last_page){
  501. return false;
  502. }
  503. var idId=$('input[name=inId]').val();
  504. loadStudent(idId,(now_page+1));
  505. });
  506. }
  507. })
  508. </script>