<template>
|
<FormDialog v-model="visible" title="采购台账详情" width="70%" operation-type="detail" @close="handleClose">
|
<el-form :model="form" label-width="140px" label-position="top">
|
<el-row :gutter="30">
|
<el-col :span="12">
|
<el-form-item label="采购合同号:">
|
<span class="readonly-text">{{ form.purchaseContractNumber || '--' }}</span>
|
</el-form-item>
|
</el-col>
|
<el-col v-if="showSalesContractBinding" :span="12">
|
<el-form-item label="销售合同号:">
|
<span class="readonly-text">{{ form.salesContractNo || '--' }}</span>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row :gutter="30">
|
<el-col :span="12">
|
<el-form-item label="供应商名称:">
|
<span class="readonly-text">{{ form.supplierName || '--' }}</span>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="项目名称:">
|
<span class="readonly-text">{{ form.projectName || '--' }}</span>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row :gutter="30">
|
<el-col :span="12">
|
<el-form-item label="付款方式:">
|
<span class="readonly-text">{{ form.paymentMethod || '--' }}</span>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="签订日期:">
|
<span class="readonly-text">{{ form.executionDate || '--' }}</span>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row :gutter="30">
|
<el-col :span="12">
|
<el-form-item label="录入人:">
|
<span class="readonly-text">{{ form.recorderName || '--' }}</span>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="录入日期:">
|
<span class="readonly-text">{{ form.entryDate || '--' }}</span>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
|
<div style="font-weight: bold; margin: 10px 0; color: #f56c6c">
|
* 产品信息:
|
</div>
|
<el-table :data="productData" border>
|
<el-table-column type="index" label="序号" width="60" align="center" />
|
<el-table-column label="产品大类" prop="productCategory" />
|
<el-table-column label="规格型号" prop="specificationModel" />
|
<el-table-column label="单位" prop="unit" />
|
<el-table-column label="数量" prop="quantity" />
|
<el-table-column label="库存预留数量" prop="stockReservedQuantity" />
|
<el-table-column label="税率(%)" prop="taxRate" />
|
<el-table-column label="含税单价(元)" prop="taxInclusiveUnitPrice" :formatter="formattedNumber" width="150" />
|
<el-table-column label="含税总价(元)" prop="taxInclusiveTotalPrice" :formatter="formattedNumber" width="150" />
|
<el-table-column label="不含税总价(元)" prop="taxExclusiveTotalPrice" :formatter="formattedNumber" width="150" />
|
<template #append>
|
<div class="summary-row" v-if="productData.length > 0">
|
<div class="summary-label">合计</div>
|
<div class="summary-value" style="width: 150px">
|
{{ formattedNumber(null, null, sumTaxInclusiveUnitPrice) }}
|
</div>
|
<div class="summary-value" style="width: 150px">
|
{{ formattedNumber(null, null, sumTaxInclusiveTotalPrice) }}
|
</div>
|
<div class="summary-value" style="width: 150px">
|
{{ formattedNumber(null, null, sumTaxExclusiveTotalPrice) }}
|
</div>
|
</div>
|
</template>
|
</el-table>
|
|
<el-row :gutter="30" style="margin-top: 20px;">
|
<el-col :span="24">
|
<el-form-item label="备注:">
|
<div class="readonly-text-area">{{ form.remarks || '--' }}</div>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
|
<el-row :gutter="30">
|
<el-col :span="24">
|
<el-form-item label="附件材料:">
|
<div class="table-container" style="width: 100%;">
|
<el-table :data="fileList" border class="attachment-table" style="width: 100%;"
|
:height="fileList.length > 0 ? 'auto' : '120px'">
|
<el-table-column label="附件名称" prop="originalFilename" show-overflow-tooltip min-width="200">
|
<template #default="scope">
|
{{ scope.row.name || scope.row.originalFilename || ('附件' + (scope.$index + 1)) }}
|
</template>
|
</el-table-column>
|
<el-table-column fixed="right" label="操作" :width="150" align="center">
|
<template #default="scope">
|
<el-button link type="primary" size="small" class="download-link"
|
@click="previewFile(scope.row.previewURL || scope.row.url)">
|
预览
|
</el-button>
|
<el-button link type="primary" size="small" class="download-link"
|
@click="downloadFile(scope.row.downloadURL || scope.row.url)">
|
下载
|
</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
</div>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-form>
|
</FormDialog>
|
<filePreview ref="filePreviewRef" />
|
</template>
|
|
<script setup>
|
import { ref, computed } from 'vue'
|
import { ElMessage } from 'element-plus'
|
import FormDialog from "@/components/Dialog/FormDialog.vue"
|
import filePreview from '@/components/filePreview/index.vue'
|
import { getPurchaseById } from "@/api/procurementManagement/procurementLedger"
|
|
const visible = ref(false)
|
// 是否显示销售合同号绑定
|
const showSalesContractBinding = false
|
const form = ref({})
|
const productData = ref([])
|
const fileList = ref([])
|
const filePreviewRef = ref()
|
|
const open = (id) => {
|
visible.value = true
|
getPurchaseById({ id: id, type: 2 }).then(res => {
|
form.value = res.data ? res.data : res || {}
|
productData.value = form.value.purchaseLedgerProductList || form.value.productData || []
|
fileList.value = form.value.storageBlobVOS || []
|
})
|
}
|
|
// 暴露 open 方法给父组件调用
|
defineExpose({
|
open
|
})
|
|
const handleClose = () => {
|
visible.value = false
|
form.value = {}
|
productData.value = []
|
fileList.value = []
|
}
|
|
const formattedNumber = (row, column, cellValue) => {
|
if (cellValue != null && !isNaN(cellValue)) {
|
return Number(cellValue).toFixed(2)
|
}
|
return cellValue
|
}
|
|
const sumTaxInclusiveUnitPrice = computed(() => {
|
return productData.value.reduce((sum, item) => {
|
return sum + (Number(item.taxInclusiveUnitPrice) || 0)
|
}, 0)
|
})
|
|
const sumTaxInclusiveTotalPrice = computed(() => {
|
return productData.value.reduce((sum, item) => {
|
return sum + (Number(item.taxInclusiveTotalPrice) || 0)
|
}, 0)
|
})
|
|
const sumTaxExclusiveTotalPrice = computed(() => {
|
return productData.value.reduce((sum, item) => {
|
return sum + (Number(item.taxExclusiveTotalPrice) || 0)
|
}, 0)
|
})
|
|
const previewFile = (url) => {
|
if (url) {
|
filePreviewRef.value.open(url)
|
} else {
|
ElMessage.warning('文件地址无效,无法预览')
|
}
|
}
|
|
const downloadFile = (url) => {
|
window.open(url, "_blank")
|
}
|
</script>
|
|
<style scoped>
|
.readonly-text {
|
width: 100%;
|
padding: 0 12px;
|
background-color: #f5f7fa;
|
color: #606266;
|
border-radius: 4px;
|
border: 1px solid #e4e7ed;
|
box-sizing: border-box;
|
min-height: 32px;
|
line-height: 32px;
|
display: inline-block;
|
}
|
|
.readonly-text-area {
|
width: 100%;
|
padding: 8px 12px;
|
background-color: #f5f7fa;
|
color: #606266;
|
border-radius: 4px;
|
border: 1px solid #e4e7ed;
|
box-sizing: border-box;
|
min-height: 64px;
|
line-height: 1.5;
|
white-space: pre-wrap;
|
word-break: break-all;
|
}
|
|
.summary-row {
|
display: flex;
|
background-color: #f5f7fa;
|
font-weight: bold;
|
border-top: 1px solid #ebeef5;
|
}
|
|
.summary-label {
|
flex: 1;
|
text-align: right;
|
padding: 12px;
|
color: #606266;
|
}
|
|
.summary-value {
|
padding: 12px;
|
color: #606266;
|
border-left: 1px solid #ebeef5;
|
}
|
|
.table-container {
|
overflow-y: auto;
|
box-sizing: border-box;
|
}
|
</style>
|