Procházet zdrojové kódy

进行批零打印

lvhao před 16 hodinami
rodič
revize
a90eaeaf00

+ 77 - 1
core/CoreApp/controllers/Whlabelfz.php

@@ -42,6 +42,8 @@ class Whlabelfz extends Start_Controller
 			$this->_bqplprint();
 		}elseif($arg == 'bqpladd'){
 			$this->_bqpladd();
+		}elseif($arg == 'printing'){
+			$this->_printing();
 		}
 	    else {
 			$this->_index();
@@ -827,8 +829,82 @@ class Whlabelfz extends Start_Controller
 		];
 	}
 
-	private function _bqplprint(){
+	private function _printing(){
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['s'])){
+			$v = $this->input->post('s');
+			$va = explode(',',rtrim($v,','));
+			$n = $this->input->post('n');
+			$tf = $this->input->post('tf');
+			$text = [];
+			$text['data'] = [];
+			$do_action_id = $va[$n];
+
+			$info = $this->whlabellabelprint->read($do_action_id);
+			if(empty($info)){
+				echo json_encode(array('msg'=>'ID为'.$do_action_id.'的数据不存在,请联系技术','success'=>false));exit;
+			}
+			if($info['status'] == 1){
+				echo json_encode(array('msg'=>$info['sku'].'的数据已打印,请勿重复打印','success'=>false));exit;
+			}
+
+			$list = [];
+			$sku = $info['features'];
+			if(!empty($sku)){
+				$list[] = [
+					'sku2'=>$sku
+				];
+			}
+			$u9_data = $this->logic_u9tools->getU9bm($list,'sku2');
+			$zh = $u9_data[0]['zh'];
+
+			$this->whlabellabelprint->save([
+				'status'=>1,
+				'print_time'=>time()
+			],$do_action_id);
+			$cpid = $this->whlabellabel->find_count();
+			$insert_arr = [
+				'shop'=>$info['shop'],
+				'purchase'=>$info['purchase'],
+				'sku'=>$info['sku'],
+				'number'=>$info['number'],
+				'features'=>$info['features'],
+				'featurespp'=>$info['featurespp'],
+				'title'=>$info['title'],
+				'label'=>$info['label'],
+				'warehouse'=>$info['warehouse'],
+				'time'=>time(),
+				'details'=>$info['details'],
+				'cpbz'=>$info['cpbz'],
+				'cpid'=>$cpid,
+			];
+			$this->whlabellabel->insert($insert_arr);
+			$text = [];
+			$text['number'] = $info['sku'];
+			
+			$details = ($info['details'] != '') ? '位置:(' . $info['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
+			if(!empty($warehouse_name)){
+				$details = ' <b style="font-size: 18px;">'.$warehouse_name."</b>  ".$details;
+			}
+			$purchase = $this->purchase->read($info['purchase']);
+			
+			$text['title'] = $info['title'];
+			$text['num'] = $info['label'];
+			$text['bqsku'] = $info['sku'];
+			$text['xbqnum'] = $info['dynum'];
+			$text['zh'] = str_replace('自然色 ', '', rtrim($zh, ' '));
+			$text['details'] = $details;
+			$text['purchase'] = $purchase['title'];
+			$text['cpbz'] = $info['cpbz'];
+			$text['usa'] = 0;
+			$rows = array('type'=>1,'n'=>$n-1,'data'=>$v,'text'=>$text);
+			echo json_encode(array('rows'=>($rows),'success'=>true));exit;
 
+		}
 	}
 
+	// private function _bqplprint(){
+
+	// }
+
 }

+ 140 - 1
template/erp/whlabelfz_bqpl.html

@@ -22,7 +22,7 @@
                         <option value="">选择打印机</option>
                     </select>
                 </div>
-                <a href="javascript:void(0);" class="printing">打 印</a>
+                <a href="javascript:void(0);" class="printing_bqpl">打 印</a>
                 <a href="javascript:void(0);" class="lv_print_excel">导入需要打印的文件</a>
                 <input id="upload-file" name="files" accept="image/xls,image/xlsx" type="file" class="none">
             </div>
@@ -209,6 +209,145 @@
     }
 
 
