浏览代码

file hub / 文件库

star7th 5 年之前
父节点
当前提交
a09dc8f3a5

+ 59 - 121
server/Application/Api/Controller/AttachmentController.class.php

@@ -68,75 +68,26 @@ class AttachmentController extends BaseController {
             return false;
         }
 
-        $oss_open = D("Options")->get("oss_open" ) ;
-        if ($oss_open) {
-            $uploadFile = $_FILES['editormd-image-file'] ;
-            $url = upload_oss($uploadFile);
-            if ($url) {
-                $sign = md5($url.time().rand()) ;
-                $insert = array(
-                "sign" => $sign,
-                "uid" => $login_user['uid'],
-                "item_id" => $item_id,
-                "page_id" => $page_id,
-                "display_name" => $uploadFile['name'],
-                "file_type" => $uploadFile['type'],
-                "file_size" => $uploadFile['size'],
-                "real_url" => $url,
-                "addtime" => time(),
-                );
-                $ret = D("UploadFile")->add($insert);
-                $url = get_domain().U("api/attachment/visitFile",array("sign" => $sign))."&showdoc=.jpg"; 
-                echo json_encode(array("url"=>$url,"success"=>1));
-            }
-            return ;
-        }
-
-        $upload = new \Think\Upload();// 实例化上传类
-        $upload->maxSize  = 1003145728 ;// 设置附件上传大小
-        $upload->allowExts  = array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
-        $upload->rootPath = './../Public/Uploads/';// 设置附件上传目录
-        $upload->savePath = '';// 设置附件上传子目录
-        $info = $upload->uploadOne($_FILES['editormd-image-file']) ;
-        if(!$info) {// 上传错误提示错误信息
-          $this->error($upload->getError());
-          return;
-        }else{// 上传成功 获取上传文件信息
-          $url = get_domain().__ROOT__.substr($upload->rootPath,1).$info['savepath'].$info['savename'] ;
-          $sign = md5($url.time().rand()) ;
-          $uploadFile = $_FILES['editormd-image-file'] ;
-          $insert = array(
-            "sign" => $sign,
-            "uid" => $login_user['uid'],
-            "item_id" => $item_id,
-            "page_id" => $page_id,
-            "display_name" => $uploadFile['name'],
-            "file_type" => $uploadFile['type'],
-            "file_size" => $uploadFile['size'],
-            "real_url" => $url,
-            "addtime" => time(),
-            );
-          $ret = D("UploadFile")->add($insert);
-          $url = get_domain().U("api/attachment/visitFile",array("sign" => $sign))."&showdoc=.jpg";
-          echo json_encode(array("url"=>$url,"success"=>1));
+        $url = D("Attachment")->upload($_FILES , 'editormd-image-file' , $login_user['uid'] , $item_id , $page_id ) ;
+        if ($url) {
+            echo json_encode(array("url"=>$url,"success"=>1));
         }
 
     }
 
