Selaa lähdekoodia

提交问卷入参传值调整

wangjian 6 päivää sitten
vanhempi
sitoutus
901585cd64

+ 42 - 9
pagesAdmin/satisfaction/business/satisfactionQuestions/satisfactionQuestions.vue

@@ -347,6 +347,11 @@ const subtitleSatisfaction = reactive({} as Record<string, number | null>);
 const anonymousType = ref(0);
 const showModal_Anonymous = ref(false); // 是否实名填写弹窗显示
 const showModal_User = ref(false); // 实名用户选择弹窗显示
+const pageParams = reactive({
+	cardNo: '',
+	cardType: '',
+  sampleId: '',
+});
 let quesAnswers = reactive({
 	MemberId: '',
 	TaskId: '-1',
@@ -367,6 +372,8 @@ let quesAnswers = reactive({
 	BedNo: '',
 	HospitalNo: '',
 	CardNo: '',
+	CardType: '',
+  SampleId: '',
 	AnswerList: [],
 });
 
@@ -376,11 +383,13 @@ let queryPatient = reactive({
 });
 
 const getAgeByBirthDate = (birthDate = '') => {
-	const birth = `${birthDate}`.replace(/-/g, '');
+	const birth = `${birthDate}`.replace(/\D/g, '').slice(0, 8);
 	if (!/^\d{8}$/.test(birth)) return '';
 	const year = Number(birth.slice(0, 4));
 	const month = Number(birth.slice(4, 6));
 	const day = Number(birth.slice(6, 8));
+	const date = new Date(year, month - 1, day);
+	if (date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day) return '';
 	const today = new Date();
 	let age = today.getFullYear() - year;
 	if (today.getMonth() + 1 < month || (today.getMonth() + 1 === month && today.getDate() < day)) {
@@ -388,12 +397,33 @@ const getAgeByBirthDate = (birthDate = '') => {
 	}
 	return age >= 0 ? `${age}` : '';
 };
+
+const getPatientInfoByIdCard = (idCard = '') => {
+	const card = `${idCard}`.trim();
+	if (!/^\d{17}[\dXx]$/.test(card)) return { sex: '', age: '' };
+	const factors = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
+	const checkCodes = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'];
+	const sum = factors.reduce((total, factor, index) => total + Number(card[index]) * factor, 0);
+	if (checkCodes[sum % 11] !== card[17].toUpperCase()) return { sex: '', age: '' };
+	const birth = card.slice(6, 14);
+	const sexCode = Number(card.slice(16, 17));
+	const age = getAgeByBirthDate(birth);
+	if (!age) return { sex: '', age: '' };
+	return {
+		sex: sexCode % 2 === 1 ? '1' : '2',
+		age,
+	};
+};
+
 const { getCurrentUser } = mapGetters({
 	getCurrentUser: 'getCurrentUser',
 });
 
 const main = async (options) => {
 	currentUser.value = getCurrentUser();
+	pageParams.cardNo = options.cardno || options.cardNo || '';
+	pageParams.cardType = options.cardtype || options.cardType || '';
+	pageParams.sampleId = options.sampleId || options.SampleId || '';
 	const params = {
 		SubjectId: options.subjectId,
 		TaskId: options.taskId,
@@ -424,8 +454,8 @@ const main = async (options) => {
 		getSec();
 		
 		if(options?.type == "sms_myddc") {
-			currentUser.value.cardNo = options.cardNo
-			currentUser.value.cardType = options.cardType
+			currentUser.value.cardNo = pageParams.cardNo
+			currentUser.value.cardType = pageParams.cardType
 			showModal_Anonymous.value = false
 			showModal_User.value = false
 		}
@@ -1042,14 +1072,14 @@ const submit = () => {
 			}
 		});
 		
-		const cardNo = currentUser.value?.cardNo ?? '';
-		const cardType = currentUser.value?.cardType ?? '';
+		const cardNo = pageParams.cardNo || currentUser.value?.cardNo || '';
+		const cardType = pageParams.cardType || currentUser.value?.cardType || '';
 		let mobile = currentUser.value?.mobile ?? '';
 		let memberName = currentUser.value?.memberName ?? '';
 		let sex = currentUser.value?.sex ?? '';
 		let age = currentUser.value?.age ?? '';
 		let idCard = currentUser.value?.idCard ?? currentUser.value?.certNum ?? '';
-		let memberId = currentUser.value?.MemberId ?? currentUser.value?.memberId ?? currentUser.value?.cardNo ?? '';
+		let memberId = currentUser.value?.MemberId ?? currentUser.value?.memberId ?? cardNo ?? '';
 
 		queryPatient.cardNo = cardNo;
 		queryPatient.cardType = cardType;
@@ -1062,11 +1092,13 @@ const submit = () => {
 
 		if (patientInfo.RespCode === '10000' && patientInfo.Data && patientInfo.Data.length > 0) {
 		  const patient = patientInfo.Data[0];
+		  const patientIdCard = patient.idCard || patient.idcard || patient.certNum || '';
+		  const patientInfoByIdCard = getPatientInfoByIdCard(patientIdCard);
 		  mobile = patient.mobile || mobile;
 		  memberName = patient.memberName || memberName;
-		  sex = patient.sex || sex;
-		  age = currentUser.value?.age || getAgeByBirthDate(patient.birthDate);
-		  idCard = patient.certNum || idCard;
+		  sex = patient.sex || patientInfoByIdCard.sex || sex;
+		  age = currentUser.value?.age || getAgeByBirthDate(patient.birthDate) || patientInfoByIdCard.age || age;
+		  idCard = patientIdCard || idCard;
 		  memberId = patient.hisMemberId || patient.memberId || memberId;
 		}
 
@@ -1087,6 +1119,7 @@ const submit = () => {
 		quesAnswers.CardNo = objType.value == '3' ? cardNo : '';
 		quesAnswers.TaskId = taskId.value;
 		quesAnswers.CardType = objType.value == '3' ? cardType : '';
+		quesAnswers.SampleId = pageParams.sampleId;
 		
 		let res = await CommitAnswer_V3(quesAnswers);
 		clearTimeout(time);