Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
R
risk-monitor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
蔡建
risk-monitor
Commits
9024c0e2
提交
9024c0e2
authored
3月 27, 2026
作者:
刘宇琪
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
法案预测接入接口
上级
247def06
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
47 行增加
和
54 行删除
+47
-54
billHome.js
src/api/bill/billHome.js
+43
-51
Step2FilterBills.vue
...nfluence/ProgressForecast/components/Step2FilterBills.vue
+4
-3
没有找到文件。
src/api/bill/billHome.js
浏览文件 @
9024c0e2
...
@@ -335,81 +335,73 @@ export function getProgressPrediction(billId) {
...
@@ -335,81 +335,73 @@ export function getProgressPrediction(billId) {
* @returns {Promise<Object>} 相似法案列表
* @returns {Promise<Object>} 相似法案列表
*/
*/
export
function
getSimiBills
(
params
=
{})
{
export
function
getSimiBills
(
params
=
{})
{
// domains 如果是数组则用逗号拼接
const
domains
=
Array
.
isArray
(
params
.
domains
)
?
params
.
domains
.
join
(
','
)
:
params
.
domains
return
request
(
'/api/BillProgressPrediction/simiBills'
,
{
return
request
(
'/api/BillProgressPrediction/simiBills'
,
{
method
:
'GET'
,
method
:
'GET'
,
params
:
{
params
:
{
billIds
:
params
.
billIds
,
billIds
:
params
.
billIds
,
domains
:
params
.
domains
,
domains
:
domains
,
patternType
:
params
.
patternType
,
patternType
:
params
.
patternType
,
proposalType
:
params
.
proposalType
,
proposalType
:
params
.
proposalType
...
params
}
}
})
})
}
}
/**
* 格式化日期 YYYY-MM-DD -> YYYY年M月D日
* @param {string} dateStr - 日期字符串
* @returns {string} 格式化后的日期
*/
function
formatDate
(
dateStr
)
{
if
(
!
dateStr
)
return
''
const
match
=
dateStr
.
match
(
/
(\d{4})
-
(\d{2})
-
(\d{2})
/
)
if
(
match
)
{
return
`
${
match
[
1
]}
年
${
parseInt
(
match
[
2
])}
月
${
parseInt
(
match
[
3
])}
日`
}
return
dateStr
}
/**
/**
* 转换相似法案 API 返回的数据为组件所需格式
* 转换相似法案 API 返回的数据为组件所需格式
* @param {Object} apiData - API 返回的原始数据
* @param {Object} apiData - API 返回的原始数据
* @returns {Object} 转换后的统计数据和法案列表
* @returns {Object} 转换后的统计数据和法案列表
*/
*/
export
function
transformSimiBillsData
(
apiData
)
{
export
function
transformSimiBillsData
(
apiData
)
{
if
(
!
apiData
||
!
apiData
.
data
||
!
Array
.
isArray
(
apiData
.
data
)
)
{
if
(
!
apiData
||
!
apiData
.
data
)
{
return
{
stats
:
null
,
bills
:
[]
}
return
{
stats
:
null
,
bills
:
[]
}
}
}
const
bills
=
apiData
.
data
const
data
=
apiData
.
data
const
simiBills
=
data
.
simi_bills
||
[]
// 计算统计数据
// 直接使用 API 返回的统计数据
let
becameLaw
=
0
let
notPassedOrShelved
=
0
let
totalDays
=
0
let
completedBills
=
0
bills
.
forEach
(
bill
=>
{
const
actions
=
bill
.
bill_actions
||
[]
const
hasBecameLaw
=
actions
.
some
(
a
=>
a
.
action_type
===
'BecameLaw'
||
a
.
action_type
===
'President'
&&
a
.
action_desc
?.
includes
(
'签署'
)
)
if
(
hasBecameLaw
)
{
becameLaw
++
// 计算耗时
if
(
actions
.
length
>=
2
)
{
const
firstDate
=
new
Date
(
actions
[
0
].
action_date
)
const
lastDate
=
new
Date
(
actions
[
actions
.
length
-
1
].
action_date
)
const
days
=
Math
.
ceil
((
lastDate
-
firstDate
)
/
(
1000
*
60
*
60
*
24
))
if
(
days
>
0
)
{
totalDays
+=
days
completedBills
++
}
}
}
else
{
notPassedOrShelved
++
}
})
const
medianDays
=
completedBills
>
0
?
Math
.
round
(
totalDays
/
completedBills
)
:
223
const
passRate
=
bills
.
length
>
0
?
((
becameLaw
/
bills
.
length
)
*
100
).
toFixed
(
1
)
:
'0'
const
stats
=
{
const
stats
=
{
totalBills
:
b
ills
.
length
,
totalBills
:
data
.
count
||
simiB
ills
.
length
,
becameLaw
,
becameLaw
:
data
.
become_law
||
0
,
notPassedOrShelved
,
notPassedOrShelved
:
(
data
.
count
||
simiBills
.
length
)
-
(
data
.
become_law
||
0
)
,
medianDays
,
medianDays
:
data
.
become_law_avg_days
||
0
,
passRate
passRate
:
data
.
become_law_prop
?
(
data
.
become_law_prop
*
100
).
toFixed
(
1
)
:
'0'
}
}
// 转换法案列表格式
// 转换法案列表格式
const
transformedBills
=
b
ills
.
map
(
bill
=>
({
const
transformedBills
=
simiB
ills
.
map
(
bill
=>
({
id
:
bill
.
bill_id
,
id
:
bill
.
bill_id
,
title
:
bill
.
bill_name
||
bill
.
bill_id
,
title
:
bill
.
bill_name
||
bill
.
bill_id
,
proposalDate
:
extractProposalDate
(
bill
.
poli_pattern_desc
),
proposalDate
:
bill
.
proposed_date
?
formatDate
(
bill
.
proposed_date
)
:
''
,
areas
:
bill
.
domain_name
?
(
Array
.
isArray
(
bill
.
domain_name
)
?
bill
.
domain_name
:
[
bill
.
domain_name
])
:
[],
areas
:
bill
.
bill_domain
?
(
Array
.
isArray
(
bill
.
bill_domain
)
?
bill
.
bill_domain
:
[
bill
.
bill_domain
])
:
[],
proposer
:
extractProposer
(
bill
.
bill_sponsors
),
proposer
:
bill
.
key_sponsor_name
||
extractProposer
(
bill
.
bill_sponsors
),
coProposers
:
bill
.
bill_proposal_desc
||
''
,
proposerParty
:
bill
.
key_sponsor_party
||
''
,
coProposers
:
bill
.
co_sponsor_desc
||
bill
.
bill_proposal_desc
||
''
,
proposalType
:
bill
.
bill_proposal_type
||
''
,
governmentType
:
formatGovernmentType
(
bill
.
poli_pattern_type
,
bill
.
poli_pattern_desc
),
governmentType
:
formatGovernmentType
(
bill
.
poli_pattern_type
,
bill
.
poli_pattern_desc
),
passDays
:
calculateTotalDays
(
bill
.
bill_actions
),
patternType
:
bill
.
poli_pattern_type
||
''
,
billStatus
:
bill
.
bill_status
||
''
,
passDays
:
bill
.
bill_action_days
||
calculateTotalDays
(
bill
.
bill_actions
),
yearsDifference
:
bill
.
years_difference
||
0
,
billActions
:
bill
.
bill_actions
||
[],
billSponsors
:
bill
.
bill_sponsors
||
[],
selected
:
true
// 默认全选
selected
:
true
// 默认全选
}))
}))
...
...
src/views/bill/influence/ProgressForecast/components/Step2FilterBills.vue
浏览文件 @
9024c0e2
...
@@ -125,7 +125,7 @@ async function loadData() {
...
@@ -125,7 +125,7 @@ async function loadData() {
// 使用真实 API,传入 billIds、domains、patternType、proposalType
// 使用真实 API,传入 billIds、domains、patternType、proposalType
const
params
=
{
const
params
=
{
billIds
:
filterParams
?.
value
.
billIds
,
billIds
:
filterParams
?.
value
.
billIds
,
domains
:
JSON
.
stringify
(
filterParams
?.
value
.
domains
)
||
[],
domains
:
filterParams
?.
value
.
domains
||
[],
patternType
:
filterParams
?.
value
.
patternType
||
'统一政府'
,
patternType
:
filterParams
?.
value
.
patternType
||
'统一政府'
,
proposalType
:
filterParams
?.
value
.
proposalType
||
'两党共同提案'
proposalType
:
filterParams
?.
value
.
proposalType
||
'两党共同提案'
}
}
...
@@ -133,14 +133,15 @@ async function loadData() {
...
@@ -133,14 +133,15 @@ async function loadData() {
const
response
=
await
getSimiBills
(
params
)
const
response
=
await
getSimiBills
(
params
)
if
(
response
&&
response
.
data
)
{
if
(
response
&&
response
.
data
)
{
// 保存原始数据
// 保存原始数据
(新 API 返回结构中 simi_bills 是法案数组)
rawBillsData
.
value
=
response
.
data
rawBillsData
.
value
=
response
.
data
.
simi_bills
||
[]
const
{
stats
:
apiStats
,
bills
:
apiBills
}
=
transformSimiBillsData
(
response
)
const
{
stats
:
apiStats
,
bills
:
apiBills
}
=
transformSimiBillsData
(
response
)
stats
.
value
=
apiStats
stats
.
value
=
apiStats
bills
.
value
=
apiBills
bills
.
value
=
apiBills
}
else
{
}
else
{
stats
.
value
=
null
stats
.
value
=
null
bills
.
value
=
[]
bills
.
value
=
[]
rawBillsData
.
value
=
[]
}
}
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
'获取相似法案失败:'
,
error
)
console
.
error
(
'获取相似法案失败:'
,
error
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论