diff --git a/src/api/hisApi.ts b/src/api/hisApi.ts index 61c84c9..f26323b 100644 --- a/src/api/hisApi.ts +++ b/src/api/hisApi.ts @@ -184,33 +184,18 @@ export async function updatePatientInfo( address?: string, id_no_pic?: File | Blob ): Promise> { - // 如果包含图片文件,使用 multipart/form-data 上传 - if (id_no_pic) { - const formData = new FormData(); - formData.append("id_no", id_no); - formData.append("marital_status", marital_status.toString()); - formData.append("province", province || ""); - formData.append("city", city || ""); - formData.append("county", county || ""); - formData.append("address", address || ""); - formData.append("id_no_pic", id_no_pic); - - const response = await axiosInstance.post>( - "patient-edit", - formData - ); - return response.data; - } - - // 否则以 JSON 方式提交 - const response = await axiosInstance.post>("patient-edit", { - id_no, - marital_status, - province: province || "", - city: city || "", - county: county || "", - address: address || "", - }); + const formData = new FormData(); + formData.append("id_no", id_no); + formData.append("id_no_pic", id_no_pic || ""); + formData.append("marital_status", marital_status.toString()); + formData.append("province", province || ""); + formData.append("city", city || ""); + formData.append("county", county || ""); + formData.append("address", address || ""); + const response = await axiosInstance.post>( + "patient-edit", + formData + ); return response.data; } diff --git a/src/utils/idCard.ts b/src/utils/idCard.ts index ce3f486..0c58ec3 100644 --- a/src/utils/idCard.ts +++ b/src/utils/idCard.ts @@ -4,11 +4,11 @@ export function parseRegionCodesFromId(idNo: string | null | undefined) { const s = String(idNo).trim(); // 身份证号码前6位为行政区划代码 if (!/^[0-9]{6,}/.test(s)) return result; - const first6 = s.slice(4, 6); - const first4 = s.slice(2, 4); + const first6 = s.slice(0, 6); + const first4 = s.slice(0, 4); const first2 = s.slice(0, 2); - result.county = first6; - result.city = `${first4}`; - result.province = `${first2}`; + result.county = first6; // 6位县级代码 + result.city = `${first4}`; // 市级代码:前4位+00 + result.province = `${first2}`; // 省级代码:前2位+0000 return result; }