<template>
|
<div class="app-container">
|
<el-form :model="filters"
|
:inline="true">
|
<el-form-item label="付款单号:">
|
<el-input v-model="filters.paymentNumber"
|
placeholder="请输入付款单号"
|
clearable
|
style="width: 200px;" />
|
</el-form-item>
|
<el-form-item label="供应商:">
|
<el-select v-model="filters.supplierId"
|
placeholder="请选择供应商"
|
clearable
|
filterable
|
style="width: 200px;">
|
<el-option v-for="item in supplierList"
|
:key="item.id"
|
:label="item.supplierName"
|
:value="item.id" />
|
</el-select>
|
</el-form-item>
|
<el-form-item label="付款方式:">
|
<el-select v-model="filters.paymentMethod"
|
placeholder="请选择付款方式"
|
clearable
|
style="width: 150px;">
|
<el-option v-for="item in checkout_payment"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value" />
|
</el-select>
|
</el-form-item>
|
<el-form-item label="付款日期:">
|
<el-date-picker v-model="filters.dateRange"
|
type="daterange"
|
value-format="YYYY-MM-DD"
|
format="YYYY-MM-DD"
|
range-separator="至"
|
start-placeholder="开始日期"
|
end-placeholder="结束日期"
|
clearable
|
style="width: 240px;" />
|
</el-form-item>
|
<el-form-item>
|
<el-button type="primary"
|
@click="onSearch">搜索</el-button>
|
<el-button @click="resetFilters">重置</el-button>
|
</el-form-item>
|
</el-form>
|
<div class="table_list">
|
<div class="actions">
|
<div>
|
<el-statistic title="本页付款合计"
|
:value="totalPaymentAmount"
|
:precision="2"
|
prefix="¥" />
|
</div>
|
<div>
|
<el-button @click="handleExport"
|
icon="Download">导出</el-button>
|
</div>
|
</div>
|
<PIMTable rowKey="id"
|
:column="columns"
|
:tableData="dataList"
|
:tableLoading="tableLoading"
|
:page="{
|
current: pagination.currentPage,
|
size: pagination.pageSize,
|
total: pagination.total,
|
}"
|
@pagination="changePage">
|
<template #amount="{ row }">
|
<span class="text-danger">¥{{ formatMoney(row.amount) }}</span>
|
</template>
|
<template #paymentMethod="{ row }">
|
<el-tag>{{ getPaymentMethodLabel(row.paymentMethod) }}</el-tag>
|
</template>
|
<template #operation="{ row }">
|
<el-button :disabled="row.accountStatemen"
|
type="danger"
|
link
|
@click="handleDelete(row)">删除</el-button>
|
</template>
|
</PIMTable>
|
</div>
|
</div>
|
</template>
|
|
<script setup>
|
import { ref, reactive, computed, onMounted, getCurrentInstance } from "vue";
|
import { ElMessage, ElMessageBox } from "element-plus";
|
import { getOptions } from "@/api/procurementManagement/procurementLedger.js";
|
import {
|
listPageAccountPurchasePayment,
|
deleteAccountPurchasePayment,
|
} from "@/api/financialManagement/accountPurchasePayment.js";
|
|
defineOptions({
|
name: "付款单",
|
});
|
|
const { proxy } = getCurrentInstance();
|
const { checkout_payment } = proxy.useDict("checkout_payment");
|
|
const filters = reactive({
|
paymentNumber: "",
|
supplierId: "",
|
paymentMethod: "",
|
dateRange: [],
|
});
|
|
const pagination = reactive({
|
currentPage: 1,
|
pageSize: 10,
|
total: 0,
|
});
|
|
const columns = [
|
{ label: "付款单号", prop: "paymentNumber", width: "150" },
|
{ label: "关联申请单", prop: "invoiceApplicationNo", width: "150" },
|
{ label: "供应商", prop: "supplierName", width: "180" },
|
{ label: "付款日期", prop: "paymentDate", width: "120" },
|
{ label: "付款金额", prop: "amount", dataType: "slot", slot: "amount" },
|
{
|
label: "付款方式",
|
prop: "paymentMethod",
|
dataType: "slot",
|
slot: "paymentMethod",
|
width: "120",
|
},
|
{ label: "备注", prop: "remark", showOverflowTooltip: true },
|
{
|
label: "操作",
|
prop: "operation",
|
dataType: "slot",
|
slot: "operation",
|
width: "80",
|
fixed: "right",
|
},
|
];
|
|
const dataList = ref([]);
|
const tableLoading = ref(false);
|
const supplierList = ref([]);
|
|
const totalPaymentAmount = computed(() =>
|
dataList.value.reduce((sum, item) => sum + Number(item.amount ?? 0), 0)
|
);
|
|
const formatMoney = value => {
|
if (value === undefined || value === null) return "0.00";
|
return Number(value)
|
.toFixed(2)
|
.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
};
|
|
const getPaymentMethodLabel = value => {
|
if (value === undefined || value === null || value === "") return "-";
|
const item = checkout_payment.value?.find(
|
m => String(m.value) === String(value)
|
);
|
return item?.label ?? value;
|
};
|
|
const normalizeTableRow = row => ({
|
...row,
|
paymentNumber: row.paymentNumber ?? row.paymentCode,
|
invoiceApplicationNo: row.invoiceApplicationNo ?? row.applyCode ?? "",
|
amount: row.paymentAmount ?? row.amount,
|
bankAccountNum: row.bankAccountNum ?? row.bankAccount ?? "",
|
bankAccountName: row.bankAccountName ?? row.bankName ?? "",
|
});
|
|
const getSupplierList = () => {
|
getOptions().then(res => {
|
if (res.code === 200) {
|
supplierList.value = res.data ?? [];
|
}
|
});
|
};
|
|
const appendFilterParams = params => {
|
if (filters.paymentNumber) {
|
params.paymentNumber = filters.paymentNumber;
|
}
|
if (filters.supplierId) {
|
params.supplierId = filters.supplierId;
|
}
|
if (filters.paymentMethod) {
|
params.paymentMethod = filters.paymentMethod;
|
}
|
if (filters.dateRange?.length === 2) {
|
params.startDate = filters.dateRange[0];
|
params.endDate = filters.dateRange[1];
|
}
|
return params;
|
};
|
|
const buildListParams = () =>
|
appendFilterParams({
|
current: pagination.currentPage,
|
size: pagination.pageSize,
|
});
|
|
const buildExportParams = () => appendFilterParams({});
|
|
const handleExport = () => {
|
proxy.download(
|
"/accountPurchasePayment/exportAccountPurchasePayment",
|
buildExportParams(),
|
`付款单_${Date.now()}.xlsx`
|
);
|
};
|
|
const getTableData = () => {
|
tableLoading.value = true;
|
listPageAccountPurchasePayment(buildListParams())
|
.then(res => {
|
if (res.code === 200) {
|
dataList.value = (res.data?.records ?? []).map(normalizeTableRow);
|
pagination.total = res.data?.total ?? 0;
|
} else {
|
dataList.value = [];
|
pagination.total = 0;
|
ElMessage.error(res.msg || "查询失败");
|
}
|
})
|
.catch(() => {
|
dataList.value = [];
|
pagination.total = 0;
|
ElMessage.error("查询失败");
|
})
|
.finally(() => {
|
tableLoading.value = false;
|
});
|
};
|
|
const onSearch = () => {
|
pagination.currentPage = 1;
|
getTableData();
|
};
|
|
const resetFilters = () => {
|
filters.paymentNumber = "";
|
filters.supplierId = "";
|
filters.paymentMethod = "";
|
filters.dateRange = [];
|
pagination.currentPage = 1;
|
getTableData();
|
};
|
|
const changePage = ({ page, limit }) => {
|
pagination.currentPage = page;
|
pagination.pageSize = limit;
|
getTableData();
|
};
|
|
const handleDelete = row => {
|
ElMessageBox.confirm(`确认删除付款单「${row.paymentNumber}」吗?`, "提示", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning",
|
}).then(() => {
|
deleteAccountPurchasePayment([row.id])
|
.then(res => {
|
if (res.code === 200) {
|
ElMessage.success("删除成功");
|
getTableData();
|
} else {
|
ElMessage.error(res.msg || "删除失败");
|
}
|
})
|
.catch(() => {
|
ElMessage.error("删除失败");
|
});
|
});
|
};
|
|
onMounted(() => {
|
getSupplierList();
|
getTableData();
|
});
|
</script>
|
|
<style lang="scss" scoped>
|
.actions {
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
margin-bottom: 15px;
|
}
|
|
.text-danger {
|
color: #f56c6c;
|
font-weight: bold;
|
}
|
</style>
|