-    //页面的上传附件
-    public function pageAttachmentUpload(){
+    //上传附件
+    public function attachmentUpload(){
         $login_user = $this->checkLogin();
         $item_id = I("item_id/d") ? I("item_id/d") : 0 ;
         $page_id = I("page_id/d") ? I("page_id/d") : 0 ;
         $uploadFile = $_FILES['file'] ;
  
-        if (!$page_id) {
-            $this->sendError(10103,"请至少先保存一次页面内容");
-            return;
-        }
-        if (!$this->checkItemPermn($login_user['uid'] , $item_id)) {
-            $this->sendError(10103);
-            return;
+        // 如果附件是要上传绑定到某个页面,那么检验项目权限。如果不绑定,只是上传到自己的文件库,则不需要校验项目权限
+        if( $page_id > 0 || $item_id > 0){
+            if (!$this->checkItemPermn($login_user['uid'] , $item_id)) {
+                $this->sendError(10103);
+                return;
+            }
         }
         
         if (!$uploadFile) {
@@ -147,54 +98,9 @@ class AttachmentController extends BaseController {
             return false;
         }
 
-        $oss_open = D("Options")->get("oss_open" ) ;
-        if ($oss_open) {
-            $url = upload_oss($uploadFile);
-            if ($url) {
-                $sign = md5($url.time().rand()) ;
-                $insert = array(
-                "sign" => $sign,
-                "uid" => $login_user['uid'],
-                "item_id" => $item_id,
-                "page_id" => $page_id,
-                "display_name" => $uploadFile['name'],
-                "file_type" => $uploadFile['type'],
-                "file_size" => $uploadFile['size'],
-                "real_url" => $url,
-                "addtime" => time(),
-                );
-                $ret = D("UploadFile")->add($insert);
-                $url = get_domain().U("api/attachment/visitFile",array("sign" => $sign)); 
-                echo json_encode(array("url"=>$url,"success"=>1));
-            }
-            return ;
-        }
-
-        $upload = new \Think\Upload();// 实例化上传类
-        $upload->maxSize  = 4145728000 ;// 设置附件上传大小
-        $upload->rootPath = './../Public/Uploads/';// 设置附件上传目录
-        $upload->savePath = '';// 设置附件上传子目录
-        $info = $upload->uploadOne($uploadFile) ;
-        if(!$info) {// 上传错误提示错误信息
-          $this->error($upload->getError());
-          return;
-        }else{// 上传成功 获取上传文件信息
-          $url = get_domain().__ROOT__.substr($upload->rootPath,1).$info['savepath'].$info['savename'] ;
-          $sign = md5($url.time().rand()) ;
-          $insert = array(
-            "sign" => $sign,
-            "uid" => $login_user['uid'],
-            "item_id" => $item_id,
-            "page_id" => $page_id,
-            "display_name" => $uploadFile['name'],
-            "file_type" => $uploadFile['type'],
-            "file_size" => $uploadFile['size'],
-            "real_url" => $url,
-            "addtime" => time(),
-            );
-          $ret = D("UploadFile")->add($insert);
-          $url = get_domain().U("api/attachment/visitFile",array("sign" => $sign));
-          echo json_encode(array("url"=>$url,"success"=>1));
+        $url = D("Attachment")->upload($_FILES , 'file' , $login_user['uid'] , $item_id , $page_id ) ;
+        if ($url) {
+            echo json_encode(array("url"=>$url,"success"=>1));
         }
 
     }
@@ -208,7 +114,7 @@ class AttachmentController extends BaseController {
             return;
         }
         $return = array() ;
-        $files = D("UploadFile")->where("page_id = '$page_id' ")->order("addtime desc")->select();
+        $files = D("UploadFile")->join(" file_page on file_page.file_id = upload_file.file_id")->field("upload_file.* , file_page.item_id as item_id ,file_page.page_id as page_id  ")->where("file_page.page_id = '$page_id' ")->order("file_page.addtime desc")->select();
         if ($files) {
             $item_id = $files[0]['item_id'] ;
             if (!$this->checkItemVisit($login_user['uid'] , $item_id)) {
@@ -239,19 +145,25 @@ class AttachmentController extends BaseController {
     public function deletePageUploadFile(){
         $login_user = $this->checkLogin();
         $file_id = I("file_id/d") ? I("file_id/d") : 0 ;
-
-        $file = D("UploadFile")->where("file_id = '$file_id' ")->find();
-        $item_id = $file['item_id'] ;
-        if (!$this->checkItemPermn($login_user['uid'] , $item_id)) {
-            $this->sendError(10103);
-            return;
-        }
-        $ret = D("Page")->deleteFile($file_id);
-        if ($ret) {
-            $this->sendResult(array());
+        $page_id = I("page_id/d") ? I("page_id/d") : 0 ;
+        $count = D("FilePage")->where(" file_id = '$file_id' and page_id > 0   ")->count() ;
+        if($count <= 1 ){
+            $this->deleteMyAttachment();
         }else{
-            $this->sendError(10101,"删除失败");
+            $page = M("Page")->where(" page_id = '$page_id' ")->find();
+            if (!$this->checkItemPermn($login_user['uid'] , $page['item_id'])) {
+                $this->sendError(10103);
+                return;
+            }
+            $res = D("FilePage")->where(" file_id = '$file_id' and page_id = '$page_id'   ")->delete() ;
+            if($res){
+                $this->sendResult(array());
+            }else{
+                $this->sendError(10101,"删除失败");
+            }
+
         }
+        
     }
 
     //获取全站的附件列表。给管理员查看附件用
@@ -327,7 +239,7 @@ class AttachmentController extends BaseController {
 
         $file = D("UploadFile")->where("file_id = '$file_id' ")->find();
 
-        $ret = D("Page")->deleteFile($file_id);
+        $ret = D("Attachment")->deleteFile($file_id);
         if ($ret) {
             $this->sendResult(array());
         }else{
@@ -403,4 +315,30 @@ class AttachmentController extends BaseController {
         $this->sendError(10101,"删除失败");
     }
 
+    //将已上传文件绑定到页面中
+    public function bindingPage(){
+        $login_user = $this->checkLogin();
+        $file_id = I("file_id/d") ? I("file_id/d") : 0 ;
+        $page_id = I("page_id/d");
+        $file = D("UploadFile")->where("file_id = '$file_id' and uid ='$login_user[uid]' ")->find();
+        $page = M("Page")->where(" page_id = '$page_id' ")->find();
+        if (!$this->checkItemPermn($login_user['uid'] , $page['item_id'])) {
+            $this->sendError(10103);
+            return;
+        }
+        $insert = array(
+            "file_id" => $file_id,
+            "item_id" => $page['item_id'] ,
+            "page_id" => $page_id,
+            "addtime" => time(),
+            );
+        $ret = D("FilePage")->add($insert);
+        if( $ret){
+            $this->sendResult(array());
+        }else{
+            $this->sendError(10101);
+        }
+
+    }
+
 }

+ 3 - 3
server/Application/Api/Controller/PageController.class.php

@@ -22,7 +22,7 @@ class PageController extends BaseController {
            //unset($page['page_content']);
            $page['addtime'] = date("Y-m-d H:i:s",$page['addtime']);
            //判断是否包含附件信息
-           $page['attachment_count'] = D("UploadFile")->where("page_id = '$page_id' ")->count();
+           $page['attachment_count'] = D("FilePage")->where("page_id = '$page_id' ")->count();
 
            $singlePage = M("SinglePage")->where(" page_id = '%d' ",array($page_id))->limit(1)->find();
            if ($singlePage) {
@@ -217,7 +217,7 @@ class PageController extends BaseController {
     //上传附件
     public function upload(){
         //重定向控制器和方法
-        R("Attachment/pageAttachmentUpload");
+        R("Attachment/attachmentUpload");
     }
 
     public function uploadList(){
@@ -284,7 +284,7 @@ class PageController extends BaseController {
            unset($page['cat_id']);
            $page['addtime'] = date("Y-m-d H:i:s",$page['addtime']);
            //判断是否包含附件信息
-           $page['attachment_count'] = D("UploadFile")->where("page_id = '$page_id' ")->count();
+           $page['attachment_count'] = D("FilePage")->where("page_id = '$page_id' ")->count();
 
         }
         $this->sendResult($page);

+ 28 - 1
server/Application/Api/Controller/UpdateController.class.php

@@ -5,7 +5,7 @@ class UpdateController extends BaseController {
 
     //检测数据库并更新
     public function checkDb(){
-        $version_num = 4 ;
+        $version_num = 5 ;
         $db_version_num = D("Options")->get("db_version_num");
         if(!$db_version_num || $db_version_num < $version_num ){
             $r = $this->updateSqlite();
@@ -329,6 +329,33 @@ class UpdateController extends BaseController {
             `last_update_time` CHAR(2000) NOT NULL DEFAULT ''
             )";
         D("User")->execute($sql);
+
+        //创建file_page表
+        $sql = "CREATE TABLE IF NOT EXISTS `file_page` (
+            `id`  INTEGER PRIMARY KEY ,
+            `file_id` int(11) NOT NULL DEFAULT '0',
+            `page_id` int(11) NOT NULL DEFAULT '0',
+            `item_id` int(11) NOT NULL DEFAULT '0',
+            `addtime` CHAR(2000) NOT NULL DEFAULT ''
+            )";
+        D("User")->execute($sql);
+
+        // 如果file_page尚未有数据,则把upload_file表的数据转换过去
+        if( !D("FilePage")->find()){
+            $files = D("UploadFile")->select() ;
+            if($files){
+                foreach ($files as $key => $value) {
+                    D("FilePage")->add( array(
+                        "file_id" => $value['file_id'] ,
+                        "page_id" => $value['page_id'] ,
+                        "item_id" => $value['item_id'] ,
+                        "addtime" => $value['addtime'] ,
+                    )) ;
+                }
+            }
+        }
+
+
         //留个注释提醒自己,如果更新数据库结构,务必更改上面的$version_num
         //留个注释提醒自己,如果更新数据库结构,务必更改上面的$version_num
         //留个注释提醒自己,如果更新数据库结构,务必更改上面的$version_num

+ 73 - 0
server/Application/Api/Model/AttachmentModel.class.php

@@ -45,8 +45,81 @@ class AttachmentModel extends BaseModel {
 			@unlink($file_path);
 		}
 		D("UploadFile")->where(" file_id = '$file_id' ")->delete();
+		D("FilePage")->where(" file_id = '$file_id' ")->delete();
 		return true ;
 
 	}
 
+	//上传文件,返回url
+	public function upload($_files , $file_key , $uid , $item_id = 0  , $page_id = 0  ){
+		$uploadFile = $_files[$file_key] ;
+
+		if (strstr(strip_tags(strtolower($uploadFile['name'])), ".php") ) {
+			return false;
+	}
+		$oss_open = D("Options")->get("oss_open" ) ;
+		if ($oss_open) {
+				$url = upload_oss($uploadFile);
+				if ($url) {
+						$sign = md5($url.time().rand()) ;
+						$insert = array(
+						"sign" => $sign,
+						"uid" => $uid,
+						"item_id" => $item_id,
+						"page_id" => $page_id,
+						"display_name" => $uploadFile['name'],
+						"file_type" => $uploadFile['type'],
+						"file_size" => $uploadFile['size'],
+						"real_url" => $url,
+						"addtime" => time(),
+						);
+						$file_id = D("UploadFile")->add($insert);
+						$insert = array(
+							"file_id" => $file_id,
+							"item_id" => $item_id,
+							"page_id" => $page_id,
+							"addtime" => time(),
+							);
+						$ret = D("FilePage")->add($insert);
+						$url = get_domain().U("api/attachment/visitFile",array("sign" => $sign)); 
+					  return $url ;
+				}
+		}else{
+			$upload = new \Think\Upload();// 实例化上传类
+			$upload->maxSize  = 1003145728 ;// 设置附件上传大小
+			$upload->rootPath = './../Public/Uploads/';// 设置附件上传目录
+			$upload->savePath = '';// 设置附件上传子目录
+			$info = $upload->uploadOne($uploadFile) ;
+			if(!$info) {// 上传错误提示错误信息
+				var_dump($upload->getError());
+				return;
+			}else{// 上传成功 获取上传文件信息
+				$url = get_domain().__ROOT__.substr($upload->rootPath,1).$info['savepath'].$info['savename'] ;
+				$sign = md5($url.time().rand()) ;
+				$insert = array(
+					"sign" => $sign,
+					"uid" => $uid,
+					"item_id" => $item_id,
+					"page_id" => $page_id,
+					"display_name" => $uploadFile['name'],
+					"file_type" => $uploadFile['type'],
+					"file_size" => $uploadFile['size'],
+					"real_url" => $url,
+					"addtime" => time(),
+					);
+					$file_id = D("UploadFile")->add($insert);
+					$insert = array(
+						"file_id" => $file_id,
+						"item_id" => $item_id,
+						"page_id" => $page_id,
+						"addtime" => time(),
+						);
+					$ret = D("FilePage")->add($insert);
+				$url = get_domain().U("api/attachment/visitFile",array("sign" => $sign));
+				return $url ;
+			}
+		}
+		return false;
+	}
+
 }

+ 2 - 0
server/Application/Home/Controller/UpdateController.class.php

@@ -3,6 +3,8 @@ namespace Home\Controller;
 use Think\Controller;
 class UpdateController extends BaseController {
     
+    //此文件不再维护。升级数据库的脚本改到了API/UpdateController
+
     //升级数据库
     public function db(){
         $this->_clear_runtime();

+ 21 - 1
web_src/src/components/attachment/Index.vue

@@ -21,6 +21,17 @@
           <el-form-item>
             <el-button @click="onSubmit">{{$t('search')}}</el-button>
           </el-form-item>
+          <el-form-item>
+            <el-upload
+              class="upload-file"
+              :action="uploadUrl"
+              :on-success="uploadCallback"
+              :on-error="uploadCallback"
+              ref="uploadFile"
+            >
+              <el-button>{{$t('upload')}}</el-button>
+            </el-upload>
+          </el-form-item>
         </el-form>
         <P>{{$t('accumulated_used_sapce')}} {{used}}M , {{$t('month_flow')}} {{used_flow}}M</P>
         <el-table :data="dataList" style="width: 100%">
@@ -69,7 +80,8 @@ export default {
       positive_type: '1',
       attachment_type: '-1',
       used: 0,
-      used_flow: 0
+      used_flow: 0,
+      uploadUrl: DocConfig.server + '/api/page/upload'
     }
   },
   methods: {
@@ -120,6 +132,14 @@ export default {
     },
     goback() {
       this.$router.push({ path: '/item/index' })
+    },
+    uploadCallback(data) {
+      if (data.error_message) {
+        this.$alert(data.error_message)
+      }
+      let childRef = this.$refs.uploadFile // 获取子组件
+      childRef.clearFiles()
+      this.getList()
     }
   },
 

+ 4 - 7
web_src/src/components/item/show/show_regular_item/Index.vue

@@ -30,15 +30,12 @@
               v-show="showfullPageBtn"
               @click="clickFullPage"
             ></i>
-            <el-badge
-              :value="attachment_count"
-              class="item"
+            <i
+              class="el-icon-upload item"
               id="attachment"
               v-if="attachment_count"
-              @click.native="ShowAttachment"
-            >
-              <i class="el-icon-upload"></i>
-            </el-badge>
+              @click="ShowAttachment"
+            ></i>
           </div>
           <div id="doc-body">
             <div id="page_md_content" class="page_content_main">

+ 38 - 13
web_src/src/components/page/edit/AttachmentList.vue

@@ -9,18 +9,25 @@
         :visible.sync="dialogTableVisible"
         :close-on-click-modal="false"
       >
-        <el-upload
-          class="upload-file"
-          :action="uploadUrl"
-          :on-success="clearFiles"
-          :on-error="clearFiles"
-          :data="uploadData"
-          ref="uploadFile"
-          v-if="manage"
-        >
-          <el-button size="small" type="primary">{{$t('upload_file')}}</el-button>
-          <small>&nbsp;&nbsp;&nbsp;{{$t('file_size_tips')}}</small>
-        </el-upload>
+        <el-form :inline="true" class="demo-form-inline">
+          <el-form-item>
+            <el-button @click="showFilehub">{{$t('from_file_gub')}}</el-button>
+          </el-form-item>
+          <el-form-item>
+            <el-upload
+              class="upload-file"
+              :action="uploadUrl"
+              :on-success="uploadCallback"
+              :on-error="uploadCallback"
+              :data="uploadData"
+              ref="uploadFile"
+              v-if="manage"
+            >
+              <el-button>{{$t('upload')}}</el-button>
+              <small>&nbsp;&nbsp;&nbsp;{{$t('file_size_tips')}}</small>
+            </el-upload>
+          </el-form-item>
+        </el-form>
 
         <el-table :data="content">
           <el-table-column property="addtime" :label="$t('add_time')" width="170"></el-table-column>
@@ -49,6 +56,7 @@
         </el-table>
       </el-dialog>
     </el-container>
+    <filehub :callback="get_content" :item_id="item_id" :page_id="page_id" ref="filehub"></filehub>
     <Footer></Footer>
     <div class></div>
   </div>
@@ -58,6 +66,7 @@
 </style>
 
 <script>
+import filehub from '@/components/page/edit/Filehub'
 export default {
   props: {
     callback: '',
@@ -73,7 +82,9 @@ export default {
       uploadUrl: DocConfig.server + '/api/page/upload'
     }
   },
-  components: {},
+  components: {
+    filehub
+  },
   computed: {
     uploadData: function() {
       return {
@@ -119,6 +130,7 @@ export default {
         var url = DocConfig.server + '/api/page/deleteUploadFile'
         var params = new URLSearchParams()
         params.append('file_id', file_id)
+        params.append('page_id', that.page_id)
         that.axios.post(url, params).then(function(response) {
           if (response.data.error_code === 0) {
             that.get_content()
@@ -144,6 +156,19 @@ export default {
         '")'
       this.callback(val)
       this.dialogTableVisible = false
+    },
+    uploadCallback(data) {
+      if (data.error_message) {
+        this.$alert(data.error_message)
+      }
+      let childRef = this.$refs.uploadFile // 获取子组件
+      childRef.clearFiles()
+      this.get_content()
+    },
+    // 文件库
+    showFilehub() {
+      let childRef = this.$refs.filehub // 获取子组件
+      childRef.show()
     }
   },
   mounted() {}

+ 174 - 0
web_src/src/components/page/edit/Filehub.vue

@@ -0,0 +1,174 @@
+<!-- 附件 -->
+<template>
+  <div class="hello">
+    <Header></Header>
+
+    <el-container class="container-narrow">
+      <el-dialog
+        :title="$t('file_gub')"
+        :visible.sync="dialogTableVisible"
+        :close-on-click-modal="false"
+        width="65%"
+      >
+        <el-form :inline="true" class="demo-form-inline">
+          <el-form-item label>
+            <el-input v-model="display_name" :placeholder="$t('display_name')"></el-input>
+          </el-form-item>
+          <el-form-item label>
+            <el-select v-model="attachment_type" placeholder>
+              <el-option :label="$t('all_attachment_type')" value="-1"></el-option>
+              <el-option :label="$t('image')" value="1"></el-option>
+              <el-option :label="$t('general_attachment')" value="2"></el-option>
+            </el-select>
+          </el-form-item>
+          <el-form-item>
+            <el-button @click="onSubmit">{{$t('search')}}</el-button>
+          </el-form-item>
+          <el-form-item>
+            <el-upload
+              class="upload-file"
+              :action="uploadUrl"
+              :on-success="uploadCallback"
+              :on-error="uploadCallback"
+              ref="uploadFile"
+            >
+              <el-button>{{$t('upload')}}</el-button>
+            </el-upload>
+          </el-form-item>
+        </el-form>
+        <P>{{$t('accumulated_used_sapce')}} {{used}}M , {{$t('month_flow')}} {{used_flow}}M</P>
+        <el-table :data="dataList" style="width: 100%">
+          <el-table-column prop="file_id" :label="$t('file_id')"></el-table-column>
+          <el-table-column prop="display_name" :label="$t('display_name')"></el-table-column>
+          <el-table-column prop="file_type" :label="$t('file_type')" width="160"></el-table-column>
+          <el-table-column prop="file_size_m" :label="$t('file_size_m')" width="160"></el-table-column>
+          <el-table-column prop="visit_times" :label="$t('visit_times')"></el-table-column>
+          <el-table-column prop="addtime" :label="$t('add_time')" width="160"></el-table-column>
+          <el-table-column prop :label="operation">
+            <template slot-scope="scope">
+              <el-button @click="select(scope.row)" type="text" size="small">{{$t('select')}}</el-button>
+              <el-button @click="visit(scope.row)" type="text" size="small">{{$t('visit')}}</el-button>
+              <el-button @click="delete_row(scope.row)" type="text" size="small">{{$t('delete')}}</el-button>
+            </template>
+          </el-table-column>
+        </el-table>
+
+        <div class="block">
+          <span class="demonstration"></span>
+          <el-pagination
+            @current-change="handleCurrentChange"
+            :page-size="count"
+            layout="total, prev, pager, next"
+            :total="total"
+          ></el-pagination>
+        </div>
+      </el-dialog>
+    </el-container>
+    <Footer></Footer>
+    <div class></div>
+  </div>
+</template>
+
+<style>
+</style>
+
+<script>
+export default {
+  props: {
+    callback: '',
+    page_id: '',
+    item_id: '',
+    manage: true
+  },
+  data() {
+    return {
+      dialogTableVisible: false,
+      page: 1,
+      count: 5,
+      display_name: '',
+      username: '',
+      dataList: [],
+      total: 0,
+      positive_type: '1',
+      attachment_type: '-1',
+      used: 0,
+      used_flow: 0,
+      uploadUrl: DocConfig.server + '/api/page/upload'
+    }
+  },
+  components: {},
+  computed: {
+    uploadData: function() {
+      return {
+        page_id: this.page_id,
+        item_id: this.item_id
+      }
+    }
+  },
+  methods: {
+    getList() {
+      this.request('/api/attachment/getMyList', {
+        page: this.page,
+        count: this.count,
+        attachment_type: this.attachment_type,
+        display_name: this.display_name,
+        username: this.username
+      }).then(data => {
+        var json = data.data
+        this.dataList = json.list
+        this.total = parseInt(json.total)
+        this.used = json.used_m
+        this.used_flow = json.used_flow_m
+      })
+    },
+    show() {
+      this.dialogTableVisible = true
+      this.getList()
+    },
+    handleCurrentChange(currentPage) {
+      this.page = currentPage
+      this.getList()
+    },
+    onSubmit() {
+      this.page = 1
+      this.getList()
+    },
+    visit(row) {
+      window.open(row.url)
+    },
+    delete_row(row) {
+      this.$confirm(this.$t('confirm_delete'), ' ', {
+        confirmButtonText: this.$t('confirm'),
+        cancelButtonText: this.$t('cancel'),
+        type: 'warning'
+      }).then(() => {
+        this.request('/api/attachment/deleteMyAttachment', {
+          file_id: row.file_id
+        }).then(data => {
+          this.$message.success(this.$t('op_success'))
+          this.getList()
+        })
+      })
+    },
+    uploadCallback(data) {
+      if (data.error_message) {
+        this.$alert(data.error_message)
+      }
+      let childRef = this.$refs.uploadFile // 获取子组件
+      childRef.clearFiles()
+      this.getList()
+    },
+    select(row) {
+      this.request('/api/attachment/bindingPage', {
+        file_id: row.file_id,
+        page_id: this.page_id
+      }).then(data => {
+        this.dialogTableVisible = false
+        this.callback()
+      })
+    }
+
+  },
+  mounted() {}
+}
+</script>

+ 5 - 1
web_src/static/lang/en.js

@@ -395,6 +395,10 @@ exports.default = {
 
   cancelSingle: 'Are you sure you want to cancel the single page link? After cancellation, the original link will be invalid immediately',
   cancelSingleYes: 'Unlink single page',
-  cancelSingleNo: 'Keep single page'
+  cancelSingleNo: 'Keep single page',
+
+  from_file_gub: 'From FileHub',
+  file_gub: 'FileHub',
+  select: 'select'
 
 }

+ 8 - 4
web_src/static/lang/zh-CN.js

@@ -369,16 +369,16 @@ exports.default = {
   attachment_manage: '附件管理',
   op_success: '操作成功',
   display_name: '展示名字',
-  all_attachment_type: '全部件类型',
+  all_attachment_type: '全部件类型',
   image: '图片',
-  general_attachment: '普通附件',
+  general_attachment: '其它文件',
   uploader: '上传者',
   file_id: '文件id',
   file_type: '文件类型',
   file_size_m: '文件大小/mb',
   visit: '查看',
   visit_times: '访问次数',
-  my_attachment: '我的附件',
+  my_attachment: '文件库',
   accumulated_used_sapce: '累计已使用空间',
   month_flow: '本月已使用流量',
 
@@ -386,5 +386,9 @@ exports.default = {
 
   cancelSingle: '是否确定取消单页链接?取消后,原链接会立马失效',
   cancelSingleYes: '取消单页链接',
-  cancelSingleNo: '保留单页链接'
+  cancelSingleNo: '保留单页链接',
+
+  from_file_gub: '从文件库选择',
+  file_gub: '文件库',
+  select: '选择'
 }