|
@@ -1,8 +1,11 @@
|
|
|
<template>
|
|
|
<hc-body split>
|
|
|
<template #left>
|
|
|
- <hc-card scrollbar>
|
|
|
- <hc-lazy-tree :is-root-expand="false" :h-props="treeProps" tree-key="id" @load="treeLoadNode" @node-tap="treeNodeTap">
|
|
|
+ <hc-card title="部门树" scrollbar>
|
|
|
+ <template #extra>
|
|
|
+ <el-button hc-btn type="primary" :disabled="isNullES(searchForm.deptId)" @click="clearSearchDeptId">清空选择</el-button>
|
|
|
+ </template>
|
|
|
+ <hc-lazy-tree ref="lazyTreeRef" :is-root-expand="false" :h-props="treeProps" tree-key="id" @load="treeLoadNode" @node-tap="treeNodeTap">
|
|
|
<template #default="{ node }">{{ node.label }}</template>
|
|
|
</hc-lazy-tree>
|
|
|
</hc-card>
|
|
@@ -26,7 +29,7 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
<template #extraToHeader>
|
|
|
- <el-button hc-btn type="primary">新增</el-button>
|
|
|
+ <el-button hc-btn type="primary" @click="addUserClick">新增</el-button>
|
|
|
<el-button hc-btn type="danger">删除</el-button>
|
|
|
<el-button hc-btn type="info">角色配置</el-button>
|
|
|
<el-button hc-btn type="warning">密码重置</el-button>
|
|
@@ -56,11 +59,11 @@
|
|
|
|
|
|
<script setup>
|
|
|
import { onActivated, ref } from 'vue'
|
|
|
-import { getArrValue } from 'js-fast-way'
|
|
|
-import deptApi from '~api/system/dept'
|
|
|
+import { getArrValue, isNullES } from 'js-fast-way'
|
|
|
import { getDictionaryData } from '~uti/tools'
|
|
|
-import mainApi from '~api/system/user'
|
|
|
import HcDataDialog from './modules/user/data.vue'
|
|
|
+import deptApi from '~api/system/dept'
|
|
|
+import mainApi from '~api/system/user'
|
|
|
|
|
|
onActivated(()=> {
|
|
|
getUserTypeData()
|
|
@@ -69,7 +72,7 @@ onActivated(()=> {
|
|
|
|
|
|
//搜索表单
|
|
|
const searchFormType = ref('account')
|
|
|
-const searchFormName = ref('pengct')
|
|
|
+const searchFormName = ref('')
|
|
|
const searchForm = ref({ deptId: null, current: 1, size: 30, total: 0 })
|
|
|
|
|
|
//获取用户平台
|
|
@@ -79,6 +82,7 @@ const getUserTypeData = async () => {
|
|
|
}
|
|
|
|
|
|
//数据格式
|
|
|
+const lazyTreeRef = ref(null)
|
|
|
const treeProps = {
|
|
|
label: 'title',
|
|
|
children: 'children',
|
|
@@ -98,6 +102,13 @@ const treeNodeTap = ({ data }) => {
|
|
|
searchClick()
|
|
|
}
|
|
|
|
|
|
+//清空树节点选择
|
|
|
+const clearSearchDeptId = () => {
|
|
|
+ searchForm.value.deptId = null
|
|
|
+ lazyTreeRef.value?.treeRef?.setCurrentKey(null)
|
|
|
+ searchClick()
|
|
|
+}
|
|
|
+
|
|
|
//搜索
|
|
|
const searchClick = () => {
|
|
|
searchForm.value.current = 1
|
|
@@ -147,17 +158,32 @@ const tableCheckChange = (rows) => {
|
|
|
tableCheckKeys.value = rows
|
|
|
}
|
|
|
|
|
|
+//新增修改用户
|
|
|
const isUserDataShow = ref(false)
|
|
|
+const userItem = ref({})
|
|
|
+
|
|
|
+//新增用户
|
|
|
+const addUserClick = () => {
|
|
|
+ userItem.value = {}
|
|
|
+ isUserDataShow.value = true
|
|
|
+}
|
|
|
|
|
|
//修改账号
|
|
|
-const userItem = ref({})
|
|
|
const editRowClick = (row) => {
|
|
|
userItem.value = row
|
|
|
isUserDataShow.value = true
|
|
|
}
|
|
|
|
|
|
//删除账号
|
|
|
-const delRowClick = () => {
|
|
|
+const delRowClick = async ({ item }, resolve) => {
|
|
|
+ await delUserData(item.id)
|
|
|
+ resolve()
|
|
|
+}
|
|
|
|
|
|
+//删除用户
|
|
|
+const delUserData = async (id) => {
|
|
|
+ const { isRes } = await mainApi.del(id)
|
|
|
+ if (!isRes) return
|
|
|
+ window.$message.success('删除成功')
|
|
|
}
|
|
|
</script>
|