yangys
2025-09-17 ae2c3f847da927b6124e872d8d74c0457a1eea14
src/views/flow/todolist.vue
@@ -1,6 +1,7 @@
<template>
    <basic-container>
        <avue-crud :option="option" :table-loading="loading" :data="data" v-model:page="page" v-model="form" ref="crud"
            :search="query"
            @search-change="searchChange" @search-reset="searchReset" @current-change="currentChange"
            @size-change="sizeChange" @refresh-change="refreshChange" @on-load="onLoad"
            @selection-change="selectionTransferTask">
@@ -13,17 +14,25 @@
                <el-button type="primary" :disabled="this.transferTaskSelection.length==0" plain @click="reassign(0)">转派</el-button>
                <el-button type="primary" :disabled="this.transferTaskSelection.length==0" v-if="permission.batch_approve" plain @click="reassign(3)">批量审批
                </el-button>
                <el-button type="primary" :disabled="this.transferTaskSelection.length==0" v-if="permission.batch_on_machine" plain @click="showBatchOnMachine()">现场编制
                </el-button>
            </template>
            <template #menu="scope">
                <el-button type="primary" text size="default" @click.stop="handleAction(scope.row, scope.index)">
                    {{approveButtonText(scope.row.taskDefinitionKey)}}
                </el-button>
            </template>
        </avue-crud>
        <el-dialog title=" " append-to-body v-model="reassignBox" width="30%">
            <avue-form ref="reassginform" :option="reassignOption" v-model="reassignForm" @submit="toPerson"></avue-form>
        </el-dialog>
        <el-drawer title="审批" append-to-body v-model="approveBox" size="100%" v-if="approveBox">
        <el-dialog title="现场编制" append-to-body v-model="onMachineBox" width="30%">
            <avue-form :option="onMachineOption" v-model="onMachineForm" @submit="batchOnMachine"></avue-form>
        </el-dialog>
        <div  class="box-drawer">
        <el-drawer title="审批" append-to-body v-model="approveBox" size="100%" v-if="approveBox" class="remark-drawer">
            <div class="approve-box">
                <div class="left">
                    <TodolistLeft ref="todolistLeft" :row="row" @selection-change="selectionChange" />
@@ -48,10 +57,11 @@
                </div>
            </div>
        </el-drawer>
        </div>
    </basic-container>
</template>
<script>
import { getList, approve, getAssignee,getAssigneeTree,reassgin,manualDispatch,autoDispatch,todoChangeNotify,batchApprove } from '@/api/flow/todolist';
import { getList, approve, getAssignee,getAssigneeTree,reassgin,manualDispatch,autoDispatch,todoChangeNotify,batchApprove, batchApproveOnMachine } from '@/api/flow/todolist';
import { mapGetters } from 'vuex';
import dayjs from 'dayjs';
import TodolistLeft from './components/TodolistLeft.vue';
@@ -143,7 +153,12 @@
                total: 0,
            },
            form: {},
            query: {},
            query: {
                machineSpec: ['1','2']
            },
            defaultQuery: {
                machineSpec: ['1','2']
            },
            loading: true,
            option: {
                rowKey: "taskId",
@@ -154,7 +169,7 @@
                tip: false,
                searchEnter:true,
                searchShow: true,
                searchMenuSpan: 6,
                searchMenuSpan: 4,
                dialogWidth: '60%',
                border: true,
                index: true,
@@ -166,7 +181,7 @@
                    {
                        label: '关键字',
                        prop: 'keyword',
                        width: 300,
                        width: 200,
                        search: true,
                        searchType: 'input',
                        hide: true,
@@ -178,6 +193,27 @@
                            {
                                label: '工控网车床程序',
                                value: 2,
                            },
                        ],
                    },
                    {
                        label: '机床类型',
                        prop: 'machineSpec',
                        width: 200,
                        search: true,
                        searchType: 'select',
                        multiple:true,
                        clearable:false,
                        hide: true,
                        emptyValues :["1",'2'],
                        dicData: [
                            {
                                label: '车床',
                                value: '1',
                            },
                            {
                                label: '加工中心',
                                value: '2',
                            },
                        ],
                    },
