修复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) { if (res.data.code === 200) {
//+ //+
console.log('注册成功') console.log('注册成功')
message.success message.success('注册成功')
router.push("/login") router.push("/login")
} else { } else {
// //

View File

@ -28,18 +28,16 @@
</div> </div>
<!-- 表格内容--> <!-- 表格内容-->
<div style="width: 87vw; 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 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 }"> <template #isActive="{ row, index }">
<Switch size="large" v-model="states.data[index].accountNoLocked" :before-change="handleBeforeSwitchChange"> <TagSelect v-model="tags.data" hide-check-all v-if="row.isActive === true" style="margin-left: 10px">
<template #open> <TagSelectOption name="enabled" color="green">可用</TagSelectOption>
<span>开启</span> </TagSelect>
</template> <TagSelect v-model="tags.data" hide-check-all v-if="row.isActive === false" style="margin-left: 10px">
<template #close> <TagSelectOption name="disabled" color="red">禁用</TagSelectOption>
<span>关闭</span> </TagSelect>
</template>
</Switch>
</template> </template>
<template #action="{ row, index }"> <template #action="{ row, index }">
@ -141,13 +139,16 @@
</template> </template>
<script setup> <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 requests from "../../public/request.js"
import {reactive, ref} from "vue"; import {reactive, ref} from "vue";
import message from "view-ui-plus/src/components/message/index.js"; import message from "view-ui-plus/src/components/message/index.js";
import {onMounted, onBeforeUpdate} from "vue"; import {onMounted, onBeforeUpdate} from "vue";
import modal from "view-ui-plus/src/components/modal/index.js"; import modal from "view-ui-plus/src/components/modal/index.js";
const tags = reactive({
data: ['enabled','disabled']
})
const currentPage = ref(1) // const currentPage = ref(1) //
const pageSize = ref(10) // const pageSize = ref(10) //
const addDialog = ref(false) const addDialog = ref(false)
@ -180,7 +181,7 @@ const columns = reactive( [
}, },
{ {
title: "标题", title: "标题",
width: 200, width: 190,
key: "title", key: "title",
align: "center" align: "center"
}, },
@ -204,7 +205,7 @@ const columns = reactive( [
{ {
title: "状态", title: "状态",
slot: "isActive", slot: "isActive",
width: 100, width: 120,
align: "center", align: "center",
}, },
{ {

View File

@ -31,19 +31,14 @@
<!-- 表格内容--> <!-- 表格内容-->
<div style="width: 87vw; 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" >
<template #status="{ row, index }"> <template #status="{ row, index }">
<Switch size="large" v-model="states.data[index].accountNoLocked" :before-change="handleBeforeSwitchChange"> <TagSelect v-model="tags.data" hide-check-all v-if="row.enabled === true" style="margin-left: 10px">
<template #open> <TagSelectOption name="enabled" color="green">可用</TagSelectOption>
<span>开启</span> </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>
<template #close>
<span>关闭</span>
</template>
</Switch>
</template>
<template #action="{ row, index }"> <template #action="{ row, index }">
<Button type="primary" size="small" style="margin-right: 5px" @click="showEditDialog(index, row)">详情</Button> <Button type="primary" size="small" style="margin-right: 5px" @click="showEditDialog(index, row)">详情</Button>
<Button type="error" size="small" @click="showDeleteDialog(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 /> <Page :total="states.data.length" size="small" show-elevator show-sizer />
</div> </div>
</div> </div>
<!-- 对话框--> <!-- 对话框-->
@ -85,7 +79,7 @@
<span style="margin-left: 98px"> <span style="margin-left: 98px">
角色 角色
<Select v-model="roleSingle" style="width:200px"> <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> </Select>
</span> </span>
</div> </div>
@ -130,13 +124,16 @@
</template> </template>
<script setup> <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 requests from "../../public/request.js"
import {reactive, ref} from "vue"; import {reactive, ref} from "vue";
import message from "view-ui-plus/src/components/message/index.js"; 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"; import modal from "view-ui-plus/src/components/modal/index.js";
const tags = reactive({
data: ['enabled','disabled']
})
const currentPage = ref(1) // const currentPage = ref(1) //
const pageSize = ref(10) // const pageSize = ref(10) //
const addDialog = ref(false) const addDialog = ref(false)
@ -180,7 +177,7 @@ const columns = reactive( [
{ {
title: "状态", title: "状态",
slot: "status", slot: "status",
width: 100, width: 120,
align: "center", align: "center",
}, },
{ {
@ -191,11 +188,12 @@ const columns = reactive( [
} }
]) ])
const states = reactive({ const states = reactive({
data:[] data:[],
role:[],
}) })
const loadingTable = ref(true) const loadingTable = ref(true)
const sex = ref('男') const sex = ref('男')
const roleSingle = ref(1)
const updateData = reactive({ const updateData = reactive({
id: 0, id: 0,
username: '', username: '',
@ -214,7 +212,7 @@ const updateData = reactive({
recommend: false, recommend: false,
isLocked: false isLocked: false
}) })
const cityList= reactive([ const roleList= reactive([
{ {
value: 1, value: 1,
label: '管理员' label: '管理员'
@ -260,8 +258,9 @@ function getAll() {
loadingTable.value = false loadingTable.value = false
for (let i = 0; i < res.data.data.length; i++) { for (let i = 0; i < res.data.data.length; i++) {
states.data[i] = res.data.data[i].user 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('取消删除') message.info('取消删除')
} }
const roleSingle = ref(1)
function showEditDialog(index, row){ function showEditDialog(index, row){
editDialog.value = true editDialog.value = true
updateData.id = row.id updateData.id = row.id
@ -353,6 +353,7 @@ function showEditDialog(index, row){
updateData.avatar = row.avatar updateData.avatar = row.avatar
updateData.nickname = row.nickname updateData.nickname = row.nickname
updateData.description = row.description updateData.description = row.description
roleSingle.value = states.role[index]
if (row.sex === 1) { if (row.sex === 1) {
sex.value = '男' sex.value = '男'
}else { }else {
@ -361,7 +362,7 @@ function showEditDialog(index, row){
} }
function editOk(){ function editOk(){
loadingTable.value = true loadingTable.value = true
editDialog.value = false; editDialog.value = false
requests.userEdit(updateData,token).then((res)=>{ requests.userEdit(updateData,token).then((res)=>{
console.log("editResult:",res) console.log("editResult:",res)
console.log("updateData:",updateData) console.log("updateData:",updateData)