supplychain/wwwroot/api/contract_attach.ui
yumoqing 9cd393c3b2 fix: 合同附件上传后列表不刷新、消息不显示的bug
- 上传后: old_params=null 破环再 render({}) 强制刷新列表
- 上传/删除后: 解析 JSON 响应并用 bricks.widgetBuild() 显示消息
- 删除后同样破环强制刷新
- URL 参数用 encodeURIComponent 防特殊字符问题
- 下载增加无路径时的兜底提示
2026-07-14 12:54:49 +08:00

97 lines
4.5 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{% 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 delete_url = entire_url('contract_attach_delete.dspy') %}
{
"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": "UiFile",
"id": "file_input",
"options": {
"name": "upfile",
"multiple": true,
"label": "拖拽文件到此处,或点击选择文件"
},
"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]);var self=this;fetch('{{entire_url('contract_upload.dspy')}}',{method:'POST',body:fd}).then(function(r){return r.json()}).then(function(r){var msg=r;var tbl=bricks.getWidgetById('attach_tbl');if(tbl){tbl.old_params=null;tbl.render({});}self.value=null;if(msg.widgettype)bricks.widgetBuild(msg).then(function(w){if(w)w.open()});}).catch(function(e){console.error('upload failed',e);alert(': '+e.message);})"
}]
},
{
"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,
"record_toolbar": [
{"name": "download", "label": "", "icon": "{{entire_url('/imgs/download.svg')}}"},
{"name": "delete_attach", "label": "", "icon": "{{entire_url('/imgs/delete.svg')}}"}
],
"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}
]
}
},
"binds": [
{
"wid": "self",
"event": "download",
"actiontype": "script",
"target": "self",
"script": "var d=this.select_row.user_data;if(d&&d.webpath)window.open(d.webpath,'_blank');else alert('')"
},
{
"wid": "self",
"event": "delete_attach",
"actiontype": "script",
"target": "self",
"script": "var d=this.select_row.user_data;if(!d||!d.id)return;if(!confirm('确定删除 '+d.filename+' '))return;var self=this;fetch('{{delete_url}}?id='+encodeURIComponent(d.id)+'&fiid={{fiid}}',{method:'POST'}).then(function(r){return r.json()}).then(function(r){if(r.widgettype==='Message'){self.old_params=null;self.render({});}else if(r.widgettype==='Error'){alert(r.options.message);}else{alert(JSON.stringify(r));}}).catch(function(e){console.error('delete failed',e);alert(': '+e.message);})"
}
]
}
]
}