yangys
2025-12-03 fdb0ed498f295b50c072c4b3652c08e2d60a747a
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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
<!--
 * @Date: 2025-08-10 14:23:00
 * @LastEditors: gaoshp
 * @LastEditTime: 2025-08-10 15:46:14
 * @FilePath: /mdmweb/src/views/flow/donelist.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" >
            <template #menu="scope">
                <el-button type="primary" text size="default" @click.stop="handleView(scope.row, scope.index)">查看</el-button>
                <el-button type="primary" :disabled="scope.row.processIsFinished==='true' || (scope.row.currentTaskKeys.toLowerCase().indexOf('program')==-1 &&  scope.row.currentTaskKeys.toLowerCase().indexOf('useable')==-1)" v-if="permission.takeback_button" text size="default" @click.stop="handleTakeBack(scope.row, scope.index)">取回</el-button>
                <el-button type="primary" :disabled="scope.row.processIsFinished==='true' || scope.row.currentTaskKeys.toLowerCase().indexOf('program')>-1" v-if="permission.withdraw_button" text size="default" @click.stop="handleWithdraw(scope.row, scope.index)">撤回</el-button>
            </template>
            
        </avue-crud>
        <el-dialog title="查看详情" v-model="dialogVisible" width="60%">
            <avue-form v-model="viewRow" :option="viewFormOption" readonly class="viewRowForm"></avue-form>
            <el-table :data="tableData" style="width: 100%">
                <el-table-column prop="assigneeName" label="执行人" />
                <el-table-column prop="taskName" label="任务名称" />
                <el-table-column prop="comment" label="批注" />
                <el-table-column prop="createTime" label="开始时间" />
                <el-table-column prop="endTime" label="完成时间" />
            </el-table>
        </el-dialog>
    </basic-container>
