supplychain/wwwroot/api/contract_attach.ui
yumoqing 3df4e237fc feat: 合同附件支持拖拽上传
drop_zone: 虚线边框拖放区域, 点击选择文件
Form: 隐藏字段 folderid+fiid + file input
Script: dragover/drop 事件处理, 拖入文件自动上传
2026-07-03 16:23:21 +08:00

123 lines
4.7 KiB
XML

{% set contract_id = params_kw.get('contract_id', '') %}
{% set contract_type = params_kw.get('contract_type', 'supply') %}
{% if contract_type == 'supply' %}
{% set fiid = 'supply_contract_attach' %}
{% else %}
{% set fiid = 'dist_agreement_attach' %}
{% endif %}
{% set folder = ensure_contract_folder(request, contract_id, fiid) %}
{
"widgettype": "VBox",
"options": {
"width": "100%",
"padding": "8px"
},
"subwidgets": [
{
"widgettype": "HBox",
"options": {
"alignItems": "center",
"marginBottom": "12px"
},
"subwidgets": [
{
"widgettype": "Title4",
"options": {
"fontWeight": "600",
"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,
"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%",
"height": "auto",
"data_url": "{{entire_url('contract_attach_list.dspy')}}?folderid={{folder}}&fiid={{fiid}}",
"data_method": "GET",
"page_rows": 50,
"row_options": {
"browserfields": {
"exclouded": [],
"cwidth": {}
},
"fields": [
{"name": "filename", "title": "文件名", "type": "str", "uitype": "str", "label": "文件名", "cwidth": 30},
{"name": "filesize", "title": "大小(bytes)", "type": "int", "uitype": "int", "label": "大小", "cwidth": 10},
{"name": "filetype", "title": "类型", "type": "str", "uitype": "str", "label": "类型", "cwidth": 8}
]
}
}
}
]
}