2024年9月3日 新增自动读取身份证

This commit is contained in:
bai 2024-09-03 12:03:13 +08:00
parent 1b971aa023
commit f11092e4e0
10 changed files with 10031 additions and 7719 deletions

View File

@ -5,7 +5,7 @@ VITE_USE_MOCK = true
VITE_PUBLIC_PATH = /
# 跨域代理,您可以配置多个 ,请注意,没有换行符
VITE_PROXY = [["/jeecgboot","http://localhost:8090/jeecg-boot"],["/ZKIDROnline","http://localhost:24010/ZKIDROnline"],["/upload","http://localhost:3300/upload"]]
VITE_PROXY = [["/jeecgboot","http://localhost:8101/jeecg-boot"],["/ZKIDROnline","http://localhost:24010/ZKIDROnline"],["/upload","http://localhost:3300/upload"]]
# 控制台不输出
VITE_DROP_CONSOLE = false
@ -14,7 +14,7 @@ VITE_DROP_CONSOLE = false
VITE_GLOB_API_URL=/jeecgboot
#后台接口全路径地址(必填)
VITE_GLOB_DOMAIN_URL=http://localhost:8090/jeecg-boot
VITE_GLOB_DOMAIN_URL=http://localhost:8101/jeecg-boot
# 接口前缀
VITE_GLOB_API_URL_PREFIX=

2
.gitignore vendored
View File

@ -32,3 +32,5 @@ pnpm-debug.log*
/.vscode/
/.history/
/svn clear.bat
nodePath.txt

25
changePath.bat Normal file
View File

@ -0,0 +1,25 @@
@echo off & chcp 65001
echo 原node版本
node -v
echo 如果运行错误请设置node版本
if not exist nodePath.txt (
echo 请在项目根目录创建【nodePath.txt】文件并填写jdk路径,文件内容大致为【D:\ProgramGreeFile\nodejs\node-21.2.0】
pause
exit
)
set /P nodePath=<nodePath.txt
if not defined nodePath (
echo 请在项目根目录创建【nodePath.txt】文件并填写jdk路径,文件内容大致为【D:\ProgramGreeFile\nodejs\node-21.2.0】
pause
exit
)
::还原
::if pathBak == '' ( ) else ( set path=%pathBak% )
if "%pathBak%"=="" (echo '') else set path=%pathBak%
set pathBak=%path%
set path2=%nodePath%;%path%
set path=%path2%
echo 现node版本
node -v
echo 开始执行

View File

@ -1 +1,3 @@
yarn bootstrap
:: @echo off & chcp 65001
call ./changePath.bat
npm run pinstall

View File

