Compare commits

...

3 Commits

4 changed files with 49 additions and 69 deletions

View File

@ -1,11 +1,8 @@
import axios from "axios";
export default {
addTenant(tenant) {
const url='http://localhost:8080/addTenant'
console.log("hahahhaahhha"+tenant.phone);
const url = '/api/tenant/addTenant'
const data = {
symbol: tenant.symbol,
contact: tenant.contact,
@ -25,24 +22,21 @@ export default {
},
getAll(){
const url='http://localhost:8080/getAllTenant'
return axios.get(url)
.then(response => {
async getAll() {
const url = '/api/tenant/getAllTenant'
const response = await axios.get(url)
return response.data;
});
},
update(tenant) {
const url='http://localhost:8080/updateTenant';
console.log("哈哈哈哈哈哈哈啊哈哈哈哈哈"+tenant);
const url = '/api/tenant/updateTenant';
return axios.post(url, tenant)
.then(response => {
});
},
delete(tenant) {
const url='http://localhost:8080/deleteTenant';
const url = '/api/tenant/deleteTenant';
return axios.post(url, tenant)
.then(response => {
});

View File

@ -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 => {
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)
}
}

View File

@ -67,9 +67,8 @@
<script lang="ts">
import tenantService from "../../services/tenantService.js";
import { onMounted, ref, defineComponent } from 'vue';
import {defineComponent, onMounted, ref} from 'vue';
import {ElMessage, ElMessageBox} from 'element-plus'
import type { Action } from 'element-plus'
interface Tenant {
symbol: string;
@ -104,8 +103,7 @@ export default defineComponent({
const fetchData = async () => {
try {
const data = await tenantService.getAll();
tableData.value = data;
tableData.value = await tenantService.getAll();
} catch (error) {
console.error("Error fetching organization:", error);
}
@ -129,11 +127,11 @@ export default defineComponent({
const editFinished = async () => {
try {
await tenantService.update(formData.value);
ElMessageBox.alert('删除成功', '提示', {
await ElMessageBox.alert('删除成功', '提示', {
// if you want to disable its autofocus
// autofocus: false,
confirmButtonText: 'OK',
callback: (action: Action) => {
callback: (action) => {
ElMessage({
type: 'info',
message: `action: ${action}`,
@ -156,18 +154,18 @@ export default defineComponent({
const handleDelete = async () => {
try{
await tenantService.delete(formData.value);
ElMessageBox.alert('删除成功', '提示', {
await ElMessageBox.alert('删除成功', '提示', {
// if you want to disable its autofocus
// autofocus: false,
confirmButtonText: 'OK',
callback: (action: Action) => {
callback: (action) => {
ElMessage({
type: 'info',
message: `action: ${action}`,
})
},
})
fetchData();
await fetchData();
}catch(error){
}

View File

@ -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);
}
@ -161,9 +161,10 @@ export default defineComponent({
const handleDelete = async () => {
try {
await userService.delete(formData.value);
fetchData();
ElMessage.error("删除成功")
await fetchData();
} catch (error) {
ElMessage.error("删除失败")
}
};