批次以及批次的生产安排

This commit is contained in:
砂糖
2025-08-15 10:12:50 +08:00
parent 916d64c1ca
commit 7f0b243c7f
4 changed files with 285 additions and 22 deletions

View File

@@ -2,13 +2,13 @@
<div>
<span class="product-name" @click="clickHandle">
<slot name="default" :product="product">
{{ product.productName ? product.productName : '--' }}
{{ product && product.productName ? product.productName : '--' }}
</slot>
</span>
<el-dialog
:visible="showDetail"
@close="showDetail = false"
:title="product.productName"
:title="product && product.productName ? product.productName : '--' "
width="500px"
append-to-body
>
@@ -62,6 +62,9 @@ export default {
watch: {
productId: {
handler(newVal) {
if (!newVal) {
this.product = {};
}
const res = this.productMap[this.productId] ? this.productMap[this.productId] : {};
this.product = res;
},

View File

@@ -0,0 +1,200 @@
<template>
<div class="merge-source-selector">
<!-- 已选任务列表 -->
<div v-if="selectedTasks.length > 0" class="selected-tasks">
<div v-for="task in selectedTasks" :key="task.taskId" class="selected-task-item">
<div class="task-info">
<ProductInfo :productId="task.productId" />
<CraftInfo :craftId="task.processId" />
<span class="task-quantity">数量: {{ task.taskQuantity }}</span>
</div>
<el-button
type="text"
icon="el-icon-delete"
size="mini"
class="delete-btn"
@click="removeTask(task.taskId)"
></el-button>
</div>
</div>
<!-- 未选择任务时的提示 -->
<div v-else class="no-selected-tip">
暂无选择的任务请从下方选择
</div>
<!-- 任务选择器 -->
<div class="task-selector">
<el-select
v-model="currentSelectTaskId"
placeholder="选择未合并的任务"
clearable
style="width: 100%;"
@change="addSelectedTask"
>
<el-option
v-for="task in availableTasks"
:key="task.taskId"
:label="`[产品: ${task.productName || task.productId}] [工艺: ${task.processName || task.processId}] 数量: ${task.taskQuantity}`"
:value="task.taskId"
></el-option>
</el-select>
</div>
</div>
</template>
<script>
import CraftInfo from '@/components/KLPService/Renderer/CraftInfo.vue';
import ProductInfo from '@/components/KLPService/Renderer/ProductInfo.vue';
export default {
name: 'MergeSourceSelector',
components: {
CraftInfo,
ProductInfo
},
props: {
// 所有未合并的任务列表
unmergedTasks: {
type: Array,
required: true,
default: () => []
},
// 所有任务列表(用于回显)
allTasks: {
type: Array,
required: true,
default: () => []
},
// 绑定的合并来源ID字符串逗号分隔
value: {
type: String,
default: ''
}
},
computed: {
// 可选择的任务(未合并且不在当前已选中列表中)
availableTasks() {
return this.unmergedTasks.filter(task =>
!this.selectedTasks.some(t => t.taskId === task.taskId)
);
}
},
data() {
return {
selectedTasks: [], // 当前选中的任务列表
currentSelectTaskId: null // 当前选择的任务ID
};
},
watch: {
// 监听外部传入的value变化同步到选中任务列表
value: {
handler(val) {
if (val) {
this.syncSelectedTasks(val.split(','));
} else {
this.selectedTasks = [];
}
},
immediate: true
},
// 监听选中任务变化,同步到外部
selectedTasks: {
handler() {
const mergeSource = this.selectedTasks.map(t => t.taskId).join(',');
this.$emit('input', mergeSource);
this.$emit('change', mergeSource, this.selectedTasks);
},
deep: true
}
},
methods: {
/** 同步选中的任务列表 */
syncSelectedTasks(taskIds) {
this.selectedTasks = taskIds
.map(taskId => this.allTasks.find(t => t.taskId === taskId))
.filter(Boolean); // 过滤无效任务
},
/** 添加选中的任务 */
addSelectedTask(taskId) {
if (!taskId) return;
// 查找任务信息
const task = this.unmergedTasks.find(t => t.taskId === taskId);
if (task && !this.selectedTasks.some(t => t.taskId === taskId)) {
this.selectedTasks.push(task);
this.currentSelectTaskId = null; // 清空选择器
}
},
/** 移除任务 */
removeTask(taskId) {
this.selectedTasks = this.selectedTasks.filter(t => t.taskId !== taskId);
},
/** 清空选中的任务 */
clear() {
this.selectedTasks = [];
}
}
};
</script>
<style scoped>
.merge-source-selector {
width: 100%;
}
.selected-tasks {
margin-bottom: 15px;
max-height: 200px;
overflow-y: auto;
border: 1px solid #e4e7ed;
border-radius: 4px;
padding: 10px;
}
.selected-task-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 8px 5px;
border-bottom: 1px dashed #e4e7ed;
}
.selected-task-item:last-child {
border-bottom: none;
}
.task-info {
display: flex;
align-items: center;
gap: 10px;
flex: 1;
flex-wrap: wrap;
}
.task-quantity {
color: #606266;
font-size: 12px;
}
.delete-btn {
color: #f56c6c;
padding: 0 5px;
}
.no-selected-tip {
text-align: center;
color: #909399;
padding: 10px;
margin-bottom: 15px;
border: 1px dashed #e4e7ed;
border-radius: 4px;
}
.task-selector {
margin-top: 10px;
}
</style>

View File

@@ -30,11 +30,12 @@
<el-table-column prop="detailId" label="明细ID" align="center" />
<el-table-column prop="lineName" label="产线名称" align="center" />
<!-- <el-table-column prop="productName" label="产品名称" align="center" /> -->
<el-table-column prop="productCode" label="产品信息" align="center">
<!-- <el-table-column prop="productCode" label="产品信息" align="center">
<template slot-scope="scope">
<ProductInfo :productId="scope.row.productId" />
</template>
</el-table-column>
</el-table-column> -->
<el-table-column prop="batchNo" label="批次号" align="center" />
<el-table-column prop="quantity" label="排产数量" align="center" />
<el-table-column prop="startDate" label="开始日期" align="center" />
<el-table-column prop="endDate" label="结束日期" align="center" />
@@ -58,14 +59,17 @@
:value="item.lineId" />
</el-select>
</el-form-item>
<el-form-item label="产品" prop="productId">
<el-select v-model="detailForm.productId" placeholder="请选择产品" filterable>
<el-form-item label="批次" prop="batchId">
<!-- <el-select v-model="detailForm.productId" placeholder="请选择产品" filterable>
<el-option v-for="item in productList" :key="item.productId" :label="item.productName"
:value="item.productId" />
</el-select> -->
<el-select v-model="detailForm.batchId" placeholder="请选择批次" filterable @change="onBatchChange">
<el-option v-for="item in batchList" :key="item.batchId" :label="item.batchNo" :value="item.batchId" />
</el-select>
</el-form-item>
<el-form-item label="排产数量" prop="quantity">
<el-input-number v-model="detailForm.quantity" :min="0.01" :step="0.01" style="width:100%" />
<el-input-number v-model="detailForm.quantity" disabled :min="0.01" :step="0.01" style="width:100%" />
</el-form-item>
<el-form-item label="计划日期" prop="dateRange">
<el-date-picker v-model="detailForm.dateRange" type="daterange" range-separator="至" start-placeholder="开始日期"
@@ -96,8 +100,10 @@ import { listSchedulePlanDetail, addSchedulePlanDetail, updateSchedulePlanDetail
import { listOrderDetail } from '@/api/wms/orderDetail';
import { listProduct } from '@/api/wms/product';
import { listProductionLine } from '@/api/wms/productionLine';
import GanttChartEcharts from '../productionLine/GanttChartEcharts.vue';
import { ganttProductionLine } from '@/api/wms/productionLine';
import { listBatch } from '@/api/wms/batch';
import GanttChartEcharts from '../productionLine/GanttChartEcharts.vue';
import ProductInfo from '@/components/KLPService/Renderer/ProductInfo.vue';
import TargetPanel from './panes/target.vue';
import CraftTaskPanel from './panes/craftTask.vue';
@@ -119,8 +125,9 @@ export default {
detailId: undefined,
planId: undefined,
lineId: undefined,
productId: undefined,
quantity: 1,
// productId: undefined,
batchId: undefined,
quantity: 0,
dateRange: [],
startDate: '',
endDate: '',
@@ -135,7 +142,8 @@ export default {
productList: [],
productionLineList: [],
lineGanttTasks: [],
previewTask: null
previewTask: null,
batchList: []
};
},
created() {
@@ -143,8 +151,9 @@ export default {
if (this.planId) {
this.fetchPlanInfo();
this.fetchDetailList();
this.fetchProductList();
// this.fetchProductList();
this.fetchProductionLineList();
this.fetchBatchList();
}
},
methods: {
@@ -159,6 +168,11 @@ export default {
this.orderDetailList = res.rows || [];
});
},
fetchBatchList() {
listBatch({ pageNum: 1, pageSize: 1000, planId: this.planId }).then(res => {
this.batchList = res.rows || [];
});
},
fetchDetailList() {
this.loading = true;
listSchedulePlanDetail({ planId: this.planId }).then(res => {
@@ -189,7 +203,8 @@ export default {
planId: this.planId,
lineId: undefined,
productId: undefined,
quantity: 1,
batchId: undefined,
quantity: 0,
dateRange: [],
startDate: '',
endDate: '',
@@ -202,6 +217,20 @@ export default {
resetDetailForm() {
this.$refs.detailForm && this.$refs.detailForm.resetFields();
},
onBatchChange(batchId) {
if (batchId) {
// 从batchList中查找
const batch = this.batchList.find(item => item.batchId == batchId);
console.log(batch);
if (batch) {
this.detailForm.quantity = batch.totalQuantity;
this.detailForm.dateRange = [
batch.estimatedStartTime,
batch.estimatedEndTime
];
}
}
},
onLineChange(lineId) {
if (!lineId) {
this.lineGanttTasks = [];
@@ -254,8 +283,8 @@ export default {
this.$refs.detailForm.validate(valid => {
if (!valid) return;
if (this.detailForm.dateRange && this.detailForm.dateRange.length === 2) {
this.detailForm.startDate = this.detailForm.dateRange[0];
this.detailForm.endDate = this.detailForm.dateRange[1];
this.detailForm.startDate = this.detailForm.dateRange[0].replace(' ', "T") + '.000Z';
this.detailForm.endDate = this.detailForm.dateRange[1].replace(' ', "T") + '.000Z';
} else {
this.detailForm.startDate = '';
this.detailForm.endDate = '';

View File

@@ -3,7 +3,7 @@
<el-row style="margin-bottom: 10px;">
<div v-for="(item, index) in taskList" style="display: flex; flex-wrap: wrap; gap: 10px; align-items: center;"
:key="index">
<ProductInfo :productId="item[0].productId" />
<ProductInfo :productId="item && item[0] && item[0].productId" />
<div v-for="process in item" :key="process.processId">
<CraftInfo :craftId="process.processId" />
</div>
@@ -75,7 +75,7 @@
<!-- 添加或修改批次合并相同工艺的任务对话框 -->
<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 ref="form" :model="form" :rules="rules" label-width="120px">
<el-form-item label="批次编号" prop="batchNo">
<el-input v-model="form.batchNo" placeholder="请输入批次编号" />
</el-form-item>
@@ -86,7 +86,13 @@
<el-input v-model="form.totalQuantity" placeholder="请输入批次总数量" />
</el-form-item> -->
<el-form-item label="合并来源" prop="mergeSource">
<el-input v-model="form.mergeSource" type="textarea" placeholder="请输入内容" />
<merge-source-selector
v-model="form.mergeSource"
:unmerged-tasks="unmergedTaskList"
:all-tasks="allTasks"
@change="handleMergeSourceChange"
/>
<!-- <el-input v-model="form.mergeSource" type="textarea" placeholder="请输入内容" /> -->
</el-form-item>
<el-form-item label="预计开始时间" prop="estimatedStartTime">
<el-date-picker clearable v-model="form.estimatedStartTime" type="datetime" value-format="yyyy-MM-dd HH:mm:ss"
@@ -152,14 +158,17 @@
import { listBatch, getBatch, delBatch, addBatch, updateBatch, generateBatch } from "@/api/wms/batch";
import { listProcessTask } from "@/api/wms/processTask";
import CraftInfo from '@/components/KLPService/Renderer/CraftInfo.vue';
import ProductInfo from '@/components/KLPService/Renderer/ProductInfo.vue';
import MergeSourceSelector from "../components/MergeSourceSelector.vue";
export default {
name: "Batch",
components: {
CraftInfo,
ProductInfo
ProductInfo,
MergeSourceSelector
},
dicts: ['batch_status'],
props: {
@@ -168,6 +177,16 @@ export default {
required: true
}
},
computed: {
// 所有还没有被合并的任务
unmergedTaskList() {
// 也就是不在batchList.mergeSource中的
return this.allTasks.filter(item => !this.batchList.some(batch => batch.mergeSource.split(',').includes(item.taskId)));
},
allTasks() {
return this.taskList.flat(1);
},
},
data() {
return {
// 按钮loading
@@ -233,8 +252,14 @@ export default {
this.taskList = Object.values(productIdToProcessTaskList);
},
getTaskInfo(taskId) {
const task = this.taskList.flat(1).find(item => item.taskId == taskId);
console.log(task, taskId);
const task = this.allTasks.find(item => item.taskId == taskId);
// console.log(task, taskId);
if (!task) {
return {
productId: '',
processId: ''
};
}
return task;
},
/** 查询批次(合并相同工艺的任务)列表 */
@@ -276,6 +301,12 @@ export default {
this.queryParams.pageNum = 1;
this.getList();
},
// 处理合并来源变化的回调
handleMergeSourceChange(mergeSource, selectedTasks) {
console.log('合并来源变化:', mergeSource);
console.log('选中的任务:', selectedTasks);
// 可以在这里做一些额外处理,比如计算总数量等
},
async handleInitBatch() {
generateBatch(this.taskList).then(res => {
console.log(res)
@@ -283,7 +314,7 @@ export default {
this.generateBatchList = res.data.map(item => {
let totalQuantity = 0;
for (const taskId of item.taskIds) {
const task = this.taskList.flat(1).find(item => item.taskId == taskId);
const task = this.allTasks.find(item => item.taskId == taskId);
totalQuantity += task.taskQuantity;
}
return {