This commit is contained in:
2026-06-29 14:56:28 +08:00
15 changed files with 6368 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
import request from '@/utils/request'
// 查询请购单列表
export function listPurchaseRequisition(query) {
return request({
url: '/erp/purchaseRequisition/list',
method: 'get',
params: query
})
}
// 查询请购单详细(含明细)
export function getPurchaseRequisition(reqId) {
return request({
url: '/erp/purchaseRequisition/' + reqId,
method: 'get'
})
}
// 新增请购单
export function addPurchaseRequisition(data) {
return request({
url: '/erp/purchaseRequisition',
method: 'post',
data
})
}
// 修改请购单
export function updatePurchaseRequisition(data) {
return request({
url: '/erp/purchaseRequisition',
method: 'put',
data
})
}
// 删除请购单
export function delPurchaseRequisition(reqIds) {
return request({
url: '/erp/purchaseRequisition/' + reqIds,
method: 'delete'
})
}
// 导出请购单
export function exportPurchaseRequisition(query) {
return request({
url: '/erp/purchaseRequisition/export',
method: 'post',
params: query,
responseType: 'blob'
})
}

View File

@@ -0,0 +1,862 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="80px">
<el-form-item label="请购部门" prop="reqDept">
<el-input v-model="queryParams.reqDept" placeholder="请购部门" clearable @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="品名" prop="itemName">
<el-input v-model="queryParams.itemName" placeholder="品名" clearable @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="状态" prop="formStatus">
<el-select v-model="queryParams.formStatus" placeholder="状态" clearable style="width:130px">
<el-option label="请购草稿" value="0" />
<el-option label="请购审批中" value="1" />
<el-option label="请购已通过" value="2" />
<el-option label="采购处理中" value="3" />
<el-option label="已完成" value="4" />
<el-option label="已驳回" value="5" />
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['erp:purchaseRequisition:add']">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate" v-hasPermi="['erp:purchaseRequisition:edit']">修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['erp:purchaseRequisition:remove']">删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['erp:purchaseRequisition:export']">导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<KLPTable v-loading="loading" :data="reqList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="序号" align="center" prop="reqId" width="70" />
<el-table-column label="请购部门" align="center" prop="reqDept" width="120" />
<el-table-column label="品名" align="center" prop="itemName" width="160" :show-overflow-tooltip="true" />
<el-table-column label="规格" align="center" prop="specification" width="140" :show-overflow-tooltip="true" />
<el-table-column label="请购量" align="center" prop="quantity" width="90" />
<el-table-column label="类别" align="center" prop="category" width="90" />
<el-table-column label="需求日期" align="center" prop="requiredDate" width="110" />
<el-table-column label="状态" align="center" prop="formStatus" width="100">
<template slot-scope="scope">
<el-tag :type="statusType(scope.row.formStatus)" size="mini">{{ statusText(scope.row.formStatus) }}</el-tag>
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" />
<el-table-column label="创建时间" align="center" prop="createTime" width="160">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="180">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-view" @click="handleView(scope.row)" v-hasPermi="['erp:purchaseRequisition:query']">查看</el-button>
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['erp:purchaseRequisition:edit']">修改</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['erp:purchaseRequisition:remove']">删除</el-button>
</template>
</el-table-column>
</KLPTable>
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
<!-- 新增/修改 弹窗 -->
<el-dialog :title="title" :visible.sync="open" width="800px" append-to-body class="pr-dialog" :close-on-click-modal="false">
<el-form :model="form" :rules="rules" ref="form" label-width="100px" size="small">
<div class="pr-section">请购信息</div>
<el-row :gutter="16">
<el-col :span="8">
<el-form-item label="请购部门" prop="reqDept">
<el-input v-model="form.reqDept" placeholder="请购部门" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="品名" prop="itemName">
<el-input v-model="form.itemName" placeholder="品名" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="规格" prop="specification">
<el-input v-model="form.specification" placeholder="规格" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="8">
<el-form-item label="单位" prop="unit">
<el-input v-model="form.unit" placeholder="单位" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="请购量" prop="quantity">
<el-input v-model="form.quantity" placeholder="请购量" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="类别" prop="category">
<el-input v-model="form.category" placeholder="类别" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="需求日期" prop="requiredDate">
<el-input v-model="form.requiredDate" placeholder="需求日期" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="使用部门" prop="useDept">
<el-input v-model="form.useDept" placeholder="使用部门" />
</el-form-item>
</el-col>
</el-row>
<el-form-item label="用途说明" prop="purposeDesc">
<el-input v-model="form.purposeDesc" type="textarea" :rows="2" placeholder="用途说明" />
</el-form-item>
<div class="pr-section">采购处理</div>
<el-row :gutter="16">
<el-col :span="8">
<el-form-item label="品检条件" prop="inspectionCondition">
<el-input v-model="form.inspectionCondition" placeholder="品检条件" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="试用天数" prop="trialDays">
<el-input v-model="form.trialDays" placeholder="试用天数" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="付款条件" prop="paymentTerms">
<el-input v-model="form.paymentTerms" placeholder="付款条件" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="前期采购记录" prop="prevPurchaseRecord">
<el-input v-model="form.prevPurchaseRecord" placeholder="前期采购记录" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="采购金额" prop="totalAmount">
<el-input v-model="form.totalAmount" placeholder="采购金额" />
</el-form-item>
</el-col>
</el-row>
<el-form-item label="采购拟办" prop="purchaseProposal">
<el-input v-model="form.purchaseProposal" type="textarea" :rows="2" placeholder="采购拟办" />
</el-form-item>
<div class="pr-section">
请购明细
<el-button type="primary" plain size="mini" icon="el-icon-plus" @click="addItem">加行</el-button>
<span class="pr-section-hint" v-if="form.items && form.items.length"> {{ form.items.length }} </span>
</div>
<el-table :data="form.items" border size="mini" max-height="280" style="margin-bottom:14px">
<el-table-column label="项次" width="60" align="center">
<template slot-scope="s">{{ s.$index + 1 }}</template>
</el-table-column>
<el-table-column label="品名" min-width="130">
<template slot-scope="s"><el-input v-model="s.row.itemName" size="mini" placeholder="品名" /></template>
</el-table-column>
<el-table-column label="规格" min-width="130">
<template slot-scope="s"><el-input v-model="s.row.specification" size="mini" placeholder="规格" /></template>
</el-table-column>
<el-table-column label="单位" width="80">
<template slot-scope="s"><el-input v-model="s.row.unit" size="mini" placeholder="单位" /></template>
</el-table-column>
<el-table-column label="请购量" width="100">
<template slot-scope="s"><el-input v-model="s.row.quantity" size="mini" placeholder="请购量" /></template>
</el-table-column>
<el-table-column label="操作" width="64" align="center" fixed="right">
<template slot-scope="s">
<i class="el-icon-delete pr-del" @click="removeItem(s.$index)" />
</template>
</el-table-column>
<template slot="empty"><span>加行添加明细</span></template>
</el-table>
<div class="pr-section">审批签名</div>
<el-row :gutter="16">
<el-col :span="8">
<el-form-item label="经办(请购)" prop="signRequestHandler">
<el-input v-model="form.signRequestHandler" placeholder="经办" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="主任(请购)" prop="signRequestDirector">
<el-input v-model="form.signRequestDirector" placeholder="主任" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="厂长(请购)" prop="signRequestFactoryMgr">
<el-input v-model="form.signRequestFactoryMgr" placeholder="厂长" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="8">
<el-form-item label="生产总经理" prop="signRequestGm">
<el-input v-model="form.signRequestGm" placeholder="生产总经理" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="经办(采购)" prop="signPurchaseHandler">
<el-input v-model="form.signPurchaseHandler" placeholder="经办" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="主任(采购)" prop="signPurchaseDirector">
<el-input v-model="form.signPurchaseDirector" placeholder="主任" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="8">
<el-form-item label="部长/厂长(采购)" prop="signPurchaseManager">
<el-input v-model="form.signPurchaseManager" placeholder="部长/厂长" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="董事长(采购)" prop="signPurchaseChairman">
<el-input v-model="form.signPurchaseChairman" placeholder="董事长" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="指定卸货位" prop="unloadLocation">
<el-input v-model="form.unloadLocation" placeholder="指定卸货位" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="12">
<el-form-item label="卸货其他位置" prop="unloadOther">
<el-input v-model="form.unloadOther" placeholder="卸货其他位置" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="状态" prop="formStatus">
<el-select v-model="form.formStatus" placeholder="状态" style="width:100%">
<el-option label="请购草稿" value="0" />
<el-option label="请购审批中" value="1" />
<el-option label="请购已通过" value="2" />
<el-option label="采购处理中" value="3" />
<el-option label="已完成" value="4" />
<el-option label="已驳回" value="5" />
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" :rows="2" placeholder="备注" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="cancel"> </el-button>
<el-button type="primary" :loading="buttonLoading" @click="submitForm"> </el-button>
</div>
</el-dialog>
<!-- 查看弹窗 -->
<el-dialog title="请购单详情" :visible.sync="viewOpen" width="700px" append-to-body class="pr-dialog">
<div class="pr-view">
<div class="pr-view-section">请购信息</div>
<el-row :gutter="16" class="pr-view-row">
<el-col :span="8"><label>请购部门</label><span>{{ viewForm.reqDept || '—' }}</span></el-col>
<el-col :span="8"><label>品名</label><span>{{ viewForm.itemName || '—' }}</span></el-col>
<el-col :span="8"><label>规格</label><span>{{ viewForm.specification || '—' }}</span></el-col>
</el-row>
<el-row :gutter="16" class="pr-view-row">
<el-col :span="8"><label>单位</label><span>{{ viewForm.unit || '—' }}</span></el-col>
<el-col :span="8"><label>请购量</label><span>{{ viewForm.quantity || '—' }}</span></el-col>
<el-col :span="8"><label>类别</label><span>{{ viewForm.category || '—' }}</span></el-col>
</el-row>
<el-row :gutter="16" class="pr-view-row">
<el-col :span="12"><label>需求日期</label><span>{{ viewForm.requiredDate || '—' }}</span></el-col>
<el-col :span="12"><label>使用部门</label><span>{{ viewForm.useDept || '—' }}</span></el-col>
</el-row>
<el-row class="pr-view-row">
<el-col><label>用途说明</label><span>{{ viewForm.purposeDesc || '—' }}</span></el-col>
</el-row>
<div class="pr-view-section">采购处理</div>
<el-row :gutter="16" class="pr-view-row">
<el-col :span="8"><label>品检条件</label><span>{{ viewForm.inspectionCondition || '—' }}</span></el-col>
<el-col :span="8"><label>试用天数</label><span>{{ viewForm.trialDays || '—' }}</span></el-col>
<el-col :span="8"><label>付款条件</label><span>{{ viewForm.paymentTerms || '—' }}</span></el-col>
</el-row>
<el-row :gutter="16" class="pr-view-row">
<el-col :span="12"><label>前期采购记录</label><span>{{ viewForm.prevPurchaseRecord || '—' }}</span></el-col>
<el-col :span="12"><label>采购金额</label><span>{{ viewForm.totalAmount || '—' }}</span></el-col>
</el-row>
<el-row class="pr-view-row">
<el-col><label>采购拟办</label><span>{{ viewForm.purchaseProposal || '—' }}</span></el-col>
</el-row>
<div class="pr-view-section">请购明细</div>
<el-table :data="viewForm.items || []" border size="mini" max-height="260" style="margin-bottom:14px">
<el-table-column label="项次" width="60" align="center">
<template slot-scope="s">{{ s.$index + 1 }}</template>
</el-table-column>
<el-table-column label="品名" prop="itemName" min-width="130" show-overflow-tooltip />
<el-table-column label="规格" prop="specification" min-width="130" show-overflow-tooltip />
<el-table-column label="单位" prop="unit" width="80" align="center" />
<el-table-column label="请购量" prop="quantity" width="100" align="right" />
<template slot="empty"><span>无明细</span></template>
</el-table>
<div class="pr-view-section">审批签名</div>
<el-row :gutter="16" class="pr-view-row">
<el-col :span="8"><label>经办(请购)</label><span>{{ viewForm.signRequestHandler || '—' }}</span></el-col>
<el-col :span="8"><label>主任(请购)</label><span>{{ viewForm.signRequestDirector || '—' }}</span></el-col>
<el-col :span="8"><label>厂长(请购)</label><span>{{ viewForm.signRequestFactoryMgr || '—' }}</span></el-col>
</el-row>
<el-row :gutter="16" class="pr-view-row">
<el-col :span="8"><label>生产总经理</label><span>{{ viewForm.signRequestGm || '—' }}</span></el-col>
<el-col :span="8"><label>经办(采购)</label><span>{{ viewForm.signPurchaseHandler || '—' }}</span></el-col>
<el-col :span="8"><label>主任(采购)</label><span>{{ viewForm.signPurchaseDirector || '—' }}</span></el-col>
</el-row>
<el-row :gutter="16" class="pr-view-row">
<el-col :span="8"><label>部长/厂长(采购)</label><span>{{ viewForm.signPurchaseManager || '—' }}</span></el-col>
<el-col :span="8"><label>董事长(采购)</label><span>{{ viewForm.signPurchaseChairman || '—' }}</span></el-col>
<el-col :span="8"><label>指定卸货位</label><span>{{ viewForm.unloadLocation || '—' }}</span></el-col>
</el-row>
<el-row :gutter="16" class="pr-view-row">
<el-col :span="12"><label>卸货其他位置</label><span>{{ viewForm.unloadOther || '—' }}</span></el-col>
<el-col :span="12"><label>状态</label><span>{{ statusText(viewForm.formStatus) }}</span></el-col>
</el-row>
<el-row class="pr-view-row">
<el-col><label>备注</label><span>{{ viewForm.remark || '—' }}</span></el-col>
</el-row>
</div>
<div slot="footer" class="dialog-footer">
<el-button @click="viewOpen = false"> </el-button>
</div>
<div slot="footer" class="dialog-footer">
<el-button type="primary" plain icon="el-icon-download" :loading="printing" @click="exportPdf">导出PDF</el-button>
<el-button @click="viewOpen = false"> </el-button>
</div>
</el-dialog>
<!-- A4 打印模板屏幕外渲染 html2canvas 截图 -->
<div class="pr-print-wrap" v-show="printing">
<div class="pr-print" ref="printTemplate">
<h1 class="pp-title">科仑普重工有限公司</h1>
<h2 class="pp-subtitle"> </h2>
<!-- 表1基本信息 -->
<table class="pp-tb">
<tr>
<td class="pp-lbl" style="width:9%">请购部门</td>
<td class="pp-val" style="width:12%">{{ printData.reqDept || '' }}</td>
<td class="pp-lbl" style="width:6%"> </td>
<td class="pp-val" style="width:15%">{{ printData.itemName || '' }}</td>
<td class="pp-lbl" style="width:6%"> </td>
<td class="pp-val" style="width:12%">{{ printData.specification || '' }}</td>
<td class="pp-lbl" style="width:6%">单位</td>
<td class="pp-val" style="width:8%">{{ printData.unit || '' }}</td>
<td class="pp-lbl" style="width:8%">请购量</td>
<td class="pp-val" style="width:10%">{{ printData.quantity || '' }}</td>
<td class="pp-lbl" style="width:6%">用途</td>
<td class="pp-val" style="width:8%">{{ printData.category || '' }}</td>
</tr>
<tr>
<td class="pp-lbl"> </td>
<td colspan="11" class="pp-val" style="text-align:left">
<span :class="ppCheck(printData.category === '原料物料')"></span>原料物料
<span :class="ppCheck(printData.category === '设备增添')"></span>设备增添
<span :class="ppCheck(printData.category === '工程劳务')"></span>工程劳务
<span :class="ppCheck(printData.category === '其它用途')"></span>其它用途
</td>
</tr>
<tr>
<td class="pp-lbl">需求日期</td>
<td class="pp-val">{{ printData.requiredDate || '' }}</td>
<td class="pp-lbl" colspan="1">用途说明</td>
<td class="pp-val" colspan="5">{{ printData.purposeDesc || '' }}</td>
<td class="pp-lbl">使用部门</td>
<td class="pp-val" colspan="3">{{ printData.useDept || '' }}</td>
</tr>
</table>
<!-- 表2明细8行分两栏 -->
<div class="pp-sec">明细</div>
<table class="pp-tb pp-it">
<thead>
<tr>
<th style="width:5%">项次</th>
<th style="width:15%">品名</th>
<th style="width:15%">规格</th>
<th style="width:8%">单位</th>
<th style="width:10%">请购量</th>
<th style="width:5%">项次</th>
<th style="width:15%">品名</th>
<th style="width:15%">规格</th>
<th style="width:8%">单位</th>
<th style="width:10%">请购量</th>
</tr>
</thead>
<tbody>
<tr v-for="idx in 4" :key="idx">
<td style="text-align:center">{{ idx }}</td>
<td>{{ printData.items && printData.items[idx-1] ? (printData.items[idx-1].itemName || '') : '' }}</td>
<td>{{ printData.items && printData.items[idx-1] ? (printData.items[idx-1].specification || '') : '' }}</td>
<td style="text-align:center">{{ printData.items && printData.items[idx-1] ? (printData.items[idx-1].unit || '') : '' }}</td>
<td style="text-align:right;padding-right:8px">{{ printData.items && printData.items[idx-1] ? (printData.items[idx-1].quantity || '') : '' }}</td>
<td style="text-align:center">{{ idx + 4 }}</td>
<td>{{ printData.items && printData.items[idx+3] ? (printData.items[idx+3].itemName || '') : '' }}</td>
<td>{{ printData.items && printData.items[idx+3] ? (printData.items[idx+3].specification || '') : '' }}</td>
<td style="text-align:center">{{ printData.items && printData.items[idx+3] ? (printData.items[idx+3].unit || '') : '' }}</td>
<td style="text-align:right;padding-right:8px">{{ printData.items && printData.items[idx+3] ? (printData.items[idx+3].quantity || '') : '' }}</td>
</tr>
</tbody>
</table>
<!-- 表3采购处理 -->
<table class="pp-tb">
<tr>
<td class="pp-lbl" style="width:10%">品检条件</td>
<td colspan="5" class="pp-val" style="text-align:left;font-size:9pt">
<span :class="ppCheck(printData.inspectionCondition && printData.inspectionCondition.includes('一般'))"></span>1.一般规格/目视检验
<span :class="ppCheck(printData.inspectionCondition && printData.inspectionCondition.includes('品保'))"></span>2.品保检验品
<span :class="ppCheck(printData.inspectionCondition && printData.inspectionCondition.includes('工程'))"></span>3.工程劳务/特殊规格品
<span :class="ppCheck(printData.inspectionCondition && printData.inspectionCondition.includes('试用'))"></span>4.试用
{{ printData.trialDays || '____' }} 天后验收
</td>
</tr>
<tr>
<td class="pp-lbl">前期采购记录</td>
<td colspan="5" class="pp-val">{{ printData.prevPurchaseRecord || '' }}</td>
</tr>
<tr>
<td class="pp-lbl">采购拟办</td>
<td colspan="5" class="pp-val">{{ printData.purchaseProposal || '' }}</td>
</tr>
<tr>
<td class="pp-lbl">付款条件</td>
<td class="pp-val" colspan="2">{{ printData.paymentTerms || '' }}</td>
<td class="pp-lbl">采购金额(人民币)</td>
<td class="pp-val" colspan="2" style="font-size:9pt">
{{ printData.totalAmount || '' }}
</td>
</tr>
</table>
<!-- 表4签名区 -->
<table class="pp-tb pp-sig">
<tr>
<th colspan="4" class="pp-lbl" style="font-size:10pt">采购单位</th>
<th colspan="4" class="pp-lbl" style="font-size:10pt">请购单位</th>
</tr>
<tr>
<td class="pp-lbl">董事长</td>
<td class="pp-lbl">部长/厂长</td>
<td class="pp-lbl">主任</td>
<td class="pp-lbl">经办</td>
<td class="pp-lbl">生产总经理</td>
<td class="pp-lbl">厂长</td>
<td class="pp-lbl">主任</td>
<td class="pp-lbl">经办</td>
</tr>
<tr>
<td class="pp-val">{{ printData.signPurchaseChairman || '' }}</td>
<td class="pp-val">{{ printData.signPurchaseManager || '' }}</td>
<td class="pp-val">{{ printData.signPurchaseDirector || '' }}</td>
<td class="pp-val">{{ printData.signPurchaseHandler || '' }}</td>
<td class="pp-val">{{ printData.signRequestGm || '' }}</td>
<td class="pp-val">{{ printData.signRequestFactoryMgr || '' }}</td>
<td class="pp-val">{{ printData.signRequestDirector || '' }}</td>
<td class="pp-val">{{ printData.signRequestHandler || '' }}</td>
</tr>
</table>
<!-- 表5底部 -->
<table class="pp-tb">
<tr>
<td class="pp-lbl" style="width:12%">物品进厂<br>指定卸货位</td>
<td class="pp-val" style="width:20%">{{ printData.unloadLocation || '' }}</td>
<td class="pp-lbl" style="width:8%">置于</td>
<td class="pp-val" style="width:20%">{{ printData.unloadOther || '' }}</td>
<td class="pp-lbl" style="width:10%">状态</td>
<td class="pp-val" style="width:20%">{{ statusText(printData.formStatus) }}</td>
</tr>
</table>
</div>
</div>
</div>
</template>
<script>
import {
listPurchaseRequisition,
getPurchaseRequisition,
addPurchaseRequisition,
updatePurchaseRequisition,
delPurchaseRequisition
} from '@/api/erp/purchaseRequisition'
export default {
name: 'PurchaseRequisition',
data() {
return {
loading: true,
buttonLoading: false,
printing: false,
showSearch: true,
ids: [],
single: true,
multiple: true,
total: 0,
reqList: [],
title: '',
open: false,
viewOpen: false,
queryParams: {
pageNum: 1,
pageSize: 10,
reqDept: undefined,
itemName: undefined,
formStatus: undefined
},
form: {},
viewForm: {},
printData: {},
rules: {}
}
},
created() {
this.getList()
},
methods: {
getList() {
this.loading = true
listPurchaseRequisition(this.queryParams).then(res => {
this.reqList = res.rows || []
this.total = res.total || 0
}).catch(() => {
this.reqList = []
this.total = 0
}).finally(() => {
this.loading = false
})
},
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
resetQuery() {
this.$refs.queryForm && this.$refs.queryForm.resetFields()
this.handleQuery()
},
handleSelectionChange(selection) {
this.ids = selection.map(r => r.reqId)
this.single = selection.length !== 1
this.multiple = !selection.length
},
// 新增
handleAdd() {
this.title = '新增请购单'
this.form = {
reqDept: '', itemName: '', specification: '', unit: '', quantity: '',
category: '', requiredDate: '', purposeDesc: '', useDept: '',
inspectionCondition: '', trialDays: '', prevPurchaseRecord: '',
purchaseProposal: '', paymentTerms: '', totalAmount: '',
signPurchaseChairman: '', signPurchaseManager: '', signPurchaseDirector: '',
signPurchaseHandler: '', signRequestGm: '', signRequestFactoryMgr: '',
signRequestDirector: '', signRequestHandler: '',
unloadLocation: '', unloadOther: '', formStatus: '0', remark: '',
items: []
}
this.open = true
},
// 修改
handleUpdate(row) {
const reqId = row.reqId || this.ids[0]
this.title = '修改请购单'
this.buttonLoading = true
getPurchaseRequisition(reqId).then(res => {
const d = res.data || {}
this.form = {
reqId: d.reqId,
reqDept: d.reqDept, itemName: d.itemName, specification: d.specification,
unit: d.unit, quantity: d.quantity,
category: d.category, requiredDate: d.requiredDate,
purposeDesc: d.purposeDesc, useDept: d.useDept,
inspectionCondition: d.inspectionCondition, trialDays: d.trialDays,
prevPurchaseRecord: d.prevPurchaseRecord, purchaseProposal: d.purchaseProposal,
paymentTerms: d.paymentTerms, totalAmount: d.totalAmount,
signPurchaseChairman: d.signPurchaseChairman, signPurchaseManager: d.signPurchaseManager,
signPurchaseDirector: d.signPurchaseDirector, signPurchaseHandler: d.signPurchaseHandler,
signRequestGm: d.signRequestGm, signRequestFactoryMgr: d.signRequestFactoryMgr,
signRequestDirector: d.signRequestDirector, signRequestHandler: d.signRequestHandler,
unloadLocation: d.unloadLocation, unloadOther: d.unloadOther,
formStatus: d.formStatus, remark: d.remark,
items: d.items || []
}
this.open = true
}).finally(() => { this.buttonLoading = false })
},
// 查看
handleView(row) {
this.viewForm = {}
this.viewOpen = true
getPurchaseRequisition(row.reqId).then(res => {
this.viewForm = res.data || {}
})
},
cancel() {
this.open = false
},
submitForm() {
this.$refs['form'].validate(valid => {
if (!valid) return
this.buttonLoading = true
const api = this.form.reqId ? updatePurchaseRequisition : addPurchaseRequisition
api(this.form).then(() => {
this.$modal.msgSuccess('保存成功')
this.open = false
this.getList()
}).finally(() => { this.buttonLoading = false })
})
},
// 删除
handleDelete(row) {
const reqIds = row.reqId ? [row.reqId] : this.ids
this.$modal.confirm('确认删除所选请购单?').then(() => {
return delPurchaseRequisition(reqIds.join(','))
}).then(() => {
this.$modal.msgSuccess('删除成功')
this.getList()
}).catch(() => {})
},
// 导出 Excel
handleExport() {
this.download('erp/purchaseRequisition/export', { ...this.queryParams }, `请购单_${new Date().getTime()}.xlsx`)
},
// 导出 PDFA4 表单格式)
async exportPdf() {
this.printing = true
this.printData = { ...this.viewForm }
await this.$nextTick()
await this.$nextTick()
try {
const html2canvas = (await import('html2canvas')).default
const { jsPDF } = await import('jspdf')
const el = this.$refs.printTemplate
const canvas = await html2canvas(el, {
scale: 2,
useCORS: true,
backgroundColor: '#ffffff',
logging: false
})
const pdf = new jsPDF({ orientation: 'portrait', unit: 'mm', format: 'a4' })
const pw = pdf.internal.pageSize.getWidth()
const ph = pdf.internal.pageSize.getHeight()
const mg = 8
const printW = pw - mg * 2
const imgW = canvas.width
const imgH = canvas.height
const ratio = printW / imgW
const totalH = imgH * ratio
const pageH = ph - mg * 2
let srcY = 0
let rem = totalH
let page = 0
while (rem > 0) {
if (page > 0) pdf.addPage()
const sliceH = Math.min(pageH, rem)
const slicePx = sliceH / ratio
const sc = document.createElement('canvas')
sc.width = imgW
sc.height = slicePx
sc.getContext('2d').drawImage(canvas, 0, srcY, imgW, slicePx, 0, 0, imgW, slicePx)
pdf.addImage(sc.toDataURL('image/jpeg', 0.95), 'JPEG', mg, mg, printW, sliceH)
srcY += slicePx
rem -= sliceH
page++
}
const reqId = this.viewForm.reqId || 'export'
pdf.save(`请购单_${reqId}.pdf`)
} catch (e) {
this.$message.error('PDF导出失败' + (e.message || e))
} finally {
this.printing = false
this.printData = {}
}
},
// 明细操作
addItem() {
const last = this.form.items[this.form.items.length - 1]
this.form.items.push({
itemName: '', specification: '', unit: '', quantity: ''
})
},
removeItem(index) {
this.form.items.splice(index, 1)
},
// 状态
statusText(s) {
const map = { '0': '请购草稿', '1': '审批中', '2': '已通过', '3': '采购处理中', '4': '已完成', '5': '已驳回' }
return map[s] || s || '—'
},
statusType(s) {
const map = { '0': 'info', '1': 'warning', '2': 'success', '3': 'warning', '4': 'success', '5': 'danger' }
return map[s] || 'info'
},
// PDF 复选框
ppCheck(cond) {
return cond ? 'pp-chk pp-on' : 'pp-chk'
}
}
}
</script>
<style lang="scss" scoped>
$accent: #5b8db8;
$sub: #909399;
.pr-section {
font-size: 13px;
font-weight: 600;
color: #303133;
border-left: 3px solid $accent;
padding-left: 8px;
margin: 16px 0 12px;
.pr-section-hint {
float: right;
font-weight: 400;
color: $sub;
font-size: 12px;
}
}
.pr-del {
color: #c45656;
cursor: pointer;
}
.pr-view {
padding: 0 4px;
.pr-view-section {
font-size: 13px;
font-weight: 600;
color: #303133;
border-left: 3px solid $accent;
padding-left: 8px;
margin: 14px 0 10px;
&:first-child { margin-top: 0; }
}
.pr-view-row {
margin-bottom: 8px;
label {
display: block;
font-size: 12px;
color: $sub;
margin-bottom: 2px;
}
span {
font-size: 13px;
color: #303133;
}
}
}
.pr-dialog {
::v-deep .el-dialog__body {
padding-top: 10px;
}
}
/* ===== A4 打印模板 ===== */
.pr-print-wrap {
position: fixed;
left: -100000px;
top: 0;
z-index: -1;
}
.pr-print {
width: 190mm;
background: #fff;
padding: 6mm 8mm;
font-family: '宋体', SimSun, serif;
color: #000;
box-sizing: border-box;
line-height: 1.3;
}
.pp-title {
text-align: center;
font-size: 13pt;
font-weight: 700;
margin: 0 0 2px;
letter-spacing: 2px;
}
.pp-subtitle {
text-align: center;
font-size: 14pt;
font-weight: 700;
margin: 0 0 5mm;
letter-spacing: 6px;
}
.pp-sec {
font-size: 10pt;
font-weight: 700;
margin: 4mm 0 2mm;
}
.pp-tb {
width: 100%;
border-collapse: collapse;
margin-bottom: 2mm;
font-size: 9pt;
}
.pp-tb td,
.pp-tb th {
border: 1px solid #000;
padding: 3px 4px;
vertical-align: middle;
}
.pp-tb .pp-lbl {
background: #f5f5f5;
font-weight: 600;
text-align: center;
white-space: nowrap;
}
.pp-tb .pp-val {
text-align: center;
}
.pp-tb.pp-it th {
background: #f5f5f5;
text-align: center;
font-weight: 600;
font-size: 8.5pt;
}
/* 签名区加高 */
.pp-sig td,
.pp-sig th {
padding: 5px 4px;
}
/* 复选框 */
.pp-chk {
font-family: '宋体', SimSun, serif;
}
.pp-chk.pp-on {
font-weight: 700;
}
</style>