This commit is contained in:
jhd
2026-05-15 16:59:49 +08:00
60 changed files with 5843 additions and 16 deletions

View File

@@ -0,0 +1,53 @@
import request from '@/utils/request'
// 查询考勤比对结果(排班与打卡比对)列表
export function listAttendanceCheck(query) {
return request({
url: '/wms/attendanceCheck/list',
method: 'get',
params: query
})
}
// 查询考勤比对结果(排班与打卡比对)详细
export function getAttendanceCheck(checkId) {
return request({
url: '/wms/attendanceCheck/' + checkId,
method: 'get'
})
}
// 新增考勤比对结果(排班与打卡比对)
export function addAttendanceCheck(data) {
return request({
url: '/wms/attendanceCheck',
method: 'post',
data: data
})
}
// 修改考勤比对结果(排班与打卡比对)
export function updateAttendanceCheck(data) {
return request({
url: '/wms/attendanceCheck',
method: 'put',
data: data
})
}
// 删除考勤比对结果(排班与打卡比对)
export function delAttendanceCheck(checkId) {
return request({
url: '/wms/attendanceCheck/' + checkId,
method: 'delete'
})
}
// 一键生成考勤对比结果
export function generateAttendanceCheck(data) {
return request({
url: '/wms/attendanceCheck/check',
method: 'post',
data: data
})
}

View File

@@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询考勤规则列表
export function listAttendanceRule(query) {
return request({
url: '/wms/attendanceRule/list',
method: 'get',
params: query
})
}
// 查询考勤规则详细
export function getAttendanceRule(ruleId) {
return request({
url: '/wms/attendanceRule/' + ruleId,
method: 'get'
})
}
// 新增考勤规则
export function addAttendanceRule(data) {
return request({
url: '/wms/attendanceRule',
method: 'post',
data: data
})
}
// 修改考勤规则
export function updateAttendanceRule(data) {
return request({
url: '/wms/attendanceRule',
method: 'put',
data: data
})
}
// 删除考勤规则
export function delAttendanceRule(ruleId) {
return request({
url: '/wms/attendanceRule/' + ruleId,
method: 'delete'
})
}

View File

@@ -0,0 +1,62 @@
import request from '@/utils/request'
// 查询排班记录列表
export function listAttendanceSchedule(query) {
return request({
url: '/wms/attendanceSchedule/list',
method: 'get',
params: query
})
}
// 查询排班记录详细
export function getAttendanceSchedule(id) {
return request({
url: '/wms/attendanceSchedule/' + id,
method: 'get'
})
}
// 新增排班记录
export function addAttendanceSchedule(data) {
return request({
url: '/wms/attendanceSchedule',
method: 'post',
data: data
})
}
// 修改排班记录
export function updateAttendanceSchedule(data) {
return request({
url: '/wms/attendanceSchedule',
method: 'put',
data: data
})
}
// 删除排班记录(支持批量删除传递csv格式字符串如1,2,3)
export function delAttendanceSchedule(ids) {
return request({
url: '/wms/attendanceSchedule/' + ids,
method: 'delete'
})
}
// 生成单个人的排班记录(批量)
export function generateenerateSchedule(data) {
return request({
url: '/wms/attendanceSchedule/generate',
method: 'post',
data: data
})
}
// 批量生成排班记录
export function batchGenerateSchedule(data) {
return request({
url: '/wms/attendanceSchedule/batchGenerate',
method: 'post',
data: data
})
}

View File

@@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询班次列表
export function listShift(query) {
return request({
url: '/wms/attendanceShift/list',
method: 'get',
params: query
})
}
// 查询班次详细
export function getShift(id) {
return request({
url: '/wms/attendanceShift/' + id,
method: 'get'
})
}
// 新增班次
export function addShift(data) {
return request({
url: '/wms/attendanceShift',
method: 'post',
data: data
})
}
// 修改班次
export function updateShift(data) {
return request({
url: '/wms/attendanceShift',
method: 'put',
data: data
})
}
// 删除班次
export function delShift(id) {
return request({
url: '/wms/attendanceShift/' + id,
method: 'delete'
})
}

View File

@@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询倒班规则列表
export function listAttendanceShiftRule(query) {
return request({
url: '/wms/attendanceShiftRule/list',
method: 'get',
params: query
})
}
// 查询倒班规则详细
export function getAttendanceShiftRule(ruleId) {
return request({
url: '/wms/attendanceShiftRule/' + ruleId,
method: 'get'
})
}
// 新增倒班规则
export function addAttendanceShiftRule(data) {
return request({
url: '/wms/attendanceShiftRule',
method: 'post',
data: data
})
}
// 修改倒班规则
export function updateAttendanceShiftRule(data) {
return request({
url: '/wms/attendanceShiftRule',
method: 'put',
data: data
})
}
// 删除倒班规则
export function delAttendanceShiftRule(ruleId) {
return request({
url: '/wms/attendanceShiftRule/' + ruleId,
method: 'delete'
})
}

View File

