refactor(wms): 移除废弃的采购计划相关组件和API

移除不再使用的采购计划相关Vue组件、API接口和视图文件,包括:
1. 删除productBom.js和purchasePlanDetail.js API文件
2. 移除RecommendPurchasePanel.vue、clac.vue、CreatePurchasePanel.vue和transfer.vue组件
3. 清理ledger/index.vue中未使用的代码

这些组件和API已被新实现替代,清理旧代码以保持代码库整洁
This commit is contained in:
砂糖
2025-11-13 13:33:39 +08:00
parent 1b56723bdb
commit 88b7e37712
7 changed files with 0 additions and 1101 deletions

View File

@@ -1,44 +0,0 @@
import request from '@/utils/request'
// 查询产品BOM产品-原材料清单)列表
export function listProductBom(query) {
return request({
url: '/wms/productBom/list',
method: 'get',
params: query
})
}
// 查询产品BOM产品-原材料清单)详细
export function getProductBom(bomId) {
return request({
url: '/wms/productBom/' + bomId,
method: 'get'
})
}
// 新增产品BOM产品-原材料清单)
export function addProductBom(data) {
return request({
url: '/wms/productBom',
method: 'post',
data: data
})
}
// 修改产品BOM产品-原材料清单)
export function updateProductBom(data) {
return request({
url: '/wms/productBom',
method: 'put',
data: data
})
}
// 删除产品BOM产品-原材料清单)
export function delProductBom(bomId) {
return request({
url: '/wms/productBom/' + bomId,
method: 'delete'
})
}

View File

