From 020a05d8d31565fc6fe2b0f76645cdabe8374e1c Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期一, 03 八月 2026 17:56:21 +0800
Subject: [PATCH] refactor(srm): 优化招标项目功能实现

---
 src/views/srm/tender/detail.vue |   57 +++++++++++++++++++++++++++++++++++----------------------
 1 files changed, 35 insertions(+), 22 deletions(-)

diff --git a/src/views/srm/tender/detail.vue b/src/views/srm/tender/detail.vue
index 7de94be..839df72 100644
--- a/src/views/srm/tender/detail.vue
+++ b/src/views/srm/tender/detail.vue
@@ -126,7 +126,7 @@
 const bidList = ref<SrmTenderApi.TenderBidVO[]>([]);
 const bidLoading = ref(false);
 const bidFormVisible = ref(false);
-const bidForm = ref<SrmTenderApi.TenderBidVO>({ tenderProjectId: projectId, supplierId: 0, bidNo: '' });
+const bidForm = ref<SrmTenderApi.TenderBidVO>({ tenderProjectId: projectId, supplierId: undefined!, bidNo: '' });
 
 async function loadBids() {
   bidLoading.value = true;
@@ -146,7 +146,7 @@
 const quoteList = ref<SrmTenderApi.QuoteVO[]>([]);
 const quoteLoading = ref(false);
 const quoteFormVisible = ref(false);
-const quoteForm = ref<SrmTenderApi.QuoteVO>({ bidId: 0, tenderMaterialId: 0 });
+const quoteForm = ref<SrmTenderApi.QuoteVO>({ bidId: undefined!, tenderMaterialId: undefined! });
 const selectedBidId = ref<number>();
 
 const availableMaterials = computed(() => {
@@ -199,7 +199,7 @@
   loadQuotes(selectedBidId.value);
 }
 function handleAddQuote() {
-  quoteForm.value = { bidId: selectedBidId.value!, tenderMaterialId: 0 };
+  quoteForm.value = { bidId: selectedBidId.value!, tenderMaterialId: undefined! };
   quoteFormVisible.value = true;
 }
 function handleEditQuote(row: SrmTenderApi.QuoteVO) {
@@ -226,7 +226,7 @@
 const evaluationList = ref<SrmTenderApi.BidEvaluationVO[]>([]);
 const evalLoading = ref(false);
 const evalFormVisible = ref(false);
-const evalForm = ref<SrmTenderApi.BidEvaluationVO>({ tenderProjectId: projectId, supplierId: 0, bidId: 0 });
+const evalForm = ref<SrmTenderApi.BidEvaluationVO>({ tenderProjectId: projectId, supplierId: undefined!, bidId: undefined! });
 
 async function loadEvaluations() {
   evalLoading.value = true;
@@ -251,7 +251,7 @@
 // ========== 瀹氭爣 ==========
 const award = ref<SrmTenderApi.BidAwardVO>();
 const awardFormVisible = ref(false);
-const awardForm = ref<SrmTenderApi.BidAwardVO>({ tenderProjectId: projectId, supplierId: 0, bidId: 0, awardNo: '' });
+const awardForm = ref<SrmTenderApi.BidAwardVO>({ tenderProjectId: projectId, supplierId: undefined!, bidId: undefined!, awardNo: '' });
 
 async function loadAward() {
   try { award.value = await getAwardByProject(projectId); } catch { award.value = undefined; }
@@ -295,7 +295,20 @@
 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 isAwarded = computed(() => project.value?.tenderStatus === TENDER_STATUS.AWARDED);
+const isDraft = computed(() => project.value?.tenderStatus === TENDER_STATUS.DRAFT);
+const isPublished = computed(() => project.value?.tenderStatus === TENDER_STATUS.PUBLISHED);
+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 stepItems = [
   { title: '鑽夌', status: TENDER_STATUS.DRAFT },
@@ -462,7 +475,7 @@
                 <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="!isAwarded" type="primary" size="small" @click="handleAddMaterial">
+                <a-button v-if="isDraft" type="primary" size="small" @click="handleAddMaterial">
                   <template #icon><IconifyIcon icon="ant-design:plus-outlined" /></template>
                   娣诲姞鐗╂枡
                 </a-button>
@@ -473,7 +486,7 @@
                     {{ record.estimatedPrice ? record.estimatedPrice.toLocaleString() : '-' }}
                   </template>
                   <template v-if="column.key === 'actions'">
-                    <a-space v-if="!isAwarded">
+                    <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>
@@ -492,7 +505,7 @@
               </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="!isAwarded" type="primary" size="small" @click="bidForm = { tenderProjectId: projectId, supplierId: 0, bidNo: '' }; bidFormVisible = true">
+                <a-button v-if="isPublishedOrBidding" type="primary" size="small" @click="bidForm = { tenderProjectId: projectId, supplierId: undefined!, bidNo: '' }; bidFormVisible = true">
                   <template #icon><IconifyIcon icon="ant-design:plus-outlined" /></template>
                   鏂板鎶曟爣
                 </a-button>
@@ -510,7 +523,7 @@
                   <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="!isAwarded && record.bidStatus === BID_STATUS.REGISTERED" title="纭鎾ゆ爣锛�" @confirm="handleWithdrawBid(record.id)">
+                      <a-popconfirm v-if="isPublishedOrBidding && 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>
@@ -533,7 +546,7 @@
                   <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="!isAwarded && selectedBid.bidStatus !== BID_STATUS.WITHDRAWN" type="primary" size="small" @click="handleAddQuote">
+                  <a-button v-if="isPublishedOrBidding && selectedBid.bidStatus !== BID_STATUS.WITHDRAWN" type="primary" size="small" @click="handleAddQuote">
                     <template #icon><IconifyIcon icon="ant-design:plus-outlined" /></template>
                     鏂板鎶ヤ环
                   </a-button>
@@ -553,7 +566,7 @@
                       {{ record.warrantyPeriod != null ? `${record.warrantyPeriod} 涓湀` : '-' }}
                     </template>
                     <template v-if="column.key === 'actions'">
-                      <a-button v-if="!isAwarded && selectedBid?.bidStatus !== BID_STATUS.WITHDRAWN" size="small" type="link" @click="handleEditQuote(record)"><IconifyIcon icon="ant-design:edit-outlined" />缂栬緫</a-button>
+                      <a-button v-if="isPublishedOrBidding && selectedBid?.bidStatus !== BID_STATUS.WITHDRAWN" size="small" type="link" @click="handleEditQuote(record)"><IconifyIcon icon="ant-design:edit-outlined" />缂栬緫</a-button>
                     </template>
                   </template>
                 </a-table>
@@ -583,7 +596,7 @@
                 <div class="text-center py-8">
                   <a-result status="info" title="灏氭湭寮�鏍�" sub-title="鎵ц寮�鏍囧悗椤圭洰杩涘叆鎶曟爣闃舵锛屼緵搴斿晢鍙寮忔姇鏍�" />
                   <br />
-                  <a-button v-if="!isAwarded" type="primary" @click="handleCreateBidOpen">
+                  <a-button v-if="isPublished" type="primary" @click="handleCreateBidOpen">
                     <template #icon><IconifyIcon icon="ant-design:thunderbolt-outlined" /></template>
                     鎵ц寮�鏍�
                   </a-button>
@@ -598,12 +611,12 @@
               </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="!isAwarded">
+                <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: 0, bidId: 0 }; evalFormVisible = true">
+                  <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>
@@ -630,7 +643,7 @@
                     <span v-else class="text-gray-300">-</span>
                   </template>
                   <template v-if="column.key === 'actions'">
-                    <a-button v-if="!isAwarded" size="small" type="link" @click="evalForm = { ...record }; evalFormVisible = true"><IconifyIcon icon="ant-design:edit-outlined" />缂栬緫</a-button>
+                    <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>
@@ -671,7 +684,7 @@
                             <span class="text-sm">閲囪喘璁㈠崟 ID: {{ award.purchaseOrderId }}</span>
                           </template>
                         </a-result>
-                        <a-popconfirm v-if="!isAwarded" title="纭畾鍒犻櫎璇ュ畾鏍囪褰曪紵" ok-text="纭畾" cancel-text="鍙栨秷" @confirm="handleDeleteAward">
+                        <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>
@@ -679,11 +692,11 @@
                     <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="!isAwarded" type="primary" block @click="handleGeneratePurchaseOrder">
+                        <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="!isAwarded" title="纭畾鍒犻櫎璇ュ畾鏍囪褰曪紵" ok-text="纭畾" cancel-text="鍙栨秷" @confirm="handleDeleteAward">
+                        <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>
@@ -691,11 +704,11 @@
                     <template v-else>
                       <div class="text-center">
                         <div class="text-gray-500 text-sm mb-3">瀹氭爣淇℃伅宸插垱寤猴紝璇峰鎵�</div>
-                        <a-button v-if="!isAwarded" type="primary" block @click="handleApproveAward" style="background: #52c41a; border-color: #52c41a;">
+                        <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="!isAwarded" title="纭畾鍒犻櫎璇ュ畾鏍囪褰曪紵" ok-text="纭畾" cancel-text="鍙栨秷" @confirm="handleDeleteAward">
+                        <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>
@@ -707,7 +720,7 @@
                 <div class="text-center py-8">
                   <a-result status="info" title="灏氭湭瀹氭爣" sub-title="鍩轰簬璇勬爣鎺掑悕閫夋嫨涓爣渚涘簲鍟嗗苟鍒涘缓瀹氭爣" />
                   <br />
-                  <a-button v-if="!isAwarded" type="primary" @click="awardForm = { tenderProjectId: projectId, supplierId: 0, bidId: 0, awardNo: '' }; awardFormVisible = true">
+                  <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>

--
Gitblit v1.9.3