yangys
2025-09-09 729b698b17d7468acbc6c495746a72c9150fdaeb
src/views/flowmgr/programexport.vue
@@ -1,7 +1,7 @@
<!--
 * @Date: 2025-06-20 20:48:17
 * @LastEditors: 李喆(开发组) lzhe@yxqiche.com
 * @LastEditTime: 2025-08-11 16:34:15
 * @LastEditors: gaoshp
 * @LastEditTime: 2025-08-17 10:17:27
 * @FilePath: /mdmweb/src/views/flowmgr/programexport.vue
-->
<template>
@@ -13,7 +13,7 @@
                    <template #menu-left>
                        <!-- <el-button type="primary" plain @click="exportWebSite">导出回传涉密网</el-button> -->
                        <!-- <el-button type="primary" plain @click="reassign">挂载车床程序库</el-button> -->
                        <el-button type="primary" plain @click="exportExcel">导出</el-button>
                        <el-button type="primary" :disabled="this.selection.length==0" plain @click="exportExcel">导出</el-button>
                    </template>
                    <template #menu="scope">
                        <!-- <el-button type="primary" text size="default"
@@ -28,7 +28,7 @@
                    <template #menu-left>
                        <!-- <el-button type="primary" plain @click="exportWebSite">导出回传涉密网</el-button> -->
                        <!-- <el-button type="primary" plain @click="reassign">挂载车床程序库</el-button> -->
                        <el-button type="primary" plain @click="exportExcel">导出</el-button>
                        <el-button type="primary" :disabled="this.selection.length==0" plain @click="exportExcel">导出</el-button>
                    </template>
                    <template #menu="scope">
                        <!-- <el-button type="primary" text size="default"
@@ -46,6 +46,7 @@
    import NProgress from 'nprogress';
    import { exportBlobPost } from '@/api/common';
    import { getToken } from '@/utils/auth';
    import {todoChangeNotify} from '@/api/flow/todolist';
    import { downloadFile } from '@/utils/util';
    export default {
    name: 'programexport',
@@ -73,6 +74,7 @@
                // simplePage: true,
                searchShow: true,
                searchMenuSpan: 6,
                searchEnter:true,
                dialogWidth: '60%',
                // tree: true,
                border: true,
@@ -86,6 +88,7 @@
               {
                        label: '流程标题',
                        prop: 'title',
                        with: 250
                    },
                    {
                        label: '零组件号',
@@ -94,19 +97,30 @@
                    {
                        label: '工序号',
                        prop: 'processNo',
                        with: 75
                    },
                    {
                        label: '图号版次',
                        prop: 'drawingNoEdition',
                        label: '工序版次',
                        prop: 'processEdition',
                        with: 85
                    },
                    {
                        label: '工序名称',
                        prop: 'processName',
                        with: 85
                    },
                    {
                        label: '程序名称',
                        label: '图纸版次',
                        prop: 'drawingNoEdition',
                        with: 85
                    },
                    {
                        label: '程序包名',
                        prop: 'name',
                        search: true,
                        with: 100
                    },
                    {
                        label: '通过时间',
@@ -134,6 +148,7 @@
                tip: false,
                // simplePage: true,
                searchShow: true,
                searchEnter:true,
                searchMenuSpan: 6,
                dialogWidth: '60%',
                // tree: true,
@@ -148,6 +163,7 @@
               {
                        label: '流程标题',
                        prop: 'title',
                        with: 200
                    },
                    {
                        label: '零组件号',
@@ -156,27 +172,43 @@
                    {
                        label: '工序号',
                        prop: 'processNo',
                        width: 70
                    },
                    {
                        label: '图号版次',
                        prop: 'drawingNoEdition',
                        label: '工序版次',
                        prop: 'processEdition',
                        width: 85
                    },
                    {
                        label: '工序名称',
                        prop: 'processName',
                        width: 85
                    },
                    {
                        label: '程序名称',
                        label: '图纸版次',
                        prop: 'drawingNoEdition',
                        width: 85
                    },
                    {
                        label: '程序包名',
                        prop: 'name',
                        search: true,
                    },
                    {
                        label: '通过时间',
                        prop: 'createTime',
                        sortable: true,
                    },
                    {
                        label: '导出人',
                        prop: 'exporter',
                        width: 70
                    },
                    {
                        label: '已办时间',
                        prop: 'updateTime',
                        sortable: true,
                    },
                    {
                        label: '通过时间',
@@ -188,6 +220,7 @@
                        valueFormat: 'YYYY-MM-DD HH:mm:ss',
                        searchRange: true,
                        searchSpan: 8,
                        sortable: true,
                    },
                ],
            }
@@ -262,13 +295,36 @@
                this.loading = false;
            });
        },
        findDuplicates(arr) {
            const seen = new Set();
            const duplicates = new Set();
            arr.forEach(item => {
                if (seen.has(item)) {
                duplicates.add(item);
                } else {
                seen.add(item);
                }
            });
            return Array.from(duplicates);
        },
        exportExcel() {
            this.$confirm('是否导出?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
            }).then(() => {
                console.log(this.selection)
                //console.log(this.selection)
                let selectArray = [];
                for(var i=0;i<this.selection.length;i++){
                    selectArray.push(this.selection[i].name+"-"+this.selection[i].processEdition)
                }
                let dupData = this.findDuplicates(selectArray);
                if(dupData.length > 0){
                    this.$message.error('不能在一次导出中选择一个程序的不同版本:['+dupData.join()+"]");
                    return;
                }
            if(this.selection == null || this.selection.length == 0){
               this.$message.error('请至少选择一条导出');
               return;
@@ -281,9 +337,8 @@
                ).then(res => {
                console.log('status='+res.status)
               if(res.status == 200){
                  //console.log(res.data);
                  let name = res.headers['content-disposition'].split('filename=')[1]
                  name = decodeURI(name)
                  //console.log(res.headers['content-disposition'].split('filename=')[1]);
                  downloadFile(res.data, `${name}`);
                  
@@ -291,6 +346,7 @@
                  this.$message.error('导出错误');
                  console.log(res);
               }
                    todoChangeNotify();
                    NProgress.done();
                    this.onLoad(this.page, this.query);
                });