</template>
<script>
import { getDoneList,todoChangeNotify} from '@/api/flow/todolist';
import { mapGetters } from 'vuex';
export default {
    data() {
        return {
            tableData: [],
            query:{},
            viewFormOption: {
                emptyBtn: false,
                submitBtn: false,
                menuBtn: false,
                
                labelWidth: 100,
                span: 8,
                column: [
                   {
                        label: '流程名称',
                        prop: '',
                        render: ({ row }) => {
                            return h('p',{'class': 'margin0'}, row?.variables?.myProcessName)
                        }
                    },
                    {
                        label: '创建时间',
                        prop: 'createTime',
                        render: ({ row }) => {
                            return h('p',{'class': 'margin0'}, row?.createTime)
                        },
                    },
                    {
                        label: '标题',
                        prop: 'variables.title',
                        render: ({ row }) => {
                            return h('p',{'class': 'margin0'}, row?.variables?.title)
                        }
                    },
                    
                    {
                        label: '批次号',
                        prop: 'variables.craftEdition',
                        render: ({ row }) => {
                            return h('p',{'class': 'margin0'}, row?.variables?.craftEdition || '');
                        }
                    },
                    {
                        label: '工序号',
                        prop: 'processNo',
                        render: ({ row }) => {
                            return h('p',{'class': 'margin0'}, row?.variables?.processNo || '');
                        }
                    },
                    {
                        label: '工序名称',
                        prop: 'processName',
                        render: ({ row }) => {
                            return h('p',{'class': 'margin0'}, row?.variables?.processName || '');
                        }
                    },
                    {
                        label: '工序版次',
                        prop: 'processEdition',
                        render: ({ row }) => {
                            return h('p',{'class': 'margin0'}, row?.variables?.processEdition || '');
                        }
                    },
                    {
                        label: '零组件号',
                        prop: 'drawingNo',
                        render: ({ row }) => {
                            return h('p',{'class': 'margin0'}, row?.variables?.drawingNo || '');
                        }
                    },
                    {
                        label: '任务车间',
                        prop: 'workshop',
                        render: ({ row }) => {
                            return h('p',{'class': 'margin0'}, row?.variables?.workshop || '');
                        }
                    },
                    {
                        label: '过程卡号',
                        prop: '',
                        render: ({ row }) => {
                            return h('p',{'class': 'margin0'}, row?.variables?.processCard || '');
                        }
                    },
                    {
                        label: '图号',
                        prop: 'drawingNo',
                        render: ({ row }) => {
                            return h('p',{'class': 'margin0'}, row?.variables?.drawingNo)
                        }
                    },
                    {
                        label: '产品型号',
                        prop: 'productModel',
                        render: ({ row }) => {
                            return h('p',{'class': 'margin0'}, row?.variables?.productModel)
                        }
                    },                    
                    {
                        label: '机床',
                        prop: 'machineCode',
                        render: ({ row }) => {
                            return h('p',{'class': 'margin0'}, row?.variables?.machineCode)
                        }
                    },
                    {
                        label: '创建人',
                        prop: 'startUserName',
                        render: ({ row }) => {
                            return h('p',{'class': 'margin0'}, row?.startUserName)
                        }
                    },
                    {
                        label: '创建时间',
                        prop: 'processCreateTime',
                        render: ({ row }) => {
                            return h('p',{'class': 'margin0'}, row?.processCreateTime)
                        }
                    },
                    {
                        label: '当前节点',
                        prop: 'taskName',
                        render: ({ row }) => {
                            return h('p',{'class': 'margin0'}, row?.taskName)
                        }
                    },
                    {
                        label: '计划加工时间',
                        prop: 'planStartTime',
                        render: ({ row }) => {
                            return h('p',{'class': 'margin0'}, row?.variables?.planStartTime || '');
                        }
                    },
                    {
                        label: '程序包名',
                        prop: 'programPackageName',
                        render: ({ row }) => {
                            return h('p',{'class': 'margin0'}, row?.variables?.programPackageName || '');
                        }
                    },
                    {
                        label: '临时更改单号',
                        prop: '',
                        render: ({ row }) => {
                            return h('p',{'class': 'margin0'}, row?.variables?.deviation || '');
                        }
                    },
                ],
            },
            viewRow: {},
            dialogVisible: false,
            loading: false,
            option: {
                rowKey: "taskId",
                addBtn: false,
                editBtn: false,
                delBtn: false,
                columnBtn: false,
                tip: false,
                searchShow: true,
                searchEnter:true,
                searchMenuSpan: 6,
                dialogWidth: '60%',
                border: true,
                index: true,
                selection: false,
                // viewBtn: true,
                menu: true,
                menuWidth: 120,
                column: [
                    {
                        label: '关键字',
                        prop: 'keyword',
                        width: 300,
                        search: true,
                        searchType: 'input',
                        hide: true,
                    },
                    {
                        label: '状态',
                        prop: 'status',
                        hide: true,
                        search: true,
                        type: 'select',
                        dicData: [
                            {
                                label:'进行中',
                                value:'1'
                            },
                            {
                                label:'已结束',
                                value:'2'
                            },
                        ],
                        labelKey: 'label', 
                       
                        span: "8"
                    },
                    {
                        label: '标题',
                        prop: '',
                        width: 200,
                        render: ({ row }) => {
                            return h('p',
                                {
                                    attrs: {},
                                    class: {},
                                    style: {},
                                }, row?.variables?.title)
                        }
                    },
                    {
                        label: '流程名称',
                        prop: '',
                        width: 100,
                        render: ({ row }) => {
                            return h('p',
                                {
                                    attrs: {},
                                    class: {},
                                    style: {},
                                }, row?.variables?.myProcessName)
                        }
                    },/*
                    {
                        label: '流程类型',
                        width: 100,
                        prop: 'categoryName',
                    },*/
 
                    {
                        label: '机床',
                        width: 100,
                        prop: '',
                        formatter: (val, value, label) => {
                            return `${val?.variables?.machineCode}`;
                        },
                    },
                    {
                        label: '创建人',
                        width: 100,
                        prop: 'startUserName',
                    },
                    {
                        label: '创建时间',
                        width: 100,
                        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: 100,
                        prop: 'createTime',
                        type: 'datetime',
                        format: 'YYYY-MM-DD HH:mm:ss',
                        valueFormat: 'YYYY-MM-DD HH:mm:ss',
                        search: false,
                        searchRange: true,
                        searchSpan: 8,
                        // hide: true,
                    },
                    {
                        label: '结束时间',
                        width: 100,
                        prop: 'endTime',
                        type: 'datetime',
                        format: 'YYYY-MM-DD HH:mm:ss',
                        valueFormat: 'YYYY-MM-DD HH:mm:ss',
                        sortable:true,
                        search: false,
                        searchRange: true,
                        searchSpan: 8,
                        // hide: true,
                    },
                    {
                        label: '任务名称',
                        width: 100,
                        prop: 'taskName',
                    },
                    {
                        label: '文件',
                        width: 200,
                        prop: 'file',
                         showOverflowTooltip:true,
                    },
                ],
            },
            page: {
                page: 1,
                size: 10,
                total: 0,
            },
            form: {},
            data: [],
        }
    },
    methods: {
        handleView(row) {
            console.log(row,1111)
            this.viewRow = {...row};
            axios({
                url: '/blade-mdm/flow/mgr/process-trace',
                method: 'get',
                params: {processInstanceId: row.processInstanceId}
            }).then(
              res => {
                this.tableData = res.data.data;
            });
            this.dialogVisible = true;
        },
        handleTakeBack(row){
            //组长取回
            this.$confirm('确认要取回吗?', '', {
                    confirmButtonText: this.$t('submitText'),
                    cancelButtonText: this.$t('cancelText'),
                    type: 'warning',
                }).then(() => {
                    axios({
                        url: '/blade-mdm/flow/mgr/takeback',
                        method: 'get',
                        params: {processInstanceId: row.processInstanceId}
                    }).then(res => {
                        if(res.data.code !== 200) {
                            this.$message.error(res.data.msg);
                            return;
                        }
                        this.$message.success('操作成功');
                        
                        todoChangeNotify();
                        
                        this.refreshChange();
                    }).catch(err => {
                        console.error(err);
                        //done()
                    });
                    
                }).catch(() => {
                    console.log('>>>>>>')
                    // this.$message.info('已取消操作');
                    //done();
                });
        },
        handleWithdraw(row) {
            //console.log(row,row.processInstanceId)
            this.$confirm('确认要撤回吗?', '', {
                    confirmButtonText: this.$t('submitText'),
                    cancelButtonText: this.$t('cancelText'),
                    type: 'warning',
                }).then(() => {
                    axios({
                        url: '/blade-mdm/flow/mgr/withdraw',
                        method: 'get',
                        params: {processInstanceId: row.processInstanceId}
                    }).then(res => {
                        if(res.data.code !== 200) {
                            this.$message.error(res.data.msg);
                            return;
                        }
                        this.$message.success('操作成功');
                        
                        todoChangeNotify();
                        
                        this.refreshChange();
                    }).catch(err => {
                        console.error(err);
                        //done()
                    });
                    
                }).catch(() => {
                    console.log('>>>>>>')
                    // this.$message.info('已取消操作');
                    //done();
                });
        },
        currentChange(currentPage) {
            this.page.currentPage = currentPage;
        },
        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] || '';
 
            data = {
                createTimeBegin: params.createTimeBegin,
                createTimeEnd: params.createTimeEnd,
                keyword: params.keyword || '',
                status: params.status || 0
            }
            this.query = data
            this.onLoad(this.page, data);
            done();
        },
        searchReset () {
            this.form = {};
            this.getDoneList();         
        },
        sizeChange() {
           
            this.getDoneList(); 
        },
        refreshChange() {
            this.onLoad(this.page, this.query);
        },
        onLoad(page, params = {},done) {
            const query = {
                ...this.query,
                // category: params.category ? flowCategory(params.category) : null,
            };
            try {
                delete query.processCreateTime; // 删除不必要的查询条件
            } catch (error) {
                console.error('日期格式化错误', error);
            }
 
            //this.loading = true;
            getDoneList(page.currentPage, page.pageSize, Object.assign(query, params)).then(res => {
                const data = res.data.data;
                this.page.total = data.total;
                this.data = data.records;
                this.loading = false;
                if(done){
                    done();
                }
            });
        },
        
    },
    computed: {
       
        ...mapGetters(['userInfo', 'permission']),
    }
}
</script>
<style lang="scss">
.margin0 {
    margin: 0
}
.viewRowForm .el-form-item--default {
    margin-bottom: 0
}
</style>