guhongwei 4 jaren geleden
bovenliggende
commit
623c23b4d3
2 gewijzigde bestanden met toevoegingen van 32 en 69 verwijderingen
  1. 8 1
      src/store/market/newmarketproduct.js
  2. 24 68
      src/views/superAdminCenter/enterpriseProduct/index.vue

+ 8 - 1
src/store/market/newmarketproduct.js

@@ -2,7 +2,10 @@ import Vue from 'vue';
 import Vuex from 'vuex';
 import _ from 'lodash';
 Vue.use(Vuex);
-const api = { newsInfo: `/api/market/product` };
+const api = {
+  newsInfo: `/api/market/product`,
+  exportexcelInfo: `/api/market/product/exportexcel`,
+};
 const state = () => ({});
 const mutations = {};
 const actions = {
@@ -39,6 +42,10 @@ const actions = {
     });
     return res;
   },
+  async exportexcel({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.exportexcelInfo}`, payload);
+    return res;
+  },
   async create({ commit }, payload) {
     const res = await this.$axios.$post(`${api.newsInfo}`, payload);
     return res;

+ 24 - 68
src/views/superAdminCenter/enterpriseProduct/index.vue

@@ -14,8 +14,9 @@
               <three :oneList="threeList" :total="threeTotal" @handleDelete="handleDelete"></three>
             </el-tab-pane>
           </el-tabs>
-          <el-col :span="24">
-            <el-button type="primary" size="mini" class="excel" @click="excelBtn()">导出数据</el-button>
+          <el-col :span="24" class="excel">
+            <el-button type="primary" size="mini" @click="excelBtn()">导出技术供求数据</el-button>
+            <el-button type="primary" size="mini" @click="excelBtns()">导出产品供求数据</el-button>
           </el-col>
         </el-col>
         <el-dialog :title="theme" width="60%" :visible.sync="dialog" @closed="handleClose" :destroy-on-close="true">
@@ -224,7 +225,7 @@ export default {
     this.maarkettype();
   },
   methods: {
-    ...newmarketproduct(['query', 'comquery', 'delete', 'fetch', 'update']),
+    ...newmarketproduct(['query', 'comquery', 'delete', 'fetch', 'update', 'exportexcel']),
     ...markettype({ markettypeList: 'query' }),
     // 查询列表
     async search({ skip = 0, limit = 10, ...info } = {}) {
@@ -304,69 +305,25 @@ export default {
     uploadDelete(index) {
       this.form.image.splice(index, 1);
     },
-    // 导出数据
-    excelBtn() {
-      require.ensure([], () => {
-        const { export_json_to_excel } = require('@/excel/Export2Excel');
-        const tHeader = [
-          '分类',
-          '名称',
-          '类型名称',
-          '简介',
-          '研发阶段',
-          '单价',
-          '单位',
-          '所属领域',
-          '服务范围',
-          '合作方式',
-          '交易方式',
-          '投入预算',
-          '需求截止日期',
-          '难题及瓶颈问题',
-          '企业解决需求',
-          '单位名称',
-          '单位地址',
-          '技术团队情况',
-          '知识产权情况',
-          '技术成熟度',
-          '合作企业',
-          '其他需求',
-          '联系人',
-          '联系电话',
-        ];
-        const filterVal = [
-          'totaltype',
-          'name',
-          'product_type_name',
-          'introduction',
-          'phase',
-          'price',
-          'priceunit',
-          'field',
-          'scope',
-          'coopermode',
-          'business',
-          'budget',
-          'end_date',
-          'difficult_problem',
-          'demand',
-          'company',
-          'address',
-          'team',
-          'property',
-          'mature',
-          'coopercompany',
-          'other',
-          'contact_user',
-          'contact_tel',
-        ];
-        const list = this.exportList;
-        const data = this.formatJson(filterVal, list);
-        for (const val of list) {
-          let companyName = val.c_name;
-          export_json_to_excel(tHeader, data, companyName);
-        }
-      });
+    // 导出技术数据
+    async excelBtn() {
+      let data = {
+        totaltype: '0',
+      };
+      const res = await this.exportexcel(data);
+      if (this.$checkRes(res)) {
+        window.open(res.data);
+      }
+    },
+    // 导出产品数据
+    async excelBtns() {
+      let data = {
+        totaltype: '1',
+      };
+      const res = await this.exportexcel(data);
+      if (this.$checkRes(res)) {
+        window.open(res.data);
+      }
     },
     formatJson(filterVal, jsonData) {
       return jsonData.map(v => filterVal.map(j => v[j]));
@@ -387,8 +344,7 @@ export default {
 <style lang="less" scoped>
 .excel {
   position: absolute;
-  top: 0;
-  right: 0;
   text-align: right;
+  top: 5px;
 }
 </style>