qq_41295110
2026-01-13 c466006a64f1cbbcbf04e0ae4a2d73de302aa92a
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
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
<template>
    <div style="padding:12px">
        <el-card>
            <el-form :inline="true" :model="query" class="mb8" ref="queryForm">
                <el-form-item label="日期间隔">
                    <el-select v-model="query.HInitTimeCycle" placeholder="请选择" style="width:160px" @change="onTimeCycleChange">
                        <el-option v-for="(t,i) in timeCycles" :key="i" :label="t.label" :value="t.value" />
                    </el-select>
                </el-form-item>
                <el-form-item label="开始日期">
                    <el-date-picker v-model="query.HBeginDate" type="date" placeholder="开始日期" style="width:160px" :disabled="timeCycleDisabled" value-formate="yyyy-MM-dd" format="yyyy-MM-dd"/>
                </el-form-item>
                <el-form-item label="结束日期">
                    <el-date-picker v-model="query.HEndDate" type="date" placeholder="结束日期" style="width:160px" :disabled="timeCycleDisabled" value-format="yyyy-MM-dd" format="yyyy-MM-dd"/>
                </el-form-item>
                <el-form-item label="单据号">
                    <el-input v-model="query.HBillNo" style="width:160px" />
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" icon="el-icon-search" @click="onSearch">查询</el-button>
                    <el-button @click="onReset">重置</el-button>
                </el-form-item>
                <el-form-item style="margin-left:12px">
                    <div v-if="currentFilterName" style="color:#fc9393;font-weight:600">当前过滤方案:{{ currentFilterName }}</div>
                </el-form-item>
            </el-form>
 
            <el-form :model="query" ref="filterForm">
                <el-collapse v-model="activeCollapse" class="filter-collapse">
                    <el-collapse-item title="更多" name="more">
                        <el-row :gutter="12">
                            <el-col :span="8">
                                <el-form-item label="部门">
                                    <el-input v-model="query.HDeptID" style="width:190px" />
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item label="物料代码">
                                    <el-input v-model="query.MaterialCode" style="width:190px" />
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item label="物料名称">
                                    <el-input v-model="query.MaterialName" style="width:190px" />
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item label="规格型号">
                                    <el-input v-model="query.SpecificationModel" style="width:190px" />
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item label="源单单号">
                                    <el-input v-model="query.HSourceBillNo" style="width:190px" />
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item label="仓库">
                                    <el-input v-model="query.Warehouse" style="width:190px" />
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item label="制单人">
                                    <el-input v-model="query.Hmaker" style="width:190px" />
                                </el-form-item>
                            </el-col>
                        </el-row>
 
                        <el-row :gutter="12" style="margin-top: 12px;">
                            <el-col :span="24">
                                <el-row :gutter="12" style="margin-bottom: 10px;">
                                    <el-col :span="6">
                                        <el-form-item label="过滤">
                                            <el-select v-model="query.ColName" style="width:190px">
                                                <!-- <el-option value="0" label=""></el-option> -->
                                                <el-option v-for="col in filterColumns" :key="col.field" :value="col.field" :label="col.title" />
                                            </el-select>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="6">
                                        <el-select v-model="query.Comparator" style="width:190px">
                                            <!-- <el-option value="0" label=""></el-option> -->
                                            <el-option value="=" label="=" />
                                            <el-option value=">=" label=">=" />
                                            <el-option value=">" label=">" />
                                            <el-option value="<=" label="<=" />
                                            <el-option value="<" label="<" />
                                            <el-option value="<>" label="<>" />
                                            <el-option value="7" label="包含" />
                                            <el-option value="8" label="左包含" />
                                            <el-option value="9" label="右包含" />
                                            <el-option value="10" label="不包含" />
                                        </el-select>
                                    </el-col>
                                    <el-col :span="6">
                                        <el-input v-model="query.ColContent" placeholder="过滤内容" />
                                    </el-col>
                                </el-row>
 
                                <el-row :gutter="12" style="margin-bottom: 10px;">
                                    <el-col :span="6">
                                        <el-form-item label="过滤1">
                                            <el-select v-model="query.ColName1" style="width:190px">
                                                <el-option value="0" label=""></el-option>
                                                <el-option v-for="col in filterColumns" :key="col.field" :value="col.field" :label="col.title" />
                                            </el-select>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="6">
                                        <el-select v-model="query.Comparator1" style="width:190px">
                                            <!-- <el-option value="0" label=""></el-option> -->
                                            <el-option value="=" label="=" />
                                            <el-option value=">=" label=">=" />
                                            <el-option value=">" label=">" />
                                            <el-option value="<=" label="<=" />
                                            <el-option value="<" label="<" />
                                            <el-option value="<>" label="<>" />
                                            <el-option value="7" label="包含" />
                                            <el-option value="8" label="左包含" />
                                            <el-option value="9" label="右包含" />
                                            <el-option value="10" label="不包含" />
                                        </el-select>
                                    </el-col>
                                    <el-col :span="6">
                                        <el-input v-model="query.ColContent1" placeholder="过滤内容" />
                                    </el-col>
                                </el-row>
 
                                <el-row :gutter="12">
                                    <el-col :span="6">
                                        <el-form-item label="过滤2">
                                            <el-select v-model="query.ColName2" style="width:190px">
                                                <el-option value="0" label=""></el-option>
                                                <el-option v-for="col in filterColumns" :key="col.field" :value="col.field" :label="col.title" />
                                            </el-select>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="6">
                                        <el-select v-model="query.Comparator2" style="width:190px">
                                            <!-- <el-option value="0" label=""></el-option> -->
                                            <el-option value="=" label="=" />
                                            <el-option value=">=" label=">=" />
                                            <el-option value=">" label=">" />
                                            <el-option value="<=" label="<=" />
                                            <el-option value="<" label="<" />
                                            <el-option value="<>" label="<>" />
                                            <el-option value="7" label="包含" />
                                            <el-option value="8" label="左包含" />
                                            <el-option value="9" label="右包含" />
                                            <el-option value="10" label="不包含" />
                                        </el-select>
                                    </el-col>
                                    <el-col :span="6">
                                        <el-input v-model="query.ColContent2" placeholder="过滤内容" />
                                    </el-col>
                                </el-row>
                            </el-col>
                        </el-row>
                    </el-collapse-item>
                </el-collapse>
            </el-form>
 
            <el-row style="margin-bottom:8px">
                <el-col>
                    <el-button size="mini" type="primary" @click="handleAdd">新增</el-button>
                    <el-button size="mini" @click="handleEdit">编辑</el-button>
                    <el-button size="mini" type="danger" @click="set_DeleteBill">删除</el-button>
                    <el-button size="mini" @click="set_CheckBill(1)">审核</el-button>
                    <el-button size="mini" @click="set_CheckBill(2)">反审核</el-button>
                    <el-button size="mini" @click="set_CloseBill(1)">关闭</el-button>
                    <el-button size="mini" @click="set_CloseBill(2)">反关闭</el-button>
                    <el-button size="mini" @click="set_DropBill(1)">作废</el-button>
                    <el-button size="mini" @click="set_DropBill(2)">反作废</el-button>
                    <el-button size="mini" @click="get_ViewReport">预览</el-button>
                    <el-button size="mini" @click="get_PrintReport">打印</el-button>
                    <el-button size="mini" @click="get_Refresh">刷新</el-button>
                    <el-button size="mini" @click="get_BarCodeDetail">条码明细</el-button>
                    <el-button type="primary" icon="el-icon-printer" size="mini" :disabled="single" @click="get_PackStockDetail">包装容器出入库明细</el-button>
                </el-col>
            </el-row>
 
            <el-table
                :data="tableData"
                stripe
                border
                style="width:100%"
                @row-click="onRowClick"
                @selection-change="onSelectionChange"
                :loading="loading"
                ref="mainTable"
            >
                <el-table-column type="selection" width="55" />
                <el-table-column v-for="(col, idx) in tableColumns" :key="idx" :prop="col.field" :label="col.title" :width="col.width" :formatter="col.formatter">
                    <template v-if="col.field === '单据号'" #default="scope">
                        <span style="color: blue; cursor: pointer;" @click="onBillNoClick(scope.row)">{{ scope.row.单据号 }}</span>
                    </template>
                </el-table-column>
            </el-table>
 
            <el-pagination style="margin-top:12px" background layout="total, sizes, prev, pager, next, jumper" :total="total" :page-size.sync="pageSize" :current-page.sync="page" @current-change="pageChange" @size-change="sizeChange" :page-sizes="[50,500,5000,20000]" />
        </el-card>
 
        <FbStepFoldinBillEdit
            :visible.sync="editDialogVisible"
            :operation-type="operationType"
            :linterid="currentId"
            @saved="handleSaved"
            @closed="handleClosed"
            />
        <BarCodeDetail 
            :visible.sync="barcodeDetailVisible"
            ref="barcodeDetail"
            />
        <PackStockDetail :visible.sync="packStockDetailShow" ref="packStockDetail"/>
        
    </div>
