feat(heli): 回滚入库管理打印功能

This commit is contained in:
zxy 2026-04-08 11:07:57 +08:00
parent 0beec72e20
commit 29d7dc1d5f
2 changed files with 398 additions and 225 deletions

View File

@ -29,10 +29,10 @@
<el-col :span="24">
<el-form-item prop="stockInType" label="入库类型">
<el-select
v-model="formData.stockInType" clearable style="width: 100%" @change="handleStockType"
v-model="formData.stockInType" clearable style="width: 100%" @change="handleStockType"
:disabled="ctrView || ctrSave">
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.HELI_STORAGE_IN_TYPE)" :key="dict.value"
v-for="dict in getIntDictOptions(DICT_TYPE.HELI_STORAGE_IN_TYPE)" :key="dict.value"
:label="dict.label" :value="dict.value" />
</el-select>
</el-form-item>
@ -45,8 +45,8 @@ v-for="dict in getIntDictOptions(DICT_TYPE.HELI_STORAGE_IN_TYPE)" :key="dict.val
<el-form-item prop="industry" label="单据状态">
<el-select v-model="formData.status" placeholder="下拉选择" clearable class="!w-700px" disabled>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.HELI_STORAGE_STATUS)" :key="dict.value"
:label="dict.label" :value="dict.value" />
v-for="dict in getIntDictOptions(DICT_TYPE.HELI_STORAGE_STATUS)" :key="dict.value"
:label="dict.label" :value="dict.value" />
</el-select>
</el-form-item>
</el-col>
@ -61,8 +61,8 @@ v-for="dict in getIntDictOptions(DICT_TYPE.HELI_STORAGE_IN_TYPE)" :key="dict.val
@click="openProjectPurchaseorderDialog" /></template>
</el-input>
</div>
<!-- <el-input v-model="formData.headerNo" class="!w-700px"-->
<!-- v-bind:disabled="ctrView || ctrSave || enableHeadNo" />-->
<!-- <el-input v-model="formData.headerNo" class="!w-700px"-->
<!-- v-bind:disabled="ctrView || ctrSave || enableHeadNo" />-->
</el-form-item>
</el-col>
</el-row>
@ -73,7 +73,7 @@ v-for="dict in getIntDictOptions(DICT_TYPE.HELI_STORAGE_IN_TYPE)" :key="dict.val
<el-form-item label="单据日期" prop="createTime">
<!-- {{ formatDate(formData.createTime, 'YYYY-MM-DD HH:mm:ss') }} -->
<el-date-picker
v-model="formData.createTime" value-format="x" placeholder="单据日期" disabled
v-model="formData.createTime" value-format="x" placeholder="单据日期" disabled
class="!w-400px" />
</el-form-item>
</el-col>
@ -82,7 +82,7 @@ v-model="formData.createTime" value-format="x" placeholder="单据日期" disabl
<el-col :span="24">
<el-form-item prop="whId" label="入库仓库">
<el-select
v-model="formData.whId" placeholder="下拉选择" clearable class="!w-400px" @change="handleWh"
v-model="formData.whId" placeholder="下拉选择" clearable class="!w-400px" @change="handleWh"
:disabled="ctrView || ctrSave">
<el-option v-for="dict in whList" :key="dict.id" :label="dict.whName" :value="dict.id" />
</el-select>
@ -135,11 +135,11 @@ v-model="formData.whId" placeholder="下拉选择" clearable class="!w-400px" @c
<el-col>
<el-card class="hl-incard">
<el-col>
<el-button class="hl-addbutton" type="primary" size="large" @click="openMatForm"
:disabled="ctrView || ctrSave">新增</el-button>
<el-button class="hl-addbutton" type="primary" size="large" @click="openMatForm"
:disabled="ctrView || ctrSave">新增</el-button>
<el-button @click="openPnForm" type="success" v-if="btnSave" size="large">新增物料</el-button></el-col>
<el-form
ref="matSubFormRef" :model="formData.matItemDOList" :rules="subFormRules"
ref="matSubFormRef" :model="formData.matItemDOList" :rules="subFormRules"
v-loading="subFormLoading" label-width="0">
<el-table :data="formData.matItemDOList" class="hl-table">
<el-table-column type="index" label="序号" min-width="80" align="center" fixed />
@ -147,9 +147,9 @@ ref="matSubFormRef" :model="formData.matItemDOList" :rules="subFormRules"
<template #header> <span class="hl-table_header">*</span> 物料编码</template>
<template #default="scope">
<el-form-item :prop="`${scope.$index}.matCode`" :rules="subFormRules.matCode" class="mb-0px!">
<el-input class="!w-265px" placeholder="物料编码" :disabled="true || ctrView || ctrSave" v-model="scope.row.matCode" readonly>
<!-- <template #append ><el-button @click="openMatForm" > <Icon icon="ep:search" class="mr-5px" /> </el-button></template> -->
</el-input>
<el-input class="!w-265px" placeholder="物料编码" :disabled="true || ctrView || ctrSave" v-model="scope.row.matCode" readonly>
<!-- <template #append ><el-button @click="openMatForm" > <Icon icon="ep:search" class="mr-5px" /> </el-button></template> -->
</el-input>
</el-form-item>
</template>
</el-table-column>
@ -177,7 +177,7 @@ ref="matSubFormRef" :model="formData.matItemDOList" :rules="subFormRules"
<template #default="scope">
<el-form-item :prop="`${scope.$index}.rgId`" :rules="subFormRules.rgId" class="mb-0px!">
<el-select
v-model="scope.row.rgId" placeholder="" style="width: 100%" @change="handleRg(scope)"
v-model="scope.row.rgId" placeholder="" style="width: 100%" @change="handleRg(scope)"
:disabled="ctrView || ctrSave">
<el-option v-for="dict in rgList" :key="dict.id" :label="dict.rg_name" :value="dict.id" />
</el-select>
@ -191,10 +191,10 @@ v-model="scope.row.rgId" placeholder="" style="width: 100%" @change="handleRg(sc
<template #default="scope">
<el-form-item :prop="`${scope.$index}.pnId`" :rules="subFormRules.pnId" class="mb-0px!">
<el-select
v-model="scope.row.pnId" placeholder="" style="width: 100%"
v-model="scope.row.pnId" placeholder="" style="width: 100%"
:disabled="ctrView || ctrSave">
<el-option
v-for="dict in scope.row.pnlist" :key="dict.id" :label="dict.pn_name"
v-for="dict in scope.row.pnlist" :key="dict.id" :label="dict.pn_name"
:value="dict.id" />
</el-select>
</el-form-item>
@ -206,7 +206,7 @@ v-for="dict in scope.row.pnlist" :key="dict.id" :label="dict.pn_name"
<template #default="scope">
<el-form-item
:prop="`${scope.$index}.storageOkQty`" :rules="subFormRules.storageOkQty"
:prop="`${scope.$index}.storageOkQty`" :rules="subFormRules.storageOkQty"
class="mb-0px!">
<el-input v-model="scope.row.storageOkQty" :disabled="ctrView || ctrSave" />
</el-form-item>
@ -218,8 +218,8 @@ v-for="dict in scope.row.pnlist" :key="dict.id" :label="dict.pn_name"
<template #default="scope">
<el-form-item
:prop="`${scope.$index}.price`" :rules="subFormRules.price"
class="mb-0px!">
:prop="`${scope.$index}.price`" :rules="subFormRules.price"
class="mb-0px!">
<el-input v-model="scope.row.price" :disabled="ctrView || ctrSave" />
</el-form-item>
</template>
@ -230,8 +230,8 @@ v-for="dict in scope.row.pnlist" :key="dict.id" :label="dict.pn_name"
<template #default="scope">
<el-form-item
:prop="`${scope.$index}.price`"
class="mb-0px!">
:prop="`${scope.$index}.price`"
class="mb-0px!">
<el-input v-model="scope.row.price" :disabled="ctrView || ctrSave" />
</el-form-item>
</template>
@ -261,7 +261,7 @@ v-for="dict in scope.row.pnlist" :key="dict.id" :label="dict.pn_name"
<template #default="scope">
<el-button
link type="danger" @click.prevent="handleDelete2(scope.$index)"
link type="danger" @click.prevent="handleDelete2(scope.$index)"
:disabled="ctrView || ctrDelete">
删除
</el-button>
@ -284,7 +284,7 @@ link type="danger" @click.prevent="handleDelete2(scope.$index)"
<el-card class="hl-incard">
<el-col>
<el-upload
ref="matUploadRef" :file-list="matUploadFiles" multiple :action="uploadUrl" :headers="{
ref="matUploadRef" :file-list="matUploadFiles" multiple :action="uploadUrl" :headers="{
Authorization: 'Bearer ' + getAccessToken(),
'tenant-id': getTenantId()
}" name="files" :show-file-list="false" :auto-upload="false" :data="matUploadData" :on-change="matUploadChange"
@ -296,7 +296,7 @@ ref="matUploadRef" :file-list="matUploadFiles" multiple :action="uploadUrl" :hea
</el-upload>
</el-col>
<el-table
:data="formData.attachments" class="hl-table" v-loading.fullscreen.lock="uploading"
:data="formData.attachments" class="hl-table" v-loading.fullscreen.lock="uploading"
element-loading-text="附件上传中..." element-loading-background="rgba(122, 122, 122, 0.6)">
<el-table-column prop="name" label="文件名称" align="center">
<!-- <template #default="scope">
@ -310,12 +310,12 @@ ref="matUploadRef" :file-list="matUploadFiles" multiple :action="uploadUrl" :hea
<template #default="scope">
<el-button
link type="danger" size="small" :disabled="ctrView || ctrDelete"
link type="danger" size="small" :disabled="ctrView || ctrDelete"
@click="handleDeleteAttachment(scope.$index, scope.row.businessFileType)">
删除
</el-button>
<el-button
link type="primary" size="small" :disabled="ctrView || ctrDelete"
link type="primary" size="small" :disabled="ctrView || ctrDelete"
@click="downloadAttachment(scope.row.name, scope.row.url)">
下载
</el-button>
@ -335,7 +335,7 @@ link type="primary" size="small" :disabled="ctrView || ctrDelete"
<el-button @click="isPrint()" type="primary" size="large" :loading="printLoading" > </el-button>
<el-button @click="submitForm" type="success" v-if="btnSave&&formData.status ==1" size="large"> </el-button>
<el-button @click="handleStatus(2)" type="primary" v-if="btnSave" size="large"> </el-button>
<!-- <el-button @click="handleStatus(3)" type="danger" v-if="btnCancel&&formData.status != 2" size="large"> </el-button>-->
<!-- <el-button @click="handleStatus(3)" type="danger" v-if="btnCancel&&formData.status != 2" size="large"> </el-button>-->
<el-button @click="handleDelete" type="danger" v-if="btnCancel&&formData.status ==1" size="large"> </el-button>
</template>
@ -378,9 +378,9 @@ link type="primary" size="small" :disabled="ctrView || ctrDelete"
</el-row>
</el-card>
</el-form>
<!-- <div class="hl-footer text-center">-->
<!-- -->
<!-- </div>-->
<!-- <div class="hl-footer text-center">-->
<!-- -->
<!-- </div>-->
</el-card>
<!-- 表单弹窗物料列表 -->
<materials ref="matOpenFormRef" @success="getList" />
@ -390,7 +390,98 @@ link type="primary" size="small" :disabled="ctrView || ctrDelete"
<purchaseorderDialog ref="projectPurchaseorderDialog" @success="handleSelectedProjectPurchaseorder" />
<!-- 表单弹窗新增物料 -->
<MaterialForm ref="materialOpenFormRef" @success="getList" />
<PrintRef ref="printFormRef" />
<el-dialog v-model="printDialogVisible" width="80%" title="入库单打印" :close-on-click-modal="false">
<div id="printArea" class="print-content">
<div class="print-header">
<div class="order-info">
<div style="display: flex;">
<span style="width: 210px;">编号{{ printData.stockNo}}</span>
<span style="margin-left:20px; width: 170px;">入库日期{{ formatDate(printData.createTime) }}</span>
<span style="margin-left:20px;width: 250px">供应商{{ printData.supplierName }}</span>
</div>
<!-- <div style="display: flex;">
<span style="margin-left:20px;width: 110px">联系人{{ printData.contactName }}</span>
<span style="margin-left:20px;width: 150px">电话{{ printData.contactMobile }}</span>
</div> -->
</div>
</div>
<table class="print-table">
<colgroup>
<col style="width: 10%;" />
<col style="width: 10%;" />
<col style="width: 10%;" />
<col style="width: 10%;" />
<col style="width: 10%;" />
<col style="width: 10%;" />
<col style="width: 10%;" />
<col style="width: 10%;" />
<col style="width: 10%;" />
<col style="width: 10%;" />
</colgroup>
<thead>
<tr>
<th>序号</th>
<th>物料号</th>
<th>零件名称</th>
<th>规格</th>
<th>单位</th>
<th>入库数量</th>
<th>单价()</th>
<th>小计()</th>
<th>项目名称</th>
<th>备注</th>
</tr>
</thead>
<tbody>
<tr v-for="(item, index) in 17" :key="index">
<td>{{ index + 1 }}</td>
<td>{{ printData.storageMatDOList[index]?.matCode || '' }}</td>
<td>{{ printData.storageMatDOList[index]?.matName ? limitTo20Chars(printData.storageMatDOList[index].matName) : '' }}</td>
<td>{{ printData.storageMatDOList[index]?.mtSpec || '' }}</td>
<td>{{ printData.storageMatDOList[index]?.matUnit || '' }}</td>
<td>{{ printData.storageMatDOList[index]?.storageOkQty || '' }}</td>
<td>{{ printData.storageMatDOList[index]?.unitPrice || '' }}</td>
<td>{{ printData.storageMatDOList[index]?.totalPrice || '' }}</td>
<td>{{ printData.storageMatDOList[index]?.projectName || '' }}</td>
<td>{{ printData.storageMatDOList[index]?.description || '' }}</td>
</tr>
<!-- <tr>
<td colspan="9"></td>
<td style="font-weight: bold;">合计</td>
<td style="font-weight: bold;">{{ printData.estimatedPriceSum }}</td>
</tr> -->
</tbody>
</table>
<div class="order-info" style="margin-top: 10px;border-bottom: 1px solid #ccc;padding-bottom: 10px;">
<div style="display: flex;width: 40%;">
<span >经手人:{{ printData.userName }}</span>
</div>
<div style="display: flex;width: 20%;justify-content: center;">
<!-- <span style="margin-left:20px;width: 150px">审核{{ printData.auditorName }}</span> -->
<!-- <span style="margin-left:20px;width: 120px">仓库签字:</span> -->
</div>
<div style="display: flex; width: 40%;justify-content: right;">
<span style="margin-left:20px;width: 150px">仓库签字:{{ printData.signature }}</span>
<span style="margin-left:20px;width: 150px">日期:{{ printData.date }}</span>
<!-- <span style="margin-left:20px;width: 150px">接收人{{ printData.username }}</span> -->
<!-- <span style="margin-left:20px;width: 150px">电话{{ printData.userMobile }}</span> -->
</div>
</div>
</div>
<template #footer>
<el-button @click="printDialogVisible = false">关闭</el-button>
<el-button type="primary" @click="doPrint">打印</el-button>
</template>
</el-dialog>
</template>
@ -421,7 +512,6 @@ import projects from './subproject.vue'
import {Search} from "@element-plus/icons-vue";
import purchaseorderDialog from '@/views/heli/outsourcestock/purchaseorderDialog.vue'
import MaterialForm from '@/views/heli/material/MaterialForm.vue'
import PrintRef from './print.vue'
import * as StorageinApi from "@/api/heli/storagein";
import * as storageInventoryApi from "@/api/heli/storageinventory";
@ -516,11 +606,11 @@ const openMatForm = () => {
// }
// formData.value.whId
console.log(formData.value.headerId)
if (formData.value.stockInType==1&&formData.value.headerNo!=null&&formData.value.headerNo!=undefined&&formData.value.headerNo!=''){
matOpenFormRef1.value.open(formData.value.whId,'in',formData.value.headerId)
if (formData.value.stockInType==1&&formData.value.headerNo!=null&&formData.value.headerNo!=undefined&&formData.value.headerNo!=''){
matOpenFormRef1.value.open(formData.value.whId,'in',formData.value.headerId)
}else {
matOpenFormRef.value.open(formData.value.whId,'in')
}
matOpenFormRef.value.open(formData.value.whId,'in')
}
}
const openPnForm = () => {
@ -538,33 +628,120 @@ function formatDate(val) {
}
const printLoading = ref(false)
const printFormRef = ref()
//
const printDialogVisible = ref(false)
const printData = ref({})
function openPrintDialog(data) {
printData.value = data
printDialogVisible.value = true
}
const isPrint = async () => {
printLoading.value = true
printLoading.value = true
try {
const newVar = await StorageApi.isPrint(query.id)
const data = newVar.storageMatDOList?.map((item, idx) => ({
编号: idx + 1,
物料号: item.matCode || '',
零件名称: item.matName ? (item.matName.length > 20 ? item.matName.slice(0, 20) : item.matName) : '',
规格: item.mtSpec || '',
单位: item.matUnit || '',
入库数量: item.storageOkQty || '',
单价: item.unitPrice || '',
小计: item.totalPrice || '',
项目名称: item.projectName || '',
备注: item.description || ''
})) || []
// 17
const emptyRow = { 编号: '', 物料号: '', 零件名称: '', 规格: '', 单位: '', 入库数量: '', 单价: '', 小计: '', 项目名称: '', 备注: '' }
while (data.length < 17) {
data.push({ ...emptyRow, 编号: data.length + 1 })
}
printFormRef.value?.open(data, '', 'detail')
var newVar = await StorageApi.isPrint(query.id);
console.log(newVar)
openPrintDialog(newVar)
} finally {
printLoading.value = false
}
}
function doPrint() {
//
const printContent = document.getElementById('printArea')
if (!printContent) return
const iframe = document.createElement('iframe')
iframe.style.position = 'absolute'
iframe.style.width = '0'
iframe.style.height = '0'
iframe.style.border = 'none'
document.body.appendChild(iframe)
const doc = iframe.contentWindow?.document
doc?.open()
doc?.write(`
<!DOCTYPE html>
<html>
<head>
<title >入库单</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 10px;
font-size: 12px;
}
.print-content {
width: 100%;
padding-top: 15px;
}
.order-info {
justify-content: space-between;
display: flex;
flex-wrap: wrap;
align-items: center;
}
.stamp-info {
margin-top: 10px;
}
.stamp-info span{
font-size: 15px !important;
}
.order-info span{
font-size: 15px !important;
}
.print-table {
width: 100%;
border-collapse: collapse;
margin-top: 10px;
}
.print-table th, .print-table td {
border: 1px solid #ddd;
padding: 5px;
text-align: center;
height: 20px; /* 设置固定高度 */
line-height: 20px; /* 垂直居中 */
}
.print-table th {
background-color: #f5f5f5;
}
@media print {
body { margin: 0; }
.print-content {
width: 100%;
margin: 0;
padding: 10px;
}
}
</style>
</head>
<body>
${printContent.innerHTML}
</body>
</html>
`)
doc?.close()
iframe.onload = () => {
iframe.contentWindow?.focus()
iframe.contentWindow?.print()
setTimeout(() => document.body.removeChild(iframe), 1000)
}
}
function limitTo20Chars(input) {
if (typeof input !== 'string') return '';
return input.length > 20 ? input.slice(0, 20) : input;
}
@ -599,8 +776,8 @@ const handleClick = (event) => {
openProjectPurchaseorderDialog()
}
const getList = async (arrMat) => {
let flag=true
let whName=''
let flag=true
let whName=''
for (let i = 0; i < whList.value.length; i++) {
if (whList.value[i].id==formData.value.whId){
whName=whList.value[i].whName
@ -642,21 +819,21 @@ const getList = async (arrMat) => {
// if (row.pnlist.length == 1) {
// row.pnId = row.pnlist[0].id
// }else
if (pnList.value.length == 0) {
if (pnList.value.length == 0) {
flag=false
}
if (noList.value.length!=0){
var filter = noList.value.filter((no)=>no.materialId==row.matId);
if (filter&&filter.length!=0){
row.price=filter[0].unitPrice
row.storageOkQty=filter[0].purchaseAmount
}else {
row.price=''
}
if (noList.value.length!=0){
var filter = noList.value.filter((no)=>no.materialId==row.matId);
if (filter&&filter.length!=0){
row.price=filter[0].unitPrice
row.storageOkQty=filter[0].purchaseAmount
}else {
row.price=''
}
}else {
row.price=''
}
if (flag){
formData.value.matItemDOList.push(row)
}
@ -726,14 +903,14 @@ const getList1 = async (arrMat) => {
}
const getProject = async (pro,scope) => {
formData.value.matItemDOList.forEach(
(item) =>{
(item) =>{
if(item.matId == scope.row.matId && item.whId == scope.row.whId && item.rgId == scope.row.rgId && item.pnId == scope.row.pnId){
item.projectNo = pro.projectSubId
item.projectSubName = pro.projectSubName
}
}
)
if(item.matId == scope.row.matId && item.whId == scope.row.whId && item.rgId == scope.row.rgId && item.pnId == scope.row.pnId){
item.projectNo = pro.projectSubId
item.projectSubName = pro.projectSubName
}
}
)
}
const deleteMatCodes = ref([])
@ -870,7 +1047,7 @@ const failedAttachments = ref<UploadUserFile[]>([])
const failedAttachmentsName = ref()
const openProjectPurchaseorderDialog = () => {
projectPurchaseorderDialog.value?.open()
projectPurchaseorderDialog.value?.open()
}
const refreshAttachments = (files, type) => {
formData.value.attachments = formData.value.attachments.filter((value) => value.id)
@ -933,7 +1110,7 @@ const handleDeleteAttachment = async (index, type) => {
//
const downloadAttachment = async (name, url) => {
if (url) {
const baseUrl = import.meta.env.VITE_BASE_URL;
const baseUrl = import.meta.env.VITE_BASE_URL;
url =baseUrl+'/admin-api/'+ url.split('/admin-api/')[1]; const data = await downloadFile(url)
download.any(data, name)
}
@ -1176,7 +1353,7 @@ onMounted(async () => {
supplierList.value = await SupplierApi.getSimpList()
if (whList.value.length==1){
formData.value.whId = whList.value[0].id;
formData.value.whId = whList.value[0].id;
const dataRgList = await RgApi.getSimpList()
rgList.value = dataRgList.filter((rg) => rg.wh_id == formData.value.whId)
//
@ -1267,4 +1444,77 @@ a {
color: #409eff;
text-decoration: none;
}
/* 打印样式 */
@media print {
/* 隐藏所有非打印内容 */
body * {
visibility: hidden;
}
/* 只显示打印区域 */
#printArea, #printArea * {
visibility: visible;
}
/* 打印区域定位 */
#printArea {
position: absolute;
left: 0;
top: 0;
width: 100%;
}
/* 隐藏弹窗相关元素 */
.el-dialog, .el-dialog__wrapper, .el-dialog__header, .el-dialog__footer {
display: none !important;
}
}
.order-info {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
}
.order-info span {
font-size: 15px !important;
margin-right: 10px !important;
}
.stamp-info {
margin-top: 10px;
}
.stamp-info span{
font-size: 15px !important;
}
.print-table {
width: 100%;
border-collapse: collapse;
margin-top: 10px;
border: 1px solid #ccc;
}
.print-table th,
.print-table td {
border: 1px solid #ccc;
padding: 6px 8px;
text-align: center;
font-size: 13px !important;
height: 30px; /* 设置固定高度 */
line-height: 30px; /* 垂直居中 */
}
.print-table th {
background-color: #f5f7fa;
color: #303133;
font-weight: 600;
font-size: 13px !important;
}
</style>

View File

@ -38,14 +38,14 @@
/>
</el-form-item>
<el-form-item label="物料名称" prop="matName">
<el-input
v-model="queryParams.matName"
placeholder="物料名称"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-input
v-model="queryParams.matName"
placeholder="物料名称"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="入库类型" prop="stockInType">
<el-select
v-model="queryParams.stockInType"
@ -91,12 +91,7 @@
<el-button type="primary" plain @click="openDetail('create')">
<Icon icon="ep:plus" class="mr-5px" /> 新增
</el-button>
<el-button
type="success"
plain
@click="handleExport"
:loading="exportLoading"
>
<el-button type="success" plain @click="handleExport" :loading="exportLoading">
<Icon icon="ep:download" class="mr-5px" /> 导出
</el-button>
</el-form-item>
@ -104,34 +99,23 @@
</ContentWrap>
<!-- 列表 -->
<el-card class="hl-card-info">
<template #header>
<div class="hl-card-info-icona"></div><span class="hl-card-info-text">订单明细</span>
<!-- <el-button style="margin-left: 20px" @click="isPrint" type="primary" size="large">打印</el-button>-->
<!-- <el-button-->
<!-- style="margin-left: 20px"-->
<!-- type="success"-->
<!-- plain-->
<!-- @click="handleExport"-->
<!-- :loading="exportLoading"-->
<!-- >-->
<!-- <Icon icon="ep:download" class="mr-5px" /> 导出EXCEL-->
<!-- </el-button>-->
</template>
<ContentWrap>
<el-table
v-loading="loading" :data="list" class="hl-table"
ref="multipleTableRef"
@selection-change="handleSelectionChange" :row-class-name="tableRowClassName">
<el-table-column type="selection" width="70" fixed="left" />
<el-table-column type="index" width="70" fixed label="序号" align="center" />
v-loading="loading"
:data="list"
:show-overflow-tooltip="true"
:stripe="true"
class="hl-table"
>
<!-- <el-table-column label="主键id" align="center" prop="id" /> -->
<el-table-column type="index" width="100" fixed label="序号" align="center" />
<el-table-column label="入库单号" align="center" prop="stockNo" min-width="210" fixed />
<!-- <template #default="scope">-->
<!-- <el-button text type="primary" @click="openDetail('review',scope.row.id)">-->
<!-- {{scope.row.stockNo}}-->
<!-- </el-button>-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- <template #default="scope">-->
<!-- <el-button text type="primary" @click="openDetail('review',scope.row.id)">-->
<!-- {{scope.row.stockNo}}-->
<!-- </el-button>-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column label="入库类型" align="center" prop="stockInType" min-width="120">
<template #default="scope">
<dict-tag :type="DICT_TYPE.HELI_STORAGE_IN_TYPE" :value="scope.row.stockInType" />
@ -143,7 +127,7 @@
{{ warehouseList.find((tag) => tag.id === scope.row.whId)?.whName }}
</template>
</el-table-column>
<el-table-column label="即入即出" align="center" prop="inOutFlag" min-width="100" >
<el-table-column label="即入即出" align="center" prop="inOutFlag" min-width="90">
<template #default="scope">
<el-tag :type="scope.row.inOutFlag ? 'success' : 'info'">
{{ scope.row.inOutFlag ? '是' : '否' }}
@ -176,26 +160,37 @@
:formatter="dateFormatter"
min-width="240"
/>
<!-- <el-table-column label="作废人" align="center" prop="cancel" min-width="120">-->
<!-- <template #default="scope">-->
<!-- {{ userList.find((user) => user.id == scope.row.cancel)?.nickname }}-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- <el-table-column-->
<!-- label="作废时间"-->
<!-- align="center"-->
<!-- prop="cancelTime"-->
<!-- :formatter="dateFormatter"-->
<!-- min-width="240"-->
<!-- />-->
<el-table-column label="单据状态" align="center" prop="status" min-width="120" fixed="right">
<!-- <el-table-column label="作废人" align="center" prop="cancel" min-width="120">-->
<!-- <template #default="scope">-->
<!-- {{ userList.find((user) => user.id == scope.row.cancel)?.nickname }}-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- <el-table-column-->
<!-- label="作废时间"-->
<!-- align="center"-->
<!-- prop="cancelTime"-->
<!-- :formatter="dateFormatter"-->
<!-- min-width="240"-->
<!-- />-->
<el-table-column
label="单据状态"
align="center"
prop="status"
min-width="120"
fixed="right"
>
<template #default="scope">
<dict-tag :type="DICT_TYPE.HELI_STORAGE_IN_STATUS" :value="scope.row.status" />
</template>
</el-table-column>
<el-table-column label="操作" align="center" min-width="180" fixed="right">
<template #default="scope">
<el-button link type="primary" @click="openDetail('update', scope.row.id)" v-if="scope.row.status != 3&&scope.row.status!=4">
<el-button
link
type="primary"
@click="openDetail('update', scope.row.id)"
v-if="scope.row.status != 3 && scope.row.status != 4"
>
编辑
</el-button>
<el-button link type="primary" @click="openDetail('review', scope.row.id)">
@ -219,8 +214,6 @@
@pagination="getList"
/>
</ContentWrap>
</el-card>
<PrintRef ref="printRef" />
</el-card>
</template>
@ -231,11 +224,8 @@ import * as StorageApi from '@/api/heli/storage'
import * as WarehouseApi from '@/api/heli/warehouse'
import * as UserApi from '@/api/system/user'
import routeParamsCache from '@/utils/routeParamsCache'
import axios from "axios";
import {getAccessToken, getTenantId} from "@/utils/auth";
import {ElButton, ElTable} from "element-plus";
import PrintRef from "./print.vue"
import * as PurchaseOrderApi from "@/api/heli/purchaseorder";
import axios from 'axios'
import { getAccessToken, getTenantId } from '@/utils/auth'
defineOptions({ name: 'Storage' })
const message = useMessage() //
@ -297,33 +287,10 @@ const resetQuery = () => {
queryFormRef.value.resetFields()
handleQuery()
}
const multipleTableRef: any = ref<InstanceType<typeof ElTable>>()
const multipleSelection: any = ref([])
const handleSelectionChange = (val: PurchaseOrderApi.PurchaseOrderVO[]) => {
// isSelected false
list.value.forEach(row => {
row.isSelected = false;
});
// isSelected true
val.forEach(selectedRow => {
//
const targetRow = list.value.find(row => row.id === selectedRow.id);
if (targetRow) {
targetRow.isSelected = true;
}
});
multipleSelection.value = val
}
const tableRowClassName = ({ row }) => {
return row.isSelected ? 'selected-row' : '';
}
/** 导出按钮操作 */
const handleExport = async () => {
if (!queryParams.stockNo){
message.error("请输入入库单号")
if (!queryParams.stockNo) {
message.error('请输入入库单号')
return
}
@ -332,16 +299,17 @@ const handleExport = async () => {
await message.exportConfirm()
//
exportLoading.value = true
loading.value = true;
loading.value = true
// ID
const baseUrl = import.meta.env.VITE_BASE_URL;
const baseUrl = import.meta.env.VITE_BASE_URL
// 使axios
const response = await axios({
url: baseUrl+'/admin-api/heli/storage/export-excel-new',
url: baseUrl + '/admin-api/heli/storage/export-excel-new',
method: 'get',
headers: { // headersheader
headers: {
// headersheader
'tenant-id': getTenantId(),
'Authorization': getAccessToken()
Authorization: getAccessToken()
},
params: {
stockNo: queryParams.stockNo ? queryParams.stockNo : undefined
@ -349,7 +317,6 @@ const handleExport = async () => {
responseType: 'blob' // blob
})
//
const url = window.URL.createObjectURL(new Blob([response.data]))
const link = document.createElement('a')
@ -361,12 +328,11 @@ const handleExport = async () => {
//
document.body.removeChild(link)
window.URL.revokeObjectURL(url)
} catch (error) {
console.error('导出失败:', error)
message.error('导出失败,请重试')
} finally {
loading.value = false;
loading.value = false
exportLoading.value = false
// ID
queryParams.ids = []
@ -382,51 +348,14 @@ const openDetail = (active: string, id?: number) => {
router.push({ path: '/inventory/storagedetail', query: { type: active, id: id } })
}
const printRef = ref<InstanceType<typeof PrintRef>>()
const isPrint = async () => {
function formatDate(val) {
if (!val) return ''
const date = new Date(val)
return date.toLocaleDateString()
}
try {
const list = multipleSelection.value|| []; //
if(list.length==0){
message.warning("请选择入库单信息");
return;
}
//
//createTime brief projectSubCode blueprintNo boomName compositionName matSpec purchaseAmount unitPrice estimatedPrice requireTime
const data = list?.map((item,idx) => ({
编号: idx + 1,
入库单号: item.stockNo,
入库类型: getIntDictOptions(DICT_TYPE.HELI_STORAGE_IN_TYPE).find(d => d.value === item.stockInType)?.label || item.stockInType,
上游单号: item.headerNo,
入库仓库: warehouseList.value.find(w => w.id === item.whId)?.whName || item.whId,
即入即出: item.inOutFlag ? '是' : '否',
单据状态: getIntDictOptions(DICT_TYPE.HELI_STORAGE_IN_STATUS).find(d => d.value === item.status)?.label || item.status,
创建时间: formatDate(item.createTime),
提交时间: formatDate(item.keeperTime),
})) || [];
console.log(data)
// openPrintDialog(newVar)
printRef.value?.open(data,"")
} finally {
}
}
/** 初始化 **/
const route = useRoute()
const routeValue = ref('')
onMounted(async () => {
let params = routeParamsCache.get(route.path);
let params = routeParamsCache.get(route.path)
routeValue.value = route.path
if (params ) {
Object.assign(queryParams, params);
if (params) {
Object.assign(queryParams, params)
}
const queryParamsWarehouse = reactive({
pageNo: 1,
@ -446,21 +375,15 @@ onMounted(async () => {
await getList()
})
onBeforeUnmount(() => {
const plainParams = JSON.parse(JSON.stringify(queryParams));
routeParamsCache.set(routeValue.value, plainParams);
});
const plainParams = JSON.parse(JSON.stringify(queryParams))
routeParamsCache.set(routeValue.value, plainParams)
})
window.addEventListener('beforeunload', () => {
const plainParams = JSON.parse(JSON.stringify(queryParams));
routeParamsCache.set(routeValue.value, plainParams);
});
const plainParams = JSON.parse(JSON.stringify(queryParams))
routeParamsCache.set(routeValue.value, plainParams)
})
onActivated(() => {
getList()
})
</script>
<style>
.selected-row {
background-color: #ffe6cc !important;
}
</style>