@ -8,6 +8,7 @@
},
"scripts": {
"bootstrap": "pnpm install",
"pinstall": "pnpm install",
"serve": "npm run dev",
"dev": "vite",
"clean:cache": "rimraf node_modules/.cache/ && rimraf node_modules/.vite",

File diff suppressed because it is too large Load Diff

View File

@ -1 +1,3 @@
yarn dev --mode development
::@echo off & chcp 65001
call ./changePath.bat
npm run dev

View File

@ -14,6 +14,11 @@
<j-input placeholder="请输入身份证号" v-model:value="queryParam.sfzh"></j-input>
</a-form-item>
</a-col>
<a-col :lg="8">
<a-form-item label="年级" name="nj">
<j-input placeholder="请输入年级" v-model:value="queryParam.nj"></j-input>
</a-form-item>
</a-col>
<a-col :xl="6" :lg="7" :md="8" :sm="24">
<span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
<a-col :lg="6">
@ -40,6 +45,7 @@
<!-- <a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button> -->
<a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined">新增</a-button>
<a-button type="primary" @click="handleAllAdd" preIcon="ant-design:plus-outlined">批量新增</a-button>
<a-button type="primary" @click="handleAllBatchAdd" preIcon="ant-design:plus-outlined">自动批量新增</a-button>
<a-button type="primary" @click="handleGATAdd" preIcon="ant-design:plus-outlined">港澳台新增</a-button>
<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
<a-button type="primary" preIcon="ant-design:export-outlined" @click="downloadDrive">下载驱动</a-button>
@ -89,6 +95,7 @@
<TSfzPicinfoModal ref="registerModal" @success="handleSuccess"></TSfzPicinfoModal>
<TSfzPicinfoAllModal ref="registerAllModal" @success="handleSuccess"></TSfzPicinfoAllModal>
<TSfzPicinfoGATModal ref="registerGATModal" @success="handleSuccess"></TSfzPicinfoGATModal>
<TSfzPicinfoAllBatchModal ref="registerAllBatchModal" @success="handleSuccess"></TSfzPicinfoAllBatchModal>
</div>
</template>
@ -104,6 +111,7 @@
import TSfzPicinfoModal from './components/TSfzPicinfoModal.vue'
import TSfzPicinfoAllModal from './components/TSfzPicinfoAllModal.vue'
import TSfzPicinfoGATModal from './components/TSfzPicinfoGATModal.vue'
import TSfzPicinfoAllBatchModal from './components/TSfzPicinfoAllBatchModal.vue'
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from '/@/hooks/web/useMessage';
import { getFileAccessHttpUrl } from '/@/utils/common/compUtils';
@ -118,6 +126,7 @@
const registerModal = ref();
const registerAllModal = ref();
const registerGATModal = ref();
const registerAllBatchModal = ref();
//table
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
tableProps: {
@ -174,7 +183,6 @@
registerModal.value.add();
}
/**
* 新增事件
*/
@ -191,6 +199,14 @@
registerGATModal.value.add();
}
/**
* 新增事件
*/
function handleAllBatchAdd() {
registerAllBatchModal.value.disableSubmit = false;
registerAllBatchModal.value.add();
}
/**
* 编辑事件
*/

View File

