Pārlūkot izejas kodu

采购单导出接口

wufeng 2 gadi atpakaļ
vecāks
revīzija
17530aaa44
2 mainītis faili ar 68 papildinājumiem un 0 dzēšanām
  1. 67 0
      app/admin/controller/Purch.php
  2. 1 0
      app/admin/route/app.php

+ 67 - 0
app/admin/controller/Purch.php

@@ -684,6 +684,73 @@ class Purch extends Base
 
     }
 
+
+    //采购单导出
+    public function exportCgdList()
+    {
+
+        $cgdNos = $this->request->post('cgdNos', [], 'trim');
+
+        if (empty($cgdNos)) return error_show(1004, '要导出的采购单编号不能为空');
+
+        $i = 1;
+        $list = Db::name("purchease_order")
+            ->alias('po')
+            ->field('"" as 序号,po.addtime as 创建时间,po.cgdNo as 单据号,po.status as 单据状态,po.cgder as 采购员,s.orderCode as 确认单号,s.addtime as 确认单时间,po.spuCode as 产品编号,po.good_name as 产品名称,"" as 规格,"" as 单位,po.supplier_name as 供应商名称,po.supplierNo as 供应商编号,po.nake_fee as 裸价,po.delivery_fee as 物流费,s.send_type as 发货方式,po.good_price as 采购单价,s.remark as 确认单备注,po.good_num as 采购数量,po.total_fee as 采购货款,b.company as 购买方公司,s.arrive_time as 到货时间,po.order_type')
+            ->whereIn('po.cgdNo', $cgdNos)
+            ->leftJoin('order_num on', 'on.cgdNo=po.cgdNo')
+            ->leftJoin('sale s', 's.orderCode=on.orderCode')
+            ->leftJoin('business b', 'b.companyNo=s.supplierNo')
+            ->order("po.addtime desc")
+            ->withAttr('序号', function () use (&$i) {
+                return $i++;
+            })
+            ->select()
+            ->toArray();
+
+//        foreach ($list as &$value) {
+//
+//            if($value['order_type']==3|| $value['order_type']==4){
+//                $temp_speclist = Db::name("good_zixun")
+//                    ->where(["spuCode"=>$value['产品编号'],"is_del"=>0])
+//                    ->value('specinfo','');
+////                    $temp_speclist=isset($goon['specinfo'])&&$goon['specinfo']!=""? json_decode($goon['specinfo'],true):"";
+//                }else {
+////                    $goon =Db::name('good_basic')
+////                        ->where(['spuCode'=>$value['产品编号']])
+////                        ->find();
+//                    $spec = Db::name("good_spec")
+//                        ->field('id,spec_id,spec_value_id')
+//                        ->where(["spuCode"=>$value['产品编号'],"is_del"=>0])
+//                        ->select()
+//                        ->toArray();
+//                    $speclist=[];
+//                    if(!empty($spec)){
+//                        foreach ($spec as $val){
+//                            $temp=[];
+////                            $temp['id']=$val['id'];
+////                            $temp['spuCode']=$val['spuCode'];
+////                            $temp['spec_id']=$val['spec_id'];
+////                            $temp['spec_value_id']=$val['spec_value_id'];
+//                            $temp['spec_name'] = Db::name("specs")->where(["id"=>$val['spec_id']])->value('spec_name','');
+//                            $temp['spec_value'] = Db::name("spec_value")->where(["id"=>$val['spec_value_id']])->value('spec_value','');
+//
+//                            $speclist[]=$temp;
+//                        }
+//                    }
+//                    $temp_speclist=empty($speclist)?[]:$speclist;
+//                }
+//
+//            $value['规格']=json_encode($temp_speclist,JSON_UNESCAPED_UNICODE);
+//
+//            unset($value['order_type']);
+//
+//        }
+
+        $headerArr = array_keys($list[0]);
+        excelSave('采购单导出' . date('YmdHis') . '.xls', $headerArr, $list);
+    }
+
 //    public function create(){
 //        $customer = isset($this->post['customer_code'])&&$this->post['customer_code']!="" ?trim($this->post['customer_code']):"";
 //        if($customer==""){

+ 1 - 0
app/admin/route/app.php

@@ -198,6 +198,7 @@ Route::rule("cgddifflist","admin/Purch/difflist");
 Route::rule("cgddiffinfo","admin/Purch/diffinfo");
 Route::rule("cgddiffstatu","admin/Purch/diffstatu");
 Route::rule("cgdeditgoldprice","admin/Purch/editGoldPrice");//修改采购单实时金价
+Route::rule("exportcgdlist","admin/Purch/exportCgdList");//导出采购单
 
 Route::rule("orderinlist","admin/Purchin/list");
 Route::rule("orderinadd","admin/Purchin/add");