Browse Source

工种导出

yanghe17378 11 months ago
parent
commit
eb7dcc5bf4

+ 35 - 11
src/views/factoryModel/jobManagement/index.vue

@@ -37,22 +37,21 @@
           >
             删除
           </el-button>
-          <!--          <el-button
-                      size="small"
-                      type="primary"
-                      icon="el-icon-upload2"
-                      class="ele-btn-icon"
-                      @click="exportProfession"
-                      plain
-                    >
-                      导出
-                    </el-button>-->
+          <el-button
+            size="small"
+            type="primary"
+            icon="el-icon-upload2"
+            class="ele-btn-icon"
+            @click="exportProfession"
+            plain
+          >
+            导出
+          </el-button>
           <el-button
             size="small"
             type="primary"
             icon="el-icon-download"
             class="ele-btn-icon"
-            v-if="$hasPermission('main:profession:update')"
             @click="importProfession"
             plain
           >
@@ -127,6 +126,8 @@
   import control from '@/api/technology/control';
   import dictMixins from '@/mixins/dictMixins';
   import importDialog from '@/components/upload/import-dialogNew.vue';
+  import request from '@/utils/request';
+  import { download } from '@/utils/file';
 
   export default {
     name: 'technologyProduction',
@@ -138,6 +139,7 @@
     mixins: [dictMixins, tabMixins],
     data() {
       return {
+        searchParams: {},
         moduleName: 'mainProfession',
         levelOptions: [
           {
@@ -267,6 +269,27 @@
       }
     },
     methods: {
+      exportProfession() {
+        /*const data = th;
+        if (!data || data === {} || !data.categoryLevelId) {
+          this.$message.warning('请选择物品类别');
+          return;
+        }*/
+        this.exportLoading = true;
+        request
+          .post('/main/profession/export', this.searchParams, {
+            responseType: 'blob'
+          })
+          .then((res) => {
+            download(res.data, '工种数据.xlsx');
+          })
+          .catch((e) => {
+            console.error(e);
+          })
+          .finally(() => {
+            this.exportLoading = false;
+          });
+      },
       importProfession() {
         debugger;
         this.$refs.importDialogRef.open();
@@ -290,6 +313,7 @@
 
       /* 刷新表格 */
       reload(where) {
+        this.searchParams = where;
         this.$refs.table.reload({ page: 1, where: where });
       },
       /* 打开编辑弹窗 */

+ 0 - 1
src/views/material/product/components/index-data.vue

@@ -856,7 +856,6 @@
       },
       /** 导出按钮操作 */
       handleExport() {
-        debugger;
         const data = this.whereData;
         if (!data || data === {} || !data.categoryLevelId) {
           this.$message.warning('请选择物品类别');