zhanglinxin 1 年之前
父节点
当前提交
33d0e02d90

+ 6 - 1
application/api/controller/Approveinfo.php

@@ -34,7 +34,11 @@ class Approveinfo extends Base
      * @Apidoc\Param("desc", type="string", require=false, desc="module=2缓急程度,module=8具体内容,module=9缓急程度,module=10来文单位名称,module=11缓急程度")
      * @Apidoc\Param("start_time", type="string", require=false, desc="module=5出差开始时间,module=6请假开始时间,module=7出发时间,module=1预计申购完成日期(日期),module=10收文日期(日期),module=11拟发文时间(日期)")
      * @Apidoc\Param("end_time", type="string", require=false, desc="module=5出差结束时间,module=6请假结束时间,module=7返回时间")
-     * @Apidoc\Param("document", type="string", require=false, desc="module=1,module=2,module=3,module=4,module=5,module=6,module=7,module=9,module=10,module=11 附件(多个用英文逗号隔开)")
+     * @Apidoc\Param("document", type="array", require=false, desc="module=1,module=2,module=3,module=4,module=5,module=6,module=7,module=9,module=10,module=11 附件",
+     *     @Apidoc\Param("fullurl", type="string", require=true, desc="文件地址"),
+     *     @Apidoc\Param("name", type="string", require=true, desc="文件名称"),
+     *     @Apidoc\Param("size", type="string", require=true, desc="文件大小"),
+     * )
      * @Apidoc\Param("images", type="string", require=false, desc="module=1,module=3,module=5,module=6,module=7,module=8 图片(多个用英文逗号隔开)")
      * @Apidoc\Param("remark", type="string", require=false, desc="module=2申请内容,module=3其它补充说明,module=4其它补充说明,module=5备注,module=6是否离深,module=9备注说明,module=10内容摘要,module=11上会情况")
      * @Apidoc\Param("total_amount", type="string", require=false, desc="module=1总金额")
@@ -122,6 +126,7 @@ class Approveinfo extends Base
         $start_time = input('start_time');
         $end_time = input('end_time');
         $document = input('document') ?: '';
+        $document = $document ? json_encode($document,JSON_UNESCAPED_UNICODE) : '';
         $images = input('images') ?: '';
         $remark = input('remark') ?: '';
         $total_amount = input('total_amount') ?: 0;

+ 34 - 22
application/api/controller/Upload.php

