You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
2.7 KiB

1 year ago
<template>
1 year ago
<w-dialog ref="dialogRef" :title="$t('re.resources.dialog.attachment.title')" width="900px" :can-maximize="false">
1 year ago
<div class="px-2">
<w-grid
ref="gridRef"
10 months ago
:height="400"
1 year ago
:title="$t('re.resources.dialog.attachment.grid.title')"
selection="multiple"
10 months ago
:config-button="false"
1 year ago
:full-screen-button="false"
:toolbar-configure="{ noIcon: false }"
:toolbar-actions="[
'refresh',
10 months ago
'separator',
{
extend: 'add',
click: () => {
addAttachmentDialogRef.open();
},
},
1 year ago
'remove',
10 months ago
'separator',
1 year ago
{
name: 'download',
label: $t('download'),
10 months ago
icon: 'bi-download',
enableIf: (arg) => {
return arg.selected;
},
click: (arg) => {
download(arg.selected.id);
},
1 year ago
},
]"
:query-form-fields="[]"
:auto-fetch-data="false"
:fetch-data-url="fetchDataUrl + '?' + foreignKey + '=' + foreignValue"
:data-url="dataUrl"
:columns="[
6 months ago
{ width: 120, name: 'id', label: $t('id'), showIf: false },
10 months ago
{
width: '100%',
name: 'name',
label: $t('name'),
format: (value, row) => {
return value;
},
},
{ width: 200, name: 'description', label: $t('description') },
1 year ago
{ width: 100, name: 'lastModifier', label: $t('lastModifier') },
{ width: 120, name: 'lastModifyDate', label: $t('lastModifyDate'), format: Formater.dateOnly() },
]"
></w-grid>
10 months ago
<AddAttachmentDialog
ref="addAttachmentDialogRef"
:foreign-key="foreignKey"
:foreign-value="foreignValue"
@after-add="gridRef.refresh()"
></AddAttachmentDialog>
1 year ago
</div>
</w-dialog>
</template>
<script setup lang="ts">
import { ref, nextTick } from 'vue';
10 months ago
import { Environment, Formater, Downloader } from 'platform-core';
import AddAttachmentDialog from './AddAttachmentDialog.vue';
1 year ago
const props = defineProps({
opener: { type: Object, default: undefined },
fetchDataUrl: { type: String, default: '' },
dataUrl: { type: String, default: '' },
foreignKey: { type: String, default: '' },
foreignValue: { type: String, default: '' },
});
const dialogRef = ref();
const gridRef = ref();
10 months ago
const addAttachmentDialogRef = ref();
1 year ago
10 months ago
const download = (id) => {
Downloader.get(Environment.apiContextPath('/api/system/attachment/download/') + id);
};
1 year ago
10 months ago
const open = () => {
dialogRef.value.show();
1 year ago
nextTick(() => {
gridRef.value.refresh();
});
};
const close = () => {
dialogRef.value.hide();
};
defineExpose({
open,
close,
});
</script>