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": [
{
"widgettype": "HBox",
"widgettype": "Title4",
"options": {
"alignItems": "center",
"marginBottom": "12px"
},
"subwidgets": [
{
"widgettype": "Title4",
"options": {
"fontWeight": "600",
"otext": "合同附件",
"i18n": true
}
},
{
"widgettype": "Filler"
}
]
"fontWeight": "600",
"otext": "合同附件",
"i18n": true,
"marginBottom": "8px"
}
},
{
"widgettype": "VBox",
"id": "drop_zone",
"widgettype": "Form",
"id": "upload_form",
"options": {
"css": "card",
"width": "100%",
"height": "80px",
"padding": "16px",
"bgcolor": "#1E293B",
"border": "2px dashed #475569",
"borderRadius": "8px",
"alignItems": "center",
"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": []
"submit_url": "{{entire_url('/filemgr/upload_file.dspy')}}",
"fields": [
{"name": "folderid", "uitype": "hide", "value": "{{folder}}"},
{"name": "fiid", "uitype": "hide", "value": "{{fiid}}"},
{"name": "upfile", "uitype": "file", "multiple": true, "label": "选择文件"}
],
"buttons": [
{"name": "submit", "label": "上传", "css": "primary"}
]
}
},
{
"widgettype": "Tabular",
@ -111,8 +53,8 @@
"cwidth": {}
},
"fields": [
{"name": "filename", "title": "文件名", "type": "str", "uitype": "str", "label": "文件名", "cwidth": 30},
{"name": "filesize", "title": "大小(bytes)", "type": "int", "uitype": "int", "label": "大小", "cwidth": 10},
{"name": "filename", "title": "文件名", "type": "str", "uitype": "str", "label": "文件名", "cwidth": 28},
{"name": "filesize", "title": "大小(KB)", "type": "str", "uitype": "str", "label": "大小", "cwidth": 10},
{"name": "filetype", "title": "类型", "type": "str", "uitype": "str", "label": "类型", "cwidth": 8}
]
}