Files
gzth/preview_easy/static/src/xml/preview_many2one.xml
T
2025-06-20 15:00:54 +08:00

94 lines
4.2 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.
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-name="preview_easy.Many2OneField">
<t t-if="props.readonly">
<t t-call="preview_easy.Many2OneFieldPreview"/>
</t>
<t t-else="">
<!-- 如果存在文件显示预览按钮,如果不存在文件,显示上传选择按钮 -->
<t t-if="resId">
<div class="oe_add">
<t t-call="preview_easy.Many2OneFieldPreview"/>
<FileInput
acceptedFileExtensions="props.acceptedFileExtensions"
multiUpload="true"
onUpload.bind="onFileUploaded"
resModel="props.record.resModel"
resId="props.record.resId or 0"
>
<button class="btn btn-secondary o_attach" data-tooltip="Attach">
<span class="fa fa-paperclip" aria-label="Attach"/>
<t t-esc="uploadText"/>
</button>
</FileInput>
<button t-if="documentsInstalled and props.showSelectBtn" class="btn btn-secondary o_attach" t-on-click="onExternalBtnClick" data-tooltip="Attach">
<i class="fa fa-folder-open-o"/>
选择文件
</button>
</div>
</t>
<t t-else="">
<div class="oe_add">
<FileInput
acceptedFileExtensions="props.acceptedFileExtensions"
multiUpload="true"
onUpload.bind="onFileUploaded"
resModel="props.record.resModel"
resId="props.record.resId or 0"
>
<button class="btn btn-secondary o_attach" data-tooltip="Attach">
<span class="fa fa-paperclip" aria-label="Attach"/>
<t t-esc="uploadText"/>
</button>
</FileInput>
<button t-if="documentsInstalled and props.showSelectBtn" class="btn btn-secondary o_attach" t-on-click="onExternalBtnClick" data-tooltip="Attach">
<i class="fa fa-folder-open-o"/>
选择文件
</button>
</div>
</t>
</t>
</t>
<t t-name="preview_easy.Many2OneFieldPreview" owl="1">
<t t-set="editable" t-value="!props.readonly"/>
<t t-set="file" t-value="getFile()"/>
<t t-if="file and file.name">
<!-- 预览按钮 -->
<t t-if="props.previewType and props.previewType === 'button'">
<button class="btn btn-secondary o_attach" t-on-click.stop="() => this.preview_Obj()" data-tooltip="Attach">
<i class="fa fa-eye"/>
<span t-if="props.previewString" t-out="props.previewString"/>
<span t-else="" t-out="'预览文件'"/>
</button>
</t>
<t t-else="">
<div t-attf-class="o_attachment o_attachment_many2many #{ editable ? 'o_attachment_editable' : '' } #{upload ? 'o_attachment_uploading' : ''}" t-att-title="file.name">
<div class="o_attachment_wrap">
<t t-set="ext" t-value="getExtension(file)"/>
<t t-set="url" t-value="getUrl(file.id)"/>
<div class="o_image_box float-start" t-att-data-tooltip="'Preview ' + file.name">
<span class="o_image o_hover" t-on-click.stop="() => this.preview_Obj(file.id,file.name)" t-att-data-mimetype="file.mimetype" t-att-data-ext="ext" role="img"/>
</div>
<div class="caption">
<a class="ml4" t-att-data-tooltip="'Download ' + file.name" t-att-href="getUrl(file.id)"><t t-esc='file.name'/></a>
</div>
<div class="caption small">
<a class="ml4 small text-uppercase" t-att-href="getUrl(file.id)"><b><t t-esc='ext'/></b></a>
<div t-if="editable" class="progress o_attachment_progress_bar">
<div class="progress-bar progress-bar-striped active" style="width: 100%">Uploading</div>
</div>
</div>
<div class="o_attachment_uploaded"><i class="text-success fa fa-check" role="img" aria-label="Uploaded" title="Uploaded"/></div>
<div t-if="editable" class="o_attachment_delete" t-on-click.stop="() => this.onFileRemove(file.id)"><span class="text-white" role="img" aria-label="Delete" title="Delete">×</span></div>
</div>
</div>
</t>
</t>
</t>
</templates>