From 401138ffbb848e5fb826003230981dda97b0d559 Mon Sep 17 00:00:00 2001 From: GUjiYN <2946459904@qq.com> Date: Fri, 1 Mar 2024 16:00:33 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=92=E8=89=B2=E9=A1=B5=E9=9D=A2=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=EF=BC=8C=E4=BF=AE=E6=94=B9=E5=AF=B9=E8=AF=9D=E6=A1=86?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MainPage/Index.vue | 78 +------------ src/Manager/components/Role.vue | 56 ++++----- src/Manager/components/User.vue | 198 ++++++++++++++------------------ 3 files changed, 112 insertions(+), 220 deletions(-) diff --git a/src/MainPage/Index.vue b/src/MainPage/Index.vue index 46a9d72..96d5394 100644 --- a/src/MainPage/Index.vue +++ b/src/MainPage/Index.vue @@ -1,4 +1,4 @@ - - - - - - - diff --git a/src/Manager/components/Role.vue b/src/Manager/components/Role.vue index e6e29ab..f684ce1 100644 --- a/src/Manager/components/Role.vue +++ b/src/Manager/components/Role.vue @@ -2,16 +2,7 @@
- - - 启用 - 禁用 - +
查询 @@ -44,9 +35,9 @@ >
-
角色id(原始id):
-
角色名称:
-
角色备注:
+
角色id(原始id):
+
角色名称:
+
角色备注:
@@ -73,7 +64,7 @@ @@ -98,7 +89,6 @@ import {usePagination} from 'vue-request'; import requests from '../../public/request.js'; import axios from 'axios'; -const value1 = ref(''); const roleid = ref(''); const AddDiaLog = ref(false); const DeleteDiaLog = ref(false); @@ -108,7 +98,7 @@ const states = reactive({ data:[] }); const updateData = reactive({ - id: 0, + id: '', name: '', displayName: '', @@ -168,6 +158,7 @@ function addOk () { console.log(res.data) if (res.data.code===200) { message.success('新增成功') + AddDiaLog.value = false; getAll() } else { @@ -217,13 +208,22 @@ const showDeleteConfirm = (record) => { /*修改角色*/ -function showEditDiaLog(record){ +/*function showEditDiaLog(record){ editDiaLog.value = true updateData.id = record.id updateData.name = record.role_name updateData.displayName = record.displayName -} +}*/ + +const showEditDiaLog = (record) => { + console.log("record:",record) + editDiaLog.value = true + updateData.id = record.id + updateData.name = record.roleName + updateData.displayName = record.displayName +}; + function editOk(){ loadingTable.value = true @@ -246,27 +246,27 @@ function editOk(){ function editCancel(){ editDiaLog.value = false; + message.info('取消修改') } /*查询用户*/ const searchData = reactive({ - username: '', - phone: '' + id:'', }) function searchRole(){ loadingTable.value = true - if (searchData.username === '' && searchData.phone === '') { + if (searchData.id === '') { getAll() } else { - requests.userCurrent(searchData,token).then((res)=>{ + requests.roleGet(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 message.success('查询成功') console.log(loadingTable.value) } @@ -372,19 +372,13 @@ const handleTableChange = (pag, filters, sorter) => { } .input { - width: 20vw; + width: 10vw; margin-top: 2vh; margin-bottom: 1vh; display: flex; flex-direction: row; } -.first-input { - margin-right: 1vw; - margin-left: 1vw; -} - - .edit { margin-top: 2vh; width: 20vw; @@ -392,7 +386,7 @@ const handleTableChange = (pag, filters, sorter) => { } .query-button { - margin-left: 4vw; + margin-left: 1vw; margin-right: 1vw; } diff --git a/src/Manager/components/User.vue b/src/Manager/components/User.vue index f947947..b099ec0 100644 --- a/src/Manager/components/User.vue +++ b/src/Manager/components/User.vue @@ -2,16 +2,7 @@
- - - - 启用 - 禁用 - +
查询 @@ -61,7 +52,6 @@ 年龄: - @@ -69,91 +59,48 @@ -
- - 用户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; }