fix: 调整user编辑逻辑OA用户只能修改角色
This commit is contained in:
@@ -46,6 +46,15 @@ export const getUserDetail = (userId) => {
|
||||
method: "get"
|
||||
});
|
||||
};
|
||||
|
||||
// 操作
|
||||
export const operate = (data, type) => {
|
||||
console.log(type ,'type');
|
||||
if(data.userId && type !== '0') return editUser(data)
|
||||
else if(type == '0') return editUserOA(data)
|
||||
return addUser(data)
|
||||
}
|
||||
|
||||
// 新增用户
|
||||
export const addUser = (data) => {
|
||||
return request({
|
||||
@@ -63,6 +72,15 @@ export const editUser = (data) => {
|
||||
})
|
||||
}
|
||||
|
||||
// 修改OA用户
|
||||
export const editUserOA = (data) => {
|
||||
return request({
|
||||
url: '/admin/mosr/user/oa',
|
||||
method: 'put',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
//删除用户信息
|
||||
export const deleteUser = (userId) => {
|
||||
return request({
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="jsx">
|
||||
import { addUser, editUser } from '@/api/user/user.js'
|
||||
import { operate } from '@/api/user/user.js'
|
||||
import { ElLoading, ElNotification } from 'element-plus';
|
||||
import { useTagsView } from '@/stores/tagsview.js'
|
||||
import { useAuthStore } from '@/stores/userstore.js'
|
||||
@@ -43,7 +43,8 @@ const schame = computed(()=>{
|
||||
clearable: true,
|
||||
filterable: true,
|
||||
checkStrictly: true,
|
||||
data: localData.subCompanyIdOpt
|
||||
data: localData.subCompanyIdOpt,
|
||||
disabled: route.query.userType == 0 ? true : false
|
||||
},
|
||||
on: {
|
||||
change: async (val) => {
|
||||
@@ -61,7 +62,8 @@ const schame = computed(()=>{
|
||||
clearable: true,
|
||||
data: localData.departmentIdOpt,
|
||||
filterable: true,
|
||||
checkStrictly: true
|
||||
checkStrictly: true,
|
||||
disabled: route.query.userType == 0 ? true : false
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -69,7 +71,8 @@ const schame = computed(()=>{
|
||||
prop: 'userName',
|
||||
component: 'el-input',
|
||||
props: {
|
||||
placeholder: '请输入'
|
||||
placeholder: '请输入',
|
||||
disabled: route.query.userType == 0 ? true : false
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -77,7 +80,8 @@ const schame = computed(()=>{
|
||||
prop: 'nickName',
|
||||
component: 'el-input',
|
||||
props: {
|
||||
placeholder: '请输入'
|
||||
placeholder: '请输入',
|
||||
disabled: route.query.userType == 0 ? true : false
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -86,7 +90,7 @@ const schame = computed(()=>{
|
||||
component: 'el-input',
|
||||
props: {
|
||||
placeholder: '请输入',
|
||||
type: 'password'
|
||||
type: 'password',
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -97,7 +101,8 @@ const schame = computed(()=>{
|
||||
placeholder: '请选择',
|
||||
filterable: true,
|
||||
checkStrictly: true,
|
||||
data: localData.jobOpt
|
||||
data: localData.jobOpt,
|
||||
disabled: route.query.userType == 0 ? true : false
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -116,7 +121,8 @@ const schame = computed(()=>{
|
||||
component: 'el-tree-select',
|
||||
props: {
|
||||
placeholder: '请选择',
|
||||
data: cacheStore.getDict('user_sex')
|
||||
data: cacheStore.getDict('user_sex'),
|
||||
disabled: route.query.userType == 0 ? true : false
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -125,7 +131,8 @@ const schame = computed(()=>{
|
||||
component: 'el-tree-select',
|
||||
props: {
|
||||
placeholder: '请选择',
|
||||
data: cacheStore.getDict('normal_disable')
|
||||
data: cacheStore.getDict('normal_disable'),
|
||||
disabled: route.query.userType == 0 ? true : false
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -133,7 +140,8 @@ const schame = computed(()=>{
|
||||
prop: 'mobile',
|
||||
component: 'el-input',
|
||||
props: {
|
||||
placeholder: '请输入'
|
||||
placeholder: '请输入',
|
||||
disabled: route.query.userType == 0 ? true : false
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -141,7 +149,8 @@ const schame = computed(()=>{
|
||||
prop: 'email',
|
||||
component: 'el-input',
|
||||
props: {
|
||||
placeholder: '请输入'
|
||||
placeholder: '请输入',
|
||||
disabled: route.query.userType == 0 ? true : false
|
||||
}
|
||||
},
|
||||
]
|
||||
@@ -198,30 +207,20 @@ const getInfo = async () => {
|
||||
|
||||
const handleSubmit = async () => {
|
||||
const loading = ElLoading.service({fullscreen: true})
|
||||
try {
|
||||
const { isValidate } = await form.value.validate()
|
||||
if(!isValidate) return Promise.reject()
|
||||
const values = form.value.getValues()
|
||||
let message
|
||||
if(route.query.isAdd) {
|
||||
const { code, msg } = await addUser(values)
|
||||
code === 1000 ? message = msg : null
|
||||
} else {
|
||||
const { code, msg } = await editUser(values)
|
||||
code === 1000 ? message = msg : null
|
||||
}
|
||||
const { isValidate } = await form.value.validate()
|
||||
if(!isValidate) return Promise.reject()
|
||||
const values = form.value.getValues()
|
||||
operate(values, route.query.userType).then(res=>{
|
||||
ElNotification({
|
||||
title: route.query.isAdd ? '新增' : '编辑',
|
||||
message: message,
|
||||
type: 'success'
|
||||
message: res.msg,
|
||||
type: res.code === 1000 ? 'success' : 'error'
|
||||
})
|
||||
loading.close()
|
||||
tagsViewStore.delViewAndGoView('/system/user')
|
||||
} catch {
|
||||
res.code === 1000 ? tagsViewStore.delViewAndGoView('/system/user') : null
|
||||
}).finally(()=>{
|
||||
loading.close()
|
||||
return Promise.reject()
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
const handleBack = () => {
|
||||
|
||||
@@ -119,14 +119,8 @@ const tableConfig = reactive({
|
||||
currentRender: ({row, index}) => {
|
||||
return (
|
||||
<div>
|
||||
{
|
||||
row.userType == 0 ?
|
||||
'--' :
|
||||
<div>
|
||||
<el-button type="primary" link onClick={()=>handleEdit(row)}>编辑</el-button>
|
||||
<el-button type="danger" link onClick={()=>handleDel(row)}>删除</el-button>
|
||||
</div>
|
||||
}
|
||||
<el-button type="primary" link onClick={()=>handleEdit(row)}>编辑</el-button>
|
||||
<el-button type="danger" link onClick={()=>handleDel(row)}>删除</el-button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -171,7 +165,8 @@ const handleEdit = (row) => {
|
||||
router.push({
|
||||
path: '/system/useredit',
|
||||
query: {
|
||||
id: row.userId
|
||||
id: row.userId,
|
||||
userType: row.userType
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user