yangys
2025-10-16 cb04b8ed8a616c5b9fae9d432c093985b56f044c
src/views/flowmgr/programexport.vue
@@ -8,32 +8,22 @@
    <basic-container>
        <el-tabs v-model="activeName" type="card" class="demo-tabs" @tab-click="tabsClick">
            <el-tab-pane label="待办" name="todo">
                <avue-crud :option="option" :table-loading="loading" :data="data" v-model:page="page" v-model="form" ref="crud" @current-change="currentChange"
                    @size-change="sizeChange" @refresh-change="refreshChange" @on-load="onLoad" @search-change="searchChange" @search-reset="searchReset" @selection-change="selectionChange">
                <avue-crud :option="option" :search="searchData" :table-loading="loading" :data="data" v-model:page="page" v-model="form" ref="crud" @current-change="currentChange"
                    @size-change="sizeChange" @refresh-change="refreshChange" @search-change="searchChange" @search-reset="searchReset" @selection-change="selectionChange" @on-load="onLoad">
                    <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"
                            @click.stop="handleAction(scope.row, scope.index)">处理意见
                        </el-button> -->
                    </template>
                </avue-crud>
            </el-tab-pane>
            <el-tab-pane label="已办" name="completed">
                <avue-crud :option="optionCompleted" :table-loading="loading" :data="data" v-model:page="page" v-model="form" ref="crud" @current-change="currentChange"
                    @size-change="sizeChange" @refresh-change="refreshChange" @on-load="onLoad" @search-change="searchChange" @search-reset="searchReset" @selection-change="selectionChange">
                <avue-crud :option="optionCompleted" :search="searchData2" :table-loading="loading" :data="data2" v-model:page="page2" v-model="form" ref="crud1" @current-change="currentChange2"
                    @size-change="sizeChange2" @refresh-change="refreshChange2" @search-change="searchChange2" @search-reset="searchReset2" @selection-change="selectionChange" @on-load="onLoad2">
                    <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"
                            @click.stop="handleAction(scope.row, scope.index)">处理意见
                        </el-button> -->
                    </template>
                </avue-crud>
            </el-tab-pane>
