Merge branch 'master' of gitee.com:youlaitech/vue3-element-admin
This commit is contained in:
@@ -135,15 +135,10 @@
|
||||
label="上级部门"
|
||||
prop="parentId"
|
||||
>
|
||||
<TreeSelect
|
||||
:treeProps="dataMap.props"
|
||||
<tree-select
|
||||
:options="dataMap.deptOptions"
|
||||
placeholder="选择上级部门"
|
||||
:originOptions="dataMap.originOptions"
|
||||
:defalut="dataMap.formVal.parentId"
|
||||
:user="true"
|
||||
@callBack="getDeptId"
|
||||
:disabled="dataMap.disabled"
|
||||
v-model:value="dataMap.formVal.parentId"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="部门名称" prop="name">
|
||||
@@ -296,25 +291,10 @@ function resetQuery() {
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
function flatten(origin: any) {
|
||||
let result: any = []
|
||||
for (let i = 0; i < origin.length; i++) {
|
||||
const item = origin[i]
|
||||
if (Array.isArray(item.children)) {
|
||||
result = result.concat(flatten(item.children))
|
||||
result.push(item)
|
||||
} else {
|
||||
result.push(item)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/** 查询部门下拉树结构 */
|
||||
function getTreeselect() {
|
||||
getDeptSelectList().then(response => {
|
||||
dataMap.deptOptions = response.data
|
||||
dataMap.originOptions = flatten(response?.data) as any
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -264,6 +264,7 @@
|
||||
width="600px"
|
||||
append-to-body
|
||||
@opened="showDialog"
|
||||
@close="cancel"
|
||||
>
|
||||
<el-form
|
||||
ref="addForm"
|
||||
@@ -288,14 +289,10 @@
|
||||
label="归属部门"
|
||||
prop="deptId"
|
||||
>
|
||||
<Treeselect
|
||||
:treeProps="dataMap.props"
|
||||
<tree-select
|
||||
:options="dataMap.deptOptions"
|
||||
placeholder="请选择归属部门"
|
||||
:originOptions="dataMap.originOptions"
|
||||
:defalut="dataMap.formVal.deptId"
|
||||
:user="true"
|
||||
@callBack="getDeptId"
|
||||
v-model:value="dataMap.formVal.deptId"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@@ -340,18 +337,19 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item
|
||||
v-if="dataMap.formVal.id === undefined"
|
||||
label="用户密码"
|
||||
prop="password"
|
||||
>
|
||||
<el-input
|
||||
v-model="dataMap.formVal.password"
|
||||
placeholder="请输入用户密码"
|
||||
type="password"
|
||||
/>
|
||||
<el-form-item label="状态">
|
||||
<el-radio-group v-model="dataMap.formVal.status">
|
||||
<el-radio
|
||||
v-for="dict in dataMap.statusOptions"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictValue"
|
||||
>
|
||||
{{ dict.dictLabel }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
@@ -369,21 +367,6 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="状态">
|
||||
<el-radio-group v-model="dataMap.formVal.status">
|
||||
<el-radio
|
||||
v-for="dict in dataMap.statusOptions"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictValue"
|
||||
>
|
||||
{{ dict.dictLabel }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="角色">
|
||||
<el-select
|
||||
@@ -402,6 +385,23 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
|
||||
|
||||
<el-col :span="12">
|
||||
<el-form-item
|
||||
v-if="dataMap.formVal.id === undefined"
|
||||
label="用户密码"
|
||||
prop="password"
|
||||
>
|
||||
<el-input
|
||||
v-model="dataMap.formVal.password"
|
||||
placeholder="请输入用户密码"
|
||||
type="password"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div
|
||||
@@ -428,7 +428,7 @@
|
||||
import {listUser, getUser, delUser, addUser, updateUser, patch} from '@/api/system/user'
|
||||
|
||||
import {getDeptSelectList} from '@/api/system/dept'
|
||||
import Treeselect from '@/components/TreeSelect/Index.vue'
|
||||
import TreeSelect from '@/components/TreeSelect/Index.vue'
|
||||
import {listRoles} from '@/api/system/role'
|
||||
import {Search, Plus, Edit, Refresh, Delete} from '@element-plus/icons'
|
||||
|
||||
@@ -607,8 +607,8 @@ function handleNodeClick(data: { [key: string]: any }) {
|
||||
// 用户状态修改
|
||||
function handleStatusChange(row: { [key: string]: any }) {
|
||||
if (dataMap.tigger) {
|
||||
const text = row.status === '1' ? '启用' : '停用'
|
||||
ElMessageBox.confirm('确认要"' + text + '""' + row.username + '"用户吗?', '警告', {
|
||||
const text = row.status === 1 ? '启用' : '停用'
|
||||
ElMessageBox.confirm('确认要' + text + ''+ row.username + '用户吗?', '警告', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
@@ -617,7 +617,7 @@ function handleStatusChange(row: { [key: string]: any }) {
|
||||
}).then(() => {
|
||||
ElMessage.success(text + '成功')
|
||||
}).catch( ()=>{
|
||||
row.status = row.status === '1' ? 1 : 0
|
||||
row.status = row.status === 1 ? 0 : 1
|
||||
})
|
||||
|
||||
}
|
||||
@@ -666,11 +666,7 @@ function handleSelectionChange(selection: any) {
|
||||
|
||||
/** 新增按钮操作 */
|
||||
function handleAdd() {
|
||||
console.log(dataMap.formVal)
|
||||
dataMap.addformFlag = true
|
||||
resetForm()
|
||||
dataMap.originOptions = []
|
||||
// loadDeptOptions()
|
||||
dataMap.open = true
|
||||
dataMap.title = '添加用户'
|
||||
dataMap.formVal.password = "123456"
|
||||
@@ -696,15 +692,12 @@ function resetForm() {
|
||||
|
||||
/** 修改按钮操作 */
|
||||
async function handleUpdate(row: { [key: string]: any }) {
|
||||
resetForm()
|
||||
const userId = row.id || dataMap.ids
|
||||
const response = await getUser(userId);
|
||||
dataMap.formVal = response.data
|
||||
console.log(response.data)
|
||||
dataMap.title = '修改用户'
|
||||
dataMap.formVal.password = ''
|
||||
dataMap.formVal.deptId = 1
|
||||
// dataMap.formVal.deptId = parseInt(response.data.deptId)
|
||||
dataMap.formVal.deptId =response.data.deptId
|
||||
dataMap.open = true
|
||||
}
|
||||
|
||||
@@ -754,9 +747,6 @@ function cancel() {
|
||||
resetForm()
|
||||
}
|
||||
|
||||
function getParentValue(event: any) {
|
||||
console.log(event)
|
||||
}
|
||||
|
||||
function getDeptId(e: any) {
|
||||
dataMap.formVal.deptId = e
|
||||
@@ -787,6 +777,7 @@ onMounted(() => {
|
||||
|
||||
function showDialog() {
|
||||
loadDeptOptions()
|
||||
loadRoleOptions()
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user