y595705120 3 anos atrás
pai
commit
25cbc9cf38

+ 8 - 0
src/App.vue

@@ -13,5 +13,13 @@ export default {
 <style lang="scss">
  @import "./assets/css/base.css";
  @import "./assets/css/main.css";
+ .el-message {
+     position: absolute;
+     top: 40% !important;
+     left: 50% !important;
+     font-size: 60px !important;
+     background-color: grey;
+     z-index: 99999 !important;
+ }
 
 </style>

+ 27 - 0
src/api/article.js

@@ -96,3 +96,30 @@ export const getArticalLikeList = (data) => {
         data
     })
 }
+
+
+export const downloadArtical = (data) => {
+    return service({
+        url: "/api/artical/downloadArtical",
+        method: 'post',
+        data
+    })
+}
+
+
+export const applyArtical = (data) => {
+    return service({
+        url: "/api/artical/applyArtical",
+        method: 'post',
+        data
+    })
+}
+
+export const replyArtical = (data) => {
+    return service({
+        url: "/api/artical/replyArtical",
+        method: 'post',
+        data
+    })
+}
+

+ 6 - 1
src/pages/data/data.js

@@ -88,5 +88,10 @@ export default {
     { "id": "mechanism", "value": "机制类" },
     { "id": "result", "value": "成果类" },
     { "id": "other", "value": "其他" }
-  ]
+  ],
+  owners:{
+    0: '无权限',
+    1: '普通',
+    2: '管理'
+  }
 }

+ 53 - 10
src/pages/other/apply-list.vue

@@ -7,34 +7,53 @@
         </div>
 
         <el-table :data="restaurants"  border stripe>
-          <el-table-column label="序号" min-width="60" prop="id">
+          <el-table-column label="序号" width="50" prop="id" align="center">
+          </el-table-column>
+          <el-table-column label="下载文件" min-width="300" prop="title">
           </el-table-column>
 
-          <el-table-column label="申请人" min-width="60" prop="username">
+          <el-table-column label="申请人" width="80" prop="username">
           </el-table-column>
 
-          <el-table-column label="申请时间" min-width="60" prop="createAt">
+          <el-table-column label="申请时间" min-width="110" prop="createAt">
             <template slot-scope="{row, $index}">
               <span> {{row.createAt|toDatetime}}</span>
             </template>
           </el-table-column>
 
-          <el-table-column label="申请原因" min-width="60" prop="applyInfo">
+          <el-table-column label="申请原因" min-width="80" prop="applyInfo">
           </el-table-column>
 
           <el-table-column
             align="center"
-            min-width="80px"
+            min-width="80"
             label="操作"
             class-name="small-padding fixed-width"
           >
+
             <template slot-scope="{row, $index}">
               <el-button
+                v-if="!row.isSend"
                 type="success"
                 size="small"
                 icon="el-icon-circle-check"
-                @click="applyDoc(row)"
+                @click="applyDoc(row, $index)"
               >审核</el-button>
+
+              <el-button
+                v-else-if="row.isSend==1"
+                type="text"
+                size="small"
+                icon="el-icon-circle-check"
+                @click="applyDoc(row, $index)"
+              >允许下载</el-button>
+
+              <el-button
+                v-else-if="row.isSend==2"
+                type="text"
+                size="small"
+                icon="el-icon-circle-close"
+              >拒绝下载</el-button>
             </template>
           </el-table-column>
 
@@ -55,8 +74,10 @@
     <el-dialog title="[办公室]XX 申请下载资料" center :visible.sync="dialogFormVisible"  >
       <h3> 【{{form.username}}】需要下载文件 【{{form.title}}】  </h3>
       <div class="dialog-footer" slot="footer">
-        <el-button type="warning" size="medium" style="width: 100px; padding: 10px; margin: 20px;" @click="dialogFormVisible=false">拒绝下载</el-button>
-        <el-button type="primary" size="medium" style="width: 100px; padding: 10px; margin: 20px;" @click="dialogFormVisible=false">允许下载</el-button>
+        <el-button type="warning" size="medium" style="width: 100px; padding: 10px; margin: 20px;"
+			@click="forbitDownload(form)" >拒绝下载</el-button>
+        <el-button type="primary" size="medium" style="width: 100px; padding: 10px; margin: 20px;"
+			@click="allowDownload( form)">允许下载</el-button>
       </div>
     </el-dialog>
   </div>
@@ -67,7 +88,7 @@ import IHeader from "./components/IHeader";
 import IFooter from "./components/IFooter";
 import glIcon from '@/icons/img/2016smyjj_gl_icon.jpg'
 import data  from '../data/data.js'
-import {getHotArticalList,getArticalList,getApplyArticalList}  from '@/api/article'
+import {replyArtical,getArticalList,getApplyArticalList}  from '@/api/article'
 
 import {toDatetime} from '@/utils/date.js'
 