</template>
 
<script>
import axios from 'axios';
//import FbStepFoldinBillEdit from './fbStepFoldinBillEdit'
import FbStepFoldinBillEdit from '@/views/FbStepFoldOutBillList/fbStepFoldOutBillListEdit'
import BarCodeDetail from '@/views/component/BarCodeDetail'
import dayjs from 'dayjs';
import PackStockDetail from '@/views/component/PackStockDetail'
 
export default {
    name: 'FbStepFoldinBillList',
        components: {
            FbStepFoldinBillEdit,
            BarCodeDetail,PackStockDetail
            
        },
    data() {
        return {
            rowForm: {},
            editDialogVisible:false,
            operationType:'1',
            currentId : '',
              barcodeDetailVisible: false,// 条码明细弹窗显示控制
            packStockDetailShow:false, 
            query: {
                HInitTimeCycle: 29,
                HBeginDate: '',
                HEndDate: '',
                HBillNo: '',
                HDeptID: '',
                MaterialCode: '',
                MaterialName: '',
                SpecificationModel: '',
                HSourceBillNo: '',
                Warehouse: '',
                Hmaker: '',
                ColName: '',
                Comparator: '',
                ColContent: '',
                ColName1: '',
                Comparator1: '',
                ColContent1: '',
                ColName2: '',
                Comparator2: '',
                ColContent2: ''
            },
            timeCycles: [
                { value: -1, label: '任意间隔' },
                { value: 0, label: '今天' },
                { value: 1, label: '近两天' },
                { value: 2, label: '近三天' },
                { value: 3, label: '近四天' },
                { value: 4, label: '近五天' },
                { value: 5, label: '近六天' },
                { value: 6, label: '近七天' },
                { value: 29, label: '近30天' },
                { value: 180, label: '近半年' },
                { value: 365, label: '近一年' }
            ],
            timeCycleDisabled: false,
            tableColumns: [],
            filterColumns: [],
            tableData: [],
            loading: false,
            page: 1,
            pageSize: 50,
            total: 0,
            selectedRows: [],
            currentFilterName: '',
            activeCollapse: [],
            baseURL: process.env.VUE_APP_BASE_API,               
        };
    },
    created() {
        this.set_ClearBill();
    },
    methods: {
        // 初始化
        set_ClearBill() {
            this.setSelect_HInitTimeCycle();
            this.setDatesByCycle();
            this.set_InitGrid();
            this.ColFilter();
            this.get_DefaultModule();
        },
        setSelect_HInitTimeCycle() {
            this.query.HInitTimeCycle = 29;
        },
        setDatesByCycle() {
            const end = new Date();
            const start = new Date();
            const cycle = this.query.HInitTimeCycle;
            
            if (cycle === -1) {
                // 任意间隔,不清空日期
                this.timeCycleDisabled = false;
                return;
            }
            
            start.setDate(start.getDate() - (cycle >= 0 ? cycle : 0));
            this.query.HBeginDate = this.formatDate(start);
            this.query.HEndDate = this.formatDate(end);
            this.timeCycleDisabled = this.query.HInitTimeCycle !== -1;
        },
        formatDate(d) {
            if (!d) return '';
            const yyyy = d.getFullYear();
            const mm = String(d.getMonth() + 1).padStart(2, '0');
            const dd = String(d.getDate()).padStart(2, '0');
            
            return `${yyyy}-${mm}-${dd}`;
        },
        onTimeCycleChange() {
            this.setDatesByCycle();
            if (this.query.HInitTimeCycle !== -1) {
                this.onSearch();
            }
        },
        set_InitGrid() {
            this.tableColumns = [];
            this.tableData = [];
        },
         // 新增
        handleAdd() {
        this.operationType = '1'
        this.currentId = ''
        this.editDialogVisible = true
        },
        // 编辑
        handleEdit(row) {
            let target = row;
            console.log('传入的行对象:', target);
            // 如果没有传入行对象,则使用当前选中的第一行
            if (!target) {
                if (this.selectedRows.length !== 1) {
                    this.$message.warning('请选择一行数据!');
                    return;
                }
 
            }
            target = this.selectedRows[0];
            this.operationType = '3';
            this.currentId = this.selectedRows[0].hmainid || target.HInterID || target.HItemID || '';
            console.log('传入的主id:', this.currentId);
            this.editDialogVisible = true;
        },
        
        // 保存成功回调
        handleSaved() {
        this.get_Display('');
        this.$message.success('操作成功')
        },
        handleClosed() {
            this.editDialogVisible = false,
            this.currentId = ''
        },
        onSearch() {
            const sWhereParts = [];
            const q = this.query;
            
            const buildComparator = (col, cmp, content) => {
                if (!col || !cmp || cmp === '0' || !content) return '';
                let com = '';
                switch (cmp) {
                    case '7': com = `like '%${content}%'`; break;
                    case '8': com = `like '%${content}'`; break;
                    case '9': com = `like '${content}%'`; break;
                    case '10': com = `not like '%${content}%'`; break;
                    default: com = `${cmp} '${content}'`; break;
                }
                return ` and ${col} ${com}`;
            };
 
            if (q.ColName && q.Comparator && q.Comparator !== '0' && q.ColContent) 
                sWhereParts.push(buildComparator(q.ColName, q.Comparator, q.ColContent));
            if (q.ColName1 && q.Comparator1 && q.Comparator1 !== '0' && q.ColContent1) 
                sWhereParts.push(buildComparator(q.ColName1, q.Comparator1, q.ColContent1));
            if (q.ColName2 && q.Comparator2 && q.Comparator2 !== '0' && q.ColContent2) 
                sWhereParts.push(buildComparator(q.ColName2, q.Comparator2, q.ColContent2));
            
            if (q.HBeginDate) sWhereParts.push(` and CONVERT(varchar(100),日期, 23) >= '${dayjs(q.HBeginDate).format("YYYY-MM-DD")}'`);
            if (q.HEndDate) sWhereParts.push(` and CONVERT(varchar(100),日期, 23) <= '${dayjs(q.HEndDate).format("YYYY-MM-DD")}'`);
            if (q.HBillNo) sWhereParts.push(` and 单据号 like '%${q.HBillNo}%'`);
            if (q.HDeptID) sWhereParts.push(` and 部门 like '%${q.HDeptID}%'`);
            if (q.MaterialCode) sWhereParts.push(` and 物料代码 like '%${q.MaterialCode}%'`);
            if (q.MaterialName) sWhereParts.push(` and 物料名称 like '%${q.MaterialName}%'`);
            if (q.SpecificationModel) sWhereParts.push(` and 规格型号 like '%${q.SpecificationModel}%'`);
            if (q.HSourceBillNo) sWhereParts.push(` and 源单单号 like '%${q.HSourceBillNo}%'`);
            if (q.Warehouse) sWhereParts.push(` and 仓库名称 like '%${q.Warehouse}%'`);
            if (q.Hmaker) sWhereParts.push(` and 制单人 like '%${q.Hmaker}%'`);
 
            const sWhere = sWhereParts.join('');
            this.get_Display(sWhere);
        },
        onReset() {
            this.query = {
                HInitTimeCycle: 29,
                HBeginDate: '',
                HEndDate: '',
                HBillNo: '',
                HDeptID: '',
                MaterialCode: '',
                MaterialName: '',
                SpecificationModel: '',
                HSourceBillNo: '',
                Warehouse: '',
                Hmaker: '',
                ColName: '0', Comparator: '0', ColContent: '',
                ColName1: '0', Comparator1: '0', ColContent1: '',
                ColName2: '0', Comparator2: '0', ColContent2: ''
            };
            this.setDatesByCycle();
            this.get_Display('');
        },
        async get_Display(sWhere) {
            this.loading = true;
            try {
                const userName = sessionStorage['HUserName'] || sessionStorage['Czybm'] || 'admin';
                const orgName = sessionStorage['OrganizationName'] || sessionStorage['Organization'] || '浙江智云迈思';
 
                const url = `${this.baseURL}/Kf_StepFoldOutBill/GetStepFoldOutBillList`;
                const params = { 
                    sWhere: sWhere || '', 
                    user: userName, 
                    //Organization: orgName 
                };
 
                const resp = await axios.get(url, { params });
                const data1 = resp.data;
                
                if (data1.count === 1) {
                    const colDefs = [];
                    const filterCols = [];
                    
                    for (let i = 0; i < data1.list.length; i++) {
                        const item = data1.list[i];
                        const name = item.ColmCols;
                        const type = item.ColmType;
                        
                        const colDef = { 
                            field: name, 
                            title: name, 
                            width: 200 
                        };
                        
                        if (type === 'DateTime') {
                            colDef.formatter = (row, col, cellValue) => this.formatDateTime(cellValue);
                        }
                        
                        colDefs.push(colDef);
                        
                        // 为过滤条件准备列选项(排除隐藏字段)
                        const hideFields = ['hmainid', 'HMaterID', 'HUnitID', 'HICMOEmpID', 'HWHID', '单据ID', '单据类型', 'HDeptID', '部门代码', 'Hunitid',
                            '计量单位代码', '调入仓库代码', 'HSPID', '调入仓位代码', 'HSCWHID', '调出仓位代码', '调出仓库代码', 'HSCSPID', 'HSecManagerID', 'HKeeperID'];
                        
                        if (!hideFields.includes(name)) {
                            filterCols.push(colDef);
                        }
                    }
                    
                    this.tableColumns = colDefs;
                    this.filterColumns = filterCols;
                    this.tableData = data1.data || [];
                    this.total = data1.count || this.tableData.length;
                } else {
                    this.$alert((data1.Message || '获取数据异常'), '错误');
                }
            } catch (err) {
                console.error('请求失败:', err);
                this.$message.error(`接口请求失败: ${err.message}`);
            } finally {
                this.loading = false;
            }
        },
        formatDateTime(value) {
            if (!value) return '';
            try {
                const d = new Date(value);
                return d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0') + ' ' + String(d.getHours()).padStart(2, '0') + ':' + String(d.getMinutes()).padStart(2, '0') + ':' + String(d.getSeconds()).padStart(2, '0');
            } catch (e) {
                return value;
            }
        },
        ColFilter() {
        },
        async get_DefaultModule() {
            try {
                const url = `${this.baseURL}/Xt_FastICScheme/Chooselist`;
                const params = { 
                    user: sessionStorage['Czybm'] || sessionStorage['HUserName'] || '', 
                    HModuleName: '分步式调出单维护', 
                    HInterID: 0, 
                    Type: 'Default' 
                };
                const resp = await axios.get(url, { params });
                if (resp.data.count == 1) {
                    const data = resp.data.data;
                    this.currentFilterName = data[0].方案名称 || '';
                    this.onSearch();
                } else {
                    this.currentFilterName = '';
                    this.onSearch();
                }
            } catch (err) {
                console.warn('获取默认过滤方案失败', err);
                this.onSearch();
            }
        },
        set_AddNew() {
            window.open('./Fb_StepFoldinBillEdit.html?OperationType=1&linterid=&HSouceBillType=0&closeType=1', '_blank');
        },
        set_ShowBill() {
            if (this.selectedRows.length !== 1) { 
                this.$message.warning('请选择一行数据编辑!'); 
                return; 
            }
            const id = this.selectedRows[0].hmainid || this.selectedRows[0].HItemID;
            window.open('./Fb_StepFoldinBillEdit.html?OperationType=3&linterid=' + id, '_blank');
        },
        async set_DeleteBill() {
            if (this.selectedRows.length !== 1) { 
                this.$message.warning('请选择一行数据删除!'); 
                return; 
            }
            const row = this.selectedRows[0];
            if (row.状态 && row.状态 !== '创建') { 
                this.$message.warning('此数据不是创建状态,无法删除!'); 
                return; 
            }
            
            try {
                await this.$confirm('确认要删除吗,删除后不能恢复', '删除确认');
                const url = `${this.baseURL}/Fb_StepFoldInBill/DeltetFb_StepFoldInBill`;
                const params = { HInterID: (row.hmainid || row.HInterID) };
                const resp = await axios.get(url, { params });
                
                if (resp.data.count == 1) {
                    this.$message.success(resp.data.Message || '删除成功');
                    this.onSearch();
                } else {
                    this.$alert((resp.data.Message || '删除失败'), '错误');
                }
            } catch (err) {
                if (err !== 'cancel') {
                    this.$message.error('接口请求失败');
                }
            }
        },
        // 审核/反审核功能
        async set_CheckBill(type) {
            if (this.selectedRows.length !== 1) { 
                this.$message.warning('请选择一行数据操作!'); 
                return; 
            }
            
            const row = this.selectedRows[0];
            const actionName = type === 1 ? '审核' : '反审核';
            
            try {
                await this.$confirm(`确认要${actionName}此单据吗?`, `${actionName}确认`);
                
                const url = `${this.baseURL}/Kf_StepFoldOutBill/AuditKf_StepFoldOutBill`;
                const params = { 
                    HInterID: (row.hmainid || row.HInterID), 
                    Type: type, 
                    user: sessionStorage['HUserName'] || '' 
                };
                
                const resp = await axios.get(url, { params });
                if (resp.data.count == 1) {
                    this.$message.success(resp.data.Message || `${actionName}成功`);
                    this.onSearch();
                } else {
                    this.$alert((resp.data.Message || `${actionName}失败`), '错误');
                }
            } catch (err) {
                if (err !== 'cancel') {
                    this.$message.error('接口请求失败');
                }
            }
        },
        // 关闭/反关闭功能
        async set_CloseBill(type) {
            if (this.selectedRows.length !== 1) { 
                this.$message.warning('请选择一行数据操作!'); 
                return; 
            }
            
            const row = this.selectedRows[0];
            const actionName = type === 1 ? '关闭' : '反关闭';
            
            try {
                await this.$confirm(`确认要${actionName}此单据吗?`, `${actionName}确认`);
                
                const url = `${this.baseURL}/Kf_StepFoldOutBill/CloseKf_StepFoldOutBill`;
                const params = { 
                    HInterID: (row.hmainid || row.HInterID), 
                    Type: type, 
                    user: sessionStorage['HUserName'] || '' 
                };
                
                const resp = await axios.get(url, { params });
                if (resp.data.count == 1) {
                    this.$message.success(resp.data.Message || `${actionName}成功`);
                    this.onSearch();
                } else {
                    this.$alert((resp.data.Message || `${actionName}失败`), '错误');
                }
            } catch (err) {
                if (err !== 'cancel') {
                    this.$message.error('接口请求失败');
                }
            }
        },
        // 作废/反作废功能
        async set_DropBill(type) {
            if (this.selectedRows.length !== 1) { 
                this.$message.warning('请选择一行数据操作!'); 
                return; 
            }
            
            const row = this.selectedRows[0];
            const actionName = type === 1 ? '作废' : '反作废';
            
            try {
                await this.$confirm(`确认要${actionName}此单据吗?`, `${actionName}确认`);
                
                const url = `${this.baseURL}/Kf_StepFoldOutBill/CancellKf_StepFoldOutBill`;
                const params = { 
                    HInterID: (row.hmainid || row.HInterID), 
                    Type: type, 
                    user: sessionStorage['HUserName'] || '' 
                };
                
                const resp = await axios.get(url, { params });
                if (resp.data.count == 1) {
                    this.$message.success(resp.data.Message || `${actionName}成功`);
                    this.onSearch();
                } else {
                    this.$alert((resp.data.Message || `${actionName}失败`), '错误');
                }
            } catch (err) {
                if (err !== 'cancel') {
                    this.$message.error('接口请求失败');
                }
            }
        },
        onRowClick(row) {
            this.$nextTick(() => {
                const table = this.$refs.mainTable;
                if (!table) return;
                table.toggleRowSelection(row);
            });
        },
        onSelectionChange(selection) {
            this.selectedRows = selection;
            this.ids = selection.map(item => item.hmainid)
            console.log('选择的行:', selection,"选择的ids:",this.ids);
            if (selection.length > 0)
            this.rowForm = selection[0]
        },
        onBillNoClick(row) {
            const table = this.$refs.mainTable;
            if (table) {
                try {
                    table.clearSelection();
                    table.toggleRowSelection(row, true);
                } catch (e) {
                    if (table.setCurrentRow) table.setCurrentRow(row);
                }
            }
            this.selectedRows = [row];
            this.operationType = '3';
            this.currentId = row.hmainid || row.HInterID || row.HItemID || '';
            this.editDialogVisible = true;
        },
        get_BarCodeDetail() {
        if (this.selectedRows.length !== 1) {
            this.$message.warning('请选择一行数据查看条码明细!')
            return
        }
        
        this.barcodeDetailVisible = true
        this.$nextTick(() => {
            this.$refs.barcodeDetail.open(this.selectedRows[0])
        })
        },
         //#region 包装容器出入库明细
            get_PackStockDetail() {
      // if (this.selectedRow.length !== 1) {
      //   this.$message.warning('请选择一行数据查看条码明细!')
      //   return
      // }
            this.packStockDetailShow = true
            this.$nextTick(() => {
                this.$refs.packStockDetail.open(this.rowForm)
            })
        },
    //#endregion
        get_ViewReport() {
            if (this.selectedRows.length !== 1) { 
                this.$message.warning('请选择一行数据打印!'); 
                return; 
            }
            const id = this.selectedRows[0].hmainid;
            window.open('../../BaseSet/SRM_OpenTmpList.html?linterid=' + id + '&MyMsg=' + id + '&Type=HMouldProdOutBill', '_blank');
        },
        get_PrintReport() {
            if (this.selectedRows.length === 0) { 
                this.$message.warning('请选择数据打印!'); 
                return; 
            }
            const hmainid = this.selectedRows.map(r => (r.hmainid * (10 ** 8)) + (r.hsubid || 0)).toString();
            window.open('../../BaseSet/SRM_OpenTmpList.html?linterid=' + hmainid + '&MyMsg=' + hmainid + '&Type=HSeOutStockBillList', '_blank');
        },
        get_Refresh() {
            this.onReset();
        },
        pageChange(val) {
            this.page = val; 
            this.onSearch();
        },
        sizeChange(val) {
            this.pageSize = val; 
            this.onSearch();
        }
    }
};
</script>
 
<style scoped>
    .mb8 { margin-bottom: 8px }
    .filter-collapse {
        margin-bottom: 12px;
    }
    :deep(.el-collapse-item__header) {
        font-weight: bold;
        background-color: #f5f7fa;
        padding: 0 12px;
    }
</style>