新增评卷地点字段,优化教师账号添加逻辑
This commit is contained in:
parent
d3594e1546
commit
760d4f08c5
|
@ -33,6 +33,12 @@ export const columns: BasicColumn[] = [
|
||||||
// return '加载失败';
|
// return '加载失败';
|
||||||
// });
|
// });
|
||||||
//},
|
//},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '评卷地点',
|
||||||
|
align: "center",
|
||||||
|
dataIndex: 'markingLocation',
|
||||||
|
width: 200
|
||||||
}
|
}
|
||||||
// {
|
// {
|
||||||
// title: '专业id',
|
// title: '专业id',
|
||||||
|
@ -63,6 +69,11 @@ export const searchFormSchema: FormSchema[] = [
|
||||||
ifShow: ({ values }) => {
|
ifShow: ({ values }) => {
|
||||||
return hasPermission('group:majorId:select');
|
return hasPermission('group:majorId:select');
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '评卷地点',
|
||||||
|
field: 'markingLocation',
|
||||||
|
component: 'Input',
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
//表单数据
|
//表单数据
|
||||||
|
@ -97,6 +108,11 @@ export const formSchema: FormSchema[] = [
|
||||||
show: ({ values }) => {
|
show: ({ values }) => {
|
||||||
return hasPermission('majorId:edit');
|
return hasPermission('majorId:edit');
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '评卷地点',
|
||||||
|
field: 'markingLocation',
|
||||||
|
component: 'Input',
|
||||||
},
|
},
|
||||||
// TODO 主键隐藏字段,目前写死为ID
|
// TODO 主键隐藏字段,目前写死为ID
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,6 +15,132 @@ export const updateGroupOptions = reactive({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 计算年龄的函数
|
||||||
|
function calculateAge(birthday: string) {
|
||||||
|
const today = new Date();
|
||||||
|
const birthDate = new Date(birthday);
|
||||||
|
let age = today.getFullYear() - birthDate.getFullYear();
|
||||||
|
const monthDiff = today.getMonth() - birthDate.getMonth();
|
||||||
|
|
||||||
|
if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDate.getDate())) {
|
||||||
|
age--;
|
||||||
|
}
|
||||||
|
|
||||||
|
return age || '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取性别
|
||||||
|
function getSex(value: string) {
|
||||||
|
if (value.length < 17) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
let sex = value.substr(16, 1);
|
||||||
|
if (sex !== '' || sex !== undefined) {
|
||||||
|
if (parseInt(sex) % 2 == 1) {
|
||||||
|
return 0; // 男
|
||||||
|
} else {
|
||||||
|
return 1; // 女
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// 校验出生日期是否合理
|
||||||
|
function validateBirthday(year: number, month: number, day: number) {
|
||||||
|
const nowTime = new Date().getTime();
|
||||||
|
const birthTime = new Date(`${year}-${month}-${day}`).getTime();
|
||||||
|
|
||||||
|
if (birthTime > nowTime) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const nowYear = new Date().getFullYear();
|
||||||
|
if (nowYear - year > 150) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (month < 1 || month > 12) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const date = new Date(year, month, 0);
|
||||||
|
if (day < 1 || day > date.getDate()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 身份证验证函数
|
||||||
|
function validateIdCard(value: string) {
|
||||||
|
let psidno = String(value);
|
||||||
|
psidno = psidno.toUpperCase();
|
||||||
|
|
||||||
|
// 1.校验身份证号格式和长度
|
||||||
|
const regPsidno = /^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[X])$)$/;
|
||||||
|
if (!regPsidno.test(psidno)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2.校验前两位的省份编码
|
||||||
|
const province = {
|
||||||
|
11: '北京', 12: '天津', 13: '河北', 14: '山西', 15: '内蒙古',
|
||||||
|
21: '辽宁', 22: '吉林', 23: '黑龙江', 31: '上海', 32: '江苏',
|
||||||
|
33: '浙江', 34: '安徽', 35: '福建', 36: '江西', 37: '山东',
|
||||||
|
41: '河南', 42: '湖北', 43: '湖南', 44: '广东', 45: '广西',
|
||||||
|
46: '海南', 50: '重庆', 51: '四川', 52: '贵州', 53: '云南',
|
||||||
|
54: '西藏', 61: '陕西', 62: '甘肃', 63: '青海', 64: '宁夏',
|
||||||
|
65: '新疆', 71: '台湾', 81: '香港', 82: '澳门', 91: '国外'
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!province[Number(psidno.slice(0, 2))]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3.校验出生日期
|
||||||
|
if (psidno.length === 15) {
|
||||||
|
const reg = new RegExp(/^(\d{6})(\d{2})(\d{2})(\d{2})(\d{3})$/);
|
||||||
|
const arrSplit = psidno.match(reg);
|
||||||
|
if (!arrSplit) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const year = Number(arrSplit[2].charAt(0)) > 0 ? '19' + arrSplit[2] : '20' + arrSplit[2];
|
||||||
|
const month = arrSplit[3];
|
||||||
|
const day = arrSplit[4];
|
||||||
|
if (!validateBirthday(Number(year), Number(month), Number(day))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (psidno.length === 18) {
|
||||||
|
const reg = new RegExp(/^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9]|X)$/);
|
||||||
|
const arrSplit = psidno.match(reg);
|
||||||
|
if (!arrSplit) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const year = arrSplit[2];
|
||||||
|
const month = arrSplit[3];
|
||||||
|
const day = arrSplit[4];
|
||||||
|
if (!validateBirthday(Number(year), Number(month), Number(day))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4.18位号码校验生成的校验码
|
||||||
|
if (psidno.length === 18) {
|
||||||
|
const Wi = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
|
||||||
|
const parity = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'];
|
||||||
|
let sum = 0;
|
||||||
|
for (let i = 0; i < 17; i++) {
|
||||||
|
sum += Number(psidno.charAt(i)) * Wi[i];
|
||||||
|
}
|
||||||
|
if (parity[sum % 11] !== psidno[17]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
//列表数据
|
//列表数据
|
||||||
export const columns: BasicColumn[] = [
|
export const columns: BasicColumn[] = [
|
||||||
{
|
{
|
||||||
|
@ -116,14 +242,14 @@ export const searchFormSchema: FormSchema[] = [
|
||||||
];
|
];
|
||||||
//表单数据
|
//表单数据
|
||||||
export const formSchema: FormSchema[] = [
|
export const formSchema: FormSchema[] = [
|
||||||
{
|
// {
|
||||||
label: '用户ID',
|
// label: '用户ID',
|
||||||
field: 'userId',
|
// field: 'userId',
|
||||||
component: 'Input',
|
// component: 'Input',
|
||||||
dynamicRules: ({ model, schema }) => {
|
// dynamicRules: ({ model, schema }) => {
|
||||||
return [{ required: true, message: '请输入用户ID!' }];
|
// return [{ required: true, message: '请输入用户ID!' }];
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
{
|
{
|
||||||
label: '姓名',
|
label: '姓名',
|
||||||
field: 'userName',
|
field: 'userName',
|
||||||
|
@ -137,13 +263,29 @@ export const formSchema: FormSchema[] = [
|
||||||
field: 'identityId',
|
field: 'identityId',
|
||||||
component: 'Input',
|
component: 'Input',
|
||||||
dynamicRules: ({ model, schema }) => {
|
dynamicRules: ({ model, schema }) => {
|
||||||
return [{ required: true, message: '请输入身份证!' }];
|
return [
|
||||||
|
{ required: true, message: '请输入身份证!' },
|
||||||
|
{
|
||||||
|
validator: (rule, value) => {
|
||||||
|
if (!value) return Promise.resolve();
|
||||||
|
if (!validateIdCard(value)) {
|
||||||
|
return Promise.reject('请输入正确的身份证号码!');
|
||||||
|
}
|
||||||
|
// 自动填入年龄和性别
|
||||||
|
const birthday = value.substring(6, 10) + '-' + value.substring(10, 12) + '-' + value.substring(12, 14);
|
||||||
|
model.age = calculateAge(birthday);
|
||||||
|
model.sex = getSex(value);
|
||||||
|
return Promise.resolve();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '年龄',
|
label: '年龄',
|
||||||
field: 'age',
|
field: 'age',
|
||||||
component: 'InputNumber',
|
component: 'InputNumber',
|
||||||
|
dynamicDisabled: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '性别',
|
label: '性别',
|
||||||
|
@ -155,6 +297,7 @@ export const formSchema: FormSchema[] = [
|
||||||
{ label: '女', value: 1 },
|
{ label: '女', value: 1 },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
dynamicDisabled: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '学科',
|
label: '学科',
|
||||||
|
|
Loading…
Reference in New Issue