supplychain/wwwroot/api/contract_attach.ui

89 lines
3.8 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 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') %}
{
"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.getWidgetById('attach_tbl');if(tbl)tbl.render({});}}).catch(function(e){console.error('upload failed',e)})"
}]
},
{
"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,
"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": 28},
{"name": "filesize", "title": "(KB)", "type": "str", "uitype": "str", "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')"
},
{
"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='+d.id+'&fiid={{fiid}}',{method:'POST'}).then(function(r){return r.json()}).then(function(r){if(r.widgettype==='Message'){self.render({})}else{alert(r.options.message)}})"
}
]
}
]
}