Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
王蔡翾
rz-GB-web
Commits
d3f9042b
Commit
d3f9042b
authored
Nov 18, 2026
by
王蔡翾
Browse files
bug修复
parent
6ed251e9
Changes
4
Show whitespace changes
Inline
Side-by-side
scripts/verify-prototype.mjs
View file @
d3f9042b
import
assert
from
'
node:assert/strict
'
import
assert
from
'
node:assert/strict
'
import
{
extractProfileFromText
}
from
'
../src/lib/profileImport.ts
'
import
{
extractProfileFromText
}
from
'
../src/lib/profileImport.ts
'
import
{
registrationDate
,
registrationReminder
}
from
'
../src/lib/day2.ts
'
import
{
registrationDate
,
registrationReminder
,
opportunityReminder
}
from
'
../src/lib/day2.ts
'
import
{
researchSourceLabel
,
toolNames
}
from
'
../src/lib/day3.ts
'
import
{
researchSourceLabel
,
toolNames
}
from
'
../src/lib/day3.ts
'
// 验收型公司名称曾触发“业绩”误识别;导入应保留原文事实并去掉字段标签。
// 验收型公司名称曾触发“业绩”误识别;导入应保留原文事实并去掉字段标签。
...
@@ -27,6 +27,23 @@ assert.equal(registrationReminder(deadline, '2026-11-11', Date.parse('2026-11-11
...
@@ -27,6 +27,23 @@ assert.equal(registrationReminder(deadline, '2026-11-11', Date.parse('2026-11-11
assert
.
equal
(
registrationReminder
(
deadline
,
'
2026-11-11
'
,
Date
.
parse
(
'
2026-11-11T17:30:00+08:00
'
))?.
label
,
'
报名已截止
'
)
assert
.
equal
(
registrationReminder
(
deadline
,
'
2026-11-11
'
,
Date
.
parse
(
'
2026-11-11T17:30:00+08:00
'
))?.
label
,
'
报名已截止
'
)
assert
.
equal
(
registrationReminder
(
deadline
,
'
2026-11-11
'
)?.
display
,
'
2026-11-11 17:30
'
)
assert
.
equal
(
registrationReminder
(
deadline
,
'
2026-11-11
'
)?.
display
,
'
2026-11-11 17:30
'
)
// 用户公告仅给出提交投标文件截止及开标时间,保留投标标签,并处理实体空格、拆开的年份和中文时段。
const
submission
=
[
'
 提交投标文件截止及开标时间: 202 6 年 11 月 13 日 上午 9 : 00
'
]
assert
.
equal
(
opportunityReminder
(
submission
,
'
2026-11-18
'
)?.
display
,
'
2026-11-13 09:00
'
)
assert
.
equal
(
opportunityReminder
(
submission
,
'
2026-11-18
'
)?.
label
,
'
投标已截止
'
)
assert
.
equal
(
opportunityReminder
(
submission
,
'
2026-11-13
'
,
Date
.
parse
(
'
2026-11-13T08:59:59+08:00
'
))?.
label
,
'
投标今天截止
'
)
assert
.
equal
(
opportunityReminder
(
submission
,
'
2026-11-13
'
,
Date
.
parse
(
'
2026-11-13T09:00:00+08:00
'
))?.
label
,
'
投标已截止
'
)
assert
.
equal
(
registrationDate
(
submission
),
null
)
assert
.
equal
(
opportunityReminder
([
'
投标截止时间:2026年11月13日下午3 : 30
'
])?.
display
,
'
2026-11-13 15:30
'
)
assert
.
equal
(
opportunityReminder
([
'
响应文件提交截止时间:2026年11月13日上午9:00
'
])?.
display
,
'
2026-11-13 09:00
'
)
assert
.
equal
(
opportunityReminder
([...
submission
,
'
报名截止2026年11月10日
'
],
'
2026-11-18
'
)?.
display
,
'
2026-11-10
'
)
assert
.
equal
(
opportunityReminder
([...
submission
,
'
报名截止2026年11月10日
'
],
'
2026-11-18
'
)?.
label
,
'
报名已截止
'
)
assert
.
equal
(
opportunityReminder
([
'
开标时间:2026年11月13日9:00
'
]),
null
)
assert
.
equal
(
opportunityReminder
([
'
服务截止时间:2026年11月13日
'
]),
null
)
assert
.
equal
(
opportunityReminder
([
'
投标截止2026-02-30
'
]),
null
)
assert
.
equal
(
opportunityReminder
(),
null
)
assert
.
equal
(
registrationReminder
([
'
报名截止时间:202 6 年 11 月 13 日 下午 3 : 00
'
])?.
display
,
'
2026-11-13 15:00
'
)
// 历史回答来源中既有后端工具名,也有真实标题。展示时应保留专名,并为缺失标题提供中文提示。
// 历史回答来源中既有后端工具名,也有真实标题。展示时应保留专名,并为缺失标题提供中文提示。
assert
.
equal
(
toolNames
.
SNAPSHOT_QA
,
'
生成追问回答
'
)
assert
.
equal
(
toolNames
.
SNAPSHOT_QA
,
'
生成追问回答
'
)
assert
.
equal
(
researchSourceLabel
(
'
get_company_profile
'
,
false
),
'
基础画像
'
)
assert
.
equal
(
researchSourceLabel
(
'
get_company_profile
'
,
false
),
'
基础画像
'
)
...
...
scripts/verify-search.mjs
View file @
d3f9042b
...
@@ -11,12 +11,15 @@ try {
...
@@ -11,12 +11,15 @@ try {
// 复现用户条件及旧方案:地区/预算进入硬条件,关键词与日期不因模式转换丢失。
// 复现用户条件及旧方案:地区/预算进入硬条件,关键词与日期不因模式转换丢失。
const
legacy
=
{
const
legacy
=
{
...
initialQuery
(),
...
publicationRange
(
30
),
keywords
:
[
'
智慧水务监测
'
],
...
initialQuery
(),
...
publicationRange
(
30
),
keywords
:
[
'
智慧水务监测
'
],
stages
:
[
1
,
2
,
4
,
7
,
8
],
preferredRegions
:
[
'
江苏
'
],
budgetMinWan
:
50
,
budgetMaxWan
:
200
,
preferredRegions
:
[
'
江苏
'
],
budgetMinWan
:
50
,
budgetMaxWan
:
200
,
}
}
const
frozen
=
JSON
.
stringify
(
legacy
)
const
frozen
=
JSON
.
stringify
(
legacy
)
const
search
=
asSearchQuery
(
legacy
)
const
search
=
asSearchQuery
(
legacy
)
assert
.
equal
(
search
.
mode
,
'
SEARCH
'
)
assert
.
equal
(
search
.
mode
,
'
SEARCH
'
)
assert
.
deepEqual
(
initialQuery
().
stages
,
[
1
,
2
,
4
,
8
])
assert
.
deepEqual
(
search
.
stages
,
[
1
,
2
,
4
,
8
])
assert
.
deepEqual
(
asSearchQuery
({
...
search
,
stages
:
[
7
,
8
]
}).
stages
,
[
8
])
assert
.
deepEqual
(
search
.
hardRegions
,
[
'
江苏
'
])
assert
.
deepEqual
(
search
.
hardRegions
,
[
'
江苏
'
])
assert
.
equal
(
search
.
hardMinWan
,
50
)
assert
.
equal
(
search
.
hardMinWan
,
50
)
assert
.
equal
(
search
.
hardMaxWan
,
200
)
assert
.
equal
(
search
.
hardMaxWan
,
200
)
...
...
src/components/OpportunityTable.tsx
View file @
d3f9042b
...
@@ -2,7 +2,7 @@ import { useState } from 'react'
...
@@ -2,7 +2,7 @@ import { useState } from 'react'
import
{
ChevronLeft
,
ChevronRight
,
ExternalLink
,
Sparkles
,
Star
,
Tag
}
from
'
lucide-react
'
import
{
ChevronLeft
,
ChevronRight
,
ExternalLink
,
Sparkles
,
Star
,
Tag
}
from
'
lucide-react
'
import
*
as
Popover
from
'
@radix-ui/react-popover
'
import
*
as
Popover
from
'
@radix-ui/react-popover
'
import
type
{
RankedItem
}
from
'
../lib/day2
'
import
type
{
RankedItem
}
from
'
../lib/day2
'
import
{
message
,
registration
Reminder
}
from
'
../lib/day2
'
import
{
message
,
opportunity
Reminder
}
from
'
../lib/day2
'
import
{
useStore
}
from
'
../lib/store
'
import
{
useStore
}
from
'
../lib/store
'
import
{
defaultMatchDimNames
}
from
'
../types
'
import
{
defaultMatchDimNames
}
from
'
../types
'
import
type
{
AnalysisPanelState
}
from
'
./AiPanel
'
import
type
{
AnalysisPanelState
}
from
'
./AiPanel
'
...
@@ -40,7 +40,8 @@ export function OpportunityTable({ items, batchId, onOpenPanel }: {
...
@@ -40,7 +40,8 @@ export function OpportunityTable({ items, batchId, onOpenPanel }: {
<
thead
><
tr
className
=
"border-b border-line-soft bg-[#FAFBFD] text-ink-400"
>
{
[
'
项目与建设内容
'
,
'
招标方与地域
'
,
'
预算
'
,
'
时间节奏
'
,
'
参与门槛
'
,
'
匹配度
'
,
'
操作
'
].
map
((
name
,
i
)
=>
<
th
key
=
{
name
}
className
=
{
i
===
0
?
'
px-5 py-2.5 font-medium
'
:
'
px-3 py-2.5 font-medium
'
}
>
{
name
}
</
th
>)
}
</
tr
></
thead
>
<
thead
><
tr
className
=
"border-b border-line-soft bg-[#FAFBFD] text-ink-400"
>
{
[
'
项目与建设内容
'
,
'
招标方与地域
'
,
'
预算
'
,
'
时间节奏
'
,
'
参与门槛
'
,
'
匹配度
'
,
'
操作
'
].
map
((
name
,
i
)
=>
<
th
key
=
{
name
}
className
=
{
i
===
0
?
'
px-5 py-2.5 font-medium
'
:
'
px-3 py-2.5 font-medium
'
}
>
{
name
}
</
th
>)
}
</
tr
></
thead
>
<
tbody
>
{
rows
.
map
(
item
=>
{
<
tbody
>
{
rows
.
map
(
item
=>
{
const
p
=
item
.
facts
,
summary
=
item
.
analysis
?.
summary
,
match
=
item
.
analysis
?.
match
const
p
=
item
.
facts
,
summary
=
item
.
analysis
?.
summary
,
match
=
item
.
analysis
?.
match
const
reminder
=
registrationReminder
(
summary
?.
schedule
)
// 服务端已校验的 AI 时间结论也参与识别,兼容旧摘录中日期和截止标签被拆开的公告。
const
reminder
=
opportunityReminder
([...(
summary
?.
schedule
??
[]),
summary
?.
conclusion
?.
timing
??
''
])
const
construction
=
summary
?.
conclusion
?.
construction
||
summary
?.
construction
||
p
.
products
.
join
(
'
、
'
)
||
(
p
.
title
?
`标题线索 ·
${
p
.
title
}
`
:
'
项目建设内容待核验
'
)
const
construction
=
summary
?.
conclusion
?.
construction
||
summary
?.
construction
||
p
.
products
.
join
(
'
、
'
)
||
(
p
.
title
?
`标题线索 ·
${
p
.
title
}
`
:
'
项目建设内容待核验
'
)
const
qualifications
=
summary
?.
qualifications
??
[]
const
qualifications
=
summary
?.
qualifications
??
[]
// 同一行尽量兼顾资质与业绩,不让多个同类条款把另一项挤出列表。
// 同一行尽量兼顾资质与业绩,不让多个同类条款把另一项挤出列表。
...
@@ -51,7 +52,16 @@ export function OpportunityTable({ items, batchId, onOpenPanel }: {
...
@@ -51,7 +52,16 @@ export function OpportunityTable({ items, batchId, onOpenPanel }: {
<
td
className
=
"px-5 py-3"
><
a
href
=
{
p
.
url
??
undefined
}
target
=
"_blank"
rel
=
"noreferrer"
onClick
=
{
e
=>
{
e
.
stopPropagation
();
if
(
!
p
.
url
)
open
(
item
)
}
}
className
=
"inline-flex items-start gap-1 font-medium leading-snug text-ink-900 hover:text-brand-500 hover:underline"
><
span
>
{
p
.
title
||
'
标题待核验
'
}
</
span
>
{
p
.
url
&&
<
ExternalLink
size
=
{
12
}
className
=
"mt-1 shrink-0 text-ink-400"
/>
}
</
a
><
p
className
=
"mt-1 break-words text-xs leading-relaxed text-ink-600"
><
span
className
=
"font-medium"
>
建设内容
</
span
>
·
{
construction
}
</
p
></
td
>
<
td
className
=
"px-5 py-3"
><
a
href
=
{
p
.
url
??
undefined
}
target
=
"_blank"
rel
=
"noreferrer"
onClick
=
{
e
=>
{
e
.
stopPropagation
();
if
(
!
p
.
url
)
open
(
item
)
}
}
className
=
"inline-flex items-start gap-1 font-medium leading-snug text-ink-900 hover:text-brand-500 hover:underline"
><
span
>
{
p
.
title
||
'
标题待核验
'
}
</
span
>
{
p
.
url
&&
<
ExternalLink
size
=
{
12
}
className
=
"mt-1 shrink-0 text-ink-400"
/>
}
</
a
><
p
className
=
"mt-1 break-words text-xs leading-relaxed text-ink-600"
><
span
className
=
"font-medium"
>
建设内容
</
span
>
·
{
construction
}
</
p
></
td
>
<
td
className
=
"px-3 py-3"
><
div
className
=
"leading-snug"
>
{
p
.
purchaser
||
'
待核验
'
}
</
div
><
div
className
=
"mt-1 text-xs text-ink-600"
>
地域 ·
{
summary
?.
conclusion
?.
region
||
summary
?.
region
||
p
.
region
||
'
项目地域待核验
'
}
</
div
></
td
>
<
td
className
=
"px-3 py-3"
><
div
className
=
"leading-snug"
>
{
p
.
purchaser
||
'
待核验
'
}
</
div
><
div
className
=
"mt-1 text-xs text-ink-600"
>
地域 ·
{
summary
?.
conclusion
?.
region
||
summary
?.
region
||
p
.
region
||
'
项目地域待核验
'
}
</
div
></
td
>
<
td
className
=
"whitespace-nowrap px-3 py-3"
>
{
p
.
budgetWan
==
null
?
<
span
className
=
"text-ink-400"
>
未披露
</
span
>
:
<
span
className
=
"font-num font-bold"
>
{
p
.
budgetWan
.
toLocaleString
()
}
<
span
className
=
"text-xs font-medium text-ink-400"
>
万元
</
span
></
span
>
}
</
td
>
<
td
className
=
"whitespace-nowrap px-3 py-3"
>
{
p
.
budgetWan
==
null
?
<
span
className
=
"text-ink-400"
>
未披露
</
span
>
:
<
span
className
=
"font-num font-bold"
>
{
p
.
budgetWan
.
toLocaleString
()
}
<
span
className
=
"text-xs font-medium text-ink-400"
>
万元
</
span
></
span
>
}
</
td
>
<
td
className
=
"px-3 py-3 text-xs"
><
p
className
=
{
`font-semibold
${
reminder
&&
reminder
.
days
>=
0
&&
reminder
.
days
<=
7
?
'
text-bad-500
'
:
'
text-ink-600
'
}
`
}
>
{
reminder
?.
label
??
'
报名截止时间待核验
'
}
</
p
>
{
reminder
&&
<
time
className
=
"mt-1 block font-num text-ink-600"
dateTime
=
{
reminder
.
dateTime
}
>
{
reminder
.
display
}
</
time
>
}{
timing
&&
<
p
className
=
"mt-1 break-words text-ink-600"
>
{
timing
}
</
p
>
}
<
p
className
=
"mt-1 font-num text-ink-400"
>
发布
{
p
.
publishDate
||
'
未知
'
}
</
p
></
td
>
<
td
className
=
"px-3 py-3 text-xs"
>
{
/* 时间节奏显示已取得的截止日或工期。只有两者都缺失时才显示待核验提示。 */
}
{
reminder
&&
<>
<
p
className
=
{
`font-semibold
${
reminder
.
days
>=
0
&&
reminder
.
days
<=
7
?
'
text-bad-500
'
:
'
text-ink-600
'
}
`
}
>
{
reminder
.
label
}
</
p
>
<
time
className
=
"mt-1 block font-num text-ink-600"
dateTime
=
{
reminder
.
dateTime
}
>
{
reminder
.
display
}
</
time
>
</>
}
{
timing
&&
<
p
className
=
"mt-1 break-words text-ink-600"
>
{
timing
}
</
p
>
}
{
!
reminder
&&
!
timing
&&
<
p
className
=
"text-ink-600"
>
时间安排待核验
</
p
>
}
<
p
className
=
"mt-1 font-num text-ink-400"
>
发布
{
p
.
publishDate
||
'
未知
'
}
</
p
>
</
td
>
<
td
className
=
"px-3 py-3 text-xs leading-relaxed text-ink-600"
>
{
summary
?.
conclusion
?.
participation
||
((
requirements
.
length
?
requirements
:
qualifications
).
slice
(
0
,
2
).
map
((
line
,
i
)
=>
<
p
key
=
{
i
}
className
=
"mb-1 break-words"
>
{
line
}
</
p
>))
}{
!
summary
?.
conclusion
?.
participation
&&
!
qualifications
.
length
&&
'
请核对公告中的资格和业绩要求
'
}
</
td
>
<
td
className
=
"px-3 py-3 text-xs leading-relaxed text-ink-600"
>
{
summary
?.
conclusion
?.
participation
||
((
requirements
.
length
?
requirements
:
qualifications
).
slice
(
0
,
2
).
map
((
line
,
i
)
=>
<
p
key
=
{
i
}
className
=
"mb-1 break-words"
>
{
line
}
</
p
>))
}{
!
summary
?.
conclusion
?.
participation
&&
!
qualifications
.
length
&&
'
请核对公告中的资格和业绩要求
'
}
</
td
>
{
/* 匹配度是只读浮层。悬停时不抢现有光标,关闭时也不把刚切到检索框的焦点还给分数按钮。 */
}
{
/* 匹配度是只读浮层。悬停时不抢现有光标,关闭时也不把刚切到检索框的焦点还给分数按钮。 */
}
<
td
className
=
"px-3 py-3"
><
Popover
.
Root
open
=
{
scoreProject
===
p
.
id
}
onOpenChange
=
{
value
=>
setScoreProject
(
value
?
p
.
id
:
null
)
}
><
Popover
.
Trigger
asChild
><
button
onMouseEnter
=
{
()
=>
setScoreProject
(
p
.
id
)
}
onMouseLeave
=
{
()
=>
setScoreProject
(
null
)
}
onFocus
=
{
()
=>
setScoreProject
(
p
.
id
)
}
onBlur
=
{
()
=>
setScoreProject
(
null
)
}
onClick
=
{
e
=>
e
.
stopPropagation
()
}
className
=
"whitespace-nowrap font-num text-[15px] font-bold text-brand-500"
aria
-
label
=
{
`查看
${
p
.
title
}
匹配度构成`
}
>
{
match
?.
score
??
'
—
'
}{
match
?.
score
!=
null
&&
<
span
className
=
"text-xs font-medium text-ink-400"
>
分
</
span
>
}
</
button
></
Popover
.
Trigger
><
Popover
.
Portal
><
Popover
.
Content
onOpenAutoFocus
=
{
e
=>
e
.
preventDefault
()
}
onCloseAutoFocus
=
{
e
=>
e
.
preventDefault
()
}
onClick
=
{
e
=>
e
.
stopPropagation
()
}
sideOffset
=
{
8
}
className
=
"z-50 w-72 rounded-card border border-line-soft bg-white p-3 shadow-card-hover"
><
h4
className
=
"text-xs font-medium"
>
贴合度打分构成
</
h4
>
{
match
?
<><
ul
className
=
"mt-2 space-y-2"
>
{
Object
.
entries
(
match
.
dimensions
).
map
(([
key
,
dim
])
=>
<
li
key
=
{
key
}
className
=
"text-xs"
><
div
className
=
"flex justify-between"
><
span
>
{
defaultMatchDimNames
[
key
as
keyof
typeof
defaultMatchDimNames
]
??
key
}
· 权重
{
match
.
weights
[
key
]
}
%
</
span
><
b
>
{
dim
.
known
?
`
${
dim
.
score
}
分`
:
'
待核验
'
}
</
b
></
div
><
p
className
=
"mt-0.5 text-[11px] text-ink-400"
>
{
dim
.
basis
}
</
p
></
li
>)
}
</
ul
><
p
className
=
"mt-2 text-[11px] text-ink-400"
>
完整性
{
match
.
completeness
}
% · 档案 v
{
match
.
profileVersion
}
·
{
match
.
limitation
}
</
p
></>
:
<
p
className
=
"mt-2 text-xs text-ink-400"
>
尚无已保存评分,请完善公司档案后重新检索。
</
p
>
}
</
Popover
.
Content
></
Popover
.
Portal
></
Popover
.
Root
></
td
>
<
td
className
=
"px-3 py-3"
><
Popover
.
Root
open
=
{
scoreProject
===
p
.
id
}
onOpenChange
=
{
value
=>
setScoreProject
(
value
?
p
.
id
:
null
)
}
><
Popover
.
Trigger
asChild
><
button
onMouseEnter
=
{
()
=>
setScoreProject
(
p
.
id
)
}
onMouseLeave
=
{
()
=>
setScoreProject
(
null
)
}
onFocus
=
{
()
=>
setScoreProject
(
p
.
id
)
}
onBlur
=
{
()
=>
setScoreProject
(
null
)
}
onClick
=
{
e
=>
e
.
stopPropagation
()
}
className
=
"whitespace-nowrap font-num text-[15px] font-bold text-brand-500"
aria
-
label
=
{
`查看
${
p
.
title
}
匹配度构成`
}
>
{
match
?.
score
??
'
—
'
}{
match
?.
score
!=
null
&&
<
span
className
=
"text-xs font-medium text-ink-400"
>
分
</
span
>
}
</
button
></
Popover
.
Trigger
><
Popover
.
Portal
><
Popover
.
Content
onOpenAutoFocus
=
{
e
=>
e
.
preventDefault
()
}
onCloseAutoFocus
=
{
e
=>
e
.
preventDefault
()
}
onClick
=
{
e
=>
e
.
stopPropagation
()
}
sideOffset
=
{
8
}
className
=
"z-50 w-72 rounded-card border border-line-soft bg-white p-3 shadow-card-hover"
><
h4
className
=
"text-xs font-medium"
>
贴合度打分构成
</
h4
>
{
match
?
<><
ul
className
=
"mt-2 space-y-2"
>
{
Object
.
entries
(
match
.
dimensions
).
map
(([
key
,
dim
])
=>
<
li
key
=
{
key
}
className
=
"text-xs"
><
div
className
=
"flex justify-between"
><
span
>
{
defaultMatchDimNames
[
key
as
keyof
typeof
defaultMatchDimNames
]
??
key
}
· 权重
{
match
.
weights
[
key
]
}
%
</
span
><
b
>
{
dim
.
known
?
`
${
dim
.
score
}
分`
:
'
待核验
'
}
</
b
></
div
><
p
className
=
"mt-0.5 text-[11px] text-ink-400"
>
{
dim
.
basis
}
</
p
></
li
>)
}
</
ul
><
p
className
=
"mt-2 text-[11px] text-ink-400"
>
完整性
{
match
.
completeness
}
% · 档案 v
{
match
.
profileVersion
}
·
{
match
.
limitation
}
</
p
></>
:
<
p
className
=
"mt-2 text-xs text-ink-400"
>
尚无已保存评分,请完善公司档案后重新检索。
</
p
>
}
</
Popover
.
Content
></
Popover
.
Portal
></
Popover
.
Root
></
td
>
...
...
src/lib/day2.ts
View file @
d3f9042b
...
@@ -55,7 +55,7 @@ export function beijingDate(offset = 0) {
...
@@ -55,7 +55,7 @@ export function beijingDate(offset = 0) {
return
new
Date
(
Date
.
now
()
+
(
8
*
60
*
60
*
1000
)
-
offset
*
86400000
).
toISOString
().
slice
(
0
,
10
)
return
new
Date
(
Date
.
now
()
+
(
8
*
60
*
60
*
1000
)
-
offset
*
86400000
).
toISOString
().
slice
(
0
,
10
)
}
}
export
function
initialQuery
():
SearchQuery
{
export
function
initialQuery
():
SearchQuery
{
return
{
keywords
:
[],
beginDate
:
beijingDate
(
89
),
endDate
:
beijingDate
(),
stages
:
[
1
,
2
,
4
,
7
,
8
],
preference
:
'
COMPREHENSIVE
'
,
preferredRegions
:
[],
budgetMinWan
:
null
,
budgetMaxWan
:
null
,
mode
:
'
LEADS
'
,
keywordMode
:
'
ANY
'
,
hardRegions
:
[],
hardMinWan
:
null
,
hardMaxWan
:
null
}
return
{
keywords
:
[],
beginDate
:
beijingDate
(
89
),
endDate
:
beijingDate
(),
stages
:
[
1
,
2
,
4
,
8
],
preference
:
'
COMPREHENSIVE
'
,
preferredRegions
:
[],
budgetMinWan
:
null
,
budgetMaxWan
:
null
,
mode
:
'
LEADS
'
,
keywordMode
:
'
ANY
'
,
hardRegions
:
[],
hardMinWan
:
null
,
hardMaxWan
:
null
}
}
}
/**
/**
...
@@ -64,9 +64,10 @@ export function initialQuery(): SearchQuery {
...
@@ -64,9 +64,10 @@ export function initialQuery(): SearchQuery {
* 返回新对象,避免编辑表单时改写已保存方案或历史任务;市场查询仍保留自身模式。
* 返回新对象,避免编辑表单时改写已保存方案或历史任务;市场查询仍保留自身模式。
*/
*/
export
function
asSearchQuery
(
query
:
SearchQuery
):
SearchQuery
{
export
function
asSearchQuery
(
query
:
SearchQuery
):
SearchQuery
{
if
(
query
.
mode
!==
'
LEADS
'
)
return
{
...
query
}
// 编辑旧方案时仅移除中标阶段,其余公告阶段继续使用方案原有条件。
if
(
query
.
mode
!==
'
LEADS
'
)
return
{
...
query
,
stages
:
query
.
mode
===
'
SEARCH
'
?
query
.
stages
.
filter
(
stage
=>
stage
!==
7
)
:
query
.
stages
}
return
{
return
{
...
query
,
mode
:
'
SEARCH
'
,
preference
:
'
COMPREHENSIVE
'
,
...
query
,
stages
:
query
.
stages
.
filter
(
stage
=>
stage
!==
7
),
mode
:
'
SEARCH
'
,
preference
:
'
COMPREHENSIVE
'
,
hardRegions
:
[...
query
.
preferredRegions
],
hardMinWan
:
query
.
budgetMinWan
,
hardMaxWan
:
query
.
budgetMaxWan
,
hardRegions
:
[...
query
.
preferredRegions
],
hardMinWan
:
query
.
budgetMinWan
,
hardMaxWan
:
query
.
budgetMaxWan
,
preferredRegions
:
[],
budgetMinWan
:
null
,
budgetMaxWan
:
null
,
preferredRegions
:
[],
budgetMinWan
:
null
,
budgetMaxWan
:
null
,
}
}
...
@@ -86,22 +87,37 @@ export function time(value: string) { return new Date(value).toLocaleString('zh-
...
@@ -86,22 +87,37 @@ export function time(value: string) { return new Date(value).toLocaleString('zh-
const
registration
=
/报名
(?:
及获取文件
)?
|
(?:
获取|领取|下载|购买
)(?:
招标|采购|磋商|询价|比选
)
文件/g
const
registration
=
/报名
(?:
及获取文件
)?
|
(?:
获取|领取|下载|购买
)(?:
招标|采购|磋商|询价|比选
)
文件/g
const
calendarDate
=
/^
(\d{4})\s
*
[
-年
/
.
]\s
*
(\d{1,2})\s
*
[
-月
/
.
]\s
*
(\d{1,2})
/
const
calendarDate
=
/^
(\d{4})\s
*
[
-年
/
.
]\s
*
(\d{1,2})\s
*
[
-月
/
.
]\s
*
(\d{1,2})
/
/** 先解码空格实体再分句,避免   的分号切断日期;日期数字及冒号之间的排版空格统一去掉。 */
function
scheduleClauses
(
schedule
:
string
[])
{
return
schedule
.
flatMap
(
line
=>
line
.
replace
(
/ |&#
(?:
x0*20|0*32
)
;/gi
,
'
'
).
split
(
/
[
,,;;。
\n]
/
))
.
map
(
clause
=>
clause
.
replace
(
/
\s
+/g
,
''
))
}
/** 公告日期按北京时间解释,严格验证日历日期,并把上午/下午转换为 24 小时制。 */
function
noticeDeadline
(
value
=
''
)
{
const
match
=
value
.
match
(
calendarDate
)
if
(
!
match
)
return
null
const
date
=
`
${
match
[
1
]}
-
${
match
[
2
].
padStart
(
2
,
'
0
'
)}
-
${
match
[
3
].
padStart
(
2
,
'
0
'
)}
`
const
parsed
=
new
Date
(
`
${
date
}
T00:00:00Z`
)
if
(
!
Number
.
isFinite
(
parsed
.
getTime
())
||
parsed
.
toISOString
().
slice
(
0
,
10
)
!==
date
)
return
null
const
clock
=
value
.
slice
(
match
[
0
].
length
).
match
(
/^
[
日号T
]
*
(
上午|下午|中午|凌晨|晚上
)?([
01
]?\d
|2
[
0-3
])[
::
]([
0-5
]\d)(?:[
::
]([
0-5
]\d))?(?!\d)
/
)
if
(
!
clock
)
return
{
date
,
time
:
null
}
let
hour
=
Number
(
clock
[
2
])
if
(
/下午|中午|晚上/
.
test
(
clock
[
1
]
??
''
)
&&
hour
<
12
)
hour
+=
12
if
(
/上午|凌晨/
.
test
(
clock
[
1
]
??
''
)
&&
hour
===
12
)
hour
=
0
const
time
=
`
${
String
(
hour
).
padStart
(
2
,
'
0
'
)}
:
${
clock
[
3
]}${
clock
[
4
]
?
`:
${
clock
[
4
]}
`
:
''
}
`
return
{
date
,
time
}
}
/** 仅在报名或获取采购文件的条款内读取截止日。日期区间取尾端,投标、开标和服务结束日期不能补位。 */
/** 仅在报名或获取采购文件的条款内读取截止日。日期区间取尾端,投标、开标和服务结束日期不能补位。 */
function
registrationDeadline
(
schedule
:
string
[]
=
[])
{
function
registrationDeadline
(
schedule
:
string
[]
=
[])
{
for
(
const
clause
of
schedule
.
flatMap
(
line
=>
line
.
split
(
/
[
,,;;。
\n]
/
)
))
{
for
(
const
clause
of
schedule
Clauses
(
schedule
))
{
for
(
const
marker
of
clause
.
matchAll
(
registration
))
{
for
(
const
marker
of
clause
.
matchAll
(
registration
))
{
const
related
=
clause
.
slice
(
marker
.
index
+
marker
[
0
].
length
).
split
(
/
(?:
递交|提交
)(?:
投标|响应
)
|投标截止|响应截止|开标|服务
(?:
截止|期
)
|工期/
)[
0
]
const
related
=
clause
.
slice
(
marker
.
index
+
marker
[
0
].
length
).
split
(
/
(?:
递交|提交
)(?:
投标|响应
)
|投标截止|响应截止|开标|服务
(?:
截止|期
)
|工期/
)[
0
]
const
end
=
related
.
match
(
/
(?:
截止|截至|结束
)(?:
时间|日期
)?\s
*
[
::为至到于
]?\s
*
(\d{4}
.*
)
/
)
const
end
=
related
.
match
(
/
(?:
截止|截至|结束
)(?:
时间|日期
)?\s
*
[
::为至到于
]?\s
*
(\d{4}
.*
)
/
)
??
related
.
match
(
/
(?:
至|到|
[
~~—–
])\s
*
(
.+
)
/
)
??
related
.
match
(
/
(?:
至|到|
[
~~—–
])\s
*
(
.+
)
/
)
const
match
=
end
?.[
1
].
match
(
calendarDate
)
const
deadline
=
noticeDeadline
(
end
?.[
1
])
if
(
!
match
)
continue
if
(
deadline
)
return
deadline
const
value
=
`
${
match
[
1
]}
-
${
match
[
2
].
padStart
(
2
,
'
0
'
)}
-
${
match
[
3
].
padStart
(
2
,
'
0
'
)}
`
const
date
=
new
Date
(
`
${
value
}
T00:00:00Z`
)
if
(
!
Number
.
isFinite
(
date
.
getTime
())
||
date
.
toISOString
().
slice
(
0
,
10
)
!==
value
)
continue
// 显式提供小时和分钟时保留时分。无时分的公告按日显示,避免把当天零点误判为截止。
const
clock
=
end
?.[
1
].
slice
(
match
[
0
].
length
).
match
(
/^
[
日号
\s
T
]
*
([
01
]?\d
|2
[
0-3
])[
::
]([
0-5
]\d)(?:[
::
]([
0-5
]\d))?(?!\d)
/
)
const
time
=
clock
?
`
${
clock
[
1
].
padStart
(
2
,
'
0
'
)}
:
${
clock
[
2
]}${
clock
[
3
]
?
`:
${
clock
[
3
]}
`
:
''
}
`
:
null
return
{
date
:
value
,
time
}
}
}
}
}
return
null
return
null
...
@@ -111,13 +127,29 @@ export function registrationDate(schedule?: string[]) { return registrationDeadl
...
@@ -111,13 +127,29 @@ export function registrationDate(schedule?: string[]) { return registrationDeadl
/** 用北京时间的两个日历日计算剩余天数,避免临近午夜时用小时差造成前后一天的偏差。 */
/** 用北京时间的两个日历日计算剩余天数,避免临近午夜时用小时差造成前后一天的偏差。 */
export
function
registrationReminder
(
schedule
?:
string
[],
today
=
beijingDate
(),
now
=
Date
.
now
())
{
export
function
registrationReminder
(
schedule
?:
string
[],
today
=
beijingDate
(),
now
=
Date
.
now
())
{
const
deadline
=
registrationDeadline
(
schedule
)
return
deadlineReminder
(
registrationDeadline
(
schedule
),
'
报名
'
,
today
,
now
)
}
/** 列表先显示报名截止。公告仅提供投标/响应截止时,以“投标”标注明确的提交期限。 */
export
function
opportunityReminder
(
schedule
:
string
[]
=
[],
today
=
beijingDate
(),
now
=
Date
.
now
())
{
const
registrationEnd
=
registrationDeadline
(
schedule
)
if
(
registrationEnd
)
return
deadlineReminder
(
registrationEnd
,
'
报名
'
,
today
,
now
)
for
(
const
clause
of
scheduleClauses
(
schedule
))
{
const
end
=
clause
.
match
(
/
(?:
提交|递交
)?(?:
投标|响应
)(?:
文件
)?(?:
提交|递交
)?(?:
的
)?(?:
截止|截至
)(?:
及开标
)?(?:
时间|日期
)?[
::为至到于
]?(\d{4}
.*
)
/
)
const
deadline
=
noticeDeadline
(
end
?.[
1
])
if
(
deadline
)
return
deadlineReminder
(
deadline
,
'
投标
'
,
today
,
now
)
}
return
null
}
/** 无时分的公告按日判断,带时分的截止点按北京时间判断,确保当天截止前后显示一致。 */
function
deadlineReminder
(
deadline
:
{
date
:
string
;
time
:
string
|
null
}
|
null
,
kind
:
string
,
today
:
string
,
now
:
number
)
{
if
(
!
deadline
)
return
null
if
(
!
deadline
)
return
null
const
{
date
,
time
}
=
deadline
const
{
date
,
time
}
=
deadline
const
days
=
(
Date
.
parse
(
date
)
-
Date
.
parse
(
today
))
/
86400000
const
days
=
(
Date
.
parse
(
date
)
-
Date
.
parse
(
today
))
/
86400000
const
dateTime
=
time
?
`
${
date
}
T
${
time
}
+08:00`
:
date
const
dateTime
=
time
?
`
${
date
}
T
${
time
}
+08:00`
:
date
const
expired
=
days
<
0
||
(
days
===
0
&&
!!
time
&&
now
>=
Date
.
parse
(
dateTime
))
const
expired
=
days
<
0
||
(
days
===
0
&&
!!
time
&&
now
>=
Date
.
parse
(
dateTime
))
return
{
date
,
dateTime
,
display
:
time
?
`
${
date
}
${
time
}
`
:
date
,
days
,
label
:
expired
?
'
报名
已截止
'
:
days
===
0
?
'
报名
今天截止
'
:
`
报名
仅剩
${
days
}
天`
}
return
{
date
,
dateTime
,
display
:
time
?
`
${
date
}
${
time
}
`
:
date
,
days
,
label
:
expired
?
`
${
kind
}
已截止
`
:
days
===
0
?
`
${
kind
}
今天截止
`
:
`
${
kind
}
仅剩
${
days
}
天`
}
}
}
export
function
budgetLabel
(
conditions
:
SearchQuery
)
{
export
function
budgetLabel
(
conditions
:
SearchQuery
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment