Просмотр исходного кода

feat: 新增批量记录导出功能

新增 exportButton 组件,支持批量记录导出为 Excel 文件,并在多个批量记录表格中集成使用。同时格式
yusheng 3 месяцев назад
Родитель
Сommit
6c2448cad1

+ 16 - 6
src/api/system/file/index.js

@@ -5,7 +5,7 @@ import { download } from '@/utils/file';
  * 上传文件
  * @param file 文件
  */
-export async function uploadFile (data) {
+export async function uploadFile(data) {
   const formData = new FormData();
   formData.append('multiPartFile', data.multiPartFile);
   formData.append('module', data.module);
@@ -19,7 +19,7 @@ export async function uploadFile (data) {
  * 上传文件 批量
  * @param file 文件
  */
-export async function uploadBatch (data) {
+export async function uploadBatch(data) {
   const formData = new FormData();
   data.multiPartFiles.forEach((item, index) => {
     formData.append(`multiPartFiles`, item);
@@ -37,7 +37,7 @@ export async function uploadBatch (data) {
 /**
  * 获取文件路径
  */
-export async function getPathAddress () {
+export async function getPathAddress() {
   const res = await request.post('/main/file/getPathAddress');
   if (res.data.code === '0') {
     return res.data.data;
@@ -47,7 +47,7 @@ export async function getPathAddress () {
 /**
  * 获取文件
  */
-export async function getFile (params, fileName) {
+export async function getFile(params, fileName) {
   const res = await request.get('/main/file/getFile', {
     params,
     responseType: 'blob'
@@ -63,7 +63,7 @@ export async function getFile (params, fileName) {
 /**
  * 删除文件
  */
-export async function removeFile (data) {
+export async function removeFile(data) {
   const res = await request.post(
     `/main/file/delete?fileId=${data.fileId}`,
     data
@@ -76,10 +76,20 @@ export async function removeFile (data) {
 /**
  * 文件列表
  */
-export async function getFileList (data) {
+export async function getFileList(data) {
   const res = await request.post(`/main/file/list`, data);
   if (res.data.code === '0') {
     return res.data.data;
   }
   return Promise.reject(new Error(res.data.message));
 }
+/**
+ * 导出
+ */
+export async function exportTable(data) {
+  const res = await request.post(data.api, data.data, {
+    responseType: 'blob'
+  });
+  console.log(res.data, '***********');
+  download(res.data, data.fileName + '.xlsx');
+}

+ 45 - 0
src/components/upload/exportButton.vue

@@ -0,0 +1,45 @@
+<template>
+  <el-button
+    type="primary"
+    size="small"
+    icon="el-icon-download"
+    @click="exportFn"
+    >{{btnName}}</el-button
+  >
+</template>
+
+<script>
+  import { exportTable } from '@/api/system/file/index.js';
+  export default {
+    props: {
+      btnName: {
+        type: String,
+        default: '导出'
+      },
+      apiUrl: '',
+      fileName: '',
+      params: {
+        default: () => {
+          return {};
+        }
+      }
+    },
+    //注册组件
+    data() {
+      return {};
+    },
+
+    created() {},
+    methods: {
+      exportFn() {
+        exportTable({
+          api: this.apiUrl,
+          fileName: this.fileName,
+          data:this.params
+        });
+      }
+    }
+  };
+</script>
+
+<style lang="scss"></style>

+ 12 - 2
src/views/batchRecord/components/tables/batchRecordTable.vue

@@ -23,6 +23,13 @@
           row.code
         }}</el-link>
       </template>
+      <template v-slot:toolbar>
+        <exportButton
+          fileName="生产记录"
+          apiUrl="/mes/producetaskrulerecord/exportBatchRecordPage"
+          :params="params"
+        ></exportButton
+      ></template>
     </ele-pro-table>
 
     <editModal ref="editModalRef"></editModal>
@@ -37,10 +44,11 @@
   import { producetaskrulerecordPage } from '@/api/producetaskrulerecord/index';
   import editModal from '../editModal.vue';
   import batchPecordPrint from './batchPecordPrint.vue';
+  import exportButton from '@/components/upload/exportButton.vue';
 
   export default {
     mixins: [dictMixins, tableColumnsMixin],
-    components: { editModal, batchPecordPrint },
+    components: { editModal, batchPecordPrint, exportButton },
     props: {
       tableQuery: {
         type: Object,
@@ -145,7 +153,8 @@
             fixed: 'right'
           }
         ],
-        cacheKeyUrl: 'mes-259231507-batchRecord-table'
+        cacheKeyUrl: 'mes-259231507-batchRecord-table',
+        params: {}
       };
     },
     computed: {
@@ -215,6 +224,7 @@
           ...this.tableQuery,
           recordOrder: 1
         };
+        this.params = body;
         return producetaskrulerecordPage(body);
       },
       search(where) {

+ 15 - 3
src/views/batchRecord/components/tables/certificate.vue

@@ -18,6 +18,13 @@
         @columns-change="handleColumnChange"
         :cache-key="cacheKeyUrl"
       >
+        <template v-slot:toolbar>
+          <exportButton
+            fileName="合格证"
+            apiUrl="/qms/qmscertificatemanagement/export"
+            :params="params"
+          ></exportButton>
+        </template>
         <template v-slot:code="{ row }">
           <el-link
             type="primary"
@@ -73,11 +80,13 @@
   import dictMixins from '@/mixins/dictMixins';
   import { getCertificatetList } from '@/api/qms/index.js';
   import certificate_conformity_jangnan_template from './certificateTemplate/certificate_conformity_jangnan_template.vue';
+  import exportButton from '@/components/upload/exportButton.vue';
 
   export default {
     mixins: [dictMixins, tabMixins],
     components: {
-      certificate_conformity_jangnan_template
+      certificate_conformity_jangnan_template,
+      exportButton
     },
     props: {
       tableQuery: {
@@ -90,6 +99,7 @@
     data() {
       return {
         cacheKeyUrl: 'qsm-c2e9664a-certificateManagement',
+        params: {},
 
         orderTypeList: [
           {
@@ -370,12 +380,14 @@
 
       /* 表格数据源 */
       datasource({ page, where, limit }) {
-        return getCertificatetList({
+        const body = {
           ...where,
           pageNum: page,
           size: limit,
           ...this.tableQuery
-        });
+        };
+        this.params = body;
+        return getCertificatetList(body);
       },
       /* 刷新表格 */
       reload(where) {

+ 12 - 2
src/views/batchRecord/components/tables/craftFilesTable.vue

@@ -20,6 +20,13 @@
           row.code
         }}</el-link>
       </template>
+      <template v-slot:toolbar>
+        <exportButton
+          fileName="工艺文件"
+          apiUrl="/mes/workorder/craftFiles/exportBatchRecordPage"
+          :params="params"
+        ></exportButton
+      ></template>
     </ele-pro-table>
 
     <fileBrowse ref="fileBrowseRef"></fileBrowse>
@@ -31,10 +38,11 @@
   import tableColumnsMixin from '@/mixins/tableColumnsMixin';
   import { batchRecordPage, filePageAPI } from '@/api/produce/workOrder.js';
   import fileBrowse from '@/views/produce/components/picking/fileBrowse.vue';
+  import exportButton from '@/components/upload/exportButton.vue';
 
   export default {
     mixins: [dictMixins, tableColumnsMixin],
-    components: { fileBrowse },
+    components: { fileBrowse, exportButton },
     props: {
       tableQuery: {
         type: Object,
@@ -115,7 +123,8 @@
             fixed: 'right'
           }
         ],
-        cacheKeyUrl: 'mes-259231537-craft-files-table'
+        cacheKeyUrl: 'mes-259231537-craft-files-table',
+        params: {}
       };
     },
     computed: {
@@ -148,6 +157,7 @@
           size: limit,
           ...this.tableQuery
         };
+        this.params = body;
         return this.getDataList(body);
       },
       // 查询数据

+ 12 - 1
src/views/batchRecord/components/tables/deviceBatchRecordTable.vue

@@ -21,6 +21,13 @@
           row.code
         }}</el-link>
       </template>
+      <template v-slot:toolbar>
+        <exportButton
+          fileName="设备工单"
+          apiUrl="/eam/workordermaintenance/exportBatchRecordPage"
+          :params="params"
+        ></exportButton
+      ></template>
     </ele-pro-table>
   </div>
 </template>
@@ -29,9 +36,11 @@
   import dictMixins from '@/mixins/dictMixins';
   import tableColumnsMixin from '@/mixins/tableColumnsMixin';
   import { batchRecordPage } from '@/api/eam/index.js';
+  import exportButton from '@/components/upload/exportButton.vue';
 
   export default {
     mixins: [dictMixins, tableColumnsMixin],
+    components: { exportButton },
     props: {
       tableQuery: {
         type: Object,
@@ -133,7 +142,8 @@
             fixed: 'right'
           }
         ],
-        cacheKeyUrl: 'mes-259231549-device-batchRecord-table'
+        cacheKeyUrl: 'mes-259231549-device-batchRecord-table',
+        params: {}
       };
     },
     computed: {
@@ -204,6 +214,7 @@
           types: [1, 2],
           ...this.tableQuery
         };
+        this.params = body;
         return batchRecordPage(body);
       },
       search(where) {

+ 13 - 2
src/views/batchRecord/components/tables/materialReturnTable.vue

@@ -21,6 +21,13 @@
           row.code
         }}</el-link>
       </template>
+      <template v-slot:toolbar>
+        <exportButton
+          fileName="退料单"
+          apiUrl="/mes/returnmaterials/exportBatchRecordPage"
+          :params="params"
+        ></exportButton
+      ></template>
     </ele-pro-table>
 
     <returnPop
@@ -37,11 +44,12 @@
   import tableColumnsMixin from '@/mixins/tableColumnsMixin';
   import { batchRecordPage } from '@/api/returnmaterials/index';
   import returnPop from '@/views/materialReturn/components/returnPop.vue';
+  import exportButton from '@/components/upload/exportButton.vue';
   import { getByCode } from '@/api/system/dictionary-data';
 
   export default {
     mixins: [dictMixins, tableColumnsMixin],
-    components: { returnPop },
+    components: { returnPop, exportButton },
     props: {
       tableQuery: {
         type: Object,
@@ -115,7 +123,9 @@
         ],
         cacheKeyUrl: 'mes-259231042-material-return-table',
         returnShow: false,
-        returnDetailsId: null
+        returnDetailsId: null,
+        sceneList: [],
+        params: {}
       };
     },
     computed: {
@@ -163,6 +173,7 @@
           size: limit,
           ...this.tableQuery
         };
+        this.params = body;
         return batchRecordPage(body);
       },
       search(where) {

+ 12 - 3
src/views/batchRecord/components/tables/materialTable.vue

@@ -28,6 +28,13 @@
           >{{ statusList[row.status] }}</el-tag
         >
       </template>
+      <template v-slot:toolbar>
+        <exportButton
+          fileName="领料单"
+          apiUrl="/mes/pickorder/exportBatchRecordPage"
+          :params="params"
+        ></exportButton
+      ></template>
     </ele-pro-table>
 
     <detailed
@@ -50,12 +57,12 @@
   import { batchRecordPage } from '@/api/pickorder/index';
   import detailed from '@/views/produce/components/picking/detailed.vue';
   import selfDetailed from '@/views/pick/pickApply/components/selfDetailed.vue';
-
+  import exportButton from '@/components/upload/exportButton.vue';
   import { getDetails } from '@/api/pick/pickApply';
 
   export default {
     mixins: [dictMixins, tableColumnsMixin],
-    components: { detailed, selfDetailed },
+    components: { detailed, selfDetailed, exportButton },
     props: {
       tableQuery: {
         type: Object,
@@ -132,7 +139,8 @@
         detailedShow: false,
         selfDetailedShow: false,
         detailedObj: null,
-        statusList: ['未领料', '领料中', '已出库', '已驳回']
+        statusList: ['未领料', '领料中', '已出库', '已驳回'],
+        params: {}
       };
     },
     computed: {
@@ -178,6 +186,7 @@
           size: limit,
           ...this.tableQuery
         };
+        this.params = body;
         return batchRecordPage(body);
       },
       search(where) {

+ 14 - 2
src/views/batchRecord/components/tables/qualityInspection.vue

@@ -32,6 +32,13 @@
         <el-tag v-if="row.status == 2">待专检</el-tag>
         <el-tag v-if="row.status == 3">已完成</el-tag>
       </template>
+      <template v-slot:toolbar>
+        <exportButton
+          fileName="首件两检"
+          apiUrl="/mes/firstarticledualinspectionrecord/exportBatchRecordPage"
+          :params="params"
+        ></exportButton
+      ></template>
     </ele-pro-table>
 
     <self-inspection-reporting
@@ -47,11 +54,14 @@
   import selfInspectionReporting from '@/views/produce/components/qualityInspection/components/selfInspectionReporting.vue';
   import { getBatchRecordList } from '@/api/produce/qualityInspection';
   import { produceTask } from '@/api/InTheSystem/index';
+  import exportButton from '@/components/upload/exportButton.vue';
+
   export default {
     mixins: [dictMixins, tableColumnsMixin],
 
     components: {
-      selfInspectionReporting
+      selfInspectionReporting,
+      exportButton
     },
 
     props: {
@@ -158,7 +168,8 @@
           }
         ],
         cacheKeyUrl: 'batchRecord-qualityInspection-2025-12-17',
-        routList: []
+        routList: [],
+        params: {}
       };
     },
 
@@ -216,6 +227,7 @@
           size: limit,
           ...this.tableQuery
         };
+        this.params = body;
         return getBatchRecordList(body);
       },
 

+ 14 - 3
src/views/batchRecord/components/tables/qualityReportApproval.vue

@@ -35,6 +35,13 @@
             打印
           </el-link></template
         >
+        <template v-slot:toolbar>
+          <exportButton
+            fileName="质检报告"
+            apiUrl="/qms/quality_work_order/exportBatchRecordPageByReport"
+            :params="params"
+          ></exportButton
+        ></template>
       </ele-pro-table>
     </el-card>
     <ele-modal
@@ -60,10 +67,11 @@
   import dictMixins from '@/mixins/dictMixins';
   import tabMixins from '@/mixins/tableColumnsMixin';
   import { getQualityReportApproval } from '@/api/qms/index.js';
+  import exportButton from '@/components/upload/exportButton.vue';
 
   export default {
     mixins: [dictMixins, tabMixins],
-    components: {},
+    components: { exportButton },
     props: {
       tableQuery: {
         type: Object,
@@ -78,6 +86,7 @@
 
         detailVisible: false,
         template: '',
+        params: {},
         columns: [
           {
             type: 'index',
@@ -232,12 +241,14 @@
     },
     methods: {
       async datasource({ page, where, limit }) {
-        return getQualityReportApproval({
+        const body = {
           ...where,
           pageNum: page,
           ...this.tableQuery,
           size: limit
-        });
+        };
+        this.params = body;
+        return getQualityReportApproval(body);
       },
       search(where) {
         this.$refs.table.reload({

+ 12 - 1
src/views/batchRecord/components/tables/qualityWorkOrderTable.vue

@@ -21,6 +21,13 @@
           row.code
         }}</el-link>
       </template>
+      <template v-slot:toolbar>
+        <exportButton
+          fileName="质检工单"
+          apiUrl="/qms/quality_work_order/exportBatchRecordPage"
+          :params="params"
+        ></exportButton
+      ></template>
     </ele-pro-table>
   </div>
 </template>
@@ -29,9 +36,11 @@
   import dictMixins from '@/mixins/dictMixins';
   import tableColumnsMixin from '@/mixins/tableColumnsMixin';
   import { batchRecordPage } from '@/api/qualityWorkOrder/index.js';
+  import exportButton from '@/components/upload/exportButton.vue';
 
   export default {
     mixins: [dictMixins, tableColumnsMixin],
+    components: { exportButton },
     props: {
       tableQuery: {
         type: Object,
@@ -139,7 +148,8 @@
             fixed: 'right'
           }
         ],
-        cacheKeyUrl: 'mes-9221130-quality-work-order-table'
+        cacheKeyUrl: 'mes-9221130-quality-work-order-table',
+        params: {}
       };
     },
     computed: {
@@ -192,6 +202,7 @@
           size: limit,
           ...this.tableQuery
         };
+        this.params = body;
         return batchRecordPage(body);
       },
       search(where) {

+ 12 - 1
src/views/batchRecord/components/tables/wmsOutInt.vue

@@ -21,6 +21,13 @@
           row.bizNo
         }}</el-link>
       </template>
+      <template v-slot:toolbar>
+        <exportButton
+          fileName="入库单"
+          apiUrl="/wms/outintwo/exportBatchRecordPage"
+          :params="params"
+        ></exportButton
+      ></template>
     </ele-pro-table>
   </div>
 </template>
@@ -31,9 +38,11 @@
   import { getPages } from '@/api/wms/index';
   import { sceneState } from '@/utils/dict/index';
   import { getBatchRecordPage } from '@/api/wms/index';
+  import exportButton from '@/components/upload/exportButton.vue';
 
   export default {
     mixins: [dictMixins, tableColumnsMixin],
+    components: { exportButton },
     props: {
       tableQuery: {
         type: Object,
@@ -134,7 +143,8 @@
             fixed: 'right'
           }
         ],
-        cacheKeyUrl: 'mes-259231507-mwmsoutint-table'
+        cacheKeyUrl: 'mes-259231507-mwmsoutint-table',
+        params: {}
       };
     },
     computed: {
@@ -183,6 +193,7 @@
           // type  "1=入库 2=出库" 默认1
           type: 1
         };
+        this.params = body;
         return getBatchRecordPage(body);
       },
       search(where) {

+ 25 - 12
src/views/batchRecord/components/tables/workOrderTable.vue

@@ -21,6 +21,13 @@
           row.code
         }}</el-link>
       </template>
+      <template v-slot:toolbar>
+        <exportButton
+          fileName="生产工单"
+          apiUrl="/mes/workorder/exportBatchRecordPage"
+          :params="params"
+        ></exportButton
+      ></template>
     </ele-pro-table>
 
     <detailsPop ref="detailsRef"> </detailsPop>
@@ -34,10 +41,11 @@
   import detailsPop from '@/views/produceOrder/components/details/index.vue';
   import { getById } from '@/api/produceOrder/index';
   import { getAllProduceTaskByUsing } from '@/api/InTheSystem/index';
+  import exportButton from '@/components/upload/exportButton.vue';
 
   export default {
     mixins: [dictMixins, tableColumnsMixin],
-    components: { detailsPop },
+    components: { detailsPop, exportButton },
     props: {
       tableQuery: {
         type: Object,
@@ -150,7 +158,8 @@
             label: '终止'
           }
         ],
-        taskList: []
+        taskList: [],
+        params: {}
       };
     },
     computed: {
@@ -176,7 +185,7 @@
             multiple: true,
             placeholder: '请选择',
             planList: this.orderStatus
-          },
+          }
           // {
           //   label: '创建时间开始',
           //   value: 'createTimeStart',
@@ -219,6 +228,7 @@
           size: limit,
           ...this.tableQuery
         };
+        this.params = body;
         return batchRecordPage(body);
       },
       search(where) {
@@ -235,18 +245,21 @@
         const data = await getAllProduceTaskByUsing({
           size: 9999
         });
-        this.taskList = data.map(item => ({
+        this.taskList = data.map((item) => ({
           value: item.produceTaskName,
           label: item.produceTaskName
-        }))
+        }));
         // -1 入库,-2完结
-        this.taskList.push({
-          value: '入库',
-          label: '入库'
-        },{
-          value: '完结',
-          label: '完结'
-        })
+        this.taskList.push(
+          {
+            value: '入库',
+            label: '入库'
+          },
+          {
+            value: '完结',
+            label: '完结'
+          }
+        );
         console.log('工序', this.taskList);
       }
     }

+ 12 - 2
src/views/batchRecord/components/tables/workReportTable.vue

@@ -15,6 +15,13 @@
           详情
         </el-link>
       </template>
+      <template v-slot:toolbar>
+        <exportButton
+          fileName="报工"
+          apiUrl="/mes/workreport/exportBatchRecordPage"
+          :params="params"
+        ></exportButton
+      ></template>
     </ele-pro-table>
 
     <!-- //工单列表 -->
@@ -33,10 +40,11 @@
   import { batchRecordPage } from '@/api/workReport/index';
   import { getById } from '@/api/produceOrder';
   import routings from '@/views/produce/components/routings.vue';
+  import exportButton from '@/components/upload/exportButton.vue';
 
   export default {
     mixins: [dictMixins, tableColumnsMixin],
-    components: { routings },
+    components: { routings, exportButton },
     props: {
       tableQuery: {
         type: Object,
@@ -119,7 +127,8 @@
         ],
         cacheKeyUrl: 'mes-259231101-workreport-table',
         routingShow: false,
-        routeObj: {}
+        routeObj: {},
+        params: {}
       };
     },
     computed: {
@@ -158,6 +167,7 @@
           size: limit,
           ...this.tableQuery
         };
+        this.params = body;
         return batchRecordPage(body);
       },
       search(where) {