班次配置页面

This commit is contained in:
z 2026-05-06 15:56:30 +08:00
parent d6df78be93
commit 79f612b789
24 changed files with 1000 additions and 724 deletions

View File

@ -1,3 +0,0 @@
# mes-majoys
美乐嘉mes

View File

@ -0,0 +1,51 @@
package com.ningxia.yunxi.chemmes.framework.mybatis.core.dataobject;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import lombok.Data;
import org.apache.ibatis.type.JdbcType;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* 基础实体对象不带逻辑删除
*
* @author 芋道源码
*/
@Data
public abstract class BaseDOWithoutLogic implements Serializable {
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
private LocalDateTime createTime;
/**
* 最后更新时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updateTime;
/**
* 创建者目前使用 SysUser id 编号
*
* 使用 String 类型的原因是未来可能会存在非数值的情况留好拓展性
*/
@TableField(fill = FieldFill.INSERT, jdbcType = JdbcType.VARCHAR)
private String creator;
/**
* 更新者目前使用 SysUser id 编号
*
* 使用 String 类型的原因是未来可能会存在非数值的情况留好拓展性
*/
@TableField(fill = FieldFill.INSERT_UPDATE, jdbcType = JdbcType.VARCHAR)
private String updater;
/**
* 是否删除
*/
private Boolean deleted;
}

View File

