管理界面完善4.

This commit is contained in:
妖姐 2024-01-21 23:05:37 +08:00
parent ae6f59c846
commit 4885680d54
3 changed files with 411 additions and 58 deletions

View File

@ -53,20 +53,7 @@
</div> </div>
<div style="width: 87vw;display: flex;flex-direction: row;margin-top: 15px;height:47vh;background-color: white;margin-right: 20px"> <div style="width: 87vw;display: flex;flex-direction: row;margin-top: 15px;height:47vh;background-color: white;margin-right: 20px">
<!-- <DescriptionList title="标题" layout="vertical" style="width: 87vw; margin-top: 20px;font-size: 15px;margin-left: 10px">-->
<!-- <Description term="Macintosh" style="background-color: #f5f7f9;height: 39vh;" @click="changecolor">-->
<!-- 麦金塔电脑是苹果电脑其中一系列的个人电脑Macintosh 是由 Macintosh 计划发起人 Jeff Raskin杰夫·拉斯金根据他最爱的苹果品种 McIntosh 命名但为了避免与音频设备制造商麦金托什实验室McIntosh Laboratory)的名字有冲突他故意改变了字母的拼写-->
<!-- </Description>-->
<!-- <Description term="Lisa" style="background-color: #f5f7f9;height: 39vh;;">-->
<!-- Lisa 是一款具有划时代意义的电脑可以说没有 Lisa 就没有 Macintosh在Mac的开发早期很多系统软件都是在Lisa上设计的她具有16位CPU鼠标硬盘以及支持图形用户界面和多任务的操作系统并且随机捆绑了7个商用软件-->
<!-- </Description>-->
<!-- <Description term="Newton" style="background-color: #f5f7f9;height: 39vh;width:22vw">-->
<!-- Apple Newton牛顿是世界上第一款掌上电脑PDA由苹果电脑公司于1993年开始制造但是因为newton在市场上找不到其定位而需求量低而停止发展并于1997年停止了生产-->
<!-- </Description>-->
<!-- </DescriptionList>-->
<!-- <div style="width: 22vw ;height:47vh;background-color: beige;border-radius: 10px" >-->
<!--<span>在线状态预览</span>-->
<!-- </div>-->
</div> </div>
<div style="bottom:0;display: flex; flex-direction: column;height: 9vh;width: 87vw;background-color: #5885a8;margin-top: 6px;"> <div style="bottom:0;display: flex; flex-direction: column;height: 9vh;width: 87vw;background-color: #5885a8;margin-top: 6px;">
<div style="text-align: center;display: flex;flex-direction: row;justify-content: center;align-content: center ;padding: 5px"> <div style="text-align: center;display: flex;flex-direction: row;justify-content: center;align-content: center ;padding: 5px">
@ -75,7 +62,7 @@
<span style="padding-right: 5px">条款</span> <span style="padding-right: 5px">条款</span>
</div> </div>
<div style="text-align: center">Copyright © 2022 View Design All Rights Reserved'</div> <div style="text-align: center">Useright © 2024 View Design All Rights Reserved'</div>
</div> </div>
</div> </div>
@ -91,10 +78,8 @@
import { import {
AvatarList, AvatarList,
Card, Card,
Carousel, Circle,
CarouselItem, Circle, Description, Icon,
DescriptionList, GlobalFooter,
GridItem, Icon,
NumberInfo, NumberInfo,
Row, Row,
Space, Space,
@ -103,7 +88,7 @@ import {
import {computed, reactive, ref} from "vue"; import {computed, reactive, ref} from "vue";
const value = ref(0) // const value = ref(0)
const percent = ref(20) const percent = ref(20)
const color = computed(() => { const color = computed(() => {
let color = '#2db7f5'; let color = '#2db7f5';
@ -130,19 +115,6 @@ const data = reactive({
], ],
}) })
function add () {
if (percent.value >= 100) {
return false;
}
percent.value += 10;
}
function minus () {
if (percent.value <= 0) {
return false;
}
percent.value -= 10;
}

View File

@ -1,28 +1,409 @@
<template> <style scoped>
<AvatarList :list="list" /> .addinput{
</template> //display: flex;
<script> //flex-direction: column;
import {AvatarList, Card, Space} from "view-ui-plus"; //justify-content: center;
//align-content: center;
}
export default { .addinput>div>input{
components: {Space, Card, AvatarList}, /*width:300px ;*/
data () { /*height: 30px;*/
return { /*border-radius: 5px;*/
list: [ //margin: 0 auto;
//outline-color: #94beae;
}
</style>
<template>
<div style="width: 87vw;height:90vh;position: relative;margin: 0;padding: 0">
<div style="padding:20px 10px;">
<Space>
<span>用户名</span>
<Input v-model="searchData.username" prefix="ios-contact" placeholder="username" clearable style="width: 200px" />
<span>电话号</span>
<Input v-model="searchData.phone" placeholder="Enter phone" style="width: auto" />
<Button @click="searchUser" type="primary" shape="circle" icon="ios-search">查询</Button>
<Button type="primary" ghost @click="showAddDialog">新增</Button>
</Space>
</div>
<!-- 表格内容-->
<div style="width: 87vw; height: 78vh; margin: 0; padding: 0">
<Table border :loading="loadingTable" ref="selection" :columns="columns" :data="states.data" style="height: 72vh ;text-align: center;" :row-class-name="setRowClassName" >
<template #status="{ row, index }">
<Switch size="large" v-model="states.data[index].accountNoLocked" :before-change="handleBeforeSwitchChange">
<template #open>
<span>开启</span>
</template>
<template #close>
<span>关闭</span>
</template>
</Switch>
</template>
<template #action="{ row, index }">
<Button type="primary" size="small" style="margin-right: 5px" @click="showEditDialog(index, row)">详情</Button>
<Button type="error" size="small" @click="showDeleteDialog(index, row)">删除</Button>
</template>
</Table>
<div style="height: 6vh ;text-align: left;padding-top: 20px">
<Page :total="states.data.length" size="small" show-elevator show-sizer />
</div>
</div>
<!-- 对话框-->
<div>
<Modal
v-model="editDialog"
title="编辑"
@on-ok="editOk"
@on-cancel="editCancel">
<div style="">
<div style="margin-bottom: 10px">
<span>
用户名<Input v-model="updateData.username" placeholder="Enter something..." style="width: 180px" />
</span>
<span style="margin-left: 20px">
<label>电话</label><Input v-model="updateData.phone" placeholder="Enter something..." style="width: 180px" />
</span>
</div>
<div style="margin-bottom: 10px">
<span>
性别
<RadioGroup v-model="sex">
<Radio label="男"></Radio>
<Radio label="女"></Radio>
</RadioGroup>
</span>
<span style="margin-left: 98px">
角色
<Select v-model="roleSingle" style="width:200px">
<Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option>
</Select>
</span>
</div>
<div style="margin-bottom: 10px">邮箱<Input v-model="updateData.email" placeholder="Enter something..." style="width: 435px" /></div>
<div style="margin-bottom: 10px">地址<Input v-model="updateData.address" placeholder="Enter something..." style="width: 435px" /></div>
<div style="margin-bottom: 10px">简介<Input v-model="updateData.description" type="textarea" placeholder="Enter something..." style="width: 435px" /></div>
</div>
</Modal>
<Modal
v-model="deleteDialog"
title="删除"
@on-ok="deleteOk"
@on-cancel="deleteCancel">
<p>请问是否要删除xxx数据</p>
</Modal>
<Modal v-model="addDialog" title="新增用户信息" @on-ok="addOk" @on-cancel="addCancel" >
<div>
<div>用户名<Input v-model="addData.username" placeholder="Enter something..." style="width: 250px; margin-bottom: 10px" /></div>
<div style="margin-left: 15px">密码<Input v-model="addData.password" placeholder="Enter something..." style="width: 250px; margin-bottom: 10px" type="password"/></div>
<div style="margin-left: 15px">地址<Input v-model="addData.address" placeholder="Enter something..." style="width: 250px; margin-bottom: 10px" /></div>
<div style="margin-left: 15px">电话<Input v-model="addData.phone" placeholder="Enter something..." style="width: 250px; margin-bottom: 10px" /></div>
<div style="margin-left: 15px">邮箱<Input v-model="addData.email" placeholder="Enter something..." style="width: 250px; margin-bottom: 10px" /></div>
<div style="margin-left: 15px">性别 <RadioGroup v-model="sex" style="margin-bottom: 10px">
<Radio label='男'></Radio>
<Radio label='女'></Radio>
</RadioGroup></div>
<div style="margin-left: 15px">年龄<Input v-model="addData.age" placeholder="Enter something..." style="width: 250px" type="number" /></div>
</div>
</Modal>
</div>
</div>
</template>
<script setup>
import {Page, Radio, RadioGroup, Space, Switch} from "view-ui-plus";
import requests from "../../public/request.js"
import {reactive, ref} from "vue";
import message from "view-ui-plus/src/components/message/index.js";
import {onMounted, onBeforeUpdate} from "vue";
import modal from "view-ui-plus/src/components/modal/index.js";
const currentPage = ref(1) //
const pageSize = ref(10) //
const addDialog = ref(false)
const deleteDialog = ref(false)
const editDialog = ref(false)
const token = window.localStorage.getItem('token')
const columns = reactive( [
{ {
src: 'https://dev-file.iviewui.com/BbnuuEiM0QXNPHVCvb3E2AFrawIjCkqW/avatar', type: "selection",
tip: '史蒂夫·乔布斯' width: 60,
align: "center"
}, },
{ {
src: 'https://dev-file.iviewui.com/zhj85zgAfEjChCNIKT1LQENUIOyOYCaX/avatar', title: "角色",
tip: '斯蒂夫·沃兹尼亚克' key: "roleName",
align: "center"
}, },
{ {
src: 'https://dev-file.iviewui.com/TkH54UozsINlex15TAMI00GElsfsKSiC/avatar', title: "解释",
tip: '乔纳森·伊夫' key: "displayName",
width: 125,
align: "center"
},
{
title: "电话",
key: "phone",
width: 125,
align: "center"
},
{
title: "邮箱",
key: "email",
align: "center"
},
{
title: "状态",
slot: "status",
width: 80,
align: "center",
},
{
title: "操作",
slot: "action",
width: 150,
align: "center"
} }
] ])
const states = reactive({
data:[]
})
const loadingTable = ref(true)
const sex = ref('男')
const roleSingle = ref(1)
const updateData = reactive({
id: 0,
username: '',
address: '',
phone: '',
email: '',
age: '',
signature: '',
sex: '',
avatar: '',
nickname: '',
description: '',
enabled: true,
isExpired: false,
passwordExpired: false,
recommend: false,
isLocked: false
})
const cityList= reactive([
{
value: 1,
label: '管理员'
},
{
value: 2,
label: '老师'
},
{
value: 3,
label: '学生'
} }
])
const userLock = reactive({
id: -1,
isLock: 1
})
/**
* 配置代码
*/
message.config({
background: true
})
function setRowClassName(row, index) {
return 'custom-row';
}
onMounted(() => {
getAll()
})
/**
* 方法函数
*/
function getAll() {
requests.roleGet(null,token).then((res)=>{
console.log(res.data.data)
states.data = res.data.data
// states.data = res.data.data
// console.log(res.data.data)
loadingTable.value = false
// for (let i = 0; i < res.data.data.length; i++) {
// states.data[i] = res.data.data[i].user
// }
// console.log("getAll:",states.data)
})
}
function handleBeforeSwitchChange(index, row) {
return new Promise((resolve) => {
this.$Modal.confirm({
title: '切换确认',
content: '您确认要切换开关状态吗?',
onOk: () => {
resolve();
message.success('切换成功')
}
})
})
}
function handlePageChange(newPage) {
this.currentPage = newPage; //
}
const addData = reactive({
username: '',
password: '',
address: '',
phone: '',
email: '',
sex: 1,
age: ''
})
function showAddDialog(){
addDialog.value = true
}
function addOk () {
if (sex.value === '男') {
addData.sex = 1
}else {
addData.sex = 0
}
requests.userAdd(addData, token).then((res)=>{
if (res.data.code===200) {
message.success('新增成功')
getAll()
}
else {
message.error('新增失败')
}
})
}
function addCancel () {
message.info('取消新增')
}
const deleteId = ref(0)
function showDeleteDialog(index, row){
deleteDialog.value = true
deleteId.value = row.id
}
function deleteOk(){
deleteDialog.value = false;
console.log(deleteId.value)
requests.userDelete(deleteId.value, token).then((res)=>{
console.log("deleteResult:",res)
if (res.data.code === 200) {
message.success('删除成功')
}else {
message.error('删除失败')
}
})
}
function deleteCancel(){
deleteDialog.value = false;
message.info('取消删除')
}
function showEditDialog(index, row){
editDialog.value = true
updateData.id = row.id
updateData.username = row.username
updateData.address = row.address
updateData.phone = row.phone
updateData.email = row.email
updateData.age = row.age
updateData.signature = row.signature
updateData.sex = row.sex
updateData.avatar = row.avatar
updateData.nickname = row.nickname
updateData.description = row.description
if (row.sex === 1) {
sex.value = '男'
}else {
sex.value = '女'
} }
} }
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()
message.success('修改成功')
}
else {
loadingTable.value = false
message.error('修改失败')
}
})
}
function editCancel(){
editDialog.value = false;
}
const searchData = reactive({
username: '',
phone: ''
})
function searchUser(){
loadingTable.value = true
if (searchData.username === '' && searchData.phone === '') {
getAll()
}
else {
requests.userCurrent(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
message.success('查询成功')
console.log(loadingTable.value)
}
else {
message.error(res.data.message)
}
})
}
}
</script> </script>

View File

@ -16,7 +16,7 @@
} }
</style> </style>
<template> <template>
<div style="width: 80vw;height:90vh;position: relative;margin: 0;padding: 0"> <div style="width: 87vw;height:90vh;position: relative;margin: 0;padding: 0">
<div style="padding:20px 10px;"> <div style="padding:20px 10px;">
<Space> <Space>
<span>用户名</span> <span>用户名</span>
@ -29,7 +29,7 @@
</Space> </Space>
</div> </div>
<!-- 表格内容--> <!-- 表格内容-->
<div style="width: 80vw; height: 78vh; margin: 0; padding: 0"> <div style="width: 87vw; height: 78vh; margin: 0; padding: 0">
<Table border :loading="loadingTable" ref="selection" :columns="columns" :data="states.data" style="height: 72vh ;text-align: center;" :row-class-name="setRowClassName" > <Table border :loading="loadingTable" ref="selection" :columns="columns" :data="states.data" style="height: 72vh ;text-align: center;" :row-class-name="setRowClassName" >