From 764e28d1e705b637f60cbe7794816d218bfe93a0 Mon Sep 17 00:00:00 2001 From: wangbing Date: Sat, 25 Apr 2020 23:29:36 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81Ajax=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Former-commit-id: 6cc18a6817d40b5838eb18d458fe616cd41ad7f0 --- .../resources/templates/control/nav.ftl | 41 +++++++++++++++---- 1 file changed, 32 insertions(+), 9 deletions(-) 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 421e861e..95940ef2 100644 --- a/src/main/resources/modules/SpringBoot/resources/templates/control/nav.ftl +++ b/src/main/resources/modules/SpringBoot/resources/templates/control/nav.ftl @@ -154,11 +154,11 @@ return Promise.resolve(rsp); }) }; - function Ajax(module, target, method) { + function Ajax(module, target, method, data) { this.mModule = module; this.mTarget = target; this.mMethod = method; - this.mData = {}; + this.mData = data ? data : {}; this.module = function (module) { this.mModule = module; @@ -177,10 +177,26 @@ return this; }; this.post = function (callback) { - jsonRequest({ - url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod, - data: JSON.stringify(this.mData), - }).then(callback) + switch (this.mMethod) { + case "upload": + case "imports": + return upRequest({ + url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod, + data: this.mData + }).then(callback); + break; + case "template": + return downRequest({ + url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod, + data: JSON.stringify(this.mData) + }).then(callback); + break; + default: + jsonRequest({ + url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod, + data: JSON.stringify(this.mData) + }).then(callback); + } }; this.create = function (callback) { this.mMethod = "create"; @@ -210,21 +226,28 @@ this.mMethod = "template"; return downRequest({ url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod, - data: JSON.stringify(this.mData), + data: JSON.stringify(this.mData) }).then(callback) }; this.imports = function (callback) { this.mMethod = "imports"; return upRequest({ url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod, - data: this.mData, + data: this.mData }).then(callback) }; this.exports = function (callback) { this.mMethod = "exports"; return downRequest({ url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod, - data: JSON.stringify(this.mData), + data: JSON.stringify(this.mData) + }).then(callback) + }; + this.upload = function (callback) { + this.mMethod = "upload"; + return upRequest({ + url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod, + data: this.mData }).then(callback) }; }