feat(credit): 更新客户信息编辑组件功能
- 替换城市输入框为省市区级联选择组件 - 新增步骤下拉选择框用于流程状态管理 - 集成文件选择组件替代原有文件路径输入框 - 实现文件上传和删除功能 - 添加文件列表管理和同步逻辑 - 优化搜索组件中关键词搜索框位置 - 完善查询参数过滤逻辑支持数组和单一值处理
This commit is contained in:
@@ -34,9 +34,9 @@
|
|||||||
</a-button>
|
</a-button>
|
||||||
</a-upload>
|
</a-upload>
|
||||||
<a-upload
|
<a-upload
|
||||||
v-else
|
v-else-if="type == 'image'"
|
||||||
:show-upload-list="false"
|
:show-upload-list="false"
|
||||||
:accept="'image/*,application/*'"
|
:accept="'image/*'"
|
||||||
:customRequest="onUpload"
|
:customRequest="onUpload"
|
||||||
>
|
>
|
||||||
<a-button type="primary" class="ele-btn-icon">
|
<a-button type="primary" class="ele-btn-icon">
|
||||||
@@ -46,6 +46,19 @@
|
|||||||
<span>上传图片</span>
|
<span>上传图片</span>
|
||||||
</a-button>
|
</a-button>
|
||||||
</a-upload>
|
</a-upload>
|
||||||
|
<a-upload
|
||||||
|
v-else
|
||||||
|
:show-upload-list="false"
|
||||||
|
:accept="'image/*,application/*,text/*'"
|
||||||
|
:customRequest="onUpload"
|
||||||
|
>
|
||||||
|
<a-button type="primary" class="ele-btn-icon">
|
||||||
|
<template #icon>
|
||||||
|
<UploadOutlined />
|
||||||
|
</template>
|
||||||
|
<span>上传文件</span>
|
||||||
|
</a-button>
|
||||||
|
</a-upload>
|
||||||
<a-select
|
<a-select
|
||||||
show-search
|
show-search
|
||||||
allow-clear
|
allow-clear
|
||||||
@@ -274,16 +287,36 @@
|
|||||||
// 上传文件
|
// 上传文件
|
||||||
const onUpload = (item) => {
|
const onUpload = (item) => {
|
||||||
const { file } = item;
|
const { file } = item;
|
||||||
if (!file.type.startsWith('image') && props.type != 'video') {
|
if (props.type == 'video') {
|
||||||
message.error('只能选择图片');
|
if (!file.type.startsWith('video')) {
|
||||||
|
message.error('只能选择视频');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (props.type == 'video') {
|
|
||||||
if (file.size / 1024 / 1024 > 100) {
|
if (file.size / 1024 / 1024 > 100) {
|
||||||
message.error('大小不能超过 100MB');
|
message.error('大小不能超过 100MB');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} else if (props.type == 'image') {
|
||||||
|
if (!file.type.startsWith('image')) {
|
||||||
|
message.error('只能选择图片');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (file.size / 1024 / 1024 > 10) {
|
||||||
|
message.error('大小不能超过 10MB');
|
||||||
|
return;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// 默认:允许图片/文档等附件
|
||||||
|
const isAllowed =
|
||||||
|
file.type.startsWith('image') ||
|
||||||
|
file.type.startsWith('application') ||
|
||||||
|
file.type.startsWith('text') ||
|
||||||
|
file.type === 'application/octet-stream' ||
|
||||||
|
file.type === '';
|
||||||
|
if (!isAllowed) {
|
||||||
|
message.error('只能选择图片或文件');
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (file.size / 1024 / 1024 > 10) {
|
if (file.size / 1024 / 1024 > 10) {
|
||||||
message.error('大小不能超过 10MB');
|
message.error('大小不能超过 10MB');
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -16,7 +16,16 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="image-upload-item">
|
<div v-else class="image-upload-item">
|
||||||
<YoutubeOutlined />
|
<a
|
||||||
|
class="file-item"
|
||||||
|
:href="item.url"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
:style="{ width: width + 'px', height: height + 'px' }"
|
||||||
|
>
|
||||||
|
<FileOutlined />
|
||||||
|
<span class="file-name">{{ item.name || guessNameFromUrl(item.url) }}</span>
|
||||||
|
</a>
|
||||||
<a class="image-upload-close" @click="onDeleteItem(index)">
|
<a class="image-upload-close" @click="onDeleteItem(index)">
|
||||||
<CloseOutlined />
|
<CloseOutlined />
|
||||||
</a>
|
</a>
|
||||||
@@ -47,7 +56,7 @@
|
|||||||
import {
|
import {
|
||||||
PlusOutlined,
|
PlusOutlined,
|
||||||
CloseOutlined,
|
CloseOutlined,
|
||||||
YoutubeOutlined
|
FileOutlined
|
||||||
} from '@ant-design/icons-vue';
|
} from '@ant-design/icons-vue';
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import SelectData from './components/select-data.vue';
|
import SelectData from './components/select-data.vue';
|
||||||
@@ -98,6 +107,16 @@
|
|||||||
const onDeleteItem = (index: number) => {
|
const onDeleteItem = (index: number) => {
|
||||||
emit('del', index);
|
emit('del', index);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const guessNameFromUrl = (url: string) => {
|
||||||
|
const cleanUrl = (url?.split('?')[0] ?? '').trim();
|
||||||
|
const last = cleanUrl.split('/').pop() || '';
|
||||||
|
try {
|
||||||
|
return decodeURIComponent(last) || url;
|
||||||
|
} catch {
|
||||||
|
return last || url;
|
||||||
|
}
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.select-picture-btn {
|
.select-picture-btn {
|
||||||
@@ -112,6 +131,21 @@
|
|||||||
.image-upload-item {
|
.image-upload-item {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
.file-item {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
border: 1px dashed var(--grey-7);
|
||||||
|
padding: 0 10px;
|
||||||
|
border-radius: 4px;
|
||||||
|
max-width: 240px;
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
.file-name {
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
.image-upload-close {
|
.image-upload-close {
|
||||||
width: 18px;
|
width: 18px;
|
||||||
height: 18px;
|
height: 18px;
|
||||||
|
|||||||
Reference in New Issue
Block a user