2858 lines
99 KiB
Vue
2858 lines
99 KiB
Vue
<!-- 生产物料库 -->
|
||
<!-- eslint-disable vue/no-v-model-argument -->
|
||
<template>
|
||
<div class="page-container">
|
||
<section class="panel">
|
||
<div class="panel-pill-tabs panel-pill-tabs--lg">
|
||
<div class="panel-pill-tabs__track" role="tablist">
|
||
<button
|
||
v-for="tab in PRODUCTION_MATERIAL_TABS"
|
||
:key="tab.name"
|
||
type="button"
|
||
role="tab"
|
||
class="panel-pill-tabs__btn"
|
||
:class="{ 'is-active': activeTab === tab.name }"
|
||
:aria-selected="activeTab === tab.name"
|
||
@click="handleTabChange(tab.name)"
|
||
>
|
||
{{ tab.label }}
|
||
</button>
|
||
</div>
|
||
</div>
|
||
|
||
<div v-show="activeTab === 'list'" class="panel-track-pane">
|
||
<div class="filter-block">
|
||
<el-form :model="searchForm" class="filter-form" @submit.prevent>
|
||
<div class="filter-grid">
|
||
<el-form-item label="关键词">
|
||
<el-input v-model="searchForm.keyword" placeholder="物料名称/批号" clearable />
|
||
</el-form-item>
|
||
<el-form-item label="物料类型">
|
||
<el-select v-model="searchForm.materialType" placeholder="全部" clearable>
|
||
<el-option label="试剂" value="reagent" />
|
||
<el-option label="耗材" value="consumable" />
|
||
<el-option label="配置试剂" value="configured_reagent" />
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item label="状态">
|
||
<el-select v-model="searchForm.status" placeholder="全部" clearable>
|
||
<el-option label="正常" value="1" />
|
||
<el-option label="停用" value="0" />
|
||
</el-select>
|
||
</el-form-item>
|
||
</div>
|
||
<div class="filter-actions-row">
|
||
<div class="filter-actions-end">
|
||
<el-button class="btn-ghost" @click="handleReset"
|
||
><el-icon><RefreshLeft /></el-icon>重置</el-button
|
||
>
|
||
<el-button class="btn-main" type="primary" @click="handleSearch"
|
||
><el-icon><Search /></el-icon>搜索</el-button
|
||
>
|
||
</div>
|
||
</div>
|
||
</el-form>
|
||
</div>
|
||
|
||
<div class="list-toolbar">
|
||
<div class="list-toolbar-row">
|
||
<div class="list-toolbar-selected">
|
||
已选 <span class="sel-num">{{ selectedRows.length }}</span> 项
|
||
</div>
|
||
<el-button class="btn-main" type="primary" @click="handleOpenStockIn">
|
||
<el-icon><Upload /></el-icon>
|
||
入库
|
||
</el-button>
|
||
<el-button class="btn-ghost" @click="handleBatchStockOut">
|
||
<el-icon><Download /></el-icon>
|
||
批量出库
|
||
</el-button>
|
||
<el-button class="btn-ghost" @click="handleBatchDiscard">
|
||
<el-icon><CircleClose /></el-icon>
|
||
批量废弃
|
||
</el-button>
|
||
<ArtExcelExport
|
||
type="default"
|
||
:data="batchExportData"
|
||
:list-total="pagination.total"
|
||
:load-all-data="loadAllProductionMaterialBatchesForExport"
|
||
:filename="productionMaterialExportFilename"
|
||
sheet-name="生产物料库"
|
||
:columns="productionMaterialExportColumns"
|
||
>
|
||
<el-icon><Download /></el-icon>导出
|
||
</ArtExcelExport>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="list-body list-wrap">
|
||
<el-table
|
||
ref="tableRef"
|
||
class="list-table"
|
||
:data="tableData"
|
||
v-loading="loading"
|
||
stripe
|
||
row-key="id"
|
||
@selection-change="handleSelectionChange"
|
||
@row-dblclick="handleView"
|
||
>
|
||
<el-table-column type="selection" min-width="55" align="center" header-align="center" />
|
||
<el-table-column
|
||
type="index"
|
||
label="序号"
|
||
min-width="68"
|
||
align="center"
|
||
header-align="center"
|
||
:index="(index) => (pagination.page - 1) * pagination.pageSize + index + 1"
|
||
/>
|
||
<el-table-column
|
||
prop="materialName"
|
||
label="物料名称"
|
||
min-width="150"
|
||
align="center"
|
||
header-align="center"
|
||
/>
|
||
<el-table-column
|
||
prop="batchNo"
|
||
label="批号"
|
||
min-width="100"
|
||
align="center"
|
||
header-align="center"
|
||
/>
|
||
<el-table-column
|
||
prop="stockInDate"
|
||
label="入库日期"
|
||
min-width="110"
|
||
align="center"
|
||
header-align="center"
|
||
/>
|
||
<el-table-column
|
||
prop="expireDate"
|
||
label="过期日期"
|
||
min-width="110"
|
||
align="center"
|
||
header-align="center"
|
||
/>
|
||
<el-table-column
|
||
prop="productionDate"
|
||
label="生产日期"
|
||
min-width="110"
|
||
align="center"
|
||
header-align="center"
|
||
/>
|
||
<el-table-column label="物料类型" min-width="100" align="center" header-align="center">
|
||
<template #default="{ row }">
|
||
<el-tag :type="productionMaterialTypeTagType(row.materialType)" size="small">
|
||
{{ productionMaterialTypeLabel(row.materialType) }}
|
||
</el-tag>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
prop="specModel"
|
||
label="规格型号"
|
||
min-width="120"
|
||
align="center"
|
||
header-align="center"
|
||
/>
|
||
<el-table-column
|
||
prop="unit"
|
||
label="单位"
|
||
min-width="80"
|
||
align="center"
|
||
header-align="center"
|
||
/>
|
||
<el-table-column
|
||
prop="manufacturer"
|
||
label="厂家"
|
||
min-width="120"
|
||
align="center"
|
||
header-align="center"
|
||
show-overflow-tooltip
|
||
/>
|
||
<el-table-column
|
||
prop="storageLocation"
|
||
label="存储位置"
|
||
min-width="120"
|
||
align="center"
|
||
header-align="center"
|
||
show-overflow-tooltip
|
||
/>
|
||
<el-table-column
|
||
label="单价(元)"
|
||
min-width="110"
|
||
align="center"
|
||
header-align="center"
|
||
>
|
||
<template #default="{ row }">{{
|
||
isConfiguredReagentRow(row) ? '—' : formatMoneyDisplay(row.unitPrice)
|
||
}}</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
label="金额(元)"
|
||
min-width="110"
|
||
align="center"
|
||
header-align="center"
|
||
>
|
||
<template #default="{ row }">{{
|
||
isConfiguredReagentRow(row) ? '—' : formatMoneyDisplay(row.amount)
|
||
}}</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
prop="inQty"
|
||
label="入库数量"
|
||
min-width="100"
|
||
align="center"
|
||
header-align="center"
|
||
/>
|
||
<el-table-column
|
||
prop="remainingQty"
|
||
label="剩余数量"
|
||
min-width="100"
|
||
align="center"
|
||
header-align="center"
|
||
/>
|
||
<el-table-column
|
||
prop="remark"
|
||
label="备注"
|
||
min-width="140"
|
||
align="center"
|
||
header-align="center"
|
||
show-overflow-tooltip
|
||
/>
|
||
<el-table-column
|
||
label="操作"
|
||
min-width="280"
|
||
fixed="right"
|
||
align="center"
|
||
header-align="center"
|
||
>
|
||
<template #default="{ row }">
|
||
<div class="table-op-btns">
|
||
<el-button class="btn-op-item" @click="handleView(row)">
|
||
<el-icon><View /></el-icon>查看
|
||
</el-button>
|
||
<el-button class="btn-op-item" @click="handleEdit(row)">
|
||
<el-icon><Edit /></el-icon>编辑
|
||
</el-button>
|
||
<el-button class="btn-op-item" @click="handleDelete(row)">
|
||
<el-icon><Delete /></el-icon>删除
|
||
</el-button>
|
||
</div>
|
||
</template>
|
||
</el-table-column>
|
||
</el-table>
|
||
<div class="pagination list-pager-bar">
|
||
<el-pagination
|
||
:current-page="pagination.page"
|
||
:page-size="pagination.pageSize"
|
||
:total="pagination.total"
|
||
:page-sizes="[10, 20, 50]"
|
||
layout="total, sizes, prev, pager, next"
|
||
@size-change="
|
||
(val) => ((pagination.page = 1), (pagination.pageSize = val), loadData())
|
||
"
|
||
@current-change="(val) => ((pagination.page = val), loadData())"
|
||
/>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 编辑入库批次弹窗 -->
|
||
<el-dialog
|
||
v-model="dialogVisible"
|
||
title="编辑"
|
||
width="960px"
|
||
class="dialog-form-layout"
|
||
align-center
|
||
append-to-body
|
||
modal-class="protocol-dialog-mask"
|
||
destroy-on-close
|
||
:close-on-click-modal="false"
|
||
>
|
||
<DialogFormBody :loading="submitLoading" body-class="min-h-[200px]">
|
||
<el-form
|
||
ref="formRef"
|
||
:model="formData"
|
||
:rules="formRules"
|
||
label-position="top"
|
||
class="material-dialog-form"
|
||
scroll-to-error
|
||
:scroll-into-view-options="{ behavior: 'smooth', block: 'center' }"
|
||
>
|
||
<div class="form-grid-3">
|
||
<el-form-item label="物资" prop="materialName">
|
||
<el-input v-model="formData.materialName" placeholder="请输入物资名称" />
|
||
</el-form-item>
|
||
<el-form-item label="规格型号" prop="specModel">
|
||
<el-input v-model="formData.specModel" placeholder="请输入规格型号" />
|
||
</el-form-item>
|
||
<el-form-item label="入库日期" prop="stockInDate">
|
||
<el-date-picker
|
||
v-model="formData.stockInDate"
|
||
type="date"
|
||
placeholder="选择入库日期"
|
||
value-format="YYYY-MM-DD"
|
||
style="width: 100%"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item label="过期日期" prop="expireDate">
|
||
<el-date-picker
|
||
v-model="formData.expireDate"
|
||
type="date"
|
||
placeholder="选择过期日期"
|
||
value-format="YYYY-MM-DD"
|
||
style="width: 100%"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item label="生产日期" prop="productionDate">
|
||
<el-date-picker
|
||
v-model="formData.productionDate"
|
||
type="date"
|
||
placeholder="选择生产日期"
|
||
value-format="YYYY-MM-DD"
|
||
style="width: 100%"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item label="批号" prop="batchNo">
|
||
<el-input v-model="formData.batchNo" placeholder="请输入批号" />
|
||
</el-form-item>
|
||
<el-form-item label="厂家" prop="manufacturer">
|
||
<el-input v-model="formData.manufacturer" placeholder="请输入厂家" />
|
||
</el-form-item>
|
||
<el-form-item label="存储位置">
|
||
<el-input v-model="formData.storageLocation" placeholder="如:试剂柜 A-3" />
|
||
</el-form-item>
|
||
<el-form-item label="单位" prop="unit">
|
||
<el-select
|
||
v-model="formData.unit"
|
||
placeholder="请选择单位"
|
||
clearable
|
||
filterable
|
||
remote
|
||
reserve-keyword
|
||
:loading="unitOptionsLoading"
|
||
:remote-method="searchUnitOptions"
|
||
style="width: 100%"
|
||
>
|
||
<el-option
|
||
v-for="item in unitOptions"
|
||
:key="item.value"
|
||
:label="item.label"
|
||
:value="item.value"
|
||
/>
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item label="入库数量">
|
||
<el-input :model-value="String(formData.inQty ?? 0)" disabled />
|
||
</el-form-item>
|
||
<el-form-item label="单价(元)" prop="unitPrice">
|
||
<AmountInput
|
||
v-model="formData.unitPrice"
|
||
:min="0"
|
||
placeholder="请输入单价"
|
||
@change="onEditPriceQtyChange"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item label="金额(元)" prop="amount">
|
||
<AmountInput
|
||
v-model="formData.amount"
|
||
:min="0"
|
||
placeholder="自动计算:单价 × 数量"
|
||
@change="formData.amountManual = true"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item label="剩余数量">
|
||
<el-input :model-value="String(formData.remainingQty ?? 0)" disabled />
|
||
</el-form-item>
|
||
<el-form-item label="备注" class="form-col-span-3">
|
||
<el-input
|
||
v-model="formData.remark"
|
||
type="textarea"
|
||
:rows="2"
|
||
placeholder="可选"
|
||
/>
|
||
</el-form-item>
|
||
</div>
|
||
</el-form>
|
||
</DialogFormBody>
|
||
<template #footer>
|
||
<el-button class="btn-ghost" @click="dialogVisible = false">
|
||
<el-icon><Close /></el-icon>
|
||
取消
|
||
</el-button>
|
||
<el-button
|
||
class="btn-main"
|
||
type="primary"
|
||
@click="handleSubmit"
|
||
:loading="submitLoading"
|
||
>
|
||
<el-icon><Check /></el-icon>
|
||
确定
|
||
</el-button>
|
||
</template>
|
||
</el-dialog>
|
||
|
||
<!-- 单条入库弹窗 -->
|
||
<el-dialog
|
||
v-model="stockInVisible"
|
||
title="物料入库"
|
||
width="960px"
|
||
class="dialog-form-layout"
|
||
align-center
|
||
append-to-body
|
||
modal-class="protocol-dialog-mask"
|
||
destroy-on-close
|
||
:close-on-click-modal="false"
|
||
>
|
||
<DialogFormBody :loading="stockInLoading" body-class="min-h-[200px]">
|
||
<el-form
|
||
ref="stockInFormRef"
|
||
:model="stockInForm"
|
||
:rules="stockInRules"
|
||
label-position="top"
|
||
class="material-dialog-form"
|
||
scroll-to-error
|
||
:scroll-into-view-options="{ behavior: 'smooth', block: 'center' }"
|
||
>
|
||
<div class="form-grid-3">
|
||
<el-form-item label="物资" prop="materialKey">
|
||
<el-select
|
||
v-model="stockInForm.materialKey"
|
||
filterable
|
||
allow-create
|
||
default-first-option
|
||
remote
|
||
clearable
|
||
placeholder="选择已有物资,或直接输入新物资名称"
|
||
:loading="materialOptionsLoading"
|
||
:remote-method="searchMaterialOptions"
|
||
style="width: 100%"
|
||
@change="onStockInMaterialKeyChange"
|
||
>
|
||
<el-option
|
||
v-for="opt in materialOptions"
|
||
:key="opt.id"
|
||
:label="opt.materialName"
|
||
:value="opt.id"
|
||
/>
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item
|
||
v-if="stockInIsManualMaterial"
|
||
label="物料类型"
|
||
prop="newMaterialType"
|
||
>
|
||
<el-select
|
||
v-model="stockInForm.newMaterialType"
|
||
placeholder="请选择物料类型"
|
||
style="width: 100%"
|
||
>
|
||
<el-option label="试剂" value="reagent" />
|
||
<el-option label="耗材" value="consumable" />
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item label="规格型号">
|
||
<el-input
|
||
v-if="stockInIsManualMaterial"
|
||
v-model="stockInForm.newSpecModel"
|
||
placeholder="可选"
|
||
/>
|
||
<el-input
|
||
v-else
|
||
:model-value="stockInSelectedOpt?.specModel || ''"
|
||
disabled
|
||
placeholder="—"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item label="入库日期" prop="stockInDate">
|
||
<el-date-picker
|
||
v-model="stockInForm.stockInDate"
|
||
type="date"
|
||
placeholder="选择入库日期"
|
||
value-format="YYYY-MM-DD"
|
||
style="width: 100%"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item label="过期日期" prop="expireDate">
|
||
<el-date-picker
|
||
v-model="stockInForm.expireDate"
|
||
type="date"
|
||
placeholder="选择过期日期"
|
||
value-format="YYYY-MM-DD"
|
||
style="width: 100%"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item label="生产日期">
|
||
<el-date-picker
|
||
v-model="stockInForm.productionDate"
|
||
type="date"
|
||
placeholder="选择生产日期"
|
||
value-format="YYYY-MM-DD"
|
||
style="width: 100%"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item label="批号" prop="batchNo">
|
||
<el-input v-model="stockInForm.batchNo" placeholder="请输入批号" />
|
||
</el-form-item>
|
||
<el-form-item label="厂家" prop="manufacturer">
|
||
<el-input v-model="stockInForm.manufacturer" placeholder="请输入厂家" />
|
||
</el-form-item>
|
||
<el-form-item label="存储位置">
|
||
<el-input v-model="stockInForm.storageLocation" placeholder="如:试剂柜 A-3" />
|
||
</el-form-item>
|
||
<el-form-item label="单位">
|
||
<el-select
|
||
v-if="stockInIsManualMaterial"
|
||
v-model="stockInForm.newUnit"
|
||
placeholder="可选"
|
||
clearable
|
||
filterable
|
||
remote
|
||
:loading="unitOptionsLoading"
|
||
:remote-method="searchUnitOptions"
|
||
style="width: 100%"
|
||
>
|
||
<el-option
|
||
v-for="item in unitOptions"
|
||
:key="item.value"
|
||
:label="item.label"
|
||
:value="item.value"
|
||
/>
|
||
</el-select>
|
||
<el-input
|
||
v-else
|
||
:model-value="stockInSelectedOpt?.unit || ''"
|
||
disabled
|
||
placeholder="—"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item label="入库数量" prop="qty">
|
||
<DecimalInput
|
||
v-model="stockInForm.qty"
|
||
:min="0.01"
|
||
:precision="2"
|
||
style="width: 100%"
|
||
@change="onSingleStockInPriceQtyChange"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item label="单价(元)" prop="unitPrice">
|
||
<AmountInput
|
||
v-model="stockInForm.unitPrice"
|
||
:min="0"
|
||
placeholder="请输入单价"
|
||
@change="onSingleStockInPriceQtyChange"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item label="金额(元)" prop="amount">
|
||
<AmountInput
|
||
v-model="stockInForm.amount"
|
||
:min="0"
|
||
placeholder="自动计算:单价 × 数量"
|
||
@change="stockInForm.amountManual = true"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item label="备注" class="form-col-span-3">
|
||
<el-input
|
||
v-model="stockInForm.remark"
|
||
type="textarea"
|
||
:rows="2"
|
||
placeholder="可选"
|
||
/>
|
||
</el-form-item>
|
||
</div>
|
||
</el-form>
|
||
</DialogFormBody>
|
||
<template #footer>
|
||
<el-button class="btn-ghost" @click="stockInVisible = false">
|
||
<el-icon><Close /></el-icon>
|
||
取消
|
||
</el-button>
|
||
<el-button
|
||
class="btn-main"
|
||
type="primary"
|
||
@click="handleStockInSubmit"
|
||
:loading="stockInLoading"
|
||
>
|
||
<el-icon><Check /></el-icon>
|
||
确认入库
|
||
</el-button>
|
||
</template>
|
||
</el-dialog>
|
||
|
||
<!-- 批量入库弹窗 -->
|
||
<el-dialog
|
||
v-model="batchStockInVisible"
|
||
title="批量入库"
|
||
width="1080px"
|
||
class="dialog-form-layout material-batch-stock-dialog"
|
||
align-center
|
||
append-to-body
|
||
modal-class="protocol-dialog-mask"
|
||
destroy-on-close
|
||
:close-on-click-modal="false"
|
||
>
|
||
<DialogFormBody :loading="batchStockInLoading" body-class="min-h-[200px]">
|
||
<el-form
|
||
ref="batchStockInFormRef"
|
||
:model="batchStockInForm"
|
||
:rules="batchStockInRules"
|
||
label-position="top"
|
||
scroll-to-error
|
||
:scroll-into-view-options="{ behavior: 'smooth', block: 'center' }"
|
||
>
|
||
<div class="form-grid-2 batch-stock-move-head">
|
||
<el-form-item label="入库时间" prop="stockInTime">
|
||
<el-date-picker
|
||
v-model="batchStockInForm.stockInTime"
|
||
type="datetime"
|
||
placeholder="选择入库时间"
|
||
value-format="YYYY-MM-DD HH:mm:ss"
|
||
style="width: 100%"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item label="备注">
|
||
<el-input
|
||
v-model="batchStockInForm.remark"
|
||
type="textarea"
|
||
:rows="2"
|
||
placeholder="可选,未填写行备注时将作为默认备注"
|
||
/>
|
||
</el-form-item>
|
||
</div>
|
||
<div class="batch-stock-move-lines">
|
||
<div class="batch-stock-move-lines-head">
|
||
<div class="batch-stock-move-lines-head-left">
|
||
<span class="batch-stock-move-lines-title">入库明细</span>
|
||
<span class="batch-stock-move-lines-hint">
|
||
共 {{ batchStockInLines.length }} 项,新增一行录入一条入库信息
|
||
</span>
|
||
</div>
|
||
<el-button class="btn-ghost" @click="addBatchStockInLine">
|
||
<el-icon><Plus /></el-icon>
|
||
新增一行
|
||
</el-button>
|
||
</div>
|
||
<div v-if="batchStockInLines.length" class="batch-in-line-list">
|
||
<div
|
||
v-for="(row, index) in batchStockInLines"
|
||
:key="index"
|
||
class="batch-in-line-card"
|
||
>
|
||
<div class="batch-in-line-card-head">
|
||
<span class="batch-in-line-card-index">{{ index + 1 }}</span>
|
||
<el-button
|
||
link
|
||
type="danger"
|
||
size="small"
|
||
@click="batchStockInLines.splice(index, 1)"
|
||
>
|
||
<el-icon><Delete /></el-icon>
|
||
</el-button>
|
||
</div>
|
||
<div class="batch-in-line-grid batch-in-line-card-body">
|
||
<el-form-item label="物资" class="batch-in-col-span-2">
|
||
<el-select
|
||
v-model="row.materialId"
|
||
size="small"
|
||
filterable
|
||
remote
|
||
clearable
|
||
placeholder="选择物资"
|
||
:loading="materialOptionsLoading"
|
||
:remote-method="searchMaterialOptions"
|
||
@change="(id) => onBatchInMaterialChange(row, id)"
|
||
>
|
||
<el-option
|
||
v-for="opt in materialOptions"
|
||
:key="opt.id"
|
||
:label="opt.materialName"
|
||
:value="opt.id"
|
||
/>
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item label="规格型号">
|
||
<el-input
|
||
:model-value="row.specModel"
|
||
size="small"
|
||
disabled
|
||
placeholder="选择物资后自动带出"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item label="单位">
|
||
<el-input
|
||
:model-value="row.unit"
|
||
size="small"
|
||
disabled
|
||
placeholder="选择物资后自动带出"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item label="入库日期">
|
||
<el-date-picker
|
||
v-model="row.stockInDate"
|
||
size="small"
|
||
type="date"
|
||
value-format="YYYY-MM-DD"
|
||
placeholder="日期"
|
||
style="width: 100%"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item label="过期日期">
|
||
<el-date-picker
|
||
v-model="row.expireDate"
|
||
size="small"
|
||
type="date"
|
||
value-format="YYYY-MM-DD"
|
||
placeholder="必填"
|
||
style="width: 100%"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item label="生产日期">
|
||
<el-date-picker
|
||
v-model="row.productionDate"
|
||
size="small"
|
||
type="date"
|
||
value-format="YYYY-MM-DD"
|
||
placeholder="可选"
|
||
style="width: 100%"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item label="批号">
|
||
<el-input v-model="row.batchNo" size="small" placeholder="必填" />
|
||
</el-form-item>
|
||
<el-form-item label="厂家">
|
||
<el-input v-model="row.manufacturer" size="small" placeholder="必填" />
|
||
</el-form-item>
|
||
<el-form-item label="存储位置">
|
||
<el-input v-model="row.storageLocation" size="small" placeholder="可选" />
|
||
</el-form-item>
|
||
<el-form-item label="数量">
|
||
<DecimalInput
|
||
v-model="row.qty"
|
||
size="small"
|
||
:min="0.01"
|
||
:precision="2"
|
||
style="width: 100%"
|
||
@change="() => onBatchInLinePriceQtyChange(row)"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item label="单价">
|
||
<AmountInput
|
||
v-model="row.unitPrice"
|
||
:min="0"
|
||
@change="() => onBatchInLinePriceQtyChange(row)"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item label="金额">
|
||
<AmountInput
|
||
v-model="row.amount"
|
||
:min="0"
|
||
@change="() => (row.amountManual = true)"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item label="备注" class="batch-in-col-span-2">
|
||
<el-input v-model="row.remark" size="small" placeholder="可选" clearable />
|
||
</el-form-item>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<el-empty v-else description="请点击「新增一行」添加入库明细" :image-size="56" />
|
||
</div>
|
||
</el-form>
|
||
</DialogFormBody>
|
||
<template #footer>
|
||
<el-button class="btn-ghost" @click="batchStockInVisible = false">
|
||
<el-icon><Close /></el-icon>
|
||
取消
|
||
</el-button>
|
||
<el-button
|
||
class="btn-main"
|
||
type="primary"
|
||
:loading="batchStockInLoading"
|
||
@click="handleBatchStockInSubmit"
|
||
>
|
||
<el-icon><Check /></el-icon>
|
||
确认入库
|
||
</el-button>
|
||
</template>
|
||
</el-dialog>
|
||
|
||
<!-- 批量出库弹窗 -->
|
||
<el-dialog
|
||
v-model="batchStockOutVisible"
|
||
title="批量出库"
|
||
width="1200px"
|
||
class="dialog-form-layout material-batch-stock-dialog"
|
||
align-center
|
||
append-to-body
|
||
modal-class="protocol-dialog-mask"
|
||
destroy-on-close
|
||
:close-on-click-modal="false"
|
||
>
|
||
<DialogFormBody :loading="batchStockOutLoading" body-class="min-h-[200px]">
|
||
<el-form
|
||
ref="batchStockOutFormRef"
|
||
:model="batchStockOutForm"
|
||
:rules="batchStockOutRules"
|
||
label-position="top"
|
||
scroll-to-error
|
||
:scroll-into-view-options="{ behavior: 'smooth', block: 'center' }"
|
||
>
|
||
<div class="form-grid-2 batch-stock-move-head">
|
||
<el-form-item label="出库时间" prop="stockOutTime">
|
||
<el-date-picker
|
||
v-model="batchStockOutForm.stockOutTime"
|
||
type="datetime"
|
||
placeholder="选择出库时间"
|
||
value-format="YYYY-MM-DD HH:mm:ss"
|
||
style="width: 100%"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item label="领用人" prop="receiver">
|
||
<el-select
|
||
v-model="batchStockOutForm.receiver"
|
||
placeholder="请选择领用人"
|
||
clearable
|
||
filterable
|
||
remote
|
||
reserve-keyword
|
||
:loading="receiverUserLoading"
|
||
:remote-method="searchReceiverUsers"
|
||
style="width: 100%"
|
||
>
|
||
<el-option
|
||
v-for="u in receiverUserOptions"
|
||
:key="u.id"
|
||
:label="formatReceiverUserLabel(u)"
|
||
:value="(u.nickName || '').trim()"
|
||
/>
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item label="用途">
|
||
<el-input
|
||
v-model="batchStockOutForm.purpose"
|
||
type="textarea"
|
||
:rows="2"
|
||
placeholder="可选"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item label="备注">
|
||
<el-input
|
||
v-model="batchStockOutForm.remark"
|
||
type="textarea"
|
||
:rows="2"
|
||
placeholder="可选"
|
||
/>
|
||
</el-form-item>
|
||
</div>
|
||
<div class="batch-stock-move-lines">
|
||
<div class="batch-stock-move-lines-head">
|
||
<div class="batch-stock-move-lines-head-left">
|
||
<span class="batch-stock-move-lines-title">出库明细</span>
|
||
<span class="batch-stock-move-lines-hint">
|
||
共 {{ batchStockOutLines.length }} 项,按物料与批号选择批次
|
||
</span>
|
||
</div>
|
||
<el-button class="btn-ghost" @click="addBatchStockOutLine">
|
||
<el-icon><Plus /></el-icon>
|
||
新增一行
|
||
</el-button>
|
||
</div>
|
||
<el-table
|
||
v-if="batchStockOutLines.length"
|
||
:data="batchStockOutLines"
|
||
stripe
|
||
class="list-table inner-table"
|
||
max-height="320"
|
||
>
|
||
<el-table-column
|
||
type="index"
|
||
label="序号"
|
||
min-width="52"
|
||
align="center"
|
||
header-align="center"
|
||
/>
|
||
<el-table-column
|
||
label="物料批次"
|
||
min-width="280"
|
||
align="center"
|
||
header-align="center"
|
||
>
|
||
<template #default="{ row, $index }">
|
||
<el-select
|
||
v-model="row.batchId"
|
||
filterable
|
||
remote
|
||
clearable
|
||
placeholder="选择物料批次"
|
||
class="inner-cell-input batch-out-select"
|
||
popper-class="batch-out-option-popper"
|
||
:loading="batchOptionsLoading"
|
||
:remote-method="searchBatchOptions"
|
||
@change="(id) => onBatchOutLinePick(row, $index, id)"
|
||
>
|
||
<el-option
|
||
v-for="opt in batchOptions"
|
||
:key="opt.id"
|
||
:label="`${opt.materialName} · 批号 ${opt.batchNo || '—'}`"
|
||
:value="opt.id"
|
||
:disabled="isBatchOutOptionDisabled(opt.id, $index)"
|
||
>
|
||
<div class="batch-option-item">
|
||
<span class="batch-option-main"
|
||
>{{ opt.materialName }} · 批号 {{ opt.batchNo || '—' }}</span
|
||
>
|
||
<span class="batch-option-sub">
|
||
厂家:{{ opt.manufacturer || '—' }} · 剩余 {{ opt.remainingQty
|
||
}}{{ opt.unit || '' }}
|
||
</span>
|
||
</div>
|
||
</el-option>
|
||
</el-select>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
prop="materialName"
|
||
label="物料名称"
|
||
min-width="120"
|
||
align="center"
|
||
header-align="center"
|
||
/>
|
||
<el-table-column
|
||
prop="batchNo"
|
||
label="批号"
|
||
min-width="90"
|
||
align="center"
|
||
header-align="center"
|
||
/>
|
||
<el-table-column label="剩余" min-width="80" align="center" header-align="center">
|
||
<template #default="{ row }">{{ row.remainingQty ?? '—' }}</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
label="出库数量"
|
||
min-width="120"
|
||
align="center"
|
||
header-align="center"
|
||
>
|
||
<template #default="{ row }">
|
||
<DecimalInput
|
||
v-model="row.qty"
|
||
:min="0.01"
|
||
:max="row.remainingQty > 0 ? row.remainingQty : undefined"
|
||
:precision="2"
|
||
style="width: 100%"
|
||
/>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
label="单位"
|
||
min-width="100"
|
||
align="center"
|
||
header-align="center"
|
||
>
|
||
<template #default="{ row }">
|
||
<el-select
|
||
v-model="row.usageUnit"
|
||
filterable
|
||
remote
|
||
clearable
|
||
placeholder="选择单位"
|
||
class="inner-cell-input"
|
||
:loading="unitOptionsLoading"
|
||
:remote-method="searchUnitOptions"
|
||
>
|
||
<el-option
|
||
v-for="opt in unitOptions"
|
||
:key="opt.value"
|
||
:label="opt.label"
|
||
:value="opt.value"
|
||
/>
|
||
</el-select>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
label="备注"
|
||
min-width="120"
|
||
align="center"
|
||
header-align="center"
|
||
>
|
||
<template #default="{ row }">
|
||
<el-input
|
||
v-model="row.remark"
|
||
placeholder="可选"
|
||
clearable
|
||
class="inner-cell-input"
|
||
/>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
label="操作"
|
||
min-width="100"
|
||
align="center"
|
||
header-align="center"
|
||
fixed="right"
|
||
>
|
||
<template #default="{ $index }">
|
||
<el-button
|
||
link
|
||
type="danger"
|
||
size="small"
|
||
@click="batchStockOutLines.splice($index, 1)"
|
||
>
|
||
<el-icon><Delete /></el-icon>删除
|
||
</el-button>
|
||
</template>
|
||
</el-table-column>
|
||
</el-table>
|
||
<el-empty v-else description="请点击「新增一行」添加出库明细" :image-size="56" />
|
||
</div>
|
||
</el-form>
|
||
</DialogFormBody>
|
||
<template #footer>
|
||
<el-button class="btn-ghost" @click="batchStockOutVisible = false">
|
||
<el-icon><Close /></el-icon>
|
||
取消
|
||
</el-button>
|
||
<el-button
|
||
class="btn-main"
|
||
type="primary"
|
||
:loading="batchStockOutLoading"
|
||
@click="handleBatchStockOutSubmit"
|
||
>
|
||
<el-icon><Check /></el-icon>
|
||
确认出库
|
||
</el-button>
|
||
</template>
|
||
</el-dialog>
|
||
|
||
<!-- 批量废弃弹窗 -->
|
||
<el-dialog
|
||
v-model="batchDiscardVisible"
|
||
title="批量废弃"
|
||
width="1200px"
|
||
class="dialog-form-layout material-batch-stock-dialog"
|
||
align-center
|
||
append-to-body
|
||
modal-class="protocol-dialog-mask"
|
||
destroy-on-close
|
||
:close-on-click-modal="false"
|
||
>
|
||
<DialogFormBody :loading="batchDiscardLoading" body-class="min-h-[200px]">
|
||
<el-form
|
||
ref="batchDiscardFormRef"
|
||
:model="batchDiscardForm"
|
||
:rules="batchDiscardRules"
|
||
label-position="top"
|
||
scroll-to-error
|
||
:scroll-into-view-options="{ behavior: 'smooth', block: 'center' }"
|
||
>
|
||
<div class="form-grid-2 batch-stock-move-head">
|
||
<el-form-item label="废弃时间" prop="discardTime">
|
||
<el-date-picker
|
||
v-model="batchDiscardForm.discardTime"
|
||
type="datetime"
|
||
placeholder="选择废弃时间"
|
||
value-format="YYYY-MM-DD HH:mm:ss"
|
||
style="width: 100%"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item label="废弃原因" prop="discardReason">
|
||
<el-select
|
||
v-model="batchDiscardForm.discardReason"
|
||
placeholder="请选择废弃原因"
|
||
clearable
|
||
style="width: 100%"
|
||
>
|
||
<el-option
|
||
v-for="opt in MATERIAL_DISCARD_REASONS"
|
||
:key="opt.value"
|
||
:label="opt.label"
|
||
:value="opt.value"
|
||
/>
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item label="备注" class="form-col-span-2">
|
||
<el-input
|
||
v-model="batchDiscardForm.remark"
|
||
type="textarea"
|
||
:rows="2"
|
||
:placeholder="
|
||
batchDiscardForm.discardReason === '其他' ? '请说明废弃原因' : '可选'
|
||
"
|
||
/>
|
||
</el-form-item>
|
||
</div>
|
||
<div class="batch-stock-move-lines">
|
||
<div class="batch-stock-move-lines-head">
|
||
<div class="batch-stock-move-lines-head-left">
|
||
<span class="batch-stock-move-lines-title">废弃明细</span>
|
||
<span class="batch-stock-move-lines-hint">
|
||
共 {{ batchDiscardLines.length }} 项,按物料与批号选择批次
|
||
</span>
|
||
</div>
|
||
<el-button class="btn-ghost" @click="addBatchDiscardLine">
|
||
<el-icon><Plus /></el-icon>
|
||
新增一行
|
||
</el-button>
|
||
</div>
|
||
<el-table
|
||
v-if="batchDiscardLines.length"
|
||
:data="batchDiscardLines"
|
||
stripe
|
||
class="list-table inner-table"
|
||
max-height="320"
|
||
>
|
||
<el-table-column
|
||
type="index"
|
||
label="序号"
|
||
min-width="52"
|
||
align="center"
|
||
header-align="center"
|
||
/>
|
||
<el-table-column
|
||
label="物料批次"
|
||
min-width="280"
|
||
align="center"
|
||
header-align="center"
|
||
>
|
||
<template #default="{ row, $index }">
|
||
<el-select
|
||
v-model="row.batchId"
|
||
filterable
|
||
remote
|
||
clearable
|
||
placeholder="选择物料批次"
|
||
class="inner-cell-input batch-out-select"
|
||
popper-class="batch-out-option-popper"
|
||
:loading="batchOptionsLoading"
|
||
:remote-method="searchBatchOptions"
|
||
@change="(id) => onBatchDiscardLinePick(row, $index, id)"
|
||
>
|
||
<el-option
|
||
v-for="opt in batchOptions"
|
||
:key="opt.id"
|
||
:label="`${opt.materialName} · 批号 ${opt.batchNo || '—'}`"
|
||
:value="opt.id"
|
||
:disabled="isBatchDiscardOptionDisabled(opt.id, $index)"
|
||
>
|
||
<div class="batch-option-item">
|
||
<span class="batch-option-main"
|
||
>{{ opt.materialName }} · 批号 {{ opt.batchNo || '—' }}</span
|
||
>
|
||
<span class="batch-option-sub">
|
||
厂家:{{ opt.manufacturer || '—' }} · 剩余 {{ opt.remainingQty
|
||
}}{{ opt.unit || '' }}
|
||
</span>
|
||
</div>
|
||
</el-option>
|
||
</el-select>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
prop="materialName"
|
||
label="物料名称"
|
||
min-width="120"
|
||
align="center"
|
||
header-align="center"
|
||
/>
|
||
<el-table-column
|
||
prop="batchNo"
|
||
label="批号"
|
||
min-width="90"
|
||
align="center"
|
||
header-align="center"
|
||
/>
|
||
<el-table-column label="剩余" min-width="80" align="center" header-align="center">
|
||
<template #default="{ row }">{{ row.remainingQty ?? '—' }}</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
label="废弃数量"
|
||
min-width="120"
|
||
align="center"
|
||
header-align="center"
|
||
>
|
||
<template #default="{ row }">
|
||
<DecimalInput
|
||
v-model="row.qty"
|
||
:min="0.01"
|
||
:max="row.remainingQty > 0 ? row.remainingQty : undefined"
|
||
:precision="2"
|
||
style="width: 100%"
|
||
/>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
label="单位"
|
||
min-width="100"
|
||
align="center"
|
||
header-align="center"
|
||
>
|
||
<template #default="{ row }">
|
||
<el-select
|
||
v-model="row.usageUnit"
|
||
filterable
|
||
remote
|
||
clearable
|
||
placeholder="选择单位"
|
||
class="inner-cell-input"
|
||
:loading="unitOptionsLoading"
|
||
:remote-method="searchUnitOptions"
|
||
>
|
||
<el-option
|
||
v-for="opt in unitOptions"
|
||
:key="opt.value"
|
||
:label="opt.label"
|
||
:value="opt.value"
|
||
/>
|
||
</el-select>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
label="备注"
|
||
min-width="120"
|
||
align="center"
|
||
header-align="center"
|
||
>
|
||
<template #default="{ row }">
|
||
<el-input
|
||
v-model="row.remark"
|
||
placeholder="可选"
|
||
clearable
|
||
class="inner-cell-input"
|
||
/>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
label="操作"
|
||
min-width="100"
|
||
align="center"
|
||
header-align="center"
|
||
fixed="right"
|
||
>
|
||
<template #default="{ $index }">
|
||
<el-button
|
||
link
|
||
type="danger"
|
||
size="small"
|
||
@click="batchDiscardLines.splice($index, 1)"
|
||
>
|
||
<el-icon><Delete /></el-icon>删除
|
||
</el-button>
|
||
</template>
|
||
</el-table-column>
|
||
</el-table>
|
||
<el-empty v-else description="请点击「新增一行」添加废弃明细" :image-size="56" />
|
||
</div>
|
||
</el-form>
|
||
</DialogFormBody>
|
||
<template #footer>
|
||
<el-button class="btn-ghost" @click="batchDiscardVisible = false">
|
||
<el-icon><Close /></el-icon>
|
||
取消
|
||
</el-button>
|
||
<el-button
|
||
class="btn-main"
|
||
type="primary"
|
||
:loading="batchDiscardLoading"
|
||
@click="handleBatchDiscardSubmit"
|
||
>
|
||
<el-icon><Check /></el-icon>
|
||
确认废弃
|
||
</el-button>
|
||
</template>
|
||
</el-dialog>
|
||
|
||
<!-- 查看弹窗 -->
|
||
<SystemViewDialog
|
||
v-model:visible="viewVisible"
|
||
:title="viewRow?.materialName || '物料详情'"
|
||
:icon="Box"
|
||
:meta="viewRow?.stockInNo || ''"
|
||
:sections="viewSections"
|
||
:loading="viewLoading"
|
||
width="960px"
|
||
:grid-columns="4"
|
||
>
|
||
<template #usage-details>
|
||
<div v-if="viewUsageRecords.length" class="view-subtable-wrap">
|
||
<el-table :data="viewUsageRecords" stripe class="list-table view-subtable">
|
||
<el-table-column
|
||
type="index"
|
||
label="序号"
|
||
min-width="56"
|
||
align="center"
|
||
header-align="center"
|
||
/>
|
||
<el-table-column label="类型" min-width="90" align="center" header-align="center">
|
||
<template #default="{ row }">
|
||
<el-tag :type="usageChangeTagType(row)" size="small">{{
|
||
usageChangeLabel(row)
|
||
}}</el-tag>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="数量" min-width="80" align="center" header-align="center">
|
||
<template #default="{ row }">{{ Math.abs(Number(row.changeQty) || 0) }}</template>
|
||
</el-table-column>
|
||
<el-table-column label="领用人" min-width="90" align="center" header-align="center">
|
||
<template #default="{ row }">{{
|
||
row.receiverName || row.receiver || '—'
|
||
}}</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
label="用途"
|
||
min-width="120"
|
||
align="center"
|
||
header-align="center"
|
||
show-overflow-tooltip
|
||
>
|
||
<template #default="{ row }">{{ row.purpose || row.remark || '—' }}</template>
|
||
</el-table-column>
|
||
<el-table-column label="时间" min-width="150" align="center" header-align="center">
|
||
<template #default="{ row }">{{ row.useTime || row.createTime || '—' }}</template>
|
||
</el-table-column>
|
||
</el-table>
|
||
</div>
|
||
<p v-else class="view-empty-hint">暂无领用记录</p>
|
||
</template>
|
||
</SystemViewDialog>
|
||
</div>
|
||
|
||
<div v-show="activeTab === 'usage'" class="panel-track-pane">
|
||
<ProductionMaterialUsageTab v-if="usageTabMounted" />
|
||
</div>
|
||
|
||
<div v-show="activeTab === 'stockCheck'" class="panel-track-pane">
|
||
<ProductionMaterialStockCheckTab v-if="stockCheckTabMounted" />
|
||
</div>
|
||
|
||
<div v-show="activeTab === 'prep'" class="panel-track-pane">
|
||
<ProductionMaterialPrepTab v-if="prepTabMounted" />
|
||
</div>
|
||
</section>
|
||
|
||
<ProductionMaterialConfiguredCatalogDialog ref="configuredCatalogRef" @saved="loadData" />
|
||
</div>
|
||
</template>
|
||
|
||
<script setup lang="ts">
|
||
import { ref, reactive, onMounted, computed } from 'vue'
|
||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||
import {
|
||
Plus,
|
||
Close,
|
||
Check,
|
||
View,
|
||
Box,
|
||
RefreshLeft,
|
||
Search,
|
||
Upload,
|
||
Download,
|
||
Edit,
|
||
Delete,
|
||
CircleClose
|
||
} from '@element-plus/icons-vue'
|
||
import SystemViewDialog from '@/components/business/system-view-dialog/index.vue'
|
||
import AmountInput from '@/components/common/amount-input/index.vue'
|
||
import { formatMoneyDisplay } from '@/utils/money-format'
|
||
import { fetchItemUnitList, fetchUserList } from '@/api/admin'
|
||
import {
|
||
fetchProductionMaterialBatchList,
|
||
fetchProductionMaterialOptions,
|
||
fetchProductionMaterialBatchOptions,
|
||
fetchCreateProductionMaterial,
|
||
fetchUpdateProductionMaterialBatch,
|
||
fetchDeleteProductionMaterialBatch,
|
||
fetchStockInProductionMaterial,
|
||
fetchBatchStockInProductionMaterial,
|
||
fetchBatchStockOutProductionMaterial,
|
||
fetchBatchDiscardProductionMaterial
|
||
} from '@/api/production-material'
|
||
import type {
|
||
ProductionMaterialBatch,
|
||
ProductionMaterialOption,
|
||
ProductionMaterialBatchOption
|
||
} from '@/api/production-material'
|
||
import {
|
||
fetchProductionMaterialUsageList,
|
||
type ProductionMaterialUsage
|
||
} from '@/api/production-material'
|
||
import { MATERIAL_DISCARD_REASONS } from '@/constants/material-discard'
|
||
import {
|
||
productionMaterialTypeLabel,
|
||
productionMaterialTypeTagType
|
||
} from '@/utils/status-tag-registry'
|
||
import { fetchAllPagedRecords } from '@/utils/fetch-paged-list'
|
||
import ProductionMaterialUsageTab from './ProductionMaterialUsageTab.vue'
|
||
import ProductionMaterialStockCheckTab from './ProductionMaterialStockCheckTab.vue'
|
||
import ProductionMaterialPrepTab from './ProductionMaterialPrepTab.vue'
|
||
import ProductionMaterialConfiguredCatalogDialog from './ProductionMaterialConfiguredCatalogDialog.vue'
|
||
import DialogFormBody from '@/components/business/dialog-form-body/index.vue'
|
||
|
||
defineOptions({ name: 'ProductionMaterialIndex' })
|
||
|
||
const configuredCatalogRef = ref<InstanceType<
|
||
typeof ProductionMaterialConfiguredCatalogDialog
|
||
> | null>(null)
|
||
|
||
function openConfiguredCatalog() {
|
||
configuredCatalogRef.value?.openCreate()
|
||
}
|
||
|
||
const route = useRoute()
|
||
|
||
const PRODUCTION_MATERIAL_TABS = [
|
||
{ name: 'list', label: '物料列表' },
|
||
{ name: 'usage', label: '变动记录' },
|
||
{ name: 'stockCheck', label: '库存盘点' },
|
||
{ name: 'prep', label: '配制单' }
|
||
] as const
|
||
|
||
const activeTab = ref('list')
|
||
const usageTabMounted = ref(false)
|
||
const stockCheckTabMounted = ref(false)
|
||
const prepTabMounted = ref(false)
|
||
|
||
function ensureTabMounted(tab: string) {
|
||
if (tab === 'usage') usageTabMounted.value = true
|
||
if (tab === 'stockCheck') stockCheckTabMounted.value = true
|
||
if (tab === 'prep') prepTabMounted.value = true
|
||
}
|
||
|
||
function handleTabChange(name: string) {
|
||
activeTab.value = name
|
||
ensureTabMounted(name)
|
||
}
|
||
const searchForm = reactive({ keyword: '', materialType: '', status: '' })
|
||
const tableRef = ref()
|
||
const tableData = ref<ProductionMaterialBatch[]>([])
|
||
const selectedRows = ref<ProductionMaterialBatch[]>([])
|
||
const loading = ref(false)
|
||
const pagination = reactive({ page: 1, pageSize: 10, total: 0 })
|
||
|
||
const unitOptions = ref<{ label: string; value: string }[]>([])
|
||
const unitOptionsLoading = ref(false)
|
||
|
||
function mapUnitOption(u: { unitName?: string; unitCode?: string }) {
|
||
const name = (u.unitName || '').trim()
|
||
const code = (u.unitCode || '').trim()
|
||
return {
|
||
label: code ? `${name}(${code})` : name,
|
||
value: name
|
||
}
|
||
}
|
||
|
||
function ensureUnitOption(unitName: string) {
|
||
const v = unitName?.trim()
|
||
if (!v) return
|
||
if (!unitOptions.value.some((o) => o.value === v)) {
|
||
unitOptions.value = [{ label: v, value: v }, ...unitOptions.value]
|
||
}
|
||
}
|
||
|
||
async function searchUnitOptions(query: string) {
|
||
unitOptionsLoading.value = true
|
||
try {
|
||
const res = await fetchItemUnitList({
|
||
page: 1,
|
||
pageSize: 100,
|
||
keyword: query?.trim() || undefined
|
||
})
|
||
unitOptions.value = (res.list || []).map(mapUnitOption).filter((o) => o.value)
|
||
} catch {
|
||
unitOptions.value = []
|
||
} finally {
|
||
unitOptionsLoading.value = false
|
||
}
|
||
}
|
||
|
||
const materialOptions = ref<ProductionMaterialOption[]>([])
|
||
const materialOptionsLoading = ref(false)
|
||
const batchOptions = ref<ProductionMaterialBatchOption[]>([])
|
||
const batchOptionsLoading = ref(false)
|
||
|
||
async function searchMaterialOptions(query: string) {
|
||
materialOptionsLoading.value = true
|
||
try {
|
||
materialOptions.value = (await fetchProductionMaterialOptions()) || []
|
||
const kw = query?.trim()
|
||
if (kw) {
|
||
materialOptions.value = materialOptions.value.filter(
|
||
(o) => o.materialName.includes(kw) || o.materialCode.includes(kw) || o.label.includes(kw)
|
||
)
|
||
}
|
||
} catch {
|
||
materialOptions.value = []
|
||
} finally {
|
||
materialOptionsLoading.value = false
|
||
}
|
||
}
|
||
|
||
async function searchBatchOptions(query: string) {
|
||
batchOptionsLoading.value = true
|
||
try {
|
||
batchOptions.value =
|
||
(await fetchProductionMaterialBatchOptions({ keyword: query?.trim() || undefined })) || []
|
||
} catch {
|
||
batchOptions.value = []
|
||
} finally {
|
||
batchOptionsLoading.value = false
|
||
}
|
||
}
|
||
|
||
function calcAmount(unitPrice: number, qty: number) {
|
||
const p = Number(unitPrice) || 0
|
||
const q = Number(qty) || 0
|
||
return Math.round(p * q * 100) / 100
|
||
}
|
||
|
||
// 编辑入库批次
|
||
const dialogVisible = ref(false)
|
||
const submitLoading = ref(false)
|
||
const formRef = ref()
|
||
const editingBatchId = ref<string | null>(null)
|
||
|
||
const formData = reactive({
|
||
stockInNo: '',
|
||
stockInDate: '',
|
||
expireDate: '',
|
||
productionDate: '',
|
||
catalogNo: '',
|
||
batchNo: '',
|
||
manufacturer: '',
|
||
storageLocation: '',
|
||
unitPrice: 0 as number | null,
|
||
amount: 0 as number | null,
|
||
amountManual: false,
|
||
inQty: 0,
|
||
remainingQty: 0,
|
||
materialCode: '',
|
||
materialName: '',
|
||
specModel: '',
|
||
unit: '',
|
||
warningQty: 0,
|
||
status: '1',
|
||
remark: ''
|
||
})
|
||
|
||
const formRules = {
|
||
stockInDate: [{ required: true, message: '请选择入库日期', trigger: 'change' }],
|
||
expireDate: [{ required: true, message: '请选择过期日期', trigger: 'change' }],
|
||
batchNo: [{ required: true, message: '请输入批号', trigger: 'blur' }],
|
||
manufacturer: [{ required: true, message: '请输入厂家', trigger: 'blur' }],
|
||
unitPrice: [{ required: true, message: '请输入单价', trigger: 'change' }],
|
||
amount: [{ required: true, message: '请输入金额', trigger: 'change' }],
|
||
materialName: [{ required: true, message: '请输入物料名称', trigger: 'blur' }]
|
||
}
|
||
|
||
// 入库
|
||
const stockInVisible = ref(false)
|
||
const stockInLoading = ref(false)
|
||
const stockInFormRef = ref()
|
||
const stockInForm = reactive({
|
||
materialKey: '',
|
||
materialId: '',
|
||
newMaterialCode: '',
|
||
newMaterialType: 'consumable',
|
||
newSpecModel: '',
|
||
newUnit: '',
|
||
stockInNo: '',
|
||
stockInDate: '',
|
||
expireDate: '',
|
||
productionDate: '',
|
||
catalogNo: '',
|
||
batchNo: '',
|
||
manufacturer: '',
|
||
storageLocation: '',
|
||
unitPrice: 0 as number | null,
|
||
amount: 0 as number | null,
|
||
amountManual: false,
|
||
qty: 1,
|
||
remark: ''
|
||
})
|
||
|
||
const stockInIsManualMaterial = computed(() => {
|
||
const key = (stockInForm.materialKey || '').trim()
|
||
if (!key) return false
|
||
return !materialOptions.value.some((o) => o.id === key)
|
||
})
|
||
|
||
const stockInSelectedOpt = computed(() => {
|
||
if (stockInIsManualMaterial.value) return null
|
||
const key = (stockInForm.materialKey || '').trim()
|
||
if (!key) return null
|
||
return materialOptions.value.find((o) => o.id === key) ?? null
|
||
})
|
||
|
||
const stockInRules = {
|
||
materialKey: [{ required: true, message: '请选择或输入物资', trigger: 'change' }],
|
||
stockInDate: [{ required: true, message: '请选择入库日期', trigger: 'change' }],
|
||
expireDate: [{ required: true, message: '请选择过期日期', trigger: 'change' }],
|
||
batchNo: [{ required: true, message: '请输入批号', trigger: 'blur' }],
|
||
manufacturer: [{ required: true, message: '请输入厂家', trigger: 'blur' }],
|
||
unitPrice: [{ required: true, message: '请输入单价', trigger: 'change' }],
|
||
amount: [{ required: true, message: '请输入金额', trigger: 'change' }],
|
||
qty: [{ required: true, message: '请输入入库数量', trigger: 'blur' }]
|
||
}
|
||
|
||
function formatReceiverUserLabel(u: Api.User.UserItem) {
|
||
const name = (u.nickName || '').trim() || '-'
|
||
const no = (u.userNo || '').trim()
|
||
const phone = (u.phoneNo || '').trim()
|
||
const parts = [name]
|
||
if (no) parts.push(no)
|
||
if (phone) parts.push(phone)
|
||
return parts.join(' · ')
|
||
}
|
||
|
||
async function searchReceiverUsers(query: string) {
|
||
receiverUserLoading.value = true
|
||
try {
|
||
const res = await fetchUserList({
|
||
page: 1,
|
||
pageSize: 50,
|
||
keyword: query?.trim() || undefined,
|
||
status: '1'
|
||
})
|
||
receiverUserOptions.value = res.list || []
|
||
} catch {
|
||
receiverUserOptions.value = []
|
||
} finally {
|
||
receiverUserLoading.value = false
|
||
}
|
||
}
|
||
|
||
const stockOutRules = {
|
||
qty: [{ required: true, message: '请输入出库数量', trigger: 'blur' }],
|
||
stockOutTime: [{ required: true, message: '请选择出库时间', trigger: 'change' }],
|
||
receiver: [{ required: true, message: '请选择领用人', trigger: 'change' }]
|
||
}
|
||
|
||
// 批量入库
|
||
type BatchStockInLine = {
|
||
materialId: string
|
||
materialCode: string
|
||
materialName: string
|
||
specModel: string
|
||
unit: string
|
||
stockInNo: string
|
||
stockInDate: string
|
||
expireDate: string
|
||
productionDate: string
|
||
catalogNo: string
|
||
batchNo: string
|
||
manufacturer: string
|
||
storageLocation: string
|
||
unitPrice: number | null
|
||
amount: number | null
|
||
amountManual: boolean
|
||
qty: number
|
||
remark: string
|
||
}
|
||
|
||
const batchStockInVisible = ref(false)
|
||
const batchStockInLoading = ref(false)
|
||
const batchStockInFormRef = ref()
|
||
const batchStockInLines = ref<BatchStockInLine[]>([])
|
||
const batchStockInForm = reactive({
|
||
stockInTime: '',
|
||
remark: ''
|
||
})
|
||
|
||
const batchStockInRules = {
|
||
stockInTime: [{ required: true, message: '请选择入库时间', trigger: 'change' }]
|
||
}
|
||
|
||
// 批量出库
|
||
type BatchStockOutLine = {
|
||
batchId: string
|
||
stockInNo: string
|
||
materialName: string
|
||
batchNo: string
|
||
remainingQty: number
|
||
qty: number
|
||
usageUnit: string
|
||
remark: string
|
||
}
|
||
|
||
const batchStockOutVisible = ref(false)
|
||
const batchStockOutLoading = ref(false)
|
||
const batchStockOutFormRef = ref()
|
||
const batchStockOutLines = ref<BatchStockOutLine[]>([])
|
||
const batchStockOutForm = reactive({
|
||
stockOutTime: '',
|
||
receiver: '',
|
||
purpose: '',
|
||
remark: ''
|
||
})
|
||
|
||
const receiverUserOptions = ref<Api.User.UserItem[]>([])
|
||
const receiverUserLoading = ref(false)
|
||
|
||
const batchStockOutRules = {
|
||
stockOutTime: [{ required: true, message: '请选择出库时间', trigger: 'change' }],
|
||
receiver: [{ required: true, message: '请选择领用人', trigger: 'change' }]
|
||
}
|
||
|
||
// 批量废弃
|
||
type BatchDiscardLine = {
|
||
batchId: string
|
||
stockInNo: string
|
||
materialName: string
|
||
batchNo: string
|
||
remainingQty: number
|
||
qty: number
|
||
usageUnit: string
|
||
remark: string
|
||
}
|
||
|
||
const batchDiscardVisible = ref(false)
|
||
const batchDiscardLoading = ref(false)
|
||
const batchDiscardFormRef = ref()
|
||
const batchDiscardLines = ref<BatchDiscardLine[]>([])
|
||
const batchDiscardForm = reactive({
|
||
discardTime: '',
|
||
discardReason: '',
|
||
remark: ''
|
||
})
|
||
|
||
const batchDiscardRules = {
|
||
discardTime: [{ required: true, message: '请选择废弃时间', trigger: 'change' }],
|
||
discardReason: [{ required: true, message: '请选择废弃原因', trigger: 'change' }],
|
||
remark: [
|
||
{
|
||
validator: (_r: unknown, _v: unknown, cb: (e?: Error) => void) => {
|
||
if (batchDiscardForm.discardReason !== '其他') return cb()
|
||
if (!(batchDiscardForm.remark || '').trim())
|
||
return cb(new Error('选择「其他」时请填写备注说明'))
|
||
cb()
|
||
},
|
||
trigger: 'blur'
|
||
}
|
||
]
|
||
}
|
||
|
||
function formatNowDatetime() {
|
||
const now = new Date()
|
||
const pad = (n: number) => String(n).padStart(2, '0')
|
||
return `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())} ${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(now.getSeconds())}`
|
||
}
|
||
|
||
const viewVisible = ref(false)
|
||
const viewLoading = ref(false)
|
||
const viewRow = ref<ProductionMaterialBatch | null>(null)
|
||
const viewUsageRecords = ref<ProductionMaterialUsage[]>([])
|
||
|
||
const productionMaterialExportFilename = 'production_material_batch_export'
|
||
|
||
const productionMaterialExportColumns = {
|
||
stockInNo: { title: '入库编号' },
|
||
stockInDate: { title: '入库日期' },
|
||
expireDate: { title: '过期日期' },
|
||
productionDate: { title: '生产日期' },
|
||
materialCode: { title: '物料编码' },
|
||
materialName: { title: '物料名称' },
|
||
materialType: {
|
||
title: '物料类型',
|
||
formatter: (v: unknown) => productionMaterialTypeLabel(String(v ?? ''))
|
||
},
|
||
specModel: { title: '规格型号' },
|
||
unit: { title: '单位' },
|
||
catalogNo: { title: '货号' },
|
||
batchNo: { title: '批号' },
|
||
manufacturer: { title: '厂家' },
|
||
storageLocation: { title: '存储位置' },
|
||
unitPrice: {
|
||
title: '单价(元)',
|
||
formatter: (v: unknown) => formatMoneyDisplay(v as number)
|
||
},
|
||
amount: {
|
||
title: '金额(元)',
|
||
formatter: (v: unknown) => formatMoneyDisplay(v as number)
|
||
},
|
||
inQty: { title: '入库数量' },
|
||
remainingQty: { title: '剩余数量' },
|
||
remark: { title: '备注' }
|
||
} as const
|
||
|
||
const mapProductionMaterialExportRow = (row: ProductionMaterialBatch) => ({
|
||
stockInNo: row.stockInNo,
|
||
stockInDate: row.stockInDate,
|
||
expireDate: row.expireDate,
|
||
productionDate: row.productionDate || '',
|
||
materialCode: row.materialCode,
|
||
materialName: row.materialName,
|
||
materialType: row.materialType,
|
||
specModel: row.specModel,
|
||
unit: row.unit,
|
||
catalogNo: row.catalogNo,
|
||
batchNo: row.batchNo,
|
||
manufacturer: row.manufacturer,
|
||
storageLocation: row.storageLocation,
|
||
unitPrice: isConfiguredReagentRow(row) ? '—' : row.unitPrice,
|
||
amount: isConfiguredReagentRow(row) ? '—' : row.amount,
|
||
inQty: row.inQty,
|
||
remainingQty: row.remainingQty,
|
||
remark: row.remark
|
||
})
|
||
|
||
const batchExportData = computed(() => {
|
||
const sel = selectedRows.value || []
|
||
if (sel.length === 0) return []
|
||
return sel.map(mapProductionMaterialExportRow)
|
||
})
|
||
|
||
const loadAllProductionMaterialBatchesForExport = async () => {
|
||
const all = await fetchAllPagedRecords((page, pageSize) =>
|
||
fetchProductionMaterialBatchList({
|
||
page,
|
||
pageSize,
|
||
keyword: searchForm.keyword || undefined,
|
||
materialType: searchForm.materialType || undefined,
|
||
status: searchForm.status || undefined
|
||
})
|
||
)
|
||
return all.map(mapProductionMaterialExportRow)
|
||
}
|
||
|
||
const handleSelectionChange = (rows: ProductionMaterialBatch[]) => {
|
||
selectedRows.value = rows
|
||
}
|
||
|
||
function isConfiguredReagentRow(row: ProductionMaterialBatch) {
|
||
return row.materialType === 'configured_reagent'
|
||
}
|
||
|
||
const viewSections = computed(() => {
|
||
if (!viewRow.value) return []
|
||
const row = viewRow.value
|
||
const batchFields = [
|
||
{ label: '物料名称', value: row.materialName },
|
||
{ label: '批号', value: row.batchNo },
|
||
{ label: '入库日期', value: row.stockInDate },
|
||
{ label: '过期日期', value: row.expireDate },
|
||
{ label: '生产日期', value: row.productionDate || '—' },
|
||
{ label: '厂家', value: row.manufacturer },
|
||
{ label: '存储位置', value: row.storageLocation || '—' },
|
||
...(isConfiguredReagentRow(row)
|
||
? []
|
||
: [
|
||
{ label: '单价(元)', value: formatMoneyDisplay(row.unitPrice) },
|
||
{ label: '金额(元)', value: formatMoneyDisplay(row.amount) }
|
||
]),
|
||
{ label: '入库数量', value: String(row.inQty ?? 0) },
|
||
{ label: '剩余数量', value: String(row.remainingQty ?? 0) }
|
||
]
|
||
return [
|
||
{
|
||
title: '批次信息',
|
||
fields: batchFields
|
||
},
|
||
{
|
||
title: '物资信息',
|
||
fields: [
|
||
{ label: '规格型号', value: row.specModel },
|
||
{ label: '单位', value: row.unit },
|
||
{
|
||
label: '状态',
|
||
value: row.status === '1' ? '正常' : '停用',
|
||
tagType: (row.status === '1' ? 'success' : 'info') as 'success' | 'info'
|
||
},
|
||
{ label: '备注', value: row.remark || '—', span: true },
|
||
{ label: '创建时间', value: row.createTime }
|
||
]
|
||
},
|
||
{
|
||
title: '领用详情',
|
||
slot: 'usage-details',
|
||
fields: []
|
||
}
|
||
]
|
||
})
|
||
|
||
function isViewUsageDiscardRow(row: ProductionMaterialUsage) {
|
||
return row.changeType === 'discard' || row.sourceType === 'manual_discard'
|
||
}
|
||
|
||
function isViewUsageManualOutRow(row: ProductionMaterialUsage) {
|
||
if (row.sourceType === 'manual_out') return true
|
||
const remark = row.remark || ''
|
||
return row.changeType === 'use' && (row.changeQty ?? 0) < 0 && remark.includes('领用人:')
|
||
}
|
||
|
||
/** 批次「领用详情」仅展示从本批次直接出库/废弃的记录,不含领用后的消耗明细 */
|
||
function isBatchRequisitionUsageRow(row: ProductionMaterialUsage) {
|
||
if (row.sourceType === 'prep_consume') return false
|
||
if ((row.parentUsageId || '').trim()) return false
|
||
if (isViewUsageDiscardRow(row)) return true
|
||
if (isViewUsageManualOutRow(row)) return true
|
||
if (row.sourceType === 'step_save') return true
|
||
return false
|
||
}
|
||
|
||
function usageChangeLabel(row: ProductionMaterialUsage) {
|
||
if (isViewUsageDiscardRow(row)) return '废弃'
|
||
if (isViewUsageManualOutRow(row)) return '手动出库'
|
||
return '任务使用'
|
||
}
|
||
|
||
function usageChangeTagType(row: ProductionMaterialUsage) {
|
||
if (isViewUsageDiscardRow(row)) return 'danger' as const
|
||
if (isViewUsageManualOutRow(row)) return 'warning' as const
|
||
return 'primary' as const
|
||
}
|
||
|
||
async function loadData() {
|
||
loading.value = true
|
||
try {
|
||
const res = await fetchProductionMaterialBatchList({
|
||
page: pagination.page,
|
||
pageSize: pagination.pageSize,
|
||
keyword: searchForm.keyword || undefined,
|
||
materialType: searchForm.materialType || undefined,
|
||
status: searchForm.status || undefined
|
||
})
|
||
tableData.value = res.list || []
|
||
pagination.total = res.total ?? 0
|
||
} finally {
|
||
loading.value = false
|
||
}
|
||
}
|
||
|
||
function handleSearch() {
|
||
pagination.page = 1
|
||
loadData()
|
||
}
|
||
|
||
function handleReset() {
|
||
searchForm.keyword = ''
|
||
searchForm.materialType = ''
|
||
searchForm.status = ''
|
||
pagination.page = 1
|
||
loadData()
|
||
}
|
||
|
||
function onEditPriceQtyChange() {
|
||
if (formData.amountManual) return
|
||
formData.amount = calcAmount(formData.unitPrice ?? 0, formData.inQty)
|
||
}
|
||
|
||
function handleEdit(row: ProductionMaterialBatch) {
|
||
editingBatchId.value = row.batchId || row.id
|
||
formData.stockInNo = row.stockInNo || ''
|
||
formData.stockInDate = row.stockInDate || ''
|
||
formData.expireDate = row.expireDate || ''
|
||
formData.productionDate = row.productionDate || ''
|
||
formData.catalogNo = row.catalogNo || ''
|
||
formData.batchNo = row.batchNo || ''
|
||
formData.manufacturer = row.manufacturer || ''
|
||
formData.storageLocation = row.storageLocation || ''
|
||
formData.unitPrice = row.unitPrice ?? null
|
||
formData.amount = row.amount ?? null
|
||
formData.amountManual = false
|
||
formData.inQty = row.inQty ?? 0
|
||
formData.remainingQty = row.remainingQty ?? 0
|
||
formData.materialCode = row.materialCode || ''
|
||
formData.materialName = row.materialName || ''
|
||
formData.specModel = row.specModel || ''
|
||
formData.unit = row.unit || ''
|
||
formData.warningQty = row.warningQty ?? 0
|
||
formData.status = row.status || '1'
|
||
formData.remark = row.remark || ''
|
||
ensureUnitOption(row.unit || '')
|
||
dialogVisible.value = true
|
||
void searchUnitOptions('')
|
||
formRef.value?.clearValidate?.()
|
||
}
|
||
|
||
async function handleSubmit() {
|
||
await formRef.value?.validate?.()
|
||
if (!editingBatchId.value) return
|
||
submitLoading.value = true
|
||
try {
|
||
await fetchUpdateProductionMaterialBatch(editingBatchId.value, {
|
||
stockInNo: formData.stockInNo.trim(),
|
||
stockInDate: formData.stockInDate,
|
||
expireDate: formData.expireDate,
|
||
productionDate: formData.productionDate || undefined,
|
||
catalogNo: formData.catalogNo.trim(),
|
||
batchNo: formData.batchNo.trim(),
|
||
manufacturer: formData.manufacturer.trim(),
|
||
storageLocation: formData.storageLocation?.trim() || undefined,
|
||
unitPrice: Number(formData.unitPrice) || 0,
|
||
amount: Number(formData.amount) || 0,
|
||
materialCode: formData.materialCode.trim(),
|
||
materialName: formData.materialName.trim(),
|
||
specModel: formData.specModel?.trim() || undefined,
|
||
unit: formData.unit?.trim() || undefined,
|
||
warningQty: formData.warningQty,
|
||
status: String(formData.status ?? '1'),
|
||
remark: formData.remark?.trim() || undefined
|
||
})
|
||
ElMessage.success('更新成功')
|
||
dialogVisible.value = false
|
||
await loadData()
|
||
} catch {
|
||
/* 校验或接口错误已由全局处理 */
|
||
} finally {
|
||
submitLoading.value = false
|
||
}
|
||
}
|
||
|
||
async function handleView(row: ProductionMaterialBatch) {
|
||
viewRow.value = row
|
||
viewVisible.value = true
|
||
viewUsageRecords.value = []
|
||
viewLoading.value = true
|
||
try {
|
||
const res = await fetchProductionMaterialUsageList({
|
||
page: 1,
|
||
pageSize: 100,
|
||
stockInNo: row.stockInNo || undefined
|
||
})
|
||
viewUsageRecords.value = (res.list || []).filter(
|
||
(u) => u.stockInNo === row.stockInNo && isBatchRequisitionUsageRow(u)
|
||
)
|
||
} catch {
|
||
viewUsageRecords.value = []
|
||
} finally {
|
||
viewLoading.value = false
|
||
}
|
||
}
|
||
|
||
async function handleDelete(row: ProductionMaterialBatch) {
|
||
try {
|
||
await ElMessageBox.confirm(
|
||
`确定要删除入库批次「${row.stockInNo}」吗?已有领用记录的批次不可删除。`,
|
||
'提示',
|
||
{ type: 'warning' }
|
||
)
|
||
} catch {
|
||
return
|
||
}
|
||
try {
|
||
await fetchDeleteProductionMaterialBatch(row.batchId || row.id)
|
||
ElMessage.success('删除成功')
|
||
await loadData()
|
||
} catch {
|
||
/* 接口错误已由全局处理 */
|
||
}
|
||
}
|
||
|
||
function formatTodayDate() {
|
||
const now = new Date()
|
||
const pad = (n: number) => String(n).padStart(2, '0')
|
||
return `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`
|
||
}
|
||
|
||
/** 入库编号默认值:RK + 年月日时分秒 + 2 位随机数(与配置试剂入库风格一致) */
|
||
function generateStockInNo() {
|
||
const now = new Date()
|
||
const pad = (n: number) => String(n).padStart(2, '0')
|
||
const day = `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}`
|
||
const time = `${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`
|
||
const rand = String(Math.floor(Math.random() * 100)).padStart(2, '0')
|
||
return `RK${day}${time}${rand}`
|
||
}
|
||
|
||
/** 货号默认值:物料编码 → 批号 → — */
|
||
function resolveCatalogNo(materialCode?: string, batchNo?: string, catalogNo?: string) {
|
||
const existing = (catalogNo || '').trim()
|
||
if (existing) return existing
|
||
const code = (materialCode || '').trim()
|
||
if (code) return code
|
||
const batch = (batchNo || '').trim()
|
||
if (batch) return batch
|
||
return '—'
|
||
}
|
||
|
||
function ensureNewMaterialCode() {
|
||
if ((stockInForm.newMaterialCode || '').trim()) return stockInForm.newMaterialCode.trim()
|
||
const pad = String(Date.now()).slice(-6)
|
||
const code = `PM-${pad}`
|
||
stockInForm.newMaterialCode = code
|
||
return code
|
||
}
|
||
|
||
function onStockInMaterialKeyChange(val: string) {
|
||
const opt = materialOptions.value.find((o) => o.id === val)
|
||
if (opt) {
|
||
stockInForm.materialId = opt.id
|
||
stockInForm.newMaterialCode = ''
|
||
stockInForm.newSpecModel = ''
|
||
stockInForm.newUnit = ''
|
||
} else {
|
||
stockInForm.materialId = ''
|
||
if (val) {
|
||
ensureNewMaterialCode()
|
||
}
|
||
}
|
||
}
|
||
|
||
async function resolveStockInMaterialId(): Promise<string> {
|
||
if (stockInForm.materialId) return stockInForm.materialId
|
||
const name = (stockInForm.materialKey || '').trim()
|
||
if (!name) throw new Error('请选择或输入物资')
|
||
const created = await fetchCreateProductionMaterial({
|
||
materialCode: ensureNewMaterialCode(),
|
||
materialName: name,
|
||
materialType: stockInForm.newMaterialType || 'consumable',
|
||
specModel: stockInForm.newSpecModel?.trim() || undefined,
|
||
unit: stockInForm.newUnit?.trim() || undefined,
|
||
status: '1'
|
||
})
|
||
return created.id
|
||
}
|
||
|
||
function resetStockInForm() {
|
||
stockInForm.materialKey = ''
|
||
stockInForm.materialId = ''
|
||
stockInForm.newMaterialCode = ''
|
||
stockInForm.newMaterialType = 'consumable'
|
||
stockInForm.newSpecModel = ''
|
||
stockInForm.newUnit = ''
|
||
stockInForm.stockInNo = ''
|
||
stockInForm.stockInDate = formatTodayDate()
|
||
stockInForm.expireDate = ''
|
||
stockInForm.productionDate = ''
|
||
stockInForm.catalogNo = ''
|
||
stockInForm.batchNo = ''
|
||
stockInForm.manufacturer = ''
|
||
stockInForm.storageLocation = ''
|
||
stockInForm.unitPrice = null
|
||
stockInForm.amount = null
|
||
stockInForm.amountManual = false
|
||
stockInForm.qty = 1
|
||
stockInForm.remark = ''
|
||
}
|
||
|
||
function onSingleStockInPriceQtyChange() {
|
||
if (stockInForm.amountManual) return
|
||
stockInForm.amount = calcAmount(stockInForm.unitPrice ?? 0, stockInForm.qty)
|
||
}
|
||
|
||
function handleOpenStockIn() {
|
||
resetStockInForm()
|
||
stockInVisible.value = true
|
||
void searchMaterialOptions('')
|
||
stockInFormRef.value?.clearValidate?.()
|
||
}
|
||
|
||
async function handleStockInSubmit() {
|
||
await stockInFormRef.value?.validate?.()
|
||
stockInLoading.value = true
|
||
try {
|
||
const materialId = await resolveStockInMaterialId()
|
||
const materialCode =
|
||
stockInSelectedOpt.value?.materialCode ||
|
||
(stockInForm.newMaterialCode || '').trim() ||
|
||
''
|
||
const stockInNo = (stockInForm.stockInNo || '').trim() || generateStockInNo()
|
||
const catalogNo = resolveCatalogNo(
|
||
materialCode,
|
||
stockInForm.batchNo,
|
||
stockInForm.catalogNo
|
||
)
|
||
await fetchStockInProductionMaterial(materialId, {
|
||
stockInNo,
|
||
stockInDate: stockInForm.stockInDate,
|
||
expireDate: stockInForm.expireDate,
|
||
productionDate: stockInForm.productionDate || undefined,
|
||
catalogNo,
|
||
batchNo: stockInForm.batchNo.trim(),
|
||
manufacturer: stockInForm.manufacturer.trim(),
|
||
storageLocation: stockInForm.storageLocation?.trim() || undefined,
|
||
unitPrice: Number(stockInForm.unitPrice) || 0,
|
||
amount: Number(stockInForm.amount) || 0,
|
||
qty: stockInForm.qty,
|
||
stockInTime: formatNowDatetime(),
|
||
remark: stockInForm.remark?.trim() || undefined
|
||
})
|
||
ElMessage.success('入库成功')
|
||
stockInVisible.value = false
|
||
await loadData()
|
||
} catch {
|
||
/* 校验或接口错误已由全局处理 */
|
||
} finally {
|
||
stockInLoading.value = false
|
||
}
|
||
}
|
||
|
||
function newBatchStockInLine(): BatchStockInLine {
|
||
return {
|
||
materialId: '',
|
||
materialCode: '',
|
||
materialName: '',
|
||
specModel: '',
|
||
unit: '',
|
||
stockInNo: '',
|
||
stockInDate: formatTodayDate(),
|
||
expireDate: '',
|
||
productionDate: '',
|
||
catalogNo: '',
|
||
batchNo: '',
|
||
manufacturer: '',
|
||
storageLocation: '',
|
||
unitPrice: null,
|
||
amount: null,
|
||
amountManual: false,
|
||
qty: 1,
|
||
remark: ''
|
||
}
|
||
}
|
||
|
||
function addBatchStockInLine() {
|
||
batchStockInLines.value.push(newBatchStockInLine())
|
||
}
|
||
|
||
function onBatchInMaterialChange(row: BatchStockInLine, materialId: string) {
|
||
if (!materialId) {
|
||
row.materialCode = ''
|
||
row.materialName = ''
|
||
row.specModel = ''
|
||
row.unit = ''
|
||
return
|
||
}
|
||
const opt = materialOptions.value.find((o) => o.id === materialId)
|
||
row.materialCode = opt?.materialCode || ''
|
||
row.materialName = opt?.materialName || ''
|
||
row.specModel = opt?.specModel || ''
|
||
row.unit = opt?.unit || ''
|
||
}
|
||
|
||
function onBatchInLinePriceQtyChange(row: BatchStockInLine) {
|
||
if (row.amountManual) return
|
||
row.amount = calcAmount(row.unitPrice ?? 0, row.qty)
|
||
}
|
||
|
||
function newBatchStockOutLine(): BatchStockOutLine {
|
||
return {
|
||
batchId: '',
|
||
stockInNo: '',
|
||
materialName: '',
|
||
batchNo: '',
|
||
remainingQty: 0,
|
||
qty: 1,
|
||
usageUnit: '',
|
||
remark: ''
|
||
}
|
||
}
|
||
|
||
function addBatchStockOutLine() {
|
||
batchStockOutLines.value.push(newBatchStockOutLine())
|
||
}
|
||
|
||
function isBatchOutOptionDisabled(batchId: string, currentIndex: number) {
|
||
return batchStockOutLines.value.some((r, i) => i !== currentIndex && r.batchId === batchId)
|
||
}
|
||
|
||
function onBatchOutLinePick(row: BatchStockOutLine, index: number, batchId: string) {
|
||
if (!batchId) return
|
||
if (isBatchOutOptionDisabled(batchId, index)) {
|
||
ElMessage.warning('该批次已在列表中')
|
||
row.batchId = ''
|
||
return
|
||
}
|
||
const opt = batchOptions.value.find((o) => o.id === batchId)
|
||
if (!opt) return
|
||
row.stockInNo = opt.stockInNo
|
||
row.materialName = opt.materialName
|
||
row.batchNo = opt.batchNo
|
||
row.remainingQty = opt.remainingQty
|
||
row.qty = Math.min(row.qty || 1, opt.remainingQty)
|
||
if (!row.usageUnit?.trim() && opt.unit) {
|
||
row.usageUnit = opt.unit
|
||
ensureUnitOption(opt.unit)
|
||
}
|
||
}
|
||
|
||
function newBatchDiscardLine(): BatchDiscardLine {
|
||
return {
|
||
batchId: '',
|
||
stockInNo: '',
|
||
materialName: '',
|
||
batchNo: '',
|
||
remainingQty: 0,
|
||
qty: 1,
|
||
usageUnit: '',
|
||
remark: ''
|
||
}
|
||
}
|
||
|
||
function addBatchDiscardLine() {
|
||
batchDiscardLines.value.push(newBatchDiscardLine())
|
||
}
|
||
|
||
function isBatchDiscardOptionDisabled(batchId: string, currentIndex: number) {
|
||
return batchDiscardLines.value.some((r, i) => i !== currentIndex && r.batchId === batchId)
|
||
}
|
||
|
||
function onBatchDiscardLinePick(row: BatchDiscardLine, index: number, batchId: string) {
|
||
if (!batchId) return
|
||
if (isBatchDiscardOptionDisabled(batchId, index)) {
|
||
ElMessage.warning('该批次已在列表中')
|
||
row.batchId = ''
|
||
return
|
||
}
|
||
const opt = batchOptions.value.find((o) => o.id === batchId)
|
||
if (!opt) return
|
||
row.stockInNo = opt.stockInNo
|
||
row.materialName = opt.materialName
|
||
row.batchNo = opt.batchNo
|
||
row.remainingQty = opt.remainingQty
|
||
row.qty = Math.min(row.qty || 1, opt.remainingQty)
|
||
if (!row.usageUnit?.trim() && opt.unit) {
|
||
row.usageUnit = opt.unit
|
||
ensureUnitOption(opt.unit)
|
||
}
|
||
}
|
||
|
||
function handleBatchDiscard() {
|
||
batchDiscardLines.value = [newBatchDiscardLine()]
|
||
batchDiscardForm.discardTime = formatNowDatetime()
|
||
batchDiscardForm.discardReason = ''
|
||
batchDiscardForm.remark = ''
|
||
batchDiscardVisible.value = true
|
||
void searchBatchOptions('')
|
||
void searchUnitOptions('')
|
||
batchDiscardFormRef.value?.clearValidate?.()
|
||
}
|
||
|
||
async function handleBatchDiscardSubmit() {
|
||
await batchDiscardFormRef.value?.validate?.()
|
||
if (!batchDiscardLines.value.length) {
|
||
ElMessage.warning('请至少添加一条废弃明细')
|
||
return
|
||
}
|
||
for (const line of batchDiscardLines.value) {
|
||
if (!line.batchId) {
|
||
ElMessage.warning('请选择入库批次')
|
||
return
|
||
}
|
||
if (!line.qty || line.qty <= 0) {
|
||
ElMessage.warning('废弃数量必须大于 0')
|
||
return
|
||
}
|
||
if (line.qty > line.remainingQty) {
|
||
ElMessage.warning(`批次「${line.stockInNo}」废弃数量不能超过剩余 ${line.remainingQty}`)
|
||
return
|
||
}
|
||
if (!line.usageUnit?.trim()) {
|
||
ElMessage.warning('请选择单位')
|
||
return
|
||
}
|
||
}
|
||
if (batchDiscardForm.discardReason === '其他' && !(batchDiscardForm.remark || '').trim()) {
|
||
ElMessage.warning('选择「其他」时请填写备注说明')
|
||
return
|
||
}
|
||
try {
|
||
await ElMessageBox.confirm(
|
||
`确定废弃 ${batchDiscardLines.value.length} 项物料吗?废弃后库存将扣减且不可恢复。`,
|
||
'批量废弃确认',
|
||
{ type: 'warning' }
|
||
)
|
||
} catch {
|
||
return
|
||
}
|
||
batchDiscardLoading.value = true
|
||
try {
|
||
const res = await fetchBatchDiscardProductionMaterial({
|
||
items: batchDiscardLines.value.map((l) => ({
|
||
batchId: l.batchId,
|
||
qty: l.qty,
|
||
usageUnit: l.usageUnit?.trim() || undefined,
|
||
remark: l.remark?.trim() || undefined
|
||
})),
|
||
discardReason: batchDiscardForm.discardReason?.trim() || '',
|
||
remark: batchDiscardForm.remark?.trim() || undefined,
|
||
discardTime: batchDiscardForm.discardTime || undefined
|
||
})
|
||
ElMessage.success(`批量废弃成功,共 ${res.count ?? batchDiscardLines.value.length} 项`)
|
||
batchDiscardVisible.value = false
|
||
await loadData()
|
||
} catch {
|
||
/* 校验或接口错误已由全局处理 */
|
||
} finally {
|
||
batchDiscardLoading.value = false
|
||
}
|
||
}
|
||
|
||
function handleBatchStockIn() {
|
||
batchStockInLines.value = [newBatchStockInLine()]
|
||
batchStockInForm.stockInTime = formatNowDatetime()
|
||
batchStockInForm.remark = ''
|
||
batchStockInVisible.value = true
|
||
void searchMaterialOptions('')
|
||
batchStockInFormRef.value?.clearValidate?.()
|
||
}
|
||
|
||
async function handleBatchStockInSubmit() {
|
||
await batchStockInFormRef.value?.validate?.()
|
||
if (!batchStockInLines.value.length) {
|
||
ElMessage.warning('请至少添加一条入库明细')
|
||
return
|
||
}
|
||
for (const line of batchStockInLines.value) {
|
||
if (!line.materialId) {
|
||
ElMessage.warning('请选择物资')
|
||
return
|
||
}
|
||
if (!line.stockInDate) {
|
||
ElMessage.warning('请选择入库日期')
|
||
return
|
||
}
|
||
if (!line.expireDate) {
|
||
ElMessage.warning('请选择过期日期')
|
||
return
|
||
}
|
||
if (!line.batchNo?.trim() || !line.manufacturer?.trim()) {
|
||
ElMessage.warning('请填写批号、厂家')
|
||
return
|
||
}
|
||
if (line.unitPrice == null || line.amount == null) {
|
||
ElMessage.warning('请填写单价和金额')
|
||
return
|
||
}
|
||
if (!line.qty || line.qty <= 0) {
|
||
ElMessage.warning('入库数量必须大于 0')
|
||
return
|
||
}
|
||
}
|
||
try {
|
||
await ElMessageBox.confirm(
|
||
`确定批量入库 ${batchStockInLines.value.length} 项吗?`,
|
||
'批量入库确认',
|
||
{ type: 'warning' }
|
||
)
|
||
} catch {
|
||
return
|
||
}
|
||
batchStockInLoading.value = true
|
||
try {
|
||
const res = await fetchBatchStockInProductionMaterial({
|
||
items: batchStockInLines.value.map((l, idx) => ({
|
||
materialId: l.materialId,
|
||
stockInNo: (l.stockInNo || '').trim() || `${generateStockInNo()}${String(idx).padStart(2, '0')}`,
|
||
stockInDate: l.stockInDate,
|
||
expireDate: l.expireDate,
|
||
productionDate: l.productionDate || undefined,
|
||
catalogNo: resolveCatalogNo(l.materialCode, l.batchNo, l.catalogNo),
|
||
batchNo: l.batchNo.trim(),
|
||
manufacturer: l.manufacturer.trim(),
|
||
storageLocation: l.storageLocation?.trim() || undefined,
|
||
unitPrice: Number(l.unitPrice) || 0,
|
||
amount: Number(l.amount) || 0,
|
||
qty: l.qty,
|
||
remark: l.remark?.trim() || undefined
|
||
})),
|
||
stockInTime: batchStockInForm.stockInTime || undefined,
|
||
remark: batchStockInForm.remark?.trim() || undefined
|
||
})
|
||
ElMessage.success(`批量入库成功,共 ${res.count ?? batchStockInLines.value.length} 项`)
|
||
batchStockInVisible.value = false
|
||
await loadData()
|
||
} catch {
|
||
/* 校验或接口错误已由全局处理 */
|
||
} finally {
|
||
batchStockInLoading.value = false
|
||
}
|
||
}
|
||
|
||
function buildBatchStockOutPrefillFromSelection(): {
|
||
lines: BatchStockOutLine[]
|
||
options: ProductionMaterialBatchOption[]
|
||
skippedZero: number
|
||
} {
|
||
const sel = selectedRows.value || []
|
||
const lines: BatchStockOutLine[] = []
|
||
const options: ProductionMaterialBatchOption[] = []
|
||
const seen = new Set<string>()
|
||
let skippedZero = 0
|
||
for (const row of sel) {
|
||
const rem = Number(row.remainingQty) || 0
|
||
if (rem <= 0) {
|
||
skippedZero += 1
|
||
continue
|
||
}
|
||
const batchId = row.batchId || row.id
|
||
if (!batchId || seen.has(batchId)) continue
|
||
seen.add(batchId)
|
||
const unit = (row.unit || '').trim()
|
||
const mfr = (row.manufacturer || '').trim()
|
||
const cat = (row.catalogNo || '').trim()
|
||
lines.push({
|
||
batchId,
|
||
stockInNo: row.stockInNo || '',
|
||
materialName: row.materialName || '',
|
||
batchNo: row.batchNo || '',
|
||
remainingQty: rem,
|
||
qty: Math.min(1, rem),
|
||
usageUnit: unit,
|
||
remark: ''
|
||
})
|
||
options.push({
|
||
id: batchId,
|
||
batchId,
|
||
stockInNo: row.stockInNo || '',
|
||
stockInDate: row.stockInDate,
|
||
expireDate: row.expireDate,
|
||
productionDate: row.productionDate,
|
||
materialId: row.materialId,
|
||
materialCode: row.materialCode || '',
|
||
materialName: row.materialName || '',
|
||
materialType: row.materialType || '',
|
||
specModel: row.specModel || '',
|
||
unit,
|
||
batchNo: row.batchNo || '',
|
||
catalogNo: row.catalogNo || '',
|
||
manufacturer: row.manufacturer || '',
|
||
storageLocation: row.storageLocation,
|
||
unitPrice: row.unitPrice,
|
||
amount: row.amount,
|
||
remainingQty: rem,
|
||
label: `${row.stockInNo || ''} / ${row.materialName || ''} / 厂家:${mfr || '—'} / 批号:${
|
||
row.batchNo || '—'
|
||
} / 货号:${cat || '—'} / 剩:${rem}${unit}`
|
||
})
|
||
if (unit) ensureUnitOption(unit)
|
||
}
|
||
return { lines, options, skippedZero }
|
||
}
|
||
|
||
function mergeBatchOptions(extra: ProductionMaterialBatchOption[]) {
|
||
if (!extra.length) return
|
||
const ids = new Set(batchOptions.value.map((o) => o.id))
|
||
const missing = extra.filter((o) => o.id && !ids.has(o.id))
|
||
if (missing.length) {
|
||
batchOptions.value = [...missing, ...batchOptions.value]
|
||
}
|
||
}
|
||
|
||
function handleBatchStockOut() {
|
||
const { lines, options, skippedZero } = buildBatchStockOutPrefillFromSelection()
|
||
const selectedCount = (selectedRows.value || []).length
|
||
if (selectedCount > 0 && lines.length === 0) {
|
||
ElMessage.warning('所选物料剩余数量均为 0,无法出库,请手动选择有库存的批次')
|
||
} else if (skippedZero > 0) {
|
||
ElMessage.warning(`已跳过 ${skippedZero} 项剩余数量为 0 的物料`)
|
||
}
|
||
batchStockOutLines.value = lines.length ? lines : [newBatchStockOutLine()]
|
||
batchOptions.value = options
|
||
batchStockOutForm.stockOutTime = formatNowDatetime()
|
||
batchStockOutForm.receiver = ''
|
||
batchStockOutForm.purpose = ''
|
||
batchStockOutForm.remark = ''
|
||
batchStockOutVisible.value = true
|
||
void searchReceiverUsers('')
|
||
void searchBatchOptions('').then(() => mergeBatchOptions(options))
|
||
void searchUnitOptions('').then(() => {
|
||
for (const line of batchStockOutLines.value) {
|
||
if (line.usageUnit) ensureUnitOption(line.usageUnit)
|
||
}
|
||
})
|
||
batchStockOutFormRef.value?.clearValidate?.()
|
||
}
|
||
|
||
async function handleBatchStockOutSubmit() {
|
||
await batchStockOutFormRef.value?.validate?.()
|
||
if (!batchStockOutLines.value.length) {
|
||
ElMessage.warning('请至少添加一条出库明细')
|
||
return
|
||
}
|
||
for (const line of batchStockOutLines.value) {
|
||
if (!line.batchId) {
|
||
ElMessage.warning('请选择入库批次')
|
||
return
|
||
}
|
||
if (!line.qty || line.qty <= 0) {
|
||
ElMessage.warning('出库数量必须大于 0')
|
||
return
|
||
}
|
||
if (line.qty > line.remainingQty) {
|
||
ElMessage.warning(`批次「${line.stockInNo}」出库数量不能超过剩余 ${line.remainingQty}`)
|
||
return
|
||
}
|
||
if (!line.usageUnit?.trim()) {
|
||
ElMessage.warning('请选择出库单位')
|
||
return
|
||
}
|
||
}
|
||
try {
|
||
await ElMessageBox.confirm(
|
||
`确定为领用人「${batchStockOutForm.receiver}」批量出库 ${batchStockOutLines.value.length} 项吗?`,
|
||
'批量出库确认',
|
||
{ type: 'warning' }
|
||
)
|
||
} catch {
|
||
return
|
||
}
|
||
batchStockOutLoading.value = true
|
||
try {
|
||
const res = await fetchBatchStockOutProductionMaterial({
|
||
items: batchStockOutLines.value.map((l) => ({
|
||
batchId: l.batchId,
|
||
qty: l.qty,
|
||
usageUnit: l.usageUnit?.trim() || undefined,
|
||
remark: l.remark?.trim() || undefined
|
||
})),
|
||
stockOutTime: batchStockOutForm.stockOutTime || undefined,
|
||
receiver: batchStockOutForm.receiver?.trim() || undefined,
|
||
purpose: batchStockOutForm.purpose?.trim() || undefined,
|
||
remark: batchStockOutForm.remark?.trim() || undefined
|
||
})
|
||
ElMessage.success(`批量出库成功,共 ${res.count ?? batchStockOutLines.value.length} 项`)
|
||
batchStockOutVisible.value = false
|
||
await loadData()
|
||
} catch {
|
||
/* 校验或接口错误已由全局处理 */
|
||
} finally {
|
||
batchStockOutLoading.value = false
|
||
}
|
||
}
|
||
// 输入检索条件时自动搜索(防抖 300ms)
|
||
watchDebounced(
|
||
searchForm,
|
||
() => {
|
||
pagination.page = 1
|
||
loadData()
|
||
},
|
||
{ debounce: 300, deep: true }
|
||
)
|
||
|
||
onMounted(() => {
|
||
const tab = route.query.tab
|
||
if (tab === 'usage' || tab === 'stockCheck' || tab === 'prep') {
|
||
activeTab.value = tab as string
|
||
ensureTabMounted(tab as string)
|
||
}
|
||
if (
|
||
route.query.materialType === 'reagent' ||
|
||
route.query.materialType === 'consumable' ||
|
||
route.query.materialType === 'configured_reagent'
|
||
) {
|
||
searchForm.materialType = route.query.materialType as string
|
||
}
|
||
loadData()
|
||
})
|
||
</script>
|
||
|
||
<style scoped lang="scss">
|
||
.table-op-btns {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
justify-content: center;
|
||
gap: 6px;
|
||
}
|
||
|
||
.form-section-label {
|
||
grid-column: 1 / -1;
|
||
margin: 8px 0 4px;
|
||
font-size: 13px;
|
||
font-weight: 600;
|
||
color: var(--mint-text, #0f172a);
|
||
|
||
&:first-child {
|
||
margin-top: 0;
|
||
}
|
||
}
|
||
|
||
.form-col-span-3 {
|
||
grid-column: 1 / -1;
|
||
}
|
||
|
||
:global(.batch-out-option-popper .el-select-dropdown__item) {
|
||
height: auto;
|
||
min-height: 52px;
|
||
line-height: 1.45;
|
||
white-space: normal;
|
||
padding-top: 8px;
|
||
padding-bottom: 8px;
|
||
}
|
||
|
||
.batch-option-item {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 4px;
|
||
line-height: 1.4;
|
||
padding: 0;
|
||
}
|
||
|
||
.batch-option-main {
|
||
font-size: 13px;
|
||
color: var(--mint-text, #0f172a);
|
||
}
|
||
|
||
.batch-option-sub {
|
||
font-size: 12px;
|
||
color: var(--mint-text-muted, #64748b);
|
||
}
|
||
|
||
.batch-out-select {
|
||
:deep(.el-select__wrapper) {
|
||
min-height: 40px;
|
||
}
|
||
}
|
||
|
||
.material-dialog-form {
|
||
:deep(.el-form-item) {
|
||
margin-bottom: 0;
|
||
}
|
||
}
|
||
|
||
.material-batch-stock-dialog {
|
||
.batch-stock-move-head {
|
||
margin-bottom: 16px;
|
||
}
|
||
|
||
.batch-stock-move-lines-head {
|
||
display: flex;
|
||
align-items: flex-end;
|
||
justify-content: space-between;
|
||
gap: 16px;
|
||
margin-bottom: 10px;
|
||
}
|
||
|
||
.batch-stock-move-lines-head-left {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 4px;
|
||
min-width: 0;
|
||
}
|
||
|
||
.batch-stock-move-material-select {
|
||
flex-shrink: 0;
|
||
width: 320px;
|
||
}
|
||
|
||
.batch-stock-move-lines-title {
|
||
font-size: 14px;
|
||
font-weight: 600;
|
||
color: var(--mint-text, #0f172a);
|
||
}
|
||
|
||
.batch-stock-move-lines-hint {
|
||
font-size: 12px;
|
||
color: var(--mint-text-muted, #64748b);
|
||
}
|
||
|
||
.inner-table {
|
||
width: 100%;
|
||
}
|
||
|
||
.inner-cell-input {
|
||
width: 100%;
|
||
}
|
||
|
||
.batch-in-line-list {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 6px;
|
||
max-height: 460px;
|
||
overflow-y: auto;
|
||
padding-right: 2px;
|
||
}
|
||
|
||
.batch-in-line-card {
|
||
display: grid;
|
||
grid-template-columns: 28px 1fr;
|
||
gap: 0 6px;
|
||
align-items: start;
|
||
border: 1px solid var(--mint-border, #e2e8f0);
|
||
border-radius: 6px;
|
||
padding: 6px 8px;
|
||
background: #fff;
|
||
|
||
&:nth-child(even) {
|
||
background: var(--el-fill-color-lighter, #f8fafc);
|
||
}
|
||
}
|
||
|
||
.batch-in-line-card-head {
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
gap: 2px;
|
||
padding-top: 18px;
|
||
}
|
||
|
||
.batch-in-line-card-index {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
width: 20px;
|
||
height: 20px;
|
||
border-radius: 4px;
|
||
font-size: 11px;
|
||
font-weight: 600;
|
||
color: var(--primary-dark, #065f46);
|
||
background: var(--primary-bg, #e8f4ee);
|
||
}
|
||
|
||
.batch-in-line-grid {
|
||
display: grid;
|
||
grid-template-columns: repeat(6, minmax(0, 1fr));
|
||
gap: 4px 8px;
|
||
min-width: 0;
|
||
}
|
||
|
||
.batch-in-col-span-2 {
|
||
grid-column: span 2;
|
||
}
|
||
|
||
.batch-in-line-card-body {
|
||
--batch-in-control-h: 28px;
|
||
|
||
:deep(.el-form-item) {
|
||
margin-bottom: 0;
|
||
}
|
||
|
||
:deep(.el-form-item__label) {
|
||
margin-bottom: 0;
|
||
padding-bottom: 2px;
|
||
font-size: 11px;
|
||
line-height: 1.2;
|
||
color: var(--mint-text-muted, #64748b);
|
||
}
|
||
|
||
:deep(.el-select),
|
||
:deep(.el-input),
|
||
:deep(.el-date-editor),
|
||
:deep(.el-input-number) {
|
||
width: 100%;
|
||
}
|
||
|
||
:deep(.el-input__wrapper),
|
||
:deep(.el-select__wrapper) {
|
||
min-height: var(--batch-in-control-h);
|
||
height: var(--batch-in-control-h);
|
||
padding-top: 0;
|
||
padding-bottom: 0;
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
:deep(.el-input__inner) {
|
||
height: calc(var(--batch-in-control-h) - 2px);
|
||
line-height: calc(var(--batch-in-control-h) - 2px);
|
||
}
|
||
|
||
:deep(.el-date-editor.el-input) {
|
||
height: var(--batch-in-control-h);
|
||
--el-input-height: var(--batch-in-control-h);
|
||
}
|
||
|
||
:deep(.el-input-number--small) {
|
||
width: 100%;
|
||
line-height: var(--batch-in-control-h);
|
||
|
||
.el-input__wrapper {
|
||
min-height: var(--batch-in-control-h);
|
||
height: var(--batch-in-control-h);
|
||
}
|
||
|
||
.el-input-number__decrease,
|
||
.el-input-number__increase {
|
||
height: calc((var(--batch-in-control-h) - 2px) / 2);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
</style>
|