This commit is contained in:
tanghc
2019-09-02 19:37:22 +08:00
parent 0cafb5829b
commit e47cd0e002
8 changed files with 197 additions and 24 deletions

View File

@@ -92,21 +92,21 @@ function createTreeTable(id, data) {
cols: [[
{field: 'name', title: '参数',width: 200}
,{field: 'val', title: '值', width: 300, templet:function (row) {
var id = currentItem.nameVersion + '-' + row.name;
var requiredTxt = row.required ? 'required lay-verify="required"' : '';
var module = row.module;
var type = row.type == 'file' ? 'file' : 'text';
var attrs = [
'id="' + id + '"'
, 'name="'+row.name+'"'
, 'class="layui-input test-input"'
, 'type="' + type + '"'
, requiredTxt
, 'module="'+module+'"'
];
var id = currentItem.nameVersion + '-' + row.name;
var requiredTxt = row.required ? 'required lay-verify="required"' : '';
var module = row.module;
var type = row.type == 'file' ? 'file' : 'text';
var attrs = [
'id="' + id + '"'
, 'name="'+row.name+'"'
, 'class="layui-input test-input"'
, 'type="' + type + '"'
, requiredTxt
, 'module="'+module+'"'
];
return !row.refs ? '<input ' + attrs.join(' ') + '/>' : '';
}}
return !row.refs ? '<input ' + attrs.join(' ') + '/>' : '';
}}
,{field: 'description', title: '描述'}
]]
});
@@ -138,6 +138,12 @@ function doTest() {
}
});
data.bizContent = JSON.stringify(bizContent);
if (isDownloadRequest(currentItem)) {
data.isDownloadRequest = true;
downloadFile(data);
// window.open()
return;
}
// 确定文件数量,并且知道参数名称
if (uploadFileObjects.length > 0) {
var formData = new FormData();
@@ -151,6 +157,20 @@ function doTest() {
}
}
function isDownloadRequest(currentItem) {
var produces = currentItem.produces;
if (!produces) {
return false;
}
for (var i = 0; i < produces.length; i++) {
var produce = produces[i];
if (produce.indexOf('application/octet-stream') > -1) {
return true;
}
}
return false;
}
function putVal(obj, input) {
if (input.type == 'text') {
obj[input.name] = input.value;
@@ -204,6 +224,16 @@ function postFile(data, formData) {
});
}
function downloadFile(data) {
$('.dl-form').remove();
var url = SopConfig.url + '/sandbox/test';
var form = $('<form class="dl-form"></form>').attr("action", url).attr("method", "get");
for(var key in data) {
form.append($("<input>").attr("type", "hidden").attr("name", key).attr("value", data[key]));
}
form.appendTo('body').submit();
}
function successHandler(resp) {
setReqInfo(resp);
showRespnfo(resp.apiResult);