yangys
2025-08-23 4538b67070a6acab27d856c778fd6991003e319b
src/views/basesetting/produceplan.vue
@@ -1,37 +1,128 @@
<!--
 * @Date: 2025-06-17 11:44:52
 * @LastEditors: gaoshp
 * @LastEditTime: 2025-06-17 21:59:33
 * @LastEditTime: 2025-08-13 22:30:53
 * @FilePath: /mdmweb/src/views/basesetting/produceplan.vue
-->
<template>
    <basic-container>
        <avue-crud :option="option" :table-loading="loading" :data="data" v-model:page="page" v-model="form" ref="crud"
            @search-change="searchChange" @search-reset="searchReset" @current-change="currentChange"
            @size-change="sizeChange" @refresh-change="refreshChange" @on-load="onLoad" @row-del="rowDel"
            @row-save="save"
            @row-update="rowUpdate">
            <template #menu-left>
                <el-button type="primary" plain @click="importAction">导入
                </el-button>
            </template>
            <!-- <template #menu="scope">
                <el-button type="primary" text size="default" v-if="permission.flow_model_update"
                    @click.stop="handleAction(scope.row, scope.index)">审批
                </el-button>
            </template> -->
        </avue-crud>
        <el-tabs v-model="activeName" type="card" class="demo-tabs" @tab-click="tabsClick">
            <el-tab-pane label="主制分工表" name="zhuzhi">
                <avue-crud :option="option" :table-loading="loading" :data="data" v-model:page="page" v-model="form" ref="crud"
                    @search-change="searchChange" @search-reset="searchReset" @current-change="currentChange"
                    @size-change="sizeChange" @refresh-change="refreshChange" @on-load="onLoad" @row-del="rowDel"
                    @row-save="save"
                    @row-update="rowUpdate">
                    <template #menu-left>
                        <el-button type="primary" plain @click="importAction">导入
                        </el-button>
                        <el-button type="primary" plain @click="downTemplateAction">下载导入模板
                        </el-button>
                    </template>
                    <!-- <template #menu="scope">
                        <el-button type="primary" text size="default" v-if="permission.flow_model_update"
                            @click.stop="handleAction(scope.row, scope.index)">审批
                        </el-button>
                    </template> -->
                </avue-crud>
            </el-tab-pane>
            <el-tab-pane label="勤哲分工表" name="qinzhe">
                <avue-crud :option="optionQz" :table-loading="loadingQz" :data="dataQz" v-model:page="pageQz"
                    @search-change="searchChangeQz" @search-reset="searchResetQz" @current-change="currentChangeQz"
                    @size-change="sizeChangeQz" @refresh-change="refreshChangeQz" @on-load="onLoadQz" @row-del="rowDelQz" @row-update="rowUpdateQz">
                    <template #menu-left>
                        <el-button type="primary" plain @click="importActionQz">导入
                        </el-button>
                        <el-button type="primary" plain @click="downTemplateActionQz">下载导入模板
                        </el-button>
                    </template>
                </avue-crud>
            </el-tab-pane>
        </el-tabs>
        <el-dialog title="" append-to-body v-model="excelBox" width="555px">
            <avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter">
                <!--
                <template #excelTemplate>
                    <el-button type="primary" @click="handleTemplate">
                        确定
                    </el-button>
                </template>
                -->
            </avue-form>
        </el-dialog>
        <el-dialog title="" append-to-body v-model="excelBoxQz" width="555px">
            <avue-form :option="excelOptionQz" v-model="excelForm" :upload-after="uploadAfterQz">
            </avue-form>
        </el-dialog>
    </basic-container>
