更新班组

This commit is contained in:
2025-11-05 13:57:58 +08:00
parent 0e1e813dc2
commit 7bee1f7863
17 changed files with 866 additions and 249 deletions

View File

@@ -2,7 +2,7 @@
* @Author: zwq
* @Date: 2025-10-13 15:07:24
* @LastEditors: zwq
* @LastEditTime: 2025-10-29 15:28:52
* @LastEditTime: 2025-11-04 16:07:45
* @Description:
-->
<template>
@@ -54,10 +54,11 @@
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="部门">
<el-form-item label="部门" prop="deptId">
<dept-select
style="width: 100%"
ref="deptSelect"
v-model="dataForm.deptId"
@DeptId="setDeptId"></dept-select>
</el-form-item>
</el-col>
@@ -111,7 +112,7 @@
</el-select>
</el-form-item>
</el-col>
<el-col :span="6" v-if="dataForm.shiftType>1">
<el-col :span="6" v-if="dataForm.shiftType > 1">
<el-form-item label="同班次连排" prop="shiftSustainedNum">
<el-input
v-model="dataForm.shiftSustainedNum"
@@ -150,6 +151,12 @@
</base-table>
<small-title style="margin: 16px 0" size="sm" :no-padding="true">
班组
<el-tag type="warning" style="color: black">
<i class="el-icon-warning" style="color: #ffbd02"></i>
排班从计划开始时间对应的第一个班次开始
<span style="color: red">班组列表顺序</span>
依次循环执行
</el-tag>
</small-title>
<base-table
:table-props="tableProps2"
@@ -157,6 +164,7 @@
:limit="10"
:table-data="tableData2"
:add-button-show="'新增'"
@emitFun="handleSort"
@emitButtonClick="addNewGroup">
<method-btn
v-if="tableBtn2.length"
@@ -174,8 +182,7 @@
:no-padding="true">
排班计划预览
<span style="font-size: 14px; color: #ff1c15">
系统将根据以下设置按班组轮班顺序依次循环每日班次生成正式排班计划请确认
系统将根据
<el-popover
placement="right"
title="比如三班两倒同班次连排2天不休周末排班如下"
@@ -192,9 +199,10 @@
</el-table>
<i
slot="reference"
class="el-icon-warning-outline"
style="color: #ff1c15"></i>
class="el-icon-chat-dot-square"
style="color: #409eff; font-size: 18px"></i>
</el-popover>
设置按班组轮班顺序依次循环每日班次生成正式排班计划请确认
</span>
</small-title>
<el-tag>
@@ -227,7 +235,7 @@
<div style="color: rgba(0, 0, 0, 0.6)">同班次连排</div>
<div style="color: #000000">
{{
dataForm.shiftSustainedNum +
(dataForm.shiftSustainedNum ? dataForm.shiftSustainedNum : '') +
['日', '周', '月', '季'][dataForm.shiftSustainedType - 1]
}}
</div>
@@ -335,6 +343,7 @@ import { parseTime } from '@/filter/code-filter';
import editClass from './edit-class.vue';
import addGroup from './add-group.vue';
import bindLine from './bind-line.vue';
import sortSet from './sortSet.vue';
import {
getCode,
createStepOne,
@@ -374,10 +383,17 @@ const tableProps1 = [
];
const tableProps2 = [
{
prop: 'shunxu',
label: '顺序',
width: 70,
subcomponent: sortSet,
},
{
prop: 'code',
label: '班组编号',
width: 140,
showOverflowtooltip: true,
},
{
prop: 'name',
@@ -476,6 +492,7 @@ export default {
name: [
{ required: true, message: '计划名称不能为空', trigger: 'blur' },
],
deptId: [{ required: true, message: '部门不能为空', trigger: 'blur' }],
startDay: [
{ required: true, message: '开始时间不能为空', trigger: 'change' },
],
@@ -610,12 +627,10 @@ export default {
this.tableData2 = res.data?.stepTwo.groupPlanTeamBaseVOList;
this.tableData2.forEach((item, index) => {
let lineName = '';
lineName = this.setLineName(item.bindLineTree, lineName);
this.$set(
this.tableData2[index],
'lineName',
lineName.slice(0, -1)
);
if (item.isProduction) {
lineName = this.setLineName(item.bindLineTree);
}
this.$set(this.tableData2[index], 'lineName', lineName);
});
});
} else {
@@ -654,9 +669,12 @@ export default {
this.$message('部门不能为空');
return;
}
const compareDate = this.compareDates(this.dataForm.startDay,this.dataForm.endDay)
const compareDate = this.compareDates(
this.dataForm.startDay,
this.dataForm.endDay
);
if (compareDate > 0 ) {
if (compareDate > 0) {
this.$message('开始时间不能大于结束时间');
return;
}
@@ -684,7 +702,10 @@ export default {
let isbindLine = false;
this.tableData2.forEach((item) => {
if (!item.bindLineTree || item.bindLineTree.length == 0) {
if (
item.isProduction &&
(!item.bindLineTree || item.bindLineTree.length == 0)
) {
isbindLine = true;
}
});
@@ -730,8 +751,8 @@ export default {
const obj = {
teamId: item.id,
name: item.name,
leaderName: item.leaderName,
leaderPhone:item.leaderPhone,
leaderName: item.leaderName,
leaderPhone: item.leaderPhone,
bindData: JSON.stringify(item.bindLineTree),
};
data.groupPlanTeamBaseVOList.push(obj);
@@ -774,7 +795,7 @@ export default {
setDataForm() {
this.$refs.deptSelect.setID(this.dataForm.deptId);
},
//比较时间,开始时间在结束时间前
//比较时间,开始时间在结束时间前
compareDates(date1, date2) {
const d1 = date1;
const d2 = date2;
@@ -793,50 +814,56 @@ export default {
this.tableData1 = [];
if (this.dataForm.shiftType == 1) {
const obj = {
sort: 1,
name: '长白班',
startTime: '08:00:00',
endTime: '17:00:00',
daySpan: 0, //是否跨天
code: 1, //排版日历页面,根据这个字段显示颜色
code: 1, //排版日历页面,根据这个字段显示颜色
};
this.tableData1.push(obj);
} else if (this.dataForm.shiftType == 2) {
const obj1 = {
sort: 1,
name: '白班',
startTime: '08:00:00',
endTime: '20:00:00',
daySpan: 0,
code: 1,
code: 1,
};
const obj2 = {
sort: 2,
name: '夜班',
startTime: '20:00:00',
endTime: '08:00:00',
daySpan: 1,
code: 3,
code: 3,
};
this.tableData1.push(obj1, obj2);
} else if (this.dataForm.shiftType == 3) {
const obj1 = {
sort: 1,
name: '早班',
startTime: '08:00:00',
endTime: '16:00:00',
daySpan: 0,
code: 1,
code: 1,
};
const obj2 = {
sort: 2,
name: '中班',
startTime: '16:00:00',
endTime: '00:00:00',
daySpan: 1,
code: 2,
code: 2,
};
const obj3 = {
sort: 3,
name: '夜班',
startTime: '00:00:00',
endTime: '08:00:00',
daySpan: 0,
code: 3,
code: 3,
};
this.tableData1.push(obj1, obj2, obj3);
}
@@ -859,11 +886,37 @@ export default {
this.tableData2.splice(val.data._pageIndex - 1, 1);
}
},
//班组改变顺序
handleSort(val) {
if (val.type == 'up') {
const temp = this.tableData2[val.index];
this.tableData2.splice(val.index, 1);
let i = 0;
//如果是数组第一个,再向上则放到最后
if (val.index == 0) {
i = this.tableData2.length;
} else {
i = val.index - 1;
}
this.tableData2.splice(i, 0, temp);
} else {
const temp = this.tableData2[val.index];
this.tableData2.splice(val.index, 1);
let i = 0;
//如果是数组最后一个,再向下则放到第一个(因为先splice(val.index, 1)所以这里length不用-1)
if (val.index == this.tableData2.length) {
i = 0;
} else {
i = val.index + 1;
}
this.tableData2.splice(i, 0, temp);
}
},
// 新增班组
addNewGroup() {
this.addOrUpdateVisible2 = true;
this.$nextTick(() => {
this.$refs.addGroupRef.init(this.dataForm.deptId,this.tableData2);
this.$refs.addGroupRef.init(this.dataForm.deptId, this.tableData2);
});
},
cancel1() {
@@ -886,6 +939,15 @@ export default {
},
refreshTableData1(index, val) {
this.tableData1.splice(index, 1, val);
this.tableData1.sort((a, b) => {
if (a.sort === b.sort) {
return -1; // sort相等时a排在b前面
}
return a.sort - b.sort;
});
this.tableData1.forEach((item, index) => {
item.sort = index + 1;
});
this.cancel1();
},
refreshTableData2(val) {
@@ -895,22 +957,38 @@ export default {
refreshTableData3(index, val) {
this.tableData2[index].bindLineTree = val;
let lineName = '';
lineName = this.setLineName(val, lineName);
lineName = this.setLineName(val);
if (lineName) {
this.$set(this.tableData2[index], 'lineName', lineName.slice(0, -1));
this.$set(this.tableData2[index], 'lineName', lineName);
}
this.cancel3();
},
//提取绑定的产线工段名展示出来
setLineName(val, lineName) {
val.forEach((item) => {
lineName += item.name + '';
if (item.children && item.children.length > 0) {
const childName = this.setLineName(item.children, lineName);
lineName = childName;
setLineName(val) {
if (!val || val.length === 0) return '';
const currentLevelNames = val.map((item) => item.name);
// 处理当前层级显示
let currentDisplay = '';
if (currentLevelNames.length > 1) {
currentDisplay = `(${currentLevelNames.join(' 、 ')})`;
} else {
currentDisplay = currentLevelNames[0];
}
// 查找所有子节点(取第一个有子节点的元素)
const childNode = val.find(
(item) => item.children && item.children.length > 0
);
if (childNode) {
const childPath = this.setLineName(childNode.children);
if (childPath) {
return `${currentDisplay} / ${childPath}`;
}
});
return lineName;
}
return currentDisplay;
},
//第三步
// 进来加载预览排班
@@ -919,6 +997,7 @@ export default {
id: this.dataForm.id,
count: day,
};
this.period = day;
this.tableProps3 = [];
this.tableData3 = [];
getPerView(data).then((res) => {
@@ -946,6 +1025,7 @@ export default {
label: item.day,
work: item.work,
subcomponent: propSpan,
showOverflowtooltip: true,
};
this.tableProps3.push(obj);
item.det.forEach((sItem, sIndex) => {