修复bug

This commit is contained in:
yannqing 2024-01-24 18:01:34 +08:00
parent 7b57e4cb68
commit d2bd7a8e21
3 changed files with 36 additions and 34 deletions

View File

@ -144,7 +144,7 @@ function registerUser() {
if (res.data.code === 200) {
//+
console.log('注册成功')
message.success
message.success('注册成功')
router.push("/login")
} else {
//

View File

@ -28,18 +28,16 @@
</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" >
<Table height="500" border :loading="loadingTable" ref="selection" :columns="columns" :data="states.data" style="height: 72vh ;text-align: center;" :row-class-name="setRowClassName" >
<template #isActive="{ 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>
<TagSelect v-model="tags.data" hide-check-all v-if="row.isActive === true" style="margin-left: 10px">
<TagSelectOption name="enabled" color="green">可用</TagSelectOption>
</TagSelect>
<TagSelect v-model="tags.data" hide-check-all v-if="row.isActive === false" style="margin-left: 10px">
<TagSelectOption name="disabled" color="red">禁用</TagSelectOption>
</TagSelect>
</template>
<template #action="{ row, index }">
@ -141,13 +139,16 @@
</template>
<script setup>
import {Page, Radio, RadioGroup, Space, Switch} from "view-ui-plus";
import {Page, Radio, RadioGroup, Space, Switch, TagSelect, TagSelectOption} 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 tags = reactive({
data: ['enabled','disabled']
})
const currentPage = ref(1) //
const pageSize = ref(10) //
const addDialog = ref(false)
@ -180,7 +181,7 @@ const columns = reactive( [
},
{
title: "标题",
width: 200,
width: 190,
key: "title",
align: "center"
},
@ -204,7 +205,7 @@ const columns = reactive( [
{
title: "状态",
slot: "isActive",
width: 100,
width: 120,
align: "center",
},
{

View File

@ -31,19 +31,14 @@
<!-- 表格内容-->
<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>
<TagSelect v-model="tags.data" hide-check-all v-if="row.enabled === true" style="margin-left: 10px">
<TagSelectOption name="enabled" color="green">可用</TagSelectOption>
</TagSelect>
<TagSelect v-model="tags.data" hide-check-all v-if="row.enabled === false" style="margin-left: 10px">
<TagSelectOption name="disabled" color="red">禁用</TagSelectOption>
</TagSelect>
</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>
@ -55,7 +50,6 @@
<Page :total="states.data.length" size="small" show-elevator show-sizer />
</div>
</div>
<!-- 对话框-->
@ -85,7 +79,7 @@
<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>
<Option v-for="item in roleList" :value="item.value" :key="item.value">{{ item.label }}</Option>
</Select>
</span>
</div>
@ -130,13 +124,16 @@
</template>
<script setup>
import {Page, Radio, RadioGroup, Space, Switch} from "view-ui-plus";
import {Page, Radio, RadioGroup, Space, TagSelect, TagSelectOption} 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 {onMounted} from "vue";
import modal from "view-ui-plus/src/components/modal/index.js";
const tags = reactive({
data: ['enabled','disabled']
})
const currentPage = ref(1) //
const pageSize = ref(10) //
const addDialog = ref(false)
@ -180,7 +177,7 @@ const columns = reactive( [
{
title: "状态",
slot: "status",
width: 100,
width: 120,
align: "center",
},
{
@ -191,11 +188,12 @@ const columns = reactive( [
}
])
const states = reactive({
data:[]
data:[],
role:[],
})
const loadingTable = ref(true)
const sex = ref('男')
const roleSingle = ref(1)
const updateData = reactive({
id: 0,
username: '',
@ -214,7 +212,7 @@ const updateData = reactive({
recommend: false,
isLocked: false
})
const cityList= reactive([
const roleList= reactive([
{
value: 1,
label: '管理员'
@ -260,8 +258,9 @@ function getAll() {
loadingTable.value = false
for (let i = 0; i < res.data.data.length; i++) {
states.data[i] = res.data.data[i].user
states.role[i] = res.data.data[i].role.rid
}
console.log("getAll:",states.data)
console.log("getAll:",states.data.length)
})
}
@ -340,6 +339,7 @@ function deleteCancel(){
message.info('取消删除')
}
const roleSingle = ref(1)
function showEditDialog(index, row){
editDialog.value = true
updateData.id = row.id
@ -353,6 +353,7 @@ function showEditDialog(index, row){
updateData.avatar = row.avatar
updateData.nickname = row.nickname
updateData.description = row.description
roleSingle.value = states.role[index]
if (row.sex === 1) {
sex.value = '男'
}else {
@ -361,7 +362,7 @@ function showEditDialog(index, row){
}
function editOk(){
loadingTable.value = true
editDialog.value = false;
editDialog.value = false
requests.userEdit(updateData,token).then((res)=>{
console.log("editResult:",res)
console.log("updateData:",updateData)