<template>
|
<div class="container">
|
<image class="bg-image" src="/static/images/tabbar/loginbg.png" mode="scaleToFill"></image>
|
|
|
<u-alert :title="title" type="warning"></u-alert>
|
<div class="formbox">
|
<u-form :model="formData" ref="uForm" :rules="rules" :label-width="200">
|
<u-form-item label="体检人姓名" prop="cusName" required>
|
<u--input placeholder="请输入姓名" border="surround" v-model="formData.cusName" maxlength="5"
|
@input="trimSpaces('cusName', $event)"></u--input>
|
</u-form-item>
|
<u-form-item label="身份证号码" prop="idcard" required>
|
<u--input placeholder="请输入身份证号" border="surround" v-model="formData.idcard" maxlength="18"
|
@input="trimSpaces('idcard', $event)"></u--input>
|
</u-form-item>
|
</u-form>
|
</div>
|
<div @click="submit" class="chaxun">查询</div>
|
|
</div>
|
</template>
|
<script>
|
import {
|
getRelativeReportList
|
} from "@/api/system/report";
|
|
export default {
|
data() {
|
return {
|
|
title: "仅能查出该亲友最新体检报告哦",
|
formData: {
|
cusName: '',
|
idcard: ''
|
},
|
rules: {
|
cusName: [{
|
required: true,
|
message: '姓名不能为空',
|
trigger: 'blur'
|
}],
|
idcard: [{
|
required: true,
|
message: '身份证号不能为空',
|
trigger: 'blur'
|
}, {
|
validator: (rule, value, callback) => {
|
const idCardReg =
|
/^[1-9]\d{5}(19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
|
if (!value) return callback(new Error('身份证号不能为空'));
|
if (!idCardReg.test(value)) return callback(new Error('身份证号格式不正确'));
|
|
const factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
|
const checkCode = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'];
|
let sum = 0;
|
for (let i = 0; i < 17; i++) {
|
sum += parseInt(value.charAt(i)) * factor[i];
|
}
|
const mod = sum % 11;
|
const lastChar = value.charAt(17).toUpperCase();
|
if (checkCode[mod] !== lastChar) {
|
return callback(new Error('身份证号校验码错误'));
|
}
|
callback();
|
},
|
trigger: 'blur'
|
}]
|
}
|
};
|
},
|
onLoad(options) {
|
// 如果有 sfzh 参数,自动查询
|
const sfzh = options.sfzh ? decodeURIComponent(options.sfzh) : '';
|
if (sfzh) {
|
uni.showLoading({
|
title: '查询中...'
|
});
|
getRelativeReportList({
|
card: sfzh
|
})
|
.then((response) => {
|
uni.hideLoading();
|
if (!response.data || response.data.length === 0) {
|
uni.showToast({
|
title: '暂无体检报告!',
|
icon: 'none'
|
});
|
} else {
|
const reportData = encodeURIComponent(JSON.stringify(response.data));
|
uni.navigateTo({
|
url: `/pages/friendReportOverview/friendReportOverview?reportData=${reportData}`
|
});
|
}
|
})
|
.catch(() => {
|
uni.hideLoading();
|
uni.showToast({
|
title: '查询失败,请稍后重试',
|
icon: 'none'
|
});
|
});
|
}
|
},
|
methods: {
|
click(item) {
|
this.index = item.index;
|
if (this.index === 1) {
|
this.formData = {
|
cusName: '',
|
idcard: ''
|
};
|
this.$nextTick(() => {
|
if (this.$refs.uForm) {
|
this.$refs.uForm.setRules(this.rules);
|
this.$refs.uForm.clearValidate();
|
}
|
});
|
}
|
},
|
trimSpaces(field, value) {
|
const trimmedValue = value.replace(/\s/g, '');
|
if (this.formData[field] !== trimmedValue) {}
|
},
|
submit() {
|
if (!this.$refs.uForm) {
|
uni.showToast({
|
title: '表单未加载',
|
icon: 'none'
|
});
|
return;
|
}
|
this.$refs.uForm.validate().then(() => {
|
const {
|
cusName,
|
idcard
|
} = this.formData;
|
uni.showLoading({
|
title: '查询中...'
|
});
|
getRelativeReportList({
|
card: idcard,
|
name: cusName
|
})
|
.then((response) => {
|
uni.hideLoading();
|
if (!response.data || response.data.length === 0) {
|
uni.showToast({
|
title: '该亲友暂无体检报告!',
|
icon: 'none'
|
});
|
} else {
|
const reportData = encodeURIComponent(JSON.stringify(response.data));
|
uni.navigateTo({
|
url: `/pagesA/friendReportOverview/friendReportOverview?reportData=${reportData}`
|
});
|
}
|
})
|
.catch(() => {
|
uni.hideLoading();
|
uni.showToast({
|
title: '查询失败,请稍后重试',
|
icon: 'none'
|
});
|
});
|
}).catch(() => {
|
uni.showToast({
|
title: '请检查输入信息是否正确',
|
icon: 'none'
|
});
|
});
|
}
|
}
|
};
|
</script>
|
|
<style lang="scss" scoped>
|
::v-deep .u-alert__content__title {
|
font-size: 26rpx !important;
|
text-align: center !important;
|
}
|
|
.container {
|
position: relative;
|
min-height: 100vh;
|
padding: 0;
|
overflow: auto;
|
box-sizing: border-box;
|
}
|
|
.bg-image {
|
position: absolute;
|
top: 0;
|
left: 0;
|
width: 100vw;
|
height: 100vh;
|
z-index: -1;
|
left: 50%;
|
transform: translateX(-50%);
|
object-fit: cover;
|
}
|
|
.formbox {
|
width: 80vw;
|
max-width: 600px;
|
margin: 246rpx auto 315rpx;
|
}
|
|
.chaxun {
|
width: 80vw;
|
max-width: 600px;
|
margin: 0 auto;
|
font-weight: 500;
|
font-size: 16px;
|
color: #ffffff;
|
text-align: center;
|
padding: 15px 0;
|
background: #419ffd;
|
border-radius: 8px;
|
box-sizing: border-box;
|
}
|
|
@media (-webkit-min-device-pixel-ratio: 1) and (max-width: 750px) {
|
.formbox {
|
width: 600rpx;
|
margin: 246rpx auto 315rpx;
|
}
|
|
.chaxun {
|
width: 600rpx;
|
font-size: 36rpx;
|
padding: 31rpx 0;
|
border-radius: 8rpx;
|
}
|
}
|
|
@media screen and (min-width: 751px) {
|
.chaxun {
|
width: 80vw;
|
max-width: 600px;
|
font-size: 16px;
|
padding: 15px 0;
|
border-radius: 8px;
|
}
|
}
|
|
::v-deep .u-form-item__body {
|
display: flex !important;
|
flex-direction: column !important;
|
align-items: flex-start !important;
|
}
|
|
::v-deep .u-form-item__body__left {
|
margin-bottom: 38rpx !important;
|
}
|
|
::v-deep .u-form-item__body__left__content__label {
|
font-size: 32rpx !important;
|
color: #333 !important;
|
white-space: nowrap !important;
|
}
|
|
::v-deep .u-form-item {
|
margin-bottom: 62rpx !important;
|
}
|
|
::v-deep .u-form-item__body__right {
|
width: 100% !important;
|
}
|
|
::v-deep .u-form-item__body__right__message {
|
text-align: left !important;
|
margin-top: 10rpx !important;
|
}
|
|
::v-deep .u-tabs__wrapper__nav__item {
|
flex: 1 1 0% !important;
|
}
|
</style>
|