@ -0,0 +1,428 @@
<template>
<a-spin :spinning="confirmLoading">
<a-form ref="formRef" class="antd-modal-form" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-row style="padding-bottom: 1rem;" v-show="!disabled">
<a-col :span="24">
<a-row style="padding-bottom: 1rem;">
<a-col v-bind="labelCol"></a-col>
<a-col v-bind="wrapperCol">
<a-button :loading="sfzBtnLoading" type="primary" @click="getIdCard">手动读取身份证仅一次读取</a-button>
</a-col>
</a-row>
<a-row style="padding-bottom: 1rem;">
<a-col v-bind="labelCol"></a-col>
<a-col v-bind="wrapperCol">
<a-button :disabled="autoReadCardFlag" type="primary" @click="startAutoReadCard">开始自动读取循环</a-button>
<a-button :disabled="!autoReadCardFlag" type="primary" style="margin-left: 1rem;" @click="stopAutoReadCard">关闭自动读取循环</a-button>
</a-col>
</a-row>
<a-row style="padding-bottom: 1rem;">
<a-col v-bind="labelCol"></a-col>
<a-col v-bind="wrapperCol">
<a-switch v-model:checked="autoReadCardIsSave" checkedChildren="读取后保存" unCheckedChildren="仅展示,不保存"/>
<a-switch style="margin-left: 1rem;" v-model:checked="autoReadCardForceSave" checkedChildren="强制保存" unCheckedChildren="自动决定保存"/>
</a-col>
</a-row>
<a-row style="padding-bottom: 1rem;">
<a-col v-bind="labelCol"></a-col>
<a-col v-bind="wrapperCol">
读取成功数{{ autoReadCardSuccessNum }}读取失败数{{ autoReadCardFailNum }}
</a-col>
</a-row>
</a-col>
</a-row>
<a-row>
<a-col :span="24">
<a-form-item label="姓名" v-bind="validateInfos.xm">
<a-input v-model:value="formData.xm" placeholder="请输入姓名" disabled></a-input>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="性别" v-bind="validateInfos.xb">
<a-input v-model:value="formData.xb" placeholder="请输入性别" disabled></a-input>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="民族" v-bind="validateInfos.mz">
<a-input v-model:value="formData.mz" placeholder="请输入民族" disabled></a-input>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="出生日期" v-bind="validateInfos.csrq">
<a-input v-model:value="formData.csrq" placeholder="请输入出生日期" disabled></a-input>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="住址" v-bind="validateInfos.zz">
<a-input v-model:value="formData.zz" placeholder="请输入住址" disabled></a-input>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="身份证号" v-bind="validateInfos.sfzh">
<a-input v-model:value="formData.sfzh" placeholder="请输入身份证号" disabled></a-input>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="签发机关" v-bind="validateInfos.qfjg">
<a-input v-model:value="formData.qfjg" placeholder="请输入签发机关" disabled></a-input>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="开始有效期" v-bind="validateInfos.startYxq">
<a-input v-model:value="formData.startYxq" placeholder="开始有效期" disabled></a-input>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="结束有效期" v-bind="validateInfos.endYxq">
<a-input v-model:value="formData.endYxq" placeholder="结束有效期" disabled></a-input>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="身份证照片" v-bind="validateInfos.sfzurl">
<!-- <j-image-upload v-model:value="formData.sfzurl" disabled></j-image-upload> -->
<tempalte v-if="formData.base64Photo">
<img width="102" height="126" :src="'data:image/png;base64,'+formData.base64Photo"/>
</tempalte>
<tempalte v-else-if="formData.sfzurl">
<img :src="getFileAccessHttpUrl(formData.sfzurl)"/>
</tempalte>
<tempalte v-else>
<div style="width:102px;height: 123px;">&nbsp;</div>
</tempalte>
</a-form-item>
</a-col>
<!-- <a-col :span="12">
<a-form-item label="是否有效0-有效 1-无效 无效:照片不存在 有效:照片存在并且以身份证命名或者通过学号已经清洗成以身份证命名" v-bind="validateInfos.sfzflag">
<a-input v-model:value="formData.sfzflag" placeholder="请输入是否有效0-有效 1-无效 无效:照片不存在 有效:照片存在并且以身份证命名或者通过学号已经清洗成以身份证命名" disabled></a-input>
</a-form-item>
</a-col> -->
</a-row>
</a-form>
<a-modal v-model:visible="errorFormVisible" width="800" title="提示">
<template #footer>
<a-button key="back" @click="handleCancel">关闭</a-button>
</template>
<a-card>
<p>读取身份证失败,请尝试以下方法</p>
<p>1.请下载并安装<a href="/downloads/ZKIDROnline.exe">驱动</a></p>
<p>2.请重新连接读卡器</p>
<div>
3.请更改浏览器设置
<p>&nbsp;&nbsp;&nbsp;&nbsp;chrome浏览器/edge浏览器, 在地址栏输入chrome://flags</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;搜索Block insecure private network requests 将值改成disabled</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;火狐浏览器, about:config</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;搜索security.fileuri.strict_origin_policy 将值改为false</p>
</div>
<div>
4.如还无法读取并弹出无法识别的提示重启电脑或打开服务找到Security ZKIDROnline Service服务打开或是重启
</div>
</a-card>
</a-modal>
</a-spin>
</template>
<script lang="ts" setup>
import { ref, reactive, defineExpose, nextTick, defineProps, computed } from 'vue';
//import { defHttp } from '/@/utils/http/axios';
import { useMessage } from '/@/hooks/web/useMessage';
//import JImageUpload from '/@/components/Form/src/jeecg/components/JImageUpload.vue';
import { getValueType } from '/@/utils';
import { saveOrUpdate } from '../TSfzPicinfo.api';
import { Form } from 'ant-design-vue';
import { getIdCardAllInfo, idCardConvert } from '/@/utils/idCardUtil';
import { getFileAccessHttpUrl } from '/@/utils/common/compUtils';
import { getCurrentSchoolYear } from '/@/views/student/common/commonConfig';
const props = defineProps({
formDisabled: { type: Boolean, default: false },
formData: { type: Object, default: ()=>{} },
formBpm: { type: Boolean, default: true }
});
const formRef = ref();
const useForm = Form.useForm;
const emit = defineEmits(['register', 'ok']);
const formData = reactive<Record<string, any>>({
id: '',
xm: '',
xb: '',
mz: '',
csrq: '',
zz: '',
sfzh: '',
sfzurl: '',
qfjg: '',
startYxq: '',
endYxq: '',
sfzflag: '',
base64Photo: '',
});
const formDataCache = ref<any>(formData);
const { createMessage } = useMessage();
const labelCol = ref<any>({ xs: { span: 24 }, sm: { span: 5 } });
const wrapperCol = ref<any>({ xs: { span: 24 }, sm: { span: 16 } });
const confirmLoading = ref<boolean>(false);
const sfzBtnLoading = ref<boolean>(false);
//
const autoReadCardIsSave = ref<boolean>(false);
//
const autoReadCardForceSave = ref<boolean>(false);
//
const autoReadCardFlag = ref<boolean>(false);
//
const autoReadCardSuccessNum = ref<Number>(0);
//
const autoReadCardFailNum = ref<Number>(0);
//
const validatorRules = {
};
const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: true });
const errorFormVisible = ref(false);
function handleCancel(){
errorFormVisible.value = false;
}
//
const disabled = computed(()=>{
if(props.formBpm === true){
if(props.formData.disabled === false){
return false;
}else{
return true;
}
}
return props.formDisabled;
});
const currentSchoolYear = ref<string>('');
//
getCurrentSchoolYear().then(res => {
let paramDate = res;
currentSchoolYear.value = paramDate?.paramValue;;
})
/**
* 新增
*/
function add() {
edit({});
}
/**
* 编辑
*/
function edit(record) {
nextTick(() => {
resetFields();
// formData.base64Photo = null;
//
Object.assign(formData, record);
});
}
/**
* 提交数据
*/
async function submitForm() {
//
await validate();
if(!formData.base64Photo){
createMessage.warning('请读取身份证!');
return;
}
confirmLoading.value = true;
const isUpdate = ref<boolean>(false);
//
let model = formData;
if (model.id) {
isUpdate.value = true;
}
//
for (let data in model) {
//
if (model[data] instanceof Array) {
let valueType = getValueType(formRef.value.getProps, data);
//
if (valueType === 'string') {
model[data] = model[data].join(',');
}
}
}
await saveOrUpdate(model, isUpdate.value).then((res) => {
if (res.success) {
createMessage.success(res.message);
emit('ok');
} else {
createMessage.warning(res.message);
}
}).finally(() => {
confirmLoading.value = false;
});
}
/**
* 提交数据
*/
async function submitFormNoClose() {
//
await validate();
if(!formData.base64Photo){
createMessage.warning('请读取身份证!');
return;
}
confirmLoading.value = true;
const isUpdate = ref<boolean>(false);
//
let model = formData;
if (model.id) {
isUpdate.value = true;
}
//
for (let data in model) {
//
if (model[data] instanceof Array) {
let valueType = getValueType(formRef.value.getProps, data);
//
if (valueType === 'string') {
model[data] = model[data].join(',');
}
}
}
await saveOrUpdate(model, isUpdate.value).then((res) => {
if (res.success) {
createMessage.success(res.message);
//
resetFields();
} else {
createMessage.warning(res.message);
}
}).finally(() => {
confirmLoading.value = false;
});
}
function getIdCard() {
sfzBtnLoading.value = true;
getIdCardAllInfo().then(res => {
let data = idCardConvert(res);
console.log(`🚀 -------------------------------------------------------------------🚀`);
console.log(`🚀 ~ file: TSfzPicinfoForm.vue:187 ~ getIdCardAllInfo ~ data:`, data);
console.log(`🚀 -------------------------------------------------------------------🚀`);
if(data.ret == 0){
formDataCache.value = Object.assign({}, formData);
//
formData.xm = data.Name;//
formData.xb = data.Sex;//
formData.mz = data.Nation;//
formData.csrq = data.Birthday;//
formData.zz = data.Address;//
formData.sfzh = data.IDNumber;//
//formData.sfzurl = data.Base64Photo;//
formData.base64Photo = data.Base64Photo;//(base64)
formData.qfjg = data.IDIssued;//
formData.startYxq = data.IssuedData;//
formData.endYxq = data.ValidDate;//
//formData.sfzflag = data.Nation;//0- 1-
formData.nj = currentSchoolYear.value;
}else{
createMessage[data.type](data.message)
resetFields();
// formData.base64Photo = null;
}
sfzBtnLoading.value = false;
}).catch(e => {
console.error('错误!',e)
errorFormVisible.value = true;
sfzBtnLoading.value = false;
})
}
async function autoReadCard() {
getIdCardAllInfo().then(async res => {
let data = idCardConvert(res);
if(data.ret == 0){
formDataCache.value = Object.assign({}, formData);
//
formData.xm = data.Name;//
formData.xb = data.Sex;//
formData.mz = data.Nation;//
formData.csrq = data.Birthday;//
formData.zz = data.Address;//
formData.sfzh = data.IDNumber;//
//formData.sfzurl = data.Base64Photo;//
formData.base64Photo = data.Base64Photo;//(base64)
formData.qfjg = data.IDIssued;//
formData.startYxq = data.IssuedData;//
formData.endYxq = data.ValidDate;//
//formData.sfzflag = data.Nation;//0- 1-
formData.nj = currentSchoolYear.value;
//
if((autoReadCardIsSave.value && formDataCache.value.sfzh != formData.sfzh) || autoReadCardForceSave.value){
autoReadCardSuccessNum.value++;
await submitFormNoClose();
}
//3
// if(formDataCache.value.sfzh == formData.sfzh){
// await new Promise(resolve => setTimeout(resolve, 3000));
// }
formDataCache.value = Object.assign({}, formData);
//
if(autoReadCardFlag.value) {
await autoReadCard();
}
} else {
createMessage[data.type](data.message)
resetFields();
//
autoReadCardFailNum.value++;
//
if(autoReadCardFlag.value) {
await autoReadCard();
}
}
}).catch(e => {
console.error('错误!',e);
errorFormVisible.value = true;
sfzBtnLoading.value = false;
stopAutoReadCard();
});
}
//
function startAutoReadCard() {
autoReadCardFlag.value = true;
autoReadCard()
}
//
function stopAutoReadCard() {
autoReadCardFlag.value = false;
}
defineExpose({
add,
edit,
submitForm,
});
</script>
<style lang="less" scoped>
.antd-modal-form {
min-height: 500px !important;
overflow-y: auto;
padding: 24px 24px 24px 24px;
}
.ant-form-item{
margin-bottom: 10px;
}
</style>

