<template>
|
<div class="app-container">
|
<el-form :model="filters" :inline="true">
|
<el-form-item label="采购合同号">
|
<el-input
|
v-model="filters.purchaseContractNumber"
|
style="width: 240px"
|
placeholder="请输入"
|
clearable
|
:prefix-icon="Search"
|
@change="getTableData"
|
/>
|
</el-form-item>
|
<el-form-item label="供应商">
|
<el-input
|
v-model="filters.supplierName"
|
style="width: 240px"
|
placeholder="请输入"
|
clearable
|
:prefix-icon="Search"
|
@change="getTableData"
|
/>
|
</el-form-item>
|
<el-form-item label="来票日期">
|
<el-date-picker
|
style="width: 240px"
|
v-model="filters.createdAt"
|
value-format="YYYY-MM-DD"
|
format="YYYY-MM-DD"
|
type="daterange"
|
start-placeholder="开始时间"
|
end-placeholder="结束时间"
|
clearable
|
@change="getTableData"
|
/>
|
</el-form-item>
|
<el-form-item>
|
<el-button type="primary" @click="getTableData">搜索</el-button>
|
<el-button @click="resetFilters"> 重置 </el-button>
|
<el-button @click="handleOut">导出</el-button>
|
</el-form-item>
|
</el-form>
|
<div class="table_list">
|
<PIMTable
|
rowKey="id"
|
:column="columns"
|
:tableLoading="loading"
|
:tableData="dataList"
|
:isSelection="true"
|
height="calc(100vh - 19.5em)"
|
:isShowSummary="true"
|
:summaryMethod="summarizeMainTable"
|
:page="{
|
current: pagination.currentPage,
|
size: pagination.pageSize,
|
total: pagination.total,
|
}"
|
@selection-change="handleSelectionChange"
|
@pagination="changePage"
|
>
|
<template #commonFilesRef="{ row }">
|
<el-dropdown @command="(command) => handleCommand(command, row)">
|
<el-button link :icon="Files" type="danger"> 附件 </el-button>
|
<template #dropdown>
|
<el-dropdown-menu>
|
<el-dropdown-item
|
v-if="row.commonFiles.length !== 0"
|
:icon="Download"
|
command="download"
|
>
|
下载
|
</el-dropdown-item>
|
<el-dropdown-item :icon="Upload" command="upload">
|
上传
|
</el-dropdown-item>
|
<el-dropdown-item
|
v-if="row.commonFiles.length !== 0"
|
:icon="Delete"
|
command="delete"
|
style="color: #f56c6c;"
|
>
|
删除
|
</el-dropdown-item>
|
</el-dropdown-menu>
|
</template>
|
</el-dropdown>
|
</template>
|
<template #operation="{ row }">
|
<el-button
|
type="primary"
|
text
|
@click="openEdit(row)"
|
>
|
编辑
|
</el-button>
|
<el-button
|
type="primary"
|
text
|
@click="handleDelete(row)"
|
>
|
删除
|
</el-button>
|
</template>
|
</PIMTable>
|
</div>
|
<UploadModal ref="modalRef" @uploadSuccess="uploadSuccess"></UploadModal>
|
<EditModal ref="editmodalRef" @success="getTableData"></EditModal>
|
</div>
|
</template>
|
|
<script setup>
|
import { ref, getCurrentInstance } from "vue";
|
import { usePaginationApi } from "@/hooks/usePaginationApi";
|
import {
|
Files,
|
Download,
|
Search,
|
Upload,
|
EditPen,
|
Delete,
|
} from "@element-plus/icons-vue";
|
import {
|
delRegistration,
|
productRecordPage,
|
productUploadFile,
|
} from "@/api/procurementManagement/procurementInvoiceLedger.js";
|
import { delCommonFile } from "@/api/publicApi/commonFile.js";
|
import { onMounted } from "vue";
|
import { ElMessageBox, ElMessage } from "element-plus";
|
import UploadModal from "./Modal/UploadModal.vue";
|
import EditModal from "./Modal/EditModal.vue";
|
import useUserStore from "@/store/modules/user.js";
|
import {delInvoiceLedgerByRegProductId} from "@/api/salesManagement/invoiceLedger.js";
|
import dayjs from "dayjs";
|
const userStore = useUserStore();
|
|
defineOptions({
|
name: "来票台账",
|
});
|
|
const modalRef = ref();
|
const editmodalRef = ref();
|
|
const { proxy } = getCurrentInstance();
|
const multipleVal = ref([]);
|
const {
|
loading,
|
filters,
|
columns,
|
dataList,
|
pagination,
|
getTableData,
|
resetFilters,
|
onCurrentChange,
|
} = usePaginationApi(
|
productRecordPage,
|
{
|
purchaseContractNumber: undefined, // 采购合同号
|
supplierName: undefined, // 供应商
|
// 设置来票日期范围为当天
|
createdAt: [dayjs().startOf('day').format('YYYY-MM-DD'), dayjs().endOf('day').format('YYYY-MM-DD')], // 来票日期
|
},
|
[
|
{
|
label: "采购合同号",
|
prop: "purchaseContractNumber",
|
width: 150,
|
},
|
{
|
label: "销售合同号",
|
prop: "salesContractNo",
|
width: 150,
|
},
|
{
|
label: "供应商名称",
|
prop: "supplierName",
|
width: 240,
|
},
|
{
|
label: "规格型号",
|
prop: "specificationModel",
|
width: 150,
|
},
|
{
|
label: "发票号",
|
prop: "invoiceNumber",
|
width: 200,
|
},
|
{
|
label: "合同金额(元)",
|
prop: "taxInclusiveTotalPrice",
|
width: 200,
|
formatData: (cell) => {
|
return cell ? parseFloat(cell).toFixed(2) : 0;
|
},
|
},
|
{
|
label: "开票日期",
|
prop: "createdAt",
|
width: 110,
|
},
|
{
|
label: "开票金额",
|
prop: "ticketsAmount",
|
width: 200,
|
formatData: (cell) => {
|
return cell ? parseFloat(cell).toFixed(2) : 0;
|
},
|
},
|
{
|
label: "不含税金额",
|
prop: "unTicketsPrice",
|
width: 200,
|
formatData: (cell) => {
|
return cell ? parseFloat(cell).toFixed(2) : 0;
|
},
|
},
|
{
|
label: "增值税",
|
prop: "invoiceAmount",
|
width: 200,
|
},
|
{
|
label: "录入人",
|
prop: "issUer",
|
width: 200,
|
},
|
{
|
label: "附件",
|
align: "center",
|
prop: "commonFiles",
|
dataType: "slot",
|
fixed: "right",
|
slot: "commonFilesRef",
|
width: 120,
|
},
|
{
|
fixed: "right",
|
width: 150,
|
label: "操作",
|
dataType: "slot",
|
slot: "operation",
|
align: "center",
|
},
|
],
|
{},
|
{
|
createdAt: (aim) => ({
|
createdAtStart: aim ? aim[0] : undefined,
|
createdAtEnd: aim ? aim[1] : undefined,
|
}),
|
}
|
);
|
|
// 主表合计方法
|
const summarizeMainTable = (param) => {
|
return proxy.summarizeTable(
|
param,
|
[
|
"taxInclusiveTotalPrice",
|
"ticketsAmount",
|
"unTicketsPrice",
|
"invoiceAmount",
|
],
|
{
|
ticketsNum: { noDecimal: true }, // 不保留小数
|
futureTickets: { noDecimal: true }, // 不保留小数
|
}
|
);
|
};
|
|
const handleSelectionChange = (val) => {
|
multipleVal.value = val;
|
};
|
|
// 导出
|
const handleOut = () => {
|
ElMessageBox.confirm("选中的内容将被导出,是否确认导出?", "导出", {
|
confirmButtonText: "确认",
|
cancelButtonText: "取消",
|
type: "warning",
|
})
|
.then(() => {
|
proxy.download("/purchase/registration/export", {}, "来票登记.xlsx");
|
})
|
.catch(() => {
|
proxy.$modal.msg("已取消");
|
});
|
};
|
|
const handleFiles = (fileList) => {
|
fileList.forEach((e) => {
|
proxy.$download.name(e.url);
|
});
|
};
|
|
const changePage = ({ page, limit }) => {
|
pagination.currentPage = page;
|
pagination.pageSize = limit;
|
onCurrentChange(page);
|
};
|
|
const handleCommand = (command, row) => {
|
switch (command) {
|
case "download":
|
handleFiles(row.commonFiles);
|
break;
|
case "upload":
|
console.log(row.commonFiles);
|
openUoload(row.ticketRegistrationId);
|
break;
|
case "delete":
|
// 删除所有附件
|
if (row.commonFiles.length > 0) {
|
ElMessageBox.confirm(`确认删除该记录的所有附件吗?`, '提示', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then(() => {
|
// 获取所有附件的ID
|
const fileIds = row.commonFiles.map(file => file.id);
|
|
delCommonFile(fileIds).then(() => {
|
ElMessage.success('删除成功')
|
// 刷新数据
|
getTableData();
|
}).catch(() => {
|
ElMessage.error('删除失败')
|
})
|
}).catch(() => {
|
ElMessage.info('已取消删除')
|
})
|
}
|
break;
|
}
|
};
|
|
const openUoload = (id) => {
|
modalRef.value.handleImport(id);
|
};
|
|
const openEdit = (row) => {
|
editmodalRef.value.open(row);
|
};
|
|
// 上传成功后做什么
|
const uploadSuccess = async (data) => {
|
const { code } = await productUploadFile({
|
ticketRegistrationId: data.id,
|
tempFileIds: data.tempFileIds,
|
});
|
if (code === 200) {
|
proxy.$modal.msgSuccess("提交成功");
|
getTableData();
|
}
|
};
|
// 删除
|
const handleDelete = (row) => {
|
let ids = [];
|
ids.push(row.id);
|
ElMessageBox.confirm("该开票台账将被删除,是否确认删除", {
|
confirmButtonText: "确认",
|
cancelButtonText: "取消",
|
type: "warning",
|
})
|
.then(() => {
|
loading.value = true;
|
delRegistration(ids).then((res) => {
|
getTableData();
|
});
|
loading.value = false;
|
})
|
.catch(() => {
|
proxy.$modal.msg("已取消");
|
});
|
};
|
|
onMounted(() => {
|
getTableData();
|
});
|
</script>
|
|
<style lang="scss" scoped>
|
.table_list {
|
margin-top: unset;
|
}
|
.tagBox {
|
margin-top: 4px;
|
}
|
</style>
|