Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/components/register.vue
This commit is contained in:
GUjiYN 2024-01-23 11:32:54 +08:00
commit fee192014d
3 changed files with 471 additions and 125 deletions

View File

@ -26,7 +26,7 @@
<path d="M7 9a4.5 4.5 0 1 0 0-9 4.5 4.5 0 0 0 0 9Zm2 1H5a5.006 5.006 0 0 0-5 5v2a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-2a5.006 5.006 0 0 0-5-5Z"/>
</svg>
</span>
<input type="text" class="rounded-none rounded-e-lg bg-gray-50 border border-gray-300 text-gray-900 focus:ring-blue-500 focus:border-blue-500 block flex-1 min-w-0 w-full text-sm p-2.5">
<input v-model="data.username" type="text" id="website-admin" class="rounded-none rounded-e-lg bg-gray-50 border border-gray-300 text-gray-900 focus:ring-blue-500 focus:border-blue-500 block flex-1 min-w-0 w-full text-sm p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500">
</div>
</div>
<div>
@ -37,7 +37,7 @@
<path d="M14 7h-1.5V4.5a4.5 4.5 0 1 0-9 0V7H2a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2Zm-5 8a1 1 0 1 1-2 0v-3a1 1 0 1 1 2 0v3Zm1.5-8h-5V4.5a2.5 2.5 0 1 1 5 0V7Z"/>
</svg>
</span>
<input type="password" class="rounded-none rounded-e-lg bg-gray-50 border border-gray-300 text-gray-900 focus:ring-blue-500 focus:border-blue-500 block flex-1 min-w-0 w-full text-sm p-2.5">
<input v-model="data.password" type="password" id="website-admin" class="rounded-none rounded-e-lg bg-gray-50 border border-gray-300 text-gray-900 focus:ring-blue-500 focus:border-blue-500 block flex-1 min-w-0 w-full text-sm p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500">
</div>
</div>
<div>
@ -48,7 +48,7 @@
<path d="m19.707 9.293-2-2-7-7a1 1 0 0 0-1.414 0l-7 7-2 2a1 1 0 0 0 1.414 1.414L2 10.414V18a2 2 0 0 0 2 2h3a1 1 0 0 0 1-1v-4a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v4a1 1 0 0 0 1 1h3a2 2 0 0 0 2-2v-7.586l.293.293a1 1 0 0 0 1.414-1.414Z"/>
</svg>
</span>
<input type="text" class="rounded-none rounded-e-lg bg-gray-50 border border-gray-300 text-gray-900 focus:ring-blue-500 focus:border-blue-500 block flex-1 min-w-0 w-full text-sm p-2.5">
<input v-model="data.address" type="text" id="website-admin" class="rounded-none rounded-e-lg bg-gray-50 border border-gray-300 text-gray-900 focus:ring-blue-500 focus:border-blue-500 block flex-1 min-w-0 w-full text-sm p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500">
</div>
</div>
<div>
@ -59,7 +59,7 @@
<path d="M18 13.446a3.02 3.02 0 0 0-.946-1.985l-1.4-1.4a3.054 3.054 0 0 0-4.218 0l-.7.7a.983.983 0 0 1-1.39 0l-2.1-2.1a.983.983 0 0 1 0-1.389l.7-.7a2.98 2.98 0 0 0 0-4.217l-1.4-1.4a2.824 2.824 0 0 0-4.218 0c-3.619 3.619-3 8.229 1.752 12.979C6.785 16.639 9.45 18 11.912 18a7.175 7.175 0 0 0 5.139-2.325A2.9 2.9 0 0 0 18 13.446Z"/>
</svg>
</span>
<input type="tel" class="rounded-none rounded-e-lg bg-gray-50 border border-gray-300 text-gray-900 focus:ring-blue-500 focus:border-blue-500 block flex-1 min-w-0 w-full text-sm p-2.5">
<input v-model="data.phone" type="tel" id="website-admin" class="rounded-none rounded-e-lg bg-gray-50 border border-gray-300 text-gray-900 focus:ring-blue-500 focus:border-blue-500 block flex-1 min-w-0 w-full text-sm p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500">
</div>
</div>
<div>
@ -71,7 +71,7 @@
<path d="M11.241 9.817c-.36.275-.801.425-1.255.427-.428 0-.845-.138-1.187-.395L0 2.6V14a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V2.5l-8.759 7.317Z"/>
</svg>
</span>
<input type="email" class="rounded-none rounded-e-lg bg-gray-50 border border-gray-300 text-gray-900 focus:ring-blue-500 focus:border-blue-500 block flex-1 min-w-0 w-full text-sm p-2.5">
<input v-model="data.email" type="email" id="website-admin" class="rounded-none rounded-e-lg bg-gray-50 border border-gray-300 text-gray-900 focus:ring-blue-500 focus:border-blue-500 block flex-1 min-w-0 w-full text-sm p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500">
</div>
</div>
<div>
@ -111,35 +111,32 @@
</template>
<script setup>
import axios from 'axios';
import getCurrentTimestamp from '../public/methods.js';
import Icp from "@/components/MainPage/Icp.vue";
import requests from '../public/request.js'
const data = {
username: '',
password: '',
address: '',
sex: '',
age: '',
unit: '',
filed: '',
hometown:''
email: '',
phone: ''
}
function registerUser() {
axios({
url: 'api/user/register',
method: 'post',
data: data,
headers: {
'content-type': 'application/json;charset=utf-8',
'Timestamp':getCurrentTimestamp()
}
}).then((res) => {
requests.register(data).then((res) => {
if (res.data.code === 200) {
//+
console.log('注册成功')
} else {
//
console.log('注册失败')
}
console.log(res)
})

View File

@ -1,3 +1,411 @@
<style scoped>
.addinput{
//display: flex;
//flex-direction: column;
//justify-content: center;
//align-content: center;
}
.addinput>div>input{
/*width:300px ;*/
/*height: 30px;*/
/*border-radius: 5px;*/
//margin: 0 auto;
//outline-color: #94beae;
}
</style>
<template>
轮播图管理
</template>
<div style="width: 87vw;height:90vh;position: relative;margin: 0;padding: 0">
<div style="padding:20px 10px;">
<Space>
<span>轮播图id</span>
<Input v-model="searchData.phone" placeholder="Enter Id" 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 AllUser = reactive({
page:1,
limit: 10,
search: null,
role: null
})
const columns = reactive( [
{
type: "selection",
width: 60,
align: "center"
},
{
title: "图片",
key: "image",
align: "center"
},
{
title: "标题",
key: "title",
width: 150,
align: "center"
},
{
title: "图片地址",
key: "imageAddress",
width: 150,
align: "center"
},
{
title: "描述",
key: "description",
align: "center"
},
{
title: "状态",
slot: "isActive",
width: 100,
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.infoGetHeaderImage(null,token).then((res)=>{
console.log(res)
// 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>

View File

@ -19,10 +19,10 @@
<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" />
<span>角色id</span>
<Input v-model="searchData.username" placeholder="roleid" 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>
@ -52,7 +52,7 @@
</Table>
<div style="height: 6vh ;text-align: left;padding-top: 20px">
<Page :total="states.data.length" size="small" show-elevator show-sizer />
<Page :total="30" size="small" show-elevator show-sizer />
</div>
@ -65,37 +65,27 @@
title="编辑"
@on-ok="editOk"
@on-cancel="editCancel">
<div style="">
<div style="margin-bottom: 10px">
<div style="">
<div style="margin-bottom: 10px;">
<span>
用户名<Input v-model="updateData.username" placeholder="Enter something..." style="width: 180px" />
角色名称<Input v-model="updateData.name" placeholder="Enter something..." style="width: 250px;padding: 10px" />
</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>
<br>
<span style="margin-left: 20px">
<label>解释</label><Input v-model="updateData.displayName" placeholder="Enter something..." style="width: 250px;margin-left: 8px;padding: 10px" />
</span>
<br>
</div>
<div style="margin-bottom: 10px">
<span style="margin-left: 18px">
状态
<RadioGroup v-model="lock">
<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>
</div>
</div>
</Modal>
@ -104,22 +94,13 @@
title="删除"
@on-ok="deleteOk"
@on-cancel="deleteCancel">
<p>请问是否要删除xxx数据</p>
<p>请问是否要删除数据</p>
</Modal>
<Modal v-model="addDialog" title="新增用户信息" @on-ok="addOk" @on-cancel="addCancel" >
<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>角色名称<Input v-model="addData.name" placeholder="Enter something..." style="width: 250px; margin-bottom: 10px" /></div>
<div style="margin-left: 27px">解释<Input v-model="addData.displayName" placeholder="Enter something..." style="width: 250px; margin-bottom: 10px;margin-left: 3px" /></div>
</div>
@ -196,40 +177,15 @@ const states = reactive({
data:[]
})
const loadingTable = ref(true)
const sex = ref('男')
const lock = 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
name: '',
displayName: '',
})
const cityList= reactive([
{
value: 1,
label: '管理员'
},
{
value: 2,
label: '老师'
},
{
value: 3,
label: '学生'
}
])
const userLock = reactive({
id: -1,
isLock: 1
@ -256,7 +212,7 @@ onMounted(() => {
function getAll() {
requests.roleGet(null,token).then((res)=>{
console.log(res.data.data)
console.log(res)
states.data = res.data.data
// states.data = res.data.data
// console.log(res.data.data)
@ -286,25 +242,22 @@ function handlePageChange(newPage) {
}
const addData = reactive({
username: '',
password: '',
address: '',
phone: '',
email: '',
sex: 1,
age: ''
// id:'',
// roleName:'',
name:'',
displayName:'',
// createdAt:'',
// updatedAt:'',
})
function showAddDialog(){
addDialog.value = true
}
function addOk () {
if (sex.value === '男') {
addData.sex = 1
}else {
addData.sex = 0
}
requests.userAdd(addData, token).then((res)=>{
requests.roleAdd(addData, token).then((res)=>{
console.log(res.data)
if (res.data.code===200) {
message.success('新增成功')
getAll()
@ -328,7 +281,7 @@ function showDeleteDialog(index, row){
function deleteOk(){
deleteDialog.value = false;
console.log(deleteId.value)
requests.userDelete(deleteId.value, token).then((res)=>{
requests.roleDelete(deleteId.value, token).then((res)=>{
console.log("deleteResult:",res)
if (res.data.code === 200) {
message.success('删除成功')
@ -346,26 +299,14 @@ function deleteCancel(){
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 = '女'
}
updateData.name = row.roleName
updateData.displayName = row.displayName
}
function editOk(){
loadingTable.value = true
editDialog.value = false;
requests.userEdit(updateData,token).then((res)=>{
requests.roleEdit(updateData,token).then((res)=>{
console.log("editResult:",res)
console.log("updateData:",updateData)
if (res.data.code === 200) {