Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
JINRUN-PERPOSITION
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xinzhedeai
JINRUN-PERPOSITION
Commits
9afa942a
Commit
9afa942a
authored
Nov 27, 2025
by
xinzhedeai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add:员工 部门列表 岗位下拉
parent
cbed1d6f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
123 additions
and
33 deletions
+123
-33
zhongkong.js
src/api/jinrun/zhongkong.js
+2
-2
yuangong.vue
src/views/person/yuangong.vue
+121
-31
No files found.
src/api/jinrun/zhongkong.js
View file @
9afa942a
...
@@ -13,8 +13,8 @@ export function getDept(data) {
...
@@ -13,8 +13,8 @@ export function getDept(data) {
export
function
getPosition
(
data
)
{
export
function
getPosition
(
data
)
{
return
request
({
return
request
({
url
:
'
/pos/list
'
,
url
:
'
/pos/list
'
,
method
:
'
pos
t
'
,
method
:
'
ge
t
'
,
data
:
data
params
:
data
})
})
}
}
...
...
src/views/person/yuangong.vue
View file @
9afa942a
...
@@ -143,19 +143,15 @@
...
@@ -143,19 +143,15 @@
</el-form-item>
</el-form-item>
</el-col>
</el-col>
<el-col
:span=
"12"
>
<el-col
:span=
"12"
>
<el-form-item
label=
"所在部门"
prop=
"cardId"
>
<el-form-item
label=
"所在部门"
prop=
"deptId"
>
<el-select
<el-cascader
v-model=
"form.cardId"
v-model=
"form.deptPath"
:options=
"deptOptions"
:props=
"cascaderProps"
placeholder=
"请选择所在部门"
placeholder=
"请选择所在部门"
clearable
clearable
>
@
change=
"handleDeptChange"
<el-option
></el-cascader>
v-for=
"item in deptOptions"
:key=
"item.value"
:label=
"item.label"
:value=
"item.value"
></el-option>
</el-select>
</el-form-item>
</el-form-item>
</el-col>
</el-col>
<el-col
:span=
"12"
>
<el-col
:span=
"12"
>
...
@@ -166,10 +162,10 @@
...
@@ -166,10 +162,10 @@
clearable
clearable
>
>
<el-option
<el-option
v-for=
"item in
cardId
Options"
v-for=
"item in
position
Options"
:key=
"item.
cardId
"
:key=
"item.
value
"
:label=
"item.
cardId
"
:label=
"item.
label
"
:value=
"item.
cardId
"
:value=
"item.
value
"
></el-option>
></el-option>
</el-select>
</el-select>
</el-form-item>
</el-form-item>
...
@@ -306,6 +302,12 @@ export default {
...
@@ -306,6 +302,12 @@ export default {
name
:
"
Info
"
,
name
:
"
Info
"
,
data
()
{
data
()
{
return
{
return
{
// 级联选择器配置
cascaderProps
:
{
value
:
"
index
"
,
label
:
"
name
"
,
children
:
"
children
"
,
},
deptOptions
:
[
deptOptions
:
[
{
{
label
:
"
部门1
"
,
label
:
"
部门1
"
,
...
@@ -386,7 +388,6 @@ export default {
...
@@ -386,7 +388,6 @@ export default {
this
.
getPersonTypeOptions
();
this
.
getPersonTypeOptions
();
// 获取部门列表
// 获取部门列表
this
.
getDeptList
();
this
.
getDeptList
();
// 获取岗位列表
// 获取岗位列表
this
.
getPositionList
();
this
.
getPositionList
();
// 获取定位卡号列表
// 获取定位卡号列表
...
@@ -394,31 +395,120 @@ export default {
...
@@ -394,31 +395,120 @@ export default {
},
},
methods
:
{
methods
:
{
/** 递归处理部门树,转换为级联选择器需要的格式 */
processDepartmentTreeForCascader
(
departments
)
{
// 直接返回处理后的部门树,不需要扁平化
return
departments
.
map
((
dept
)
=>
{
const
processedDept
=
{
index
:
dept
.
index
,
name
:
dept
.
name
,
children
:
[],
};
// 如果有子部门,递归处理
if
(
dept
.
children
&&
dept
.
children
.
length
>
0
)
{
processedDept
.
children
=
this
.
processDepartmentTreeForCascader
(
dept
.
children
);
}
else
{
// 如果没有子部门,设置为null
processedDept
.
children
=
null
;
}
return
processedDept
;
});
},
/** 获取部门列表 */
getDeptList
()
{
getDept
({})
.
then
((
response
)
=>
{
console
.
log
(
response
.
data
,
"
部门数据
"
);
// 检查数据格式是否正确
if
(
response
.
data
&&
Array
.
isArray
(
response
.
data
)
&&
response
.
data
.
length
>
0
)
{
// 获取根节点的子部门并处理为级联格式
const
rootChildren
=
response
.
data
[
0
].
children
||
[];
this
.
deptOptions
=
this
.
processDepartmentTreeForCascader
(
rootChildren
);
}
else
{
this
.
deptOptions
=
[];
console
.
error
(
"
部门数据格式不正确
"
);
}
})
.
catch
((
error
)
=>
{
console
.
error
(
"
获取部门列表失败:
"
,
error
);
this
.
deptOptions
=
[];
});
},
/** 处理部门选择变化 */
handleDeptChange
(
value
)
{
if
(
value
&&
value
.
length
>
0
)
{
// 保存最后一级的部门ID作为deptId
this
.
form
.
deptId
=
value
[
value
.
length
-
1
];
// 查找选择的部门对象,获取部门名称
if
(
this
.
deptOptions
&&
this
.
deptOptions
.
length
>
0
)
{
let
selectedDept
=
this
.
findDeptById
(
this
.
deptOptions
,
this
.
form
.
deptId
);
if
(
selectedDept
)
{
this
.
form
.
deptName
=
selectedDept
.
name
;
}
}
}
else
{
this
.
form
.
deptId
=
null
;
this
.
form
.
deptName
=
null
;
}
},
/** 根据ID查找部门对象 */
findDeptById
(
departments
,
targetId
)
{
for
(
const
dept
of
departments
)
{
if
(
dept
.
index
===
targetId
)
{
return
dept
;
}
if
(
dept
.
children
&&
dept
.
children
.
length
>
0
)
{
const
found
=
this
.
findDeptById
(
dept
.
children
,
targetId
);
if
(
found
)
{
return
found
;
}
}
}
return
null
;
},
/** 获取岗位列表 */
/** 获取岗位列表 */
getPositionList
()
{
getPositionList
()
{
getPosition
({
getPosition
({
pageNum
:
1
,
pageNum
:
1
,
pageSize
:
1000
,
pageSize
:
1000
,
}).
then
((
response
)
=>
{
}).
then
((
response
)
=>
{
console
.
log
(
response
.
data
);
console
.
log
(
response
.
data
,
"
22222
"
);
this
.
positionOptions
=
response
.
data
.
map
((
item
)
=>
({
this
.
positionOptions
=
response
.
data
.
map
((
item
)
=>
({
label
:
item
.
posName
,
label
:
item
.
posName
,
value
:
item
.
posI
d
,
value
:
item
.
i
d
,
}));
}));
});
});
},
},
/** 获取部门列表 */
/** 获取部门列表 */
getDeptList
()
{
// getDeptList() {
getDept
({
// getDept({
pageNum
:
1
,
// pageNum: 1,
pageSize
:
1000
,
// pageSize: 1000,
}).
then
((
response
)
=>
{
// }).then((response) => {
this
.
deptOptions
=
response
.
data
.
map
((
item
)
=>
({
// console.log(response.data, "33333");
label
:
item
.
deptName
,
// this.deptOptions = response.data.data[0].children.map((item) => ({
value
:
item
.
deptId
,
// label: item.deptName,
}));
// value: item.deptId,
});
// }));
},
// });
// },
/** 解绑卡按钮操作 */
/** 解绑卡按钮操作 */
handleUnbindCard
(
row
)
{
handleUnbindCard
(
row
)
{
this
.
$modal
this
.
$modal
...
@@ -637,7 +727,7 @@ export default {
...
@@ -637,7 +727,7 @@ export default {
submitForm
()
{
submitForm
()
{
this
.
$refs
[
"
form
"
].
validate
((
valid
)
=>
{
this
.
$refs
[
"
form
"
].
validate
((
valid
)
=>
{
if
(
valid
)
{
if
(
valid
)
{
this
.
form
.
personType
=
"
staff
"
;
this
.
form
.
personType
=
"
1
"
;
// 创建一个表单数据的副本,避免直接修改原表单
// 创建一个表单数据的副本,避免直接修改原表单
const
formData
=
{
...
this
.
form
};
const
formData
=
{
...
this
.
form
};
...
@@ -652,7 +742,7 @@ export default {
...
@@ -652,7 +742,7 @@ export default {
(
item
)
=>
item
.
value
===
formData
.
deptId
(
item
)
=>
item
.
value
===
formData
.
deptId
);
);
if
(
deptItem
)
{
if
(
deptItem
)
{
formData
.
deptName
=
deptItem
.
label
;
// 添加部门名称参数
formData
.
deptName
=
deptItem
.
label
.
replace
(
/^├─/
,
""
);
// 移除前缀后作为部门名称
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment