|
@@ -0,0 +1,161 @@
|
|
|
|
|
+<template>
|
|
|
|
|
+ <PageWrapper>
|
|
|
|
|
+ <el-card :bordered="false" class="mb-3 proCard">
|
|
|
|
|
+ <el-space align="center">
|
|
|
|
|
+ <el-input
|
|
|
|
|
+ :style="{ width: '320px' }"
|
|
|
|
|
+ v-model="params.username"
|
|
|
|
|
+ clearable
|
|
|
|
|
+ placeholder="请输入账号"
|
|
|
|
|
+ @keyup.enter="reloadTable"
|
|
|
|
|
+ />
|
|
|
|
|
+ <el-button type="primary" @click="reloadTable" :icon="Search"> 查询 </el-button>
|
|
|
|
|
+ </el-space>
|
|
|
|
|
+ </el-card>
|
|
|
|
|
+ <el-card :bordered="false" class="proCard">
|
|
|
|
|
+ <BasicTable
|
|
|
|
|
+ :columns="columns"
|
|
|
|
|
+ :request="loadDataTable"
|
|
|
|
|
+ :row-key="(row) => row.userId"
|
|
|
|
|
+ ref="basicTableRef"
|
|
|
|
|
+ :actionColumn="actionColumn"
|
|
|
|
|
+ @update:checked-row-keys="onCheckedRow"
|
|
|
|
|
+ virtual-scroll
|
|
|
|
|
+ >
|
|
|
|
|
+ <template #tableTitle>
|
|
|
|
|
+ <el-space align="center">
|
|
|
|
|
+ <el-button type="primary" @click="openCreateDrawer">
|
|
|
|
|
+ <template #icon>
|
|
|
|
|
+ <el-icon>
|
|
|
|
|
+ <FileAddOutlined />
|
|
|
|
|
+ </el-icon>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ 添加
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- <el-button type="error" @click="openRemoveModal" :disabled="!rowKeys.length">
|
|
|
|
|
+ <template #icon>
|
|
|
|
|
+ <el-icon>
|
|
|
|
|
+ <DeleteOutlined />
|
|
|
|
|
+ </el-icon>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ 删除
|
|
|
|
|
+ </el-button> -->
|
|
|
|
|
+ </el-space>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </BasicTable>
|
|
|
|
|
+ </el-card>
|
|
|
|
|
+
|
|
|
|
|
+ <CreateDrawer
|
|
|
|
|
+ ref="createDrawerRef"
|
|
|
|
|
+ :title="drawerTitle"
|
|
|
|
|
+ :roleList="roleData"
|
|
|
|
|
+ @change="reloadTable"
|
|
|
|
|
+ />
|
|
|
|
|
+ </PageWrapper>
|
|
|
|
|
+</template>
|
|
|
|
|
+
|
|
|
|
|
+<script lang="ts" setup>
|
|
|
|
|
+ import { h, reactive, ref, onMounted } from 'vue';
|
|
|
|
|
+ import { ElMessage } from 'element-plus';
|
|
|
|
|
+ import { BasicTable, TableAction, BasicColumn } from '@/components/Table';
|
|
|
|
|
+ import { getUserList } from '@/api/system/user';
|
|
|
|
|
+ import { FileAddOutlined } from '@vicons/antd';
|
|
|
|
|
+ import { roleAllList } from '@/api/system/role';
|
|
|
|
|
+ import { delUser } from '@/api/system/user';
|
|
|
|
|
+ import CreateDrawer from './CreateDrawer.vue';
|
|
|
|
|
+ import { columns } from './columns';
|
|
|
|
|
+ import { Search } from '@element-plus/icons-vue';
|
|
|
|
|
+
|
|
|
|
|
+ const message = ElMessage;
|
|
|
|
|
+ const basicTableRef = ref();
|
|
|
|
|
+ const rowKeys = ref([]);
|
|
|
|
|
+ const rowKeysName = ref([]);
|
|
|
|
|
+ const tableData = ref();
|
|
|
|
|
+ const createDrawerRef = ref();
|
|
|
|
|
+ const drawerTitle = ref('添加用户');
|
|
|
|
|
+ const roleData = ref([]);
|
|
|
|
|
+
|
|
|
|
|
+ const params = reactive({
|
|
|
|
|
+ username: '',
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ const actionColumn: BasicColumn = reactive({
|
|
|
|
|
+ width: 150,
|
|
|
|
|
+ title: '操作',
|
|
|
|
|
+ prop: 'action',
|
|
|
|
|
+ fixed: 'right',
|
|
|
|
|
+ align: 'center',
|
|
|
|
|
+ render(record) {
|
|
|
|
|
+ return h(TableAction as any, {
|
|
|
|
|
+ actions: [
|
|
|
|
|
+ {
|
|
|
|
|
+ label: '删除',
|
|
|
|
|
+ isConfirm: true,
|
|
|
|
|
+ popConfirm: {
|
|
|
|
|
+ onConfirm: handleDelete.bind(null, record.row),
|
|
|
|
|
+ title: '您确定要删除吗?',
|
|
|
|
|
+ confirmButtonText: '确定',
|
|
|
|
|
+ cancelButtonText: '取消',
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ label: '编辑',
|
|
|
|
|
+ onClick: handleEdit.bind(null, record.row),
|
|
|
|
|
+ },
|
|
|
|
|
+ ],
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ const loadDataTable = async (res) => {
|
|
|
|
|
+ const result = await getUserList({ ...params, ...res });
|
|
|
|
|
+ tableData.value = result.list;
|
|
|
|
|
+ return result;
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ function onCheckedRow(keys) {
|
|
|
|
|
+ rowKeys.value = keys;
|
|
|
|
|
+ rowKeysName.value = tableData.value
|
|
|
|
|
+ .filter((item) => {
|
|
|
|
|
+ return keys.includes(item.id);
|
|
|
|
|
+ })
|
|
|
|
|
+ .map((item) => {
|
|
|
|
|
+ return item.username;
|
|
|
|
|
+ })
|
|
|
|
|
+ .join(',');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function reloadTable() {
|
|
|
|
|
+ basicTableRef.value.reload();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function openCreateDrawer() {
|
|
|
|
|
+ const { openDrawer } = createDrawerRef.value;
|
|
|
|
|
+ openDrawer();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function handleEdit(record: Recordable) {
|
|
|
|
|
+ console.log('点击了编辑', record);
|
|
|
|
|
+ drawerTitle.value = '编辑用户';
|
|
|
|
|
+ const { openDrawer } = createDrawerRef.value;
|
|
|
|
|
+ openDrawer(record.userId);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function handleDelete(record: Recordable) {
|
|
|
|
|
+ delUser({ userId: record.userId }).then(() => {
|
|
|
|
|
+ message.success('删除成功');
|
|
|
|
|
+ reloadTable();
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ onMounted(async () => {
|
|
|
|
|
+ const res = await roleAllList();
|
|
|
|
|
+ roleData.value = res.list.map((item: any) => {
|
|
|
|
|
+ return {
|
|
|
|
|
+ value: item.roleId,
|
|
|
|
|
+ label: item.roleName,
|
|
|
|
|
+ };
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+</script>
|