-
-
- 启用
- 禁用
-
+
-
角色id(原始id):
- 角色名称:
- 角色备注:
+ 角色id(原始id):
+ 角色名称:
+ 角色备注:
-
-
-
- 启用
- 禁用
-
+
-
- 用户id:
-
+
+
+
-
- 用户名:
-
+
+
-
- 地址:
-
+
+
-
- 手机号码:
-
+
+
-
- 邮箱:
-
+
+
-
- 年龄:
-
+
+
-
- 签名:
-
+
+
-
- 性别:
-
+
+
-
- 头像:
-
-
-
- 昵称:
-
-
-
-
-
- 个人描述:
-
-
-
- 用户是否启用:
-
-
-
-
-
- 用户是否过期:
-
-
-
- 密码是否过期:
-
-
-
-
-
- 是否展示:
-
-
-
- 用户是否被锁:
-
+
+
@@ -204,8 +151,6 @@ import {
import {message, Modal} from "ant-design-vue";
import requests from "@/public/request.js";
-const value1 = ref('');
-const value2 = ref('');
const AddDiaLog = ref(false);
const EditDiaLog = ref(false);
let dataSource = ref([]);
@@ -230,25 +175,25 @@ const sex = ref('男')
const updateData = reactive({
- id: '',
+ //id: '',
username: '',
address: '',
phone: '',
email: '',
age: '',
- signature: '',
+ //signature: '',
sex: '',
avatar: '',
- nickname: '',
+ //nickname: '',
description: '',
enabled: true,
- isExpired: false,
- passwordExpired: false,
+ //isExpired: false,
+ //passwordExpired: false,
recommend: false,
- isLocked: false,
- createdAt:'',
- updateAt:'',
- isDelete:false,
+ //isLocked: false,
+ // createdAt:'',
+ //updateAt:'',
+ //isDelete:false,
})
@@ -286,7 +231,7 @@ onMounted(() => {
function getAll() {
- requests.userAllCurrent(AllUser,token).then((res)=>{
+ requests.userAllCurrent(null,token).then((res)=>{
console.log(res)
// states.data = res.data.data
// console.log(res.data.data)
@@ -300,6 +245,25 @@ function getAll() {
}
+/*
+function getAll() {
+ requests.userAllCurrent(AllUser, token).then((res) => {
+ console.log(res);
+ loadingTable.value = false;
+
+ // 直接更新整个数组来确保响应性
+ states.data = res.data.data.map(item => item.user);
+ states.role = res.data.data.map(item => item.role.rid);
+
+ console.log("getAll:", states.data.length);
+ });
+}
+
+*/
+
+
+
+
/*新增用户*/
const addData = reactive({
@@ -333,8 +297,8 @@ function addOk () {
console.log(res.data)
if (res.data.code===200) {
message.success('新增成功')
- getAll();
AddDiaLog.value = false;
+ getAll();
}
else {
message.error('新增失败')
@@ -389,20 +353,22 @@ const showDeleteConfirm = (record) => {
/*编辑用户*/
-function showEditDiaLog(record, index){
+function showEditDiaLog(record){
EditDiaLog.value = true
- updateData.id = record.id
+ //updateData.id = record.id
updateData.username = record.username
updateData.address = record.address
updateData.phone = record.phone
updateData.email = record.email
updateData.age = record.age
- updateData.signature = record.signature
+ //updateData.signature = record.signature
updateData.sex = record.sex
updateData.avatar = record.avatar
- updateData.nickname = record.nickname
- updateData.description = record.description
- updateData.isDelete = record.isDelete
+ //updateData.nickname = record.nickname
+ //updateData.description = record.description
+ //updateData.isDelete = record.isDelete
+ updateData.recommend = record.recommend
+ updateData.enabled = record.enabled
roleSingle.value = states.role[index]
if (record.sex === 1) {
sex.value = '男'
@@ -412,12 +378,12 @@ function showEditDiaLog(record, index){
}
function editOk(){
loadingTable.value = true
- EditDiaLog.value = false
requests.userEdit(updateData,token).then((res)=>{
console.log("editResult:",res)
console.log("updateData:",updateData)
if (res.data.code === 200) {
getAll()
+ EditDiaLog.value = false
message.success('修改成功')
}
else {
@@ -436,22 +402,23 @@ function editCancel(){
/*查询用户*/
const searchData = reactive({
- username: '',
- phone: ''
+ id:'',
})
function searchUser(){
loadingTable.value = true
- if (searchData.username === '' && searchData.phone === '') {
+ if (searchData.id === '') {
getAll()
}
else {
- requests.userCurrent(searchData,token).then((res)=>{
+ requests.userAllCurrent(searchData, token).then((res)=>{
loadingTable.value = false
console.log("searchResult:",res)
if (res.data.code === 200) {
states.data = []
- states.data[0] = res.data.data.user
+ states.data = res.data.data.user
+ states.role = []
+ states.role = res.data.data.role
message.success('查询成功')
console.log(loadingTable.value)
}
@@ -468,6 +435,11 @@ const columns = [
dataIndex: 'id',
key: 'id',
},
+ {
+ title:'角色id',
+ dataIndex: 'rid',
+ key:'rid',
+ },
{
title: '用户名',
dataIndex: 'username',
@@ -516,7 +488,8 @@ const rowSelection = {
};
-/*async function fetchData() {
+/*
+async function fetchData() {
try {
const queryData = await requests.userAllCurrent(
{
@@ -554,7 +527,8 @@ console.log(dataSource)
// 组件挂载时调用 fetchData
onMounted(() => {
fetchData();
-});*/
+});
+*/
async function fetchData() {
@@ -575,6 +549,7 @@ async function fetchData() {
// 修正循环条件,确保我们不越界
for (let i = 0; i < dataSource.value.count; i++) {
const user = dataSource.value.users[i].user;
+ const role = dataSource.value.users[i].role;
if (user.updatedAt === null) {
user.updatedAt = "null";
}
@@ -589,6 +564,13 @@ async function fetchData() {
updatedAt: user.updatedAt,
id: user.id,
isDelete:user.isDelete,
+ rid:role.rid,
+ address:user.address,
+ sex:user.sex,
+ age:user.age,
+ email:user.email,
+ avatar:user.avatar,
+ recommend:user.recommend
});
}
console.log(data.value);
@@ -622,21 +604,13 @@ onMounted(() => {
}
.input {
- width: 35vw;
+ width: 10vw;
margin-top: 2vh;
margin-bottom: 1vh;
display: flex;
flex-direction: row;
}
-.first-input {
- margin-right: 1vw;
- margin-left: 1vw;
-}
-
-.second-input {
- margin-right: 1vw;
-}
.edit {
margin-top: 2vh;
@@ -645,7 +619,7 @@ onMounted(() => {
}
.query-button {
- margin-left: 4vw;
+ margin-left: 1vw;
margin-right: 1vw;
}