修改调用方式

This commit is contained in:
shiziyuan9527 2020-02-19 11:31:01 +08:00
parent 14a6b787e0
commit fd0389c86f
2 changed files with 52 additions and 92 deletions

View File

@ -133,15 +133,11 @@
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
this.$get(this.deletePath + row.id).then(response => { this.$get(this.deletePath + row.id,() => {
if (response.data.success) { this.$message({
this.$message({ type: 'success',
type: 'success', message: '删除成功!'
message: '删除成功!' });
});
} else {
this.$message.error(response.message);
}
this.initTableData() this.initTableData()
}); });
}).catch(() => { }).catch(() => {
@ -154,18 +150,13 @@
createOrganization(createOrganizationForm) { createOrganization(createOrganizationForm) {
this.$refs[createOrganizationForm].validate( valide => { this.$refs[createOrganizationForm].validate( valide => {
if (valide) { if (valide) {
this.$post(this.createPath, this.form) this.$post(this.createPath, this.form,() => {
.then(response => { this.$message({
if (response.data.success) { type: 'success',
this.$message({ message: '添加成功!'
type: 'success', });
message: '添加成功!' this.initTableData();
}); this.createVisible = false;
this.initTableData();
} else {
this.$message.error(response.message);
}
this.createVisible = false;
}); });
} else { } else {
return false; return false;
@ -175,19 +166,14 @@
updateOrganization(udpateOrganizationForm) { updateOrganization(udpateOrganizationForm) {
this.$refs[udpateOrganizationForm].validate(valide => { this.$refs[udpateOrganizationForm].validate(valide => {
if (valide) { if (valide) {
this.$post(this.updatePath, this.form) this.$post(this.updatePath, this.form,() => {
.then(response => { this.$message({
if (response.data.success) { type: 'success',
this.$message({ message: '修改成功!'
type: 'success', });
message: '修改成功!' this.updateVisible = false;
}); this.initTableData();
this.updateVisible = false; self.loading = false;
} else {
this.$message.error(response.message);
}
this.initTableData();
self.loading = false;
}); });
} else { } else {
return false; return false;
@ -195,14 +181,10 @@
}) })
}, },
initTableData() { initTableData() {
this.$post(this.buildPagePath(this.queryPath)).then(response => { this.$post(this.buildPagePath(this.queryPath),{},response => {
if (response.data.success) { let data = response.data;
let data = response.data.data; this.total = data.itemCount;
this.total = data.itemCount; this.tableData = data.listObject;
this.tableData = data.listObject;
} else {
this.$message.error(response.message);
}
}) })
}, },
closeFunc() { closeFunc() {

View File

@ -180,16 +180,12 @@
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
this.$get(this.deletePath + row.id).then(response => { this.$get(this.deletePath + row.id, () => {
if (response.data.success) { this.$message({
this.$message({ type: 'success',
type: 'success', message: '删除成功!'
message: '删除成功!' });
}); this.initTableData();
this.initTableData()
} else {
this.$message.error(response.message)
}
}); });
}).catch(() => { }).catch(() => {
this.$message({ this.$message({
@ -201,18 +197,13 @@
createUser(createUserForm) { createUser(createUserForm) {
this.$refs[createUserForm].validate(valide => { this.$refs[createUserForm].validate(valide => {
if (valide) { if (valide) {
this.$post(this.createPath, this.form) this.$post(this.createPath, this.form, () => {
.then(response => { this.$message({
if (response.data.success) { type: 'success',
this.$message({ message: '添加成功!'
type: 'success', });
message: '添加成功!' this.initTableData();
}); this.createVisible = false;
this.initTableData();
} else {
this.$message.error(response.message);
}
this.createVisible = false;
}); });
} else { } else {
return false; return false;
@ -222,19 +213,14 @@
updateUser(updateUserForm) { updateUser(updateUserForm) {
this.$refs[updateUserForm].validate(valide => { this.$refs[updateUserForm].validate(valide => {
if (valide) { if (valide) {
this.$post(this.updatePath, this.form) this.$post(this.updatePath, this.form,() => {
.then(response => { this.$message({
if (response.data.success) { type: 'success',
this.$message({ message: '修改成功!'
type: 'success', });
message: '修改成功!' this.updateVisible = false;
}); this.initTableData();
this.updateVisible = false; self.loading = false;
} else {
this.$message.error(response.message);
}
this.initTableData();
self.loading = false;
}); });
} else { } else {
return false; return false;
@ -242,29 +228,21 @@
}) })
}, },
initTableData() { initTableData() {
this.$post(this.buildPagePath(this.queryPath)).then(response => { this.$post(this.buildPagePath(this.queryPath),{},response => {
if (response.data.success) { let data = response.data;
let data = response.data.data;
this.total = data.itemCount; this.total = data.itemCount;
this.tableData = data.listObject; this.tableData = data.listObject;
} else {
this.$message.error(response.message);
}
}) })
}, },
closeFunc() { closeFunc() {
this.form = {}; this.form = {};
}, },
changeSwitch(row) { changeSwitch(row) {
this.$post(this.updatePath, row).then(response =>{ this.$post(this.updatePath, row,() =>{
if (response.data.success) { this.$message({
this.$message({ type: 'success',
type: 'success', message: '状态修改成功!'
message: '状态修改成功!' });
});
} else {
this.$message.error(response.message);
}
}) })
}, },
buildPagePath(path) { buildPagePath(path) {