diff --git a/src/main/resources/modules/SpringBoot/resources/templates/control/nav.ftl b/src/main/resources/modules/SpringBoot/resources/templates/control/nav.ftl
index c4e3606a..cd2b4d21 100644
--- a/src/main/resources/modules/SpringBoot/resources/templates/control/nav.ftl
+++ b/src/main/resources/modules/SpringBoot/resources/templates/control/nav.ftl
@@ -193,100 +193,83 @@
return Promise.resolve(rsp);
})
};
- function Ajax(module, target, method, data) {
+ function Ajax(module, target, method) {
this.mModule = module;
this.mTarget = target;
this.mMethod = method;
- this.mData = data ? data : {};
- this.module = function (module) {
- this.mModule = module;
- return this;
- };
- this.target = function (target) {
- this.mTarget = target;
- return this;
- };
- this.method = function (method) {
- this.mMethod = method;
- return this;
- };
- this.data = function (data) {
- this.mData = data;
- return this;
- };
- this.post = function (callback) {
+ this.post = function (data, callback) {
switch (this.mMethod) {
case "upload":
return uploadRequest({
url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod,
- data: this.mData
+ data: data
}).then(callback);
break;
case "imports":
return importRequest({
url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod,
- data: this.mData
+ data: data
}).then(callback);
break;
case "exports":
return downRequest({
url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod,
- data: JSON.stringify(this.mData)
+ data: JSON.stringify(data)
}).then(callback)
break;
case "template":
return downRequest({
url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod,
- data: JSON.stringify(this.mData)
+ data: JSON.stringify(data)
}).then(callback);
break;
default:
jsonRequest({
url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod,
- data: JSON.stringify(this.mData)
+ data: JSON.stringify(data)
}).then(callback);
}
};
- this.create = function (callback) {
+ this.create = function (data, callback) {
this.mMethod = "create";
- this.post(callback);
+ this.post(data, callback);
};
- this.delete = function (callback) {
+ this.delete = function (data, callback) {
this.mMethod = "delete";
- this.post(callback);
+ this.post(data, callback);
};
- this.update = function (callback) {
+ this.update = function (data, callback) {
this.mMethod = "update";
- this.post(callback);
+ this.post(data, callback);
};
- this.find = function (callback) {
+ this.find = function (data, callback) {
this.mMethod = "find";
- this.post(callback);
+ this.post(data, callback);
};
- this.get = function (callback) {
+ this.get = function (data, callback) {
this.mMethod = "get";
- this.post(callback);
+ this.post(data, callback);
};
- this.load = function (callback) {
+ this.load = function (data, callback) {
this.mMethod = "load";
- this.post(callback);
+ this.post(data, callback);
};
- this.template = function (callback) {
+ this.template = function (data, callback) {
this.mMethod = "template";
- this.post(callback);
+ this.post(data, callback);
};
- this.imports = function (callback) {
+ this.imports = function (data, callback) {
this.mMethod = "imports";
- this.post(callback);
+ this.post(data, callback);
};
- this.exports = function (callback) {
+ this.exports = function (data, callback) {
this.mMethod = "exports";
- this.post(callback);
+ this.post(data, callback);
};
- this.upload = function (callback) {
+ this.upload = function (data, callback) {
this.mMethod = "upload";
- this.post(callback);
+ this.post(data, callback);
};
}
diff --git a/src/main/resources/modules/SpringBoot/resources/templates/screen/home.ftl b/src/main/resources/modules/SpringBoot/resources/templates/screen/home.ftl
index 68bb4fcb..58321130 100644
--- a/src/main/resources/modules/SpringBoot/resources/templates/screen/home.ftl
+++ b/src/main/resources/modules/SpringBoot/resources/templates/screen/home.ftl
@@ -1029,17 +1029,13 @@
},
methods: {
doAjax: function () {
- new Ajax()
- .module("system")
- .target("user")
- .data({})
- .find(function (response) {
- if (response.errors.length > 0) {
- nav.e(response.errors[0].message);
- } else {
- nav.i("Ajax调用成功!");
- }
- }.bind(this))
+ new Ajax("system", "user","find").post(function (response) {
+ if (response.errors.length > 0) {
+ nav.e(response.errors[0].message);
+ } else {
+ nav.i("Ajax调用成功!");
+ }
+ }.bind(this))
},
doPush: function () {
if (window.EventSource) {
diff --git a/src/main/resources/modules/SpringBoot/resources/templates/screen/index.ftl b/src/main/resources/modules/SpringBoot/resources/templates/screen/index.ftl
index be6b4f38..590d1b33 100644
--- a/src/main/resources/modules/SpringBoot/resources/templates/screen/index.ftl
+++ b/src/main/resources/modules/SpringBoot/resources/templates/screen/index.ftl
@@ -374,18 +374,14 @@
onCommand: function (cmd) {
switch (cmd) {
case "logout":
- new Ajax()
- .module("system")
- .target("User")
- .method("logout")
- .post(function (response) {
- if (response.errors.length > 0) {
- nav.e(response.errors[0].message);
- } else {
- nav.clearCookie("token");
- nav.toOpen("/login.htm");
- }
- }.bind(this));
+ new Ajax("system", "User", "logout").post(function (response) {
+ if (response.errors.length > 0) {
+ nav.e(response.errors[0].message);
+ } else {
+ nav.clearCookie("token");
+ nav.toOpen("/login.htm");
+ }
+ }.bind(this));
break;
default:
nav.w("未找到对应的命令");
diff --git a/src/main/resources/modules/SpringBoot/resources/templates/screen/login.ftl b/src/main/resources/modules/SpringBoot/resources/templates/screen/login.ftl
index fea5e3fc..05ecd2ae 100644
--- a/src/main/resources/modules/SpringBoot/resources/templates/screen/login.ftl
+++ b/src/main/resources/modules/SpringBoot/resources/templates/screen/login.ftl
@@ -110,21 +110,16 @@
this.$refs[formName].validate(function (valid) {
if (valid) {
this.isSubmit = true;
- new Ajax()
- .module("system")
- .target("User")
- .method("login")
- .data(this.form)
- .post(function (response) {
- this.isSubmit = false;
- if (response.errors.length > 0) {
- nav.e(response.errors[0].message);
- } else {
- nav.i("登录成功!", function () {
- nav.toHome();
- });
- }
- }.bind(this));
+ new Ajax("system", "User", "login", this.form).post(function (response) {
+ this.isSubmit = false;
+ if (response.errors.length > 0) {
+ nav.e(response.errors[0].message);
+ } else {
+ nav.i("登录成功!", function () {
+ nav.toHome();
+ });
+ }
+ }.bind(this));
} else {
return false;
}
diff --git a/src/main/resources/modules/SpringBoot/resources/templates/screen/module/mgr.ftl b/src/main/resources/modules/SpringBoot/resources/templates/screen/module/mgr.ftl
index 2e4fe868..d915dfca 100644
--- a/src/main/resources/modules/SpringBoot/resources/templates/screen/module/mgr.ftl
+++ b/src/main/resources/modules/SpringBoot/resources/templates/screen/module/mgr.ftl
@@ -163,7 +163,7 @@
:total="vm.totalCount">
-
+
0) {
- nav.e(response.errors[0].message);
- } else {
- nav.s("删除成功");
- this.onFind();
- }
- }.bind(this))
+ new Ajax(this.module, this.target, "delete", {id: item.id}).post(function (response) {
+ if (response.errors.length > 0) {
+ nav.e(response.errors[0].message);
+ } else {
+ nav.s("删除成功");
+ this.onFind();
+ }
+ }.bind(this))
}.bind(this)).catch(function (action) {
});
diff --git a/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/dept.ftl b/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/dept.ftl
index b4a8f9ff..66a80019 100644
--- a/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/dept.ftl
+++ b/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/dept.ftl
@@ -302,18 +302,14 @@
cancelButtonText: '取消',
type: 'warning'
}).then(function () {
- new Ajax()
- .module(this.module)
- .target(this.target)
- .data({id: item.id})
- .delete(function (response) {
- if (response.errors.length > 0) {
- nav.e(response.errors[0].message);
- } else {
- nav.s("删除成功");
- this.onFind();
- }
- }.bind(this))
+ new Ajax("system", "dept", "delete",{id: item.id}).post((function (response) {
+ if (response.errors.length > 0) {
+ nav.e(response.errors[0].message);
+ } else {
+ nav.s("删除成功");
+ this.onFind();
+ }
+ }.bind(this))
}.bind(this)).catch(function (action) {
});
@@ -345,52 +341,39 @@
return data.deptName.indexOf(value) !== -1;
},
onLoadTree: function () {
- new Ajax()
- .module("system")
- .target("dept")
- .method("tree")
- .data({})
- .post(function (response) {
- if (response.errors.length > 0) {
- nav.e(response.errors[0].message);
- } else {
- this.treeData = response.result;
- }
- }.bind(this))
+ new Ajax("system","dept","tree").post(function (response) {
+ if (response.errors.length > 0) {
+ nav.e(response.errors[0].message);
+ } else {
+ this.treeData = response.result;
+ }
+ }.bind(this))
},
onSave: function () {
this.$refs['form'].validate(function (valid) {
if (valid) {
if (this.form.id) {
- new Ajax()
- .module(this.module)
- .target(this.target)
- .data(this.form)
- .update(function (response) {
- if (response.errors.length > 0) {
- nav.e(response.errors[0].message);
- } else {
- this.onFind();
- this.onLoadTree();
- this.$refs['form'].resetFields();
- this.form.dialog = false;
- }
- }.bind(this))
+ new Ajax("system", "dept").data(this.form).update(function (response) {
+ if (response.errors.length > 0) {
+ nav.e(response.errors[0].message);
+ } else {
+ this.onFind();
+ this.onLoadTree();
+ this.$refs['form'].resetFields();
+ this.form.dialog = false;
+ }
+ }.bind(this))
} else {
- new Ajax()
- .module(this.module)
- .target(this.target)
- .data(this.form)
- .create(function (response) {
- if (response.errors.length > 0) {
- nav.e(response.errors[0].message);
- } else {
- this.onFind();
- this.onLoadTree();
- this.$refs['form'].resetFields();
- this.form.dialog = false;
- }
- }.bind(this))
+ new Ajax("system", "dept").data(this.form).create(function (response) {
+ if (response.errors.length > 0) {
+ nav.e(response.errors[0].message);
+ } else {
+ this.onFind();
+ this.onLoadTree();
+ this.$refs['form'].resetFields();
+ this.form.dialog = false;
+ }
+ }.bind(this))
}
} else {
return false;
diff --git a/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/dict.ftl b/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/dict.ftl
index d4937986..d1908eae 100644
--- a/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/dict.ftl
+++ b/src/main/resources/modules/SpringBoot/resources/templates/screen/module/system/dict.ftl
@@ -131,34 +131,34 @@
:visible.sync="form.dialog">
-
-
-
-
-
-
-
-
-
-
-
-
- 是
- 否
-
-
-
-
+