From 3df4e237fcd6b5ff88e394a5fe3d3b4e7e169dd9 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Fri, 3 Jul 2026 16:23:21 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=90=88=E5=90=8C=E9=99=84=E4=BB=B6?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=8B=96=E6=8B=BD=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit drop_zone: 虚线边框拖放区域, 点击选择文件 Form: 隐藏字段 folderid+fiid + file input Script: dragover/drop 事件处理, 拖入文件自动上传 --- wwwroot/api/contract_attach.ui | 87 ++++++++++++++++++++++++---------- 1 file changed, 63 insertions(+), 24 deletions(-) diff --git a/wwwroot/api/contract_attach.ui b/wwwroot/api/contract_attach.ui index be8a27d..05cd319 100644 --- a/wwwroot/api/contract_attach.ui +++ b/wwwroot/api/contract_attach.ui @@ -30,35 +30,74 @@ }, { "widgettype": "Filler" - }, - { - "widgettype": "Button", - "options": { - "label": "上传附件", - "css": "primary", - "borderRadius": "6px", - "padding": "4px 12px" - }, - "binds": [{ - "wid": "self", - "event": "click", - "actiontype": "urlwidget", - "target": "PopupWindow", - "popup_options": { - "title": "上传附件", - "width": "450px", - "height": "200px", - "dismiss_events": ["cancel"] - }, - "options": { - "url": "{{entire_url('/filemgr/upload_file.ui')}}?id={{folder}}&fiid={{fiid}}" - } - }] } ] }, + { + "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, + "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", + "id": "attach_tbl", "options": { "css": "card", "width": "100%",