This commit is contained in:
lsd不是沙雕 2024-07-05 16:31:08 +08:00
parent c996fe40a2
commit aafee5564b
15 changed files with 643 additions and 400 deletions

BIN
public/background.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

17
src/assets/global.css Normal file
View File

@ -0,0 +1,17 @@
body {
background-image: url('/public/background.jpg');
background-size: contain;
background-repeat: no-repeat;
background-position: center;
background-attachment: fixed;
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
@media (min-width: 768px) {
body {
background-size: cover;
}
}

View File

@ -8,6 +8,7 @@
import ElementPlus from 'element-plus' import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css' import 'element-plus/dist/index.css'
import App from './App.vue' import App from './App.vue'
import './assets/global.css'
const app = createApp(App) const app = createApp(App)
app.use(ElementPlus) app.use(ElementPlus)

View File

@ -13,8 +13,6 @@ import UserManagement from "../view/UserManagement.vue";
import TenantManagement from "../view/TenantManagement.vue"; import TenantManagement from "../view/TenantManagement.vue";
import AddUser from "../view/AddUser.vue"; import AddUser from "../view/AddUser.vue";
import AddTenant from "../view/AddTenant.vue"; import AddTenant from "../view/AddTenant.vue";
import EditTenant from "../view/EditTenant.vue";
import EditUser from "../view/EditUser.vue";
import test from "../test.vue"; import test from "../test.vue";
const routes = [ const routes = [
{ path: '/', component: Home}, { path: '/', component: Home},
@ -36,25 +34,11 @@ const routes = [
name: 'AddTenant', name: 'AddTenant',
component: AddTenant component: AddTenant
}, },
{ path: '/editTenant',
name: 'EditTenant',
component: EditTenant
},
{ path: '/editUser',
name: 'EditUser',
component: EditUser
},
{ path: '/test', { path: '/test',
name: 'Test', name: 'Test',
component: test component: test
}, },
{ path: '/userManagement', name: 'UM', component:UserManagement } { path: '/userManagement', name: 'UM', component:UserManagement }
// ...authenticationRoutes,
// ...courseManagementRoutes,
// ...meetingManagementRoutes,
// ...newsManagementRoutes,
// ...organizationManagementRoutes,
// ...userManagementRoutes,
] ]
const router = createRouter({ const router = createRouter({

View File

@ -28,7 +28,6 @@
alert("登录失败"); alert("登录失败");
} }
// 处理登录成功的逻辑 // 处理登录成功的逻辑
console.log(response.data);
return response.data; return response.data;
}); });

View File

@ -0,0 +1,51 @@
import axios from "axios";
export default {
addTenant(tenant){
const url='http://localhost:8080/addTenant'
console.log("hahahhaahhha"+tenant.phone);
const data={
symbol: tenant.symbol,
contact: tenant.contact,
phone: tenant.phone,
manager: tenant.manager,
name: tenant.name,
}
return axios.post(url, data)
.then(response => {
if(response.data!=null){
alert("新增成功");
}else
alert("新增失败");
location.href="/tenantManagement";
});
},
getAll(){
const url='http://localhost:8080/getAllTenant'
return axios.get(url)
.then(response => {
return response.data;
});
},
update(tenant){
const url='http://localhost:8080/updateTenant';
console.log("哈哈哈哈哈哈哈啊哈哈哈哈哈"+tenant);
return axios.post(url,tenant)
.then(response => {
});
},
delete(tenant){
const url='http://localhost:8080/deleteTenant';
return axios.post(url,tenant)
.then(response => {
});
}
}

View File

