Browse Source

项目模块增加模板下载功能

ljb 7 months ago
parent
commit
1d512bf2e9

+ 44 - 0
src/components/file-download-btn/index.vue

@@ -0,0 +1,44 @@
+<template>
+  <el-button :type="type" :icon="icon" :size="size" @click="handleDownClick">{{ btnText }}</el-button>
+</template>
+
+<script>
+import {getList as getTempList} from "@/api/resource/attach";
+import { downloadFileByUrl } from "@/util/util";
+
+
+export default {
+  props: {
+    size: {
+      type: String,
+      default: 'small'
+    },
+    type: {
+      type: String,
+      default: 'text'
+    },
+    icon: String,
+    btnText: {
+      type: String,
+      default: '下载模板'
+    },
+    templateKey: String,
+  },
+  methods: {
+    handleDownClick() {
+      getTempList(1, 1, { title: this.templateKey }).then(({ data }) => {
+        if (data.code == 200) {
+          if (data.data.records.length && data.data.records[0].link) {
+            let linkObj = new URL(data.data.records[0].link);
+            let downLink = window.location.origin + '/oss' + linkObj.pathname;
+            
+            downloadFileByUrl(downLink, data.data.records[0].title + '-模板.' + data.data.records[0].extension);
+          } else {
+            this.$message.error('暂未配置模板');
+          }
+        }
+      });
+    }
+  }
+}
+</script>

+ 43 - 8
src/views/external-reports/external-manage/torch-develop-annual-report.vue

@@ -1,7 +1,8 @@
 <template>
-  <basic-container>
+  <basic-container style="overflow-x: auto;">
+    <!-- <div style="width: auto; overflow: auto;"> -->
     <div class="doc-page" v-loading="loading">
-      <h3 class="page-title" style="margin: 24px 0 16px">火炬发展年报</h3>
+      <h3 class="page-title" style="margin: 24px 0 16px">{{ pageTitle }}</h3>
       <div style="display: flex; margin: 12px 0;">
         <year-month-select v-model="yearAndMonth" :showMonth="false" style="margin: 0 15px 0 0;"></year-month-select>
         <el-button
@@ -20,6 +21,14 @@
         >
           导出
         </el-button>
+        <file-download-btn type="primary" icon="el-icon-download" btnText="下载完整模板" templateKey="对外报表-火炬发展年报"></file-download-btn>
+        <el-button
+          type="primary"
+          size="small"
+          icon="el-icon-upload2"
+        >
+          上传火炬系统定稿版
+        </el-button>
       </div>
       <div>第1步 (封面)基本信息</div>
       <div style="margin-bottom: 8px;">第2步 (一)企业概况</div>
@@ -560,31 +569,37 @@
           <tr>
             <td>累计形成国家或行业标准</td>
             <td align="center">个</td>
-            <td align="center">qj27</td>
-            <td>{{ formData.qj27 }}</td>
+            <td align="center">qi27</td>
+            <td>{{ formData.qi27 }}</td>
           </tr>
           <tr>
             <td style="padding-left: 30px;">其中:形成国家或行业标准</td>
             <td align="center">项</td>
-            <td align="center">qj27_1</td>
-            <td>{{ formData.qj27_1 }}</td>
+            <td align="center">qi27_1</td>
+            <td>{{ formData.qi27_1 }}</td>
           </tr>
         </tbody>
       </table>
       
       
+    <!-- </div> -->
     </div>
   </basic-container>
 </template>
 
 <script>
 import moment from "moment";
+import fileDownloadBtn from "@/components/file-download-btn";
 import yearMonthSelect from "@/components/year-month-select";
 import { getData } from "@/api/externalReports/torchDevelopAnnualReport";
-import { Form } from "element-ui";
+import { exportBlob } from "@/api/common";
+import { getToken } from "@/util/auth";
+import { downloadXls } from "@/util/util";
+import { mapGetters } from "vuex";
 
 export default {
   components: {
+    fileDownloadBtn,
     yearMonthSelect,
   },
   data() {
@@ -601,6 +616,13 @@ export default {
       this.getDataFunc(newVal);
     },
   },
+  computed: {
+    ...mapGetters(['tag']),
+    pageTitle() {
+      let yearCN = this.yearAndMonth ? moment(this.yearAndMonth).format('yyyy年') : '';
+      return `${yearCN}${this.tag.label}`
+    }
+  },
   methods: {
     handleReady() {
       this.getDataFunc(this.yearAndMonth);
@@ -615,7 +637,20 @@ export default {
       }).catch(() => {
         this.loading = false;
       })
-    }
+    },
+    handleExport() {
+      exportBlob(
+        `/api/kd-scientific/hjfznb/export?${
+          this.website.tokenHeader
+        }=${getToken()}`,
+        { year: this.yearAndMonth }
+      ).then((res) => {
+        downloadXls(
+          res.data,
+          `${this.pageTitle}.xlsx`
+        );
+      });
+    },
   },
 };
 </script>

+ 18 - 6
src/views/project-manage/components/accept-form.vue

@@ -84,23 +84,33 @@
       <avue-form v-show="!isPrintPage" v-model="formData" :option="option" style="margin-top: 30px; padding: 0;">
         <template slot="ysbgLabel">
           <label>验收报告</label>
-          <el-link type="primary" style="position: absolute; left: 220px; z-index: 1;">下载模板</el-link>
+          <div style="position: absolute; top: 0; left: 220px; z-index: 1;">
+            <file-download-btn templateKey="研发项目管理-项目结题-验收报告"></file-download-btn>
+          </div>
         </template>
         <template slot="jsbgLabel">
           <label>技术报告</label>