@@ -347,7 +383,52 @@
                    },
                ],
            },
            reassignForm: {}
            reassignForm: {},
            onMachineBox: false,//现场编制框
            onMachineForm: {},
            onMachineOption: {
                submitBtn: true,
                emptyBtn: false,
                column: [
                    {
                        label: '审批结果',
                        prop: 'approve',
                        type: 'radio',
                        span: 24,
                        display: false,
                        dicData: [
                            { label: '通过', value: 'Y' },
                            { label: '驳回', value: 'N' },
                        ],
                        rules: [{ required: true, message: '请选择审批结果', trigger: 'blur' }],
                    },
                    {
                        label: '发送给',
                        prop: 'assignee',
                        component: 'elTreeSelect',
                        params: {
                            props:{
                                label: 'name',
                                value:'id',
                                disabled: (data) => data.nodeType==='dept',
                                isLeaf: (data) => data.children==null || data.children.length==0,
                            },
                        },
                        display: true,
                        filterable: true,
                        span: 24,
                        disabled: false,
                        rules: [{ required: true, message: '请输入选择', trigger: 'blur' }],
                    },
                    {
                        label: '备注',
                        span: 24,
                        prop: 'comment',
                        type: 'textarea',
                    },
                ],
            },
        };
    },
    watch: {
@@ -407,6 +488,7 @@
                
                this.optionApprove.column[1].data = this.assigneeData;
                this.reassignOption.column[1].data = this.assigneeData;
                this.onMachineOption.column[1].data = this.assigneeData;
             });
    },
    methods: {
@@ -629,8 +711,41 @@
                }
            }
            
        },
        showBatchOnMachine(){//显示现场编制对话框
            this.onMachineBox = true;
            this.onMachineForm.assignee = this.transferTaskSelection[0].variables.checker;
        },
        batchOnMachine() {//编制批量处理(现场编制)
            this.$confirm('请确认是否将选定任务设置为现场编制?', '', {
                confirmButtonText: this.$t('submitText'),
                cancelButtonText: this.$t('cancelText'),
                type: 'warning',
            }).then(() => {
                batchApproveOnMachine({
                    taskIds: this.transferTaskSelection.map(v => v.taskId),
                    processInstanceIds: this.transferTaskSelection.map(v => v.processInstanceId),
                    assignee: this.onMachineForm.assignee,
                }).then(res => {
                    if(res.data.code !== 200) {
                        this.$message.error(res.data.msg);
                        return;
                    }
                    this.$message.success('操作成功');
                    this.onMachineBox = false;
                    this.onLoad(this.page, this.query);
                    todoChangeNotify();
                }).catch(err => {
                    this.$message.success('操作失败');
                })
            }).catch(() => {
                // this.$message.info('已取消操作');
            });
        },
        toPerson(form, done) {
            let tip = ''
            this.reassignType === 1 ? tip = '请确认是否手动派工' : this.reassignType === 2 ? tip = '请确认是否自动派工' : tip = '请确认是否重新指派';
@@ -768,16 +883,35 @@
            this.setApproveBtn(row);
            //console.log('handleAction', row, index);
        },
        handleSubmit(form, done) {
            //this.$alert(this.$refs.todolistLeft.programOnMachine)
            //done();
            //return;
        async handleSubmit(form, done) {
            let programOnMachine = 'N'
            if(this.row.taskDefinitionKey==='programmingTask'){
            let goApprove = true;
            if(this.row.taskDefinitionKey==='programmingTask' || this.row.taskDefinitionKey==='cureProgramTask'){
                programOnMachine = this.$refs.todolistLeft.programOnMachine?'Y':'N';
                let atts = this.$refs.todolistLeft.tableData;
                let otherFileCOunt = atts.filter(att => att.program === false).length;
                if(otherFileCOunt == 0){
                    let confirResult = await this.$confirm('文件列表中无其他文件,确认要提交吗?', '', {
                        confirmButtonText: this.$t('submitText'),
                        cancelButtonText: this.$t('cancelText'),
                        type: 'warning',
                    }).then(()=>{
                        goApprove = true;
                    }).catch(action => {
                        //取消操作
                        goApprove = false;
                    });
                }
            }
            if(goApprove == false){
                done();
                return;
            }
            approve({
                ...this.formApprove,
                taskId: this.row.taskId,
@@ -804,6 +938,7 @@
            let data = {}
            this.query = params;
            this.page.currentPage = 1;
            /*
            console.log('searchChange', params);
            params.createTimeBegin = params?.processCreateTime?.[0] || '';
            params.createTimeEnd = params?.processCreateTime?.[1] || '';
@@ -813,11 +948,12 @@
                keyword: params.keyword || ''
            }
            this.query = data
            this.onLoad(this.page, data);
            */
            this.onLoad(this.page, {});
            done();
        },
        searchReset() {
            this.query = {};
            this.query = this.defaultQuery;
            this.onLoad(this.page);
        },
        currentChange(currentPage) {
@@ -833,7 +969,6 @@
        onLoad(page, params = {}) {
            const query = {
                ...this.query,
                // category: params.category ? flowCategory(params.category) : null,
                mode: this.mode,
            };
            try {
@@ -841,7 +976,9 @@
            } catch (error) {
                console.error('日期格式化错误', error);
            }
             console.log('params',params);
            console.log('q',query);
            console.log('thisq',this.query);
            this.loading = true;
            getList(page.currentPage, page.pageSize, Object.assign(query, params)).then(res => {
                const data = res.data.data;
@@ -857,7 +994,19 @@
};
</script>
<style lang="scss">
.remark-drawer  {
    .el-drawer__header {
        padding-top:5px;
      margin-bottom: 0px !important;
    }
    .el-drawer__body{
        padding-top:5px;
    }
}
</style>
<style scoped="scoped" lang="scss">
.approve-box {
    display: flex;