97 lines
4.1 KiB
XML
97 lines
4.1 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 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)}})"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|