Commit 1b27bb69 by zhangxw

过户资料样式修改

1 parent ab4addd3
......@@ -24,17 +24,17 @@
</div>
</div>
<div class="mb-12"></div>
<title-divider title="新车主身份证照片"></title-divider>
<a-image-preview-group>
<a-image :width="120" v-for="image in auctionOrder.newOwnerIdCard" :src="image.url" :key="image.uid"/>
</a-image-preview-group>
<div class="mb-12"></div>
<title-divider title="新车牌号"></title-divider>
<a-descriptions v-if="auctionOrder" :column="3" size="small" class="mt-16">
<a-descriptions-item label="车牌号码" name="newPlateNumber">
{{ auctionOrder.newPlateNumber }}
</a-descriptions-item>
</a-descriptions>
<div class="mb-12"></div>
<title-divider title="新车主身份证照片"></title-divider>
<a-image-preview-group>
<a-image :width="120" v-for="image in auctionOrder.newOwnerIdCard" :src="image.url" :key="image.uid"/>
</a-image-preview-group>
<a-spin :spinning="submitted">
<a-form v-if="formState" :model="formState" :label-col="labelCol" :wrapper-col="wrapperCol" ref="formRef">
<!-- <a-form-item label="审核历史" name="auditState">-->
......
......@@ -13,27 +13,27 @@
<div v-if="auctionOrder.transferInvoice && auctionOrder.transferInvoice.length > 0" class="file-list">
<div v-for="file in auctionOrder.transferInvoice" :key="file.uid" class="file-card">
<div class="file-info">
<div class="file-icon">PDF</div>
<div class="file-meta">
<div class="file-name">{{ file.name || '过户发票.pdf' }}</div>
<div class="file-extra">{{ file.size || '' }} · 上传时间 {{ file.uploadTime || '' }}</div>
<div class="file-name">文件名称:{{ file.name || '过户发票.pdf' }}</div>
<div class="file-extra">文件大小:{{ formatFileSize(file.size) || '' }}</div>
<div class="file-extra">上传日期 {{ file.lastModifiedDate || file.uploadTime || '' }}</div>
</div>
</div>
<a-button type="default" size="small" @click="downloadFile(file)">下载</a-button>
<div class="download-btn" @click="downloadFile(file)">下载</div>
</div>
</div>
<div class="mb-12"></div>
<title-divider title="新车主身份证照片"></title-divider>
<a-image-preview-group>
<a-image :width="120" v-for="image in auctionOrder.ownerIdCard" :src="image.url" :key="image.uid"/>
</a-image-preview-group>
<div class="mb-12"></div>
<title-divider title="新车牌号"></title-divider>
<a-descriptions v-if="auctionOrder" :column="3" size="small" class="mt-16">
<a-descriptions-item label="车牌号码" name="newPlateNumber">
{{ auctionOrder.newPlateNumber }}
</a-descriptions-item>
</a-descriptions>
<div class="mb-12"></div>
<title-divider title="新车主身份证照片"></title-divider>
<a-image-preview-group>
<a-image :width="120" v-for="image in auctionOrder.ownerIdCard" :src="image.url" :key="image.uid"/>
</a-image-preview-group>
</template>
<script lang="ts">
import {Component, Prop, Vue} from "vue-facing-decorator";
......@@ -55,8 +55,8 @@ export default class TransferAuctionOrder extends Vue {
uid: 'mock-transfer-invoice-1',
url: 'https://example.com/transfer-invoice.pdf',
name: '过户发票_京A12345.pdf',
size: '2.1 MB',
uploadTime: '2026-07-28 14:32'
size: 2202009,
lastModifiedDate: '2026-07-28 14:32'
}
];
this.auctionOrder.ownerIdCard = [
......@@ -72,16 +72,26 @@ export default class TransferAuctionOrder extends Vue {
// TODO: 假数据结束
}
downloadFile(file: any): void {
if (!file || !file.url) {
return;
formatFileSize(bytes: number): string {
if (!bytes || bytes === 0) return "";
const kb = bytes / 1024;
const mb = bytes / 1024 / 1024;
if (bytes < 1024) {
return `${bytes} B`;
}
else if (bytes < 1024 * 1024) {
return `${kb.toFixed(2)} KB`;
}
else {
return `${mb.toFixed(2)} MB`;
}
const link = document.createElement('a');
link.href = file.url;
link.download = file.name || '过户发票.pdf';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
downloadFile(file: any): void {
if (!file || !file.url) return;
window.open(file.url, "_blank");
}
}
......@@ -105,15 +115,11 @@ export default class TransferAuctionOrder extends Vue {
flex-direction: column;
gap: 12px;
margin-bottom: 16px;
background: #F7F8F9;
border-radius: 2px;
width: auto;
.file-card {
display: flex;
justify-content: space-between;
align-items: center;
padding: 12px 16px;
border: 1px solid #E1E3E6;
border-radius: 8px;
background: #fff;
.file-info {
display: flex;
......@@ -149,6 +155,11 @@ export default class TransferAuctionOrder extends Vue {
}
}
}
.download-btn {
margin-top: 20px;
cursor: pointer;
color: #1956FE;
}
}
}
</style>
......@@ -33,11 +33,18 @@
:max-size="10"
upload-text="上传图片"
directory="auction/transfer"
:slot-mode="true"
:slot-titles="['主页', '副页']"
@change="handleImageChange('vehicleLicense', $event)"
/>
</a-form-item>
<div class="mb-12"></div>
<title-divider title="新车牌号"></title-divider>
<a-form-item label="车牌号码" name="newPlateNumber">
<a-input v-model:value="formState.newPlateNumber" placeholder="请输入新车牌号" style="width: 300px;" />
</a-form-item>
<div class="mb-12"></div>
<title-divider title="新车主身份证照片"></title-divider>
<a-form-item label="">
<transfer-image-upload
......@@ -46,15 +53,11 @@
:max-size="10"
upload-text="上传图片"
directory="auction/transfer"
:slot-mode="true"
:slot-titles="['正面', '反面']"
@change="handleImageChange('newOwnerIdCard', $event)"
/>
</a-form-item>
<div class="mb-12"></div>
<title-divider title="新车牌号"></title-divider>
<a-form-item label="车牌号码" name="newPlateNumber">
<a-input v-model:value="formState.newPlateNumber" placeholder="请输入新车牌号" style="width: 300px;" />
</a-form-item>
</a-form>
</template>
......
......@@ -5,14 +5,40 @@
ref="fileInputRef"
type="file"
accept="image/jpeg,image/jpg,image/png,image/jpeg"
multiple
:multiple="!slotMode"
class="hidden-input"
@change="onFileChange"
/>
<!-- 上传区域 -->
<div class="upload-list">
<!-- 已上传的图片 -->
<!-- 槽位模式:每个槽位独立上传一张,按钮文案为「上传+标题」 -->
<div v-if="slotMode" class="slot-list">
<div
v-for="(title, slotIndex) in slotTitles"
:key="slotIndex"
class="slot-item"
>
<div v-if="slottedImages[slotIndex]" class="upload-item slot-upload-item">
<a-image :src="slottedImages[slotIndex]" class="image-preview" />
<div class="delete-icon" @click="handleSlotDelete(slotIndex)">
<CloseCircleOutlined />
</div>
</div>
<div
v-else-if="!readonly"
class="upload-btn slot-upload-btn"
@click="handleSlotUploadClick(slotIndex)"
>
<PlusOutlined class="plus-icon" />
<div class="upload-text">{{ title ? `上传${title}` : (uploadText || '上传图片') }}</div>
</div>
<div v-else class="upload-placeholder">
暂无图片
</div>
</div>
</div>
<!-- 普通模式:保持原有样式 -->
<div v-else class="upload-list">
<div
v-for="(url, index) in imageList"
:key="index"
......@@ -24,7 +50,6 @@
</div>
</div>
<!-- 上传按钮 -->
<div
v-if="imageList.length < maxCount && !readonly"
class="upload-btn"
......@@ -35,7 +60,6 @@
</div>
</div>
<!-- 提示文字 -->
<div v-if="hint" class="upload-hint">{{ hint }}</div>
</div>
</template>
......@@ -58,7 +82,7 @@ export default class TransferImageUpload extends Vue {
maxCount!: number;
@Prop({ type: Number, default: 10 })
maxSize!: number; // MB
maxSize!: number;
@Prop({ type: String, default: "" })
uploadText!: string;
......@@ -72,20 +96,45 @@ export default class TransferImageUpload extends Vue {
@Prop({ type: String, default: "auction/transfer" })
directory!: string;
@Prop({ type: Boolean, default: false })
slotMode!: boolean;
@Prop({ type: Array, default: () => [] })
slotTitles!: string[];
imageList: string[] = [];
slottedImages: (string | null)[] = [];
uploading = false;
currentSlotIndex: number = -1;
@Watch("slotTitles", { immediate: true })
onSlotTitlesChange(titles: string[]) {
if (!this.slotMode) return;
const len = (titles || []).length;
const next: (string | null)[] = new Array(len).fill(null);
for (let i = 0; i < Math.min(len, this.slottedImages.length); i++) {
next[i] = this.slottedImages[i] || null;
}
this.slottedImages = next;
}
@Watch("value", { deep: true, immediate: true })
onValueChange(val: any[]) {
if (!val || val.length === 0) {
this.imageList = [];
} else {
this.imageList = val.map((item: any) => {
if (typeof item === "string") {
return item;
}
const urls: string[] = (!val || val.length === 0)
? []
: val.map((item: any) => {
if (typeof item === "string") return item;
return item.url || item.aliyunAddress || "";
});
}).filter(Boolean);
if (this.slotMode) {
const len = (this.slotTitles || []).length || urls.length;
const next: (string | null)[] = new Array(Math.max(len, urls.length)).fill(null);
urls.forEach((u, i) => { next[i] = u; });
this.slottedImages = next;
this.imageList = this.slottedImages.filter((x): x is string => !!x);
} else {
this.imageList = urls;
}
}
......@@ -94,6 +143,12 @@ export default class TransferImageUpload extends Vue {
(this.$refs.fileInputRef as HTMLInputElement)?.click();
}
handleSlotUploadClick(slotIndex: number) {
if (this.readonly || this.uploading) return;
this.currentSlotIndex = slotIndex;
(this.$refs.fileInputRef as HTMLInputElement)?.click();
}
async onFileChange(ev: Event) {
const input = ev.target as HTMLInputElement;
const files = Array.from(input.files || []);
......@@ -101,35 +156,67 @@ export default class TransferImageUpload extends Vue {
if (files.length === 0) return;
// 数量限制
if (this.slotMode) {
await this.handleSlotFile(files[0]);
this.currentSlotIndex = -1;
return;
}
if (this.imageList.length + files.length > this.maxCount) {
message.warning(`最多上传${this.maxCount}张图片`);
return;
}
// 验证文件
for (const file of files) {
if (!isLikelyImageFile(file)) {
message.error(`${file.name} 不是有效的图片文件`);
return;
}
if (file.size > this.maxSize * 1024 * 1024) {
message.error(`${file.name} 大小超过${this.maxSize}MB`);
return;
}
}
// 上传文件
try {
this.uploading = true;
const uploadPromises = files.map(file => uploadFile(file, { dir: this.directory }));
const results = await Promise.all(uploadPromises);
const newUrls = results.map(res => res.aliyunAddress || res.url || "");
const newUrls = results.map(res => res.aliyunAddress || res.url || "").filter(Boolean);
this.imageList = [...this.imageList, ...newUrls];
this.emitChange();
message.success("上传成功");
} catch (error: any) {
message.error(`上传失败:${error.message || error}`);
} finally {
this.uploading = false;
}
}
async handleSlotFile(file: File) {
if (!file) return;
const slotIndex = this.currentSlotIndex;
if (slotIndex < 0) return;
if (!isLikelyImageFile(file)) {
message.error(`${file.name} 不是有效的图片文件`);
return;
}
if (file.size > this.maxSize * 1024 * 1024) {
message.error(`${file.name} 大小超过${this.maxSize}MB`);
return;
}
try {
this.uploading = true;
const res = await uploadFile(file, { dir: this.directory });
const url = res.aliyunAddress || res.url || "";
if (!url) throw new Error("上传返回地址为空");
const next = [...this.slottedImages];
next[slotIndex] = url;
this.slottedImages = next;
this.imageList = next.filter((x): x is string => !!x);
this.emitChange();
message.success("上传成功");
} catch (error: any) {
message.error(`上传失败:${error.message || error}`);
......@@ -144,8 +231,20 @@ export default class TransferImageUpload extends Vue {
this.emitChange();
}
handleSlotDelete(slotIndex: number) {
if (this.readonly) return;
const next = [...this.slottedImages];
next[slotIndex] = null;
this.slottedImages = next;
this.imageList = next.filter((x): x is string => !!x);
this.emitChange();
}
emitChange() {
const fileList = this.imageList.map(url => ({
const urls = this.slotMode
? this.slottedImages.filter((x): x is string => !!x)
: this.imageList;
const fileList = urls.map(url => ({
url,
uid: `${Date.now()}_${Math.random()}`,
name: url.split("/").pop() || "",
......@@ -175,6 +274,44 @@ export default class TransferImageUpload extends Vue {
gap: 12px;
}
.slot-list {
display: flex;
flex-wrap: wrap;
gap: 16px;
}
.slot-item {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 8px;
.slot-label {
font-size: 13px;
color: #333;
font-weight: 500;
line-height: 1;
}
}
.slot-upload-item,
.slot-upload-btn,
.upload-placeholder {
width: 120px;
height: 120px;
}
.upload-placeholder {
display: flex;
align-items: center;
justify-content: center;
color: #bfbfbf;
font-size: 12px;
border: 1px dashed #e1e3e6;
border-radius: 6px;
background: #fafafa;
}
.upload-item {
position: relative;
width: 88px;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!