fix: UiFile-based upload with drag-drop support, download/delete toolbar
This commit is contained in:
parent
07d5173d75
commit
7c0acb5245
@ -6,8 +6,6 @@
|
|||||||
{% set fiid = 'dist_agreement_attach' %}
|
{% set fiid = 'dist_agreement_attach' %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% set folder = ensure_contract_folder(request, contract_id, fiid) %}
|
{% set folder = ensure_contract_folder(request, contract_id, fiid) %}
|
||||||
{% set upload_url = entire_url('contract_upload.dspy') %}
|
|
||||||
{% set list_url = entire_url('contract_attach_list.dspy') %}
|
|
||||||
{% set delete_url = entire_url('contract_attach_delete.dspy') %}
|
{% set delete_url = entire_url('contract_attach_delete.dspy') %}
|
||||||
{
|
{
|
||||||
"widgettype": "VBox",
|
"widgettype": "VBox",
|
||||||
@ -17,13 +15,24 @@
|
|||||||
},
|
},
|
||||||
"subwidgets": [
|
"subwidgets": [
|
||||||
{
|
{
|
||||||
"widgettype": "Title4",
|
"widgettype": "HBox",
|
||||||
"options": {
|
"options": {
|
||||||
"fontWeight": "600",
|
"alignItems": "center",
|
||||||
"otext": "合同附件",
|
"marginBottom": "12px"
|
||||||
"i18n": true,
|
},
|
||||||
"marginBottom": "8px"
|
"subwidgets": [
|
||||||
}
|
{
|
||||||
|
"widgettype": "Title4",
|
||||||
|
"options": {
|
||||||
|
"fontWeight": "600",
|
||||||
|
"otext": "合同附件",
|
||||||
|
"i18n": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"widgettype": "Filler"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"widgettype": "UiFile",
|
"widgettype": "UiFile",
|
||||||
@ -31,14 +40,13 @@
|
|||||||
"options": {
|
"options": {
|
||||||
"name": "upfile",
|
"name": "upfile",
|
||||||
"multiple": true,
|
"multiple": true,
|
||||||
"label": "选择文件(支持多选及拖拽)",
|
"label": "拖拽文件到此处,或点击选择文件"
|
||||||
"cwidth": 30
|
|
||||||
},
|
},
|
||||||
"binds": [{
|
"binds": [{
|
||||||
"wid": "self",
|
"wid": "self",
|
||||||
"event": "changed",
|
"event": "changed",
|
||||||
"actiontype": "script",
|
"actiontype": "script",
|
||||||
"script": "var files=this.value;if(!files||!files.length)return;var fd=new FormData();fd.append('folderid','{{folder}}');fd.append('fiid','{{fiid}}');for(var i=0;i<files.length;i++)fd.append('upfile',files[i]);fetch('{{upload_url}}',{method:'POST',body:fd}).then(function(r){if(r.ok){var tbl=bricks.getWidgetById('attach_tbl');if(tbl)tbl.render({});}}).catch(function(e){console.error('upload failed',e)})"
|
"script": "var files=this.value;if(!files||!files.length)return;var fd=new FormData();fd.append('folderid','{{folder}}');fd.append('fiid','{{fiid}}');for(var i=0;i<files.length;i++)fd.append('upfile',files[i]);var self=this;fetch('{{entire_url('contract_upload.dspy')}}',{method:'POST',body:fd}).then(function(r){if(r.ok){var tbl=bricks.getWidgetById('attach_tbl');if(tbl)tbl.render({});self.value=null;}}).catch(function(e){console.error('upload failed',e)})"
|
||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -48,7 +56,7 @@
|
|||||||
"css": "card",
|
"css": "card",
|
||||||
"width": "100%",
|
"width": "100%",
|
||||||
"height": "auto",
|
"height": "auto",
|
||||||
"data_url": "{{list_url}}?folderid={{folder}}&fiid={{fiid}}",
|
"data_url": "{{entire_url('contract_attach_list.dspy')}}?folderid={{folder}}&fiid={{fiid}}",
|
||||||
"data_method": "GET",
|
"data_method": "GET",
|
||||||
"page_rows": 50,
|
"page_rows": 50,
|
||||||
"record_toolbar": [
|
"record_toolbar": [
|
||||||
@ -61,8 +69,8 @@
|
|||||||
"cwidth": {}
|
"cwidth": {}
|
||||||
},
|
},
|
||||||
"fields": [
|
"fields": [
|
||||||
{"name": "filename", "title": "文件名", "type": "str", "uitype": "str", "label": "文件名", "cwidth": 28},
|
{"name": "filename", "title": "文件名", "type": "str", "uitype": "str", "label": "文件名", "cwidth": 30},
|
||||||
{"name": "filesize", "title": "大小(KB)", "type": "str", "uitype": "str", "label": "大小", "cwidth": 10},
|
{"name": "filesize", "title": "大小(bytes)", "type": "int", "uitype": "int", "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