zhanglinxin hai 1 ano
pai
achega
813f02cb5f

+ 2 - 7
application/api/controller/Common.php

@@ -354,13 +354,8 @@ class Common extends Base
     public function test()
     {
         $id = input('id') ?: 0;
-        $html = ApproveInfoService::get_html($id);
-//        p($html);exit;
-        $realpath = self::getPath();
-        $pdf = new \TCPDF();
-        $pdf = self::setPdfAttr($pdf);
-        self::exportPdf($pdf,$html,$realpath);
-        $this->success('测试');
+        $data = ApproveInfoService::download($id);
+        $this->success('测试',$data);
     }
 
 }

+ 5 - 3
application/common/service/ApproveInfoService.php

@@ -1485,10 +1485,12 @@ class ApproveInfoService
         $get_pay_type_list = ApplyConstant::get_pay_type_list();
         $get_degree_list = OfferConstant::get_degree_list();
         $get_type_list = CommonService::get_type_list($data['module']);
+        $title = $get_module_list[$data['module']];
+        $name = $data['create_user']['name'].'提交的'.$title.'审批单';
         $data = compact('vo','template','get_module_list','get_approve_status_list','get_approve_status_list_admin','get_is_who_list','get_pay_type_list','get_degree_list','get_type_list');
 
         $html = self::get_html($data);
-        $realpath = self::getPath();
+        $realpath = self::getPath($name);
         $pdf = new \TCPDF();
         $pdf = self::setPdfAttr($pdf);
         self::exportPdf($pdf,$html,$realpath);
@@ -1504,7 +1506,7 @@ class ApproveInfoService
     }
 
     // 获取路径
-    public static  function getPath(){
+    public static  function getPath($name){
         //保存文件
         $subPath = date('Ymd');
         $savePath = './upload/pdf/' . $subPath;
@@ -1527,7 +1529,7 @@ class ApproveInfoService
             }
         }
         $filename = date('Ymd') . sha1(date('YmdHis', time()) . uniqid());
-        $filename = date('Ymd') . date('YmdHis', time()).time();
+        $filename = $name.date('Ymd') . date('YmdHis', time()).time();
         $suffix = '.pdf';
         $realpath = substr($savePath, 1) . '/' . $filename . $suffix;
         return $realpath;