supplychain/wwwroot/api/contract_attach.ui

97 lines
4.1 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){if(r.ok){var tbl=bricks.getWidgetById('attach_tbl');if(tbl)tbl.render({});self.value=null;}}).catch(function(e){console.error('upload failed',e)})"
}]
},
{
"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')"
},
{
"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)}})"
}
]
}
]
}