mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-09-17 10:56:39 +08:00
commit
013d1c237b
@ -1,9 +1,11 @@
|
||||
package net.lab1024.sa.admin.module.business.goods.domain.form;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import net.lab1024.sa.admin.module.business.goods.constant.GoodsStatusEnum;
|
||||
import net.lab1024.sa.base.common.domain.PageParam;
|
||||
import net.lab1024.sa.base.common.json.deserializer.DictValueVoDeserializer;
|
||||
import net.lab1024.sa.base.common.swagger.SchemaEnum;
|
||||
import net.lab1024.sa.base.common.validator.enumeration.CheckEnum;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
@ -32,6 +34,7 @@ public class GoodsQueryForm extends PageParam {
|
||||
private Integer goodsStatus;
|
||||
|
||||
@Schema(description = "产地")
|
||||
@JsonDeserialize(using = DictValueVoDeserializer.class)
|
||||
private String place;
|
||||
|
||||
@Schema(description = "上架状态")
|
||||
|
@ -199,7 +199,7 @@ public class GoodsService {
|
||||
GoodsExcelVO.builder()
|
||||
.goodsStatus(SmartEnumUtil.getEnumDescByValue(e.getGoodsStatus(), GoodsStatusEnum.class))
|
||||
.categoryName(categoryQueryService.queryCategoryName(e.getCategoryId()))
|
||||
.place(dictCacheService.selectValueNameByValueCode(e.getPlace()))
|
||||
.place(Arrays.stream(e.getPlace().split(",")).map(code -> dictCacheService.selectValueNameByValueCode(code)).collect(Collectors.joining(",")))
|
||||
.price(e.getPrice())
|
||||
.goodsName(e.getGoodsName())
|
||||
.remark(e.getRemark())
|
||||
|
@ -114,4 +114,14 @@ public interface NoticeDao extends BaseMapper<NoticeEntity> {
|
||||
*/
|
||||
void updateViewRecord(@Param("noticeId")Long noticeId, @Param("employeeId")Long requestEmployeeId,@Param("ip") String ip, @Param("userAgent")String userAgent);
|
||||
|
||||
/**
|
||||
* 更新 浏览量
|
||||
*
|
||||
* @param noticeId 通知 id
|
||||
* @param pageViewCountIncrement 页面浏览量的增量
|
||||
* @param userViewCountIncrement 用户浏览量的增量
|
||||
*/
|
||||
void updateViewCount(@Param("noticeId")Long noticeId,@Param("pageViewCountIncrement") Integer pageViewCountIncrement, @Param("userViewCountIncrement")Integer userViewCountIncrement);
|
||||
|
||||
|
||||
}
|
||||
|
@ -52,10 +52,10 @@ public class NoticeEmployeeService {
|
||||
public ResponseDTO<PageResult<NoticeEmployeeVO>> queryList(Long requestEmployeeId, NoticeEmployeeQueryForm noticeEmployeeQueryForm) {
|
||||
Page<?> page = SmartPageUtil.convert2PageQuery(noticeEmployeeQueryForm);
|
||||
|
||||
//获取请求人的 部门及其子部门
|
||||
List<Long> employeeDepartmentIdList = Lists.newArrayList();
|
||||
EmployeeEntity employeeEntity = employeeService.getById(requestEmployeeId);
|
||||
if (employeeEntity.getDepartmentId() != null) {
|
||||
// 如果不是管理员 则获取请求人的 部门及其子部门
|
||||
if (!employeeEntity.getAdministratorFlag() && employeeEntity.getDepartmentId() != null) {
|
||||
employeeDepartmentIdList = departmentService.selfAndChildrenIdList(employeeEntity.getDepartmentId());
|
||||
}
|
||||
|
||||
@ -106,8 +106,15 @@ public class NoticeEmployeeService {
|
||||
long viewCount = noticeDao.viewRecordCount(noticeId, requestEmployeeId);
|
||||
if (viewCount == 0) {
|
||||
noticeDao.insertViewRecord(noticeId, requestEmployeeId, ip, userAgent, 1);
|
||||
// 该员工对于这个通知是第一次查看 页面浏览量+1 用户浏览量+1
|
||||
noticeDao.updateViewCount(noticeId, 1, 1);
|
||||
noticeDetailVO.setPageViewCount(noticeDetailVO.getPageViewCount() + 1);
|
||||
noticeDetailVO.setUserViewCount(noticeDetailVO.getUserViewCount() + 1);
|
||||
} else {
|
||||
noticeDao.updateViewRecord(noticeId, requestEmployeeId, ip, userAgent);
|
||||
// 该员工对于这个通知不是第一次查看 页面浏览量+1 用户浏览量+0
|
||||
noticeDao.updateViewCount(noticeId, 1, 0);
|
||||
noticeDetailVO.setPageViewCount(noticeDetailVO.getPageViewCount() + 1);
|
||||
}
|
||||
|
||||
return ResponseDTO.ok(noticeDetailVO);
|
||||
|
@ -60,8 +60,11 @@ public class EmployeeManager extends ServiceImpl<EmployeeDao, EmployeeEntity> {
|
||||
// 保存员工 获得id
|
||||
employeeDao.updateById(employee);
|
||||
|
||||
if (CollectionUtils.isNotEmpty(roleIdList)) {
|
||||
List<RoleEmployeeEntity> roleEmployeeList = roleIdList.stream().map(e -> new RoleEmployeeEntity(e, employee.getEmployeeId())).collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(roleIdList)) {
|
||||
// 删除员工角色
|
||||
this.updateEmployeeRole(employee.getEmployeeId(), null);
|
||||
} else {
|
||||
List<RoleEmployeeEntity> roleEmployeeList = roleIdList.stream().map(roleId -> new RoleEmployeeEntity(roleId, employee.getEmployeeId())).collect(Collectors.toList());
|
||||
this.updateEmployeeRole(employee.getEmployeeId(), roleEmployeeList);
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import net.lab1024.sa.admin.module.system.role.domain.form.RoleEmployeeQueryForm
|
||||
import net.lab1024.sa.admin.module.system.role.domain.vo.RoleEmployeeVO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
@ -50,7 +51,7 @@ public interface RoleEmployeeDao extends BaseMapper<RoleEmployeeEntity> {
|
||||
/**
|
||||
* 查询角色下的人员id
|
||||
*/
|
||||
List<Long> selectEmployeeIdByRoleIdList(@Param("roleIdList") List<Long> roleIdList);
|
||||
Set<Long> selectEmployeeIdByRoleIdList(@Param("roleIdList") List<Long> roleIdList);
|
||||
|
||||
/**
|
||||
*
|
||||
@ -79,5 +80,10 @@ public interface RoleEmployeeDao extends BaseMapper<RoleEmployeeEntity> {
|
||||
/**
|
||||
* 批量删除某个角色下的某批用户的关联关系
|
||||
*/
|
||||
void batchDeleteEmployeeRole(@Param("roleId") Long roleId,@Param("employeeIds")List<Long> employeeIds);
|
||||
void batchDeleteEmployeeRole(@Param("roleId") Long roleId, @Param("employeeIds") Set<Long> employeeIds);
|
||||
|
||||
/**
|
||||
* 判断某个角色下是否存在用户
|
||||
*/
|
||||
Integer existsByRoleId(@Param("roleId") Long roleId);
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 角色的员工更新
|
||||
@ -25,6 +25,6 @@ public class RoleEmployeeUpdateForm {
|
||||
|
||||
@Schema(description = "员工id集合")
|
||||
@NotEmpty(message = "员工id不能为空")
|
||||
protected List<Long> employeeIdList;
|
||||
protected Set<Long> employeeIdList;
|
||||
|
||||
}
|
||||
|
@ -3,11 +3,7 @@ package net.lab1024.sa.admin.module.system.role.manager;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import net.lab1024.sa.admin.module.system.role.dao.RoleEmployeeDao;
|
||||
import net.lab1024.sa.admin.module.system.role.domain.entity.RoleEmployeeEntity;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 角色员工 manager
|
||||
@ -16,20 +12,9 @@ import java.util.List;
|
||||
* @Date 2022-04-08 21:53:04
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Service
|
||||
public class RoleEmployeeManager extends ServiceImpl<RoleEmployeeDao, RoleEmployeeEntity> {
|
||||
|
||||
/**
|
||||
* 保存 角色员工
|
||||
*
|
||||
*/
|
||||
@Transactional(rollbackFor = Throwable.class)
|
||||
public void saveRoleEmployee(Long roleId, List<RoleEmployeeEntity> roleEmployeeList) {
|
||||
this.getBaseMapper().deleteByRoleId(roleId);
|
||||
if (CollectionUtils.isNotEmpty(roleEmployeeList)) {
|
||||
this.saveBatch(roleEmployeeList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.lab1024.sa.admin.module.system.role.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.lab1024.sa.admin.module.system.department.dao.DepartmentDao;
|
||||
import net.lab1024.sa.admin.module.system.department.domain.entity.DepartmentEntity;
|
||||
import net.lab1024.sa.admin.module.system.employee.domain.vo.EmployeeVO;
|
||||
@ -20,12 +21,12 @@ import net.lab1024.sa.base.common.util.SmartBeanUtil;
|
||||
import net.lab1024.sa.base.common.util.SmartPageUtil;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -88,7 +89,6 @@ public class RoleEmployeeService {
|
||||
* 移除员工角色
|
||||
*
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResponseDTO<String> removeRoleEmployee(Long employeeId, Long roleId) {
|
||||
if (null == employeeId || null == roleId) {
|
||||
return ResponseDTO.userErrorParam();
|
||||
@ -112,16 +112,21 @@ public class RoleEmployeeService {
|
||||
*/
|
||||
public ResponseDTO<String> batchAddRoleEmployee(RoleEmployeeUpdateForm roleEmployeeUpdateForm) {
|
||||
Long roleId = roleEmployeeUpdateForm.getRoleId();
|
||||
List<Long> employeeIdList = roleEmployeeUpdateForm.getEmployeeIdList();
|
||||
// 保存新的角色员工
|
||||
List<RoleEmployeeEntity> roleEmployeeList = null;
|
||||
if (CollectionUtils.isNotEmpty(employeeIdList)) {
|
||||
roleEmployeeList = employeeIdList.stream()
|
||||
|
||||
// 已选择的员工id列表
|
||||
Set<Long> selectedEmployeeIdList = roleEmployeeUpdateForm.getEmployeeIdList();
|
||||
// 数据库里已有的员工id列表
|
||||
Set<Long> dbEmployeeIdList = roleEmployeeDao.selectEmployeeIdByRoleIdList(Lists.newArrayList(roleId));
|
||||
// 从已选择的员工id列表里 过滤数据库里不存在的 即需要添加的员工 id
|
||||
Set<Long> addEmployeeIdList = selectedEmployeeIdList.stream().filter(id -> !dbEmployeeIdList.contains(id)).collect(Collectors.toSet());
|
||||
|
||||
// 添加角色员工
|
||||
if (CollectionUtils.isNotEmpty(addEmployeeIdList)) {
|
||||
List<RoleEmployeeEntity> roleEmployeeList = addEmployeeIdList.stream()
|
||||
.map(employeeId -> new RoleEmployeeEntity(roleId, employeeId))
|
||||
.collect(Collectors.toList());
|
||||
roleEmployeeManager.saveBatch(roleEmployeeList);
|
||||
}
|
||||
// 保存数据
|
||||
roleEmployeeManager.saveRoleEmployee(roleId, roleEmployeeList);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
|
@ -65,6 +65,11 @@ public class RoleService {
|
||||
if (null == roleEntity) {
|
||||
return ResponseDTO.error(UserErrorCode.DATA_NOT_EXIST);
|
||||
}
|
||||
// 当没有员工绑定这个角色时才可以删除
|
||||
Integer exists = roleEmployeeDao.existsByRoleId(roleId);
|
||||
if (exists != null) {
|
||||
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST, "该角色下存在员工,无法删除");
|
||||
}
|
||||
roleDao.deleteById(roleId);
|
||||
roleMenuDao.deleteByRoleId(roleId);
|
||||
roleEmployeeDao.deleteByRoleId(roleId);
|
||||
@ -86,7 +91,7 @@ public class RoleService {
|
||||
}
|
||||
|
||||
existRoleEntity = roleDao.getByRoleCode(roleUpdateForm.getRoleCode());
|
||||
if (null != existRoleEntity) {
|
||||
if (null != existRoleEntity && !existRoleEntity.getRoleId().equals(roleUpdateForm.getRoleId())) {
|
||||
return ResponseDTO.userErrorParam("角色编码重复,重复的角色为:" + existRoleEntity.getRoleName());
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
INSTR(goods_name,#{query.searchWord})
|
||||
</if>
|
||||
<if test="query.place != null">
|
||||
AND place = #{query.place}
|
||||
AND INSTR(place,#{query.place})
|
||||
</if>
|
||||
<if test="query.goodsStatus != null">
|
||||
AND goods_status = #{query.goodsStatus}
|
||||
|
@ -1,69 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="net.lab1024.sa.admin.module.business.notice.NoticeDao">
|
||||
<update id="updateWatchAmount">
|
||||
UPDATE t_notice
|
||||
SET watch_amount = watch_amount + 1
|
||||
WHERE notice_id = #{noticeId}
|
||||
</update>
|
||||
<update id="batchDeleteNotice">
|
||||
UPDATE t_notice
|
||||
SET deleted_flag = #{deletedFlag}
|
||||
WHERE notice_id IN
|
||||
<foreach collection="noticeIdList" open="(" close=")" separator="," item="item">
|
||||
#{item}
|
||||
</foreach>
|
||||
</update>
|
||||
<update id="updateNotice">
|
||||
UPDATE t_notice
|
||||
SET notice_type = #{noticeType},
|
||||
notice_belong_type = #{noticeBelongType},
|
||||
notice_title = #{noticeTitle},
|
||||
notice_content = #{noticeContent},
|
||||
link_address = #{linkAddress},
|
||||
cover_file_key = #{coverFileKey},
|
||||
accessory_file_keys = #{accessoryFileKeys},
|
||||
top_flag = #{topFlag},
|
||||
publish_time = #{publishTime},
|
||||
disabled_flag = #{disabledFlag}
|
||||
WHERE notice_id = #{noticeId}
|
||||
</update>
|
||||
<select id="queryPage" resultType="net.lab1024.sa.admin.module.business.oa.notice.domain.vo.NoticeVO">
|
||||
SELECT t_notice.*,
|
||||
t_employee.actual_name AS createUserName
|
||||
FROM t_notice
|
||||
LEFT JOIN t_employee ON t_notice.create_user_id = t_employee.employee_id
|
||||
<where>
|
||||
t_notice.deleted_flag = #{queryForm.deletedFlag}
|
||||
<if test="queryForm.keywords != null and queryForm.keywords != ''">
|
||||
AND (INSTR(t_notice.notice_title,#{queryForm.keywords}) OR INSTR(t_employee.actual_name,#{queryForm.keywords}))
|
||||
</if>
|
||||
<if test="queryForm.noticeType != null">
|
||||
AND t_notice.notice_type = #{queryForm.noticeType}
|
||||
</if>
|
||||
<if test="queryForm.noticeBelongType != null">
|
||||
AND t_notice.notice_belong_type = #{queryForm.noticeBelongType}
|
||||
</if>
|
||||
<if test="queryForm.startTime != null">
|
||||
AND DATE_FORMAT(t_notice.publish_time, '%Y-%m-%d') >= #{queryForm.startTime}
|
||||
</if>
|
||||
<if test="queryForm.endTime != null">
|
||||
AND DATE_FORMAT(t_notice.publish_time, '%Y-%m-%d') <= #{queryForm.endTime}
|
||||
</if>
|
||||
<if test="queryForm.disabledFlag != null">
|
||||
AND t_notice.disabled_flag = #{queryForm.disabledFlag}
|
||||
</if>
|
||||
</where>
|
||||
<if test="queryForm.sortItemList == null or queryForm.sortItemList.size == 0">
|
||||
ORDER BY t_notice.top_flag DESC,t_notice.publish_time DESC
|
||||
</if>
|
||||
</select>
|
||||
<select id="getDetail" resultType="net.lab1024.sa.admin.module.business.oa.notice.domain.vo.NoticeVO">
|
||||
SELECT tn.*,
|
||||
e.actual_name AS createUserName
|
||||
FROM t_notice tn
|
||||
LEFT JOIN t_employee e ON tn.create_user_id = e.employee_id
|
||||
WHERE tn.notice_id = #{noticeId}
|
||||
AND tn.deleted_flag = #{deletedFlag}
|
||||
</select>
|
||||
</mapper>
|
@ -242,5 +242,11 @@
|
||||
where notice_id = #{noticeId}
|
||||
and employee_id = #{employeeId}
|
||||
</update>
|
||||
<update id="updateViewCount">
|
||||
update t_notice
|
||||
set page_view_count = page_view_count + #{pageViewCountIncrement},
|
||||
user_view_count = user_view_count + #{userViewCountIncrement}
|
||||
where notice_id = #{noticeId}
|
||||
</update>
|
||||
|
||||
</mapper>
|
@ -138,4 +138,12 @@
|
||||
#{item}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="existsByRoleId" resultType="java.lang.Integer">
|
||||
SELECT 1
|
||||
FROM t_role_employee er
|
||||
WHERE er.role_id = #{roleId}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -28,19 +28,19 @@ public class DictValueVoDeserializer extends JsonDeserializer<String> {
|
||||
|
||||
@Override
|
||||
public String deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
|
||||
List<DictValueVO> list = new ArrayList<>();
|
||||
List<String> list = new ArrayList<>();
|
||||
ObjectCodec objectCodec = jsonParser.getCodec();
|
||||
JsonNode listOrObjectNode = objectCodec.readTree(jsonParser);
|
||||
String deserialize = "";
|
||||
try {
|
||||
if (listOrObjectNode.isArray()) {
|
||||
for (JsonNode node : listOrObjectNode) {
|
||||
list.add(objectCodec.treeToValue(node, DictValueVO.class));
|
||||
list.add(node.asText());
|
||||
}
|
||||
} else {
|
||||
list.add(objectCodec.treeToValue(listOrObjectNode, DictValueVO.class));
|
||||
list.add(listOrObjectNode.asText());
|
||||
}
|
||||
deserialize = list.stream().map(DictValueVO::getValueCode).collect(Collectors.joining(","));
|
||||
deserialize = String.join(",", list);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
deserialize = listOrObjectNode.asText();
|
||||
|
@ -12,7 +12,6 @@ import org.apache.commons.collections4.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 分页工具类
|
||||
@ -32,6 +31,10 @@ public class SmartPageUtil {
|
||||
public static Page<?> convert2PageQuery(PageParam pageParam) {
|
||||
Page<?> page = new Page<>(pageParam.getPageNum(), pageParam.getPageSize());
|
||||
|
||||
if (pageParam.getSearchCount() != null) {
|
||||
page.setSearchCount(pageParam.getSearchCount());
|
||||
}
|
||||
|
||||
List<PageParam.SortItem> sortItemList = pageParam.getSortItemList();
|
||||
if (CollectionUtils.isEmpty(sortItemList)) {
|
||||
return page;
|
||||
|
@ -7,10 +7,12 @@ import com.alibaba.druid.support.http.StatViewServlet;
|
||||
import com.alibaba.druid.support.http.WebStatFilter;
|
||||
import com.alibaba.druid.support.spring.stat.DruidStatInterceptor;
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import com.baomidou.mybatisplus.core.config.GlobalConfig;
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.lab1024.sa.base.common.domain.DataScopePlugin;
|
||||
import net.lab1024.sa.base.handler.MybatisPlusFillHandler;
|
||||
import org.apache.ibatis.plugin.Interceptor;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.springframework.aop.support.DefaultPointcutAdvisor;
|
||||
@ -144,6 +146,8 @@ public class DataSourceConfig {
|
||||
pluginsList.add(dataScopePlugin);
|
||||
}
|
||||
factoryBean.setPlugins(pluginsList.toArray(new Interceptor[pluginsList.size()]));
|
||||
// 添加字段自动填充处理
|
||||
factoryBean.setGlobalConfig(new GlobalConfig().setBanner(false).setMetaObjectHandler(new MybatisPlusFillHandler()));
|
||||
|
||||
return factoryBean.getObject();
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.PropertyAccessor;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@ -43,7 +44,8 @@ public class RedisConfig {
|
||||
.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
|
||||
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
||||
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
|
||||
// enableDefaultTyping 官方已弃用 所以改为 activateDefaultTyping
|
||||
om.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL);
|
||||
jackson2JsonRedisSerializer.setObjectMapper(om);
|
||||
RedisTemplate<String, Object> template = new RedisTemplate<>();
|
||||
template.setConnectionFactory(factory);
|
||||
|
@ -0,0 +1,40 @@
|
||||
package net.lab1024.sa.base.handler;
|
||||
|
||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* Mybatis Plus 插入或者更新时指定字段设置值
|
||||
*
|
||||
* @author zhoumingfa
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class MybatisPlusFillHandler implements MetaObjectHandler {
|
||||
|
||||
public static final String CREATE_TIME = "createTime";
|
||||
|
||||
public static final String UPDATE_TIME = "updateTime";
|
||||
|
||||
@Override
|
||||
public void insertFill(MetaObject metaObject) {
|
||||
if (metaObject.hasSetter(CREATE_TIME)) {
|
||||
this.fillStrategy(metaObject, CREATE_TIME, LocalDateTime.now());
|
||||
}
|
||||
if (metaObject.hasSetter(UPDATE_TIME)) {
|
||||
this.fillStrategy(metaObject, UPDATE_TIME, LocalDateTime.now());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFill(MetaObject metaObject) {
|
||||
if (metaObject.hasSetter(UPDATE_TIME)) {
|
||||
this.fillStrategy(metaObject, UPDATE_TIME, LocalDateTime.now());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -41,7 +41,7 @@ public enum CodeFrontComponentEnum implements BaseEnum {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,6 @@ public class CodeGeneratorConfigForm {
|
||||
@Schema(description = "表名")
|
||||
private String tableName;
|
||||
|
||||
|
||||
@Valid
|
||||
@NotNull(message = "基础信息不能为空")
|
||||
@Schema(description = "基础信息")
|
||||
|
@ -39,8 +39,8 @@ public class CodeInsertAndUpdateField {
|
||||
@Schema(description = "更新标识")
|
||||
private Boolean updateFlag;
|
||||
|
||||
@SchemaEnum(value = CodeGeneratorPageTypeEnum.class)
|
||||
@CheckEnum(value = CodeFrontComponentEnum.class, message = "3.增加、修改 增加、修改 组件类型 枚举值错误", required = true)
|
||||
@SchemaEnum(value = CodeFrontComponentEnum.class)
|
||||
@CheckEnum(value = CodeFrontComponentEnum.class, message = "3.增加、修改 组件类型 枚举值错误", required = true)
|
||||
private String frontComponent;
|
||||
|
||||
}
|
||||
|
@ -13,16 +13,13 @@ import net.lab1024.sa.base.common.util.SmartStringUtil;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.domain.entity.CodeGeneratorConfigEntity;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.domain.form.CodeGeneratorConfigForm;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.domain.model.*;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.service.variable.backend.ControllerVariableService;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.service.variable.backend.DaoVariableService;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.service.variable.backend.ManagerVariableService;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.service.variable.backend.ServiceVariableService;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.service.variable.CodeGenerateBaseVariableService;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.service.variable.backend.*;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.service.variable.backend.domain.*;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.service.variable.front.ApiVariableService;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.service.variable.front.ConstVariableService;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.service.variable.front.FormVariableService;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.service.variable.front.ListVariableService;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.service.variable.CodeGenerateBaseVariableService;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.util.CodeGeneratorTool;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.velocity.Template;
|
||||
@ -36,7 +33,7 @@ import javax.annotation.PostConstruct;
|
||||
import java.io.File;
|
||||
import java.io.OutputStream;
|
||||
import java.io.StringWriter;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -47,7 +44,7 @@ import java.util.stream.Collectors;
|
||||
* @Date 2022-06-30 22:15:38
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
|
||||
@Service
|
||||
@ -70,6 +67,8 @@ public class CodeGeneratorTemplateService {
|
||||
map.put("java/manager/Manager.java", new ManagerVariableService());
|
||||
map.put("java/dao/Dao.java", new DaoVariableService());
|
||||
map.put("java/mapper/Mapper.xml", new MapperVariableService());
|
||||
// 菜单 SQL
|
||||
map.put("java/sql/Menu.sql", new MenuVariableService());
|
||||
// 前端
|
||||
map.put("js/api.js", new ApiVariableService());
|
||||
map.put("js/const.js", new ConstVariableService());
|
||||
@ -94,6 +93,7 @@ public class CodeGeneratorTemplateService {
|
||||
String fileName = templateFile.startsWith("java") ? upperCamel + templateSplit[templateSplit.length - 1] : lowerHyphen + "-" + templateSplit[templateSplit.length - 1];
|
||||
String fullPathFileName = templateFile.replaceAll(templateSplit[templateSplit.length - 1], fileName);
|
||||
fullPathFileName = fullPathFileName.replaceAll("java/", "java/" + basic.getModuleName().toLowerCase() + "/");
|
||||
fullPathFileName = fullPathFileName.replaceAll("js/", "js/" + lowerHyphen + "/");
|
||||
|
||||
String fileContent = generate(tableName, templateFile, codeGeneratorConfigEntity);
|
||||
File file = new File(uuid + "/" + fullPathFileName);
|
||||
@ -129,7 +129,7 @@ public class CodeGeneratorTemplateService {
|
||||
}
|
||||
|
||||
|
||||
ZipUtil.zip(outputStream, Charset.forName("utf-8"), false, null, dir);
|
||||
ZipUtil.zip(outputStream, StandardCharsets.UTF_8, false, null, dir);
|
||||
|
||||
FileUtil.del(dir);
|
||||
|
||||
|
@ -2,6 +2,7 @@ package net.lab1024.sa.base.module.support.codegenerator.service.variable;
|
||||
|
||||
import com.google.common.base.CaseFormat;
|
||||
import net.lab1024.sa.base.common.util.SmartStringUtil;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.constant.CodeFrontComponentEnum;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.domain.form.CodeGeneratorConfigForm;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.domain.model.CodeField;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.domain.model.CodeInsertAndUpdate;
|
||||
@ -17,7 +18,7 @@ import java.util.stream.Collectors;
|
||||
* @Date 2022/9/29 17:20:41
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
public abstract class CodeGenerateBaseVariableService {
|
||||
|
||||
@ -43,13 +44,13 @@ public abstract class CodeGenerateBaseVariableService {
|
||||
String upperCamelName = CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_CAMEL, form.getBasic().getModuleName());
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
|
||||
list.add("import " + form.getBasic().getJavaPackageName() + ".domain.entity." + upperCamelName + "Entity;" );
|
||||
list.add("import " + form.getBasic().getJavaPackageName() + ".domain.entity." + upperCamelName + "Entity;");
|
||||
|
||||
list.add("import " + form.getBasic().getJavaPackageName() + ".domain.form." + upperCamelName + "AddForm;" );
|
||||
list.add("import " + form.getBasic().getJavaPackageName() + ".domain.form." + upperCamelName + "UpdateForm;" );
|
||||
list.add("import " + form.getBasic().getJavaPackageName() + ".domain.form." + upperCamelName + "QueryForm;" );
|
||||
list.add("import " + form.getBasic().getJavaPackageName() + ".domain.form." + upperCamelName + "AddForm;");
|
||||
list.add("import " + form.getBasic().getJavaPackageName() + ".domain.form." + upperCamelName + "UpdateForm;");
|
||||
list.add("import " + form.getBasic().getJavaPackageName() + ".domain.form." + upperCamelName + "QueryForm;");
|
||||
|
||||
list.add("import " + form.getBasic().getJavaPackageName() + ".domain.vo." + upperCamelName + "VO;" );
|
||||
list.add("import " + form.getBasic().getJavaPackageName() + ".domain.vo." + upperCamelName + "VO;");
|
||||
return list;
|
||||
}
|
||||
|
||||
@ -88,43 +89,33 @@ public abstract class CodeGenerateBaseVariableService {
|
||||
}
|
||||
|
||||
CodeInsertAndUpdateField field = first.get();
|
||||
return SmartStringUtil.contains(field.getFrontComponent(), "Upload" );
|
||||
return SmartStringUtil.equals(field.getFrontComponent(), CodeFrontComponentEnum.FILE_UPLOAD.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为 枚举
|
||||
* 是否为 字典
|
||||
*/
|
||||
protected boolean isDict(String columnName, CodeGeneratorConfigForm form) {
|
||||
List<CodeField> fields = form.getFields();
|
||||
if (CollectionUtils.isEmpty(fields)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Optional<CodeField> first = fields.stream().filter(e -> columnName.equals(e.getColumnName())).findFirst();
|
||||
if (first.isPresent()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CodeField codeField = first.get();
|
||||
return codeField.getDict() != null;
|
||||
CodeField codeField = getCodeField(columnName, form);
|
||||
return codeField != null && codeField.getDict() != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为 枚举
|
||||
*/
|
||||
protected boolean isEnum(String columnName, CodeGeneratorConfigForm form) {
|
||||
CodeField codeField = getCodeField(columnName, form);
|
||||
return codeField != null && codeField.getEnumName() != null;
|
||||
}
|
||||
|
||||
private CodeField getCodeField(String columnName, CodeGeneratorConfigForm form) {
|
||||
List<CodeField> fields = form.getFields();
|
||||
if (CollectionUtils.isEmpty(fields)) {
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
Optional<CodeField> first = fields.stream().filter(e -> columnName.equals(e.getColumnName())).findFirst();
|
||||
if (first.isPresent()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CodeField codeField = first.get();
|
||||
return codeField.getEnumName() != null;
|
||||
return first.orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,27 @@
|
||||
package net.lab1024.sa.base.module.support.codegenerator.service.variable.backend;
|
||||
|
||||
import net.lab1024.sa.base.module.support.codegenerator.domain.form.CodeGeneratorConfigForm;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.service.variable.CodeGenerateBaseVariableService;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 目前暂时没用到 这是一个空实现
|
||||
*
|
||||
* @author zhoumingfa
|
||||
* @date 2024/8/13
|
||||
*/
|
||||
public class MenuVariableService extends CodeGenerateBaseVariableService {
|
||||
|
||||
@Override
|
||||
public boolean isSupport(CodeGeneratorConfigForm form) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getInjectVariablesMap(CodeGeneratorConfigForm form) {
|
||||
return new HashMap<>(2);
|
||||
}
|
||||
|
||||
}
|
@ -2,6 +2,7 @@ package net.lab1024.sa.base.module.support.codegenerator.service.variable.backen
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import net.lab1024.sa.base.common.util.SmartStringUtil;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.constant.CodeFrontComponentEnum;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.domain.form.CodeGeneratorConfigForm;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.domain.model.CodeField;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.domain.model.CodeInsertAndUpdate;
|
||||
@ -100,7 +101,6 @@ public class AddFormVariableService extends CodeGenerateBaseVariableService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//字典
|
||||
if (SmartStringUtil.isNotEmpty(codeField.getDict())) {
|
||||
finalFieldMap.put("dict", "\n @JsonDeserialize(using = DictValueVoDeserializer.class)");
|
||||
@ -109,7 +109,7 @@ public class AddFormVariableService extends CodeGenerateBaseVariableService {
|
||||
}
|
||||
|
||||
//文件上传
|
||||
if (SmartStringUtil.contains(field.getFrontComponent(), "Upload")) {
|
||||
if (CodeFrontComponentEnum.FILE_UPLOAD.equalsValue(field.getFrontComponent())) {
|
||||
finalFieldMap.put("file", "\n @JsonDeserialize(using = FileKeyVoDeserializer.class)");
|
||||
packageList.add("import com.fasterxml.jackson.databind.annotation.JsonDeserialize;");
|
||||
packageList.add("import net.lab1024.sa.base.common.json.deserializer.FileKeyVoDeserializer;");
|
||||
|
@ -14,7 +14,7 @@ import java.util.stream.Collectors;
|
||||
* @Date 2022/9/29 17:20:41
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
|
||||
public class EntityVariableService extends CodeGenerateBaseVariableService {
|
||||
@ -54,14 +54,21 @@ public class EntityVariableService extends CodeGenerateBaseVariableService {
|
||||
// mybatis plus
|
||||
result.add("import com.baomidou.mybatisplus.annotation.TableName;");
|
||||
|
||||
// 自动填充注解
|
||||
boolean existCreateAndUpdate = fields.stream().anyMatch(e -> "create_time".equals(e.getColumnName()) || "update_time".equals(e.getColumnName()));
|
||||
if (existCreateAndUpdate) {
|
||||
result.add("import com.baomidou.mybatisplus.annotation.FieldFill;");
|
||||
result.add("import com.baomidou.mybatisplus.annotation.TableField;");
|
||||
}
|
||||
|
||||
//主键
|
||||
boolean isExistPrimaryKey = fields.stream().filter(e -> e.getPrimaryKeyFlag() != null && e.getPrimaryKeyFlag()).findFirst().isPresent();
|
||||
boolean isExistPrimaryKey = fields.stream().anyMatch(e -> e.getPrimaryKeyFlag() != null && e.getPrimaryKeyFlag());
|
||||
if (isExistPrimaryKey) {
|
||||
result.add("import com.baomidou.mybatisplus.annotation.TableId;");
|
||||
}
|
||||
|
||||
//自增
|
||||
boolean isExistAutoIncrease = fields.stream().filter(e -> e.getAutoIncreaseFlag() != null && e.getAutoIncreaseFlag()).findFirst().isPresent();
|
||||
boolean isExistAutoIncrease = fields.stream().anyMatch(e -> e.getAutoIncreaseFlag() != null && e.getAutoIncreaseFlag());
|
||||
if (isExistAutoIncrease) {
|
||||
result.add("import com.baomidou.mybatisplus.annotation.IdType;");
|
||||
}
|
||||
|
@ -3,19 +3,20 @@ package net.lab1024.sa.base.module.support.codegenerator.service.variable.backen
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.constant.CodeQueryFieldQueryTypeEnum;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.domain.form.CodeGeneratorConfigForm;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.domain.model.CodeInsertAndUpdateField;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.domain.model.CodeQueryField;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.service.variable.CodeGenerateBaseVariableService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author 1024创新实验室-主任:卓大
|
||||
* @Date 2022/9/29 17:20:41
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
|
||||
public class MapperVariableService extends CodeGenerateBaseVariableService {
|
||||
@ -39,55 +40,47 @@ public class MapperVariableService extends CodeGenerateBaseVariableService {
|
||||
List<String> columnNameList = queryField.getColumnNameList();
|
||||
if (columnNameList.size() == 1) {
|
||||
// AND INSTR(t_notice.title,#{query.keywords})
|
||||
stringBuilder.append(" AND INSTR(" )
|
||||
.append(form.getTableName()).append("." ).append(queryField.getColumnNameList().get(0))
|
||||
.append(",#{queryForm." )
|
||||
stringBuilder.append(" AND INSTR(")
|
||||
.append(form.getTableName()).append(".").append(queryField.getColumnNameList().get(0))
|
||||
.append(",#{queryForm.")
|
||||
.append(queryField.getFieldName())
|
||||
.append("})" );
|
||||
.append("})");
|
||||
} else {
|
||||
for (int i = 0; i < columnNameList.size(); i++) {
|
||||
if (i == 0) {
|
||||
stringBuilder.append("AND ( INSTR(" )
|
||||
.append(form.getTableName()).append("." ).append(queryField.getColumnNameList().get(i))
|
||||
.append(",#{queryForm." )
|
||||
stringBuilder.append("AND ( INSTR(")
|
||||
.append(form.getTableName()).append(".").append(queryField.getColumnNameList().get(i))
|
||||
.append(",#{queryForm.")
|
||||
.append(queryField.getFieldName())
|
||||
.append("})" );
|
||||
.append("})");
|
||||
} else {
|
||||
// OR INSTR(t_notice.author,#{query.keywords})
|
||||
stringBuilder.append("\n OR INSTR(" )
|
||||
.append(form.getTableName()).append("." ).append(queryField.getColumnNameList().get(i))
|
||||
.append(",#{queryForm." )
|
||||
stringBuilder.append("\n OR INSTR(")
|
||||
.append(form.getTableName()).append(".").append(queryField.getColumnNameList().get(i))
|
||||
.append(",#{queryForm.")
|
||||
.append(queryField.getFieldName())
|
||||
.append("})" );
|
||||
.append("})");
|
||||
}
|
||||
}
|
||||
stringBuilder.append("\n )" );
|
||||
stringBuilder.append("\n )");
|
||||
}
|
||||
fieldMap.put("likeStr", stringBuilder.toString());
|
||||
}else{
|
||||
fieldMap.put("columnName",queryField.getColumnNameList().get(0));
|
||||
} else if (CodeQueryFieldQueryTypeEnum.DICT.equalsValue(queryField.getQueryTypeEnum())) {
|
||||
String stringBuilder = "AND INSTR(" +
|
||||
form.getTableName() + "." + queryField.getColumnNameList().get(0) +
|
||||
",#{queryForm." +
|
||||
queryField.getFieldName() +
|
||||
"})";
|
||||
fieldMap.put("likeStr", stringBuilder);
|
||||
}
|
||||
else {
|
||||
fieldMap.put("columnName", queryField.getColumnNameList().get(0));
|
||||
}
|
||||
}
|
||||
|
||||
variablesMap.put("queryFields", finalQueryFiledList);
|
||||
variablesMap.put("daoClassName", form.getBasic().getJavaPackageName() + ".dao." + form.getBasic().getModuleName() + "Dao" );
|
||||
variablesMap.put("daoClassName", form.getBasic().getJavaPackageName() + ".dao." + form.getBasic().getModuleName() + "Dao");
|
||||
return variablesMap;
|
||||
}
|
||||
|
||||
|
||||
public List<String> getPackageList(List<CodeInsertAndUpdateField> fields, CodeGeneratorConfigForm form) {
|
||||
if (CollectionUtils.isEmpty(fields)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
HashSet<String> packageList = new HashSet<>();
|
||||
|
||||
//1、javabean相关的包
|
||||
packageList.addAll(getJavaBeanImportClass(form));
|
||||
|
||||
//2、dao
|
||||
packageList.add("import " + form.getBasic().getJavaPackageName() + ".dao." + form.getBasic().getModuleName() + "Dao;" );
|
||||
return new ArrayList<>(packageList);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package net.lab1024.sa.base.module.support.codegenerator.service.variable.backen
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import net.lab1024.sa.base.common.util.SmartEnumUtil;
|
||||
import net.lab1024.sa.base.common.util.SmartStringUtil;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.constant.CodeQueryFieldQueryTypeEnum;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.domain.form.CodeGeneratorConfigForm;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.domain.model.CodeField;
|
||||
@ -18,7 +19,7 @@ import java.util.stream.Collectors;
|
||||
* @Date 2022/9/29 17:20:41
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
|
||||
public class QueryFormVariableService extends CodeGenerateBaseVariableService {
|
||||
@ -41,14 +42,11 @@ public class QueryFormVariableService extends CodeGenerateBaseVariableService {
|
||||
|
||||
|
||||
public ImmutablePair<List<String>, List<Map<String, Object>>> getPackageListAndFields(CodeGeneratorConfigForm form) {
|
||||
|
||||
List<CodeQueryField> fields = form.getQueryFields();
|
||||
if (CollectionUtils.isEmpty(fields)) {
|
||||
return ImmutablePair.of(new ArrayList<>(), new ArrayList<>());
|
||||
}
|
||||
|
||||
HashSet<String> packageList = new HashSet<>();
|
||||
|
||||
|
||||
/**
|
||||
* 1、LocalDate、LocalDateTime、BigDecimal 类型的包名
|
||||
* 2、排序
|
||||
@ -75,9 +73,6 @@ public class QueryFormVariableService extends CodeGenerateBaseVariableService {
|
||||
CodeField codeField = null;
|
||||
|
||||
switch (queryTypeEnum) {
|
||||
case LIKE:
|
||||
finalFieldMap.put("javaType", "String");
|
||||
break;
|
||||
case EQUAL:
|
||||
codeField = getCodeFieldByColumnName(field.getColumnNameList().get(0), form);
|
||||
if (codeField == null) {
|
||||
@ -109,6 +104,14 @@ public class QueryFormVariableService extends CodeGenerateBaseVariableService {
|
||||
|
||||
finalFieldMap.put("javaType", codeField.getJavaType());
|
||||
break;
|
||||
case DICT:
|
||||
codeField = getCodeFieldByColumnName(field.getColumnNameList().get(0), form);
|
||||
if (SmartStringUtil.isNotEmpty(codeField.getDict())) {
|
||||
finalFieldMap.put("dict", "\n @JsonDeserialize(using = DictValueVoDeserializer.class)");
|
||||
packageList.add("import com.fasterxml.jackson.databind.annotation.JsonDeserialize;");
|
||||
packageList.add("import net.lab1024.sa.base.common.json.deserializer.DictValueVoDeserializer;");
|
||||
}
|
||||
finalFieldMap.put("javaType", "String");
|
||||
default:
|
||||
finalFieldMap.put("javaType", "String");
|
||||
}
|
||||
@ -116,12 +119,11 @@ public class QueryFormVariableService extends CodeGenerateBaseVariableService {
|
||||
finalFieldList.add(finalFieldMap);
|
||||
}
|
||||
|
||||
|
||||
// lombok
|
||||
packageList.add("import lombok.Data;");
|
||||
packageList.add("import lombok.EqualsAndHashCode;");
|
||||
|
||||
List<String> packageNameList = packageList.stream().filter(Objects::nonNull).collect(Collectors.toList());
|
||||
Collections.sort(packageNameList);
|
||||
List<String> packageNameList = packageList.stream().filter(Objects::nonNull).sorted().collect(Collectors.toList());
|
||||
return ImmutablePair.of(packageNameList, finalFieldList);
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package net.lab1024.sa.base.module.support.codegenerator.service.variable.backen
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import net.lab1024.sa.base.common.util.SmartStringUtil;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.constant.CodeFrontComponentEnum;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.domain.form.CodeGeneratorConfigForm;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.domain.model.CodeField;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.domain.model.CodeInsertAndUpdate;
|
||||
@ -18,7 +19,7 @@ import java.util.stream.Collectors;
|
||||
* @Date 2022/9/29 17:20:41
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
|
||||
public class UpdateFormVariableService extends CodeGenerateBaseVariableService {
|
||||
@ -42,7 +43,7 @@ public class UpdateFormVariableService extends CodeGenerateBaseVariableService {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(Boolean.TRUE.equals(codeField.getPrimaryKeyFlag())){
|
||||
if (Boolean.TRUE.equals(codeField.getPrimaryKeyFlag())) {
|
||||
e.setRequiredFlag(true);
|
||||
}
|
||||
|
||||
@ -123,7 +124,7 @@ public class UpdateFormVariableService extends CodeGenerateBaseVariableService {
|
||||
}
|
||||
|
||||
//文件上传
|
||||
if (SmartStringUtil.contains(field.getFrontComponent(), "Upload")) {
|
||||
if (CodeFrontComponentEnum.FILE_UPLOAD.equalsValue(field.getFrontComponent())) {
|
||||
finalFieldMap.put("file", "\n @JsonDeserialize(using = FileKeyVoDeserializer.class)");
|
||||
packageList.add("import com.fasterxml.jackson.databind.annotation.JsonDeserialize;");
|
||||
packageList.add("import net.lab1024.sa.base.common.json.deserializer.FileKeyVoDeserializer;");
|
||||
|
@ -17,7 +17,7 @@ import java.util.stream.Collectors;
|
||||
* @Date 2022/9/29 17:20:41
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
|
||||
public class VOVariableService extends CodeGenerateBaseVariableService {
|
||||
@ -87,16 +87,16 @@ public class VOVariableService extends CodeGenerateBaseVariableService {
|
||||
|
||||
//字典
|
||||
if (isDict(field.getColumnName(), form)) {
|
||||
finalFieldMap.put("dict", "\n @JsonDeserialize(using = DictValueVoDeserializer.class)");
|
||||
packageList.add("import com.fasterxml.jackson.databind.annotation.JsonDeserialize;");
|
||||
packageList.add("import net.lab1024.sa.base.common.json.deserializer.DictValueVoDeserializer;");
|
||||
finalFieldMap.put("dict", "\n @JsonSerialize(using = DictValueVoSerializer.class)");
|
||||
packageList.add("import com.fasterxml.jackson.databind.annotation.JsonSerialize;");
|
||||
packageList.add("import net.lab1024.sa.base.common.json.serializer.DictValueVoSerializer;");
|
||||
}
|
||||
|
||||
//文件上传
|
||||
if (isFile(field.getColumnName(), form)) {
|
||||
finalFieldMap.put("file", "\n @JsonDeserialize(using = FileKeyVoDeserializer.class)");
|
||||
packageList.add("import com.fasterxml.jackson.databind.annotation.JsonDeserialize;");
|
||||
packageList.add("import net.lab1024.sa.base.common.json.deserializer.FileKeyVoDeserializer;");
|
||||
finalFieldMap.put("file", "\n @JsonSerialize(using = FileKeyVoSerializer.class)");
|
||||
packageList.add("import com.fasterxml.jackson.databind.annotation.JsonSerialize;");
|
||||
packageList.add("import net.lab1024.sa.base.common.json.serializer.FileKeyVoSerializer;");
|
||||
}
|
||||
|
||||
packageList.add(getJavaPackageName(codeField.getJavaType()));
|
||||
|
@ -57,19 +57,20 @@ public class FormVariableService extends CodeGenerateBaseVariableService {
|
||||
|
||||
fieldsVariableList.add(objectMap);
|
||||
|
||||
if (CodeFrontComponentEnum.ENUM_SELECT.getValue().equals(field.getFrontComponent())) {
|
||||
if (CodeFrontComponentEnum.ENUM_SELECT.equalsValue(field.getFrontComponent())) {
|
||||
frontImportSet.add("import SmartEnumSelect from '/@/components/framework/smart-enum-select/index.vue';");
|
||||
}
|
||||
|
||||
if (CodeFrontComponentEnum.BOOLEAN_SELECT.getValue().equals(field.getFrontComponent())) {
|
||||
if (CodeFrontComponentEnum.BOOLEAN_SELECT.equalsValue(field.getFrontComponent())) {
|
||||
frontImportSet.add("import BooleanSelect from '/@/components/framework/boolean-select/index.vue';");
|
||||
}
|
||||
|
||||
if (CodeFrontComponentEnum.DICT_SELECT.getValue().equals(field.getFrontComponent())) {
|
||||
if (CodeFrontComponentEnum.DICT_SELECT.equalsValue(field.getFrontComponent())) {
|
||||
frontImportSet.add("import DictSelect from '/@/components/support/dict-select/index.vue';");
|
||||
}
|
||||
|
||||
if (CodeFrontComponentEnum.FILE_UPLOAD.getValue().equals(field.getFrontComponent())) {
|
||||
if (CodeFrontComponentEnum.FILE_UPLOAD.equalsValue(field.getFrontComponent())) {
|
||||
frontImportSet.add("import { FILE_FOLDER_TYPE_ENUM } from '/@/constants/support/file-const';");
|
||||
frontImportSet.add("import FileUpload from '/@/components/support/file-upload/index.vue';");
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
|
||||
import com.google.common.base.CaseFormat;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.constant.CodeQueryFieldQueryTypeEnum;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.domain.form.CodeGeneratorConfigForm;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.domain.model.CodeField;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.domain.model.CodeQueryField;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.service.variable.CodeGenerateBaseVariableService;
|
||||
|
||||
@ -35,19 +36,23 @@ public class ListVariableService extends CodeGenerateBaseVariableService {
|
||||
|
||||
for (CodeQueryField queryField : queryFields) {
|
||||
Map<String, Object> objectMap = BeanUtil.beanToMap(queryField);
|
||||
variableList.add(objectMap);
|
||||
|
||||
if("Enum".equals(queryField.getQueryTypeEnum())){
|
||||
CodeField codeField = getCodeFieldByColumnName(queryField.getColumnNameList().get(0), form);
|
||||
objectMap.put("frontEnumName", codeField.getEnumName());
|
||||
objectMap.put("dict", codeField.getDict());
|
||||
|
||||
if(CodeQueryFieldQueryTypeEnum.ENUM.equalsValue(queryField.getQueryTypeEnum())){
|
||||
frontImportSet.add("import SmartEnumSelect from '/@/components/framework/smart-enum-select/index.vue';");
|
||||
}
|
||||
|
||||
if("Dict".equals(queryField.getQueryTypeEnum())){
|
||||
if(CodeQueryFieldQueryTypeEnum.DICT.equalsValue(queryField.getQueryTypeEnum())){
|
||||
frontImportSet.add("import DictSelect from '/@/components/support/dict-select/index.vue';");
|
||||
}
|
||||
|
||||
if(CodeQueryFieldQueryTypeEnum.DATE_RANGE.getValue().equals(queryField.getQueryTypeEnum())){
|
||||
if(CodeQueryFieldQueryTypeEnum.DATE_RANGE.equalsValue(queryField.getQueryTypeEnum())){
|
||||
frontImportSet.add("import { defaultTimeRanges } from '/@/lib/default-time-ranges';");
|
||||
}
|
||||
variableList.add(objectMap);
|
||||
|
||||
}
|
||||
variablesMap.put("queryFields",variableList);
|
||||
|
@ -142,6 +142,8 @@ public class SmartJobExecutor implements Runnable {
|
||||
logEntity.setSuccessFlag(true);
|
||||
// 执行开始时间
|
||||
logEntity.setExecuteStartTime(executeTime);
|
||||
logEntity.setExecuteEndTime(executeTime);
|
||||
logEntity.setExecuteTimeMillis(0L);
|
||||
logEntity.setCreateName(executorName);
|
||||
logEntity.setIp(SmartIpUtil.getLocalFirstIp());
|
||||
logEntity.setProcessId(SmartJobUtil.getProcessId());
|
||||
|
@ -2,6 +2,7 @@ package ${packageName};
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import net.lab1024.sa.base.common.enumeration.BaseEnum;
|
||||
|
||||
/**
|
||||
* ${enumDesc}
|
||||
|
@ -3,6 +3,7 @@ package ${packageName};
|
||||
#foreach ($importClass in $importPackageList)
|
||||
$importClass
|
||||
#end
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
||||
import net.lab1024.sa.base.common.domain.PageResult;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@ -23,7 +24,7 @@ import javax.validation.Valid;
|
||||
*/
|
||||
|
||||
@RestController
|
||||
@Tag(name = "")
|
||||
@Tag(name = "${basic.description}")
|
||||
public class ${name.upperCamel}Controller {
|
||||
|
||||
@Resource
|
||||
@ -31,6 +32,7 @@ public class ${name.upperCamel}Controller {
|
||||
|
||||
@Operation(summary = "分页查询 @author ${basic.backendAuthor}")
|
||||
@PostMapping("/${name.lowerCamel}/queryPage")
|
||||
@SaCheckPermission("${name.lowerCamel}:query")
|
||||
public ResponseDTO<PageResult<${name.upperCamel}VO>> queryPage(@RequestBody @Valid ${name.upperCamel}QueryForm queryForm) {
|
||||
return ResponseDTO.ok(${name.lowerCamel}Service.queryPage(queryForm));
|
||||
}
|
||||
@ -38,12 +40,14 @@ public class ${name.upperCamel}Controller {
|
||||
#if($insertAndUpdate.isSupportInsertAndUpdate)
|
||||
@Operation(summary = "添加 @author ${basic.backendAuthor}")
|
||||
@PostMapping("/${name.lowerCamel}/add")
|
||||
@SaCheckPermission("${name.lowerCamel}:add")
|
||||
public ResponseDTO<String> add(@RequestBody @Valid ${name.upperCamel}AddForm addForm) {
|
||||
return ${name.lowerCamel}Service.add(addForm);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新 @author ${basic.backendAuthor}")
|
||||
@PostMapping("/${name.lowerCamel}/update")
|
||||
@SaCheckPermission("${name.lowerCamel}:update")
|
||||
public ResponseDTO<String> update(@RequestBody @Valid ${name.upperCamel}UpdateForm updateForm) {
|
||||
return ${name.lowerCamel}Service.update(updateForm);
|
||||
}
|
||||
@ -53,6 +57,7 @@ public class ${name.upperCamel}Controller {
|
||||
#if($deleteInfo.deleteEnum == "Batch" || $deleteInfo.deleteEnum == "SingleAndBatch")
|
||||
@Operation(summary = "批量删除 @author ${basic.backendAuthor}")
|
||||
@PostMapping("/${name.lowerCamel}/batchDelete")
|
||||
@SaCheckPermission("${name.lowerCamel}:delete")
|
||||
public ResponseDTO<String> batchDelete(@RequestBody ValidateList<${primaryKeyJavaType}> idList) {
|
||||
return ${name.lowerCamel}Service.batchDelete(idList);
|
||||
}
|
||||
@ -61,6 +66,7 @@ public class ${name.upperCamel}Controller {
|
||||
#if($deleteInfo.deleteEnum == "Single" || $deleteInfo.deleteEnum == "SingleAndBatch")
|
||||
@Operation(summary = "单个删除 @author ${basic.backendAuthor}")
|
||||
@GetMapping("/${name.lowerCamel}/delete/{${primaryKeyFieldName}}")
|
||||
@SaCheckPermission("${name.lowerCamel}:delete")
|
||||
public ResponseDTO<String> batchDelete(@PathVariable ${primaryKeyJavaType} ${primaryKeyFieldName}) {
|
||||
return ${name.lowerCamel}Service.delete(${primaryKeyFieldName});
|
||||
}
|
||||
|
@ -38,14 +38,15 @@ public interface ${name.upperCamel}Dao extends BaseMapper<${name.upperCamel}Enti
|
||||
* 更新删除状态
|
||||
*/
|
||||
long updateDeleted(@Param("${primaryKeyFieldName}")${primaryKeyJavaType} ${primaryKeyFieldName},@Param("${deletedFlag}")boolean deletedFlag);
|
||||
|
||||
#end
|
||||
#if($deleteInfo.deleteEnum == "Batch" || $deleteInfo.deleteEnum == "SingleAndBatch")
|
||||
/**
|
||||
* 批量更新删除状态
|
||||
*/
|
||||
void batchUpdateDeleted(@Param("idList")List<${primaryKeyJavaType}> idList,@Param("${deletedFlag}")boolean deletedFlag);
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
}
|
||||
|
@ -20,12 +20,18 @@ public class ${name.upperCamel}Entity {
|
||||
/**
|
||||
* $field.label
|
||||
*/
|
||||
#if($field.primaryKeyFlag && $field.autoIncreaseFlag)
|
||||
#if($field.primaryKeyFlag && $field.autoIncreaseFlag)
|
||||
@TableId(type = IdType.AUTO)
|
||||
#end
|
||||
#if($field.primaryKeyFlag && !$field.autoIncreaseFlag)
|
||||
#end
|
||||
#if($field.primaryKeyFlag && !$field.autoIncreaseFlag)
|
||||
@TableId
|
||||
#end
|
||||
#end
|
||||
#if($field.columnName == "create_time")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
#end
|
||||
#if($field.columnName == "update_time")
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
#end
|
||||
private $field.javaType $field.fieldName;
|
||||
#end
|
||||
|
||||
|
@ -14,7 +14,8 @@ $importClass
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class ${name.upperCamel}QueryForm extends PageParam{
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class ${name.upperCamel}QueryForm extends PageParam {
|
||||
#foreach ($field in $fields)
|
||||
|
||||
#if($field.isEnum)
|
||||
|
@ -17,14 +17,8 @@ public class ${name.upperCamel}VO {
|
||||
|
||||
#foreach ($field in $fields)
|
||||
|
||||
#if($field.isEnum)
|
||||
${field.apiModelProperty}
|
||||
${field.apiModelProperty}$!{field.notEmpty}$!{field.dict}$!{field.file}
|
||||
private $field.javaType $field.fieldName;
|
||||
#end
|
||||
#if(!$field.isEnum)
|
||||
${field.apiModelProperty}$!{field.dict}$!{field.file}
|
||||
private $field.javaType $field.fieldName;
|
||||
#end
|
||||
#end
|
||||
|
||||
}
|
@ -2,10 +2,17 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="${daoClassName}">
|
||||
|
||||
<!-- 查询结果列 -->
|
||||
<sql id="base_columns">
|
||||
#foreach ($field in $fields)
|
||||
${tableName}.${field.columnName}#if($foreach.hasNext),#end
|
||||
#end
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="queryPage" resultType="${basic.javaPackageName}.domain.vo.${name.upperCamel}VO">
|
||||
SELECT
|
||||
*
|
||||
<include refid="base_columns"/>
|
||||
FROM ${tableName}
|
||||
#if($queryFields.size() > 0)
|
||||
<where>
|
||||
@ -16,22 +23,27 @@
|
||||
${queryField.likeStr}
|
||||
</if>
|
||||
#end
|
||||
#if(${queryField.queryTypeEnum} == "Equal" || ${queryField.queryTypeEnum} == "Enum" || ${queryField.queryTypeEnum} == "Dict")
|
||||
#if(${queryField.queryTypeEnum} == "Dict")
|
||||
<if test="queryForm.${queryField.fieldName} != null and queryForm.${queryField.fieldName} != ''">
|
||||
${queryField.likeStr}
|
||||
</if>
|
||||
#end
|
||||
#if(${queryField.queryTypeEnum} == "Equal" || ${queryField.queryTypeEnum} == "Enum")
|
||||
<if test="queryForm.${queryField.fieldName} != null">
|
||||
AND ${tableName}.${queryField.columnName} = #{queryForm.${queryField.fieldName}}
|
||||
</if>
|
||||
#end
|
||||
#if(${queryField.queryTypeEnum} == "Date")
|
||||
<if test="queryForm.${queryField.fieldName} != null">
|
||||
AND DATE_FORMAT(${tableName}.${queryField.columnName}, '%Y-%m-%d') = #{queryForm.${queryField.fieldName}}
|
||||
AND ${tableName}.${queryField.columnName} = #{queryForm.${queryField.fieldName}}
|
||||
</if>
|
||||
#end
|
||||
#if(${queryField.queryTypeEnum} == "DateRange")
|
||||
<if test="queryForm.${queryField.fieldName}Begin != null">
|
||||
AND DATE_FORMAT(${tableName}.${queryField.columnName}, '%Y-%m-%d') >= #{queryForm.${queryField.fieldName}Begin}
|
||||
AND ${tableName}.${queryField.columnName} >= #{queryForm.${queryField.fieldName}Begin}
|
||||
</if>
|
||||
<if test="queryForm.${queryField.fieldName}End != null">
|
||||
AND DATE_FORMAT(${tableName}.${queryField.columnName}, '%Y-%m-%d') <= #{queryForm.${queryField.fieldName}End}
|
||||
AND ${tableName}.${queryField.columnName} <= #{queryForm.${queryField.fieldName}End}
|
||||
</if>
|
||||
#end
|
||||
#end
|
||||
@ -39,21 +51,10 @@
|
||||
#end
|
||||
</select>
|
||||
|
||||
#if($dao.deletedFieldUpperName != $null)
|
||||
<update id="batchUpdate${dao.deletedFieldUpperName}">
|
||||
update ${mapper.tableName} set ${mapper.deletedColumnName} = #{deletedFlag}
|
||||
where ${mapper.mainKeyColumnName} in
|
||||
<foreach collection="idList" open="(" close=")" separator="," item="item">
|
||||
#{item}
|
||||
</foreach>
|
||||
</update>
|
||||
#end
|
||||
|
||||
#if($deleteInfo.isSupportDelete)
|
||||
### 假删除
|
||||
#if(!${deleteInfo.isPhysicallyDeleted})
|
||||
#if($deleteInfo.deleteEnum == "Batch" || $deleteInfo.deleteEnum == "SingleAndBatch")
|
||||
|
||||
<update id="batchUpdateDeleted">
|
||||
update ${tableName} set deleted_flag = #{deletedFlag}
|
||||
where ${primaryKeyColumnName} in
|
||||
@ -71,4 +72,5 @@
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
|
||||
</mapper>
|
@ -64,7 +64,7 @@ public class ${name.upperCamel}Service {
|
||||
#end
|
||||
|
||||
#if($deleteInfo.isSupportDelete)
|
||||
#if($deleteInfo.deleteEnum == "BATCH" || $deleteInfo.deleteEnum == "SingleAndBatch")
|
||||
#if($deleteInfo.deleteEnum == "Batch" || $deleteInfo.deleteEnum == "SingleAndBatch")
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
@ -97,7 +97,7 @@ public class ${name.upperCamel}Service {
|
||||
|
||||
### 真删除 or 假删除
|
||||
#if(!${deleteInfo.isPhysicallyDeleted})
|
||||
${name.lowerCamel}Dao.updateDeleted(${primaryKeyFieldName},true);
|
||||
${name.lowerCamel}Dao.updateDeleted(${primaryKeyFieldName}, true);
|
||||
#end
|
||||
#if(${deleteInfo.isPhysicallyDeleted})
|
||||
${name.lowerCamel}Dao.deleteById(${primaryKeyFieldName});
|
||||
|
@ -0,0 +1,22 @@
|
||||
# 默认是按前端工程文件的 /views/business 文件夹的路径作为前端组件路径,如果你没把生成的 .vue 前端代码放在 /views/business 下,
|
||||
# 那就根据自己实际情况修改下面 SQL 的 path,component 字段值,避免执行 SQL 后菜单无法访问。
|
||||
# 如果你一切都是按照默认,那么下面的 SQL 基本不用改
|
||||
|
||||
INSERT INTO t_menu ( menu_name, menu_type, parent_id, path, component, frame_flag, cache_flag, visible_flag, disabled_flag, perms_type, create_user_id )
|
||||
VALUES ( '${basic.description}', 2, 0, '/${name.lowerHyphenCamel}/list', '/business/${name.lowerHyphenCamel}/${name.lowerHyphenCamel}-list.vue', false, false, true, false, 1, 1 );
|
||||
|
||||
# 按菜单名称查询该菜单的 menu_id 作为按钮权限的 父菜单ID 与 功能点关联菜单ID
|
||||
SET @parent_id = NULL;
|
||||
SELECT t_menu.menu_id INTO @parent_id FROM t_menu WHERE t_menu.menu_name = '${basic.description}';
|
||||
|
||||
INSERT INTO t_menu ( menu_name, menu_type, parent_id, frame_flag, cache_flag, visible_flag, disabled_flag, api_perms, perms_type, context_menu_id, create_user_id )
|
||||
VALUES ( '查询', 3, @parent_id, false, true, true, false, '${name.lowerCamel}:query', 1, @parent_id, 1 );
|
||||
|
||||
INSERT INTO t_menu ( menu_name, menu_type, parent_id, frame_flag, cache_flag, visible_flag, disabled_flag, api_perms, perms_type, context_menu_id, create_user_id )
|
||||
VALUES ( '添加', 3, @parent_id, false, true, true, false, '${name.lowerCamel}:add', 1, @parent_id, 1 );
|
||||
|
||||
INSERT INTO t_menu ( menu_name, menu_type, parent_id, frame_flag, cache_flag, visible_flag, disabled_flag, api_perms, perms_type, context_menu_id, create_user_id )
|
||||
VALUES ( '更新', 3, @parent_id, false, true, true, false, '${name.lowerCamel}:update', 1, @parent_id, 1 );
|
||||
|
||||
INSERT INTO t_menu ( menu_name, menu_type, parent_id, frame_flag, cache_flag, visible_flag, disabled_flag, api_perms, perms_type, context_menu_id, create_user_id )
|
||||
VALUES ( '删除', 3, @parent_id, false, true, true, false, '${name.lowerCamel}:delete', 1, @parent_id, 1 );
|
@ -8,7 +8,7 @@
|
||||
<template>
|
||||
<a-$!{insertAndUpdate.pageType}
|
||||
:title="form.$!{primaryKeyFieldName} ? '编辑' : '添加'"
|
||||
width="$!{insertAndUpdate.width}"
|
||||
:width="$!{insertAndUpdate.width}"
|
||||
:open="visibleFlag"
|
||||
#if($!{insertAndUpdate.pageType} == 'drawer')
|
||||
@close="onClose"
|
||||
@ -19,124 +19,121 @@
|
||||
:destroyOnClose="true"
|
||||
>
|
||||
<a-form ref="formRef" :model="form" :rules="rules" :label-col="{ span: 5 }" >
|
||||
#if($insertAndUpdate.countPerLine == 1)
|
||||
<a-row>
|
||||
#foreach ($field in $formFields)
|
||||
#if($field.frontComponent == "Input")
|
||||
<a-form-item label="$!{field.label}" name="${field.fieldName}">
|
||||
<a-input style="width: 100%" v-model:value="form.${field.fieldName}" placeholder="$!{field.label}" />
|
||||
</a-form-item>
|
||||
#end
|
||||
#if($field.frontComponent == "InputNumber")
|
||||
<a-form-item label="$!{field.label}" name="${field.fieldName}">
|
||||
<a-input-number style="width: 100%" v-model:value="form.${field.fieldName}" placeholder="$!{field.label}" />
|
||||
</a-form-item>
|
||||
#end
|
||||
#if($field.frontComponent == "Textarea")
|
||||
<a-form-item label="$!{field.label}" name="${field.fieldName}">
|
||||
<a-textarea style="width: 100%" v-model:value="form.${field.fieldName}" placeholder="$!{field.label}" />
|
||||
</a-form-item>
|
||||
#end
|
||||
#if($field.frontComponent == "BooleanSelect")
|
||||
<a-form-item label="$!{field.label}" name="${field.fieldName}">
|
||||
<BooleanSelect v-model:value="form.${field.fieldName}" style="width: 100%" />
|
||||
</a-form-item>
|
||||
#end
|
||||
#if($field.frontComponent == "SmartEnumSelect")
|
||||
<a-form-item label="$codeGeneratorTool.removeEnumDesc($!{field.label})" name="${field.fieldName}">
|
||||
<SmartEnumSelect width="100%" v-model:value="form.${field.fieldName}" enumName="$!{field.upperUnderscoreEnum}" placeholder="$codeGeneratorTool.removeEnumDesc($!{field.label})"/>
|
||||
</a-form-item>
|
||||
#end
|
||||
#if($field.frontComponent == "DictSelect")
|
||||
<a-form-item label="$codeGeneratorTool.removeEnumDesc($!{field.label})" name="${field.fieldName}">
|
||||
<DictSelect width="100%" v-model:value="form.${field.fieldName}" keyCode="$!{field.dict}" placeholder="$!{field.label}"/>
|
||||
</a-form-item>
|
||||
#end
|
||||
#if($field.frontComponent == "Date")
|
||||
<a-form-item label="$!{field.label}" name="${field.fieldName}">
|
||||
<a-date-picker valueFormat="YYYY-MM-DD" v-model:value="form.$!{field.fieldName}" style="width: 100%" placeholder="$!{field.label}"/>
|
||||
</a-form-item>
|
||||
#end
|
||||
#if($field.frontComponent == "DateTime")
|
||||
<a-form-item label="$!{field.label}" name="${field.fieldName}">
|
||||
<a-date-picker show-time valueFormat="YYYY-MM-DD HH:mm:ss" v-model:value="form.$!{field.fieldName}" style="width: 100%" placeholder="$!{field.label}" />
|
||||
</a-form-item>
|
||||
#end
|
||||
#if($field.frontComponent == "Upload")
|
||||
<a-form-item label="$!{field.label}" name="${field.fieldName}">
|
||||
<FileUpload
|
||||
:defaultFileList="form.$!{field.fieldName}"
|
||||
:folder="FILE_FOLDER_TYPE_ENUM.COMMON.value"
|
||||
buttonText="上传 $!{field.label}"
|
||||
listType="text"
|
||||
@change="e => form.$!{field.fieldName} = e"
|
||||
/>
|
||||
</a-form-item>
|
||||
#end
|
||||
#end
|
||||
</a-row>
|
||||
#if($insertAndUpdate.countPerLine == 1)
|
||||
#foreach ($field in $formFields)
|
||||
#if($field.frontComponent == "Input")
|
||||
<a-form-item label="$!{field.label}" name="${field.fieldName}">
|
||||
<a-input style="width: 100%" v-model:value="form.${field.fieldName}" placeholder="$!{field.label}" />
|
||||
</a-form-item>
|
||||
#end
|
||||
#if($field.frontComponent == "InputNumber")
|
||||
<a-form-item label="$!{field.label}" name="${field.fieldName}">
|
||||
<a-input-number style="width: 100%" v-model:value="form.${field.fieldName}" placeholder="$!{field.label}" />
|
||||
</a-form-item>
|
||||
#end
|
||||
#if($field.frontComponent == "Textarea")
|
||||
<a-form-item label="$!{field.label}" name="${field.fieldName}">
|
||||
<a-textarea style="width: 100%" v-model:value="form.${field.fieldName}" placeholder="$!{field.label}" />
|
||||
</a-form-item>
|
||||
#end
|
||||
#if($field.frontComponent == "BooleanSelect")
|
||||
<a-form-item label="$!{field.label}" name="${field.fieldName}">
|
||||
<BooleanSelect v-model:value="form.${field.fieldName}" style="width: 100%" />
|
||||
</a-form-item>
|
||||
#end
|
||||
#if($field.frontComponent == "SmartEnumSelect")
|
||||
<a-form-item label="$codeGeneratorTool.removeEnumDesc($!{field.label})" name="${field.fieldName}">
|
||||
<SmartEnumSelect width="100%" v-model:value="form.${field.fieldName}" enumName="$!{field.upperUnderscoreEnum}" placeholder="$codeGeneratorTool.removeEnumDesc($!{field.label})"/>
|
||||
</a-form-item>
|
||||
#end
|
||||
#if($field.frontComponent == "DictSelect")
|
||||
<a-form-item label="$codeGeneratorTool.removeEnumDesc($!{field.label})" name="${field.fieldName}">
|
||||
<DictSelect width="100%" v-model:value="form.${field.fieldName}" keyCode="$!{field.dict}" placeholder="$!{field.label}"/>
|
||||
</a-form-item>
|
||||
#end
|
||||
#if($field.frontComponent == "Date")
|
||||
<a-form-item label="$!{field.label}" name="${field.fieldName}">
|
||||
<a-date-picker valueFormat="YYYY-MM-DD" v-model:value="form.$!{field.fieldName}" style="width: 100%" placeholder="$!{field.label}"/>
|
||||
</a-form-item>
|
||||
#end
|
||||
#if($field.frontComponent == "DateTime")
|
||||
<a-form-item label="$!{field.label}" name="${field.fieldName}">
|
||||
<a-date-picker show-time valueFormat="YYYY-MM-DD HH:mm:ss" v-model:value="form.$!{field.fieldName}" style="width: 100%" placeholder="$!{field.label}" />
|
||||
</a-form-item>
|
||||
#end
|
||||
#if($field.frontComponent == "FileUpload")
|
||||
<a-form-item label="$!{field.label}" name="${field.fieldName}">
|
||||
<FileUpload
|
||||
:defaultFileList="form.$!{field.fieldName}"
|
||||
:folder="FILE_FOLDER_TYPE_ENUM.COMMON.value"
|
||||
buttonText="上传 $!{field.label}"
|
||||
listType="text"
|
||||
@change="e => form.$!{field.fieldName} = e"
|
||||
/>
|
||||
</a-form-item>
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
#if($insertAndUpdate.countPerLine > 1)
|
||||
<a-row>
|
||||
#set($span=24 / $!insertAndUpdate.countPerLine )
|
||||
#foreach ($field in $formFields)
|
||||
<a-col :span="$!{span}">
|
||||
#if($field.frontComponent == "Input")
|
||||
<a-form-item label="$!{field.label}" name="${field.fieldName}">
|
||||
<a-input style="width: 100%" v-model:value="form.${field.fieldName}" placeholder="$!{field.label}" />
|
||||
</a-form-item>
|
||||
#end
|
||||
|
||||
#if($insertAndUpdate.countPerLine > 1)
|
||||
<a-row>
|
||||
#set($span=24 / $!insertAndUpdate.countPerLine )
|
||||
#foreach ($field in $formFields)
|
||||
<a-col :span="$!{span}">
|
||||
#if($field.frontComponent == "Input")
|
||||
<a-form-item label="$!{field.label}" name="${field.fieldName}">
|
||||
<a-input style="width: 100%" v-model:value="form.${field.fieldName}" placeholder="$!{field.label}" />
|
||||
</a-form-item>
|
||||
#end
|
||||
#if($field.frontComponent == "InputNumber")
|
||||
<a-form-item label="$!{field.label}" name="${field.fieldName}">
|
||||
<a-input-number style="width: 100%" v-model:value="form.${field.fieldName}" placeholder="$!{field.label}" />
|
||||
</a-form-item>
|
||||
#end
|
||||
#if($field.frontComponent == "Textarea")
|
||||
<a-form-item label="$!{field.label}" name="${field.fieldName}">
|
||||
<a-textarea style="width: 100%" v-model:value="form.${field.fieldName}" placeholder="$!{field.label}" />
|
||||
</a-form-item>
|
||||
#end
|
||||
#if($field.frontComponent == "BooleanSelect")
|
||||
<a-form-item label="$!{field.label}" name="${field.fieldName}">
|
||||
<BooleanSelect v-model:value="form.${field.fieldName}" style="width: 100%" />
|
||||
</a-form-item>
|
||||
#end
|
||||
#if($field.frontComponent == "SmartEnumSelect")
|
||||
<a-form-item label="$codeGeneratorTool.removeEnumDesc($!{field.label})" name="${field.fieldName}">
|
||||
<SmartEnumSelect width="100%" v-model:value="form.${field.fieldName}" enumName="$!{field.upperUnderscoreEnum}" placeholder="$codeGeneratorTool.removeEnumDesc($!{field.label})"/>
|
||||
</a-form-item>
|
||||
#end
|
||||
#if($field.frontComponent == "DictSelect")
|
||||
<a-form-item label="$codeGeneratorTool.removeEnumDesc($!{field.label})" name="${field.fieldName}">
|
||||
<DictSelect width="100%" v-model:value="form.${field.fieldName}" keyCode="$!{field.dict}" placeholder="$!{field.label}"/>
|
||||
</a-form-item>
|
||||
#end
|
||||
#if($field.frontComponent == "Date")
|
||||
<a-form-item label="$!{field.label}" name="${field.fieldName}">
|
||||
<a-date-picker valueFormat="YYYY-MM-DD" v-model:value="form.$!{field.fieldName}" style="width: 100%" placeholder="$!{field.label}"/>
|
||||
</a-form-item>
|
||||
#end
|
||||
#if($field.frontComponent == "DateTime")
|
||||
<a-form-item label="$!{field.label}" name="${field.fieldName}">
|
||||
<a-date-picker show-time valueFormat="YYYY-MM-DD HH:mm:ss" v-model:value="form.$!{field.fieldName}" style="width: 100%" placeholder="$!{field.label}" />
|
||||
</a-form-item>
|
||||
#end
|
||||
#if($field.frontComponent == "Upload")
|
||||
<a-form-item label="$!{field.label}" name="${field.fieldName}">
|
||||
<FileUpload
|
||||
:defaultFileList="form.$!{field.fieldName}"
|
||||
:folder="FILE_FOLDER_TYPE_ENUM.COMMON.value"
|
||||
buttonText="上传 $!{field.label}"
|
||||
listType="text"
|
||||
@change="e => form.$!{field.fieldName} = e"
|
||||
/>
|
||||
</a-form-item>
|
||||
#end
|
||||
</a-col>
|
||||
#end
|
||||
</a-row>
|
||||
#if($field.frontComponent == "InputNumber")
|
||||
<a-form-item label="$!{field.label}" name="${field.fieldName}">
|
||||
<a-input-number style="width: 100%" v-model:value="form.${field.fieldName}" placeholder="$!{field.label}" />
|
||||
</a-form-item>
|
||||
#end
|
||||
#if($field.frontComponent == "Textarea")
|
||||
<a-form-item label="$!{field.label}" name="${field.fieldName}">
|
||||
<a-textarea style="width: 100%" v-model:value="form.${field.fieldName}" placeholder="$!{field.label}" />
|
||||
</a-form-item>
|
||||
#end
|
||||
#if($field.frontComponent == "BooleanSelect")
|
||||
<a-form-item label="$!{field.label}" name="${field.fieldName}">
|
||||
<BooleanSelect v-model:value="form.${field.fieldName}" style="width: 100%" />
|
||||
</a-form-item>
|
||||
#end
|
||||
#if($field.frontComponent == "SmartEnumSelect")
|
||||
<a-form-item label="$codeGeneratorTool.removeEnumDesc($!{field.label})" name="${field.fieldName}">
|
||||
<SmartEnumSelect width="100%" v-model:value="form.${field.fieldName}" enumName="$!{field.upperUnderscoreEnum}" placeholder="$codeGeneratorTool.removeEnumDesc($!{field.label})"/>
|
||||
</a-form-item>
|
||||
#end
|
||||
#if($field.frontComponent == "DictSelect")
|
||||
<a-form-item label="$codeGeneratorTool.removeEnumDesc($!{field.label})" name="${field.fieldName}">
|
||||
<DictSelect width="100%" v-model:value="form.${field.fieldName}" keyCode="$!{field.dict}" placeholder="$!{field.label}"/>
|
||||
</a-form-item>
|
||||
#end
|
||||
#if($field.frontComponent == "Date")
|
||||
<a-form-item label="$!{field.label}" name="${field.fieldName}">
|
||||
<a-date-picker valueFormat="YYYY-MM-DD" v-model:value="form.$!{field.fieldName}" style="width: 100%" placeholder="$!{field.label}"/>
|
||||
</a-form-item>
|
||||
#end
|
||||
#if($field.frontComponent == "DateTime")
|
||||
<a-form-item label="$!{field.label}" name="${field.fieldName}">
|
||||
<a-date-picker show-time valueFormat="YYYY-MM-DD HH:mm:ss" v-model:value="form.$!{field.fieldName}" style="width: 100%" placeholder="$!{field.label}" />
|
||||
</a-form-item>
|
||||
#end
|
||||
#if($field.frontComponent == "FileUpload")
|
||||
<a-form-item label="$!{field.label}" name="${field.fieldName}">
|
||||
<FileUpload
|
||||
:defaultFileList="form.$!{field.fieldName}"
|
||||
:folder="FILE_FOLDER_TYPE_ENUM.COMMON.value"
|
||||
buttonText="上传 $!{field.label}"
|
||||
listType="text"
|
||||
@change="e => form.$!{field.fieldName} = e"
|
||||
/>
|
||||
</a-form-item>
|
||||
#end
|
||||
</a-col>
|
||||
#end
|
||||
</a-row>
|
||||
#end
|
||||
</a-form>
|
||||
|
||||
<template #footer>
|
||||
@ -154,9 +151,9 @@
|
||||
import { SmartLoading } from '/@/components/framework/smart-loading';
|
||||
import { $!{name.lowerCamel}Api } from '/@/api/business/$!{name.lowerHyphenCamel}/$!{name.lowerHyphenCamel}-api';
|
||||
import { smartSentry } from '/@/lib/smart-sentry';
|
||||
#foreach ($import in $frontImportList)
|
||||
$!{import}
|
||||
#end
|
||||
#foreach ($import in $frontImportList)
|
||||
$!{import}
|
||||
#end
|
||||
|
||||
// ------------------------ 事件 ------------------------
|
||||
|
||||
@ -171,6 +168,10 @@
|
||||
if (rowData && !_.isEmpty(rowData)) {
|
||||
Object.assign(form, rowData);
|
||||
}
|
||||
// 使用字典时把下面这注释修改成自己的字典字段 有多个字典字段就复制多份同理修改 不然打开表单时不显示字典初始值
|
||||
// if (form.status && form.status.length > 0) {
|
||||
// form.status = form.status.map((e) => e.valueCode);
|
||||
// }
|
||||
visibleFlag.value = true;
|
||||
nextTick(() => {
|
||||
formRef.value.clearValidate();
|
||||
@ -188,9 +189,8 @@
|
||||
const formRef = ref();
|
||||
|
||||
const formDefault = {
|
||||
$!{primaryKeyFieldName}: undefined,
|
||||
#foreach ($field in $formFields)
|
||||
$!{field.fieldName}: undefined, //$!{field.label}
|
||||
$!{field.fieldName}: undefined, //$!{field.label}
|
||||
#end
|
||||
};
|
||||
|
||||
@ -198,9 +198,9 @@
|
||||
|
||||
const rules = {
|
||||
#foreach ($field in $formFields)
|
||||
#if($field.requiredFlag)
|
||||
$!{field.fieldName}: [{ required: true, message: '$!{field.label} 必填' }],
|
||||
#end
|
||||
#if($field.requiredFlag)
|
||||
$!{field.fieldName}: [{ required: true, message: '$!{field.label} 必填' }],
|
||||
#end
|
||||
#end
|
||||
};
|
||||
|
||||
|
@ -72,7 +72,7 @@
|
||||
</a-button>
|
||||
#end
|
||||
#if($deleteInfo.isSupportDelete && ($deleteInfo.deleteEnum == "Batch"||$deleteInfo.deleteEnum == "SingleAndBatch"))
|
||||
<a-button @click="confirmBatchDelete" type="danger" size="small" :disabled="selectedRowKeyList.length == 0">
|
||||
<a-button @click="confirmBatchDelete" type="primary" danger size="small" :disabled="selectedRowKeyList.length == 0">
|
||||
<template #icon>
|
||||
<DeleteOutlined />
|
||||
</template>
|
||||
@ -88,18 +88,32 @@
|
||||
|
||||
<!---------- 表格 begin ----------->
|
||||
<a-table
|
||||
size="small"
|
||||
:dataSource="tableData"
|
||||
:columns="columns"
|
||||
rowKey="$!{primaryKeyFieldName}"
|
||||
bordered
|
||||
:loading="tableLoading"
|
||||
:pagination="false"
|
||||
size="small"
|
||||
:dataSource="tableData"
|
||||
:columns="columns"
|
||||
rowKey="$!{primaryKeyFieldName}"
|
||||
bordered
|
||||
:loading="tableLoading"
|
||||
:pagination="false"
|
||||
#if($deleteInfo.isSupportDelete && ($deleteInfo.deleteEnum == "Batch"||$deleteInfo.deleteEnum == "SingleAndBatch"))
|
||||
:row-selection="{ selectedRowKeys: selectedRowKeyList, onChange: onSelectChange }"
|
||||
:row-selection="{ selectedRowKeys: selectedRowKeyList, onChange: onSelectChange }"
|
||||
#end
|
||||
>
|
||||
<template #bodyCell="{ text, record, column }">
|
||||
|
||||
<!-- 有图片预览时 注释解开并把下面的'picture'修改成自己的图片字段名即可 -->
|
||||
<!-- <template v-if="column.dataIndex === 'picture'">
|
||||
<FilePreview :fileList="text" type="picture" />
|
||||
</template> -->
|
||||
|
||||
<!-- 使用字典时 注释解开并把下面的'dict'修改成自己的字典字段名即可 有多个字典字段就复制多份同理修改 不然不显示字典 -->
|
||||
<!-- 方便修改tag的颜色 orange green purple success processing error default warning -->
|
||||
<!-- <template v-if="column.dataIndex === 'dict'">
|
||||
<a-tag color="cyan">
|
||||
{{ text && text.length > 0 ? text.map((e) => e.valueName).join(',') : '暂无' }}
|
||||
</a-tag>
|
||||
</template> -->
|
||||
|
||||
<template v-if="column.dataIndex === 'action'">
|
||||
<div class="smart-table-operate">
|
||||
#if($insertAndUpdate.isSupportInsertAndUpdate)
|
||||
@ -116,17 +130,17 @@
|
||||
|
||||
<div class="smart-query-table-page">
|
||||
<a-pagination
|
||||
showSizeChanger
|
||||
showQuickJumper
|
||||
show-less-items
|
||||
:pageSizeOptions="PAGE_SIZE_OPTIONS"
|
||||
:defaultPageSize="queryForm.pageSize"
|
||||
v-model:current="queryForm.pageNum"
|
||||
v-model:pageSize="queryForm.pageSize"
|
||||
:total="total"
|
||||
@change="queryData"
|
||||
@showSizeChange="queryData"
|
||||
:show-total="(total) => `共${total}条`"
|
||||
showSizeChanger
|
||||
showQuickJumper
|
||||
show-less-items
|
||||
:pageSizeOptions="PAGE_SIZE_OPTIONS"
|
||||
:defaultPageSize="queryForm.pageSize"
|
||||
v-model:current="queryForm.pageNum"
|
||||
v-model:pageSize="queryForm.pageSize"
|
||||
:total="total"
|
||||
@change="queryData"
|
||||
@showSizeChange="queryData"
|
||||
:show-total="(total) => `共${total}条`"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@ -145,6 +159,8 @@
|
||||
#foreach ($import in $frontImportList)
|
||||
$!{import}
|
||||
#end
|
||||
//import FilePreview from '/@/components/support/file-preview/index.vue'; // 图片预览组件
|
||||
|
||||
// ---------------------------- 表格列 ----------------------------
|
||||
|
||||
const columns = ref([
|
||||
|
@ -61,7 +61,6 @@
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(nVal) => {
|
||||
console.log(nVal);
|
||||
editorHtml.value = nVal;
|
||||
},
|
||||
{
|
||||
|
@ -27,9 +27,13 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { computed, onMounted, ref, watch, defineExpose } from 'vue';
|
||||
import { dictApi } from '/src/api/support/dict-api';
|
||||
|
||||
defineExpose({
|
||||
queryDict,
|
||||
});
|
||||
|
||||
const props = defineProps({
|
||||
value: [Array, String],
|
||||
placeholder: {
|
||||
|
@ -64,24 +64,6 @@
|
||||
dictValueList.value = res.data;
|
||||
}
|
||||
|
||||
const values = computed(() => {
|
||||
if (!props.value) {
|
||||
return [];
|
||||
}
|
||||
if (!Array.isArray(props.value)) {
|
||||
console.error('valueList is not array!!!');
|
||||
return [];
|
||||
}
|
||||
let res = [];
|
||||
if (props.value && props.value.length > 0) {
|
||||
props.value.forEach((element) => {
|
||||
res.push(element.valueCode);
|
||||
});
|
||||
return res;
|
||||
}
|
||||
return res;
|
||||
});
|
||||
|
||||
onMounted(queryDict);
|
||||
|
||||
// -------------------------- 选中 相关、事件 --------------------------
|
||||
@ -96,21 +78,16 @@
|
||||
|
||||
const emit = defineEmits(['update:value', 'change']);
|
||||
function onChange(value) {
|
||||
let selected = [];
|
||||
if (!value) {
|
||||
emit('update:value', selected);
|
||||
emit('change', selected);
|
||||
return selected;
|
||||
emit('update:value', []);
|
||||
emit('change', []);
|
||||
}
|
||||
if (Array.isArray(props.value)) {
|
||||
let valueList = dictValueList.value.filter((e) => value.includes(e.valueCode));
|
||||
valueList = valueList.map((e) => e.valueCode);
|
||||
emit('update:value', valueList);
|
||||
emit('change', valueList);
|
||||
if (Array.isArray(value)) {
|
||||
emit('update:value', value);
|
||||
emit('change', value);
|
||||
} else {
|
||||
let findValue = dictValueList.value.find((e) => e.valueCode === value);
|
||||
emit('update:value', findValue.valueCode);
|
||||
emit('change', findValue.valueCode);
|
||||
emit('update:value', [value]);
|
||||
emit('change', [value]);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -40,7 +40,7 @@
|
||||
</a-row>
|
||||
</a-form>
|
||||
<a-table
|
||||
:row-selection="{ selectedRowKeys: selectedRowKeyList, onChange: onSelectChange }"
|
||||
:row-selection="{ selectedRowKeys: selectedRowKeyList, onChange: onSelectChange, getCheckboxProps: getCheckboxProps }"
|
||||
:loading="tableLoading"
|
||||
size="small"
|
||||
:columns="columns"
|
||||
@ -95,6 +95,7 @@
|
||||
|
||||
const visible = ref(false);
|
||||
async function showModal(selectEmployeeId) {
|
||||
originalRowKeyList.value = selectEmployeeId || [];
|
||||
selectedRowKeyList.value = selectEmployeeId || [];
|
||||
visible.value = true;
|
||||
onSearch();
|
||||
@ -144,8 +145,9 @@
|
||||
}
|
||||
|
||||
// ----------------------- 员工表格选择 ---------------------
|
||||
const originalRowKeyList = ref([]);
|
||||
let selectedRowKeyList = ref([]);
|
||||
const hasSelected = computed(() => selectedRowKeyList.value.length > 0);
|
||||
const hasSelected = computed(() => selectedRowKeyList.value.length !== originalRowKeyList.value.length);
|
||||
|
||||
function onSelectChange(selectedRowKeys) {
|
||||
selectedRowKeyList.value = selectedRowKeys;
|
||||
@ -156,10 +158,19 @@
|
||||
message.warning('请选择角色人员');
|
||||
return;
|
||||
}
|
||||
emits('selectData', selectedRowKeyList.value);
|
||||
// 过滤出新选择的人员id
|
||||
const newEmployeeIdList = selectedRowKeyList.value.filter((id) => !originalRowKeyList.value.includes(id));
|
||||
emits('selectData', newEmployeeIdList);
|
||||
closeModal();
|
||||
}
|
||||
|
||||
function getCheckboxProps(record) {
|
||||
return {
|
||||
// 角色员工列表的添加员工弹窗中 禁止添加选择已存在该角色的员工
|
||||
disabled: originalRowKeyList.value.includes(record.employeeId),
|
||||
};
|
||||
}
|
||||
|
||||
// ----------------------- 员工表格渲染 ---------------------
|
||||
const tableData = ref([]);
|
||||
//字段
|
||||
|
@ -30,4 +30,6 @@ export default {
|
||||
HOME_QUICK_ENTRY: `${KEY_PREFIX}home_quick_entry`,
|
||||
// 通知信息已读
|
||||
NOTICE_READ: `${KEY_PREFIX}notice_read`,
|
||||
// 待办
|
||||
TO_BE_DONE: `${KEY_PREFIX}to_be_done`,
|
||||
};
|
||||
|
@ -37,7 +37,6 @@
|
||||
import { computed, ref, onMounted } from 'vue';
|
||||
import { loginApi } from '/src/api/system/login-api';
|
||||
import { useUserStore } from '/@/store/modules/system/user';
|
||||
import { localClear } from '/@/utils/local-util';
|
||||
import { smartSentry } from '/@/lib/smart-sentry';
|
||||
import HeaderResetPassword from './header-reset-password-modal/index.vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
@ -53,7 +52,6 @@
|
||||
} catch (e) {
|
||||
smartSentry.captureError(e);
|
||||
} finally {
|
||||
localClear();
|
||||
useUserStore().logout();
|
||||
location.reload();
|
||||
}
|
||||
|
@ -0,0 +1,44 @@
|
||||
<template>
|
||||
<a-modal v-model:open="showFlag" :width="800" title="消息内容" :destroyOnClose="true" @ok="showFlag = false">
|
||||
<a-descriptions bordered :column="2" size="small">
|
||||
<a-descriptions-item :labelStyle="{ width: '80px' }" :span="1" label="类型"
|
||||
>{{ $smartEnumPlugin.getDescByValue('MESSAGE_TYPE_ENUM', messageDetail.messageType) }}
|
||||
</a-descriptions-item>
|
||||
<a-descriptions-item :labelStyle="{ width: '120px' }" :span="1" label="发送时间">{{ messageDetail.createTime }}</a-descriptions-item>
|
||||
<a-descriptions-item :labelStyle="{ width: '80px' }" :span="2" label="标题">{{ messageDetail.title }}</a-descriptions-item>
|
||||
<a-descriptions-item :labelStyle="{ width: '80px' }" :span="2" label="内容">
|
||||
<pre>{{ messageDetail.content }}</pre>
|
||||
</a-descriptions-item>
|
||||
</a-descriptions>
|
||||
</a-modal>
|
||||
</template>
|
||||
<script setup>
|
||||
import { reactive, ref } from 'vue';
|
||||
import { messageApi } from '/@/api/support/message-api.js';
|
||||
|
||||
const emit = defineEmits(['refresh']);
|
||||
|
||||
const messageDetail = reactive({
|
||||
messageType: '',
|
||||
title: '',
|
||||
content: '',
|
||||
createTime: '',
|
||||
});
|
||||
|
||||
const showFlag = ref(false);
|
||||
|
||||
function show(data) {
|
||||
Object.assign(messageDetail, data);
|
||||
showFlag.value = true;
|
||||
read(data);
|
||||
}
|
||||
|
||||
async function read(message) {
|
||||
if (!message.readFlag) {
|
||||
await messageApi.updateReadFlag(message.messageId);
|
||||
emit('refresh');
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({ show });
|
||||
</script>
|
@ -9,26 +9,33 @@
|
||||
-->
|
||||
|
||||
<template>
|
||||
<a-dropdown trigger="click" v-model:open="show">
|
||||
<a-button type="text" @click="queryMessage" style="padding: 4px 5px">
|
||||
<a-badge :count="unreadMessageCount">
|
||||
<div style="width: 26px; height: 26px">
|
||||
<BellOutlined :style="{ fontSize: '16px' }" />
|
||||
</div>
|
||||
</a-badge>
|
||||
</a-button>
|
||||
<div>
|
||||
<a-popover v-model:open="show" trigger="contextmenu" placement="bottomLeft" @openChange="() => (show = true)">
|
||||
<a-button type="text" @click="showMessage" style="padding: 4px 5px">
|
||||
<a-badge :count="unreadMessageCount + toBeDoneCount">
|
||||
<div style="width: 26px; height: 26px">
|
||||
<BellOutlined :style="{ fontSize: '16px' }" />
|
||||
</div>
|
||||
</a-badge>
|
||||
</a-button>
|
||||
|
||||
<template #overlay>
|
||||
<a-card class="message-container" :bodyStyle="{ padding: 0 }">
|
||||
<template #content>
|
||||
<!-- 为了能在点击查看消息详情弹窗的同时防止消息气泡卡片关闭 所以加了一个手动关闭按钮 -->
|
||||
<a-button type="text" @click="closeMessage" style="padding: 4px 5px"> 关闭 </a-button>
|
||||
<a-spin :spinning="loading">
|
||||
<a-tabs class="dropdown-tabs" centered :tabBarStyle="{ textAlign: 'center' }" style="width: 300px">
|
||||
<a-tab-pane tab="未读消息" key="message">
|
||||
<a-tab-pane key="message">
|
||||
<template #tab>
|
||||
未读消息
|
||||
<a-badge :count="unreadMessageCount" showZero :offset="[0, -20]" />
|
||||
</template>
|
||||
<a-list class="tab-pane" size="small">
|
||||
<a-list-item v-for="item in messageList" :key="item.messageId">
|
||||
<a-list-item-meta>
|
||||
<template #title>
|
||||
<div class="title">
|
||||
<a @click="gotoMessage">{{ item.title }}</a>
|
||||
<a-badge status="error" />
|
||||
<a @click="showMessageDetail(item)">{{ item.title }}</a>
|
||||
</div>
|
||||
</template>
|
||||
<template #description>
|
||||
@ -36,16 +43,34 @@
|
||||
</template>
|
||||
</a-list-item-meta>
|
||||
</a-list-item>
|
||||
<a-list-item v-if="unreadMessageCount > 3">
|
||||
<a-button type="text" @click="gotoMessage" style="padding: 4px 5px"> ... 查看更多 </a-button>
|
||||
</a-list-item>
|
||||
</a-list>
|
||||
</a-tab-pane>
|
||||
<a-tab-pane tab="待办工作" key="todo">
|
||||
<a-list class="tab-pane" />
|
||||
<a-tab-pane key="to_be_done">
|
||||
<template #tab>
|
||||
待办工作
|
||||
<a-badge :count="toBeDoneCount" showZero :offset="[0, -20]" />
|
||||
</template>
|
||||
<a-list class="tab-pane" size="small" :locale="{ emptyText: '暂无待办' }">
|
||||
<a-list-item v-for="(item, index) in toBeDoneList" :key="index">
|
||||
<a-list-item-meta>
|
||||
<template #title>
|
||||
<a-badge status="error" />
|
||||
<a-tag v-if="item.starFlag" color="red">重要</a-tag>
|
||||
<span>{{ item.title }}</span>
|
||||
</template>
|
||||
</a-list-item-meta>
|
||||
</a-list-item>
|
||||
</a-list>
|
||||
</a-tab-pane>
|
||||
</a-tabs>
|
||||
</a-spin>
|
||||
</a-card>
|
||||
</template>
|
||||
</a-dropdown>
|
||||
</template>
|
||||
</a-popover>
|
||||
<MessageDetailModal ref="messageDetailModalRef" @refresh="queryMessage" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@ -57,19 +82,27 @@
|
||||
import dayjs from 'dayjs';
|
||||
import { theme } from 'ant-design-vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import MessageDetailModal from './header-message-detail-modal.vue';
|
||||
import localKey from '/@/constants/local-storage-key-const';
|
||||
import { localRead } from '/@/utils/local-util';
|
||||
|
||||
const { useToken } = theme;
|
||||
const { token } = useToken();
|
||||
|
||||
defineExpose({ showMessage });
|
||||
|
||||
function showMessage() {
|
||||
show.value = true;
|
||||
}
|
||||
|
||||
const loading = ref(false);
|
||||
const show = ref(false);
|
||||
|
||||
// 点击按钮打开消息气泡卡片的同时刷新消息
|
||||
function showMessage() {
|
||||
show.value = true;
|
||||
queryMessage();
|
||||
loadToBeDoneList();
|
||||
}
|
||||
|
||||
function closeMessage() {
|
||||
show.value = false;
|
||||
}
|
||||
|
||||
// ------------------------- 查询消息 -------------------------
|
||||
|
||||
// 未读消息
|
||||
@ -90,6 +123,8 @@
|
||||
readFlag: false,
|
||||
});
|
||||
messageList.value = responseModel.data.list;
|
||||
// 若中途有新消息了 打开列表也能及时更新未读数量
|
||||
useUserStore().queryUnreadMessageCount();
|
||||
} catch (e) {
|
||||
smartSentry.captureError(e);
|
||||
} finally {
|
||||
@ -97,12 +132,41 @@
|
||||
}
|
||||
}
|
||||
|
||||
const messageDetailModalRef = ref();
|
||||
function showMessageDetail(data) {
|
||||
messageDetailModalRef.value.show(data);
|
||||
}
|
||||
|
||||
const router = useRouter();
|
||||
function gotoMessage() {
|
||||
show.value = false;
|
||||
router.push({ path: '/account', query: { menuId: 'message' } });
|
||||
}
|
||||
|
||||
// ------------------------- 待办工作 -------------------------
|
||||
|
||||
// 待办工作数
|
||||
const toBeDoneCount = computed(() => {
|
||||
return useUserStore().toBeDoneCount;
|
||||
});
|
||||
|
||||
// 待办工作列表
|
||||
const toBeDoneList = ref([]);
|
||||
|
||||
const loadToBeDoneList = async () => {
|
||||
try {
|
||||
loading.value = true;
|
||||
let localToBeDoneList = localRead(localKey.TO_BE_DONE);
|
||||
if (localToBeDoneList) {
|
||||
toBeDoneList.value = JSON.parse(localToBeDoneList).filter((e) => !e.doneFlag);
|
||||
}
|
||||
} catch (err) {
|
||||
smartSentry.captureError(err);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// ------------------------- 时间计算 -------------------------
|
||||
function timeago(dateStr) {
|
||||
let dateTimeStamp = dayjs(dateStr).toDate().getTime();
|
||||
@ -181,12 +245,13 @@
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.message-container {
|
||||
border: #eeeeee solid 1px;
|
||||
}
|
||||
|
||||
.dropdown-tabs {
|
||||
background-color: @base-bg-color;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.tab-pane {
|
||||
height: 250px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
</style>
|
||||
|
@ -18,7 +18,7 @@
|
||||
</a-form-item>
|
||||
<a-form-item :label="$t('setting.color')">
|
||||
<div class="color-container">
|
||||
<template v-for="(item, index) in themeColors">
|
||||
<template v-for="(item, index) in themeColors" :key="index">
|
||||
<div v-if="index === formState.colorIndex" class="color">
|
||||
<CheckSquareFilled :style="{ color: item.primaryColor, fontSize: '22px' }" />
|
||||
</div>
|
||||
@ -34,7 +34,7 @@
|
||||
>
|
||||
<path
|
||||
d="M128 160.01219c0-17.67619 14.336-32.01219 32.01219-32.01219h704c17.65181 0 31.98781 14.336 31.98781 32.01219v704c0 17.65181-14.336 31.98781-32.01219 31.98781H160.036571a31.98781 31.98781 0 0 1-32.01219-32.01219V160.036571z"
|
||||
></path>
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -57,12 +57,6 @@
|
||||
headerSetting.value.show();
|
||||
}
|
||||
|
||||
//消息通知
|
||||
const headerMessage = ref();
|
||||
function showMessage() {
|
||||
headerMessage.value.showMessage();
|
||||
}
|
||||
|
||||
//帮助文档
|
||||
function showHelpDoc() {
|
||||
useAppConfigStore().showHelpDoc();
|
||||
|
@ -9,7 +9,8 @@
|
||||
*/
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import axios from 'axios';
|
||||
import { localClear, localRead } from '/@/utils/local-util';
|
||||
import { localRead } from '/@/utils/local-util';
|
||||
import { useUserStore } from '/@/store/modules/system/user';
|
||||
import { decryptData, encryptData } from './encrypt';
|
||||
import { DATA_TYPE_ENUM } from '../constants/common-const';
|
||||
import _ from 'lodash';
|
||||
@ -25,7 +26,7 @@ const smartAxios = axios.create({
|
||||
|
||||
// 退出系统
|
||||
function logout() {
|
||||
localClear();
|
||||
useUserStore().logout();
|
||||
location.href = '/';
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ import { PAGE_PATH_404, PAGE_PATH_LOGIN } from '/@/constants/common-const';
|
||||
import { HOME_PAGE_NAME } from '/@/constants/system/home-const';
|
||||
import SmartLayout from '../layout/index.vue';
|
||||
import { useUserStore } from '/@/store/modules/system/user';
|
||||
import { localClear, localRead } from '/@/utils/local-util';
|
||||
import { localRead } from '/@/utils/local-util';
|
||||
import _ from 'lodash';
|
||||
import LocalStorageKeyConst from '/@/constants/local-storage-key-const.js';
|
||||
|
||||
@ -41,7 +41,7 @@ router.beforeEach(async (to, from, next) => {
|
||||
// 验证登录
|
||||
const token = localRead(LocalStorageKeyConst.USER_TOKEN);
|
||||
if (!token) {
|
||||
localClear();
|
||||
useUserStore().logout();
|
||||
next({ path: PAGE_PATH_LOGIN });
|
||||
return;
|
||||
}
|
||||
|
@ -12,10 +12,10 @@ import { defineStore } from 'pinia';
|
||||
import localKey from '/@/constants/local-storage-key-const';
|
||||
import { HOME_PAGE_NAME } from '/@/constants/system/home-const';
|
||||
import { MENU_TYPE_ENUM } from '/@/constants/system/menu-const';
|
||||
import { localClear, localRead, localSave } from '/@/utils/local-util';
|
||||
import LocalStorageKeyConst from '/@/constants/local-storage-key-const';
|
||||
import { messageApi } from '/@/api/support/message-api.js';
|
||||
import { smartSentry } from '/@/lib/smart-sentry.js';
|
||||
import { localRead, localSave, localRemove } from '/@/utils/local-util';
|
||||
|
||||
|
||||
export const useUserStore = defineStore({
|
||||
id: 'userStore',
|
||||
@ -61,13 +61,15 @@ export const useUserStore = defineStore({
|
||||
keepAliveIncludes: [],
|
||||
// 未读消息数量
|
||||
unreadMessageCount: 0,
|
||||
// 待办工作数
|
||||
toBeDoneCount: 0,
|
||||
}),
|
||||
getters: {
|
||||
getToken(state) {
|
||||
if (state.token) {
|
||||
return state.token;
|
||||
}
|
||||
return localRead(LocalStorageKeyConst.USER_TOKEN);
|
||||
return localRead(localKey.USER_TOKEN);
|
||||
},
|
||||
//是否初始化了 路由
|
||||
getMenuRouterInitFlag(state) {
|
||||
@ -115,7 +117,9 @@ export const useUserStore = defineStore({
|
||||
this.tagNav = [];
|
||||
this.userInfo = {};
|
||||
this.unreadMessageCount = 0;
|
||||
localClear();
|
||||
localRemove(localKey.USER_TOKEN);
|
||||
localRemove(localKey.USER_POINTS);
|
||||
localRemove(localKey.USER_TAG_NAV);
|
||||
},
|
||||
// 查询未读消息数量
|
||||
async queryUnreadMessageCount() {
|
||||
@ -126,6 +130,16 @@ export const useUserStore = defineStore({
|
||||
smartSentry.captureError(e);
|
||||
}
|
||||
},
|
||||
async queryToBeDoneList() {
|
||||
try {
|
||||
let localToBeDoneList = localRead(localKey.TO_BE_DONE);
|
||||
if (localToBeDoneList) {
|
||||
this.toBeDoneCount = JSON.parse(localToBeDoneList).filter((e) => !e.doneFlag).length;
|
||||
}
|
||||
} catch (err) {
|
||||
smartSentry.captureError(err);
|
||||
}
|
||||
},
|
||||
//设置登录信息
|
||||
setUserLoginInfo(data) {
|
||||
// 用户基本信息
|
||||
@ -157,6 +171,8 @@ export const useUserStore = defineStore({
|
||||
|
||||
// 获取用户未读消息
|
||||
this.queryUnreadMessageCount();
|
||||
// 获取待办工作数
|
||||
this.queryToBeDoneList();
|
||||
},
|
||||
setToken(token) {
|
||||
this.token = token;
|
||||
|
@ -19,3 +19,7 @@ export const localRead = (key) => {
|
||||
export const localClear = () => {
|
||||
localStorage.clear();
|
||||
};
|
||||
|
||||
export const localRemove = (key) => {
|
||||
localStorage.removeItem(key);
|
||||
};
|
||||
|
@ -20,7 +20,7 @@
|
||||
<SmartEnumSelect enum-name="GOODS_STATUS_ENUM" v-model:value="form.goodsStatus" />
|
||||
</a-form-item>
|
||||
<a-form-item label="产地" name="place">
|
||||
<DictSelect key-code="GODOS_PLACE" v-model:value="form.place" />
|
||||
<DictSelect width="100%" key-code="GODOS_PLACE" v-model:value="form.place" mode="tags" />
|
||||
</a-form-item>
|
||||
<a-form-item label="上架状态" name="shelvesFlag">
|
||||
<a-radio-group v-model:value="form.shelvesFlag">
|
||||
@ -80,7 +80,7 @@
|
||||
//商品状态
|
||||
goodsStatus: GOODS_STATUS_ENUM.APPOINTMENT.value,
|
||||
//产地
|
||||
place: undefined,
|
||||
place: [],
|
||||
//商品价格
|
||||
price: undefined,
|
||||
//上架状态
|
||||
@ -107,9 +107,8 @@
|
||||
Object.assign(form, rowData);
|
||||
}
|
||||
if (form.place && form.place.length > 0) {
|
||||
form.place = form.place[0].valueCode;
|
||||
form.place = form.place.map((e) => e.valueCode);
|
||||
}
|
||||
console.log(form);
|
||||
visible.value = true;
|
||||
nextTick(() => {
|
||||
formRef.value.clearValidate();
|
||||
@ -127,14 +126,10 @@
|
||||
.then(async () => {
|
||||
SmartLoading.show();
|
||||
try {
|
||||
let params = _.cloneDeep(form);
|
||||
if (params.place && Array.isArray(params.place) && params.place.length > 0) {
|
||||
params.place = params.place[0].valueCode;
|
||||
}
|
||||
if (form.goodsId) {
|
||||
await goodsApi.updateGoods(params);
|
||||
await goodsApi.updateGoods(form);
|
||||
} else {
|
||||
await goodsApi.addGoods(params);
|
||||
await goodsApi.addGoods(form);
|
||||
}
|
||||
message.success(`${form.goodsId ? '修改' : '添加'}成功`);
|
||||
onClose();
|
||||
|
@ -109,7 +109,7 @@
|
||||
>
|
||||
<template #bodyCell="{ text, record, column }">
|
||||
<template v-if="column.dataIndex === 'place'">
|
||||
<span>{{ text && text.length > 0 ? text[0].valueName : '' }}</span>
|
||||
<span>{{ text && text.length > 0 ? text.map((e) => e.valueName).join(',') : '' }}</span>
|
||||
</template>
|
||||
<template v-if="column.dataIndex === 'goodsStatus'">
|
||||
<span>{{ $smartEnumPlugin.getDescByValue('GOODS_STATUS_ENUM', text) }}</span>
|
||||
|
@ -2,6 +2,7 @@ import { convertUpperCamel } from '/@/utils/str-util';
|
||||
|
||||
// -------------------------------- java 类型 --------------------------------
|
||||
export const JavaTypeMap = new Map();
|
||||
JavaTypeMap.set('bit', 'Boolean');
|
||||
JavaTypeMap.set('int', 'Integer');
|
||||
JavaTypeMap.set('tinyint', 'Integer');
|
||||
JavaTypeMap.set('smallint', 'Integer');
|
||||
@ -37,6 +38,7 @@ export function getJavaType(dataType) {
|
||||
|
||||
// -------------------------------- js 类型 --------------------------------
|
||||
export const JsTypeMap = new Map();
|
||||
JsTypeMap.set('bit', 'Boolean');
|
||||
JsTypeMap.set('int', 'Number');
|
||||
JsTypeMap.set('tinyint', 'Number');
|
||||
JsTypeMap.set('smallint', 'Number');
|
||||
@ -56,11 +58,10 @@ JsTypeMap.set('date', 'Date');
|
||||
JsTypeMap.set('datetime', 'Date');
|
||||
|
||||
export const JsTypeList = [
|
||||
'Boolean', //
|
||||
'Number', //
|
||||
'String', //
|
||||
'Date', //
|
||||
'Boolean', //
|
||||
'String', //
|
||||
];
|
||||
|
||||
export function getJsType(dataType) {
|
||||
@ -70,8 +71,9 @@ export function getJsType(dataType) {
|
||||
// -------------------------------- 前端组件 --------------------------------
|
||||
|
||||
export const FrontComponentMap = new Map();
|
||||
FrontComponentMap.set('bit', 'BooleanSelect');
|
||||
FrontComponentMap.set('int', 'InputNumber');
|
||||
FrontComponentMap.set('tinyint', 'BooleanSelect');
|
||||
FrontComponentMap.set('tinyint', 'InputNumber');
|
||||
FrontComponentMap.set('smallint', 'InputNumber');
|
||||
FrontComponentMap.set('integer', 'InputNumber');
|
||||
FrontComponentMap.set('year', 'Date');
|
||||
@ -84,7 +86,7 @@ FrontComponentMap.set('varchar', 'Input');
|
||||
FrontComponentMap.set('tinytext', 'Input');
|
||||
FrontComponentMap.set('text', 'Textarea');
|
||||
FrontComponentMap.set('longtext', 'Textarea');
|
||||
FrontComponentMap.set('blob', 'Upload');
|
||||
FrontComponentMap.set('blob', 'FileUpload');
|
||||
FrontComponentMap.set('date', 'Date');
|
||||
FrontComponentMap.set('datetime', 'DateTime');
|
||||
|
||||
@ -131,6 +133,7 @@ export const JAVA_FILE_LIST = [
|
||||
'Dao.java', //
|
||||
'Mapper.xml', //
|
||||
...JAVA_DOMAIN_FILE_LIST,
|
||||
'Menu.sql', //
|
||||
];
|
||||
|
||||
// -------------------------------- 枚举enum --------------------------------
|
||||
|
@ -68,11 +68,12 @@
|
||||
if (deletedFlagColumn) {
|
||||
deleteFlagColumnName.value = deletedFlagColumn.columnName;
|
||||
}
|
||||
console.log(deletedFlagColumn);
|
||||
|
||||
//表单
|
||||
let deleteInfo = config.delete;
|
||||
let deleteInfo = config.deleteInfo;
|
||||
|
||||
formData.isSupportDelete = deleteInfo && deleteInfo.isSupportDelete ? deleteInfo.isSupportDelete : true;
|
||||
formData.isSupportDelete = deleteInfo ? deleteInfo.isSupportDelete : true;
|
||||
formData.isPhysicallyDeleted = deleteInfo && deleteInfo.isPhysicallyDeleted ? deleteInfo.isPhysicallyDeleted : !deletedFlagColumn;
|
||||
formData.deleteEnum = deleteInfo && deleteInfo.deleteEnum ? deleteInfo.deleteEnum : CODE_DELETE_ENUM.SINGLE_AND_BATCH.value;
|
||||
}
|
||||
|
@ -11,6 +11,10 @@
|
||||
<a-alert :closable="true" message="请务必将每一个字段的 “ 字段名词 ” 填写完整!!!" type="success" show-icon>
|
||||
<template #icon><smile-outlined /></template>
|
||||
</a-alert>
|
||||
<!-- 为了方便再配置时中途新增字典后 可以重新刷新字典下拉 (需要先随便选择一个字典后才能看到最新的字典) -->
|
||||
<div style="float: right; padding: 10px 0px">
|
||||
<a-button type="primary" @click="refreshDict">刷新字典</a-button>
|
||||
</div>
|
||||
<a-table
|
||||
:scroll="{ x: 1300 }"
|
||||
size="small"
|
||||
@ -64,7 +68,7 @@
|
||||
</template>
|
||||
|
||||
<template v-if="column.dataIndex === 'dict'">
|
||||
<DictKeySelect v-model:value="record.dict" />
|
||||
<DictKeySelect ref="dictRef" v-model:value="record.dict" />
|
||||
</template>
|
||||
|
||||
<template v-if="column.dataIndex === 'enumName'">
|
||||
@ -81,6 +85,11 @@
|
||||
import { convertUpperCamel, convertLowerCamel } from '/@/utils/str-util';
|
||||
import _ from 'lodash';
|
||||
|
||||
const dictRef = ref();
|
||||
function refreshDict() {
|
||||
dictRef.value.queryDict();
|
||||
}
|
||||
|
||||
//------------------------ 全局数据 ---------------------
|
||||
const tableInfo = inject('tableInfo');
|
||||
|
||||
|
@ -75,11 +75,9 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import _ from 'lodash';
|
||||
import Sortable from 'sortablejs';
|
||||
import { inject, nextTick, ref } from 'vue';
|
||||
import SmartEnumSelect from '/@/components/framework/smart-enum-select/index.vue';
|
||||
import { SmartLoading } from '/@/components/framework/smart-loading';
|
||||
import { CODE_QUERY_FIELD_QUERY_TYPE_ENUM } from '/@/constants/support/code-generator-const';
|
||||
import { convertLowerCamel } from '/@/utils/str-util';
|
||||
|
||||
@ -130,12 +128,13 @@
|
||||
|
||||
const tableColumns = ref([]);
|
||||
|
||||
let rowKeyCounter = 1;
|
||||
//初始化设置数据
|
||||
function setData(tableColumnInfos, config) {
|
||||
rowKeyCounter = 1;
|
||||
let data = config && config.queryFields ? config.queryFields : [];
|
||||
for (let index = 0; index < data.length; index++) {
|
||||
data[index].rowKey = 'rowKey' + (index + 1);
|
||||
data[index].rowKey = 'rowKey' + rowKeyCounter;
|
||||
rowKeyCounter++;
|
||||
}
|
||||
tableData.value = data;
|
||||
@ -147,7 +146,6 @@
|
||||
}
|
||||
|
||||
// ------------------- 增加、删除 -------------------
|
||||
let rowKeyCounter = 1;
|
||||
function addQuery() {
|
||||
tableData.value.push({
|
||||
rowKey: 'rowKey' + rowKeyCounter,
|
||||
@ -155,13 +153,19 @@
|
||||
fieldName: '',
|
||||
queryTypeEnum: '',
|
||||
columnNameList: null,
|
||||
width: '',
|
||||
width: '200px',
|
||||
});
|
||||
rowKeyCounter++;
|
||||
}
|
||||
|
||||
function onDelete(index) {
|
||||
_.pullAt(tableData.value, index);
|
||||
// 以这种方式删除 列表才会重新渲染
|
||||
const tempList = [...tableData.value];
|
||||
tempList.splice(index, 1);
|
||||
tableData.value = [];
|
||||
nextTick(() => {
|
||||
tableData.value = tempList;
|
||||
});
|
||||
}
|
||||
|
||||
//初始化拖拽
|
||||
@ -173,6 +177,10 @@
|
||||
ghostClass: 'smart-ghost-class', //设置拖拽停靠样式类名
|
||||
chosenClass: 'smart-ghost-class', //设置选中样式类名
|
||||
handle: '.handle',
|
||||
onEnd: ({ oldIndex, newIndex }) => {
|
||||
const oldRow = tableData.value.splice(oldIndex, 1)[0];
|
||||
tableData.value.splice(newIndex, 0, oldRow);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@ -211,36 +219,16 @@
|
||||
|
||||
// 获取表单数据
|
||||
function getFieldsForm() {
|
||||
let result = [];
|
||||
let trList = document.querySelectorAll('#smartCodeQueryFieldsTable tbody .column-row');
|
||||
if (trList && trList.length === 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
for (let tr of trList) {
|
||||
let rowKey = tr.getAttribute('data-row-key');
|
||||
if (!rowKey) {
|
||||
continue;
|
||||
}
|
||||
if (rowKey && rowKey.indexOf('rowKey') === -1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let index = parseInt(rowKey.substring(6));
|
||||
let tableItem = tableData.value[index - 1];
|
||||
let obj = {
|
||||
queryTypeEnum: tableItem.queryTypeEnum,
|
||||
label: tableItem.label,
|
||||
fieldName: tableItem.fieldName,
|
||||
columnNameList: tableItem.columnNameList,
|
||||
width: tableItem.width,
|
||||
let result = tableData.value.map((item) => {
|
||||
return {
|
||||
label: item.label,
|
||||
width: item.width,
|
||||
fieldName: item.fieldName,
|
||||
queryTypeEnum: item.queryTypeEnum,
|
||||
// 字符串转为数组
|
||||
columnNameList: item.columnNameList && typeof item.columnNameList === 'string' ? [item.columnNameList] : item.columnNameList,
|
||||
};
|
||||
// 字符串转为数组
|
||||
if (obj.columnNameList && typeof obj.columnNameList === 'string') {
|
||||
obj.columnNameList = [obj.columnNameList];
|
||||
}
|
||||
result.push(obj);
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
title="代码配置"
|
||||
style=""
|
||||
:open="visibleFlag"
|
||||
:width="1000"
|
||||
:width="1500"
|
||||
:footerStyle="{ textAlign: 'right' }"
|
||||
@close="onClose"
|
||||
:maskClosable="false"
|
||||
@ -175,7 +175,7 @@
|
||||
let insertAndUpdateValidated = await insertAndUpdateRef.value.validateForm();
|
||||
let deleteValidated = await deleteRef.value.validateForm();
|
||||
|
||||
if (!basicValidated || !insertAndUpdateValidated || !deleteValidated ) {
|
||||
if (!basicValidated || !insertAndUpdateValidated || !deleteValidated) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -201,7 +201,7 @@
|
||||
onClose();
|
||||
} catch (e) {
|
||||
smartSentry.captureError(e);
|
||||
}finally{
|
||||
} finally {
|
||||
SmartLoading.hide();
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
<a-drawer
|
||||
title="代码预览"
|
||||
:open="visibleFlag"
|
||||
:width="1200"
|
||||
:width="1500"
|
||||
:footerStyle="{ textAlign: 'right' }"
|
||||
:bodyStyle="{ padding: '8px 24px' }"
|
||||
@close="onClose"
|
||||
@ -37,9 +37,9 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, nextTick, ref, watch } from 'vue';
|
||||
import { computed, nextTick, ref } from 'vue';
|
||||
import { codeGeneratorApi } from '/@/api/support/code-generator-api';
|
||||
import { JAVA_FILE_LIST, LANGUAGE_LIST, JS_FILE_LIST,TS_FILE_LIST, JAVA_DOMAIN_FILE_LIST } from '../../code-generator-util';
|
||||
import { JAVA_FILE_LIST, LANGUAGE_LIST, JS_FILE_LIST, TS_FILE_LIST } from '../../code-generator-util';
|
||||
import { smartSentry } from '/@/lib/smart-sentry';
|
||||
import { lineNumbersBlock } from '/@/lib/highlight-line-number';
|
||||
import hljs from 'highlight.js';
|
||||
@ -74,11 +74,11 @@
|
||||
// ------------------ 标签页 ------------------
|
||||
const languageType = ref(LANGUAGE_LIST[0]);
|
||||
const tabList = computed(() => {
|
||||
if(languageType.value === LANGUAGE_LIST[0]){
|
||||
if (languageType.value === LANGUAGE_LIST[0]) {
|
||||
return JS_FILE_LIST;
|
||||
}else if(languageType.value === LANGUAGE_LIST[1]){
|
||||
} else if (languageType.value === LANGUAGE_LIST[1]) {
|
||||
return TS_FILE_LIST;
|
||||
}else{
|
||||
} else {
|
||||
return JAVA_FILE_LIST;
|
||||
}
|
||||
});
|
||||
@ -86,21 +86,21 @@
|
||||
const fileKey = ref(tabList.value[0]);
|
||||
|
||||
function getLanguage() {
|
||||
if(languageType.value === LANGUAGE_LIST[0]){
|
||||
if (languageType.value === LANGUAGE_LIST[0]) {
|
||||
return 'javascript';
|
||||
}else if(languageType.value === LANGUAGE_LIST[1]){
|
||||
} else if (languageType.value === LANGUAGE_LIST[1]) {
|
||||
return 'typescript';
|
||||
}else{
|
||||
} else {
|
||||
return 'java';
|
||||
}
|
||||
}
|
||||
|
||||
function onChangeLanguageType(e){
|
||||
if(e.target.value === LANGUAGE_LIST[0]){
|
||||
function onChangeLanguageType(e) {
|
||||
if (e.target.value === LANGUAGE_LIST[0]) {
|
||||
fileKey.value = JS_FILE_LIST[0];
|
||||
}else if(e.target.value === LANGUAGE_LIST[1]){
|
||||
} else if (e.target.value === LANGUAGE_LIST[1]) {
|
||||
fileKey.value = TS_FILE_LIST[0];
|
||||
}else{
|
||||
} else {
|
||||
fileKey.value = JAVA_FILE_LIST[0];
|
||||
}
|
||||
onChangeTab(fileKey.value);
|
||||
|
@ -270,7 +270,7 @@
|
||||
// 下载文件
|
||||
async function download(file) {
|
||||
try {
|
||||
await fileApi.downLoadFile(file.fileName, file.fileKey);
|
||||
await fileApi.downLoadFile(file.fileKey);
|
||||
} catch (e) {
|
||||
smartSentry.captureError(e);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="类型" class="smart-query-form-item">
|
||||
<smart-enum-select v-model:value="queryForm.messageType" placeholder="消息类型" enum-name="MESSAGE_TYPE_ENUM" />
|
||||
<smart-enum-select style="width: 150px" v-model:value="queryForm.messageType" placeholder="消息类型" enum-name="MESSAGE_TYPE_ENUM" />
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="消息时间" class="smart-query-form-item">
|
||||
@ -43,7 +43,7 @@
|
||||
</a-form>
|
||||
|
||||
<a-table size="small" :dataSource="tableData" :columns="columns" rowKey="messageId" :pagination="false" bordered>
|
||||
<template #bodyCell="{ text, record, index, column }">
|
||||
<template #bodyCell="{ text, record, column }">
|
||||
<template v-if="column.dataIndex === 'messageType'">
|
||||
<span>{{ $smartEnumPlugin.getDescByValue('MESSAGE_TYPE_ENUM', text) }}</span>
|
||||
</template>
|
||||
|
@ -49,7 +49,6 @@
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
.card-container {
|
||||
background-color: #fff;
|
||||
height: 100%;
|
||||
|
||||
.title {
|
||||
|
@ -1,158 +0,0 @@
|
||||
<!--
|
||||
* 已办/代办
|
||||
*
|
||||
* @Author: 1024创新实验室-主任:卓大
|
||||
* @Date: 2022-09-12 22:34:00
|
||||
* @Wechat: zhuda1024
|
||||
* @Email: lab1024@163.com
|
||||
* @Copyright 1024创新实验室 ( https://1024lab.net ),Since 2012
|
||||
*
|
||||
-->
|
||||
<template>
|
||||
<default-home-card icon="Star" title="已办待办">
|
||||
<div style="height: 280px">
|
||||
<div class="center column">
|
||||
<a-space direction="vertical" style="width: 100%">
|
||||
<div v-for="(item, index) in toDoList" :key="index" :class="['to-do', { done: item.doneFlag }]">
|
||||
<a-checkbox v-model:checked="item.doneFlag">
|
||||
<span class="task">{{ item.title }}</span>
|
||||
</a-checkbox>
|
||||
<div class="star-icon" @click="itemStar(item)">
|
||||
<StarFilled v-if="item.starFlag" style="color: #ff8c00" />
|
||||
<StarOutlined v-else style="color: #c0c0c0" />
|
||||
</div>
|
||||
</div>
|
||||
<div v-for="(item, index) in doneList" :key="index" :class="['to-do', { done: item.doneFlag }]">
|
||||
<a-checkbox v-model:checked="item.doneFlag">
|
||||
<span class="task">{{ item.title }}</span>
|
||||
</a-checkbox>
|
||||
<div class="star-icon" @click="itemStar(item)">
|
||||
<StarFilled v-if="item.starFlag" style="color: #ff8c00" />
|
||||
<StarOutlined v-else style="color: #c0c0c0" />
|
||||
</div>
|
||||
</div>
|
||||
</a-space>
|
||||
</div>
|
||||
</div>
|
||||
</default-home-card>
|
||||
</template>
|
||||
<script setup>
|
||||
import DefaultHomeCard from '/@/views/system/home/components/default-home-card.vue';
|
||||
import { computed, ref } from 'vue';
|
||||
import dayjs from 'dayjs';
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
let taskList = ref([
|
||||
{
|
||||
title: '周五下班前需要提交周报',
|
||||
doneFlag: true,
|
||||
starFlag: true,
|
||||
starTime: 0,
|
||||
},
|
||||
{
|
||||
title: '为SmartAdmin前端小组分配任务',
|
||||
doneFlag: false,
|
||||
starFlag: false,
|
||||
starTime: 0,
|
||||
},
|
||||
{
|
||||
title: '跟进团建内容事宜',
|
||||
doneFlag: false,
|
||||
starFlag: true,
|
||||
starTime: 0,
|
||||
},
|
||||
{
|
||||
title: '跟进客户定制一个软件平台',
|
||||
doneFlag: false,
|
||||
starFlag: false,
|
||||
starTime: 0,
|
||||
},
|
||||
{
|
||||
title: '下个版本的需求确认',
|
||||
doneFlag: false,
|
||||
starFlag: false,
|
||||
starTime: 0,
|
||||
},
|
||||
{
|
||||
title: '线上版本发布',
|
||||
doneFlag: true,
|
||||
starFlag: true,
|
||||
starTime: dayjs().unix(),
|
||||
},
|
||||
{
|
||||
title: '周一财务报销',
|
||||
doneFlag: true,
|
||||
starFlag: false,
|
||||
starTime: 0,
|
||||
},
|
||||
]);
|
||||
|
||||
let toDoList = computed(() => {
|
||||
return taskList.value.filter((e) => !e.doneFlag).sort((a, b) => b.starTime - a.starTime);
|
||||
});
|
||||
|
||||
let doneList = computed(() => {
|
||||
return taskList.value.filter((e) => e.doneFlag);
|
||||
});
|
||||
|
||||
function itemStar(item) {
|
||||
item.starFlag = !item.starFlag;
|
||||
if (item.starFlag) {
|
||||
item.starTime = dayjs().unix();
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------任务新建-----------------------
|
||||
let taskTitle = ref('');
|
||||
function addTask() {
|
||||
if (!taskTitle.value) {
|
||||
message.warn('请输入任务标题');
|
||||
return;
|
||||
}
|
||||
let data = {
|
||||
title: taskTitle.value,
|
||||
doneFlag: false,
|
||||
starFlag: false,
|
||||
starTime: 0,
|
||||
};
|
||||
taskList.value.unshift(data);
|
||||
taskTitle.value = '';
|
||||
}
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
.center {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
height: 100%;
|
||||
|
||||
&.column {
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
padding: 0 10px;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
}
|
||||
|
||||
.to-do {
|
||||
width: 100%;
|
||||
border: 1px solid #d3d3d3;
|
||||
border-radius: 4px;
|
||||
padding: 4px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.star-icon {
|
||||
margin-left: auto;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
&.done {
|
||||
text-decoration: line-through;
|
||||
color: #8c8c8c;
|
||||
|
||||
.task {
|
||||
color: #8c8c8c;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
@ -0,0 +1,177 @@
|
||||
<!--
|
||||
* 待办工作
|
||||
*
|
||||
* @Author: 1024创新实验室-主任:卓大
|
||||
* @Date: 2022-09-12 22:34:00
|
||||
* @Copyright 1024创新实验室 ( https://1024lab.net ),Since 2012
|
||||
*
|
||||
-->
|
||||
<template>
|
||||
<default-home-card extra="添加" icon="StarTwoTone" title="待办工作" @extraClick="showAddToBeDone">
|
||||
<div style="height: 280px">
|
||||
<div class="center column">
|
||||
<a-space direction="vertical" style="width: 100%">
|
||||
<a-empty v-if="$lodash.isEmpty(toBeDoneList)" description="暂无待办工作" />
|
||||
<div v-for="(item, index) in toDoList" :key="index" :class="['to-do', { done: item.doneFlag }]">
|
||||
<a-checkbox v-model:checked="item.doneFlag" @change="handleCheckbox">
|
||||
<span class="task">{{ item.title }}</span>
|
||||
</a-checkbox>
|
||||
<div v-if="!item.doneFlag" class="star-icon" @click="itemStar(item)">
|
||||
<StarFilled v-if="item.starFlag" style="color: #ff8c00" />
|
||||
<StarOutlined v-else style="color: #c0c0c0" />
|
||||
</div>
|
||||
<close-circle-outlined class="delete-icon" @click="toDelete(item)" />
|
||||
</div>
|
||||
<div v-for="(item, index) in doneList" :key="index" :class="['to-do', { done: item.doneFlag }]">
|
||||
<a-checkbox v-model:checked="item.doneFlag" @change="handleCheckbox">
|
||||
<span class="task">{{ item.title }}</span>
|
||||
</a-checkbox>
|
||||
<div v-if="!item.doneFlag" class="star-icon" @click="itemStar(item)">
|
||||
<StarFilled v-if="item.starFlag" style="color: #ff8c00" />
|
||||
<StarOutlined v-else style="color: #c0c0c0" />
|
||||
</div>
|
||||
<close-circle-outlined class="delete-icon" @click="toDelete(item)" />
|
||||
</div>
|
||||
</a-space>
|
||||
</div>
|
||||
</div>
|
||||
</default-home-card>
|
||||
<ToBeDoneModal ref="toBeDoneModalRef" @addToBeDone="addToBeDone" />
|
||||
</template>
|
||||
<script setup>
|
||||
import DefaultHomeCard from '/@/views/system/home/components/default-home-card.vue';
|
||||
import ToBeDoneModal from './to-be-done-modal.vue';
|
||||
import localKey from '/@/constants/local-storage-key-const';
|
||||
import { localRead, localSave } from '/@/utils/local-util';
|
||||
import { useUserStore } from '/@/store/modules/system/user.js';
|
||||
import { computed, ref, onMounted } from 'vue';
|
||||
import { Modal } from 'ant-design-vue';
|
||||
|
||||
let toBeDoneList = ref([]);
|
||||
|
||||
onMounted(() => {
|
||||
initTaskList();
|
||||
});
|
||||
|
||||
function initTaskList() {
|
||||
let localTaskList = localRead(localKey.TO_BE_DONE);
|
||||
if (localTaskList) {
|
||||
toBeDoneList.value = JSON.parse(localTaskList);
|
||||
}
|
||||
}
|
||||
|
||||
let toDoList = computed(() => {
|
||||
return toBeDoneList.value.filter((e) => !e.doneFlag);
|
||||
});
|
||||
|
||||
let doneList = computed(() => {
|
||||
return toBeDoneList.value.filter((e) => e.doneFlag);
|
||||
});
|
||||
|
||||
function handleCheckbox(e) {
|
||||
localSave(localKey.TO_BE_DONE, JSON.stringify(toBeDoneList.value));
|
||||
useUserStore().toBeDoneCount = toDoList.value.length;
|
||||
}
|
||||
|
||||
function itemStar(data) {
|
||||
data.starFlag = !data.starFlag;
|
||||
// 将取消 star 的删除掉
|
||||
const index = toBeDoneList.value.findIndex((item) => item.title === data.title);
|
||||
toBeDoneList.value.splice(index, 1);
|
||||
if (data.starFlag) {
|
||||
// 最新添加标记star的移动到第一位
|
||||
toBeDoneList.value.unshift(data);
|
||||
} else {
|
||||
// 取消标记star的移动到最后一个标记 star 的后面添加
|
||||
const lastStarIndex = toBeDoneList.value.findLastIndex((item) => item.starFlag);
|
||||
toBeDoneList.value.splice(lastStarIndex + 1, 0, data);
|
||||
}
|
||||
localSave(localKey.TO_BE_DONE, JSON.stringify(toBeDoneList.value));
|
||||
}
|
||||
|
||||
//-------------------------任务新建-----------------------
|
||||
|
||||
let toBeDoneModalRef = ref();
|
||||
|
||||
function showAddToBeDone() {
|
||||
toBeDoneModalRef.value.showModal();
|
||||
}
|
||||
|
||||
// 添加待办工作
|
||||
function addToBeDone(data) {
|
||||
toBeDoneList.value.push(data);
|
||||
localSave(localKey.TO_BE_DONE, JSON.stringify(toBeDoneList.value));
|
||||
useUserStore().toBeDoneCount = toDoList.value.length;
|
||||
}
|
||||
|
||||
function toDelete(data) {
|
||||
if (!data.doneFlag) {
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确定要删除吗?',
|
||||
okText: '删除',
|
||||
okType: 'danger',
|
||||
onOk() {
|
||||
deleteToBeDone(data);
|
||||
},
|
||||
cancelText: '取消',
|
||||
onCancel() {},
|
||||
});
|
||||
} else {
|
||||
deleteToBeDone(data);
|
||||
}
|
||||
}
|
||||
|
||||
// 删除待办工作
|
||||
function deleteToBeDone(data) {
|
||||
const index = toBeDoneList.value.findIndex((item) => item.title === data.title);
|
||||
toBeDoneList.value.splice(index, 1);
|
||||
localSave(localKey.TO_BE_DONE, JSON.stringify(toBeDoneList.value));
|
||||
useUserStore().toBeDoneCount = toDoList.value.length;
|
||||
}
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
.center {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
height: 100%;
|
||||
overflow-y: auto;
|
||||
|
||||
&.column {
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
padding: 0 10px;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
}
|
||||
|
||||
.to-do {
|
||||
width: 100%;
|
||||
border: 1px solid #d3d3d3;
|
||||
border-radius: 4px;
|
||||
padding: 4px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
.star-icon {
|
||||
margin-left: auto;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
&.done {
|
||||
text-decoration: line-through;
|
||||
color: #8c8c8c;
|
||||
|
||||
.task {
|
||||
color: #8c8c8c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.delete-icon {
|
||||
color: #f08080;
|
||||
padding-left: 10px;
|
||||
top: -5px;
|
||||
right: -5px;
|
||||
float: right;
|
||||
}
|
||||
</style>
|
@ -0,0 +1,65 @@
|
||||
<template>
|
||||
<div>
|
||||
<a-modal v-model:open="visible" title="新建待办" @close="onClose">
|
||||
<a-form ref="formRef" :model="form" :rules="rules">
|
||||
<a-form-item label="标题" name="title">
|
||||
<a-input v-model:value="form.title" placeholder="请输入标题" />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
<template #footer>
|
||||
<a-button @click="onClose">取消</a-button>
|
||||
<a-button type="primary" @click="onSubmit">确定</a-button>
|
||||
</template>
|
||||
</a-modal>
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import { reactive, ref } from 'vue';
|
||||
import { message } from 'ant-design-vue';
|
||||
import _ from 'lodash';
|
||||
|
||||
defineExpose({
|
||||
showModal,
|
||||
});
|
||||
|
||||
const emit = defineEmits(['addToBeDone']);
|
||||
|
||||
// 组件ref
|
||||
const formRef = ref();
|
||||
|
||||
const formDefault = {
|
||||
title: undefined,
|
||||
doneFlag: false,
|
||||
starFlag: false,
|
||||
starTime: 0,
|
||||
};
|
||||
let form = reactive({ ...formDefault });
|
||||
const rules = {
|
||||
title: [{ required: true, message: '标题不能为空' }],
|
||||
};
|
||||
|
||||
const visible = ref(false);
|
||||
|
||||
function showModal() {
|
||||
visible.value = true;
|
||||
}
|
||||
|
||||
function onClose() {
|
||||
Object.assign(form, formDefault);
|
||||
visible.value = false;
|
||||
}
|
||||
|
||||
function onSubmit() {
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
emit('addToBeDone', _.cloneDeep(form));
|
||||
onClose();
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log('error', error);
|
||||
message.error('参数验证错误,请仔细填写表单数据!');
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<style lang="less" scoped></style>
|
@ -70,7 +70,7 @@
|
||||
import HomeNotice from './home-notice.vue';
|
||||
import HomeQuickEntry from './components/quick-entry/home-quick-entry.vue';
|
||||
import OfficialAccountCard from './components/official-account-card.vue';
|
||||
import ToBeDoneCard from './components/to-be-done-card.vue';
|
||||
import ToBeDoneCard from './components/to-be-done-card/home-to-be-done.vue';
|
||||
import ChangelogCard from './components/changelog-card.vue';
|
||||
import Gauge from './components/echarts/gauge.vue';
|
||||
import Category from './components/echarts/category.vue';
|
||||
|
@ -61,7 +61,7 @@
|
||||
<a-switch v-model:checked="form.visibleFlag" checked-children="显示" un-checked-children="不显示" />
|
||||
</a-form-item>
|
||||
<a-form-item label="禁用状态" name="frameFlag">
|
||||
<a-switch v-model:checked="form.disabledFlag" checked-children="启用" un-checked-children="禁用" />
|
||||
<a-switch v-model:checked="form.disabledFlag" :checkedValue="false" :unCheckedValue="true" checked-children="启用" un-checked-children="禁用" />
|
||||
</a-form-item>
|
||||
</template>
|
||||
<!-- 目录 菜单 end -->
|
||||
@ -74,7 +74,7 @@
|
||||
<MenuTreeSelect ref="contextMenuTreeSelect" v-model:value="form.contextMenuId" />
|
||||
</a-form-item>
|
||||
<a-form-item label="功能点状态" name="frameFlag">
|
||||
<a-switch v-model:checked="form.disabledFlag" checked-children="启用" un-checked-children="禁用" />
|
||||
<a-switch v-model:checked="form.disabledFlag" :checkedValue="false" :unCheckedValue="true" checked-children="启用" un-checked-children="禁用" />
|
||||
</a-form-item>
|
||||
<a-form-item label="权限类型" name="permsType">
|
||||
<a-radio-group v-model:value="form.permsType">
|
||||
|
@ -168,7 +168,7 @@
|
||||
|
||||
async function addRoleEmployee() {
|
||||
let res = await roleApi.getRoleAllEmployee(selectRoleId.value);
|
||||
let selectedIdList = res.data.map((e) => e.roleId) || [];
|
||||
let selectedIdList = res.data.map((e) => e.employeeId) || [];
|
||||
selectEmployeeModal.value.showModal(selectedIdList);
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ export const fileApi = {
|
||||
/**
|
||||
* 下载文件流(根据fileKey) @author 胡克
|
||||
*/
|
||||
downLoadFile: (fileName, fileKey) => {
|
||||
return getDownload(fileName, '/support/file/downLoad', { fileKey });
|
||||
downLoadFile: (fileKey) => {
|
||||
return getDownload('/support/file/downLoad', { fileKey });
|
||||
},
|
||||
};
|
||||
|
@ -270,7 +270,7 @@ function view(file) {
|
||||
// 下载文件
|
||||
async function download(file) {
|
||||
try {
|
||||
await fileApi.downLoadFile(file.fileName, file.fileKey);
|
||||
await fileApi.downLoadFile(file.fileKey);
|
||||
} catch (e) {
|
||||
smartSentry.captureError(e);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user