班组bug

This commit is contained in:
2025-11-11 15:38:31 +08:00
parent 399e2bc965
commit 0e76fe7dbf
21 changed files with 2971 additions and 57 deletions

View File

@@ -2,7 +2,7 @@
* @Author: zwq
* @Date: 2025-10-11 14:27:37
* @LastEditors: zwq
* @LastEditTime: 2025-11-04 15:16:48
* @LastEditTime: 2025-11-10 16:20:13
* @Description:
-->
<template>
@@ -105,6 +105,7 @@ export default {
getDataList() {
this.urlOptions.getDataListURL(this.formInline).then((response) => {
this.tableData = response.data.list;
this.tableData.forEach(item=>item.teamId= item.id)
this.$nextTick(() => {
if (this.selectedArr.length > 0) {
this.setSelectedRows();
@@ -119,12 +120,12 @@ export default {
table.clearSelection();
this.selectedArr.forEach((item) => {
const rowInTable = this.tableData.find((i) => i.id === item.id);
const rowInTable = this.tableData.find((i) => i.teamId === item.teamId);
if (rowInTable) {
//这里一定要用table.tableData这样才是指向同一个数组
this.$set(table.store.states, 'selection', [
...table.store.states.selection,
table.tableData.find((i) => i.id === item.id),
table.tableData.find((i) => i.teamId === item.teamId),
]);
}
});
@@ -152,7 +153,7 @@ export default {
// 判断两个数组是否有重复的 id,去重
hasDuplicateIds(arr1, arr2) {
return arr2.filter(
(item2) => !arr1.some((item1) => item1.id === item2.id)
(item2) => !arr1.some((item1) => item1.teamId === item2.teamId)
);
},

View File

@@ -2,7 +2,7 @@
* @Author: zwq
* @Date: 2025-10-13 15:07:24
* @LastEditors: zwq
* @LastEditTime: 2025-11-04 16:07:45
* @LastEditTime: 2025-11-11 15:32:04
* @Description:
-->
<template>
@@ -135,6 +135,11 @@
<div v-if="stepNum == 2">
<small-title style="margin: 16px 0" size="sm" :no-padding="true">
班次
<el-tag type="warning" style="color: black" v-if="!isClassTimePass">
<i class="el-icon-warning" style="color: #ffbd02"></i>
两班倒和三班倒的班次设置时间
<span style="color: red">不能重叠且必须连续覆盖24小时</span>
</el-tag>
</small-title>
<base-table
:table-props="tableProps1"
@@ -438,6 +443,7 @@ export default {
},
],
stepNum: 1, // 当前第几步
isEdit: false, //是否是编辑状态,编辑的时候,让前端上一步和取消都不用接口
shiftTypeEdit: undefined, //该值为编辑时获取的shiftType到第二步判断dataForm.shiftType是否改变同时改变班次信息
//第一步参数
dataForm: {
@@ -525,6 +531,7 @@ export default {
btnName: '编辑',
},
].filter((v) => v),
isClassTimePass: true, //修改班次时间后需要判断时间是否有覆盖且是否覆盖24小时
tableData1: [],
tableProps2,
tableBtn2: [
@@ -614,8 +621,9 @@ export default {
};
},
methods: {
init(id) {
init(id,isEdit) {
this.dataForm.id = id || undefined;
this.isEdit = isEdit || false
this.$nextTick(() => {
this.$refs['dataForm'].resetFields();
if (this.dataForm.id) {
@@ -643,18 +651,33 @@ export default {
//上一步
upSubmit() {
if (this.stepNum == 2) {
returnStepOne(this.dataForm.id).then((res) => {
if (!this.isEdit) {
//编辑的时候,让前端上一步和取消都不用接口,
returnStepOne(this.dataForm.id).then((res) => {
this.stepNum -= 1;
this.$emit('setSN', this.stepNum);
this.$nextTick(() => {
this.setDataForm();
});
});
} else {
this.stepNum -= 1;
this.$emit('setSN', this.stepNum);
this.$nextTick(() => {
this.setDataForm();
});
});
}
} else if (this.stepNum == 3) {
returnStepTwo(this.dataForm.id).then((res) => {
if (!this.dataForm.id) {
//编辑的时候,让前端上一步和取消都不用接口,
returnStepTwo(this.dataForm.id).then((res) => {
this.stepNum -= 1;
this.$emit('setSN', this.stepNum);
});
} else {
this.stepNum -= 1;
this.$emit('setSN', this.stepNum);
});
}
}
},
//下一步
@@ -695,6 +718,7 @@ export default {
return;
}
if (this.stepNum == 2) {
//班组验证
if (!this.tableData2 || this.tableData2.length == 0) {
this.$message('班组不能为空');
return;
@@ -732,6 +756,11 @@ export default {
return;
}
//班次验证
if (!this.isClassTimePass) {
this.$message('班次内时间有误,请重新填写!');
return;
}
let data = {};
data.planId = this.dataForm.id;
data.groupPlanClassesBaseVOList = []; //排班-班次信息list
@@ -743,6 +772,7 @@ export default {
startTime: item.startTime,
endTime: item.endTime,
daySpan: item.daySpan,
code: item.code,
};
data.groupPlanClassesBaseVOList.push(obj);
});
@@ -868,6 +898,51 @@ export default {
this.tableData1.push(obj1, obj2, obj3);
}
},
/**
* 将时间字符串转换为分钟数
* @param {string} timeStr - 时间字符串,如 "08:00:00"
* @returns {number} 分钟数
*/
timeToMinutes(timeStr) {
const [hours, minutes, s] = timeStr.split(':').map(Number);
return hours * 60 + minutes;
},
/**
* 修改班次时间后需要判断时间是否有覆盖且是否覆盖24小时
* @param {string} start1 - 开始时间1
* @param {string} end1 - 结束时间1
* @param {string} start2 - 开始时间2
* @param {string} end2 - 结束时间2
* @returns {boolean} 是否重叠 true则重叠false则可以使用
*/
isTimeOverlap(start1, end1, start2, end2) {
const start1Min = this.timeToMinutes(start1);
const end1Min = this.timeToMinutes(end1);
const start2Min = this.timeToMinutes(start2);
const end2Min = this.timeToMinutes(end2);
// 处理跨天情况
const totalMinutes = 24 * 60;
// 如果结束时间小于开始时间,说明跨天
const isEnd1NextDay = end1Min < start1Min;
const isEnd2NextDay = end2Min < start2Min;
if (isEnd1NextDay && isEnd2NextDay) {
// 两个时间段都跨天,直接比较
return true;
} else if (isEnd1NextDay) {
// 第一个时间段跨天
return start2Min < end1Min || end2Min > start1Min;
} else if (isEnd2NextDay) {
// 第二个时间段跨天
return start1Min < end2Min || end1Min > start2Min;
} else {
// 都不跨天,正常比较
return start1Min < end2Min && end1Min > start2Min;
}
},
//编辑班次
handleClick1(val) {
this.addOrUpdateVisible1 = true;
@@ -948,6 +1023,44 @@ export default {
this.tableData1.forEach((item, index) => {
item.sort = index + 1;
});
//修改班次时间后需要判断时间是否有覆盖且是否覆盖24小时,isTimeOverlap方法返回false才是校验通过
if (this.dataForm.shiftType == 2) {
const twoClass = this.tableData1.map(({ startTime, endTime }) => ({
startTime,
endTime,
}));
this.isClassTimePass = !this.isTimeOverlap(
twoClass[0].startTime,
twoClass[0].endTime,
twoClass[1].startTime,
twoClass[1].endTime
);
} else if (this.dataForm.shiftType == 3) {
const threeClass = this.tableData1.map(({ startTime, endTime }) => ({
startTime,
endTime,
}));
const result1 = this.isTimeOverlap(
threeClass[0].startTime,
threeClass[0].endTime,
threeClass[1].startTime,
threeClass[1].endTime
);
const result2 = this.isTimeOverlap(
threeClass[1].startTime,
threeClass[1].endTime,
threeClass[2].startTime,
threeClass[2].endTime
);
const result3 = this.isTimeOverlap(
threeClass[0].startTime,
threeClass[0].endTime,
threeClass[2].startTime,
threeClass[2].endTime
);
this.isClassTimePass = !(result1 || result2 || result3);
}
this.cancel1();
},
refreshTableData2(val) {
@@ -1050,7 +1163,8 @@ export default {
});
},
cancelStep() {
if (this.stepNum > 1) {
if (this.stepNum > 1 && !this.isEdit) {
//编辑的时候,让前端上一步和取消都不用接口,
cancelStepThree(this.dataForm.id).then((res) => {
this.$message('已取消计划');
this.$emit('refreshDataList');

View File

@@ -2,7 +2,7 @@
* @Author: zwq
* @Date: 2021-11-18 14:16:25
* @LastEditors: zwq
* @LastEditTime: 2025-10-30 10:47:09
* @LastEditTime: 2025-11-10 16:07:01
* @Description:
-->
<template>
@@ -13,8 +13,12 @@
:to_data="toData"
@add-btn="add"
@remove-btn="remove"
pid="pid"
:defaultProps="{ label: 'name' }"
pid="fid"
:node_key="'uniqueId'"
:defaultProps="{
label: 'name',
children: 'children',
}"
height="450px"
style="padding-bottom: 20px"
:mode="mode"
@@ -43,16 +47,34 @@ export default {
this.fromData = [];
this.toData = [];
getGroupPlanTree().then((res) => {
this.fromData = res.data;
this.fromData.forEach((item) => {
res.data.forEach((item) => {
item.productionLineId = 0;
});
this.fromData = this.generateUniqueData(res.data);
this.$nextTick(() => {
this.toData = val.bindLineTree || [];
this.getFilterLeftData(this.fromData, this.toData); //编辑时组件有bug左边相同数据不消失
});
});
},
generateUniqueData(data) {
return data.map((node) => this.processNode(node));
},
processNode(node) {
// 创建唯一ID类型-原始ID
const uniqueId = node.id + node.type;
if (node.type > 0) {
node.fid = node.pid + node.type - 1;
}
return {
...node,
uniqueId,
children: node.children
? node.children.map((child) => this.processNode(child))
: [],
};
},
// 监听穿梭框组件添加
add(fromData, toData, obj) {
console.log('fromData:', fromData);

View File

@@ -2,7 +2,7 @@
* @Author: zwq
* @Date: 2025-10-21 14:27:23
* @LastEditors: zwq
* @LastEditTime: 2025-11-04 10:49:16
* @LastEditTime: 2025-11-10 17:07:54
* @Description:
-->
<template>
@@ -150,8 +150,7 @@ export default {
this.infoData = {};
getPlan(id).then((res) => {
this.infoData = res.data || {};
console.log(res);
this.tableData1 = res.data?.groupPlanClassesBaseVOList;
this.tableData1 = res.data?.groupPlanClassesBaseVOList.sort((a, b) => a.sort - b.sort);
this.tableData2 = res.data?.groupPlanTeamBaseVOList;
this.tableData2.forEach((item, index) => {
let lineName = '';

View File

@@ -490,7 +490,7 @@ export default {
this.addOrUpdateVisible = true;
this.addOrEditTitle = '编辑';
this.$nextTick(() => {
this.$refs.addOrUpdate.init(val.data.id);
this.$refs.addOrUpdate.init(val.data.id,true);
});
} else if (val.type === 'delete') {
this.deleteHandle(val.data.id, val.data.name, val.data._pageIndex);