| | |
| | | style="width: 200px" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="预警级别:"> |
| | | <el-select |
| | | v-model="searchForm.warningLevel" |
| | | placeholder="请选择预警级别" |
| | | clearable |
| | | style="width: 150px" |
| | | > |
| | | <el-option label="紧急" value="紧急" /> |
| | | <el-option label="重要" value="重要" /> |
| | | <el-option label="一般" value="一般" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="预警状态:"> |
| | | <el-select |
| | | v-model="searchForm.warningStatus" |
| | |
| | | <span v-else>-</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="建议类型" prop="suggestionType" width="110" show-overflow-tooltip /> |
| | | <el-table-column label="建议内容" prop="suggestionContent" show-overflow-tooltip /> |
| | | <el-table-column fixed="right" label="操作" width="210" align="center"> |
| | | <template #default="scope"> |
| | | <el-button link type="primary" size="small" @click="handleSuggestion(scope.row, '采购建议')">采购建议</el-button> |
| | | <el-button link type="warning" size="small" @click="handleSuggestion(scope.row, '滞销处理')">滞销提示</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <pagination |
| | | v-show="total > 0" |
| | |
| | | import { ElMessage } from 'element-plus' |
| | | import pagination from '@/components/PIMTable/Pagination.vue' |
| | | import { |
| | | getStockWarningLedgerPage |
| | | getStockWarningLedgerPage, |
| | | generateSuggestion |
| | | } from '@/api/inventoryManagement/stockWarningLedger.js' |
| | | |
| | | // 响应式数据 |
| | |
| | | const searchForm = reactive({ |
| | | productCategory: '', |
| | | specificationModel: '', |
| | | warningLevel: '', |
| | | warningStatus: '' |
| | | }) |
| | | |
| | |
| | | if (res.code === 200) { |
| | | tableData.value = res.data.records || [] |
| | | total.value = res.data.total || 0 |
| | | |
| | | |
| | | // 计算预警级别和状态 |
| | | tableData.value = tableData.value.map(item => { |
| | | const currentStock = parseFloat(item.inboundNum0 || item.currentStock || 0) |
| | | const warnNum = parseFloat(item.warnNum || 0) |
| | | const safetyStock = parseFloat(item.safetyStock || warnNum * 1.2) |
| | | |
| | | |
| | | // 计算预警级别 |
| | | if (currentStock <= 0) { |
| | | item.warningLevel = '紧急' |
| | |
| | | item.warningLevel = '' |
| | | item.warningStatus = '正常' |
| | | } |
| | | |
| | | |
| | | // 计算预计缺货时间(基于日均消耗量,这里简化处理) |
| | | if (item.warningStatus === '已预警' && currentStock > 0 && warnNum > 0) { |
| | | const dailyConsumption = warnNum / 30 // 假设30天消耗完最低库存 |
| | |
| | | item.expectedShortageTime = date.toISOString().split('T')[0] |
| | | } |
| | | } |
| | | |
| | | |
| | | item.currentStock = currentStock |
| | | item.safetyStock = safetyStock |
| | | |
| | | |
| | | return item |
| | | }) |
| | | } |
| | |
| | | const getStockClass = (row) => { |
| | | const currentStock = parseFloat(row.currentStock || row.inboundNum0 || 0) |
| | | const warnNum = parseFloat(row.warnNum || 0) |
| | | |
| | | |
| | | if (currentStock <= 0) { |
| | | return 'text-danger' |
| | | } else if (currentStock < warnNum) { |
| | |
| | | } |
| | | |
| | | // 页面加载 |
| | | // 生成采购建议 / 滞销处理提示 |
| | | const handleSuggestion = (row, type) => { |
| | | generateSuggestion({ id: row.id, type }).then((res) => { |
| | | ElMessage({ message: res.msg || res.data || '已生成', type: 'success', duration: 6000, showClose: true }) |
| | | getList() |
| | | }).catch(() => { |
| | | ElMessage.error('生成失败') |
| | | }) |
| | | } |
| | | |
| | | onMounted(() => { |
| | | getList() |
| | | }) |