|
|
@@ -0,0 +1,539 @@
|
|
|
+<template>
|
|
|
+ <div class="ele-body">
|
|
|
+ <el-card shadow="never">
|
|
|
+ <div class="ele-border-lighter form-content">
|
|
|
+ <!-- 查询区:等宽栅格排列,控件统一占满列宽,避免各控件宽度不一 -->
|
|
|
+ <el-form
|
|
|
+ :inline="true"
|
|
|
+ size="small"
|
|
|
+ label-width="90px"
|
|
|
+ class="report-search-form"
|
|
|
+ @submit.native.prevent
|
|
|
+ >
|
|
|
+ <div class="report-search-form__fields">
|
|
|
+ <el-form-item label="开始时间:">
|
|
|
+ <el-date-picker
|
|
|
+ v-model="queryForm.startCreateTime"
|
|
|
+ type="datetime"
|
|
|
+ value-format="yyyy-MM-dd HH:mm:ss"
|
|
|
+ placeholder="请选择开始时间"
|
|
|
+ clearable
|
|
|
+ ></el-date-picker>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="结束时间:">
|
|
|
+ <el-date-picker
|
|
|
+ v-model="queryForm.endCreateTime"
|
|
|
+ type="datetime"
|
|
|
+ value-format="yyyy-MM-dd HH:mm:ss"
|
|
|
+ placeholder="请选择结束时间"
|
|
|
+ clearable
|
|
|
+ ></el-date-picker>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="项目名称:">
|
|
|
+ <el-input
|
|
|
+ v-model="queryForm.projectName"
|
|
|
+ placeholder="请输入项目名称"
|
|
|
+ clearable
|
|
|
+ @keyup.enter.native="handleSearch"
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="请购人:">
|
|
|
+ <el-input
|
|
|
+ v-model="queryForm.requisitioner"
|
|
|
+ placeholder="请输入请购人"
|
|
|
+ clearable
|
|
|
+ @keyup.enter.native="handleSearch"
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="请购单号:">
|
|
|
+ <el-input
|
|
|
+ v-model="queryForm.requisitionNumber"
|
|
|
+ placeholder="请输入请购单号"
|
|
|
+ clearable
|
|
|
+ @keyup.enter.native="handleSearch"
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="物料名称:">
|
|
|
+ <el-input
|
|
|
+ v-model="queryForm.materialName"
|
|
|
+ placeholder="请输入物料名称"
|
|
|
+ clearable
|
|
|
+ @keyup.enter.native="handleSearch"
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="采购方:">
|
|
|
+ <el-input
|
|
|
+ v-model="queryForm.procuringentity"
|
|
|
+ placeholder="请输入采购方"
|
|
|
+ clearable
|
|
|
+ @keyup.enter.native="handleSearch"
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="采购单号:">
|
|
|
+ <el-input
|
|
|
+ v-model="queryForm.purchaseOrderNumber"
|
|
|
+ placeholder="请输入采购单号"
|
|
|
+ clearable
|
|
|
+ @keyup.enter.native="handleSearch"
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </div>
|
|
|
+ <div class="report-search-form__actions">
|
|
|
+ <el-button icon="el-icon-refresh-left" @click="handleReset">
|
|
|
+ 重置
|
|
|
+ </el-button>
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ icon="el-icon-search"
|
|
|
+ class="ele-btn-icon"
|
|
|
+ @click="handleSearch"
|
|
|
+ >
|
|
|
+ 查询
|
|
|
+ </el-button>
|
|
|
+ </div>
|
|
|
+ </el-form>
|
|
|
+
|
|
|
+ <!-- 数据表格 -->
|
|
|
+ <ele-pro-table
|
|
|
+ ref="table"
|
|
|
+ :columns="columns"
|
|
|
+ :datasource="datasource"
|
|
|
+ height="calc(100vh - 504px)"
|
|
|
+ full-height="calc(100vh - 116px)"
|
|
|
+ tool-class="ele-toolbar-form"
|
|
|
+ :page-size="20"
|
|
|
+ >
|
|
|
+ <!-- 表头工具栏 -->
|
|
|
+ <template v-slot:toolbar>
|
|
|
+ <el-button
|
|
|
+ size="small"
|
|
|
+ type="primary"
|
|
|
+ icon="el-icon-download"
|
|
|
+ class="ele-btn-icon"
|
|
|
+ :loading="exportLoading"
|
|
|
+ @click="handleExport"
|
|
|
+ >
|
|
|
+ 导出
|
|
|
+ </el-button>
|
|
|
+ </template>
|
|
|
+ </ele-pro-table>
|
|
|
+ </div>
|
|
|
+ </el-card>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+ import { getPurchaseReportPage, exportPurchaseReport } from '@/api/reportForms/reportForms';
|
|
|
+ import { download } from '@/utils/file';
|
|
|
+ import { formatDate } from '@/utils/dateUtils';
|
|
|
+
|
|
|
+ // 导出文件的 mime 类型
|
|
|
+ const XLSX_TYPE =
|
|
|
+ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
|
|
|
+
|
|
|
+ // 空值统一展示为空,不显示 null / undefined
|
|
|
+ function emptyFormatter(row, column, cellValue) {
|
|
|
+ return cellValue === null || cellValue === undefined ? '' : cellValue;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询区初始条件
|
|
|
+ function initQueryForm() {
|
|
|
+ return {
|
|
|
+ startCreateTime: '',
|
|
|
+ endCreateTime: '',
|
|
|
+ projectName: '',
|
|
|
+ requisitioner: '',
|
|
|
+ requisitionNumber: '',
|
|
|
+ materialName: '',
|
|
|
+ procuringentity: '',
|
|
|
+ purchaseOrderNumber: ''
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ exportLoading: false, // 导出中状态
|
|
|
+ queryForm: initQueryForm(),
|
|
|
+ // 当前已生效的查询条件(不含分页字段),导出使用它而不是当前页数据
|
|
|
+ activeWhere: {},
|
|
|
+ columns: [
|
|
|
+ {
|
|
|
+ prop: 'productCode',
|
|
|
+ label: '项目编号',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 160,
|
|
|
+ formatter: emptyFormatter
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'productName',
|
|
|
+ label: '项目名称',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 180,
|
|
|
+ formatter: emptyFormatter
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'requirementDate',
|
|
|
+ label: '请购日期',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 170,
|
|
|
+ formatter: emptyFormatter
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'requisitioner',
|
|
|
+ label: '请购人',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 110,
|
|
|
+ formatter: emptyFormatter
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'requirementCode',
|
|
|
+ label: '请购单号',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 170,
|
|
|
+ formatter: emptyFormatter
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'materialName',
|
|
|
+ label: '物料名称',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 160,
|
|
|
+ formatter: emptyFormatter
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'specification',
|
|
|
+ label: '物料规格',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 160,
|
|
|
+ formatter: emptyFormatter
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'applyCount',
|
|
|
+ label: '申请数量',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 110,
|
|
|
+ formatter: emptyFormatter
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'measuringUnit',
|
|
|
+ label: '单位',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 110,
|
|
|
+ formatter: emptyFormatter
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'purchaseDate',
|
|
|
+ label: '采购日期',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 170,
|
|
|
+ formatter: emptyFormatter
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'purchaser',
|
|
|
+ label: '采购人',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 110,
|
|
|
+ formatter: emptyFormatter
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'purchaseOrderNo',
|
|
|
+ label: '采购单号/合同号',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 200,
|
|
|
+ // 合同号后端已自带 '/' 前缀,这里直接拼接,不再加分隔符
|
|
|
+ formatter: (row) => {
|
|
|
+ const orderNo = row.purchaseOrderNo || '';
|
|
|
+ const contractNo = row.contractNo || '';
|
|
|
+ return orderNo + contractNo;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'supplierName',
|
|
|
+ label: '供应商',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 180,
|
|
|
+ formatter: emptyFormatter
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'purchaseCount',
|
|
|
+ label: '采购数量',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 110,
|
|
|
+ formatter: emptyFormatter
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'purchaseUnitPrice',
|
|
|
+ label: '采购单价',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 110,
|
|
|
+ formatter: emptyFormatter
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'purchaseTotalAmount',
|
|
|
+ label: '采购总金额',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 120,
|
|
|
+ formatter: emptyFormatter
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'unpurchasedCount',
|
|
|
+ label: '未采购数量',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 110,
|
|
|
+ formatter: emptyFormatter
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'receiveDates',
|
|
|
+ label: '采购到货日期',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 170,
|
|
|
+ formatter: emptyFormatter
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'receiveCount',
|
|
|
+ label: '采购到货数量',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 120,
|
|
|
+ formatter: emptyFormatter
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'unreceivedCount',
|
|
|
+ label: '采购未到货数量',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 130,
|
|
|
+ formatter: emptyFormatter
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'inboundDates',
|
|
|
+ label: '入库日期',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 170,
|
|
|
+ formatter: emptyFormatter
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'inboundCount',
|
|
|
+ label: '入库数量',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 110,
|
|
|
+ formatter: emptyFormatter
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'paymentMode',
|
|
|
+ label: '付款方式',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 110,
|
|
|
+ formatter: emptyFormatter
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'requestPaymentTime',
|
|
|
+ label: '请款时间',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 170,
|
|
|
+ formatter: emptyFormatter
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'requestedAmount',
|
|
|
+ label: '已请货款金额',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 130,
|
|
|
+ formatter: emptyFormatter
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'unrequestedAmount',
|
|
|
+ label: '未请货款金额',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 140,
|
|
|
+ formatter: emptyFormatter
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'paymentTime',
|
|
|
+ label: '付款时间',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 170,
|
|
|
+ formatter: emptyFormatter
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'paidAmount',
|
|
|
+ label: '已付款金额',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 120,
|
|
|
+ formatter: emptyFormatter
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'unpaidAmount',
|
|
|
+ label: '未付款金额',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 120,
|
|
|
+ formatter: emptyFormatter
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'progressNode',
|
|
|
+ label: '目前节点',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 130,
|
|
|
+ formatter: emptyFormatter
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'invoiceNo',
|
|
|
+ label: '发票号',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 160,
|
|
|
+ formatter: emptyFormatter
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'invoiceAmount',
|
|
|
+ label: '发票金额',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 110,
|
|
|
+ formatter: emptyFormatter
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'invoiceDate',
|
|
|
+ label: '发票日期',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 170,
|
|
|
+ formatter: emptyFormatter
|
|
|
+ },
|
|
|
+ ]
|
|
|
+ };
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ /* 表格数据源 */
|
|
|
+ datasource({ page, limit, where }) {
|
|
|
+ // 记录当前生效的查询条件,导出时使用(不带 pageNum / pageSize)
|
|
|
+ this.activeWhere = { ...where };
|
|
|
+ return getPurchaseReportPage({
|
|
|
+ ...where,
|
|
|
+ pageNum: page,
|
|
|
+ size: limit
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /* 组装查询条件,空值不提交 */
|
|
|
+ buildWhere() {
|
|
|
+ const where = {};
|
|
|
+ Object.keys(this.queryForm).forEach((key) => {
|
|
|
+ const value = this.queryForm[key];
|
|
|
+ if (value !== '' && value !== null && value !== undefined) {
|
|
|
+ where[key] = value;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return where;
|
|
|
+ },
|
|
|
+ /* 查询 */
|
|
|
+ handleSearch() {
|
|
|
+ this.$refs.table.reload({ page: 1, where: this.buildWhere() });
|
|
|
+ },
|
|
|
+ /* 重置 */
|
|
|
+ handleReset() {
|
|
|
+ this.queryForm = initQueryForm();
|
|
|
+ this.$refs.table.reload({ page: 1, where: {} });
|
|
|
+ },
|
|
|
+ /* 全量导出:按当前已生效的查询条件导出全部数据,不是当前页 */
|
|
|
+ async handleExport() {
|
|
|
+ if (this.exportLoading) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.exportLoading = true;
|
|
|
+ try {
|
|
|
+ const blob = await exportPurchaseReport(this.activeWhere);
|
|
|
+ const name = `采购报表_${formatDate(
|
|
|
+ new Date(),
|
|
|
+ 'yyyyMMddHHmmss'
|
|
|
+ )}.xlsx`;
|
|
|
+ download(new Blob([blob], { type: XLSX_TYPE }), name);
|
|
|
+ this.$message.success('导出成功');
|
|
|
+ } catch (e) {
|
|
|
+ this.$message.error(e && e.message ? e.message : '导出失败');
|
|
|
+ } finally {
|
|
|
+ this.exportLoading = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+ .report-search-form {
|
|
|
+ margin-bottom: 12px;
|
|
|
+ padding: 12px 12px 8px;
|
|
|
+ background: #fafbfd;
|
|
|
+ border: 1px solid #eef1f6;
|
|
|
+ border-radius: 6px;
|
|
|
+
|
|
|
+ /* 条件区:自适应等宽栅格,列对齐;窗口变窄时按整列换行,不会出现参差 */
|
|
|
+ &__fields {
|
|
|
+ display: grid;
|
|
|
+ grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
|
|
|
+ gap: 10px 16px;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* 操作区:靠右并与条件区用分隔线隔开,避免和条件行混排 */
|
|
|
+ &__actions {
|
|
|
+ display: flex;
|
|
|
+ justify-content: flex-end;
|
|
|
+ margin-top: 8px;
|
|
|
+ padding-top: 8px;
|
|
|
+ border-top: 1px solid #eef1f6;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* element-ui 的 inline 模式让表单项收缩宽度(inline-block),
|
|
|
+ 各控件按自身内容宽度渲染才会参差不齐;这里改成 flex:
|
|
|
+ 标签定宽、控件撑满剩余宽度,输入框与日期框因此等宽等高 */
|
|
|
+ :deep(.el-form-item) {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ margin: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ :deep(.el-form-item__label) {
|
|
|
+ flex: 0 0 auto;
|
|
|
+ padding-right: 8px;
|
|
|
+ line-height: 32px;
|
|
|
+ }
|
|
|
+
|
|
|
+ :deep(.el-form-item__content) {
|
|
|
+ display: block;
|
|
|
+ flex: 1 1 auto;
|
|
|
+ min-width: 0;
|
|
|
+ line-height: 32px;
|
|
|
+ }
|
|
|
+
|
|
|
+ :deep(.el-input),
|
|
|
+ :deep(.el-date-editor.el-input) {
|
|
|
+ width: 100%;
|
|
|
+ }
|
|
|
+ }
|
|
|
+</style>
|