gaoshp
2025-08-06 7acbfc9ec91fc7cc6f0f57541331900165311bf5
src/views/flow/todolist.vue
@@ -9,8 +9,7 @@
                </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 type="primary" text size="default" @click.stop="handleAction(scope.row, scope.index)">审批
                </el-button>
            </template>
        </avue-crud>
@@ -44,13 +43,15 @@
    },
    data() {
        return {
            applist: [],
            assigneeData: [],
            row: {},
            approveBox: false,
            formApprove: {
                comment: '',
                approve: '', // 默认同意
                approve: 'Y', // 默认同意
                assignee: ''
            },
            optionApprove: {
                labelWidth: 100,
@@ -77,6 +78,7 @@
                            label: 'name',
                            value: 'id',
                        },
                        filterable: true,
                        span: 24,
                        disabled: false,
                        dicData: [
@@ -89,7 +91,20 @@
                        span: 24,
                        prop: 'comment',
                        type: 'textarea',
                        rules: [{ required: true, message: '请输入审批意见', trigger: 'blur' }],
                        // rules: [{ required: true, message: '请输入审批意见', trigger: 'blur' }],
                        rules: [
                            {
                            validator: (rule, value, callback) => {
                                console.log('-------',this.formApprove)
                                if (value === '' && this.formApprove.approve !== 'Y') {
                                    callback(new Error('请输入备注'));
                                } else {
                                    callback();
                                }
                            },
                            trigger: 'blur'
                            }
                        ]
                    },
                ],
            },
@@ -102,6 +117,7 @@
            query: {},
            loading: true,
            option: {
                rowKey: "taskId",
                addBtn: false,
                editBtn: false,
                delBtn: false,
@@ -137,16 +153,29 @@
                            },
                        ],
                    },
               {
                        label: '标题',
                        prop: '',
                        width: 100,
                  render: ({ row }) => {
                            return h('p',
                                {
                                    attrs: {},
                                    class: {},
                                    style: {},
                                }, row?.variables?.title)
                        }
                    },
                    {
                        label: '任务名称',
                        label: '流程名称',
                        prop: 'processDefinitionName',
                        width: 100,
                    },
                    },/*
                    {
                        label: '流程类型',
                        width: 100,
                        prop: 'categoryName',
                    },
                    },*/
                    {
                        label: '机床',
@@ -189,7 +218,7 @@
                    {
                        label: '文件',
                        width: 200,
                        prop: '',
                        prop: 'file',
                    },
                    {
                        label: '到达时间',
@@ -253,11 +282,14 @@
        //     });
        // },
        'formApprove.approve'(val) {
            if (val === 'Y' && this.row.taskDefinitionKey === 'approveTask') {
            if (val === 'Y' && ["approveTask", 'seniorApproveTask'].includes(this.row.taskDefinitionKey)) {// 高师
                this.optionApprove.column[1].disabled = true;
                this.formApprove.assignee = ''; // 如果是通过,则默认指派给自己
            } else {
                this.optionApprove.column[1].disabled = false;
            } else if(val === 'Y'){
               this.setAssignee(this.row);
            } else if(val === 'N') {
                this.formApprove.assignee = ''
                // this.formApprove.assignee = row.variables.senior;
            }
        },
    },
@@ -310,45 +342,62 @@
                    this.reassignBox = false;
                    this.$refs?.reassginform?.resetForm();
                    this.onLoad(this.page, this.query);
                    done()
                }).catch(err => {
                    console.error(err);
                    done()
                })
            });
            done();
        },
        handleAction(row, index) {
            this.formApprove = {
                comment: '',
                approve: '', // 默认同
            }
            this.approveBox = true;
            this.row = row
            if (row.taskDefinitionKey == "check") {
        setAssignee (row) {
             if (["check", 'cureCheckTask '].includes(row.taskDefinitionKey)) {// 校对
                this.formApprove.assignee = row.variables.senior;
            } else if (row.taskDefinitionKey == "programmingTask") {
            } else if (["programmingTask",'cureProgramTask'].includes(row.taskDefinitionKey)) {// 编制,校对
                this.formApprove.assignee = row.variables.checker;
            } else if (row.taskDefinitionKey == "teamLeaderTask") {
                this.formApprove.assignee = row.variables.programmer
            } else if (row.taskDefinitionKey == "confirmIsUseableTask") {
                this.formApprove.assignee = row.variables.checker
            } else if (row.taskDefinitionKey == "approveTask") {
            } else if (["approveTask", 'seniorApproveTask'].includes(row.taskDefinitionKey)) {// 高师审核
            }
        },
        handleAction(row, index) {
            this.formApprove = {
                comment: '',
                approve: 'Y', // 默认同
            }
            this.approveBox = true;
            this.row = row
            this.setAssignee(row);
            console.log('handleAction', row, index);
        },
        handleSubmit(form, done) {
            if(this.row.taskDefinitionKey === 'programmingTask') {
                // if(this.applist.length !== 1) {
                //     done();
                //     return this.$message.success('请选择1个程序');
                // }
            }
            approve({
                ...this.formApprove,
                taskId: this.row.taskId,
                processInstanceId: this.row.processInstanceId,
                programIds: this.row.taskDefinitionKey === 'programmingTask' ? this.applist.map(v => v.id).join(',') : '',
                // programIds: this.row.taskDefinitionKey === 'programmingTask' ? this.applist.map(v => v.id).join(',') : '',
            }).then(res => {
                if(res.data.code !== 200) {
                    this.$message.error(res.data.msg);
                    done();
                    return;
                }
                this.$message.success('审批成功');
                this.approveBox = false;
                this.onLoad(this.page, this.query);
                done();
            }).catch(err => {
                done();
                console.error(err);
            });
        },