@@ -1,291 +0,0 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="存储位置" prop="warehouseId">
<WarehouseSelect v-model="queryParams.warehouseId" placeholder="请选择仓库/库区/库位" clearable @change="getList" />
</el-form-item>
<MaterialSelect :itemType.sync="queryParams.itemType" :itemId.sync="queryParams.itemId" @change="getList" />
<el-form-item label="变动时间" prop="changeTime">
<el-date-picker
clearable
v-model="queryParams.changeTime"
type="daterange"
value-format="yyyy-MM-dd"
placeholder="请选择实际库存变动时间">
</el-date-picker>
</el-form-item>
<el-form-item label="批次号" prop="batchNo">
<el-input v-model="queryParams.batchNo" placeholder="请输入批次号" />
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<KLPTable v-loading="loading" :data="stockLogList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="存储位置" align="center" prop="warehouseName" />
<el-table-column label="物品ID" align="center" prop="itemId">
<template slot-scope="scope">
<RawMaterialInfo v-if="scope.row.itemType == 'raw_material'" :material-id="scope.row.itemId" />
<ProductInfo v-else-if="scope.row.itemType == 'product' || scope.row.itemType == 'semi'" :product-id="scope.row.itemId" />
</template>
</el-table-column>
<el-table-column label="物品类型" align="center" prop="itemType">
<template slot-scope="scope">
<dict-tag :options="dict.type.stock_item_type" :value="scope.row.itemType" />
</template>
</el-table-column>
<el-table-column label="变动数量" align="center" prop="changeQty" />
<el-table-column label="变动后的库存数量" align="center" prop="afterQty" />
<el-table-column label="变动类型" align="center" prop="changeType" />
<el-table-column label="库存数量变动时间" align="center" prop="changeTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.changeTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="批次号" align="center" prop="batchNo" />
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
>修改</el-button>
</template>
</el-table-column>
</KLPTable>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改库存流水对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="存储位置" prop="warehouseId" disabled>
<el-input v-model="form.warehouseId" placeholder="请输入仓库/库区/库位ID" disabled />
</el-form-item>
<el-form-item label="物品信息" prop="itemId" disabled>
<RawMaterialInfo v-if="form.itemType == 'raw_material'" :material-id="form.itemId" />
<ProductInfo v-else-if="form.itemType == 'product' || form.itemType == 'semi'" :product-id="form.itemId" />
</el-form-item>
<el-form-item label="变动数量" prop="changeQty" disabled>
<el-input v-model="form.changeQty" placeholder="请输入变动数量" disabled />
</el-form-item>
<el-form-item label="库存数量" prop="afterQty" disabled>
<el-input v-model="form.afterQty" placeholder="请输入变动后的库存数量" disabled />
</el-form-item>
<el-form-item label="变动时间" prop="changeTime" disabled>
<el-date-picker clearable
v-model="form.changeTime"
type="datetime"
value-format="yyyy-MM-dd HH:mm:ss"
placeholder="请选择实际库存变动时间" disabled>
</el-date-picker>
</el-form-item>
<el-form-item label="批次号" prop="batchNo">
<el-input v-model="form.batchNo" placeholder="请输入批次号" disabled/>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listStockLog, getStockLog, updateStockLog } from "@/api/wms/stockLog";
import WarehouseSelect from '@/components/KLPService/WarehouseSelect/index.vue';
import RawMaterialSelect from '@/components/KLPService/RawMaterialSelect/index.vue';
import ProductSelect from '@/components/KLPService/ProductSelect/index.vue';
import SemiSelect from '@/components/KLPService/SemiSelect/index.vue';
import RawMaterialInfo from '@/components/KLPService/Renderer/RawMaterialInfo.vue';
import ProductInfo from '@/components/KLPService/Renderer/ProductInfo.vue';
import MaterialSelect from '@/components/KLPService/MaterialSelect/index.vue';
export default {
name: "StockLog",
components: {
WarehouseSelect,
RawMaterialSelect,
ProductSelect,
RawMaterialInfo,
ProductInfo,
SemiSelect,
MaterialSelect
},
dicts: ['stock_item_type'],
data() {
return {
// 按钮loading
buttonLoading: false,
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 库存流水表格数据
stockLogList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 20,
warehouseId: undefined,
itemId: undefined,
itemType: undefined,
changeQty: undefined,
afterQty: undefined,
changeType: undefined,
changeTime: undefined,
batchNo: undefined,
},
// 表单参数
form: {},
// 表单校验
rules: {
}
};
},
created() {
const itemId = this.$route.query.itemId;
const itemType = this.$route.query.itemType;
if (itemId && itemType) {
this.queryParams.itemId = itemId;
this.queryParams.itemType = itemType;
}
this.getList();
},
methods: {
/** 查询库存流水列表 */
getList() {
this.loading = true;
const { changeTime, ...payload } = {
...this.queryParams,
startTime: this.queryParams.changeTime ? this.queryParams.changeTime[0] + ' 00:00:00' : undefined,
endTime: this.queryParams.changeTime ? this.queryParams.changeTime[1] + ' 23:59:59' : undefined
}
listStockLog(payload).then(response => {
this.stockLogList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
id: undefined,
warehouseId: undefined,
itemId: undefined,
itemType: undefined,
changeQty: undefined,
afterQty: undefined,
changeType: undefined,
changeTime: undefined,
remark: undefined,
createTime: undefined,
createBy: undefined,
updateTime: undefined,
updateBy: undefined,
delFlag: undefined
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 修改按钮操作 */
handleUpdate(row) {
this.loading = true;
this.reset();
const id = row.id || this.ids
getStockLog(id).then(response => {
this.loading = false;
this.form = response.data;
this.open = true;
this.title = "修改库存流水";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
this.buttonLoading = true;
if (this.form.id != null) {
updateStockLog(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
}
}
});
},
/** 导出按钮操作 */
handleExport() {
this.download('klp/stockLog/export', {
...this.queryParams
}, `stockLog_${new Date().getTime()}.xlsx`)
}
}
};
</script>

View File

@@ -1,255 +0,0 @@
<template>
<div class="purchase-plan-transfer">
<!-- 采购单信息区 -->
<el-card class="section-card" shadow="never">
<div slot="header" class="section-title">采购单信息</div>
<el-form :model="mainForm" :rules="mainFormRules" ref="mainFormRef" :inline="true" label-width="120px" style="margin-bottom: 0;" v-loading="formLoading" element-loading-text="正在加载主数据...">
<el-form-item label="计划编号" prop="planCode">
<el-input v-model="mainForm.planCode" placeholder="请输入计划编号" style="width: 200px;" />
</el-form-item>
<el-form-item label="负责人" prop="owner">
<el-input v-model="mainForm.owner" :multiple="false" placeholder="请填写负责人" style="width: 200px;" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="mainForm.remark" placeholder="请输入备注" style="width: 300px;" />
</el-form-item>
</el-form>
</el-card>
<div>
<!-- 采购单明细区 -->
<el-card shadow="never">
<div slot="header" class="section-title">采购单明细</div>
<KLPTable
:data="purchaseList"
@selection-change="handleRightSelectionChange"
style="width: 100%"
ref="rightTable"
border
>
<el-table-column type="selection" width="55" />
<el-table-column prop="rawMaterialId" label="原材料">
<template #default="scope">
<RawMaterialSelect v-model="scope.row.rawMaterialId" placeholder="请选择原材料" />
</template>
</el-table-column>
<el-table-column label="参数" align="center">
<template #default="scope">
<BomInfoMini item-type="raw_material" :item-id="scope.row.rawMaterialId" />
</template>
</el-table-column>
<el-table-column prop="unit" label="单位" />
<el-table-column prop="onTheWay" label="在途" />
<el-table-column prop="inventory" label="在库" />
<el-table-column prop="demand" label="所需" />
<el-table-column prop="quantity" label="计划采购数">
<template #default="scope">
<el-input-number :controls=false controls-position="right" v-model="scope.row.quantity" :min="0" size="small" />
</template>
</el-table-column>
<el-table-column prop="owner" label="负责人">
<template #default="scope">
<el-input v-model="scope.row.owner" :multiple="false" placeholder="请填写负责人" size="small" />
</template>
</el-table-column>
<el-table-column prop="remark" label="备注">
<template #default="scope">
<el-input v-model="scope.row.remark" size="small" />
</template>
</el-table-column>
</KLPTable>
</el-card>
</div>
<div style="margin-top: 20px; text-align: right;" v-loading="submitLoading" element-loading-text="正在提交数据...">
<el-button type="primary" @click="confirm" :loading="submitLoading">{{ submitLoading ? '提交中...' : '确认' }}</el-button>
</div>
</div>
</template>
<script>
import { createPurchasePlan } from '@/api/wms/purchasePlan'
import { listRawMaterial } from '@/api/wms/rawMaterial'
import UserSelect from '@/components/KLPService/UserSelect'
import RawMaterialSelect from '@/components/KLPService/RawMaterialSelect'
import BomInfoMini from '@/components/KLPService/Renderer/BomInfoMini.vue';
export default {
name: 'CreatePurchasePanel',
components: { UserSelect, RawMaterialSelect, BomInfoMini },
props: {
orderId: {
type: [String, Number],
required: true
},
recommendData: {
type: Object,
default: () => ({})
}
},
data() {
return {
// 原材料表格相关
rawMaterialList: [],
total: 0,
pageNum: 1,
pageSize: 20,
rawMaterialLoading: false,
leftSelected: [],
rightSelected: [],
rawMaterialNameFilter: '',
// 采购列表
purchaseList: [],
// 细化的loading状态
formLoading: false,
submitLoading: false,
mainForm: {
planCode: '',
owner: '',
remark: ''
},
mainFormRules: {
planCode: [
{ required: true, message: '请输入计划编号', trigger: 'blur' }
],
owner: [
{ required: true, message: '请输入负责人', trigger: 'blur' }
]
}
}
},
watch: {
recommendData: {
immediate: true,
handler(newVal) {
if (newVal && newVal.detailList) {
this.purchaseList = newVal.detailList
this.mainForm = {
planCode: newVal.planCode || '',
owner: newVal.owner || '',
remark: newVal.remark || ''
}
}
}
}
},
mounted() {
this.fetchRawMaterials();
},
methods: {
// 原材料分页查询
fetchRawMaterials() {
this.rawMaterialLoading = true;
listRawMaterial({ pageNum: this.pageNum, pageSize: this.pageSize, rawMaterialName: this.rawMaterialNameFilter }).then(res => {
// 过滤掉已在采购列表中的原材料
const purchaseIds = this.purchaseList.map(item => item.rawMaterialId);
this.rawMaterialList = (res.rows || []).filter(item => !purchaseIds.includes(item.rawMaterialId));
this.total = res.total || 0;
this.rawMaterialLoading = false;
}).catch(() => {
this.rawMaterialLoading = false;
});
},
handlePageChange(page) {
this.pageNum = page;
this.fetchRawMaterials();
},
handleSelectionChange(selection) {
this.leftSelected = selection;
},
handleRightSelectionChange(selection) {
this.rightSelected = selection;
},
handleRawMaterialFilter() {
this.pageNum = 1;
this.fetchRawMaterials();
},
addToPurchase() {
// 去重添加
const ids = this.purchaseList.map(item => item.rawMaterialId);
const newItems = this.leftSelected.filter(item => !ids.includes(item.rawMaterialId)).map(item => ({
...item,
quantity: 0,
owner: '',
remark: ''
}));
this.purchaseList = this.purchaseList.concat(newItems);
this.$refs.leftTable.clearSelection();
this.fetchRawMaterials();
},
removeFromPurchase() {
const removeIds = this.rightSelected.map(item => item.rawMaterialId);
this.purchaseList = this.purchaseList.filter(item => !removeIds.includes(item.rawMaterialId));
this.$refs.rightTable.clearSelection();
this.fetchRawMaterials();
},
confirm() {
this.submitLoading = true;
this.$refs.mainFormRef.validate(async(valid) => {
if (!valid) {
this.$message.error('请完整填写主数据信息');
this.submitLoading = false;
return;
}
// 校验采购列表数据除remark外都不能为空
const filtered = this.purchaseList.filter(row => row.rawMaterialId && row.rawMaterialId !== '');
const invalid = filtered.some(row => {
return !row.rawMaterialId || !row.owner || !row.unit || row.quantity === '' || row.quantity === null || row.quantity === undefined;
});
if (invalid) {
this.$message.error('请完整填写所有必填项');
this.submitLoading = false;
return;
}
// 合并主数据和明细数据
const submitData = {
...this.mainForm,
orderId: this.orderId,
detailList: filtered
};
await createPurchasePlan(submitData);
this.$emit('confirm', submitData);
this.submitLoading = false;
});
}
}
}
</script>
<style scoped>
.purchase-plan-transfer {
display: flex;
flex-direction: column;
}
.section-card {
margin-bottom: 20px;
}
.section-title {
font-weight: bold;
font-size: 16px;
color: #333;
}
.transfer-content {
display: flex;
align-items: flex-start;
}
.left-table {
width: 30%;
}
.right-table {
width: 60%;
}
.transfer-actions {
width: 10%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.transfer-actions .el-button {
margin: 10px 0;
}
.filter-bar {
display: flex;
align-items: center;
margin-bottom: 10px;
}
</style>

View File

@@ -1,57 +0,0 @@
<template>
<div>
<el-button v-if="showButton" type="primary" @click="handleRecommend" :loading="loading">推荐采购计划</el-button>
</div>
</template>
<script>
import { recommendPurchasePlan } from '@/api/wms/purchasePlan'
export default {
name: 'RecommendPurchasePanel',
props: {
orderId: {
type: [String, Number],
required: true
},
showButton: {
type: Boolean,
default: true
}
},
data() {
return {
loading: false
}
},
watch: {
orderId: {
handler(newVal) {
this.handleRecommend()
}
}
},
mounted() {
if (!this.showButton) {
this.handleRecommend();
}
},
methods: {
async handleRecommend() {
if (!this.orderId) {
this.$message.error('缺少订单ID');
return;
}
this.loading = true;
try {
const res = await recommendPurchasePlan(this.orderId);
this.$emit('recommend', res.data);
} catch (e) {
this.$message.error('推荐失败');
} finally {
this.loading = false;
}
}
}
}
</script>

View File

@@ -1,115 +0,0 @@
<template>
<div class="purchase-plan-transfer">
<!-- 推荐采购计划自动推荐无按钮 -->
<recommend-purchase-panel :order-id="orderId" :show-button="false" @recommend="onRecommend" />
<!-- 创建采购计划表单及明细 -->
<create-purchase-panel
:order-id="orderId"
:recommend-data="recommendData"
@confirm="onConfirm"
/>
</div>
</template>
<script>
import RecommendPurchasePanel from './RecommendPurchasePanel.vue'
import CreatePurchasePanel from './CreatePurchasePanel.vue'
import { updateOrder } from '@/api/wms/order'
import { EOrderStatus } from '@/utils/enums'
export default {
name: 'PurchasePlanClac',
components: {
RecommendPurchasePanel,
CreatePurchasePanel
},
props: {
orderId: {
type: [String, Number],
required: true
}
},
data() {
return {
recommendData: {},
EOrderStatus: EOrderStatus
}
},
methods: {
onRecommend(data) {
console.log('获取推荐数据', data)
this.recommendData = data
},
onConfirm(submitData) {
console.log('calc层', submitData)
updateOrder({
orderId: this.orderId,
orderStatus: this.EOrderStatus.PRODUCTIONING,
}).then(response => {
this.$emit('confirm', submitData)
})
}
}
}
</script>
<style scoped>
.purchase-plan-transfer {
display: flex;
flex-direction: column;
}
.section-card {
margin-bottom: 20px;
}
.section-title {
font-weight: bold;
font-size: 16px;
color: #333;
}
.transfer-content {
display: flex;
align-items: flex-start;
}
.left-table {
width: 30%;
}
.right-table {
width: 60%;
}
.transfer-actions {
width: 10%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.transfer-actions .el-button {
margin: 10px 0;
}
.global-loading-overlay {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(255, 255, 255, 0.9);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
z-index: 2000;
border-radius: 4px;
}
.global-loading-overlay p {
margin-top: 10px;
color: #409EFF;
font-size: 14px;
}
.filter-bar {
display: flex;
align-items: center;
margin-bottom: 10px;
}
</style>

View File

@@ -1,295 +0,0 @@
<template>
<div class="purchase-plan-transfer">
<!-- 采购单信息区 -->
<el-card class="section-card" shadow="never">
<div slot="header" class="section-title">采购单信息</div>
<el-form :model="mainForm" :rules="mainFormRules" ref="mainFormRef" :inline="true" label-width="120px" style="margin-bottom: 0;" v-loading="formLoading" element-loading-text="正在加载主数据...">
<el-form-item label="计划编号" prop="planCode">
<el-input v-model="mainForm.planCode" placeholder="请输入计划编号" style="width: 200px;" />
</el-form-item>
<el-form-item label="负责人" prop="owner">
<el-input v-model="mainForm.owner" :multiple="false" placeholder="请填写负责人" style="width: 200px;" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="mainForm.remark" placeholder="请输入备注" style="width: 300px;" />
</el-form-item>
</el-form>
</el-card>
<div>
<el-row style="height: 60vh;">
<el-col :span="8">
<!-- 原材料表格 -->
<KLPTable v-loading="rawMaterialLoading" ref="leftTable" :data="rawMaterialList" style="width: 100%" height="600" class="message-table" stripe @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" />
<el-table-column prop="rawMaterialId" label="原材料" align="center">
<template #default="scope">
<RawMaterialInfo :materialId="scope.row.rawMaterialId" />
</template>
</el-table-column>
<el-table-column label="参数" align="center">
<template #default="scope">
<BomInfoMini item-type="raw_material" :item-id="scope.row.rawMaterialId" />
</template>
</el-table-column>
<el-table-column prop="unit" label="单位" align="center" />
<el-table-column prop="onTheWay" label="在途" align="center" />
<el-table-column prop="inventory" label="在库" align="center" />
<el-table-column prop="demand" label="所需" align="center" />
</KLPTable>
<el-pagination
style="margin-top: 10px;"
background
layout="prev, pager, next"
:total="total"
:page-size="pageSize"
:current-page="pageNum"
@current-change="handlePageChange"
/>
</el-col>
<!-- 穿梭操作 -->
<el-col :span="2">
<div style="display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%;">
<el-button type="primary" @click="addToPurchase">添加</el-button>
<el-button type="danger" @click="removeFromPurchase" style="margin-top: 10px;">删除</el-button>
</div>
</el-col>
<el-col :span="14">
<div slot="header" class="section-title">采购单明细</div>
<KLPTable
:data="purchaseList"
@selection-change="handleRightSelectionChange"
style="width: 100%"
height="600"
ref="rightTable"
border
>
<el-table-column type="selection" width="55" />
<el-table-column prop="rawMaterialId" label="原材料">
<template #default="scope">
<RawMaterialInfo :materialId="scope.row.rawMaterialId" />
</template>
</el-table-column>
<el-table-column label="参数" align="center">
<template #default="scope">
<BomInfoMini item-type="raw_material" :item-id="scope.row.rawMaterialId" />
</template>
</el-table-column>
<el-table-column prop="unit" label="单位" />
<el-table-column prop="onTheWay" label="在途" />
<el-table-column prop="inventory" label="在库" />
<el-table-column prop="demand" label="所需" />
<el-table-column prop="quantity" label="计划采购数">
<template #default="scope">
<el-input-number :controls=false controls-position="right" v-model="scope.row.quantity" :min="0" size="small" />
</template>
</el-table-column>
<el-table-column prop="owner" label="负责人">
<template #default="scope">
<el-input v-model="scope.row.owner" :multiple="false" placeholder="请填写负责人" size="small" />
</template>
</el-table-column>
<el-table-column prop="remark" label="备注">
<template #default="scope">
<el-input v-model="scope.row.remark" size="small" />
</template>
</el-table-column>
</KLPTable>
</el-col>
</el-row>
</div>
<div style="margin-top: 20px; text-align: right;" v-loading="submitLoading" element-loading-text="正在提交数据...">
<el-button type="primary" @click="confirm" :loading="submitLoading">{{ submitLoading ? '提交中...' : '确认' }}</el-button>
</div>
</div>
</template>
<script>
import { createPurchasePlan } from '@/api/wms/purchasePlan'
import { listRawMaterial, listRawMaterialWithDemand } from '@/api/wms/rawMaterial'
import UserSelect from '@/components/KLPService/UserSelect'
import RawMaterialSelect from '@/components/KLPService/RawMaterialSelect'
import RawMaterialInfo from '@/components/KLPService/Renderer/RawMaterialInfo.vue'
import BomInfoMini from '@/components/KLPService/Renderer/BomInfoMini.vue';
export default {
name: 'CreatePurchasePanel',
components: { UserSelect, RawMaterialSelect, RawMaterialInfo, BomInfoMini },
props: {
orderId: {
type: [String, Number],
required: true
},
recommendData: {
type: Object,
default: () => ({})
}
},
data() {
return {
// 原材料表格相关
rawMaterialList: [],
total: 0,
pageNum: 1,
pageSize: 20,
rawMaterialLoading: false,
leftSelected: [],
rightSelected: [],
rawMaterialNameFilter: '',
// 采购列表
purchaseList: [],
// 细化的loading状态
formLoading: false,
submitLoading: false,
mainForm: {
planCode: '',
owner: '',
remark: ''
},
mainFormRules: {
planCode: [
{ required: true, message: '请输入计划编号', trigger: 'blur' }
],
owner: [
{ required: true, message: '请输入负责人', trigger: 'blur' }
]
}
}
},
watch: {
recommendData: {
immediate: true,
handler(newVal) {
if (newVal && newVal.detailList) {
this.purchaseList = newVal.detailList
this.mainForm = {
planCode: newVal.planCode || '',
owner: newVal.owner || '',
remark: newVal.remark || ''
}
}
}
}
},
mounted() {
this.fetchRawMaterials();
},
methods: {
// 原材料分页查询
fetchRawMaterials() {
this.rawMaterialLoading = true;
listRawMaterialWithDemand({ pageNum: this.pageNum, pageSize: this.pageSize, rawMaterialName: this.rawMaterialNameFilter }).then(res => {
// 过滤掉已在采购列表中的原材料
const purchaseIds = this.purchaseList.map(item => item.rawMaterialId);
this.rawMaterialList = (res.rows || []).filter(item => !purchaseIds.includes(item.rawMaterialId));
this.total = res.total || 0;
this.rawMaterialLoading = false;
}).catch(() => {
this.rawMaterialLoading = false;
});
},
handlePageChange(page) {
this.pageNum = page;
this.fetchRawMaterials();
},
handleSelectionChange(selection) {
this.leftSelected = selection;
},
handleRightSelectionChange(selection) {
this.rightSelected = selection;
},
handleRawMaterialFilter() {
this.pageNum = 1;
this.fetchRawMaterials();
},
addToPurchase() {
// 去重添加
const ids = this.purchaseList.map(item => item.rawMaterialId);
const newItems = this.leftSelected.filter(item => !ids.includes(item.rawMaterialId)).map(item => ({
...item,
quantity: 0,
owner: '',
remark: ''
}));
this.purchaseList = this.purchaseList.concat(newItems);
this.$refs.leftTable.clearSelection();
this.fetchRawMaterials();
},
removeFromPurchase() {
const removeIds = this.rightSelected.map(item => item.rawMaterialId);
this.purchaseList = this.purchaseList.filter(item => !removeIds.includes(item.rawMaterialId));
this.$refs.rightTable.clearSelection();
this.fetchRawMaterials();
},
confirm() {
this.submitLoading = true;
this.$refs.mainFormRef.validate(async(valid) => {
if (!valid) {
this.$message.error('请完整填写主数据信息');
this.submitLoading = false;
return;
}
// 校验采购列表数据除remark外都不能为空
const filtered = this.purchaseList.filter(row => row.rawMaterialId && row.rawMaterialId !== '');
const invalid = filtered.some(row => {
return !row.rawMaterialId || !row.owner || !row.unit || row.quantity === '' || row.quantity === null || row.quantity === undefined;
});
if (invalid) {
this.$message.error('请完整填写所有必填项');
this.submitLoading = false;
return;
}
// 合并主数据和明细数据
const submitData = {
...this.mainForm,
orderId: this.orderId,
detailList: filtered
};
await createPurchasePlan(submitData);
this.$emit('confirm', submitData);
this.submitLoading = false;
});
}
}
}
</script>
<style scoped>
.purchase-plan-transfer {
display: flex;
flex-direction: column;
}
.section-card {
margin-bottom: 20px;
}
.section-title {
font-weight: bold;
font-size: 16px;
color: #333;
}
.transfer-content {
display: flex;
align-items: flex-start;
}
.left-table {
width: 30%;
}
.right-table {
width: 60%;
}
.transfer-actions {
width: 10%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.transfer-actions .el-button {
margin: 10px 0;
}
.filter-bar {
display: flex;
align-items: center;
margin-bottom: 10px;
}
</style>

View File

@@ -1,44 +0,0 @@
import request from '@/utils/request'
// 查询采购计划明细列表
export function listPurchasePlanDetail(query) {
return request({
url: '/wms/purchasePlanDetail/list',
method: 'get',
params: query
})
}
// 查询采购计划明细详细
export function getPurchasePlanDetail(detailId) {
return request({
url: '/wms/purchasePlanDetail/' + detailId,
method: 'get'
})
}
// 新增采购计划明细
export function addPurchasePlanDetail(data) {
return request({
url: '/wms/purchasePlanDetail',
method: 'post',
data: data
})
}
// 修改采购计划明细
export function updatePurchasePlanDetail(data) {
return request({
url: '/wms/purchasePlanDetail',
method: 'put',
data: data
})
}
// 删除采购计划明细
export function delPurchasePlanDetail(detailId) {
return request({
url: '/wms/purchasePlanDetail/' + detailId,
method: 'delete'
})
}