@@ -109,10 +130,32 @@ export default {
     toDatetime
   },
   methods: {
-    applyDoc( row ){
+    applyDoc( row, index ){
       this.dialogFormVisible = true
+      row.index = index
       this.form = row
     },
+    forbitDownload(item){
+      let param = {articalId: item.articalId, id:item.id, action:2}
+      replyArtical( param ).then( res=>{
+        if( res.code == 200){
+          item.isSend = 2
+          this.dialogFormVisible = false;
+          this.$message.successMsg("处理完成", 2)
+        }
+      })
+    },
+    allowDownload(item){
+      let param = {articalId: item.articalId,id:item.id, action:1}
+      replyArtical( param ).then( res=>{
+        if( res.code == 200){
+          item.isSend = 1
+          this.dialogFormVisible = false;
+          this.$message.successMsg("处理完成", 2)
+        }
+      })
+
+    },
     getApplyArticalList() {
       getApplyArticalList( {} ).then( res=>{
         this.restaurants = res.data.list

+ 105 - 20
src/pages/other/file-info.vue

@@ -11,37 +11,73 @@
             <span class="ml10"><i class="el-icon-download"></i> {{info.downloadCount}}</span>
           </h4>
         </div>
-        <div class="mt35">
-          <h2> 文章简介 </h2>
-          <div class="content mt20 p20">
-            <div>{{info.brief}} </div>
-          </div>
-        </div>
+
+
+       <el-form :inline="true" class="p20" label-width="80px" label-position="left">
+          <el-row>
+            <el-col :span="12">
+              <el-form-item label="所属部门">
+                  <span class="pl10 nowrap span-tit">{{info.department }}</span>
+              </el-form-item>
+            </el-col>
+
+            <el-col :span="12">
+              <el-form-item label="文件分类">
+                  <span class="pl10 nowrap span-tit">{{info.category }}</span>
+              </el-form-item>
+            </el-col>
+
+            <el-col :span="12">
+              <el-form-item label="发布人">
+                  <span class="pl10 nowrap span-tit">{{info.username||'超管' }}</span>
+              </el-form-item>
+            </el-col>
+
+            <el-col :span="12">
+              <el-form-item label="发布时间">
+                  <span class="pl10 nowrap span-tit">{{info.publishTime|toDatetime }}</span>
+              </el-form-item>
+            </el-col>
+
+            <el-col :span="12">
+              <el-form-item label="是否公开">
+                  <span class="pl10 nowrap span-tit">{{info.isOpen?'是':'否' }}</span>
+              </el-form-item>
+            </el-col>
+
+
+            <el-col :span="12">
+              <el-form-item label="我的权限">
+                  <span class="pl10 nowrap span-tit">{{owners[isLeader]}}</span>
+              </el-form-item>
+            </el-col>
+
+          </el-row>
+
+       </el-form>
+
+       <div class="mt35">
+         <h2> 文章简介 </h2>
+         <div class="content mt20 p20">
+           <div>{{info.brief}} </div>
+         </div>
+       </div>
+
 
         <div class="p20">
           <el-button v-if="!isLike" icon="el-icon-star-off" @click="likeArtical"> 收藏</el-button>
           <el-button v-else icon="el-icon-star-on" type="info" @click="unLikeArtical">取消</el-button>
 
-          <el-button  icon="el-icon-download" @click="likeArtical"> 下载</el-button>
 
 
+          <el-button  icon="el-icon-download" v-if="isLeader>0 || info.isOpen" @click="download"> 下载</el-button>
+          <el-button  icon="el-icon-download" v-else @click="applyDownload">申请下载</el-button>
         </div>
 
 
       </div>
     </div>
-      <!--  -->
-    <el-card class="mt10">
-      <el-row>
-        <el-col :span="12" >
-           <h2>我的下载记录</h2>
-        </el-col>
-
-        <el-col :span="12">
-           <h2>我的下载记录</h2>
-        </el-col>
-      </el-row>
-    </el-card>
+
 
     <div style="height: 60px;"></div>
   </div>
@@ -51,7 +87,10 @@
   import IHeader from "./components/IHeader";
   import IFooter from "./components/IFooter";
   import {toDatetime } from '@/utils/date.js'
+  import data from '../data/data.js'
   import { getArticalInfo, likeArtical, unLikeArtical} from '@/api/article.js'
+    import { downloadArtical, applyArtical} from '@/api/article.js'
+  import { mapGetters } from "vuex";
 
   export default {
     name: 'application',
@@ -70,9 +109,13 @@
         recommend: [],
         apply_list: [],
         isLike: 0,
+        owners: data.owners,
         info: {}
       }
     },
+    computed: {
+    	...mapGetters("user", ["userDepartments"])
+    },
     created() {
       this.articalId = +this.$route.query.articalId || 0;
       if (this.articalId) {
@@ -80,6 +123,44 @@
       }
     },
     methods: {
+      download(){
+        let param ={articalId: this.articalId, isLeader:this.isLeader}
+        this.loading = true;
+        this.$message.successMsg("文件生成中", 1)
+        downloadArtical( param ).then( res=>{
+          console.log( "res", res)
+          if( res.status != 200 ) {
+            this.loading = false;
+            this.$message.errorMsg("下载失败", 1)
+            return;
+          }
+          const blob = new Blob([res.data])
+          const fileName = res.header.filename
+          const link = document.createElement('a')
+          link.download = fileName
+          link.style.display = 'none'
+          link.href = URL.createObjectURL(blob)
+          document.body.appendChild(link)
+          link.click()
+          URL.revokeObjectURL(link.href)
+          document.body.removeChild(link)
+          this.loading = false;
+        }).catch( ()=>{
+          this.loading = false;
+        })
+      },
+      applyDownload(){
+        let param ={articalId: this.articalId}
+        this.loading = true;
+        applyArtical( param ).then( res=>{
+          if( res.code == 200){
+            this.$message.successMsg("申请成功", 3)
+          }
+          this.loading = false;
+        }).catch( ()=>{
+          this.loading = false
+        })
+      },
       likeArtical(){
         let param ={articalId: this.articalId}
         this.loading = true;
@@ -92,7 +173,6 @@
         }).catch( ()=>{
           this.loading = false
         })
-
       },
       unLikeArtical(){
         let param ={articalId: this.articalId}
@@ -115,6 +195,11 @@
         getArticalInfo(param).then(res => {
           if (res.code == 200) {
             this.info = res.data.info;
+            for( let i in this.userDepartments){
+              if( this.userDepartments[i].departmentId == this.info.departmentId){
+                this.isLeader = this.userDepartments[i].isLeader;
+              }
+            }
             this.recommend = res.data.recommend || [];
             this.apply_list = res.data.apply_list || [];
             this.isLike = res.data.isLike || 0;

+ 5 - 3
src/pages/other/index.vue

@@ -29,9 +29,11 @@ export default {
     ...mapActions("user", ["loadDepartment"])
   },
   created() {
-    console.log("userInfo", this.userInfo )
-    if( this.userInfo && this.userInfo.userId) return;
-    this.loadDepartment()
+    // console.log("userInfo", this.userInfo )
+    // if( this.userInfo && this.userInfo.userId) return;
+    if( this.userDepartments.length <1 ){
+      this.loadDepartment()
+    }
   }
 };
 </script>

+ 4 - 4
src/pages/other/reply-list.vue

@@ -74,7 +74,7 @@ import IHeader from "./components/IHeader";
 import IFooter from "./components/IFooter";
 import glIcon from '@/icons/img/2016smyjj_gl_icon.jpg'
 import data  from '../data/data.js'
-import {getHotArticalList,getArticalList,getApplyArticalList}  from '@/api/article'
+import {getHotArticalList,getArticalList,getReplyArticalList}  from '@/api/article'
 
 import {toDatetime} from '@/utils/date.js'
 
@@ -103,7 +103,7 @@ export default {
     }
   },
   mounted() {
-    this.getApplyArticalList();
+    this.getReplyArticalList();
   },
   filters:{
     filterTitle(val){
@@ -120,8 +120,8 @@ export default {
       this.dialogFormVisible = true
       this.form = row
     },
-    getApplyArticalList() {
-      getApplyArticalList( {} ).then( res=>{
+    getReplyArticalList() {
+      getReplyArticalList( {} ).then( res=>{
         this.restaurants = res.data.list
         this.total = res.data.total
         console.log("getHotArticalList", res)

+ 2 - 1
src/store/modules/user.js

@@ -109,7 +109,8 @@ const actions = {
     if( !state.token )  return;
     getMyDepartmentList( {}).then( res=>{
       if( res.code == 200){
-        commit('SET_DEPARTMENT', res.data)
+        commit('SET_DEPARTMENT', res.data.departments)
+        commit('SET_INFO', res.data.user)
       }
     })
 

+ 4 - 2
src/utils/request.js

@@ -63,8 +63,10 @@ service.interceptors.response.use(
         if (response.headers["new-token"]) {
             store.commit('user/setToken', response.headers["new-token"])
         }
-
-        if (response.data.code == 200 || response.headers.success === "true") {
+        // 下载文件
+        if ( response.headers.success == "true"){
+          return  response
+        } else if (response.data.code == 200 ) {
             return response.data
         } else {
           if (response.data.data && response.data.data.reload) {