diff --git a/data/magic-api/api/系统管理/文件管理/下载post.ms b/data/magic-api/api/系统管理/文件管理/下载post.ms new file mode 100644 index 0000000..9c0ec31 --- /dev/null +++ b/data/magic-api/api/系统管理/文件管理/下载post.ms @@ -0,0 +1,26 @@ +{ + "properties" : { }, + "id" : "f9dc93ff77d94016a771456c21774789", + "script" : null, + "groupId" : "fd3d225a1cf141bf9998c4ec4bf4a6ab", + "name" : "下载post", + "createTime" : null, + "updateTime" : 1656055977595, + "lock" : null, + "createBy" : null, + "updateBy" : null, + "path" : "/download", + "method" : "POST", + "parameters" : [ ], + "options" : [ ], + "requestBody" : "", + "headers" : [ ], + "paths" : [ ], + "responseBody" : null, + "description" : null, + "requestBodyDefinition" : null, + "responseBodyDefinition" : null +} +================================ +import '@get:/system/file/download' as download; +return download(); \ No newline at end of file diff --git a/magic-boot-ui/src/components/magic/data/mb-table-column.vue b/magic-boot-ui/src/components/magic/data/mb-table-column.vue index cb6ca13..0436a8c 100644 --- a/magic-boot-ui/src/components/magic/data/mb-table-column.vue +++ b/magic-boot-ui/src/components/magic/data/mb-table-column.vue @@ -31,6 +31,13 @@ +
+ + {{ url.substring(url.lastIndexOf('/') + 1) }} + {{ i != scope.row[col.field].split(',').length - 1 ? ',' : '' }} + +
+ 下载 { })) } +common.$get = (url, data) => request({ url, params: data }) +common.$delete = (url, data) => request({ url, method: 'delete', params: data }) +common.$post = (url, data) => request.post(url, data, { + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + }, + transformRequest: [data => data && Object.keys(data).map(it => encodeURIComponent(it) + '=' + encodeURIComponent(data[it] === null || data[it] === undefined ? '' : data[it])).join('&')] +}) +common.$postJson = (url, data) => request.post(url, JSON.stringify(data), { + headers: { + 'Content-Type': 'application/json' + } +}) + common.renderWhere = (where) => { var newWhere = {} for(var key in where) { @@ -160,6 +174,28 @@ common.getUrl = (url, data) => { return url } +common.downloadMore = (urls, filename) => { + var params = { + urls: encodeURI(urls), + filename: filename || '', + token: getToken() + } + var form = document.createElement("form"); + form.style.display = 'none'; + form.action = global.baseApi + '/system/file/download'; + form.method = 'post'; + document.body.appendChild(form); + for(var key in params){ + var input = document.createElement("input"); + input.type = 'hidden'; + input.name = key; + input.value = params[key]; + form.appendChild(input); + } + form.submit(); + form.remove(); +} + common.download = (urls, filename) => { location.href = common.downloadHref(urls, filename) } diff --git a/magic-boot-ui/src/scripts/globalProperties.js b/magic-boot-ui/src/scripts/globalProperties.js index 611cf1e..6d3bcec 100644 --- a/magic-boot-ui/src/scripts/globalProperties.js +++ b/magic-boot-ui/src/scripts/globalProperties.js @@ -6,19 +6,10 @@ import treeTable from './treeTable' const install = (app) => { app.config.globalProperties.$request = request - app.config.globalProperties.$post = (url, data) => request.post(url, data, { - headers: { - 'Content-Type': 'application/x-www-form-urlencoded' - }, - transformRequest: [data => data && Object.keys(data).map(it => encodeURIComponent(it) + '=' + encodeURIComponent(data[it] === null || data[it] === undefined ? '' : data[it])).join('&')] - }) - app.config.globalProperties.$postJson = (url, data) => request.post(url, JSON.stringify(data), { - headers: { - 'Content-Type': 'application/json' - } - }) - app.config.globalProperties.$get = (url, data) => request({ url, params: data }) - app.config.globalProperties.$delete = (url, data) => request({ url, method: 'delete', params: data }) + app.config.globalProperties.$post = common.$post + app.config.globalProperties.$postJson = common.$postJson + app.config.globalProperties.$get = common.$get + app.config.globalProperties.$delete = common.$delete app.config.globalProperties.$global = global app.config.globalProperties.$common = common app.config.globalProperties.$treeTable = treeTable