5 天以前 91c82965b2d987452ca276e3a03b48c8dcda2ae9
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
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
<script lang="ts" setup>
import type { SrmTenderApi } from '#/api/srm/tender';
 
import { computed, onMounted, ref } from 'vue';
import { useRoute, useRouter } from 'vue-router';
 
import { Page } from '@vben/common-ui';
 
import { message, Modal } from 'ant-design-vue';
import { IconifyIcon } from '@vben/icons';
 
import {
  getTenderProject,
  getMaterialList, createMaterial, updateMaterial, deleteMaterial,
  getBidListByProject, createBid, withdrawBid,
  getQuoteList, createQuote, updateQuote,
  createBidOpen, getBidOpen,
  getEvaluationList, createBidEvaluation, updateBidEvaluation, calculateRanking,
  createAward, deleteAward, getAward, getAwardByProject, approveAward, generatePurchaseOrder,
  confirmTenderProject,
} from '#/api/srm/tender';
import { getSupplierList } from '#/api/srm/supplier';
import { getItemSimpleList } from '#/api/mdm/item';
import type { MdmItemApi } from '#/api/mdm/item';
import {
  TENDER_STATUS,
  TENDER_STATUS_CELLTAG,
  TENDER_STATUS_COLORS,
  TENDER_TYPE_CELLTAG,
  BID_STATUS,
  BID_STATUS_MAP,
  AWARD_STATUS,
  AWARD_STATUS_MAP,
  getLabel,
  BIDDING_MODE,
} from '../enums';
 
defineOptions({ name: 'SrmTenderDetail' });
 
const route = useRoute();
const router = useRouter();
const projectId = Number(route.query.id);
 
const project = ref<SrmTenderApi.TenderProjectVO>();
const activeTab = ref('info');
 
// ========== 下拉选项数据 ==========
const mdmItemList = ref<MdmItemApi.Item[]>([]);
const supplierList = ref<{ id: number; name: string }[]>([]);
 
onMounted(async () => {
  const [items, suppliers] = await Promise.all([
    getItemSimpleList(),
    getSupplierList(),
  ]);
  mdmItemList.value = items;
  supplierList.value = suppliers;
});
 
const filterOption = (input: string, option: any) =>
  option.label?.toLowerCase().indexOf(input.toLowerCase()) >= 0;
 
// ========== 基本信息 ==========
const materialList = ref<SrmTenderApi.TenderMaterialVO[]>([]);
const materialLoading = ref(false);
const materialFormVisible = ref(false);
const materialForm = ref<SrmTenderApi.TenderMaterialVO>({ tenderProjectId: projectId });
 
// 已添加的物料产品ID集合,避免重复添加
const addedProductIds = computed(() => {
  const ids = new Set(
    materialList.value
      .filter((m) => m.productId !== undefined)
      .map((m) => m.productId!),
  );
  // 编辑时允许保留当前物料的 productId
  if (materialForm.value.id && materialForm.value.productId) {
    ids.delete(materialForm.value.productId);
  }
  return ids;
});
 
// 物料下拉可选列表(排除已添加的)
const availableMdmItems = computed(() =>
  mdmItemList.value.filter((item) => !addedProductIds.value.has(item.id!)),
);
 
async function loadProject() {
  project.value = await getTenderProject(projectId);
}
async function loadMaterials() {
  materialLoading.value = true;
  try { materialList.value = await getMaterialList(projectId); } finally { materialLoading.value = false; }
}
async function handleSaveMaterial() {
  if (materialForm.value.id) {
    await updateMaterial(materialForm.value);
  } else {
    await createMaterial(materialForm.value);
  }
  materialFormVisible.value = false;
  loadMaterials();
}
function onMaterialSelect(itemId: number) {
  const item = mdmItemList.value.find((i) => i.id === itemId);
  if (item) {
    materialForm.value.productCode = item.code;
    materialForm.value.productName = item.name;
    materialForm.value.productSpec = item.specification;
    materialForm.value.unit = item.unitMeasureName;
  }
}
 
function handleAddMaterial() {
  materialForm.value = { tenderProjectId: projectId };
  materialFormVisible.value = true;
}
function handleEditMaterial(row: SrmTenderApi.TenderMaterialVO) {
  materialForm.value = { ...row };
  materialFormVisible.value = true;
}
async function handleDeleteMaterial(id: number) {
  await deleteMaterial(id);
  loadMaterials();
}
 
// ========== 投标管理 ==========
const bidList = ref<SrmTenderApi.TenderBidVO[]>([]);
const bidLoading = ref(false);
const bidFormVisible = ref(false);
const bidForm = ref<SrmTenderApi.TenderBidVO>({ tenderProjectId: projectId, supplierId: undefined!, bidNo: '' });
 
async function loadBids() {
  bidLoading.value = true;
  try { bidList.value = await getBidListByProject(projectId); } finally { bidLoading.value = false; }
}
async function handleCreateBid() {
  await createBid(bidForm.value);
  bidFormVisible.value = false;
  loadBids();
}
async function handleWithdrawBid(id: number) {
  await withdrawBid(id);
  loadBids();
}
 
// ========== 报价管理 ==========
const quoteList = ref<SrmTenderApi.QuoteVO[]>([]);
const quoteLoading = ref(false);
const quoteFormVisible = ref(false);
const quoteForm = ref<SrmTenderApi.QuoteVO>({ bidId: undefined!, tenderMaterialId: undefined! });
const selectedBidId = ref<number>();
 
const availableMaterials = computed(() => {
  const quotedIds = new Set(
    quoteList.value
      .filter((q) => q.tenderMaterialId !== undefined)
      .map((q) => q.tenderMaterialId),
  );
  // 编辑时允许保留当前物料
  if (quoteForm.value.id && quoteForm.value.tenderMaterialId) {
    quotedIds.delete(quoteForm.value.tenderMaterialId);
  }
  return materialList.value.filter((m) => !quotedIds.has(m.id));
});
 