@@ -46,22 +36,31 @@
    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',
    data() {
        return {
            activeName: "todo",
            // Define your data properties here
            page: {
                pageSize: 10,
                currentPage: 1,
                total: 0,
            },
            page2: {
                pageSize: 10,
                currentPage: 1,
                total: 0,
            },
            form: {},
            searchData:{},
            searchData2:{},
            query: {},
            query2: {},
            loading: true,
            data: [],
            data2: [],
            selection: [],
            option: {
                addBtn: false,
@@ -70,15 +69,13 @@
                viewBtn: true,
                columnBtn: false,
                tip: false,
                // simplePage: true,
                searchShow: true,
                searchMenuSpan: 6,
                searchEnter:true,
                dialogWidth: '60%',
                // tree: true,
                border: true,
                index: true,
                selection: true,
                // viewBtn: true,
                menuWidth: 200,
                menu: false,
                dialogClickModal: false,
@@ -86,6 +83,7 @@
               {
                        label: '流程标题',
                        prop: 'title',
                        with: 250
                    },
                    {
                        label: '零组件号',
@@ -94,25 +92,40 @@
                    {
                        label: '工序号',
                        prop: 'processNo',
                        with: 75
                    },
                    
                    {
                        label: '工序版次',
                        prop: 'processEdition',
                        with: 85
                    },
                    {
                        label: '工序名称',
                        prop: 'processName',
                        with: 85
                    },
                    {
                        label: '图号版次',
                        label: '图纸版次',
                        prop: 'drawingNoEdition',
                        with: 85
                    },
                    
                    {
                        label: '程序包名',
                        prop: 'name',
                        search: true,
                        searchSpan:6,
                        with: 100
                    },
                     {
                        label: '查询范围',
                        prop: 'queryType',
                        type: 'select',
                        search: true,
                        clearable:false,
                        searchSpan:4,
                        with: 100,
                    },
                    {
                        label: '通过时间',
@@ -138,15 +151,13 @@
                viewBtn: true,
                columnBtn: false,
                tip: false,
                // simplePage: true,
                searchShow: true,
                searchEnter:true,
                searchMenuSpan: 6,
                dialogWidth: '60%',
                // tree: true,
                border: true,
                index: true,
                selection: true,
                // viewBtn: true,
                menuWidth: 200,
                menu: false,
                dialogClickModal: false,
@@ -154,6 +165,7 @@
               {
                        label: '流程标题',
                        prop: 'title',
                        with: 200
                    },
                    {
                        label: '零组件号',
@@ -162,18 +174,22 @@
                    {
                        label: '工序号',
                        prop: 'processNo',
                        width: 70
                    },
                    {
                        label: '工序版次',
                        prop: 'processEdition',
                        width: 85
                    },
                    {
                        label: '工序名称',
                        prop: 'processName',
                        width: 85
                    },
                    {
                        label: '图号版次',
                        label: '图纸版次',
                        prop: 'drawingNoEdition',
                        width: 85
                    },
                    
                    {
@@ -182,15 +198,30 @@
                        search: true,
                    },
                    {
                        label: '查询范围',
                        prop: 'queryType',
                        type: 'select',
                        search: true,
                        clearable:false,
                        searchSpan:4,
                        with: 100,
                    },
                    {
                        label: '通过时间',
                        prop: 'createTime',
                        sortable: true,
                    },
                    {
                        label: '导出人',
                        prop: 'exporter',
                        width: 70
                    },
                    {
                        label: '已办时间',
                        prop: 'updateTime',
                        sortable: true,
                    },
                    {
                        label: '通过时间',
                        prop: 'passTime',
@@ -204,64 +235,96 @@
                        sortable: true,
                    },
                ],
            }
            },
        };
    },
    methods: {
        tabsClick(tab,event) {
            this.onLoad(this.page, this.query);
            if(tab.paneName == 'todo'){
                this.onLoad(this.page, this.searchData);
            }else{
               // console.log(this.searchData2)
                this.onLoad2(this.page2, this.searchData2);
            }
        },
        selectionChange(list) {
            this.selection = list;
        },
        // Define your methods here
        currentChange(currentPage) {
            this.page.currentPage = currentPage;
            // this.onLoad();
        },
        currentChange2(currentPage) {
            this.page2.currentPage = currentPage;
        },
        sizeChange(pageSize) {
            this.page.pageSize = pageSize;
        },
        sizeChange2(pageSize) {
            this.page2.pageSize = pageSize;
        },
        refreshChange() {
            this.onLoad(this.page, this.query);
        },
        refreshChange2() {
            this.onLoad2(this.page2, this.query2);
        },
        searchChange(params, done) {
            let data = {}
            this.query = params;
            this.page.currentPage = 1;
            console.log('searchChange', params);
            //console.log('searchChange', params);
            params.passTimeBegin = params?.passTime?.[0] || '';
            params.passTimeEnd = params?.passTime?.[1] || '';
            console.log(params);
            //console.log(params);
            data = {
                createTimeBegin: params.passTimeBegin,
                createTimeEnd: params.passTimeEnd,
                name: params.name || ''
                name: params.name || '',
                queryType:this.query.queryType
            }
            this.query = data
            this.onLoad(this.page, data);
            done();
        },
        searchChange2(params, done) {
            let data = {}
            this.query2 = params;
            this.page2.currentPage = 1;
            //console.log('searchChange', params);
            params.passTimeBegin = params?.passTime?.[0] || '';
            params.passTimeEnd = params?.passTime?.[1] || '';
            //console.log(params);
            data = {
                createTimeBegin: params.passTimeBegin,
                createTimeEnd: params.passTimeEnd,
                name: params.name || '',
                queryType:this.query2.queryType
            }
            this.query2 = data
            this.onLoad2(this.page2, data);
            done();
        },
        searchReset() {
            this.query = {};
            this.query.queryType = this.searchData.queryType;
            this.onLoad(this.page);
        },
        searchReset2() {
            this.query2 = {};
            this.query2.queryType = this.searchData2.queryType;
            this.onLoad2(this.page2);
        },
        /** * 页面加载时获取数据
         */
        onLoad(page, params = {}) {
            const query = {
                ...this.query,
                // category: params.category ? flowCategory(params.category) : null,
                mode: this.mode,
            };
            var status = this.activeName == 'todo'?null:2;
            params.status = status;
            try {
                delete query.confirmTime; // 删除不必要的查询条件
            } catch (error) {
                console.error('日期格式化错误', error);
            }
            this.loading = true;
            getList(page.currentPage, page.pageSize, Object.assign(query, params)).then(res => {
                const data = res.data.data;
@@ -276,13 +339,57 @@
                this.loading = false;
            });
        },
        onLoad2(page, params = {}) {
            const query = {
                ...this.query2,
            };
            params.status = 2;
            //params.queryType = this.searchData2.queryType;
            this.loading = true;
            getList(page.currentPage, page.pageSize, Object.assign(query, params)).then(res => {
                const data = res.data.data;
                this.page2.total = data.total;
                this.data2 = data.records;
                this.loading = false;
            }, () => {
                this.data2 = [];
                this.loading = false;
            }).catch(err => {
                this.data2 = [];
                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;
@@ -295,9 +402,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}`);
                  
@@ -305,14 +411,41 @@
                  this.$message.error('导出错误');
                  console.log(res);
               }
                    todoChangeNotify();
                    NProgress.done();
                    this.onLoad(this.page, this.query);
                });
            });
        },
    },
    computed: {
       ...mapGetters(['permission']),
    },
    mounted() {
        let queryTypeDicData = [
                            {
                                label: '同组编制',
                                value:'group',
                            },
                            {
                                label: '本人编制',
                                value:'self',
                            }
                        ];
        //console.log('this.permission.program_allexpor',this.permission.program_allexport)
        if(this.permission.program_allexport==true){
            queryTypeDicData.push({label:'全部数据',value:'all'});
            this.searchData.queryType = 'all'
            this.searchData2.queryType = 'all'
        }else{
            this.searchData.queryType = 'self';
            this.searchData2.queryType = 'self';
        }
        this.option.column[7].dicData = queryTypeDicData;
        this.optionCompleted.column[7].dicData = queryTypeDicData;
        this.onLoad(this.page, this.searchData);
    }
}
</script>