@ -26,14 +26,6 @@ export default {
}, },
editUser(){
},
searchUser(){
},
getAll(){ getAll(){
const url='http://localhost:8080/getAll' const url='http://localhost:8080/getAll'
return axios.get(url) return axios.get(url)
@ -47,10 +39,19 @@ export default {
console.log("哈哈哈哈哈哈哈啊哈哈哈哈哈"+user); console.log("哈哈哈哈哈哈哈啊哈哈哈哈哈"+user);
return axios.post(url,user) return axios.post(url,user)
.then(response => { .then(response => {
if(response.data!=null){ location.href="/userManagement";
console.log(response.data) });
},
delete(user){
const url='http://localhost:8080/delete';
console.log("哈哈哈哈哈哈哈啊哈哈哈哈哈"+user);
return axios.post(url,user)
.then(response => {
if(response.data==boolean){
alert("删除成功");
}else }else
console.log("更新失败"); alert("删除失败");
location.href="/userManagement"; location.href="/userManagement";
}); });
} }

View File

@ -1,11 +1,107 @@
<script setup>
</script>
<template> <template>
<div class="container">
<el-card class="form-container" shadow="hover">
<el-row>
<el-col :span="6">
<el-text class="mx-1" type="primary">租户名称</el-text>
</el-col>
<el-col :span="18">
<el-input v-model="name" placeholder="请输入名称" />
</el-col>
</el-row>
<el-row style="margin-top: 20px;">
<el-col :span="6">
<el-text class="mx-1" type="primary">租户标识</el-text>
</el-col>
<el-col :span="18">
<el-input v-model="symbol" placeholder="请输入标识" />
</el-col>
</el-row>
<el-row style="margin-top: 20px;">
<el-col :span="6">
<el-text class="mx-1" type="primary">联系人</el-text>
</el-col>
<el-col :span="18">
<el-input v-model="contact" placeholder="请输入联系人" />
</el-col>
</el-row>
<el-row style="margin-top: 20px;">
<el-col :span="6">
<el-text class="mx-1" type="primary">手机号码</el-text>
</el-col>
<el-col :span="18">
<el-input v-model="phone" placeholder="请输入手机号码" />
</el-col>
</el-row>
<el-row style="margin-top: 20px;">
<el-col :span="6">
<el-text class="mx-1" type="primary">管理员</el-text>
</el-col>
<el-col :span="18">
<el-input v-model="manager" placeholder="请输入管理员" />
</el-col>
</el-row>
<el-row style="margin-top: 20px;">
<el-col :offset="6" :span="18">
<el-button type="primary" @click="addFinished">确认新增</el-button>
</el-col>
</el-row>
</el-card>
</div>
</template> </template>
<style scoped> <script lang="ts" setup>
import { ref } from 'vue';
import tenantService from "../services/tenantService.js";
</style> const manager = ref<String>('');
const phone = ref<String>('');
const contact = ref<String>('');
const name = ref<String>('');
const symbol = ref<String>('');
const addFinished = () => {
const tenant = {
symbol: symbol.value,
name: name.value,
contact: contact.value,
manager: manager.value,
phone: phone.value,
};
tenantService.addTenant(tenant);
};
</script>
<style scoped>
.container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f0f2f5; /* 设置背景色为浅色 */
}
.form-container {
background-color: #333; /* 深色背景 */
color: white; /* 确保文本颜色与深色背景有对比 */
padding: 20px;
border-radius: 10px;
width: 400px;
}
.el-text {
color: white; /* 确保文本颜色与深色背景有对比 */
}
.el-input {
width: 100%;
}
</style>

View File

