Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
jijin
/
dance-pc
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
ee54414c
authored
2025-06-20 16:46:55 +0800
by
zhangmeng
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
国内赛
1 parent
df021c15
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
81 additions
and
33 deletions
src/utils/ruoyi.js
src/viewsPc/match/components/addCoach.vue
src/utils/ruoyi.js
View file @
ee54414
...
...
@@ -114,10 +114,10 @@ export function selectDictLabels(datas, value, separator) {
// 字符串格式化(%s )
export
function
sprintf
(
str
)
{
var
args
=
arguments
;
var
flag
=
true
;
var
args
=
arguments
var
flag
=
true
var
i
=
1
str
=
str
.
replace
(
/%s/g
,
function
()
{
str
=
str
.
replace
(
/%s/g
,
function
()
{
var
arg
=
args
[
i
++
]
if
(
typeof
arg
===
'undefined'
)
{
flag
=
false
...
...
@@ -165,11 +165,11 @@ export function handleTree(data, id, parentId, children) {
parentId
:
parentId
||
'parentId'
,
childrenList
:
children
||
'children'
}
var
childrenListMap
=
{}
var
nodeIds
=
{}
var
tree
=
[]
for
(
const
d
of
data
)
{
const
parentId
=
d
[
config
.
parentId
]
if
(
childrenListMap
[
parentId
]
==
null
)
{
...
...
@@ -178,18 +178,18 @@ export function handleTree(data, id, parentId, children) {
nodeIds
[
d
[
config
.
id
]]
=
d
childrenListMap
[
parentId
].
push
(
d
)
}
for
(
const
d
of
data
)
{
const
parentId
=
d
[
config
.
parentId
]
if
(
nodeIds
[
parentId
]
==
null
)
{
tree
.
push
(
d
)
}
}
for
(
const
t
of
tree
)
{
adaptToChildrenList
(
t
)
}
function
adaptToChildrenList
(
o
)
{
if
(
childrenListMap
[
o
[
config
.
id
]]
!==
null
)
{
o
[
config
.
childrenList
]
=
childrenListMap
[
o
[
config
.
id
]]
...
...
@@ -200,7 +200,7 @@ export function handleTree(data, id, parentId, children) {
}
}
}
return
tree
}
...
...
@@ -236,7 +236,7 @@ export function getNormalPath(p) {
if
(
p
.
length
===
0
||
!
p
||
p
==
'undefined'
)
{
return
p
}
const
res
=
p
.
replace
(
'//'
,
'/'
)
if
(
res
[
res
.
length
-
1
]
===
'/'
)
{
return
res
.
slice
(
0
,
res
.
length
-
1
)
...
...
@@ -260,7 +260,7 @@ export function digitUppercase(price) {
if
(
price
===
null
||
price
===
undefined
)
{
return
}
const
fraction
=
[
'角'
,
'分'
]
const
digit
=
[
'零'
,
'壹'
,
'贰'
,
'叁'
,
'肆'
,
'伍'
,
'陆'
,
'柒'
,
'捌'
,
'玖'
]
const
unit
=
[
...
...
@@ -282,7 +282,7 @@ export function digitUppercase(price) {
}
s
=
p
.
replace
(
/
(
零.
)
*零$/
,
''
).
replace
(
/^$/
,
'零'
)
+
unit
[
0
][
i
]
+
s
}
return
s
.
replace
(
/
(
零.
)
*零元/
,
'元'
).
replace
(
/
(
零.
)
+/g
,
'零'
).
replace
(
/^整$/
,
'零元整'
)
}
...
...
@@ -323,3 +323,42 @@ export function triggerLanguage(fn, cn, en) {
return
cn
}
}
export
function
parseIDCardInfo
(
idNumber
)
{
// 基础校验
if
(
typeof
idNumber
!==
'string'
||
(
idNumber
.
length
!==
15
&&
idNumber
.
length
!==
18
))
{
return
{
error
:
'身份证号码格式错误(需15位或18位数字)'
}
}
// 移除可能的空格(兼容用户输入带空格的情况)
const
cleanId
=
idNumber
.
replace
(
/
\s
+/g
,
''
)
// 解析出生日期
let
birthDate
if
(
cleanId
.
length
===
18
)
{
// 18位:第7-14位为YYYYMMDD
const
datePart
=
cleanId
.
slice
(
6
,
14
)
if
(
!
/^
\d{8}
$/
.
test
(
datePart
))
return
{
error
:
'身份证号码出生日期部分无效'
}
birthDate
=
datePart
.
replace
(
/
(\d{4})(\d{2})(\d{2})
/
,
'$1-$2-$3'
)
}
else
{
// 15位:第7-12位为YYMMDD(补全年份为19xx)
const
datePart
=
cleanId
.
slice
(
6
,
12
)
if
(
!
/^
\d{6}
$/
.
test
(
datePart
))
return
{
error
:
'身份证号码出生日期部分无效'
}
const
year
=
`19
${
datePart
.
slice
(
0
,
2
)}
`
// 15位身份证年份默认19xx
const
month
=
datePart
.
slice
(
2
,
4
).
padStart
(
2
,
'0'
)
const
day
=
datePart
.
slice
(
4
,
6
).
padStart
(
2
,
'0'
)
birthDate
=
`
${
year
}
-
${
month
}
-
${
day
}
`
}
// 解析性别(最后一位前的奇偶判断)
const
genderDigit
=
cleanId
.
slice
(
-
2
,
-
1
)
// 18位取倒数第2位,15位取倒数第2位(总长度15时slice(14,15))
const
genderCode
=
parseInt
(
genderDigit
,
10
)
if
(
isNaN
(
genderCode
))
return
{
error
:
'身份证号码性别位无效'
}
return
{
gender
:
genderCode
%
2
===
1
?
'男'
:
'女'
,
birthDate
:
birthDate
,
rawId
:
cleanId
// 可选:返回清理后的原始号码
}
}
...
...
src/viewsPc/match/components/addCoach.vue
View file @
ee54414
...
...
@@ -38,14 +38,14 @@
</el-form-item>
<el-form-item
:label=
"language==0?'性别':'Gender'"
prop=
"sex"
>
<el-radio-group
v-model=
"form.sex"
:disabled=
"editgay&&form.labelArr.indexOf('0')>-1"
>
<el-radio-group
v-model=
"form.sex"
:disabled=
"editgay&&form.labelArr.indexOf('0')>-1
||form.idcType==0
"
>
<el-radio
value=
"0"
>
{{
language
==
0
?
'女'
:
'female'
}}
</el-radio>
<el-radio
value=
"1"
>
{{
language
==
0
?
'男'
:
'male'
}}
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item
:label=
"language==0?'出生日期':'Date of Birth'"
prop=
"birth"
required
>
<el-date-picker
v-model=
"form.birth"
:disabled=
"editgay&&form.labelArr.indexOf('0')>-1"
v-model=
"form.birth"
:disabled=
"editgay&&form.labelArr.indexOf('0')>-1
||form.idcType==0
"
:disabled-date=
"disabledBirth"
format=
"YYYY-MM-DD"
style=
"width: 100%;"
type=
"date"
value-format=
"YYYY-MM-DD"
...
...
@@ -104,6 +104,7 @@
<
script
setup
>
import
{
reactive
,
ref
,
toRefs
,
watch
}
from
'vue'
import
{
getCurrentInstance
,
nextTick
,
onMounted
}
from
'@vue/runtime-core'
import
{
parseIDCardInfo
}
from
'@/utils/ruoyi'
import
*
as
match
from
'@/apiPc/match'
import
{
dayjs
,
ElMessage
}
from
'element-plus'
import
_
from
'lodash'
...
...
@@ -125,6 +126,7 @@ const certificates = ref([
}
])
const
{
proxy
}
=
getCurrentInstance
()
const
disabledIdcType
=
ref
(
false
)
const
emit
=
defineEmits
([
'submitForm'
])
const
data
=
reactive
({
form
:
{
...
...
@@ -302,30 +304,37 @@ function checkCode() {
function
giveBirthDay
()
{
// 判断身份证正确性/赋值生日
if
(
form
.
value
.
idcType
==
0
)
{
if
(
form
.
value
.
idc
Code
&&
form
.
value
.
idc
Type
==
0
)
{
if
(
!
(
/
(
^
\d{15}
$
)
|
(
^
\d{17}([
0-9
]
|X
)
$
)
/
.
test
(
form
.
value
.
idcCode
)))
{
ElMessage
.
warning
(
'请输入正确的身份证号码'
)
}
else
{
let
tmpStr
=
''
if
(
form
.
value
.
idcCode
.
length
==
15
)
{
tmpStr
=
form
.
value
.
idcCode
.
substring
(
6
,
12
)
tmpStr
=
'19'
+
tmpStr
tmpStr
=
tmpStr
.
substring
(
0
,
4
)
+
'-'
+
tmpStr
.
substring
(
4
,
6
)
+
'-'
+
tmpStr
.
substring
(
6
)
const
res
=
parseIDCardInfo
(
form
.
value
.
idcCode
)
if
(
res
.
gender
==
'女'
)
{
form
.
value
.
sex
=
'0'
}
else
{
tmpStr
=
form
.
value
.
idcCode
.
substring
(
6
,
14
)
tmpStr
=
tmpStr
.
substring
(
0
,
4
)
+
'-'
+
tmpStr
.
substring
(
4
,
6
)
+
'-'
+
tmpStr
.
substring
(
6
)
}
form
.
value
.
birth
=
tmpStr
const
res
=
/^
(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([
0-9
]
|X
)
$/
if
(
form
.
value
.
idcCode
&&
res
.
test
(
form
.
value
.
idcCode
))
{
const
genderCode
=
form
.
value
.
idcCode
.
charAt
(
16
)
if
(
parseInt
(
genderCode
)
%
2
==
0
)
{
form
.
value
.
sex
=
'0'
}
else
{
form
.
value
.
sex
=
'1'
}
form
.
value
.
sex
=
'1'
}
if
(
res
.
birthDate
)
form
.
value
.
birth
=
res
.
birthDate
// let tmpStr = ''
// if (form.value.idcCode.length == 15) {
// tmpStr = form.value.idcCode.substring(6, 12)
// tmpStr = '19' + tmpStr
// tmpStr = tmpStr.substring(0, 4) + '-' + tmpStr.substring(4, 6) + '-' + tmpStr.substring(6)
// } else {
// tmpStr = form.value.idcCode.substring(6, 14)
// tmpStr = tmpStr.substring(0, 4) + '-' + tmpStr.substring(4, 6) + '-' + tmpStr.substring(6)
// }
// form.value.birth = tmpStr
//
// const res = /^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9]|X)$/
// if (form.value.idcCode && res.test(form.value.idcCode)) {
// const genderCode = form.value.idcCode.charAt(16)
// if (parseInt(genderCode) % 2 == 0) {
// form.value.sex = '0'
// } else {
// form.value.sex = '1'
// }
// }
}
}
}
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment