对tenantManagement页面进行微调,统一service的API
This commit is contained in:
parent
bb6dc0999f
commit
acd9cad23f
@ -1,10 +1,8 @@
|
||||
import axios from "axios";
|
||||
|
||||
import {ref} from "vue";
|
||||
|
||||
export default {
|
||||
addUser(user){
|
||||
const url='http://localhost:8080/addUser'
|
||||
const url='/api/user/addUser'
|
||||
const data={
|
||||
account: user.account,
|
||||
name: user.name,
|
||||
@ -26,34 +24,23 @@ export default {
|
||||
},
|
||||
|
||||
|
||||
getAll(){
|
||||
const url='http://localhost:8080/getAll'
|
||||
return axios.get(url)
|
||||
.then(response => {
|
||||
return response.data;
|
||||
});
|
||||
async getAll() {
|
||||
const url = '/api/user/getAll'
|
||||
const response = await axios.get(url)
|
||||
return response.data;
|
||||
},
|
||||
|
||||
update(user){
|
||||
const url='http://localhost:8080/update';
|
||||
console.log("哈哈哈哈哈哈哈啊哈哈哈哈哈"+user);
|
||||
const url='/api/user/update';
|
||||
return axios.post(url,user)
|
||||
.then(response => {
|
||||
.then(() => {
|
||||
location.href="/userManagement";
|
||||
});
|
||||
},
|
||||
|
||||
delete(user){
|
||||
const url='http://localhost:8080/delete';
|
||||
console.log("哈哈哈哈哈哈哈啊哈哈哈哈哈"+user);
|
||||
return axios.post(url,user)
|
||||
.then(response => {
|
||||
if(response.data==boolean){
|
||||
alert("删除成功");
|
||||
}else
|
||||
alert("删除失败");
|
||||
location.href="/userManagement";
|
||||
});
|
||||
async delete(user){
|
||||
const url='/api/user/delete';
|
||||
return await axios.post(url, user)
|
||||
}
|
||||
|
||||
}
|
||||
@ -75,7 +75,8 @@
|
||||
|
||||
<script lang="ts">
|
||||
import userService from "../../services/userService.js";
|
||||
import { onMounted, ref, defineComponent } from 'vue';
|
||||
import {defineComponent, onMounted, ref} from 'vue';
|
||||
import {ElMessage} from "element-plus";
|
||||
|
||||
interface User {
|
||||
id: number;
|
||||
@ -119,8 +120,7 @@ export default defineComponent({
|
||||
|
||||
const fetchData = async () => {
|
||||
try {
|
||||
const data = await userService.getAll();
|
||||
tableData.value = data;
|
||||
tableData.value = await userService.getAll();
|
||||
} catch (error) {
|
||||
console.error("Error fetching organization:", error);
|
||||
}
|
||||
@ -129,7 +129,7 @@ export default defineComponent({
|
||||
const handleSelectionChange = (rows) => {
|
||||
selectedRows.value = rows;
|
||||
if (rows.length === 1) {
|
||||
formData.value = { ...rows[0] };
|
||||
formData.value = {...rows[0]};
|
||||
} else {
|
||||
formData.value = {
|
||||
id: null,
|
||||
@ -159,34 +159,35 @@ export default defineComponent({
|
||||
};
|
||||
|
||||
const handleDelete = async () => {
|
||||
try{
|
||||
try {
|
||||
await userService.delete(formData.value);
|
||||
fetchData();
|
||||
}catch(error){
|
||||
|
||||
ElMessage.error("删除成功")
|
||||
await fetchData();
|
||||
} catch (error) {
|
||||
ElMessage.error("删除失败")
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const handleSearch = async () => {
|
||||
tableData.value =tableData.value.filter(
|
||||
tableData.value = tableData.value.filter(
|
||||
(data) => {
|
||||
const isNameValid = searchName.value;
|
||||
const isOrganizationValid =searchOrganization.value;
|
||||
const isOrganizationValid = searchOrganization.value;
|
||||
const isPhoneValid = searchPhone.value;
|
||||
// search.value && search.value.
|
||||
|
||||
return (!isNameValid || data.name.toLowerCase().includes(searchName.value.toLowerCase())) &&
|
||||
(!isPhoneValid || data.phone.toLowerCase().includes(searchPhone.value.toLowerCase()) )&&
|
||||
(!isPhoneValid || data.phone.toLowerCase().includes(searchPhone.value.toLowerCase())) &&
|
||||
(!isOrganizationValid || data.organization.toLowerCase().includes(searchOrganization.value.toLowerCase()))
|
||||
}
|
||||
)
|
||||
};
|
||||
|
||||
|
||||
const handleReset=()=>{
|
||||
location.href = '/userManagement';
|
||||
}
|
||||
const handleReset = () => {
|
||||
location.href = '/userManagement';
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchData();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user