|
@@ -0,0 +1,226 @@
|
|
|
|
|
+<template>
|
|
|
|
|
+ <div class="collect-content">
|
|
|
|
|
+ <div class="router-title">
|
|
|
|
|
+ <span>
|
|
|
|
|
+ {{ routerTitle }}
|
|
|
|
|
+ </span>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div class="controls-box">
|
|
|
|
|
+ <div class="scarch-content">
|
|
|
|
|
+ <span>搜索项:</span>
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <a-input-search
|
|
|
|
|
+ v-model:value="pagination.username"
|
|
|
|
|
+ placeholder="请输入用户名"
|
|
|
|
|
+ enter-button
|
|
|
|
|
+ @search="onSearch"
|
|
|
|
|
+ />
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <a-button @click="resetSearch">重置</a-button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <a-button type="primary" @click="showModal">新增</a-button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div class="table-body">
|
|
|
|
|
+ <a-config-provider>
|
|
|
|
|
+ <a-table
|
|
|
|
|
+ :scroll="{ x: 0, y: 600 }"
|
|
|
|
|
+ :pagination="pagination"
|
|
|
|
|
+ @change="handleTableChange"
|
|
|
|
|
+ :loading="loading"
|
|
|
|
|
+ :dataSource="dataSource"
|
|
|
|
|
+ :columns="columns"
|
|
|
|
|
+ emptyText="暂无数据"
|
|
|
|
|
+ >
|
|
|
|
|
+ <template #bodyCell="{ column, record }">
|
|
|
|
|
+ <template v-if="column.key === 'isAdmin'">
|
|
|
|
|
+ <span v-if="record.isAdmin == 1">管理员</span>
|
|
|
|
|
+ <span v-else>普通成员</span>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ <template v-if="column.key === 'action'">
|
|
|
|
|
+ <div class="action-content" v-if="record.isAdmin != 1">
|
|
|
|
|
+ <a-button type="text" @click="resetPassword(record.id)"
|
|
|
|
|
+ >重置密码</a-button
|
|
|
|
|
+ >
|
|
|
|
|
+
|
|
|
|
|
+ <a-popconfirm
|
|
|
|
|
+ title="请确认是否删除"
|
|
|
|
|
+ ok-text="删除"
|
|
|
|
|
+ cancel-text="取消"
|
|
|
|
|
+ @confirm="deleteConfirm(record.id)"
|
|
|
|
|
+ >
|
|
|
|
|
+ <a-button type="text" danger>删除</a-button>
|
|
|
|
|
+ </a-popconfirm>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <span v-else>/</span>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </a-table>
|
|
|
|
|
+ </a-config-provider>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ <AddUser :open="open" @close="open = false" @confirm="getData" />
|
|
|
|
|
+</template>
|
|
|
|
|
+<script setup>
|
|
|
|
|
+import { ref, reactive, onMounted, nextTick } from "vue";
|
|
|
|
|
+
|
|
|
|
|
+import { useRouter, useRoute } from "vue-router";
|
|
|
|
|
+import { message } from "ant-design-vue";
|
|
|
|
|
+import { userList, delUser, resetUserPassword } from "@/api";
|
|
|
|
|
+import AddUser from "./addUser/index.vue";
|
|
|
|
|
+const route = useRoute();
|
|
|
|
|
+const routerTitle = ref(route.meta.title);
|
|
|
|
|
+const open = ref(false);
|
|
|
|
|
+const loading = ref(false);
|
|
|
|
|
+const onFinish = (values) => {
|
|
|
|
|
+ console.log("Success:", values);
|
|
|
|
|
+};
|
|
|
|
|
+const onFinishFailed = (errorInfo) => {
|
|
|
|
|
+ console.log("Failed:", errorInfo);
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+const deleteConfirm = async (id) => {
|
|
|
|
|
+ let res = await delUser(id);
|
|
|
|
|
+ if (res.code == 0) {
|
|
|
|
|
+ getData();
|
|
|
|
|
+ message.success("操作成功");
|
|
|
|
|
+ }
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+const handleTableChange = (pag, filters, sorter) => {
|
|
|
|
|
+ console.log("分页回调pag, filters, sorter", pag, filters, sorter);
|
|
|
|
|
+
|
|
|
|
|
+ pagination.value.current = pag.current;
|
|
|
|
|
+ pagination.value.pageSize = pag.pageSize;
|
|
|
|
|
+ getData();
|
|
|
|
|
+};
|
|
|
|
|
+const dataSource = ref([]);
|
|
|
|
|
+const columns = ref([
|
|
|
|
|
+ {
|
|
|
|
|
+ title: "用户名",
|
|
|
|
|
+ dataIndex: "username",
|
|
|
|
|
+ key: "username",
|
|
|
|
|
+ ellipsis: true,
|
|
|
|
|
+ width: "50%",
|
|
|
|
|
+ align: "center",
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ title: "角色",
|
|
|
|
|
+ dataIndex: "isAdmin",
|
|
|
|
|
+ key: "isAdmin",
|
|
|
|
|
+ ellipsis: true,
|
|
|
|
|
+ width: "50%",
|
|
|
|
|
+ align: "center",
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ title: "创建时间",
|
|
|
|
|
+ dataIndex: "createTime",
|
|
|
|
|
+ key: "createTime",
|
|
|
|
|
+ ellipsis: true,
|
|
|
|
|
+ width: "50%",
|
|
|
|
|
+ align: "center",
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ {
|
|
|
|
|
+ title: "操作",
|
|
|
|
|
+ key: "action",
|
|
|
|
|
+ ellipsis: true,
|
|
|
|
|
+ width: "50%",
|
|
|
|
|
+ align: "center",
|
|
|
|
|
+ },
|
|
|
|
|
+]);
|
|
|
|
|
+const showModal = () => {
|
|
|
|
|
+ open.value = true;
|
|
|
|
|
+};
|
|
|
|
|
+const resetPassword = (userId) => {
|
|
|
|
|
+ loading.value = true;
|
|
|
|
|
+ resetUserPassword(userId)
|
|
|
|
|
+ .then((res) => {
|
|
|
|
|
+ loading.value = false;
|
|
|
|
|
+ if (res.code == 0) {
|
|
|
|
|
+ message.success("密码已重置为123456");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ message.success(res.message);
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch((err) => {
|
|
|
|
|
+ loading.value = false;
|
|
|
|
|
+ });
|
|
|
|
|
+};
|
|
|
|
|
+const onSearch = () => {
|
|
|
|
|
+ console.log("搜索内容:", pagination.value.username);
|
|
|
|
|
+ getData();
|
|
|
|
|
+};
|
|
|
|
|
+const resetSearch = () => {
|
|
|
|
|
+ pagination.value.username = "";
|
|
|
|
|
+ console.log("重置搜索");
|
|
|
|
|
+ getData();
|
|
|
|
|
+};
|
|
|
|
|
+const pagination = ref({
|
|
|
|
|
+ total: 0,
|
|
|
|
|
+ current: 1,
|
|
|
|
|
+ pageSize: 10,
|
|
|
|
|
+ username: "",
|
|
|
|
|
+ hideOnSinglePage: true,
|
|
|
|
|
+});
|
|
|
|
|
+const getData = async () => {
|
|
|
|
|
+ loading.value = true;
|
|
|
|
|
+ let params = {
|
|
|
|
|
+ pageNo: pagination.value.current,
|
|
|
|
|
+ pageSize: pagination.value.pageSize,
|
|
|
|
|
+ username: pagination.value.username,
|
|
|
|
|
+ };
|
|
|
|
|
+ try {
|
|
|
|
|
+ let res = await userList(params);
|
|
|
|
|
+ if (res.code == 0) {
|
|
|
|
|
+ dataSource.value = res.data.pageData;
|
|
|
|
|
+ pagination.value.total = res.data.total;
|
|
|
|
|
+ pagination.value.current = res.data.pageNum;
|
|
|
|
|
+ pagination.value.pageSize = res.data.pageSize;
|
|
|
|
|
+ loading.value = false;
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (err) {
|
|
|
|
|
+ loading.value = false;
|
|
|
|
|
+ }
|
|
|
|
|
+};
|
|
|
|
|
+onMounted(() => {
|
|
|
|
|
+ getData();
|
|
|
|
|
+});
|
|
|
|
|
+</script>
|
|
|
|
|
+<style lang="scss" scoped>
|
|
|
|
|
+.collect-content {
|
|
|
|
|
+ color: #000;
|
|
|
|
|
+ width: 100%;
|
|
|
|
|
+ height: 100%;
|
|
|
|
|
+ .router-title {
|
|
|
|
|
+ height: 60px;
|
|
|
|
|
+ font-size: 18px;
|
|
|
|
|
+ font-weight: bold;
|
|
|
|
|
+ line-height: 60px;
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ justify-content: space-between;
|
|
|
|
|
+ padding: 0 20px;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+.controls-box {
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ justify-content: space-between;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ margin-bottom: 10px;
|
|
|
|
|
+ height: 60px;
|
|
|
|
|
+ padding: 0 20px;
|
|
|
|
|
+ .scarch-content {
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ justify-content: flex-start;
|
|
|
|
|
+ line-height: normal;
|
|
|
|
|
+ span {
|
|
|
|
|
+ margin-right: 8px;
|
|
|
|
|
+ }
|
|
|
|
|
+ .ant-input-search {
|
|
|
|
|
+ width: 200px;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+</style>
|