优化外校新增

This commit is contained in:
Qi 2025-05-26 22:57:25 +08:00
parent cbdc977fd6
commit 80338616ee
3 changed files with 87 additions and 45 deletions

View File

@ -34,7 +34,7 @@ function getSex(value: string) {
if (value.length < 17) {
return '';
}
let sex = value.substr(16, 1);
const sex = value.substr(16, 1);
if (sex !== '' || sex !== undefined) {
if (parseInt(sex) % 2 == 1) {
return 0; // 男
@ -49,20 +49,20 @@ function getSex(value: string) {
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;
@ -74,24 +74,53 @@ function validateBirthday(year: number, month: number, day: number) {
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])$)$/;
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: '国外'
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;
}
@ -388,14 +417,7 @@ export const formSchema: FormSchema[] = [
// return [{ required: true, message: '请输入开户行!' }];
//},
},
{
label: '车牌号',
field: 'carNumber',
component: 'Input',
//dynamicRules: ({ model, schema }) => {
// return [{ required: true, message: '请输入车牌号!' }];
//},
},
{
label: '饭卡',
field: 'mealCard',
@ -414,9 +436,9 @@ export const formSchema: FormSchema[] = [
{ label: '否', value: 0 },
],
},
//dynamicRules: ({ model, schema }) => {
// return [{ required: true, message: '请输入是否住宿!' }];
//},
dynamicRules: ({ model, schema }) => {
return [{ required: true, message: '请输入是否住宿!' }];
},
},
{
label: '所属分组',
@ -440,9 +462,24 @@ export const formSchema: FormSchema[] = [
{ label: '否', value: 0 },
],
},
//dynamicRules: ({ model, schema }) => {
// return [{ required: true, message: '请输入车辆是否入校!' }];
//},
dynamicRules: ({ model, schema }) => {
return [{ required: true, message: '请输入车辆是否入校!' }];
},
},
{
label: '车牌号',
field: 'carNumber',
component: 'Input',
componentProps: {
// 输入时自动转为大写
onInput: (e) => {
e.target.value = e.target.value.toUpperCase();
},
},
dynamicRules: ({ model }) => {
return model.carStatus === 1 ? [{ required: true, message: '请输入车牌号!' }] : [];
},
show: ({ model }) => model.carStatus === 1,
},
//{
// label: '住宿信息',

View File

@ -406,7 +406,6 @@
<select
className="custom-select"
value={record.dormitoryName}
disabled={!!record.dormitoryName}
onFocus={() => handleFocus(record)}
onChange={(e) => handleChange(record.userId, e.target.value, record)}
>
@ -527,11 +526,11 @@
.qr {
display: flex;
}
/** 自定义选择框容器 */
/* 自定义选择框容器 */
.custom-select-wrapper {
position: relative;
display: inline-block;
width: 150px;
width: 200px; /* 增加宽度 */
}
/* 原生select元素美化 */
@ -540,14 +539,14 @@
-webkit-appearance: none;
-moz-appearance: none;
width: 100%;
padding: 6px 12px;
padding: 10px 15px; /* 增加内边距 */
font-size: 14px;
line-height: 1.5;
color: rgba(0, 0, 0, 0.85);
background-color: #fff;
color: #333; /* 深灰色文字 */
background-color: #f9f9f9; /* 浅灰色背景 */
background-image: none;
border: 1px solid #d9d9d9;
border-radius: 4px;
border: 1px solid #ccc; /* 浅灰色边框 */
border-radius: 6px; /* 增加圆角 */
transition: all 0.3s;
cursor: pointer;
}
@ -556,31 +555,33 @@
.custom-arrow {
position: absolute;
top: 50%;
right: 12px;
right: 15px; /* 增加右边距 */
transform: translateY(-50%);
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-top: 5px solid #999;
border-left: 6px solid transparent; /* 增大箭头大小 */
border-right: 6px solid transparent;
border-top: 6px solid #666; /* 深灰色箭头 */
pointer-events: none;
}
/* 交互状态 */
.custom-select:focus {
border-color: #40a9ff;
border-color: #40a9ff; /* 蓝色边框 */
box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
outline: none;
}
.custom-select:disabled {
color: rgba(0, 0, 0, 0.25);
background-color: #f5f5f5;
color: #ccc; /* 浅灰色文字 */
background-color: #f5f5f5; /* 浅灰色背景 */
cursor: not-allowed;
}
/* 选项样式 */
.custom-select option {
padding: 8px 12px;
padding: 10px 15px; /* 增加内边距 */
background-color: #f9f9f9; /* 浅灰色背景 */
color: #333; /* 深灰色文字 */
}
</style>

View File

@ -42,6 +42,10 @@
try {
let values = await validate();
setModalProps({ confirmLoading: true });
//
if (values.carNumber) {
values.carNumber = values.carNumber.toUpperCase();
}
//
await saveOrUpdate(values, isUpdate.value);
//