mirror of
https://gitee.com/ssssssss-team/magic-boot.git
synced 2025-02-21 02:12:50 +08:00
mb-table 添加 download downloadAll 快捷下载属性
This commit is contained in:
parent
8b64662664
commit
a74b8009d7
26
data/magic-api/api/系统管理/文件管理/下载post.ms
Normal file
26
data/magic-api/api/系统管理/文件管理/下载post.ms
Normal file
@ -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();
|
@ -31,6 +31,13 @@
|
||||
</el-button>
|
||||
</template>
|
||||
</div>
|
||||
<div v-else-if="col.type == 'download'">
|
||||
<a v-for="(url, i) in scope.row[col.field].split(',')" @click="$common.downloadMore(url)" href="javascript:;">
|
||||
{{ url.substring(url.lastIndexOf('/') + 1) }}
|
||||
{{ i != scope.row[col.field].split(',').length - 1 ? ',' : '' }}
|
||||
</a>
|
||||
</div>
|
||||
<a v-else-if="col.type == 'downloadAll'" @click="$common.downloadMore(scope.row[col.field])" href="javascript:;">下载</a>
|
||||
<el-image
|
||||
v-else-if="col.type === 'image'"
|
||||
:src="scope.row[col.field].startsWith('http') ? scope.row[col.field] : $global.baseApi + scope.row[col.field]"
|
||||
|
@ -62,6 +62,20 @@ const formatJson = (list, filterVal) => {
|
||||
}))
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user