View File

@ -0,0 +1,75 @@
<template>
<a-modal :title="title" :width="width" :visible="visible" @ok="handleOk" :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }" @cancel="handleCancel" cancelText="关闭">
<TSfzPicinfoForm ref="registerForm" @ok="submitCallback" :formDisabled="disableSubmit" :formBpm="false"></TSfzPicinfoForm>
</a-modal>
</template>
<script lang="ts" setup>
import { ref, nextTick, defineExpose } from 'vue';
import TSfzPicinfoForm from './TSfzPicinfoAllBatchForm.vue'
const title = ref<string>('');
const width = ref<number>(800);
const visible = ref<boolean>(false);
const disableSubmit = ref<boolean>(false);
const registerForm = ref();
const emit = defineEmits(['register', 'success']);
/**
* 新增
*/
function add() {
title.value = '新增';
visible.value = true;
nextTick(() => {
registerForm.value.add();
});
}
/**
* 编辑
* @param record
*/
function edit(record) {
title.value = disableSubmit.value ? '详情' : '编辑';
visible.value = true;
nextTick(() => {
registerForm.value.edit(record);
});
}
/**
* 确定按钮点击事件
*/
function handleOk() {
registerForm.value.submitForm();
}
/**
* form保存回调事件
*/
function submitCallback() {
handleCancel();
emit('success');
}
/**
* 取消按钮回调事件
*/
function handleCancel() {
visible.value = false;
}
defineExpose({
add,
edit,
disableSubmit,
});
</script>
<style>
/**隐藏样式-modal确定按钮 */
.jee-hidden {
display: none !important;
}
</style>