提交 0a918a66 编写于 作者: RedPig97's avatar RedPig97

update: 更新

上级 7cde0413
...@@ -24,8 +24,10 @@ ...@@ -24,8 +24,10 @@
{{/if}} {{/if}}
{{#eq item.psEditor.editorType "PICTURE"}} {{#eq item.psEditor.editorType "PICTURE"}}
accept='image/*' accept='image/*'
listType="picture-card"
{{/eq}} {{/eq}}
{{#eq item.psEditor.editorType "PICTURE_ONE"}} {{#eq item.psEditor.editorType "PICTURE_ONE"}}
accept='image/*' accept='image/*'
listType="picture-card"
{{/eq}} {{/eq}}
@editorEvent="handleEditorEvent"/> @editorEvent="handleEditorEvent"/>
<script setup lang="ts"> <script setup lang="ts">
import { getDownloadUrl, getRequestingHeader, getUploadUrl, IActionParam, IParam } from "@ibiz-core"; import { getDownloadUrl, getRequestingHeader, getUploadUrl, IActionParam, IParam } from "@ibiz-core";
import { UploadOutlined, PlusOutlined } from '@ant-design/icons-vue';
import { ref, Ref } from "vue"; import { ref, Ref } from "vue";
interface UploadProps { interface UploadProps {
/** /**
...@@ -52,6 +53,13 @@ interface UploadProps { ...@@ -52,6 +53,13 @@ interface UploadProps {
*/ */
limit: number; limit: number;
/**
* 文件列表样式
*
* @type {boolean}
*/
listType: string;
/** /**
* 按钮提示信息 * 按钮提示信息
* *
...@@ -82,11 +90,12 @@ const props = withDefaults(defineProps<UploadProps>(), { ...@@ -82,11 +90,12 @@ const props = withDefaults(defineProps<UploadProps>(), {
disabled: false, disabled: false,
readonly: false, readonly: false,
method: 'post', method: 'post',
multiple: true, multiple: false,
showUploadList: true, showUploadList: true,
tooltip: '点击上传', tooltip: '点击上传',
accept:"*", accept:"*",
limit: 999, limit: 999,
listType: 'text',
}); });
const emit = defineEmits<EditorEmit>(); const emit = defineEmits<EditorEmit>();
const uploadUrl = getUploadUrl(); const uploadUrl = getUploadUrl();
...@@ -95,12 +104,18 @@ const headers = getRequestingHeader(); ...@@ -95,12 +104,18 @@ const headers = getRequestingHeader();
const fileList: Ref<IParam[]> = ref([]) const fileList: Ref<IParam[]> = ref([])
const previewFile = (file: IParam) => { const previewFile = (file: IParam) => {
//todo //todo
} }
const onChange = (value: number) => { const onChange = ($event: any) => {
if($event.fileList.length > props.limit) {
console.log(`当前限制选择 ${props.limit} 个文件, 共选择了 ${$event.fileList.length} 个文件`);
return;
}
fileList.value = $event.fileList;
emit("editorEvent", { emit("editorEvent", {
tag: props.name, tag: props.name,
action: "valueChange", action: "valueChange",
data: value, data: $event,
}); });
}; };
</script> </script>
...@@ -108,20 +123,26 @@ const onChange = (value: number) => { ...@@ -108,20 +123,26 @@ const onChange = (value: number) => {
<template> <template>
<div :class="['app-editor-container', `app-upload-${name}`]"> <div :class="['app-editor-container', `app-upload-${name}`]">
<a-upload <a-upload
v-model:fileList="fileList"
:class="{'ant-upload--limit': fileList.length == limit}"
:action="uploadUrl" :action="uploadUrl"
:method="method" :method="method"
:accept="accept" :accept="accept"
v-model:fileList="fileList"
:headers="headers" :headers="headers"
:multiple="multiple" :multiple="multiple"
:previewFile="previewFile" :previewFile="previewFile"
:showUploadList="showUploadList" :showUploadList="showUploadList"
:list-type="listType"
:disabled="disabled || readonly" :disabled="disabled || readonly"
@change="onChange"> @change="onChange">
<a-button> <a-button v-if="Object.is(listType,'text')">
<upload-outlined></upload-outlined> <upload-outlined></upload-outlined>
{{tooltip}} \{{tooltip}}
</a-button> </a-button>
<div v-else>
<plus-outlined />
<div class="ant-upload-text">\{{tooltip}}</div>
</div>
</a-upload> </a-upload>
</div> </div>
</template> </template>
...@@ -130,5 +151,13 @@ const onChange = (value: number) => { ...@@ -130,5 +151,13 @@ const onChange = (value: number) => {
.app-editor-container { .app-editor-container {
width: 100%; width: 100%;
height: 100%; height: 100%;
text-align: left;
}
.app-editor-container .ant-upload--limit .ant-upload-select-picture-card {
display: none;
}
.ant-upload-select-picture-card .ant-upload-text {
margin-top: 8px;
color: #666;
} }
</style> </style>
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册