async function loadQuotes(bidId?: number) {
  if (!bidId) return;
  selectedBidId.value = bidId;
  quoteLoading.value = true;
  try { quoteList.value = await getQuoteList(bidId); } finally { quoteLoading.value = false; }
}
async function handleSaveQuote() {
  // 校验:报价金额与投标金额一致性
  const bid = bidList.value.find((b) => b.id === quoteForm.value.bidId);
  if (bid?.bidTotalAmount != null) {
    const otherQuotesTotal = quoteList.value
      .filter((q) => q.id !== quoteForm.value.id)
      .reduce((sum, q) => sum + (q.quotePrice ?? 0), 0);
    const newTotal = otherQuotesTotal + (quoteForm.value.quotePrice ?? 0);
    if (newTotal !== bid.bidTotalAmount) {
      await new Promise<void>((resolve, reject) => {
        Modal.confirm({
          title: '金额不一致提示',
          content: `报价总金额(${newTotal.toLocaleString()})与投标金额(${bid.bidTotalAmount!.toLocaleString()})不一致,是否继续提交?`,
          okText: '继续提交',
          cancelText: '取消',
          onOk: () => { resolve(); },
          onCancel: () => { reject(new Error('cancel')); },
        });
      });
    }
  }
 
  if (quoteForm.value.id) {
    await updateQuote(quoteForm.value);
  } else {
    await createQuote(quoteForm.value);
  }
  quoteFormVisible.value = false;
  loadQuotes(selectedBidId.value);
}
function handleAddQuote() {
  quoteForm.value = { bidId: selectedBidId.value!, tenderMaterialId: undefined! };
  quoteFormVisible.value = true;
}
function handleEditQuote(row: SrmTenderApi.QuoteVO) {
  quoteForm.value = { ...row };
  quoteFormVisible.value = true;
}
 
// ========== 开标 ==========
const bidOpen = ref<any>(null);
 
async function loadBidOpen() {
  try {
    bidOpen.value = null;
  } catch { /* 暂无开标记录 */ }
}
async function handleCreateBidOpen() {
  await createBidOpen(projectId);
  message.success('开标成功');
  loadBidOpen();
  loadProject();
}
 
// ========== 评标管理 ==========
const evaluationList = ref<SrmTenderApi.BidEvaluationVO[]>([]);
const evalLoading = ref(false);
const evalFormVisible = ref(false);
const evalForm = ref<SrmTenderApi.BidEvaluationVO>({ tenderProjectId: projectId, supplierId: undefined!, bidId: undefined! });
 
async function loadEvaluations() {
  evalLoading.value = true;
  try { evaluationList.value = await getEvaluationList(projectId); } finally { evalLoading.value = false; }
}
async function handleCreateEvaluation() {
  if (evalForm.value.id) {
    await updateBidEvaluation(evalForm.value);
  } else {
    await createBidEvaluation(evalForm.value);
  }
  evalFormVisible.value = false;
  loadEvaluations();
  loadProject();
}
async function handleCalculateRanking() {
  await calculateRanking(projectId);
  message.success('排名计算完成');
  loadEvaluations();
}
 
// ========== 定标 ==========
const award = ref<SrmTenderApi.BidAwardVO>();
const awardFormVisible = ref(false);
const awardForm = ref<SrmTenderApi.BidAwardVO>({ tenderProjectId: projectId, supplierId: undefined!, bidId: undefined!, awardNo: '' });
 
/** 已投标且未撤标的供应商列表(从投标记录中提取) */
const bidSuppliers = computed(() => {
  const activeBids = bidList.value.filter((b) => b.bidStatus !== BID_STATUS.WITHDRAWN);
  const seen = new Map<number, { id: number; name: string }>();
  activeBids.forEach((b) => {
    if (b.supplierId && !seen.has(b.supplierId)) {
      seen.set(b.supplierId, { id: b.supplierId, name: b.supplierName || '' });
    }
  });
  return [...seen.values()];
});
 
/** 可选投标记录:排除撤标,且如果选了供应商则只显示该供应商的投标 */
const activeBids = computed(() => {
  return bidList.value.filter((b) => {
    if (b.bidStatus === BID_STATUS.WITHDRAWN) return false;
    if (awardForm.value.supplierId && b.supplierId !== awardForm.value.supplierId) return false;
    return true;
  });
});
 
/** 选择供应商时清空已选的投标 */
function onAwardSupplierChange() {
  awardForm.value.bidId = undefined!;
}
 
/** 选择投标时自动带入该投标的报价金额 */
function onAwardBidChange(bidId: number) {
  const bid = bidList.value.find((b) => b.id === bidId);
  if (bid?.bidTotalAmount != null) {
    awardForm.value.awardAmount = bid.bidTotalAmount;
  }
}
 
async function loadAward() {
  try { award.value = await getAwardByProject(projectId); } catch { award.value = undefined; }
}
async function handleCreateAward() {
  await createAward(awardForm.value);
  awardFormVisible.value = false;
  loadAward();
  loadProject();
}
async function handleApproveAward() {
  if (!award.value?.id) return;
  await approveAward(award.value.id);
  message.success('定标审批通过');
  loadAward();
  loadProject();
}
async function handleDeleteAward() {
  if (!award.value?.id) return;
  await deleteAward(award.value.id);
  message.success('定标已删除');
  award.value = undefined;
}
 
async function handleGeneratePurchaseOrder() {
  if (!award.value?.id) return;
  await generatePurchaseOrder(award.value.id);
  message.success('采购订单已生成');
  loadAward();
  loadProject();
}
 
// ========== 简易模式:确认中标 ==========
const confirmBidId = ref<number>();
const confirmModalVisible = ref(false);
 
async function handleConfirmBidAsWinner(bidId: number) {
  await confirmTenderProject({ id: projectId, bidId });
  message.success('确认中标成功,采购订单已自动生成');
  loadProject();
  loadBids();
  loadAward();
}
 
function openSimpleConfirmModal() {
  confirmBidId.value = undefined;
  confirmModalVisible.value = true;
}
 
async function handleSimpleConfirm() {
  if (!confirmBidId.value) {
    message.warning('请选择中标的投标记录');
    return;
  }
  await confirmTenderProject({ id: projectId, bidId: confirmBidId.value });
  message.success('确认中标成功,采购订单已自动生成');
  confirmModalVisible.value = false;
  loadProject();
  loadBids();
  loadAward();
}
 
// ========== 初始化 ==========
loadProject();
loadMaterials();
loadBids();
loadEvaluations();
loadAward();
 
