扫码枪页面

This commit is contained in:
砂糖
2025-07-31 14:44:10 +08:00
parent dc92cb240f
commit b1f40f09e9
11 changed files with 916 additions and 11 deletions

View File

@@ -42,3 +42,11 @@ export function delRawMaterial(rawMaterialId) {
method: 'delete'
})
}
export function listRawMaterialWithDemand(query) {
return request({
url: '/wms/rawMaterial//listWithDemand',
method: 'get',
params: query
})
}

View File

@@ -235,14 +235,14 @@
title="新增采购计划"
:visible.sync="addDrawerOpen"
direction="btt"
size="90%"
size="98%"
:with-header="true"
:wrapperClosable="false"
custom-class="purchase-drawer"
append-to-body
mask-closable="false"
>
<CreatePurchasePanel
<Transfer
:order-id="''"
:recommend-data="{}"
@confirm="onAddConfirm"
@@ -256,17 +256,17 @@ import { listPurchasePlan, getPurchasePlan, delPurchasePlan, addPurchasePlan, up
import { listOrder } from "@/api/wms/order";
import PurchasePlanClac from "./panels/clac.vue";
import PurchasePlanDetail from "./panels/detail.vue";
import CreatePurchasePanel from "./panels/CreatePurchasePanel.vue";
import { EOrderStatus } from "../../../utils/enums";
import UserSelect from '@/components/KLPService/UserSelect'
import Transfer from './panels/transfer.vue'
export default {
name: "PurchasePlan",
components: {
PurchasePlanClac,
PurchasePlanDetail,
CreatePurchasePanel,
UserSelect
UserSelect,
Transfer,
},
dicts: ['order_status'],
data() {
@@ -334,9 +334,6 @@ export default {
owner: [
{ required: true, message: "负责人不能为空", trigger: "blur" }
],
// orderId: [
// { required: true, message: "关联订单ID不能为空", trigger: "blur" }
// ],
status: [
{ required: true, message: "状态不能为空", trigger: "change" }
],

View File

@@ -70,7 +70,11 @@
<el-table-column label="单位" align="center" prop="unit" />
<el-table-column label="状态" align="center" prop="status">
<template slot-scope="scope">
<dict-tag :options="dict.type.pruchase_detail_status" :value="scope.row.status"/>
<el-select v-model="scope.row.status" @change="handleStatusChange(scope.row, scope.row.status, scope.row.status)">
<el-option v-for="item in dict.type.pruchase_detail_status" :key="item.value" :label="item.label" :value="parseInt(item.value)">
<dict-tag :options="dict.type.pruchase_detail_status" :value="item.value" />
</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" />
@@ -110,6 +114,12 @@
icon="el-icon-refresh"
@click="handleStatusChange(scope.row, EPurchaseDetailStatus.REVIEW, '待审核')"
>设为待审核</el-button>
<!-- <el-button
v-if="scope.row.status === EPurchaseDetailStatus.REVIEW || scope.row.status === EPurchaseDetailStatus.FINISH"
size="mini"
type="text"
icon="el-icon-document"
>质保单</el-button> -->
<el-button
v-if="scope.row.status === EPurchaseDetailStatus.REVIEW"
size="mini"
@@ -382,7 +392,7 @@ export default {
},
/** 状态修改按钮操作 */
handleStatusChange(row, status, label) {
this.$modal.confirm('是否确认将采购计划明细编号为"' + row.detailId + '"的状态改为"' + label + '"').then(() => {
// this.$modal.confirm('是否确认将采购计划明细编号为"' + row.detailId + '"的状态改为"' + label + '"').then(() => {
this.loading = true;
updatePurchasePlanDetail({ detailId: row.detailId, status: status }).then(response => {
this.$modal.msgSuccess("状态修改成功");
@@ -393,7 +403,7 @@ export default {
}).finally(() => {
this.loading = false;
});
});
// });
},
/** 创建入库单按钮操作 */
handleCreateStockIn() {

View File

@@ -0,0 +1,285 @@
<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">
<!-- 原材料表格 -->
<el-table 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 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" />
</el-table>
<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>
<el-table
: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 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 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>
</el-table>
</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'
export default {
name: 'CreatePurchasePanel',
components: { UserSelect, RawMaterialSelect, RawMaterialInfo },
props: {
orderId: {
type: [String, Number],
required: true
},
recommendData: {
type: Object,
default: () => ({})
}
},
data() {
return {
// 原材料表格相关
rawMaterialList: [],
total: 0,
pageNum: 1,
pageSize: 10,
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>