Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qr-consistency-vue3
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
刘怀志
qr-consistency-vue3
Commits
65e1ffce
Commit
65e1ffce
authored
Apr 29, 2025
by
lwy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(用户管理):修复配置制造厂,配置事业部,新建管理员功能
parent
ce8a94ec
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
172 additions
and
60 deletions
+172
-60
user.js
src/api/system/user.js
+18
-0
index.vue
src/views/system/user/index.vue
+154
-60
No files found.
src/api/system/user.js
View file @
65e1ffce
...
@@ -127,6 +127,24 @@ export function updateAuthRole(data) {
...
@@ -127,6 +127,24 @@ export function updateAuthRole(data) {
})
})
}
}
// 配置制造厂
export
function
updateUserFactory
(
data
)
{
return
request
({
url
:
'/system/user/addUserFactory'
,
method
:
'put'
,
params
:
data
,
})
}
// 配置制造厂
export
function
updateUserUnit
(
data
)
{
return
request
({
url
:
'/system/user/addUserUnit'
,
method
:
'put'
,
params
:
data
,
})
}
// 查询部门下拉树结构
// 查询部门下拉树结构
export
function
deptTreeSelect
()
{
export
function
deptTreeSelect
()
{
return
request
({
return
request
({
...
...
src/views/system/user/index.vue
View file @
65e1ffce
...
@@ -94,10 +94,10 @@
...
@@ -94,10 +94,10 @@
/>
/>
</el-form-item>
</el-form-item>
<el-form-item>
<el-form-item>
<el-button
type=
"primary"
icon=
"Search"
@
click=
"handleQuery"
<el-button
type=
"primary"
class=
"btn-A"
icon=
"Search"
@
click=
"handleQuery"
>
搜索
</el-button
>
搜索
</el-button
>
>
<el-button
icon=
"Refresh"
@
click=
"resetQuery"
>
重置
</el-button>
<el-button
class=
"btn-B"
icon=
"Refresh"
@
click=
"resetQuery"
>
重置
</el-button>
</el-form-item>
</el-form-item>
</el-form>
</el-form>
...
@@ -105,6 +105,7 @@
...
@@ -105,6 +105,7 @@
<el-button
<el-button
v-hasPermi=
"['system:user:add']"
v-hasPermi=
"['system:user:add']"
style=
"float: right;margin: 12px 0"
style=
"float: right;margin: 12px 0"
class=
"btn-A"
type=
"primary"
type=
"primary"
plain
plain
icon=
"Plus"
icon=
"Plus"
...
@@ -257,7 +258,7 @@
...
@@ -257,7 +258,7 @@
v-if=
"scope.row.userType !== '00'"
v-if=
"scope.row.userType !== '00'"
type=
"primary"
type=
"primary"
v-hasPermi=
"['system:user:edit']"
v-hasPermi=
"['system:user:edit']"
@
click=
"
divsionDialog = true
"
@
click=
"
openDivsionDialog(scope.row)
"
>
配置事业部
</el-button>
>
配置事业部
</el-button>
<el-button
<el-button
v-hasPermi=
"['system:user:edit']"
v-hasPermi=
"['system:user:edit']"
...
@@ -277,14 +278,15 @@
...
@@ -277,14 +278,15 @@
@
pagination=
"getList"
@
pagination=
"getList"
/>
/>
</el-col>
</el-col>
<!--事业部 出来再改-->
<!--配置事业部-->
<el-dialog
v-model=
"divsionDialog"
title=
"配置事业部"
width=
"600px"
append-to-body
>
<el-dialog
v-model=
"divsionDialog"
title=
"配置事业部"
width=
"600px"
append-to-body
>
<el-form
ref=
"userRef"
:model=
"form"
label-width=
"80px"
>
<el-form
ref=
"userRef"
:model=
"form"
label-width=
"80px"
>
<el-form-item>
<el-form-item
label=
"事业部"
prop=
"unitNames"
>
<el-checkbox-group
v-model=
"selecteDivsions"
>
<el-checkbox-group
v-model=
"selecteDivsions"
>
<div
style=
"display: flex; flex-wrap: wrap;"
>
<div
style=
"display: flex; flex-wrap: wrap;"
>
<div
v-for=
"(
divsion, index) in allDivsions"
:key=
"index
"
style=
"width: 33%; margin-bottom: 10px;"
>
<div
v-for=
"(
businessUnit) in allDivsions"
:key=
"businessUnit
"
style=
"width: 33%; margin-bottom: 10px;"
>
<el-checkbox
:
label=
"divsion"
>
{{ divsion
}}
</el-checkbox>
<el-checkbox
:
value=
"businessUnit.id"
>
{{ businessUnit.name
}}
</el-checkbox>
</div>
</div>
</div>
</div>
</el-checkbox-group>
</el-checkbox-group>
...
@@ -293,7 +295,7 @@
...
@@ -293,7 +295,7 @@
<
template
#
footer
>
<
template
#
footer
>
<span
class=
"dialog-footer"
>
<span
class=
"dialog-footer"
>
<el-button
@
click=
"cancel"
>
取 消
</el-button>
<el-button
@
click=
"cancel"
>
取 消
</el-button>
<el-button
type=
"primary"
@
click=
"submit
Form
"
>
保 存
</el-button>
<el-button
type=
"primary"
@
click=
"submit
Unit
"
>
保 存
</el-button>
</span>
</span>
</
template
>
</
template
>
</el-dialog>
</el-dialog>
...
@@ -301,12 +303,12 @@
...
@@ -301,12 +303,12 @@
<!-- 配置制造工厂 -->
<!-- 配置制造工厂 -->
<el-dialog
v-model=
"dialogFactory"
title=
"配置制造工厂"
width=
"600px"
append-to-body
>
<el-dialog
v-model=
"dialogFactory"
title=
"配置制造工厂"
width=
"600px"
append-to-body
>
<el-form
ref=
"userRef"
:model=
"form"
label-width=
"80px"
>
<el-form
ref=
"userRef"
:model=
"form"
label-width=
"80px"
>
<el-form-item
label=
"制造工厂"
prop=
"factoryName"
>
<el-form-item
label=
"制造工厂"
prop=
"factoryName
s
"
>
<el-checkbox-group
v-model=
"selectedFactories"
>
<el-checkbox-group
v-model=
"selectedFactories"
>
<div
style=
"display: flex; flex-wrap: wrap;"
>
<div
style=
"display: flex; flex-wrap: wrap;"
>
<div
v-for=
"(factory
, index) in allFactories"
:key=
"index
"
style=
"width: 33%; margin-bottom: 10px;"
>
<div
v-for=
"(factory
) in allFactories"
:key=
"factory.id
"
style=
"width: 33%; margin-bottom: 10px;"
>
<!-- 在 el-checkbox 标签中 -->
<!-- 在 el-checkbox 标签中 -->
<el-checkbox
:
label=
"factory"
>
{{ factory
}}
</el-checkbox>
<el-checkbox
:
value=
"factory.id"
>
{{ factory.name
}}
</el-checkbox>
</div>
</div>
</div>
</div>
</el-checkbox-group>
</el-checkbox-group>
...
@@ -315,7 +317,7 @@
...
@@ -315,7 +317,7 @@
<
template
#
footer
>
<
template
#
footer
>
<span
class=
"dialog-footer"
>
<span
class=
"dialog-footer"
>
<el-button
@
click=
"cancel"
>
取 消
</el-button>
<el-button
@
click=
"cancel"
>
取 消
</el-button>
<el-button
type=
"primary"
@
click=
"submitF
orm
"
>
保 存
</el-button>
<el-button
type=
"primary"
@
click=
"submitF
actory
"
>
保 存
</el-button>
</span>
</span>
</
template
>
</
template
>
</el-dialog>
</el-dialog>
...
@@ -348,12 +350,19 @@
...
@@ -348,12 +350,19 @@
maxlength=
"30"
maxlength=
"30"
/>
/>
</el-form-item>
</el-form-item>
<!--事业部数据出来后修改-->
<el-form-item
label=
"所属事业部"
prop=
"divsions"
>
<el-form-item
label=
"所属事业部"
prop=
"divsion"
>
<el-select
<el-input
v-model=
"form.divsions"
v-model=
"form.divsion"
placeholder=
"请选择"
placeholder=
"请输入事业部"
multiple
maxlength=
"30"
/>
>
<el-option
v-for=
"item in allDivsions"
:key=
"item.id"
:label=
"item.name"
:value=
"item.id"
/>
</el-select>
</el-form-item>
</el-form-item>
<el-form-item
label=
"联系电话"
prop=
"phonenumber"
>
<el-form-item
label=
"联系电话"
prop=
"phonenumber"
>
<el-input
<el-input
...
@@ -362,17 +371,6 @@
...
@@ -362,17 +371,6 @@
maxlength=
"11"
maxlength=
"11"
/>
/>
</el-form-item>
</el-form-item>
<el-form-item
v-if=
"form.userId == undefined"
label=
"用户名称"
prop=
"userName"
>
<el-input
v-model=
"form.userName"
placeholder=
"请输入用户名称"
maxlength=
"30"
/>
</el-form-item>
<el-form-item
<el-form-item
label=
"用户密码"
label=
"用户密码"
prop=
"password"
prop=
"password"
...
@@ -399,8 +397,8 @@
...
@@ -399,8 +397,8 @@
v-for=
"dict in sys_user_status"
v-for=
"dict in sys_user_status"
:key=
"dict.value"
:key=
"dict.value"
:value=
"dict.value"
:value=
"dict.value"
>
{{ dict.label }}
</el-radio
>
{{ dict.label }}
>
</el-radio
>
</el-radio-group>
</el-radio-group>
</el-form-item>
</el-form-item>
<el-form-item
label=
"备注"
>
<el-form-item
label=
"备注"
>
...
@@ -480,7 +478,10 @@ import {
...
@@ -480,7 +478,10 @@ import {
updateUser
,
updateUser
,
addUser
,
addUser
,
deptTreeSelect
,
deptTreeSelect
,
updateUserFactory
,
updateUserUnit
}
from
'@/api/system/user'
}
from
'@/api/system/user'
import
{
getAllBusinessUnitName
}
from
"@/api/system/basicdata/businessunit.js"
;
import
{
Splitpanes
,
Pane
}
from
'splitpanes'
import
{
Splitpanes
,
Pane
}
from
'splitpanes'
import
'splitpanes/dist/splitpanes.css'
import
'splitpanes/dist/splitpanes.css'
import
{
getAllFactoryName
}
from
"@/api/system/factory"
;
import
{
getAllFactoryName
}
from
"@/api/system/factory"
;
...
@@ -495,6 +496,7 @@ const { sys_normal_disable, sys_user_sex, sys_user_status, sys_user_type } = pro
...
@@ -495,6 +496,7 @@ const { sys_normal_disable, sys_user_sex, sys_user_status, sys_user_type } = pro
'sys_user_status'
,
'sys_user_status'
,
'sys_user_type'
'sys_user_type'
)
)
const
dialogFactory
=
ref
(
false
)
const
dialogFactory
=
ref
(
false
)
const
divsionDialog
=
ref
(
false
)
const
divsionDialog
=
ref
(
false
)
// 选中的工厂列表
// 选中的工厂列表
...
@@ -518,6 +520,11 @@ const enabledDeptOptions = ref(undefined)
...
@@ -518,6 +520,11 @@ const enabledDeptOptions = ref(undefined)
const
initPassword
=
ref
(
undefined
)
const
initPassword
=
ref
(
undefined
)
const
postOptions
=
ref
([])
const
postOptions
=
ref
([])
const
roleOptions
=
ref
([])
const
roleOptions
=
ref
([])
const
currentUserId
=
ref
(
''
);
// 当前行用户ID
const
allDivsions
=
ref
([]);
// 所有可选的工厂列表
const
allFactories
=
ref
([])
/*** 用户导入参数 */
/*** 用户导入参数 */
const
upload
=
reactive
({
const
upload
=
reactive
({
...
@@ -549,6 +556,7 @@ const columns = ref([
...
@@ -549,6 +556,7 @@ const columns = ref([
const
data
=
reactive
({
const
data
=
reactive
({
form
:
{},
form
:
{},
queryParams
:
{
queryParams
:
{
divsions
:
[],
//新建管理员所需事业部
pageNum
:
1
,
pageNum
:
1
,
pageSize
:
10
,
pageSize
:
10
,
userName
:
null
,
userName
:
null
,
...
@@ -558,7 +566,7 @@ const data = reactive({
...
@@ -558,7 +566,7 @@ const data = reactive({
},
},
rules
:
{
rules
:
{
userName
:
[
userName
:
[
{
required
:
true
,
message
:
'用户名
称
不能为空'
,
trigger
:
'blur'
},
{
required
:
true
,
message
:
'用户名不能为空'
,
trigger
:
'blur'
},
{
{
min
:
2
,
min
:
2
,
max
:
20
,
max
:
20
,
...
@@ -567,7 +575,7 @@ const data = reactive({
...
@@ -567,7 +575,7 @@ const data = reactive({
},
},
],
],
nickName
:
[
nickName
:
[
{
required
:
true
,
message
:
'用户
昵称
不能为空'
,
trigger
:
'blur'
},
{
required
:
true
,
message
:
'用户
姓名
不能为空'
,
trigger
:
'blur'
},
],
],
password
:
[
password
:
[
{
required
:
true
,
message
:
'用户密码不能为空'
,
trigger
:
'blur'
},
{
required
:
true
,
message
:
'用户密码不能为空'
,
trigger
:
'blur'
},
...
@@ -601,10 +609,8 @@ const data = reactive({
...
@@ -601,10 +609,8 @@ const data = reactive({
})
})
const
{
queryParams
,
form
,
rules
}
=
toRefs
(
data
)
const
{
queryParams
,
form
,
rules
}
=
toRefs
(
data
)
// 所有可选的工厂列表
const
allFactories
=
ref
([])
// 所有可选的角色
const
allRoles
=
ref
([])
const
isEditMode
=
computed
(()
=>
{
const
isEditMode
=
computed
(()
=>
{
return
title
.
value
===
"编辑"
;
return
title
.
value
===
"编辑"
;
});
});
...
@@ -620,49 +626,90 @@ watch(deptName, (val) => {
...
@@ -620,49 +626,90 @@ watch(deptName, (val) => {
proxy
.
$refs
[
'deptTreeRef'
].
filter
(
val
)
proxy
.
$refs
[
'deptTreeRef'
].
filter
(
val
)
})
})
// 所有可选的事业部
const
allDivsions
=
ref
([
'奇瑞'
,
'星途'
,
'智界'
,
'捷途'
,
'iCAR'
]);
watch
(()
=>
form
.
value
.
divsion
,
(
newVal
)
=>
{
try
{
const
divsionObj
=
JSON
.
parse
(
newVal
||
'{}'
);
selecteDivsions
.
value
=
Object
.
values
(
factoryObj
);
}
catch
(
e
)
{
selecteDivsions
.
value
=
[];
}
},
{
immediate
:
true
});
// 打开配置制造工厂对话框
// 打开配置制造工厂对话框
function
openFactoryDialog
(
row
)
{
function
openFactoryDialog
(
row
)
{
dialogFactory
.
value
=
true
;
dialogFactory
.
value
=
true
;
currentUserId
.
value
=
row
.
userId
;
// 直接使用当前行的 factoryName(假设是数组)
// 直接使用当前行的 factoryName(假设是数组)
selectedFactories
.
value
=
row
.
factoryName
?
row
.
factoryName
.
split
(
','
)
:
[];
const
factoryNames
=
(
row
.
factoryNames
||
''
).
split
(
'、'
).
map
(
name
=>
name
.
trim
());
const
selectedIds
=
factoryNames
.
map
(
name
=>
{
const
factory
=
allFactories
.
value
.
find
(
f
=>
f
.
name
===
name
);
return
factory
?.
id
;
}).
filter
(
id
=>
id
!==
undefined
);
selectedFactories
.
value
=
selectedIds
;
}
}
// 解析 factoryName(假设存储为 JSON 字符串数组)
// 监听选中的工厂变化,更新表单数据
watch
(
selectedFactories
,
(
newVal
)
=>
{
watch
(
selectedFactories
,
(
newVal
)
=>
{
form
.
value
.
factoryNames
=
JSON
.
stringify
(
newVal
);
// 存储为 JSON 字符串
// 生成名称字符串
// 当selectedFactories发生变化时,从allFactories中过滤出对应工厂名称,并组合成一个名称字符串
const
selectedNames
=
allFactories
.
value
.
filter
(
factory
=>
newVal
.
includes
(
factory
.
id
))
.
map
(
factory
=>
factory
.
name
)
.
join
(
','
);
form
.
value
.
factoryNames
=
selectedNames
;
// 可选:存储ID数组
form
.
value
.
factoryIds
=
newVal
;
},
{
deep
:
true
});
},
{
deep
:
true
});
// 获取工厂数据的方法
// 获取工厂数据的方法
const
fetchFactories
=
async
()
=>
{
const
fetchFactories
=
async
()
=>
{
try
{
try
{
const
response
=
await
getAllFactoryName
();
const
response
=
await
getAllFactoryName
();
// 提取factoryName字段
// 提取factoryName字段
allFactories
.
value
=
response
.
data
.
map
(
item
=>
item
.
factoryName
);
allFactories
.
value
=
response
.
data
.
map
(
item
=>
({
id
:
item
.
id
.
toString
(),
name
:
item
.
factoryName
}));
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
'获取工厂列表失败:'
,
error
);
console
.
error
(
'获取工厂列表失败:'
,
error
);
}
}
};
};
// 获取角色的方法
/*const fetchRoles = async () => {
//获取所有事业部名称的方法
const response = await listRole();
const
fetchBusinessUnits
=
async
()
=>
{
allRoles.value = response.data.map(item => item.roleName);
try
{
};*/
const
response
=
await
getAllBusinessUnitName
();
allDivsions
.
value
=
response
.
data
.
map
(
item
=>
({
id
:
item
.
id
.
toString
(),
name
:
item
.
businessUnitName
}));
}
catch
(
error
)
{
console
.
error
(
'获取事业部列表失败:'
,
error
);
}
};
//打开分配事业部对话框
function
openDivsionDialog
(
row
)
{
divsionDialog
.
value
=
true
;
currentUserId
.
value
=
row
.
userId
;
const
unitNames
=
(
row
.
unitNames
||
''
).
split
(
'、'
).
map
(
name
=>
name
.
trim
());
// 根据单位名称数组转换并过滤出对应的单位ID数组
const
selectedUnitIds
=
unitNames
.
map
(
name
=>
{
// 在所有划分中查找与当前名称匹配的业务单位
const
businessUnit
=
allDivsions
.
value
.
find
(
f
=>
f
.
name
===
name
);
// 返回找到的业务单位的ID,如果未找到则返回undefined
return
businessUnit
?.
id
;
}).
filter
(
id
=>
id
!==
undefined
);
// 过滤掉未找到的单位ID,确保结果数组中仅包含有效的单位ID
selecteDivsions
.
value
=
selectedUnitIds
;
}
watch
(
selecteDivsions
,
(
newVal
)
=>
{
// 生成名称字符串
const
selectedUnitNames
=
allDivsions
.
value
.
filter
(
divsion
=>
newVal
.
includes
(
divsion
.
id
))
.
map
(
divsion
=>
divsion
.
name
)
.
join
(
','
);
form
.
value
.
unitNames
=
selectedUnitNames
;
// 可选:存储ID数组
form
.
value
.
unitIds
=
newVal
;
},
{
deep
:
true
});
/** 查询用户列表 */
/** 查询用户列表 */
function
getList
()
{
function
getList
()
{
...
@@ -856,6 +903,7 @@ function submitFileForm() {
...
@@ -856,6 +903,7 @@ function submitFileForm() {
/** 重置操作表单 */
/** 重置操作表单 */
function
reset
()
{
function
reset
()
{
form
.
value
=
{
form
.
value
=
{
divsions
:
[],
userId
:
null
,
userId
:
null
,
deptId
:
null
,
deptId
:
null
,
userName
:
null
,
userName
:
null
,
...
@@ -937,8 +985,54 @@ function submitForm() {
...
@@ -937,8 +985,54 @@ function submitForm() {
}
}
})
})
}
}
/** 提交制造厂按钮 */
function
submitFactory
()
{
proxy
.
$refs
[
'userRef'
].
validate
((
valid
)
=>
{
if
(
valid
)
{
const
formData
=
new
URLSearchParams
();
formData
.
append
(
'userId'
,
currentUserId
.
value
);
selectedFactories
.
value
.
forEach
((
id
)
=>
{
formData
.
append
(
'factoryIds[]'
,
id
);
});
updateUserFactory
(
formData
)
.
then
(()
=>
{
proxy
.
$modal
.
msgSuccess
(
'配置成功'
);
dialogFactory
.
value
=
false
;
getList
();
})
.
catch
(()
=>
{
proxy
.
$modal
.
msgError
(
'配置失败,请重试'
);
});
}
})
}
/** 提交事业部按钮 */
function
submitUnit
()
{
proxy
.
$refs
[
'userRef'
].
validate
((
valid
)
=>
{
if
(
valid
)
{
const
formData
=
new
URLSearchParams
();
formData
.
append
(
'userId'
,
currentUserId
.
value
);
selecteDivsions
.
value
.
forEach
((
id
)
=>
{
formData
.
append
(
'unitIds[]'
,
id
);
});
updateUserUnit
(
formData
)
.
then
(()
=>
{
proxy
.
$modal
.
msgSuccess
(
'配置成功'
);
divsionDialog
.
value
=
false
;
getList
();
})
.
catch
(()
=>
{
proxy
.
$modal
.
msgError
(
'配置失败,请重试'
);
});
}
})
}
onMounted
(()
=>
{
onMounted
(()
=>
{
fetchFactories
();
fetchFactories
();
fetchBusinessUnits
();
//fetchRoles();
//fetchRoles();
});
});
getDeptTree
()
getDeptTree
()
...
...
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