// ========== 状态判断 ==========
const statusLabel = computed(() => getLabel(TENDER_STATUS_CELLTAG.labels, project.value?.tenderStatus));
const statusColor = computed(() => TENDER_STATUS_COLORS[project.value?.tenderStatus!] || 'default');
const typeLabel = computed(() => getLabel(TENDER_TYPE_CELLTAG.labels, project.value?.tenderType));
const isDraft = computed(() => project.value?.tenderStatus === TENDER_STATUS.DRAFT);
const isPublished = computed(() => project.value?.tenderStatus === TENDER_STATUS.PUBLISHED);
const isBidding = computed(() => project.value?.tenderStatus === TENDER_STATUS.BIDDING);
const isPublishedOrBidding = computed(() => {
  const s = project.value?.tenderStatus;
  return s === TENDER_STATUS.PUBLISHED || s === TENDER_STATUS.BIDDING;
});
const isBiddingOrEvaluating = computed(() => {
  const s = project.value?.tenderStatus;
  return s === TENDER_STATUS.BIDDING || s === TENDER_STATUS.EVALUATING;
});
const isEvaluating = computed(() => project.value?.tenderStatus === TENDER_STATUS.EVALUATING);
const canDeleteAward = computed(() => award.value?.awardStatus === AWARD_STATUS.PENDING_APPROVAL);
const canApproveAward = computed(() => award.value?.awardStatus === AWARD_STATUS.PENDING_APPROVAL);
const canGeneratePO = computed(() => award.value?.awardStatus === AWARD_STATUS.AWARDED);
 
// 简易模式
const isSimpleMode = computed(() => project.value?.biddingMode === BIDDING_MODE.SIMPLE);
const isPriceComparing = computed(() => project.value?.tenderStatus === TENDER_STATUS.PRICE_COMPARING);
 
const stepItems = computed(() => {
  if (isSimpleMode.value) {
    return [
      { title: '草稿', status: TENDER_STATUS.DRAFT },
      { title: '比价中', status: TENDER_STATUS.PRICE_COMPARING },
      { title: '已确认', status: TENDER_STATUS.CONFIRMED },
    ];
  }
  return [
    { title: '草稿', status: TENDER_STATUS.DRAFT },
    { title: '发布', status: TENDER_STATUS.PUBLISHED },
    { title: '投标中', status: TENDER_STATUS.BIDDING },
    { title: '评标中', status: TENDER_STATUS.EVALUATING },
    { title: '已定标', status: TENDER_STATUS.AWARDED },
  ];
});
const currentStep = computed(() => {
  const s = project.value?.tenderStatus ?? 0;
  const items = stepItems.value;
  if (s === TENDER_STATUS.CLOSED) return items.length - 1;
  const idx = items.findIndex((item) => item.status >= s);
  return idx === -1 ? 0 : idx;
});
const stepStatus = computed(() => {
  const s = project.value?.tenderStatus;
  if (s === TENDER_STATUS.CLOSED) return 'error';
  if (s === TENDER_STATUS.AWARDED || s === TENDER_STATUS.CONFIRMED) return 'finish';
  return 'process';
});
 
const materialTotalAmount = computed(() =>
  materialList.value.reduce((sum, m) => sum + (m.estimatedPrice ?? 0) * (m.quantity ?? 0), 0),
);
const bidCount = computed(() => bidList.value.length);
const bidTotalAmount = computed(() =>
  bidList.value.reduce((sum, b) => sum + (b.bidTotalAmount ?? 0), 0),
);
const evalCount = computed(() => evaluationList.value.length);
const rankedCount = computed(() => evaluationList.value.filter((e) => e.rank != null).length);
 
const selectedBid = computed(() =>
  bidList.value.find((b) => b.id === selectedBidId.value),
);
 
const materialColumns = [
  { title: '物料编码', dataIndex: 'productCode', width: 120 },
  { title: '物料名称', dataIndex: 'productName', width: 150 },
  { title: '规格型号', dataIndex: 'productSpec', width: 120 },
  { title: '单位', dataIndex: 'unit', width: 80 },
  { title: '数量', dataIndex: 'quantity', width: 80 },
  { title: '技术要求', dataIndex: 'techRequirement', width: 150 },
  { title: '预估单价', dataIndex: 'estimatedPrice', width: 100 },
  { title: '操作', key: 'actions', width: 150 },
];
 
const bidColumns = [
  { title: '投标编号', dataIndex: 'bidNo', width: 140 },
  { title: '供应商', dataIndex: 'supplierName', width: 200 },
  { title: '投标总金额', dataIndex: 'bidTotalAmount', width: 120 },
  { title: '投标时间', dataIndex: 'bidTime', width: 160 },
  { title: '状态', dataIndex: 'bidStatus', width: 100, customRender: ({ text }: any) => BID_STATUS_MAP[text] || text },
  { title: '操作', key: 'actions', width: 240 },
];
 
const quoteColumns = [
  { title: '物料', dataIndex: 'materialName', width: 120 },
  { title: '报价单价', dataIndex: 'quotePrice', width: 100 },
  { title: '税率(%)', dataIndex: 'taxRate', width: 80 },
  { title: '交期(天)', dataIndex: 'deliveryCycle', width: 80 },
  { title: '付款条件', dataIndex: 'paymentTerms', width: 120 },
  { title: '质保期(月)', dataIndex: 'warrantyPeriod', width: 80 },
  { title: '备注', dataIndex: 'remark', width: 150 },
  { title: '操作', key: 'actions', width: 120 },
];
 
const evalColumns = [
  { title: '投标ID', dataIndex: 'bidId', width: 80 },
  { title: '供应商', dataIndex: 'supplierName', width: 150 },
  { title: '价格评分', dataIndex: 'priceScore', width: 100 },
  { title: '技术评分', dataIndex: 'techScore', width: 100 },
  { title: '交付评分', dataIndex: 'deliveryScore', width: 100 },
  { title: '服务评分', dataIndex: 'serviceScore', width: 100 },
  { title: '综合评分', dataIndex: 'compositeScore', width: 100 },
  { title: '排名', dataIndex: 'rank', width: 80 },
  { title: '评委', dataIndex: 'evaluatorName', width: 100 },
  { title: '评语', dataIndex: 'evaluationOpinion', width: 150 },
  { title: '操作', key: 'actions', width: 120 },
];
</script>
 
<template>
  <Page auto-content-height>
    <!-- 加载中 -->
    <a-skeleton v-if="!project" active class="p-4" />
    <template v-else>
      <!-- 顶部标题栏 -->
      <div class="flex items-center gap-2 px-4 pt-3 pb-2">
        <a-button type="text" size="small" @click="router.back()">
          <template #icon><IconifyIcon icon="ant-design:arrow-left-outlined" /></template>
        </a-button>
        <span class="text-lg font-bold truncate max-w-md">{{ project.tenderName }}</span>
        <span class="text-gray-400 text-xs">{{ project.tenderNo }}</span>
        <a-tag :color="statusColor">{{ statusLabel }}</a-tag>
        <a-tag color="blue">{{ typeLabel }}</a-tag>
        <a-tag v-if="isSimpleMode" color="purple">简易版</a-tag>
        <div class="flex-1" />
        <a-button
          v-if="isPriceComparing"
          type="primary"
          size="small"
          @click="openSimpleConfirmModal"
        >
          确认中标
        </a-button>
        <a-button size="small" @click="loadProject(); loadMaterials(); loadBids(); loadEvaluations(); loadAward();">
          <template #icon><IconifyIcon icon="ant-design:reload-outlined" /></template>
          刷新
        </a-button>
      </div>
 
      <!-- 工作流进度 + 关键信息 -->
      <div class="px-4 mb-3">
        <a-card size="small">
          <!-- 流程步骤 -->
          <a-steps :current="currentStep" :status="stepStatus" size="small" class="mb-3">
              <a-step v-for="item in stepItems" :key="item.status" :title="item.title" />
            </a-steps>
 
          <!-- 关键字段 -->
          <div class="grid grid-cols-6 gap-3 text-xs">
            <div>
              <div class="text-gray-400 mb-0.5">预算金额</div>
              <div class="font-semibold text-blue-500">{{ project.budgetAmount?.toLocaleString() ?? '-' }} 元</div>
            </div>
            <div>
              <div class="text-gray-400 mb-0.5">负责人</div>
              <div class="font-semibold">{{ project.projectLeaderName || '-' }}</div>
            </div>
            <div>
              <div class="text-gray-400 mb-0.5">采购组织</div>
              <div class="font-semibold">{{ project.purchaseOrg || '-' }}</div>
            </div>
            <div>
              <div class="text-gray-400 mb-0.5">开标时间</div>
              <div class="font-semibold">{{ project.bidOpenTime || '待定' }}</div>
            </div>
            <div>
              <div class="text-gray-400 mb-0.5">开始时间</div>
              <div class="font-semibold">{{ project.startTime || '-' }}</div>
            </div>
            <div>
              <div class="text-gray-400 mb-0.5">截止时间</div>
              <div class="font-semibold">{{ project.endTime || '-' }}</div>
            </div>
          </div>
 
          <!-- 招标说明 / 资质要求 -->
          <template
            v-if="project.tenderDesc || project.qualificationRequirements || (project.attachmentList && project.attachmentList.length)"
          >
            <a-divider class="!my-2" />
            <a-collapse :bordered="false" ghost expand-icon-position="end">
              <a-collapse-panel v-if="project.tenderDesc" key="desc" header="招标说明">
                <p class="text-gray-500 text-xs whitespace-pre-wrap">{{ project.tenderDesc }}</p>
              </a-collapse-panel>
              <a-collapse-panel
                v-if="project.qualificationRequirements || (project.attachmentList && project.attachmentList.length)"
                key="req"
                header="资质要求"
              >
                <p v-if="project.qualificationRequirements" class="text-gray-500 text-xs whitespace-pre-wrap">{{ project.qualificationRequirements }}</p>
                <div v-if="project.attachmentList && project.attachmentList.length" class="mt-2 flex flex-col gap-1">
                  <a
                    v-for="file in project.attachmentList"
                    :key="file.id"
                    :href="file.url"
                    target="_blank"
                    rel="noopener noreferrer"
                    class="text-blue-500 text-xs hover:underline"
                  >
                    {{ file.name || '附件-' + file.id }}
                  </a>
                </div>
              </a-collapse-panel>
            </a-collapse>
          </template>
        </a-card>
      </div>
 
      <!-- Tab 页签 -->
      <div class="px-4 pb-4">
        <a-card size="small">
          <a-tabs v-model:activeKey="activeTab" size="small">
            <!-- Tab1: 物料清单 -->
            <a-tab-pane key="info">
              <template #tab>
                <a-space :size="4"><IconifyIcon icon="ant-design:unordered-list-outlined" />物料清单</a-space>
              </template>
              <div class="flex items-center justify-between mb-3">
                <a-space>
                  <span class="text-xs text-gray-400">共 <b class="text-gray-600">{{ materialList.length }}</b> 项,预估总金额 <b class="text-blue-500">{{ materialTotalAmount.toLocaleString() }}</b> 元</span>
                </a-space>
                <a-button v-if="isDraft" type="primary" size="small" @click="handleAddMaterial">
                  <template #icon><IconifyIcon icon="ant-design:plus-outlined" /></template>
                  添加物料
                </a-button>
              </div>
              <a-table :columns="materialColumns" :data-source="materialList" :loading="materialLoading" :pagination="false" row-key="id" size="small">
                <template #bodyCell="{ column, record }">
                  <template v-if="column.dataIndex === 'estimatedPrice'">
                    {{ record.estimatedPrice ? record.estimatedPrice.toLocaleString() : '-' }}
                  </template>
                  <template v-if="column.key === 'actions'">
                    <a-space v-if="isDraft">
                      <a-button size="small" type="link" @click="handleEditMaterial(record)"><IconifyIcon icon="ant-design:edit-outlined" />编辑</a-button>
                      <a-popconfirm title="确认删除该物料?" @confirm="handleDeleteMaterial(record.id)">
                        <a-button size="small" type="link" danger><IconifyIcon icon="ant-design:delete-outlined" />删除</a-button>
                      </a-popconfirm>
                    </a-space>
                  </template>
                </template>
              </a-table>
              <a-empty v-if="!materialLoading && materialList.length === 0" description="暂无物料" class="mt-8" />
            </a-tab-pane>
 
            <!-- Tab2: 投标管理 -->
            <a-tab-pane key="bid">
              <template #tab>
                <a-space :size="4"><IconifyIcon icon="ant-design:team-outlined" />投标管理</a-space>
              </template>
              <div class="flex items-center justify-between mb-3">
                <span class="text-xs text-gray-400">共 <b class="text-gray-600">{{ bidCount }}</b> 个投标</span>
                <a-button v-if="isBidding || isDraft || isPriceComparing" type="primary" size="small" @click="bidForm = { tenderProjectId: projectId, supplierId: undefined!, bidNo: '' }; bidFormVisible = true">
                  <template #icon><IconifyIcon icon="ant-design:plus-outlined" /></template>
                  新增投标
                </a-button>
              </div>
              <a-table :columns="bidColumns" :data-source="bidList" :loading="bidLoading" :pagination="false" row-key="id" size="small">
                <template #bodyCell="{ column, record }">
                  <template v-if="column.dataIndex === 'bidTotalAmount'">
                    <span class="font-medium">{{ record.bidTotalAmount?.toLocaleString() }}</span>
                  </template>
                  <template v-if="column.dataIndex === 'bidStatus'">
                    <a-tag :color="record.bidStatus === BID_STATUS.WIN ? 'green' : record.bidStatus === BID_STATUS.LOSE ? 'red' : 'default'">
                      {{ BID_STATUS_MAP[record.bidStatus] }}
                    </a-tag>
                  </template>
                  <template v-if="column.key === 'actions'">
                    <a-space>
                      <a-button size="small" type="link" @click="loadQuotes(record.id); activeTab = 'quote'"><IconifyIcon icon="ant-design:dollar-outlined" />报价</a-button>
                      <a-popconfirm v-if="isPriceComparing && record.bidStatus !== BID_STATUS.WITHDRAWN" title="确认选择该投标为中标?将自动生成采购订单。" ok-text="确认中标" cancel-text="取消" @confirm="handleConfirmBidAsWinner(record.id)">
                        <a-button size="small" type="link" style="color: #52c41a;"><IconifyIcon icon="ant-design:check-circle-outlined" />确认中标</a-button>
                      </a-popconfirm>
                      <a-popconfirm v-if="(isPublishedOrBidding || isDraft || isPriceComparing) && record.bidStatus === BID_STATUS.REGISTERED" title="确认撤标?" @confirm="handleWithdrawBid(record.id)">
                        <a-button size="small" type="link" danger><IconifyIcon icon="ant-design:close-circle-outlined" />撤标</a-button>
                      </a-popconfirm>
                    </a-space>
                  </template>
                </template>
              </a-table>
              <a-empty v-if="!bidLoading && bidList.length === 0" description="暂无投标记录" class="mt-8" />
            </a-tab-pane>
 
            <!-- Tab3: 报价管理 -->
            <a-tab-pane key="quote">
              <template #tab>
                <a-space :size="4"><IconifyIcon icon="ant-design:dollar-outlined" />报价管理</a-space>
              </template>
              <template v-if="selectedBidId && selectedBid">
                <div class="flex items-center gap-3 mb-3 px-3 py-2 bg-gray-50 rounded text-xs">
                  <span class="text-gray-400">投标:<b class="text-gray-700">{{ selectedBid.bidNo }}</b></span>
                  <a-divider type="vertical" />
                  <span class="text-gray-400">供应商:<b class="text-gray-700">{{ selectedBid.supplierName }}</b></span>
                  <a-button size="small" type="link" class="ml-auto" @click="activeTab = 'bid'">切换投标</a-button>
                </div>
                <div class="text-right mb-3">
                  <a-button v-if="(isPublishedOrBidding || isDraft || isPriceComparing) && selectedBid?.bidStatus !== BID_STATUS.WITHDRAWN" type="primary" size="small" @click="handleAddQuote">
                    <template #icon><IconifyIcon icon="ant-design:plus-outlined" /></template>
                    新增报价
                  </a-button>
                </div>
                <a-table :columns="quoteColumns" :data-source="quoteList" :loading="quoteLoading" :pagination="false" row-key="id" size="small">
                  <template #bodyCell="{ column, record }">
                    <template v-if="column.dataIndex === 'quotePrice'">
                      <span class="font-medium text-blue-600">{{ record.quotePrice?.toLocaleString() }}</span>
                    </template>
                    <template v-if="column.dataIndex === 'taxRate'">
                      {{ record.taxRate != null ? `${record.taxRate}%` : '-' }}
                    </template>
                    <template v-if="column.dataIndex === 'deliveryCycle'">
                      {{ record.deliveryCycle != null ? `${record.deliveryCycle} 天` : '-' }}
                    </template>
                    <template v-if="column.dataIndex === 'warrantyPeriod'">
                      {{ record.warrantyPeriod != null ? `${record.warrantyPeriod} 个月` : '-' }}
                    </template>
                    <template v-if="column.key === 'actions'">
                      <a-button v-if="(isPublishedOrBidding || isDraft || isPriceComparing) && selectedBid?.bidStatus !== BID_STATUS.WITHDRAWN" size="small" type="link" @click="handleEditQuote(record)"><IconifyIcon icon="ant-design:edit-outlined" />编辑</a-button>
                    </template>
                  </template>
                </a-table>
                <a-empty v-if="!quoteLoading && quoteList.length === 0" description="暂无报价明细" class="mt-8" />
              </template>
              <a-empty v-else description="请先在「投标管理」中选择一个投标查看报价">
                <a-button type="primary" @click="activeTab = 'bid'">前往投标管理</a-button>
              </a-empty>
            </a-tab-pane>
 
            <!-- Tab4: 开标 -->
            <a-tab-pane v-if="!isSimpleMode" key="bidOpen">
              <template #tab>
                <a-space :size="4"><IconifyIcon icon="ant-design:unlock-outlined" />开标</a-space>
              </template>
              <template v-if="bidOpen">
                <a-result status="success" title="已开标">
                  <template #sub-title>
                    <a-descriptions :column="2" size="small" class="mt-4">
                      <a-descriptions-item label="开标编号">{{ bidOpen.id }}</a-descriptions-item>
                      <a-descriptions-item label="开标时间">{{ bidOpen.openTime }}</a-descriptions-item>
                    </a-descriptions>
                  </template>
                </a-result>
              </template>
              <template v-else>
                <div class="text-center py-8">
                  <a-result status="info" title="尚未开标" sub-title="执行开标后项目进入投标阶段,供应商可正式投标" />
                  <br />
                  <a-button v-if="isPublished" type="primary" @click="handleCreateBidOpen">
                    <template #icon><IconifyIcon icon="ant-design:thunderbolt-outlined" /></template>
                    执行开标
                  </a-button>
                </div>
              </template>
            </a-tab-pane>
 
            <!-- Tab5: 评标 -->
            <a-tab-pane v-if="!isSimpleMode" key="evaluation">
              <template #tab>
                <a-space :size="4"><IconifyIcon icon="ant-design:trophy-outlined" />评标</a-space>
              </template>
              <div class="flex items-center justify-between mb-3">
                <span class="text-xs text-gray-400">共 <b class="text-gray-600">{{ evalCount }}</b> 条,已排名 <b class="text-green-500">{{ rankedCount }}</b> 条</span>
                <a-space v-if="isBiddingOrEvaluating">
                  <a-button size="small" @click="handleCalculateRanking">
                    <template #icon><IconifyIcon icon="ant-design:bar-chart-outlined" /></template>
                    计算排名
                  </a-button>
                  <a-button type="primary" size="small" @click="evalForm = { tenderProjectId: projectId, supplierId: undefined!, bidId: undefined! }; evalFormVisible = true">
                    <template #icon><IconifyIcon icon="ant-design:plus-outlined" /></template>
                    新增评标
                  </a-button>
                </a-space>
              </div>
              <a-table :columns="evalColumns" :data-source="evaluationList" :loading="evalLoading" :pagination="false" row-key="id" size="small">
                <template #bodyCell="{ column, record }">
                  <template v-if="['priceScore', 'techScore', 'deliveryScore', 'serviceScore'].includes(column.dataIndex)">
                    <div class="flex items-center gap-2">
                      <a-progress :percent="record[column.dataIndex] || 0" :show-info="false" size="small"
                        :stroke-color="record[column.dataIndex] >= 80 ? '#52c41a' : record[column.dataIndex] >= 60 ? '#faad14' : '#ff4d4f'"
                        class="flex-1" style="min-width: 50px;" />
                      <span class="text-xs w-8 text-right">{{ record[column.dataIndex] ?? '-' }}</span>
                    </div>
                  </template>
                  <template v-if="column.dataIndex === 'compositeScore'">
                    <span class="font-bold" :class="record.compositeScore >= 80 ? 'text-green-500' : record.compositeScore >= 60 ? 'text-orange-500' : 'text-red-500'">
                      {{ record.compositeScore ?? '-' }}
                    </span>
                  </template>
                  <template v-if="column.dataIndex === 'rank'">
                    <a-tag v-if="record.rank === 1" color="gold"><IconifyIcon icon="ant-design:trophy-outlined" /> 第1名</a-tag>
                    <a-tag v-else-if="record.rank" color="default">第{{ record.rank }}名</a-tag>
                    <span v-else class="text-gray-300">-</span>
                  </template>
                  <template v-if="column.key === 'actions'">
                    <a-button v-if="isBiddingOrEvaluating" size="small" type="link" @click="evalForm = { ...record }; evalFormVisible = true"><IconifyIcon icon="ant-design:edit-outlined" />编辑</a-button>
                  </template>
                </template>
              </a-table>
              <a-empty v-if="!evalLoading && evaluationList.length === 0" description="暂无评标记录" class="mt-8" />
            </a-tab-pane>
 
            <!-- Tab6: 定标 -->
            <a-tab-pane v-if="!isSimpleMode" key="award">
              <template #tab>
                <a-space :size="4"><IconifyIcon icon="ant-design:check-circle-outlined" />定标</a-space>
              </template>
              <template v-if="award">
                <a-row :gutter="16">
                  <a-col :span="16">
                    <a-descriptions :column="2" bordered size="small">
                      <a-descriptions-item label="定标编号">
                        <span class="font-mono">{{ award.awardNo }}</span>
                      </a-descriptions-item>
                      <a-descriptions-item label="中标供应商">
                        <a-tag color="blue">{{ award.supplierName || award.supplierId }}</a-tag>
                      </a-descriptions-item>
                      <a-descriptions-item label="定标金额">
                        <span class="font-bold text-blue-600">{{ award.awardAmount?.toLocaleString() }}</span> 元
                      </a-descriptions-item>
                      <a-descriptions-item label="定标时间">{{ award.awardTime || '-' }}</a-descriptions-item>
                      <a-descriptions-item label="状态">
                        <a-tag :color="award.awardStatus === AWARD_STATUS.AWARDED ? 'green' : 'orange'">{{ AWARD_STATUS_MAP[award.awardStatus] }}</a-tag>
                      </a-descriptions-item>
                      <a-descriptions-item label="采购订单">{{ award.purchaseOrderId || '待生成' }}</a-descriptions-item>
                      <a-descriptions-item label="备注" :span="2">{{ award.remark || '-' }}</a-descriptions-item>
                    </a-descriptions>
                  </a-col>
                  <a-col :span="8" class="flex items-center justify-center">
                    <template v-if="award.awardStatus === AWARD_STATUS.ORDER_GENERATED">
                      <div class="text-center">
                        <a-result status="success" title="订单已生成" class="p-0">
                          <template #sub-title>
                            <span class="text-sm">采购订单 ID: {{ award.purchaseOrderId }}</span>
                          </template>
                        </a-result>
                        <a-popconfirm v-if="canDeleteAward" title="确定删除该定标记录?" ok-text="确定" cancel-text="取消" @confirm="handleDeleteAward">
                          <a-button type="link" danger size="small" class="mt-2">删除定标</a-button>
                        </a-popconfirm>
                      </div>
                    </template>
                    <template v-else-if="award.awardStatus === AWARD_STATUS.AWARDED">
                      <div class="text-center">
                        <a-result status="success" title="定标完成" class="p-0 mb-3" />
                        <a-button v-if="canGeneratePO" type="primary" block @click="handleGeneratePurchaseOrder">
                          <template #icon><IconifyIcon icon="ant-design:shopping-cart-outlined" /></template>
                          生成采购订单
                        </a-button>
                        <a-popconfirm v-if="canDeleteAward" title="确定删除该定标记录?" ok-text="确定" cancel-text="取消" @confirm="handleDeleteAward">
                          <a-button type="link" danger size="small" class="mt-2">删除定标</a-button>
                        </a-popconfirm>
                      </div>
                    </template>
                    <template v-else>
                      <div class="text-center">
                        <div class="text-gray-500 text-sm mb-3">定标信息已创建,请审批</div>
                        <a-button v-if="canApproveAward" type="primary" block @click="handleApproveAward" style="background: #52c41a; border-color: #52c41a;">
                          <template #icon><IconifyIcon icon="ant-design:check-outlined" /></template>
                          审批通过
                        </a-button>
                        <a-popconfirm v-if="canDeleteAward" title="确定删除该定标记录?" ok-text="确定" cancel-text="取消" @confirm="handleDeleteAward">
                          <a-button type="link" danger size="small" class="mt-2">删除定标</a-button>
                        </a-popconfirm>
                      </div>
                    </template>
                  </a-col>
                </a-row>
              </template>
              <template v-else>
                <div class="text-center py-8">
                  <a-result status="info" title="尚未定标" sub-title="基于评标排名选择中标供应商并创建定标" />
                  <br />
                  <a-button v-if="isEvaluating" type="primary" @click="awardForm = { tenderProjectId: projectId, supplierId: undefined!, bidId: undefined!, awardNo: '' }; awardFormVisible = true">
                    <template #icon><IconifyIcon icon="ant-design:plus-outlined" /></template>
                    创建定标
                  </a-button>
                </div>
              </template>
            </a-tab-pane>
          </a-tabs>
        </a-card>
      </div>
 
      <!-- ========== 弹窗 ========== -->
 
      <!-- 物料表单 -->
      <a-modal v-model:open="materialFormVisible" :title="materialForm.id ? '编辑物料' : '添加物料'" :width="560" @ok="handleSaveMaterial">
        <a-form layout="vertical" class="mt-4">
          <a-form-item label="MDM物料" required>
            <a-select v-model:value="materialForm.productId" show-search placeholder="搜索并选择MDM物料" :filter-option="filterOption" option-label-prop="label" @change="onMaterialSelect">
              <a-select-option v-for="item in availableMdmItems" :key="item.id" :value="item.id" :label="`${item.code} ${item.name}`">
                <div class="flex flex-col">
                  <span class="font-medium">{{ item.code }}</span>
                  <span class="text-xs text-gray-400">{{ item.name }}{{ item.specification ? ` · ${item.specification}` : '' }}</span>
                </div>
              </a-select-option>
            </a-select>
          </a-form-item>
          <a-row :gutter="12">
            <a-col :span="12">
              <a-form-item label="物料名称" required><a-input v-model:value="materialForm.productName" placeholder="自动带入" /></a-form-item>
            </a-col>
            <a-col :span="12">
              <a-form-item label="规格型号"><a-input v-model:value="materialForm.productSpec" placeholder="自动带入" /></a-form-item>
            </a-col>
          </a-row>
          <a-row :gutter="12">
            <a-col :span="8">
              <a-form-item label="单位"><a-input v-model:value="materialForm.unit" placeholder="自动带入" /></a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item label="数量" required><a-input-number v-model:value="materialForm.quantity" :min="0" class="!w-full" placeholder="数量" /></a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item label="预估单价"><a-input-number v-model:value="materialForm.estimatedPrice" :min="0" class="!w-full" placeholder="单价" /></a-form-item>
            </a-col>
          </a-row>
          <a-form-item label="技术要求">
            <a-textarea v-model:value="materialForm.techRequirement" placeholder="如:符合GB/T标准" :rows="2" />
          </a-form-item>
        </a-form>
      </a-modal>
 
      <!-- 投标表单 -->
      <a-modal v-model:open="bidFormVisible" title="新增投标" :width="460" @ok="handleCreateBid">
        <a-form layout="vertical" class="mt-4">
          <a-form-item label="投标编号" required><a-input v-model:value="bidForm.bidNo" placeholder="如 BID2024010001" /></a-form-item>
          <a-form-item label="供应商" required>
            <a-select v-model:value="bidForm.supplierId" show-search placeholder="搜索并选择供应商" :filter-option="filterOption">
              <a-select-option v-for="s in supplierList" :key="s.id" :value="s.id" :label="s.name">{{ s.name }}</a-select-option>
            </a-select>
          </a-form-item>
          <a-form-item label="投标总金额">
            <a-input-number v-model:value="bidForm.bidTotalAmount" :min="0" class="!w-full" placeholder="投标总金额"><template #addonAfter>元</template></a-input-number>
          </a-form-item>
        </a-form>
      </a-modal>
 
      <!-- 报价表单 -->
      <a-modal v-model:open="quoteFormVisible" :title="quoteForm.id ? '编辑报价' : '新增报价'" :width="560" @ok="handleSaveQuote">
        <a-form layout="vertical" class="mt-4">
          <a-form-item label="招标物料" required>
            <a-select v-model:value="quoteForm.tenderMaterialId" show-search placeholder="搜索并选择招标物料" :filter-option="filterOption">
              <a-select-option v-for="m in availableMaterials" :key="m.id" :value="m.id" :label="m.productName">{{ m.productCode }} - {{ m.productName }}</a-select-option>
            </a-select>
          </a-form-item>
          <a-row :gutter="12">
            <a-col :span="8">
              <a-form-item label="报价单价" required><a-input-number v-model:value="quoteForm.quotePrice" :min="0" class="!w-full" placeholder="报价"><template #addonAfter>元</template></a-input-number></a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item label="税率(%)"><a-input-number v-model:value="quoteForm.taxRate" :min="0" :max="100" class="!w-full" placeholder="如 13" /></a-form-item>
            </a-col>
            <a-col :span="8">
              <a-form-item label="交期(天)"><a-input-number v-model:value="quoteForm.deliveryCycle" :min="0" class="!w-full" placeholder="天数" /></a-form-item>
            </a-col>
          </a-row>
          <a-row :gutter="12">
            <a-col :span="12">
              <a-form-item label="付款条件"><a-input v-model:value="quoteForm.paymentTerms" placeholder="如:货到30天付款" /></a-form-item>
            </a-col>
            <a-col :span="12">
              <a-form-item label="质保期(月)"><a-input-number v-model:value="quoteForm.warrantyPeriod" :min="0" class="!w-full" placeholder="月数" /></a-form-item>
            </a-col>
          </a-row>
          <a-form-item label="备注"><a-textarea v-model:value="quoteForm.remark" placeholder="如含运费" :rows="2" /></a-form-item>
        </a-form>
      </a-modal>
 
      <!-- 评标表单 -->
      <a-modal v-model:open="evalFormVisible" :title="evalForm.id ? '编辑评标' : '新增评标'" :width="600" @ok="handleCreateEvaluation">
        <a-form layout="vertical" class="mt-4">
          <a-row :gutter="12">
            <a-col :span="12">
              <a-form-item label="投标" required>
                <a-select v-model:value="evalForm.bidId" show-search placeholder="选择投标" :filter-option="filterOption"
                  @change="(val: number) => { const b = bidList.find(i => i.id === val); if (b) { evalForm.supplierId = b.supplierId; evalForm.supplierName = b.supplierName; } }">
                  <a-select-option v-for="b in bidList" :key="b.id" :value="b.id" :label="`${b.bidNo} - ${b.supplierName}`">{{ b.bidNo }} - {{ b.supplierName }}</a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
            <a-col :span="12">
              <a-form-item label="供应商">
                <a-select v-model:value="evalForm.supplierId" show-search placeholder="选择供应商" :filter-option="filterOption">
                  <a-select-option v-for="s in supplierList" :key="s.id" :value="s.id" :label="s.name">{{ s.name }}</a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
          </a-row>
          <a-divider class="!my-2">评分项(百分制)</a-divider>
          <a-row :gutter="12">
            <a-col :span="12"><a-form-item label="价格评分"><a-input-number v-model:value="evalForm.priceScore" :min="0" :max="100" class="!w-full" placeholder="0-100" /></a-form-item></a-col>
            <a-col :span="12"><a-form-item label="技术评分"><a-input-number v-model:value="evalForm.techScore" :min="0" :max="100" class="!w-full" placeholder="0-100" /></a-form-item></a-col>
            <a-col :span="12"><a-form-item label="交付评分"><a-input-number v-model:value="evalForm.deliveryScore" :min="0" :max="100" class="!w-full" placeholder="0-100" /></a-form-item></a-col>
            <a-col :span="12"><a-form-item label="服务评分"><a-input-number v-model:value="evalForm.serviceScore" :min="0" :max="100" class="!w-full" placeholder="0-100" /></a-form-item></a-col>
          </a-row>
          <a-divider class="!my-2" />
          <a-row :gutter="12">
            <a-col :span="12"><a-form-item label="评委"><a-input v-model:value="evalForm.evaluatorName" placeholder="评委姓名" /></a-form-item></a-col>
          </a-row>
          <a-form-item label="评标意见"><a-textarea v-model:value="evalForm.evaluationOpinion" placeholder="供应商的技术方案、交付能力等综合评价" :rows="3" /></a-form-item>
        </a-form>
      </a-modal>
 
      <!-- 简易模式:确认中标弹窗 -->
      <a-modal v-model:open="confirmModalVisible" title="确认中标" :width="460" @ok="handleSimpleConfirm">
        <a-form layout="vertical" class="mt-4">
          <a-form-item label="中标投标记录" required>
            <a-select
              v-model:value="confirmBidId"
              show-search
              placeholder="选择中标的投标记录"
              :filter-option="filterOption"
            >
              <a-select-option
                v-for="b in bidList.filter((i) => i.bidStatus !== BID_STATUS.WITHDRAWN)"
                :key="b.id"
                :value="b.id"
                :label="`${b.supplierName} - ${b.bidNo}`"
              >
                {{ b.supplierName }} - {{ b.bidNo }} (¥{{ b.bidTotalAmount?.toLocaleString?.() ?? b.bidTotalAmount }})
              </a-select-option>
            </a-select>
          </a-form-item>
          <div class="text-gray-400 text-xs">
            确认后将自动生成采购订单,该操作不可撤销。
          </div>
        </a-form>
      </a-modal>
 
      <!-- 定标表单 -->
      <a-modal v-model:open="awardFormVisible" title="创建定标" :width="500" @ok="handleCreateAward">
        <a-form layout="vertical" class="mt-4">
          <a-form-item label="定标编号" required><a-input v-model:value="awardForm.awardNo" placeholder="如 AWARD2024010001" /></a-form-item>
          <a-row :gutter="12">
            <a-col :span="12">
              <a-form-item label="供应商" required>
                <a-select v-model:value="awardForm.supplierId" show-search placeholder="选择供应商" :filter-option="filterOption" @change="onAwardSupplierChange">
                  <a-select-option v-for="s in bidSuppliers" :key="s.id" :value="s.id" :label="s.name">{{ s.name }}</a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
            <a-col :span="12">
              <a-form-item label="投标" required>
                <a-select v-model:value="awardForm.bidId" show-search placeholder="选择投标" :filter-option="filterOption" :disabled="!awardForm.supplierId" @change="onAwardBidChange">
                  <a-select-option v-for="b in activeBids" :key="b.id" :value="b.id" :label="`${b.bidNo} - ${b.supplierName}`">{{ b.bidNo }} - {{ b.supplierName }}</a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
          </a-row>
          <a-form-item label="定标金额" required>
            <a-input-number v-model:value="awardForm.awardAmount" :min="0" class="!w-full" placeholder="定标金额"><template #addonAfter>元</template></a-input-number>
          </a-form-item>
          <a-form-item label="备注"><a-textarea v-model:value="awardForm.remark" placeholder="如:综合评标第一名" :rows="2" /></a-form-item>
        </a-form>
      </a-modal>
    </template>
  </Page>
</template>