使用接口

This commit is contained in:
xianyi
2025-11-25 18:16:45 +08:00
parent 2571d52940
commit f3bea31e91
11 changed files with 439 additions and 582 deletions

View File

@@ -1,12 +1,17 @@
import React from "react";
import React, { useEffect, useState } from "react";
import "./UI6.css";
import "../../assets/css/basic.css";
import { useNavigate } from "react-router-dom";
import BackButton from "../../components/BackButton";
import ConfirmButton from "../../components/ConfirmButton";
import DecorLine from "../../components/DecorLine";
import { getPackagItemDetail } from "../../api/hisApi";
const UI6: React.FC = () => {
// !
localStorage.setItem("selectedExamId", "100030906");
const navigate = useNavigate();
const handleBack = () => {
@@ -16,49 +21,48 @@ const UI6: React.FC = () => {
const handleConfirm = () => {
navigate("/UI7");
};
const testData = [
{
"department": "B超科室",
"project": ["甲状腺B超", "腹部B超" , "乳腺B超"]
},
{
"department": "血常规科室",
"project": ["血常规", "血型"]
},
{
"department": "心电图科室",
"project": ["心电图", "心电图"]
},
{
"department": "心电图科室",
"project": ["心电图", "心电图"]
},
{
"department": "心电图科室",
"project": ["心电图", "心电图"]
},
{
"department": "心电图科室",
"project": ["心电图", "心电图"]
},
{
"department": "心电图科室",
"project": ["心电图", "心电图"]
},
{
"department": "心电图科室",
"project": ["心电图", "心电图"]
},
{
"department": "心电图科室",
"project": ["心电图", "心电图"]
},
{
"department": "心电图科室",
"project": ["心电图", "心电图","心电图", "心电图","心电图", "心电图","心电图", "心电图","心电图", "心电图"]
const [ListData, setListData] = useState<any[]>([]);
const [PackageInfo, setPackageInfo] = useState<any>({});
useEffect(() => {
getListData();
}, []);
const getListData = async () => {
const id_no = localStorage.getItem("lastIdCardNo");
if (!id_no) {
alert("请先输入身份证号");
return;
}
]
const res = await getPackagItemDetail(id_no as string);
if (res.Status === 200) {
// 处理数据:将 project_id 和 project_name 字符串分离为数组
const processedData = res.Data.listPackDetail.map((item: any) => {
// 将 project_id 字符串按中文顿号分割为数组
const project_ids = item.project_id
? item.project_id.split("、").map((id: string) => id.trim()).filter((id: string) => id)
: [];
// 将 project_name 字符串按中文顿号分割为数组
const project_names = item.project_name
? item.project_name.split("、").map((name: string) => name.trim()).filter((name: string) => name)
: [];
return {
...item,
project_ids,
project_names,
};
});
setListData(processedData);
setPackageInfo(res.Data.packagItemInfo);
} else {
alert(`获取列表数据失败: ${res.Message}`);
}
};
return (
<div className="basic-root">
@@ -68,10 +72,10 @@ const UI6: React.FC = () => {
<DecorLine />
<span className="basic-paragraph">
{localStorage.getItem("name")}{localStorage.getItem("gender") === "男" ? "先生" : "女士"}
<br />
<br />
2022-02-219:00-9:30的体
{PackageInfo.appointment_datetime}
</span>
<div className="ui6-table-container">
@@ -83,11 +87,11 @@ const UI6: React.FC = () => {
</tr>
</thead>
<tbody>
{testData.map((item, index) => (
{ListData.map((item, index) => (
<tr key={index} className="ui6-table-row">
<td className="ui6-table-dept-cell">{item.department}</td>
<td className="ui6-table-dept-cell">{item.department_name}</td>
<td className="ui6-table-project-cell">
{item.project.map((project, pIndex) => (
{item.project_names.map((project: string, pIndex: number) => (
<div key={pIndex} className="ui6-project-item">
<span style={{ paddingLeft: 20 }}>{project}</span>
</div>
@@ -101,7 +105,7 @@ const UI6: React.FC = () => {
<div className="basic-confirm-section">
<BackButton text="返回" onClick={handleBack} />
<ConfirmButton text="签名" onClick={handleConfirm} />
<ConfirmButton text="确定" onClick={handleConfirm} />
</div>
</div>
</div>