123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- <template>
- <hc-body split>
- <template #left>
- <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>
- </template>
- <hc-card w-to="1800">
- <template #headerToSearch>
- <div class="w-140px">
- <el-select v-model="searchForm.type" placeholder="用户平台" filterable clearable block>
- <el-option v-for="item in userTypeData" :key="item.value" :label="item.label" :value="item.value" />
- </el-select>
- </div>
- <div class="ml-2 w-340px">
- <hc-search-input v-model="searchFormName" placeholder="请输入关键字" @search="searchClick">
- <template #prepend>
- <el-select v-model="searchFormType" placeholder="类型" clearable style="width: 100px">
- <el-option label="登录账号" value="account" />
- <el-option label="用户姓名" value="realName" />
- </el-select>
- </template>
- </hc-search-input>
- </div>
- </template>
- <template #extraToHeader>
- <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>
- <el-button hc-btn type="info">平台配置</el-button>
- <el-button hc-btn type="danger">账号封禁</el-button>
- <el-button hc-btn type="success">账号解封</el-button>
- <el-button hc-btn type="success" plain>导入</el-button>
- <el-button hc-btn type="warning" plain>导出</el-button>
- </template>
- <hc-table
- :column="tableColumn" :datas="tableData" :loading="tableLoading" :index-style="{ width: 60 }"
- is-check :check-style="{ width: 29 }" @selection-change="tableCheckChange"
- >
- <template #action="{ row }">
- <el-link type="warning" @click="editRowClick(row)">修改</el-link>
- <el-link v-del-com:[delRowClick]="row" type="danger">删除</el-link>
- </template>
- </hc-table>
- <template #action>
- <hc-pages :pages="searchForm" @change="pageChange" />
- </template>
- </hc-card>
-
- <HcDataDialog v-model="isUserDataShow" :info="userItem" @finish="getTableData" />
- </hc-body>
- </template>
- <script setup>
- import { onActivated, ref } from 'vue'
- import { getArrValue, isNullES } from 'js-fast-way'
- import { getDictionaryData } from '~uti/tools'
- import HcDataDialog from './modules/user/data.vue'
- import deptApi from '~api/system/dept'
- import mainApi from '~api/system/user'
- onActivated(()=> {
- getUserTypeData()
- searchClick()
- })
- const searchFormType = ref('account')
- const searchFormName = ref('')
- const searchForm = ref({ deptId: null, current: 1, size: 30, total: 0 })
- const userTypeData = ref([])
- const getUserTypeData = async () => {
- userTypeData.value = await getDictionaryData('user_type')
- }
- const lazyTreeRef = ref(null)
- const treeProps = {
- label: 'title',
- children: 'children',
- isLeaf: (item) => {
- return !item.hasChildren
- },
- }
- const treeLoadNode = async ({ item, level }, resolve) => {
- const parentId = level === 0 ? 0 : item.id
- const { data } = await deptApi.getDeptLazyTree(parentId)
- resolve(getArrValue(data))
- }
- const treeNodeTap = ({ data }) => {
- searchForm.value.deptId = data.id
- searchClick()
- }
- const clearSearchDeptId = () => {
- searchForm.value.deptId = null
- lazyTreeRef.value?.treeRef?.setCurrentKey(null)
- searchClick()
- }
- const searchClick = () => {
- searchForm.value.current = 1
- getTableData()
- }
- const pageChange = ({ current, size }) => {
- searchForm.value.current = current
- searchForm.value.size = size
- getTableData()
- }
- const tableColumn = ref([
- { key: 'account', name: '登录账号', width: 140, align: 'center' },
- { key: 'tenantName', name: '所属租户', width: 100, align: 'center' },
- { key: 'realName', name: '用户姓名', width: 100, align: 'center' },
- { key: 'roleName', name: '所属角色', width: 180, align: 'center' },
- { key: 'deptName', name: '所属部门' },
- { key: 'userTypeName', name: '用户平台' },
- { key: 'action', name: '操作', width: 100, align: 'center' },
- ])
- const tableData = ref([])
- const tableLoading = ref(false)
- const getTableData = async () => {
- tableData.value = []
- tableLoading.value = true
- const form = {
- ...searchForm.value,
- total: null,
- }
- if (searchFormName.value) {
- form[searchFormType.value] = searchFormName.value
- }
- const { data } = await mainApi.page(form)
- tableLoading.value = false
- tableData.value = getArrValue(data?.records)
- searchForm.value.total = data?.total ?? 0
- }
- const tableCheckKeys = ref([])
- const tableCheckChange = (rows) => {
- tableCheckKeys.value = rows
- }
- const isUserDataShow = ref(false)
- const userItem = ref({})
- const addUserClick = () => {
- userItem.value = {}
- isUserDataShow.value = true
- }
- const editRowClick = (row) => {
- userItem.value = row
- isUserDataShow.value = true
- }
- 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>
|