@ -1,6 +1,7 @@
package com.ningxia.yunxi.chemmes.framework.mybatis.core.handler;
import com.ningxia.yunxi.chemmes.framework.mybatis.core.dataobject.BaseDO;
import com.ningxia.yunxi.chemmes.framework.mybatis.core.dataobject.BaseDOWithoutLogic;
import com.ningxia.yunxi.chemmes.framework.web.core.util.WebFrameworkUtils;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
@ -19,10 +20,33 @@ public class DefaultDBFieldHandler implements MetaObjectHandler {
@Override
public void insertFill(MetaObject metaObject) {
if (Objects.nonNull(metaObject) && metaObject.getOriginalObject() instanceof BaseDO) {
BaseDO baseDO = (BaseDO) metaObject.getOriginalObject();
if (Objects.isNull(metaObject)) {
return;
}
LocalDateTime current = LocalDateTime.now();
LocalDateTime current = LocalDateTime.now();
Long userId = WebFrameworkUtils.getLoginUserId();
if (metaObject.getOriginalObject() instanceof BaseDO) {
BaseDO baseDO = (BaseDO) metaObject.getOriginalObject();
// 创建时间为空则以当前时间为插入时间
if (Objects.isNull(baseDO.getCreateTime())) {
baseDO.setCreateTime(current);
}
// 更新时间为空则以当前时间为更新时间
if (Objects.isNull(baseDO.getUpdateTime())) {
baseDO.setUpdateTime(current);
}
// 当前登录用户不为空创建人为空则当前登录用户为创建人
if (Objects.nonNull(userId) && Objects.isNull(baseDO.getCreator())) {
baseDO.setCreator(userId.toString());
}
// 当前登录用户不为空更新人为空则当前登录用户为更新人
if (Objects.nonNull(userId) && Objects.isNull(baseDO.getUpdater())) {
baseDO.setUpdater(userId.toString());
}
} else if (metaObject.getOriginalObject() instanceof BaseDOWithoutLogic) {
BaseDOWithoutLogic baseDO = (BaseDOWithoutLogic) metaObject.getOriginalObject();
// 创建时间为空则以当前时间为插入时间
if (Objects.isNull(baseDO.getCreateTime())) {
baseDO.setCreateTime(current);
@ -31,8 +55,6 @@ public class DefaultDBFieldHandler implements MetaObjectHandler {
if (Objects.isNull(baseDO.getUpdateTime())) {
baseDO.setUpdateTime(current);
}
Long userId = WebFrameworkUtils.getLoginUserId();
// 当前登录用户不为空创建人为空则当前登录用户为创建人
if (Objects.nonNull(userId) && Objects.isNull(baseDO.getCreator())) {
baseDO.setCreator(userId.toString());

View File

@ -41,8 +41,9 @@ public class ShiftConfigController {
@PostMapping("/create")
@Operation(summary = "创建班次循环配置")
@PreAuthorize("@ss.hasPermission('biz:shift-config:create')")
public CommonResult<Integer> createShiftConfig(@Valid @RequestBody ShiftConfigSaveReqVO createReqVO) {
return success(shiftConfigService.createShiftConfig(createReqVO));
public CommonResult<Boolean> createShiftConfig(@Valid @RequestBody ShiftConfigSaveReqVO createReqVO) {
shiftConfigService.createShiftConfig(createReqVO);
return success(true);
}
@PutMapping("/update")
@ -57,8 +58,8 @@ public class ShiftConfigController {
@Operation(summary = "删除班次循环配置")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('biz:shift-config:delete')")
public CommonResult<Boolean> deleteShiftConfig(@RequestParam("id") Integer id) {
shiftConfigService.deleteShiftConfig(id);
public CommonResult<Boolean> deleteShiftConfig(@RequestParam("chgClassType") String chgClassType) {
shiftConfigService.deleteShiftConfig(chgClassType);
return success(true);
}

View File

@ -1,10 +1,12 @@
package com.ningxia.yunxi.chemmes.module.biz.controller.admin.shiftconfig.vo;
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.shiftconfig.ShiftConfigDO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.time.LocalTime;
import java.util.List;
@Schema(description = "管理后台 - 班次循环配置新增/修改 Request VO")
@Data
@ -32,11 +34,11 @@ public class ShiftConfigSaveReqVO {
private String chgClassType;
@Schema(description = "开始时间", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "开始时间不能为空")
private LocalTime bgnDtime;
@Schema(description = "结束时间", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "结束时间不能为空")
private LocalTime endDtime;
@Schema(description = "明细集合")
private List<ShiftConfigDO> shiftConfigList;
}

View File

@ -91,5 +91,10 @@ public class ShiftResultController {
ExcelUtils.write(response, "班次结果.xls", "数据", ShiftResultRespVO.class,
BeanUtils.toBean(list, ShiftResultRespVO.class));
}
@PostMapping("/generate")
@Operation(summary = "生成班次结果")
@PreAuthorize("@ss.hasPermission('biz:shift-result:query')")
public CommonResult<Boolean> generate(@Valid ShiftResultPageReqVO pageReqVO) {
return shiftResultService.generate(pageReqVO);
}
}

View File

@ -1,5 +1,6 @@
package com.ningxia.yunxi.chemmes.module.biz.controller.admin.shiftresult.vo;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.ningxia.yunxi.chemmes.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@ -9,6 +10,7 @@ import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
import static com.ningxia.yunxi.chemmes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@ -20,16 +22,22 @@ public class ShiftResultPageReqVO extends PageParam {
@Schema(description = "状态(1启用 2 未启用)", example = "2")
private Integer enabledStatus;
/** 年月 */
@JsonProperty("years")
private Object years;
@Schema(description = "开始时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] bgnDtime;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date bgnDtime;
@Schema(description = "结束时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] endDtime;
@Schema(description = "排班月份")
private LocalDate month;
@Schema(description = "班次代码")
private String chgClassType;
}

View File

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ningxia.yunxi.chemmes.framework.mybatis.core.dataobject.BaseDO;
import com.ningxia.yunxi.chemmes.framework.mybatis.core.dataobject.BaseDOWithoutLogic;
import com.sun.xml.bind.v2.TODO;
import lombok.*;
@ -22,7 +23,7 @@ import java.time.LocalTime;
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ShiftConfigDO extends BaseDO {
public class ShiftConfigDO extends BaseDOWithoutLogic {
/**
* 自增字段

View File

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ningxia.yunxi.chemmes.framework.mybatis.core.dataobject.BaseDO;
import com.ningxia.yunxi.chemmes.framework.mybatis.core.dataobject.BaseDOWithoutLogic;
import com.sun.xml.bind.v2.TODO;
import lombok.*;
@ -23,7 +24,7 @@ import java.time.LocalDateTime;
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ShiftResultDO extends BaseDO {
public class ShiftResultDO extends BaseDOWithoutLogic {
/**
* 自增字段

View File

@ -1,6 +1,5 @@
package com.ningxia.yunxi.chemmes.module.biz.dal.mysql.shiftconfig;
import java.util.*;
import com.ningxia.yunxi.chemmes.framework.common.pojo.PageResult;
import com.ningxia.yunxi.chemmes.framework.mybatis.core.query.LambdaQueryWrapperX;
@ -21,7 +20,11 @@ public interface ShiftConfigMapper extends BaseMapperX<ShiftConfigDO> {
return selectPage(reqVO, new LambdaQueryWrapperX<ShiftConfigDO>()
.eqIfPresent(ShiftConfigDO::getEnabledStatus, reqVO.getEnabledStatus())
.eqIfPresent(ShiftConfigDO::getChgClassType, reqVO.getChgClassType())
.orderByDesc(ShiftConfigDO::getId));
.orderByAsc(ShiftConfigDO::getSeqNo));
}
default void deleteByChgClassType(String chgClassType) {
delete(new LambdaQueryWrapperX<ShiftConfigDO>()
.eq(ShiftConfigDO::getChgClassType, chgClassType));
}
}

View File

@ -2,6 +2,8 @@ package com.ningxia.yunxi.chemmes.module.biz.dal.mysql.shiftresult;
import java.util.*;
import cn.hutool.core.util.ObjectUtil;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.ningxia.yunxi.chemmes.framework.common.pojo.PageResult;
import com.ningxia.yunxi.chemmes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.ningxia.yunxi.chemmes.framework.mybatis.core.mapper.BaseMapperX;
@ -18,12 +20,14 @@ import com.ningxia.yunxi.chemmes.module.biz.controller.admin.shiftresult.vo.*;
public interface ShiftResultMapper extends BaseMapperX<ShiftResultDO> {
default PageResult<ShiftResultDO> selectPage(ShiftResultPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<ShiftResultDO>()
.eqIfPresent(ShiftResultDO::getEnabledStatus, reqVO.getEnabledStatus())
.betweenIfPresent(ShiftResultDO::getBgnDtime, reqVO.getBgnDtime())
.betweenIfPresent(ShiftResultDO::getEndDtime, reqVO.getEndDtime())
.eqIfPresent(ShiftResultDO::getMonth, reqVO.getMonth())
.orderByDesc(ShiftResultDO::getId));
LambdaQueryWrapperX<ShiftResultDO> wrapper = new LambdaQueryWrapperX<>();
wrapper.orderByAsc(ShiftResultDO::getBgnDtime);
if (ObjectUtil.isNotEmpty(reqVO.getYears())) {
wrapper.likeRight(ShiftResultDO::getMonth, reqVO.getYears().toString());
}
return selectPage(reqVO, wrapper);
}
}

View File

@ -20,7 +20,7 @@ public interface ShiftConfigService {
* @param createReqVO 创建信息
* @return 编号
*/
Integer createShiftConfig(@Valid ShiftConfigSaveReqVO createReqVO);
void createShiftConfig(@Valid ShiftConfigSaveReqVO createReqVO);
/**
* 更新班次循环配置
@ -32,9 +32,9 @@ public interface ShiftConfigService {
/**
* 删除班次循环配置
*
* @param id 编号
* @param chgClassType 类型
*/
void deleteShiftConfig(Integer id);
void deleteShiftConfig(String chgClassType);
/**
* 获得班次循环配置

View File

@ -1,5 +1,7 @@
package com.ningxia.yunxi.chemmes.module.biz.service.shiftconfig;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.ningxia.yunxi.chemmes.framework.common.pojo.PageResult;
import com.ningxia.yunxi.chemmes.framework.common.util.object.BeanUtils;
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.shiftconfig.vo.ShiftConfigPageReqVO;
@ -10,6 +12,7 @@ import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.List;
/**
* 班次循环配置 Service 实现类
@ -24,12 +27,21 @@ public class ShiftConfigServiceImpl implements ShiftConfigService {
private ShiftConfigMapper shiftConfigMapper;
@Override
public Integer createShiftConfig(ShiftConfigSaveReqVO createReqVO) {
// 插入
ShiftConfigDO shiftConfig = BeanUtils.toBean(createReqVO, ShiftConfigDO.class);
shiftConfigMapper.insert(shiftConfig);
public void createShiftConfig(ShiftConfigSaveReqVO createReqVO) {
List<ShiftConfigDO> entityList = createReqVO.getShiftConfigList();
if (ObjectUtil.isEmpty(entityList)) {
return;
}
//删除旧数据
shiftConfigMapper.deleteByChgClassType(createReqVO.getChgClassType());
// 批量设置属性并保存新数据
entityList.forEach(entity -> {
entity.setChgClassType(createReqVO.getChgClassType());
});
shiftConfigMapper.insertBatch(entityList);
// 返回
return shiftConfig.getId();
}
@Override
@ -42,11 +54,9 @@ public class ShiftConfigServiceImpl implements ShiftConfigService {
}
@Override
public void deleteShiftConfig(Integer id) {
// 校验存在
validateShiftConfigExists(id);
// 删除
shiftConfigMapper.deleteById(id);
public void deleteShiftConfig(String chgClassType) {
shiftConfigMapper.deleteByChgClassType(chgClassType);
}
private void validateShiftConfigExists(Integer id) {

View File

@ -2,6 +2,8 @@ package com.ningxia.yunxi.chemmes.module.biz.service.shiftresult;
import java.util.*;
import javax.validation.*;
import com.ningxia.yunxi.chemmes.framework.common.pojo.CommonResult;
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.shiftresult.vo.*;
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.shiftresult.ShiftResultDO;
import com.ningxia.yunxi.chemmes.framework.common.pojo.PageResult;
@ -52,4 +54,5 @@ public interface ShiftResultService {
*/
PageResult<ShiftResultDO> getShiftResultPage(ShiftResultPageReqVO pageReqVO);
CommonResult<Boolean> generate(ShiftResultPageReqVO pageReqVO);
}

View File

@ -1,15 +1,31 @@
package com.ningxia.yunxi.chemmes.module.biz.service.shiftresult;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ningxia.yunxi.chemmes.framework.common.pojo.CommonResult;
import com.ningxia.yunxi.chemmes.framework.common.pojo.PageResult;
import com.ningxia.yunxi.chemmes.framework.common.util.object.BeanUtils;
import com.ningxia.yunxi.chemmes.framework.tenant.core.context.TenantContextHolder;
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.shiftresult.vo.ShiftResultPageReqVO;
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.shiftresult.vo.ShiftResultSaveReqVO;
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.shiftconfig.ShiftConfigDO;
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.shiftresult.ShiftResultDO;
import com.ningxia.yunxi.chemmes.module.biz.dal.mysql.shiftconfig.ShiftConfigMapper;
import com.ningxia.yunxi.chemmes.module.biz.dal.mysql.shiftresult.ShiftResultMapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.List;
import static com.ningxia.yunxi.chemmes.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
/**
* 班次结果 Service 实现类
@ -22,6 +38,8 @@ public class ShiftResultServiceImpl implements ShiftResultService {
@Resource
private ShiftResultMapper shiftResultMapper;
@Resource
private ShiftConfigMapper shiftConfigMapper;
@Override
public Integer createShiftResult(ShiftResultSaveReqVO createReqVO) {
@ -65,4 +83,96 @@ public class ShiftResultServiceImpl implements ShiftResultService {
return shiftResultMapper.selectPage(pageReqVO);
}
@Resource
private DataSource dataSource;
@Override
public CommonResult<Boolean> generate(ShiftResultPageReqVO pageReqVO) {
// 查询班次配置
LambdaQueryWrapper<ShiftConfigDO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ShiftConfigDO::getChgClassType, pageReqVO.getChgClassType());
queryWrapper.orderByAsc(ShiftConfigDO::getSeqNo);
List<ShiftConfigDO> configList = shiftConfigMapper.selectList(queryWrapper);
if (ObjectUtil.isEmpty(configList)) {
return CommonResult.error(400, "该倒班类型" + ("1".equals(pageReqVO.getChgClassType()) ? "四班三倒" : "三班两倒") + "未配置班次信息");
}
// 确定每天的班次数量和工作小时数
int shiftsPerDay = "1".equals(pageReqVO.getChgClassType()) ? 3 : ("2".equals(pageReqVO.getChgClassType()) ? 2 : 0);
int shiftHour = shiftsPerDay == 3 ? 8 : (shiftsPerDay == 2 ? 12 : 0);
if (shiftsPerDay == 0) {
return CommonResult.error(400, "不支持的班次类型");
}
// 删除全表数据
shiftResultMapper.delete(null);
Long userId = getLoginUserId(); // 用户ID
Long tenantId = TenantContextHolder.getTenantId(); // 租户ID
// 使用 JDBC 原生批量插入
String sql = "INSERT INTO tba_shift_result (class_group, class_rate, bgn_dtime, end_dtime, month, shift_hour, create_time, update_time,creator,updater,tenant_id) VALUES (?, ?, ?, ?, ?, ?, NOW(), NOW(),?,?,?)";
int batchSize = 1000;
int totalRecords = 366 * shiftsPerDay;
try (Connection conn = dataSource.getConnection();
PreparedStatement ps = conn.prepareStatement(sql)) {
conn.setAutoCommit(false);
LocalDate startDate = pageReqVO.getBgnDtime().toInstant().atZone(java.time.ZoneOffset.systemDefault()).toLocalDate();
int configSize = configList.size();
int batchCount = 0;
for (int day = 0; day < 366; day++) {
LocalDate currentDate = startDate.plusDays(day);
LocalDate month = currentDate.withDayOfMonth(1);
for (int shiftIndex = 0; shiftIndex < shiftsPerDay; shiftIndex++) {
int configIndex = (day * shiftsPerDay + shiftIndex) % configSize;
ShiftConfigDO config = configList.get(configIndex);
ps.setString(1, config.getClassGroup());
ps.setString(2, config.getClassRate());
ps.setObject(3, currentDate.atTime(config.getBgnDtime()));
ps.setObject(4, combineDateTime(currentDate, config.getEndDtime()));
ps.setObject(5, month);
ps.setInt(6, shiftHour);
ps.setLong(7, userId); // creator
ps.setLong(8, userId); // updater
ps.setLong(9, tenantId); // tenant_id
ps.addBatch();
batchCount++;
if (batchCount >= batchSize) {
ps.executeBatch();
conn.commit();
batchCount = 0;
}
}
}
// 执行剩余的批次
if (batchCount > 0) {
ps.executeBatch();
conn.commit();
}
} catch (Exception e) {
return CommonResult.error(500, "批量插入失败: " + e.getMessage());
}
return CommonResult.success(true);
}
/**
* 组合日期和时间处理结束时间为0点的情况
*/
private LocalDateTime combineDateTime(LocalDate date, LocalTime localTime) {
LocalDateTime result = date.atTime(localTime);
// 只有结束时间是 0 点时日期才自动加一天
if (localTime.getHour() == 0 && localTime.getMinute() == 0) {
result = result.plusDays(1);
}
return result;
}
}

View File

@ -13,8 +13,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>16</source>
<target>16</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>

View File

@ -8,8 +8,9 @@ export interface ShiftConfigVO {
remark: string
seqNo: number
chgClassType: string
bgnDtime: localtime
endDtime: localtime
bgnDtime: Date
endDtime: Date
shiftConfigList:[]
}
// 查询班次循环配置分页
@ -33,11 +34,16 @@ export const updateShiftConfig = async (data: ShiftConfigVO) => {
}
// 删除班次循环配置
export const deleteShiftConfig = async (id: number) => {
return await request.delete({ url: `/biz/shift-config/delete?id=` + id })
export const deleteShiftConfig = async (chgClassType: string) => {
return await request.delete({ url: `/biz/shift-config/delete?chgClassType=` + chgClassType })
}
// 导出班次循环配置 Excel
export const exportShiftConfig = async (params) => {
return await request.download({ url: `/biz/shift-config/export-excel`, params })
}
// 生成排班结果
export const generateShiftSchedule = async (params) => {
return await request.post({ url: `/biz/shift-config/generate`, params })
}

View File

@ -9,7 +9,7 @@ export interface ShiftResultVO {
bgnDtime: Date
endDtime: Date
shiftHour: number
month: localdate
month: Date
}
// 查询班次结果分页
@ -41,3 +41,8 @@ export const deleteShiftResult = async (id: number) => {
export const exportShiftResult = async (params) => {
return await request.download({ url: `/biz/shift-result/export-excel`, params })
}
// 生成排班结果
export const generateShiftSchedule = async (params) => {
return await request.post({ url: `/biz/shift-result/generate`, params })
}

View File

@ -228,6 +228,7 @@ export enum DICT_TYPE {
MAT_TYPE='mat_type', // 物料类型
MAT_UNIT='mat_unit', // 物料单位
SHIFT_WORK_TYPE='shift_work_type', // 倒班类型
SHIFT_SCHEDULE='shift_schedule', // 班组
TEAM_OR_GROUP='team_or_group', // 班组
DEVICE_TYPE='device_type', // 设备类型
DEVICE_STATUS='device_status', // 设备状态

View File

@ -195,12 +195,11 @@ export function formatPast2(ms) {
/**
* element plus Formatter 使 YYYY-MM-DD HH:mm:ss
*
* @param row
* @param column
* @param _row
* @param _column
* @param cellValue
*/
// @ts-ignore
export const dateFormatter = (row, column, cellValue): string => {
export const dateFormatter = (_row, _column, cellValue): string => {
if (!cellValue) {
return ''
}
@ -210,12 +209,11 @@ export const dateFormatter = (row, column, cellValue): string => {
/**
* element plus Formatter 使 YYYY-MM-DD
*
* @param row
* @param column
* @param _row
* @param _column
* @param cellValue
*/
// @ts-ignore
export const dateFormatter2 = (row, column, cellValue) => {
export const dateFormatter2 = (_row, _column, cellValue) => {
if (!cellValue) {
return
}
@ -224,18 +222,24 @@ export const dateFormatter2 = (row, column, cellValue) => {
/**
* element plus Formatter 使 YYYY-MM
*
* @param row
* @param column
* @param _row
* @param _column
* @param cellValue
*/
// @ts-ignore
export const dateFormatter3 = (row, column, cellValue) => {
export const dateFormatter3 = (_row, _column, cellValue) => {
if (!cellValue) {
return
}
return formatDate(cellValue, 'YYYY-MM')
}
export const dateFormatter4 = (_row, _column, cellValue) => {
if (!cellValue) {
return
}
return formatDate(cellValue, 'YYYY-MM-DD HH:mm')
}
/**
* 时间为00:00:00
* @param param

View File

@ -150,7 +150,6 @@
<script setup lang="ts">
import { getStrDictOptions, DICT_TYPE } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download'
import * as CustomerApi from '@/api/biz/customer'
import CustomerForm from './CustomerForm.vue'

View File

@ -1,5 +1,5 @@
<template>
<Dialog :title="dialogTitle" v-model="dialogVisible">
<Dialog :title="dialogTitle" v-model="dialogVisible" width="1000px" @close="cancel" >
<el-form
ref="formRef"
:model="formData"
@ -7,31 +7,13 @@
label-width="100px"
v-loading="formLoading"
>
<el-form-item label="班组(甲 乙 丙 丁)" prop="classGroup">
<el-input v-model="formData.classGroup" placeholder="请输入班组(甲 乙 丙 丁)" />
</el-form-item>
<el-form-item label="班次( 1 白 2 中 3 夜)" prop="classRate">
<el-input v-model="formData.classRate" placeholder="请输入班次( 1 白 2 中 3 夜)" />
</el-form-item>
<el-form-item label="状态(1启用 2 未启用)" prop="enabledStatus">
<el-radio-group v-model="formData.enabledStatus">
<el-radio
v-for="dict in getIntDictOptions(DICT_TYPE.SYSTEM_STATUS)"
:key="dict.value"
:label="dict.value"
>
{{ dict.label }}
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="formData.remark" placeholder="请输入备注" />
</el-form-item>
<el-form-item label="序列号" prop="seqNo">
<el-input v-model="formData.seqNo" placeholder="请输入序列号" />
</el-form-item>
<el-form-item label="倒班类型(1 四班三倒 2 三班两到)" prop="chgClassType">
<el-select v-model="formData.chgClassType" placeholder="请选择倒班类型(1 四班三倒 2 三班两到)">
<el-form-item label="倒班类型" prop="chgClassType">
<el-select
v-model="formData.chgClassType"
placeholder="请选择倒班类型"
clearable
class="!w-240px"
>
<el-option
v-for="dict in getStrDictOptions(DICT_TYPE.SHIFT_WORK_TYPE)"
:key="dict.value"
@ -39,33 +21,129 @@
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="开始时间" prop="bgnDtime">
<el-date-picker
v-model="formData.bgnDtime"
type="date"
value-format="x"
placeholder="选择开始时间"
/>
</el-form-item>
<el-form-item label="结束时间" prop="endDtime">
<el-date-picker
v-model="formData.endDtime"
type="date"
value-format="x"
placeholder="选择结束时间"
/>
</el-form-item>
</el-form-item>
<el-card class="hl-card-info">
<template #header>
<div class="hl-card-info-icona"></div><span class="hl-card-info-text">班次明细</span>
<el-button type="primary" size="large" @click="onAddItem" style="margin-left: 20px">新增</el-button>
</template>
<el-row>
<el-col>
<el-card class="hl-incard">
<el-form ref="OrderYsDetailSubFormRef" :model="formData.shiftConfigList" label-width="0" >
<el-table :data="formData.shiftConfigList" class="hl-table" >
<el-table-column type="index" label="序号" align="center" min-width="60" fixed />
<el-table-column align="center" label="班次">
<template #default="scope">
<el-form-item prop="classRate" >
<el-select
v-model="scope.row.classRate"
placeholder="请选择"
clearable
>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.SHIFT_SCHEDULE)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
</template>
</el-table-column>
<el-table-column align="center" label="班组">
<template #default="scope">
<el-form-item prop="classGroup" >
<el-select
v-model="scope.row.classGroup"
placeholder="请选择"
clearable
>
<el-option
v-for="dict in getStrDictOptions(DICT_TYPE.TEAM_OR_GROUP)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
</template>
</el-table-column>
<el-table-column label="开始时间" prop="bgnDtime" align="center">
<template #default="scope">
<el-form-item prop="bgnDtime">
<el-time-picker
v-model="scope.row.bgnDtime"
placeholder="请选择"
clearable
format="HH:mm"
value-format="HH:mm"
class="!w-1/1"
/>
</el-form-item>
</template>
</el-table-column>
<el-table-column label="结束时间" prop="endDtime" align="center">
<template #default="scope">
<el-form-item prop="endDtime">
<el-time-picker
v-model="scope.row.endDtime"
placeholder="请选择"
clearable
format="HH:mm"
value-format="HH:mm"
class="!w-1/1"
/>
</el-form-item>
</template>
</el-table-column>
<el-table-column label="序列号" prop="seqNo" align="center" >
<template #default="scope">
<el-form-item prop="seqNo">
<el-input-number
v-model="scope.row.seqNo"
placeholder="请输入"
:min="0"
controls-position="right"
class="!w-1/1"
/>
</el-form-item>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="120" fixed="right">
<template #default="scope">
<el-button link type="danger" size="small" @click.prevent="onDeleteItem(scope.$index)" >
删除
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
</el-form>
</el-card>
</el-col>
</el-row>
</el-card>
</el-form>
<template #footer>
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
<el-button @click="cancel"> </el-button>
</template>
</Dialog>
</template>
<script setup lang="ts">
import { getIntDictOptions, getStrDictOptions, DICT_TYPE } from '@/utils/dict'
import * as ShiftConfigApi from '@/api/biz/shiftconfig'
import {DICT_TYPE, getIntDictOptions, getStrDictOptions} from "@/utils/dict";
const { t } = useI18n() //
const message = useMessage() //
@ -84,13 +162,17 @@ const formData = ref({
chgClassType: undefined,
bgnDtime: undefined,
endDtime: undefined,
shiftConfigList:[]
})
const formRules = reactive({
bgnDtime: [{ required: true, message: '开始时间不能为空', trigger: 'blur' }],
endDtime: [{ required: true, message: '结束时间不能为空', trigger: 'blur' }],
chgClassType: [{ required: true, message: '倒班类型不能为空', trigger: 'change' }]
})
const formRef = ref() // Ref
const cancel = async () => {
dialogVisible.value = false
emit('success')
}
/** 打开弹窗 */
const open = async (type: string, id?: number) => {
dialogVisible.value = true
@ -101,7 +183,9 @@ const open = async (type: string, id?: number) => {
if (id) {
formLoading.value = true
try {
formData.value = await ShiftConfigApi.getShiftConfig(id)
const data = await ShiftConfigApi.getShiftConfig(id)
formData.value = data
} finally {
formLoading.value = false
}
@ -132,6 +216,23 @@ const submitForm = async () => {
formLoading.value = false
}
}
/** 新增子项按钮操作 */
const onAddItem = () => {
const row = {
id: undefined,
classGroup: undefined,
classRate:undefined,
bgnDtime: undefined,
endDtime: undefined,
seqNo: undefined,
}
formData.value.shiftConfigList.push(row)
}
/** 删除子项操作 */
const onDeleteItem = async (index) => {
formData.value.shiftConfigList.splice(index, 1)
}
/** 重置表单 */
const resetForm = () => {
@ -145,6 +246,7 @@ const resetForm = () => {
chgClassType: undefined,
bgnDtime: undefined,
endDtime: undefined,
shiftConfigList:[],
}
formRef.value?.resetFields()
}

View File

@ -6,27 +6,12 @@
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="68px"
label-width="80px"
>
<el-form-item label="状态(1启用 2 未启用)" prop="enabledStatus">
<el-select
v-model="queryParams.enabledStatus"
placeholder="请选择状态(1启用 2 未启用)"
clearable
class="!w-240px"
>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.SYSTEM_STATUS)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="倒班类型(1 四班三倒 2 三班两到)" prop="chgClassType">
<el-form-item label="倒班类型" prop="chgClassType">
<el-select
v-model="queryParams.chgClassType"
placeholder="请选择倒班类型(1 四班三倒 2 三班两到)"
placeholder="请选择倒班类型"
clearable
class="!w-240px"
>
@ -45,78 +30,53 @@
type="primary"
plain
@click="openForm('create')"
v-hasPermi="['biz:shift-config:create']"
>
<Icon icon="ep:plus" class="mr-5px" /> 新增
</el-button>
<el-button
type="success"
type="danger"
plain
@click="handleExport"
:loading="exportLoading"
v-hasPermi="['biz:shift-config:export']"
@click="handleDelete"
:disabled="!queryParams.chgClassType"
>
<Icon icon="ep:download" class="mr-5px" /> 导出
<Icon icon="ep:delete" class="mr-5px" /> 删除
</el-button>
</el-form-item>
</el-form>
</ContentWrap>
<!-- 列表 -->
<ContentWrap>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
<el-table-column label="自增字段" align="center" prop="id" />
<el-table-column
label="创建时间"
align="center"
prop="createTime"
:formatter="dateFormatter"
width="180px"
/>
<el-table-column label="班组(甲 乙 丙 丁)" align="center" prop="classGroup">
<template #default="scope">
<dict-tag :type="DICT_TYPE.TEAM_OR_GROUP" :value="scope.row.classGroup" />
</template>
</el-table-column>
<el-table-column label="班次( 1 白 2 中 3 夜)" align="center" prop="classRate">
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true" border>
<el-table-column type="index" label="序号" align="center" min-width="60" />
<el-table-column label="班次" align="center" prop="classRate">
<template #default="scope">
<dict-tag :type="DICT_TYPE.SHIFT_SCHEDULE" :value="scope.row.classRate" />
</template>
</el-table-column>
<el-table-column label="状态(1启用 2 未启用)" align="center" prop="enabledStatus">
<el-table-column label="班组" align="center" prop="classGroup">
<template #default="scope">
<dict-tag :type="DICT_TYPE.SYSTEM_STATUS" :value="scope.row.enabledStatus" />
<dict-tag :type="DICT_TYPE.TEAM_OR_GROUP" :value="scope.row.classGroup" />
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="序列号" align="center" prop="seqNo" />
<el-table-column label="倒班类型(1 四班三倒 2 三班两到)" align="center" prop="chgClassType">
<el-table-column label="倒班类型" align="center" prop="chgClassType">
<template #default="scope">
<dict-tag :type="DICT_TYPE.SHIFT_WORK_TYPE" :value="scope.row.chgClassType" />
</template>
</el-table-column>
<el-table-column label="开始时间" align="center" prop="bgnDtime" />
<el-table-column label="结束时间" align="center" prop="endDtime" />
<el-table-column label="操作" align="center">
<el-table-column label="开始时间" align="center" prop="bgnDtime">
<template #default="scope">
<el-button
link
type="primary"
@click="openForm('update', scope.row.id)"
v-hasPermi="['biz:shift-config:update']"
>
编辑
</el-button>
<el-button
link
type="danger"
@click="handleDelete(scope.row.id)"
v-hasPermi="['biz:shift-config:delete']"
>
删除
</el-button>
<span>{{ formatTime(scope.row.bgnDtime) }}</span>
</template>
</el-table-column>
<el-table-column label="结束时间" align="center" prop="endDtime">
<template #default="scope">
<span>{{ formatTime(scope.row.endDtime) }}</span>
</template>
</el-table-column>
<el-table-column label="序列号" align="center" prop="seqNo" />
</el-table>
<!-- 分页 -->
<Pagination
@ -132,18 +92,17 @@
</template>
<script setup lang="ts">
import { getIntDictOptions, getStrDictOptions, DICT_TYPE } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download'
import { getStrDictOptions, DICT_TYPE } from '@/utils/dict'
import * as ShiftConfigApi from '@/api/biz/shiftconfig'
import ShiftConfigForm from './ShiftConfigForm.vue'
defineOptions({ name: 'ShiftConfig' })
defineOptions({ name: 'shiftConfig' })
const message = useMessage() //
const { t } = useI18n() //
const loading = ref(true) //
const loading = ref(false) //
const list = ref([]) //
const total = ref(0) //
const queryParams = reactive({
@ -153,7 +112,6 @@ const queryParams = reactive({
chgClassType: undefined,
})
const queryFormRef = ref() //
const exportLoading = ref(false) //
/** 查询列表 */
const getList = async () => {
@ -186,35 +144,47 @@ const openForm = (type: string, id?: number) => {
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
const handleDelete = async () => {
if (queryParams.chgClassType){
try {
//
await message.delConfirm()
//
await ShiftConfigApi.deleteShiftConfig(id)
await ShiftConfigApi.deleteShiftConfig(queryParams.chgClassType)
message.success(t('common.delSuccess'))
//
await getList()
} catch {}
}
}
/** 导出按钮操作 */
const handleExport = async () => {
try {
//
await message.exportConfirm()
//
exportLoading.value = true
const data = await ShiftConfigApi.exportShiftConfig(queryParams)
download.excel(data, '班次循环配置.xls')
} catch {
} finally {
exportLoading.value = false
/** 格式化时间显示 HH:mm **/
const formatTime = (time: any) => {
if (!time) return ''
// [, ]
if (Array.isArray(time)) {
const hours = String(time[0] || 0).padStart(2, '0')
const minutes = String(time[1] || 0).padStart(2, '0')
return `${hours}:${minutes}`
}
//
const timeStr = String(time)
// HH:mm
if (timeStr.includes('T') || timeStr.includes('-')) {
const match = timeStr.match(/(\d{2}):(\d{2})(?::\d{2})?/)
if (match) return `${match[1]}:${match[2]}`
}
// HH:mm
if (timeStr.includes(':')) {
return timeStr.substring(0, 5)
}
return timeStr
}
/** 初始化 **/
onMounted(() => {
getList()
// getList()
})
</script>

View File

@ -1,146 +1,110 @@
<template>
<ContentWrap>
<!-- 搜索工作栏 -->
<el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="68px"
>
<el-form-item label="状态(1启用 2 未启用)" prop="enabledStatus">
<el-select
v-model="queryParams.enabledStatus"
placeholder="请选择状态(1启用 2 未启用)"
clearable
class="!w-240px"
>
<el-option
v-for="dict in getIntDictOptions(DICT_TYPE.SYSTEM_STATUS)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="开始时间" prop="bgnDtime">
<el-date-picker
v-model="queryParams.bgnDtime"
value-format="YYYY-MM-DD HH:mm:ss"
type="daterange"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="结束时间" prop="endDtime">
<el-date-picker
v-model="queryParams.endDtime"
value-format="YYYY-MM-DD HH:mm:ss"
type="daterange"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="排班月份" prop="month">
<el-input
v-model="queryParams.month"
placeholder="请输入排班月份"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item>
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
<el-button
type="primary"
plain
@click="openForm('create')"
v-hasPermi="['biz:shift-result:create']"
>
<Icon icon="ep:plus" class="mr-5px" /> 新增
</el-button>
<el-button
type="success"
plain
@click="handleExport"
:loading="exportLoading"
v-hasPermi="['biz:shift-result:export']"
>
<Icon icon="ep:download" class="mr-5px" /> 导出
</el-button>
</el-form-item>
<el-form class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="80px">
<el-row :gutter="16">
<el-col :span="6">
<el-form-item label="排班年月">
<el-date-picker
v-model="queryParams.years"
value-format="YYYY-MM"
type="month"
placeholder="请选择排班年月"
clearable
class="!w-240px"
/>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item>
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="16">
<el-col :span="6">
<el-form-item label="倒班类型">
<el-select
v-model="queryParams.chgClassType"
placeholder="请选择倒班类型"
clearable
class="!w-240px"
>
<el-option
v-for="dict in getStrDictOptions(DICT_TYPE.SHIFT_WORK_TYPE)"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="开始日期">
<el-date-picker
v-model="queryParams.bgnDtime"
value-format="YYYY-MM-DD"
type="date"
placeholder="请选择开始日期"
clearable
class="!w-240px"
:disabled-date="disabledDate"
/>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item>
<el-button
type="success"
@click="handleGenerate"
:loading="generatedLoading"
:disabled="generatedLoading"
>
生成排班结果
</el-button>
</el-form-item>
</el-col>
</el-row>
</el-form>
</ContentWrap>
<!-- 列表 -->
<ContentWrap>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
<el-table-column label="自增字段" align="center" prop="id" />
<el-table-column
label="创建时间"
align="center"
prop="createTime"
:formatter="dateFormatter"
width="180px"
/>
<el-table-column label="班组(甲 乙 丙 丁)" align="center" prop="classGroup">
<template #default="scope">
<dict-tag :type="DICT_TYPE.TEAM_OR_GROUP" :value="scope.row.classGroup" />
</template>
</el-table-column>
<el-table-column label="班次( 1 白 2 中 3 夜)" align="center" prop="classRate">
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true" border>
<el-table-column type="index" label="序号" align="center" min-width="60" />
<el-table-column label="班次" align="center" prop="classRate">
<template #default="scope">
<dict-tag :type="DICT_TYPE.SHIFT_SCHEDULE" :value="scope.row.classRate" />
</template>
</el-table-column>
<el-table-column label="状态(1启用 2 未启用)" align="center" prop="enabledStatus">
<el-table-column label="班组" align="center" prop="classGroup">
<template #default="scope">
<dict-tag :type="DICT_TYPE.SYSTEM_STATUS" :value="scope.row.enabledStatus" />
<dict-tag :type="DICT_TYPE.TEAM_OR_GROUP" :value="scope.row.classGroup" />
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column
label="开始时间"
align="center"
prop="bgnDtime"
:formatter="dateFormatter"
:formatter="dateFormatter4"
width="180px"
/>
<el-table-column
label="结束时间"
align="center"
prop="endDtime"
:formatter="dateFormatter"
:formatter="dateFormatter4"
width="180px"
/>
<el-table-column label="小时数" align="center" prop="shiftHour" />
<el-table-column label="排班月份" align="center" prop="month" />
<el-table-column label="操作" align="center">
<template #default="scope">
<el-button
link
type="primary"
@click="openForm('update', scope.row.id)"
v-hasPermi="['biz:shift-result:update']"
>
编辑
</el-button>
<el-button
link
type="danger"
@click="handleDelete(scope.row.id)"
v-hasPermi="['biz:shift-result:delete']"
>
删除
</el-button>
</template>
</el-table-column>
<el-table-column label="排班月份" align="center" prop="month" :formatter="dateFormatter3" />
</el-table>
<!-- 分页 -->
<Pagination
@ -156,30 +120,46 @@
</template>
<script setup lang="ts">
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download'
import { getStrDictOptions, DICT_TYPE } from '@/utils/dict'
import { dateFormatter3, dateFormatter4} from '@/utils/formatTime'
import * as ShiftResultApi from '@/api/biz/shiftresult'
import ShiftResultForm from './ShiftResultForm.vue'
defineOptions({ name: 'ShiftResult' })
const message = useMessage() //
const { t } = useI18n() //
const loading = ref(true) //
const loading = ref(false) //
const list = ref([]) //
const total = ref(0) //
const generatedLoading = ref(false) //
/** 获取当天日期 YYYY-MM-DD */
const getTodayDate = () => {
const now = new Date()
return `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')}`
}
/** 获取当月 YYYY-MM */
const getCurrentMonth = () => {
const now = new Date()
return `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}`
}
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
enabledStatus: undefined,
bgnDtime: [],
endDtime: [],
month: undefined,
years: getCurrentMonth(),
chgClassType: undefined,
bgnDtime: getTodayDate(),
})
const queryFormRef = ref() //
const exportLoading = ref(false) //
/** 禁用今天之前的日期 */
const disabledDate = (time: Date) => {
return time.getTime() < Date.now() - 8.64e7
}
/** 查询列表 */
const getList = async () => {
@ -205,42 +185,33 @@ const resetQuery = () => {
handleQuery()
}
/** 添加/修改操作 */
const formRef = ref()
const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
/** 生成排班结果按钮操作 */
const handleGenerate = async () => {
if (!queryParams.chgClassType) {
message.warning('请先选择倒班类型')
return
}
if (!queryParams.bgnDtime) {
message.warning('请先选择开始日期')
return
}
try {
//
await message.delConfirm()
//
await ShiftResultApi.deleteShiftResult(id)
message.success(t('common.delSuccess'))
//
await getList()
} catch {}
}
/** 导出按钮操作 */
const handleExport = async () => {
try {
//
await message.exportConfirm()
//
exportLoading.value = true
const data = await ShiftResultApi.exportShiftResult(queryParams)
download.excel(data, '班次结果.xls')
generatedLoading.value = true
await ShiftResultApi.generateShiftSchedule({
chgClassType: queryParams.chgClassType,
bgnDtime: queryParams.bgnDtime
})
message.success('排班结果生成成功')
getList()
} catch {
} finally {
exportLoading.value = false
generatedLoading.value = false
}
}
/** 初始化 **/
onMounted(() => {
getList()
// getList()
})
</script>