@@ -85,7 +85,7 @@
</el-form-item>
<el-form-item v-if="showWaybill" label="发货单时间">
<el-date-picker v-model="queryParams.shipmentTime" type="daterange" value-format="yyyy-MM-dd HH:mm:ss"
<el-date-picker v-model="queryParams.shipmentTime" type="daterange" value-format="yyyy-MM-dd"
range-separator="" start-placeholder="开始日期" end-placeholder="结束日期" />
</el-form-item>
@@ -1747,8 +1747,8 @@ export default {
...this.queryParams,
exportTimeBy: true,
selectType: this.querys.materialType === '原料' ? 'raw_material' : 'product',
startTime: this.queryParams.shipmentTime?.[0],
endTime: this.queryParams.shipmentTime?.[1],
startTime: this.queryParams.shipmentTime?.[0] && this.queryParams.shipmentTime?.[0] + ' 00:00:00',
endTime: this.queryParams.shipmentTime?.[1] && this.queryParams.shipmentTime?.[1] + ' 23:59:59',
}
listBoundCoil(query).then(res => {
this.materialCoilList = res.rows || [];

View File

@@ -6,6 +6,7 @@
import BasePage from './panels/base.vue';
export default {
name: "Exp-Coil",
components: {
BasePage
},

View File

@@ -10,6 +10,7 @@
import BasePage from './panels/base.vue';
export default {
name: 'Exp-Bind',
components: {
BasePage
},

View File

@@ -70,6 +70,7 @@ import { listCoilByIds } from "@/api/wms/coil";
import WayBill from "../components/wayBill.vue";
export default {
name: "Exp-Bills",
data() {
return {
deliveryWaybillList: [],

View File

@@ -15,6 +15,7 @@
import BasePage from '@/views/wms/coil/panels/base.vue';
export default {
name: "Exp-Canuse",
components: {
BasePage
},

View File

@@ -248,7 +248,7 @@ import PlanSelector from "../components/planSelector.vue";
import DragResizePanel from "@/components/DragResizePanel";
export default {
name: "DeliveryWaybill",
name: "Exp-Waybill",
components: {
MemoInput,
DeliveryWaybillDetail,

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,308 @@
<template>
<div class="app-container">
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="attendanceRuleList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="主键ID" align="center" prop="ruleId" v-if="false"/>
<el-table-column label="迟到警告阈值" align="center" prop="lateWarn" />
<el-table-column label="迟到一级阈值" align="center" prop="lateOne" />
<el-table-column label="迟到二级阈值" align="center" prop="lateTwo" />
<el-table-column label="迟到一级扣款" align="center" prop="deductOne" />
<el-table-column label="迟到二级扣款" align="center" prop="deductTwo" />
<el-table-column label="超过多少分钟按旷工半天处理" align="center" prop="absentHalfDay" />
<el-table-column label="连续旷工多少天自动离职" align="center" prop="continuousAbsentDays" />
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改考勤规则对话框 -->
<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-item label="迟到警告阈值" prop="lateWarn">
<el-input v-model="form.lateWarn" placeholder="请输入迟到警告阈值" />
</el-form-item>
<el-form-item label="迟到一级阈值" prop="lateOne">
<el-input v-model="form.lateOne" placeholder="请输入迟到一级阈值" />
</el-form-item>
<el-form-item label="迟到二级阈值" prop="lateTwo">
<el-input v-model="form.lateTwo" placeholder="请输入迟到二级阈值" />
</el-form-item>
<el-form-item label="迟到一级扣款" prop="deductOne">
<el-input v-model="form.deductOne" placeholder="请输入迟到一级扣款" />
</el-form-item>
<el-form-item label="迟到二级扣款" prop="deductTwo">
<el-input v-model="form.deductTwo" placeholder="请输入迟到二级扣款" />
</el-form-item>
<el-form-item label="超过多少分钟按旷工半天处理" prop="absentHalfDay">
<el-input v-model="form.absentHalfDay" placeholder="请输入超过多少分钟按旷工半天处理" />
</el-form-item>
<el-form-item label="连续旷工多少天自动离职" prop="continuousAbsentDays">
<el-input v-model="form.continuousAbsentDays" placeholder="请输入连续旷工多少天自动离职" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listAttendanceRule, getAttendanceRule, delAttendanceRule, addAttendanceRule, updateAttendanceRule } from "@/api/wms/attendanceRule";
export default {
name: "AttendanceRule",
data() {
return {
// 按钮loading
buttonLoading: false,
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 考勤规则表格数据
attendanceRuleList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
lateWarn: undefined,
lateOne: undefined,
lateTwo: undefined,
deductOne: undefined,
deductTwo: undefined,
absentHalfDay: undefined,
continuousAbsentDays: undefined,
},
// 表单参数
form: {},
// 表单校验
rules: {
lateWarn: [
{ required: true, message: "迟到警告阈值不能为空", trigger: "blur" }
],
lateOne: [
{ required: true, message: "迟到一级阈值不能为空", trigger: "blur" }
],
lateTwo: [
{ required: true, message: "迟到二级阈值不能为空", trigger: "blur" }
],
deductOne: [
{ required: true, message: "迟到一级扣款不能为空", trigger: "blur" }
],
deductTwo: [
{ required: true, message: "迟到二级扣款不能为空", trigger: "blur" }
],
absentHalfDay: [
{ required: true, message: "超过多少分钟按旷工半天处理不能为空", trigger: "blur" }
],
continuousAbsentDays: [
{ required: true, message: "连续旷工多少天自动离职不能为空", trigger: "blur" }
],
remark: [
{ required: true, message: "备注不能为空", trigger: "blur" }
],
}
};
},
created() {
this.getList();
},
methods: {
/** 查询考勤规则列表 */
getList() {
this.loading = true;
listAttendanceRule(this.queryParams).then(response => {
this.attendanceRuleList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
ruleId: undefined,
lateWarn: undefined,
lateOne: undefined,
lateTwo: undefined,
deductOne: undefined,
deductTwo: undefined,
absentHalfDay: undefined,
continuousAbsentDays: undefined,
remark: undefined,
delFlag: undefined,
createBy: undefined,
updateBy: undefined,
createTime: undefined,
updateTime: undefined
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.ruleId)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加考勤规则";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.loading = true;
this.reset();
const ruleId = row.ruleId || this.ids
getAttendanceRule(ruleId).then(response => {
this.loading = false;
this.form = response.data;
this.open = true;
this.title = "修改考勤规则";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
this.buttonLoading = true;
if (this.form.ruleId != null) {
updateAttendanceRule(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
} else {
addAttendanceRule(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ruleIds = row.ruleId || this.ids;
this.$modal.confirm('是否确认删除考勤规则编号为"' + ruleIds + '"的数据项?').then(() => {
this.loading = true;
return delAttendanceRule(ruleIds);
}).then(() => {
this.loading = false;
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {
}).finally(() => {
this.loading = false;
});
},
/** 导出按钮操作 */
handleExport() {
this.download('wms/attendanceRule/export', {
...this.queryParams
}, `attendanceRule_${new Date().getTime()}.xlsx`)
}
}
};
</script>

View File

@@ -0,0 +1,719 @@
<template>
<div class="app-container">
<!-- 日期范围选择 -->
<div class="date-range-section">
<TimeRangePicker v-model="dateRangeParams" startKey="scheduleDateStart" endKey="scheduleDateEnd"
:defaultStartTime="defaultStartTime" :defaultEndTime="defaultEndTime" @change="handleDateRangeChange"
@quick-select="getScheduleList" />
</div>
<!-- 操作栏 -->
<div class="operation-bar">
<el-button plain type="primary" icon="el-icon-plus" @click="handleCreate">创建排班</el-button>
<el-button plain type="info" icon="el-icon-refresh" @click="handleRefresh">刷新</el-button>
</div>
<el-alert type="info" title="提示:双击排班单元格可编辑排班"></el-alert>
<!-- 排班表格 -->
<div class="schedule-table-wrapper">
<el-table v-loading="loading" :data="scheduleData" border stripe>
<!-- 员工列 -->
<el-table-column prop="employeeName" label="员工" width="120" fixed="left" />
<!-- 操作列 -->
<el-table-column label="操作" width="120" fixed="right">
<template slot-scope="scope">
<el-button size="mini" type="danger" @click="handleDeleteRow(scope.row)">删除整行</el-button>
</template>
</el-table-column>
<!-- 动态日期列 -->
<el-table-column v-for="date in dateList" :key="date" :label="formatDateLabel(date)" width="150" align="center">
<template slot-scope="scope">
<div class="schedule-cell" :class="{ 'has-data': scope.row[date], 'empty-cell': !scope.row[date] }"
@dblclick="handleCellDoubleClick(scope.row, date)">
<template v-if="scope.row[date]">
<div class="shift-name" :class="getShiftTypeClass(scope.row[date].shiftType)">
{{ scope.row[date].shiftName }}
</div>
<div class="shift-time-info">
<span v-if="scope.row[date].shiftStartTime">{{ scope.row[date].shiftStartTime }}-{{
scope.row[date].shiftEndTime }}</span>
<span v-if="scope.row[date].shiftStartTime2" class="second-shift">
{{ scope.row[date].shiftStartTime2 }}-{{ scope.row[date].shiftEndTime2 }}
</span>
</div>
</template>
<template v-else>
<span class="empty-hint">双击排班</span>
</template>
</div>
</template>
</el-table-column>
</el-table>
</div>
<!-- 创建排班弹窗 -->
<el-dialog title="创建排班" :visible.sync="dialogVisible" width="800px">
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-form-item label="时间段" prop="dateRange">
<el-date-picker v-model="form.dateRange" type="daterange" range-separator="至" start-placeholder="开始日期"
end-placeholder="结束日期" value-format="yyyy-MM-dd" style="width: 100%;" />
</el-form-item>
<el-form-item label="选择员工" prop="selectedEmployees">
<EmployeeSelector v-model="form.selectedEmployees" :multiple="true" placeholder="请点击选择员工" title="选择排班员工"
@change="handleEmployeeSelect" />
</el-form-item>
<el-form-item label="排班配置" v-if="form.shiftConfig.length > 0">
<div class="shift-config">
<div v-for="(item, index) in form.shiftConfig" :key="index" class="shift-config-item">
<div class="employee-info">
<el-button icon="el-icon-delete" type="default" size="mini" @click="handleDeleteEmployee(index)"></el-button>
<el-tag type="info">{{ item.employeeName || '员工' + (index + 1) }}</el-tag>
</div>
<template>
<el-select clearable v-model="item.shiftId" placeholder="选择班次" style="width: 150px;">
<el-option v-for="shift in shiftList" :key="shift.shiftId" :label="shift.shiftName"
:value="shift.shiftId" />
</el-select>
<div class="shift-time" v-if="item.shiftId">
<span class="time-label">工作时间</span>
<span class="time-value">{{ getShiftTime(item.shiftId) }}</span>
</div>
<el-select clearable v-model="item.shiftRuleId" placeholder="选择倒班规则(不倒班则不填)" style="width: 200px;">
<el-option v-for="rule in shiftRuleList" :key="rule.ruleId" :label="rule.ruleName"
:value="rule.ruleId" />
</el-select>
</template>
</div>
</div>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="cancel">取消</el-button>
<el-button type="primary" @click="submitForm" :loading="buttonLoading" :disabled="!canSubmit">确定</el-button>
</div>
</el-dialog>
<!-- 编辑班次弹窗 -->
<el-dialog title="编辑班次" :visible.sync="editDialogVisible" width="400px">
<el-form ref="editForm" :model="editForm" label-width="80px">
<el-form-item label="班次">
<el-select v-model="editForm.shiftId" placeholder="选择班次" style="width: 100%;">
<el-option v-for="shift in shiftList" :key="shift.shiftId" :label="shift.shiftName"
:value="shift.shiftId" />
</el-select>
</el-form-item>
<el-form-item label="工作时间">
<div v-if="currentShift" class="shift-detail">
<div>
<span class="time-label">时段一</span>
<span class="time-value">{{ currentShift.startTime }} - {{ currentShift.endTime }}</span>
</div>
<div v-if="currentShift.startTime2">
<span class="time-label">时段二</span>
<span class="time-value">{{ currentShift.startTime2 }} - {{ currentShift.endTime2 }}</span>
</div>
</div>
<span v-else>请选择班次</span>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="cancelEdit">取消</el-button>
<el-button type="danger"
v-if="currentEditRow && currentEditRow[currentEditDate] && currentEditRow[currentEditDate].scheduleId"
@click="handleDelete">删除排班</el-button>
<el-button type="primary" @click="submitEdit" :disabled="!editForm.shiftId">确定</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import TimeRangePicker from '@/views/wms/report/components/timeRangePicker.vue'
import EmployeeSelector from '@/components/EmployeeSelector/index.vue'
import { listAttendanceSchedule, generateenerateSchedule, updateAttendanceSchedule, addAttendanceSchedule, delAttendanceSchedule } from '@/api/wms/attendanceSchedule'
import { listShift } from '@/api/wms/attendanceShift'
import { listAttendanceShiftRule } from '@/api/wms/attendanceShiftRule'
export default {
name: 'AttendanceSchedule',
components: { TimeRangePicker, EmployeeSelector },
data() {
return {
loading: false,
buttonLoading: false,
dateRangeParams: {},
defaultStartTime: '',
defaultEndTime: '',
dateList: [],
scheduleData: [],
shiftList: [],
shiftRuleList: [],
dialogVisible: false,
editDialogVisible: false,
scheduleMode: 'single', // single: 普通排班, rotate: 倒班排班
form: {
dateRange: [],
selectedEmployees: '',
shiftConfig: []
},
editForm: {
shiftId: ''
},
currentEditRow: null,
currentEditDate: '',
rules: {
dateRange: [
{ required: true, message: '请选择时间段', trigger: 'change' }
],
selectedEmployees: [
{ required: true, message: '请选择员工', trigger: 'change' }
]
}
}
},
computed: {
canSubmit() {
if (!this.form.dateRange || this.form.dateRange.length === 0) {
return false
}
if (!this.form.selectedEmployees) {
return false
}
if (this.form.shiftConfig.length === 0) {
return false
}
if (this.scheduleMode === 'single') {
return this.form.shiftConfig.every(item => item.shiftId)
} else {
return this.form.shiftConfig.every(item => item.shiftRuleId)
}
},
currentShift() {
if (!this.editForm.shiftId) {
return null
}
return this.shiftList.find(s => s.shiftId === this.editForm.shiftId)
}
},
created() {
this.initDateRange()
this.getShiftList()
this.getShiftRuleList()
},
methods: {
// 刷新排班
handleRefresh() {
this.getScheduleList()
},
// 初始化日期范围为当前月份
initDateRange() {
const now = new Date()
const firstDay = new Date(now.getFullYear(), now.getMonth(), 1)
const lastDay = new Date(now.getFullYear(), now.getMonth() + 1, 0)
this.defaultStartTime = this.formatDate(firstDay) + ' 00:00:00'
this.defaultEndTime = this.formatDate(lastDay) + ' 23:59:59'
this.dateRangeParams = {
scheduleDateStart: this.defaultStartTime,
scheduleDateEnd: this.defaultEndTime
}
this.generateDateList(firstDay, lastDay)
this.getScheduleList()
},
// 格式化日期
formatDate(date) {
const year = date.getFullYear()
const month = (date.getMonth() + 1).toString().padStart(2, '0')
const day = date.getDate().toString().padStart(2, '0')
return `${year}-${month}-${day}`
},
// 生成日期列表
generateDateList(startDate, endDate) {
this.dateList = []
let currentDate = new Date(startDate)
while (currentDate <= endDate) {
this.dateList.push(this.formatDate(currentDate))
currentDate.setDate(currentDate.getDate() + 1)
}
},
handleDeleteEmployee(index) {
this.form.shiftConfig.splice(index, 1)
},
// 格式化日期标签
formatDateLabel(date) {
const dateObj = new Date(date)
const weekDays = ['日', '一', '二', '三', '四', '五', '六']
const month = dateObj.getMonth() + 1
const day = dateObj.getDate()
const weekDay = weekDays[dateObj.getDay()]
return `${month}${day}日 周${weekDay}`
},
// 日期范围变化
handleDateRangeChange() {
if (this.dateRangeParams.scheduleDateStart && this.dateRangeParams.scheduleDateEnd) {
const startDate = new Date(this.dateRangeParams.scheduleDateStart.split(' ')[0])
const endDate = new Date(this.dateRangeParams.scheduleDateEnd.split(' ')[0])
this.generateDateList(startDate, endDate)
this.getScheduleList()
}
},
// 获取排班列表
getScheduleList() {
this.loading = true
listAttendanceSchedule(this.dateRangeParams).then(response => {
this.scheduleData = this.transformScheduleData(response.rows || [])
this.loading = false
}).catch(() => {
this.loading = false
})
},
// 转换排班数据
transformScheduleData(rows) {
const dataMap = {}
rows.forEach(record => {
if (!dataMap[record.userId]) {
dataMap[record.userId] = {
employeeName: record.employeeName,
employeeId: record.userId
}
}
if (record.workDate) {
const dateKey = record.workDate.split(' ')[0]
dataMap[record.userId][dateKey] = {
scheduleId: record.scheduleId,
shiftId: record.shiftId,
shiftName: record.shiftName,
shiftType: record.shiftType,
shiftStartTime: record.shiftStartTime,
shiftEndTime: record.shiftEndTime,
shiftStartTime2: record.shiftStartTime2,
shiftEndTime2: record.shiftEndTime2
}
}
})
return Object.values(dataMap)
},
// 获取班次列表
getShiftList() {
listShift().then(response => {
this.shiftList = response.rows || []
})
},
// 获取倒班规则列表
getShiftRuleList() {
listAttendanceShiftRule().then(response => {
this.shiftRuleList = response.rows || []
})
},
// 获取班次时间显示
getShiftTime(shiftId) {
const shift = this.shiftList.find(s => s.shiftId === shiftId)
if (!shift) return ''
const startTime = shift.startTime ? shift.startTime.substring(0, 5) : ''
const endTime = shift.endTime ? shift.endTime.substring(0, 5) : ''
if (shift.isCrossDay) {
return `${startTime} - 次日${endTime}`
}
return `${startTime} - ${endTime}`
},
// 获取班次类型样式
getShiftTypeClass(shiftType) {
return shiftType === '夜班' ? 'night-shift' : 'day-shift'
},
// 双击单元格处理
handleCellDoubleClick(row, date) {
this.currentEditRow = row
this.currentEditDate = date
if (row[date]) {
this.editForm.shiftId = row[date].shiftId
} else {
this.editForm.shiftId = ''
}
this.editDialogVisible = true
},
// 取消编辑
cancelEdit() {
this.editDialogVisible = false
this.editForm.shiftId = ''
this.currentEditRow = null
this.currentEditDate = ''
},
// 提交编辑
submitEdit() {
if (!this.editForm.shiftId || !this.currentEditRow) {
return
}
const shift = this.shiftList.find(s => s.shiftId === this.editForm.shiftId)
if (!shift) {
return
}
const date = this.currentEditDate
const employeeId = this.currentEditRow.employeeId
if (this.currentEditRow[date]) {
updateAttendanceSchedule({
scheduleId: this.currentEditRow[date].scheduleId,
userId: employeeId,
workDate: date,
shiftId: shift.shiftId,
shiftName: shift.shiftName,
}).then(_ => {
this.$message.success('修改成功')
this.getScheduleList()
}).catch(() => {
this.$message.error('修改失败')
this.getScheduleList()
})
} else {
addAttendanceSchedule({
shiftId: shift.shiftId,
userId: employeeId,
workDate: date,
shiftName: shift.shiftName,
}).then(_ => {
this.$message.success('添加成功')
this.getScheduleList()
}).catch(() => {
this.$message.error('添加失败')
this.getScheduleList()
})
}
// this.currentEditRow[date] = {
// scheduleId: this.currentEditRow[date]?.scheduleId,
// shiftId: shift.shiftId,
// shiftName: shift.shiftName,
// shiftType: shift.shiftType,
// shiftStartTime: shift.startTime,
// shiftEndTime: shift.endTime,
// shiftStartTime2: shift.startTime2,
// shiftEndTime2: shift.endTime2
// }
this.cancelEdit()
},
// 删除排班
handleDelete() {
const scheduleId = this.currentEditRow[this.currentEditDate]?.scheduleId
if (!scheduleId) {
return
}
this.$confirm('确定要删除该排班吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
delAttendanceSchedule(scheduleId).then(() => {
this.$message.success('删除成功')
delete this.currentEditRow[this.currentEditDate]
this.cancelEdit()
}).catch(() => {
this.$message.error('删除失败,正在重新获取数据')
this.getScheduleList()
this.cancelEdit()
})
}).catch(() => {
this.$message.info('已取消删除')
})
},
// 删除整行排班
handleDeleteRow(row) {
const scheduleIds = []
this.dateList.forEach(date => {
if (row[date] && row[date].scheduleId) {
scheduleIds.push(row[date].scheduleId)
}
})
if (scheduleIds.length === 0) {
this.$message.info('该行没有排班记录')
return
}
this.$confirm(`确定要删除该员工的 ${scheduleIds.length} 条排班记录吗?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
delAttendanceSchedule(scheduleIds.join(',')).then(() => {
this.$message.success('删除成功')
this.getScheduleList()
}).catch(() => {
this.$message.error('删除失败,正在重新获取数据')
this.getScheduleList()
})
}).catch(() => {
this.$message.info('已取消删除')
})
},
// 处理班次变更
handleShiftChange(employeeId, date, shiftId) {
if (!shiftId) {
return
}
const shift = this.shiftList.find(s => s.shiftId === shiftId)
if (!shift) {
return
}
const scheduleItem = this.scheduleData.find(item => item.employeeId === employeeId)
if (scheduleItem && scheduleItem[date]) {
updateAttendanceSchedule({
...scheduleItem[date],
shiftId: scheduleItem.shiftId
}).then(_ => {
this.$message.success('修改成功')
}).catch(() => {
this.$message.success('修改成功')
this.getScheduleList()
})
scheduleItem[date].shiftId = shift.shiftId
scheduleItem[date].shiftName = shift.shiftName
scheduleItem[date].shiftType = shift.shiftType
scheduleItem[date].shiftStartTime = shift.startTime
scheduleItem[date].shiftEndTime = shift.endTime
scheduleItem[date].shiftStartTime2 = shift.startTime2
scheduleItem[date].shiftEndTime2 = shift.endTime2
} else if (scheduleItem) {
scheduleItem[date] = {
shiftId: shift.shiftId,
shiftName: shift.shiftName,
shiftType: shift.shiftType,
shiftStartTime: shift.startTime,
shiftEndTime: shift.endTime,
shiftStartTime2: shift.startTime2,
shiftEndTime2: shift.endTime2
}
}
},
// 创建排班
handleCreate() {
this.reset()
this.dialogVisible = true
},
// 重置表单
reset() {
this.scheduleMode = 'single'
this.form = {
dateRange: [],
selectedEmployees: '',
shiftConfig: []
}
this.resetForm('form')
},
// 员工选择变化时自动生成配置项
handleEmployeeSelect(employees) {
if (!employees || employees.length === 0) {
this.form.shiftConfig = []
return
}
// 为每个选中的员工生成配置项
if (this.scheduleMode === 'single') {
this.form.shiftConfig = employees.map(employee => ({
employeeId: employee.infoId,
employeeName: employee.name,
shiftId: null
}))
} else {
this.form.shiftConfig = employees.map(employee => ({
employeeId: employee.infoId,
employeeName: employee.name,
shiftRuleId: null
}))
}
},
// 排班模式切换
handleScheduleModeChange() {
// 模式切换时重新生成配置项
if (this.form.selectedEmployees && this.form.selectedEmployees.length > 0) {
this.handleEmployeeSelect(this.form.selectedEmployees)
}
},
// 提交表单
submitForm() {
this.$refs['form'].validate(valid => {
if (valid) {
this.loading = true;
this.buttonLoading = true;
// 构建提交数据
const list = []
for (const item of this.form.shiftConfig) {
const payload = {
userId: item.employeeId,
shiftId: item.shiftId,
ruleId: item.shiftRuleId,
startDate: this.dateRangeParams.scheduleDateStart.split(' ')[0],
endDate: this.dateRangeParams.scheduleDateEnd.split(' ')[0]
}
list.push(payload)
}
// 调用API
generateenerateSchedule(list).then(response => {
this.$modal.msgSuccess('生成成功')
this.dialogVisible = false
this.loading = false;
this.buttonLoading = false;
this.getScheduleList()
})
}
})
},
// 取消
cancel() {
this.dialogVisible = false
this.reset()
}
}
}
</script>
<style scoped>
.app-container {
padding: 20px;
}
.date-range-section {
margin-bottom: 20px;
}
.operation-bar {
margin-bottom: 20px;
}
.schedule-table-wrapper {
overflow-x: auto;
}
.schedule-cell {
padding: 4px;
min-height: 60px;
cursor: pointer;
transition: background-color 0.2s;
}
.schedule-cell:hover {
background-color: #f5f7fa;
}
.has-data {
padding: 8px 4px;
}
.empty-cell {
display: flex;
align-items: center;
justify-content: center;
}
.empty-hint {
font-size: 12px;
color: #c0c4cc;
}
.shift-info {
text-align: center;
}
.shift-name {
display: inline-block;
padding: 2px 6px;
border-radius: 4px;
font-size: 11px;
color: #fff;
margin-bottom: 2px;
}
.day-shift {
background-color: #67c23a;
}
.night-shift {
background-color: #409eff;
}
.shift-time-info {
font-size: 10px;
color: #606266;
line-height: 1.4;
}
.second-shift {
display: block;
margin-top: 2px;
}
.shift-config {
width: 100%;
}
.shift-config-item {
margin-bottom: 12px;
padding: 12px;
background-color: #f5f7fa;
border-radius: 4px;
display: flex;
align-items: center;
gap: 12px;
}
.employee-info {
min-width: 100px;
}
.shift-time {
flex: 1;
margin-left: 12px;
}
.time-label {
font-size: 12px;
color: #909399;
}
.time-value {
font-size: 12px;
color: #606266;
}
</style>

View File

@@ -0,0 +1,519 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="班次名称" prop="shiftName">
<el-input
v-model="queryParams.shiftName"
placeholder="请输入班次名称"
clearable
style="width: 200px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="班次类型" prop="shiftType">
<el-select
v-model="queryParams.shiftType"
placeholder="请选择班次类型"
clearable
style="width: 200px"
allow-create
filterable
>
<el-option label="白班" value="白班" />
<el-option label="夜班" value="夜班" />
</el-select>
</el-form-item>
<el-form-item label="季节" prop="season">
<el-select
v-model="queryParams.season"
placeholder="请选择季节"
clearable
style="width: 200px"
allow-create
filterable
>
<el-option label="夏季" value="夏季" />
<el-option label="冬季" value="冬季" />
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
>新增</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<KLPTable v-loading="loading" :data="shiftList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="班次名称" align="center" prop="shiftName" :show-overflow-tooltip="true" />
<el-table-column label="班次类型" align="center" prop="shiftType">
<template slot-scope="scope">
<el-tag :type="scope.row.shiftType === '白班' ? 'success' : 'info'">{{ scope.row.shiftType }}</el-tag>
</template>
</el-table-column>
<el-table-column label="季节" align="center" prop="season">
<template slot-scope="scope">
<el-tag :type="scope.row.season === '夏季' ? 'warning' : 'primary'">{{ scope.row.season }}</el-tag>
</template>
</el-table-column>
<el-table-column label="上班1" align="center" prop="startTime" />
<el-table-column label="下班1" align="center" prop="endTime" />
<el-table-column label="上班2" align="center" prop="startTime2" />
<el-table-column label="下班2" align="center" prop="endTime2" />
<el-table-column label="是否跨天" align="center" prop="isCrossDay">
<template slot-scope="scope">
<el-tag :type="scope.row.isCrossDay === 1 ? 'danger' : 'success'">{{ scope.row.isCrossDay === 1 ? '是' : '否' }}</el-tag>
</template>
</el-table-column>
<el-table-column label="工时" align="center" prop="workHours" />
<el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" />
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="240">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-document-copy"
@click="handleCopy(scope.row)"
>变更</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
>删除</el-button>
</template>
</el-table-column>
</KLPTable>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改班次对话框 -->
<el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
<el-alert
v-if="title === '变更班次'"
title="变更是在当前班次规则的基础上进行调整生成一个新的班次规则"
type="warning"
:closable="false"
show-icon
style="margin-bottom: 15px;"
/>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="班次名称" prop="shiftName">
<el-input v-model="form.shiftName" placeholder="请输入班次名称" />
</el-form-item>
<el-form-item label="班次类型" prop="shiftType">
<el-select v-model="form.shiftType" placeholder="请选择班次类型" filterable style="width: 100%" allow-create>
<el-option label="白班" value="白班" />
<el-option label="夜班" value="夜班" />
</el-select>
</el-form-item>
<el-form-item label="季节" prop="season">
<el-select v-model="form.season" placeholder="请选择季节" filterable style="width: 100%" allow-create>
<el-option label="夏季" value="夏季" />
<el-option label="冬季" value="冬季" />
</el-select>
</el-form-item>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="上班1" prop="startTime">
<el-input
v-model="form.startTime"
placeholder="例如: 08:30"
style="width: 100%"
@blur="formatTime('startTime')"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="下班1" prop="endTime">
<el-input
v-model="form.endTime"
placeholder="例如: 17:30"
style="width: 100%"
@blur="formatTime('endTime')"
/>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="上班2" prop="startTime2">
<el-input
v-model="form.startTime2"
placeholder="例如: 08:30"
style="width: 100%"
@blur="formatTime('startTime2')"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="下班2" prop="endTime2">
<el-input
v-model="form.endTime2"
placeholder="例如: 17:30"
style="width: 100%"
@blur="formatTime('endTime2')"
/>
</el-form-item>
</el-col>
</el-row>
<el-form-item label="是否跨天" prop="isCrossDay">
<el-radio-group v-model="form.isCrossDay">
<el-radio :label="0"></el-radio>
<el-radio :label="1"></el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listShift, getShift, addShift, updateShift, delShift } from "@/api/wms/attendanceShift";
export default {
name: "AttendanceShift",
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 班次表格数据
shiftList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 20,
shiftName: undefined,
shiftType: undefined,
season: undefined
},
// 表单参数
form: {},
// 表单校验
rules: {
shiftName: [
{ required: true, message: "班次名称不能为空", trigger: "blur" }
],
shiftType: [
{ required: true, message: "班次类型不能为空", trigger: "change" }
],
season: [
{ required: true, message: "季节不能为空", trigger: "change" }
],
// startTime: [
// { required: true, message: "上班1时间不能为空", trigger: "blur" },
// { pattern: /^([01]\d|2[0-3]):([0-5]\d):([0-5]\d)$/, message: "请输入正确的时间格式,例如 08:30", trigger: "blur" }
// ],
// endTime: [
// { required: true, message: "下班1时间不能为空", trigger: "blur" },
// { pattern: /^([01]\d|2[0-3]):([0-5]\d):([0-5]\d)$/, message: "请输入正确的时间格式,例如 17:30", trigger: "blur" }
// ],
// startTime2: [
// {
// validator: (rule, value, callback) => {
// if (this.form.endTime2 && !value) {
// callback(new Error("请输入上班2时间"));
// } else if (value && !/^([01]\d|2[0-3]):([0-5]\d):([0-5]\d)$/.test(value)) {
// callback(new Error("请输入正确的时间格式,例如 08:30"));
// } else {
// callback();
// }
// },
// trigger: "blur"
// }
// ],
// endTime2: [
// {
// validator: (rule, value, callback) => {
// if (this.form.startTime2 && !value) {
// callback(new Error("请输入下班2时间"));
// } else if (value && !/^([01]\d|2[0-3]):([0-5]\d):([0-5]\d)$/.test(value)) {
// callback(new Error("请输入正确的时间格式,例如 17:30"));
// } else {
// callback();
// }
// },
// trigger: "blur"
// }
// ]
}
};
},
created() {
this.getList();
},
watch: {
"form.startTime": {
handler() {
this.calculateWorkHours();
}
},
"form.endTime": {
handler() {
this.calculateWorkHours();
}
},
"form.startTime2": {
handler() {
this.calculateWorkHours();
}
},
"form.endTime2": {
handler() {
this.calculateWorkHours();
}
},
"form.isCrossDay": {
handler() {
this.calculateWorkHours();
}
}
},
methods: {
/** 格式化时间为 hh:mm:ss */
formatTime(field) {
let time = this.form[field];
if (!time) return;
// 移除非数字和冒号的字符
time = time.replace(/[^\d:]/g, '');
let hours, minutes, seconds = '00';
// 处理输入格式
if (time.includes(':')) {
const parts = time.split(':');
hours = parts[0].padStart(2, '0');
minutes = parts[1] ? parts[1].padStart(2, '0') : '00';
seconds = parts[2] ? parts[2].padStart(2, '0') : '00';
} else if (time.length >= 4) {
// 直接输入数字,如 0830 或 830
hours = time.substring(0, 2).padStart(2, '0');
minutes = time.substring(2, 4).padStart(2, '0');
} else if (time.length === 3) {
// 如 830
hours = '0' + time.substring(0, 1);
minutes = time.substring(1, 3).padStart(2, '0');
} else if (time.length === 2) {
// 如 08默认分钟为00
hours = time.padStart(2, '0');
minutes = '00';
} else if (time.length === 1) {
// 如 8默认分钟为00
hours = '0' + time;
minutes = '00';
}
// 验证并限制范围
hours = Math.min(23, Math.max(0, parseInt(hours || 0))).toString().padStart(2, '0');
minutes = Math.min(59, Math.max(0, parseInt(minutes || 0))).toString().padStart(2, '0');
seconds = Math.min(59, Math.max(0, parseInt(seconds || 0))).toString().padStart(2, '0');
this.form[field] = `${hours}:${minutes}:${seconds}`;
this.calculateWorkHours();
},
/** 计算工时 */
calculateWorkHours() {
if (!this.form.startTime || !this.form.endTime) {
this.form.workHours = undefined;
return;
}
const parseTime = (timeStr) => {
if (!timeStr) return null;
const [hours, minutes, seconds] = timeStr.split(":").map(Number);
return hours * 3600 + minutes * 60 + (seconds || 0);
};
let totalSeconds = 0;
// 计算第一段工作时间
const start1 = parseTime(this.form.startTime);
const end1 = parseTime(this.form.endTime);
if (start1 !== null && end1 !== null) {
let diff1 = end1 - start1;
if (diff1 < 0) {
diff1 += 24 * 3600; // 跨天
}
totalSeconds += diff1;
}
// 计算第二段工作时间(如果有)
if (this.form.startTime2 && this.form.endTime2) {
const start2 = parseTime(this.form.startTime2);
const end2 = parseTime(this.form.endTime2);
if (start2 !== null && end2 !== null) {
let diff2 = end2 - start2;
if (diff2 < 0) {
diff2 += 24 * 3600; // 跨天
}
totalSeconds += diff2;
}
}
// 转换为小时,保留两位小数
this.form.workHours = parseFloat((totalSeconds / 3600).toFixed(2));
},
/** 查询班次列表 */
getList() {
this.loading = true;
listShift(this.queryParams).then(response => {
this.shiftList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
shiftId: undefined,
shiftName: undefined,
shiftType: undefined,
season: undefined,
startTime: undefined,
endTime: undefined,
startTime2: undefined,
endTime2: undefined,
isCrossDay: 0,
workHours: undefined,
remark: undefined
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "新增班次";
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.shiftId);
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
// 获取详细数据
getShift(row.shiftId).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改班次";
});
},
/** 变更按钮操作(复制当前数据新增) */
handleCopy(row) {
this.reset();
// 复制当前数据但不包含id
this.form = {
shiftName: row.shiftName,
shiftType: row.shiftType,
season: row.season,
startTime: row.startTime,
endTime: row.endTime,
startTime2: row.startTime2,
endTime2: row.endTime2,
isCrossDay: row.isCrossDay,
workHours: row.workHours,
remark: row.remark
};
// 重新计算工时
this.calculateWorkHours();
this.open = true;
this.title = "变更班次";
},
/** 提交按钮 */
submitForm: function() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.shiftId) {
updateShift(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addShift(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
this.$modal.confirm('是否确认删除班次"' + row.shiftName + '"? 如果使用该班次进行过排班,可能会导致排班异常。').then(() => {
return delShift(row.shiftId);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
}
}
};
</script>

View File

@@ -0,0 +1,399 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="倒班日期" prop="changeDays">
<el-input
v-model="queryParams.changeDays"
placeholder="请输入倒班日期"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="周期天数" prop="cycleDays">
<el-input
v-model="queryParams.cycleDays"
placeholder="请输入周期天数"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="班次A" prop="shiftA">
<el-input
v-model="queryParams.shiftA"
placeholder="请输入班次A"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="班次B" prop="shiftB">
<el-input
v-model="queryParams.shiftB"
placeholder="请输入班次B"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="attendanceShiftRuleList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="主键ID" align="center" prop="ruleId" v-if="true"/>
<el-table-column label="规则类型" align="center" prop="ruleType" />
<el-table-column label="倒班日期" align="center" prop="changeDays" />
<el-table-column label="周期天数" align="center" prop="cycleDays" />
<el-table-column label="班次A" align="center" prop="shiftA">
<template slot-scope="scope">
{{ getShiftName(scope.row.shiftA) }}
</template>
</el-table-column>
<el-table-column label="班次B" align="center" prop="shiftB">
<template slot-scope="scope">
{{ getShiftName(scope.row.shiftB) }}
</template>
</el-table-column>
<el-table-column label="倒班日班次(白转夜)" align="center" prop="changeShiftBId">
<template slot-scope="scope">
{{ getShiftName(scope.row.changeShiftBId) }}
</template>
</el-table-column>
<el-table-column label="倒班日班次(夜转白)" align="center" prop="changeShiftAId">
<template slot-scope="scope">
{{ getShiftName(scope.row.changeShiftAId) }}
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改倒班规则对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
<el-form-item label="倒班日期" prop="changeDays">
<el-input v-model="form.changeDays" placeholder="请输入倒班日期" />
</el-form-item>
<el-form-item label="周期天数" prop="cycleDays">
<el-input v-model="form.cycleDays" placeholder="请输入周期天数" />
</el-form-item>
<el-form-item label="班次A" prop="shiftA">
<el-select v-model="form.shiftA" placeholder="请选择班次A" style="width: 100%;">
<el-option
v-for="item in shiftList"
:key="item.shiftId"
:label="item.shiftName"
:value="item.shiftId"
/>
</el-select>
</el-form-item>
<el-form-item label="班次B" prop="shiftB">
<el-select v-model="form.shiftB" placeholder="请选择班次B" style="width: 100%;">
<el-option
v-for="item in shiftList"
:key="item.shiftId"
:label="item.shiftName"
:value="item.shiftId"
/>
</el-select>
</el-form-item>
<el-form-item label="倒班日班次(白转夜)" prop="changeShiftBId">
<el-select v-model="form.changeShiftBId" placeholder="请选择倒班日班次(白转夜)" style="width: 100%;">
<el-option
v-for="item in shiftList"
:key="item.shiftId"
:label="item.shiftName"
:value="item.shiftId"
/>
</el-select>
</el-form-item>
<el-form-item label="倒班日班次(夜转白)" prop="changeShiftAId">
<el-select v-model="form.changeShiftAId" placeholder="请选择倒班日班次(夜转白)" style="width: 100%;">
<el-option
v-for="item in shiftList"
:key="item.shiftId"
:label="item.shiftName"
:value="item.shiftId"
/>
</el-select>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listAttendanceShiftRule, getAttendanceShiftRule, delAttendanceShiftRule, addAttendanceShiftRule, updateAttendanceShiftRule } from "@/api/wms/attendanceShiftRule";
import { listShift } from "@/api/wms/attendanceShift";
export default {
name: "AttendanceShiftRule",
data() {
return {
// 按钮loading
buttonLoading: false,
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 倒班规则表格数据
attendanceShiftRuleList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 班次列表
shiftList: [],
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
ruleType: undefined,
changeDays: undefined,
cycleDays: undefined,
shiftA: undefined,
shiftB: undefined,
},
// 表单参数
form: {},
// 表单校验
rules: {
shiftA: [
{ required: true, message: "班次A不能为空", trigger: "change" }
],
shiftB: [
{ required: true, message: "班次B不能为空", trigger: "change" }
],
changeShiftBId: [
{ required: true, message: "倒班日班次(白转夜)不能为空", trigger: "change" }
],
changeShiftAId: [
{ required: true, message: "倒班日班次(夜转白)不能为空", trigger: "change" }
],
}
};
},
created() {
this.getList();
this.getShiftList();
},
methods: {
/** 查询倒班规则列表 */
getList() {
this.loading = true;
listAttendanceShiftRule(this.queryParams).then(response => {
this.attendanceShiftRuleList = response.rows;
this.total = response.total;
this.loading = false;
});
},
/** 获取班次列表 */
getShiftList() {
listShift().then(response => {
this.shiftList = response.rows || [];
});
},
/** 获取班次名称和理论打卡时间 */
getShiftName(shiftId) {
if (!shiftId) return '';
const shift = this.shiftList.find(item => item.shiftId === shiftId);
if (!shift) return shiftId;
let timeStr = '';
if (shift.startTime && shift.endTime) {
timeStr = `(${shift.startTime.slice(0, 5)}-${shift.endTime.slice(0, 5)}`;
if (shift.startTime2 && shift.endTime2) {
timeStr += `, ${shift.startTime2.slice(0, 5)}-${shift.endTime2.slice(0, 5)}`;
}
timeStr += ')';
}
return `${shift.shiftName} ${timeStr}`;
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
ruleId: undefined,
ruleType: undefined,
changeDays: undefined,
cycleDays: undefined,
shiftA: undefined,
shiftB: undefined,
changeShiftBId: undefined,
changeShiftAId: undefined,
remark: undefined,
delFlag: undefined,
createBy: undefined,
updateBy: undefined,
createTime: undefined,
updateTime: undefined
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.ruleId)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加倒班规则";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.loading = true;
this.reset();
const ruleId = row.ruleId || this.ids
getAttendanceShiftRule(ruleId).then(response => {
this.loading = false;
this.form = response.data;
this.open = true;
this.title = "修改倒班规则";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
this.buttonLoading = true;
if (this.form.ruleId != null) {
updateAttendanceShiftRule(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
} else {
addAttendanceShiftRule(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
}).finally(() => {
this.buttonLoading = false;
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ruleIds = row.ruleId || this.ids;
this.$modal.confirm('是否确认删除倒班规则编号为"' + ruleIds + '"的数据项?').then(() => {
this.loading = true;
return delAttendanceShiftRule(ruleIds);
}).then(() => {
this.loading = false;
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {
}).finally(() => {
this.loading = false;
});
},
/** 导出按钮操作 */
handleExport() {
this.download('wms/attendanceShiftRule/export', {
...this.queryParams
}, `attendanceShiftRule_${new Date().getTime()}.xlsx`)
}
}
};
</script>

View File

@@ -4,18 +4,18 @@
<el-date-picker
style="width: 200px;"
v-model="startTime"
type="datetime"
value-format="yyyy-MM-dd HH:mm:ss"
placeholder="选择开始时间"
:type="pickerType"
:value-format="format"
:placeholder="isDateType ? '选择开始日期' : '选择开始时间'"
@change="handleTimeChange"
/>
<span class="separator"></span>
<el-date-picker
style="width: 200px;"
v-model="endTime"
type="datetime"
value-format="yyyy-MM-dd HH:mm:ss"
placeholder="选择结束时间"
:type="pickerType"
:value-format="format"
:placeholder="isDateType ? '选择结束日期' : '选择结束时间'"
@change="handleTimeChange"
/>
</div>
@@ -55,6 +55,18 @@ export default {
defaultEndTime: {
type: String,
default: ''
},
format: {
type: String,
default: 'yyyy-MM-dd HH:mm:ss'
}
},
computed: {
pickerType() {
return this.isDateType ? 'date' : 'datetime'
},
isDateType() {
return this.format === 'yyyy-MM-dd'
}
},
data() {
@@ -94,12 +106,14 @@ export default {
},
// 从时间字符串中提取时分秒部分
getTimePart(timeStr) {
if (this.isDateType) return ''
if (!timeStr) return '07:00:00'
const parts = timeStr.split(' ')
return parts.length > 1 ? parts[1] : '07:00:00'
},
// 将日期和时间组合
combineDateTime(dateStr, timeStr) {
if (this.isDateType) return dateStr
return `${dateStr} ${timeStr}`
},
handleTimeChange() {