@@ -13,14 +13,15 @@ use think\Exception;
  */
 class Upload extends Base
 {
-    protected $id ;
+    protected $id;
     protected $key;
     protected $host;
 
-    public function initialize(){
-       $this->id =   sysconf('storage_oss_keyid');
-       $this->key =  sysconf('storage_oss_secret');
-       $this->host = "https://".sysconf('storage_oss_domain');
+    public function initialize()
+    {
+        $this->id = sysconf('storage_oss_keyid');
+        $this->key = sysconf('storage_oss_secret');
+        $this->host = "https://" . sysconf('storage_oss_domain');
     }
 
     /**
@@ -32,7 +33,9 @@ class Upload extends Base
      * @Apidoc\ParamType("formdata")
      * @Apidoc\Param("file",type="file", require=true,desc="附件")
      * @Apidoc\Returned("url", type="string", desc="上传后的文件路径")
-     * @Apidoc\Returned("fullurl", type="string", desc="全路径")
+     * @Apidoc\Returned("fullurl", type="string", desc="文件地址")
+     * @Apidoc\Returned("name", type="string", desc="文件名称")
+     * @Apidoc\Returned("size", type="string", desc="文件大小")
      */
     public function upload()
     {
@@ -46,23 +49,29 @@ class Upload extends Base
         if ($file->checkExt('php,sh')) {
             $this->error('可执行文件禁止上传到本地服务器!');
         }
+        $fileinfo = $file->getInfo();
         $this->safe = boolval(input('safe'));
         $this->uptype = $this->getUploadType();
         $this->extend = pathinfo($file->getInfo('name'), PATHINFO_EXTENSION);
-//        $name = File::name($file->getPathname(), $this->extend, '', 'md5_file');
         $subPath = date('Ymd');
+        $savePath = $subPath;
         $filename = date('YmdHis') . uniqid();
-        $suffix = '.'.$this->extend;
-        $realpath = $subPath . '/' . $filename.$suffix;
-        try{
+        $suffix = '.' . $this->extend;
+        $realpath = $savePath . '/' . $filename . $suffix;
+        try {
             $info = File::instance($this->uptype)->save($realpath, file_get_contents($file->getRealPath()), $this->safe);
-        } catch (Exception $e){
+        } catch (Exception $e) {
             $this->error($e->getMessage());
         }
         if (is_array($info) && isset($info['url'])) {
             $url = $this->safe ? $realpath : $info['url'];
-            $data = ['url' => '/'.$info['key'], 'fullurl' => $info['url']];
-            $this->success('上传成功',$data);
+            $data = [
+                'url' => '/' . $info['key'],
+                'fullurl' => $info['url'],
+                'name' => $fileinfo['name'],
+                'size' => $fileinfo['size'],
+            ];
+            $this->success('上传成功', $data);
         } else {
             $this->error('文件处理失败,请稍候再试!');
         }
@@ -89,21 +98,23 @@ class Upload extends Base
      * @Apidoc\Returned("expire", type="string", desc="有效截止时间")
      * @Apidoc\Returned("key", type="string", desc="路径(前端生成的目录名称+/)")
      */
-    public function getSignedUrl(){
+    public function getSignedUrl()
+    {
 
-        $type=$this->request->get('type','image');
-        $data=$this->getPolicy($type.'/');
-        $this->success('操作成功',$data);
+        $type = $this->request->get('type', 'image');
+        $data = $this->getPolicy($type . '/');
+        $this->success('操作成功', $data);
     }
 
-    public function getPolicy($path,$maxSize=5000000){
+    public function getPolicy($path, $maxSize = 5000000)
+    {
         $now = time();
         $expire = 600; //设置该policy超时时间是10s. 即这个policy过了这个有效时间,将不能访问
         $end = $now + $expire;
         $expiration = $this->_gmt_iso8601($end);
         $policy = [
-            'expiration'=>$expiration,
-            'conditions'=>[
+            'expiration' => $expiration,
+            'conditions' => [
                 ['content-length-range', 1, $maxSize],
                 ['starts-with', '$key', $path],
             ]
@@ -124,13 +135,14 @@ class Upload extends Base
         return $response;
     }
 
-    protected function _gmt_iso8601($time) {
+    protected function _gmt_iso8601($time)
+    {
         $dtStr = date("c", $time);
         $mydatetime = new \DateTime($dtStr);
         $expiration = $mydatetime->format(\DateTime::ISO8601);
         $pos = strpos($expiration, '+');
         $expiration = substr($expiration, 0, $pos);
-        return $expiration."Z";
+        return $expiration . "Z";
     }
 
 }

+ 1 - 1
application/common/model/ApproveApply.php

@@ -22,7 +22,7 @@ class ApproveApply extends Model
     public function getDocumentTextAttr($value, $data)
     {
         $value = $value ? $value : (isset($data['document']) ? $data['document'] : '');
-        return $value ? array_filter(explode(',', $value)) : [];
+        return $value ? json_decode($value,true) : [];
     }
 
     public function getImagesTextAttr($value, $data)

+ 1 - 1
application/common/model/ApproveCar.php

@@ -22,7 +22,7 @@ class ApproveCar extends Model
     public function getDocumentTextAttr($value, $data)
     {
         $value = $value ? $value : (isset($data['document']) ? $data['document'] : '');
-        return $value ? array_filter(explode(',', $value)) : [];
+        return $value ? json_decode($value,true) : [];
     }
 
     public function getImagesTextAttr($value, $data)

+ 1 - 1
application/common/model/ApproveContract.php

@@ -21,7 +21,7 @@ class ApproveContract extends Model
     public function getDocumentTextAttr($value, $data)
     {
         $value = $value ? $value : (isset($data['document']) ? $data['document'] : '');
-        return $value ? array_filter(explode(',', $value)) : [];
+        return $value ? json_decode($value,true) : [];
     }
 
 }

+ 1 - 1
application/common/model/ApproveEvection.php

@@ -22,7 +22,7 @@ class ApproveEvection extends Model
     public function getDocumentTextAttr($value, $data)
     {
         $value = $value ? $value : (isset($data['document']) ? $data['document'] : '');
-        return $value ? array_filter(explode(',', $value)) : [];
+        return $value ? json_decode($value,true) : [];
     }
 
     public function getImagesTextAttr($value, $data)

+ 1 - 1
application/common/model/ApproveFile.php

@@ -21,7 +21,7 @@ class ApproveFile extends Model
     public function getDocumentTextAttr($value, $data)
     {
         $value = $value ? $value : (isset($data['document']) ? $data['document'] : '');
-        return $value ? array_filter(explode(',', $value)) : [];
+        return $value ? json_decode($value,true) : [];
     }
 
 }

+ 1 - 1
application/common/model/ApproveLeave.php

@@ -22,7 +22,7 @@ class ApproveLeave extends Model
     public function getDocumentTextAttr($value, $data)
     {
         $value = $value ? $value : (isset($data['document']) ? $data['document'] : '');
-        return $value ? array_filter(explode(',', $value)) : [];
+        return $value ? json_decode($value,true) : [];
     }
 
     public function getImagesTextAttr($value, $data)

+ 1 - 1
application/common/model/ApproveOffer.php

@@ -21,7 +21,7 @@ class ApproveOffer extends Model
     public function getDocumentTextAttr($value, $data)
     {
         $value = $value ? $value : (isset($data['document']) ? $data['document'] : '');
-        return $value ? array_filter(explode(',', $value)) : [];
+        return $value ? json_decode($value,true) : [];
     }
 
 }

+ 1 - 1
application/common/model/ApproveSchool.php

@@ -21,7 +21,7 @@ class ApproveSchool extends Model
     public function getDocumentTextAttr($value, $data)
     {
         $value = $value ? $value : (isset($data['document']) ? $data['document'] : '');
-        return $value ? array_filter(explode(',', $value)) : [];
+        return $value ? json_decode($value,true) : [];
     }
 
 }

+ 1 - 1
application/common/model/ApproveStock.php

@@ -22,7 +22,7 @@ class ApproveStock extends Model
     public function getDocumentTextAttr($value, $data)
     {
         $value = $value ? $value : (isset($data['document']) ? $data['document'] : '');
-        return $value ? array_filter(explode(',', $value)) : [];
+        return $value ? json_decode($value,true) : [];
     }
 
     public function getImagesTextAttr($value, $data)

+ 1 - 1
application/common/model/ApproveUse.php

@@ -21,7 +21,7 @@ class ApproveUse extends Model
     public function getDocumentTextAttr($value, $data)
     {
         $value = $value ? $value : (isset($data['document']) ? $data['document'] : '');
-        return $value ? array_filter(explode(',', $value)) : [];
+        return $value ? json_decode($value,true) : [];
     }
 
 }

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

@@ -1523,16 +1523,14 @@ class ApproveInfoService
                 // 尝试创建目录
                 if (!mkdir($savePath, 0755, true)) {
                     except('上传目录' . $savePath . '不存在');
-                    return false;
                 }
             }
         } else {
             if (!is_writeable($savePath)) {
                 except('上传目录' . $savePath . '不可写');
-                return false;
             }
         }
-        $filename = date('Ymd') . sha1(date('YmdHis', time()) . uniqid());
+        $filename = date('YmdHis') . uniqid();
         $filename = $name . date('Ymd') . time();
         $suffix = '.pdf';
         $realpath = substr($savePath, 1) . '/' . $filename . $suffix;