+    </script>
+
+    <script>
+        $(".printing_bqpl").click(function() {
+            var a = "";
+            $(".datatext input[name='check']:checked").each(function() {
+                a = a + $(this).val() + ",";
+            });
+            if (a) {
+                if ($("select[name='printer']").children("option:selected").val() == "") {
+                    $(".ts p").html("请选择打印机!");
+                    $(".ts").show();
+                    setTimeout('$(".ts").fadeOut()', 1000);
+                } else {
+                    $(".systemwindow div p:eq(0)").text("是否确认批量打印所选内容?");
+                    $(".systemwindow div p:eq(1)").html(
+                        "<p><font id='printingon_bqpl'>确 定</font><font class='esc'>取 消</font></p>");
+                    $(".systemwindow").show();
+                }
+            } else {
+                $(".ts p").html("请勾选需要打印的内容");
+                $(".ts").show();
+                setTimeout('$(".ts").fadeOut()', 1000);
+            }
+        });
+        /*  批量打印开始 */
+        $(".systemwindow").on('click', "#printingon_bqpl", function() {
+            $(".systemwindow").hide();
+            $(".systemwindow div p:eq(0)").html("<i class='fa fa-2x fa-cog fa-spin'></i> &nbsp; 正在处理打印信息,请稍后...");
+            $(".systemwindow div p:eq(1)").html("");
+            $(".systemwindow").show();
+
+            var a = "";
+            var i = 0;
+            $(".datatext input[name='check']:checked").each(function() {
+                a = a + $(this).val() + ',';
+                i++;
+            });
+            var tf = $("select[name='print']").children("option:selected").val();
+            ajax_bqpl(i - 1, a, tf);
+        });
+
+        function site_bqpl(num, list, number, data, i) {
+            var jobsite = $("#site").html();
+            if (jobsite == '0') {
+                $("#job").html("");
+                $("#site").html("");
+                if (data == '1') {
+                    var tf = $("select[name='print']").children("option:selected").val();
+                    ajax_bqpl(num, list, tf);
+                    return;
+                } else if (data == '2') {
+                    $("#music_print_ok")[0].play();
+                    $(".tyrows").hide();
+                    $(".systemwindow").hide();
+                    $("#music_d")[0].play();
+                    $(".systemwindow div p:eq(0)").html('运单打印完成,请更换为新运单后再次操作出库');
+                    $(".systemwindow div p:eq(1)").html("<font class='wcsj'>确 定</font>");
+                    $(".systemwindow").show();
+                    $("#orderinfo").val("");
+                    $("#orderinfo").focus();
+                } else {
+                    wprinter.sound("打印完成")
+                    $(".systemwindow div p:eq(0)").html("打印完成!");
+                    $(".systemwindow div p:eq(1)").html("<font class='printok'>确 定</font>");
+                    $(".systemwindow").show();
+                    return;
+                }
+            } else {
+                if (i < '71') {
+                    if ($("#job").html() != '') {
+                        wprinter.getStatusValue();
+                    }
+                    setTimeout(function() {
+                        site_bqpl(num, list, number, data, i + 1);
+                    }, 1500);
+                    return;
+                } else {
+                    wprinter.sound("打印机异常")
+                    $(".systemwindow div p:eq(0)").html("订单:" + number + " 打印失败!系统已停止打印,请检查打印机!如未出此单,请再次打印");
+                    $(".systemwindow div p:eq(1)").html("<font class='printok'>确 定</font>");
+                    $(".systemwindow").show();
+                    $("#job").html("");
+                    $("#site").html("");
+                    $(".tyrowsout").hide();
+                    $("#orderinfo").val("");
+                    $("#orderinfo").focus();
+                    return;
+                }
+            }
+        }
+
+        function ajax_bqpl(num, list, tf) {
+            $.ajax({
+                url: "/whlabelfz/printing/",
+                data: "tf=" + tf + "&s=" + list + "&n=" + num,
+                type: "POST",
+                dataType: "json",
+                timeout: 60001,
+                success: function(c) {
+                    if (c.success) {
+                        wprinter.xbq(c.rows.text)
+                        if (c.rows['n'] > -1) {
+                            //ajax(c.rows['n'],c.rows['data']);
+                            site_bqpl(c.rows['n'], c.rows['data'], c.rows['text']['number'], 1, 0);
+                        } else {
+                            if (c.rows['type'] == 3) {
+                                wprinter.sound("有错误订单")
+                                $(".systemwindow div p:eq(0)").html(c.rows['text']['number'] +
+                                "资料错误未成功打印,已移交给店员处理");
+                                $(".systemwindow div p:eq(1)").html("<font class='printok'>确 定</font>");
+                                $(".systemwindow").show();
+                            } else {
+                                site_bqpl(1, 1, c.rows['text']['number'], 0, 0);
+                            }
+
+                        }
+                    } else {
+                        $(".systemwindow").hide();
+                        layx.alert('错误', c.msg, function(id, button) {
+                            $(".search span").click();
+                        }, {
+                            dialogIcon: 'error'
+                        });
+                    }
+                },
+                error: function(textStatus) {
+                    wprinter.sound("错误,请求数据超时!请重试")
+                    $(".systemwindow").hide();
+                    layx.alert('错误', '请求数据超时!请重试', function(id, button) {
+                        $(".search span").click();
+                    }, {
+                        dialogIcon: 'error'
+                    });
+                },
+            });
+        }
+
+
     </script>
     <script type="text/javascript" src="{$theme}js/excel/xlxs.js" ></script>
     <script type="text/javascript" src="{$theme}js/laydate.js"></script>