1
0

fix(web): 优化文件上传适配

This commit is contained in:
2024-11-27 18:05:15 +08:00
parent f15bcc2f53
commit aba9a1716c
16 changed files with 318 additions and 114 deletions

View File

@@ -1,5 +1,5 @@
const information = {
debug: false,
debug: true,
// baseUrl: '',
baseUrl: 'http://127.0.0.1:20080',
title: '可信供给中心',
@@ -170,6 +170,13 @@ export const userStateMapping = [
mappingItem('禁用', 'DISABLED', 'bg-danger'),
]
export const confirmationStateMapping = [
mappingItem('草稿', 'DRAFT', 'bg-primary'),
mappingItem('审查中', 'CHECKING', 'bg-warning'),
mappingItem('通过', 'NORMAL', 'bg-success'),
mappingItem('驳回', 'REJECT', 'bg-danger'),
]
function api(method, url) {
return {
method: method,
@@ -211,7 +218,47 @@ export const formInputClearable = {
clearValueOnEmpty: true,
}
export function formInputFileStatic(field, label) {
const formInputFileStaticColumns = [
{
name: 'filename',
label: '文件名',
},
{
type: 'operation',
label: '操作',
width: 140,
buttons: [
{
type: 'action',
label: '预览',
level: 'link',
icon: 'fas fa-eye'
},
{
type: 'action',
label: '下载',
level: 'link',
icon: 'fa fa-download'
}
]
}
]
export function formInputSingleFileStatic(field, label) {
return {
visibleOn: '${detail}',
type: 'control',
label: label,
required: true,
body: {
type: 'table',
source: `\${${field}|asArray}`,
columns: formInputFileStaticColumns,
}
}
}
export function formInputMultiFileStatic(field, label) {
return {
visibleOn: '${detail}',
type: 'input-table',
@@ -219,30 +266,6 @@ export function formInputFileStatic(field, label) {
name: field,
required: true,
resizable: false,
columns: [
{
name: 'filename',
label: '文件名',
},
{
type: 'operation',
label: '操作',
width: 140,
buttons: [
{
type: 'action',
label: '预览',
level: 'link',
icon: 'fas fa-eye'
},
{
type: 'action',
label: '下载',
level: 'link',
icon: 'fa fa-download'
}
]
}
]
columns: formInputFileStaticColumns,
}
}

View File

@@ -3,7 +3,7 @@ import {
apiGet,
apiPost,
formInputClearable,
formInputFileStatic,
formInputMultiFileStatic,
horizontalFormOptions,
inputFileFormItemCommonOptions,
size100MB
@@ -43,15 +43,15 @@ function detailForm() {
name: 'description',
...formInputClearable,
},
formInputFileStatic('evidenceIds', '相关材料'),
formInputMultiFileStatic('evidenceFiles', '相关材料'),
{
visibleOn: '${!detail}',
type: 'input-file',
label: '相关材料',
name: 'evidenceIds',
name: 'evidenceFiles',
multiple: true,
required: true,
extractValue: true,
joinValues: false,
...inputFileFormItemCommonOptions(undefined, size100MB),
}
]
@@ -76,7 +76,6 @@ export function permissionAddDialog() {
}
],
body: {
debug: true,
...detailForm(),
api: apiPost('${base}/confirmation/save'),
data: {
@@ -95,7 +94,6 @@ export function permissionDetailDialog(field = 'id') {
size: 'md',
actions: [],
body: {
debug: true,
...detailForm(),
initApi: apiGet(`\${base}/confirmation/detail/\${${field}}`),
static: true,
@@ -106,3 +104,32 @@ export function permissionDetailDialog(field = 'id') {
}
}
}
export function permissionEditeDialog(field = 'id') {
return {
actionType: 'dialog',
dialog: {
title: '确权申请详情',
size: 'md',
actions: [
{
type: 'reset',
label: '重置',
},
{
type: 'submit',
label: '确定',
level: 'primary',
}
],
body: {
...detailForm(),
api: apiPost('${base}/confirmation/save'),
initApi: apiGet(`\${base}/confirmation/detail/\${${field}}`),
data: {
edit: true,
}
},
}
}
}

View File

@@ -3,7 +3,7 @@ import {
apiGet,
apiPost,
formInputClearable,
formInputFileStatic,
formInputSingleFileStatic,
horizontalFormOptions,
inputFileFormItemCommonOptions,
size1GB,
@@ -12,7 +12,6 @@ import {
function detailForm() {
return {
debug: true,
type: 'form',
...horizontalFormOptions(),
horizontal: {
@@ -87,7 +86,7 @@ function detailForm() {
visibleOn: "${resourceType === 'FILE'}",
type: 'fieldSet',
body: [
formInputFileStatic('file', '数据文件'),
formInputSingleFileStatic('file', '数据文件'),
{
visibleOn: "${!detail}",
type: 'input-file',
@@ -96,10 +95,8 @@ function detailForm() {
name: 'file',
multiple: false,
required: true,
joinValues: false,
...inputFileFormItemCommonOptions('.zip', size1GB),
autoFill: {
fileId: '${value}'
}
},
]
},
@@ -143,29 +140,27 @@ function detailForm() {
visibleOn: "${resourceType === 'HDFS'}",
type: 'fieldSet',
body: [
formInputFileStatic('coreSiteFile', 'core-site.xml'),
formInputSingleFileStatic('coreSiteFile', 'core-site.xml'),
{
visibleOn: "${!detail}",
type: 'input-file',
label: 'core-site.xml',
name: 'coreSiteFile',
multiple: false,
required: true,
joinValues: false,
...inputFileFormItemCommonOptions('.xml'),
autoFill: {
coreSiteFileId: '${value}'
}
},
formInputFileStatic('hdfsSiteFile', 'hdfs-site.xml'),
formInputSingleFileStatic('hdfsSiteFile', 'hdfs-site.xml'),
{
visibleOn: "${!detail}",
type: 'input-file',
label: 'hdfs-site.xml',
name: 'hdfsSiteFile',
multiple: false,
required: true,
joinValues: false,
...inputFileFormItemCommonOptions('.xml'),
autoFill: {
hdfsSiteFileId: '${value}'
}
},
]
},
@@ -285,17 +280,16 @@ function detailForm() {
label: 'JSON格式',
language: 'json',
},
formInputFileStatic('exampleFile', '资源示例'),
formInputSingleFileStatic('exampleFile', '资源示例'),
{
visibleOn: "${!detail}",
type: 'input-file',
label: '资源示例',
name: 'exampleFile',
description: '可以上传用于作为格式示范的样例数据',
multiple: false,
joinValues: false,
...inputFileFormItemCommonOptions(undefined, size500MB),
autoFill: {
exampleFileId: '${value}'
}
},
]
}