1、Ajax优化

Former-commit-id: d3a1db56f11bf797d934c55fa8535dd6a6a0153b
master
王兵 5 years ago
parent 5de8789629
commit f5b18a1af4

@ -1,5 +1,7 @@
package xyz.wbsite.dbtool.web.frame.utils; package xyz.wbsite.dbtool.web.frame.utils;
import java.io.File;
import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
/** /**
@ -494,4 +496,20 @@ public class Base64Util {
return dArr; return dArr;
} }
public static void main(String[] args) throws IOException {
try {
byte[] bytes = FileUtil.readFileToByteArray(new File("E:\\patt.png"));
String string = Base64Util.encodeToString(bytes);
System.out.println(string);
} catch (IOException e) {
e.printStackTrace();
}
}
} }

@ -229,7 +229,7 @@
}).then(callback); }).then(callback);
break; break;
default: default:
jsonRequest({ return jsonRequest({
url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod, url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod,
data: JSON.stringify(data) data: JSON.stringify(data)
}).then(callback); }).then(callback);
@ -307,7 +307,7 @@
this.select = select; this.select = select;
}, },
onTemplate: function () { onTemplate: function () {
new Ajax(this.module, this.target, "template").post(function (response) { new Ajax(this.module, this.target).method("template").post({}, function (response) {
if (response.errors.length > 0) { if (response.errors.length > 0) {
nav.e(response.errors[0].message); nav.e(response.errors[0].message);
} }
@ -315,7 +315,7 @@
}, },
onImport: function (item) { onImport: function (item) {
utils.selectFile(function (files) { utils.selectFile(function (files) {
new Ajax(this.module, this.target, "imports", files[0]).post(function (response) { new Ajax(this.module, this.target).method("imports").post(files[0], function (response) {
if (response.errors.length > 0) { if (response.errors.length > 0) {
nav.e(response.errors[0].message); nav.e(response.errors[0].message);
} }
@ -323,7 +323,7 @@
}.bind(this)) }.bind(this))
}, },
onExport: function () { onExport: function () {
new Ajax(this.module, this.target, "exports", this.vm).post(function (response) { new Ajax(this.module, this.target).method("exports").post(this.vm, function (response) {
if (response.errors.length > 0) { if (response.errors.length > 0) {
nav.e(response.errors[0].message); nav.e(response.errors[0].message);
} }
@ -333,7 +333,7 @@
this.$refs['form'].validate(function (valid) { this.$refs['form'].validate(function (valid) {
if (valid) { if (valid) {
if (this.form.id) { if (this.form.id) {
new Ajax(this.module, this.target, "update", this.form).post(function (response) { new Ajax(this.module, this.target).update(this.form, function (response) {
if (response.errors.length > 0) { if (response.errors.length > 0) {
nav.e(response.errors[0].message); nav.e(response.errors[0].message);
} else { } else {
@ -343,7 +343,7 @@
} }
}.bind(this)) }.bind(this))
} else { } else {
new Ajax(this.module, this.target, "create", this.form).post(function (response) { new Ajax(this.module, this.target).create(this.form, function (response) {
if (response.errors.length > 0) { if (response.errors.length > 0) {
nav.e(response.errors[0].message); nav.e(response.errors[0].message);
} else { } else {
@ -359,7 +359,7 @@
}.bind(this)); }.bind(this));
}, },
onFind: function () { onFind: function () {
new Ajax(this.module, this.target, "find", this.vm).post(function (response) { new Ajax(this.module, this.target).find(this.vm, function (response) {
if (response.errors.length > 0) { if (response.errors.length > 0) {
nav.e(response.errors[0].message); nav.e(response.errors[0].message);
} else { } else {
@ -374,7 +374,7 @@
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(function () { }).then(function () {
new Ajax(this.module, this.target, "delete", {id: item.id}).post(function (response) { new Ajax(this.module, this.target).delete({id: item.id}, function (response) {
if (response.errors.length > 0) { if (response.errors.length > 0) {
nav.e(response.errors[0].message); nav.e(response.errors[0].message);
} else { } else {
@ -397,7 +397,7 @@
}).then(function () { }).then(function () {
for (var i = 0; i < this.select.length; i++) { for (var i = 0; i < this.select.length; i++) {
(function (obj) { (function (obj) {
new Ajax(this.module, this.target, "delete", {id: obj.id}).post(function (response) { new Ajax(this.module, this.target).delete({id: obj.id}, function (response) {
if (response.errors.length > 0) { if (response.errors.length > 0) {
nav.e(response.errors[0].message); nav.e(response.errors[0].message);
} else { } else {
@ -698,7 +698,9 @@
}, },
created: function () { created: function () {
if (this.dictName) { if (this.dictName) {
new Ajax("system", "dict", "load").data({dictName: this.dictName}).post(function (response) { new Ajax("system", "dict").method("load").post({
dictName: this.dictName
},function (response) {
if (response.errors.length > 0) { if (response.errors.length > 0) {
console.error(response.errors[0].message) console.error(response.errors[0].message)
} else { } else {
@ -750,7 +752,9 @@
} }
}, },
created: function () { created: function () {
new Ajax("system", "dept", "tree").data({dictName: this.dictName}).post(function (response) { new Ajax("system", "dept").method("tree").post({
dictName: this.dictName
},function (response) {
if (response.errors.length > 0) { if (response.errors.length > 0) {
console.error(response.errors[0].message) console.error(response.errors[0].message)
} else { } else {

@ -1029,7 +1029,7 @@
}, },
methods: { methods: {
doAjax: function () { doAjax: function () {
new Ajax("system", "user","find").post(function (response) { new Ajax("system", "user").find({}, function (response) {
if (response.errors.length > 0) { if (response.errors.length > 0) {
nav.e(response.errors[0].message); nav.e(response.errors[0].message);
} else { } else {

@ -374,7 +374,7 @@
onCommand: function (cmd) { onCommand: function (cmd) {
switch (cmd) { switch (cmd) {
case "logout": case "logout":
new Ajax("system", "User", "logout").post(function (response) { new Ajax("system", "User").method("logout").post({}, function (response) {
if (response.errors.length > 0) { if (response.errors.length > 0) {
nav.e(response.errors[0].message); nav.e(response.errors[0].message);
} else { } else {

@ -110,7 +110,7 @@
this.$refs[formName].validate(function (valid) { this.$refs[formName].validate(function (valid) {
if (valid) { if (valid) {
this.isSubmit = true; this.isSubmit = true;
new Ajax("system", "User", "login", this.form).post(function (response) { new Ajax("system", "User").method("login").post(this.form, function (response) {
this.isSubmit = false; this.isSubmit = false;
if (response.errors.length > 0) { if (response.errors.length > 0) {
nav.e(response.errors[0].message); nav.e(response.errors[0].message);

@ -313,7 +313,7 @@
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(function () { }).then(function () {
new Ajax(this.module, this.target, "delete", {id: item.id}).post(function (response) { new Ajax("${module}", "${table.getFName()}").delete({id: item.id}, function (response) {
if (response.errors.length > 0) { if (response.errors.length > 0) {
nav.e(response.errors[0].message); nav.e(response.errors[0].message);
} else { } else {

@ -305,7 +305,7 @@
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(function () { }).then(function () {
new Ajax("system", "dept", "delete").post({id: item.id}, function (response) { new Ajax("system", "dept").delete({id: item.id}, function (response) {
if (response.errors.length > 0) { if (response.errors.length > 0) {
nav.e(response.errors[0].message); nav.e(response.errors[0].message);
} else { } else {
@ -344,7 +344,7 @@
return data.deptName.indexOf(value) !== -1; return data.deptName.indexOf(value) !== -1;
}, },
onLoadTree: function () { onLoadTree: function () {
new Ajax("system", "dept", "tree").post(function (response) { new Ajax("system", "dept").method("tree").post({}, function (response) {
if (response.errors.length > 0) { if (response.errors.length > 0) {
nav.e(response.errors[0].message); nav.e(response.errors[0].message);
} else { } else {
@ -356,7 +356,7 @@
this.$refs['form'].validate(function (valid) { this.$refs['form'].validate(function (valid) {
if (valid) { if (valid) {
if (this.form.id) { if (this.form.id) {
new Ajax("system", "dept").data(this.form).update(function (response) { new Ajax("system", "dept").update(this.form, function (response) {
if (response.errors.length > 0) { if (response.errors.length > 0) {
nav.e(response.errors[0].message); nav.e(response.errors[0].message);
} else { } else {
@ -367,7 +367,7 @@
} }
}.bind(this)) }.bind(this))
} else { } else {
new Ajax("system", "dept").data(this.form).create(function (response) { new Ajax("system", "dept").create(this.form, function (response) {
if (response.errors.length > 0) { if (response.errors.length > 0) {
nav.e(response.errors[0].message); nav.e(response.errors[0].message);
} else { } else {

@ -234,9 +234,7 @@
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(function () { }).then(function () {
new Ajax("system", "dict").delete({ new Ajax("system", "dict").delete({id: item.id}, function (response) {
id: item.id
}, function (response) {
if (response.errors.length > 0) { if (response.errors.length > 0) {
nav.e(response.errors[0].message); nav.e(response.errors[0].message);
} else { } else {

@ -230,7 +230,7 @@
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(function () { }).then(function () {
new Ajax("system", "dictItem", "delete", {id: item.id}).post(function (response) { new Ajax("system", "dictItem").delete({id: item.id}, function (response) {
if (response.errors.length > 0) { if (response.errors.length > 0) {
nav.e(response.errors[0].message); nav.e(response.errors[0].message);
} else { } else {

@ -238,7 +238,7 @@
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(function () { }).then(function () {
new Ajax("system", "file", "delete", {id: item.id}).post(function (response) { new Ajax("system", "file").delete({id: item.id}, function (response) {
if (response.errors.length > 0) { if (response.errors.length > 0) {
nav.e(response.errors[0].message); nav.e(response.errors[0].message);
} else { } else {

@ -260,7 +260,7 @@
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(function () { }).then(function () {
new Ajax("system", "logErr", "delete", {id: item.id}).post(function (response) { new Ajax("system", "logErr").delete({id: item.id},function (response) {
if (response.errors.length > 0) { if (response.errors.length > 0) {
nav.e(response.errors[0].message); nav.e(response.errors[0].message);
} else { } else {

@ -311,7 +311,7 @@
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(function () { }).then(function () {
new Ajax("system", "res", "delete", {id: item.id}).post(function (response) { new Ajax("system", "res").delete({id: item.id}, function (response) {
if (response.errors.length > 0) { if (response.errors.length > 0) {
nav.e(response.errors[0].message); nav.e(response.errors[0].message);
} else { } else {
@ -352,7 +352,7 @@
return data.comment.indexOf(value) !== -1; return data.comment.indexOf(value) !== -1;
}, },
onLoadTree: function () { onLoadTree: function () {
new Ajax("system", "res", "tree").post(function (response) { new Ajax("system", "res").method("tree").post({}, function (response) {
if (response.errors.length > 0) { if (response.errors.length > 0) {
nav.e(response.errors[0].message); nav.e(response.errors[0].message);
} else { } else {
@ -364,7 +364,7 @@
this.$refs['form'].validate(function (valid) { this.$refs['form'].validate(function (valid) {
if (valid) { if (valid) {
if (this.form.id) { if (this.form.id) {
new Ajax("system", "res", "update", this.form).post(function (response) { new Ajax("system", "res").update(this.form, function (response) {
if (response.errors.length > 0) { if (response.errors.length > 0) {
nav.e(response.errors[0].message); nav.e(response.errors[0].message);
} else { } else {
@ -375,7 +375,7 @@
} }
}.bind(this)) }.bind(this))
} else { } else {
new Ajax("system", "res", "create", this.form).post(function (response) { new Ajax("system", "res").create(this.form, function (response) {
if (response.errors.length > 0) { if (response.errors.length > 0) {
nav.e(response.errors[0].message); nav.e(response.errors[0].message);
} else { } else {

@ -227,7 +227,7 @@
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(function () { }).then(function () {
new Ajax("system", "role", "delete", {id: item.id}).post(function (response) { new Ajax("system", "role").delete({id: item.id}, function (response) {
if (response.errors.length > 0) { if (response.errors.length > 0) {
nav.e(response.errors[0].message); nav.e(response.errors[0].message);
} else { } else {
@ -244,7 +244,10 @@
this.formResource.dialog = true; this.formResource.dialog = true;
this.formResource.roleId = item.id; this.formResource.roleId = item.id;
this.formResource.roleCode = item.code; this.formResource.roleCode = item.code;
new Ajax("system", "roleRes", "find", {roleId: item.id, pageSize: 0}).post(function (response) { new Ajax("system", "roleRes").find({
roleId: item.id,
pageSize: 0
}, function (response) {
if (response.errors.length > 0) { if (response.errors.length > 0) {
nav.e(response.errors[0].message); nav.e(response.errors[0].message);
} else { } else {
@ -258,14 +261,13 @@
}.bind(this)) }.bind(this))
}, },
onCheck: function (item, status) { onCheck: function (item, status) {
var param = { new Ajax("system", "roleRes").method("check").post({
roleId: this.formResource.roleId, roleId: this.formResource.roleId,
roleCode: this.formResource.roleCode, roleCode: this.formResource.roleCode,
resId: item.id, resId: item.id,
resCode: item.resCode, resCode: item.resCode,
checked: status.checkedKeys.indexOf(item.id) !== -1 checked: status.checkedKeys.indexOf(item.id) !== -1
} }, function (response) {
new Ajax("system", "roleRes", "check", param).post(function (response) {
if (response.errors.length > 0) { if (response.errors.length > 0) {
nav.e(response.errors[0].message); nav.e(response.errors[0].message);
} else { } else {
@ -274,7 +276,7 @@
}.bind(this)) }.bind(this))
}, },
onLoadTree: function () { onLoadTree: function () {
new Ajax("system", "res", "tree").post(function (response) { new Ajax("system", "res").method("tree").post({}, function (response) {
if (response.errors.length > 0) { if (response.errors.length > 0) {
nav.e(response.errors[0].message); nav.e(response.errors[0].message);
} else { } else {

@ -55,7 +55,7 @@
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(function () { }).then(function () {
new Ajax("system", "schedule", "delete", {id: item.id}).post(function (response) { new Ajax("system", "schedule").delete({id: item.id},function (response) {
if (response.errors.length > 0) { if (response.errors.length > 0) {
nav.e(response.errors[0].message); nav.e(response.errors[0].message);
} else { } else {

@ -249,7 +249,7 @@
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(function () { }).then(function () {
new Ajax("system", "tokens", "logout", {token: item.token}).post(function (response) { new Ajax("system", "tokens").method("logout").post({token: item.token}, function (response) {
if (response.errors.length > 0) { if (response.errors.length > 0) {
nav.e(response.errors[0].message); nav.e(response.errors[0].message);
} else { } else {

@ -269,7 +269,7 @@
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(function () { }).then(function () {
new Ajax("system", "user", "delete", {id: item.id}).post(function (response) { new Ajax("system", "user").delete({id: item.id}, function (response) {
if (response.errors.length > 0) { if (response.errors.length > 0) {
nav.e(response.errors[0].message); nav.e(response.errors[0].message);
} else { } else {
@ -282,7 +282,7 @@
}); });
}, },
loadRoles: function () { loadRoles: function () {
new Ajax("system", "role", "find", {pageSize: 0}).post(function (response) { new Ajax("system", "role").find({pageSize: 0}, function (response) {
if (response.errors.length > 0) { if (response.errors.length > 0) {
nav.e(response.errors[0].message); nav.e(response.errors[0].message);
} else { } else {

Loading…
Cancel
Save

Powered by TurnKey Linux.