Kaynağa Gözat

修改工厂的u9的外销单导出

lvhao 10 saat önce
ebeveyn
işleme
734f5f83c7

+ 80 - 0
core/CoreApp/controllers/Zzququeu9.php

@@ -83,6 +83,9 @@ class Zzququeu9 extends Start_Controller {
           }elseif($arg == 'cpkbh_index'){
                $this->_cpkbh_index();
           }
+          elseif($arg == 'excelwx'){
+               $this->_excelwx();
+          }
           elseif($arg == 'checkProduct'){
                $this->_checkProduct();
           }
@@ -1512,5 +1515,82 @@ class Zzququeu9 extends Start_Controller {
                echo json_encode(array('msg'=>$res['msg'],'success'=>false,'data'=>[]));
                exit;
           }
+    }
+
+    //导出excel
+    protected function _excelwx(){
+         $params = $this->input->post(null, TRUE);
+         if(empty($params)){
+           echo json_encode(array('msg'=>'参数错误','success'=>false));
+           exit;
+         }
+         $timetk = $this->input->post('timetk',true);//订单开始时间
+         $timetj = $this->input->post('timetj',true);//订单结束时间
+         $timetk = strtotime($timetk);
+         $timetj = strtotime($timetj);
+         $order_no = $this->input->post('order_no',true);
+         $where = " ( type = 20) ";
+         if($order_no){
+             $where .= " and order_no like '%".$order_no."%' ";
+         }
+         if($timetk && $timetj){
+             $where .= " and create_time  > ".$timetk." and create_time  < ".$timetj." ";
+         }
+        
+         
+         $info_list = $this->zzquque_u9->find_all($where,'*','id desc');
+         $list = [];
+         $lb_list= [];
+         foreach($info_list as $k=>$v){
+              $bzsh_no = $v['bzsh_no'];
+              $xs_no = empty($v['xs_no'])?"":$v['xs_no'];
+              $bzch_no = empty($v['bzch_no'])?"":$v['bzch_no'];               
+              $lb_list[] = $v['child_order_no'];
+              $list[] = [
+                   'id'=>$v['id'],
+                   'order_no'=>$v['order_no'],
+                   'type'=>"工厂外销单",
+                   'child_order_no'=>$v['child_order_no'],
+                   'bzsh_no'=> $bzsh_no,
+                   'xs_no'=>$xs_no,
+                   'bzch_no'=>$bzch_no,
+                   'create_time'=>date("Y-m-d H:i:s",$v['create_time']),
+                   'update_time'=>date("Y-m-d H:i:s",$v['update_time'])
+              ];
+         }
+         $lb_list = array_unique($lb_list);
+         $lb_arr = [];
+         if(!empty($lb_list)){
+              $lb_arr = $this->systemtransfer->find_all("id in (".implode(',',$lb_list).") ","id,jm,title,pm");
+              $lb_arr = array_column($lb_arr,null,'id');
+         }
+         foreach($list as $k=>$v){
+              $list[$k]['child_order_no'] = isset($lb_arr[$v['child_order_no']])?$lb_arr[$v['child_order_no']]['pm']:'';
+         }
+         $final_list = [];
+         foreach($list as $k=>$v){
+          $final_list[] = [
+               "订单号"=>$v['order_no'],
+               "类型"=>$v['type'],
+               "成品入库单号"=>$v['bzsh_no'],
+               "销售单号"=>$v['xs_no'],
+               "标准出货单号"=>$v['bzch_no'],
+               "创建时间"=>$v['create_time'],
+               "更新时间"=>$v['update_time'],
+               "品名"=>$v['child_order_no'],
+          ];
+         }
+         if(empty($list)){
+           echo json_encode(array('msg'=>'没有数据','success'=>false));
+           exit;
+         }else{
+           echo json_encode(array('msg'=>'获取成功','success'=>true,'data'=>$final_list));
+           exit;
+         }
+        
+
+
+
+
     }
 }

+ 63 - 14
template/erp/zzququeu9wx.html

@@ -51,8 +51,8 @@
                 <!-- <a href="javascript:void(0);" class="btn btn-success" onclick="addData()">添 加</a> -->
                 
                 <!-- <a href="javascript:void(0);" style="font-size: 15px;" class="check">删 除</a> -->
-                <!-- <a href="javascript:void(0);" style="font-size: 15px;background-color: #f39c12;" onclick="excelexport()">按条件导出</a> -->
-                </div>
+                <a href="javascript:void(0);" style="font-size: 15px;background-color: #f39c12;" onclick="excelexport()">按条件导出</a>
+            </div>
             
             <table class="datatitle data" border="0" style="border-collapse:collapse;">
                 <tr>
@@ -216,26 +216,75 @@
         });
     });
     function excelexport(){
-        let url = "/zzququeu9/excel"
-        //timetk="+$("input[name='timetk']").val()+"&timetj="+$("input[name='timetj']").val();
+        let obj = {};
         let order_no = $("input[name='order_no']").val();
-        url += "?order_no="+order_no
+        if(order_no){
+            obj.order_no = order_no;
+        }
+
         let timetk = $("input[name='timetk']").val();
-        url += "&timetk="+timetk;
+        obj.timetk = timetk;
         let timetj = $("input[name='timetj']").val()
-        url += "&timetj="+timetj;
-        let status = $(".select").val()
-        if(status){
-            url += "&status="+status;
-        }
+        obj.timetj = timetj;
+
+
         
-        window.location.href = url
+        layx.load('loadId','提交中,请稍后',{shadable:0.6});
+        $.ajax({
+            url:"/zzququeu9/excelwx",
+            data:obj,
+            type:"post",
+            dataType:"json",
+            success:function(a){
+                layx.destroy('loadId');
+                if (a && a.success) {
+                    explortExcel(a.data);
+                }else{
+                    layx.msg(a.msg,{dialogIcon:'warn', position:'cc'});
+                }
+            }
+        })
     }
 
-     
+    function explortExcel(data){
+        let  sheet = XLSX.utils.json_to_sheet(data)
+        sheet['!cols'] = [
+                //订单号
+                {
+                    wch:20,
+                },
+                //订单编码
+                {
+                    wch:15,
+                },
+                {
+                    wch:20,
+                },
+                {
+                    wch:20,
+                },
+                {
+                    wch:20,
+                },{
+                    wch:20,
+                },
+                {
+                    wch:20,
+                },
+                {
+                    wch:100,
+                },
+                
+                
+            ];
+        let workbook = XLSX.utils.book_new();
+        
+        XLSX.utils.book_append_sheet(workbook, sheet, "Sheet1");
+        XLSX.writeFile(workbook, "工厂外销订单.xlsx");
+    }
     </script>
     <script type="text/javascript" src="{$theme}js/laydate.js"></script>
-    <script type="text/javascript" src="{$theme}js/print.js?v=202007160001"></script>
+    <script type="text/javascript" src="{$theme}js/excel/xlxs.js" ></script>
 
 
     {Template footer}