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}'
}
},
]
}

View File

@@ -19,6 +19,9 @@ export function resourceList() {
...resourceAddDialog()
},
],
rowSelection: {
disableOn: '${confirmationId}',
},
columns: [
{
label: '名称',
@@ -57,6 +60,7 @@ export function resourceList() {
trigger: 'hover',
buttons: [
{
disabledOn: '${confirmationId}',
type: 'action',
label: '编辑',
level: 'link',
@@ -65,7 +69,7 @@ export function resourceList() {
{
disabledOn: '${confirmationId}',
type: 'action',
label: "${IF(confirmationId, '删除(确权中)', '删除')}",
label: "删除",
confirmTitle: '确认删除',
confirmText: '确认删除名称为「${name}」的数据资源吗?',
actionType: 'ajax',

View File

@@ -1,5 +1,16 @@
import {apiGet, crudCommonOptions, providerOnly, userOnly} from "../../components/constants.js";
import {permissionAddDialog, permissionDetailDialog} from "../../components/permission/dialog-permission.js";
import {
apiGet,
confirmationStateMapping,
crudCommonOptions,
mappingField,
providerOnly,
userOnly
} from "../../components/constants.js";
import {
permissionAddDialog,
permissionDetailDialog,
permissionEditeDialog
} from "../../components/permission/dialog-permission.js";
export function tabPermissions() {
return {
@@ -37,6 +48,12 @@ export function tabPermissions() {
label: '描述',
name: 'description',
},
{
label: '状态',
width: 80,
align: 'center',
...mappingField('state', confirmationStateMapping)
},
{
label: '创建时间',
width: 150,
@@ -58,9 +75,49 @@ export function tabPermissions() {
...permissionDetailDialog(),
},
{
visibleOn: "${state === 'CHECKING'}",
type: 'action',
label: '编辑',
label: '撤销',
level: 'link',
confirmTitle: '确认撤销',
confirmText: '确认撤销名称为「${name}」的确权申请吗?',
actionType: 'ajax',
api: apiGet('${base}/confirmation/retract/${id}'),
},
{
visibleOn: "${state === 'DRAFT' || state === 'REJECT'}",
type: 'action',
label: '提交',
level: 'link',
confirmTitle: '确认提交',
confirmText: '确认提交名称为「${name}」的确权申请吗?',
actionType: 'ajax',
api: apiGet('${base}/confirmation/submit/${id}'),
},
{
type: 'dropdown-button',
level: 'link',
icon: 'fa fa-ellipsis-h',
hideCaret: true,
trigger: 'hover',
buttons: [
{
disabledOn: "${state === 'CHECKING'}",
type: 'action',
label: '编辑',
level: 'link',
...permissionEditeDialog(),
},
{
disabledOn: "${state === 'CHECKING'}",
type: 'action',
label: "删除",
confirmTitle: '确认删除',
confirmText: '确认删除名称为「${name}」的确权申请吗?',
actionType: 'ajax',
api: apiGet('${base}/confirmation/remove/${id}'),
},
]
},
]
},