fix: 附件上传改用 Form submit_url (multipart) + UiFile multiple
Form submit_url 直接POST到 filemgr, 支持multipart文件上传 UiFile multiple: true 浏览器原生支持拖拽 去掉无用的按钮+toolbar
This commit is contained in:
parent
832d0828df
commit
1f06a23fa3
@ -12,88 +12,30 @@
|
|||||||
"width": "100%",
|
"width": "100%",
|
||||||
"padding": "8px"
|
"padding": "8px"
|
||||||
},
|
},
|
||||||
"subwidgets": [
|
|
||||||
{
|
|
||||||
"widgettype": "HBox",
|
|
||||||
"options": {
|
|
||||||
"alignItems": "center",
|
|
||||||
"marginBottom": "12px"
|
|
||||||
},
|
|
||||||
"subwidgets": [
|
"subwidgets": [
|
||||||
{
|
{
|
||||||
"widgettype": "Title4",
|
"widgettype": "Title4",
|
||||||
"options": {
|
"options": {
|
||||||
"fontWeight": "600",
|
"fontWeight": "600",
|
||||||
"otext": "合同附件",
|
"otext": "合同附件",
|
||||||
"i18n": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"widgettype": "Filler"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"widgettype": "VBox",
|
|
||||||
"id": "drop_zone",
|
|
||||||
"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,
|
"i18n": true,
|
||||||
"color": "#94A3B8",
|
"marginBottom": "8px"
|
||||||
"fontSize": "13px"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"widgettype": "Form",
|
"widgettype": "Form",
|
||||||
"id": "upload_form",
|
"id": "upload_form",
|
||||||
"options": {
|
"options": {
|
||||||
|
"submit_url": "{{entire_url('/filemgr/upload_file.dspy')}}",
|
||||||
"fields": [
|
"fields": [
|
||||||
{"name": "folderid", "uitype": "hide", "value": "{{folder}}"},
|
{"name": "folderid", "uitype": "hide", "value": "{{folder}}"},
|
||||||
{"name": "fiid", "uitype": "hide", "value": "{{fiid}}"},
|
{"name": "fiid", "uitype": "hide", "value": "{{fiid}}"},
|
||||||
{"name": "upfile", "uitype": "file", "label": ""}
|
{"name": "upfile", "uitype": "file", "multiple": true, "label": "选择文件"}
|
||||||
]
|
|
||||||
},
|
|
||||||
"binds": [{
|
|
||||||
"wid": "self",
|
|
||||||
"event": "submited",
|
|
||||||
"actiontype": "urlwidget",
|
|
||||||
"target": "self",
|
|
||||||
"options": {
|
|
||||||
"url": "{{entire_url('/filemgr/upload_file.dspy')}}"
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
],
|
],
|
||||||
"binds": [{
|
"buttons": [
|
||||||
"wid": "self",
|
{"name": "submit", "label": "上传", "css": "primary"}
|
||||||
"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}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user