</template>
<script>
import { getList, remove,save,update } from '@/api/basesetting/produceplan';
import { getListQz, removeQz,saveQz,updateQz } from '@/api/basesetting/qinzhefgb';
import { mapGetters } from 'vuex';
import { exportBlob } from '@/api/common';
import { getToken } from '@/utils/auth';
import NProgress from 'nprogress';
import { downloadXls } from '@/utils/util';
export default {
    name: 'ProducePlan',
    data() {
        return {
            activeName: "zhuzhi",
            // Define your data properties here
            excelOption: {
                submitBtn: false,
                emptyBtn: false,
                column: [
                    {
                        label: '文件导入',
                        prop: 'file',
                        type: 'upload',
                        drag: true,
                        loadText: '导入中,请稍后',
                        span: 24,
                        propsHttp: {
                            res: 'data',
                        },
                        data: {
                        },
                        tip: '',
                        action: '/blade-mdm/producedivision/import-division',
                    },
                ],
            },
            excelOptionQz: {
                submitBtn: false,
                emptyBtn: false,
                column: [
                    {
                        label: '文件导入',
                        prop: 'file',
                        type: 'upload',
                        drag: true,
                        loadText: '导入中,请稍后',
                        span: 24,
                        propsHttp: {
                            res: 'data',
                        },
                        data: {
                        },
                        tip: '',
                        action: '/blade-mdm/producedivision/import-qinzhe',
                    },
                ],
            },
            excelForm: {
                fileType: 'program',
                excelFile: [],
            },
            excelBox: false,
            excelBoxQz: false,
            option: {
                // Define your Avue CRUD options here
                addBtn: true,
@@ -39,29 +130,15 @@
                delBtn: true,
                columnBtn: false,
                tip: false,
                // simplePage: true,
                searchShow: true,
                searchMenuSpan: 6,
                // tree: true,
                searchEnter:true,
                border: true,
                index: true,
                // selection: true,
                // viewBtn: true,
                menuWidth: 320,
                dialogWidth: 500,
                dialogClickModal: false,
                column: [
                    // {
                    //     label: '程序名称',
                    //     prop: 'programName',
                    //     type: 'input',
                    //     search: false,
                    //     searchRange: true,
                    //     searchSpan: 8,
                    //     hide: true,
                    //     span: 24,
                    //     rules: [{ required: true, message: '请输入程序名称', trigger: 'blur' }],
                    // },
                    {
                        label: '人员名称',
                        prop: 'name',
@@ -72,30 +149,14 @@
                        hide: true,
                        display: false,
                    },
                    // {
                    //     label: '序号',
                    //     prop: 'index',
                    //     type: 'index',
                    // },
                    {
                        label: '专业组长',
                        prop: 'teamLeaderId',
                        type: 'select',
                        span: 24,
                        display: true,
                        dicUrl: `/blade-mdm/flow/flow-user-list?deptId=0`,
                        props: {
                            label: 'name',
                            value: 'id',
                        },
                        rules: [{ required: true, message: '请输入专业组长', trigger: 'blur' }],
                    },
                    {
                        label: '编制(工艺员)',
                        label: '编制',
                        prop: 'programmerId',
                        type: 'select',
                        display: true,
                        filterable:true,
                        span: 24,
                        dicUrl: `/blade-mdm/flow/flow-user-list?deptId=0`,
                        props: {
@@ -110,6 +171,7 @@
                        prop: 'checkerId',
                        type: 'select',
                        display: true,
                        filterable:true,
                        span: 24,
                        dicUrl: `/blade-mdm/flow/flow-user-list?deptId=0`,
                        props: {
@@ -119,10 +181,25 @@
                        rules: [{ required: true, message: '请输入校对(工艺员)', trigger: 'blur' }],
                    },
                    {
                        label: '专业组长',
                        prop: 'teamLeaderId',
                        type: 'select',
                        span: 24,
                        display: true,
                        filterable:true,
                        dicUrl: `/blade-mdm/flow/flow-user-list?deptId=0`,
                        props: {
                            label: 'name',
                            value: 'id',
                        },
                        rules: [{ required: true, message: '请输入专业组长', trigger: 'blur' }],
                    },
                    {
                        label: '审核(高师)',
                        label: '审核',
                        prop: 'seniorId',
                        type: 'select',
                        filterable:true,
                        display: true,
                        span: 24,
                        dicUrl: `/blade-mdm/flow/flow-user-list?deptId=0`,
@@ -132,6 +209,7 @@
                        },
                        rules: [{ required: true, message: '请输入审核(高师)', trigger: 'blur' }],
                    },
                    // Add more columns as needed
                ],
@@ -145,10 +223,80 @@
            },
            form: {}, // This will hold the form data
            query: {}, // This will hold the search query
            //勤哲页面数据
            dataQz:[],
            loadingQz:false,
            pageQz: {
                pageSize: 10,
                currentPage: 1,
                total: 0,
            },
            queryQz: {},
            optionQz: {
                addBtn: false,
                editBtn: true,
                delBtn: true,
                columnBtn: false,
                tip: false,
                searchShow: true,
                searchMenuSpan: 6,
                searchEnter:true,
                border: true,
                index: true,
                menuWidth: 320,
                dialogWidth: 500,
                dialogClickModal: false,
                column: [
                    {
                        label: '产品号',
                        prop: 'cph',
                        type: 'input',
                        display: true,
                        span: 24,
                    },
               {
                        label: '零组件号',
                        prop: 'ljh',
                        type: 'input',
                        search: true,
                        display: true,
                        span: 24,
                    },
                    {
                        label: '主管工艺',
                        prop: 'zggy',
                        type: 'input',
                        search: true,
                        display: true,
                        span: 24
                    },
                    {
                        label: '数据来源',
                        prop: 'source',
                        type: 'input',
                        search: false,
                        display: false,
                        span: 24,
                  render: ({ row}) => {
                            console.log('val',row)
                            if(row.source == 'MDM'){
                                return "MDM"
                            }else{
                                return "勤哲"
                            }
                        }
                    }
                ],
            },
        };
    },
    methods: {
        // Define your methods here
        tabsClick(tab,event) {
            //console.log('tab',tab)
            this.onLoad(this.page, this.query);
        },
        searchChange(params, done) {
            this.query = params;
            this.page.currentPage = 1;
@@ -186,7 +334,54 @@
        },
        importAction() {
            // Logic for importing data
            this.$message.success('导入功能尚未实现');
            // this.$message.success('导入功能尚未实现');
            this.excelBox = true;
        },
        importActionQz() {
            // Logic for importing data
            // this.$message.success('导入功能尚未实现');
            this.excelBoxQz = true;
        },
        uploadAfter(res, done, loading, column) {
            //window.console.log(column);
            //console.log('res',res)
            if(res.success>0){
                //有成功的,关闭对话框
                this.excelBox = false;
                this.$message.success(res.message);
                this.onLoad(this.page);
                //done();
            }else{
                //0成功的,仅提示
                this.$message.success(res.message);
            }
        },
        uploadAfterQz(res, done, loading, column) {
            //window.console.log(column);
           this.$message.success('导入完成');
           this.excelBoxQz = false;
            this.onLoadQz(this.pageQz);
        },
      downTemplateAction() {
            NProgress.start();
            exportBlob(
                `/blade-mdm/producedivision/download-template`
            ).then(res => {
                downloadXls(res.data, `主制分工表导入模版.xlsx`);
                NProgress.done();
            });
        },
        downTemplateActionQz() {
            NProgress.start();
            exportBlob(
                `/blade-mdm/producedivision/download-template-qz`
            ).then(res => {
                downloadXls(res.data, `勤哲分工表导入模版.xlsx`);
                NProgress.done();
            });
        },
        rowDel(row) {
            this.$confirm('确定将选择数据删除?', {
@@ -199,6 +394,23 @@
                })
                .then(() => {
                    this.onLoad(this.page);
                    this.$message({
                        type: 'success',
                        message: '操作成功!',
                    });
                });
        },
        rowDelQz(row) {
            this.$confirm('确定将选择数据删除?', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
            })
                .then(() => {
                    return removeQz({ljhs: [row.ljh].toString()});
                })
                .then(() => {
                    this.onLoadQz(this.pageQz);
                    this.$message({
                        type: 'success',
                        message: '操作成功!',
@@ -219,27 +431,87 @@
                    },
                    error => {
                      window.console.log(error);
                      loading();
                      //loading();
                      loadingZq();
                    }
                  );
        },
        rowUpdateQz (row, index, done, loading) {
            console.log('rowUpdateQz', row);
            updateQz(row).then(
                    () => {
                      this.onLoadQz(this.pageQz);
                      this.$message({
                        type: 'success',
                        message: '操作成功!',
                      });
                      done();
                    },
                    error => {
                      window.console.log(error);
                      //loading();
                      loadingZq();
                    }
                  );
        },
        save (row, done, loading) {
            console.log('save', row);
            save(row).then(
                () => {
                this.onLoad(this.page);
                this.$message({
                    type: 'success',
                    message: '操作成功!',
                });
                done();
                (res) => {
               if(res.data.code !== 200) {
                  this.$message.error(res.data.msg);
                        loading()
                  //done();//关闭窗口
                  return;
               }
               this.onLoad(this.page);
               this.$message({
                  type: 'success',
                  message: '操作成功!',
               });
               done();
                },
                error => {
                loading();
                window.console.log(error);
               loading();
               window.console.log(error);
                }
            );
        }
        },
        sizeChangeQz() {
            this.pageQz.pageSize = pageSize;
        },
        searchChangeQz(params, done) {
            this.queryQz = params;
            this.pageQz.currentPage = 1;
            this.onLoadQz(this.pageQz, params);
            done();
        },
        searchResetQz() {
            this.queryQz = {};
            this.onLoadQz(this.pageQz);
        },
        currentChangeQz() {
            this.pageQz.currentPage = currentPage;
        },
        onLoadQz(page, params = {}) {
            const query = {
                ...this.queryQz,
                // category: params.category ? flowCategory(params.category) : null,
                mode: this.mode,
            };
            this.loadingQz = true;
            getListQz(page.currentPage, page.pageSize, Object.assign(params, query)).then(res => {
                const data = res.data.data;
                this.pageQz.total = data.total;
                this.dataQz = data.records;
                this.loadingQz = false;
            });
        },
        refreshChangeQz() {
            this.onLoadQz(this.pageQz, this.queryQz);
        },
    },
    mounted() {
        // Code to run when the component is mounted