@ -1,51 +1,89 @@
<template> <template>
<el-text class="mx-1" type="primary">用户名称</el-text> <div class="container">
<el-input v-model="name" style="width: 240px" placeholder="请输入名称" /> <el-card class="form-container" shadow="hover">
<el-row>
<el-text class="mx-1" type="primary">用户名称</el-text> <el-col :span="6">
<el-input v-model="account" style="width: 240px" placeholder="请输入账号" /> <el-text class="mx-1" type="primary">用户名称</el-text>
</el-col>
<el-text class="mx-1" type="primary">用户密码</el-text> <el-col :span="18">
<el-input v-model="password" style="width: 240px" placeholder="请输入密码" /> <el-input v-model="name" placeholder="请输入名称" />
</el-col>
<el-text class="mx-1" type="primary">手机号码</el-text> </el-row>
<el-input v-model="phone" style="width: 240px" placeholder="请输入手机号码" /> <el-row style="margin-top: 20px;">
<el-col :span="6">
<el-text class="mx-1" type="primary">邮箱</el-text> <el-text class="mx-1" type="primary">用户账号</el-text>
<el-input v-model="email" style="width: 240px" placeholder="请输入邮箱" /> </el-col>
<el-col :span="18">
<el-input v-model="account" placeholder="请输入账号" />
<el-text class="mx-1" type="primary">用户性别</el-text> </el-col>
<el-input v-model="gender" style="width: 240px" placeholder="请输入性别" /> </el-row>
<el-row style="margin-top: 20px;">
<el-text class="mx-1" type="primary">组织</el-text> <el-col :span="6">
<el-input v-model="organization" style="width: 240px" placeholder="请输入组织" /> <el-text class="mx-1" type="primary">用户密码</el-text>
</el-col>
<el-button type="primary" @click="addFinished">确认新增</el-button> <el-col :span="18">
<el-input v-model="password" placeholder="请输入密码" />
</el-col>
</el-row>
<el-row style="margin-top: 20px;">
<el-col :span="6">
<el-text class="mx-1" type="primary">手机号码</el-text>
</el-col>
<el-col :span="18">
<el-input v-model="phone" placeholder="请输入手机号码" />
</el-col>
</el-row>
<el-row style="margin-top: 20px;">
<el-col :span="6">
<el-text class="mx-1" type="primary">邮箱</el-text>
</el-col>
<el-col :span="18">
<el-input v-model="email" placeholder="请输入邮箱" />
</el-col>
</el-row>
<el-row style="margin-top: 20px;">
<el-col :span="6">
<el-text class="mx-1" type="primary">用户性别</el-text>
</el-col>
<el-col :span="18">
<el-input v-model="gender" placeholder="请输入性别" />
</el-col>
</el-row>
<el-row style="margin-top: 20px;">
<el-col :span="6">
<el-text class="mx-1" type="primary">组织</el-text>
</el-col>
<el-col :span="18">
<el-input v-model="organization" placeholder="请输入组织" />
</el-col>
</el-row>
<el-row style="margin-top: 20px;">
<el-col :offset="6" :span="18">
<el-button type="primary" @click="addFinished">确认新增</el-button>
</el-col>
</el-row>
</el-card>
</div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref } from 'vue' import { ref } from 'vue';
import userService from "../services/userService.js"; import userService from "../services/userService.js";
const account = ref<String>('');
const account=ref<String>(''); const phone = ref<String>('');
const phone=ref<String>(''); const email = ref<String>('');
const email=ref<String>(''); const name = ref<String>('');
const name=ref<String>(''); const gender = ref<String>('');
const gender=ref<String>(''); const organization = ref<String>('');
const organization=ref<String>(''); const password = ref<String>('');
const password=ref<String>('');
const addFinished = () => { const addFinished = () => {
const user = { const user = {
account: account.value, account: account.value,
name: name.value, name: name.value,
organization: organization.value, organization: organization.value,
password:password.value, password: password.value,
email: email.value, email: email.value,
gender: gender.value, gender: gender.value,
phone: phone.value, phone: phone.value,
@ -55,5 +93,27 @@ const addFinished = () => {
</script> </script>
<style scoped> <style scoped>
.container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f0f2f5; /* 设置背景色为浅色 */
}
</style> .form-container {
background-color: #333; /* 深色背景 */
color: white; /* 确保文本颜色与深色背景有对比 */
padding: 20px;
border-radius: 10px;
width: 400px;
}
.el-text {
color: white; /* 确保文本颜色与深色背景有对比 */
}
.el-input {
width: 100%;
}
</style>

View File

@ -1,11 +0,0 @@
<script setup>
</script>
<template>
</template>
<style scoped>
</style>

View File

@ -1,46 +0,0 @@
<template>
<el-text class="mx-1" type="primary">用户名称</el-text>
<el-input v-model="name" style="width: 240px" placeholder="请输入名称" />
<el-text class="mx-1" type="primary">用户名称</el-text>
<el-input v-model="account" style="width: 240px" placeholder="请输入账号" />
<el-text class="mx-1" type="primary">用户密码</el-text>
<el-input v-model="password" style="width: 240px" placeholder="请输入密码" />
<el-text class="mx-1" type="primary">手机号码</el-text>
<el-input v-model="phone" style="width: 240px" placeholder="请输入手机号码" />
<el-text class="mx-1" type="primary">邮箱</el-text>
<el-input v-model="email" style="width: 240px" placeholder="请输入邮箱" />
<el-text class="mx-1" type="primary">用户性别</el-text>
<el-input v-model="gender" style="width: 240px" placeholder="请输入性别" />
<el-text class="mx-1" type="primary">组织</el-text>
<el-input v-model="organization" style="width: 240px" placeholder="请输入组织" />
<el-button type="primary" @click="editFinished">确认修改</el-button>
</template>
<script setup>
import userService from "../services/userService.js";
import {ref} from "vue";
const account=ref<String>('');
const phone=ref<String>('');
const email=ref<String>('');
const name=ref<String>('');
const gender=ref<String>('');
const organization=ref<String>('');
const password=ref<String>('');
</script>
<style scoped>
</style>

View File

@ -1,33 +1,64 @@
<template> <template>
<div> <el-card class="login-container" shadow="hover">
<el-text class="mx-1" type="primary" style="margin-left: 30px; margin-top: -90px;">名称</el-text> <el-row>
<el-input v-model="account" style="width: 240px; margin-left: 50px; margin-top: -20px;" placeholder="请输入账号" /> <el-col :span="6">
<el-text class="mx-1" type="primary">名称</el-text>
<el-text class="mx-1" type="primary" style="margin-left: 30px; margin-top: 20px;">密码</el-text> </el-col>
<el-input v-model="password" style="width: 240px; margin-left: 50px; margin-top: 20px;" placeholder="请输入密码" /> <el-col :span="18">
<el-button type="primary" style="padding: 20px; width: 90px; margin-top: 20px;" @click="handleLogin" >登录</el-button> <el-input v-model="account" placeholder="请输入账号" />
<el-button type="primary" style="padding: 20px; width: 90px; margin-left: 20px; margin-top: 20px" @click="handleRegister">注册</el-button> </el-col>
</el-row>
<el-row style="margin-top: 20px;">
</div> <el-col :span="6">
<el-text class="mx-1" type="primary">密码</el-text>
</el-col>
<el-col :span="18">
<el-input v-model="password" placeholder="请输入密码" />
</el-col>
</el-row>
<el-row style="margin-top: 20px;">
<el-col :offset="6" :span="9">
<el-button type="primary" @click="handleLogin">登录</el-button>
</el-col>
<el-col :span="9">
<el-button type="primary" @click="handleRegister">注册</el-button>
</el-col>
</el-row>
</el-card>
</template> </template>
<script setup> <script setup>
import authenticationService from "../services/authenticationService.js"; import authenticationService from "../services/authenticationService.js";
import {useRouter} from "vue-router"; import {useRouter} from "vue-router";
import {ref} from "vue"; import {ref} from "vue";
const account=ref('');
const password=ref('');
const router=useRouter();
const handleLogin = ()=>{ const account = ref('');
authenticationService.login(account.value,password.value).then(res=>{}); const password = ref('');
const router = useRouter();
const handleLogin = () => {
authenticationService.login(account.value, password.value).then(res => {
});
} }
const handleRegister = () => { const handleRegister = () => {
router.push('/register'); router.push('/register');
}; };
</script> </script>
<style scoped> <style scoped>
.login-container {
background-color: #333; /* 深色背景 */
color: white; /* 确保文本颜色与深色背景有对比 */
padding: 20px;
border-radius: 10px;
}
.el-text {
color: white; /* 确保文本颜色与深色背景有对比 */
}
.el-input {
width: 100%;
}
</style> </style>

View File

@ -1,31 +1,34 @@
<template> <template>
<div> <div class="form-container">
<div class="form-item">
<el-text class="mx-1" type="primary" style="margin-left: 30px; margin-top: 20px;">名称</el-text> <el-text class="label" type="primary">名称</el-text>
<el-input v-model="name" style="width: 240px; margin-left: 50px; margin-top: 20px;" placeholder="请输入名称" /> <el-input v-model="name" class="input" placeholder="请输入名称" />
</div>
<el-text class="mx-1" type="primary" style="margin-left: 30px; margin-top: 20px;">账号</el-text> <div class="form-item">
<el-input v-model="account" style="width: 240px; margin-left: 50px; margin-top: 20px;" placeholder="请输入账号" /> <el-text class="label" type="primary">账号</el-text>
<el-input v-model="account" class="input" placeholder="请输入账号" />
<el-text class="mx-1" type="primary" style="margin-left: 30px; margin-top: 20px;">密码</el-text> </div>
<el-input v-model="password" style="width: 240px; margin-left: 50px; margin-top: 20px;" placeholder="请输入密码" /> <div class="form-item">
<el-text class="label" type="primary">密码</el-text>
<el-text class="mx-1" type="primary" style="margin-left: 30px; margin-top: 20px;">性别</el-text> <el-input v-model="password" class="input" placeholder="请输入密码" />
<el-input v-model="gender" style="width: 240px; margin-left: 50px; margin-top: 20px;" placeholder="请输入性别" /> </div>
<div class="form-item">
<el-text class="mx-1" type="primary" style="margin-left: 30px; margin-top: 20px;">电话号码</el-text> <el-text class="label" type="primary">性别</el-text>
<el-input v-model="phone" style="width: 240px; margin-left: 50px; margin-top: 20px;" placeholder="请输入电话号码" /> <el-input v-model="gender" class="input" placeholder="请输入性别" />
</div>
<el-text class="mx-1" type="primary" style="margin-left: 30px; margin-top: 20px;">邮箱</el-text> <div class="form-item">
<el-input v-model="email" style="width: 240px; margin-left: 50px; margin-top: 20px;" placeholder="请输入邮箱" /> <el-text class="label" type="primary">电话号码</el-text>
<el-input v-model="phone" class="input" placeholder="请输入电话号码" />
<el-text class="mx-1" type="primary" style="margin-left: 30px; margin-top: 20px;">组织</el-text> </div>
<el-input v-model="organization" style="width: 240px; margin-left: 50px; margin-top: 20px;" placeholder="请输入组织" /> <div class="form-item">
<el-text class="label" type="primary">邮箱</el-text>
<el-input v-model="email" class="input" placeholder="请输入邮箱" />
</div>
<el-button plain @click="open">注册</el-button> <div class="form-item">
<!-- style="padding: 20px; width: 90px; margin-left: 20px; margin-top: 20px;"--> <el-text class="label" type="primary">组织</el-text>
<el-input v-model="organization" class="input" placeholder="请输入组织" />
</div>
<el-button plain @click="open" class="register-button">注册</el-button>
<router-view></router-view> <router-view></router-view>
</div> </div>
</template> </template>
@ -43,12 +46,10 @@ const gender = ref<string>('');
const phone = ref<string>(''); const phone = ref<string>('');
const email = ref<string>(''); const email = ref<string>('');
const organization = ref<string>(''); const organization = ref<string>('');
const account = ref<String>(''); const account = ref<string>('');
const router = useRouter(); const router = useRouter();
const open = () => { const open = () => {
const user = { const user = {
account: account.value, account: account.value,
@ -74,8 +75,34 @@ const open = () => {
}, },
}); });
}; };
</script> </script>
<style scoped> <style scoped>
.form-container {
display: flex;
flex-direction: column;
align-items: flex-start;
padding: 20px;
}
.form-item {
display: flex;
align-items: center;
margin-bottom: 20px;
width: 100%;
}
.label {
width: 100px;
text-align: right;
margin-right: 10px;
}
.input {
width: 240px;
}
.register-button {
margin-left: 110px; /* Adjust to align with the inputs */
}
</style> </style>

View File

@ -1,11 +1,230 @@
<script setup>
</script>
<template> <template>
<router-view></router-view> <div>
<router-view></router-view>
<el-row :gutter="20">
<el-col :span="6">
<el-input v-model="searchSymbol" placeholder="请输入标识"></el-input>
</el-col>
<el-col :span="6">
<el-input v-model="searchContact" placeholder="请输入联系人"></el-input>
</el-col>
<el-col :span="6">
<el-input v-model="searchPhone" placeholder="请输入手机号"></el-input>
</el-col>
<el-col :span="6">
<el-input v-model="searchName" placeholder="请输入名称"></el-input>
</el-col>
</el-row>
<el-row :gutter="20" class="mt-2">
<el-col :span="24">
<el-button type="primary" @click="handleAdd">新增</el-button>
<el-button plain @click="dialogVisible=true">修改</el-button>
<el-button type="danger" @click="handleDelete">删除</el-button>
<el-button type="primary" @click="handleSearch">查询</el-button>
<el-button type="primary" @click="handleReset">重置</el-button>
</el-col>
</el-row>
<el-table :data="tableData" style="width: 100%" class="mt-2" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55"></el-table-column>
<el-table-column prop="symbol" label="租户标识" width="120"></el-table-column>
<el-table-column prop="contact" label="联系人" width="120"></el-table-column>
<el-table-column prop="phone" label="电话" width="120"></el-table-column>
<el-table-column prop="name" label="租户名称" width="120"></el-table-column>
<el-table-column prop="manager" label="管理员" width="120"></el-table-column>
</el-table>
<el-dialog v-model="dialogVisible" title="Tips" width="500" :before-close="handleClose">
<span>修改租户信息</span>
<template #footer>
<div>
<el-form :model="formData">
<el-form-item label="姓名">
<el-input v-model="formData.name"></el-input>
</el-form-item>
<el-form-item label="联系人">
<el-input v-model="formData.contact"></el-input>
</el-form-item>
<el-form-item label="电话">
<el-input v-model="formData.phone"></el-input>
</el-form-item>
<el-form-item label="管理员">
<el-input v-model="formData.manager"></el-input>
</el-form-item>
</el-form>
</div>
<div class="dialog-footer">
<el-button @click="dialogVisible = false">关闭</el-button>
<el-button type="primary" @click="editFinished">确认修改</el-button>
</div>
</template>
</el-dialog>
</div>
</template> </template>
<style scoped> <script lang="ts">
import tenantService from "../services/tenantService.js";
import { onMounted, ref, defineComponent } from 'vue';
import { ElMessage, ElMessageBox } from 'element-plus'
import type { Action } from 'element-plus'
</style> interface Tenant {
symbol: string;
contact: string;
phone: string;
name: string;
manager: string;
}
export default defineComponent({
setup() {
const searchSymbol = ref('');
const searchContact = ref('');
const searchPhone = ref('');
const searchName = ref('');
const tableData = ref<Tenant[]>([]);
const selectedRows = ref<Tenant[]>([]);
const formData = ref({
symbol: '',
contact: '',
phone: '',
name: '',
manager: '',
});
const dialogVisible = ref(false);
const handleClose = (done: () => void) => {
done();
};
const fetchData = async () => {
try {
const data = await tenantService.getAll();
tableData.value = data;
} catch (error) {
console.error("Error fetching organization:", error);
}
};
const handleSelectionChange = (rows) => {
selectedRows.value = rows;
if (rows.length === 1) {
formData.value = { ...rows[0] };
} else {
formData.value = {
symbol: '',
contact: '',
phone: '',
name: '',
manager: '',
};
}
};
const editFinished = async () => {
try {
await tenantService.update(formData.value);
ElMessageBox.alert('删除成功', '提示', {
// if you want to disable its autofocus
// autofocus: false,
confirmButtonText: 'OK',
callback: (action: Action) => {
ElMessage({
type: 'info',
message: `action: ${action}`,
})
},
})
dialogVisible.value = false;
location.href="/tenantManagement";
fetchData();
} catch (error) {
console.error("Error updating user:", error);
}
};
const handleAdd = () => {
location.href = '/addTenant';
};
const handleDelete = async () => {
try{
await tenantService.delete(formData.value);
ElMessageBox.alert('删除成功', '提示', {
// if you want to disable its autofocus
// autofocus: false,
confirmButtonText: 'OK',
callback: (action: Action) => {
ElMessage({
type: 'info',
message: `action: ${action}`,
})
},
})
fetchData();
}catch(error){
}
};
const handleSearch = async () => {
tableData.value =tableData.value.filter(
(data) => {
const isNameValid = searchName.value;
const isSymbolValid =searchSymbol.value;
const isPhoneValid = searchPhone.value;
const isContactValid = searchContact.value;
// search.value && search.value.
return (!isNameValid || data.name.toLowerCase().includes(searchName.value.toLowerCase())) &&
(!isPhoneValid || data.phone.toLowerCase().includes(searchPhone.value.toLowerCase()) )&&
(!isSymbolValid || data.symbol.toLowerCase().includes(searchSymbol.value.toLowerCase()))&&
(!isContactValid || data.contact.toLowerCase().includes(searchContact.value.toLowerCase()))
}
)
};
const handleReset=()=>{
location.href = '/tenantManagement';
};
onMounted(() => {
fetchData();
});
return {
tableData,
handleAdd,
formData,
dialogVisible,
handleClose,
selectedRows,
handleSelectionChange,
editFinished,
handleDelete,
searchPhone,
searchSymbol,
searchName,
searchContact,
handleSearch,
handleReset
};
}
});
</script>
<style>
.mt-2 {
margin-top: 20px;
}
</style>

View File

@ -1,204 +1,3 @@
<!--<template>-->
<!-- <div>-->
<!-- <router-view></router-view>-->
<!-- <el-row :gutter="20">-->
<!-- <el-col :span="6">-->
<!-- <el-input v-model="organization1" placeholder="请输入组织"></el-input>-->
<!-- </el-col>-->
<!-- <el-col :span="6">-->
<!-- <el-input v-model="name1" placeholder="请输入用户名"></el-input>-->
<!-- </el-col>-->
<!-- <el-col :span="6">-->
<!-- <el-input v-model="phone1" placeholder="请输入手机号"></el-input>-->
<!-- </el-col>-->
<!-- </el-row>-->
<!-- <el-row :gutter="20" class="mt-2">-->
<!-- <el-col :span="24">-->
<!-- <el-button type="primary" @click="handleAdd">新增</el-button>-->
<!-- <el-button plain @click="dialogVisible=true">修改</el-button>-->
<!-- <el-button type="danger" @click="handleDelete">删除</el-button>-->
<!-- <el-button type="primary" @clcik="handleSearch">查询</el-button>-->
<!-- </el-col>-->
<!-- </el-row>-->
<!-- <el-table :data="tableData" style="width: 100%" class="mt-2" @selection-change="handleSelectionChange">-->
<!-- <el-table-column type="selection" width="55"></el-table-column>-->
<!-- <el-table-column prop="id" label="用户编号" width="120"></el-table-column>-->
<!-- <el-table-column prop="account" label="账号" width="120"></el-table-column>-->
<!-- <el-table-column prop="name" label="名称" width="120"></el-table-column>-->
<!-- <el-table-column prop="organization" label="组织" width="120"></el-table-column>-->
<!-- <el-table-column prop="phone" label="手机号" width="150"></el-table-column>-->
<!-- <el-table-column prop="email" label="邮箱" width="180"></el-table-column>-->
<!-- <el-table-column prop="gender" label="性别" width="180"></el-table-column>-->
<!-- </el-table>-->
<!-- <el-dialog-->
<!-- v-model="dialogVisible"-->
<!-- title="Tips"-->
<!-- width="500"-->
<!-- :before-close="handleClose"-->
<!-- >-->
<!-- <span>修改用户</span>-->
<!-- <template #footer>-->
<!-- <div>-->
<!-- <el-form :model="formData">-->
<!-- <el-form-item label="姓名">-->
<!-- <el-input v-model="formData.name" ></el-input>-->
<!-- </el-form-item>-->
<!-- <el-form-item label="账号">-->
<!-- <el-input v-model="formData.account"></el-input>-->
<!-- </el-form-item>-->
<!-- <el-form-item label="组织">-->
<!-- <el-input v-model="formData.organization"></el-input>-->
<!-- </el-form-item>-->
<!-- <el-form-item label="邮箱">-->
<!-- <el-input v-model="formData.email"></el-input>-->
<!-- </el-form-item>-->
<!-- <el-form-item label="性别">-->
<!-- <el-input v-model="formData.gender"></el-input>-->
<!-- </el-form-item>-->
<!-- <el-form-item label="电话">-->
<!-- <el-input v-model="formData.phone"></el-input>-->
<!-- </el-form-item>-->
<!-- <el-form-item label="密码">-->
<!-- <el-input type="password" v-model="formData.password"></el-input>-->
<!-- </el-form-item>-->
<!-- </el-form>-->
<!-- </div>-->
<!-- <div class="dialog-footer">-->
<!-- <el-button @click="dialogVisible = false">关闭</el-button>-->
<!-- <el-button type="primary" @click="editFinished" >-->
<!-- 确认修改-->
<!-- </el-button>-->
<!-- </div>-->
<!-- </template>-->
<!-- </el-dialog>-->
<!-- </div>-->
<!--</template>-->
<!--<script lang="ts">-->
<!--import userService from "../services/userService.js";-->
<!--import { onMounted,ref,defineComponent } from 'vue';-->
<!--interface User {-->
<!-- id: number;-->
<!-- account: string;-->
<!-- name: string;-->
<!-- organization: string;-->
<!-- phone: string;-->
<!-- email: string;-->
<!-- gender:string;-->
<!--}-->
<!--export default defineComponent({-->
<!-- setup(){-->
<!-- const organization1=ref('')-->
<!-- const name1=ref('')-->
<!-- const phone1=ref('')-->
<!-- const tableData = ref<User[]>([]);-->
<!-- const selectedRows = ref([]);-->
<!-- const formData = ref({-->
<!-- account: '',-->
<!-- name: '',-->
<!-- organization: '',-->
<!-- email: '',-->
<!-- gender: '',-->
<!-- phone: '',-->
<!-- password: '',-->
<!-- });-->
<!-- const user=ref({-->
<!-- account:formData.value.account,-->
<!-- name:formData.value.name,-->
<!-- organization:formData.value.organization,-->
<!-- phone:formData.value.phone,-->
<!-- email:formData.value.email,-->
<!-- gender:formData.value.gender,-->
<!-- password:formData.value.password-->
<!-- });-->
<!-- const dialogVisible = ref(false)-->
<!-- const handleClose = (done: () => void) => {-->
<!-- done();-->
<!-- }-->
<!-- const fetchData = async () =>{-->
<!-- try {-->
<!-- const data = await userService.getAll();-->
<!-- tableData.value = data; // ref value -->
<!-- } catch (error) {-->
<!-- console.error("Error fetching organization:", error);-->
<!-- }-->
<!-- }-->
<!-- const selectedRow=ref(null);-->
<!-- const handleSelectionChange = (rows) => {-->
<!-- if (rows.length === 1) {-->
<!-- selectedRow.value = { ...rows[0] }; // selectedRow-->
<!-- formData.value={...selectedRow.value};-->
<!-- } else {-->
<!-- selectedRow.value = null;-->
<!-- }-->
<!-- };-->
<!-- const editFinished=()=>{-->
<!-- console.log("aaa"+formData);-->
<!-- userService.update(formData);-->
<!-- dialogVisible.value = false;-->
<!-- }-->
<!-- const handleAdd = () =>{-->
<!-- location.href='/addUser';-->
<!-- }-->
<!-- const handleDelete=()=>{-->
<!-- }-->
<!-- const handleSearch=()=>{-->
<!-- }-->
<!-- onMounted(() => {-->
<!-- fetchData();-->
<!-- });-->
<!-- return {-->
<!-- tableData,-->
<!-- handleAdd,-->
<!-- formData,-->
<!-- dialogVisible,-->
<!-- handleClose,-->
<!-- selectedRows,-->
<!-- handleSelectionChange,-->
<!-- editFinished,-->
<!-- user,-->
<!-- handleDelete,-->
<!-- phone1,-->
<!-- organization1,-->
<!-- name1,-->
<!-- handleSearch-->
<!-- }-->
<!-- }-->
<!--});-->
<!--</script>-->
<!--<style >-->
<!--.mt-2 {-->
<!-- margin-top: 20px;-->
<!--}-->
<!--</style>-->
<template> <template>
<div> <div>
<router-view></router-view> <router-view></router-view>
@ -221,6 +20,7 @@
<el-button plain @click="dialogVisible=true">修改</el-button> <el-button plain @click="dialogVisible=true">修改</el-button>
<el-button type="danger" @click="handleDelete">删除</el-button> <el-button type="danger" @click="handleDelete">删除</el-button>
<el-button type="primary" @click="handleSearch">查询</el-button> <el-button type="primary" @click="handleSearch">查询</el-button>
<el-button type="primary" @click="handleReset">重置</el-button>
</el-col> </el-col>
</el-row> </el-row>
@ -289,11 +89,17 @@ interface User {
export default defineComponent({ export default defineComponent({
setup() { setup() {
const searchOrganization = ref(''); const searchOrganization = ref('');
const searchName = ref(''); const searchName = ref('');
const searchPhone = ref(''); const searchPhone = ref('');
const tableData = ref<User[]>([]); const tableData = ref<User[]>([]);
const selectedRows = ref<User[]>([]); const selectedRows = ref<User[]>([]);
const formData = ref({ const formData = ref({
id: null, id: null,
account: '', account: '',
@ -353,28 +159,35 @@ export default defineComponent({
}; };
const handleDelete = async () => { const handleDelete = async () => {
try { try{
const ids = selectedRows.value.map(row => row.id); await userService.delete(formData.value);
await userService.delete(ids);
fetchData(); fetchData();
} catch (error) { }catch(error){
console.error("Error deleting users:", error);
} }
}; };
const handleSearch = async () => { const handleSearch = async () => {
try { tableData.value =tableData.value.filter(
const data = await userService.search({ (data) => {
organization: searchOrganization.value, const isNameValid = searchName.value;
name: searchName.value, const isOrganizationValid =searchOrganization.value;
phone: searchPhone.value, const isPhoneValid = searchPhone.value;
}); // search.value && search.value.
tableData.value = data;
} catch (error) { return (!isNameValid || data.name.toLowerCase().includes(searchName.value.toLowerCase())) &&
console.error("Error searching users:", error); (!isPhoneValid || data.phone.toLowerCase().includes(searchPhone.value.toLowerCase()) )&&
} (!isOrganizationValid || data.organization.toLowerCase().includes(searchOrganization.value.toLowerCase()))
}
)
}; };
const handleReset=()=>{
location.href = '/userManagement';
}
onMounted(() => { onMounted(() => {
fetchData(); fetchData();
}); });
@ -392,7 +205,8 @@ export default defineComponent({
searchPhone, searchPhone,
searchOrganization, searchOrganization,
searchName, searchName,
handleSearch handleSearch,
handleReset
}; };
} }
}); });