This commit is contained in:
2026-08-25 22:35:50 +08:00
parent cb98355715
commit 3da2d428f3
11 changed files with 883 additions and 130 deletions
@@ -102,14 +102,13 @@
}}</span></template
></el-table-column
>
<el-table-column label="调整金额(不含税)" min-width="170" align="center"
<el-table-column
v-if="!editable"
label="调整金额(不含税)"
min-width="170"
align="center"
><template #default="{ row }"
><el-input-number
v-if="editable"
v-model="row.adjustmentAmountNoTax"
:precision="2"
:controls="false"
/><span v-else>{{ formatMoney(row.adjustmentAmountNoTax) }}</span></template
><span>{{ formatMoney(row.adjustmentAmountNoTax) }}</span></template
></el-table-column
>
<el-table-column label="备注" min-width="180" align="center"
@@ -140,6 +139,60 @@
>;调整后结算金额:<strong>{{ formatMoney(form.adjustedSettlementAmount) }}</strong>
</div>
</section-card>
<section-card title="附件材料">
<el-table :data="attachments" border>
<el-table-column type="index" label="序号" width="64" align="center" />
<el-table-column label="文件名" min-width="220" show-overflow-tooltip>
<template #default="{ row }">
<el-link type="primary" @click="previewAttachment(row)">
{{ attachmentName(row) }}
</el-link>
</template>
</el-table-column>
<el-table-column label="附件描述" min-width="240">
<template #default="{ row }">
<el-input
v-if="editable"
v-model="row.description"
maxlength="200"
placeholder="请输入附件描述"
/>
<span v-else>{{ displayValue(row.description) }}</span>
</template>
</el-table-column>
<el-table-column label="文件大小" width="120" align="center">
<template #default="{ row }">{{ formatFileSize(row) }}</template>
</el-table-column>
<el-table-column prop="uploadUserName" label="上传人" width="140" align="center" />
<el-table-column prop="uploadTime" label="上传时间" width="170" align="center" />
<el-table-column label="操作" :width="editable ? 130 : 70" fixed="right" align="center">
<template #default="{ row, $index }">
<div class="settlement-adjustment-editor__links">
<el-link type="primary" @click="downloadAttachment(row)">下载</el-link>
<el-link v-if="editable" type="danger" @click="removeAttachment($index)">
删除
</el-link>
</div>
</template>
</el-table-column>
<template #empty><el-empty description="暂无附件材料" /></template>
</el-table>
<div v-show="editable" class="settlement-adjustment-editor__attachment-upload">
<vehicle-attachment-upload
ref="attachmentUploadRef"
v-model="attachments"
:readonly="!editable"
:multiple="true"
:limit="20"
:max-size="500"
:file-types="attachmentFileTypes"
:show-file-list="false"
button-text="上传附件"
@change="handleAttachmentChange"
/>
</div>
</section-card>
</div>
<template #footer
><el-button @click="visible = false">取消</el-button
@@ -199,6 +252,7 @@ import {
createSettlementAdjustmentForm,
settlementAdjustmentFormFields,
} from '@/option/settlement/settlementAdjustmentForm';
import { downloadFileByUrl } from '@/utils/util';
export default {
name: 'SettlementAdjustmentEditor',
props: { modelValue: Boolean, recordId: [String, Number], readonly: Boolean },
@@ -209,6 +263,23 @@ export default {
form: createSettlementAdjustmentForm(),
fields: settlementAdjustmentFormFields,
details: [],
attachments: [],
attachmentFileTypes: [
'pdf',
'bmp',
'jpeg',
'png',
'jpg',
'doc',
'docx',
'ppt',
'pptx',
'xlsx',
'xls',
'eml',
'msg',
'zip',
],
candidates: [],
feeRows: [],
rules: {
@@ -248,6 +319,7 @@ export default {
async initialize() {
this.form = createSettlementAdjustmentForm();
this.details = [];
this.attachments = [];
this.candidates = [];
this.feeRows = [];
if (!this.recordId) {
@@ -264,6 +336,7 @@ export default {
adjustmentAmountNoTax:
item.adjustmentAmountNoTax == null ? null : Number(item.adjustmentAmountNoTax),
}));
this.attachments = this.parseAttachments(data.attachmentsJson);
await this.loadFormalSettlements(this.form.formalSettlementNo || '');
} finally {
this.loading = false;
@@ -276,8 +349,9 @@ export default {
async handleFormalChange(id) {
const item = this.candidates.find(row => String(row.id) === String(id));
if (!item) return;
Object.assign(this.form, item, {
formalSettlementId: id,
const { id: formalSettlementId, ...formalSettlement } = item;
Object.assign(this.form, formalSettlement, {
formalSettlementId,
formalSettlementNo: item.formalSettlementNo,
originalSettlementAmount: Number(item.settlementAmount || 0),
settlementTypeName: item.settlementTypeName,
@@ -321,8 +395,9 @@ export default {
this.saving = true;
try {
await api.save({
id: this.form.id,
...(this.recordId ? { id: this.form.id } : {}),
formalSettlementId: this.form.formalSettlementId,
attachmentsJson: JSON.stringify(this.attachments || []),
remark: this.form.remark,
details: this.details.map(item => ({
formalSettlementDetailId: item.formalSettlementDetailId,
@@ -347,15 +422,77 @@ export default {
formatMoney(value) {
return Number(value || 0).toFixed(2);
},
handleAttachmentChange(files) {
const userInfo = this.$store.getters.userInfo || {};
const uploadUserName = userInfo.realName || userInfo.userName || '';
const uploadTime = this.$dayjs().format('YYYY-MM-DD HH:mm:ss');
this.attachments = (files || []).map(file => ({
...file,
description: file.description || '',
uploadUserName: file.uploadUserName || uploadUserName,
uploadTime: file.uploadTime || uploadTime,
}));
},
parseAttachments(value) {
if (!value) return [];
if (Array.isArray(value)) return value;
try {
const parsed = JSON.parse(value);
return Array.isArray(parsed) ? parsed : [];
} catch (error) {
return [];
}
},
attachmentName(file = {}) {
return file.originalName || file.name || file.fileName || '附件';
},
attachmentUrl(file = {}) {
return file.url || file.link || file.fileUrl || file.domain || '';
},
formatFileSize(file = {}) {
const bytes = Number(file.size || file.fileSize || file.attachSize || 0);
if (!bytes) return '-';
if (bytes < 1024) return `${bytes}B`;
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)}KB`;
return `${(bytes / 1024 / 1024).toFixed(1)}MB`;
},
previewAttachment(file) {
this.$refs.attachmentUploadRef?.handlePreview(file);
},
downloadAttachment(file) {
const url = this.attachmentUrl(file);
if (!url) {
this.$message.warning('附件地址为空');
return;
}
downloadFileByUrl(url, this.attachmentName(file));
},
removeAttachment(index) {
this.attachments.splice(index, 1);
},
},
};
</script>
<style scoped lang="scss">
.settlement-adjustment-editor {
max-height: 72vh;
overflow-y: auto;
padding-right: 4px;
}
.settlement-adjustment-editor__summary {
padding: 12px 0;
text-align: right;
}
.settlement-adjustment-editor__attachment-upload {
padding-top: 12px;
}
.settlement-adjustment-editor__links {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 8px;
}
.settlement-adjustment-editor :deep(.el-form-item) {
margin-bottom: 16px;
}