更新班组
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* @Author: zwq
|
||||
* @Date: 2025-10-13 15:07:24
|
||||
* @LastEditors: zwq
|
||||
* @LastEditTime: 2025-10-17 17:01:35
|
||||
* @LastEditTime: 2025-10-24 09:19:17
|
||||
* @Description:
|
||||
-->
|
||||
<template>
|
||||
@@ -116,15 +116,7 @@
|
||||
<el-input
|
||||
v-model="dataForm.shiftSustainedNum"
|
||||
oninput="value=value.replace(/^(0+)|[^\d]+/g,'')">
|
||||
<el-select
|
||||
style="width: 80px"
|
||||
v-model="dataForm.shiftSustainedType"
|
||||
slot="append">
|
||||
<el-option label="日" :value="1"></el-option>
|
||||
<el-option label="周" :value="2"></el-option>
|
||||
<el-option label="月" :value="3"></el-option>
|
||||
<el-option label="季" :value="4"></el-option>
|
||||
</el-select>
|
||||
<span slot="append">日</span>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@@ -176,7 +168,10 @@
|
||||
</base-table>
|
||||
</div>
|
||||
<div v-if="stepNum == 3">
|
||||
<small-title style="margin: 16px 0" size="sm" :no-padding="true">
|
||||
<small-title
|
||||
style="margin: 16px 0; font-size: 16px"
|
||||
size="de"
|
||||
:no-padding="true">
|
||||
排班计划预览
|
||||
<span style="font-size: 14px; color: #ff1c15">
|
||||
系统将根据以下设置,按班组轮班顺序依次循环每日班次,生成正式排班计划,请确认。
|
||||
@@ -263,6 +258,31 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<small-title
|
||||
style="margin: 16px 0; font-size: 16px"
|
||||
size="de"
|
||||
:no-padding="true">
|
||||
预览周期
|
||||
<span>
|
||||
<el-select
|
||||
style="height: 20px"
|
||||
v-model="period"
|
||||
size="mini"
|
||||
@change="setPeriod"
|
||||
placeholder="请选择">
|
||||
<el-option
|
||||
v-for="item in periodArr"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"></el-option>
|
||||
</el-select>
|
||||
</span>
|
||||
</small-title>
|
||||
|
||||
<base-table
|
||||
v-if="tableProps3.length > 0"
|
||||
:table-props="tableProps3"
|
||||
:table-data="tableData3"></base-table>
|
||||
</div>
|
||||
<base-dialog
|
||||
:dialogTitle="'修改班次'"
|
||||
@@ -306,11 +326,24 @@
|
||||
<script>
|
||||
import deptSelect from './../deptSelect.vue';
|
||||
import SmallTitle from './SmallTitle';
|
||||
import propfirstSpan from './propfirstSpan.vue';
|
||||
import propSpan from './propSpan.vue';
|
||||
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 { getCode, createStepOne, returnStepOne } from '@/api/group/Schedule';
|
||||
import {
|
||||
getCode,
|
||||
createStepOne,
|
||||
returnStepOne,
|
||||
createStepTwo,
|
||||
returnStepTwo,
|
||||
getPerView,
|
||||
draftEditing,
|
||||
cancelStepThree,
|
||||
checkPlan,
|
||||
createStepFour,
|
||||
} from '@/api/group/Schedule';
|
||||
|
||||
const tableProps1 = [
|
||||
{
|
||||
@@ -318,18 +351,18 @@ const tableProps1 = [
|
||||
label: '班次名称',
|
||||
},
|
||||
{
|
||||
prop: 'startDay',
|
||||
prop: 'startTime',
|
||||
label: '开始时间',
|
||||
// filter: (val) => {
|
||||
// parseTime(val, '{H}:{mm}');
|
||||
// },
|
||||
filter: (val) => {
|
||||
return val ? val.slice(0, -3) : '-';
|
||||
},
|
||||
},
|
||||
{
|
||||
prop: 'endDay',
|
||||
prop: 'endTime',
|
||||
label: '结束时间',
|
||||
// filter: (val) => {
|
||||
// parseTime(val, '{H}:{mm}');
|
||||
// },
|
||||
filter: (val) => {
|
||||
return val ? val.slice(0, -3) : '-';
|
||||
},
|
||||
},
|
||||
{
|
||||
prop: 'remark',
|
||||
@@ -356,7 +389,7 @@ const tableProps2 = [
|
||||
width: 110,
|
||||
},
|
||||
{
|
||||
prop: 'code1',
|
||||
prop: 'lineName',
|
||||
label: '产线及工段',
|
||||
},
|
||||
];
|
||||
@@ -368,6 +401,8 @@ export default {
|
||||
editClass,
|
||||
addGroup,
|
||||
bindLine,
|
||||
propfirstSpan,
|
||||
propSpan,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -383,6 +418,7 @@ export default {
|
||||
},
|
||||
],
|
||||
stepNum: 1, // 当前第几步
|
||||
shiftTypeEdit: undefined, //该值为编辑时获取的shiftType,到第二步,判断dataForm.shiftType是否改变,同时改变班次信息
|
||||
//第一步参数
|
||||
dataForm: {
|
||||
id: undefined,
|
||||
@@ -527,41 +563,55 @@ export default {
|
||||
class2: 'B',
|
||||
},
|
||||
],
|
||||
period: 7, //预览周期
|
||||
periodArr: [
|
||||
{
|
||||
value: 7,
|
||||
label: '7天',
|
||||
},
|
||||
{
|
||||
value: 14,
|
||||
label: '14天',
|
||||
},
|
||||
{
|
||||
value: 30,
|
||||
label: '30天',
|
||||
},
|
||||
],
|
||||
tableProps3: [],
|
||||
tableData3: [],
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
//子组件获取的部门id
|
||||
setDeptId(val) {
|
||||
this.dataForm.deptId = val;
|
||||
},
|
||||
//详情时传给子组件的部门id
|
||||
setDataForm() {
|
||||
this.$refs.deptSelect.setID(this.dataForm.deptId);
|
||||
},
|
||||
init() {
|
||||
init(id) {
|
||||
this.dataForm.id = id || undefined;
|
||||
this.$nextTick(() => {
|
||||
this.$refs['dataForm'].resetFields();
|
||||
getCode().then((res) => {
|
||||
this.dataForm.code = res.data;
|
||||
});
|
||||
if (this.dataForm.id) {
|
||||
draftEditing(this.dataForm.id).then((res) => {
|
||||
this.dataForm = res.data?.stepOne;
|
||||
this.shiftTypeEdit = res.data?.stepOne.shiftType;
|
||||
this.setDataForm();
|
||||
this.tableData1 = res.data?.stepTwo.groupPlanClassesBaseVOList;
|
||||
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)
|
||||
);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
getCode().then((res) => {
|
||||
this.dataForm.code = res.data;
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
handleClick1(val) {
|
||||
this.addOrUpdateVisible1 = true;
|
||||
this.$nextTick(() => {
|
||||
this.$refs.editClassRef.init(val.data);
|
||||
});
|
||||
},
|
||||
handleClick2(val) {
|
||||
if (val.type === 'bind') {
|
||||
this.addOrUpdateVisible3 = true;
|
||||
this.$nextTick(() => {
|
||||
this.$refs.bindLineRef.init(val.data.id);
|
||||
});
|
||||
} else if (val.type === 'delete') {
|
||||
this.tableData2.splice(val.data._pageIndex - 1, 1);
|
||||
}
|
||||
},
|
||||
//上一步
|
||||
upSubmit() {
|
||||
if (this.stepNum == 2) {
|
||||
returnStepOne(this.dataForm.id).then((res) => {
|
||||
@@ -571,8 +621,14 @@ export default {
|
||||
this.setDataForm();
|
||||
});
|
||||
});
|
||||
} else if (this.stepNum == 3) {
|
||||
returnStepTwo(this.dataForm.id).then((res) => {
|
||||
this.stepNum -= 1;
|
||||
this.$emit('setSN', this.stepNum);
|
||||
});
|
||||
}
|
||||
},
|
||||
//下一步
|
||||
nextSubmit() {
|
||||
if (this.stepNum == 1) {
|
||||
this.$refs['dataForm'].validate((valid) => {
|
||||
@@ -585,93 +641,191 @@ export default {
|
||||
return;
|
||||
}
|
||||
createStepOne(this.dataForm).then((res) => {
|
||||
this.dataForm.id = res.data;
|
||||
if (!this.dataForm.id) {
|
||||
this.dataForm.id = res.data;
|
||||
}
|
||||
this.stepNum += 1;
|
||||
this.$emit('setSN', this.stepNum);
|
||||
this.setTWOclass(); // 第一步提交后,根据倒班方式设置第二部班次
|
||||
if (
|
||||
!this.dataForm.id ||
|
||||
this.dataForm.shiftType !== this.shiftTypeEdit
|
||||
) {
|
||||
this.setTWOclass(); // (新增时或者编辑时倒班方式变了)第一步提交后,根据倒班方式设置第二部班次
|
||||
}
|
||||
});
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (this.stepNum == 2) {
|
||||
let data = {}
|
||||
data.planId = this.dataForm.id
|
||||
data.groupPlanClassesBaseVOList = [] //排班-班次信息list
|
||||
this.tableData1.forEach((item,index)=>{
|
||||
const obj = {
|
||||
sort: index+1,
|
||||
name : item.name,
|
||||
remark: item.remark,
|
||||
startTime: {
|
||||
hour:item.startDay.split(':')[0],
|
||||
minute:item.startDay.split(':')[1],
|
||||
},
|
||||
endTime: {
|
||||
hour:item.endDay.split(':')[0],
|
||||
minute:item.endDay.split(':')[1],
|
||||
}
|
||||
}
|
||||
data.groupPlanClassesBaseVOList.push(obj)
|
||||
})
|
||||
data.groupPlanTeamBaseVOList = [] //排班-班组信息list
|
||||
this.tableData2.forEach(item=>{
|
||||
const obj = {
|
||||
teamId:item.id,
|
||||
bindData: ''
|
||||
}
|
||||
data.groupPlanTeamBaseVOList.push(obj)
|
||||
})
|
||||
this.stepNum += 1;
|
||||
this.$emit('setSN', this.stepNum);
|
||||
if (!this.tableData2 || this.tableData2.length == 0) {
|
||||
this.$message('班组不能为空');
|
||||
return;
|
||||
}
|
||||
|
||||
let isbindLine = false;
|
||||
this.tableData2.forEach((item) => {
|
||||
if (!item.bindLineTree || item.bindLineTree.length == 0) {
|
||||
isbindLine = true;
|
||||
}
|
||||
});
|
||||
if (isbindLine) {
|
||||
this.$message('生产班组必须绑定产线或工段');
|
||||
return;
|
||||
}
|
||||
|
||||
const ids = this.tableData2.map((item) => item.id);
|
||||
const uniqueIds = [...new Set(ids)];
|
||||
if (ids.length !== uniqueIds.length) {
|
||||
this.$message('存在重复的班组,请检查!');
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.dataForm.shiftType == 1 && this.tableData2.length > 1) {
|
||||
this.$message('白班,班组数量仅支持 1个 班组');
|
||||
return;
|
||||
} else if (this.dataForm.shiftType == 2 && this.tableData2.length < 2) {
|
||||
this.$message('两班倒,班组数量至少 2个 班组');
|
||||
return;
|
||||
} else if (this.dataForm.shiftType == 3 && this.tableData2.length < 3) {
|
||||
this.$message('三班倒,班组数量至少 3个 班组');
|
||||
return;
|
||||
}
|
||||
|
||||
let data = {};
|
||||
data.planId = this.dataForm.id;
|
||||
data.groupPlanClassesBaseVOList = []; //排班-班次信息list
|
||||
this.tableData1.forEach((item, index) => {
|
||||
const obj = {
|
||||
sort: index + 1,
|
||||
name: item.name,
|
||||
remark: item.remark,
|
||||
startTime: item.startTime,
|
||||
endTime: item.endTime,
|
||||
daySpan: item.daySpan,
|
||||
};
|
||||
data.groupPlanClassesBaseVOList.push(obj);
|
||||
});
|
||||
data.groupPlanTeamBaseVOList = []; //排班-班组信息list
|
||||
this.tableData2.forEach((item) => {
|
||||
const obj = {
|
||||
teamId: item.id,
|
||||
name: item.name,
|
||||
leaderName: item.leaderName,
|
||||
leaderPhone:item.leaderPhone,
|
||||
bindData: JSON.stringify(item.bindLineTree),
|
||||
};
|
||||
data.groupPlanTeamBaseVOList.push(obj);
|
||||
});
|
||||
createStepTwo(data).then((res) => {
|
||||
this.stepNum += 1;
|
||||
this.$emit('setSN', this.stepNum);
|
||||
this.getThreeGroup(7); // 第三步,进来加载预览排班,默认7天预览周期
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (this.stepNum == 3) {
|
||||
this.stepNum = 1;
|
||||
this.$emit('setSN', this.stepNum);
|
||||
let data = { planId: this.dataForm.id };
|
||||
data.groupPlanTeamBaseVOList = []; //排班-班组信息list
|
||||
this.tableData2.forEach((item) => {
|
||||
const obj = {
|
||||
teamId: item.id,
|
||||
name: item.name,
|
||||
bindData: JSON.stringify(item.bindLineTree),
|
||||
};
|
||||
data.groupPlanTeamBaseVOList.push(obj);
|
||||
});
|
||||
checkPlan(data).then((RES) => {
|
||||
createStepFour(this.dataForm.id).then((res) => {
|
||||
this.$modal.msgSuccess('创建计划成功');
|
||||
this.stepNum = 1;
|
||||
this.$emit('setSN', this.stepNum);
|
||||
this.$emit('refreshDataList');
|
||||
});
|
||||
});
|
||||
return;
|
||||
}
|
||||
},
|
||||
//第一步
|
||||
//子组件获取的部门id
|
||||
setDeptId(val) {
|
||||
this.dataForm.deptId = val;
|
||||
},
|
||||
//详情时传给子组件的部门id
|
||||
setDataForm() {
|
||||
this.$refs.deptSelect.setID(this.dataForm.deptId);
|
||||
},
|
||||
//第二步
|
||||
//设置第二部班次
|
||||
setTWOclass() {
|
||||
this.tableData1 = [];
|
||||
if (this.dataForm.shiftType == 1) {
|
||||
const obj = {
|
||||
name: '长白班',
|
||||
startDay: '8:00',
|
||||
endDay: '17:00',
|
||||
startTime: '08:00:00',
|
||||
endTime: '17:00:00',
|
||||
daySpan: 0, //是否跨天
|
||||
code: 1, //排版日历页面,根据这个字段显示颜色
|
||||
};
|
||||
this.tableData1.push(obj);
|
||||
} else if (this.dataForm.shiftType == 2) {
|
||||
const obj1 = {
|
||||
name: '白班',
|
||||
startDay: '8:00',
|
||||
endDay: '20:00',
|
||||
startTime: '08:00:00',
|
||||
endTime: '20:00:00',
|
||||
daySpan: 0,
|
||||
code: 1,
|
||||
};
|
||||
const obj2 = {
|
||||
name: '夜班',
|
||||
startDay: '20:00',
|
||||
endDay: '8:00',
|
||||
startTime: '20:00:00',
|
||||
endTime: '08:00:00',
|
||||
daySpan: 1,
|
||||
code: 3,
|
||||
};
|
||||
this.tableData1.push(obj1, obj2);
|
||||
} else if (this.dataForm.shiftType == 3) {
|
||||
const obj1 = {
|
||||
name: '早班',
|
||||
startDay: '8:00',
|
||||
endDay: '16:00',
|
||||
startTime: '08:00:00',
|
||||
endTime: '16:00:00',
|
||||
daySpan: 0,
|
||||
code: 1,
|
||||
};
|
||||
const obj2 = {
|
||||
name: '中班',
|
||||
startDay: '16:00',
|
||||
endDay: '00:00',
|
||||
startTime: '16:00:00',
|
||||
endTime: '00:00:00',
|
||||
daySpan: 1,
|
||||
code: 2,
|
||||
};
|
||||
const obj3 = {
|
||||
name: '夜班',
|
||||
startDay: '00:00',
|
||||
endDay: '8:00',
|
||||
startTime: '00:00:00',
|
||||
endTime: '08:00:00',
|
||||
daySpan: 0,
|
||||
code: 3,
|
||||
};
|
||||
this.tableData1.push(obj1, obj2, obj3);
|
||||
}
|
||||
},
|
||||
//编辑班次
|
||||
handleClick1(val) {
|
||||
this.addOrUpdateVisible1 = true;
|
||||
this.$nextTick(() => {
|
||||
this.$refs.editClassRef.init(val.data);
|
||||
});
|
||||
},
|
||||
//班组操作
|
||||
handleClick2(val) {
|
||||
if (val.type === 'bind') {
|
||||
this.addOrUpdateVisible3 = true;
|
||||
this.$nextTick(() => {
|
||||
this.$refs.bindLineRef.init(val.data);
|
||||
});
|
||||
} else if (val.type === 'delete') {
|
||||
this.tableData2.splice(val.data._pageIndex - 1, 1);
|
||||
}
|
||||
},
|
||||
// 新增班组
|
||||
addNewGroup() {
|
||||
this.addOrUpdateVisible2 = true;
|
||||
@@ -705,10 +859,93 @@ export default {
|
||||
this.tableData2.push(...val);
|
||||
this.cancel2();
|
||||
},
|
||||
refreshTableData3(val) {
|
||||
console.log(val);
|
||||
refreshTableData3(index, val) {
|
||||
this.tableData2[index].bindLineTree = val;
|
||||
let lineName = '';
|
||||
lineName = this.setLineName(val, lineName);
|
||||
if (lineName) {
|
||||
this.$set(this.tableData2[index], 'lineName', lineName.slice(0, -1));
|
||||
}
|
||||
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;
|
||||
}
|
||||
});
|
||||
return lineName;
|
||||
},
|
||||
//第三步
|
||||
// 进来加载预览排班
|
||||
getThreeGroup(day) {
|
||||
const data = {
|
||||
id: this.dataForm.id,
|
||||
count: day,
|
||||
};
|
||||
this.tableProps3 = [];
|
||||
this.tableData3 = [];
|
||||
getPerView(data).then((res) => {
|
||||
this.setThreeData(res.data);
|
||||
});
|
||||
},
|
||||
setPeriod(val) {
|
||||
this.getThreeGroup(val);
|
||||
},
|
||||
|
||||
setThreeData(data) {
|
||||
//表头第一个为班次名称
|
||||
const propfirst = {
|
||||
prop: 'name',
|
||||
label: '',
|
||||
align: 'center',
|
||||
fixed: true,
|
||||
subcomponent: propfirstSpan,
|
||||
};
|
||||
this.tableProps3.push(propfirst);
|
||||
data.forEach((item, index) => {
|
||||
//设置所有日期为表头
|
||||
const obj = {
|
||||
prop: 'daydata' + index,
|
||||
label: item.day,
|
||||
work: item.work,
|
||||
subcomponent: propSpan,
|
||||
};
|
||||
this.tableProps3.push(obj);
|
||||
item.det.forEach((sItem, sIndex) => {
|
||||
if (index === 0) {
|
||||
let sObj = {
|
||||
name: sItem.classesName + '/' + sItem.time,
|
||||
sort: sItem.sort,
|
||||
};
|
||||
sObj['daydata' + index] = item.work
|
||||
? sItem.teamName
|
||||
: item.holidayName;
|
||||
this.tableData3.push(sObj);
|
||||
} else {
|
||||
this.$set(
|
||||
this.tableData3[sIndex],
|
||||
'daydata' + index,
|
||||
item.work ? sItem.teamName : item.holidayName
|
||||
);
|
||||
this.$set(this.tableData3[sIndex], 'sort', sItem.sort);
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
cancelStep() {
|
||||
if (this.stepNum > 1) {
|
||||
cancelStepThree(this.dataForm.id).then((res) => {
|
||||
this.$message('已取消计划');
|
||||
this.$emit('refreshDataList');
|
||||
});
|
||||
} else {
|
||||
this.$emit('refreshDataList');
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user