gaoshp
2025-06-17 613d624e36041c24b94d4cbe692f8217a15c54fd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
<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">
            <template #menu-left>
                <el-button type="primary" plain @click="reassign">重新指派
                </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-dialog title="审批" append-to-body v-model="approveBox" width="20%">
            <avue-form ref="form" :option="optionApprove" v-model="formApprove" @submit="handleSubmit" />
            <!-- <template #footer>
                <span class="dialog-footer">
                    <el-button @click="deployBox = false">取 消</el-button>
                    <el-button type="primary" @click="handleDoDeploy" :loading="deployLoading">确 定</el-button>
                </span>
            </template> -->
        </el-dialog>
    </basic-container>
</template>
 
<script>
import { getList, approve,getAssignee } from '@/api/flow/todolist';
import { mapGetters } from 'vuex';
 
export default {
    data() {
        return {
            assigneeData: [],
            row: {},
            approveBox: false,
            formApprove: {
                comment: '',
                approve: '', // 默认同意
            },
            optionApprove: {
                labelWidth: 100,
                column: [
 
                    {
                        label: '审批结果',
                        prop: 'approve',
                        type: 'radio',
                        span: 24,
                        dicData: [
                            { label: '通过', value: 'Y' },
                            { label: '驳回', value: 'N' },
                        ],
                        rules: [{ required: true, message: '请选择审批结果', trigger: 'blur' }],
                    },
                    {
                        label: '下一审批用户',
                        prop: 'assignee',
                        type: 'select',
                        // dicUrl: `/blade-mdm/flow/flow-user-list?deptId=0`,
                        // dicFlag: true,
                        props: {
                            label: 'name',
                            value: 'id',
                        },
                        span: 24,
                        disabled: false,
                        dicData: [
                            
                        ],
                        // rules: [{ required: true, message: '请选择下一审批用户', trigger: 'blur' }],
                    },
                    {
                        label: '备注',
                        span: 24,
                        prop: 'comment',
                        type: 'textarea',
                        rules: [{ required: true, message: '请输入审批意见', trigger: 'blur' }],
                    },
                ],
            },
            page: {
                pageSize: 10,
                currentPage: 1,
                total: 0,
            },
            form: {},
            query: {},
            loading: true,
            page: {
                pageSize: 10,
                currentPage: 1,
                total: 0,
            },
            option: {
                addBtn: false,
                editBtn: false,
                delBtn: false,
                columnBtn: false,
                tip: false,
                // simplePage: true,
                searchShow: true,
                searchMenuSpan: 6,
                dialogWidth: '60%',
                // tree: true,
                border: true,
                index: true,
                // selection: true,
                // viewBtn: true,
                menuWidth: 100,
                dialogClickModal: false,
 
                column: [
                    {
                        label: '关键字',
                        prop: 'keyword',
                        width: 300,
                        search: true,
                        searchType: 'input',
                        hide: true,
                        dicData: [
                            {
                                label: '涉密网程序',
                                value: 1,
                            },
                            {
                                label: '工控网车床程序',
                                value: 2,
                            },
                        ],
                    },
                    {
                        label: '任务名称',
                        prop: 'taskName',
                        width: 100,
                    },
                    {
                        label: '流程类型',
                        width: 100,
                        prop: 'processDefinitionName',
                    },
                    
                    {
                        label: '机床',
                        width: 100,
                        prop: '',
                        formatter: (val, value, label) => {
                            return `${val?.variables?.machineCode}`;
                        },
                    },
                    {
                        label: '创建人',
                        width: 100,
                        prop: 'startUserName',
                    },
                    {
                        label: '创建时间',
                        width: 200,
                        prop: 'processCreateTime',
                        type: 'datetime',
                        format: 'YYYY-MM-DD HH:mm:ss',
                        valueFormat: 'YYYY-MM-DD HH:mm:ss',
                        search: true,
                        searchRange: true,
                        searchSpan: 8,
                        // hide: true,
                    },
                    {
                        label: '到达时间',
                        width: 200,
                        prop: 'createTime',
                    },
                    {
                        label: '到达描述',
                        width: 200,
                        prop: 'comment',
                    },
                    {
                        label: '文件',
                        width: 200,
                        prop: '',
                    },
                    {
                        label: '当前节点',
                        prop: '',
                    },
 
                ],
            },
            data: [],
        };
    },
    watch: {
        // 'form.category'() {
        //     const category = func.toInt(this.form.category);
        //     this.$refs.crud.option.column.filter(item => {
        //         if (item.prop === 'path') {
        //             item.rules[0].required = category === 1;
        //         }
        //         if (item.prop === 'isOpen') {
        //             item.disabled = category === 2;
        //         }
        //     });
        // },
        'formApprove.approve'(val) {
            if (val === 'Y' && this.row.taskDefinitionKey === 'approveTask') {
                this.optionApprove.column[1].disabled = true;
                this.formApprove.assignee = ''; // 如果是通过,则默认指派给自己
            } else {
                this.optionApprove.column[1].disabled = false;
            }
        },
    },
    computed: {
        ...mapGetters(['userInfo', 'permission']),
        // permissionList() {
        //     return {
        //         addBtn: this.validData(this.permission.menu_add, false),
        //         viewBtn: this.validData(this.permission.menu_view, false),
        //         delBtn: this.validData(this.permission.menu_delete, false),
        //         editBtn: this.validData(this.permission.menu_edit, false),
        //     };
        // },
    },
    mounted() {
        getAssignee().then(res=> {
            this.assigneeData = res.data.data;
            this.optionApprove.column[1].dicData = this.assigneeData;
        })
    },
    methods: {
        handleAction(row, index) {
            this.formApprove = {
                comment: '',
                approve: '', // 默认同
            }
            this.approveBox = true;
            this.row = row
            if(row.taskDefinitionKey=="check") {
                this.formApprove.assignee = row.variables.senior;
            } else if(row.taskDefinitionKey=="programmingTask") {
                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") {
 
            }
            console.log('handleAction', row, index);
        },
        handleSubmit(form, done) {
            approve({
                ...this.formApprove,
                taskId: this.row.taskId,
                processInstanceId: this.row.processInstanceId,
            }).then(res => {
                this.$message.success('审批成功');
                this.approveBox = false;
                this.onLoad(this.page, this.query);
                done();
            }).catch(err => {
                console.error(err);
            });
        },
        reassign() {// 重新指派
 
        },
        searchChange(params, done) {
            let data = {}
            this.query = params;
            this.page.currentPage = 1;
            console.log('searchChange', params);
            params.createTimeBegin = params?.processCreateTime?.[0] || '';
            params.createTimeEnd = params?.processCreateTime?.[1] || '';
            console.log(params);
            data = {
                createTimeBegin: params.createTimeBegin,
                createTimeEnd: params.createTimeEnd,
                keyword: params.keyword || ''
            }
            this.onLoad(this.page, data);
            done();
        },
        searchReset() {
            this.query = {};
            this.onLoad(this.page);
        },
        currentChange(currentPage) {
            this.page.currentPage = currentPage;
        },
        sizeChange(pageSize) {
            this.page.pageSize = pageSize;
        },
        refreshChange() {
            this.onLoad(this.page, this.query);
        },
 
        onLoad(page, params = {}) {
            const query = {
                ...this.query,
                // category: params.category ? flowCategory(params.category) : null,
                mode: this.mode,
            };
            delete query.processCreateTime; // 删除不必要的查询条件
            this.loading = true;
            getList(page.currentPage, page.pageSize, Object.assign(params, query)).then(res => {
                const data = res.data.data;
                this.page.total = data.total;
                this.data = data.records;
                this.loading = false;
            });
        },
    },
};
</script>
 
<style></style>