supplychain/wwwroot/api/contract_attach.ui

68 lines
2.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) %}
{% set upload_url = entire_url('/filemgr/upload_file.dspy') %}
{% set list_url = entire_url('contract_attach_list.dspy') %}
{
"widgettype": "VBox",
"options": {
"width": "100%",
"padding": "8px"
},
"subwidgets": [
{
"widgettype": "Title4",
"options": {
"fontWeight": "600",
"otext": "合同附件",
"i18n": true,
"marginBottom": "8px"
}
},
{
"widgettype": "UiFile",
"id": "file_input",
"options": {
"name": "upfile",
"multiple": true,
"label": "选择文件(支持多选及拖拽)",
"cwidth": 30
},
"binds": [{
"wid": "self",
"event": "changed",
"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.app.getWidgetById('attach_tbl');if(tbl)tbl.render({});}else{r.text().then(function(t){bricks.app.show_error('上传失败',t)})}}).catch(function(e){bricks.app.show_error('上传失败',e.message)})"
}]
},
{
"widgettype": "Tabular",
"id": "attach_tbl",
"options": {
"css": "card",
"width": "100%",
"height": "auto",
"data_url": "{{list_url}}?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": 28},
{"name": "filesize", "title": "(KB)", "type": "str", "uitype": "str", "label": "", "cwidth": 10},
{"name": "filetype", "title": "", "type": "str", "uitype": "str", "label": "", "cwidth": 8}
]
}
}
}
]
}