-          <el-link type="primary" style="position: absolute; left: 220px; z-index: 1;">下载模板</el-link>
+          <div style="position: absolute; top: 0; left: 220px; z-index: 1;">
+            <file-download-btn templateKey="研发项目管理-项目结题-技术报告"></file-download-btn>
+          </div>
         </template>
         <template slot="cgbgLabel">
           <label>成果报告</label>
-          <el-link type="primary" style="position: absolute; left: 220px; z-index: 1;">下载模板</el-link>
+          <div style="position: absolute; top: 0; left: 220px; z-index: 1;">
+            <file-download-btn templateKey="研发项目管理-项目结题-成果报告"></file-download-btn>
+          </div>
         </template>
         <template slot="xybgLabel">
           <label>效益报告</label>
-          <el-link type="primary" style="position: absolute; left: 220px; z-index: 1;">下载模板</el-link>
+          <div style="position: absolute; top: 0; left: 220px; z-index: 1;">
+            <file-download-btn templateKey="研发项目管理-项目结题-效益报告"></file-download-btn>
+          </div>
         </template>
         <template slot="yspwLabel">
           <label>验收批文</label>
-          <el-link type="primary" style="position: absolute; left: 220px; z-index: 1;">下载模板</el-link>
+          <div style="position: absolute; top: 0; left: 220px; z-index: 1;">
+            <file-download-btn templateKey="研发项目管理-项目结题-验收批文"></file-download-btn>
+          </div>
         </template>
       </avue-form>
 
@@ -153,6 +163,7 @@
 <script>
 import projectSelect from "@/components/project-select";
 import secondUnitCascader from "@/components/second-unit-cascader";
+import fileDownloadBtn from "@/components/file-download-btn";
 import { save, getDetail } from "@/api/projectManage/accept";
 import moment from "moment";
 import { mapGetters } from "vuex";
@@ -163,7 +174,8 @@ import { downloadFileByUrl } from "@/util/util";
 export default {
   components: {
     projectSelect,
-    secondUnitCascader
+    secondUnitCascader,
+    fileDownloadBtn
   },
   props: {
     projectId: [String, Number]

+ 16 - 5
src/views/project-manage/components/apply-form.vue

@@ -211,15 +211,21 @@
       <avue-form v-show="!isPrintPage" v-model="formData" :option="option" style="margin-top: 30px; padding: 0;">
         <template slot="lxpwLabel">
           <label>立项批文</label>
-          <el-link type="primary" style="position: absolute; left: 220px; z-index: 1;">下载模板</el-link>
+          <div style="position: absolute; top: 0; left: 220px; z-index: 1;">
+            <file-download-btn templateKey="研发项目管理-项目立项-立项批文"></file-download-btn>
+          </div>
         </template>
         <template slot="lxbgLabel">
           <label>立项报告</label>
-          <el-link type="primary" style="position: absolute; left: 220px; z-index: 1;">下载模板</el-link>
+          <div style="position: absolute; top: 0; left: 220px; z-index: 1;">
+            <file-download-btn templateKey="研发项目管理-项目立项-立项报告"></file-download-btn>
+          </div>
         </template>
         <template slot="qtzlLabel">
           <label>其他资料</label>
-          <el-link type="primary" style="position: absolute; left: 220px; z-index: 1;">下载模板</el-link>
+          <div style="position: absolute; top: 0; left: 220px; z-index: 1;">
+            <file-download-btn templateKey="研发项目管理-项目立项-其他资料"></file-download-btn>
+          </div>
         </template>
       </avue-form>
       <div v-show="isPrintPage" class="file-list" style="margin-top: 30px;">
@@ -258,6 +264,7 @@
 <script>
 import secondUnitCascader from "@/components/second-unit-cascader";
 import personSelect from "@/components/person-select";
+import fileDownloadBtn from "@/components/file-download-btn";
 import { getDictionary } from "@/api/system/dictbiz";
 import { save, update, getApprove } from "@/api/projectManage/projectList";
 import moment from "moment";
@@ -273,11 +280,15 @@ import { downloadXls } from "@/util/util";
 export default {
   components: {
     personSelect,
-    secondUnitCascader
+    secondUnitCascader,
+    fileDownloadBtn
   },
   props: {
     // add or edit
-    operateType: String,
+    operateType: {
+      type: String,
+      default: 'add'
+    },
     projectId: [String, Number]
   },
   data() {

+ 6 - 2
src/views/project-manage/components/implement-form.vue

@@ -135,7 +135,9 @@
       <avue-form v-show="!isPrintPage" v-model="formData" :option="option" style="margin-top: 30px; padding: 0;">
         <template slot="attachmentLabel">
           <label>附件信息:</label>
-          <el-link type="primary" style="position: absolute; left: 290px; z-index: 1;">下载模板</el-link>
+          <div style="position: absolute; top: 0; left: 300px; z-index: 1;">
+            <file-download-btn templateKey="研发项目管理-阶段性报告"></file-download-btn>
+          </div>
         </template>
       </avue-form>
 
@@ -160,6 +162,7 @@
 
 <script>
 import projectSelect from "@/components/project-select";
+import fileDownloadBtn from "@/components/file-download-btn";
 import { getDictionary } from "@/api/system/dictbiz";
 import { save, getDetail } from "@/api/projectManage/implement";
 import moment from "moment";
@@ -176,7 +179,8 @@ export default {
     }
   },
   components: {
-    projectSelect
+    projectSelect,
+    fileDownloadBtn
   },
   data() {
     return {