|
|
@ -13,6 +13,16 @@
|
|
|
|
headers: {'Content-Type': 'application/json;charset=UTF-8'},
|
|
|
|
headers: {'Content-Type': 'application/json;charset=UTF-8'},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
var uploadService = axios.create({
|
|
|
|
var uploadService = axios.create({
|
|
|
|
|
|
|
|
method: 'post',
|
|
|
|
|
|
|
|
timeout: 30000,
|
|
|
|
|
|
|
|
baseURL: '${context?default("")}',
|
|
|
|
|
|
|
|
headers: {'Content-Type': 'multipart/form-data'},
|
|
|
|
|
|
|
|
onUploadProgress: function (progressEvent) {
|
|
|
|
|
|
|
|
var complete = (progressEvent.loaded / progressEvent.total * 100 | 0) + '%'
|
|
|
|
|
|
|
|
nav.tipShow("上传中(" + complete + ")")
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
var importService = axios.create({
|
|
|
|
method: 'post',
|
|
|
|
method: 'post',
|
|
|
|
timeout: 30000,
|
|
|
|
timeout: 30000,
|
|
|
|
baseURL: '${context?default("")}',
|
|
|
|
baseURL: '${context?default("")}',
|
|
|
@ -64,8 +74,37 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Promise.resolve(rsp);
|
|
|
|
return Promise.resolve(rsp);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
function uploadRequest(data) {
|
|
|
|
|
|
|
|
nav.barShow();
|
|
|
|
|
|
|
|
nav.tipShow("上传中...");
|
|
|
|
|
|
|
|
var fd = new FormData();
|
|
|
|
|
|
|
|
fd.append("file", data.data);
|
|
|
|
|
|
|
|
data.data = fd;
|
|
|
|
|
|
|
|
return uploadService.request(data)
|
|
|
|
|
|
|
|
.then(function (response) {
|
|
|
|
|
|
|
|
nav.tipClose();
|
|
|
|
|
|
|
|
if (response.data.errors && response.data.errors.length == 0) {
|
|
|
|
|
|
|
|
nav.barFinish();
|
|
|
|
|
|
|
|
} else if (response.data.errors && response.data.errors.length > 0) {
|
|
|
|
|
|
|
|
nav.barError();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
response.data = {errors: [{message: '服务器响应错误'}]};
|
|
|
|
|
|
|
|
nav.barError();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return Promise.resolve(response.data);
|
|
|
|
|
|
|
|
}, function (error) {
|
|
|
|
|
|
|
|
nav.barError();
|
|
|
|
|
|
|
|
const rsp = {errors: []};
|
|
|
|
|
|
|
|
if (!error.response) {
|
|
|
|
|
|
|
|
rsp.errors.push({message: error.message});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
rsp.errors.push(handleError(error.response.status));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function upRequest(data) {
|
|
|
|
return Promise.resolve(rsp);
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
function importRequest(data) {
|
|
|
|
nav.barShow();
|
|
|
|
nav.barShow();
|
|
|
|
nav.tipShow("上传中...");
|
|
|
|
nav.tipShow("上传中...");
|
|
|
|
var fd = new FormData();
|
|
|
|
var fd = new FormData();
|
|
|
@ -179,8 +218,13 @@
|
|
|
|
this.post = function (callback) {
|
|
|
|
this.post = function (callback) {
|
|
|
|
switch (this.mMethod) {
|
|
|
|
switch (this.mMethod) {
|
|
|
|
case "upload":
|
|
|
|
case "upload":
|
|
|
|
|
|
|
|
return uploadRequest({
|
|
|
|
|
|
|
|
url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod,
|
|
|
|
|
|
|
|
data: this.mData
|
|
|
|
|
|
|
|
}).then(callback);
|
|
|
|
|
|
|
|
break;
|
|
|
|
case "imports":
|
|
|
|
case "imports":
|
|
|
|
return upRequest({
|
|
|
|
return importRequest({
|
|
|
|
url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod,
|
|
|
|
url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod,
|
|
|
|
data: this.mData
|
|
|
|
data: this.mData
|
|
|
|
}).then(callback);
|
|
|
|
}).then(callback);
|
|
|
@ -231,7 +275,7 @@
|
|
|
|
};
|
|
|
|
};
|
|
|
|
this.imports = function (callback) {
|
|
|
|
this.imports = function (callback) {
|
|
|
|
this.mMethod = "imports";
|
|
|
|
this.mMethod = "imports";
|
|
|
|
return upRequest({
|
|
|
|
return importRequest({
|
|
|
|
url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod,
|
|
|
|
url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod,
|
|
|
|
data: this.mData
|
|
|
|
data: this.mData
|
|
|
|
}).then(callback)
|
|
|
|
}).then(callback)
|
|
|
@ -245,7 +289,7 @@
|
|
|
|
};
|
|
|
|
};
|
|
|
|
this.upload = function (callback) {
|
|
|
|
this.upload = function (callback) {
|
|
|
|
this.mMethod = "upload";
|
|
|
|
this.mMethod = "upload";
|
|
|
|
return upRequest({
|
|
|
|
return uploadRequest({
|
|
|
|
url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod,
|
|
|
|
url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod,
|
|
|
|
data: this.mData
|
|
|
|
data: this.mData
|
|
|
|
}).then(callback)
|
|
|
|
}).then(callback)
|
|
|
@ -282,11 +326,7 @@
|
|
|
|
this.select = select;
|
|
|
|
this.select = select;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
onTemplate: function () {
|
|
|
|
onTemplate: function () {
|
|
|
|
new Ajax()
|
|
|
|
new Ajax(this.module, this.target, "template").post(function (response) {
|
|
|
|
.module(this.module)
|
|
|
|
|
|
|
|
.target(this.target)
|
|
|
|
|
|
|
|
.method("template")
|
|
|
|
|
|
|
|
.template(function (response) {
|
|
|
|
|
|
|
|
if (response.errors.length > 0) {
|
|
|
|
if (response.errors.length > 0) {
|
|
|
|
nav.e(response.errors[0].message);
|
|
|
|
nav.e(response.errors[0].message);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -294,11 +334,7 @@
|
|
|
|
},
|
|
|
|
},
|
|
|
|
onImport: function (item) {
|
|
|
|
onImport: function (item) {
|
|
|
|
utils.selectFile(function (files) {
|
|
|
|
utils.selectFile(function (files) {
|
|
|
|
new Ajax()
|
|
|
|
new Ajax(this.module, this.target, "imports", files[0]).post(function (response) {
|
|
|
|
.module(this.module)
|
|
|
|
|
|
|
|
.target(this.target)
|
|
|
|
|
|
|
|
.data(files[0])
|
|
|
|
|
|
|
|
.imports(function (response) {
|
|
|
|
|
|
|
|
if (response.errors.length > 0) {
|
|
|
|
if (response.errors.length > 0) {
|
|
|
|
nav.e(response.errors[0].message);
|
|
|
|
nav.e(response.errors[0].message);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -306,11 +342,7 @@
|
|
|
|
}.bind(this))
|
|
|
|
}.bind(this))
|
|
|
|
},
|
|
|
|
},
|
|
|
|
onExport: function () {
|
|
|
|
onExport: function () {
|
|
|
|
new Ajax()
|
|
|
|
new Ajax(this.module, this.target, "exports", this.vm).post(function (response) {
|
|
|
|
.module(this.module)
|
|
|
|
|
|
|
|
.target(this.target)
|
|
|
|
|
|
|
|
.data(this.vm)
|
|
|
|
|
|
|
|
.exports(function (response) {
|
|
|
|
|
|
|
|
if (response.errors.length > 0) {
|
|
|
|
if (response.errors.length > 0) {
|
|
|
|
nav.e(response.errors[0].message);
|
|
|
|
nav.e(response.errors[0].message);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -320,11 +352,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()
|
|
|
|
new Ajax(this.module, this.target, "update", this.form).post(function (response) {
|
|
|
|
.module(this.module)
|
|
|
|
|
|
|
|
.target(this.target)
|
|
|
|
|
|
|
|
.data(this.form)
|
|
|
|
|
|
|
|
.update(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 {
|
|
|
@ -334,11 +362,7 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}.bind(this))
|
|
|
|
}.bind(this))
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
new Ajax()
|
|
|
|
new Ajax(this.module, this.target, "create", this.form).post(function (response) {
|
|
|
|
.module(this.module)
|
|
|
|
|
|
|
|
.target(this.target)
|
|
|
|
|
|
|
|
.data(this.form)
|
|
|
|
|
|
|
|
.create(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 {
|
|
|
@ -354,11 +378,7 @@
|
|
|
|
}.bind(this));
|
|
|
|
}.bind(this));
|
|
|
|
},
|
|
|
|
},
|
|
|
|
onFind: function () {
|
|
|
|
onFind: function () {
|
|
|
|
new Ajax()
|
|
|
|
new Ajax(this.module, this.target, "find", this.vm).post(function (response) {
|
|
|
|
.module(this.module)
|
|
|
|
|
|
|
|
.target(this.target)
|
|
|
|
|
|
|
|
.data(this.vm)
|
|
|
|
|
|
|
|
.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 {
|
|
|
@ -373,11 +393,7 @@
|
|
|
|
cancelButtonText: '取消',
|
|
|
|
cancelButtonText: '取消',
|
|
|
|
type: 'warning'
|
|
|
|
type: 'warning'
|
|
|
|
}).then(function () {
|
|
|
|
}).then(function () {
|
|
|
|
new Ajax()
|
|
|
|
new Ajax(this.module, this.target, "delete", {id: item.id}).post(function (response) {
|
|
|
|
.module(this.module)
|
|
|
|
|
|
|
|
.target(this.target)
|
|
|
|
|
|
|
|
.data({id: item.id})
|
|
|
|
|
|
|
|
.delete(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 {
|
|
|
@ -400,11 +416,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()
|
|
|
|
new Ajax(this.module, this.target, "delete", {id: obj.id}).post(function (response) {
|
|
|
|
.module(this.module)
|
|
|
|
|
|
|
|
.target(this.target)
|
|
|
|
|
|
|
|
.data({id: obj.id})
|
|
|
|
|
|
|
|
.delete(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 {
|
|
|
|