fix: 附件上传改用 Form submit_url (multipart) + UiFile multiple

Form submit_url 直接POST到 filemgr, 支持multipart文件上传
UiFile multiple: true 浏览器原生支持拖拽
去掉无用的按钮+toolbar
This commit is contained in:
yumoqing 2026-07-03 16:37:26 +08:00
parent 832d0828df
commit 1f06a23fa3

View File

@ -14,86 +14,28 @@
}, },
"subwidgets": [ "subwidgets": [
{ {
"widgettype": "HBox", "widgettype": "Title4",
"options": { "options": {
"alignItems": "center", "fontWeight": "600",
"marginBottom": "12px" "otext": "合同附件",
}, "i18n": true,
"subwidgets": [ "marginBottom": "8px"
{ }
"widgettype": "Title4",
"options": {
"fontWeight": "600",
"otext": "合同附件",
"i18n": true
}
},
{
"widgettype": "Filler"
}
]
}, },
{ {
"widgettype": "VBox", "widgettype": "Form",
"id": "drop_zone", "id": "upload_form",
"options": { "options": {
"css": "card", "submit_url": "{{entire_url('/filemgr/upload_file.dspy')}}",
"width": "100%", "fields": [
"height": "80px", {"name": "folderid", "uitype": "hide", "value": "{{folder}}"},
"padding": "16px", {"name": "fiid", "uitype": "hide", "value": "{{fiid}}"},
"bgcolor": "#1E293B", {"name": "upfile", "uitype": "file", "multiple": true, "label": "选择文件"}
"border": "2px dashed #475569", ],
"borderRadius": "8px", "buttons": [
"alignItems": "center", {"name": "submit", "label": "上传", "css": "primary"}
"justifyContent": "center", ]
"marginBottom": "12px" }
},
"subwidgets": [
{
"widgettype": "Text",
"options": {
"otext": "拖拽文件到此处上传,或点击选择文件",
"i18n": true,
"color": "#94A3B8",
"fontSize": "13px"
}
},
{
"widgettype": "Form",
"id": "upload_form",
"options": {
"fields": [
{"name": "folderid", "uitype": "hide", "value": "{{folder}}"},
{"name": "fiid", "uitype": "hide", "value": "{{fiid}}"},
{"name": "upfile", "uitype": "file", "label": ""}
]
},
"binds": [{
"wid": "self",
"event": "submited",
"actiontype": "urlwidget",
"target": "self",
"options": {
"url": "{{entire_url('/filemgr/upload_file.dspy')}}"
}
}]
}
],
"binds": [{
"wid": "self",
"event": "click",
"actiontype": "method",
"target": "upload_form",
"method": "select_file"
}]
},
{
"widgettype": "Script",
"id": "drop_handler",
"options": {
"script": "var dz=document.querySelector('#drop_zone'); if(dz){dz.addEventListener('dragover',function(e){e.preventDefault();e.stopPropagation();this.style.borderColor='#3B82F6';});dz.addEventListener('dragleave',function(e){e.preventDefault();e.stopPropagation();this.style.borderColor='#475569';});dz.addEventListener('drop',function(e){e.preventDefault();e.stopPropagation();this.style.borderColor='#475569';var dt=e.dataTransfer;if(!dt.files.length)return;var fi=bricks.app.getWidgetById('upload_form');if(fi&&fi.widgets&&fi.widgets[2]){fi.widgets[2].files=dt.files;fi.widgets[2]._onchange();}});}"
},
"binds": []
}, },
{ {
"widgettype": "Tabular", "widgettype": "Tabular",
@ -111,8 +53,8 @@
"cwidth": {} "cwidth": {}
}, },
"fields": [ "fields": [
{"name": "filename", "title": "文件名", "type": "str", "uitype": "str", "label": "文件名", "cwidth": 30}, {"name": "filename", "title": "文件名", "type": "str", "uitype": "str", "label": "文件名", "cwidth": 28},
{"name": "filesize", "title": "大小(bytes)", "type": "int", "uitype": "int", "label": "大小", "cwidth": 10}, {"name": "filesize", "title": "大小(KB)", "type": "str", "uitype": "str", "label": "大小", "cwidth": 10},
{"name": "filetype", "title": "类型", "type": "str", "uitype": "str", "label": "类型", "cwidth": 8} {"name": "filetype", "title": "类型", "type": "str", "uitype": "str", "label": "类型", "cwidth": 8}
] ]
} }